diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-31 05:24:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-31 05:24:01 +0000 |
commit | 6ebd15e81a4d44ac51c24bffe2705586d5edffee (patch) | |
tree | b57041beac0b668b9f9131f0e589a0997f8fc3dc /lib/AST/ASTContext.cpp | |
parent | 2ec09f1dc123e1942ed756e8ee4fef86451eac9e (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/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 1b73679beb..c4740843e5 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2118,9 +2118,25 @@ TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) { // If this template name refers to a set of overloaded function templates, /// the canonical template name merely stores the set of function templates. - if (OverloadedFunctionDecl *Ovl = Name.getAsOverloadedFunctionDecl()) - // FIXME: Can't really canonicalize a set of overloaded functions, can we? - return TemplateName(Ovl); + if (OverloadedFunctionDecl *Ovl = Name.getAsOverloadedFunctionDecl()) { + OverloadedFunctionDecl *CanonOvl = 0; + for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(), + FEnd = Ovl->function_end(); + F != FEnd; ++F) { + Decl *Canon = F->get()->getCanonicalDecl(); + if (CanonOvl || Canon != F->get()) { + if (!CanonOvl) + CanonOvl = OverloadedFunctionDecl::Create(*this, + Ovl->getDeclContext(), + Ovl->getDeclName()); + + CanonOvl->addOverload( + AnyFunctionDecl::getFromNamedDecl(cast<NamedDecl>(Canon))); + } + } + + return TemplateName(CanonOvl? CanonOvl : Ovl); + } DependentTemplateName *DTN = Name.getAsDependentTemplateName(); assert(DTN && "Non-dependent template names must refer to template decls."); |