From 81d4f939bc031ee0710bc2d41d0e10648b4ff95b Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 15 Oct 2014 12:18:35 +0000 Subject: Fix llvm-header-guard check. Summary: This patch makes the check work better for LLVM code: * always fix existing #endif comments * use one space before the comment (+allow customization for other styles) Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5795 llvm-svn: 219789 --- .../unittests/clang-tidy/LLVMModuleTest.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp') diff --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp index a35f29a..92f9cc3 100644 --- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp @@ -103,9 +103,19 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { "#endif\n", "include/clang/bar.h", /*ExpectedWarnings=*/1)); + // Fix incorrect #endif comments even if we shouldn't add new ones. EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" - "#endif // LLVM_ADT_FOO_H\n", + "#endif // LLVM_ADT_FOO_H\n", + runHeaderGuardCheck("#ifndef FOO\n" + "#define FOO\n" + "#endif // FOO\n", + "include/llvm/ADT/foo.h", + /*ExpectedWarnings=*/1)); + + EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" + "#define LLVM_ADT_FOO_H\n" + "#endif // LLVM_ADT_FOO_H\n", runHeaderGuardCheckWithEndif("#ifndef FOO\n" "#define FOO\n" "#endif\n", @@ -114,7 +124,7 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" - "#endif // LLVM_ADT_FOO_H\n", + "#endif // LLVM_ADT_FOO_H\n", runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" "#endif // LLVM_H\n", @@ -141,7 +151,7 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" - "#endif // LLVM_ADT_FOO_H\n", + "#endif // LLVM_ADT_FOO_H\n", runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H_\n" "#define LLVM_ADT_FOO_H_\n" "#endif // LLVM\n", -- cgit v1.1