@@ -3114,25 +3114,18 @@ ASTVisitor::
31143114findFileInfo (clang::SourceLocation const loc)
31153115{
31163116 MRDOCS_CHECK_OR (!loc.isInvalid (), nullptr );
3117-
3118- // KRYSTIAN FIXME: we really should not be calling getPresumedLoc this often,
3119- // it's quite expensive
3120- auto const presumed = source_.getPresumedLoc (loc, false );
3121- MRDOCS_CHECK_OR (!presumed.isInvalid (), nullptr );
3122-
3123- FileEntry const * entry = source_.getFileEntryForID ( presumed.getFileID ());
3124- MRDOCS_CHECK_OR (entry, nullptr );
3117+ // Find the presumed location, ignoring #line directives
3118+ PresumedLoc presumed = source_.getPresumedLoc (loc, false );
3119+ FileID id = presumed.getFileID ();
3120+ if (id.isInvalid ())
3121+ return nullptr ;
31253122
31263123 // Find in the cache
3127- if (auto const it = files_.find (entry); it != files_.end ())
3128- {
3124+ if (auto const it = files_.find (id); it != files_.end ())
31293125 return std::addressof (it->second );
3130- }
31313126
3132- // Build FileInfo
3133- auto const FI = buildFileInfo (entry);
3134- MRDOCS_CHECK_OR (FI, nullptr );
3135- auto [it, inserted] = files_.try_emplace (entry, std::move (*FI));
3127+ auto [it, inserted] = files_.try_emplace (
3128+ id, buildFileInfo (presumed.getFilename ()));
31363129 return std::addressof (it->second );
31373130}
31383131
@@ -3148,15 +3141,6 @@ findFileInfo(Decl const* D)
31483141 return findFileInfo (Loc);
31493142}
31503143
3151- std::optional<ASTVisitor::FileInfo>
3152- ASTVisitor::
3153- buildFileInfo (FileEntry const * entry)
3154- {
3155- std::string_view const file_path = entry->tryGetRealPathName ();
3156- MRDOCS_CHECK_OR (!file_path.empty (), std::nullopt );
3157- return buildFileInfo (file_path);
3158- }
3159-
31603144ASTVisitor::FileInfo
31613145ASTVisitor::
31623146buildFileInfo (std::string_view const file_path)
0 commit comments