]> granicus.if.org Git - clang/commitdiff
Don't create a null reference in ASTUnit::LoadFromCommandLine.
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 28 Aug 2014 23:51:01 +0000 (23:51 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 28 Aug 2014 23:51:01 +0000 (23:51 +0000)
This change is the last in the pack of five commits
(also see r216691, r216694, r216695, and r216696) that reduces the number
of test failures in "check-clang" invocation in UBSan bootstrap
from 2443 down to 5.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216697 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp

index 31dbc7a44ce6de612049704d150bd85dc8a1d72d..31266dca92803aeb2333760824b3bf0c289a27d6 100644 (file)
@@ -1985,7 +1985,6 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   AST.reset(new ASTUnit(false));
   ConfigureDiags(Diags, ArgBegin, ArgEnd, *AST, CaptureDiagnostics);
   AST->Diagnostics = Diags;
-  Diags = nullptr; // Zero out now to ease cleanup during crash recovery.
   AST->FileSystemOpts = CI->getFileSystemOpts();
   IntrusiveRefCntPtr<vfs::FileSystem> VFS =
       createVFSFromCompilerInvocation(*CI, *Diags);
@@ -2004,7 +2003,9 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   AST->Invocation = CI;
   if (ForSerialization)
     AST->WriterData.reset(new ASTWriterData());
-  CI = nullptr; // Zero out now to ease cleanup during crash recovery.
+  // Zero out now to ease cleanup during crash recovery.
+  CI = nullptr;
+  Diags = nullptr;
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>