[Clang] change default storing path of `-ftime-trace`
authorJunduo Dong <andj4cn@gmail.com>
Tue, 9 Aug 2022 05:04:38 +0000 (22:04 -0700)
committerJunduo Dong <andj4cn@gmail.com>
Sat, 3 Sep 2022 01:49:11 +0000 (18:49 -0700)
commit38941da066a7b785ba4771710189172e94e37824
tree843655c78b4fee1215fa1ae13b63194341532984
parent95201fcca0d452757da5b25f431e998f46eecd48
[Clang] change default storing path of `-ftime-trace`

1. This implementation change the default storing behavior of -ftime-trace only.

That is, if the compiling job contains the linking action, the executable file' s directory may be seem as the main work directory.
Thus the time trace files would be stored in the same directory of linking result.

By this approach, the user can easily get the time-trace files in the main work directory. The improved demo results:

```
$ clang++ -ftime-trace -o main.out /demo/main.cpp
$ ls .
main.out   main-[random-string].json
```

2. In addition, the main codes of time-trace files' path inference have been refactored.

* The <path> of -ftime-trace=<path> is infered in clang driver
* After that, -ftime-trace=<path> can be added into clang's options

By this approach, the dirty work of path processing and judging can be implemented in driver layer, so that the clang may focus on its main work.

 #   $ clang -ftime-trace -o xxx.out xxx.cpp

Differential Revision: https://reviews.llvm.org/D131469
clang/lib/Driver/Driver.cpp
clang/test/Driver/check-time-trace.cpp
clang/tools/driver/cc1_main.cpp