[cfe-commits] r167413 - in /cfe/trunk: include/clang/Basic/ include/clang/Driver/ lib/CodeGen/ lib/Driver/ lib/Frontend/ test/CodeGen/ test/CodeGenCXX/ test/CodeGenObjCXX/ test/Lexer/

Alexey Samsonov samsonov at google.com
Tue Nov 6 04:53:24 PST 2012


This breaks ASan tests on Mac, as driver on Darwin still uses
-faddress-sanitizer flag.
It is accessed in both Tools.cpp and ToolChains.cpp, looks like we need to
move SanitizeArgs into a header.
I'm testing the fix for this.

On Tue, Nov 6, 2012 at 2:21 AM, Richard Smith <richard-llvm at metafoo.co.uk>wrote:

> Author: rsmith
> Date: Mon Nov  5 16:21:05 2012
> New Revision: 167413
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167413&view=rev
> Log:
> Use the individual -fsanitize=<...> arguments to control which of the UBSan
> checks to enable. Remove frontend support for -fcatch-undefined-behavior,
> -faddress-sanitizer and -fthread-sanitizer now that they don't do anything.
>
> Modified:
>     cfe/trunk/include/clang/Basic/LangOptions.def
>     cfe/trunk/include/clang/Driver/Options.td
>     cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>     cfe/trunk/lib/CodeGen/CGExpr.cpp
>     cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>     cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>     cfe/trunk/lib/CodeGen/CodeGenFunction.h
>     cfe/trunk/lib/Driver/Tools.cpp
>     cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>     cfe/trunk/test/CodeGen/address-safety-attr.cpp
>     cfe/trunk/test/CodeGen/catch-undef-behavior.c
>     cfe/trunk/test/CodeGen/integer-overflow.c
>     cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp
>     cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>     cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm
>     cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Nov  5 16:21:05 2012
> @@ -117,7 +117,6 @@
>
>  LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc))
> for C++'s new operators")
>  BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
> -BENIGN_LANGOPT(CatchUndefined    , 1, 0, "catching undefined behavior at
> run time")
>  BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd
> records")
>  BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of
> IRgen'd records in a simple form")
>  BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted
> vtables")
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Nov  5 16:21:05 2012
> @@ -293,12 +293,12 @@
>    HelpText<"Use Apple's kernel extensions ABI">;
>  def fapple_pragma_pack : Flag<["-"], "fapple-pragma-pack">,
> Group<f_Group>, Flags<[CC1Option]>,
>    HelpText<"Enable Apple gcc-compatible #pragma pack handling">;
> -def faddress_sanitizer : Flag<["-"], "faddress-sanitizer">,
> Group<f_Group>, Flags<[CC1Option]>,
> +def faddress_sanitizer : Flag<["-"], "faddress-sanitizer">,
> Group<f_Group>,
>    HelpText<"Enable AddressSanitizer instrumentation (memory error
> detection)">;
> -def fno_address_sanitizer : Flag<["-"], "fno-address-sanitizer">,
> Group<f_Group>, Flags<[CC1Option]>;
> -def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>,
> Flags<[CC1Option]>,
> +def fno_address_sanitizer : Flag<["-"], "fno-address-sanitizer">,
> Group<f_Group>;
> +def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>,
>    HelpText<"Enable ThreadSanitizer instrumentation (race detection)">;
> -def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">,
> Group<f_Group>, Flags<[CC1Option]>;
> +def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">,
> Group<f_Group>;
>  def fasm : Flag<["-"], "fasm">, Group<f_Group>;
>
>  def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>;
> @@ -322,7 +322,7 @@
>  def fbuiltin_strcpy : Flag<["-"], "fbuiltin-strcpy">, Group<f_Group>;
>  def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;
>  def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">,
> Group<f_Group>;
> -def fcatch_undefined_behavior : Flag<["-"], "fcatch-undefined-behavior">,
> Flags<[CC1Option]>,
> +def fcatch_undefined_behavior : Flag<["-"], "fcatch-undefined-behavior">,
>    Group<f_Group>, HelpText<"Generate runtime checks for undefined
> behavior.">;
>  def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
>  def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">,
> Group<f_Group>, Flags<[CC1Option]>,
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Nov  5 16:21:05 2012
> @@ -406,7 +406,7 @@
>      return RValue::get(Builder.CreateCall(F));
>    }
>    case Builtin::BI__builtin_unreachable: {
> -    if (CatchUndefined)
> +    if (getLangOpts().SanitizeUnreachable)
>        EmitCheck(Builder.getFalse(), "builtin_unreachable",
>                  EmitCheckSourceLocation(E->getExprLoc()),
>                  llvm::ArrayRef<llvm::Value *>());
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  5 16:21:05 2012
> @@ -389,7 +389,7 @@
>                                                     ReferenceTemporaryDtor,
>
> ObjCARCReferenceLifetimeType,
>                                                     InitializedDecl);
> -  if (CatchUndefined && !E->getType()->isFunctionType()) {
> +  if (SanitizePerformTypeCheck && !E->getType()->isFunctionType()) {
>      // C++11 [dcl.ref]p5 (as amended by core issue 453):
>      //   If a glvalue to which a reference is directly bound designates
> neither
>      //   an existing object or function of an appropriate type nor a
> region of
> @@ -476,7 +476,7 @@
>  void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,
>                                      llvm::Value *Address,
>                                      QualType Ty, CharUnits Alignment) {
> -  if (!CatchUndefined)
> +  if (!SanitizePerformTypeCheck)
>      return;
>
>    // Don't check pointers outside the default address space. The null
> check
> @@ -487,19 +487,17 @@
>
>    llvm::Value *Cond = 0;
>
> -  // The glvalue must not be an empty glvalue.
> -  Cond = Builder.CreateICmpNE(
> -    Address, llvm::Constant::getNullValue(Address->getType()));
> -
> -  uint64_t AlignVal = Alignment.getQuantity();
> +  if (getLangOpts().SanitizeNull) {
> +    // The glvalue must not be an empty glvalue.
> +    Cond = Builder.CreateICmpNE(
> +        Address, llvm::Constant::getNullValue(Address->getType()));
> +  }
>
> -  if (!Ty->isIncompleteType()) {
> +  if (getLangOpts().SanitizeObjectSize && !Ty->isIncompleteType()) {
>      uint64_t Size = getContext().getTypeSizeInChars(Ty).getQuantity();
> -    if (!AlignVal)
> -      AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();
>
>      // The glvalue must refer to a large enough storage region.
> -    // FIXME: If -faddress-sanitizer is enabled, insert dynamic
> instrumentation
> +    // FIXME: If Address Sanitizer is enabled, insert dynamic
> instrumentation
>      //        to check this.
>      llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize,
> IntPtrTy);
>      llvm::Value *Min = Builder.getFalse();
> @@ -510,13 +508,22 @@
>      Cond = Cond ? Builder.CreateAnd(Cond, LargeEnough) : LargeEnough;
>    }
>
> -  if (AlignVal) {
> +  uint64_t AlignVal = 0;
> +
> +  if (getLangOpts().SanitizeAlignment) {
> +    AlignVal = Alignment.getQuantity();
> +    if (!Ty->isIncompleteType() && !AlignVal)
> +      AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();
> +
>      // The glvalue must be suitably aligned.
> -    llvm::Value *Align =
> -        Builder.CreateAnd(Builder.CreatePtrToInt(Address, IntPtrTy),
> -                          llvm::ConstantInt::get(IntPtrTy, AlignVal - 1));
> -    Cond = Builder.CreateAnd(Cond,
> -        Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)));
> +    if (AlignVal) {
> +      llvm::Value *Align =
> +          Builder.CreateAnd(Builder.CreatePtrToInt(Address, IntPtrTy),
> +                            llvm::ConstantInt::get(IntPtrTy, AlignVal -
> 1));
> +      llvm::Value *Aligned =
> +        Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0));
> +      Cond = Cond ? Builder.CreateAnd(Cond, Aligned) : Aligned;
> +    }
>    }
>
>    if (Cond) {
> @@ -529,14 +536,11 @@
>      EmitCheck(Cond, "type_mismatch", StaticData, Address);
>    }
>
> +  // If possible, check that the vptr indicates that there is a subobject
> of
> +  // type Ty at offset zero within this object.
>    CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
> -  if (TCK != TCK_ConstructorCall &&
> +  if (getLangOpts().SanitizeVptr && TCK != TCK_ConstructorCall &&
>        RD && RD->hasDefinition() && RD->isDynamicClass()) {
> -    // Check that the vptr indicates that there is a subobject of type Ty
> at
> -    // offset zero within this object.
> -    // FIXME: Produce a diagnostic if the user tries to combine this
> check with
> -    //        -fno-rtti.
> -
>      // Compute a hash of the mangled name of the type.
>      //
>      // FIXME: This is not guaranteed to be deterministic! Move to a
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Nov  5 16:21:05 2012
> @@ -406,14 +406,14 @@
>        case LangOptions::SOB_Defined:
>          return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
>        case LangOptions::SOB_Undefined:
> -        if (!CGF.CatchUndefined)
> +        if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)
>            return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
>          // Fall through.
>        case LangOptions::SOB_Trapping:
>          return EmitOverflowCheckedBinOp(Ops);
>        }
>      }
> -
> +
>      if (Ops.LHS->getType()->isFPOrFPVectorTy())
>        return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");
>      return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
> @@ -731,7 +731,7 @@
>
>    // An overflowing conversion has undefined behavior if either the
> source type
>    // or the destination type is a floating-point type.
> -  if (CGF.CatchUndefined &&
> +  if (CGF.getLangOpts().SanitizeFloatCastOverflow &&
>        (OrigSrcType->isFloatingType() || DstType->isFloatingType()))
>      EmitFloatConversionCheck(OrigSrc, OrigSrcType, Src, SrcType, DstType,
> DstTy);
>
> @@ -1417,7 +1417,7 @@
>    case LangOptions::SOB_Defined:
>      return Builder.CreateAdd(InVal, NextVal, IsInc ? "inc" : "dec");
>    case LangOptions::SOB_Undefined:
> -    if (!CGF.CatchUndefined)
> +    if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)
>        return Builder.CreateNSWAdd(InVal, NextVal, IsInc ? "inc" : "dec");
>      // Fall through.
>    case LangOptions::SOB_Trapping:
> @@ -1942,7 +1942,7 @@
>  }
>
>  Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {
> -  if (CGF.CatchUndefined) {
> +  if (CGF.getLangOpts().SanitizeDivideByZero) {
>      llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
>
>      if (Ops.Ty->isIntegerType())
> @@ -1970,7 +1970,7 @@
>
>  Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
>    // Rem in C can't be a floating point type: C99 6.5.5p2.
> -  if (CGF.CatchUndefined) {
> +  if (CGF.getLangOpts().SanitizeDivideByZero) {
>      llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
>
>      if (Ops.Ty->isIntegerType())
> @@ -2021,9 +2021,9 @@
>    const std::string *handlerName =
>      &CGF.getLangOpts().OverflowHandler;
>    if (handlerName->empty()) {
> -    // If -fcatch-undefined-behavior is enabled, emit a call to its
> +    // If the signed-integer-overflow sanitizer is enabled, emit a call
> to its
>      // runtime. Otherwise, this is a -ftrapv check, so just emit a trap.
> -    if (CGF.CatchUndefined)
> +    if (CGF.getLangOpts().SanitizeSignedIntegerOverflow)
>        EmitBinOpCheck(Builder.CreateNot(overflow), Ops);
>      else
>        CGF.EmitTrapvCheck(Builder.CreateNot(overflow));
> @@ -2241,7 +2241,7 @@
>      case LangOptions::SOB_Defined:
>        return Builder.CreateAdd(op.LHS, op.RHS, "add");
>      case LangOptions::SOB_Undefined:
> -      if (!CGF.CatchUndefined)
> +      if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)
>          return Builder.CreateNSWAdd(op.LHS, op.RHS, "add");
>        // Fall through.
>      case LangOptions::SOB_Trapping:
> @@ -2268,7 +2268,7 @@
>        case LangOptions::SOB_Defined:
>          return Builder.CreateSub(op.LHS, op.RHS, "sub");
>        case LangOptions::SOB_Undefined:
> -        if (!CGF.CatchUndefined)
> +        if (!CGF.getLangOpts().SanitizeSignedIntegerOverflow)
>            return Builder.CreateNSWSub(op.LHS, op.RHS, "sub");
>          // Fall through.
>        case LangOptions::SOB_Trapping:
> @@ -2351,7 +2351,8 @@
>    if (Ops.LHS->getType() != RHS->getType())
>      RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
> "sh_prom");
>
> -  if (CGF.CatchUndefined && isa<llvm::IntegerType>(Ops.LHS->getType())) {
> +  if (CGF.getLangOpts().SanitizeShift &&
> +      isa<llvm::IntegerType>(Ops.LHS->getType())) {
>      unsigned Width =
> cast<llvm::IntegerType>(Ops.LHS->getType())->getBitWidth();
>      llvm::Value *WidthMinusOne =
>        llvm::ConstantInt::get(RHS->getType(), Width - 1);
> @@ -2390,7 +2391,8 @@
>    if (Ops.LHS->getType() != RHS->getType())
>      RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
> "sh_prom");
>
> -  if (CGF.CatchUndefined && isa<llvm::IntegerType>(Ops.LHS->getType())) {
> +  if (CGF.getLangOpts().SanitizeShift &&
> +      isa<llvm::IntegerType>(Ops.LHS->getType())) {
>      unsigned Width =
> cast<llvm::IntegerType>(Ops.LHS->getType())->getBitWidth();
>      llvm::Value *WidthVal = llvm::ConstantInt::get(RHS->getType(), Width);
>      EmitBinOpCheck(Builder.CreateICmpULT(RHS, WidthVal), Ops);
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Nov  5 16:21:05 2012
> @@ -32,6 +32,10 @@
>    : CodeGenTypeCache(cgm), CGM(cgm),
>      Target(CGM.getContext().getTargetInfo()),
>      Builder(cgm.getModule().getContext()),
> +    SanitizePerformTypeCheck(CGM.getLangOpts().SanitizeNull |
> +                             CGM.getLangOpts().SanitizeAlignment |
> +                             CGM.getLangOpts().SanitizeObjectSize |
> +                             CGM.getLangOpts().SanitizeVptr),
>      AutoreleaseResult(false), BlockInfo(0), BlockPointer(0),
>      LambdaThisCaptureField(0), NormalCleanupDest(0),
> NextCleanupDestIndex(1),
>      FirstBlockInfo(0), EHResumeBlock(0), ExceptionSlot(0),
> EHSelectorSlot(0),
> @@ -40,8 +44,6 @@
>      CXXABIThisDecl(0), CXXABIThisValue(0), CXXThisValue(0), CXXVTTDecl(0),
>      CXXVTTValue(0), OutermostConditional(0), TerminateLandingPad(0),
>      TerminateHandler(0), TrapBB(0) {
> -
> -  CatchUndefined = getLangOpts().CatchUndefined;
>    if (!suppressNewContext)
>      CGM.getCXXABI().getMangleContext().startNewFunction();
>  }
> @@ -543,7 +545,7 @@
>    //   function call is used by the caller, the behavior is undefined.
>    if (getLangOpts().CPlusPlus && !FD->hasImplicitReturnZero() &&
>        !FD->getResultType()->isVoidType() && Builder.GetInsertBlock()) {
> -    if (CatchUndefined)
> +    if (getLangOpts().SanitizeReturn)
>        EmitCheck(Builder.getFalse(), "missing_return",
>                  EmitCheckSourceLocation(FD->getLocation()),
>                  llvm::ArrayRef<llvm::Value*>());
> @@ -1128,7 +1130,8 @@
>            //   If the size is an expression that is not an integer
> constant
>            //   expression [...] each time it is evaluated it shall have a
> value
>            //   greater than zero.
> -          if (CatchUndefined && size->getType()->isSignedIntegerType()) {
> +          if (getLangOpts().SanitizeVLABound &&
> +              size->getType()->isSignedIntegerType()) {
>              llvm::Value *Zero =
> llvm::Constant::getNullValue(Size->getType());
>              llvm::Constant *StaticArgs[] = {
>                EmitCheckSourceLocation(size->getLocStart()),
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Nov  5 16:21:05 2012
> @@ -594,8 +594,9 @@
>    /// potentially higher performance penalties.
>    unsigned char BoundsChecking;
>
> -  /// CatchUndefined - Emit run-time checks to catch undefined behaviors.
> -  bool CatchUndefined;
> +  /// \brief Whether any type-checking sanitizers are enabled. If \c
> false,
> +  /// calls to EmitTypeCheck can be skipped.
> +  bool SanitizePerformTypeCheck;
>
>    /// In ARC, whether we should autorelease the return value.
>    bool AutoreleaseResult;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Nov  5 16:21:05 2012
> @@ -1506,12 +1506,6 @@
>    }
>
>    void addArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
> -    if (Kind & Address)
> -      CmdArgs.push_back("-faddress-sanitizer");
> -    if (Kind & Thread)
> -      CmdArgs.push_back("-fthread-sanitizer");
> -    if (Kind & Undefined)
> -      CmdArgs.push_back("-fcatch-undefined-behavior");
>      if (!Kind)
>        return;
>      llvm::SmallString<256> SanitizeOpt("-fsanitize=");
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov  5 16:21:05 2012
> @@ -1213,7 +1213,6 @@
>      Args.getLastArgValue(OPT_fconstant_string_class);
>    Opts.ObjCDefaultSynthProperties =
>      Args.hasArg(OPT_fobjc_default_synthesize_properties);
> -  Opts.CatchUndefined = Args.hasArg(OPT_fcatch_undefined_behavior);
>    Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
>    Opts.PackStruct = Args.getLastArgIntValue(OPT_fpack_struct_EQ, 0,
> Diags);
>    Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);
> @@ -1234,8 +1233,6 @@
>    Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);
>    Opts.DebuggerCastResultToId =
> Args.hasArg(OPT_fdebugger_cast_result_to_id);
>    Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
> -  Opts.SanitizeAddress = Args.hasArg(OPT_faddress_sanitizer);
> -  Opts.SanitizeThread = Args.hasArg(OPT_fthread_sanitizer);
>    Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
>    Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);
>
>
> Modified: cfe/trunk/test/CodeGen/address-safety-attr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-safety-attr.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/address-safety-attr.cpp (original)
> +++ cfe/trunk/test/CodeGen/address-safety-attr.cpp Mon Nov  5 16:21:05 2012
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
> -// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck
> -check-prefix ASAN %s
> +// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck
> -check-prefix ASAN %s
>
>  // The address_safety attribute should be attached to functions
>  // when AddressSanitizer is enabled, unless no_address_safety_analysis
> attribute
>
> Modified: cfe/trunk/test/CodeGen/catch-undef-behavior.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/catch-undef-behavior.c (original)
> +++ cfe/trunk/test/CodeGen/catch-undef-behavior.c Mon Nov  5 16:21:05 2012
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - -triple
> x86_64-linux-gnu | FileCheck %s
> +// 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
> +// RUN: %clang_cc1 -fsanitize=null -emit-llvm %s -o - -triple
> x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NULL
>
>  // CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x
> i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
>
> @@ -17,8 +18,11 @@
>  // CHECK: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
>  // CHECK: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
>
> +// CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr constant {{.*}},
> i32 100, i32 5 {{.*}}
> +
>  // PR6805
>  // CHECK: @foo
> +// CHECK-NULL: @foo
>  void foo() {
>    union { int i; } u;
>    // CHECK:      %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
> @@ -37,6 +41,11 @@
>
>    // CHECK:      %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
>    // CHECK-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast
> ({{.*}} @[[LINE_100]] to i8*), i64 %[[ARG]]) noreturn nounwind
> +
> +  // With -fsanitize=null, only perform the null check.
> +  // CHECK-NULL: %[[NULL:.*]] = icmp ne {{.*}}, null
> +  // CHECK-NULL: br i1 %[[NULL]]
> +  // CHECK-NULL: call void @__ubsan_handle_type_mismatch(i8* bitcast
> ({{.*}} @[[LINE_100]] to i8*), i64 %{{.*}}) noreturn nounwind
>  #line 100
>    u.i=1;
>  }
> @@ -137,6 +146,8 @@
>  // CHECK: @no_return
>  int no_return() {
>    // Reaching the end of a noreturn function is fine in C.
> +  // FIXME: If the user explicitly requests -fsanitize=return, we should
> catch
> +  //        that here even though it's not undefined behavior.
>    // CHECK-NOT: call
>    // CHECK-NOT: unreachable
>    // CHECK: ret i32
>
> Modified: cfe/trunk/test/CodeGen/integer-overflow.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/integer-overflow.c?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/integer-overflow.c (original)
> +++ cfe/trunk/test/CodeGen/integer-overflow.c Mon Nov  5 16:21:05 2012
> @@ -1,7 +1,7 @@
>  // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - |
> FileCheck %s --check-prefix=DEFAULT
>  // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv
> | FileCheck %s --check-prefix=WRAPV
>  // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv
> | FileCheck %s --check-prefix=TRAPV
> -// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o -
> -fcatch-undefined-behavior | FileCheck %s --check-prefix=CATCH_UB
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o -
> -fsanitize=signed-integer-overflow | FileCheck %s --check-prefix=CATCH_UB
>  // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv
> -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER
>
>
>
> Modified: cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp (original)
> +++ cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp Mon Nov  5 16:21:05 2012
> @@ -1,6 +1,6 @@
> -// RUN: %clang_cc1 -emit-llvm -o - -O0 -fthread-sanitizer %s | FileCheck
> %s
> +// RUN: %clang_cc1 -emit-llvm -o - -O0 -fsanitize=thread %s | FileCheck %s
>  // RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s
> -// RUN: %clang_cc1 -emit-llvm -o - -O1  -relaxed-aliasing
> -fthread-sanitizer %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -O1  -relaxed-aliasing
> -fsanitize=thread %s | FileCheck %s
>  //
>  // RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s
> --check-prefix=NOTBAA
>  // RUN: %clang_cc1 -emit-llvm -o - -O2  -relaxed-aliasing %s | FileCheck
> %s --check-prefix=NOTBAA
>
> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Mon Nov  5 16:21:05
> 2012
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - -triple
> x86_64-linux-gnu | FileCheck %s
> +// 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
>
>  // CHECK: @_Z17reference_binding
>  void reference_binding(int *p) {
>
> Modified: cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm (original)
> +++ cfe/trunk/test/CodeGenObjCXX/address-safety-attr.mm Mon Nov  5
> 16:21:05 2012
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
> -// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck
> -check-prefix ASAN %s
> +// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck
> -check-prefix ASAN %s
>
>  @interface MyClass
>  + (int) addressSafety:(int*)a;
>
> Modified: cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp?rev=167413&r1=167412&r2=167413&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp (original)
> +++ cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp Mon Nov  5
> 16:21:05 2012
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -E -faddress-sanitizer %s -o - | FileCheck
> --check-prefix=CHECK-ASAN %s
> +// RUN: %clang_cc1 -E -fsanitize=address %s -o - | FileCheck
> --check-prefix=CHECK-ASAN %s
>  // RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
>
>  #if __has_feature(address_sanitizer)
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121106/7b388410/attachment.html>


More information about the cfe-commits mailing list