[llvm] 3d4e5d2 - [NFC][LLLexer] Consistently initialize *Val fields
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 19:10:50 PDT 2023
Author: Vitaly Buka
Date: 2023-05-11T19:10:38-07:00
New Revision: 3d4e5d2ad911182ae5bb797b44747fb3656a3c48
URL: https://github.com/llvm/llvm-project/commit/3d4e5d2ad911182ae5bb797b44747fb3656a3c48
DIFF: https://github.com/llvm/llvm-project/commit/3d4e5d2ad911182ae5bb797b44747fb3656a3c48.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/AsmParser/LLLexer.h
llvm/lib/AsmParser/LLLexer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/AsmParser/LLLexer.h b/llvm/include/llvm/AsmParser/LLLexer.h
index 7bcb33f187684..bd929db33c4a2 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 6525dfdde7056..23a7b4481110c 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();
}
More information about the llvm-commits
mailing list