[cfe-commits] r107101 - in /cfe/trunk/tools/libclang: CIndex.cpp CXSourceLocation.h

Ted Kremenek kremenek at apple.com
Mon Jun 28 16:54:17 PDT 2010


Author: kremenek
Date: Mon Jun 28 18:54:17 2010
New Revision: 107101

URL: http://llvm.org/viewvc/llvm-project?rev=107101&view=rev
Log:
Per Doug's suggestion, move check for invalid SourceLocation into
cxloc::translateSourceLocation() (thus causing all clients of this
function to have the same behavior).

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CXSourceLocation.h

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=107101&r1=107100&r2=107101&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Jun 28 18:54:17 2010
@@ -1417,9 +1417,7 @@
                                         static_cast<const FileEntry *>(file),
                                               line, column);
 
-  return SLoc.isInvalid() ?
-           clang_getNullLocation() :
-           cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
+  return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
 }
 
 CXSourceRange clang_getNullRange() {

Modified: cfe/trunk/tools/libclang/CXSourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXSourceLocation.h?rev=107101&r1=107100&r2=107101&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXSourceLocation.h (original)
+++ cfe/trunk/tools/libclang/CXSourceLocation.h Mon Jun 28 18:54:17 2010
@@ -29,6 +29,9 @@
 static inline CXSourceLocation 
 translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
                         SourceLocation Loc) {
+  if (Loc.isInvalid())
+    clang_getNullLocation();
+
   CXSourceLocation Result = { { (void*) &SM, (void*) &LangOpts, },
                               Loc.getRawEncoding() };
   return Result;





More information about the cfe-commits mailing list