Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dr. Michael Petter
LLVM-abstractinterpretation
Commits
daa80424
Commit
daa80424
authored
Nov 12, 2021
by
Administrator
Browse files
added starter c++ sample and toolchain
parent
9fe2f614
Changes
2
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
daa80424
...
...
@@ -271,10 +271,13 @@ set(SAMPLES
while-bigger-steps
while-neg
example-1
A
B
C
D
# A
# B
# C
# D
)
set
(
CPPSAMPLES
classes
)
# Older CMake version do not support list transformations
...
...
@@ -297,11 +300,17 @@ list_transform_append(SAMPLES ".bc" SAMPLES_BC)
list_transform_append
(
SAMPLES
".ll"
SAMPLES_LL
)
list_transform_prepend
(
SAMPLES_LL
"
${
CMAKE_SOURCE_DIR
}
/output/"
)
list_transform_prepend
(
SAMPLES_BC
"
${
CMAKE_SOURCE_DIR
}
/output/"
)
list_transform_prepend
(
SAMOLES_C
"
${
CMAKE_SOURCE_DIR
}
/samples/"
)
list_transform_prepend
(
SAMPLES_C
"
${
CMAKE_SOURCE_DIR
}
/samples/"
)
list_transform_append
(
CPPSAMPLES
".cpp"
CPPSAMPLES_CPP
)
list_transform_append
(
CPPSAMPLES
".bc"
CPPSAMPLES_BC
)
list_transform_append
(
CPPSAMPLES
".ll"
CPPSAMPLES_LL
)
list_transform_prepend
(
CPPSAMPLES_LL
"
${
CMAKE_SOURCE_DIR
}
/output/"
)
list_transform_prepend
(
CPPSAMPLES_BC
"
${
CMAKE_SOURCE_DIR
}
/output/"
)
list_transform_prepend
(
CPPSAMPLES_CPP
"
${
CMAKE_SOURCE_DIR
}
/samples/"
)
add_custom_target
(
irgen
DEPENDS
${
SAMPLES_LL
}
${
SAMPLES_BC
}
)
DEPENDS
${
SAMPLES_LL
}
${
SAMPLES_BC
}
${
CPPSAMPLES_LL
}
${
CPPSAMPLES_BC
}
)
file
(
MAKE_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/output
)
...
...
@@ -313,7 +322,17 @@ foreach(src ${SAMPLES})
COMMAND clang --sysroot
${
CMAKE_OSX_SYSROOT
}
-O0 -emit-llvm
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.c -Xclang -disable-O0-optnone -c -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc
COMMAND opt -S -mem2reg
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
DEPENDS clang opt
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.c
COMMENT
"Generating LLVM IR for example
${
src
}
"
COMMENT
"Generating LLVM IR for example
${
src
}
.c"
)
endforeach
(
src
)
foreach
(
src
${
CPPSAMPLES
}
)
add_custom_command
(
OUTPUT
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
COMMAND clang++ --sysroot
${
CMAKE_OSX_SYSROOT
}
-O0 -emit-llvm
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.cpp -Xclang -disable-O0-optnone -c -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc
COMMAND opt -S -mem2reg
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
DEPENDS clang opt
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.cpp
COMMENT
"Generating LLVM IR for example
${
src
}
.cpp"
)
endforeach
(
src
)
...
...
@@ -325,10 +344,21 @@ foreach(src ${SAMPLES})
COMMAND clang -O0 -emit-llvm
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.c -Xclang -disable-O0-optnone -c -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc
COMMAND opt -S -mem2reg
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
DEPENDS clang opt
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.c
COMMENT
"Generating LLVM IR for example
${
src
}
"
COMMENT
"Generating LLVM IR for example
${
src
}
.c
"
)
endforeach
(
src
)
foreach
(
src
${
CPPSAMPLES
}
)
add_custom_command
(
OUTPUT
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
COMMAND clang++ -O0 -emit-llvm
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.cpp -Xclang -disable-O0-optnone -c -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc
COMMAND opt -S -mem2reg
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.bc -o
${
CMAKE_SOURCE_DIR
}
/output/
${
src
}
.ll
DEPENDS clang opt
${
CMAKE_SOURCE_DIR
}
/samples/
${
src
}
.cpp
COMMENT
"Generating LLVM IR for example
${
src
}
.cpp"
)
endforeach
(
src
)
endif
()
configure_file
(
.lldbinit.in .lldbinit
)
\ No newline at end of file
samples/classes.cpp
0 → 100644
View file @
daa80424
class
A
{
public:
int
a
;
virtual
int
f
(){
return
0
;
};
virtual
int
g
(){
return
0
;
};
};
class
B
:
public
A
{
public:
int
b
;
virtual
int
f
()
{
return
42
;
};
};
class
D
:
public
A
{
public:
int
d
;
virtual
int
g
(){
return
4711
;
};
};
class
C
:
public
B
,
public
D
{
public:
int
c
;
};
int
main
(
void
)
{
int
res
=
0
;
A
*
a
;
if
(
a
==
0
)
a
=
new
A
();
else
a
=
new
B
();
res
+=
a
->
f
();
a
=
dynamic_cast
<
D
*>
(
new
C
());
res
+=
a
->
g
();
return
res
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment