From efc6cb24dd1fc8bf663e7bbcf8774e5a5ca04f42 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Thu, 28 Aug 2014 23:51:01 +0000 Subject: [PATCH] Don't create a null reference in ASTUnit::LoadFromCommandLine. 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 31dbc7a44c..31266dca92 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -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 = 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 -- 2.40.0