r342793 - [Lexer] Add udefined_behavior_sanitizer feature

Leonard Chan via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 21 18:28:06 PDT 2018


My bad. I saw that Vitaly accepted it and thought it would be ok since
I got 2 LGTMs.
On Fri, Sep 21, 2018 at 6:21 PM Aaron Ballman <aaron at aaronballman.com> wrote:
>
> The reviewer asked you to wait a day so that others might have a
> chance to review it, so this commit seems premature. I have no
> technical concerns with the patch, but the sanitizer owners should
> have had a chance to weigh in. That said, I don't see value in
> reverting and recommitting later, so if there are concerns, they can
> be dealt with post commit.
>
> ~Aaron
>
> On Fri, Sep 21, 2018 at 9:03 PM, Leonard Chan via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: leonardchan
> > Date: Fri Sep 21 18:03:16 2018
> > New Revision: 342793
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=342793&view=rev
> > Log:
> > [Lexer] Add udefined_behavior_sanitizer feature
> >
> > This can be used to detect whether the code is being built with UBSan using
> > the __has_feature(undefined_behavior_sanitizer) predicate.
> >
> > Differential Revision: https://reviews.llvm.org/D52386
> >
> > Added:
> >     cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
> > Modified:
> >     cfe/trunk/include/clang/Basic/Features.def
> >
> > Modified: cfe/trunk/include/clang/Basic/Features.def
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=342793&r1=342792&r2=342793&view=diff
> > ==============================================================================
> > --- cfe/trunk/include/clang/Basic/Features.def (original)
> > +++ cfe/trunk/include/clang/Basic/Features.def Fri Sep 21 18:03:16 2018
> > @@ -38,6 +38,8 @@ FEATURE(hwaddress_sanitizer,
> >          LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
> >                                     SanitizerKind::KernelHWAddress))
> >  FEATURE(xray_instrument, LangOpts.XRayInstrument)
> > +FEATURE(undefined_behavior_sanitizer,
> > +        LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
> >  FEATURE(assume_nonnull, true)
> >  FEATURE(attribute_analyzer_noreturn, true)
> >  FEATURE(attribute_availability, true)
> >
> > Added: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp?rev=342793&view=auto
> > ==============================================================================
> > --- cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp (added)
> > +++ cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp Fri Sep 21 18:03:16 2018
> > @@ -0,0 +1,13 @@
> > +// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s
> > +// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck --check-prefix=CHECK-ALIGNMENT %s
> > +// RUN: %clang -E  %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
> > +
> > +#if __has_feature(undefined_behavior_sanitizer)
> > +int UBSanEnabled();
> > +#else
> > +int UBSanDisabled();
> > +#endif
> > +
> > +// CHECK-UBSAN: UBSanEnabled
> > +// CHECK-ALIGNMENT: UBSanEnabled
> > +// CHECK-NO-UBSAN: UBSanDisabled
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list