Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin-based ClangAstDumper #154

Open
wants to merge 68 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
be63ae3
Adds deps package for llvm14
joaobispo Feb 17, 2023
ce33270
[ClangAstDumper] Updates LLVM library from 12 to 14
joaobispo Feb 17, 2023
8cbef06
[deps] Updates LLVM libraries in llvm14 package
joaobispo Feb 18, 2023
24d29ad
[ClangASTDumper] Fix breaking changes caused by llvm version bump
lm-sousa Feb 17, 2023
dfbdf9d
[ClangAstDumper] Fixes use of Expected in main.cpp
joaobispo Feb 18, 2023
965f848
[ClangAstDumper] Updates method for generating enums
joaobispo Feb 18, 2023
bf3a881
[ClangAstDumper] Updates (auto-generated) enums
joaobispo Feb 18, 2023
8aa5597
[ClangAstDumper] Adds support for attribute TypeVisibilityAttr
joaobispo Feb 18, 2023
fb1da66
[ClavaAst] Updates several enums
joaobispo Feb 19, 2023
651d16c
[ClavaAst] Adds new nodes
joaobispo Feb 19, 2023
4d41db1
[ClangAstParser] Moves tests that do not pass yet to their own package
joaobispo Feb 19, 2023
6f68a1d
[ClangAstParser] Updates C++ test 'Decl'
joaobispo Feb 19, 2023
3234867
[ClangAstDumper] Fixes dumping of attributes names
joaobispo Feb 19, 2023
0a12a6e
[ClangAstParser] Update related to enums
joaobispo Feb 19, 2023
23d1712
[ClavaAst] Experiment with attribute code generation
joaobispo Feb 19, 2023
fdece3e
[ClavaAst] Renames TypeVisibilityAttr
joaobispo Feb 19, 2023
2043dd8
[ClavaAst] Removes TypeVisibilityAttr_
joaobispo Feb 19, 2023
d139c81
[ClangAstDumper] Removes references to TypeVisibilityAttr
joaobispo Feb 19, 2023
4ba5e2f
[ClangAstParser] Updates web resources for Windows and Ubuntu for v14…
joaobispo Feb 19, 2023
677af51
[ClangAstDumper] Specify clang version
lm-sousa Feb 19, 2023
52117cb
[ClangAstParser] Fixes libcxx web resource for Linux
joaobispo Feb 19, 2023
58c9bd6
[ClangAstParser] Fixes versions of libc and libcxx
joaobispo Feb 19, 2023
2c2a717
[ClangAstParser] Updates builtins web resources
joaobispo Feb 19, 2023
4885b5e
[deps] Updates clang instructions
joaobispo Feb 19, 2023
d8b11ce
[ClangAstParser] Adds omp.h to builtin includes
joaobispo Feb 19, 2023
c056a67
[ClavaWeaver] Update C++ test 'OmpThreadsExplore'
joaobispo Feb 19, 2023
8bf52dc
[ClangAstParser] Updates dumper binary for Linux
joaobispo Feb 19, 2023
c52b58b
[ClangAstParser] Removes commented code
joaobispo Feb 19, 2023
6daf77d
[ClangAstDumper] Downgrades C++ standard from 20 to 17
joaobispo Feb 23, 2023
e1c9bfb
Moved sources to dedicated folder
lm-sousa Mar 28, 2023
302a39c
Modified Cmake to build a plugin
lm-sousa Mar 28, 2023
eff3232
Remove unused code
lm-sousa Mar 28, 2023
5026ced
[ClavaAst] Changes some methods in DeclRefExpr to refer to Decl
joaobispo Apr 6, 2023
b43d36f
Using standard clang binary for compilation
joaobispo Apr 6, 2023
c7b9a88
Refactor CMakeLists.txt
lm-sousa Apr 27, 2024
6788124
Refactor clang_enums code
lm-sousa Apr 30, 2024
20e221a
Removed Clava as a dependency to build the ClangAstDumper
lm-sousa May 1, 2024
7e197f7
Pipe through clang's stderr in case of error
lm-sousa May 2, 2024
d312d83
Added compatibility with clang-15
lm-sousa May 2, 2024
0855121
Refactor the project structure
lm-sousa May 2, 2024
660ed7b
Remove commented code from source files
lm-sousa May 2, 2024
9600dae
Unify build system to auto-generate the enum file on compilation
lm-sousa May 3, 2024
fedf8bf
Remove unecessary Proxy class
lm-sousa Jun 4, 2024
4a6e82c
Fix build process
lm-sousa Jun 4, 2024
3ecc184
Implement preliminary Inter process communication to generate correct…
lm-sousa Jun 4, 2024
7de5437
Include the IncludeDumper in the Plugin execution
lm-sousa Jun 4, 2024
2d64f7d
Code cleanup
lm-sousa Jun 4, 2024
65001bb
Remove old redundant file
lm-sousa Jun 4, 2024
9543717
Update java settings files
lm-sousa Jun 27, 2024
bb273d7
Fix enum extractors for clang-12
lm-sousa Jul 2, 2024
7c537b6
Add plugin support for DumpResources class and command-line arguments.
lm-sousa Jul 2, 2024
31bdd97
Fix bugs in tests
lm-sousa Jul 2, 2024
45f4e5d
Null check bug fix
lm-sousa Jul 2, 2024
90cf58c
Refactor CxxWeaver.java: remove commented-out code
lm-sousa Jul 2, 2024
35b6da2
Partially revert 43a13df13a
lm-sousa Jul 4, 2024
37ec2eb
The most time consuming fix I ever had the displeasure of doing
lm-sousa Jul 4, 2024
9efce41
Fix tests
lm-sousa Jul 8, 2024
340399a
[ClangAstDumper] Update dumper plugin to be compatible with clang-16
lm-sousa Jul 8, 2024
21cf278
Add resilience to plugin build system
lm-sousa Jul 8, 2024
9cd5307
Update java preference files
lm-sousa Jul 8, 2024
8e7d21f
Update plugin api tests
lm-sousa Jul 8, 2024
8fc5fd9
Include plugin binaries for clang 14, 15 and 16
lm-sousa Jul 8, 2024
754827c
Fix tests for clang-16 and ignore build files
lm-sousa Jul 8, 2024
6b14bd4
Remove outdated test
lm-sousa Jul 8, 2024
f63ec86
Update clava-js interim test files
lm-sousa Jul 8, 2024
751fd28
Remove Microsoft-specific code from test
lm-sousa Jul 8, 2024
1f0bbb3
Update Java code to use new plugin-based clang-16 AST dumper on Linux…
lm-sousa Jul 8, 2024
6f6f9e7
Remove old files
lm-sousa Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ RemoteSystemsTempFiles/
# Custom ignores #
##################

.vscode
deps/temp
**/.settings/org.eclipse.buildship.core.prefs

tomJava/
.svn/
sf.eclipse.javacc.prefs
Expand Down
26 changes: 21 additions & 5 deletions AntarexClavaApi/.classpath
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-java"/>
<classpathentry kind="src" path="src-lara"/>
<classpathentry kind="src" path="src-js"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" output="bin/main" path="src-java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src-lara">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src-js">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry combineaccessrules="false" kind="src" path="/LaraUtils"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpecsUtils"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
6 changes: 6 additions & 0 deletions AntarexClavaApi/.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
Expand Down
4 changes: 4 additions & 0 deletions AntarexClavaApi/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.source=17
12 changes: 10 additions & 2 deletions ClangAstDumper/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
.vscode
.cache
build
CMakeFiles/
cmake_install.cmake
CMakeCache.txt
*Plugin.so
Makefile
.vscode
testSources
*.so
*.gch
*.o
*.a

src/ClangEnums/enums_*
java_enums/
151 changes: 50 additions & 101 deletions ClangAstDumper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,111 +1,60 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.14)
project(ClangAstDumper)

#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
#message(STATUS HELLO)
set(CLANG_VERSION 16)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#SET(CMAKE_C_COMPILER "clang")
#SET(CMAKE_CXX_COMPILER "clang++")
SET(CMAKE_C_COMPILER "clang-${CLANG_VERSION}")
SET(CMAKE_CXX_COMPILER "clang++-${CLANG_VERSION}")

# Initialize Deps
include("../deps.cmake")
SET(Clang_DIR "/usr/lib/cmake/clang-${CLANG_VERSION}")
SET(LLVM_DIR "/usr/lib/llvm-${CLANG_VERSION}/lib/cmake/llvm")

# Add Modules
#deps_find_package(llvm3.8 REQUIRED) # LLVM
#deps_find_package(llvm7 REQUIRED) # LLVM
deps_find_package(llvm12 REQUIRED) # LLVM
add_compile_options(-Wsuggest-override)

set(COMMON_CXX_FLAGS "-std=c++14 -O3 -Wall -Wno-unused-function")
#set(COMMON_CXX_FLAGS "-std=c++14 -O3 -Wall -Wno-unused-function -fuse-ld=\"C:/Program Files/LLVM/bin/ld.lld.exe\"")
#-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DVISIT_CHECK

#add_definitions(-DOLD_OUTPUT)

if(SYSTEM_PLATFORM STREQUAL "MacOS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS} -stdlib=libc++")
else()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS}")
endif()


#Enable debug
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")

# For CentOS and macOS
# Set SYSTEM_PLATFORM in deps_config.cmake
if(SYSTEM_PLATFORM STREQUAL "Centos" OR SYSTEM_PLATFORM STREQUAL "MacOS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS")
endif()


OPTION(USE_CLAVA "Uses Clava during compilation")

# Enable Clava
if(USE_CLAVA)
# message(STATUS "Using Clava in this project")
find_package(Clava REQUIRED)
#else()
# message(STATUS "Not using Clava")
endif(USE_CLAVA)
unset(USE_CLAVA CACHE) # So that the value is refreshed
find_package(Clang REQUIRED CONFIG)
include_directories("/usr/lib/clang/${CLANG_VERSION}/include/")
include_directories("/usr/lib/llvm-${CLANG_VERSION}/include/")

file (GLOB ENUM_FILES CONFIGURE_DEPENDS
"src/ClangEnums/enums_*.h"
"src/ClangEnums/enums_*.cpp")

set(SOURCE_FILES
main.cpp
ClangAst.cpp
ClangAstDumper.cpp
ClangAstDumperTypes.cpp
ClangAstDumperStmts.cpp
ClangAstDumperDecls.cpp
ClangAstDumperExtra.cpp
TypeMarker.cpp
ClavaDataDumper.cpp
ClavaDataDumperDecls.cpp
ChildrenVisitorDecls.cpp
ClangNodes.cpp
ClavaDataDumperStmts.cpp
ClavaDataDumperTypes.cpp
ClangAstDumperExprs.cpp
ChildrenVisitorStmts.cpp
ClavaConstants.cpp
ChildrenVisitorTypes.cpp
ClangEnums.cpp
ClangastDumperAttr.cpp
ChildrenVisitorAttrs.cpp
ClavaDataDumperAttrs.cpp
ChildrenVisitorExtras.cpp
ClavaDecl.cpp
enums_Type_h.cpp
enums_OperationKinds_h.cpp
enums_AttrKinds_h.cpp
enums_Specifiers_h.cpp
enums_ExceptionSpecificationType_h.cpp
enums_Linkage_h.cpp
enums_Visibility_h.cpp
enums_TemplateBase_h.cpp
enums_Decl_h.cpp
enums_ExprCXX_h.cpp
enums_TypeTraits_h.cpp
enums_NestedNameSpecifier_h.cpp
enums_DeclCxx_h.cpp
enums_Lambda_h.cpp
enums_TemplateName_h.cpp
enums_Attr_h.cpp
enums_Expr_h.cpp
)

add_executable(ClangAstDumper ${SOURCE_FILES})

# Add includes
target_include_directories(ClangAstDumper
SYSTEM PUBLIC ${DEPS_INCLUDES}
)

# Add enums helper

# Add Libraries
target_link_libraries(ClangAstDumper
${DEPS_LIBRARIES}
)
src/plugin.cpp
src/Clang/ClangAst.cpp
src/Clang/ClangNodes.cpp
src/ClangEnums/ClangEnums.cpp
src/TypeMarker/TypeMarker.cpp
src/Clava/ClavaConstants.cpp
src/Clava/ClavaDecl.cpp
src/ClavaDataDumper/ClavaDataDumper.cpp
src/ClavaDataDumper/ClavaDataDumperAttrs.cpp
src/ClavaDataDumper/ClavaDataDumperDecls.cpp
src/ClavaDataDumper/ClavaDataDumperStmts.cpp
src/ClavaDataDumper/ClavaDataDumperTypes.cpp
src/ChildrenVisitor/ChildrenVisitorAttrs.cpp
src/ChildrenVisitor/ChildrenVisitorDecls.cpp
src/ChildrenVisitor/ChildrenVisitorExtras.cpp
src/ChildrenVisitor/ChildrenVisitorStmts.cpp
src/ChildrenVisitor/ChildrenVisitorTypes.cpp
src/ClangAstDumper/ClangAstDumper.cpp
src/ClangAstDumper/ClangAstDumperAttr.cpp
src/ClangAstDumper/ClangAstDumperDecls.cpp
src/ClangAstDumper/ClangAstDumperExprs.cpp
src/ClangAstDumper/ClangAstDumperExtra.cpp
src/ClangAstDumper/ClangAstDumperStmts.cpp
src/ClangAstDumper/ClangAstDumperTypes.cpp
${ENUM_FILES}
)

add_library(MyPlugin MODULE ${SOURCE_FILES})
target_compile_features(MyPlugin PRIVATE cxx_std_20)


add_custom_target (
clang_enums
COMMAND node --experimental-default-type="module" clang_enums/Main.js ${CLANG_VERSION} src/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_dependencies(MyPlugin clang_enums)
59 changes: 0 additions & 59 deletions ClangAstDumper/ChildrenVisitorAttrs.cpp

This file was deleted.

Loading