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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 16 06:43:22 PDT 2019


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This LGTM aside from a few nits, but please give a chance for other reviewers to weigh in on their comments.



================
Comment at: lib/Sema/SemaExpr.cpp:11025-11031
+  if (LHSStrRef.startswith("0b") || LHSStrRef.startswith("0B") ||
+      RHSStrRef.startswith("0b") || RHSStrRef.startswith("0B"))
+    return;
+  // Do not diagnose hexadecimal literals.
+  if (LHSStrRef.startswith("0x") || LHSStrRef.startswith("0X") ||
+      RHSStrRef.startswith("0x") || RHSStrRef.startswith("0X"))
+    return;
----------------
Might as well combine these.


================
Comment at: test/SemaCXX/warn-xor-as-pow.cpp:100-102
+  res = 10 ^ 5_xor;
+  res = 10 ^ 5_0b;
+  res = 10_0X ^ 5;
----------------
I'd also like to see a case like `res = 10_xor ^ 5;`


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

https://reviews.llvm.org/D63423





More information about the cfe-commits mailing list