[cfe-commits] r142430 - in /cfe/trunk: include/clang/Basic/SourceManager.h tools/libclang/CIndex.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Oct 18 14:59:55 PDT 2011


Author: akirtzidis
Date: Tue Oct 18 16:59:54 2011
New Revision: 142430

URL: http://llvm.org/viewvc/llvm-project?rev=142430&view=rev
Log:
[libclang] Make sure we do a correct invalid check in clang_getExpansionLocation.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=142430&r1=142429&r2=142430&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Oct 18 16:59:54 2011
@@ -1213,6 +1213,10 @@
   }
 
   const SrcMgr::SLocEntry &getSLocEntry(FileID FID, bool *Invalid = 0) const {
+    if (FID.ID == 0 || FID.ID == -1) {
+      if (Invalid) *Invalid = true;
+      return LocalSLocEntryTable[0];
+    }
     return getSLocEntryByID(FID.ID);
   }
 

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=142430&r1=142429&r2=142430&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Oct 18 16:59:54 2011
@@ -2814,7 +2814,7 @@
   FileID fileID = SM.getFileID(ExpansionLoc);
   bool Invalid = false;
   const SrcMgr::SLocEntry &sloc = SM.getSLocEntry(fileID, &Invalid);
-  if (!sloc.isFile() || Invalid) {
+  if (Invalid || !sloc.isFile()) {
     createNullLocation(file, line, column, offset);
     return;
   }





More information about the cfe-commits mailing list