summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 19:49:07 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 19:49:07 +0000
commit7f8d486f3c2293482880ef53395d85698ea36b08 (patch)
treea08964185f2449b557897769f61f562c4c75734c
parent41ac03ddd8c7d63faf83265ee11fab95b37dd2c3 (diff)
downloadchromium_src-7f8d486f3c2293482880ef53395d85698ea36b08.zip
chromium_src-7f8d486f3c2293482880ef53395d85698ea36b08.tar.gz
chromium_src-7f8d486f3c2293482880ef53395d85698ea36b08.tar.bz2
clang: Use -Wheader-hygiene instead of a custom check in the plugin.
Revert the parts of http://codereview.chromium.org/6698051/ that added the custom plugin code, and use the new warning we added to upstream clang instead. Define U_USING_ICU_NAMESPACE=0 to make ICU not use |using namespace icu;| in its header and adapt cc files that use ICU. Depends on http://codereview.chromium.org/6691062 BUG=none TEST=none Review URL: http://codereview.chromium.org/6677115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80509 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/common.gypi2
-rw-r--r--tools/clang/plugins/ChromeClassTester.cpp31
-rw-r--r--tools/clang/plugins/ChromeClassTester.h8
-rw-r--r--tools/clang/plugins/FindBadConstructs.cpp10
-rwxr-xr-xtools/clang/plugins/tests/test.sh7
-rw-r--r--tools/clang/plugins/tests/using_directive.cpp15
-rw-r--r--tools/clang/plugins/tests/using_directive.h13
-rw-r--r--tools/clang/plugins/tests/using_directive.txt5
8 files changed, 8 insertions, 83 deletions
diff --git a/build/common.gypi b/build/common.gypi
index 0a27489..3eab5ac 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1248,6 +1248,7 @@
'target_conditions': [
['_toolset=="target"', {
'cflags': [
+ '-Wheader-hygiene',
# Clang spots more unused functions.
'-Wno-unused-function',
# Don't die on dtoa code that uses a char as an array index.
@@ -1381,6 +1382,7 @@
],
['clang==1', {
'WARNING_CFLAGS': [
+ '-Wheader-hygiene',
# Don't die on dtoa code that uses a char as an array index.
# This is required solely for base/third_party/dmg_fp/dtoa.cc.
'-Wno-char-subscripts',
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp
index 32ea1ea..0f6d847 100644
--- a/tools/clang/plugins/ChromeClassTester.cpp
+++ b/tools/clang/plugins/ChromeClassTester.cpp
@@ -175,37 +175,6 @@ void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) {
}
}
-void ChromeClassTester::HandleTranslationUnit(clang::ASTContext& ctx) {
- RecursivelyCheckTopLevels(ctx.getTranslationUnitDecl());
-}
-
-void ChromeClassTester::RecursivelyCheckTopLevels(Decl* d) {
- // Unlike HandleTagDeclDefinition, we can only rely on having parsing
- // information here. We absoluetly shouldn't check that any semantic data
- // here because we will assert.
- //
- // This method will NOT recurse into classes declarations or any record
- // types.
-
- Decl::Kind kind = d->getKind();
- if (kind == Decl::UsingDirective) {
- UsingDirectiveDecl* record = cast<UsingDirectiveDecl>(d);
- SourceLocation record_location = record->getLocation();
- if (!InBannedDirectory(record_location))
- CheckChromeUsingDirective(record_location, record);
- }
-
- // If this is a DeclContext that isn't a function/method, recurse.
- if (DeclContext* context = dyn_cast<DeclContext>(d)) {
- if (context->isFileContext()) {
- for (DeclContext::decl_iterator it = context->decls_begin();
- it != context->decls_end(); ++it) {
- RecursivelyCheckTopLevels(*it);
- }
- }
- }
-}
-
void ChromeClassTester::emitWarning(SourceLocation loc, const char* raw_error) {
FullSourceLoc full(loc, instance().getSourceManager());
std::string err;
diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h
index a61cd01..f00bb6a 100644
--- a/tools/clang/plugins/ChromeClassTester.h
+++ b/tools/clang/plugins/ChromeClassTester.h
@@ -26,7 +26,6 @@ class ChromeClassTester : public clang::ASTConsumer {
// ASTConsumer:
virtual void HandleTagDeclDefinition(clang::TagDecl* tag);
- virtual void HandleTranslationUnit(clang::ASTContext& ctx);
protected:
clang::CompilerInstance& instance() { return instance_; }
@@ -46,13 +45,6 @@ class ChromeClassTester : public clang::ASTConsumer {
// chrome header files.
virtual void CheckChromeClass(const clang::SourceLocation& record_location,
clang::CXXRecordDecl* record) = 0;
- virtual void CheckChromeUsingDirective(
- const clang::SourceLocation& record_location,
- clang::UsingDirectiveDecl* record) = 0;
-
- // The ChromeClassTester receives each top level declaration, looking for
- // Decls we are interested in.
- void RecursivelyCheckTopLevels(clang::Decl* d);
// Utility methods used for filtering out non-chrome classes (and ones we
// delibrately ignore) in HandleTagDeclDefinition().
diff --git a/tools/clang/plugins/FindBadConstructs.cpp b/tools/clang/plugins/FindBadConstructs.cpp
index 3c8f623..d7bcdae 100644
--- a/tools/clang/plugins/FindBadConstructs.cpp
+++ b/tools/clang/plugins/FindBadConstructs.cpp
@@ -47,16 +47,6 @@ class FindBadConstructsConsumer : public ChromeClassTester {
CheckVirtualMethods(record_location, record);
}
- virtual void CheckChromeUsingDirective(
- const clang::SourceLocation& record_location,
- clang::UsingDirectiveDecl* record) {
- // |record| is a using directive in a chrome header. This should never be
- // allowed.
- emitWarning(record_location,
- "Using namespace directives are banned in headers in Google "
- "style.");
- }
-
// Prints errors if the constructor/destructor weight it too heavy.
void CheckCtorDtorWeight(const SourceLocation& record_location,
CXXRecordDecl* record) {
diff --git a/tools/clang/plugins/tests/test.sh b/tools/clang/plugins/tests/test.sh
index ef0070f..e22e0d7 100755
--- a/tools/clang/plugins/tests/test.sh
+++ b/tools/clang/plugins/tests/test.sh
@@ -21,7 +21,7 @@ usage() {
# Runs a single test case.
do_testcase() {
local output="$("${CLANG_DIR}"/bin/clang -cc1 \
- -load "${CLANG_DIR}"/lib/libFindBadConstructs.so \
+ -load "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
-plugin find-bad-constructs ${1} 2>&1)"
local diffout="$(echo "${output}" | diff - "${2}")"
if [ "${diffout}" = "" ]; then
@@ -44,6 +44,11 @@ elif [[ ! -d "${1}" ]]; then
else
echo "Using clang directory ${1}..."
export CLANG_DIR="${1}"
+ if [ "$(uname -s)" = "Linux" ]; then
+ export LIB=so
+ elif [ "$(uname -s)" = "Darwin" ]; then
+ export LIB=dylib
+ fi
fi
for input in *.cpp; do
diff --git a/tools/clang/plugins/tests/using_directive.cpp b/tools/clang/plugins/tests/using_directive.cpp
deleted file mode 100644
index f48f2c1..0000000
--- a/tools/clang/plugins/tests/using_directive.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2011 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 "using_directive.h"
-
-int main() {
- // Don't warn here. We use this pattern in unit tests and it's probably
- // harmless. Headers included in multiple translation units could be harmful
- // though.
- using namespace std;
- vector<int> a;
- a.push_back(1);
- return 0;
-}
diff --git a/tools/clang/plugins/tests/using_directive.h b/tools/clang/plugins/tests/using_directive.h
deleted file mode 100644
index d31840f..0000000
--- a/tools/clang/plugins/tests/using_directive.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef USING_DIRECTIVE_H_
-#define USING_DIRECTIVE_H_
-
-#include <vector>
-
-// Should warn in headers.
-using namespace std;
-
-#endif // USING_DIRECTIVE_H_
diff --git a/tools/clang/plugins/tests/using_directive.txt b/tools/clang/plugins/tests/using_directive.txt
deleted file mode 100644
index d415fa5..0000000
--- a/tools/clang/plugins/tests/using_directive.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-In file included from using_directive.cpp:5:
-./using_directive.h:11:17: warning: [chromium-style] Using namespace directives are banned in headers in Google style.
-using namespace std;
- ^
-1 warning generated.