<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">This breaks ASan tests on Mac, as driver on Darwin still uses -faddress-sanitizer flag.<div><div>It is accessed in both Tools.cpp and ToolChains.cpp, looks like we need to move SanitizeArgs into a header.</div>
<div>I'm testing the fix for this.</div><div><div><br><div class="gmail_quote">On Tue, Nov 6, 2012 at 2:21 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon Nov  5 16:21:05 2012<br>
New Revision: 167413<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=167413&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=167413&view=rev</a><br>
Log:<br>
Use the individual -fsanitize=<...> arguments to control which of the UBSan<br>
checks to enable. Remove frontend support for -fcatch-undefined-behavior,<br>
-faddress-sanitizer and -fthread-sanitizer now that they don't do anything.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/LangOptions.def<br>
    cfe/trunk/include/clang/Driver/Options.td<br>
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
    cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
    cfe/trunk/lib/Driver/Tools.cpp<br>
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
    cfe/trunk/test/CodeGen/address-safety-attr.cpp<br>
    cfe/trunk/test/CodeGen/catch-undef-behavior.c<br>
    cfe/trunk/test/CodeGen/integer-overflow.c<br>
    cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp<br>
    cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp<br>
    cfe/trunk/test/CodeGenObjCXX/<a href="http://address-safety-attr.mm" target="_blank">address-safety-attr.mm</a><br>
    cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/LangOptions.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)<br>
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Nov  5 16:21:05 2012<br>
@@ -117,7 +117,6 @@<br>
<br>
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators")<br>
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")<br>
-BENIGN_LANGOPT(CatchUndefined    , 1, 0, "catching undefined behavior at run time")<br>
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")<br>
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form")<br>
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables")<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/Options.td Mon Nov  5 16:21:05 2012<br>
@@ -293,12 +293,12 @@<br>
   HelpText<"Use Apple's kernel extensions ABI">;<br>
 def fapple_pragma_pack : Flag<["-"], "fapple-pragma-pack">, Group<f_Group>, Flags<[CC1Option]>,<br>
   HelpText<"Enable Apple gcc-compatible #pragma pack handling">;<br>
-def faddress_sanitizer : Flag<["-"], "faddress-sanitizer">, Group<f_Group>, Flags<[CC1Option]>,<br>
+def faddress_sanitizer : Flag<["-"], "faddress-sanitizer">, Group<f_Group>,<br>
   HelpText<"Enable AddressSanitizer instrumentation (memory error detection)">;<br>
-def fno_address_sanitizer : Flag<["-"], "fno-address-sanitizer">, Group<f_Group>, Flags<[CC1Option]>;<br>
-def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>, Flags<[CC1Option]>,<br>
+def fno_address_sanitizer : Flag<["-"], "fno-address-sanitizer">, Group<f_Group>;<br>
+def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>,<br>
   HelpText<"Enable ThreadSanitizer instrumentation (race detection)">;<br>
-def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group<f_Group>, Flags<[CC1Option]>;<br>
+def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group<f_Group>;<br>
 def fasm : Flag<["-"], "fasm">, Group<f_Group>;<br>
<br>
 def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>;<br>
@@ -322,7 +322,7 @@<br>
 def fbuiltin_strcpy : Flag<["-"], "fbuiltin-strcpy">, Group<f_Group>;<br>
 def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;<br>
 def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>;<br>
-def fcatch_undefined_behavior : Flag<["-"], "fcatch-undefined-behavior">, Flags<[CC1Option]>,<br>
+def fcatch_undefined_behavior : Flag<["-"], "fcatch-undefined-behavior">,<br>
   Group<f_Group>, HelpText<"Generate runtime checks for undefined behavior.">;<br>
 def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;<br>
 def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>, Flags<[CC1Option]>,<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Nov  5 16:21:05 2012<br>
@@ -406,7 +406,7 @@<br>
     return RValue::get(Builder.CreateCall(F));<br>
   }<br>
   case Builtin::BI__builtin_unreachable: {<br>
-    if (CatchUndefined)<br>
+    if (getLangOpts().SanitizeUnreachable)<br>
       EmitCheck(Builder.getFalse(), "builtin_unreachable",<br>
                 EmitCheckSourceLocation(E->getExprLoc()),<br>
                 llvm::ArrayRef<llvm::Value *>());<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  5 16:21:05 2012<br>
@@ -389,7 +389,7 @@<br>
                                                    ReferenceTemporaryDtor,<br>
                                                    ObjCARCReferenceLifetimeType,<br>
                                                    InitializedDecl);<br>
-  if (CatchUndefined && !E->getType()->isFunctionType()) {<br>
+  if (SanitizePerformTypeCheck && !E->getType()->isFunctionType()) {<br>
     // C++11 [dcl.ref]p5 (as amended by core issue 453):<br>
     //   If a glvalue to which a reference is directly bound designates neither<br>
     //   an existing object or function of an appropriate type nor a region of<br>
@@ -476,7 +476,7 @@<br>
 void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,<br>
                                     llvm::Value *Address,<br>
                                     QualType Ty, CharUnits Alignment) {<br>
-  if (!CatchUndefined)<br>
+  if (!SanitizePerformTypeCheck)<br>
     return;<br>
<br>
   // Don't check pointers outside the default address space. The null check<br>
@@ -487,19 +487,17 @@<br>
<br>
   llvm::Value *Cond = 0;<br>
<br>
-  // The glvalue must not be an empty glvalue.<br>
-  Cond = Builder.CreateICmpNE(<br>
-    Address, llvm::Constant::getNullValue(Address->getType()));<br>
-<br>
-  uint64_t AlignVal = Alignment.getQuantity();<br>
+  if (getLangOpts().SanitizeNull) {<br>
+    // The glvalue must not be an empty glvalue.<br>
+    Cond = Builder.CreateICmpNE(<br>
+        Address, llvm::Constant::getNullValue(Address->getType()));<br>
+  }<br>
<br>
-  if (!Ty->isIncompleteType()) {<br>
+  if (getLangOpts().SanitizeObjectSize && !Ty->isIncompleteType()) {<br>
     uint64_t Size = getContext().getTypeSizeInChars(Ty).getQuantity();<br>
-    if (!AlignVal)<br>
-      AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();<br>
<br>
     // The glvalue must refer to a large enough storage region.<br>
-    // FIXME: If -faddress-sanitizer is enabled, insert dynamic instrumentation<br>
+    // FIXME: If Address Sanitizer is enabled, insert dynamic instrumentation<br>
     //        to check this.<br>
     llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize, IntPtrTy);<br>
     llvm::Value *Min = Builder.getFalse();<br>
@@ -510,13 +508,22 @@<br>
     Cond = Cond ? Builder.CreateAnd(Cond, LargeEnough) : LargeEnough;<br>
   }<br>
<br>
-  if (AlignVal) {<br>
+  uint64_t AlignVal = 0;<br>
+<br>
+  if (getLangOpts().SanitizeAlignment) {<br>
+    AlignVal = Alignment.getQuantity();<br>
+    if (!Ty->isIncompleteType() && !AlignVal)<br>
+      AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();<br>
+<br>
     // The glvalue must be suitably aligned.<br>
-    llvm::Value *Align =<br>
-        Builder.CreateAnd(Builder.CreatePtrToInt(Address, IntPtrTy),<br>
-                          llvm::ConstantInt::get(IntPtrTy, AlignVal - 1));<br>
-    Cond = Builder.CreateAnd(Cond,<br>
-        Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)));<br>
+    if (AlignVal) {<br>
+      llvm::Value *Align =<br>
+          Builder.CreateAnd(Builder.CreatePtrToInt(Address, IntPtrTy),<br>
+                            llvm::ConstantInt::get(IntPtrTy, AlignVal - 1));<br>
+      llvm::Value *Aligned =<br>
+        Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0));<br>
+      Cond = Cond ? Builder.CreateAnd(Cond, Aligned) : Aligned;<br>
+    }<br>
   }<br>
<br>
   if (Cond) {<br>
@@ -529,14 +536,11 @@<br>
     EmitCheck(Cond, "type_mismatch", StaticData, Address);<br>
   }<br>
<br>
+  // If possible, check that the vptr indicates that there is a subobject of<br>
+  // type Ty at offset zero within this object.<br>
   CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();<br>
-  if (TCK != TCK_ConstructorCall &&<br>
+  if (getLangOpts().SanitizeVptr && TCK != TCK_ConstructorCall &&<br>
       RD && RD->hasDefinition() && RD->isDynamicClass()) {<br>
-    // Check that the vptr indicates that there is a subobject of type Ty at<br>
-    // offset zero within this object.<br>
-    // FIXME: Produce a diagnostic if the user tries to combine this check with<br>
-    //        -fno-rtti.<br>
-<br>
     // Compute a hash of the mangled name of the type.<br>
     //<br>
     // FIXME: This is not guaranteed to be deterministic! Move to a<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Nov  5 16:21:05 2012<br>
@@ -406,14 +406,14 @@<br>
       case LangOptions::SOB_Defined:<br>
         return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");<br>
       case LangOptions::SOB_Undefined:<br>
-        if (!CGF.CatchUndefined)<br>
+        if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)<br>
           return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");<br>
         // Fall through.<br>
       case LangOptions::SOB_Trapping:<br>
         return EmitOverflowCheckedBinOp(Ops);<br>
       }<br>
     }<br>
-<br>
+<br>
     if (Ops.LHS->getType()->isFPOrFPVectorTy())<br>
       return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");<br>
     return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");<br>
@@ -731,7 +731,7 @@<br>
<br>
   // An overflowing conversion has undefined behavior if either the source type<br>
   // or the destination type is a floating-point type.<br>
-  if (CGF.CatchUndefined &&<br>
+  if (CGF.getLangOpts().SanitizeFloatCastOverflow &&<br>
       (OrigSrcType->isFloatingType() || DstType->isFloatingType()))<br>
     EmitFloatConversionCheck(OrigSrc, OrigSrcType, Src, SrcType, DstType, DstTy);<br>
<br>
@@ -1417,7 +1417,7 @@<br>
   case LangOptions::SOB_Defined:<br>
     return Builder.CreateAdd(InVal, NextVal, IsInc ? "inc" : "dec");<br>
   case LangOptions::SOB_Undefined:<br>
-    if (!CGF.CatchUndefined)<br>
+    if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)<br>
       return Builder.CreateNSWAdd(InVal, NextVal, IsInc ? "inc" : "dec");<br>
     // Fall through.<br>
   case LangOptions::SOB_Trapping:<br>
@@ -1942,7 +1942,7 @@<br>
 }<br>
<br>
 Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {<br>
-  if (CGF.CatchUndefined) {<br>
+  if (CGF.getLangOpts().SanitizeDivideByZero) {<br>
     llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));<br>
<br>
     if (Ops.Ty->isIntegerType())<br>
@@ -1970,7 +1970,7 @@<br>
<br>
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {<br>
   // Rem in C can't be a floating point type: C99 6.5.5p2.<br>
-  if (CGF.CatchUndefined) {<br>
+  if (CGF.getLangOpts().SanitizeDivideByZero) {<br>
     llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));<br>
<br>
     if (Ops.Ty->isIntegerType())<br>
@@ -2021,9 +2021,9 @@<br>
   const std::string *handlerName =<br>
     &CGF.getLangOpts().OverflowHandler;<br>
   if (handlerName->empty()) {<br>
-    // If -fcatch-undefined-behavior is enabled, emit a call to its<br>
+    // If the signed-integer-overflow sanitizer is enabled, emit a call to its<br>
     // runtime. Otherwise, this is a -ftrapv check, so just emit a trap.<br>
-    if (CGF.CatchUndefined)<br>
+    if (CGF.getLangOpts().SanitizeSignedIntegerOverflow)<br>
       EmitBinOpCheck(Builder.CreateNot(overflow), Ops);<br>
     else<br>
       CGF.EmitTrapvCheck(Builder.CreateNot(overflow));<br>
@@ -2241,7 +2241,7 @@<br>
     case LangOptions::SOB_Defined:<br>
       return Builder.CreateAdd(op.LHS, op.RHS, "add");<br>
     case LangOptions::SOB_Undefined:<br>
-      if (!CGF.CatchUndefined)<br>
+      if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)<br>
         return Builder.CreateNSWAdd(op.LHS, op.RHS, "add");<br>
       // Fall through.<br>
     case LangOptions::SOB_Trapping:<br>
@@ -2268,7 +2268,7 @@<br>
       case LangOptions::SOB_Defined:<br>
         return Builder.CreateSub(op.LHS, op.RHS, "sub");<br>
       case LangOptions::SOB_Undefined:<br>
-        if (!CGF.CatchUndefined)<br>
+        if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)<br>
           return Builder.CreateNSWSub(op.LHS, op.RHS, "sub");<br>
         // Fall through.<br>
       case LangOptions::SOB_Trapping:<br>
@@ -2351,7 +2351,8 @@<br>
   if (Ops.LHS->getType() != RHS->getType())<br>
     RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");<br>
<br>
-  if (CGF.CatchUndefined && isa<llvm::IntegerType>(Ops.LHS->getType())) {<br>
+  if (CGF.getLangOpts().SanitizeShift &&<br>
+      isa<llvm::IntegerType>(Ops.LHS->getType())) {<br>
     unsigned Width = cast<llvm::IntegerType>(Ops.LHS->getType())->getBitWidth();<br>
     llvm::Value *WidthMinusOne =<br>
       llvm::ConstantInt::get(RHS->getType(), Width - 1);<br>
@@ -2390,7 +2391,8 @@<br>
   if (Ops.LHS->getType() != RHS->getType())<br>
     RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");<br>
<br>
-  if (CGF.CatchUndefined && isa<llvm::IntegerType>(Ops.LHS->getType())) {<br>
+  if (CGF.getLangOpts().SanitizeShift &&<br>
+      isa<llvm::IntegerType>(Ops.LHS->getType())) {<br>
     unsigned Width = cast<llvm::IntegerType>(Ops.LHS->getType())->getBitWidth();<br>
     llvm::Value *WidthVal = llvm::ConstantInt::get(RHS->getType(), Width);<br>
     EmitBinOpCheck(Builder.CreateICmpULT(RHS, WidthVal), Ops);<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Nov  5 16:21:05 2012<br>
@@ -32,6 +32,10 @@<br>
   : CodeGenTypeCache(cgm), CGM(cgm),<br>
     Target(CGM.getContext().getTargetInfo()),<br>
     Builder(cgm.getModule().getContext()),<br>
+    SanitizePerformTypeCheck(CGM.getLangOpts().SanitizeNull |<br>
+                             CGM.getLangOpts().SanitizeAlignment |<br>
+                             CGM.getLangOpts().SanitizeObjectSize |<br>
+                             CGM.getLangOpts().SanitizeVptr),<br>
     AutoreleaseResult(false), BlockInfo(0), BlockPointer(0),<br>
     LambdaThisCaptureField(0), NormalCleanupDest(0), NextCleanupDestIndex(1),<br>
     FirstBlockInfo(0), EHResumeBlock(0), ExceptionSlot(0), EHSelectorSlot(0),<br>
@@ -40,8 +44,6 @@<br>
     CXXABIThisDecl(0), CXXABIThisValue(0), CXXThisValue(0), CXXVTTDecl(0),<br>
     CXXVTTValue(0), OutermostConditional(0), TerminateLandingPad(0),<br>
     TerminateHandler(0), TrapBB(0) {<br>
-<br>
-  CatchUndefined = getLangOpts().CatchUndefined;<br>
   if (!suppressNewContext)<br>
     CGM.getCXXABI().getMangleContext().startNewFunction();<br>
 }<br>
@@ -543,7 +545,7 @@<br>
   //   function call is used by the caller, the behavior is undefined.<br>
   if (getLangOpts().CPlusPlus && !FD->hasImplicitReturnZero() &&<br>
       !FD->getResultType()->isVoidType() && Builder.GetInsertBlock()) {<br>
-    if (CatchUndefined)<br>
+    if (getLangOpts().SanitizeReturn)<br>
       EmitCheck(Builder.getFalse(), "missing_return",<br>
                 EmitCheckSourceLocation(FD->getLocation()),<br>
                 llvm::ArrayRef<llvm::Value*>());<br>
@@ -1128,7 +1130,8 @@<br>
           //   If the size is an expression that is not an integer constant<br>
           //   expression [...] each time it is evaluated it shall have a value<br>
           //   greater than zero.<br>
-          if (CatchUndefined && size->getType()->isSignedIntegerType()) {<br>
+          if (getLangOpts().SanitizeVLABound &&<br>
+              size->getType()->isSignedIntegerType()) {<br>
             llvm::Value *Zero = llvm::Constant::getNullValue(Size->getType());<br>
             llvm::Constant *StaticArgs[] = {<br>
               EmitCheckSourceLocation(size->getLocStart()),<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Nov  5 16:21:05 2012<br>
@@ -594,8 +594,9 @@<br>
   /// potentially higher performance penalties.<br>
   unsigned char BoundsChecking;<br>
<br>
-  /// CatchUndefined - Emit run-time checks to catch undefined behaviors.<br>
-  bool CatchUndefined;<br>
+  /// \brief Whether any type-checking sanitizers are enabled. If \c false,<br>
+  /// calls to EmitTypeCheck can be skipped.<br>
+  bool SanitizePerformTypeCheck;<br>
<br>
   /// In ARC, whether we should autorelease the return value.<br>
   bool AutoreleaseResult;<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1506,12 +1506,6 @@<br>
   }<br>
<br>
   void addArgs(const ArgList &Args, ArgStringList &CmdArgs) const {<br>
-    if (Kind & Address)<br>
-      CmdArgs.push_back("-faddress-sanitizer");<br>
-    if (Kind & Thread)<br>
-      CmdArgs.push_back("-fthread-sanitizer");<br>
-    if (Kind & Undefined)<br>
-      CmdArgs.push_back("-fcatch-undefined-behavior");<br>
     if (!Kind)<br>
       return;<br>
     llvm::SmallString<256> SanitizeOpt("-fsanitize=");<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1213,7 +1213,6 @@<br>
     Args.getLastArgValue(OPT_fconstant_string_class);<br>
   Opts.ObjCDefaultSynthProperties =<br>
     Args.hasArg(OPT_fobjc_default_synthesize_properties);<br>
-  Opts.CatchUndefined = Args.hasArg(OPT_fcatch_undefined_behavior);<br>
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);<br>
   Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct_EQ, 0, Diags);<br>
   Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);<br>
@@ -1234,8 +1233,6 @@<br>
   Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);<br>
   Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);<br>
   Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);<br>
-  Opts.SanitizeAddress = Args.hasArg(OPT_faddress_sanitizer);<br>
-  Opts.SanitizeThread = Args.hasArg(OPT_fthread_sanitizer);<br>
   Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);<br>
   Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);<br>
<br>
<br>
Modified: cfe/trunk/test/CodeGen/address-safety-attr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-safety-attr.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-safety-attr.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/address-safety-attr.cpp (original)<br>
+++ cfe/trunk/test/CodeGen/address-safety-attr.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1,5 +1,5 @@<br>
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s<br>
-// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s<br>
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck -check-prefix ASAN %s<br>
<br>
 // The address_safety attribute should be attached to functions<br>
 // when AddressSanitizer is enabled, unless no_address_safety_analysis attribute<br>
<br>
Modified: cfe/trunk/test/CodeGen/catch-undef-behavior.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/catch-undef-behavior.c (original)<br>
+++ cfe/trunk/test/CodeGen/catch-undef-behavior.c Mon Nov  5 16:21:05 2012<br>
@@ -1,4 +1,5 @@<br>
-// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s<br>
+// RUN: %clang_cc1 -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s<br>
+// RUN: %clang_cc1 -fsanitize=null -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NULL<br>
<br>
 // CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }<br>
<br>
@@ -17,8 +18,11 @@<br>
 // CHECK: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }<br>
 // CHECK: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }<br>
<br>
+// CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr constant {{.*}}, i32 100, i32 5 {{.*}}<br>
+<br>
 // PR6805<br>
 // CHECK: @foo<br>
+// CHECK-NULL: @foo<br>
 void foo() {<br>
   union { int i; } u;<br>
   // CHECK:      %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null<br>
@@ -37,6 +41,11 @@<br>
<br>
   // CHECK:      %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64<br>
   // CHECK-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %[[ARG]]) noreturn nounwind<br>
+<br>
+  // With -fsanitize=null, only perform the null check.<br>
+  // CHECK-NULL: %[[NULL:.*]] = icmp ne {{.*}}, null<br>
+  // CHECK-NULL: br i1 %[[NULL]]<br>
+  // CHECK-NULL: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %{{.*}}) noreturn nounwind<br>
 #line 100<br>
   u.i=1;<br>
 }<br>
@@ -137,6 +146,8 @@<br>
 // CHECK: @no_return<br>
 int no_return() {<br>
   // Reaching the end of a noreturn function is fine in C.<br>
+  // FIXME: If the user explicitly requests -fsanitize=return, we should catch<br>
+  //        that here even though it's not undefined behavior.<br>
   // CHECK-NOT: call<br>
   // CHECK-NOT: unreachable<br>
   // CHECK: ret i32<br>
<br>
Modified: cfe/trunk/test/CodeGen/integer-overflow.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/integer-overflow.c?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/integer-overflow.c?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/integer-overflow.c (original)<br>
+++ cfe/trunk/test/CodeGen/integer-overflow.c Mon Nov  5 16:21:05 2012<br>
@@ -1,7 +1,7 @@<br>
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT<br>
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV<br>
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV<br>
-// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fcatch-undefined-behavior | FileCheck %s --check-prefix=CATCH_UB<br>
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CATCH_UB<br>
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER<br>
<br>
<br>
<br>
Modified: cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp (original)<br>
+++ cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1,6 +1,6 @@<br>
-// RUN: %clang_cc1 -emit-llvm -o - -O0 -fthread-sanitizer %s | FileCheck %s<br>
+// RUN: %clang_cc1 -emit-llvm -o - -O0 -fsanitize=thread %s | FileCheck %s<br>
 // RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s<br>
-// RUN: %clang_cc1 -emit-llvm -o - -O1  -relaxed-aliasing -fthread-sanitizer %s | FileCheck %s<br>
+// RUN: %clang_cc1 -emit-llvm -o - -O1  -relaxed-aliasing -fsanitize=thread %s | FileCheck %s<br>
 //<br>
 // RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s --check-prefix=NOTBAA<br>
 // RUN: %clang_cc1 -emit-llvm -o - -O2  -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1,4 +1,4 @@<br>
-// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s<br>
+// RUN: %clang_cc1 -fsanitize=signed-integer-overflow,divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s<br>
<br>
 // CHECK: @_Z17reference_binding<br>
 void reference_binding(int *p) {<br>
<br>
Modified: cfe/trunk/test/CodeGenObjCXX/<a href="http://address-safety-attr.mm" target="_blank">address-safety-attr.mm</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGenObjCXX/<a href="http://address-safety-attr.mm" target="_blank">address-safety-attr.mm</a> (original)<br>
+++ cfe/trunk/test/CodeGenObjCXX/<a href="http://address-safety-attr.mm" target="_blank">address-safety-attr.mm</a> Mon Nov  5 16:21:05 2012<br>
@@ -1,5 +1,5 @@<br>
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s<br>
-// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s<br>
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck -check-prefix ASAN %s<br>
<br>
 @interface MyClass<br>
 + (int) addressSafety:(int*)a;<br>
<br>
Modified: cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp?rev=167413&r1=167412&r2=167413&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp?rev=167413&r1=167412&r2=167413&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp (original)<br>
+++ cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp Mon Nov  5 16:21:05 2012<br>
@@ -1,4 +1,4 @@<br>
-// RUN: %clang_cc1 -E -faddress-sanitizer %s -o - | FileCheck --check-prefix=CHECK-ASAN %s<br>
+// RUN: %clang_cc1 -E -fsanitize=address %s -o - | FileCheck --check-prefix=CHECK-ASAN %s<br>
 // RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s<br>
<br>
 #if __has_feature(address_sanitizer)<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div></div></div></div>