summaryrefslogtreecommitdiffstats
path: root/tools/clang
diff options
context:
space:
mode:
authorDaniel Cheng <dcheng@chromium.org>2016-02-02 17:30:58 -0800
committerDaniel Cheng <dcheng@chromium.org>2016-02-03 01:36:58 +0000
commit3e1aee36d736f9f622e5e983cca9e9e2f7a3ebbe (patch)
tree45a273eee060feb5a0c0331393763f44db9b7c68 /tools/clang
parentf246b3224a5371fbca304c15ab663351a76bb836 (diff)
downloadchromium_src-3e1aee36d736f9f622e5e983cca9e9e2f7a3ebbe.zip
chromium_src-3e1aee36d736f9f622e5e983cca9e9e2f7a3ebbe.tar.gz
chromium_src-3e1aee36d736f9f622e5e983cca9e9e2f7a3ebbe.tar.bz2
rewrite_to_chrome_style: Fix build with new clang, and a crash
- Don't crash when trying to determine if a method on a class defined in the global namespace is a Blink method. - Fix the build when building with newer revisions of clang that have an isDefaulted() matcher. BUG=none R=danakj@chromium.org Review URL: https://codereview.chromium.org/1652953004 . Cr-Commit-Position: refs/heads/master@{#373120}
Diffstat (limited to 'tools/clang')
-rw-r--r--tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp16
-rw-r--r--tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc4
-rw-r--r--tools/clang/rewrite_to_chrome_style/tests/methods-original.cc4
3 files changed, 14 insertions, 10 deletions
diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
index b703823..5733b2c 100644
--- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
+++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
@@ -48,6 +48,18 @@ using llvm::StringRef;
namespace {
+// Hack: prevent the custom isDefaulted() from conflicting with the one defined
+// in newer revisions of Clang.
+namespace internal_hack {
+
+// This is available in newer clang revisions... but alas, Chrome has not rolled
+// that far yet.
+AST_MATCHER(clang::FunctionDecl, isDefaulted) {
+ return Node.isDefaulted();
+}
+
+} // namespace internal_hack
+
const char kBlinkFieldPrefix[] = "m_";
const char kBlinkStaticMemberPrefix[] = "s_";
@@ -58,7 +70,7 @@ AST_MATCHER(clang::FunctionDecl, isOverloadedOperator) {
// A method is from Blink if it is from the Blink namespace or overrides a
// method from the Blink namespace.
bool IsBlinkMethod(const clang::CXXMethodDecl& decl) {
- auto* namespace_decl = clang::cast_or_null<clang::NamespaceDecl>(
+ auto* namespace_decl = clang::dyn_cast_or_null<clang::NamespaceDecl>(
decl.getParent()->getEnclosingNamespaceContext());
if (namespace_decl && namespace_decl->getParent()->isTranslationUnit() &&
(namespace_decl->getName() == "blink" ||
@@ -415,7 +427,7 @@ int main(int argc, const char* argv[]) {
// compiler, such as a synthesized copy constructor.
// This skips explicitly defaulted functions as well, but that's OK:
// there's nothing interesting to rewrite in those either.
- unless(hasAncestor(functionDecl(isDefaulted())))));
+ unless(hasAncestor(functionDecl(internal_hack::isDefaulted())))));
auto decl_ref_matcher = id("expr", declRefExpr(to(var_decl_matcher)));
MemberRewriter member_rewriter(&replacements);
diff --git a/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc b/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc
index fd34bde..1dc5ce4 100644
--- a/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc
+++ b/tools/clang/rewrite_to_chrome_style/tests/methods-expected.cc
@@ -55,8 +55,6 @@ void Task::DoTheWork() {
} // namespace blink
-namespace Moo {
-
// Test that overrides from outside the Blink namespace are also updated.
class BovineTask : public blink::Task {
public:
@@ -82,5 +80,3 @@ void F() {
void (blink::Task::*p3)() = &blink::Task::ReallyDoTheWork;
void (BovineTask::*p4)() = &BovineTask::ReallyDoTheWork;
}
-
-} // namespace Moo
diff --git a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
index 1547030..b2d9381 100644
--- a/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
+++ b/tools/clang/rewrite_to_chrome_style/tests/methods-original.cc
@@ -59,8 +59,6 @@ void Task::doTheWork() {
} // namespace blink
-namespace Moo {
-
// Test that overrides from outside the Blink namespace are also updated.
class BovineTask : public blink::Task {
public:
@@ -86,5 +84,3 @@ void F() {
void (blink::Task::*p3)() = &blink::Task::reallyDoTheWork;
void (BovineTask::*p4)() = &BovineTask::reallyDoTheWork;
}
-
-} // namespace Moo