summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2019-08-23 08:47:27 +0000
committerHaojian Wu <hokein@google.com>2019-08-23 08:47:27 +0000
commitc4905a232c9ba5bccfd99bd2649efaa1651ce0bd (patch)
tree5fbbc9fa01f5a18712252e818c5508f7838e3e9d
parent6ef01c3e2bc2b19c9628518c53cf360cb6a43e23 (diff)
downloadbcm5719-llvm-c4905a232c9ba5bccfd99bd2649efaa1651ce0bd.tar.gz
bcm5719-llvm-c4905a232c9ba5bccfd99bd2649efaa1651ce0bd.zip
[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 llvm-svn: 369739
-rw-r--r--clang-tools-extra/clang-tidy/google/NonConstReferences.cpp3
-rw-r--r--clang-tools-extra/test/clang-tidy/google-runtime-references.cpp4
2 files changed, 7 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/google/NonConstReferences.cpp b/clang-tools-extra/clang-tidy/google/NonConstReferences.cpp
index 6e0fcfe529b..95dc708456a 100644
--- a/clang-tools-extra/clang-tidy/google/NonConstReferences.cpp
+++ b/clang-tools-extra/clang-tidy/google/NonConstReferences.cpp
@@ -52,6 +52,9 @@ void NonConstReferences::check(const MatchFinder::MatchResult &Result) {
if (Function == nullptr || Function->isImplicit())
return;
+ if (Function->getLocation().isMacroID())
+ return;
+
if (!Function->isCanonicalDecl())
return;
diff --git a/clang-tools-extra/test/clang-tidy/google-runtime-references.cpp b/clang-tools-extra/test/clang-tidy/google-runtime-references.cpp
index 2abd5afc75e..1ebbbe3fc86 100644
--- a/clang-tools-extra/test/clang-tidy/google-runtime-references.cpp
+++ b/clang-tools-extra/test/clang-tidy/google-runtime-references.cpp
@@ -149,3 +149,7 @@ void f8(B &);
}
void f9(whitelist::A &);
void f10(whitelist::B &);
+
+#define DEFINE_F(name) void name(int& a)
+
+DEFINE_F(func) {}
OpenPOWER on IntegriCloud