PVS-StudioWarnings

PVS-Studio warning V556 for Clang

Nov 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. enum LegalizeAction {
  2.   Legal,
  3.   Promote,
  4.   Expand,
  5.   Custom
  6. };
  7.  
  8. enum LegalizeTypeAction {
  9.   TypeLegal,
  10.   TypePromoteInteger,
  11.   TypeExpandInteger,
  12.   TypeSoftenFloat,
  13.   TypeExpandFloat,
  14.   TypeScalarizeVector,
  15.   TypeSplitVector,
  16.   TypeWidenVector
  17. };
  18.  
  19. LegalizeTypeAction getTypeAction(LLVMContext &Context,
  20.                                  EVT VT) const;
  21.  
  22. EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const {
  23.   ...
  24.   switch (getTypeAction(Context, VT)) {
  25.   case Legal:
  26.     return VT;
  27.   case Expand:
  28.   ...
  29. }
  30.  
  31. It works because the values coincide, but that's strange.
  32.  
  33. This suspicious code was found in Clang project by PVS-Studio static code analyzer.
  34. Warning message is:
  35. V556 The values of different enum types are compared: switch(ENUM_TYPE_A) { case ENUM_TYPE_B: ... }. LLVMAsmPrinter targetlowering.h 268
  36.  
  37. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment