1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[DWARFYAML] Fix unintialized value Is64BitAddrSize. NFC.

This patch fixes the undefined behavior that reported by ubsan.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/
This commit is contained in:
Xing GUO 2020-08-05 00:09:12 +08:00
parent 1a2c4f8162
commit 7bc6977b8b
3 changed files with 8 additions and 3 deletions

View File

@ -48,7 +48,8 @@ std::function<Error(raw_ostream &, const Data &)>
getDWARFEmitterByName(StringRef SecName);
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
emitDebugSections(StringRef YAMLString,
bool IsLittleEndian = sys::IsLittleEndianHost);
bool IsLittleEndian = sys::IsLittleEndianHost,
bool Is64BitAddrSize = true);
} // end namespace DWARFYAML
} // end namespace llvm

View File

@ -945,7 +945,8 @@ emitDebugSectionImpl(const DWARFYAML::Data &DI, StringRef Sec,
}
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
DWARFYAML::emitDebugSections(StringRef YAMLString, bool IsLittleEndian) {
DWARFYAML::emitDebugSections(StringRef YAMLString, bool IsLittleEndian,
bool Is64BitAddrSize) {
auto CollectDiagnostic = [](const SMDiagnostic &Diag, void *DiagContext) {
*static_cast<SMDiagnostic *>(DiagContext) = Diag;
};
@ -956,6 +957,8 @@ DWARFYAML::emitDebugSections(StringRef YAMLString, bool IsLittleEndian) {
DWARFYAML::Data DI;
DI.IsLittleEndian = IsLittleEndian;
DI.Is64BitAddrSize = Is64BitAddrSize;
YIn >> DI;
if (YIn.error())
return createStringError(YIn.error(), GeneratedDiag.getMessage());

View File

@ -65,7 +65,8 @@ TEST(DWARFDie, getLocations) {
)";
Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
DWARFYAML::emitDebugSections(StringRef(yamldata),
/*IsLittleEndian=*/true);
/*IsLittleEndian=*/true,
/*Is64BitAddrSize=*/false);
ASSERT_THAT_EXPECTED(Sections, Succeeded());
std::unique_ptr<DWARFContext> Ctx =
DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);