forked from OSchip/llvm-project
[modules] Separately track whether an identifier's preprocessor information and
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). llvm-svn: 259901
This commit is contained in:
parent
1242ce9695
commit
d79514e24b
clang
include/clang/Basic
lib
test/Modules
|
@ -62,6 +62,9 @@ class IdentifierInfo {
|
|||
// 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
|
||||
|
@ -69,7 +72,7 @@ class IdentifierInfo {
|
|||
// 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;
|
||||
|
@ -303,6 +306,18 @@ public:
|
|||
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; }
|
||||
|
|
|
@ -42,6 +42,7 @@ IdentifierInfo::IdentifierInfo() {
|
|||
NeedsHandleIdentifier = false;
|
||||
IsFromAST = false;
|
||||
ChangedAfterLoad = false;
|
||||
FEChangedAfterLoad = false;
|
||||
RevertedTokenID = false;
|
||||
OutOfDate = false;
|
||||
IsModulesImport = false;
|
||||
|
|
|
@ -381,7 +381,7 @@ void IdentifierResolver::updatingIdentifier(IdentifierInfo &II) {
|
|||
PP.getExternalSource()->updateOutOfDateIdentifier(II);
|
||||
|
||||
if (II.isFromAST())
|
||||
II.setChangedSinceDeserialization();
|
||||
II.setFETokenInfoChangedSinceDeserialization();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -3162,6 +3162,8 @@ public:
|
|||
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());
|
||||
}
|
||||
|
@ -3307,7 +3309,9 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// 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
|
Loading…
Reference in New Issue