r234141 - Don't crash when passing a non-existent file to -fprofile-instr-use=.

Nico Weber nicolasweber at gmx.de
Sun Apr 5 21:16:48 PDT 2015


Author: nico
Date: Sun Apr  5 23:16:48 2015
New Revision: 234141

URL: http://llvm.org/viewvc/llvm-project?rev=234141&view=rev
Log:
Don't crash when passing a non-existent file to -fprofile-instr-use=.

Fixes a regression from r229434.

Added:
    cfe/trunk/test/Profile/profile-does-not-exist.c
Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Apr  5 23:16:48 2015
@@ -147,8 +147,8 @@ CodeGenModule::CodeGenModule(ASTContext
       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

Added: cfe/trunk/test/Profile/profile-does-not-exist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/profile-does-not-exist.c?rev=234141&view=auto
==============================================================================
--- cfe/trunk/test/Profile/profile-does-not-exist.c (added)
+++ cfe/trunk/test/Profile/profile-does-not-exist.c Sun Apr  5 23:16:48 2015
@@ -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





More information about the cfe-commits mailing list