[Demangle] fix windows tests
My reland of https://reviews.llvm.org/D148546 has caused a few windows demangler tests to fail when run with -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON on windows. I have a sneaking suspicion that MSVC's std::string_view::iterator::operator* may be missing a nullptr check. Link: https://lab.llvm.org/buildbot/#/builders/42/builds/9723/steps/7/logs/stdio Reviewed By: ayzhao Differential Revision: https://reviews.llvm.org/D148852
This commit is contained in:
1 parent
ba38640b99
commit
6bad76c7ae
1 file changed
+5
-2
@@ -793,6 +793,7 @@ SymbolNode *Demangler::demangleMD5Name(std::string_view &MangledName) {
|
||||
return nullptr;
|
||||
}
|
||||
const char *Start = &*MangledName.begin();
|
||||
const size_t StartSize = MangledName.size();
|
||||
MangledName.remove_prefix(MD5Last + 1);
|
||||
|
||||
// There are two additional special cases for MD5 names:
|
||||
@@ -807,7 +808,9 @@ SymbolNode *Demangler::demangleMD5Name(std::string_view &MangledName) {
|
||||
// either.
|
||||
consumeFront(MangledName, "??_R4@");
|
||||
|
||||
std::string_view MD5(Start, &*MangledName.begin() - Start);
|
||||
assert(MangledName.size() < StartSize);
|
||||
const size_t Count = StartSize - MangledName.size();
|
||||
std::string_view MD5(Start, Count);
|
||||
SymbolNode *S = Arena.alloc<SymbolNode>(NodeKind::Md5Symbol);
|
||||
S->Name = synthesizeQualifiedName(Arena, MD5);
|
||||
|
||||
@@ -2402,7 +2405,7 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled,
|
||||
std::string_view Name{MangledName};
|
||||
SymbolNode *AST = D.parse(Name);
|
||||
if (!D.Error && NMangled)
|
||||
*NMangled = &*Name.begin() - MangledName;
|
||||
*NMangled = Name.empty() ? 0 : &*Name.begin() - MangledName;
|
||||
|
||||
if (Flags & MSDF_DumpBackrefs)
|
||||
D.dumpBackReferences();
|
||||
|
||||
Reference in new issue
Block a user