[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:46:36 PDT 2019


xbolva00 marked an inline comment as done.
xbolva00 added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:10929
+    // Do not diagnose if xor keyword is used.
+    if (ExprStr.find("xor") != llvm::StringRef::npos)
+      return;
----------------
Quuxplusone wrote:
> xbolva00 wrote:
> > 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.
> I believe JF is worried about expressions like `constexpr int flexor_exponent = 3; return 10 ^ flexor_exponent;`. That expression contains the substring `"xor"` but does not use the `xor` keyword. Which reminds me, can you add some test cases showing what behavior you expect for operands that are not integer literals but still compile-time `const`, or `constexpr`, or template arguments?
Ah, I will change it to “ xor “.


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

https://reviews.llvm.org/D63423





More information about the cfe-commits mailing list