diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp | 99 |
1 files changed, 85 insertions, 14 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp b/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp index 214378a..e5526ce 100644 --- a/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp +++ b/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp @@ -69,8 +69,12 @@ namespace { void StmtProfiler::VisitStmt(const Stmt *S) { ID.AddInteger(S->getStmtClass()); - for (Stmt::const_child_range C = S->children(); C; ++C) - Visit(*C); + for (Stmt::const_child_range C = S->children(); C; ++C) { + if (*C) + Visit(*C); + else + ID.AddInteger(0); + } } void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { @@ -182,6 +186,13 @@ void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { VisitStmt(S); } +void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { + VisitStmt(S); + ID.AddBoolean(S->isIfExists()); + VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); + VisitName(S->getNameInfo().getName()); +} + void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { VisitStmt(S); } @@ -268,7 +279,7 @@ void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { VisitExpr(S); - ID.AddString(S->getString()); + ID.AddString(S->getBytes()); ID.AddInteger(S->getKind()); } @@ -449,13 +460,6 @@ void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { VisitDecl(S->getBlockDecl()); } -void StmtProfiler::VisitBlockDeclRefExpr(const BlockDeclRefExpr *S) { - VisitExpr(S); - VisitDecl(S->getDecl()); - ID.AddBoolean(S->isByRef()); - ID.AddBoolean(S->isConstQualAdded()); -} - void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { VisitExpr(S); for (unsigned i = 0; i != S->getNumAssocs(); ++i) { @@ -468,6 +472,15 @@ void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { } } +void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { + VisitExpr(S); + for (PseudoObjectExpr::const_semantics_iterator + i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) + // Normally, we would not profile the source expressions of OVEs. + if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) + Visit(OVE->getSourceExpr()); +} + void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { VisitExpr(S); ID.AddInteger(S->getOp()); @@ -487,7 +500,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, case OO_Conditional: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); - return Stmt::ArraySubscriptExprClass; case OO_Plus: if (S->getNumArgs() == 1) { @@ -719,6 +731,10 @@ void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { VisitCXXNamedCastExpr(S); } +void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { + VisitCallExpr(S); +} + void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { VisitExpr(S); ID.AddBoolean(S->getValue()); @@ -775,6 +791,24 @@ StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { } void +StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { + VisitExpr(S); + for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), + CEnd = S->explicit_capture_end(); + C != CEnd; ++C) { + ID.AddInteger(C->getCaptureKind()); + if (C->capturesVariable()) { + VisitDecl(C->getCapturedVar()); + ID.AddBoolean(C->isPackExpansion()); + } + } + // Note: If we actually needed to be able to match lambda + // expressions, we would have to consider parameters and return type + // here, among other things. + VisitStmt(S->getBody()); +} + +void StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { VisitExpr(S); } @@ -792,13 +826,11 @@ void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { VisitType(S->getAllocatedType()); VisitDecl(S->getOperatorNew()); VisitDecl(S->getOperatorDelete()); - VisitDecl(S->getConstructor()); ID.AddBoolean(S->isArray()); ID.AddInteger(S->getNumPlacementArgs()); ID.AddBoolean(S->isGlobalNew()); ID.AddBoolean(S->isParenTypeId()); - ID.AddBoolean(S->hasInitializer()); - ID.AddInteger(S->getNumConstructorArgs()); + ID.AddInteger(S->getInitializationStyle()); } void @@ -837,6 +869,14 @@ void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) { VisitType(S->getRhsType()); } +void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { + VisitExpr(S); + ID.AddInteger(S->getTrait()); + ID.AddInteger(S->getNumArgs()); + for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) + VisitType(S->getArg(I)->getType()); +} + void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { VisitExpr(S); ID.AddInteger(S->getTrait()); @@ -935,6 +975,18 @@ void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { VisitExpr(S); } +void StmtProfiler::VisitObjCNumericLiteral(const ObjCNumericLiteral *E) { + VisitExpr(E); +} + +void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { + VisitExpr(E); +} + +void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { + VisitExpr(E); +} + void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { VisitExpr(S); VisitType(S->getEncodedType()); @@ -971,6 +1023,12 @@ void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { } } +void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { + VisitExpr(S); + VisitDecl(S->getAtIndexMethodDecl()); + VisitDecl(S->setAtIndexMethodDecl()); +} + void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { VisitExpr(S); VisitName(S->getSelector()); @@ -982,6 +1040,11 @@ void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { ID.AddBoolean(S->isArrow()); } +void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { + VisitExpr(S); + ID.AddBoolean(S->getValue()); +} + void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( const ObjCIndirectCopyRestoreExpr *S) { VisitExpr(S); @@ -1020,6 +1083,14 @@ void StmtProfiler::VisitDecl(const Decl *D) { return; } + if (const TemplateTypeParmDecl *TTP = + dyn_cast<TemplateTypeParmDecl>(D)) { + ID.AddInteger(TTP->getDepth()); + ID.AddInteger(TTP->getIndex()); + ID.AddBoolean(TTP->isParameterPack()); + return; + } + if (const TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) { ID.AddInteger(TTP->getDepth()); |