================
@@ -109,9 +134,54 @@ void DuplicateIncludeCallbacks::MacroUndefined(const Token
&MacroNameTok,
Files.back().clear();
}
+bool DuplicateIncludeCallbacks::IsAllowedDuplicateInclude(
+ StringRef TokenName, OptionalFileEntryRef File, StringRef RelativePath) {
+ SmallVector<StringRef, 3> matchArguments;
+ matchArguments.push_back(TokenName);
+
+ if (!RelativePath.empty())
+ matchArguments.push_back(llvm::sys::path::filename(RelativePath));
+
+ if (File) {
+ StringRef RealPath = File->getFileEntry().tryGetRealPathName();
+ if (!RealPath.empty())
+ matchArguments.push_back(llvm::sys::path::filename(RealPath));
+ }
+
+ // try to match with each regex
+ for (const llvm::Regex ® : AllowedDuplicateRegex) {
+ for (StringRef arg : matchArguments) {
+ if (reg.match(arg))
+ return true;
+ }
+ }
+ return false;
+}
+
+DuplicateIncludeCheck::DuplicateIncludeCheck(StringRef Name,
+ ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {
+ std::string Raw = Options.get("AllowedDuplicateIncludes", "").str();
+ if (!Raw.empty()) {
+ SmallVector<StringRef, 4> StringParts;
+ StringRef(Raw).split(StringParts, ',', -1, false);
----------------
vbvictor wrote:
Should be semicolon-separated, see
https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html#cmdoption-arg-IgnoreHeaders.
https://github.com/llvm/llvm-project/pull/167046
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits