-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy][readability-identifier-naming] Resolve symlinks for chec…
…king style for file (#81985) Summary: Some build systems create symlinks in a temporary build directory for headers in the source tree for isolation purposes. These symlinks prevent `readability-identifier-naming` detecting issues and applying fixes. Without this fix clang-tidy is checking .clang-tidy config file in a temporary directory instead of source source location. Test Plan: check-clang-tools
- Loading branch information
1 parent
ad78e21
commit c310782
Showing
5 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...test/clang-tidy/checkers/readability/Inputs/identifier-naming/symlink/include/.clang-tidy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Checks: readability-identifier-naming | ||
CheckOptions: | ||
readability-identifier-naming.GlobalConstantCase: CamelCase | ||
readability-identifier-naming.GlobalConstantPrefix: k |
1 change: 1 addition & 0 deletions
1
...xtra/test/clang-tidy/checkers/readability/Inputs/identifier-naming/symlink/include/test.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const int global_const = 5; |
18 changes: 18 additions & 0 deletions
18
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-symlink.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Specify `-std=c++20` to run test only once becuase test expects changes | ||
// in the header file so it fails if runs multiple times with different | ||
// `-std` flags as check_clang_tidy doesn by default. | ||
// | ||
// RUN: rm -rf %T/symlink | ||
// RUN: cp -r %S/Inputs/identifier-naming/symlink %T/symlink | ||
// RUN: mkdir -p %T/symlink/build | ||
// RUN: ln -s %T/symlink/include/test.h %T/symlink/build/test.h | ||
// RUN: %check_clang_tidy -std=c++20 %s readability-identifier-naming %t -- --header-filter="test.h" --config-file=%S/Inputs/identifier-naming/symlink/include/.clang-tidy -- -I %T/symlink/build | ||
// UNSUPPORTED: system-windows | ||
|
||
#include "test.h" | ||
|
||
int foo() { | ||
return global_const; | ||
// CHECK-MESSAGES: warning: invalid case style for global constant 'global_const' [readability-identifier-naming] | ||
// CHECK-FIXES: return kGlobalConst; | ||
} |