[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.

Kevin Athey via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 27 01:19:55 PDT 2021


kda updated this revision to Diff 340754.
kda added a comment.

fixed up some more naming issues.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101122/new/

https://reviews.llvm.org/D101122

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h


Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===================================================================
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
   Invalid, ///< Not a valid destructor Kind.
   // TODO(dliew): Add more more kinds.
 };
+
+/// Kinds of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnKind {
+  Never,   ///< Never detect stack use after return.
+  Runtime, ///< Detect stack use after return if runtime flag is enabled
+           ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+  Always,  ///< Always detect stack use after return.
+  Invalid, ///< Not a valid detect mode.
+};
+
 } // namespace llvm
+
 #endif
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
       NormalizedValuesScope<"llvm::AsanDtorKind">,
       NormalizedValues<["None", "Global"]>,
       MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDtorKind">, "Global">;
+def sanitize_address_detect_stack_use_after_return_EQ
+    : Joined<["-"], "fsanitize-address-detect-stack-use-after-return=">,
+      MetaVarName<"<kind>">,
+      Flags<[CC1Option]>,
+      HelpText<"Select the enabling method of detect-stack-use-after-return in AddressSanitizer">,
+      Group<f_clang_Group>,
+      Values<"never,runtime,always">,
+      NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnKind">,
+      NormalizedValues<["Never", "Runtime", "Always"]>,
+      MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDetectStackUseAfterReturn">, "Runtime">;
 // Note: This flag was introduced when it was necessary to distinguish between
 //       ABI for correct codegen.  This is no longer needed, but the flag is
 //       not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===================================================================
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -222,6 +222,10 @@
 ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
                 llvm::AsanDtorKind::Global)  ///< Set how ASan global
                                              ///< destructors are emitted.
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturn,
+                llvm::AsanDetectStackUseAfterReturnKind, 2,
+                llvm::AsanDetectStackUseAfterReturnKind::Runtime
+                ) ///< Set detection mode for stack-use-after-return.
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
                                              ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101122.340754.patch
Type: text/x-patch
Size: 2974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210427/47553d65/attachment.bin>


More information about the cfe-commits mailing list