[clang][driver] Ensure we don't accumulate entries in -MJ files
authorJan Svoboda <jan_svoboda@apple.com>
Fri, 17 Jun 2022 21:31:07 +0000 (23:31 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Fri, 17 Jun 2022 22:00:43 +0000 (00:00 +0200)
commit92c6ffa14cdeb3edd50b46d30c830698705db9f5
treebc6eebf4696f5943ccf14be40a8cf022308aada9
parent7bc00ce5cd41aad5fd0775f58c8e85a0a8d9ee56
[clang][driver] Ensure we don't accumulate entries in -MJ files

Previously, each job would overwrite the -MJ file. This didn't quite work for Clang invocations with multiple architectures, which got fixed in D121997 by always appending to the -MJ file. That's not correct either, since the file would grow indefinitely on subsequent Clang invocations. This patch ensures the driver always removes the file before jobs fill it in by appending.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D128098
clang/lib/Driver/Driver.cpp
clang/test/Driver/compilation_database_multiarch.c