[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 21 09:30:01 PDT 2019
Quuxplusone added inline comments.
================
Comment at: lib/Sema/SemaExpr.cpp:10950
+
+ // Do not diagnose binary literals.
+ if (ExprStr.find("0b") != llvm::StringRef::npos)
----------------
I would rather see this whole section as a three-liner:
// Do not diagnose binary, octal, or hexadecimal literals.
if (StringRef(LHSStr).startswith("0") || StringRef(RHSStr).startswith("0"))
return;
================
Comment at: lib/Sema/SemaExpr.cpp:10963
+ if (LeftSideValue == 2 && RightSideIntValue >= 0) {
+ std::string SuggestedExpr = "1<<" + RHSStr;
+ bool Overflow = false;
----------------
Here and on line 10971, I suggest whitespace around the `<<` (in the suggested expression).
================
Comment at: lib/Sema/SemaExpr.cpp:10983
+
+ S.Diag(Loc, diag::note_xor_used_as_pow_silence) << ("0x2 ^ " + RHSStr);
+ } else if (LeftSideValue == 10) {
----------------
Do you currently warn on, let's say, `2uLL ^ 7`? and if so, do we care that the suggested expression `0x2 ^ 7` has a different type? I imagine the answer to "do we care" is "no," but I thought I should ask.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63423/new/
https://reviews.llvm.org/D63423
More information about the cfe-commits
mailing list