From 809500fc2c13c8173a16b052304d983864e4a1e1 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 8 Apr 2013 18:45:10 +0000 Subject: Vendor import of clang trunk r178860: http://llvm.org/svn/llvm-project/cfe/trunk@178860 --- lib/Sema/IdentifierResolver.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/Sema/IdentifierResolver.cpp') diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index 7d5530442f48..d44c1fb926f5 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -13,12 +13,11 @@ //===----------------------------------------------------------------------===// #include "clang/Sema/IdentifierResolver.h" -#include "clang/Sema/Scope.h" #include "clang/AST/Decl.h" -#include "clang/AST/DeclObjC.h" #include "clang/Basic/LangOptions.h" #include "clang/Lex/ExternalPreprocessorSource.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Sema/Scope.h" using namespace clang; @@ -108,8 +107,7 @@ IdentifierResolver::~IdentifierResolver() { /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns /// true if 'D' belongs to the given declaration context. -bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, - ASTContext &Context, Scope *S, +bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S, bool ExplicitInstantiationOrSpecialization) const { Ctx = Ctx->getRedeclContext(); @@ -304,6 +302,14 @@ static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New) { // If the declarations are redeclarations of each other, keep the newest one. if (Existing->getCanonicalDecl() == New->getCanonicalDecl()) { + // If either of these is the most recent declaration, use it. + Decl *MostRecent = Existing->getMostRecentDecl(); + if (Existing == MostRecent) + return DMK_Ignore; + + if (New == MostRecent) + return DMK_Replace; + // If the existing declaration is somewhere in the previous declaration // chain of the new declaration, then prefer the new declaration. for (Decl::redecl_iterator RD = New->redecls_begin(), -- cgit v1.3