forked from OSchip/llvm-project
Make clang_isFromMainFile() robust against NULL source locations.
llvm-svn: 104474
This commit is contained in:
parent
dc99965343
commit
01308a0e11
|
@ -1481,6 +1481,9 @@ CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
|
|||
|
||||
unsigned clang_isFromMainFile(CXSourceLocation loc) {
|
||||
SourceLocation Loc = SourceLocation::getFromRawEncoding(loc.int_data);
|
||||
if (!loc.ptr_data[0] || Loc.isInvalid())
|
||||
return 0;
|
||||
|
||||
const SourceManager &SM =
|
||||
*static_cast<const SourceManager*>(loc.ptr_data[0]);
|
||||
return SM.isFromMainFile(Loc) ? 1 : 0;
|
||||
|
|
Loading…
Reference in New Issue