зеркало из https://github.com/microsoft/clang-1.git
Robustify PreprocessingRecord slightly, by only creating macro
instantiations when we have the corresponding macro definition and by removing macro definition information from our table when the macro is undefined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
6a5a23f8e7
Коммит
1b058e8956
|
@ -253,10 +253,11 @@ namespace clang {
|
|||
|
||||
/// \brief Retrieve the macro definition that corresponds to the given
|
||||
/// \c MacroInfo.
|
||||
MacroDefinition *findMacroDefinition(MacroInfo *MI);
|
||||
MacroDefinition *findMacroDefinition(const MacroInfo *MI);
|
||||
|
||||
virtual void MacroExpands(const Token &Id, const MacroInfo* MI);
|
||||
virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
|
||||
virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI);
|
||||
};
|
||||
} // end namespace clang
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void PreprocessingRecord::RegisterMacroDefinition(MacroInfo *Macro,
|
|||
MacroDefinitions[Macro] = MD;
|
||||
}
|
||||
|
||||
MacroDefinition *PreprocessingRecord::findMacroDefinition(MacroInfo *MI) {
|
||||
MacroDefinition *PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) {
|
||||
llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos
|
||||
= MacroDefinitions.find(MI);
|
||||
if (Pos == MacroDefinitions.end())
|
||||
|
@ -102,10 +102,11 @@ MacroDefinition *PreprocessingRecord::findMacroDefinition(MacroInfo *MI) {
|
|||
}
|
||||
|
||||
void PreprocessingRecord::MacroExpands(const Token &Id, const MacroInfo* MI) {
|
||||
PreprocessedEntities.push_back(
|
||||
if (MacroDefinition *Def = findMacroDefinition(MI))
|
||||
PreprocessedEntities.push_back(
|
||||
new (*this) MacroInstantiation(Id.getIdentifierInfo(),
|
||||
Id.getLocation(),
|
||||
MacroDefinitions[MI]));
|
||||
Def));
|
||||
}
|
||||
|
||||
void PreprocessingRecord::MacroDefined(const IdentifierInfo *II,
|
||||
|
@ -117,3 +118,11 @@ void PreprocessingRecord::MacroDefined(const IdentifierInfo *II,
|
|||
PreprocessedEntities.push_back(Def);
|
||||
}
|
||||
|
||||
void PreprocessingRecord::MacroUndefined(const IdentifierInfo *II,
|
||||
const MacroInfo *MI) {
|
||||
llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos
|
||||
= MacroDefinitions.find(MI);
|
||||
if (Pos != MacroDefinitions.end())
|
||||
MacroDefinitions.erase(Pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ int main (int argc, const char * argv[]) {
|
|||
void f() {
|
||||
int CONCAT(my,_var);
|
||||
}
|
||||
#undef CONCAT
|
||||
|
||||
// CHECK: [1:1 - 3:1] Invalid Cursor => NoDeclFound
|
||||
// CHECK: [3:1 - 7:1] ObjCInterfaceDecl=Foo:3:12
|
||||
|
|
Загрузка…
Ссылка в новой задаче