Per Doug's suggestion, move check for invalid SourceLocation into

cxloc::translateSourceLocation() (thus causing all clients of this
function to have the same behavior).

llvm-svn: 107101
This commit is contained in:
Ted Kremenek 2010-06-28 23:54:17 +00:00
parent 8d38ac4536
commit 5414027020
2 changed files with 4 additions and 3 deletions

View 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() {

View 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;