[PATCH] [clang-tidy] Add a generic header guard checker + LLVM implementation.

Alexander Kornienko alexfh at google.com
Wed Aug 13 06:45:17 PDT 2014


LG

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:21
@@ +20,3 @@
+                                                 StringRef OldGuard) {
+  std::string Guard = tooling::getAbsolutePath(Filename);
+
----------------
Can we use the location of the compilation database to make project-relative paths? We can easily pass compilation database to the check via ClangTidyContext, if need be. We should consider this, but it shouldn't block this patch, though.

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.h:21
@@ +20,3 @@
+public:
+  bool shouldSuggestEndifComment(StringRef Filename) override { return false; }
+  bool shouldFixHeaderGuard(StringRef Filename) override;
----------------
Why false? Aren't #endif comments used in LLVM?

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.h:24
@@ +23,3 @@
+  std::string getHeaderGuard(StringRef Filename,
+                             StringRef OldGuard = StringRef()) override;
+};
----------------
Do you need to provide a default argument in the overridden method? Are you using this specific method with one argument?

http://reviews.llvm.org/D4867






More information about the cfe-commits mailing list