[PATCH] D52137: Added warning for unary minus used with unsigned type

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 15 14:50:03 PDT 2018


xbolva00 added a comment.

/home/xbolva00/LLVM/llvm/tools/clang/test/Sema/unary-minus-unsigned.c:13:15: warning: unary minus operator applied to type 'unsigned long', result value is still unsigned [-Wsign-conversion]

  long b3 = -b; // expected-warning {{unary minus operator applied to type 'unsigned long', result value is still unsigned}}
                   ^~
                   0u -

Any advice how to get UnaryOperator operand as a string? To emit fixit hint like 0u - b

FixItHint::CreateReplacement(InputExpr->getBeginLoc(), "0u - " + ???) << Input.get()->getSourceRange();


https://reviews.llvm.org/D52137





More information about the cfe-commits mailing list