[cfe-commits] r77284 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/CMakeLists.txt lib/AST/StmtProfile.cpp
Douglas Gregor
dgregor at apple.com
Mon Jul 27 17:33:39 PDT 2009
Author: dgregor
Date: Mon Jul 27 19:33:38 2009
New Revision: 77284
URL: http://llvm.org/viewvc/llvm-project?rev=77284&view=rev
Log:
Add a Profile function for statements so that we can (eventually) determine
when statements and expressions are equivalent.
Added:
cfe/trunk/lib/AST/StmtProfile.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/CMakeLists.txt
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=77284&r1=77283&r2=77284&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Jul 27 19:33:38 2009
@@ -1687,7 +1687,7 @@
SourceLocation RP) :
Expr(ShuffleVectorExprClass, Type), BuiltinLoc(BLoc),
RParenLoc(RP), NumExprs(nexpr) {
-
+ // FIXME: Allocate in ASTContext!
SubExprs = new Stmt*[nexpr];
for (unsigned i = 0; i < nexpr; i++)
SubExprs[i] = args[i];
@@ -1915,6 +1915,7 @@
/// return NULL, indicating that the current initializer list also
/// serves as its syntactic form.
class InitListExpr : public Expr {
+ // FIXME: Eliminate this vector in favor of ASTContext allocation
std::vector<Stmt *> InitExprs;
SourceLocation LBraceLoc, RBraceLoc;
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=77284&r1=77283&r2=77284&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Jul 27 19:33:38 2009
@@ -26,6 +26,10 @@
#include <string>
using llvm::dyn_cast_or_null;
+namespace llvm {
+ class FoldingSetNodeID;
+}
+
namespace clang {
class ASTContext;
class Expr;
@@ -227,6 +231,21 @@
const_child_iterator child_end() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_end());
}
+
+ /// \brief Produce a unique representation of the given statement.
+ ///
+ /// \brief ID once the profiling operation is complete, will contain
+ /// the unique representation of the given statement.
+ ///
+ /// \brief Context the AST context in which the statement resides
+ ///
+ /// \brief Canonical whether the profile should be based on the canonical
+ /// representation of this statement (e.g., where non-type template
+ /// parameters are identified by index/level rather than their
+ /// declaration pointers) or the exact representation of the statement as
+ /// written in the source.
+ void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
+ bool Canonical);
};
/// DeclStmt - Adaptor class for mixing declarations with statements and
Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=77284&r1=77283&r2=77284&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Mon Jul 27 19:33:38 2009
@@ -23,6 +23,7 @@
StmtDumper.cpp
StmtIterator.cpp
StmtPrinter.cpp
+ StmtProfile.cpp
StmtViz.cpp
TemplateName.cpp
Type.cpp
Added: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=77284&view=auto
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (added)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Jul 27 19:33:38 2009
@@ -0,0 +1,537 @@
+//===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the Stmt::Profile method, which builds a unique bit
+// representation that identifiers a statement/expression.
+//
+//===----------------------------------------------------------------------===//
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprObjC.h"
+#include "clang/AST/StmtVisitor.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/Compiler.h"
+using namespace clang;
+
+namespace {
+ class VISIBILITY_HIDDEN StmtProfiler : public StmtVisitor<StmtProfiler> {
+ llvm::FoldingSetNodeID &ID;
+ ASTContext &Context;
+ bool Canonical;
+
+ public:
+ StmtProfiler(llvm::FoldingSetNodeID &ID, ASTContext &Context,
+ bool Canonical)
+ : ID(ID), Context(Context), Canonical(Canonical) { }
+
+ // FIXME: Use StmtNodes.def to declare all VisitXXX functions
+
+ void VisitStmt(Stmt *S);
+ void VisitExpr(Expr *S);
+ void VisitDeclRefExpr(DeclRefExpr *S);
+ void VisitPredefinedExpr(PredefinedExpr *S);
+ void VisitIntegerLiteral(IntegerLiteral *S);
+ void VisitCharacterLiteral(CharacterLiteral *S);
+ void VisitFloatingLiteral(FloatingLiteral *S);
+ void VisitImaginaryLiteral(ImaginaryLiteral *S);
+ void VisitStringLiteral(StringLiteral *S);
+ void VisitParenExpr(ParenExpr *S);
+ void VisitUnaryOperator(UnaryOperator *S);
+ void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *S);
+ void VisitArraySubscriptExpr(ArraySubscriptExpr *S);
+ void VisitCallExpr(CallExpr *S);
+ void VisitMemberExpr(MemberExpr *S);
+ void VisitCompoundLiteralExpr(CompoundLiteralExpr *S);
+ void VisitCastExpr(CastExpr *S);
+ void VisitImplicitCastExpr(ImplicitCastExpr *S);
+ void VisitExplicitCastExpr(ExplicitCastExpr *S);
+ void VisitCStyleCastExpr(CStyleCastExpr *S);
+ void VisitBinaryOperator(BinaryOperator *S);
+ void VisitCompoundAssignOperator(CompoundAssignOperator *S);
+ void VisitConditionalOperator(ConditionalOperator *S);
+ void VisitAddrLabelExpr(AddrLabelExpr *S);
+ void VisitStmtExpr(StmtExpr *S);
+ void VisitTypesCompatibleExpr(TypesCompatibleExpr *S);
+ void VisitShuffleVectorExpr(ShuffleVectorExpr *S);
+ void VisitChooseExpr(ChooseExpr *S);
+ void VisitGNUNullExpr(GNUNullExpr *S);
+ void VisitInitListExpr(InitListExpr *S);
+ void VisitDesignatedInitExpr(DesignatedInitExpr *S);
+ void VisitImplicitValueInitExpr(ImplicitValueInitExpr *S);
+ void VisitExtVectorElementExpr(ExtVectorElementExpr *S);
+ void VisitBlockExpr(BlockExpr *S);
+ void VisitBlockDeclRefExpr(BlockDeclRefExpr *S);
+ void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S);
+ void VisitCXXMemberCallExpr(CXXMemberCallExpr *S);
+ void VisitCXXNamedCastExpr(CXXNamedCastExpr *S);
+ void VisitCXXStaticCastExpr(CXXStaticCastExpr *S);
+ void VisitCXXDynamicCastExpr(CXXDynamicCastExpr *S);
+ void VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *S);
+ void VisitCXXConstCastExpr(CXXConstCastExpr *S);
+ void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *S);
+ void VisitCXXTypeidExpr(CXXTypeidExpr *S);
+ void VisitCXXThisExpr(CXXThisExpr *S);
+ void VisitCXXThrowExpr(CXXThrowExpr *S);
+ void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *S);
+ void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *S);
+ void VisitCXXConstructExpr(CXXConstructExpr *S);
+ void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *S);
+ void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *S);
+ void VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *S);
+ void VisitCXXConditionDeclExpr(CXXConditionDeclExpr *S);
+ void VisitCXXNewExpr(CXXNewExpr *S);
+ void VisitCXXDeleteExpr(CXXDeleteExpr *S);
+ void VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *S);
+ void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S);
+ void VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *S);
+ void VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *S);
+ void VisitTemplateIdRefExpr(TemplateIdRefExpr *S);
+ // FIXME: pick up at CXXExprWithTemporaries, handle Objective-C expressions
+
+ /// \brief Visit a declaration that is referenced within an expression
+ /// or statement.
+ void VisitDecl(Decl *D);
+
+ /// \brief Visit a type that is referenced within an expression or
+ /// statement.
+ void VisitType(QualType T);
+
+ /// \brief Visit a name that occurs within an expression or statement.
+ void VisitName(DeclarationName Name);
+
+ /// \brief Visit a nested-name-specifier that occurs within an expression
+ /// or statement.
+ void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
+
+ /// \brief Visit a template name that occurs within an expression or
+ /// statement.
+ void VisitTemplateName(TemplateName Name);
+
+ /// \brief Visit template arguments that occur within an expression or
+ /// statement.
+ void VisitTemplateArguments(const TemplateArgument *Args, unsigned NumArgs);
+ };
+}
+
+void StmtProfiler::VisitStmt(Stmt *S) {
+ ID.AddInteger(S->getStmtClass());
+ for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
+ C != CEnd; ++C)
+ Visit(*C);
+}
+
+void StmtProfiler::VisitExpr(Expr *S) {
+ VisitStmt(S);
+}
+
+void StmtProfiler::VisitDeclRefExpr(DeclRefExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getDecl());
+}
+
+void StmtProfiler::VisitPredefinedExpr(PredefinedExpr *S) {
+ VisitExpr(S);
+ ID.AddInteger(S->getIdentType());
+}
+
+void StmtProfiler::VisitIntegerLiteral(IntegerLiteral *S) {
+ VisitExpr(S);
+ S->getValue().Profile(ID);
+}
+
+void StmtProfiler::VisitCharacterLiteral(CharacterLiteral *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->isWide());
+ ID.AddInteger(S->getValue());
+}
+
+void StmtProfiler::VisitFloatingLiteral(FloatingLiteral *S) {
+ VisitExpr(S);
+ S->getValue().Profile(ID);
+ ID.AddBoolean(S->isExact());
+}
+
+void StmtProfiler::VisitImaginaryLiteral(ImaginaryLiteral *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitStringLiteral(StringLiteral *S) {
+ VisitExpr(S);
+ ID.AddString(S->getStrData(), S->getStrData() + S->getByteLength());
+ ID.AddBoolean(S->isWide());
+}
+
+void StmtProfiler::VisitParenExpr(ParenExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitUnaryOperator(UnaryOperator *S) {
+ VisitExpr(S);
+ ID.AddInteger(S->getOpcode());
+}
+
+void StmtProfiler::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->isSizeOf());
+ if (S->isArgumentType())
+ VisitType(S->getArgumentType());
+}
+
+void StmtProfiler::VisitArraySubscriptExpr(ArraySubscriptExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitCallExpr(CallExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitMemberExpr(MemberExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getMemberDecl());
+ ID.AddBoolean(S->isArrow());
+}
+
+void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->isFileScope());
+}
+
+void StmtProfiler::VisitDecl(Decl *D) {
+ if (Canonical) {
+ if (NonTypeTemplateParmDecl *NTTP
+ = dyn_cast_or_null<NonTypeTemplateParmDecl>(D)) {
+ ID.AddInteger(NTTP->getDepth());
+ ID.AddInteger(NTTP->getIndex());
+ return;
+ }
+
+ // FIXME: Other template template parameters?
+ }
+
+ ID.AddPointer(D? D->getCanonicalDecl() : 0);
+}
+
+void StmtProfiler::VisitCastExpr(CastExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitImplicitCastExpr(ImplicitCastExpr *S) {
+ VisitCastExpr(S);
+ ID.AddBoolean(S->isLvalueCast());
+}
+
+void StmtProfiler::VisitExplicitCastExpr(ExplicitCastExpr *S) {
+ VisitCastExpr(S);
+ VisitType(S->getTypeAsWritten());
+}
+
+void StmtProfiler::VisitCStyleCastExpr(CStyleCastExpr *S) {
+ VisitExplicitCastExpr(S);
+}
+
+void StmtProfiler::VisitBinaryOperator(BinaryOperator *S) {
+ VisitExpr(S);
+ ID.AddInteger(S->getOpcode());
+}
+
+void StmtProfiler::VisitCompoundAssignOperator(CompoundAssignOperator *S) {
+ VisitBinaryOperator(S);
+}
+
+void StmtProfiler::VisitConditionalOperator(ConditionalOperator *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitAddrLabelExpr(AddrLabelExpr *S) {
+ VisitExpr(S);
+ ID.AddPointer(S->getLabel());
+}
+
+void StmtProfiler::VisitStmtExpr(StmtExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitTypesCompatibleExpr(TypesCompatibleExpr *S) {
+ VisitExpr(S);
+ VisitType(S->getArgType1());
+ VisitType(S->getArgType2());
+}
+
+void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitChooseExpr(ChooseExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitGNUNullExpr(GNUNullExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
+ if (S->getSyntacticForm()) {
+ VisitInitListExpr(S->getSyntacticForm());
+ return;
+ }
+
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitDesignatedInitExpr(DesignatedInitExpr *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->usesGNUSyntax());
+ for (DesignatedInitExpr::designators_iterator D = S->designators_begin(),
+ DEnd = S->designators_end();
+ D != DEnd; ++D) {
+ if (D->isFieldDesignator()) {
+ ID.AddInteger(0);
+ VisitName(D->getFieldName());
+ continue;
+ }
+
+ if (D->isArrayDesignator()) {
+ ID.AddInteger(1);
+ } else {
+ assert(D->isArrayRangeDesignator());
+ ID.AddInteger(2);
+ }
+ ID.AddInteger(D->getFirstExprIndex());
+ }
+}
+
+void StmtProfiler::VisitImplicitValueInitExpr(ImplicitValueInitExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitExtVectorElementExpr(ExtVectorElementExpr *S) {
+ VisitExpr(S);
+ VisitName(&S->getAccessor());
+}
+
+void StmtProfiler::VisitBlockExpr(BlockExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getBlockDecl());
+}
+
+void StmtProfiler::VisitBlockDeclRefExpr(BlockDeclRefExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getDecl());
+ ID.AddBoolean(S->isByRef());
+ ID.AddBoolean(S->isConstQualAdded());
+}
+
+void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+ VisitCallExpr(S);
+ ID.AddInteger(S->getOperator());
+}
+
+void StmtProfiler::VisitCXXMemberCallExpr(CXXMemberCallExpr *S) {
+ VisitCallExpr(S);
+}
+
+void StmtProfiler::VisitCXXNamedCastExpr(CXXNamedCastExpr *S) {
+ VisitExplicitCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXStaticCastExpr(CXXStaticCastExpr *S) {
+ VisitCXXNamedCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *S) {
+ VisitCXXNamedCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *S) {
+ VisitCXXNamedCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXConstCastExpr(CXXConstCastExpr *S) {
+ VisitCXXNamedCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->getValue());
+}
+
+void StmtProfiler::VisitCXXTypeidExpr(CXXTypeidExpr *S) {
+ VisitExpr(S);
+ if (S->isTypeOperand())
+ VisitType(S->getTypeOperand());
+}
+
+void StmtProfiler::VisitCXXThisExpr(CXXThisExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitCXXThrowExpr(CXXThrowExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getParam());
+}
+
+void StmtProfiler::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *S) {
+ VisitExpr(S);
+ VisitDecl(
+ const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
+}
+
+void StmtProfiler::VisitCXXConstructExpr(CXXConstructExpr *S) {
+ VisitExpr(S);
+ VisitDecl(S->getConstructor());
+ ID.AddBoolean(S->isElidable());
+}
+
+void StmtProfiler::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *S) {
+ VisitExplicitCastExpr(S);
+}
+
+void StmtProfiler::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *S) {
+ VisitCXXConstructExpr(S);
+}
+
+void StmtProfiler::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *S) {
+ VisitExpr(S);
+}
+
+void StmtProfiler::VisitCXXConditionDeclExpr(CXXConditionDeclExpr *S) {
+ VisitDeclRefExpr(S);
+}
+
+void StmtProfiler::VisitCXXDeleteExpr(CXXDeleteExpr *S) {
+ VisitExpr(S);
+ ID.AddBoolean(S->isGlobalDelete());
+ ID.AddBoolean(S->isArrayForm());
+ VisitDecl(S->getOperatorDelete());
+}
+
+
+void StmtProfiler::VisitCXXNewExpr(CXXNewExpr *S) {
+ VisitExpr(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());
+}
+
+void
+StmtProfiler::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *S) {
+ VisitExpr(S);
+ VisitName(S->getName());
+}
+
+void StmtProfiler::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S) {
+ VisitExpr(S);
+ ID.AddInteger(S->getTrait());
+ VisitType(S->getQueriedType());
+}
+
+void StmtProfiler::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *S) {
+ VisitDeclRefExpr(S);
+ VisitNestedNameSpecifier(S->getQualifier());
+}
+
+void StmtProfiler::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *S) {
+ VisitExpr(S);
+ VisitName(S->getDeclName());
+ VisitNestedNameSpecifier(S->getQualifier());
+ ID.AddBoolean(S->isAddressOfOperand());
+}
+
+void StmtProfiler::VisitTemplateIdRefExpr(TemplateIdRefExpr *S) {
+ VisitExpr(S);
+ VisitNestedNameSpecifier(S->getQualifier());
+ VisitTemplateName(S->getTemplateName());
+ VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
+}
+
+void StmtProfiler::VisitType(QualType T) {
+ if (Canonical) {
+ if (const TemplateTypeParmType *TTP = T->getAs<TemplateTypeParmType>()) {
+ ID.AddInteger(TTP->getDepth());
+ ID.AddInteger(TTP->getIndex());
+ return;
+ }
+
+ T = Context.getCanonicalType(T);
+ }
+
+ ID.AddPointer(T.getAsOpaquePtr());
+}
+
+void StmtProfiler::VisitName(DeclarationName Name) {
+ ID.AddPointer(Name.getAsOpaquePtr());
+}
+
+void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
+ if (Canonical)
+ NNS = Context.getCanonicalNestedNameSpecifier(NNS);
+ ID.AddPointer(NNS);
+}
+
+void StmtProfiler::VisitTemplateName(TemplateName Name) {
+ if (Canonical)
+ Name = Context.getCanonicalTemplateName(Name);
+
+ Name.Profile(ID);
+}
+
+void StmtProfiler::VisitTemplateArguments(const TemplateArgument *Args,
+ unsigned NumArgs) {
+ ID.AddInteger(NumArgs);
+ for (unsigned I = 0; I != NumArgs; ++I) {
+ const TemplateArgument &Arg = Args[I];
+
+ // Mostly repetitive with TemplateArgument::Profile!
+ ID.AddInteger(Arg.getKind());
+ switch (Arg.getKind()) {
+ case TemplateArgument::Null:
+ break;
+
+ case TemplateArgument::Type:
+ VisitType(Arg.getAsType());
+ break;
+
+ case TemplateArgument::Declaration:
+ VisitDecl(Arg.getAsDecl());
+ break;
+
+ case TemplateArgument::Integral:
+ Arg.getAsIntegral()->Profile(ID);
+ VisitType(Arg.getIntegralType());
+ break;
+
+ case TemplateArgument::Expression:
+ Visit(Arg.getAsExpr());
+ break;
+
+ case TemplateArgument::Pack:
+ VisitTemplateArguments(Arg.pack_begin(), Arg.pack_size());
+ break;
+ }
+ }
+}
+
+void Stmt::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
+ bool Canonical) {
+ StmtProfiler Profiler(ID, Context, Canonical);
+ Profiler.Visit(this);
+}
More information about the cfe-commits
mailing list