diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-26 17:17:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-26 17:17:01 +0000 |
commit | c56fff7fd231aebf4b152f60f8f11ef91835c48a (patch) | |
tree | 22119f54c12ae692e50e7ed4930160f950e37f2f /tools | |
parent | 1232e279b4a0d98885b9672d3bb5905488360e49 (diff) |
[Preprocessor/Modules] Separate the macro directives kinds into their own MacroDirective's subclasses.
For each macro directive (define, undefine, visibility) have a separate object that gets chained
to the macro directive history. This has several benefits:
-No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like
PPMutationListener become unnecessary.
-No need to keep extra source locations for the undef/visibility locations for the define directive object
(which is the majority of the directives)
-Much easier to hide/unhide a section in the macro directive history.
-Easier to track the effects of the directives across different submodules.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178037 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndex.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 98891269d7..3c75e441b7 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -6305,10 +6305,12 @@ MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II, ASTUnit *Unit = cxtu::getASTUnit(TU); Preprocessor &PP = Unit->getPreprocessor(); MacroDirective *MD = PP.getMacroDirectiveHistory(&II); - while (MD) { - if (MacroDefLoc == MD->getInfo()->getDefinitionLoc()) - return MD->getInfo(); - MD = MD->getPrevious(); + if (MD) { + for (MacroDirective::DefInfo + Def = MD->getDefinition(); Def; Def = Def.getPreviousDefinition()) { + if (MacroDefLoc == Def.getMacroInfo()->getDefinitionLoc()) + return Def.getMacroInfo(); + } } return 0; @@ -6364,7 +6366,7 @@ MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI, if (!InnerMD) return 0; - return PPRec->findMacroDefinition(InnerMD->getInfo()); + return PPRec->findMacroDefinition(InnerMD->getMacroInfo()); } MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI, |