[llvm] r339894 - Fix -Wmicrosoft-goto warnings.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 09:30:28 PDT 2018
Author: zturner
Date: Thu Aug 16 09:30:27 2018
New Revision: 339894
URL: http://llvm.org/viewvc/llvm-project?rev=339894&view=rev
Log:
Fix -Wmicrosoft-goto warnings.
Modified:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=339894&r1=339893&r2=339894&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Thu Aug 16 09:30:27 2018
@@ -1505,10 +1505,12 @@ CharLiteralError:
}
wchar_t Demangler::demangleWcharLiteral(StringView &MangledName) {
- uint8_t C1 = demangleCharLiteral(MangledName);
+ uint8_t C1, C2;
+
+ C1 = demangleCharLiteral(MangledName);
if (Error)
goto WCharLiteralError;
- uint8_t C2 = demangleCharLiteral(MangledName);
+ C2 = demangleCharLiteral(MangledName);
if (Error)
goto WCharLiteralError;
@@ -1663,8 +1665,15 @@ static unsigned decodeMultiByteChar(cons
}
Name *Demangler::demangleStringLiteral(StringView &MangledName) {
+ // This function uses goto, so declare all variables up front.
OutputStream OS;
StringView CRC;
+ uint64_t StringByteSize;
+ bool IsWcharT = false;
+ bool IsNegative = false;
+ size_t CrcEndPos = 0;
+ char *ResultBuffer = nullptr;
+
Name *Result = Arena.alloc<Name>();
Result->IsStringLiteral = true;
@@ -1673,7 +1682,6 @@ Name *Demangler::demangleStringLiteral(S
goto StringLiteralError;
// Char Type (regular or wchar_t)
- bool IsWcharT = false;
switch (MangledName.popFront()) {
case '1':
IsWcharT = true;
@@ -1685,14 +1693,12 @@ Name *Demangler::demangleStringLiteral(S
}
// Encoded Length
- uint64_t StringByteSize;
- bool IsNegative;
std::tie(StringByteSize, IsNegative) = demangleNumber(MangledName);
if (Error || IsNegative)
goto StringLiteralError;
// CRC 32 (always 8 characters plus a terminator)
- size_t CrcEndPos = MangledName.find('@');
+ CrcEndPos = MangledName.find('@');
if (CrcEndPos == StringView::npos)
goto StringLiteralError;
CRC = MangledName.substr(0, CrcEndPos);
@@ -1754,7 +1760,7 @@ Name *Demangler::demangleStringLiteral(S
}
OS << '\0';
- char *ResultBuffer = OS.getBuffer();
+ ResultBuffer = OS.getBuffer();
Result->Str = copyString(ResultBuffer);
return Result;
More information about the llvm-commits
mailing list