[clang] 1fd6f06 - [format] Fix an uninitialized variable

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 09:18:57 PDT 2022


Author: Benjamin Kramer
Date: 2022-06-07T18:18:29+02:00
New Revision: 1fd6f06b9e975386f4bb30ce8a1d044abeb1b633

URL: https://github.com/llvm/llvm-project/commit/1fd6f06b9e975386f4bb30ce8a1d044abeb1b633
DIFF: https://github.com/llvm/llvm-project/commit/1fd6f06b9e975386f4bb30ce8a1d044abeb1b633.diff

LOG: [format] Fix an uninitialized variable

parseBlock may decide to leave it unchanged. Found by msan.

Added: 
    

Modified: 
    clang/lib/Format/UnwrappedLineParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index f581005e8c3ca..86b42c499b23b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2595,7 +2595,7 @@ FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
       FormatTok->setFinalizedType(TT_ElseLBrace);
       ElseLeftBrace = FormatTok;
       CompoundStatementIndenter Indenter(this, Style, Line->Level);
-      IfStmtKind ElseBlockKind;
+      IfStmtKind ElseBlockKind = IfStmtKind::NotIf;
       parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
                  /*MunchSemi=*/true, KeepElseBraces, &ElseBlockKind);
       if ((ElseBlockKind == IfStmtKind::IfOnly ||


        


More information about the cfe-commits mailing list