File tree Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1408,13 +1408,16 @@ const IdentifierNamingCheck::FileStyle &
1408
1408
IdentifierNamingCheck::getStyleForFile (StringRef FileName) const {
1409
1409
if (!GetConfigPerFile)
1410
1410
return *MainFileStyle;
1411
- StringRef Parent = llvm::sys::path::parent_path (FileName);
1411
+
1412
+ SmallString<128 > RealFileName;
1413
+ llvm::sys::fs::real_path (FileName, RealFileName);
1414
+ StringRef Parent = llvm::sys::path::parent_path (RealFileName);
1412
1415
auto Iter = NamingStylesCache.find (Parent);
1413
1416
if (Iter != NamingStylesCache.end ())
1414
1417
return Iter->getValue ();
1415
1418
1416
1419
llvm::StringRef CheckName = getID ();
1417
- ClangTidyOptions Options = Context->getOptionsForFile (FileName );
1420
+ ClangTidyOptions Options = Context->getOptionsForFile (RealFileName );
1418
1421
if (Options.Checks && GlobList (*Options.Checks ).contains (CheckName)) {
1419
1422
auto It = NamingStylesCache.try_emplace (
1420
1423
Parent,
Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ Changes in existing checks
188
188
<clang-tidy/checks/readability/redundant-inline-specifier>` check to properly
189
189
emit warnings for static data member with an in-class initializer.
190
190
191
+ - Improved :doc: `readability-identifier-naming
192
+ <clang-tidy/checks/readability/identifier-naming>` check in `GetConfigPerFile `
193
+ mode by resolving symbolic links to header files.
194
+
191
195
Removed checks
192
196
^^^^^^^^^^^^^^
193
197
Original file line number Diff line number Diff line change
1
+ Checks : readability-identifier-naming
2
+ CheckOptions :
3
+ readability-identifier-naming.GlobalConstantCase : CamelCase
4
+ readability-identifier-naming.GlobalConstantPrefix : k
Original file line number Diff line number Diff line change
1
+ const int global_const = 5 ;
Original file line number Diff line number Diff line change
1
+ // Specify `-std=c++20` to run test only once becuase test expects changes
2
+ // in the header file so it fails if runs multiple times with different
3
+ // `-std` flags as check_clang_tidy doesn by default.
4
+ //
5
+ // RUN: rm -rf %T/symlink
6
+ // RUN: cp -r %S/Inputs/identifier-naming/symlink %T/symlink
7
+ // RUN: mkdir -p %T/symlink/build
8
+ // RUN: ln -s %T/symlink/include/test.h %T/symlink/build/test.h
9
+ // 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
10
+ // UNSUPPORTED: system-windows
11
+
12
+ #include " test.h"
13
+
14
+ int foo () {
15
+ return global_const;
16
+ // CHECK-MESSAGES: warning: invalid case style for global constant 'global_const' [readability-identifier-naming]
17
+ // CHECK-FIXES: return kGlobalConst;
18
+ }
You can’t perform that action at this time.
0 commit comments