[lldb] Make sure import-std-module/sysroot actually passes for the right reasons

This test was previously passing because myabs was actually emitted into the
debug information and we called that. The test itself was broken as it didn't
use the libc++ directory structure (the /v1/ directory was just called /include/).

This patch gives myabs a default argument which we can't get from debug information
and inlines the function to make sure we can't call it from LLDB without loading
the C++ module.

llvm-svn: 374335
This commit is contained in:
Raphael Isemann 2019-10-10 12:57:14 +00:00
parent 3370d4d2b7
commit f5b2b76008
6 changed files with 16 additions and 9 deletions

View File

@ -3,7 +3,7 @@
# system headers.
NO_TEST_COMMON_H := 1
CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/include/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/v1/ -I $(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
CXX_SOURCES := main.cpp
include Makefile.rules

View File

@ -27,4 +27,6 @@ class ImportStdModule(TestBase):
# Call our custom function in our sysroot std module.
# If this gives us the correct result, then we used the sysroot.
self.expect("expr std::myabs(-42)", substrs=['(int) $0 = 42'])
# We rely on the default argument of -123 to make sure we actually have the C++ module.
# (We don't have default arguments in the debug information).
self.expect("expr std::myabs()", substrs=['(int) $0 = 123'])

View File

@ -2,5 +2,6 @@
int main(int argc, char **argv) {
libc_struct s;
std::vector v;
return 0; // Set break point at this line.
}

View File

@ -1,7 +0,0 @@
#include "libc_header.h"
namespace std {
int myabs(int i) {
return i < 0 ? -i : i;
}
}

View File

@ -0,0 +1,11 @@
#include "libc_header.h"
namespace std {
// Makes sure we get a support file for this header.
struct vector { int i; };
inline int myabs(int i = -123) {
double nil;
return i < 0 ? -i : i;
}
}