зеркало из https://github.com/microsoft/clang-1.git
Don't try to write a macro offset for an identifier that names a non-exported macro, for real this time
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
5ed6277d2e
Коммит
ce835df930
|
@ -2223,24 +2223,23 @@ class ASTIdentifierTableTrait {
|
|||
/// that needs a full IdentifierInfo structure written into the hash
|
||||
/// table.
|
||||
bool isInterestingIdentifier(IdentifierInfo *II, MacroInfo *&Macro) {
|
||||
Macro = 0;
|
||||
|
||||
if (II->isPoisoned() ||
|
||||
II->isExtensionToken() ||
|
||||
II->getObjCOrBuiltinID() ||
|
||||
II->getFETokenInfo<void>())
|
||||
return true;
|
||||
|
||||
return hasMacroDefinition(II, Macro);
|
||||
}
|
||||
|
||||
bool hasMacroDefinition(IdentifierInfo *II, MacroInfo *&Macro) {
|
||||
if (!II->hasMacroDefinition())
|
||||
return false;
|
||||
|
||||
if (!IsModule)
|
||||
return true;
|
||||
if (Macro || (Macro = PP.getMacroInfo(II)))
|
||||
return !Macro->isBuiltinMacro() && (!IsModule || Macro->isExported());
|
||||
|
||||
if ((Macro = PP.getMacroInfo(II)))
|
||||
return Macro->isExported();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -2261,11 +2260,10 @@ public:
|
|||
EmitKeyDataLength(raw_ostream& Out, IdentifierInfo* II, IdentID ID) {
|
||||
unsigned KeyLen = II->getLength() + 1;
|
||||
unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
|
||||
MacroInfo *Macro;
|
||||
MacroInfo *Macro = 0;
|
||||
if (isInterestingIdentifier(II, Macro)) {
|
||||
DataLen += 2; // 2 bytes for builtin ID, flags
|
||||
if (II->hasMacroDefinition() &&
|
||||
!PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
|
||||
if (hasMacroDefinition(II, Macro))
|
||||
DataLen += 4;
|
||||
for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
|
||||
DEnd = IdentifierResolver::end();
|
||||
|
@ -2290,7 +2288,7 @@ public:
|
|||
|
||||
void EmitData(raw_ostream& Out, IdentifierInfo* II,
|
||||
IdentID ID, unsigned) {
|
||||
MacroInfo *Macro;
|
||||
MacroInfo *Macro = 0;
|
||||
if (!isInterestingIdentifier(II, Macro)) {
|
||||
clang::io::Emit32(Out, ID << 1);
|
||||
return;
|
||||
|
@ -2298,18 +2296,16 @@ public:
|
|||
|
||||
clang::io::Emit32(Out, (ID << 1) | 0x01);
|
||||
uint32_t Bits = 0;
|
||||
bool hasMacroDefinition
|
||||
= II->hasMacroDefinition() &&
|
||||
(Macro || (Macro = PP.getMacroInfo(II))) && !Macro->isBuiltinMacro();
|
||||
bool HasMacroDefinition = hasMacroDefinition(II, Macro);
|
||||
Bits = (uint32_t)II->getObjCOrBuiltinID();
|
||||
Bits = (Bits << 1) | unsigned(hasMacroDefinition);
|
||||
Bits = (Bits << 1) | unsigned(HasMacroDefinition);
|
||||
Bits = (Bits << 1) | unsigned(II->isExtensionToken());
|
||||
Bits = (Bits << 1) | unsigned(II->isPoisoned());
|
||||
Bits = (Bits << 1) | unsigned(II->hasRevertedTokenIDToIdentifier());
|
||||
Bits = (Bits << 1) | unsigned(II->isCPlusPlusOperatorKeyword());
|
||||
clang::io::Emit16(Out, Bits);
|
||||
|
||||
if (hasMacroDefinition)
|
||||
if (HasMacroDefinition)
|
||||
clang::io::Emit32(Out, Writer.getMacroOffset(II));
|
||||
|
||||
// Emit the declaration IDs in reverse order, because the
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#__export_macro__ INTEGER
|
||||
#__export_macro__ DOUBLE
|
||||
|
||||
int (INTEGER);
|
||||
|
||||
#else
|
||||
|
||||
__import_module__ macros;
|
||||
|
@ -30,4 +32,7 @@ DOUBLE *dp = &d;
|
|||
|
||||
#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
|
||||
|
||||
void f() {
|
||||
int i = INTEGER; // the value was exported, the macro was not.
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче