commit | c1582bfe01b611058316a2d0a0905a3527a99884 | [log] [tgz] |
---|---|---|
author | Haojian Wu <hokein@google.com> | Fri Aug 23 08:47:27 2019 +0000 |
committer | Haojian Wu <hokein@google.com> | Fri Aug 23 08:47:27 2019 +0000 |
tree | 6b5eb130e63ac30f0d272483eec5a9e8846c48e6 | |
parent | c1bf6a91832621d6a43e91cef265e32de77f63af [diff] |
[clang-tidy] Don't emit google-runtime-references warning for functions defined in macros. Summary: The macro are usually defined in the common/base headers which are hard for normal users to modify it. Reviewers: gribozavr, alexfh Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66631 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@369739 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clang-tidy/google/NonConstReferences.cpp b/clang-tidy/google/NonConstReferences.cpp index 6e0fcfe..95dc708 100644 --- a/clang-tidy/google/NonConstReferences.cpp +++ b/clang-tidy/google/NonConstReferences.cpp
@@ -52,6 +52,9 @@ if (Function == nullptr || Function->isImplicit()) return; + if (Function->getLocation().isMacroID()) + return; + if (!Function->isCanonicalDecl()) return;
diff --git a/test/clang-tidy/google-runtime-references.cpp b/test/clang-tidy/google-runtime-references.cpp index 2abd5af..1ebbbe3 100644 --- a/test/clang-tidy/google-runtime-references.cpp +++ b/test/clang-tidy/google-runtime-references.cpp
@@ -149,3 +149,7 @@ } void f9(whitelist::A &); void f10(whitelist::B &); + +#define DEFINE_F(name) void name(int& a) + +DEFINE_F(func) {}