aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/StmtProfile.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-07-31 05:24:01 +0000
committerDouglas Gregor <dgregor@apple.com>2009-07-31 05:24:01 +0000
commit6ebd15e81a4d44ac51c24bffe2705586d5edffee (patch)
treeb57041beac0b668b9f9131f0e589a0997f8fc3dc /lib/AST/StmtProfile.cpp
parent2ec09f1dc123e1942ed756e8ee4fef86451eac9e (diff)
Canonicalization and profiling for overloaded function declarations,
for those extra-esoteric cases. Not that any two given C++ compilers agree on this test case, but this change gives us a strong definition of equivalent types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtProfile.cpp')
-rw-r--r--lib/AST/StmtProfile.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 8039d97731..5714c682a2 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -603,8 +603,7 @@ void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
void StmtProfiler::VisitDecl(Decl *D) {
if (Canonical && D) {
- if (NonTypeTemplateParmDecl *NTTP
- = dyn_cast<NonTypeTemplateParmDecl>(D)) {
+ if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
ID.AddInteger(NTTP->getDepth());
ID.AddInteger(NTTP->getIndex());
VisitType(NTTP->getType());
@@ -612,6 +611,29 @@ void StmtProfiler::VisitDecl(Decl *D) {
}
// FIXME: Template template parameters?
+
+ if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
+ // Canonicalize all of the function declarations within the overload
+ // set.
+ llvm::SmallVector<Decl *, 4> Functions;
+ for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
+ FEnd = Ovl->function_end();
+ F != FEnd; ++F)
+ Functions.push_back(F->get()->getCanonicalDecl());
+
+ // Sorting the functions based on the point means that the ID generated
+ // will be different from one execution of the compiler to another.
+ // Since these IDs don't persist over time, the change in ordering will
+ // not affect compilation.
+ std::sort(Functions.begin(), Functions.end());
+
+ for (llvm::SmallVector<Decl *, 4>::iterator F = Functions.begin(),
+ FEnd = Functions.end();
+ F != FEnd; ++F)
+ VisitDecl(*F);
+
+ return;
+ }
}
ID.AddPointer(D? D->getCanonicalDecl() : 0);