]> granicus.if.org Git - clang/commit
When the ASTImporter imports a source location, it avoids importing macro
authorSean Callanan <scallanan@apple.com>
Mon, 7 Nov 2016 20:42:25 +0000 (20:42 +0000)
committerSean Callanan <scallanan@apple.com>
Mon, 7 Nov 2016 20:42:25 +0000 (20:42 +0000)
commit2d91c3ae7263449c2f49a4217187a5cf7ff35d55
treefd4cd2d2dbf7b6d0d66071cb67494e853a468a4c
parent777d844d0f09ca78023557ac0c8318d6061c4188
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286144 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ASTImporter.cpp
test/ASTMerge/Inputs/macro.modulemap [new file with mode: 0644]
test/ASTMerge/Inputs/macro1.h [new file with mode: 0644]
test/ASTMerge/Inputs/macro1.m [new file with mode: 0644]
test/ASTMerge/Inputs/macro2.m [new file with mode: 0644]
test/ASTMerge/macro.m [new file with mode: 0644]