summaryrefslogtreecommitdiffstats
path: root/lldb/test/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/namespace')
-rw-r--r--lldb/test/namespace/Makefile125
-rw-r--r--lldb/test/namespace/cmds.txt3
-rw-r--r--lldb/test/namespace/main.cpp69
3 files changed, 197 insertions, 0 deletions
diff --git a/lldb/test/namespace/Makefile b/lldb/test/namespace/Makefile
new file mode 100644
index 00000000000..fb5e33230e9
--- /dev/null
+++ b/lldb/test/namespace/Makefile
@@ -0,0 +1,125 @@
+#----------------------------------------------------------------------
+# Fill in the source files to build
+#----------------------------------------------------------------------
+C_SOURCES :=
+CXX_SOURCES :=main.cpp
+OBJC_SOURCES :=
+OBJCXX_SOURCES :=
+
+# Uncomment line below for debugging shell commands
+# SHELL = /bin/sh -x
+
+#----------------------------------------------------------------------
+# Change any build/tool options needed
+#----------------------------------------------------------------------
+DS := /usr/bin/dsymutil
+DSFLAGS =
+CFLAGS ?=-arch x86_64 -gdwarf-2 -O0
+CPLUSPLUSFLAGS +=$(CFLAGS)
+CPPFLAGS +=$(CFLAGS)
+LD = gcc
+LDFLAGS = $(CFLAGS)
+OBJECTS =
+EXE=a.out
+DSYM=$(EXE).dSYM
+
+#----------------------------------------------------------------------
+# Check if we have any C source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(C_SOURCES))" ""
+ OBJECTS +=$(strip $(C_SOURCES:.c=.o))
+endif
+
+#----------------------------------------------------------------------
+# Check if we have any C++ source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(CXX_SOURCES))" ""
+ OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
+ LD = g++
+endif
+
+#----------------------------------------------------------------------
+# Check if we have any ObjC source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(OBJC_SOURCES))" ""
+ OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
+ LDFLAGS +=-lobjc
+endif
+
+#----------------------------------------------------------------------
+# Check if we have any ObjC++ source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(OBJCXX_SOURCES))" ""
+ OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
+ LD = g++
+ ifeq $(findstring lobjc,$(LDFLAGS)) ""
+ LDFLAGS +=-lobjc
+ endif
+endif
+
+
+#----------------------------------------------------------------------
+# Make the dSYM file from the executable
+#----------------------------------------------------------------------
+$(DSYM) : $(EXE)
+ $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
+
+#----------------------------------------------------------------------
+# Compile the executable from all the objects (default rule) with no
+# dsym file.
+#----------------------------------------------------------------------
+$(EXE) : $(OBJECTS)
+ $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)"
+
+
+#----------------------------------------------------------------------
+# Automatic variables based on items already entered. Below we create
+# an objects lists from the list of sources by replacing all entries
+# that end with .c with .o, and we also create a list of prerequisite
+# files by replacing all .c files with .d.
+#----------------------------------------------------------------------
+PREREQS := $(OBJECTS:.o=.d)
+
+#----------------------------------------------------------------------
+# Rule for Generating Prerequisites Automatically using .d files and
+# the compiler -MM option. The -M option will list all system headers,
+# and the -MM option will list all non-system dependencies.
+#----------------------------------------------------------------------
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.cpp
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.m
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.mm
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+#----------------------------------------------------------------------
+# Include all of the makefiles for each source file so we don't have
+# to manually track all of the prerequisites for each source file.
+#----------------------------------------------------------------------
+sinclude $(PREREQS)
+
+.PHONY: clean
+dsym: $(DSYM)
+all: $(EXE) $(DSYM)
+clean:
+ rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS)
+
+
+
diff --git a/lldb/test/namespace/cmds.txt b/lldb/test/namespace/cmds.txt
new file mode 100644
index 00000000000..76bb1bcba75
--- /dev/null
+++ b/lldb/test/namespace/cmds.txt
@@ -0,0 +1,3 @@
+b main.cpp:54
+c
+var
diff --git a/lldb/test/namespace/main.cpp b/lldb/test/namespace/main.cpp
new file mode 100644
index 00000000000..dda8b93306b
--- /dev/null
+++ b/lldb/test/namespace/main.cpp
@@ -0,0 +1,69 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace {
+ typedef unsigned int uint_t;
+ int i;
+}
+
+namespace A {
+ typedef unsigned int uint_t;
+ namespace B {
+ typedef unsigned int uint_t;
+ int j;
+ int myfunc (int a);
+ int myfunc2(int a)
+ {
+ return a + 2;
+ }
+ float myfunc (float f)
+ {
+ return f - 2.0;
+ }
+ }
+}
+
+namespace Y
+{
+ typedef unsigned int uint_t;
+ using A::B::j;
+ int foo;
+}
+
+using A::B::j; // using declaration
+
+namespace Foo = A::B; // namespace alias
+
+using Foo::myfunc; // using declaration
+
+using namespace Foo; // using directive
+
+namespace A {
+ namespace B {
+ using namespace Y;
+ int k;
+ }
+}
+
+int Foo::myfunc(int a)
+{
+ ::uint_t anon_uint = 0;
+ A::uint_t a_uint = 1;
+ B::uint_t b_uint = 2;
+ Y::uint_t y_uint = 3;
+ i = 3;
+ j = 4;
+ return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint;
+}
+
+int
+main (int argc, char const *argv[])
+{
+ return Foo::myfunc(12);
+}
OpenPOWER on IntegriCloud