summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-08-13 13:57:57 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-08-13 13:57:57 +0000
commit498cce575f348ae645561665fcfd0d5ef83280db (patch)
tree244186fc4bf3c21916f6112ab194aa89e2e87069 /clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
parent0a5eb23bbdd65ede49ac6a3d0d101c963ed455d3 (diff)
downloadbcm5719-llvm-498cce575f348ae645561665fcfd0d5ef83280db.tar.gz
bcm5719-llvm-498cce575f348ae645561665fcfd0d5ef83280db.zip
[clang-tidy] Add a generic header guard checker + LLVM implementation.
The implementation is split into a generic part and a LLVM-specific part. Other codebases can implement it with their own style. The specific features supported are: - Verification (and fixing) of header guards against a style based on the file path - Automatic insertion of header guards for headers that are missing them - A warning when the header guard doesn't enable our fancy header guard optimization (e.g. when there's an include preceeding the guard) - Automatic insertion of a comment with the guard name after #endif. For the LLVM style we disable #endif comments for now, they're not very common in the codebase. We also only flag headers in the include directories, there doesn't seem to be a common style outside. Differential Revision: http://reviews.llvm.org/D4867 llvm-svn: 215548
Diffstat (limited to 'clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h')
-rw-r--r--clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
new file mode 100644
index 00000000000..fa99f9967f0
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
@@ -0,0 +1,29 @@
+//===--- HeaderGuardCheck.h - clang-tidy ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_HEADER_GUARD_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_HEADER_GUARD_CHECK_H
+
+#include "../utils/HeaderGuard.h"
+
+namespace clang {
+namespace tidy {
+
+/// Finds and fixes header guards that do not adhere to LLVM style.
+class LLVMHeaderGuardCheck : public HeaderGuardCheck {
+public:
+ bool shouldSuggestEndifComment(StringRef Filename) override { return false; }
+ bool shouldFixHeaderGuard(StringRef Filename) override;
+ std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_HEADER_GUARD_CHECK_H
OpenPOWER on IntegriCloud