aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-02-06 17:11:22 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-02-06 17:17:09 +0800
commit7c97c574cc795705737cd0b73daf6867406fe624 (patch)
treebd859ec3401fafbc77bb59156f4c3cceeaaeb68f /clang/lib/Frontend/CompilerInstance.cpp
parent322a2ed3557a3cdba9ee459d46bc1fc0c159d850 (diff)
downloadllvm-7c97c574cc795705737cd0b73daf6867406fe624.zip
llvm-7c97c574cc795705737cd0b73daf6867406fe624.tar.gz
llvm-7c97c574cc795705737cd0b73daf6867406fe624.tar.bz2
[Modules] Recreate file manager for ftime-trace when compiling a module
Close https://github.com/llvm/llvm-project/issues/60544. The root cause for the issue is that when we compile a module unit, the file manager (and proprocessor and source manager) are owned by AST instead of the compilaton instance. So the file manager may be invalid when we want to create a time-report file for -ftime-trace when we are compiling a module unit. This patch tries to recreate the file manager for -ftime-trace if we find the file manager is not valid.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index ecc1c4c..9c79e85 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -851,6 +851,9 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary,
// relative to that.
std::optional<SmallString<128>> AbsPath;
if (OutputPath != "-" && !llvm::sys::path::is_absolute(OutputPath)) {
+ assert(hasFileManager() &&
+ "File Manager is required to fix up relative path.\n");
+
AbsPath.emplace(OutputPath);
FileMgr->FixupRelativePath(*AbsPath);
OutputPath = *AbsPath;