diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -123,12 +123,7 @@ // Emit warnings for headers that are missing guards. checkGuardlessHeaders(); - - // Clear all state. - Macros.clear(); - Files.clear(); - Ifndefs.clear(); - EndIfs.clear(); + clearAllState(); } bool wouldFixEndifComment(StringRef FileName, SourceLocation EndIf, @@ -255,6 +250,13 @@ } private: + void clearAllState() { + Macros.clear(); + Files.clear(); + Ifndefs.clear(); + EndIfs.clear(); + } + std::vector> Macros; llvm::StringMap Files; std::map>