Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-27 06:27:32 +0300
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-27 06:27:32 +0300
commit8e464dd76befbc4a39a1d21968a3d5f543e29312 (patch)
tree5c2102bf1a61ca1e9957081eb5602edc1b66e2b9
parente4871c1e2e5d01f662a122ecdc267ae4f7701778 (diff)
Frontend: Use early returns in CompilerInstance::clearOutputFiles, NFC
Use early returns in `CompilerInstance::clearOutputFiles` to clarify the logic, and rename `ec` to `EC` as a drive-by. No functionality change.
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 8afd9b36adb6..956877d34680 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -648,25 +648,30 @@ void CompilerInstance::createSema(TranslationUnitKind TUKind,
void CompilerInstance::clearOutputFiles(bool EraseFiles) {
for (OutputFile &OF : OutputFiles) {
- if (!OF.TempFilename.empty()) {
- if (EraseFiles) {
+ if (EraseFiles) {
+ if (!OF.TempFilename.empty()) {
llvm::sys::fs::remove(OF.TempFilename);
- } else {
- SmallString<128> NewOutFile(OF.Filename);
-
- // If '-working-directory' was passed, the output filename should be
- // relative to that.
- FileMgr->FixupRelativePath(NewOutFile);
- if (std::error_code ec =
- llvm::sys::fs::rename(OF.TempFilename, NewOutFile)) {
- getDiagnostics().Report(diag::err_unable_to_rename_temp)
- << OF.TempFilename << OF.Filename << ec.message();
-
- llvm::sys::fs::remove(OF.TempFilename);
- }
+ continue;
}
- } else if (!OF.Filename.empty() && EraseFiles)
- llvm::sys::fs::remove(OF.Filename);
+ if (!OF.Filename.empty())
+ llvm::sys::fs::remove(OF.Filename);
+ continue;
+ }
+
+ if (OF.TempFilename.empty())
+ continue;
+
+ // If '-working-directory' was passed, the output filename should be
+ // relative to that.
+ SmallString<128> NewOutFile(OF.Filename);
+ FileMgr->FixupRelativePath(NewOutFile);
+ std::error_code EC = llvm::sys::fs::rename(OF.TempFilename, NewOutFile);
+ if (!EC)
+ continue;
+ getDiagnostics().Report(diag::err_unable_to_rename_temp)
+ << OF.TempFilename << OF.Filename << EC.message();
+
+ llvm::sys::fs::remove(OF.TempFilename);
}
OutputFiles.clear();
if (DeleteBuiltModules) {