aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2014-05-19 16:39:08 +0000
committerAlexander Kornienko <alexfh@google.com>2014-05-19 16:39:08 +0000
commitbef51cdf055d19dfb276c0e155d82acf62feed09 (patch)
tree65692f83672d62722c421559d7d1e28b70821794 /clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
parent06c59e259867ee866b23ae3108a10e62af72c852 (diff)
downloadllvm-bef51cdf055d19dfb276c0e155d82acf62feed09.zip
llvm-bef51cdf055d19dfb276c0e155d82acf62feed09.tar.gz
llvm-bef51cdf055d19dfb276c0e155d82acf62feed09.tar.bz2
Improved llvm-namespace-comment check.
Summary: Handle various forms of existing namespace closing comments, fix existing comments with wrong namespace name, ignore short namespaces. The state of this check now seems to be enough to enable it by default to gather user feedback ;) Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3825 llvm-svn: 209141
Diffstat (limited to 'clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
new file mode 100644
index 0000000..de4f650a
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -0,0 +1,44 @@
+//===--- IncludeOrderCheck.cpp - clang-tidy -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "IncludeOrderCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+class IncludeOrderPPCallbacks : public PPCallbacks {
+public:
+ explicit IncludeOrderPPCallbacks(IncludeOrderCheck &Check) : Check(Check) {}
+
+ void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+ StringRef FileName, bool IsAngled,
+ CharSourceRange FilenameRange, const FileEntry *File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported) override {
+ // FIXME: This is a dummy implementation to show how to get at preprocessor
+ // information. Implement a real include order check.
+ Check.diag(HashLoc, "This is an include");
+ }
+
+private:
+ IncludeOrderCheck &Check;
+};
+} // namespace
+
+void IncludeOrderCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+ Compiler.getPreprocessor()
+ .addPPCallbacks(new IncludeOrderPPCallbacks(*this));
+}
+
+} // namespace tidy
+} // namespace clang