[PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

Filipe Cabecinhas via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 20 17:42:28 PDT 2015


filcab added a subscriber: filcab.
filcab added a comment.

Looks good, thanks for working on this.
I added some code style comments.


================
Comment at: lib/CodeGen/CGExpr.cpp:2399
@@ -2385,1 +2398,3 @@
+
+void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, const std::string &TrapFuncName) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
----------------
80 columns

================
Comment at: lib/CodeGen/CGExpr.cpp:2408
@@ -2392,3 +2407,3 @@
     EmitBlock(TrapBB);
-    llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
+    llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap, TrapFuncName);
     TrapCall->setDoesNotReturn();
----------------
80 columns.

================
Comment at: lib/CodeGen/CGExpr.cpp:2419
@@ -2403,3 +2418,3 @@
 
-llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
+llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID, const std::string &TrapFuncName) {
   llvm::CallInst *TrapCall = Builder.CreateCall(CGM.getIntrinsic(IntrID));
----------------
80 columns.

================
Comment at: lib/CodeGen/CGExpr.cpp:2425
@@ -2409,3 +2424,3 @@
                            "trap-func-name",
-                           CGM.getCodeGenOpts().TrapFuncName);
+                           TrapFuncName);
 
----------------
Please run clang-format on lines you change.

================
Comment at: lib/CodeGen/CodeGenFunction.h:2887
@@ -2886,2 +2886,3 @@
 
   /// \brief Create a basic block that will call the trap intrinsic, and emit a
+  /// conditional branch to it, for the -fsanitize checks.
----------------
Don't add `\brief` if the comment is just one sentence (if you want to remove ones that were there previously, don't do it in the same commit, though).
I would probably remove the first comma, too.

================
Comment at: lib/CodeGen/CodeGenFunction.h:2904
@@ +2903,3 @@
+
+  /// \brief Emit a call to trap or debugtrap and attach function attribute
+  /// "trap-func-name" if nonempty.
----------------
Again, don't add `\brief`.

================
Comment at: lib/Frontend/CompilerInvocation.cpp:684
@@ -683,2 +683,3 @@
                       Opts.SanitizeTrap);
+  Opts.SanitizeTrapFuncName = Args.getLastArgValue(OPT_fsanitize_trap_function_EQ);
 
----------------
clang-format here.


http://reviews.llvm.org/D12181





More information about the cfe-commits mailing list