Skip to content

Commit 56791cf

Browse files
committed
Change macro to function
1 parent 613c33a commit 56791cf

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

compiler-rt/lib/msan/msan.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,28 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
352352

353353
using namespace __msan;
354354

355-
#define PRINT_FAULTING_INSTRUCTION(instname) \
356-
if (__msan::flags()->print_faulting_instruction) { \
357-
Printf("Instruction that failed the shadow check: %s\n", instname); \
358-
Printf("\n"); \
355+
static inline void PrintFaultingInstruction(char *instname) {
356+
if (__msan::flags()->print_faulting_instruction) {
357+
Printf("Instruction that failed the shadow check: %s\n", instname);
358+
Printf("\n");
359359
}
360+
}
360361

361-
#define WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED \
362-
if (__msan::flags()->print_faulting_instruction) { \
363-
Printf( \
364-
"Error: print_faulting_instruction requested but code was not " \
365-
"instrumented with -mllvm -embed-faulting-instruction.\n"); \
366-
Printf("\n"); \
362+
static inline void WarnIfPrintFaultingInstructionRequested() {
363+
if (__msan::flags()->print_faulting_instruction) {
364+
Printf(
365+
"Error: print_faulting_instruction requested but code was not "
366+
"instrumented with -mllvm -embed-faulting-instruction.\n");
367+
Printf("\n");
367368
}
369+
}
368370

369371
#define MSAN_MAYBE_WARNING_INSTNAME(type, size, instname) \
370372
void __msan_maybe_warning_instname_##size(type s, u32 o, char *instname) { \
371373
GET_CALLER_PC_BP; \
372374
if (UNLIKELY(s)) { \
373375
if (instname) \
374-
PRINT_FAULTING_INSTRUCTION(instname); \
376+
PrintFaultingInstruction(instname); \
375377
PrintWarningWithOrigin(pc, bp, o); \
376378
if (__msan::flags()->halt_on_error) { \
377379
Printf("Exiting\n"); \
@@ -389,7 +391,7 @@ MSAN_MAYBE_WARNING_INSTNAME(u64, 8, instname)
389391
void __msan_maybe_warning_##size(type s, u32 o) { \
390392
GET_CALLER_PC_BP; \
391393
if (UNLIKELY(s)) { \
392-
WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED; \
394+
WarnIfPrintFaultingInstructionRequested(); \
393395
PrintWarningWithOrigin(pc, bp, o); \
394396
if (__msan::flags()->halt_on_error) { \
395397
Printf("Exiting\n"); \
@@ -439,12 +441,12 @@ MSAN_MAYBE_STORE_ORIGIN(u64, 8)
439441
}
440442

441443
void __msan_warning() {
442-
WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED;
444+
WarnIfPrintFaultingInstructionRequested();
443445
__MSAN_WARNING_BODY
444446
}
445447

446448
void __msan_warning_instname(char *instname) {
447-
PRINT_FAULTING_INSTRUCTION(instname);
449+
PrintFaultingInstruction(instname);
448450
__MSAN_WARNING_BODY
449451
}
450452

@@ -457,12 +459,12 @@ void __msan_warning_instname(char *instname) {
457459
Die();
458460

459461
void __msan_warning_noreturn() {
460-
WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED;
462+
WarnIfPrintFaultingInstructionRequested();
461463
__MSAN_WARNING_NORETURN_BODY
462464
}
463465

464466
void __msan_warning_noreturn_instname(char *instname) {
465-
PRINT_FAULTING_INSTRUCTION(instname);
467+
PrintFaultingInstruction(instname);
466468
__MSAN_WARNING_NORETURN_BODY
467469
}
468470

@@ -477,12 +479,12 @@ void __msan_warning_noreturn_instname(char *instname) {
477479
}
478480

479481
void __msan_warning_with_origin(u32 origin) {
480-
WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED;
482+
WarnIfPrintFaultingInstructionRequested();
481483
__MSAN_WARNING_WITH_ORIGIN_BODY(origin)
482484
}
483485

484486
void __msan_warning_with_origin_instname(u32 origin, char *instname) {
485-
PRINT_FAULTING_INSTRUCTION(instname);
487+
PrintFaultingInstruction(instname);
486488
__MSAN_WARNING_WITH_ORIGIN_BODY(origin)
487489
}
488490

@@ -495,12 +497,12 @@ void __msan_warning_with_origin_instname(u32 origin, char *instname) {
495497
Die();
496498

497499
void __msan_warning_with_origin_noreturn(u32 origin) {
498-
WARN_IF_PRINT_FAULTING_INSTRUCTION_REQUESTED;
500+
WarnIfPrintFaultingInstructionRequested();
499501
__MSAN_WARNING_WITH_ORIGIN_NORETURN_BODY(origin)
500502
}
501503

502504
void __msan_warning_with_origin_noreturn_instname(u32 origin, char *instname) {
503-
PRINT_FAULTING_INSTRUCTION(instname);
505+
PrintFaultingInstruction(instname);
504506
__MSAN_WARNING_WITH_ORIGIN_NORETURN_BODY(origin)
505507
}
506508

0 commit comments

Comments
 (0)