| 1 |
//===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
/// |
| 9 |
/// \file |
| 10 |
/// Implements serialization for Statements and Expressions. |
| 11 |
/// |
| 12 |
//===----------------------------------------------------------------------===// |
| 13 |
|
| 14 |
#include "clang/AST/ASTConcept.h" |
| 15 |
#include "clang/AST/ASTContext.h" |
| 16 |
#include "clang/AST/DeclCXX.h" |
| 17 |
#include "clang/AST/DeclObjC.h" |
| 18 |
#include "clang/AST/DeclTemplate.h" |
| 19 |
#include "clang/AST/ExprOpenMP.h" |
| 20 |
#include "clang/AST/StmtVisitor.h" |
| 21 |
#include "clang/Serialization/ASTReader.h" |
| 22 |
#include "clang/Serialization/ASTRecordWriter.h" |
| 23 |
#include "llvm/Bitstream/BitstreamWriter.h" |
| 24 |
using namespace clang; |
| 25 |
|
| 26 |
//===----------------------------------------------------------------------===// |
| 27 |
// Statement/expression serialization |
| 28 |
//===----------------------------------------------------------------------===// |
| 29 |
|
| 30 |
namespace clang { |
| 31 |
|
| 32 |
class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> { |
| 33 |
ASTWriter &Writer; |
| 34 |
ASTRecordWriter Record; |
| 35 |
|
| 36 |
serialization::StmtCode Code; |
| 37 |
unsigned AbbrevToUse; |
| 38 |
|
| 39 |
/// A helper that can help us to write a packed bit across function |
| 40 |
/// calls. For example, we may write separate bits in separate functions: |
| 41 |
/// |
| 42 |
/// void VisitA(A* a) { |
| 43 |
/// Record.push_back(a->isSomething()); |
| 44 |
/// } |
| 45 |
/// |
| 46 |
/// void Visitb(B *b) { |
| 47 |
/// VisitA(b); |
| 48 |
/// Record.push_back(b->isAnother()); |
| 49 |
/// } |
| 50 |
/// |
| 51 |
/// In such cases, it'll be better if we can pack these 2 bits. We achieve |
| 52 |
/// this by writing a zero value in `VisitA` and recorded that first and add |
| 53 |
/// the new bit to the recorded value. |
| 54 |
class PakedBitsWriter { |
| 55 |
public: |
| 56 |
PakedBitsWriter(ASTRecordWriter &Record) : RecordRef(Record) {} |
| 57 |
~PakedBitsWriter() { assert(!CurrentIndex); } |
| 58 |
|
| 59 |
void addBit(bool Value) { |
| 60 |
assert(CurrentIndex && "Writing Bits without recording first!"); |
| 61 |
PackingBits.addBit(Value); |
| 62 |
} |
| 63 |
void addBits(uint32_t Value, uint32_t BitsWidth) { |
| 64 |
assert(CurrentIndex && "Writing Bits without recording first!"); |
| 65 |
PackingBits.addBits(Value, BitsWidth); |
| 66 |
} |
| 67 |
|
| 68 |
void writeBits() { |
| 69 |
if (!CurrentIndex) |
| 70 |
return; |
| 71 |
|
| 72 |
RecordRef[*CurrentIndex] = (uint32_t)PackingBits; |
| 73 |
CurrentIndex = std::nullopt; |
| 74 |
PackingBits.reset(0); |
| 75 |
} |
| 76 |
|
| 77 |
void updateBits() { |
| 78 |
writeBits(); |
| 79 |
|
| 80 |
CurrentIndex = RecordRef.size(); |
| 81 |
RecordRef.push_back(0); |
| 82 |
} |
| 83 |
|
| 84 |
private: |
| 85 |
BitsPacker PackingBits; |
| 86 |
ASTRecordWriter &RecordRef; |
| 87 |
std::optional<unsigned> CurrentIndex; |
| 88 |
}; |
| 89 |
|
| 90 |
PakedBitsWriter CurrentPackingBits; |
| 91 |
|
| 92 |
public: |
| 93 |
ASTStmtWriter(ASTContext &Context, ASTWriter &Writer, |
| 94 |
ASTWriter::RecordData &Record) |
| 95 |
: Writer(Writer), Record(Context, Writer, Record), |
| 96 |
Code(serialization::STMT_NULL_PTR), AbbrevToUse(0), |
| 97 |
CurrentPackingBits(this->Record) {} |
| 98 |
|
| 99 |
ASTStmtWriter(const ASTStmtWriter&) = delete; |
| 100 |
ASTStmtWriter &operator=(const ASTStmtWriter &) = delete; |
| 101 |
|
| 102 |
uint64_t Emit() { |
| 103 |
CurrentPackingBits.writeBits(); |
| 104 |
assert(Code != serialization::STMT_NULL_PTR && |
| 105 |
"unhandled sub-statement writing AST file"); |
| 106 |
return Record.EmitStmt(Code, AbbrevToUse); |
| 107 |
} |
| 108 |
|
| 109 |
void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &ArgInfo, |
| 110 |
const TemplateArgumentLoc *Args); |
| 111 |
|
| 112 |
void VisitStmt(Stmt *S); |
| 113 |
#define STMT(Type, Base) \ |
| 114 |
void Visit##Type(Type *); |
| 115 |
#include "clang/AST/StmtNodes.inc" |
| 116 |
}; |
| 117 |
} |
| 118 |
|
| 119 |
void ASTStmtWriter::AddTemplateKWAndArgsInfo( |
| 120 |
const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc *Args) { |
| 121 |
Record.AddSourceLocation(ArgInfo.TemplateKWLoc); |
| 122 |
Record.AddSourceLocation(ArgInfo.LAngleLoc); |
| 123 |
Record.AddSourceLocation(ArgInfo.RAngleLoc); |
| 124 |
for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; ++i) |
| 125 |
Record.AddTemplateArgumentLoc(Args[i]); |
| 126 |
} |
| 127 |
|
| 128 |
void ASTStmtWriter::VisitStmt(Stmt *S) { |
| 129 |
} |
| 130 |
|
| 131 |
void ASTStmtWriter::VisitNullStmt(NullStmt *S) { |
| 132 |
VisitStmt(S); |
| 133 |
Record.AddSourceLocation(S->getSemiLoc()); |
| 134 |
Record.push_back(S->NullStmtBits.HasLeadingEmptyMacro); |
| 135 |
Code = serialization::STMT_NULL; |
| 136 |
} |
| 137 |
|
| 138 |
void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) { |
| 139 |
VisitStmt(S); |
| 140 |
|
| 141 |
Record.push_back(S->size()); |
| 142 |
Record.push_back(S->hasStoredFPFeatures()); |
| 143 |
|
| 144 |
for (auto *CS : S->body()) |
| 145 |
Record.AddStmt(CS); |
| 146 |
if (S->hasStoredFPFeatures()) |
| 147 |
Record.push_back(S->getStoredFPFeatures().getAsOpaqueInt()); |
| 148 |
Record.AddSourceLocation(S->getLBracLoc()); |
| 149 |
Record.AddSourceLocation(S->getRBracLoc()); |
| 150 |
|
| 151 |
if (!S->hasStoredFPFeatures()) |
| 152 |
AbbrevToUse = Writer.getCompoundStmtAbbrev(); |
| 153 |
|
| 154 |
Code = serialization::STMT_COMPOUND; |
| 155 |
} |
| 156 |
|
| 157 |
void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) { |
| 158 |
VisitStmt(S); |
| 159 |
Record.push_back(Writer.getSwitchCaseID(S)); |
| 160 |
Record.AddSourceLocation(S->getKeywordLoc()); |
| 161 |
Record.AddSourceLocation(S->getColonLoc()); |
| 162 |
} |
| 163 |
|
| 164 |
void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) { |
| 165 |
VisitSwitchCase(S); |
| 166 |
Record.push_back(S->caseStmtIsGNURange()); |
| 167 |
Record.AddStmt(S->getLHS()); |
| 168 |
Record.AddStmt(S->getSubStmt()); |
| 169 |
if (S->caseStmtIsGNURange()) { |
| 170 |
Record.AddStmt(S->getRHS()); |
| 171 |
Record.AddSourceLocation(S->getEllipsisLoc()); |
| 172 |
} |
| 173 |
Code = serialization::STMT_CASE; |
| 174 |
} |
| 175 |
|
| 176 |
void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) { |
| 177 |
VisitSwitchCase(S); |
| 178 |
Record.AddStmt(S->getSubStmt()); |
| 179 |
Code = serialization::STMT_DEFAULT; |
| 180 |
} |
| 181 |
|
| 182 |
void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) { |
| 183 |
VisitStmt(S); |
| 184 |
Record.push_back(S->isSideEntry()); |
| 185 |
Record.AddDeclRef(S->getDecl()); |
| 186 |
Record.AddStmt(S->getSubStmt()); |
| 187 |
Record.AddSourceLocation(S->getIdentLoc()); |
| 188 |
Code = serialization::STMT_LABEL; |
| 189 |
} |
| 190 |
|
| 191 |
void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) { |
| 192 |
VisitStmt(S); |
| 193 |
Record.push_back(S->getAttrs().size()); |
| 194 |
Record.AddAttributes(S->getAttrs()); |
| 195 |
Record.AddStmt(S->getSubStmt()); |
| 196 |
Record.AddSourceLocation(S->getAttrLoc()); |
| 197 |
Code = serialization::STMT_ATTRIBUTED; |
| 198 |
} |
| 199 |
|
| 200 |
void ASTStmtWriter::VisitIfStmt(IfStmt *S) { |
| 201 |
VisitStmt(S); |
| 202 |
|
| 203 |
bool HasElse = S->getElse() != nullptr; |
| 204 |
bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
| 205 |
bool HasInit = S->getInit() != nullptr; |
| 206 |
|
| 207 |
CurrentPackingBits.updateBits(); |
| 208 |
|
| 209 |
CurrentPackingBits.addBit(HasElse); |
| 210 |
CurrentPackingBits.addBit(HasVar); |
| 211 |
CurrentPackingBits.addBit(HasInit); |
| 212 |
Record.push_back(static_cast<uint64_t>(S->getStatementKind())); |
| 213 |
Record.AddStmt(S->getCond()); |
| 214 |
Record.AddStmt(S->getThen()); |
| 215 |
if (HasElse) |
| 216 |
Record.AddStmt(S->getElse()); |
| 217 |
if (HasVar) |
| 218 |
Record.AddStmt(S->getConditionVariableDeclStmt()); |
| 219 |
if (HasInit) |
| 220 |
Record.AddStmt(S->getInit()); |
| 221 |
|
| 222 |
Record.AddSourceLocation(S->getIfLoc()); |
| 223 |
Record.AddSourceLocation(S->getLParenLoc()); |
| 224 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 225 |
if (HasElse) |
| 226 |
Record.AddSourceLocation(S->getElseLoc()); |
| 227 |
|
| 228 |
Code = serialization::STMT_IF; |
| 229 |
} |
| 230 |
|
| 231 |
void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) { |
| 232 |
VisitStmt(S); |
| 233 |
|
| 234 |
bool HasInit = S->getInit() != nullptr; |
| 235 |
bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
| 236 |
Record.push_back(HasInit); |
| 237 |
Record.push_back(HasVar); |
| 238 |
Record.push_back(S->isAllEnumCasesCovered()); |
| 239 |
|
| 240 |
Record.AddStmt(S->getCond()); |
| 241 |
Record.AddStmt(S->getBody()); |
| 242 |
if (HasInit) |
| 243 |
Record.AddStmt(S->getInit()); |
| 244 |
if (HasVar) |
| 245 |
Record.AddStmt(S->getConditionVariableDeclStmt()); |
| 246 |
|
| 247 |
Record.AddSourceLocation(S->getSwitchLoc()); |
| 248 |
Record.AddSourceLocation(S->getLParenLoc()); |
| 249 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 250 |
|
| 251 |
for (SwitchCase *SC = S->getSwitchCaseList(); SC; |
| 252 |
SC = SC->getNextSwitchCase()) |
| 253 |
Record.push_back(Writer.RecordSwitchCaseID(SC)); |
| 254 |
Code = serialization::STMT_SWITCH; |
| 255 |
} |
| 256 |
|
| 257 |
void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) { |
| 258 |
VisitStmt(S); |
| 259 |
|
| 260 |
bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
| 261 |
Record.push_back(HasVar); |
| 262 |
|
| 263 |
Record.AddStmt(S->getCond()); |
| 264 |
Record.AddStmt(S->getBody()); |
| 265 |
if (HasVar) |
| 266 |
Record.AddStmt(S->getConditionVariableDeclStmt()); |
| 267 |
|
| 268 |
Record.AddSourceLocation(S->getWhileLoc()); |
| 269 |
Record.AddSourceLocation(S->getLParenLoc()); |
| 270 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 271 |
Code = serialization::STMT_WHILE; |
| 272 |
} |
| 273 |
|
| 274 |
void ASTStmtWriter::VisitDoStmt(DoStmt *S) { |
| 275 |
VisitStmt(S); |
| 276 |
Record.AddStmt(S->getCond()); |
| 277 |
Record.AddStmt(S->getBody()); |
| 278 |
Record.AddSourceLocation(S->getDoLoc()); |
| 279 |
Record.AddSourceLocation(S->getWhileLoc()); |
| 280 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 281 |
Code = serialization::STMT_DO; |
| 282 |
} |
| 283 |
|
| 284 |
void ASTStmtWriter::VisitForStmt(ForStmt *S) { |
| 285 |
VisitStmt(S); |
| 286 |
Record.AddStmt(S->getInit()); |
| 287 |
Record.AddStmt(S->getCond()); |
| 288 |
Record.AddStmt(S->getConditionVariableDeclStmt()); |
| 289 |
Record.AddStmt(S->getInc()); |
| 290 |
Record.AddStmt(S->getBody()); |
| 291 |
Record.AddSourceLocation(S->getForLoc()); |
| 292 |
Record.AddSourceLocation(S->getLParenLoc()); |
| 293 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 294 |
Code = serialization::STMT_FOR; |
| 295 |
} |
| 296 |
|
| 297 |
void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) { |
| 298 |
VisitStmt(S); |
| 299 |
Record.AddDeclRef(S->getLabel()); |
| 300 |
Record.AddSourceLocation(S->getGotoLoc()); |
| 301 |
Record.AddSourceLocation(S->getLabelLoc()); |
| 302 |
Code = serialization::STMT_GOTO; |
| 303 |
} |
| 304 |
|
| 305 |
void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
| 306 |
VisitStmt(S); |
| 307 |
Record.AddSourceLocation(S->getGotoLoc()); |
| 308 |
Record.AddSourceLocation(S->getStarLoc()); |
| 309 |
Record.AddStmt(S->getTarget()); |
| 310 |
Code = serialization::STMT_INDIRECT_GOTO; |
| 311 |
} |
| 312 |
|
| 313 |
void ASTStmtWriter::VisitLoopControlStmt(LoopControlStmt *S) { |
| 314 |
VisitStmt(S); |
| 315 |
Record.AddSourceLocation(S->getKwLoc()); |
| 316 |
Record.push_back(S->hasLabelTarget()); |
| 317 |
if (S->hasLabelTarget()) { |
| 318 |
Record.AddDeclRef(S->getLabelDecl()); |
| 319 |
Record.AddSourceLocation(S->getLabelLoc()); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) { |
| 324 |
VisitLoopControlStmt(S); |
| 325 |
Code = serialization::STMT_CONTINUE; |
| 326 |
} |
| 327 |
|
| 328 |
void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) { |
| 329 |
VisitLoopControlStmt(S); |
| 330 |
Code = serialization::STMT_BREAK; |
| 331 |
} |
| 332 |
|
| 333 |
void ASTStmtWriter::VisitDeferStmt(DeferStmt *S) { |
| 334 |
VisitStmt(S); |
| 335 |
Record.AddSourceLocation(S->getDeferLoc()); |
| 336 |
Record.AddStmt(S->getBody()); |
| 337 |
Code = serialization::STMT_DEFER; |
| 338 |
} |
| 339 |
|
| 340 |
void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) { |
| 341 |
VisitStmt(S); |
| 342 |
|
| 343 |
bool HasNRVOCandidate = S->getNRVOCandidate() != nullptr; |
| 344 |
Record.push_back(HasNRVOCandidate); |
| 345 |
|
| 346 |
Record.AddStmt(S->getRetValue()); |
| 347 |
if (HasNRVOCandidate) |
| 348 |
Record.AddDeclRef(S->getNRVOCandidate()); |
| 349 |
|
| 350 |
Record.AddSourceLocation(S->getReturnLoc()); |
| 351 |
Code = serialization::STMT_RETURN; |
| 352 |
} |
| 353 |
|
| 354 |
void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) { |
| 355 |
VisitStmt(S); |
| 356 |
Record.AddSourceLocation(S->getBeginLoc()); |
| 357 |
Record.AddSourceLocation(S->getEndLoc()); |
| 358 |
DeclGroupRef DG = S->getDeclGroup(); |
| 359 |
for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D) |
| 360 |
Record.AddDeclRef(*D); |
| 361 |
Code = serialization::STMT_DECL; |
| 362 |
} |
| 363 |
|
| 364 |
void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) { |
| 365 |
VisitStmt(S); |
| 366 |
Record.push_back(S->getNumOutputs()); |
| 367 |
Record.push_back(S->getNumInputs()); |
| 368 |
Record.push_back(S->getNumClobbers()); |
| 369 |
Record.AddSourceLocation(S->getAsmLoc()); |
| 370 |
Record.push_back(S->isVolatile()); |
| 371 |
Record.push_back(S->isSimple()); |
| 372 |
} |
| 373 |
|
| 374 |
void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) { |
| 375 |
VisitAsmStmt(S); |
| 376 |
Record.push_back(S->getNumLabels()); |
| 377 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 378 |
Record.AddStmt(S->getAsmStringExpr()); |
| 379 |
|
| 380 |
// Outputs |
| 381 |
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
| 382 |
Record.AddIdentifierRef(S->getOutputIdentifier(I)); |
| 383 |
Record.AddStmt(S->getOutputConstraintExpr(I)); |
| 384 |
Record.AddStmt(S->getOutputExpr(I)); |
| 385 |
} |
| 386 |
|
| 387 |
// Inputs |
| 388 |
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
| 389 |
Record.AddIdentifierRef(S->getInputIdentifier(I)); |
| 390 |
Record.AddStmt(S->getInputConstraintExpr(I)); |
| 391 |
Record.AddStmt(S->getInputExpr(I)); |
| 392 |
} |
| 393 |
|
| 394 |
// Clobbers |
| 395 |
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) |
| 396 |
Record.AddStmt(S->getClobberExpr(I)); |
| 397 |
|
| 398 |
// Labels |
| 399 |
for (unsigned I = 0, N = S->getNumLabels(); I != N; ++I) { |
| 400 |
Record.AddIdentifierRef(S->getLabelIdentifier(I)); |
| 401 |
Record.AddStmt(S->getLabelExpr(I)); |
| 402 |
} |
| 403 |
|
| 404 |
Code = serialization::STMT_GCCASM; |
| 405 |
} |
| 406 |
|
| 407 |
void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) { |
| 408 |
VisitAsmStmt(S); |
| 409 |
Record.AddSourceLocation(S->getLBraceLoc()); |
| 410 |
Record.AddSourceLocation(S->getEndLoc()); |
| 411 |
Record.push_back(S->getNumAsmToks()); |
| 412 |
Record.AddString(S->getAsmString()); |
| 413 |
|
| 414 |
// Tokens |
| 415 |
for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) { |
| 416 |
// FIXME: Move this to ASTRecordWriter? |
| 417 |
Writer.AddToken(S->getAsmToks()[I], Record.getRecordData()); |
| 418 |
} |
| 419 |
|
| 420 |
// Clobbers |
| 421 |
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) { |
| 422 |
Record.AddString(S->getClobber(I)); |
| 423 |
} |
| 424 |
|
| 425 |
// Outputs |
| 426 |
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
| 427 |
Record.AddStmt(S->getOutputExpr(I)); |
| 428 |
Record.AddString(S->getOutputConstraint(I)); |
| 429 |
} |
| 430 |
|
| 431 |
// Inputs |
| 432 |
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
| 433 |
Record.AddStmt(S->getInputExpr(I)); |
| 434 |
Record.AddString(S->getInputConstraint(I)); |
| 435 |
} |
| 436 |
|
| 437 |
Code = serialization::STMT_MSASM; |
| 438 |
} |
| 439 |
|
| 440 |
void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) { |
| 441 |
VisitStmt(CoroStmt); |
| 442 |
Record.push_back(CoroStmt->getParamMoves().size()); |
| 443 |
for (Stmt *S : CoroStmt->children()) |
| 444 |
Record.AddStmt(S); |
| 445 |
Code = serialization::STMT_COROUTINE_BODY; |
| 446 |
} |
| 447 |
|
| 448 |
void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) { |
| 449 |
VisitStmt(S); |
| 450 |
Record.AddSourceLocation(S->getKeywordLoc()); |
| 451 |
Record.AddStmt(S->getOperand()); |
| 452 |
Record.AddStmt(S->getPromiseCall()); |
| 453 |
Record.push_back(S->isImplicit()); |
| 454 |
Code = serialization::STMT_CORETURN; |
| 455 |
} |
| 456 |
|
| 457 |
void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) { |
| 458 |
VisitExpr(E); |
| 459 |
Record.AddSourceLocation(E->getKeywordLoc()); |
| 460 |
for (Stmt *S : E->children()) |
| 461 |
Record.AddStmt(S); |
| 462 |
Record.AddStmt(E->getOpaqueValue()); |
| 463 |
} |
| 464 |
|
| 465 |
void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) { |
| 466 |
VisitCoroutineSuspendExpr(E); |
| 467 |
Record.push_back(E->isImplicit()); |
| 468 |
Code = serialization::EXPR_COAWAIT; |
| 469 |
} |
| 470 |
|
| 471 |
void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) { |
| 472 |
VisitCoroutineSuspendExpr(E); |
| 473 |
Code = serialization::EXPR_COYIELD; |
| 474 |
} |
| 475 |
|
| 476 |
void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) { |
| 477 |
VisitExpr(E); |
| 478 |
Record.AddSourceLocation(E->getKeywordLoc()); |
| 479 |
for (Stmt *S : E->children()) |
| 480 |
Record.AddStmt(S); |
| 481 |
Code = serialization::EXPR_DEPENDENT_COAWAIT; |
| 482 |
} |
| 483 |
|
| 484 |
static void |
| 485 |
addConstraintSatisfaction(ASTRecordWriter &Record, |
| 486 |
const ASTConstraintSatisfaction &Satisfaction) { |
| 487 |
Record.push_back(Satisfaction.IsSatisfied); |
| 488 |
Record.push_back(Satisfaction.ContainsErrors); |
| 489 |
if (!Satisfaction.IsSatisfied) { |
| 490 |
Record.push_back(Satisfaction.NumRecords); |
| 491 |
for (const auto &DetailRecord : Satisfaction) { |
| 492 |
if (auto *Diag = dyn_cast<const ConstraintSubstitutionDiagnostic *>( |
| 493 |
DetailRecord)) { |
| 494 |
Record.push_back(/*Kind=*/0); |
| 495 |
Record.AddSourceLocation(Diag->first); |
| 496 |
Record.AddString(Diag->second); |
| 497 |
continue; |
| 498 |
} |
| 499 |
if (auto *E = dyn_cast<const Expr *>(DetailRecord)) { |
| 500 |
Record.push_back(/*Kind=*/1); |
| 501 |
Record.AddStmt(const_cast<Expr *>(E)); |
| 502 |
} else { |
| 503 |
Record.push_back(/*Kind=*/2); |
| 504 |
auto *CR = cast<const ConceptReference *>(DetailRecord); |
| 505 |
Record.AddConceptReference(CR); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
static void |
| 512 |
addSubstitutionDiagnostic( |
| 513 |
ASTRecordWriter &Record, |
| 514 |
const concepts::Requirement::SubstitutionDiagnostic *D) { |
| 515 |
Record.AddString(D->SubstitutedEntity); |
| 516 |
Record.AddSourceLocation(D->DiagLoc); |
| 517 |
Record.AddString(D->DiagMessage); |
| 518 |
} |
| 519 |
|
| 520 |
void ASTStmtWriter::VisitConceptSpecializationExpr( |
| 521 |
ConceptSpecializationExpr *E) { |
| 522 |
VisitExpr(E); |
| 523 |
Record.AddDeclRef(E->getSpecializationDecl()); |
| 524 |
const ConceptReference *CR = E->getConceptReference(); |
| 525 |
Record.push_back(CR != nullptr); |
| 526 |
if (CR) |
| 527 |
Record.AddConceptReference(CR); |
| 528 |
if (!E->isValueDependent()) |
| 529 |
addConstraintSatisfaction(Record, E->getSatisfaction()); |
| 530 |
|
| 531 |
Code = serialization::EXPR_CONCEPT_SPECIALIZATION; |
| 532 |
} |
| 533 |
|
| 534 |
void ASTStmtWriter::VisitRequiresExpr(RequiresExpr *E) { |
| 535 |
VisitExpr(E); |
| 536 |
Record.push_back(E->getLocalParameters().size()); |
| 537 |
Record.push_back(E->getRequirements().size()); |
| 538 |
Record.AddSourceLocation(E->RequiresExprBits.RequiresKWLoc); |
| 539 |
Record.push_back(E->RequiresExprBits.IsSatisfied); |
| 540 |
Record.AddDeclRef(E->getBody()); |
| 541 |
for (ParmVarDecl *P : E->getLocalParameters()) |
| 542 |
Record.AddDeclRef(P); |
| 543 |
for (concepts::Requirement *R : E->getRequirements()) { |
| 544 |
if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(R)) { |
| 545 |
Record.push_back(concepts::Requirement::RK_Type); |
| 546 |
Record.push_back(TypeReq->Status); |
| 547 |
if (TypeReq->Status == concepts::TypeRequirement::SS_SubstitutionFailure) |
| 548 |
addSubstitutionDiagnostic(Record, TypeReq->getSubstitutionDiagnostic()); |
| 549 |
else |
| 550 |
Record.AddTypeSourceInfo(TypeReq->getType()); |
| 551 |
} else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R)) { |
| 552 |
Record.push_back(ExprReq->getKind()); |
| 553 |
Record.push_back(ExprReq->Status); |
| 554 |
if (ExprReq->isExprSubstitutionFailure()) { |
| 555 |
addSubstitutionDiagnostic( |
| 556 |
Record, cast<concepts::Requirement::SubstitutionDiagnostic *>( |
| 557 |
ExprReq->Value)); |
| 558 |
} else |
| 559 |
Record.AddStmt(cast<Expr *>(ExprReq->Value)); |
| 560 |
if (ExprReq->getKind() == concepts::Requirement::RK_Compound) { |
| 561 |
Record.AddSourceLocation(ExprReq->NoexceptLoc); |
| 562 |
const auto &RetReq = ExprReq->getReturnTypeRequirement(); |
| 563 |
if (RetReq.isSubstitutionFailure()) { |
| 564 |
Record.push_back(2); |
| 565 |
addSubstitutionDiagnostic(Record, RetReq.getSubstitutionDiagnostic()); |
| 566 |
} else if (RetReq.isTypeConstraint()) { |
| 567 |
Record.push_back(1); |
| 568 |
Record.AddTemplateParameterList( |
| 569 |
RetReq.getTypeConstraintTemplateParameterList()); |
| 570 |
if (ExprReq->Status >= |
| 571 |
concepts::ExprRequirement::SS_ConstraintsNotSatisfied) |
| 572 |
Record.AddStmt( |
| 573 |
ExprReq->getReturnTypeRequirementSubstitutedConstraintExpr()); |
| 574 |
} else { |
| 575 |
assert(RetReq.isEmpty()); |
| 576 |
Record.push_back(0); |
| 577 |
} |
| 578 |
} |
| 579 |
} else { |
| 580 |
auto *NestedReq = cast<concepts::NestedRequirement>(R); |
| 581 |
Record.push_back(concepts::Requirement::RK_Nested); |
| 582 |
Record.push_back(NestedReq->hasInvalidConstraint()); |
| 583 |
if (NestedReq->hasInvalidConstraint()) { |
| 584 |
Record.AddString(NestedReq->getInvalidConstraintEntity()); |
| 585 |
addConstraintSatisfaction(Record, *NestedReq->Satisfaction); |
| 586 |
} else { |
| 587 |
Record.AddStmt(NestedReq->getConstraintExpr()); |
| 588 |
if (!NestedReq->isDependent()) |
| 589 |
addConstraintSatisfaction(Record, *NestedReq->Satisfaction); |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 594 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 595 |
Record.AddSourceLocation(E->getEndLoc()); |
| 596 |
|
| 597 |
Code = serialization::EXPR_REQUIRES; |
| 598 |
} |
| 599 |
|
| 600 |
|
| 601 |
void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) { |
| 602 |
VisitStmt(S); |
| 603 |
// NumCaptures |
| 604 |
Record.push_back(std::distance(S->capture_begin(), S->capture_end())); |
| 605 |
|
| 606 |
// CapturedDecl and captured region kind |
| 607 |
Record.AddDeclRef(S->getCapturedDecl()); |
| 608 |
Record.push_back(S->getCapturedRegionKind()); |
| 609 |
|
| 610 |
Record.AddDeclRef(S->getCapturedRecordDecl()); |
| 611 |
|
| 612 |
// Capture inits |
| 613 |
for (auto *I : S->capture_inits()) |
| 614 |
Record.AddStmt(I); |
| 615 |
|
| 616 |
// Body |
| 617 |
Record.AddStmt(S->getCapturedStmt()); |
| 618 |
|
| 619 |
// Captures |
| 620 |
for (const auto &I : S->captures()) { |
| 621 |
if (I.capturesThis() || I.capturesVariableArrayType()) |
| 622 |
Record.AddDeclRef(nullptr); |
| 623 |
else |
| 624 |
Record.AddDeclRef(I.getCapturedVar()); |
| 625 |
Record.push_back(I.getCaptureKind()); |
| 626 |
Record.AddSourceLocation(I.getLocation()); |
| 627 |
} |
| 628 |
|
| 629 |
Code = serialization::STMT_CAPTURED; |
| 630 |
} |
| 631 |
|
| 632 |
void ASTStmtWriter::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *S) { |
| 633 |
VisitStmt(S); |
| 634 |
Record.AddStmt(S->getOriginalStmt()); |
| 635 |
Record.AddDeclRef(S->getOutlinedFunctionDecl()); |
| 636 |
|
| 637 |
Code = serialization::STMT_SYCLKERNELCALL; |
| 638 |
} |
| 639 |
|
| 640 |
void ASTStmtWriter::VisitExpr(Expr *E) { |
| 641 |
VisitStmt(E); |
| 642 |
|
| 643 |
CurrentPackingBits.updateBits(); |
| 644 |
CurrentPackingBits.addBits(E->getDependence(), /*BitsWidth=*/5); |
| 645 |
CurrentPackingBits.addBits(E->getValueKind(), /*BitsWidth=*/2); |
| 646 |
CurrentPackingBits.addBits(E->getObjectKind(), /*BitsWidth=*/3); |
| 647 |
|
| 648 |
Record.AddTypeRef(E->getType()); |
| 649 |
} |
| 650 |
|
| 651 |
void ASTStmtWriter::VisitConstantExpr(ConstantExpr *E) { |
| 652 |
VisitExpr(E); |
| 653 |
Record.push_back(E->ConstantExprBits.ResultKind); |
| 654 |
|
| 655 |
Record.push_back(E->ConstantExprBits.APValueKind); |
| 656 |
Record.push_back(E->ConstantExprBits.IsUnsigned); |
| 657 |
Record.push_back(E->ConstantExprBits.BitWidth); |
| 658 |
// HasCleanup not serialized since we can just query the APValue. |
| 659 |
Record.push_back(E->ConstantExprBits.IsImmediateInvocation); |
| 660 |
|
| 661 |
switch (E->getResultStorageKind()) { |
| 662 |
case ConstantResultStorageKind::None: |
| 663 |
break; |
| 664 |
case ConstantResultStorageKind::Int64: |
| 665 |
Record.push_back(E->Int64Result()); |
| 666 |
break; |
| 667 |
case ConstantResultStorageKind::APValue: |
| 668 |
Record.AddAPValue(E->APValueResult()); |
| 669 |
break; |
| 670 |
} |
| 671 |
|
| 672 |
Record.AddStmt(E->getSubExpr()); |
| 673 |
Code = serialization::EXPR_CONSTANT; |
| 674 |
} |
| 675 |
|
| 676 |
void ASTStmtWriter::VisitOpenACCAsteriskSizeExpr(OpenACCAsteriskSizeExpr *E) { |
| 677 |
VisitExpr(E); |
| 678 |
Record.AddSourceLocation(E->getLocation()); |
| 679 |
Code = serialization::EXPR_OPENACC_ASTERISK_SIZE; |
| 680 |
} |
| 681 |
|
| 682 |
void ASTStmtWriter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) { |
| 683 |
VisitExpr(E); |
| 684 |
|
| 685 |
Record.AddSourceLocation(E->getLocation()); |
| 686 |
Record.AddSourceLocation(E->getLParenLocation()); |
| 687 |
Record.AddSourceLocation(E->getRParenLocation()); |
| 688 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 689 |
|
| 690 |
Code = serialization::EXPR_SYCL_UNIQUE_STABLE_NAME; |
| 691 |
} |
| 692 |
|
| 693 |
void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) { |
| 694 |
VisitExpr(E); |
| 695 |
|
| 696 |
bool HasFunctionName = E->getFunctionName() != nullptr; |
| 697 |
Record.push_back(HasFunctionName); |
| 698 |
Record.push_back( |
| 699 |
llvm::to_underlying(E->getIdentKind())); // FIXME: stable encoding |
| 700 |
Record.push_back(E->isTransparent()); |
| 701 |
Record.AddSourceLocation(E->getLocation()); |
| 702 |
if (HasFunctionName) |
| 703 |
Record.AddStmt(E->getFunctionName()); |
| 704 |
Code = serialization::EXPR_PREDEFINED; |
| 705 |
} |
| 706 |
|
| 707 |
void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) { |
| 708 |
VisitExpr(E); |
| 709 |
|
| 710 |
CurrentPackingBits.updateBits(); |
| 711 |
|
| 712 |
CurrentPackingBits.addBit(E->hadMultipleCandidates()); |
| 713 |
CurrentPackingBits.addBit(E->refersToEnclosingVariableOrCapture()); |
| 714 |
CurrentPackingBits.addBits(E->isNonOdrUse(), /*Width=*/2); |
| 715 |
CurrentPackingBits.addBit(E->isImmediateEscalating()); |
| 716 |
CurrentPackingBits.addBit(E->getDecl() != E->getFoundDecl()); |
| 717 |
CurrentPackingBits.addBit(E->hasQualifier()); |
| 718 |
CurrentPackingBits.addBit(E->hasTemplateKWAndArgsInfo()); |
| 719 |
|
| 720 |
if (E->hasTemplateKWAndArgsInfo()) { |
| 721 |
unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
| 722 |
Record.push_back(NumTemplateArgs); |
| 723 |
} |
| 724 |
|
| 725 |
DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind()); |
| 726 |
|
| 727 |
if ((!E->hasTemplateKWAndArgsInfo()) && (!E->hasQualifier()) && |
| 728 |
(E->getDecl() == E->getFoundDecl()) && |
| 729 |
nk == DeclarationName::Identifier && E->getObjectKind() == OK_Ordinary) { |
| 730 |
AbbrevToUse = Writer.getDeclRefExprAbbrev(); |
| 731 |
} |
| 732 |
|
| 733 |
if (E->hasQualifier()) |
| 734 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 735 |
|
| 736 |
if (E->getDecl() != E->getFoundDecl()) |
| 737 |
Record.AddDeclRef(E->getFoundDecl()); |
| 738 |
|
| 739 |
if (E->hasTemplateKWAndArgsInfo()) |
| 740 |
AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), |
| 741 |
E->getTrailingObjects<TemplateArgumentLoc>()); |
| 742 |
|
| 743 |
Record.AddDeclRef(E->getDecl()); |
| 744 |
Record.AddSourceLocation(E->getLocation()); |
| 745 |
Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName()); |
| 746 |
Code = serialization::EXPR_DECL_REF; |
| 747 |
} |
| 748 |
|
| 749 |
void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) { |
| 750 |
VisitExpr(E); |
| 751 |
Record.AddSourceLocation(E->getLocation()); |
| 752 |
Record.AddAPInt(E->getValue()); |
| 753 |
|
| 754 |
if (E->getBitWidth() == 32) { |
| 755 |
AbbrevToUse = Writer.getIntegerLiteralAbbrev(); |
| 756 |
} |
| 757 |
|
| 758 |
Code = serialization::EXPR_INTEGER_LITERAL; |
| 759 |
} |
| 760 |
|
| 761 |
void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral *E) { |
| 762 |
VisitExpr(E); |
| 763 |
Record.AddSourceLocation(E->getLocation()); |
| 764 |
Record.push_back(E->getScale()); |
| 765 |
Record.AddAPInt(E->getValue()); |
| 766 |
Code = serialization::EXPR_FIXEDPOINT_LITERAL; |
| 767 |
} |
| 768 |
|
| 769 |
void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) { |
| 770 |
VisitExpr(E); |
| 771 |
Record.push_back(E->getRawSemantics()); |
| 772 |
Record.push_back(E->isExact()); |
| 773 |
Record.AddAPFloat(E->getValue()); |
| 774 |
Record.AddSourceLocation(E->getLocation()); |
| 775 |
Code = serialization::EXPR_FLOATING_LITERAL; |
| 776 |
} |
| 777 |
|
| 778 |
void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
| 779 |
VisitExpr(E); |
| 780 |
Record.AddStmt(E->getSubExpr()); |
| 781 |
Code = serialization::EXPR_IMAGINARY_LITERAL; |
| 782 |
} |
| 783 |
|
| 784 |
void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) { |
| 785 |
VisitExpr(E); |
| 786 |
|
| 787 |
// Store the various bits of data of StringLiteral. |
| 788 |
Record.push_back(E->getNumConcatenated()); |
| 789 |
Record.push_back(E->getLength()); |
| 790 |
Record.push_back(E->getCharByteWidth()); |
| 791 |
Record.push_back(llvm::to_underlying(E->getKind())); |
| 792 |
Record.push_back(E->isPascal()); |
| 793 |
|
| 794 |
// Store the trailing array of SourceLocation. |
| 795 |
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) |
| 796 |
Record.AddSourceLocation(E->getStrTokenLoc(I)); |
| 797 |
|
| 798 |
// Store the trailing array of char holding the string data. |
| 799 |
StringRef StrData = E->getBytes(); |
| 800 |
for (unsigned I = 0, N = E->getByteLength(); I != N; ++I) |
| 801 |
Record.push_back(StrData[I]); |
| 802 |
|
| 803 |
Code = serialization::EXPR_STRING_LITERAL; |
| 804 |
} |
| 805 |
|
| 806 |
void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) { |
| 807 |
VisitExpr(E); |
| 808 |
Record.push_back(E->getValue()); |
| 809 |
Record.AddSourceLocation(E->getLocation()); |
| 810 |
Record.push_back(llvm::to_underlying(E->getKind())); |
| 811 |
|
| 812 |
AbbrevToUse = Writer.getCharacterLiteralAbbrev(); |
| 813 |
|
| 814 |
Code = serialization::EXPR_CHARACTER_LITERAL; |
| 815 |
} |
| 816 |
|
| 817 |
void ASTStmtWriter::VisitParenExpr(ParenExpr *E) { |
| 818 |
VisitExpr(E); |
| 819 |
Record.push_back(E->isProducedByFoldExpansion()); |
| 820 |
Record.AddSourceLocation(E->getLParen()); |
| 821 |
Record.AddSourceLocation(E->getRParen()); |
| 822 |
Record.AddStmt(E->getSubExpr()); |
| 823 |
Code = serialization::EXPR_PAREN; |
| 824 |
} |
| 825 |
|
| 826 |
void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) { |
| 827 |
VisitExpr(E); |
| 828 |
Record.push_back(E->getNumExprs()); |
| 829 |
for (auto *SubStmt : E->exprs()) |
| 830 |
Record.AddStmt(SubStmt); |
| 831 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 832 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 833 |
Code = serialization::EXPR_PAREN_LIST; |
| 834 |
} |
| 835 |
|
| 836 |
void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) { |
| 837 |
VisitExpr(E); |
| 838 |
bool HasFPFeatures = E->hasStoredFPFeatures(); |
| 839 |
// Write this first for easy access when deserializing, as they affect the |
| 840 |
// size of the UnaryOperator. |
| 841 |
CurrentPackingBits.addBit(HasFPFeatures); |
| 842 |
Record.AddStmt(E->getSubExpr()); |
| 843 |
CurrentPackingBits.addBits(E->getOpcode(), |
| 844 |
/*Width=*/5); // FIXME: stable encoding |
| 845 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 846 |
CurrentPackingBits.addBit(E->canOverflow()); |
| 847 |
|
| 848 |
if (HasFPFeatures) |
| 849 |
Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt()); |
| 850 |
Code = serialization::EXPR_UNARY_OPERATOR; |
| 851 |
} |
| 852 |
|
| 853 |
void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) { |
| 854 |
VisitExpr(E); |
| 855 |
Record.push_back(E->getNumComponents()); |
| 856 |
Record.push_back(E->getNumExpressions()); |
| 857 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 858 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 859 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 860 |
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
| 861 |
const OffsetOfNode &ON = E->getComponent(I); |
| 862 |
Record.push_back(ON.getKind()); // FIXME: Stable encoding |
| 863 |
Record.AddSourceLocation(ON.getSourceRange().getBegin()); |
| 864 |
Record.AddSourceLocation(ON.getSourceRange().getEnd()); |
| 865 |
switch (ON.getKind()) { |
| 866 |
case OffsetOfNode::Array: |
| 867 |
Record.push_back(ON.getArrayExprIndex()); |
| 868 |
break; |
| 869 |
|
| 870 |
case OffsetOfNode::Field: |
| 871 |
Record.AddDeclRef(ON.getField()); |
| 872 |
break; |
| 873 |
|
| 874 |
case OffsetOfNode::Identifier: |
| 875 |
Record.AddIdentifierRef(ON.getFieldName()); |
| 876 |
break; |
| 877 |
|
| 878 |
case OffsetOfNode::Base: |
| 879 |
Record.AddCXXBaseSpecifier(*ON.getBase()); |
| 880 |
break; |
| 881 |
} |
| 882 |
} |
| 883 |
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) |
| 884 |
Record.AddStmt(E->getIndexExpr(I)); |
| 885 |
Code = serialization::EXPR_OFFSETOF; |
| 886 |
} |
| 887 |
|
| 888 |
void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { |
| 889 |
VisitExpr(E); |
| 890 |
Record.push_back(E->getKind()); |
| 891 |
if (E->isArgumentType()) |
| 892 |
Record.AddTypeSourceInfo(E->getArgumentTypeInfo()); |
| 893 |
else { |
| 894 |
Record.push_back(0); |
| 895 |
Record.AddStmt(E->getArgumentExpr()); |
| 896 |
} |
| 897 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 898 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 899 |
Code = serialization::EXPR_SIZEOF_ALIGN_OF; |
| 900 |
} |
| 901 |
|
| 902 |
void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
| 903 |
VisitExpr(E); |
| 904 |
Record.AddStmt(E->getLHS()); |
| 905 |
Record.AddStmt(E->getRHS()); |
| 906 |
Record.AddSourceLocation(E->getRBracketLoc()); |
| 907 |
Code = serialization::EXPR_ARRAY_SUBSCRIPT; |
| 908 |
} |
| 909 |
|
| 910 |
void ASTStmtWriter::VisitMatrixSingleSubscriptExpr( |
| 911 |
MatrixSingleSubscriptExpr *E) { |
| 912 |
VisitExpr(E); |
| 913 |
Record.AddStmt(E->getBase()); |
| 914 |
Record.AddStmt(E->getRowIdx()); |
| 915 |
Record.AddSourceLocation(E->getRBracketLoc()); |
| 916 |
Code = serialization::EXPR_ARRAY_SUBSCRIPT; |
| 917 |
} |
| 918 |
|
| 919 |
void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) { |
| 920 |
VisitExpr(E); |
| 921 |
Record.AddStmt(E->getBase()); |
| 922 |
Record.AddStmt(E->getRowIdx()); |
| 923 |
Record.AddStmt(E->getColumnIdx()); |
| 924 |
Record.AddSourceLocation(E->getRBracketLoc()); |
| 925 |
Code = serialization::EXPR_ARRAY_SUBSCRIPT; |
| 926 |
} |
| 927 |
|
| 928 |
void ASTStmtWriter::VisitArraySectionExpr(ArraySectionExpr *E) { |
| 929 |
VisitExpr(E); |
| 930 |
Record.writeEnum(E->ASType); |
| 931 |
Record.AddStmt(E->getBase()); |
| 932 |
Record.AddStmt(E->getLowerBound()); |
| 933 |
Record.AddStmt(E->getLength()); |
| 934 |
if (E->isOMPArraySection()) |
| 935 |
Record.AddStmt(E->getStride()); |
| 936 |
Record.AddSourceLocation(E->getColonLocFirst()); |
| 937 |
|
| 938 |
if (E->isOMPArraySection()) |
| 939 |
Record.AddSourceLocation(E->getColonLocSecond()); |
| 940 |
|
| 941 |
Record.AddSourceLocation(E->getRBracketLoc()); |
| 942 |
Code = serialization::EXPR_ARRAY_SECTION; |
| 943 |
} |
| 944 |
|
| 945 |
void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) { |
| 946 |
VisitExpr(E); |
| 947 |
Record.push_back(E->getDimensions().size()); |
| 948 |
Record.AddStmt(E->getBase()); |
| 949 |
for (Expr *Dim : E->getDimensions()) |
| 950 |
Record.AddStmt(Dim); |
| 951 |
for (SourceRange SR : E->getBracketsRanges()) |
| 952 |
Record.AddSourceRange(SR); |
| 953 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 954 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 955 |
Code = serialization::EXPR_OMP_ARRAY_SHAPING; |
| 956 |
} |
| 957 |
|
| 958 |
void ASTStmtWriter::VisitOMPIteratorExpr(OMPIteratorExpr *E) { |
| 959 |
VisitExpr(E); |
| 960 |
Record.push_back(E->numOfIterators()); |
| 961 |
Record.AddSourceLocation(E->getIteratorKwLoc()); |
| 962 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 963 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 964 |
for (unsigned I = 0, End = E->numOfIterators(); I < End; ++I) { |
| 965 |
Record.AddDeclRef(E->getIteratorDecl(I)); |
| 966 |
Record.AddSourceLocation(E->getAssignLoc(I)); |
| 967 |
OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I); |
| 968 |
Record.AddStmt(Range.Begin); |
| 969 |
Record.AddStmt(Range.End); |
| 970 |
Record.AddStmt(Range.Step); |
| 971 |
Record.AddSourceLocation(E->getColonLoc(I)); |
| 972 |
if (Range.Step) |
| 973 |
Record.AddSourceLocation(E->getSecondColonLoc(I)); |
| 974 |
// Serialize helpers |
| 975 |
OMPIteratorHelperData &HD = E->getHelper(I); |
| 976 |
Record.AddDeclRef(HD.CounterVD); |
| 977 |
Record.AddStmt(HD.Upper); |
| 978 |
Record.AddStmt(HD.Update); |
| 979 |
Record.AddStmt(HD.CounterUpdate); |
| 980 |
} |
| 981 |
Code = serialization::EXPR_OMP_ITERATOR; |
| 982 |
} |
| 983 |
|
| 984 |
void ASTStmtWriter::VisitCallExpr(CallExpr *E) { |
| 985 |
VisitExpr(E); |
| 986 |
|
| 987 |
Record.push_back(E->getNumArgs()); |
| 988 |
CurrentPackingBits.updateBits(); |
| 989 |
CurrentPackingBits.addBit(static_cast<bool>(E->getADLCallKind())); |
| 990 |
CurrentPackingBits.addBit(E->hasStoredFPFeatures()); |
| 991 |
CurrentPackingBits.addBit(E->isCoroElideSafe()); |
| 992 |
CurrentPackingBits.addBit(E->usesMemberSyntax()); |
| 993 |
|
| 994 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 995 |
Record.AddStmt(E->getCallee()); |
| 996 |
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
| 997 |
Arg != ArgEnd; ++Arg) |
| 998 |
Record.AddStmt(*Arg); |
| 999 |
|
| 1000 |
if (E->hasStoredFPFeatures()) |
| 1001 |
Record.push_back(E->getFPFeatures().getAsOpaqueInt()); |
| 1002 |
|
| 1003 |
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()) && |
| 1004 |
!E->isCoroElideSafe() && !E->usesMemberSyntax() && |
| 1005 |
E->getStmtClass() == Stmt::CallExprClass) |
| 1006 |
AbbrevToUse = Writer.getCallExprAbbrev(); |
| 1007 |
|
| 1008 |
Code = serialization::EXPR_CALL; |
| 1009 |
} |
| 1010 |
|
| 1011 |
void ASTStmtWriter::VisitRecoveryExpr(RecoveryExpr *E) { |
| 1012 |
VisitExpr(E); |
| 1013 |
Record.push_back(std::distance(E->children().begin(), E->children().end())); |
| 1014 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 1015 |
Record.AddSourceLocation(E->getEndLoc()); |
| 1016 |
for (Stmt *Child : E->children()) |
| 1017 |
Record.AddStmt(Child); |
| 1018 |
Code = serialization::EXPR_RECOVERY; |
| 1019 |
} |
| 1020 |
|
| 1021 |
void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) { |
| 1022 |
VisitExpr(E); |
| 1023 |
|
| 1024 |
bool HasQualifier = E->hasQualifier(); |
| 1025 |
bool HasFoundDecl = E->hasFoundDecl(); |
| 1026 |
bool HasTemplateInfo = E->hasTemplateKWAndArgsInfo(); |
| 1027 |
unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
| 1028 |
|
| 1029 |
// Write these first for easy access when deserializing, as they affect the |
| 1030 |
// size of the MemberExpr. |
| 1031 |
CurrentPackingBits.updateBits(); |
| 1032 |
CurrentPackingBits.addBit(HasQualifier); |
| 1033 |
CurrentPackingBits.addBit(HasFoundDecl); |
| 1034 |
CurrentPackingBits.addBit(HasTemplateInfo); |
| 1035 |
Record.push_back(NumTemplateArgs); |
| 1036 |
|
| 1037 |
Record.AddStmt(E->getBase()); |
| 1038 |
Record.AddDeclRef(E->getMemberDecl()); |
| 1039 |
Record.AddDeclarationNameLoc(E->MemberDNLoc, |
| 1040 |
E->getMemberDecl()->getDeclName()); |
| 1041 |
Record.AddSourceLocation(E->getMemberLoc()); |
| 1042 |
CurrentPackingBits.addBit(E->isArrow()); |
| 1043 |
CurrentPackingBits.addBit(E->hadMultipleCandidates()); |
| 1044 |
CurrentPackingBits.addBits(E->isNonOdrUse(), /*Width=*/2); |
| 1045 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 1046 |
|
| 1047 |
if (HasQualifier) |
| 1048 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 1049 |
|
| 1050 |
if (HasFoundDecl) { |
| 1051 |
DeclAccessPair FoundDecl = E->getFoundDecl(); |
| 1052 |
Record.AddDeclRef(FoundDecl.getDecl()); |
| 1053 |
CurrentPackingBits.addBits(FoundDecl.getAccess(), /*BitWidth=*/2); |
| 1054 |
} |
| 1055 |
|
| 1056 |
if (HasTemplateInfo) |
| 1057 |
AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), |
| 1058 |
E->getTrailingObjects<TemplateArgumentLoc>()); |
| 1059 |
|
| 1060 |
Code = serialization::EXPR_MEMBER; |
| 1061 |
} |
| 1062 |
|
| 1063 |
void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
| 1064 |
VisitExpr(E); |
| 1065 |
Record.AddStmt(E->getBase()); |
| 1066 |
Record.AddSourceLocation(E->getIsaMemberLoc()); |
| 1067 |
Record.AddSourceLocation(E->getOpLoc()); |
| 1068 |
Record.push_back(E->isArrow()); |
| 1069 |
Code = serialization::EXPR_OBJC_ISA; |
| 1070 |
} |
| 1071 |
|
| 1072 |
void ASTStmtWriter:: |
| 1073 |
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { |
| 1074 |
VisitExpr(E); |
| 1075 |
Record.AddStmt(E->getSubExpr()); |
| 1076 |
Record.push_back(E->shouldCopy()); |
| 1077 |
Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE; |
| 1078 |
} |
| 1079 |
|
| 1080 |
void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { |
| 1081 |
VisitExplicitCastExpr(E); |
| 1082 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 1083 |
Record.AddSourceLocation(E->getBridgeKeywordLoc()); |
| 1084 |
Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding |
| 1085 |
Code = serialization::EXPR_OBJC_BRIDGED_CAST; |
| 1086 |
} |
| 1087 |
|
| 1088 |
void ASTStmtWriter::VisitCastExpr(CastExpr *E) { |
| 1089 |
VisitExpr(E); |
| 1090 |
|
| 1091 |
Record.push_back(E->path_size()); |
| 1092 |
CurrentPackingBits.updateBits(); |
| 1093 |
// 7 bits should be enough to store the casting kinds. |
| 1094 |
CurrentPackingBits.addBits(E->getCastKind(), /*Width=*/7); |
| 1095 |
CurrentPackingBits.addBit(E->hasStoredFPFeatures()); |
| 1096 |
Record.AddStmt(E->getSubExpr()); |
| 1097 |
|
| 1098 |
for (CastExpr::path_iterator |
| 1099 |
PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI) |
| 1100 |
Record.AddCXXBaseSpecifier(**PI); |
| 1101 |
|
| 1102 |
if (E->hasStoredFPFeatures()) |
| 1103 |
Record.push_back(E->getFPFeatures().getAsOpaqueInt()); |
| 1104 |
} |
| 1105 |
|
| 1106 |
void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) { |
| 1107 |
VisitExpr(E); |
| 1108 |
|
| 1109 |
// Write this first for easy access when deserializing, as they affect the |
| 1110 |
// size of the UnaryOperator. |
| 1111 |
CurrentPackingBits.updateBits(); |
| 1112 |
CurrentPackingBits.addBits(E->getOpcode(), /*Width=*/6); |
| 1113 |
bool HasFPFeatures = E->hasStoredFPFeatures(); |
| 1114 |
CurrentPackingBits.addBit(HasFPFeatures); |
| 1115 |
CurrentPackingBits.addBit(E->hasExcludedOverflowPattern()); |
| 1116 |
Record.AddStmt(E->getLHS()); |
| 1117 |
Record.AddStmt(E->getRHS()); |
| 1118 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 1119 |
if (HasFPFeatures) |
| 1120 |
Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt()); |
| 1121 |
|
| 1122 |
if (!HasFPFeatures && E->getValueKind() == VK_PRValue && |
| 1123 |
E->getObjectKind() == OK_Ordinary) |
| 1124 |
AbbrevToUse = Writer.getBinaryOperatorAbbrev(); |
| 1125 |
|
| 1126 |
Code = serialization::EXPR_BINARY_OPERATOR; |
| 1127 |
} |
| 1128 |
|
| 1129 |
void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
| 1130 |
VisitBinaryOperator(E); |
| 1131 |
Record.AddTypeRef(E->getComputationLHSType()); |
| 1132 |
Record.AddTypeRef(E->getComputationResultType()); |
| 1133 |
|
| 1134 |
if (!E->hasStoredFPFeatures() && E->getValueKind() == VK_PRValue && |
| 1135 |
E->getObjectKind() == OK_Ordinary) |
| 1136 |
AbbrevToUse = Writer.getCompoundAssignOperatorAbbrev(); |
| 1137 |
|
| 1138 |
Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR; |
| 1139 |
} |
| 1140 |
|
| 1141 |
void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) { |
| 1142 |
VisitExpr(E); |
| 1143 |
Record.AddStmt(E->getCond()); |
| 1144 |
Record.AddStmt(E->getLHS()); |
| 1145 |
Record.AddStmt(E->getRHS()); |
| 1146 |
Record.AddSourceLocation(E->getQuestionLoc()); |
| 1147 |
Record.AddSourceLocation(E->getColonLoc()); |
| 1148 |
Code = serialization::EXPR_CONDITIONAL_OPERATOR; |
| 1149 |
} |
| 1150 |
|
| 1151 |
void |
| 1152 |
ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { |
| 1153 |
VisitExpr(E); |
| 1154 |
Record.AddStmt(E->getOpaqueValue()); |
| 1155 |
Record.AddStmt(E->getCommon()); |
| 1156 |
Record.AddStmt(E->getCond()); |
| 1157 |
Record.AddStmt(E->getTrueExpr()); |
| 1158 |
Record.AddStmt(E->getFalseExpr()); |
| 1159 |
Record.AddSourceLocation(E->getQuestionLoc()); |
| 1160 |
Record.AddSourceLocation(E->getColonLoc()); |
| 1161 |
Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR; |
| 1162 |
} |
| 1163 |
|
| 1164 |
void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
| 1165 |
VisitCastExpr(E); |
| 1166 |
CurrentPackingBits.addBit(E->isPartOfExplicitCast()); |
| 1167 |
|
| 1168 |
if (E->path_size() == 0 && !E->hasStoredFPFeatures()) |
| 1169 |
AbbrevToUse = Writer.getExprImplicitCastAbbrev(); |
| 1170 |
|
| 1171 |
Code = serialization::EXPR_IMPLICIT_CAST; |
| 1172 |
} |
| 1173 |
|
| 1174 |
void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
| 1175 |
VisitCastExpr(E); |
| 1176 |
Record.AddTypeSourceInfo(E->getTypeInfoAsWritten()); |
| 1177 |
} |
| 1178 |
|
| 1179 |
void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) { |
| 1180 |
VisitExplicitCastExpr(E); |
| 1181 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 1182 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1183 |
Code = serialization::EXPR_CSTYLE_CAST; |
| 1184 |
} |
| 1185 |
|
| 1186 |
void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
| 1187 |
VisitExpr(E); |
| 1188 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 1189 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 1190 |
Record.AddStmt(E->getInitializer()); |
| 1191 |
Record.push_back(E->isFileScope()); |
| 1192 |
Code = serialization::EXPR_COMPOUND_LITERAL; |
| 1193 |
} |
| 1194 |
|
| 1195 |
void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
| 1196 |
VisitExpr(E); |
| 1197 |
Record.AddStmt(E->getBase()); |
| 1198 |
Record.AddIdentifierRef(&E->getAccessor()); |
| 1199 |
Record.AddSourceLocation(E->getAccessorLoc()); |
| 1200 |
Code = serialization::EXPR_EXT_VECTOR_ELEMENT; |
| 1201 |
} |
| 1202 |
|
| 1203 |
void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) { |
| 1204 |
VisitExpr(E); |
| 1205 |
// NOTE: only add the (possibly null) syntactic form. |
| 1206 |
// No need to serialize the isSemanticForm flag and the semantic form. |
| 1207 |
Record.AddStmt(E->getSyntacticForm()); |
| 1208 |
Record.AddSourceLocation(E->getLBraceLoc()); |
| 1209 |
Record.AddSourceLocation(E->getRBraceLoc()); |
| 1210 |
bool isArrayFiller = isa<Expr *>(E->ArrayFillerOrUnionFieldInit); |
| 1211 |
Record.push_back(isArrayFiller); |
| 1212 |
if (isArrayFiller) |
| 1213 |
Record.AddStmt(E->getArrayFiller()); |
| 1214 |
else |
| 1215 |
Record.AddDeclRef(E->getInitializedFieldInUnion()); |
| 1216 |
Record.push_back(E->hadArrayRangeDesignator()); |
| 1217 |
Record.push_back(E->getNumInits()); |
| 1218 |
if (isArrayFiller) { |
| 1219 |
// ArrayFiller may have filled "holes" due to designated initializer. |
| 1220 |
// Replace them by 0 to indicate that the filler goes in that place. |
| 1221 |
Expr *filler = E->getArrayFiller(); |
| 1222 |
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) |
| 1223 |
Record.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr); |
| 1224 |
} else { |
| 1225 |
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) |
| 1226 |
Record.AddStmt(E->getInit(I)); |
| 1227 |
} |
| 1228 |
Code = serialization::EXPR_INIT_LIST; |
| 1229 |
} |
| 1230 |
|
| 1231 |
void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
| 1232 |
VisitExpr(E); |
| 1233 |
Record.push_back(E->getNumSubExprs()); |
| 1234 |
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) |
| 1235 |
Record.AddStmt(E->getSubExpr(I)); |
| 1236 |
Record.AddSourceLocation(E->getEqualOrColonLoc()); |
| 1237 |
Record.push_back(E->usesGNUSyntax()); |
| 1238 |
for (const DesignatedInitExpr::Designator &D : E->designators()) { |
| 1239 |
if (D.isFieldDesignator()) { |
| 1240 |
if (FieldDecl *Field = D.getFieldDecl()) { |
| 1241 |
Record.push_back(serialization::DESIG_FIELD_DECL); |
| 1242 |
Record.AddDeclRef(Field); |
| 1243 |
} else { |
| 1244 |
Record.push_back(serialization::DESIG_FIELD_NAME); |
| 1245 |
Record.AddIdentifierRef(D.getFieldName()); |
| 1246 |
} |
| 1247 |
Record.AddSourceLocation(D.getDotLoc()); |
| 1248 |
Record.AddSourceLocation(D.getFieldLoc()); |
| 1249 |
} else if (D.isArrayDesignator()) { |
| 1250 |
Record.push_back(serialization::DESIG_ARRAY); |
| 1251 |
Record.push_back(D.getArrayIndex()); |
| 1252 |
Record.AddSourceLocation(D.getLBracketLoc()); |
| 1253 |
Record.AddSourceLocation(D.getRBracketLoc()); |
| 1254 |
} else { |
| 1255 |
assert(D.isArrayRangeDesignator() && "Unknown designator"); |
| 1256 |
Record.push_back(serialization::DESIG_ARRAY_RANGE); |
| 1257 |
Record.push_back(D.getArrayIndex()); |
| 1258 |
Record.AddSourceLocation(D.getLBracketLoc()); |
| 1259 |
Record.AddSourceLocation(D.getEllipsisLoc()); |
| 1260 |
Record.AddSourceLocation(D.getRBracketLoc()); |
| 1261 |
} |
| 1262 |
} |
| 1263 |
Code = serialization::EXPR_DESIGNATED_INIT; |
| 1264 |
} |
| 1265 |
|
| 1266 |
void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) { |
| 1267 |
VisitExpr(E); |
| 1268 |
Record.AddStmt(E->getBase()); |
| 1269 |
Record.AddStmt(E->getUpdater()); |
| 1270 |
Code = serialization::EXPR_DESIGNATED_INIT_UPDATE; |
| 1271 |
} |
| 1272 |
|
| 1273 |
void ASTStmtWriter::VisitNoInitExpr(NoInitExpr *E) { |
| 1274 |
VisitExpr(E); |
| 1275 |
Code = serialization::EXPR_NO_INIT; |
| 1276 |
} |
| 1277 |
|
| 1278 |
void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) { |
| 1279 |
VisitExpr(E); |
| 1280 |
Record.AddStmt(E->SubExprs[0]); |
| 1281 |
Record.AddStmt(E->SubExprs[1]); |
| 1282 |
Code = serialization::EXPR_ARRAY_INIT_LOOP; |
| 1283 |
} |
| 1284 |
|
| 1285 |
void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) { |
| 1286 |
VisitExpr(E); |
| 1287 |
Code = serialization::EXPR_ARRAY_INIT_INDEX; |
| 1288 |
} |
| 1289 |
|
| 1290 |
void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
| 1291 |
VisitExpr(E); |
| 1292 |
Code = serialization::EXPR_IMPLICIT_VALUE_INIT; |
| 1293 |
} |
| 1294 |
|
| 1295 |
void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) { |
| 1296 |
VisitExpr(E); |
| 1297 |
Record.AddStmt(E->getSubExpr()); |
| 1298 |
Record.AddTypeSourceInfo(E->getWrittenTypeInfo()); |
| 1299 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 1300 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1301 |
Record.push_back(E->isMicrosoftABI()); |
| 1302 |
Code = serialization::EXPR_VA_ARG; |
| 1303 |
} |
| 1304 |
|
| 1305 |
void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr *E) { |
| 1306 |
VisitExpr(E); |
| 1307 |
Record.AddDeclRef(cast_or_null<Decl>(E->getParentContext())); |
| 1308 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 1309 |
Record.AddSourceLocation(E->getEndLoc()); |
| 1310 |
Record.push_back(llvm::to_underlying(E->getIdentKind())); |
| 1311 |
Code = serialization::EXPR_SOURCE_LOC; |
| 1312 |
} |
| 1313 |
|
| 1314 |
void ASTStmtWriter::VisitEmbedExpr(EmbedExpr *E) { |
| 1315 |
VisitExpr(E); |
| 1316 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 1317 |
Record.AddSourceLocation(E->getEndLoc()); |
| 1318 |
Record.AddStmt(E->getDataStringLiteral()); |
| 1319 |
Record.writeUInt32(E->getStartingElementPos()); |
| 1320 |
Record.writeUInt32(E->getDataElementCount()); |
| 1321 |
Code = serialization::EXPR_BUILTIN_PP_EMBED; |
| 1322 |
} |
| 1323 |
|
| 1324 |
void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) { |
| 1325 |
VisitExpr(E); |
| 1326 |
Record.AddSourceLocation(E->getAmpAmpLoc()); |
| 1327 |
Record.AddSourceLocation(E->getLabelLoc()); |
| 1328 |
Record.AddDeclRef(E->getLabel()); |
| 1329 |
Code = serialization::EXPR_ADDR_LABEL; |
| 1330 |
} |
| 1331 |
|
| 1332 |
void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) { |
| 1333 |
VisitExpr(E); |
| 1334 |
Record.AddStmt(E->getSubStmt()); |
| 1335 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 1336 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1337 |
Record.push_back(E->getTemplateDepth()); |
| 1338 |
Code = serialization::EXPR_STMT; |
| 1339 |
} |
| 1340 |
|
| 1341 |
void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) { |
| 1342 |
VisitExpr(E); |
| 1343 |
Record.AddStmt(E->getCond()); |
| 1344 |
Record.AddStmt(E->getLHS()); |
| 1345 |
Record.AddStmt(E->getRHS()); |
| 1346 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 1347 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1348 |
Record.push_back(E->isConditionDependent() ? false : E->isConditionTrue()); |
| 1349 |
Code = serialization::EXPR_CHOOSE; |
| 1350 |
} |
| 1351 |
|
| 1352 |
void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) { |
| 1353 |
VisitExpr(E); |
| 1354 |
Record.AddSourceLocation(E->getTokenLocation()); |
| 1355 |
Code = serialization::EXPR_GNU_NULL; |
| 1356 |
} |
| 1357 |
|
| 1358 |
void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
| 1359 |
VisitExpr(E); |
| 1360 |
Record.push_back(E->getNumSubExprs()); |
| 1361 |
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) |
| 1362 |
Record.AddStmt(E->getExpr(I)); |
| 1363 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 1364 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1365 |
Code = serialization::EXPR_SHUFFLE_VECTOR; |
| 1366 |
} |
| 1367 |
|
| 1368 |
void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) { |
| 1369 |
VisitExpr(E); |
| 1370 |
bool HasFPFeatures = E->hasStoredFPFeatures(); |
| 1371 |
CurrentPackingBits.addBit(HasFPFeatures); |
| 1372 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 1373 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1374 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 1375 |
Record.AddStmt(E->getSrcExpr()); |
| 1376 |
Code = serialization::EXPR_CONVERT_VECTOR; |
| 1377 |
if (HasFPFeatures) |
| 1378 |
Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt()); |
| 1379 |
} |
| 1380 |
|
| 1381 |
void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) { |
| 1382 |
VisitExpr(E); |
| 1383 |
Record.AddDeclRef(E->getBlockDecl()); |
| 1384 |
Code = serialization::EXPR_BLOCK; |
| 1385 |
} |
| 1386 |
|
| 1387 |
void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) { |
| 1388 |
VisitExpr(E); |
| 1389 |
|
| 1390 |
Record.push_back(E->getNumAssocs()); |
| 1391 |
Record.push_back(E->isExprPredicate()); |
| 1392 |
Record.push_back(E->ResultIndex); |
| 1393 |
Record.AddSourceLocation(E->getGenericLoc()); |
| 1394 |
Record.AddSourceLocation(E->getDefaultLoc()); |
| 1395 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1396 |
|
| 1397 |
Stmt **Stmts = E->getTrailingObjects<Stmt *>(); |
| 1398 |
// Add 1 to account for the controlling expression which is the first |
| 1399 |
// expression in the trailing array of Stmt *. This is not needed for |
| 1400 |
// the trailing array of TypeSourceInfo *. |
| 1401 |
for (unsigned I = 0, N = E->getNumAssocs() + 1; I < N; ++I) |
| 1402 |
Record.AddStmt(Stmts[I]); |
| 1403 |
|
| 1404 |
TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>(); |
| 1405 |
for (unsigned I = 0, N = E->getNumAssocs(); I < N; ++I) |
| 1406 |
Record.AddTypeSourceInfo(TSIs[I]); |
| 1407 |
|
| 1408 |
Code = serialization::EXPR_GENERIC_SELECTION; |
| 1409 |
} |
| 1410 |
|
| 1411 |
void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) { |
| 1412 |
VisitExpr(E); |
| 1413 |
Record.push_back(E->getNumSemanticExprs()); |
| 1414 |
|
| 1415 |
// Push the result index. Currently, this needs to exactly match |
| 1416 |
// the encoding used internally for ResultIndex. |
| 1417 |
unsigned result = E->getResultExprIndex(); |
| 1418 |
result = (result == PseudoObjectExpr::NoResult ? 0 : result + 1); |
| 1419 |
Record.push_back(result); |
| 1420 |
|
| 1421 |
Record.AddStmt(E->getSyntacticForm()); |
| 1422 |
for (PseudoObjectExpr::semantics_iterator |
| 1423 |
i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) { |
| 1424 |
Record.AddStmt(*i); |
| 1425 |
} |
| 1426 |
Code = serialization::EXPR_PSEUDO_OBJECT; |
| 1427 |
} |
| 1428 |
|
| 1429 |
void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) { |
| 1430 |
VisitExpr(E); |
| 1431 |
Record.push_back(E->getOp()); |
| 1432 |
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) |
| 1433 |
Record.AddStmt(E->getSubExprs()[I]); |
| 1434 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 1435 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1436 |
Code = serialization::EXPR_ATOMIC; |
| 1437 |
} |
| 1438 |
|
| 1439 |
//===----------------------------------------------------------------------===// |
| 1440 |
// Objective-C Expressions and Statements. |
| 1441 |
//===----------------------------------------------------------------------===// |
| 1442 |
|
| 1443 |
void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
| 1444 |
VisitExpr(E); |
| 1445 |
Record.AddStmt(E->getString()); |
| 1446 |
Record.AddSourceLocation(E->getAtLoc()); |
| 1447 |
Code = serialization::EXPR_OBJC_STRING_LITERAL; |
| 1448 |
} |
| 1449 |
|
| 1450 |
void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { |
| 1451 |
VisitExpr(E); |
| 1452 |
Record.AddStmt(E->getSubExpr()); |
| 1453 |
Record.AddDeclRef(E->getBoxingMethod()); |
| 1454 |
Record.AddSourceRange(E->getSourceRange()); |
| 1455 |
Code = serialization::EXPR_OBJC_BOXED_EXPRESSION; |
| 1456 |
} |
| 1457 |
|
| 1458 |
void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { |
| 1459 |
VisitExpr(E); |
| 1460 |
Record.push_back(E->getNumElements()); |
| 1461 |
for (unsigned i = 0; i < E->getNumElements(); i++) |
| 1462 |
Record.AddStmt(E->getElement(i)); |
| 1463 |
Record.AddDeclRef(E->getArrayWithObjectsMethod()); |
| 1464 |
Record.AddSourceRange(E->getSourceRange()); |
| 1465 |
Code = serialization::EXPR_OBJC_ARRAY_LITERAL; |
| 1466 |
} |
| 1467 |
|
| 1468 |
void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { |
| 1469 |
VisitExpr(E); |
| 1470 |
Record.push_back(E->getNumElements()); |
| 1471 |
Record.push_back(E->HasPackExpansions); |
| 1472 |
for (unsigned i = 0; i < E->getNumElements(); i++) { |
| 1473 |
ObjCDictionaryElement Element = E->getKeyValueElement(i); |
| 1474 |
Record.AddStmt(Element.Key); |
| 1475 |
Record.AddStmt(Element.Value); |
| 1476 |
if (E->HasPackExpansions) { |
| 1477 |
Record.AddSourceLocation(Element.EllipsisLoc); |
| 1478 |
unsigned NumExpansions = 0; |
| 1479 |
if (Element.NumExpansions) |
| 1480 |
NumExpansions = *Element.NumExpansions + 1; |
| 1481 |
Record.push_back(NumExpansions); |
| 1482 |
} |
| 1483 |
} |
| 1484 |
|
| 1485 |
Record.AddDeclRef(E->getDictWithObjectsMethod()); |
| 1486 |
Record.AddSourceRange(E->getSourceRange()); |
| 1487 |
Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL; |
| 1488 |
} |
| 1489 |
|
| 1490 |
void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
| 1491 |
VisitExpr(E); |
| 1492 |
Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo()); |
| 1493 |
Record.AddSourceLocation(E->getAtLoc()); |
| 1494 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1495 |
Code = serialization::EXPR_OBJC_ENCODE; |
| 1496 |
} |
| 1497 |
|
| 1498 |
void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
| 1499 |
VisitExpr(E); |
| 1500 |
Record.AddSelectorRef(E->getSelector()); |
| 1501 |
Record.AddSourceLocation(E->getAtLoc()); |
| 1502 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1503 |
Code = serialization::EXPR_OBJC_SELECTOR_EXPR; |
| 1504 |
} |
| 1505 |
|
| 1506 |
void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
| 1507 |
VisitExpr(E); |
| 1508 |
Record.AddDeclRef(E->getProtocol()); |
| 1509 |
Record.AddSourceLocation(E->getAtLoc()); |
| 1510 |
Record.AddSourceLocation(E->ProtoLoc); |
| 1511 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1512 |
Code = serialization::EXPR_OBJC_PROTOCOL_EXPR; |
| 1513 |
} |
| 1514 |
|
| 1515 |
void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
| 1516 |
VisitExpr(E); |
| 1517 |
Record.AddDeclRef(E->getDecl()); |
| 1518 |
Record.AddSourceLocation(E->getLocation()); |
| 1519 |
Record.AddSourceLocation(E->getOpLoc()); |
| 1520 |
Record.AddStmt(E->getBase()); |
| 1521 |
Record.push_back(E->isArrow()); |
| 1522 |
Record.push_back(E->isFreeIvar()); |
| 1523 |
Code = serialization::EXPR_OBJC_IVAR_REF_EXPR; |
| 1524 |
} |
| 1525 |
|
| 1526 |
void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
| 1527 |
VisitExpr(E); |
| 1528 |
Record.push_back(E->SetterAndMethodRefFlags.getInt()); |
| 1529 |
Record.push_back(E->isImplicitProperty()); |
| 1530 |
if (E->isImplicitProperty()) { |
| 1531 |
Record.AddDeclRef(E->getImplicitPropertyGetter()); |
| 1532 |
Record.AddDeclRef(E->getImplicitPropertySetter()); |
| 1533 |
} else { |
| 1534 |
Record.AddDeclRef(E->getExplicitProperty()); |
| 1535 |
} |
| 1536 |
Record.AddSourceLocation(E->getLocation()); |
| 1537 |
Record.AddSourceLocation(E->getReceiverLocation()); |
| 1538 |
if (E->isObjectReceiver()) { |
| 1539 |
Record.push_back(0); |
| 1540 |
Record.AddStmt(E->getBase()); |
| 1541 |
} else if (E->isSuperReceiver()) { |
| 1542 |
Record.push_back(1); |
| 1543 |
Record.AddTypeRef(E->getSuperReceiverType()); |
| 1544 |
} else { |
| 1545 |
Record.push_back(2); |
| 1546 |
Record.AddDeclRef(E->getClassReceiver()); |
| 1547 |
} |
| 1548 |
|
| 1549 |
Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR; |
| 1550 |
} |
| 1551 |
|
| 1552 |
void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { |
| 1553 |
VisitExpr(E); |
| 1554 |
Record.AddSourceLocation(E->getRBracket()); |
| 1555 |
Record.AddStmt(E->getBaseExpr()); |
| 1556 |
Record.AddStmt(E->getKeyExpr()); |
| 1557 |
Record.AddDeclRef(E->getAtIndexMethodDecl()); |
| 1558 |
Record.AddDeclRef(E->setAtIndexMethodDecl()); |
| 1559 |
|
| 1560 |
Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR; |
| 1561 |
} |
| 1562 |
|
| 1563 |
void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
| 1564 |
VisitExpr(E); |
| 1565 |
Record.push_back(E->getNumArgs()); |
| 1566 |
Record.push_back(E->getNumStoredSelLocs()); |
| 1567 |
Record.push_back(E->SelLocsKind); |
| 1568 |
Record.push_back(E->isDelegateInitCall()); |
| 1569 |
Record.push_back(E->IsImplicit); |
| 1570 |
Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding |
| 1571 |
switch (E->getReceiverKind()) { |
| 1572 |
case ObjCMessageExpr::Instance: |
| 1573 |
Record.AddStmt(E->getInstanceReceiver()); |
| 1574 |
break; |
| 1575 |
|
| 1576 |
case ObjCMessageExpr::Class: |
| 1577 |
Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo()); |
| 1578 |
break; |
| 1579 |
|
| 1580 |
case ObjCMessageExpr::SuperClass: |
| 1581 |
case ObjCMessageExpr::SuperInstance: |
| 1582 |
Record.AddTypeRef(E->getSuperType()); |
| 1583 |
Record.AddSourceLocation(E->getSuperLoc()); |
| 1584 |
break; |
| 1585 |
} |
| 1586 |
|
| 1587 |
if (E->getMethodDecl()) { |
| 1588 |
Record.push_back(1); |
| 1589 |
Record.AddDeclRef(E->getMethodDecl()); |
| 1590 |
} else { |
| 1591 |
Record.push_back(0); |
| 1592 |
Record.AddSelectorRef(E->getSelector()); |
| 1593 |
} |
| 1594 |
|
| 1595 |
Record.AddSourceLocation(E->getLeftLoc()); |
| 1596 |
Record.AddSourceLocation(E->getRightLoc()); |
| 1597 |
|
| 1598 |
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
| 1599 |
Arg != ArgEnd; ++Arg) |
| 1600 |
Record.AddStmt(*Arg); |
| 1601 |
|
| 1602 |
SourceLocation *Locs = E->getStoredSelLocs(); |
| 1603 |
for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i) |
| 1604 |
Record.AddSourceLocation(Locs[i]); |
| 1605 |
|
| 1606 |
Code = serialization::EXPR_OBJC_MESSAGE_EXPR; |
| 1607 |
} |
| 1608 |
|
| 1609 |
void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
| 1610 |
VisitStmt(S); |
| 1611 |
Record.AddStmt(S->getElement()); |
| 1612 |
Record.AddStmt(S->getCollection()); |
| 1613 |
Record.AddStmt(S->getBody()); |
| 1614 |
Record.AddSourceLocation(S->getForLoc()); |
| 1615 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 1616 |
Code = serialization::STMT_OBJC_FOR_COLLECTION; |
| 1617 |
} |
| 1618 |
|
| 1619 |
void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
| 1620 |
VisitStmt(S); |
| 1621 |
Record.AddStmt(S->getCatchBody()); |
| 1622 |
Record.AddDeclRef(S->getCatchParamDecl()); |
| 1623 |
Record.AddSourceLocation(S->getAtCatchLoc()); |
| 1624 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 1625 |
Code = serialization::STMT_OBJC_CATCH; |
| 1626 |
} |
| 1627 |
|
| 1628 |
void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
| 1629 |
VisitStmt(S); |
| 1630 |
Record.AddStmt(S->getFinallyBody()); |
| 1631 |
Record.AddSourceLocation(S->getAtFinallyLoc()); |
| 1632 |
Code = serialization::STMT_OBJC_FINALLY; |
| 1633 |
} |
| 1634 |
|
| 1635 |
void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { |
| 1636 |
VisitStmt(S); // FIXME: no test coverage. |
| 1637 |
Record.AddStmt(S->getSubStmt()); |
| 1638 |
Record.AddSourceLocation(S->getAtLoc()); |
| 1639 |
Code = serialization::STMT_OBJC_AUTORELEASE_POOL; |
| 1640 |
} |
| 1641 |
|
| 1642 |
void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
| 1643 |
VisitStmt(S); |
| 1644 |
Record.push_back(S->getNumCatchStmts()); |
| 1645 |
Record.push_back(S->getFinallyStmt() != nullptr); |
| 1646 |
Record.AddStmt(S->getTryBody()); |
| 1647 |
for (ObjCAtCatchStmt *C : S->catch_stmts()) |
| 1648 |
Record.AddStmt(C); |
| 1649 |
if (S->getFinallyStmt()) |
| 1650 |
Record.AddStmt(S->getFinallyStmt()); |
| 1651 |
Record.AddSourceLocation(S->getAtTryLoc()); |
| 1652 |
Code = serialization::STMT_OBJC_AT_TRY; |
| 1653 |
} |
| 1654 |
|
| 1655 |
void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
| 1656 |
VisitStmt(S); // FIXME: no test coverage. |
| 1657 |
Record.AddStmt(S->getSynchExpr()); |
| 1658 |
Record.AddStmt(S->getSynchBody()); |
| 1659 |
Record.AddSourceLocation(S->getAtSynchronizedLoc()); |
| 1660 |
Code = serialization::STMT_OBJC_AT_SYNCHRONIZED; |
| 1661 |
} |
| 1662 |
|
| 1663 |
void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
| 1664 |
VisitStmt(S); // FIXME: no test coverage. |
| 1665 |
Record.AddStmt(S->getThrowExpr()); |
| 1666 |
Record.AddSourceLocation(S->getThrowLoc()); |
| 1667 |
Code = serialization::STMT_OBJC_AT_THROW; |
| 1668 |
} |
| 1669 |
|
| 1670 |
void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { |
| 1671 |
VisitExpr(E); |
| 1672 |
Record.push_back(E->getValue()); |
| 1673 |
Record.AddSourceLocation(E->getLocation()); |
| 1674 |
Code = serialization::EXPR_OBJC_BOOL_LITERAL; |
| 1675 |
} |
| 1676 |
|
| 1677 |
void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { |
| 1678 |
VisitExpr(E); |
| 1679 |
Record.AddSourceRange(E->getSourceRange()); |
| 1680 |
Record.AddVersionTuple(E->getVersion()); |
| 1681 |
Code = serialization::EXPR_OBJC_AVAILABILITY_CHECK; |
| 1682 |
} |
| 1683 |
|
| 1684 |
//===----------------------------------------------------------------------===// |
| 1685 |
// C++ Expressions and Statements. |
| 1686 |
//===----------------------------------------------------------------------===// |
| 1687 |
|
| 1688 |
void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) { |
| 1689 |
VisitStmt(S); |
| 1690 |
Record.AddSourceLocation(S->getCatchLoc()); |
| 1691 |
Record.AddDeclRef(S->getExceptionDecl()); |
| 1692 |
Record.AddStmt(S->getHandlerBlock()); |
| 1693 |
Code = serialization::STMT_CXX_CATCH; |
| 1694 |
} |
| 1695 |
|
| 1696 |
void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) { |
| 1697 |
VisitStmt(S); |
| 1698 |
Record.push_back(S->getNumHandlers()); |
| 1699 |
Record.AddSourceLocation(S->getTryLoc()); |
| 1700 |
Record.AddStmt(S->getTryBlock()); |
| 1701 |
for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) |
| 1702 |
Record.AddStmt(S->getHandler(i)); |
| 1703 |
Code = serialization::STMT_CXX_TRY; |
| 1704 |
} |
| 1705 |
|
| 1706 |
void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) { |
| 1707 |
VisitStmt(S); |
| 1708 |
Record.AddSourceLocation(S->getForLoc()); |
| 1709 |
Record.AddSourceLocation(S->getCoawaitLoc()); |
| 1710 |
Record.AddSourceLocation(S->getColonLoc()); |
| 1711 |
Record.AddSourceLocation(S->getRParenLoc()); |
| 1712 |
Record.AddStmt(S->getInit()); |
| 1713 |
Record.AddStmt(S->getRangeStmt()); |
| 1714 |
Record.AddStmt(S->getBeginStmt()); |
| 1715 |
Record.AddStmt(S->getEndStmt()); |
| 1716 |
Record.AddStmt(S->getCond()); |
| 1717 |
Record.AddStmt(S->getInc()); |
| 1718 |
Record.AddStmt(S->getLoopVarStmt()); |
| 1719 |
Record.AddStmt(S->getBody()); |
| 1720 |
Code = serialization::STMT_CXX_FOR_RANGE; |
| 1721 |
} |
| 1722 |
|
| 1723 |
void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { |
| 1724 |
VisitStmt(S); |
| 1725 |
Record.AddSourceLocation(S->getKeywordLoc()); |
| 1726 |
Record.push_back(S->isIfExists()); |
| 1727 |
Record.AddNestedNameSpecifierLoc(S->getQualifierLoc()); |
| 1728 |
Record.AddDeclarationNameInfo(S->getNameInfo()); |
| 1729 |
Record.AddStmt(S->getSubStmt()); |
| 1730 |
Code = serialization::STMT_MS_DEPENDENT_EXISTS; |
| 1731 |
} |
| 1732 |
|
| 1733 |
void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
| 1734 |
VisitCallExpr(E); |
| 1735 |
Record.push_back(E->getOperator()); |
| 1736 |
Record.AddSourceLocation(E->BeginLoc); |
| 1737 |
|
| 1738 |
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()) && |
| 1739 |
!E->isCoroElideSafe() && !E->usesMemberSyntax()) |
| 1740 |
AbbrevToUse = Writer.getCXXOperatorCallExprAbbrev(); |
| 1741 |
|
| 1742 |
Code = serialization::EXPR_CXX_OPERATOR_CALL; |
| 1743 |
} |
| 1744 |
|
| 1745 |
void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { |
| 1746 |
VisitCallExpr(E); |
| 1747 |
|
| 1748 |
if (!E->hasStoredFPFeatures() && !static_cast<bool>(E->getADLCallKind()) && |
| 1749 |
!E->isCoroElideSafe() && !E->usesMemberSyntax()) |
| 1750 |
AbbrevToUse = Writer.getCXXMemberCallExprAbbrev(); |
| 1751 |
|
| 1752 |
Code = serialization::EXPR_CXX_MEMBER_CALL; |
| 1753 |
} |
| 1754 |
|
| 1755 |
void ASTStmtWriter::VisitCXXRewrittenBinaryOperator( |
| 1756 |
CXXRewrittenBinaryOperator *E) { |
| 1757 |
VisitExpr(E); |
| 1758 |
Record.push_back(E->isReversed()); |
| 1759 |
Record.AddStmt(E->getSemanticForm()); |
| 1760 |
Code = serialization::EXPR_CXX_REWRITTEN_BINARY_OPERATOR; |
| 1761 |
} |
| 1762 |
|
| 1763 |
void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) { |
| 1764 |
VisitExpr(E); |
| 1765 |
|
| 1766 |
Record.push_back(E->getNumArgs()); |
| 1767 |
Record.push_back(E->isElidable()); |
| 1768 |
Record.push_back(E->hadMultipleCandidates()); |
| 1769 |
Record.push_back(E->isListInitialization()); |
| 1770 |
Record.push_back(E->isStdInitListInitialization()); |
| 1771 |
Record.push_back(E->requiresZeroInitialization()); |
| 1772 |
Record.push_back( |
| 1773 |
llvm::to_underlying(E->getConstructionKind())); // FIXME: stable encoding |
| 1774 |
Record.push_back(E->isImmediateEscalating()); |
| 1775 |
Record.AddSourceLocation(E->getLocation()); |
| 1776 |
Record.AddDeclRef(E->getConstructor()); |
| 1777 |
Record.AddSourceRange(E->getParenOrBraceRange()); |
| 1778 |
|
| 1779 |
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 1780 |
Record.AddStmt(E->getArg(I)); |
| 1781 |
|
| 1782 |
Code = serialization::EXPR_CXX_CONSTRUCT; |
| 1783 |
} |
| 1784 |
|
| 1785 |
void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { |
| 1786 |
VisitExpr(E); |
| 1787 |
Record.AddDeclRef(E->getConstructor()); |
| 1788 |
Record.AddSourceLocation(E->getLocation()); |
| 1789 |
Record.push_back(E->constructsVBase()); |
| 1790 |
Record.push_back(E->inheritedFromVBase()); |
| 1791 |
Code = serialization::EXPR_CXX_INHERITED_CTOR_INIT; |
| 1792 |
} |
| 1793 |
|
| 1794 |
void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { |
| 1795 |
VisitCXXConstructExpr(E); |
| 1796 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 1797 |
Code = serialization::EXPR_CXX_TEMPORARY_OBJECT; |
| 1798 |
} |
| 1799 |
|
| 1800 |
void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) { |
| 1801 |
VisitExpr(E); |
| 1802 |
Record.push_back(E->LambdaExprBits.NumCaptures); |
| 1803 |
Record.AddSourceRange(E->IntroducerRange); |
| 1804 |
Record.push_back(E->LambdaExprBits.CaptureDefault); // FIXME: stable encoding |
| 1805 |
Record.AddSourceLocation(E->CaptureDefaultLoc); |
| 1806 |
Record.push_back(E->LambdaExprBits.ExplicitParams); |
| 1807 |
Record.push_back(E->LambdaExprBits.ExplicitResultType); |
| 1808 |
Record.AddSourceLocation(E->ClosingBrace); |
| 1809 |
|
| 1810 |
// Add capture initializers. |
| 1811 |
for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), |
| 1812 |
CEnd = E->capture_init_end(); |
| 1813 |
C != CEnd; ++C) { |
| 1814 |
Record.AddStmt(*C); |
| 1815 |
} |
| 1816 |
|
| 1817 |
// Don't serialize the body. It belongs to the call operator declaration. |
| 1818 |
// LambdaExpr only stores a copy of the Stmt *. |
| 1819 |
|
| 1820 |
Code = serialization::EXPR_LAMBDA; |
| 1821 |
} |
| 1822 |
|
| 1823 |
void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { |
| 1824 |
VisitExpr(E); |
| 1825 |
Record.AddStmt(E->getSubExpr()); |
| 1826 |
Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST; |
| 1827 |
} |
| 1828 |
|
| 1829 |
void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
| 1830 |
VisitExplicitCastExpr(E); |
| 1831 |
Record.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc())); |
| 1832 |
CurrentPackingBits.addBit(E->getAngleBrackets().isValid()); |
| 1833 |
if (E->getAngleBrackets().isValid()) |
| 1834 |
Record.AddSourceRange(E->getAngleBrackets()); |
| 1835 |
} |
| 1836 |
|
| 1837 |
void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
| 1838 |
VisitCXXNamedCastExpr(E); |
| 1839 |
Code = serialization::EXPR_CXX_STATIC_CAST; |
| 1840 |
} |
| 1841 |
|
| 1842 |
void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
| 1843 |
VisitCXXNamedCastExpr(E); |
| 1844 |
Code = serialization::EXPR_CXX_DYNAMIC_CAST; |
| 1845 |
} |
| 1846 |
|
| 1847 |
void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
| 1848 |
VisitCXXNamedCastExpr(E); |
| 1849 |
Code = serialization::EXPR_CXX_REINTERPRET_CAST; |
| 1850 |
} |
| 1851 |
|
| 1852 |
void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
| 1853 |
VisitCXXNamedCastExpr(E); |
| 1854 |
Code = serialization::EXPR_CXX_CONST_CAST; |
| 1855 |
} |
| 1856 |
|
| 1857 |
void ASTStmtWriter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) { |
| 1858 |
VisitCXXNamedCastExpr(E); |
| 1859 |
Code = serialization::EXPR_CXX_ADDRSPACE_CAST; |
| 1860 |
} |
| 1861 |
|
| 1862 |
void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
| 1863 |
VisitExplicitCastExpr(E); |
| 1864 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 1865 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1866 |
Code = serialization::EXPR_CXX_FUNCTIONAL_CAST; |
| 1867 |
} |
| 1868 |
|
| 1869 |
void ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) { |
| 1870 |
VisitExplicitCastExpr(E); |
| 1871 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 1872 |
Record.AddSourceLocation(E->getEndLoc()); |
| 1873 |
Code = serialization::EXPR_BUILTIN_BIT_CAST; |
| 1874 |
} |
| 1875 |
|
| 1876 |
void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) { |
| 1877 |
VisitCallExpr(E); |
| 1878 |
Record.AddSourceLocation(E->UDSuffixLoc); |
| 1879 |
Code = serialization::EXPR_USER_DEFINED_LITERAL; |
| 1880 |
} |
| 1881 |
|
| 1882 |
void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
| 1883 |
VisitExpr(E); |
| 1884 |
Record.push_back(E->getValue()); |
| 1885 |
Record.AddSourceLocation(E->getLocation()); |
| 1886 |
Code = serialization::EXPR_CXX_BOOL_LITERAL; |
| 1887 |
} |
| 1888 |
|
| 1889 |
void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
| 1890 |
VisitExpr(E); |
| 1891 |
Record.AddSourceLocation(E->getLocation()); |
| 1892 |
Code = serialization::EXPR_CXX_NULL_PTR_LITERAL; |
| 1893 |
} |
| 1894 |
|
| 1895 |
void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
| 1896 |
VisitExpr(E); |
| 1897 |
Record.AddSourceRange(E->getSourceRange()); |
| 1898 |
if (E->isTypeOperand()) { |
| 1899 |
Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo()); |
| 1900 |
Code = serialization::EXPR_CXX_TYPEID_TYPE; |
| 1901 |
} else { |
| 1902 |
Record.AddStmt(E->getExprOperand()); |
| 1903 |
Code = serialization::EXPR_CXX_TYPEID_EXPR; |
| 1904 |
} |
| 1905 |
} |
| 1906 |
|
| 1907 |
void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) { |
| 1908 |
VisitExpr(E); |
| 1909 |
Record.AddSourceLocation(E->getLocation()); |
| 1910 |
Record.push_back(E->isImplicit()); |
| 1911 |
Record.push_back(E->isCapturedByCopyInLambdaWithExplicitObjectParameter()); |
| 1912 |
|
| 1913 |
Code = serialization::EXPR_CXX_THIS; |
| 1914 |
} |
| 1915 |
|
| 1916 |
void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) { |
| 1917 |
VisitExpr(E); |
| 1918 |
Record.AddSourceLocation(E->getThrowLoc()); |
| 1919 |
Record.AddStmt(E->getSubExpr()); |
| 1920 |
Record.push_back(E->isThrownVariableInScope()); |
| 1921 |
Code = serialization::EXPR_CXX_THROW; |
| 1922 |
} |
| 1923 |
|
| 1924 |
void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
| 1925 |
VisitExpr(E); |
| 1926 |
Record.AddDeclRef(E->getParam()); |
| 1927 |
Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext())); |
| 1928 |
Record.AddSourceLocation(E->getUsedLocation()); |
| 1929 |
Record.push_back(E->hasRewrittenInit()); |
| 1930 |
if (E->hasRewrittenInit()) |
| 1931 |
Record.AddStmt(E->getRewrittenExpr()); |
| 1932 |
Code = serialization::EXPR_CXX_DEFAULT_ARG; |
| 1933 |
} |
| 1934 |
|
| 1935 |
void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { |
| 1936 |
VisitExpr(E); |
| 1937 |
Record.push_back(E->hasRewrittenInit()); |
| 1938 |
Record.AddDeclRef(E->getField()); |
| 1939 |
Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext())); |
| 1940 |
Record.AddSourceLocation(E->getExprLoc()); |
| 1941 |
if (E->hasRewrittenInit()) |
| 1942 |
Record.AddStmt(E->getRewrittenExpr()); |
| 1943 |
Code = serialization::EXPR_CXX_DEFAULT_INIT; |
| 1944 |
} |
| 1945 |
|
| 1946 |
void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
| 1947 |
VisitExpr(E); |
| 1948 |
Record.AddCXXTemporary(E->getTemporary()); |
| 1949 |
Record.AddStmt(E->getSubExpr()); |
| 1950 |
Code = serialization::EXPR_CXX_BIND_TEMPORARY; |
| 1951 |
} |
| 1952 |
|
| 1953 |
void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { |
| 1954 |
VisitExpr(E); |
| 1955 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 1956 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 1957 |
Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT; |
| 1958 |
} |
| 1959 |
|
| 1960 |
void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) { |
| 1961 |
VisitExpr(E); |
| 1962 |
|
| 1963 |
Record.push_back(E->isArray()); |
| 1964 |
Record.push_back(E->hasInitializer()); |
| 1965 |
Record.push_back(E->getNumPlacementArgs()); |
| 1966 |
Record.push_back(E->isParenTypeId()); |
| 1967 |
|
| 1968 |
Record.push_back(E->isGlobalNew()); |
| 1969 |
ImplicitAllocationParameters IAP = E->implicitAllocationParameters(); |
| 1970 |
Record.push_back(isAlignedAllocation(IAP.PassAlignment)); |
| 1971 |
Record.push_back(isTypeAwareAllocation(IAP.PassTypeIdentity)); |
| 1972 |
Record.push_back(E->doesUsualArrayDeleteWantSize()); |
| 1973 |
Record.push_back(E->CXXNewExprBits.HasInitializer); |
| 1974 |
Record.push_back(E->CXXNewExprBits.StoredInitializationStyle); |
| 1975 |
|
| 1976 |
Record.AddDeclRef(E->getOperatorNew()); |
| 1977 |
Record.AddDeclRef(E->getOperatorDelete()); |
| 1978 |
Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo()); |
| 1979 |
if (E->isParenTypeId()) |
| 1980 |
Record.AddSourceRange(E->getTypeIdParens()); |
| 1981 |
Record.AddSourceRange(E->getSourceRange()); |
| 1982 |
Record.AddSourceRange(E->getDirectInitRange()); |
| 1983 |
|
| 1984 |
for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), N = E->raw_arg_end(); |
| 1985 |
I != N; ++I) |
| 1986 |
Record.AddStmt(*I); |
| 1987 |
|
| 1988 |
Code = serialization::EXPR_CXX_NEW; |
| 1989 |
} |
| 1990 |
|
| 1991 |
void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
| 1992 |
VisitExpr(E); |
| 1993 |
Record.push_back(E->isGlobalDelete()); |
| 1994 |
Record.push_back(E->isArrayForm()); |
| 1995 |
Record.push_back(E->isArrayFormAsWritten()); |
| 1996 |
Record.push_back(E->doesUsualArrayDeleteWantSize()); |
| 1997 |
Record.AddDeclRef(E->getOperatorDelete()); |
| 1998 |
Record.AddStmt(E->getArgument()); |
| 1999 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 2000 |
|
| 2001 |
Code = serialization::EXPR_CXX_DELETE; |
| 2002 |
} |
| 2003 |
|
| 2004 |
void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { |
| 2005 |
VisitExpr(E); |
| 2006 |
|
| 2007 |
Record.AddStmt(E->getBase()); |
| 2008 |
Record.push_back(E->isArrow()); |
| 2009 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 2010 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 2011 |
Record.AddTypeSourceInfo(E->getScopeTypeInfo()); |
| 2012 |
Record.AddSourceLocation(E->getColonColonLoc()); |
| 2013 |
Record.AddSourceLocation(E->getTildeLoc()); |
| 2014 |
|
| 2015 |
// PseudoDestructorTypeStorage. |
| 2016 |
Record.AddIdentifierRef(E->getDestroyedTypeIdentifier()); |
| 2017 |
if (E->getDestroyedTypeIdentifier()) |
| 2018 |
Record.AddSourceLocation(E->getDestroyedTypeLoc()); |
| 2019 |
else |
| 2020 |
Record.AddTypeSourceInfo(E->getDestroyedTypeInfo()); |
| 2021 |
|
| 2022 |
Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR; |
| 2023 |
} |
| 2024 |
|
| 2025 |
void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) { |
| 2026 |
VisitExpr(E); |
| 2027 |
Record.push_back(E->getNumObjects()); |
| 2028 |
for (auto &Obj : E->getObjects()) { |
| 2029 |
if (auto *BD = Obj.dyn_cast<BlockDecl *>()) { |
| 2030 |
Record.push_back(serialization::COK_Block); |
| 2031 |
Record.AddDeclRef(BD); |
| 2032 |
} else if (auto *CLE = Obj.dyn_cast<CompoundLiteralExpr *>()) { |
| 2033 |
Record.push_back(serialization::COK_CompoundLiteral); |
| 2034 |
Record.AddStmt(CLE); |
| 2035 |
} |
| 2036 |
} |
| 2037 |
|
| 2038 |
Record.push_back(E->cleanupsHaveSideEffects()); |
| 2039 |
Record.AddStmt(E->getSubExpr()); |
| 2040 |
Code = serialization::EXPR_EXPR_WITH_CLEANUPS; |
| 2041 |
} |
| 2042 |
|
| 2043 |
void ASTStmtWriter::VisitCXXDependentScopeMemberExpr( |
| 2044 |
CXXDependentScopeMemberExpr *E) { |
| 2045 |
VisitExpr(E); |
| 2046 |
|
| 2047 |
// Don't emit anything here (or if you do you will have to update |
| 2048 |
// the corresponding deserialization function). |
| 2049 |
Record.push_back(E->getNumTemplateArgs()); |
| 2050 |
CurrentPackingBits.updateBits(); |
| 2051 |
CurrentPackingBits.addBit(E->hasTemplateKWAndArgsInfo()); |
| 2052 |
CurrentPackingBits.addBit(E->hasFirstQualifierFoundInScope()); |
| 2053 |
|
| 2054 |
if (E->hasTemplateKWAndArgsInfo()) { |
| 2055 |
const ASTTemplateKWAndArgsInfo &ArgInfo = |
| 2056 |
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(); |
| 2057 |
AddTemplateKWAndArgsInfo(ArgInfo, |
| 2058 |
E->getTrailingObjects<TemplateArgumentLoc>()); |
| 2059 |
} |
| 2060 |
|
| 2061 |
CurrentPackingBits.addBit(E->isArrow()); |
| 2062 |
|
| 2063 |
Record.AddTypeRef(E->getBaseType()); |
| 2064 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 2065 |
CurrentPackingBits.addBit(!E->isImplicitAccess()); |
| 2066 |
if (!E->isImplicitAccess()) |
| 2067 |
Record.AddStmt(E->getBase()); |
| 2068 |
|
| 2069 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 2070 |
|
| 2071 |
if (E->hasFirstQualifierFoundInScope()) |
| 2072 |
Record.AddDeclRef(E->getFirstQualifierFoundInScope()); |
| 2073 |
|
| 2074 |
Record.AddDeclarationNameInfo(E->MemberNameInfo); |
| 2075 |
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER; |
| 2076 |
} |
| 2077 |
|
| 2078 |
void |
| 2079 |
ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { |
| 2080 |
VisitExpr(E); |
| 2081 |
|
| 2082 |
// Don't emit anything here, HasTemplateKWAndArgsInfo must be |
| 2083 |
// emitted first. |
| 2084 |
CurrentPackingBits.addBit( |
| 2085 |
E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo); |
| 2086 |
|
| 2087 |
if (E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo) { |
| 2088 |
const ASTTemplateKWAndArgsInfo &ArgInfo = |
| 2089 |
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(); |
| 2090 |
// 16 bits should be enought to store the number of args |
| 2091 |
CurrentPackingBits.addBits(ArgInfo.NumTemplateArgs, /*Width=*/16); |
| 2092 |
AddTemplateKWAndArgsInfo(ArgInfo, |
| 2093 |
E->getTrailingObjects<TemplateArgumentLoc>()); |
| 2094 |
} |
| 2095 |
|
| 2096 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 2097 |
Record.AddDeclarationNameInfo(E->NameInfo); |
| 2098 |
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF; |
| 2099 |
} |
| 2100 |
|
| 2101 |
void |
| 2102 |
ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { |
| 2103 |
VisitExpr(E); |
| 2104 |
Record.push_back(E->getNumArgs()); |
| 2105 |
for (CXXUnresolvedConstructExpr::arg_iterator |
| 2106 |
ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI) |
| 2107 |
Record.AddStmt(*ArgI); |
| 2108 |
Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
| 2109 |
Record.AddSourceLocation(E->getLParenLoc()); |
| 2110 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 2111 |
Record.push_back(E->isListInitialization()); |
| 2112 |
Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT; |
| 2113 |
} |
| 2114 |
|
| 2115 |
void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) { |
| 2116 |
VisitExpr(E); |
| 2117 |
|
| 2118 |
Record.push_back(E->getNumDecls()); |
| 2119 |
|
| 2120 |
CurrentPackingBits.updateBits(); |
| 2121 |
CurrentPackingBits.addBit(E->hasTemplateKWAndArgsInfo()); |
| 2122 |
if (E->hasTemplateKWAndArgsInfo()) { |
| 2123 |
const ASTTemplateKWAndArgsInfo &ArgInfo = |
| 2124 |
*E->getTrailingASTTemplateKWAndArgsInfo(); |
| 2125 |
Record.push_back(ArgInfo.NumTemplateArgs); |
| 2126 |
AddTemplateKWAndArgsInfo(ArgInfo, E->getTrailingTemplateArgumentLoc()); |
| 2127 |
} |
| 2128 |
|
| 2129 |
for (OverloadExpr::decls_iterator OvI = E->decls_begin(), |
| 2130 |
OvE = E->decls_end(); |
| 2131 |
OvI != OvE; ++OvI) { |
| 2132 |
Record.AddDeclRef(OvI.getDecl()); |
| 2133 |
Record.push_back(OvI.getAccess()); |
| 2134 |
} |
| 2135 |
|
| 2136 |
Record.AddDeclarationNameInfo(E->getNameInfo()); |
| 2137 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 2138 |
} |
| 2139 |
|
| 2140 |
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { |
| 2141 |
VisitOverloadExpr(E); |
| 2142 |
CurrentPackingBits.addBit(E->isArrow()); |
| 2143 |
CurrentPackingBits.addBit(E->hasUnresolvedUsing()); |
| 2144 |
CurrentPackingBits.addBit(!E->isImplicitAccess()); |
| 2145 |
if (!E->isImplicitAccess()) |
| 2146 |
Record.AddStmt(E->getBase()); |
| 2147 |
|
| 2148 |
Record.AddSourceLocation(E->getOperatorLoc()); |
| 2149 |
|
| 2150 |
Record.AddTypeRef(E->getBaseType()); |
| 2151 |
Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER; |
| 2152 |
} |
| 2153 |
|
| 2154 |
void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { |
| 2155 |
VisitOverloadExpr(E); |
| 2156 |
CurrentPackingBits.addBit(E->requiresADL()); |
| 2157 |
Record.AddDeclRef(E->getNamingClass()); |
| 2158 |
Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP; |
| 2159 |
|
| 2160 |
if (Writer.isWritingStdCXXNamedModules() && Writer.getChain()) { |
| 2161 |
// Referencing all the possible declarations to make sure the change get |
| 2162 |
// propagted. |
| 2163 |
DeclarationName Name = E->getName(); |
| 2164 |
for (auto *Found : |
| 2165 |
Record.getASTContext().getTranslationUnitDecl()->lookup(Name)) |
| 2166 |
if (Found->isFromASTFile()) |
| 2167 |
Writer.GetDeclRef(Found); |
| 2168 |
|
| 2169 |
llvm::SmallVector<NamespaceDecl *> ExternalNSs; |
| 2170 |
Writer.getChain()->ReadKnownNamespaces(ExternalNSs); |
| 2171 |
for (auto *NS : ExternalNSs) |
| 2172 |
for (auto *Found : NS->lookup(Name)) |
| 2173 |
Writer.GetDeclRef(Found); |
| 2174 |
} |
| 2175 |
} |
| 2176 |
|
| 2177 |
void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) { |
| 2178 |
VisitExpr(E); |
| 2179 |
Record.push_back(E->TypeTraitExprBits.IsBooleanTypeTrait); |
| 2180 |
Record.push_back(E->TypeTraitExprBits.NumArgs); |
| 2181 |
Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding |
| 2182 |
|
| 2183 |
if (E->TypeTraitExprBits.IsBooleanTypeTrait) |
| 2184 |
Record.push_back(E->TypeTraitExprBits.Value); |
| 2185 |
else |
| 2186 |
Record.AddAPValue(E->getAPValue()); |
| 2187 |
|
| 2188 |
Record.AddSourceRange(E->getSourceRange()); |
| 2189 |
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) |
| 2190 |
Record.AddTypeSourceInfo(E->getArg(I)); |
| 2191 |
Code = serialization::EXPR_TYPE_TRAIT; |
| 2192 |
} |
| 2193 |
|
| 2194 |
void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { |
| 2195 |
VisitExpr(E); |
| 2196 |
Record.push_back(E->getTrait()); |
| 2197 |
Record.push_back(E->getValue()); |
| 2198 |
Record.AddSourceRange(E->getSourceRange()); |
| 2199 |
Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo()); |
| 2200 |
Record.AddStmt(E->getDimensionExpression()); |
| 2201 |
Code = serialization::EXPR_ARRAY_TYPE_TRAIT; |
| 2202 |
} |
| 2203 |
|
| 2204 |
void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { |
| 2205 |
VisitExpr(E); |
| 2206 |
Record.push_back(E->getTrait()); |
| 2207 |
Record.push_back(E->getValue()); |
| 2208 |
Record.AddSourceRange(E->getSourceRange()); |
| 2209 |
Record.AddStmt(E->getQueriedExpression()); |
| 2210 |
Code = serialization::EXPR_CXX_EXPRESSION_TRAIT; |
| 2211 |
} |
| 2212 |
|
| 2213 |
void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { |
| 2214 |
VisitExpr(E); |
| 2215 |
Record.push_back(E->getValue()); |
| 2216 |
Record.AddSourceRange(E->getSourceRange()); |
| 2217 |
Record.AddStmt(E->getOperand()); |
| 2218 |
Code = serialization::EXPR_CXX_NOEXCEPT; |
| 2219 |
} |
| 2220 |
|
| 2221 |
void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) { |
| 2222 |
VisitExpr(E); |
| 2223 |
Record.AddSourceLocation(E->getEllipsisLoc()); |
| 2224 |
Record.push_back(E->NumExpansions); |
| 2225 |
Record.AddStmt(E->getPattern()); |
| 2226 |
Code = serialization::EXPR_PACK_EXPANSION; |
| 2227 |
} |
| 2228 |
|
| 2229 |
void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) { |
| 2230 |
VisitExpr(E); |
| 2231 |
Record.push_back(E->isPartiallySubstituted() ? E->getPartialArguments().size() |
| 2232 |
: 0); |
| 2233 |
Record.AddSourceLocation(E->OperatorLoc); |
| 2234 |
Record.AddSourceLocation(E->PackLoc); |
| 2235 |
Record.AddSourceLocation(E->RParenLoc); |
| 2236 |
Record.AddDeclRef(E->Pack); |
| 2237 |
if (E->isPartiallySubstituted()) { |
| 2238 |
for (const auto &TA : E->getPartialArguments()) |
| 2239 |
Record.AddTemplateArgument(TA); |
| 2240 |
} else if (!E->isValueDependent()) { |
| 2241 |
Record.push_back(E->getPackLength()); |
| 2242 |
} |
| 2243 |
Code = serialization::EXPR_SIZEOF_PACK; |
| 2244 |
} |
| 2245 |
|
| 2246 |
void ASTStmtWriter::VisitPackIndexingExpr(PackIndexingExpr *E) { |
| 2247 |
VisitExpr(E); |
| 2248 |
Record.push_back(E->PackIndexingExprBits.TransformedExpressions); |
| 2249 |
Record.push_back(E->PackIndexingExprBits.FullySubstituted); |
| 2250 |
Record.AddSourceLocation(E->getEllipsisLoc()); |
| 2251 |
Record.AddSourceLocation(E->getRSquareLoc()); |
| 2252 |
Record.AddStmt(E->getPackIdExpression()); |
| 2253 |
Record.AddStmt(E->getIndexExpr()); |
| 2254 |
for (Expr *Sub : E->getExpressions()) |
| 2255 |
Record.AddStmt(Sub); |
| 2256 |
Code = serialization::EXPR_PACK_INDEXING; |
| 2257 |
} |
| 2258 |
|
| 2259 |
void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr( |
| 2260 |
SubstNonTypeTemplateParmExpr *E) { |
| 2261 |
VisitExpr(E); |
| 2262 |
Record.AddDeclRef(E->getAssociatedDecl()); |
| 2263 |
CurrentPackingBits.addBit(E->isReferenceParameter()); |
| 2264 |
CurrentPackingBits.addBits(E->getIndex(), /*Width=*/12); |
| 2265 |
Record.writeUnsignedOrNone(E->getPackIndex()); |
| 2266 |
CurrentPackingBits.addBit(E->getFinal()); |
| 2267 |
|
| 2268 |
Record.AddSourceLocation(E->getNameLoc()); |
| 2269 |
Record.AddStmt(E->getReplacement()); |
| 2270 |
Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM; |
| 2271 |
} |
| 2272 |
|
| 2273 |
void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr( |
| 2274 |
SubstNonTypeTemplateParmPackExpr *E) { |
| 2275 |
VisitExpr(E); |
| 2276 |
Record.AddDeclRef(E->getAssociatedDecl()); |
| 2277 |
CurrentPackingBits.addBit(E->getFinal()); |
| 2278 |
Record.push_back(E->getIndex()); |
| 2279 |
Record.AddTemplateArgument(E->getArgumentPack()); |
| 2280 |
Record.AddSourceLocation(E->getParameterPackLocation()); |
| 2281 |
Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK; |
| 2282 |
} |
| 2283 |
|
| 2284 |
void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { |
| 2285 |
VisitExpr(E); |
| 2286 |
Record.push_back(E->getNumExpansions()); |
| 2287 |
Record.AddDeclRef(E->getParameterPack()); |
| 2288 |
Record.AddSourceLocation(E->getParameterPackLocation()); |
| 2289 |
for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end(); |
| 2290 |
I != End; ++I) |
| 2291 |
Record.AddDeclRef(*I); |
| 2292 |
Code = serialization::EXPR_FUNCTION_PARM_PACK; |
| 2293 |
} |
| 2294 |
|
| 2295 |
void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { |
| 2296 |
VisitExpr(E); |
| 2297 |
Record.push_back(static_cast<bool>(E->getLifetimeExtendedTemporaryDecl())); |
| 2298 |
if (E->getLifetimeExtendedTemporaryDecl()) |
| 2299 |
Record.AddDeclRef(E->getLifetimeExtendedTemporaryDecl()); |
| 2300 |
else |
| 2301 |
Record.AddStmt(E->getSubExpr()); |
| 2302 |
Code = serialization::EXPR_MATERIALIZE_TEMPORARY; |
| 2303 |
} |
| 2304 |
|
| 2305 |
void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) { |
| 2306 |
VisitExpr(E); |
| 2307 |
Record.AddSourceLocation(E->LParenLoc); |
| 2308 |
Record.AddSourceLocation(E->EllipsisLoc); |
| 2309 |
Record.AddSourceLocation(E->RParenLoc); |
| 2310 |
Record.push_back(E->NumExpansions.toInternalRepresentation()); |
| 2311 |
Record.AddStmt(E->SubExprs[0]); |
| 2312 |
Record.AddStmt(E->SubExprs[1]); |
| 2313 |
Record.AddStmt(E->SubExprs[2]); |
| 2314 |
Record.push_back(E->CXXFoldExprBits.Opcode); |
| 2315 |
Code = serialization::EXPR_CXX_FOLD; |
| 2316 |
} |
| 2317 |
|
| 2318 |
void ASTStmtWriter::VisitCXXParenListInitExpr(CXXParenListInitExpr *E) { |
| 2319 |
VisitExpr(E); |
| 2320 |
ArrayRef<Expr *> InitExprs = E->getInitExprs(); |
| 2321 |
Record.push_back(InitExprs.size()); |
| 2322 |
Record.push_back(E->getUserSpecifiedInitExprs().size()); |
| 2323 |
Record.AddSourceLocation(E->getInitLoc()); |
| 2324 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 2325 |
Record.AddSourceLocation(E->getEndLoc()); |
| 2326 |
for (Expr *InitExpr : E->getInitExprs()) |
| 2327 |
Record.AddStmt(InitExpr); |
| 2328 |
Expr *ArrayFiller = E->getArrayFiller(); |
| 2329 |
FieldDecl *UnionField = E->getInitializedFieldInUnion(); |
| 2330 |
bool HasArrayFillerOrUnionDecl = ArrayFiller || UnionField; |
| 2331 |
Record.push_back(HasArrayFillerOrUnionDecl); |
| 2332 |
if (HasArrayFillerOrUnionDecl) { |
| 2333 |
Record.push_back(static_cast<bool>(ArrayFiller)); |
| 2334 |
if (ArrayFiller) |
| 2335 |
Record.AddStmt(ArrayFiller); |
| 2336 |
else |
| 2337 |
Record.AddDeclRef(UnionField); |
| 2338 |
} |
| 2339 |
Code = serialization::EXPR_CXX_PAREN_LIST_INIT; |
| 2340 |
} |
| 2341 |
|
| 2342 |
void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) { |
| 2343 |
VisitExpr(E); |
| 2344 |
Record.AddStmt(E->getSourceExpr()); |
| 2345 |
Record.AddSourceLocation(E->getLocation()); |
| 2346 |
Record.push_back(E->isUnique()); |
| 2347 |
Code = serialization::EXPR_OPAQUE_VALUE; |
| 2348 |
} |
| 2349 |
|
| 2350 |
//===----------------------------------------------------------------------===// |
| 2351 |
// CUDA Expressions and Statements. |
| 2352 |
//===----------------------------------------------------------------------===// |
| 2353 |
|
| 2354 |
void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { |
| 2355 |
VisitCallExpr(E); |
| 2356 |
Record.AddStmt(E->getConfig()); |
| 2357 |
Code = serialization::EXPR_CUDA_KERNEL_CALL; |
| 2358 |
} |
| 2359 |
|
| 2360 |
//===----------------------------------------------------------------------===// |
| 2361 |
// OpenCL Expressions and Statements. |
| 2362 |
//===----------------------------------------------------------------------===// |
| 2363 |
void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) { |
| 2364 |
VisitExpr(E); |
| 2365 |
Record.AddSourceLocation(E->getBuiltinLoc()); |
| 2366 |
Record.AddSourceLocation(E->getRParenLoc()); |
| 2367 |
Record.AddStmt(E->getSrcExpr()); |
| 2368 |
Code = serialization::EXPR_ASTYPE; |
| 2369 |
} |
| 2370 |
|
| 2371 |
//===----------------------------------------------------------------------===// |
| 2372 |
// Microsoft Expressions and Statements. |
| 2373 |
//===----------------------------------------------------------------------===// |
| 2374 |
void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { |
| 2375 |
VisitExpr(E); |
| 2376 |
Record.push_back(E->isArrow()); |
| 2377 |
Record.AddStmt(E->getBaseExpr()); |
| 2378 |
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
| 2379 |
Record.AddSourceLocation(E->getMemberLoc()); |
| 2380 |
Record.AddDeclRef(E->getPropertyDecl()); |
| 2381 |
Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR; |
| 2382 |
} |
| 2383 |
|
| 2384 |
void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { |
| 2385 |
VisitExpr(E); |
| 2386 |
Record.AddStmt(E->getBase()); |
| 2387 |
Record.AddStmt(E->getIdx()); |
| 2388 |
Record.AddSourceLocation(E->getRBracketLoc()); |
| 2389 |
Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR; |
| 2390 |
} |
| 2391 |
|
| 2392 |
void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) { |
| 2393 |
VisitExpr(E); |
| 2394 |
Record.AddSourceRange(E->getSourceRange()); |
| 2395 |
Record.AddDeclRef(E->getGuidDecl()); |
| 2396 |
if (E->isTypeOperand()) { |
| 2397 |
Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo()); |
| 2398 |
Code = serialization::EXPR_CXX_UUIDOF_TYPE; |
| 2399 |
} else { |
| 2400 |
Record.AddStmt(E->getExprOperand()); |
| 2401 |
Code = serialization::EXPR_CXX_UUIDOF_EXPR; |
| 2402 |
} |
| 2403 |
} |
| 2404 |
|
| 2405 |
void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) { |
| 2406 |
VisitStmt(S); |
| 2407 |
Record.AddSourceLocation(S->getExceptLoc()); |
| 2408 |
Record.AddStmt(S->getFilterExpr()); |
| 2409 |
Record.AddStmt(S->getBlock()); |
| 2410 |
Code = serialization::STMT_SEH_EXCEPT; |
| 2411 |
} |
| 2412 |
|
| 2413 |
void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) { |
| 2414 |
VisitStmt(S); |
| 2415 |
Record.AddSourceLocation(S->getFinallyLoc()); |
| 2416 |
Record.AddStmt(S->getBlock()); |
| 2417 |
Code = serialization::STMT_SEH_FINALLY; |
| 2418 |
} |
| 2419 |
|
| 2420 |
void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) { |
| 2421 |
VisitStmt(S); |
| 2422 |
Record.push_back(S->getIsCXXTry()); |
| 2423 |
Record.AddSourceLocation(S->getTryLoc()); |
| 2424 |
Record.AddStmt(S->getTryBlock()); |
| 2425 |
Record.AddStmt(S->getHandler()); |
| 2426 |
Code = serialization::STMT_SEH_TRY; |
| 2427 |
} |
| 2428 |
|
| 2429 |
void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) { |
| 2430 |
VisitStmt(S); |
| 2431 |
Record.AddSourceLocation(S->getLeaveLoc()); |
| 2432 |
Code = serialization::STMT_SEH_LEAVE; |
| 2433 |
} |
| 2434 |
|
| 2435 |
//===----------------------------------------------------------------------===// |
| 2436 |
// OpenMP Directives. |
| 2437 |
//===----------------------------------------------------------------------===// |
| 2438 |
|
| 2439 |
void ASTStmtWriter::VisitOMPCanonicalLoop(OMPCanonicalLoop *S) { |
| 2440 |
VisitStmt(S); |
| 2441 |
for (Stmt *SubStmt : S->SubStmts) |
| 2442 |
Record.AddStmt(SubStmt); |
| 2443 |
Code = serialization::STMT_OMP_CANONICAL_LOOP; |
| 2444 |
} |
| 2445 |
|
| 2446 |
void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) { |
| 2447 |
Record.writeOMPChildren(E->Data); |
| 2448 |
Record.AddSourceLocation(E->getBeginLoc()); |
| 2449 |
Record.AddSourceLocation(E->getEndLoc()); |
| 2450 |
} |
| 2451 |
|
| 2452 |
void ASTStmtWriter::VisitOMPLoopBasedDirective(OMPLoopBasedDirective *D) { |
| 2453 |
VisitStmt(D); |
| 2454 |
Record.writeUInt32(D->getLoopsNumber()); |
| 2455 |
VisitOMPExecutableDirective(D); |
| 2456 |
} |
| 2457 |
|
| 2458 |
void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) { |
| 2459 |
VisitOMPLoopBasedDirective(D); |
| 2460 |
} |
| 2461 |
|
| 2462 |
void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective *D) { |
| 2463 |
VisitStmt(D); |
| 2464 |
Record.push_back(D->getNumClauses()); |
| 2465 |
VisitOMPExecutableDirective(D); |
| 2466 |
Code = serialization::STMT_OMP_META_DIRECTIVE; |
| 2467 |
} |
| 2468 |
|
| 2469 |
void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) { |
| 2470 |
VisitStmt(D); |
| 2471 |
VisitOMPExecutableDirective(D); |
| 2472 |
Record.writeBool(D->hasCancel()); |
| 2473 |
Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE; |
| 2474 |
} |
| 2475 |
|
| 2476 |
void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) { |
| 2477 |
VisitOMPLoopDirective(D); |
| 2478 |
Code = serialization::STMT_OMP_SIMD_DIRECTIVE; |
| 2479 |
} |
| 2480 |
|
| 2481 |
void ASTStmtWriter::VisitOMPCanonicalLoopNestTransformationDirective( |
| 2482 |
OMPCanonicalLoopNestTransformationDirective *D) { |
| 2483 |
VisitOMPLoopBasedDirective(D); |
| 2484 |
Record.writeUInt32(D->getNumGeneratedTopLevelLoops()); |
| 2485 |
} |
| 2486 |
|
| 2487 |
void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) { |
| 2488 |
VisitOMPCanonicalLoopNestTransformationDirective(D); |
| 2489 |
Code = serialization::STMT_OMP_TILE_DIRECTIVE; |
| 2490 |
} |
| 2491 |
|
| 2492 |
void ASTStmtWriter::VisitOMPStripeDirective(OMPStripeDirective *D) { |
| 2493 |
VisitOMPCanonicalLoopNestTransformationDirective(D); |
| 2494 |
Code = serialization::STMP_OMP_STRIPE_DIRECTIVE; |
| 2495 |
} |
| 2496 |
|
| 2497 |
void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective *D) { |
| 2498 |
VisitOMPCanonicalLoopNestTransformationDirective(D); |
| 2499 |
Code = serialization::STMT_OMP_UNROLL_DIRECTIVE; |
| 2500 |
} |
| 2501 |
|
| 2502 |
void ASTStmtWriter::VisitOMPReverseDirective(OMPReverseDirective *D) { |
| 2503 |
VisitOMPCanonicalLoopNestTransformationDirective(D); |
| 2504 |
Code = serialization::STMT_OMP_REVERSE_DIRECTIVE; |
| 2505 |
} |
| 2506 |
|
| 2507 |
void ASTStmtWriter::VisitOMPInterchangeDirective(OMPInterchangeDirective *D) { |
| 2508 |
VisitOMPCanonicalLoopNestTransformationDirective(D); |
| 2509 |
Code = serialization::STMT_OMP_INTERCHANGE_DIRECTIVE; |
| 2510 |
} |
| 2511 |
|
| 2512 |
void ASTStmtWriter::VisitOMPCanonicalLoopSequenceTransformationDirective( |
| 2513 |
OMPCanonicalLoopSequenceTransformationDirective *D) { |
| 2514 |
VisitStmt(D); |
| 2515 |
VisitOMPExecutableDirective(D); |
| 2516 |
Record.writeUInt32(D->getNumGeneratedTopLevelLoops()); |
| 2517 |
} |
| 2518 |
|
| 2519 |
void ASTStmtWriter::VisitOMPFuseDirective(OMPFuseDirective *D) { |
| 2520 |
VisitOMPCanonicalLoopSequenceTransformationDirective(D); |
| 2521 |
Code = serialization::STMT_OMP_FUSE_DIRECTIVE; |
| 2522 |
} |
| 2523 |
|
| 2524 |
void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) { |
| 2525 |
VisitOMPLoopDirective(D); |
| 2526 |
Record.writeBool(D->hasCancel()); |
| 2527 |
Code = serialization::STMT_OMP_FOR_DIRECTIVE; |
| 2528 |
} |
| 2529 |
|
| 2530 |
void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective *D) { |
| 2531 |
VisitOMPLoopDirective(D); |
| 2532 |
Code = serialization::STMT_OMP_FOR_SIMD_DIRECTIVE; |
| 2533 |
} |
| 2534 |
|
| 2535 |
void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) { |
| 2536 |
VisitStmt(D); |
| 2537 |
VisitOMPExecutableDirective(D); |
| 2538 |
Record.writeBool(D->hasCancel()); |
| 2539 |
Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE; |
| 2540 |
} |
| 2541 |
|
| 2542 |
void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) { |
| 2543 |
VisitStmt(D); |
| 2544 |
VisitOMPExecutableDirective(D); |
| 2545 |
Record.writeBool(D->hasCancel()); |
| 2546 |
Code = serialization::STMT_OMP_SECTION_DIRECTIVE; |
| 2547 |
} |
| 2548 |
|
| 2549 |
void ASTStmtWriter::VisitOMPScopeDirective(OMPScopeDirective *D) { |
| 2550 |
VisitStmt(D); |
| 2551 |
VisitOMPExecutableDirective(D); |
| 2552 |
Code = serialization::STMT_OMP_SCOPE_DIRECTIVE; |
| 2553 |
} |
| 2554 |
|
| 2555 |
void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) { |
| 2556 |
VisitStmt(D); |
| 2557 |
VisitOMPExecutableDirective(D); |
| 2558 |
Code = serialization::STMT_OMP_SINGLE_DIRECTIVE; |
| 2559 |
} |
| 2560 |
|
| 2561 |
void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective *D) { |
| 2562 |
VisitStmt(D); |
| 2563 |
VisitOMPExecutableDirective(D); |
| 2564 |
Code = serialization::STMT_OMP_MASTER_DIRECTIVE; |
| 2565 |
} |
| 2566 |
|
| 2567 |
void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) { |
| 2568 |
VisitStmt(D); |
| 2569 |
VisitOMPExecutableDirective(D); |
| 2570 |
Record.AddDeclarationNameInfo(D->getDirectiveName()); |
| 2571 |
Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE; |
| 2572 |
} |
| 2573 |
|
| 2574 |
void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) { |
| 2575 |
VisitOMPLoopDirective(D); |
| 2576 |
Record.writeBool(D->hasCancel()); |
| 2577 |
Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE; |
| 2578 |
} |
| 2579 |
|
| 2580 |
void ASTStmtWriter::VisitOMPParallelForSimdDirective( |
| 2581 |
OMPParallelForSimdDirective *D) { |
| 2582 |
VisitOMPLoopDirective(D); |
| 2583 |
Code = serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE; |
| 2584 |
} |
| 2585 |
|
| 2586 |
void ASTStmtWriter::VisitOMPParallelMasterDirective( |
| 2587 |
OMPParallelMasterDirective *D) { |
| 2588 |
VisitStmt(D); |
| 2589 |
VisitOMPExecutableDirective(D); |
| 2590 |
Code = serialization::STMT_OMP_PARALLEL_MASTER_DIRECTIVE; |
| 2591 |
} |
| 2592 |
|
| 2593 |
void ASTStmtWriter::VisitOMPParallelMaskedDirective( |
| 2594 |
OMPParallelMaskedDirective *D) { |
| 2595 |
VisitStmt(D); |
| 2596 |
VisitOMPExecutableDirective(D); |
| 2597 |
Code = serialization::STMT_OMP_PARALLEL_MASKED_DIRECTIVE; |
| 2598 |
} |
| 2599 |
|
| 2600 |
void ASTStmtWriter::VisitOMPParallelSectionsDirective( |
| 2601 |
OMPParallelSectionsDirective *D) { |
| 2602 |
VisitStmt(D); |
| 2603 |
VisitOMPExecutableDirective(D); |
| 2604 |
Record.writeBool(D->hasCancel()); |
| 2605 |
Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE; |
| 2606 |
} |
| 2607 |
|
| 2608 |
void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) { |
| 2609 |
VisitStmt(D); |
| 2610 |
VisitOMPExecutableDirective(D); |
| 2611 |
Record.writeBool(D->hasCancel()); |
| 2612 |
Code = serialization::STMT_OMP_TASK_DIRECTIVE; |
| 2613 |
} |
| 2614 |
|
| 2615 |
void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) { |
| 2616 |
VisitStmt(D); |
| 2617 |
VisitOMPExecutableDirective(D); |
| 2618 |
Record.writeBool(D->isXLHSInRHSPart()); |
| 2619 |
Record.writeBool(D->isPostfixUpdate()); |
| 2620 |
Record.writeBool(D->isFailOnly()); |
| 2621 |
Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE; |
| 2622 |
} |
| 2623 |
|
| 2624 |
void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) { |
| 2625 |
VisitStmt(D); |
| 2626 |
VisitOMPExecutableDirective(D); |
| 2627 |
Code = serialization::STMT_OMP_TARGET_DIRECTIVE; |
| 2628 |
} |
| 2629 |
|
| 2630 |
void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { |
| 2631 |
VisitStmt(D); |
| 2632 |
VisitOMPExecutableDirective(D); |
| 2633 |
Code = serialization::STMT_OMP_TARGET_DATA_DIRECTIVE; |
| 2634 |
} |
| 2635 |
|
| 2636 |
void ASTStmtWriter::VisitOMPTargetEnterDataDirective( |
| 2637 |
OMPTargetEnterDataDirective *D) { |
| 2638 |
VisitStmt(D); |
| 2639 |
VisitOMPExecutableDirective(D); |
| 2640 |
Code = serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE; |
| 2641 |
} |
| 2642 |
|
| 2643 |
void ASTStmtWriter::VisitOMPTargetExitDataDirective( |
| 2644 |
OMPTargetExitDataDirective *D) { |
| 2645 |
VisitStmt(D); |
| 2646 |
VisitOMPExecutableDirective(D); |
| 2647 |
Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE; |
| 2648 |
} |
| 2649 |
|
| 2650 |
void ASTStmtWriter::VisitOMPTargetParallelDirective( |
| 2651 |
OMPTargetParallelDirective *D) { |
| 2652 |
VisitStmt(D); |
| 2653 |
VisitOMPExecutableDirective(D); |
| 2654 |
Record.writeBool(D->hasCancel()); |
| 2655 |
Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE; |
| 2656 |
} |
| 2657 |
|
| 2658 |
void ASTStmtWriter::VisitOMPTargetParallelForDirective( |
| 2659 |
OMPTargetParallelForDirective *D) { |
| 2660 |
VisitOMPLoopDirective(D); |
| 2661 |
Record.writeBool(D->hasCancel()); |
| 2662 |
Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE; |
| 2663 |
} |
| 2664 |
|
| 2665 |
void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { |
| 2666 |
VisitStmt(D); |
| 2667 |
VisitOMPExecutableDirective(D); |
| 2668 |
Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE; |
| 2669 |
} |
| 2670 |
|
| 2671 |
void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) { |
| 2672 |
VisitStmt(D); |
| 2673 |
VisitOMPExecutableDirective(D); |
| 2674 |
Code = serialization::STMT_OMP_BARRIER_DIRECTIVE; |
| 2675 |
} |
| 2676 |
|
| 2677 |
void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { |
| 2678 |
VisitStmt(D); |
| 2679 |
Record.push_back(D->getNumClauses()); |
| 2680 |
VisitOMPExecutableDirective(D); |
| 2681 |
Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE; |
| 2682 |
} |
| 2683 |
|
| 2684 |
void ASTStmtWriter::VisitOMPAssumeDirective(OMPAssumeDirective *D) { |
| 2685 |
VisitStmt(D); |
| 2686 |
VisitOMPExecutableDirective(D); |
| 2687 |
Code = serialization::STMT_OMP_ASSUME_DIRECTIVE; |
| 2688 |
} |
| 2689 |
|
| 2690 |
void ASTStmtWriter::VisitOMPErrorDirective(OMPErrorDirective *D) { |
| 2691 |
VisitStmt(D); |
| 2692 |
Record.push_back(D->getNumClauses()); |
| 2693 |
VisitOMPExecutableDirective(D); |
| 2694 |
Code = serialization::STMT_OMP_ERROR_DIRECTIVE; |
| 2695 |
} |
| 2696 |
|
| 2697 |
void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) { |
| 2698 |
VisitStmt(D); |
| 2699 |
VisitOMPExecutableDirective(D); |
| 2700 |
Code = serialization::STMT_OMP_TASKGROUP_DIRECTIVE; |
| 2701 |
} |
| 2702 |
|
| 2703 |
void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective *D) { |
| 2704 |
VisitStmt(D); |
| 2705 |
VisitOMPExecutableDirective(D); |
| 2706 |
Code = serialization::STMT_OMP_FLUSH_DIRECTIVE; |
| 2707 |
} |
| 2708 |
|
| 2709 |
void ASTStmtWriter::VisitOMPDepobjDirective(OMPDepobjDirective *D) { |
| 2710 |
VisitStmt(D); |
| 2711 |
VisitOMPExecutableDirective(D); |
| 2712 |
Code = serialization::STMT_OMP_DEPOBJ_DIRECTIVE; |
| 2713 |
} |
| 2714 |
|
| 2715 |
void ASTStmtWriter::VisitOMPScanDirective(OMPScanDirective *D) { |
| 2716 |
VisitStmt(D); |
| 2717 |
VisitOMPExecutableDirective(D); |
| 2718 |
Code = serialization::STMT_OMP_SCAN_DIRECTIVE; |
| 2719 |
} |
| 2720 |
|
| 2721 |
void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective *D) { |
| 2722 |
VisitStmt(D); |
| 2723 |
VisitOMPExecutableDirective(D); |
| 2724 |
Code = serialization::STMT_OMP_ORDERED_DIRECTIVE; |
| 2725 |
} |
| 2726 |
|
| 2727 |
void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) { |
| 2728 |
VisitStmt(D); |
| 2729 |
VisitOMPExecutableDirective(D); |
| 2730 |
Code = serialization::STMT_OMP_TEAMS_DIRECTIVE; |
| 2731 |
} |
| 2732 |
|
| 2733 |
void ASTStmtWriter::VisitOMPCancellationPointDirective( |
| 2734 |
OMPCancellationPointDirective *D) { |
| 2735 |
VisitStmt(D); |
| 2736 |
VisitOMPExecutableDirective(D); |
| 2737 |
Record.writeEnum(D->getCancelRegion()); |
| 2738 |
Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE; |
| 2739 |
} |
| 2740 |
|
| 2741 |
void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective *D) { |
| 2742 |
VisitStmt(D); |
| 2743 |
VisitOMPExecutableDirective(D); |
| 2744 |
Record.writeEnum(D->getCancelRegion()); |
| 2745 |
Code = serialization::STMT_OMP_CANCEL_DIRECTIVE; |
| 2746 |
} |
| 2747 |
|
| 2748 |
void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { |
| 2749 |
VisitOMPLoopDirective(D); |
| 2750 |
Record.writeBool(D->hasCancel()); |
| 2751 |
Code = serialization::STMT_OMP_TASKLOOP_DIRECTIVE; |
| 2752 |
} |
| 2753 |
|
| 2754 |
void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) { |
| 2755 |
VisitOMPLoopDirective(D); |
| 2756 |
Code = serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE; |
| 2757 |
} |
| 2758 |
|
| 2759 |
void ASTStmtWriter::VisitOMPMasterTaskLoopDirective( |
| 2760 |
OMPMasterTaskLoopDirective *D) { |
| 2761 |
VisitOMPLoopDirective(D); |
| 2762 |
Record.writeBool(D->hasCancel()); |
| 2763 |
Code = serialization::STMT_OMP_MASTER_TASKLOOP_DIRECTIVE; |
| 2764 |
} |
| 2765 |
|
| 2766 |
void ASTStmtWriter::VisitOMPMaskedTaskLoopDirective( |
| 2767 |
OMPMaskedTaskLoopDirective *D) { |
| 2768 |
VisitOMPLoopDirective(D); |
| 2769 |
Record.writeBool(D->hasCancel()); |
| 2770 |
Code = serialization::STMT_OMP_MASKED_TASKLOOP_DIRECTIVE; |
| 2771 |
} |
| 2772 |
|
| 2773 |
void ASTStmtWriter::VisitOMPMasterTaskLoopSimdDirective( |
| 2774 |
OMPMasterTaskLoopSimdDirective *D) { |
| 2775 |
VisitOMPLoopDirective(D); |
| 2776 |
Code = serialization::STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE; |
| 2777 |
} |
| 2778 |
|
| 2779 |
void ASTStmtWriter::VisitOMPMaskedTaskLoopSimdDirective( |
| 2780 |
OMPMaskedTaskLoopSimdDirective *D) { |
| 2781 |
VisitOMPLoopDirective(D); |
| 2782 |
Code = serialization::STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE; |
| 2783 |
} |
| 2784 |
|
| 2785 |
void ASTStmtWriter::VisitOMPParallelMasterTaskLoopDirective( |
| 2786 |
OMPParallelMasterTaskLoopDirective *D) { |
| 2787 |
VisitOMPLoopDirective(D); |
| 2788 |
Record.writeBool(D->hasCancel()); |
| 2789 |
Code = serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE; |
| 2790 |
} |
| 2791 |
|
| 2792 |
void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopDirective( |
| 2793 |
OMPParallelMaskedTaskLoopDirective *D) { |
| 2794 |
VisitOMPLoopDirective(D); |
| 2795 |
Record.writeBool(D->hasCancel()); |
| 2796 |
Code = serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE; |
| 2797 |
} |
| 2798 |
|
| 2799 |
void ASTStmtWriter::VisitOMPParallelMasterTaskLoopSimdDirective( |
| 2800 |
OMPParallelMasterTaskLoopSimdDirective *D) { |
| 2801 |
VisitOMPLoopDirective(D); |
| 2802 |
Code = serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE; |
| 2803 |
} |
| 2804 |
|
| 2805 |
void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopSimdDirective( |
| 2806 |
OMPParallelMaskedTaskLoopSimdDirective *D) { |
| 2807 |
VisitOMPLoopDirective(D); |
| 2808 |
Code = serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE; |
| 2809 |
} |
| 2810 |
|
| 2811 |
void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) { |
| 2812 |
VisitOMPLoopDirective(D); |
| 2813 |
Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE; |
| 2814 |
} |
| 2815 |
|
| 2816 |
void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { |
| 2817 |
VisitStmt(D); |
| 2818 |
VisitOMPExecutableDirective(D); |
| 2819 |
Code = serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE; |
| 2820 |
} |
| 2821 |
|
| 2822 |
void ASTStmtWriter::VisitOMPDistributeParallelForDirective( |
| 2823 |
OMPDistributeParallelForDirective *D) { |
| 2824 |
VisitOMPLoopDirective(D); |
| 2825 |
Record.writeBool(D->hasCancel()); |
| 2826 |
Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
| 2827 |
} |
| 2828 |
|
| 2829 |
void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective( |
| 2830 |
OMPDistributeParallelForSimdDirective *D) { |
| 2831 |
VisitOMPLoopDirective(D); |
| 2832 |
Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
| 2833 |
} |
| 2834 |
|
| 2835 |
void ASTStmtWriter::VisitOMPDistributeSimdDirective( |
| 2836 |
OMPDistributeSimdDirective *D) { |
| 2837 |
VisitOMPLoopDirective(D); |
| 2838 |
Code = serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE; |
| 2839 |
} |
| 2840 |
|
| 2841 |
void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective( |
| 2842 |
OMPTargetParallelForSimdDirective *D) { |
| 2843 |
VisitOMPLoopDirective(D); |
| 2844 |
Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE; |
| 2845 |
} |
| 2846 |
|
| 2847 |
void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { |
| 2848 |
VisitOMPLoopDirective(D); |
| 2849 |
Code = serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE; |
| 2850 |
} |
| 2851 |
|
| 2852 |
void ASTStmtWriter::VisitOMPTeamsDistributeDirective( |
| 2853 |
OMPTeamsDistributeDirective *D) { |
| 2854 |
VisitOMPLoopDirective(D); |
| 2855 |
Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE; |
| 2856 |
} |
| 2857 |
|
| 2858 |
void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective( |
| 2859 |
OMPTeamsDistributeSimdDirective *D) { |
| 2860 |
VisitOMPLoopDirective(D); |
| 2861 |
Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE; |
| 2862 |
} |
| 2863 |
|
| 2864 |
void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective( |
| 2865 |
OMPTeamsDistributeParallelForSimdDirective *D) { |
| 2866 |
VisitOMPLoopDirective(D); |
| 2867 |
Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
| 2868 |
} |
| 2869 |
|
| 2870 |
void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective( |
| 2871 |
OMPTeamsDistributeParallelForDirective *D) { |
| 2872 |
VisitOMPLoopDirective(D); |
| 2873 |
Record.writeBool(D->hasCancel()); |
| 2874 |
Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
| 2875 |
} |
| 2876 |
|
| 2877 |
void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) { |
| 2878 |
VisitStmt(D); |
| 2879 |
VisitOMPExecutableDirective(D); |
| 2880 |
Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE; |
| 2881 |
} |
| 2882 |
|
| 2883 |
void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective( |
| 2884 |
OMPTargetTeamsDistributeDirective *D) { |
| 2885 |
VisitOMPLoopDirective(D); |
| 2886 |
Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE; |
| 2887 |
} |
| 2888 |
|
| 2889 |
void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective( |
| 2890 |
OMPTargetTeamsDistributeParallelForDirective *D) { |
| 2891 |
VisitOMPLoopDirective(D); |
| 2892 |
Record.writeBool(D->hasCancel()); |
| 2893 |
Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
| 2894 |
} |
| 2895 |
|
| 2896 |
void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective( |
| 2897 |
OMPTargetTeamsDistributeParallelForSimdDirective *D) { |
| 2898 |
VisitOMPLoopDirective(D); |
| 2899 |
Code = serialization:: |
| 2900 |
STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
| 2901 |
} |
| 2902 |
|
| 2903 |
void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective( |
| 2904 |
OMPTargetTeamsDistributeSimdDirective *D) { |
| 2905 |
VisitOMPLoopDirective(D); |
| 2906 |
Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE; |
| 2907 |
} |
| 2908 |
|
| 2909 |
void ASTStmtWriter::VisitOMPInteropDirective(OMPInteropDirective *D) { |
| 2910 |
VisitStmt(D); |
| 2911 |
VisitOMPExecutableDirective(D); |
| 2912 |
Code = serialization::STMT_OMP_INTEROP_DIRECTIVE; |
| 2913 |
} |
| 2914 |
|
| 2915 |
void ASTStmtWriter::VisitOMPDispatchDirective(OMPDispatchDirective *D) { |
| 2916 |
VisitStmt(D); |
| 2917 |
VisitOMPExecutableDirective(D); |
| 2918 |
Record.AddSourceLocation(D->getTargetCallLoc()); |
| 2919 |
Code = serialization::STMT_OMP_DISPATCH_DIRECTIVE; |
| 2920 |
} |
| 2921 |
|
| 2922 |
void ASTStmtWriter::VisitOMPMaskedDirective(OMPMaskedDirective *D) { |
| 2923 |
VisitStmt(D); |
| 2924 |
VisitOMPExecutableDirective(D); |
| 2925 |
Code = serialization::STMT_OMP_MASKED_DIRECTIVE; |
| 2926 |
} |
| 2927 |
|
| 2928 |
void ASTStmtWriter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) { |
| 2929 |
VisitOMPLoopDirective(D); |
| 2930 |
Code = serialization::STMT_OMP_GENERIC_LOOP_DIRECTIVE; |
| 2931 |
} |
| 2932 |
|
| 2933 |
void ASTStmtWriter::VisitOMPTeamsGenericLoopDirective( |
| 2934 |
OMPTeamsGenericLoopDirective *D) { |
| 2935 |
VisitOMPLoopDirective(D); |
| 2936 |
Code = serialization::STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE; |
| 2937 |
} |
| 2938 |
|
| 2939 |
void ASTStmtWriter::VisitOMPTargetTeamsGenericLoopDirective( |
| 2940 |
OMPTargetTeamsGenericLoopDirective *D) { |
| 2941 |
VisitOMPLoopDirective(D); |
| 2942 |
Record.writeBool(D->canBeParallelFor()); |
| 2943 |
Code = serialization::STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE; |
| 2944 |
} |
| 2945 |
|
| 2946 |
void ASTStmtWriter::VisitOMPParallelGenericLoopDirective( |
| 2947 |
OMPParallelGenericLoopDirective *D) { |
| 2948 |
VisitOMPLoopDirective(D); |
| 2949 |
Code = serialization::STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE; |
| 2950 |
} |
| 2951 |
|
| 2952 |
void ASTStmtWriter::VisitOMPTargetParallelGenericLoopDirective( |
| 2953 |
OMPTargetParallelGenericLoopDirective *D) { |
| 2954 |
VisitOMPLoopDirective(D); |
| 2955 |
Code = serialization::STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE; |
| 2956 |
} |
| 2957 |
|
| 2958 |
//===----------------------------------------------------------------------===// |
| 2959 |
// OpenACC Constructs/Directives. |
| 2960 |
//===----------------------------------------------------------------------===// |
| 2961 |
void ASTStmtWriter::VisitOpenACCConstructStmt(OpenACCConstructStmt *S) { |
| 2962 |
Record.push_back(S->clauses().size()); |
| 2963 |
Record.writeEnum(S->Kind); |
| 2964 |
Record.AddSourceRange(S->Range); |
| 2965 |
Record.AddSourceLocation(S->DirectiveLoc); |
| 2966 |
Record.writeOpenACCClauseList(S->clauses()); |
| 2967 |
} |
| 2968 |
|
| 2969 |
void ASTStmtWriter::VisitOpenACCAssociatedStmtConstruct( |
| 2970 |
OpenACCAssociatedStmtConstruct *S) { |
| 2971 |
VisitOpenACCConstructStmt(S); |
| 2972 |
Record.AddStmt(S->getAssociatedStmt()); |
| 2973 |
} |
| 2974 |
|
| 2975 |
void ASTStmtWriter::VisitOpenACCComputeConstruct(OpenACCComputeConstruct *S) { |
| 2976 |
VisitStmt(S); |
| 2977 |
VisitOpenACCAssociatedStmtConstruct(S); |
| 2978 |
Code = serialization::STMT_OPENACC_COMPUTE_CONSTRUCT; |
| 2979 |
} |
| 2980 |
|
| 2981 |
void ASTStmtWriter::VisitOpenACCLoopConstruct(OpenACCLoopConstruct *S) { |
| 2982 |
VisitStmt(S); |
| 2983 |
VisitOpenACCAssociatedStmtConstruct(S); |
| 2984 |
Record.writeEnum(S->getParentComputeConstructKind()); |
| 2985 |
Code = serialization::STMT_OPENACC_LOOP_CONSTRUCT; |
| 2986 |
} |
| 2987 |
|
| 2988 |
void ASTStmtWriter::VisitOpenACCCombinedConstruct(OpenACCCombinedConstruct *S) { |
| 2989 |
VisitStmt(S); |
| 2990 |
VisitOpenACCAssociatedStmtConstruct(S); |
| 2991 |
Code = serialization::STMT_OPENACC_COMBINED_CONSTRUCT; |
| 2992 |
} |
| 2993 |
|
| 2994 |
void ASTStmtWriter::VisitOpenACCDataConstruct(OpenACCDataConstruct *S) { |
| 2995 |
VisitStmt(S); |
| 2996 |
VisitOpenACCAssociatedStmtConstruct(S); |
| 2997 |
Code = serialization::STMT_OPENACC_DATA_CONSTRUCT; |
| 2998 |
} |
| 2999 |
|
| 3000 |
void ASTStmtWriter::VisitOpenACCEnterDataConstruct( |
| 3001 |
OpenACCEnterDataConstruct *S) { |
| 3002 |
VisitStmt(S); |
| 3003 |
VisitOpenACCConstructStmt(S); |
| 3004 |
Code = serialization::STMT_OPENACC_ENTER_DATA_CONSTRUCT; |
| 3005 |
} |
| 3006 |
|
| 3007 |
void ASTStmtWriter::VisitOpenACCExitDataConstruct(OpenACCExitDataConstruct *S) { |
| 3008 |
VisitStmt(S); |
| 3009 |
VisitOpenACCConstructStmt(S); |
| 3010 |
Code = serialization::STMT_OPENACC_EXIT_DATA_CONSTRUCT; |
| 3011 |
} |
| 3012 |
|
| 3013 |
void ASTStmtWriter::VisitOpenACCInitConstruct(OpenACCInitConstruct *S) { |
| 3014 |
VisitStmt(S); |
| 3015 |
VisitOpenACCConstructStmt(S); |
| 3016 |
Code = serialization::STMT_OPENACC_INIT_CONSTRUCT; |
| 3017 |
} |
| 3018 |
|
| 3019 |
void ASTStmtWriter::VisitOpenACCShutdownConstruct(OpenACCShutdownConstruct *S) { |
| 3020 |
VisitStmt(S); |
| 3021 |
VisitOpenACCConstructStmt(S); |
| 3022 |
Code = serialization::STMT_OPENACC_SHUTDOWN_CONSTRUCT; |
| 3023 |
} |
| 3024 |
|
| 3025 |
void ASTStmtWriter::VisitOpenACCSetConstruct(OpenACCSetConstruct *S) { |
| 3026 |
VisitStmt(S); |
| 3027 |
VisitOpenACCConstructStmt(S); |
| 3028 |
Code = serialization::STMT_OPENACC_SET_CONSTRUCT; |
| 3029 |
} |
| 3030 |
|
| 3031 |
void ASTStmtWriter::VisitOpenACCUpdateConstruct(OpenACCUpdateConstruct *S) { |
| 3032 |
VisitStmt(S); |
| 3033 |
VisitOpenACCConstructStmt(S); |
| 3034 |
Code = serialization::STMT_OPENACC_UPDATE_CONSTRUCT; |
| 3035 |
} |
| 3036 |
|
| 3037 |
void ASTStmtWriter::VisitOpenACCHostDataConstruct(OpenACCHostDataConstruct *S) { |
| 3038 |
VisitStmt(S); |
| 3039 |
VisitOpenACCAssociatedStmtConstruct(S); |
| 3040 |
Code = serialization::STMT_OPENACC_HOST_DATA_CONSTRUCT; |
| 3041 |
} |
| 3042 |
|
| 3043 |
void ASTStmtWriter::VisitOpenACCWaitConstruct(OpenACCWaitConstruct *S) { |
| 3044 |
VisitStmt(S); |
| 3045 |
Record.push_back(S->getExprs().size()); |
| 3046 |
VisitOpenACCConstructStmt(S); |
| 3047 |
Record.AddSourceLocation(S->LParenLoc); |
| 3048 |
Record.AddSourceLocation(S->RParenLoc); |
| 3049 |
Record.AddSourceLocation(S->QueuesLoc); |
| 3050 |
|
| 3051 |
for(Expr *E : S->getExprs()) |
| 3052 |
Record.AddStmt(E); |
| 3053 |
|
| 3054 |
Code = serialization::STMT_OPENACC_WAIT_CONSTRUCT; |
| 3055 |
} |
| 3056 |
|
| 3057 |
void ASTStmtWriter::VisitOpenACCAtomicConstruct(OpenACCAtomicConstruct *S) { |
| 3058 |
VisitStmt(S); |
| 3059 |
VisitOpenACCConstructStmt(S); |
| 3060 |
Record.writeEnum(S->getAtomicKind()); |
| 3061 |
Record.AddStmt(S->getAssociatedStmt()); |
| 3062 |
|
| 3063 |
Code = serialization::STMT_OPENACC_ATOMIC_CONSTRUCT; |
| 3064 |
} |
| 3065 |
|
| 3066 |
void ASTStmtWriter::VisitOpenACCCacheConstruct(OpenACCCacheConstruct *S) { |
| 3067 |
VisitStmt(S); |
| 3068 |
Record.push_back(S->getVarList().size()); |
| 3069 |
VisitOpenACCConstructStmt(S); |
| 3070 |
Record.AddSourceRange(S->ParensLoc); |
| 3071 |
Record.AddSourceLocation(S->ReadOnlyLoc); |
| 3072 |
|
| 3073 |
for (Expr *E : S->getVarList()) |
| 3074 |
Record.AddStmt(E); |
| 3075 |
Code = serialization::STMT_OPENACC_CACHE_CONSTRUCT; |
| 3076 |
} |
| 3077 |
|
| 3078 |
//===----------------------------------------------------------------------===// |
| 3079 |
// HLSL Constructs/Directives. |
| 3080 |
//===----------------------------------------------------------------------===// |
| 3081 |
|
| 3082 |
void ASTStmtWriter::VisitHLSLOutArgExpr(HLSLOutArgExpr *S) { |
| 3083 |
VisitExpr(S); |
| 3084 |
Record.AddStmt(S->getOpaqueArgLValue()); |
| 3085 |
Record.AddStmt(S->getCastedTemporary()); |
| 3086 |
Record.AddStmt(S->getWritebackCast()); |
| 3087 |
Record.writeBool(S->isInOut()); |
| 3088 |
Code = serialization::EXPR_HLSL_OUT_ARG; |
| 3089 |
} |
| 3090 |
|
| 3091 |
//===----------------------------------------------------------------------===// |
| 3092 |
// ASTWriter Implementation |
| 3093 |
//===----------------------------------------------------------------------===// |
| 3094 |
|
| 3095 |
unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) { |
| 3096 |
assert(!SwitchCaseIDs.contains(S) && "SwitchCase recorded twice"); |
| 3097 |
unsigned NextID = SwitchCaseIDs.size(); |
| 3098 |
SwitchCaseIDs[S] = NextID; |
| 3099 |
return NextID; |
| 3100 |
} |
| 3101 |
|
| 3102 |
unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) { |
| 3103 |
assert(SwitchCaseIDs.contains(S) && "SwitchCase hasn't been seen yet"); |
| 3104 |
return SwitchCaseIDs[S]; |
| 3105 |
} |
| 3106 |
|
| 3107 |
void ASTWriter::ClearSwitchCaseIDs() { |
| 3108 |
SwitchCaseIDs.clear(); |
| 3109 |
} |
| 3110 |
|
| 3111 |
/// Write the given substatement or subexpression to the |
| 3112 |
/// bitstream. |
| 3113 |
void ASTWriter::WriteSubStmt(ASTContext &Context, Stmt *S) { |
| 3114 |
RecordData Record; |
| 3115 |
ASTStmtWriter Writer(Context, *this, Record); |
| 3116 |
++NumStatements; |
| 3117 |
|
| 3118 |
if (!S) { |
| 3119 |
Stream.EmitRecord(serialization::STMT_NULL_PTR, Record); |
| 3120 |
return; |
| 3121 |
} |
| 3122 |
|
| 3123 |
llvm::DenseMap<Stmt *, uint64_t>::iterator I = SubStmtEntries.find(S); |
| 3124 |
if (I != SubStmtEntries.end()) { |
| 3125 |
Record.push_back(I->second); |
| 3126 |
Stream.EmitRecord(serialization::STMT_REF_PTR, Record); |
| 3127 |
return; |
| 3128 |
} |
| 3129 |
|
| 3130 |
#ifndef NDEBUG |
| 3131 |
assert(!ParentStmts.count(S) && "There is a Stmt cycle!"); |
| 3132 |
|
| 3133 |
struct ParentStmtInserterRAII { |
| 3134 |
Stmt *S; |
| 3135 |
llvm::DenseSet<Stmt *> &ParentStmts; |
| 3136 |
|
| 3137 |
ParentStmtInserterRAII(Stmt *S, llvm::DenseSet<Stmt *> &ParentStmts) |
| 3138 |
: S(S), ParentStmts(ParentStmts) { |
| 3139 |
ParentStmts.insert(S); |
| 3140 |
} |
| 3141 |
~ParentStmtInserterRAII() { |
| 3142 |
ParentStmts.erase(S); |
| 3143 |
} |
| 3144 |
}; |
| 3145 |
|
| 3146 |
ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts); |
| 3147 |
#endif |
| 3148 |
|
| 3149 |
Writer.Visit(S); |
| 3150 |
|
| 3151 |
uint64_t Offset = Writer.Emit(); |
| 3152 |
SubStmtEntries[S] = Offset; |
| 3153 |
} |
| 3154 |
|
| 3155 |
/// Flush all of the statements that have been added to the |
| 3156 |
/// queue via AddStmt(). |
| 3157 |
void ASTRecordWriter::FlushStmts() { |
| 3158 |
// We expect to be the only consumer of the two temporary statement maps, |
| 3159 |
// assert that they are empty. |
| 3160 |
assert(Writer->SubStmtEntries.empty() && "unexpected entries in sub-stmt map"); |
| 3161 |
assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map"); |
| 3162 |
|
| 3163 |
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { |
| 3164 |
Writer->WriteSubStmt(getASTContext(), StmtsToEmit[I]); |
| 3165 |
|
| 3166 |
assert(N == StmtsToEmit.size() && "record modified while being written!"); |
| 3167 |
|
| 3168 |
// Note that we are at the end of a full expression. Any |
| 3169 |
// expression records that follow this one are part of a different |
| 3170 |
// expression. |
| 3171 |
Writer->Stream.EmitRecord(serialization::STMT_STOP, ArrayRef<uint32_t>()); |
| 3172 |
|
| 3173 |
Writer->SubStmtEntries.clear(); |
| 3174 |
Writer->ParentStmts.clear(); |
| 3175 |
} |
| 3176 |
|
| 3177 |
StmtsToEmit.clear(); |
| 3178 |
} |
| 3179 |
|
| 3180 |
void ASTRecordWriter::FlushSubStmts() { |
| 3181 |
// For a nested statement, write out the substatements in reverse order (so |
| 3182 |
// that a simple stack machine can be used when loading), and don't emit a |
| 3183 |
// STMT_STOP after each one. |
| 3184 |
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { |
| 3185 |
Writer->WriteSubStmt(getASTContext(), StmtsToEmit[N - I - 1]); |
| 3186 |
assert(N == StmtsToEmit.size() && "record modified while being written!"); |
| 3187 |
} |
| 3188 |
|
| 3189 |
StmtsToEmit.clear(); |
| 3190 |
} |