[llvm-branch-commits] [cfe-branch] r118041 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Daniel Dunbar daniel at zuster.org
Tue Nov 2 13:32:25 PDT 2010


Author: ddunbar
Date: Tue Nov  2 15:32:25 2010
New Revision: 118041

URL: http://llvm.org/viewvc/llvm-project?rev=118041&view=rev
Log:
Merge r117946:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Mon Nov 1 20:13:04 2010 +0000

    Do not compare invalid source locations

Modified:
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=118041&r1=118040&r2=118041&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Tue Nov  2 15:32:25 2010
@@ -3635,7 +3635,9 @@
 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 @@
       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 @@
       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





More information about the llvm-branch-commits mailing list