From: Nico Weber Date: Mon, 6 Apr 2015 04:16:48 +0000 (+0000) Subject: Don't crash when passing a non-existent file to -fprofile-instr-use=. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1259fb859d727be32dafd6e5905c8f4e15874e5d;p=clang Don't crash when passing a non-existent file to -fprofile-instr-use=. Fixes a regression from r229434. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234141 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 7fce6208d4..dd9d6305ca 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -147,8 +147,8 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, "Could not read profile: %0"); getDiags().Report(DiagID) << EC.message(); - } - PGOReader = std::move(ReaderOrErr.get()); + } else + PGOReader = std::move(ReaderOrErr.get()); } // If coverage mapping generation is enabled, create the diff --git a/test/Profile/profile-does-not-exist.c b/test/Profile/profile-does-not-exist.c new file mode 100644 index 0000000000..98eba5343f --- /dev/null +++ b/test/Profile/profile-does-not-exist.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 -emit-llvm %s -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s + +// CHECK: error: Could not read profile: No such file or directory +// CHECK-NOT: Assertion failed