diff options
-rw-r--r-- | lib/ubsan/ubsan_diag.cc | 15 | ||||
-rw-r--r-- | lib/ubsan/ubsan_diag.h | 4 | ||||
-rw-r--r-- | lib/ubsan/ubsan_handlers.cc | 10 |
3 files changed, 14 insertions, 15 deletions
diff --git a/lib/ubsan/ubsan_diag.cc b/lib/ubsan/ubsan_diag.cc index 76ce2bd39..4bd0eb8df 100644 --- a/lib/ubsan/ubsan_diag.cc +++ b/lib/ubsan/ubsan_diag.cc @@ -66,25 +66,24 @@ class Decorator : public SanitizerCommonDecorator { }; } -Location __ubsan::getCallerLocation(uptr CallerLoc) { - if (!CallerLoc) +Location __ubsan::getCallerLocation(uptr CallerPC) { + if (!CallerPC) return Location(); - uptr Loc = StackTrace::GetPreviousInstructionPc(CallerLoc); - return getFunctionLocation(Loc, 0); + return getFunctionLocation(StackTrace::GetPreviousInstructionPc(CallerPC), 0); } -Location __ubsan::getFunctionLocation(uptr Loc, const char **FName) { - if (!Loc) +Location __ubsan::getFunctionLocation(uptr PC, const char **FName) { + if (!PC) return Location(); InitIfNecessary(); - SymbolizedStack *Frames = Symbolizer::GetOrInit()->SymbolizePC(Loc); + SymbolizedStack *Frames = Symbolizer::GetOrInit()->SymbolizePC(PC); const AddressInfo &Info = Frames->info; if (!Info.module) { Frames->ClearAll(); - return Location(Loc); + return Location(PC); } if (FName && Info.function) diff --git a/lib/ubsan/ubsan_diag.h b/lib/ubsan/ubsan_diag.h index 296ec0d3f..bc46a0c23 100644 --- a/lib/ubsan/ubsan_diag.h +++ b/lib/ubsan/ubsan_diag.h @@ -80,13 +80,13 @@ public: /// Try to obtain a location for the caller. This might fail, and produce either /// an invalid location or a module location for the caller. -Location getCallerLocation(uptr CallerLoc = GET_CALLER_PC()); +Location getCallerLocation(uptr CallerPC); /// Try to obtain a location for the given function pointer. This might fail, /// and produce either an invalid location or a module location for the caller. /// If FName is non-null and the name of the function is known, set *FName to /// the function name, otherwise *FName is unchanged. -Location getFunctionLocation(uptr Loc, const char **FName); +Location getFunctionLocation(uptr PC, const char **FName); /// A diagnostic severity level. enum DiagLevel { diff --git a/lib/ubsan/ubsan_handlers.cc b/lib/ubsan/ubsan_handlers.cc index a0ecff943..579ff7617 100644 --- a/lib/ubsan/ubsan_handlers.cc +++ b/lib/ubsan/ubsan_handlers.cc @@ -37,14 +37,14 @@ const char *TypeCheckKinds[] = { } static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer, - Location FallbackLoc, ReportOptions Opts) { + ReportOptions Opts) { Location Loc = Data->Loc.acquire(); // Use the SourceLocation from Data to track deduplication, even if 'invalid' if (ignoreReport(Loc.getSourceLocation(), Opts)) return; if (Data->Loc.isInvalid()) - Loc = FallbackLoc; + Loc = getCallerLocation(Opts.pc); ScopedReport R(Opts, Loc); @@ -67,12 +67,12 @@ static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer, void __ubsan::__ubsan_handle_type_mismatch(TypeMismatchData *Data, ValueHandle Pointer) { GET_REPORT_OPTIONS(false); - handleTypeMismatchImpl(Data, Pointer, getCallerLocation(), Opts); + handleTypeMismatchImpl(Data, Pointer, Opts); } void __ubsan::__ubsan_handle_type_mismatch_abort(TypeMismatchData *Data, ValueHandle Pointer) { GET_REPORT_OPTIONS(true); - handleTypeMismatchImpl(Data, Pointer, getCallerLocation(), Opts); + handleTypeMismatchImpl(Data, Pointer, Opts); Die(); } @@ -288,7 +288,7 @@ void __ubsan::__ubsan_handle_vla_bound_not_positive_abort(VLABoundData *Data, static void handleFloatCastOverflow(FloatCastOverflowData *Data, ValueHandle From, ReportOptions Opts) { // TODO: Add deduplication once a SourceLocation is generated for this check. - Location Loc = getCallerLocation(); + Location Loc = getCallerLocation(Opts.pc); ScopedReport R(Opts, Loc); Diag(Loc, DL_Error, |