]> granicus.if.org Git - clang/commitdiff
Per Doug's suggestion, move check for invalid SourceLocation into
authorTed Kremenek <kremenek@apple.com>
Mon, 28 Jun 2010 23:54:17 +0000 (23:54 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 28 Jun 2010 23:54:17 +0000 (23:54 +0000)
cxloc::translateSourceLocation() (thus causing all clients of this
function to have the same behavior).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107101 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp
tools/libclang/CXSourceLocation.h

index e19cd4214f4cace0b9ab6566bf1416280118d2b5..ce9357de330d7bf72a23fc7fa79973b1733b629d 100644 (file)
@@ -1417,9 +1417,7 @@ CXSourceLocation clang_getLocation(CXTranslationUnit tu,
                                         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() {
index 235f78c5a1b69572002747fffce9aeccc45cb469..7a502059634a5a7127cb728c1b47e9ac664cc49d 100644 (file)
@@ -29,6 +29,9 @@ namespace cxloc {
 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;