]> granicus.if.org Git - clang/commitdiff
Ensure we preserve line information for each trap for
authorMike Stump <mrs@apple.com>
Tue, 15 Dec 2009 00:59:40 +0000 (00:59 +0000)
committerMike Stump <mrs@apple.com>
Tue, 15 Dec 2009 00:59:40 +0000 (00:59 +0000)
-fcatch-undefined-behavior if we aren't optimizing.  WIP.

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

lib/CodeGen/CGExpr.cpp

index 975f7492555f53c934c5456d5f7f5117f1c3cdd5..9af79ab70b6eee78c5e73d7e8a2356065015f262 100644 (file)
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
 #include "llvm/Intrinsics.h"
+#include "clang/CodeGen/CodeGenOptions.h"
 #include "llvm/Target/TargetData.h"
 using namespace clang;
 using namespace CodeGen;
@@ -1014,7 +1015,14 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
 }
 
 llvm::BasicBlock*CodeGenFunction::getTrapBB() {
-  if (TrapBB)
+  const CodeGenOptions &GCO = CGM.getCodeGenOpts();
+
+  // If we are not optimzing, don't collapse all calls to trap in the function
+  // to the same call, that way, in the debugger they can see which operation
+  // did in fact fail.  If we are optimizing, we collpase all call to trap down
+  // to just one per function to save on codesize.
+  if (GCO.OptimizationLevel
+      && TrapBB)
     return TrapBB;
 
   llvm::BasicBlock *Cont = 0;