diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-01 20:13:04 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-01 20:13:04 +0000 |
commit | 81d3c04b0934c43518355289ad104d34f6fde06f (patch) | |
tree | 85cfa23c0d3722ee5c704096ca4a84890773de47 | |
parent | 11ab79030938209f50691acae0ddb65e72a58ca9 (diff) |
Do not compare invalid source locations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117946 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/libclang/CIndex.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 279e0fb3a2..44493497bd 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3635,7 +3635,9 @@ enum CXChildVisitResult AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { CXSourceLocation Loc = clang_getCursorLocation(cursor); SourceRange cursorRange = getRawCursorExtent(cursor); - + if (cursorRange.isInvalid()) + return CXChildVisit_Recurse; + if (clang_isPreprocessing(cursor.kind)) { // For macro instantiations, just note where the beginning of the macro // instantiation occurs. @@ -3644,9 +3646,6 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { return CXChildVisit_Recurse; } - if (cursorRange.isInvalid()) - return CXChildVisit_Continue; - // Items in the preprocessing record are kept separate from items in // declarations, so we keep a separate token index. unsigned SavedTokIdx = TokIdx; @@ -3711,13 +3710,13 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { if (TypeSourceInfo *TI = DD->getTypeSourceInfo()) { TypeLoc TL = TI->getTypeLoc(); SourceLocation TLoc = TL.getSourceRange().getBegin(); - if (TLoc.isValid() && + if (TLoc.isValid() && L.isValid() && SrcMgr.isBeforeInTranslationUnit(TLoc, L)) cursorRange.setBegin(TLoc); } } } - + // If the location of the cursor occurs within a macro instantiation, record // the spelling location of the cursor in our annotation map. We can then // paper over the token labelings during a post-processing step to try and |