[clang-tools-extra] r254785 - Added coverage check for extensionless headers, and exclude hidden dot directoryies.

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 18:19:19 PST 2015


On Fri, Dec 4, 2015 at 6:04 PM, John Thompson <
john.thompson.jtsoftware at gmail.com> wrote:

> >Aren't we already rejecting directories in the line `if (type ==
> sys::fs::file_type::directory_file)` above? Why check the filename?
>
> The iterator will walk the directories.  That statement just keeps the
> directories out of the file list.  The iterator also give the relative path
> from the starting directory, so I look for directory nodes or file names
> that start with "." so I can avoid stuff that is usually private, like the
> .svn directory, which bit me on one of the platforms.  Not perfect, but
> close enough, I think.
>

Ah, that makes sense. Thanks for the explanation.

-- Sean Silva


>
> Thanks for looking at it.
>
> -John
>
>
> On Fri, Dec 4, 2015 at 5:08 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>>
>>
>> On Fri, Dec 4, 2015 at 2:42 PM, John Thompson via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>>> Author: jtsoftware
>>> Date: Fri Dec  4 16:42:18 2015
>>> New Revision: 254785
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=254785&view=rev
>>> Log:
>>> Added coverage check for extensionless headers, and exclude hidden dot
>>> directoryies.
>>>
>>> Added:
>>>
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/
>>>
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h
>>>
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageProblems/Level3B
>>> Modified:
>>>     clang-tools-extra/trunk/modularize/CoverageChecker.cpp
>>>     clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
>>>     clang-tools-extra/trunk/test/modularize/ProblemsCoverage.modularize
>>>
>>> Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=254785&r1=254784&r2=254785&view=diff
>>>
>>> ==============================================================================
>>> --- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
>>> +++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Fri Dec  4
>>> 16:42:18 2015
>>> @@ -370,12 +370,18 @@ bool CoverageChecker::collectFileSystemH
>>>      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;
>>>
>>
>> Aren't we already rejecting directories in the line `if (type ==
>> sys::fs::file_type::directory_file)` above? Why check the filename?
>>
>> -- Sean Silva
>>
>>
>>>      // If the file does not have a common header extension, ignore it.
>>>      if (!ModularizeUtilities::isHeader(file))
>>>        continue;
>>>
>>> Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=254785&r1=254784&r2=254785&view=diff
>>>
>>> ==============================================================================
>>> --- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
>>> +++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Fri Dec
>>> 4 16:42:18 2015
>>> @@ -468,7 +468,7 @@ std::string ModularizeUtilities::getCano
>>>  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"))
>>>
>>> Added:
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h?rev=254785&view=auto
>>>
>>> ==============================================================================
>>> ---
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h
>>> (added)
>>> +++
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageNoProblems/Includes1/.hidden/DontFindMe.h
>>> Fri Dec  4 16:42:18 2015
>>> @@ -0,0 +1,3 @@
>>> +#error DontFindMe.h shouldn't be found.
>>> +
>>> +
>>>
>>> Added:
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageProblems/Level3B
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/Inputs/CoverageProblems/Level3B?rev=254785&view=auto
>>>
>>> ==============================================================================
>>> ---
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageProblems/Level3B
>>> (added)
>>> +++
>>> clang-tools-extra/trunk/test/modularize/Inputs/CoverageProblems/Level3B Fri
>>> Dec  4 16:42:18 2015
>>> @@ -0,0 +1 @@
>>> +#define MACRO_3B 1
>>>
>>> Modified:
>>> clang-tools-extra/trunk/test/modularize/ProblemsCoverage.modularize
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/ProblemsCoverage.modularize?rev=254785&r1=254784&r2=254785&view=diff
>>>
>>> ==============================================================================
>>> --- clang-tools-extra/trunk/test/modularize/ProblemsCoverage.modularize
>>> (original)
>>> +++ clang-tools-extra/trunk/test/modularize/ProblemsCoverage.modularize
>>> Fri Dec  4 16:42:18 2015
>>> @@ -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
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
>
> --
> John Thompson
> John.Thompson.JTSoftware at gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151204/c8279557/attachment-0001.html>


More information about the cfe-commits mailing list