[PATCH] D20512: [PATCH] Bug 27475 - Request header guard check processes .hpp files as well as .h files

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 24 10:17:17 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:18
@@ +17,3 @@
+  StringRef extension = ::llvm::sys::path::extension(Filename);
+  if (extension.size() > 0 && extension.front() == '.') {
+    extension = extension.substr(1);
----------------
nit: In LLVM/Clang code it's not common to enclose single-line if/while/for bodies in braces.

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:18
@@ +17,3 @@
+  StringRef extension = ::llvm::sys::path::extension(Filename);
+  if (extension.size() > 0 && extension.front() == '.') {
+    extension = extension.substr(1);
----------------
alexfh wrote:
> nit: In LLVM/Clang code it's not common to enclose single-line if/while/for bodies in braces.
`if (extension.startswith("."))`

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:22
@@ +21,3 @@
+
+  if (HeaderFileExtensions.count(extension))
+    return true;
----------------
`return HeaderFileExtensions.count(extension) > 0;`

================
Comment at: clang-tidy/llvm/HeaderGuardCheck.cpp:26
@@ -18,2 +25,3 @@
+  return false;
 }
 
----------------
Were you going to use `isHeaderFileExtension`, btw?

================
Comment at: clang-tidy/utils/HeaderFileExtensionsUtils.cpp:64
@@ -63,1 +63,3 @@
 
+bool isHeaderFileExtension(StringRef FileName, HeaderFileExtensionsSet HeaderFileExtensions) {
+  StringRef extension = ::llvm::sys::path::extension(FileName);
----------------
1. clang-format the code
2. see comments for `LLVMHeaderGuardCheck::shouldFixHeaderGuard` above


https://reviews.llvm.org/D20512





More information about the cfe-commits mailing list