From 3d4e5d2ad911182ae5bb797b44747fb3656a3c48 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 11 May 2023 19:07:29 -0700 Subject: [PATCH] [NFC][LLLexer] Consistently initialize *Val fields LLParser::parseInstruction speculatively getUIntVal() but uses that only in some branches. APFloatVal, TyVal and StrVal were already initialized, when UIntVal and APSIntVal were not. --- llvm/include/llvm/AsmParser/LLLexer.h | 8 ++++---- llvm/lib/AsmParser/LLLexer.cpp | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/AsmParser/LLLexer.h b/llvm/include/llvm/AsmParser/LLLexer.h index 7bcb33f18768..bd929db33c4a 100644 --- a/llvm/include/llvm/AsmParser/LLLexer.h +++ b/llvm/include/llvm/AsmParser/LLLexer.h @@ -36,14 +36,14 @@ namespace llvm { const char *TokStart; lltok::Kind CurKind; std::string StrVal; - unsigned UIntVal; + unsigned UIntVal = 0; Type *TyVal = nullptr; - APFloat APFloatVal; - APSInt APSIntVal; + APFloat APFloatVal{0.0}; + APSInt APSIntVal{0}; // When false (default), an identifier ending in ':' is a label token. // When true, the ':' is treated as a separate token. - bool IgnoreColonInIdentifiers; + bool IgnoreColonInIdentifiers = false; public: explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &, diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 6525dfdde705..23a7b4481110 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -158,8 +158,7 @@ static const char *isLabelTail(const char *CurPtr) { LLLexer::LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &Err, LLVMContext &C) - : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(C), APFloatVal(0.0), - IgnoreColonInIdentifiers(false) { + : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(C) { CurPtr = CurBuf.begin(); } -- 2.34.1