name lookup information have changed since deserialization. For a C++ modules
build, we do not need to re-emit the identifier into the serialized identifier
table if only the name lookup information has changed (and in all cases, we
don't need to re-emit the macro information if only the name lookup information
has changed).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259901
91177308-0d34-0410-b5e6-
96231b3b80d8
// partially) from an AST file.
bool ChangedAfterLoad : 1; // True if identifier has changed from the
// definition loaded from an AST file.
+ bool FEChangedAfterLoad : 1; // True if identifier's frontend information
+ // has changed from the definition loaded
+ // from an AST file.
bool RevertedTokenID : 1; // True if revertTokenIDToIdentifier was
// called.
bool OutOfDate : 1; // True if there may be additional
// stored externally.
bool IsModulesImport : 1; // True if this is the 'import' contextual
// keyword.
- // 30 bit left in 64-bit word.
+ // 29 bit left in 64-bit word.
void *FETokenInfo; // Managed by the language front-end.
llvm::StringMapEntry<IdentifierInfo*> *Entry;
ChangedAfterLoad = true;
}
+ /// \brief Determine whether the frontend token information for this
+ /// identifier has changed since it was loaded from an AST file.
+ bool hasFETokenInfoChangedSinceDeserialization() const {
+ return FEChangedAfterLoad;
+ }
+
+ /// \brief Note that the frontend token information for this identifier has
+ /// changed since it was loaded from an AST file.
+ void setFETokenInfoChangedSinceDeserialization() {
+ FEChangedAfterLoad = true;
+ }
+
/// \brief Determine whether the information for this identifier is out of
/// date with respect to the external source.
bool isOutOfDate() const { return OutOfDate; }
NeedsHandleIdentifier = false;
IsFromAST = false;
ChangedAfterLoad = false;
+ FEChangedAfterLoad = false;
RevertedTokenID = false;
OutOfDate = false;
IsModulesImport = false;
PP.getExternalSource()->updateOutOfDateIdentifier(II);
if (II.isFromAST())
- II.setChangedSinceDeserialization();
+ II.setFETokenInfoChangedSinceDeserialization();
}
//===----------------------------------------------------------------------===//
NeedDecls(!IsModule || !Writer.getLangOpts().CPlusPlus),
InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
+ bool needDecls() const { return NeedDecls; }
+
static hash_value_type ComputeHash(const IdentifierInfo* II) {
return llvm::HashString(II->getName());
}
auto *II = const_cast<IdentifierInfo *>(IdentIDPair.first);
IdentID ID = IdentIDPair.second;
assert(II && "NULL identifier in identifier table");
- if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
+ if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization() ||
+ (Trait.needDecls() &&
+ II->hasFETokenInfoChangedSinceDeserialization()))
Generator.insert(II, ID, Trait);
}
--- /dev/null
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'extern int some_long_variable_name;' > %t/x.h
+// RUN: echo 'extern int some_long_variable_name;' > %t/y.h
+// RUN: echo 'module X { header "x.h" } module Y { header "y.h" }' > %t/map
+// RUN: %clang_cc1 -fmodules -x c++ -fmodule-name=X %t/map -emit-module -o %t/x.pcm
+// RUN: %clang_cc1 -fmodules -x c++ -fmodule-name=Y %t/map -fmodule-file=%t/x.pcm -emit-module -o %t/y.pcm
+// RUN: cat %t/y.pcm | FileCheck %s
+//
+// CHECK-NOT: some_long_variable_name