[PATCH] D26454: Implement no_sanitize_address for global vars

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 10:36:59 PST 2016


aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaDeclAttr.cpp:5348
       S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
-    else if (isGlobalVar(D) && SanitizerName != "address")
+    else if (isGlobalVar(D) && SanitizerName != "address") {
       S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
----------------
This is unfortunate because the declarative subject information from Attr.td does not match the semantics in SemaDeclAttr.cpp for many of the sanitizer names. For instance, this means that someone using `__attribute__((no_sanitize("thread"))`` on a static local variable will get a diagnostic telling them that it only applies to functions, methods, and global variables. If they make their static local variable into a global variable, they will then get a different diagnostic telling them, oops, just functions or methods.

While I understand that this was already submitted in r284272, I don't see any rationale given in the commit log as to why this behavior is desirable in the first place. Can you give me some background information on why this is needed? Does it apply to other sanitizer names as well?


https://reviews.llvm.org/D26454





More information about the cfe-commits mailing list