[clang] 1ff3064 - [Driver] Simplify -fsanitize-memory-track-origins handling. NFC

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 22:21:18 PST 2023


Author: Fangrui Song
Date: 2023-01-05T22:21:13-08:00
New Revision: 1ff3064c65b4d4440254311474efe176fd1c4e2c

URL: https://github.com/llvm/llvm-project/commit/1ff3064c65b4d4440254311474efe176fd1c4e2c
DIFF: https://github.com/llvm/llvm-project/commit/1ff3064c65b4d4440254311474efe176fd1c4e2c.diff

LOG: [Driver] Simplify -fsanitize-memory-track-origins handling. NFC

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/SanitizerArgs.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index dd299fa8e8830..b2f74add94ee4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1728,6 +1728,7 @@ def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-or
                                         MarshallingInfoInt<CodeGenOpts<"SanitizeMemoryTrackOrigins">>;
 def fsanitize_memory_track_origins : Flag<["-"], "fsanitize-memory-track-origins">,
                                      Group<f_clang_Group>,
+                                     Alias<fsanitize_memory_track_origins_EQ>, AliasArgs<["2"]>,
                                      HelpText<"Enable origins tracking in MemorySanitizer">;
 def fno_sanitize_memory_track_origins : Flag<["-"], "fno-sanitize-memory-track-origins">,
                                         Group<f_clang_Group>,

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 96a701366e37b..52bee6a755ff4 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -650,14 +650,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
   if (AllAddedKinds & SanitizerKind::Memory) {
     if (Arg *A =
             Args.getLastArg(options::OPT_fsanitize_memory_track_origins_EQ,
-                            options::OPT_fsanitize_memory_track_origins,
                             options::OPT_fno_sanitize_memory_track_origins)) {
-      if (A->getOption().matches(options::OPT_fsanitize_memory_track_origins)) {
-        MsanTrackOrigins = 2;
-      } else if (A->getOption().matches(
-                     options::OPT_fno_sanitize_memory_track_origins)) {
-        MsanTrackOrigins = 0;
-      } else {
+      if (!A->getOption().matches(
+              options::OPT_fno_sanitize_memory_track_origins)) {
         StringRef S = A->getValue();
         if (S.getAsInteger(0, MsanTrackOrigins) || MsanTrackOrigins < 0 ||
             MsanTrackOrigins > 2) {


        


More information about the cfe-commits mailing list