Re: r284272 - Implement no_sanitize_address for global vars
will do. I'll initiate a review for the original change and a new one for the suggestions. The ExpectedFunctionGlobalVarMethodOrProperty diagnostic was essentially a copy-and-paste from here: def Alias : Attr { let Spellings = [GCC<"alias">]; let Args = [StringArgument<"Aliasee">]; let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, "ExpectedFunctionGlobalVarMethodOrProperty">; let Documentation = [Undocumented]; } I guess that one's wrong? That'll teach me to look at existing code. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284272 - Implement no_sanitize_address for global vars
On Fri, Oct 14, 2016 at 3:55 PM, Douglas Katzman via cfe-commitswrote: > Author: dougk > Date: Fri Oct 14 14:55:09 2016 > New Revision: 284272 > > URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev > Log: > Implement no_sanitize_address for global vars > > Modified: > cfe/trunk/include/clang/Basic/Attr.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/AttributeList.h > cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/CodeGen/asan-globals.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp > > Modified: cfe/trunk/include/clang/Basic/Attr.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=284272=284271=284272=diff > == > --- cfe/trunk/include/clang/Basic/Attr.td (original) > +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 > @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl > def NoSanitize : InheritableAttr { >let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >let Args = [VariadicStringArgument<"Sanitizers">]; > - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; > + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag, > +"ExpectedFunctionMethodOrGlobalVar">; The down-side to this change is that now every no_sanitize attribute now appertains to a global variable, as far as its subjects go, but really only the address sanitizer applies to global variables. I'm not certain there's much to be done for it, but this divergence is unfortunate. For instance, this means that misuse of no_sanitizer for thread may tell the user the attribute appertains to global variables, and when they fix the misuse on a global variable, they're told "just kidding, this doesn't apply to global variables." >let Documentation = [NoSanitizeDocs]; >let AdditionalMembers = [{ > SanitizerMask getMask() const { > @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr > GCC<"no_sanitize_address">, > GCC<"no_sanitize_thread">, > GNU<"no_sanitize_memory">]; > - let Subjects = SubjectList<[Function], ErrorDiag>; > + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, > +"ExpectedFunctionGlobalVarMethodOrProperty">; This new diagnostic looks incorrect to me -- the subject list does not list methods or properties, for instance. >let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, > NoSanitizeMemoryDocs]; >let ASTNode = 0; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 14:55:09 > 2016 > @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >"|functions, methods and blocks" >"|functions, methods, and classes" >"|functions, methods, and parameters" > + "|functions, methods, and global variables" >"|classes" >"|enums" >"|variables" > > Modified: cfe/trunk/include/clang/Sema/AttributeList.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=284272=284271=284272=diff > == > --- cfe/trunk/include/clang/Sema/AttributeList.h (original) > +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 > @@ -891,6 +891,7 @@ enum AttributeDeclKind { >ExpectedFunctionMethodOrBlock, >ExpectedFunctionMethodOrClass, >ExpectedFunctionMethodOrParameter, > + ExpectedFunctionMethodOrGlobalVar, >ExpectedClass, >ExpectedEnum, >ExpectedVariable, > > Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp?rev=284272=284271=284272=diff > == > --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) > +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 > @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >std::string QualName; >llvm::raw_string_ostream OS(QualName); >D.printQualifiedName(OS); > - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit); > + > + bool IsBlacklisted = false; > + for (auto Attr : D.specific_attrs()) This should be const auto * and probably not use Attr (since that's a type name). > +if
Re: r284272 - Implement no_sanitize_address for global vars
oh, sorry for missing this email. I'll say "no" - I was hoping you'd audit it! jyknight looked at it and gave me the suggestion to fail the attribute parsing if, in the non-deprecated syntax, _any_ of the no_sanitize modifiers are inapplicable to global vars. On Tue, Oct 25, 2016 at 7:19 PM, Kostya Serebryanywrote: > ping > > On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany wrote: > >> Did you code-review this? >> (sorry if I missed it) >> >> On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: dougk >>> Date: Fri Oct 14 14:55:09 2016 >>> New Revision: 284272 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev >>> Log: >>> Implement no_sanitize_address for global vars >>> >>> Modified: >>> cfe/trunk/include/clang/Basic/Attr.td >>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> cfe/trunk/include/clang/Sema/AttributeList.h >>> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp >>> cfe/trunk/test/CodeGen/asan-globals.cpp >>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp >>> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/Attr.td >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Basic/Attr.td?rev=284272=284271=284272=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/Attr.td (original) >>> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 >>> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl >>> def NoSanitize : InheritableAttr { >>>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >>>let Args = [VariadicStringArgument<"Sanitizers">]; >>> - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; >>> + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], >>> ErrorDiag, >>> +"ExpectedFunctionMethodOrGlobalVar">; >>>let Documentation = [NoSanitizeDocs]; >>>let AdditionalMembers = [{ >>> SanitizerMask getMask() const { >>> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr >>> GCC<"no_sanitize_address">, >>> GCC<"no_sanitize_thread">, >>> GNU<"no_sanitize_memory">]; >>> - let Subjects = SubjectList<[Function], ErrorDiag>; >>> + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, >>> +"ExpectedFunctionGlobalVarMethodOrProperty">; >>>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, >>> NoSanitizeMemoryDocs]; >>>let ASTNode = 0; >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 >>> 14:55:09 2016 >>> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >>>"|functions, methods and blocks" >>>"|functions, methods, and classes" >>>"|functions, methods, and parameters" >>> + "|functions, methods, and global variables" >>>"|classes" >>>"|enums" >>>"|variables" >>> >>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>> Sema/AttributeList.h?rev=284272=284271=284272=diff >>> >>> == >>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original) >>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 >>> 2016 >>> @@ -891,6 +891,7 @@ enum AttributeDeclKind { >>>ExpectedFunctionMethodOrBlock, >>>ExpectedFunctionMethodOrClass, >>>ExpectedFunctionMethodOrParameter, >>> + ExpectedFunctionMethodOrGlobalVar, >>>ExpectedClass, >>>ExpectedEnum, >>>ExpectedVariable, >>> >>> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa >>> nitizerMetadata.cpp?rev=284272=284271=284272=diff >>> >>> == >>> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) >>> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 >>> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >>>std::string QualName; >>>llvm::raw_string_ostream OS(QualName); >>>D.printQualifiedName(OS); >>> - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), >>> IsDynInit); >>> + >>> + bool IsBlacklisted = false; >>> + for (auto Attr : D.specific_attrs()) >>> +if (Attr->getMask() &
Re: r284272 - Implement no_sanitize_address for global vars
ping On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryanywrote: > Did you code-review this? > (sorry if I missed it) > > On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: dougk >> Date: Fri Oct 14 14:55:09 2016 >> New Revision: 284272 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev >> Log: >> Implement no_sanitize_address for global vars >> >> Modified: >> cfe/trunk/include/clang/Basic/Attr.td >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> cfe/trunk/include/clang/Sema/AttributeList.h >> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp >> cfe/trunk/test/CodeGen/asan-globals.cpp >> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp >> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp >> >> Modified: cfe/trunk/include/clang/Basic/Attr.td >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Basic/Attr.td?rev=284272=284271=284272=diff >> >> == >> --- cfe/trunk/include/clang/Basic/Attr.td (original) >> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 >> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl >> def NoSanitize : InheritableAttr { >>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >>let Args = [VariadicStringArgument<"Sanitizers">]; >> - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; >> + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], >> ErrorDiag, >> +"ExpectedFunctionMethodOrGlobalVar">; >>let Documentation = [NoSanitizeDocs]; >>let AdditionalMembers = [{ >> SanitizerMask getMask() const { >> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr >> GCC<"no_sanitize_address">, >> GCC<"no_sanitize_thread">, >> GNU<"no_sanitize_memory">]; >> - let Subjects = SubjectList<[Function], ErrorDiag>; >> + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, >> +"ExpectedFunctionGlobalVarMethodOrProperty">; >>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, >> NoSanitizeMemoryDocs]; >>let ASTNode = 0; >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff >> >> == >> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 >> 14:55:09 2016 >> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >>"|functions, methods and blocks" >>"|functions, methods, and classes" >>"|functions, methods, and parameters" >> + "|functions, methods, and global variables" >>"|classes" >>"|enums" >>"|variables" >> >> Modified: cfe/trunk/include/clang/Sema/AttributeList.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Sema/AttributeList.h?rev=284272=284271=284272=diff >> >> == >> --- cfe/trunk/include/clang/Sema/AttributeList.h (original) >> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 >> @@ -891,6 +891,7 @@ enum AttributeDeclKind { >>ExpectedFunctionMethodOrBlock, >>ExpectedFunctionMethodOrClass, >>ExpectedFunctionMethodOrParameter, >> + ExpectedFunctionMethodOrGlobalVar, >>ExpectedClass, >>ExpectedEnum, >>ExpectedVariable, >> >> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa >> nitizerMetadata.cpp?rev=284272=284271=284272=diff >> >> == >> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) >> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 >> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >>std::string QualName; >>llvm::raw_string_ostream OS(QualName); >>D.printQualifiedName(OS); >> - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), >> IsDynInit); >> + >> + bool IsBlacklisted = false; >> + for (auto Attr : D.specific_attrs()) >> +if (Attr->getMask() & SanitizerKind::Address) >> + IsBlacklisted = true; >> + reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), >> IsDynInit, >> + IsBlacklisted); >> } >> >> void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable >> *GV) { >> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD >> eclAttr.cpp?rev=284272=284271=284272=diff >>
Re: r284272 - Implement no_sanitize_address for global vars
Did you code-review this? (sorry if I missed it) On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: dougk > Date: Fri Oct 14 14:55:09 2016 > New Revision: 284272 > > URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev > Log: > Implement no_sanitize_address for global vars > > Modified: > cfe/trunk/include/clang/Basic/Attr.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/AttributeList.h > cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/CodeGen/asan-globals.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp > cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp > > Modified: cfe/trunk/include/clang/Basic/Attr.td > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Basic/Attr.td?rev=284272=284271=284272=diff > > == > --- cfe/trunk/include/clang/Basic/Attr.td (original) > +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 > @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl > def NoSanitize : InheritableAttr { >let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; >let Args = [VariadicStringArgument<"Sanitizers">]; > - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; > + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag, > +"ExpectedFunctionMethodOrGlobalVar">; >let Documentation = [NoSanitizeDocs]; >let AdditionalMembers = [{ > SanitizerMask getMask() const { > @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr > GCC<"no_sanitize_address">, > GCC<"no_sanitize_thread">, > GNU<"no_sanitize_memory">]; > - let Subjects = SubjectList<[Function], ErrorDiag>; > + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, > +"ExpectedFunctionGlobalVarMethodOrProperty">; >let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, > NoSanitizeMemoryDocs]; >let ASTNode = 0; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ > DiagnosticSemaKinds.td?rev=284272=284271=284272=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 > 14:55:09 2016 > @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War >"|functions, methods and blocks" >"|functions, methods, and classes" >"|functions, methods, and parameters" > + "|functions, methods, and global variables" >"|classes" >"|enums" >"|variables" > > Modified: cfe/trunk/include/clang/Sema/AttributeList.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Sema/AttributeList.h?rev=284272=284271=284272=diff > > == > --- cfe/trunk/include/clang/Sema/AttributeList.h (original) > +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 > @@ -891,6 +891,7 @@ enum AttributeDeclKind { >ExpectedFunctionMethodOrBlock, >ExpectedFunctionMethodOrClass, >ExpectedFunctionMethodOrParameter, > + ExpectedFunctionMethodOrGlobalVar, >ExpectedClass, >ExpectedEnum, >ExpectedVariable, > > Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ > SanitizerMetadata.cpp?rev=284272=284271=284272=diff > > == > --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) > +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 > @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS >std::string QualName; >llvm::raw_string_ostream OS(QualName); >D.printQualifiedName(OS); > - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), > IsDynInit); > + > + bool IsBlacklisted = false; > + for (auto Attr : D.specific_attrs()) > +if (Attr->getMask() & SanitizerKind::Address) > + IsBlacklisted = true; > + reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), > IsDynInit, > + IsBlacklisted); > } > > void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable > *GV) { > > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaDeclAttr.cpp?rev=284272=284271=284272=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct 14 14:55:09 2016 > @@ -5313,9 +5313,15 @@
r284272 - Implement no_sanitize_address for global vars
Author: dougk Date: Fri Oct 14 14:55:09 2016 New Revision: 284272 URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev Log: Implement no_sanitize_address for global vars Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/AttributeList.h cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/CodeGen/asan-globals.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=284272=284271=284272=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016 @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl def NoSanitize : InheritableAttr { let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">]; let Args = [VariadicStringArgument<"Sanitizers">]; - let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>; + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag, +"ExpectedFunctionMethodOrGlobalVar">; let Documentation = [NoSanitizeDocs]; let AdditionalMembers = [{ SanitizerMask getMask() const { @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr GCC<"no_sanitize_address">, GCC<"no_sanitize_thread">, GNU<"no_sanitize_memory">]; - let Subjects = SubjectList<[Function], ErrorDiag>; + let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag, +"ExpectedFunctionGlobalVarMethodOrProperty">; let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs, NoSanitizeMemoryDocs]; let ASTNode = 0; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 14:55:09 2016 @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War "|functions, methods and blocks" "|functions, methods, and classes" "|functions, methods, and parameters" + "|functions, methods, and global variables" "|classes" "|enums" "|variables" Modified: cfe/trunk/include/clang/Sema/AttributeList.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=284272=284271=284272=diff == --- cfe/trunk/include/clang/Sema/AttributeList.h (original) +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016 @@ -891,6 +891,7 @@ enum AttributeDeclKind { ExpectedFunctionMethodOrBlock, ExpectedFunctionMethodOrClass, ExpectedFunctionMethodOrParameter, + ExpectedFunctionMethodOrGlobalVar, ExpectedClass, ExpectedEnum, ExpectedVariable, Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp?rev=284272=284271=284272=diff == --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original) +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016 @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS std::string QualName; llvm::raw_string_ostream OS(QualName); D.printQualifiedName(OS); - reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit); + + bool IsBlacklisted = false; + for (auto Attr : D.specific_attrs()) +if (Attr->getMask() & SanitizerKind::Address) + IsBlacklisted = true; + reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit, + IsBlacklisted); } void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) { Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=284272=284271=284272=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct 14 14:55:09 2016 @@ -5313,9 +5313,15 @@ static void handleDeprecatedAttr(Sema !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu"))) S.Diag(Attr.getLoc(), diag::ext_cxx14_attr) << Attr.getName(); - D->addAttr(::new (S.Context) DeprecatedAttr(Attr.getRange(), S.Context, Str, - Replacement, -