[clang] [Modules] Fix an identifier hiding a function-like macro definition. (PR #135471)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 14 15:27:03 PDT 2025
================
@@ -3871,7 +3874,8 @@ class ASTIdentifierTableTrait {
if (isInterestingIdentifier(II, MacroOffset)) {
DataLen += 2; // 2 bytes for builtin ID
DataLen += 2; // 2 bytes for flags
- if (MacroOffset)
+ if (MacroOffset || (II->hasMacroDefinition() &&
+ II->hasFETokenInfoChangedSinceDeserialization()))
----------------
jansvoboda11 wrote:
Ah, I see that `ASTReader` does this for each `ModuleFile`:
```c++
for (auto Offset : F.PreloadIdentifierOffsets) {
// ...
IdentifierInfo *II;
if (!PP.getLangOpts().CPlusPlus) {
// Identifiers present in both the module file and the importing
// instance are marked out-of-date so that they can be deserialized
// on next use via ASTReader::updateOutOfDateIdentifier().
// Identifiers present in the module file but not in the importing
// instance are ignored for now, preventing growth of the identifier
// table. They will be deserialized on first use via ASTReader::get().
auto It = PP.getIdentifierTable().find(Key);
if (It == PP.getIdentifierTable().end())
continue;
II = It->second;
} else {
// With C++ modules, not many identifiers are considered interesting.
// All identifiers in the module file can be placed into the identifier
// table of the importing instance and marked as out-of-date. This makes
// ASTReader::get() a no-op, and deserialization will take place on
// first/next use via ASTReader::updateOutOfDateIdentifier().
II = &PP.getIdentifierTable().getOwn(Key);
}
// ...
markIdentifierFromAST(*this, *II, /*IsModule=*/true);
//...
}
```
and "__Q" already is in the table, so that works out. Makes sense, thanks for walking me through it.
https://github.com/llvm/llvm-project/pull/135471
More information about the cfe-commits
mailing list