]> granicus.if.org Git - clang/commitdiff
Don't crash when passing a non-existent file to -fprofile-instr-use=.
authorNico Weber <nicolasweber@gmx.de>
Mon, 6 Apr 2015 04:16:48 +0000 (04:16 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 6 Apr 2015 04:16:48 +0000 (04:16 +0000)
Fixes a regression from r229434.

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

lib/CodeGen/CodeGenModule.cpp
test/Profile/profile-does-not-exist.c [new file with mode: 0644]

index 7fce6208d446412a8fc70a68f4aced4715a03dc4..dd9d6305caa78314087f7fb0264892a2e2390641 100644 (file)
@@ -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 (file)
index 0000000..98eba53
--- /dev/null
@@ -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