// 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(),
return StringRef((const char*) d, n-1);
}
+/// \brief Whether the given identifier is "interesting".
+static bool isInterestingIdentifier(IdentifierInfo &II) {
+ return II.isPoisoned() ||
+ II.isExtensionToken() ||
+ II.getObjCOrBuiltinID() ||
+ II.hasRevertedTokenIDToIdentifier() ||
+ II.hadMacroDefinition() ||
+ II.getFETokenInfo<void>();
+}
+
IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
const unsigned char* d,
unsigned DataLen) {
KnownII = II;
}
Reader.SetIdentifierInfo(ID, II);
- II->setIsFromAST();
- Reader.markIdentifierUpToDate(II);
+ if (!II->isFromAST()) {
+ bool WasInteresting = isInterestingIdentifier(*II);
+ II->setIsFromAST();
+ if (WasInteresting)
+ II->setChangedSinceDeserialization();
+ }
+ Reader.markIdentifierUpToDate(II);
return II;
}
KnownII = II;
}
Reader.markIdentifierUpToDate(II);
- II->setIsFromAST();
+ if (!II->isFromAST()) {
+ bool WasInteresting = isInterestingIdentifier(*II);
+ II->setIsFromAST();
+ if (WasInteresting)
+ II->setChangedSinceDeserialization();
+ }
// Set or check the various bits in the IdentifierInfo structure.
// Token IDs are read-only.
export *
}
module redecl_merge_bottom {
+ explicit module prefix {
+ header "redecl-merge-bottom-prefix.h"
+ }
+
header "redecl-merge-bottom.h"
export *
}
--- /dev/null
+// A class that is declared in the 'bottom' module, then loaded from
+// one of the modules it depends on. It needs to be visible when this
+// module is loaded.
+@class DeclaredThenLoaded;
void refers_to_C4(C4*);
+@interface UnrelatedToDeclaredThenLoaded
+- declaredThenLoadedMethod;
+@end
+
+@class DeclaredThenLoaded;
// top level.
typedef void funcptr_with_id(int id);
+// A class that is declared in the 'bottom' module, then loaded from
+// one of the modules it depends on.
+@interface DeclaredThenLoaded
+- declaredThenLoadedMethod;
+@end
+
+@class DeclaredThenLoaded;
+
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -Wno-objc-root-class
+// expected-no-diagnostics
+
+@import redecl_merge_bottom.prefix;
+
+DeclaredThenLoaded *dtl;
+