summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-03-03 08:04:19 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-03-03 08:04:19 +0000
commitf0b4cd1ed3b2a7b20a08253ae915255a51366fc3 (patch)
treef70baca42f69a30cbbc4a7a4b589bfa4c6e86790 /clang/lib/Frontend/ASTUnit.cpp
parentb1de8c2b73b77e18f2d022425dc01d69a5afe522 (diff)
downloadbcm5719-llvm-f0b4cd1ed3b2a7b20a08253ae915255a51366fc3.tar.gz
bcm5719-llvm-f0b4cd1ed3b2a7b20a08253ae915255a51366fc3.zip
[ASTUnit] Fix crash when trying to load a module file via ASTUnit::LoadFromASTFile.
rdar://19997358 llvm-svn: 231060
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index bfb1efe3522..d153ca245c3 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -714,6 +714,13 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
*AST->PP, Context, AST->ASTFileLangOpts, AST->TargetOpts, AST->Target,
Counter));
+ // Attach the AST reader to the AST context as an external AST
+ // source, so that declarations will be deserialized from the
+ // AST file as needed.
+ // We need the external source to be set up before we read the AST, because
+ // eagerly-deserialized declarations may use it.
+ Context.setExternalSource(AST->Reader);
+
switch (AST->Reader->ReadAST(Filename, serialization::MK_MainFile,
SourceLocation(), ASTReader::ARR_None)) {
case ASTReader::Success:
@@ -733,11 +740,6 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
PP.setCounterValue(Counter);
- // Attach the AST reader to the AST context as an external AST
- // source, so that declarations will be deserialized from the
- // AST file as needed.
- Context.setExternalSource(AST->Reader);
-
// Create an AST consumer, even though it isn't used.
AST->Consumer.reset(new ASTConsumer);
OpenPOWER on IntegriCloud