diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-12 01:05:25 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-12-12 01:05:25 +0000 |
commit | 12023e1ec355ff4c1ac2ab8d71600faf1651575c (patch) | |
tree | 501df48b3819a0ff873e18643ae7d75e1d2ca6a9 /clang/tools/libclang/CIndex.cpp | |
parent | 29a2ffc7aa82fc64b1f9cd0bcf249822f7345305 (diff) | |
download | bcm5719-llvm-12023e1ec355ff4c1ac2ab8d71600faf1651575c.tar.gz bcm5719-llvm-12023e1ec355ff4c1ac2ab8d71600faf1651575c.zip |
[libclang] Make sure tokens from preprocessor directives are annotated as such,
even if the directive is inside a declaration.
Fixes rdar://11548788 & http://llvm.org/PR12970
llvm-svn: 169949
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index c0f3f571a4a..1fb9a70336a 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -4935,9 +4935,7 @@ void AnnotateTokensWorker::AnnotateTokens() { for (unsigned I = 0 ; I < TokIdx ; ++I) { AnnotateTokensData::iterator Pos = Annotated.find(Tokens[I].int_data[1]); - if (Pos != Annotated.end() && - (clang_isInvalid(Cursors[I].kind) || - Pos->second.kind != CXCursor_PreprocessingDirective)) + if (Pos != Annotated.end() && !clang_isPreprocessing(Cursors[I].kind)) Cursors[I] = Pos->second; } @@ -5067,13 +5065,6 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { } if (clang_isPreprocessing(cursor.kind)) { - // For macro expansions, just note where the beginning of the macro - // expansion occurs. - if (cursor.kind == CXCursor_MacroExpansion) { - Annotated[Loc.int_data] = cursor; - return CXChildVisit_Recurse; - } - // Items in the preprocessing record are kept separate from items in // declarations, so we keep a separate token index. unsigned SavedTokIdx = TokIdx; @@ -5107,6 +5098,10 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { case RangeOverlap: Cursors[I] = cursor; AdvanceToken(); + // For macro expansions, just note where the beginning of the macro + // expansion occurs. + if (cursor.kind == CXCursor_MacroExpansion) + break; continue; } break; |