summaryrefslogtreecommitdiffstats
path: root/tools/clang
diff options
context:
space:
mode:
authorhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 18:33:22 +0000
committerhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 18:33:22 +0000
commit6902553a220388ce27a07253d5eb153f06f96ae5 (patch)
treef0d49d679d8839b9c87e96e53a5638e1c689d5b4 /tools/clang
parent045017d3879c22bb2dba64732f48455f397aafa0 (diff)
downloadchromium_src-6902553a220388ce27a07253d5eb153f06f96ae5.zip
chromium_src-6902553a220388ce27a07253d5eb153f06f96ae5.tar.gz
chromium_src-6902553a220388ce27a07253d5eb153f06f96ae5.tar.bz2
Clang style-checker: Fix weird warning about inline copy ctors.
When the style-checker complains about an inline copy constructor that the user didn't define, make the error message more descriptive. Otherwise it would just say "this ctor is inline", and point to the start of the class, which is very confusing. BUG=97483 TEST=style plugin test Review URL: https://chromiumcodereview.appspot.com/10720002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/clang')
-rw-r--r--tools/clang/plugins/FindBadConstructs.cpp11
-rw-r--r--tools/clang/plugins/tests/inline_copy_ctor.cpp5
-rw-r--r--tools/clang/plugins/tests/inline_copy_ctor.h12
-rw-r--r--tools/clang/plugins/tests/inline_copy_ctor.txt5
4 files changed, 31 insertions, 2 deletions
diff --git a/tools/clang/plugins/FindBadConstructs.cpp b/tools/clang/plugins/FindBadConstructs.cpp
index af78b43..383368a 100644
--- a/tools/clang/plugins/FindBadConstructs.cpp
+++ b/tools/clang/plugins/FindBadConstructs.cpp
@@ -208,8 +208,15 @@ class FindBadConstructsConsumer : public ChromeClassTester {
for (CXXRecordDecl::ctor_iterator it = record->ctor_begin();
it != record->ctor_end(); ++it) {
if (it->hasInlineBody()) {
- emitWarning(it->getInnerLocStart(),
- "Complex constructor has an inlined body.");
+ if (it->isCopyConstructor() &&
+ !record->hasUserDeclaredCopyConstructor()) {
+ emitWarning(record_location,
+ "Complex class/struct needs an explicit out-of-line "
+ "copy constructor.");
+ } else {
+ emitWarning(it->getInnerLocStart(),
+ "Complex constructor has an inlined body.");
+ }
}
}
}
diff --git a/tools/clang/plugins/tests/inline_copy_ctor.cpp b/tools/clang/plugins/tests/inline_copy_ctor.cpp
new file mode 100644
index 0000000..dcd9002
--- /dev/null
+++ b/tools/clang/plugins/tests/inline_copy_ctor.cpp
@@ -0,0 +1,5 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "inline_copy_ctor.h"
diff --git a/tools/clang/plugins/tests/inline_copy_ctor.h b/tools/clang/plugins/tests/inline_copy_ctor.h
new file mode 100644
index 0000000..619a183
--- /dev/null
+++ b/tools/clang/plugins/tests/inline_copy_ctor.h
@@ -0,0 +1,12 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+struct C {
+ C();
+ ~C();
+
+ static C foo() { return C(); }
+
+ int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p , q, r, s, t, u, v, w, x;
+};
diff --git a/tools/clang/plugins/tests/inline_copy_ctor.txt b/tools/clang/plugins/tests/inline_copy_ctor.txt
new file mode 100644
index 0000000..bc4bd89
--- /dev/null
+++ b/tools/clang/plugins/tests/inline_copy_ctor.txt
@@ -0,0 +1,5 @@
+In file included from inline_copy_ctor.cpp:5:
+./inline_copy_ctor.h:5:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line copy constructor.
+struct C {
+^
+1 warning generated.