[Modules] Recreate file manager for ftime-trace when compiling a module
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Mon, 6 Feb 2023 09:11:22 +0000 (17:11 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Mon, 6 Feb 2023 09:17:09 +0000 (17:17 +0800)
commit7c97c574cc795705737cd0b73daf6867406fe624
treebd859ec3401fafbc77bb59156f4c3cceeaaeb68f
parent322a2ed3557a3cdba9ee459d46bc1fc0c159d850
[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.
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/test/Modules/ftime-trace.cppm [new file with mode: 0644]
clang/tools/driver/cc1_main.cpp