diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp index b3c4227b6238..8549c0d4a6e3 100644 --- a/clang-tools-extra/modularize/CoverageChecker.cpp +++ b/clang-tools-extra/modularize/CoverageChecker.cpp @@ -370,12 +370,18 @@ bool CoverageChecker::collectFileSystemHeaders(StringRef IncludePath) { I.increment(EC)) { if (EC) return false; - std::string file(I->path()); + //std::string file(I->path()); + StringRef file(I->path()); I->status(Status); sys::fs::file_type type = Status.type(); // If the file is a directory, ignore the name (but still recurses). if (type == sys::fs::file_type::directory_file) continue; + // Assume directories or files starting with '.' are private and not to + // be considered. + if (file.startswith(".") || (file.find("\\.") != StringRef::npos) + || (file.find("/.") != StringRef::npos)) + continue; // If the file does not have a common header extension, ignore it. if (!ModularizeUtilities::isHeader(file)) continue; diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 08c92fc90c0d..1db60185656a 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -468,7 +468,7 @@ std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) { bool ModularizeUtilities::isHeader(StringRef FileName) { StringRef Extension = llvm::sys::path::extension(FileName); if (Extension.size() == 0) - return false; + return true; if (Extension.equals_lower(".h")) return true; if (Extension.equals_lower(".inc")) diff --git a/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h b/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h new file mode 100644 index 000000000000..f60b66cd1f62 --- /dev/null +++ b/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h @@ -0,0 +1,3 @@ +#error DontFindMe.h shouldn't be found. + + diff --git a/clang-tools-extra/test/modularize/Inputs/CoverageProblems/Level3B b/clang-tools-extra/test/modularize/Inputs/CoverageProblems/Level3B new file mode 100644 index 000000000000..e1eee7ef8b56 --- /dev/null +++ b/clang-tools-extra/test/modularize/Inputs/CoverageProblems/Level3B @@ -0,0 +1 @@ +#define MACRO_3B 1 diff --git a/clang-tools-extra/test/modularize/ProblemsCoverage.modularize b/clang-tools-extra/test/modularize/ProblemsCoverage.modularize index 68224e1c3743..5a1c3489beb7 100644 --- a/clang-tools-extra/test/modularize/ProblemsCoverage.modularize +++ b/clang-tools-extra/test/modularize/ProblemsCoverage.modularize @@ -1,4 +1,5 @@ # RUN: not modularize %S/Inputs/CoverageProblems/module.modulemap 2>&1 | FileCheck %s # CHECK: warning: {{.*}}{{[/\\]}}Inputs/CoverageProblems/module.modulemap does not account for file: {{.*}}{{[/\\]}}Inputs/CoverageProblems/Level3A.h +# CHECK-NEXT: warning: {{.*}}{{[/\\]}}Inputs/CoverageProblems/module.modulemap does not account for file: {{.*}}{{[/\\]}}Inputs/CoverageProblems/Level3B # CHECK-NEXT: warning: {{.*}}{{[/\\]}}Inputs/CoverageProblems/module.modulemap does not account for file: {{.*}}{{[/\\]}}Inputs/CoverageProblems/Sub/Level3B.h