diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp --- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp @@ -54,6 +54,7 @@ std::replace(Guard.begin(), Guard.end(), '/', '_'); std::replace(Guard.begin(), Guard.end(), '.', '_'); std::replace(Guard.begin(), Guard.end(), '-', '_'); + std::replace(Guard.begin(), Guard.end(), ':', '_'); // The prevalent style in clang is LLVM_CLANG_FOO_BAR_H if (StringRef(Guard).startswith("clang")) diff --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp --- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp @@ -267,6 +267,15 @@ runHeaderGuardCheck( "", "\\\\?\\C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h", StringRef("header is missing header guard"))); + + EXPECT_EQ("#ifndef C__TEST_FOO_H\n" + "#define C__TEST_FOO_H\n" + "\n" + "\n" + "#endif\n", + runHeaderGuardCheck("", "c:\\test\\foo.h", + StringRef("header is missing header guard"))); + #endif }