Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 5cd00d1

Browse files
author
George Rimar
committed
[LLVMDebugInfoPDB] - Use cantFail() instead of assert().
Currently injected-sources-native.test fails with "Expected<T> value was in success state. (Note: Expected<T> values in success mode must still be checked prior to being destroyed)" when llvm is compiled with LLVM_ENABLE_ABI_BREAKING_CHECKS in Release. The problem is that getStringForID returns Expected<StringRef> and Expected value must always be checked, even if it is in success state. Checking with assert only helps in Debug and is wrong. Differential revision: https://reviews.llvm.org/D69251 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375492 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d35e5f8 commit 5cd00d1

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Diff for: lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,31 @@ class NativeInjectedSource final : public IPDBInjectedSource {
4646
uint64_t getCodeByteSize() const override { return Entry.FileSize; }
4747

4848
std::string getFileName() const override {
49-
auto Name = Strings.getStringForID(Entry.FileNI);
50-
assert(Name && "InjectedSourceStream should have rejected this");
51-
return *Name;
49+
StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI),
50+
"InjectedSourceStream should have rejected this");
51+
return Ret;
5252
}
5353

5454
std::string getObjectFileName() const override {
55-
auto ObjName = Strings.getStringForID(Entry.ObjNI);
56-
assert(ObjName && "InjectedSourceStream should have rejected this");
57-
return *ObjName;
55+
StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI),
56+
"InjectedSourceStream should have rejected this");
57+
return Ret;
5858
}
5959

6060
std::string getVirtualFileName() const override {
61-
auto VName = Strings.getStringForID(Entry.VFileNI);
62-
assert(VName && "InjectedSourceStream should have rejected this");
63-
return *VName;
61+
StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI),
62+
"InjectedSourceStream should have rejected this");
63+
return Ret;
6464
}
6565

6666
uint32_t getCompression() const override { return Entry.Compression; }
6767

6868
std::string getCode() const override {
6969
// Get name of stream storing the data.
70-
auto VName = Strings.getStringForID(Entry.VFileNI);
71-
assert(VName && "InjectedSourceStream should have rejected this");
72-
std::string StreamName = ("/src/files/" + *VName).str();
70+
StringRef VName =
71+
cantFail(Strings.getStringForID(Entry.VFileNI),
72+
"InjectedSourceStream should have rejected this");
73+
std::string StreamName = ("/src/files/" + VName).str();
7374

7475
// Find stream with that name and read its data.
7576
// FIXME: Consider validating (or even loading) all this in

0 commit comments

Comments
 (0)