[clang] dc87a14 - [Clang] Fix sanitizer failure on DenseMap sentinel value enum
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 22 07:12:19 PDT 2025
Author: Joseph Huber
Date: 2025-07-22T09:12:13-05:00
New Revision: dc87a14efb381d960c8fbf988221f31216d7f5fd
URL: https://github.com/llvm/llvm-project/commit/dc87a14efb381d960c8fbf988221f31216d7f5fd
DIFF: https://github.com/llvm/llvm-project/commit/dc87a14efb381d960c8fbf988221f31216d7f5fd.diff
LOG: [Clang] Fix sanitizer failure on DenseMap sentinel value enum
Summary:
This triggers UBSan because the sentinel value `-1` is outside the range
of accepted enum values. Just replace this with a small set.
Added:
Modified:
clang/lib/Driver/Driver.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 706b905eed407..ff2f92d1a94c8 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
#include "clang/Driver/Types.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
@@ -1062,7 +1063,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
(C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) &&
!(IsCuda || IsHIP))));
- llvm::DenseSet<Action::OffloadKind> Kinds;
+ llvm::SmallSet<Action::OffloadKind, 4> Kinds;
const std::pair<bool, Action::OffloadKind> ActiveKinds[] = {
{IsCuda, Action::OFK_Cuda},
{IsHIP, Action::OFK_HIP},
More information about the cfe-commits
mailing list