diff options
| author | Sean Callanan <scallanan@apple.com> | 2016-11-07 20:42:25 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2016-11-07 20:42:25 +0000 |
| commit | 24c5fe6b343eaf2d1261786f573fd3d866b15ef9 (patch) | |
| tree | af16e9795b1e8de3dbaf7b00209313a015b52941 /clang/lib | |
| parent | 5caae908b71c9a4f94a96e336b674f07598fe525 (diff) | |
| download | bcm5719-llvm-24c5fe6b343eaf2d1261786f573fd3d866b15ef9.tar.gz bcm5719-llvm-24c5fe6b343eaf2d1261786f573fd3d866b15ef9.zip | |
When the ASTImporter imports a source location, it avoids importing macro
expansions by calling getSpellingLoc(). That's great in most cases, but for
macros defined in the '<built-in>' source file, the source file is invalid
and does not import correctly, causing an assertion failure (the assertion
is Invalid SLocOffset or bad function choice).
A more reliable way to avoid this is to use getFileLoc(), which does not
return built-in locations. This avoids the crash but still preserves valid
source locations.
I've added a testcase that covers the previously crashing scenario.
https://reviews.llvm.org/D26054
llvm-svn: 286144
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 9e17c0c3de5..e783854448b 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -6943,10 +6943,10 @@ SourceLocation ASTImporter::Import(SourceLocation FromLoc) { SourceManager &FromSM = FromContext.getSourceManager(); - // For now, map everything down to its spelling location, so that we + // For now, map everything down to its file location, so that we // don't have to import macro expansions. // FIXME: Import macro expansions! - FromLoc = FromSM.getSpellingLoc(FromLoc); + FromLoc = FromSM.getFileLoc(FromLoc); std::pair<FileID, unsigned> Decomposed = FromSM.getDecomposedLoc(FromLoc); SourceManager &ToSM = ToContext.getSourceManager(); FileID ToFileID = Import(Decomposed.first); |

