This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix llvm-header-guard so that it works with Windows paths
ClosedPublic

Authored by salman-javed-nz on Nov 8 2021, 6:45 PM.

Details

Summary

Fixes https://bugs.llvm.org/show_bug.cgi?id=40372.

The llvm-header-guard check does not take into account that the path
separator on Windows is \, not /.

This means that instead of suggesting a header guard in the form of:
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FOO_H

it incorrectly suggests:
C:\LLVM_PROJECT\CLANG_TOOLS_EXTRA\CLANG_TIDY\FOO_H

Diff Detail

Event Timeline

salman-javed-nz created this revision.Nov 8 2021, 6:45 PM
salman-javed-nz requested review of this revision.Nov 8 2021, 6:45 PM
aaron.ballman accepted this revision.Nov 9 2021, 4:22 AM

LGTM, thank you for the fix!

clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
248–250

Another test case is UNC paths: \\\\?\\C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h (with escapes already added).

This revision is now accepted and ready to land.Nov 9 2021, 4:22 AM

Unit tests:

  • Renamed Samba to SMB
  • Added test for UNC paths
salman-javed-nz marked an inline comment as done.Nov 9 2021, 4:52 AM

@aaron.ballman -
I've added the unit test for UNC path as you suggested. Since you've already given the LGTM, I assume you don't need to see the patch again, so I have gone ahead with the commit.
Anyway, I'll be around to address any problems if they crop up.