[PATCH] D70624: [Diagnostics] Warn for comparison with string literals expanded from macro (PR44064)

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 15:28:59 PST 2019


xbolva00 created this revision.
xbolva00 added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.


================
Comment at: clang/test/Sema/warn-stringcompare.c:4-6
+#define DELIM "/"
+#define NULL (void *)0
+
----------------
Current behaviour: https://godbolt.org/z/7nYH6N


As noted in PR, we have a poor test coverage for this warning. I think macro support was just overlooked. GCC warns in these cases.
Clang missed a real bug in the code I am working with, GCC caught it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70624

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c
  clang/test/Sema/warn-stringcompare.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70624.230735.patch
Type: text/x-patch
Size: 5291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191122/27ad1cfd/attachment.bin>


More information about the cfe-commits mailing list