This patch fixes LLDB data formatter support for llvm::Expected<T> with the following changes: llvm/utils/lldbDataFormatters.py: Fix ExpectedSynthProvider to handle non-templated storage types (e.g., int, int*). Previously the formatter only worked with templated storage types like std::reference_wrapper<T>. cross-project-tests/lit.cfg.py: Fix get_lldb_version_string() to use locally-built LLDB on non-Darwin platforms instead of system LLDB Fix minimum version from "1900" to "19.0.0" (typo in original code) New test files: Added expected.cpp and expected.test to test the formatter with Expected<int> and Expected<int*>. --------- Co-authored-by: Jeffrey Tan <jeffreytan@fb.com>
37 lines
1011 B
C++
37 lines
1011 B
C++
// Test llvm::Expected<T> data formatters.
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <cstdio>
|
|
|
|
using namespace llvm;
|
|
|
|
int main() {
|
|
// Test primitive type (storage is T directly).
|
|
Expected<int> ExpectedInt = 42;
|
|
(void)static_cast<bool>(ExpectedInt);
|
|
|
|
// Test pointer type (storage is T* directly).
|
|
int x = 10;
|
|
Expected<int *> ExpectedPtr = &x;
|
|
(void)static_cast<bool>(ExpectedPtr);
|
|
|
|
// Test reference type (storage is std::reference_wrapper<T>).
|
|
int y = 100;
|
|
Expected<int &> ExpectedRef = y;
|
|
(void)static_cast<bool>(ExpectedRef);
|
|
|
|
// Test templated type (storage is the template type directly).
|
|
Expected<SmallVector<int, 2>> ExpectedVec = SmallVector<int, 2>{1, 2};
|
|
(void)static_cast<bool>(ExpectedVec);
|
|
|
|
// Test templated reference type (storage is std::reference_wrapper<T>).
|
|
SmallVector<int, 2> vec{3, 4};
|
|
Expected<SmallVector<int, 2> &> ExpectedVecRef = vec;
|
|
(void)static_cast<bool>(ExpectedVecRef);
|
|
|
|
puts("Break here");
|
|
|
|
return 0;
|
|
}
|