Skip to content

Commit a8687dd

Browse files
authored
[compiler-rt][nsan] Improve nsan reports (#98798)
Currently NSAN prints reports that are entirely red and the terminal prompt after the program exits is red too. With this change we make red only `WARNING` summary and the rest of the report isn't colored. This behavior is similar to the behavior of other sanitizers.
1 parent 93d2b23 commit a8687dd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler-rt/lib/nsan/nsan.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT CheckType,
513513
}
514514
using ValuePrinter = FTPrinter<FT>;
515515
using ShadowPrinter = FTPrinter<ShadowFT>;
516+
Printf("%s", D.Default());
517+
516518
Printf("\n"
517519
"%-12s precision (native): dec: %s hex: %s\n"
518520
"%-12s precision (shadow): dec: %s hex: %s\n"
@@ -638,8 +640,9 @@ void fCmpFailFT(const FT Lhs, const FT Rhs, ShadowFT LhsShadow,
638640
const char *const PredicateName = GetPredicateName(Predicate);
639641
Printf("%s", D.Warning());
640642
Printf("WARNING: NumericalStabilitySanitizer: floating-point comparison "
641-
"results depend on precision\n"
642-
"%-12s precision dec (native): %s %s %s (%s)\n"
643+
"results depend on precision\n");
644+
Printf("%s", D.Default());
645+
Printf("%-12s precision dec (native): %s %s %s (%s)\n"
643646
"%-12s precision dec (shadow): %s %s %s (%s)\n"
644647
"%-12s precision hex (native): %s %s %s (%s)\n"
645648
"%-12s precision hex (shadow): %s %s %s (%s)\n"
@@ -658,7 +661,6 @@ void fCmpFailFT(const FT Lhs, const FT Rhs, ShadowFT LhsShadow,
658661
FTInfo<ShadowFT>::kCppTypeName, ShadowPrinter::hex(LhsShadow).Buffer,
659662
PredicateName, ShadowPrinter::hex(RhsShadow).Buffer,
660663
GetTruthValueName(ShadowResult), D.End());
661-
Printf("%s", D.Default());
662664
stack.Print();
663665
if (flags().halt_on_error) {
664666
Printf("Exiting\n");

0 commit comments

Comments
 (0)