2009-07-28 00:33:38 +00:00
|
|
|
//===---- 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
|
2009-07-28 16:39:25 +00:00
|
|
|
// representation that identifies a statement/expression.
|
2009-07-28 00:33:38 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/AST/ASTContext.h"
|
2009-07-28 14:44:31 +00:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
|
|
|
#include "clang/AST/DeclObjC.h"
|
2009-07-28 00:33:38 +00:00
|
|
|
#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"
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
namespace {
|
2009-11-28 19:03:38 +00:00
|
|
|
class StmtProfiler : public StmtVisitor<StmtProfiler> {
|
2009-07-28 00:33:38 +00:00
|
|
|
llvm::FoldingSetNodeID &ID;
|
2011-01-12 09:06:06 +00:00
|
|
|
const ASTContext &Context;
|
2009-07-28 00:33:38 +00:00
|
|
|
bool Canonical;
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
public:
|
2011-01-12 09:06:06 +00:00
|
|
|
StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
|
2009-09-09 15:08:12 +00:00
|
|
|
bool Canonical)
|
2009-07-28 00:33:38 +00:00
|
|
|
: ID(ID), Context(Context), Canonical(Canonical) { }
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void VisitStmt(Stmt *S);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 15:27:13 +00:00
|
|
|
#define STMT(Node, Base) void Visit##Node(Node *S);
|
2010-05-05 15:24:00 +00:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
/// \brief Visit a declaration that is referenced within an expression
|
|
|
|
/// or statement.
|
|
|
|
void VisitDecl(Decl *D);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
|
|
|
/// \brief Visit a type that is referenced within an expression or
|
2009-07-28 00:33:38 +00:00
|
|
|
/// statement.
|
|
|
|
void VisitType(QualType T);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
/// \brief Visit a name that occurs within an expression or statement.
|
|
|
|
void VisitName(DeclarationName Name);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
/// \brief Visit a nested-name-specifier that occurs within an expression
|
|
|
|
/// or statement.
|
|
|
|
void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
/// \brief Visit a template name that occurs within an expression or
|
|
|
|
/// statement.
|
|
|
|
void VisitTemplateName(TemplateName Name);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
/// \brief Visit template arguments that occur within an expression or
|
|
|
|
/// statement.
|
2009-10-29 08:12:44 +00:00
|
|
|
void VisitTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs);
|
|
|
|
|
|
|
|
/// \brief Visit a single template argument.
|
|
|
|
void VisitTemplateArgument(const TemplateArgument &Arg);
|
2009-07-28 00:33:38 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitStmt(Stmt *S) {
|
|
|
|
ID.AddInteger(S->getStmtClass());
|
2011-02-13 04:07:26 +00:00
|
|
|
for (Stmt::child_range C = S->children(); C; ++C)
|
2009-07-28 00:33:38 +00:00
|
|
|
Visit(*C);
|
|
|
|
}
|
|
|
|
|
2009-07-28 15:27:13 +00:00
|
|
|
void StmtProfiler::VisitDeclStmt(DeclStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
|
|
|
|
D != DEnd; ++D)
|
|
|
|
VisitDecl(*D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitNullStmt(NullStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCompoundStmt(CompoundStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitSwitchCase(SwitchCase *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCaseStmt(CaseStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitDefaultStmt(DefaultStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitLabelStmt(LabelStmt *S) {
|
|
|
|
VisitStmt(S);
|
2011-02-17 07:39:24 +00:00
|
|
|
VisitDecl(S->getDecl());
|
2009-07-28 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitIfStmt(IfStmt *S) {
|
|
|
|
VisitStmt(S);
|
2009-11-25 00:27:52 +00:00
|
|
|
VisitDecl(S->getConditionVariable());
|
2009-07-28 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
2009-07-29 16:09:57 +00:00
|
|
|
void StmtProfiler::VisitSwitchStmt(SwitchStmt *S) {
|
|
|
|
VisitStmt(S);
|
2009-11-25 00:27:52 +00:00
|
|
|
VisitDecl(S->getConditionVariable());
|
2009-07-29 16:09:57 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 15:27:13 +00:00
|
|
|
void StmtProfiler::VisitWhileStmt(WhileStmt *S) {
|
|
|
|
VisitStmt(S);
|
2009-11-25 00:27:52 +00:00
|
|
|
VisitDecl(S->getConditionVariable());
|
2009-07-28 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitDoStmt(DoStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitForStmt(ForStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitGotoStmt(GotoStmt *S) {
|
|
|
|
VisitStmt(S);
|
2011-02-17 07:39:24 +00:00
|
|
|
VisitDecl(S->getLabel());
|
2009-07-28 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitContinueStmt(ContinueStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitBreakStmt(BreakStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitReturnStmt(ReturnStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitAsmStmt(AsmStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
ID.AddBoolean(S->isVolatile());
|
|
|
|
ID.AddBoolean(S->isSimple());
|
|
|
|
VisitStringLiteral(S->getAsmString());
|
|
|
|
ID.AddInteger(S->getNumOutputs());
|
|
|
|
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
|
|
|
|
ID.AddString(S->getOutputName(I));
|
|
|
|
VisitStringLiteral(S->getOutputConstraintLiteral(I));
|
|
|
|
}
|
|
|
|
ID.AddInteger(S->getNumInputs());
|
|
|
|
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
|
|
|
|
ID.AddString(S->getInputName(I));
|
|
|
|
VisitStringLiteral(S->getInputConstraintLiteral(I));
|
|
|
|
}
|
|
|
|
ID.AddInteger(S->getNumClobbers());
|
|
|
|
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
|
|
|
|
VisitStringLiteral(S->getClobber(I));
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCXXCatchStmt(CXXCatchStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
VisitType(S->getCaughtType());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCXXTryStmt(CXXTryStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
ID.AddBoolean(S->hasEllipsis());
|
|
|
|
if (S->getCatchParamDecl())
|
|
|
|
VisitType(S->getCatchParamDecl()->getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitExpr(Expr *S) {
|
|
|
|
VisitStmt(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitDeclRefExpr(DeclRefExpr *S) {
|
|
|
|
VisitExpr(S);
|
2010-07-13 08:37:11 +00:00
|
|
|
if (!Canonical)
|
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitDecl(S->getDecl());
|
2010-07-13 08:37:11 +00:00
|
|
|
if (!Canonical)
|
|
|
|
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2009-09-22 10:06:21 +00:00
|
|
|
ID.AddString(S->getString());
|
2009-07-28 00:33:38 +00:00
|
|
|
ID.AddBoolean(S->isWide());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitParenExpr(ParenExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-08-10 23:49:36 +00:00
|
|
|
void StmtProfiler::VisitParenListExpr(ParenListExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitUnaryOperator(UnaryOperator *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddInteger(S->getOpcode());
|
|
|
|
}
|
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-28 22:16:22 +00:00
|
|
|
void StmtProfiler::VisitOffsetOfExpr(OffsetOfExpr *S) {
|
|
|
|
VisitType(S->getTypeSourceInfo()->getType());
|
|
|
|
unsigned n = S->getNumComponents();
|
|
|
|
for (unsigned i = 0; i < n; ++i) {
|
|
|
|
const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
|
|
|
|
ID.AddInteger(ON.getKind());
|
|
|
|
switch (ON.getKind()) {
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Array:
|
|
|
|
// Expressions handled below.
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Field:
|
|
|
|
VisitDecl(ON.getField());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OffsetOfExpr::OffsetOfNode::Identifier:
|
|
|
|
ID.AddPointer(ON.getFieldName());
|
|
|
|
break;
|
2010-05-05 15:23:54 +00:00
|
|
|
|
2010-04-29 00:18:15 +00:00
|
|
|
case OffsetOfExpr::OffsetOfNode::Base:
|
|
|
|
// These nodes are implicit, and therefore don't need profiling.
|
|
|
|
break;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-28 22:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-05 15:23:54 +00:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-28 22:16:22 +00:00
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2011-03-11 19:24:49 +00:00
|
|
|
void StmtProfiler::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *S) {
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitExpr(S);
|
2011-03-11 19:24:49 +00:00
|
|
|
ID.AddInteger(S->getKind());
|
2009-07-28 00:33:38 +00:00
|
|
|
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());
|
2010-07-13 08:37:11 +00:00
|
|
|
if (!Canonical)
|
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
2009-07-28 00:33:38 +00:00
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddBoolean(S->isFileScope());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCastExpr(CastExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitImplicitCastExpr(ImplicitCastExpr *S) {
|
|
|
|
VisitCastExpr(S);
|
2010-08-25 10:28:54 +00:00
|
|
|
ID.AddInteger(S->getValueKind());
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-02-17 10:25:35 +00:00
|
|
|
void StmtProfiler::VisitBinaryConditionalOperator(BinaryConditionalOperator *S){
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitAddrLabelExpr(AddrLabelExpr *S) {
|
|
|
|
VisitExpr(S);
|
2011-02-17 07:39:24 +00:00
|
|
|
VisitDecl(S->getLabel());
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitStmtExpr(StmtExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitChooseExpr(ChooseExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitGNUNullExpr(GNUNullExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-29 16:09:57 +00:00
|
|
|
void StmtProfiler::VisitVAArgExpr(VAArgExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
|
|
|
|
if (S->getSyntacticForm()) {
|
|
|
|
VisitInitListExpr(S->getSyntacticForm());
|
|
|
|
return;
|
|
|
|
}
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2010-05-19 04:13:23 +00:00
|
|
|
static Stmt::StmtClass DecodeOperatorCall(CXXOperatorCallExpr *S,
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOperatorKind &UnaryOp,
|
|
|
|
BinaryOperatorKind &BinaryOp) {
|
2010-05-19 04:13:23 +00:00
|
|
|
switch (S->getOperator()) {
|
|
|
|
case OO_None:
|
|
|
|
case OO_New:
|
|
|
|
case OO_Delete:
|
|
|
|
case OO_Array_New:
|
|
|
|
case OO_Array_Delete:
|
|
|
|
case OO_Arrow:
|
|
|
|
case OO_Call:
|
|
|
|
case OO_Conditional:
|
|
|
|
case NUM_OVERLOADED_OPERATORS:
|
|
|
|
llvm_unreachable("Invalid operator call kind");
|
|
|
|
return Stmt::ArraySubscriptExprClass;
|
|
|
|
|
|
|
|
case OO_Plus:
|
|
|
|
if (S->getNumArgs() == 1) {
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_Plus;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
}
|
|
|
|
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Add;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Minus:
|
|
|
|
if (S->getNumArgs() == 1) {
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_Minus;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
}
|
|
|
|
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Sub;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Star:
|
|
|
|
if (S->getNumArgs() == 1) {
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_Minus;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
}
|
|
|
|
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Sub;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Slash:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Div;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Percent:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Rem;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Caret:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Xor;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Amp:
|
|
|
|
if (S->getNumArgs() == 1) {
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_AddrOf;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
}
|
|
|
|
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_And;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Pipe:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Or;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Tilde:
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_Not;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Exclaim:
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = UO_LNot;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Equal:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Assign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Less:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_LT;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Greater:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_GT;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_PlusEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_AddAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_MinusEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_SubAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_StarEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_MulAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_SlashEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_DivAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_PercentEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_RemAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_CaretEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_XorAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_AmpEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_AndAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_PipeEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_OrAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_LessLess:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Shl;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_GreaterGreater:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Shr;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_LessLessEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_ShlAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_GreaterGreaterEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_ShrAssign;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::CompoundAssignOperatorClass;
|
|
|
|
|
|
|
|
case OO_EqualEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_EQ;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_ExclaimEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_NE;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_LessEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_LE;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_GreaterEqual:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_GE;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_AmpAmp:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_LAnd;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_PipePipe:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_LOr;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_PlusPlus:
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = S->getNumArgs() == 1? UO_PreInc
|
|
|
|
: UO_PostInc;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_MinusMinus:
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOp = S->getNumArgs() == 1? UO_PreDec
|
|
|
|
: UO_PostDec;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::UnaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Comma:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_Comma;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
|
|
|
|
case OO_ArrowStar:
|
2010-08-25 11:45:40 +00:00
|
|
|
BinaryOp = BO_PtrMemI;
|
2010-05-19 04:13:23 +00:00
|
|
|
return Stmt::BinaryOperatorClass;
|
|
|
|
|
|
|
|
case OO_Subscript:
|
|
|
|
return Stmt::ArraySubscriptExprClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm_unreachable("Invalid overloaded operator expression");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
|
2010-05-19 04:13:23 +00:00
|
|
|
if (S->isTypeDependent()) {
|
|
|
|
// Type-dependent operator calls are profiled like their underlying
|
|
|
|
// syntactic operator.
|
2010-08-25 11:45:40 +00:00
|
|
|
UnaryOperatorKind UnaryOp = UO_Extension;
|
|
|
|
BinaryOperatorKind BinaryOp = BO_Comma;
|
2010-05-19 04:13:23 +00:00
|
|
|
Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
|
|
|
|
|
|
|
|
ID.AddInteger(SC);
|
|
|
|
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
|
|
|
|
Visit(S->getArg(I));
|
|
|
|
if (SC == Stmt::UnaryOperatorClass)
|
|
|
|
ID.AddInteger(UnaryOp);
|
|
|
|
else if (SC == Stmt::BinaryOperatorClass ||
|
|
|
|
SC == Stmt::CompoundAssignOperatorClass)
|
|
|
|
ID.AddInteger(BinaryOp);
|
|
|
|
else
|
|
|
|
assert(SC == Stmt::ArraySubscriptExprClass);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitCallExpr(S);
|
|
|
|
ID.AddInteger(S->getOperator());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitCXXMemberCallExpr(CXXMemberCallExpr *S) {
|
|
|
|
VisitCallExpr(S);
|
|
|
|
}
|
|
|
|
|
2011-02-09 21:07:24 +00:00
|
|
|
void StmtProfiler::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *S) {
|
|
|
|
VisitCallExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2009-07-29 16:09:57 +00:00
|
|
|
void StmtProfiler::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
void StmtProfiler::VisitCXXTypeidExpr(CXXTypeidExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
if (S->isTypeOperand())
|
|
|
|
VisitType(S->getTypeOperand());
|
|
|
|
}
|
|
|
|
|
2010-09-08 12:20:18 +00:00
|
|
|
void StmtProfiler::VisitCXXUuidofExpr(CXXUuidofExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
if (S->isTypeOperand())
|
|
|
|
VisitType(S->getTypeOperand());
|
|
|
|
}
|
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-07-08 06:14:04 +00:00
|
|
|
void StmtProfiler::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *S) {
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitExpr(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());
|
|
|
|
}
|
|
|
|
|
2009-09-04 17:36:40 +00:00
|
|
|
void StmtProfiler::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
|
|
|
VisitType(S->getDestroyedType());
|
|
|
|
}
|
|
|
|
|
2010-08-15 01:15:38 +00:00
|
|
|
void StmtProfiler::VisitOverloadExpr(OverloadExpr *S) {
|
2010-08-15 20:53:20 +00:00
|
|
|
VisitExpr(S);
|
2009-11-24 19:00:30 +00:00
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitName(S->getName());
|
2009-11-24 19:00:30 +00:00
|
|
|
ID.AddBoolean(S->hasExplicitTemplateArgs());
|
|
|
|
if (S->hasExplicitTemplateArgs())
|
2010-08-15 01:15:38 +00:00
|
|
|
VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
|
|
|
|
S->getExplicitTemplateArgs().NumTemplateArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StmtProfiler::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *S) {
|
|
|
|
VisitOverloadExpr(S);
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddInteger(S->getTrait());
|
|
|
|
VisitType(S->getQueriedType());
|
|
|
|
}
|
|
|
|
|
2010-12-07 00:08:36 +00:00
|
|
|
void StmtProfiler::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddInteger(S->getTrait());
|
|
|
|
VisitType(S->getLhsType());
|
|
|
|
VisitType(S->getRhsType());
|
|
|
|
}
|
|
|
|
|
2009-11-19 22:55:06 +00:00
|
|
|
void
|
|
|
|
StmtProfiler::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *S) {
|
2009-07-28 00:33:38 +00:00
|
|
|
VisitExpr(S);
|
|
|
|
VisitName(S->getDeclName());
|
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
2009-11-24 19:00:30 +00:00
|
|
|
ID.AddBoolean(S->hasExplicitTemplateArgs());
|
|
|
|
if (S->hasExplicitTemplateArgs())
|
|
|
|
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 08:20:24 +00:00
|
|
|
void StmtProfiler::VisitExprWithCleanups(ExprWithCleanups *S) {
|
2009-07-28 14:44:31 +00:00
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:08:12 +00:00
|
|
|
void
|
2009-07-28 14:44:31 +00:00
|
|
|
StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitType(S->getTypeAsWritten());
|
|
|
|
}
|
|
|
|
|
2009-11-19 22:55:06 +00:00
|
|
|
void
|
|
|
|
StmtProfiler::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *S) {
|
2009-12-01 22:10:20 +00:00
|
|
|
ID.AddBoolean(S->isImplicitAccess());
|
|
|
|
if (!S->isImplicitAccess()) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
}
|
2009-09-03 16:14:30 +00:00
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
2009-07-28 14:44:31 +00:00
|
|
|
VisitName(S->getMember());
|
2009-12-01 22:10:20 +00:00
|
|
|
ID.AddBoolean(S->hasExplicitTemplateArgs());
|
|
|
|
if (S->hasExplicitTemplateArgs())
|
2009-11-30 22:42:35 +00:00
|
|
|
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *S) {
|
2009-12-01 22:10:20 +00:00
|
|
|
ID.AddBoolean(S->isImplicitAccess());
|
|
|
|
if (!S->isImplicitAccess()) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
}
|
2009-11-30 22:42:35 +00:00
|
|
|
VisitNestedNameSpecifier(S->getQualifier());
|
|
|
|
VisitName(S->getMemberName());
|
|
|
|
ID.AddBoolean(S->hasExplicitTemplateArgs());
|
|
|
|
if (S->hasExplicitTemplateArgs())
|
|
|
|
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
|
2009-07-28 14:44:31 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 20:55:43 +00:00
|
|
|
void StmtProfiler::VisitCXXNoexceptExpr(CXXNoexceptExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2011-01-03 17:17:50 +00:00
|
|
|
void StmtProfiler::VisitPackExpansionExpr(PackExpansionExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
2011-01-04 17:33:58 +00:00
|
|
|
void StmtProfiler::VisitSizeOfPackExpr(SizeOfPackExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitDecl(S->getPack());
|
|
|
|
}
|
|
|
|
|
2011-01-15 01:15:58 +00:00
|
|
|
void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
|
|
|
|
SubstNonTypeTemplateParmPackExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitDecl(S->getParameterPack());
|
|
|
|
VisitTemplateArgument(S->getArgumentPack());
|
|
|
|
}
|
|
|
|
|
2010-11-15 23:31:06 +00:00
|
|
|
void StmtProfiler::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
|
|
|
|
VisitExpr(E);
|
|
|
|
}
|
|
|
|
|
2009-07-28 14:44:31 +00:00
|
|
|
void StmtProfiler::VisitObjCStringLiteral(ObjCStringLiteral *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCEncodeExpr(ObjCEncodeExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitType(S->getEncodedType());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCSelectorExpr(ObjCSelectorExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitName(S->getSelector());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCProtocolExpr(ObjCProtocolExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitDecl(S->getProtocol());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitDecl(S->getDecl());
|
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
ID.AddBoolean(S->isFreeIvar());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) {
|
|
|
|
VisitExpr(S);
|
2010-12-02 01:19:52 +00:00
|
|
|
if (S->isImplicitProperty()) {
|
|
|
|
VisitDecl(S->getImplicitPropertyGetter());
|
|
|
|
VisitDecl(S->getImplicitPropertySetter());
|
|
|
|
} else {
|
|
|
|
VisitDecl(S->getExplicitProperty());
|
2010-10-14 16:04:05 +00:00
|
|
|
}
|
|
|
|
if (S->isSuperReceiver()) {
|
|
|
|
ID.AddBoolean(S->isSuperReceiver());
|
2010-12-02 01:19:52 +00:00
|
|
|
VisitType(S->getSuperReceiverType());
|
2010-10-14 16:04:05 +00:00
|
|
|
}
|
2009-07-28 14:44:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCMessageExpr(ObjCMessageExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
VisitName(S->getSelector());
|
|
|
|
VisitDecl(S->getMethodDecl());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
|
|
|
|
VisitExpr(S);
|
|
|
|
ID.AddBoolean(S->isArrow());
|
|
|
|
}
|
|
|
|
|
2009-07-28 15:32:17 +00:00
|
|
|
void StmtProfiler::VisitDecl(Decl *D) {
|
2009-07-31 15:45:02 +00:00
|
|
|
ID.AddInteger(D? D->getKind() : 0);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-30 23:18:24 +00:00
|
|
|
if (Canonical && D) {
|
2009-07-31 05:24:01 +00:00
|
|
|
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
|
2009-07-28 15:32:17 +00:00
|
|
|
ID.AddInteger(NTTP->getDepth());
|
|
|
|
ID.AddInteger(NTTP->getIndex());
|
2011-01-05 15:48:55 +00:00
|
|
|
ID.AddBoolean(NTTP->isParameterPack());
|
2009-07-29 16:09:57 +00:00
|
|
|
VisitType(NTTP->getType());
|
2009-07-28 00:33:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-31 15:45:02 +00:00
|
|
|
if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
|
|
|
|
// The Itanium C++ ABI uses the type of a parameter when mangling
|
|
|
|
// expressions that involve function parameters, so we will use the
|
|
|
|
// parameter's type for establishing function parameter identity. That
|
2009-09-09 15:08:12 +00:00
|
|
|
// way, our definition of "equivalent" (per C++ [temp.over.link])
|
2009-07-31 15:45:02 +00:00
|
|
|
// matches the definition of "equivalent" used for name mangling.
|
|
|
|
VisitType(Parm->getType());
|
|
|
|
return;
|
|
|
|
}
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-31 15:46:56 +00:00
|
|
|
if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
|
|
|
|
ID.AddInteger(TTP->getDepth());
|
|
|
|
ID.AddInteger(TTP->getIndex());
|
2011-01-05 15:48:55 +00:00
|
|
|
ID.AddBoolean(TTP->isParameterPack());
|
2009-07-31 15:46:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 15:32:17 +00:00
|
|
|
ID.AddPointer(D? D->getCanonicalDecl() : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitType(QualType T) {
|
|
|
|
if (Canonical)
|
|
|
|
T = Context.getCanonicalType(T);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
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);
|
2009-09-09 15:08:12 +00:00
|
|
|
|
2009-07-28 00:33:38 +00:00
|
|
|
Name.Profile(ID);
|
|
|
|
}
|
|
|
|
|
2009-10-29 08:12:44 +00:00
|
|
|
void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
|
2009-07-28 00:33:38 +00:00
|
|
|
unsigned NumArgs) {
|
|
|
|
ID.AddInteger(NumArgs);
|
2009-10-29 08:12:44 +00:00
|
|
|
for (unsigned I = 0; I != NumArgs; ++I)
|
|
|
|
VisitTemplateArgument(Args[I].getArgument());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
|
|
|
|
// Mostly repetitive with TemplateArgument::Profile!
|
|
|
|
ID.AddInteger(Arg.getKind());
|
|
|
|
switch (Arg.getKind()) {
|
|
|
|
case TemplateArgument::Null:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TemplateArgument::Type:
|
|
|
|
VisitType(Arg.getAsType());
|
|
|
|
break;
|
|
|
|
|
2009-11-11 01:00:40 +00:00
|
|
|
case TemplateArgument::Template:
|
2011-01-05 18:58:31 +00:00
|
|
|
case TemplateArgument::TemplateExpansion:
|
|
|
|
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
|
2009-11-11 01:00:40 +00:00
|
|
|
break;
|
2010-05-05 15:23:54 +00:00
|
|
|
|
2009-10-29 08:12:44 +00:00
|
|
|
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:
|
|
|
|
const TemplateArgument *Pack = Arg.pack_begin();
|
|
|
|
for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
|
|
|
|
VisitTemplateArgument(Pack[i]);
|
|
|
|
break;
|
2009-07-28 00:33:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-12 09:06:06 +00:00
|
|
|
void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
|
2009-07-28 00:33:38 +00:00
|
|
|
bool Canonical) {
|
|
|
|
StmtProfiler Profiler(ID, Context, Canonical);
|
|
|
|
Profiler.Visit(this);
|
|
|
|
}
|