File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1414,13 +1414,21 @@ IdentifierNamingCheck::getDiagInfo(const NamingCheckId &ID,
1414
1414
}};
1415
1415
}
1416
1416
1417
+ StringRef IdentifierNamingCheck::getRealFileName (StringRef FileName) const {
1418
+ auto Iter = RealFileNameCache.try_emplace (FileName);
1419
+ SmallString<256U > &RealFileName = Iter.first ->getValue ();
1420
+ if (!Iter.second )
1421
+ return RealFileName;
1422
+ llvm::sys::fs::real_path (FileName, RealFileName);
1423
+ return RealFileName;
1424
+ }
1425
+
1417
1426
const IdentifierNamingCheck::FileStyle &
1418
1427
IdentifierNamingCheck::getStyleForFile (StringRef FileName) const {
1419
1428
if (!GetConfigPerFile)
1420
1429
return *MainFileStyle;
1421
1430
1422
- SmallString<128 > RealFileName;
1423
- llvm::sys::fs::real_path (FileName, RealFileName);
1431
+ StringRef RealFileName = getRealFileName (FileName);
1424
1432
StringRef Parent = llvm::sys::path::parent_path (RealFileName);
1425
1433
auto Iter = NamingStylesCache.find (Parent);
1426
1434
if (Iter != NamingStylesCache.end ())
Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck {
205
205
const NamingCheckFailure &Failure) const override ;
206
206
207
207
const FileStyle &getStyleForFile (StringRef FileName) const ;
208
+ StringRef getRealFileName (StringRef FileName) const ;
208
209
209
210
// / Find the style kind of a field in an anonymous record.
210
211
StyleKind findStyleKindForAnonField (
@@ -222,6 +223,7 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck {
222
223
// / Stores the style options as a vector, indexed by the specified \ref
223
224
// / StyleKind, for a given directory.
224
225
mutable llvm::StringMap<FileStyle> NamingStylesCache;
226
+ mutable llvm::StringMap<SmallString<256U >> RealFileNameCache;
225
227
FileStyle *MainFileStyle;
226
228
ClangTidyContext *Context;
227
229
const bool GetConfigPerFile;
You can’t perform that action at this time.
0 commit comments