Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -148,7 +148,7 @@ llvm::BumpPtrAllocator DebugInfoNames; StringRef CWDName; - llvm::StringMap DIFileCache; + llvm::DenseMap DIFileCache; llvm::DenseMap SPCache; /// Cache declarations relevant to DW_TAG_imported_declarations (C++ /// using declarations and global alias variables) that aren't covered Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -397,6 +397,7 @@ // createFile() below for canonicalization if the source file was specified // with an absolute path. FileName = TheCU->getFile()->getFilename(); + FID = SM.getMainFileID(); } else { PresumedLoc PLoc = SM.getPresumedLoc(Loc); FileName = PLoc.getFilename(); Index: clang/test/CodeGenCXX/debug-info-function-context.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-function-context.cpp +++ clang/test/CodeGenCXX/debug-info-function-context.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-pc-linux-gnu %s \ -// RUN: -dwarf-version=5 -main-file-name %s -o - | FileCheck %s +// RUN: -dwarf-version=5 -main-file-name debug-info-function-context.cpp -o - | FileCheck %s struct C { void member_function();