This is an archive of the discontinued LLVM Phabricator instance.

[gold-plugin] Fix a bunch of build warnings
ClosedPublic

Authored by mgrang on Nov 1 2018, 2:17 PM.

Details

Reviewers
tejohnson
chapuni

Diff Detail

Event Timeline

mgrang created this revision.EditedNov 1 2018, 2:17 PM

Fixed the following warnings:

1. gold-plugin.cpp:452:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
  case DS_Warning:
  ^
gold-plugin.cpp:452:3: note: insert 'LLVM_FALLTHROUGH;' to silence this warning


2. gold-plugin.cpp:449:8: warning: variable 'Level' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
  case DS_Error:
       ^~~~~~~~
gold-plugin.cpp:461:11: note: uninitialized use occurs here
  message(Level, "LLVM gold plugin: %s",  ErrStorage.c_str());
          ^~~~~
gold-plugin.cpp:447:3: note: variable 'Level' is declared here
  ld_plugin_level Level;
tejohnson added inline comments.Nov 1 2018, 2:29 PM
tools/gold/gold-plugin.cpp
450

Thanks for the fix. I am not sure in fact why we need this separate call to message, rather than just allowing the code to fall through and use the one below the switch statement. I don't see value in the different style of message, particularly now with ThinLTO (looks like this code is quite old, predating ThinLTO).

Can you just remove the call to message() here and instead set Level = LDPL_FATAL here?

mgrang updated this revision to Diff 172264.Nov 1 2018, 4:22 PM
mgrang marked an inline comment as done.
This revision is now accepted and ready to land.Nov 1 2018, 4:29 PM
mgrang closed this revision.Nov 1 2018, 4:37 PM