diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-17 21:46:03 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-17 21:46:03 +0000 |
commit | baf3ca5c0101cd4b2d26a0a7da013edb55b3ab5d (patch) | |
tree | 15e6a192fda263b0355fe4b5df8023c1139f6e6c /clang/lib/AST/Decl.cpp | |
parent | ba419ce21d0cc6083e44cc5555158750d876c943 (diff) | |
download | bcm5719-llvm-baf3ca5c0101cd4b2d26a0a7da013edb55b3ab5d.tar.gz bcm5719-llvm-baf3ca5c0101cd4b2d26a0a7da013edb55b3ab5d.zip |
Don't fold together the name lookup entries for two declarations if they are
declared in different namespaces in the same inline namespace set.
llvm-svn: 204082
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a61af50c480..050e61c1f87 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1381,6 +1381,7 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { if (isa<ObjCMethodDecl>(this)) return false; + // FIXME: Is this correct if one of the decls comes from an inline namespace? if (isa<ObjCInterfaceDecl>(this) && isa<ObjCCompatibleAliasDecl>(OldD)) return true; @@ -1407,14 +1408,19 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { // A typedef of an Objective-C class type can replace an Objective-C class // declaration or definition, and vice versa. + // FIXME: Is this correct if one of the decls comes from an inline namespace? if ((isa<TypedefNameDecl>(this) && isa<ObjCInterfaceDecl>(OldD)) || (isa<ObjCInterfaceDecl>(this) && isa<TypedefNameDecl>(OldD))) return true; - + // For non-function declarations, if the declarations are of the - // same kind then this must be a redeclaration, or semantic analysis - // would not have given us the new declaration. - return this->getKind() == OldD->getKind(); + // same kind and have the same parent then this must be a redeclaration, + // or semantic analysis would not have given us the new declaration. + // Note that inline namespaces can give us two declarations with the same + // name and kind in the same scope but different contexts. + return this->getKind() == OldD->getKind() && + this->getDeclContext()->getRedeclContext()->Equals( + OldD->getDeclContext()->getRedeclContext()); } bool NamedDecl::hasLinkage() const { |