[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 09:31:38 PDT 2019


xbolva00 marked 3 inline comments as done.
xbolva00 added inline comments.


================
Comment at: include/clang/Basic/DiagnosticGroups.td:508
 def Varargs : DiagGroup<"varargs">;
+def XorUsedAsPow : DiagGroup<"xor-used-as-pow">;
 
----------------
jfb wrote:
> Does this match the naming that GCC ended up with?
No, they have no progress yet.  GCC should not block our progress here..


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3309
+def warn_xor_used_as_pow_shift_count_overflow : Warning<
+  "result of '%0' is %1; did you mean '%2', but shift count >= width of type">,
+  InGroup<XorUsedAsPow>;
----------------
jfb wrote:
> This is still a bad diagnostic, I'd rather see it fixed.
Why so? Can you propose wording here?

We provide a fixit for it, e.g. 1LL<<32..


================
Comment at: lib/Sema/SemaExpr.cpp:10929
+    // Do not diagnose if xor keyword is used.
+    if (ExprStr.find("xor") != llvm::StringRef::npos)
+      return;
----------------
jfb wrote:
> Doesn't this match any expression that contains `xor`? Put another way, I don't see `"xor"` used anywhere else under clang, what's usually done?
Yes, but since xor is keyword in C++, I think this is safe.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63423/new/

https://reviews.llvm.org/D63423





More information about the cfe-commits mailing list