summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2015-12-16 15:05:27 +0000
committerAlexander Kornienko <alexfh@google.com>2015-12-16 15:05:27 +0000
commit821ca470bbbb11246e9d27df4e92888ae5435fee (patch)
tree4c625ef11405a7dc39fb344b102ce2ed54562f1e /clang-tools-extra/clang-tidy
parentd4ff820fb83d83f22a60e325550822f2f80b722a (diff)
downloadbcm5719-llvm-821ca470bbbb11246e9d27df4e92888ae5435fee.tar.gz
bcm5719-llvm-821ca470bbbb11246e9d27df4e92888ae5435fee.zip
[clang-tidy] Add namespace support to add_new_check.py
Summary: Without namespace you can not create checks with same name in different modules Reviewers: alexfh Subscribers: cfe-commits Patch by Cong Liu! Differential Revision: http://reviews.llvm.org/D15571 llvm-svn: 255770
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rwxr-xr-xclang-tools-extra/clang-tidy/add_new_check.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py
index 3d566ef2b5d..0041576e482 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -73,6 +73,7 @@ def write_header(module_path, module, check_name, check_name_camel):
namespace clang {
namespace tidy {
+namespace %(module)s {
/// FIXME: Write a short description.
///
@@ -86,6 +87,7 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace %(module)s
} // namespace tidy
} // namespace clang
@@ -93,11 +95,12 @@ public:
""" % {'header_guard': header_guard,
'check_name': check_name_camel,
- 'check_name_dashes': check_name_dashes})
+ 'check_name_dashes': check_name_dashes,
+ 'module': module})
# Adds the implementation of the new check.
-def write_implementation(module_path, check_name_camel):
+def write_implementation(module_path, module, check_name_camel):
filename = os.path.join(module_path, check_name_camel) + '.cpp'
print('Creating %s...' % filename)
with open(filename, 'wb') as f:
@@ -123,6 +126,7 @@ using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
+namespace %(module)s {
void %(check_name)s::registerMatchers(MatchFinder *Finder) {
// FIXME: Add matchers.
@@ -139,10 +143,12 @@ void %(check_name)s::check(const MatchFinder::MatchResult &Result) {
<< FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
}
+} // namespace %(module)s
} // namespace tidy
} // namespace clang
-""" % {'check_name': check_name_camel})
+""" % {'check_name': check_name_camel,
+ 'module': module})
# Modifies the module to include the new check.
@@ -261,7 +267,7 @@ def main():
if not adapt_cmake(module_path, check_name_camel):
return
write_header(module_path, module, check_name, check_name_camel)
- write_implementation(module_path, check_name_camel)
+ write_implementation(module_path, module, check_name_camel)
adapt_module(module_path, module, check_name, check_name_camel)
write_test(module_path, module, check_name)
write_docs(module_path, module, check_name)
OpenPOWER on IntegriCloud