]> granicus.if.org Git - clang/commitdiff
ASan docs: no_sanitize("address") works on globals.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 21 Jun 2018 00:16:32 +0000 (00:16 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 21 Jun 2018 00:16:32 +0000 (00:16 +0000)
Summary: Mention that no_sanitize attribute can be used with globals.

Reviewers: alekseyshl

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48390

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335193 91177308-0d34-0410-b5e6-96231b3b80d8

docs/AddressSanitizer.rst
include/clang/Basic/AttrDocs.td

index f58995576f91a47cc10fc02ed44c1b0713afa3bf..20cf699ac0b9c63f11664d5d078488ad57228d98 100644 (file)
@@ -197,13 +197,17 @@ this purpose.
 Disabling Instrumentation with ``__attribute__((no_sanitize("address")))``
 --------------------------------------------------------------------------
 
-Some code should not be instrumented by AddressSanitizer. One may use the
-function attribute ``__attribute__((no_sanitize("address")))`` (which has
-deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to
-disable instrumentation of a particular function. This attribute may not be
-supported by other compilers, so we suggest to use it together with
+Some code should not be instrumented by AddressSanitizer. One may use
+the attribute ``__attribute__((no_sanitize("address")))`` (which has
+deprecated synonyms `no_sanitize_address` and
+`no_address_safety_analysis`) to disable instrumentation of a
+particular function. This attribute may not be supported by other
+compilers, so we suggest to use it together with
 ``__has_feature(address_sanitizer)``.
 
+The same attribute used on a global variable prevents AddressSanitizer
+from adding redzones around it and detecting out of bounds accesses.
+
 Suppressing Errors in Recompiled Code (Blacklist)
 -------------------------------------------------
 
index 1cb510560d088ef630c0d5578051912aaa81df51..8210bf0a86a89730afa1610921142bf3efca1d9a 100644 (file)
@@ -1804,13 +1804,14 @@ This attribute accepts a single parameter that must be one of the following:
 def NoSanitizeDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-Use the ``no_sanitize`` attribute on a function declaration to specify
-that a particular instrumentation or set of instrumentations should not be
-applied to that function. The attribute takes a list of string literals,
-which have the same meaning as values accepted by the ``-fno-sanitize=``
-flag. For example, ``__attribute__((no_sanitize("address", "thread")))``
-specifies that AddressSanitizer and ThreadSanitizer should not be applied
-to the function.
+Use the ``no_sanitize`` attribute on a function or a global variable
+declaration to specify that a particular instrumentation or set of
+instrumentations should not be applied. The attribute takes a list of
+string literals, which have the same meaning as values accepted by the
+``-fno-sanitize=`` flag. For example,
+``__attribute__((no_sanitize("address", "thread")))`` specifies that
+AddressSanitizer and ThreadSanitizer should not be applied to the
+function or variable.
 
 See :ref:`Controlling Code Generation <controlling-code-generation>` for a
 full list of supported sanitizer flags.
@@ -1825,9 +1826,9 @@ def NoSanitizeAddressDocs : Documentation {
   let Content = [{
 .. _langext-address_sanitizer:
 
-Use ``__attribute__((no_sanitize_address))`` on a function declaration to
-specify that address safety instrumentation (e.g. AddressSanitizer) should
-not be applied to that function.
+Use ``__attribute__((no_sanitize_address))`` on a function or a global
+variable declaration to specify that address safety instrumentation
+(e.g. AddressSanitizer) should not be applied.
   }];
 }