[clang] 895b555 - [clang][Diagnostics][NFC] Move variable decl into if statement

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed May 31 01:50:04 PDT 2023


Author: Timm Bäder
Date: 2023-05-31T10:49:06+02:00
New Revision: 895b55537870cdaf6e4c304a09f4bf01954ccbd6

URL: https://github.com/llvm/llvm-project/commit/895b55537870cdaf6e4c304a09f4bf01954ccbd6
DIFF: https://github.com/llvm/llvm-project/commit/895b55537870cdaf6e4c304a09f4bf01954ccbd6.diff

LOG: [clang][Diagnostics][NFC] Move variable decl into if statement

Added: 
    

Modified: 
    clang/lib/Frontend/TextDiagnostic.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 11ae2667dfa8..ad5f1d45cb63 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -773,8 +773,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
                                        ArrayRef<CharSourceRange> Ranges) {
   if (PLoc.isInvalid()) {
     // At least print the file name if available:
-    FileID FID = Loc.getFileID();
-    if (FID.isValid()) {
+    if (FileID FID = Loc.getFileID(); FID.isValid()) {
       if (const FileEntry *FE = Loc.getFileEntry()) {
         emitFilename(FE->getName(), Loc.getManager());
         OS << ": ";


        


More information about the cfe-commits mailing list