[PATCH] D20197: [clang-tidy] Ignore using-declarations defined in marcro in misc-unused-using-decls checks.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 12 02:47:22 PDT 2016
hokein updated this revision to Diff 57008.
hokein added a comment.
Address review comments.
http://reviews.llvm.org/D20197
Files:
clang-tidy/misc/UnusedUsingDeclsCheck.cpp
test/clang-tidy/misc-unused-using-decls.cpp
Index: test/clang-tidy/misc-unused-using-decls.cpp
===================================================================
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -70,6 +70,14 @@
using n::cout;
using n::endl;
+#define DEFINE_INT(name) \
+ namespace INT { \
+ static const int _##name = 1; \
+ } \
+ using INT::_##name
+DEFINE_INT(test);
+#undef DEFIND_INT
+
// ----- Usages -----
void f(B b);
void g() {
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===================================================================
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -35,6 +35,10 @@
const auto *TargetDecl =
Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
+ // Ignores using-declarations defined in macros.
+ if (TargetDecl->getLocation().isMacroID())
+ return;
+
// Ignores using-declarations defined in class definition.
if (isa<CXXRecordDecl>(TargetDecl->getDeclContext()))
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20197.57008.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160512/4aef7712/attachment.bin>
More information about the cfe-commits
mailing list