[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 20 00:23:10 PDT 2024
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/96142
>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH] more
Created using spr 1.3.5-bogner
---
compiler-rt/lib/nsan/nsan.cpp | 59 ++++++------
compiler-rt/lib/nsan/nsan_flags.cpp | 2 -
compiler-rt/lib/nsan/nsan_stats.cpp | 107 ++++++++++-----------
compiler-rt/lib/nsan/nsan_stats.h | 43 +++++----
compiler-rt/lib/nsan/nsan_suppressions.cpp | 48 +++++----
5 files changed, 124 insertions(+), 135 deletions(-)
diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
}
-namespace __nsan {
const char *FTInfo<float>::kCppTypeName = "float";
const char *FTInfo<double>::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template <typename T> T max(T a, T b) { return a < b ? b : a; }
} // end anonymous namespace
-} // end namespace __nsan
-
void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
void *context,
bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() {
if (nsan_stats)
- nsan_stats->print();
+ nsan_stats->Print();
}
static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 *store_addr, uptr n) {
return getShadowPtrForStore<long double>(store_addr, n);
}
-template <typename FT> static bool isValidShadowType(const u8 *shadow_type) {
+template <typename FT> static bool IsValidShadowType(const u8 *shadow_type) {
return __builtin_memcmp(shadow_type, FTInfo<FT>::kTypePattern, sizeof(FT)) ==
0;
}
-template <int kSize, typename T> static bool isZero(const T *ptr) {
+template <int kSize, typename T> static bool IsZero(const T *ptr) {
constexpr const char kZeros[kSize] = {}; // Zero initialized.
return __builtin_memcmp(ptr, kZeros, kSize) == 0;
}
-template <typename FT> static bool isUnknownShadowType(const u8 *shadow_type) {
- return isZero<sizeof(FTInfo<FT>::kTypePattern)>(shadow_type);
+template <typename FT> static bool IsUnknownShadowType(const u8 *shadow_type) {
+ return IsZero<sizeof(FTInfo<FT>::kTypePattern)>(shadow_type);
}
// The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template <typename FT>
static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
for (uptr i = 0; i < n; ++i) {
- if (!isValidShadowType<FT>(shadow_type + i * sizeof(FT))) {
+ if (!IsValidShadowType<FT>(shadow_type + i * sizeof(FT))) {
// If loadtracking stats are enabled, log loads with invalid types
// (tampered with through type punning).
if (flags().enable_loadtracking_stats) {
- if (isUnknownShadowType<FT>(shadow_type + i * sizeof(FT))) {
+ if (IsUnknownShadowType<FT>(shadow_type + i * sizeof(FT))) {
// Warn only if the value is non-zero. Zero is special because
// applications typically initialize large buffers to zero in an
// untyped way.
- if (!isZero<sizeof(FT)>(load_addr)) {
+ if (!IsZero<sizeof(FT)>(load_addr)) {
GET_CALLER_PC_BP;
- nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+ nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
}
} else {
GET_CALLER_PC_BP;
- nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+ nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
}
}
return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT CheckType,
// want to avoid having to move the computation of `largest` before the
// absolute value check when this branch is not taken.
const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
- nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+ nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
}
// Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT CheckType,
if (flags().enable_warning_stats) {
GET_CALLER_PC_BP;
- nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+ nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
}
if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, __float128 shadow,
return checkFT(value, shadow, static_cast<CheckTypeT>(check_type), check_arg);
}
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { return v ? "true" : "false"; }
// This uses the same values as CmpInst::Predicate.
-static const char *getPredicateName(int v) {
+static const char *GetPredicateName(int v) {
switch (v) {
case 0:
return "(false)";
@@ -618,21 +615,19 @@ void fCmpFailFT(const FT Lhs, const FT Rhs, ShadowFT LhsShadow,
}
GET_CALLER_PC_BP;
- BufferedStackTrace Stack;
- Stack.Unwind(pc, bp, nullptr, false);
+ BufferedStackTrace stack;
+ stack.Unwind(pc, bp, nullptr, false);
- if (GetSuppressionForStack(&Stack, CheckKind::Fcmp)) {
+ if (GetSuppressionForStack(&stack, CheckKind::Fcmp)) {
// FIXME: optionally print.
return;
}
- if (flags().enable_warning_stats) {
- nsan_stats->addWarning(CheckTypeT::kFcmp, pc, bp, 0.0);
- }
+ if (flags().enable_warning_stats)
+ nsan_stats->AddWarning(CheckTypeT::kFcmp, pc, bp, 0.0);
- if (flags().disable_warnings) {
+ if (flags().disable_warnings)
return;
- }
// FIXME: ideally we would print the shadow value as FP128. Right now because
// we truncate to long double we can sometimes see stuff like:
@@ -640,7 +635,7 @@ void fCmpFailFT(const FT Lhs, const FT Rhs, ShadowFT LhsShadow,
using ValuePrinter = FTPrinter<FT>;
using ShadowPrinter = FTPrinter<ShadowFT>;
Decorator D;
- const char *const PredicateName = getPredicateName(Predicate);
+ const char *const PredicateName = GetPredicateName(Predicate);
Printf("%s", D.Warning());
Printf("WARNING: NumericalStabilitySanitizer: floating-point comparison "
"results depend on precision\n"
@@ -651,20 +646,20 @@ void fCmpFailFT(const FT Lhs, const FT Rhs, ShadowFT LhsShadow,
"%s",
// Native, decimal.
FTInfo<FT>::kCppTypeName, ValuePrinter::dec(Lhs).Buffer, PredicateName,
- ValuePrinter::dec(Rhs).Buffer, getTruthValueName(result),
+ ValuePrinter::dec(Rhs).Buffer, GetTruthValueName(result),
// Shadow, decimal
FTInfo<ShadowFT>::kCppTypeName, ShadowPrinter::dec(LhsShadow).Buffer,
PredicateName, ShadowPrinter::dec(RhsShadow).Buffer,
- getTruthValueName(ShadowResult),
+ GetTruthValueName(ShadowResult),
// Native, hex.
FTInfo<FT>::kCppTypeName, ValuePrinter::hex(Lhs).Buffer, PredicateName,
- ValuePrinter::hex(Rhs).Buffer, getTruthValueName(result),
+ ValuePrinter::hex(Rhs).Buffer, GetTruthValueName(result),
// Shadow, hex
FTInfo<ShadowFT>::kCppTypeName, ShadowPrinter::hex(LhsShadow).Buffer,
PredicateName, ShadowPrinter::hex(RhsShadow).Buffer,
- getTruthValueName(ShadowResult), D.End());
+ GetTruthValueName(ShadowResult), D.End());
Printf("%s", D.Default());
- Stack.Print();
+ stack.Print();
if (flags().halt_on_error) {
Printf("Exiting\n");
Die();
@@ -799,7 +794,7 @@ extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_init() {
InitializeInterceptors();
- initializeStats();
+ InitializeStats();
if (flags().print_stats_on_exit)
Atexit(NsanAtexit);
diff --git a/compiler-rt/lib/nsan/nsan_flags.cpp b/compiler-rt/lib/nsan/nsan_flags.cpp
index 2c7764653a22d..94e3a187c8e6c 100644
--- a/compiler-rt/lib/nsan/nsan_flags.cpp
+++ b/compiler-rt/lib/nsan/nsan_flags.cpp
@@ -18,11 +18,9 @@
using namespace __sanitizer;
using namespace __nsan;
-namespace __nsan {
SANITIZER_INTERFACE_WEAK_DEF(const char *, __nsan_default_options, void) {
return "";
}
-} // namespace __nsan
Flags __nsan::flags_data;
diff --git a/compiler-rt/lib/nsan/nsan_stats.cpp b/compiler-rt/lib/nsan/nsan_stats.cpp
index f23a72e3ba2a8..d188df1b1f70b 100644
--- a/compiler-rt/lib/nsan/nsan_stats.cpp
+++ b/compiler-rt/lib/nsan/nsan_stats.cpp
@@ -22,72 +22,73 @@
#include <assert.h>
#include <stdio.h>
-namespace __nsan {
-
using namespace __sanitizer;
+using namespace __nsan;
Stats::Stats() {
- CheckAndWarnings.Initialize(0);
+ check_and_warnings.Initialize(0);
TrackedLoads.Initialize(0);
}
Stats::~Stats() { Printf("deleting nsan stats\n"); }
-static uptr key(CheckTypeT CheckType, u32 StackId) {
+static uptr Key(CheckTypeT CheckType, u32 StackId) {
return static_cast<uptr>(CheckType) +
StackId * static_cast<uptr>(CheckTypeT::kMaxCheckType);
}
template <typename MapT, typename VectorT, typename Fn>
-void UpdateEntry(CheckTypeT CheckTy, uptr PC, uptr BP, MapT *Map,
- VectorT *Vector, Mutex *Mutex, Fn F) {
+static void UpdateEntry(CheckTypeT check_ty, uptr pc, uptr bp, MapT *map,
+ VectorT *vector, Mutex *mutex, Fn F) {
BufferedStackTrace Stack;
- Stack.Unwind(PC, BP, nullptr, false);
- u32 StackId = StackDepotPut(Stack);
- typename MapT::Handle Handle(Map, key(CheckTy, StackId));
- Lock L(Mutex);
+ Stack.Unwind(pc, bp, nullptr, false);
+ u32 stack_id = StackDepotPut(Stack);
+ typename MapT::Handle Handle(map, Key(check_ty, stack_id));
+ Lock L(mutex);
if (Handle.created()) {
- typename VectorT::value_type Entry;
- Entry.StackId = StackId;
- Entry.CheckTy = CheckTy;
- F(Entry);
- Vector->push_back(Entry);
+ typename VectorT::value_type entry;
+ entry.stack_id = stack_id;
+ entry.check_ty = check_ty;
+ F(entry);
+ vector->push_back(entry);
} else {
- auto &Entry = (*Vector)[*Handle];
- F(Entry);
+ auto &entry = (*vector)[*Handle];
+ F(entry);
}
}
-void Stats::addCheck(CheckTypeT CheckTy, uptr PC, uptr BP, double RelErr) {
- UpdateEntry(CheckTy, PC, BP, &CheckAndWarningsMap, &CheckAndWarnings,
- &CheckAndWarningsMutex, [RelErr](CheckAndWarningsValue &Entry) {
- ++Entry.NumChecks;
- if (RelErr > Entry.MaxRelativeError) {
- Entry.MaxRelativeError = RelErr;
+void Stats::AddCheck(CheckTypeT check_ty, uptr pc, uptr bp, double rel_err) {
+ UpdateEntry(check_ty, pc, bp, &CheckAndWarningsMap, &check_and_warnings,
+ &check_and_warning_mutex,
+ [rel_err](CheckAndWarningsValue &entry) {
+ ++entry.num_checks;
+ if (rel_err > entry.max_relative_err) {
+ entry.max_relative_err = rel_err;
}
});
}
-void Stats::addWarning(CheckTypeT CheckTy, uptr PC, uptr BP, double RelErr) {
- UpdateEntry(CheckTy, PC, BP, &CheckAndWarningsMap, &CheckAndWarnings,
- &CheckAndWarningsMutex, [RelErr](CheckAndWarningsValue &Entry) {
- ++Entry.NumWarnings;
- if (RelErr > Entry.MaxRelativeError) {
- Entry.MaxRelativeError = RelErr;
+void Stats::AddWarning(CheckTypeT check_ty, uptr pc, uptr bp, double rel_err) {
+ UpdateEntry(check_ty, pc, bp, &CheckAndWarningsMap, &check_and_warnings,
+ &check_and_warning_mutex,
+ [rel_err](CheckAndWarningsValue &entry) {
+ ++entry.num_warnings;
+ if (rel_err > entry.max_relative_err) {
+ entry.max_relative_err = rel_err;
}
});
}
-void Stats::addInvalidLoadTrackingEvent(uptr PC, uptr BP) {
- UpdateEntry(CheckTypeT::kLoad, PC, BP, &LoadTrackingMap, &TrackedLoads,
+void Stats::AddInvalidLoadTrackingEvent(uptr pc, uptr bp) {
+ UpdateEntry(CheckTypeT::kLoad, pc, bp, &LoadTrackingMap, &TrackedLoads,
&TrackedLoadsMutex,
- [](LoadTrackingValue &Entry) { ++Entry.NumInvalid; });
+ [](LoadTrackingValue &entry) { ++entry.num_invalid; });
}
-void Stats::addUnknownLoadTrackingEvent(uptr PC, uptr BP) {
- UpdateEntry(CheckTypeT::kLoad, PC, BP, &LoadTrackingMap, &TrackedLoads,
+void Stats::AddUnknownLoadTrackingEvent(uptr pc, uptr bp) {
+ UpdateEntry(CheckTypeT::kLoad, pc, bp, &LoadTrackingMap, &TrackedLoads,
&TrackedLoadsMutex,
- [](LoadTrackingValue &Entry) { ++Entry.NumUnknown; });
+ [](LoadTrackingValue &entry) { ++entry.num_unknown; });
}
static const char *CheckTypeDisplay(CheckTypeT CheckType) {
@@ -115,20 +116,20 @@ static const char *CheckTypeDisplay(CheckTypeT CheckType) {
return "";
}
-void Stats::print() const {
+void Stats::Print() const {
{
- Lock L(&CheckAndWarningsMutex);
- for (const auto &Entry : CheckAndWarnings) {
- Printf("warned %llu times out of %llu %s checks ", Entry.NumWarnings,
- Entry.NumChecks, CheckTypeDisplay(Entry.CheckTy));
- if (Entry.NumWarnings > 0) {
+ Lock L(&check_and_warning_mutex);
+ for (const auto &entry : check_and_warnings) {
+ Printf("warned %llu times out of %llu %s checks ", entry.num_warnings,
+ entry.num_checks, CheckTypeDisplay(entry.check_ty));
+ if (entry.num_warnings > 0) {
char RelErrBuf[64];
snprintf(RelErrBuf, sizeof(RelErrBuf) - 1, "%f",
- Entry.MaxRelativeError * 100.0);
+ entry.max_relative_err * 100.0);
Printf("(max relative error: %s%%) ", RelErrBuf);
}
Printf("at:\n");
- StackDepotGet(Entry.StackId).Print();
+ StackDepotGet(entry.stack_id).Print();
}
}
@@ -136,12 +137,12 @@ void Stats::print() const {
Lock L(&TrackedLoadsMutex);
u64 TotalInvalidLoadTracking = 0;
u64 TotalUnknownLoadTracking = 0;
- for (const auto &Entry : TrackedLoads) {
- TotalInvalidLoadTracking += Entry.NumInvalid;
- TotalUnknownLoadTracking += Entry.NumUnknown;
- Printf("invalid/unknown type for %llu/%llu loads at:\n", Entry.NumInvalid,
- Entry.NumUnknown);
- StackDepotGet(Entry.StackId).Print();
+ for (const auto &entry : TrackedLoads) {
+ TotalInvalidLoadTracking += entry.num_invalid;
+ TotalUnknownLoadTracking += entry.num_unknown;
+ Printf("invalid/unknown type for %llu/%llu loads at:\n",
+ entry.num_invalid, entry.num_unknown);
+ StackDepotGet(entry.stack_id).Print();
}
Printf(
"There were %llu/%llu floating-point loads where the shadow type was "
@@ -150,9 +151,7 @@ void Stats::print() const {
}
}
-alignas(64) static char StatsPlaceholder[sizeof(Stats)];
-Stats *nsan_stats = nullptr;
-
-void initializeStats() { nsan_stats = new (StatsPlaceholder) Stats(); }
+alignas(64) static char stats_placeholder[sizeof(Stats)];
+Stats *__nsan::nsan_stats = nullptr;
-} // namespace __nsan
+void __nsan::InitializeStats() { nsan_stats = new (stats_placeholder) Stats(); }
diff --git a/compiler-rt/lib/nsan/nsan_stats.h b/compiler-rt/lib/nsan/nsan_stats.h
index 7e8c7bb7bf12d..d1c7e0115e7ae 100644
--- a/compiler-rt/lib/nsan/nsan_stats.h
+++ b/compiler-rt/lib/nsan/nsan_stats.h
@@ -40,52 +40,53 @@ class Stats {
~Stats();
// Signal that we checked the instruction at the given address.
- void addCheck(CheckTypeT CheckType, __sanitizer::uptr PC,
- __sanitizer::uptr BP, double RelErr);
+ void AddCheck(CheckTypeT check_ty, __sanitizer::uptr pc, __sanitizer::uptr bp,
+ double rel_err);
// Signal that we warned for the instruction at the given address.
- void addWarning(CheckTypeT CheckType, __sanitizer::uptr PC,
- __sanitizer::uptr BP, double RelErr);
+ void AddWarning(CheckTypeT check_ty, __sanitizer::uptr pc,
+ __sanitizer::uptr bp, double rel_err);
// Signal that we detected a floating-point load where the shadow type was
// invalid.
- void addInvalidLoadTrackingEvent(__sanitizer::uptr PC, __sanitizer::uptr BP);
+ void AddInvalidLoadTrackingEvent(__sanitizer::uptr pc, __sanitizer::uptr bp);
// Signal that we detected a floating-point load where the shadow type was
// unknown but the value was nonzero.
- void addUnknownLoadTrackingEvent(__sanitizer::uptr PC, __sanitizer::uptr BP);
+ void AddUnknownLoadTrackingEvent(__sanitizer::uptr pc, __sanitizer::uptr bp);
- void print() const;
+ void Print() const;
private:
using IndexMap = __sanitizer::AddrHashMap<__sanitizer::uptr, 11>;
struct CheckAndWarningsValue {
- CheckTypeT CheckTy;
- __sanitizer::u32 StackId = 0;
- __sanitizer::u64 NumChecks = 0;
- __sanitizer::u64 NumWarnings = 0;
+ CheckTypeT check_ty;
+ __sanitizer::u32 stack_id = 0;
+ __sanitizer::u64 num_checks = 0;
+ __sanitizer::u64 num_warnings = 0;
// This is a bitcasted double. Doubles have the nice idea to be ordered as
// ints.
- double MaxRelativeError = 0;
+ double max_relative_err = 0;
};
- // Maps key(CheckType, StackId) to indices in CheckAndWarnings.
+ // Map Key(check_ty, StackId) to indices in CheckAndWarnings.
IndexMap CheckAndWarningsMap;
- __sanitizer::InternalMmapVectorNoCtor<CheckAndWarningsValue> CheckAndWarnings;
- mutable __sanitizer::Mutex CheckAndWarningsMutex;
+ __sanitizer::InternalMmapVectorNoCtor<CheckAndWarningsValue>
+ check_and_warnings;
+ mutable __sanitizer::Mutex check_and_warning_mutex;
struct LoadTrackingValue {
- CheckTypeT CheckTy;
- __sanitizer::u32 StackId = 0;
- __sanitizer::u64 NumInvalid = 0;
- __sanitizer::u64 NumUnknown = 0;
+ CheckTypeT check_ty;
+ __sanitizer::u32 stack_id = 0;
+ __sanitizer::u64 num_invalid = 0;
+ __sanitizer::u64 num_unknown = 0;
};
- // Maps key(CheckTypeT::kLoad, StackId) to indices in TrackedLoads.
+ // Map Key(CheckTypeT::kLoad, StackId) to indices in TrackedLoads.
IndexMap LoadTrackingMap;
__sanitizer::InternalMmapVectorNoCtor<LoadTrackingValue> TrackedLoads;
mutable __sanitizer::Mutex TrackedLoadsMutex;
};
extern Stats *nsan_stats;
-void initializeStats();
+void InitializeStats();
} // namespace __nsan
diff --git a/compiler-rt/lib/nsan/nsan_suppressions.cpp b/compiler-rt/lib/nsan/nsan_suppressions.cpp
index 12dd8708c37e7..c4d438e090e05 100644
--- a/compiler-rt/lib/nsan/nsan_suppressions.cpp
+++ b/compiler-rt/lib/nsan/nsan_suppressions.cpp
@@ -7,55 +7,52 @@
//===----------------------------------------------------------------------===//
#include "nsan_suppressions.h"
-
+#include "nsan_flags.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
-#include "nsan_flags.h"
-
-// Can be overriden in frontend.
-SANITIZER_WEAK_DEFAULT_IMPL
-const char *__nsan_default_suppressions() { return 0; }
-
-namespace __nsan {
+using namespace __sanitizer;
+using namespace __nsan;
-const char *const kSuppressionFcmp = "fcmp";
-const char *const kSuppressionConsistency = "consistency";
+SANITIZER_INTERFACE_WEAK_DEF(const char *, __nsan_default_suppressions, void) {
+ return 0;
+}
-using namespace __sanitizer;
+const char kSuppressionFcmp[] = "fcmp";
+const char kSuppressionConsistency[] = "consistency";
-alignas(64) static char suppressionPlaceholder[sizeof(SuppressionContext)];
-static SuppressionContext *suppressionCtx = nullptr;
+alignas(64) static char suppression_placeholder[sizeof(SuppressionContext)];
+static SuppressionContext *suppression_ctx;
// The order should match the enum CheckKind.
static const char *kSuppressionTypes[] = {kSuppressionFcmp,
kSuppressionConsistency};
-void InitializeSuppressions() {
- CHECK_EQ(nullptr, suppressionCtx);
- suppressionCtx = new (suppressionPlaceholder)
+void __nsan::InitializeSuppressions() {
+ CHECK_EQ(nullptr, suppression_ctx);
+ suppression_ctx = new (suppression_placeholder)
SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
- suppressionCtx->ParseFromFile(flags().suppressions);
- suppressionCtx->Parse(__nsan_default_suppressions());
+ suppression_ctx->ParseFromFile(flags().suppressions);
+ suppression_ctx->Parse(__nsan_default_suppressions());
}
-static Suppression *GetSuppressionForAddr(uptr addr, const char *supprType) {
+static Suppression *GetSuppressionForAddr(uptr addr, const char *suppr_type) {
Suppression *s = nullptr;
// Suppress by module name.
- SuppressionContext *suppressions = suppressionCtx;
+ SuppressionContext *suppressions = suppression_ctx;
if (const char *moduleName =
Symbolizer::GetOrInit()->GetModuleNameForPc(addr)) {
- if (suppressions->Match(moduleName, supprType, &s))
+ if (suppressions->Match(moduleName, suppr_type, &s))
return s;
}
// Suppress by file or function name.
SymbolizedStack *frames = Symbolizer::GetOrInit()->SymbolizePC(addr);
for (SymbolizedStack *cur = frames; cur; cur = cur->next) {
- if (suppressions->Match(cur->info.function, supprType, &s) ||
- suppressions->Match(cur->info.file, supprType, &s)) {
+ if (suppressions->Match(cur->info.function, suppr_type, &s) ||
+ suppressions->Match(cur->info.file, suppr_type, &s)) {
break;
}
}
@@ -63,7 +60,8 @@ static Suppression *GetSuppressionForAddr(uptr addr, const char *supprType) {
return s;
}
-Suppression *GetSuppressionForStack(const StackTrace *stack, CheckKind k) {
+Suppression *__nsan::GetSuppressionForStack(const StackTrace *stack,
+ CheckKind k) {
for (uptr i = 0, e = stack->size; i < e; i++) {
Suppression *s = GetSuppressionForAddr(
StackTrace::GetPreviousInstructionPc(stack->trace[i]),
@@ -73,5 +71,3 @@ Suppression *GetSuppressionForStack(const StackTrace *stack, CheckKind k) {
}
return nullptr;
}
-
-} // end namespace __nsan
More information about the llvm-branch-commits
mailing list