This is an archive of the discontinued LLVM Phabricator instance.

[ClangDiagnostics] Silence warning about fallthrough after PrintFatalError
ClosedPublic

Authored by xbolva00 on May 24 2018, 11:03 AM.

Details

Summary

ClangDiagnosticsEmitter.cpp:1047:57: warning: this statement may fall through [-Wimplicit-fallthrough=]

Builder.PrintFatalError("Unknown modifier type: " + Modifier);
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

ClangDiagnosticsEmitter.cpp:1048:5: note: here

case MT_Select: {
              ^

Diff Detail

Repository
rL LLVM

Event Timeline

xbolva00 created this revision.May 24 2018, 11:03 AM
rtrieu added a subscriber: rtrieu.May 24 2018, 5:17 PM

Instead of adding a break, you should add a noreturn attribute to the PrintFatalError function. LLVM has the macro LLVM_ATTRIBUTE_NORETURN to do this. You can confirm that PrintFatalError is a noreturn function by seeing that it unconditionally calls llvm::PrintFatalError which itself is attributed with LLVM_ATTRIBUTE_NORETURN.

xbolva00 updated this revision to Diff 148523.May 24 2018, 5:31 PM

Add correct NORETURN attribute

rtrieu accepted this revision.May 25 2018, 6:10 PM

lgtm

This revision is now accepted and ready to land.May 25 2018, 6:10 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.