@@ -3120,25 +3120,18 @@ ASTVisitor::
31203120findFileInfo (clang::SourceLocation const loc)
31213121{
31223122 MRDOCS_CHECK_OR (!loc.isInvalid (), nullptr );
3123-
3124- // KRYSTIAN FIXME: we really should not be calling getPresumedLoc this often,
3125- // it's quite expensive
3126- auto const presumed = source_.getPresumedLoc (loc, false );
3127- MRDOCS_CHECK_OR (!presumed.isInvalid (), nullptr );
3128-
3129- FileEntry const * entry = source_.getFileEntryForID ( presumed.getFileID ());
3130- MRDOCS_CHECK_OR (entry, nullptr );
3123+ // Find the presumed location, ignoring #line directives
3124+ PresumedLoc presumed = source_.getPresumedLoc (loc, false );
3125+ FileID id = presumed.getFileID ();
3126+ if (id.isInvalid ())
3127+ return nullptr ;
31313128
31323129 // Find in the cache
3133- if (auto const it = files_.find (entry); it != files_.end ())
3134- {
3130+ if (auto const it = files_.find (id); it != files_.end ())
31353131 return std::addressof (it->second );
3136- }
31373132
3138- // Build FileInfo
3139- auto const FI = buildFileInfo (entry);
3140- MRDOCS_CHECK_OR (FI, nullptr );
3141- auto [it, inserted] = files_.try_emplace (entry, std::move (*FI));
3133+ auto [it, inserted] = files_.try_emplace (
3134+ id, buildFileInfo (presumed.getFilename ()));
31423135 return std::addressof (it->second );
31433136}
31443137
@@ -3154,25 +3147,19 @@ findFileInfo(Decl const* D)
31543147 return findFileInfo (Loc);
31553148}
31563149
3157- std::optional<ASTVisitor::FileInfo>
3158- ASTVisitor::
3159- buildFileInfo (FileEntry const * entry)
3160- {
3161- std::string_view const file_path = entry->tryGetRealPathName ();
3162- MRDOCS_CHECK_OR (!file_path.empty (), std::nullopt );
3163- return buildFileInfo (file_path);
3164- }
3165-
31663150ASTVisitor::FileInfo
31673151ASTVisitor::
3168- buildFileInfo (std::string_view const file_path )
3152+ buildFileInfo (std::string_view path )
31693153{
31703154 FileInfo file_info;
3171- file_info.full_path = file_path;
3172- if (!files::isPosixStyle (file_info.full_path ))
3173- {
3155+ file_info.full_path = path;
3156+
3157+ if (! files::isAbsolute (file_info.full_path ))
3158+ file_info.full_path = files::makeAbsolute (
3159+ file_info.full_path , config_->sourceRoot );
3160+
3161+ if (! files::isPosixStyle (file_info.full_path ))
31743162 file_info.full_path = files::makePosixStyle (file_info.full_path );
3175- }
31763163
31773164 // Attempts to get a relative path for the prefix
31783165 auto tryGetRelativePosixPath = [&file_info](std::string_view const prefix)
0 commit comments