Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ SpacesBeforeTrailingComments: 2
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
AlignOperands: Align
BreakBeforeBinaryOperators: All
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ build/
.html/
.latex/

out/
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Ensure only standard C++ features

# TODO: Maybe get rid of? Don't remember why its here and I think libhal's cmake utils handles this
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# add_custom_target(copy_compile_commands ALL
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_BINARY_DIR}/compile_commands.json
# ${CMAKE_SOURCE_DIR}/compile_commands.json
# DEPENDS ${CMAKE_BINARY_DIR}/compile_commands.json)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(ctre REQUIRED)



# Find package dependancies
#TODO: Remove due to this being a temporary patch for libraries to work
Expand All @@ -26,6 +24,11 @@ target_link_libraries(${PROJECT_NAME} libelf::libelf)

#Linking Libraries
target_link_libraries(${PROJECT_NAME} libelf::libelf)
add_executable(${PROJECT_NAME} src/main.cpp src/gcc_parse.cpp)

# Add include directories
target_include_directories(${PROJECT_NAME} PUBLIC include/)
target_link_libraries(${PROJECT_NAME} PUBLIC ctre::ctre)

# Add compile options
list(APPEND COMPILER_BUILD_FLAGS
Expand Down
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def requirements(self):
self.requires("libelf/0.8.13")

self.requires("tl-function-ref/1.0.0")
self.requires("ctre/[^3.9.0]")

def generate(self):
c = CMake(self)
Expand Down
129 changes: 129 additions & 0 deletions demo_class.wpa.081i.whole-program
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@

Marking local functions: method/0


Marking externally visible functions: main/6 foo/2 bar/1


Marking externally visible variables:


Reclaiming functions:
Reclaiming variables:
Clearing address taken flags:
Symbol table:

__builtin_eh_pointer/10 (__builtin_eh_pointer)
Type: function
Visibility: semantic_interposition external public visibility_specified artificial
References:
Referring:
Availability: not_available
Unit id: 1
Function flags:
Called by: main/6
Calls:
__cxa_begin_catch/11 (__cxa_begin_catch)
Type: function
Visibility: semantic_interposition external public visibility_specified artificial
References:
Referring:
Availability: not_available
Unit id: 1
Function flags:
Called by: main/6
Calls:
__cxa_end_catch/12 (__cxa_end_catch)
Type: function
Visibility: semantic_interposition external public visibility_specified artificial
References:
Referring:
Availability: not_available
Unit id: 1
Function flags:
Called by: main/6
Calls:
__cxa_allocate_exception/7 (__cxa_allocate_exception)
Type: function
Visibility: semantic_interposition external public visibility_specified artificial
References:
Referring:
Availability: not_available
Unit id: 1
Function flags: decl_is_malloc
Called by: _Z3barv/1
Calls:
__cxa_throw/8 (__cxa_throw)
Type: function
Visibility: semantic_interposition external public visibility_specified artificial
References:
Referring:
Availability: not_available
Unit id: 1
Function flags:
Called by: _Z3barv/1 (can throw external)
Calls:
__gxx_personality_v0/13 (__gxx_personality_v0)
Type: function
Visibility: semantic_interposition external public artificial
Address is taken.
References:
Referring: main/6 (addr)
Availability: not_available
Unit id: 1
Function flags:
Called by:
Calls:
main/6 (main)
Type: function definition analyzed
Visibility: force_output externally_visible semantic_interposition no_reorder public
References: __gxx_personality_v0/13 (addr)
Referring:
Read from file: /private/tmp/nix-shell-14976-0/cceFgUpS.o
Availability: available
Unit id: 1
Function flags:
Called by:
Calls: __cxa_end_catch/12 __cxa_begin_catch/11 __builtin_eh_pointer/10 _Z3foov/2 _ZN1A6methodEv/0
_Z3foov/2 (foo)
Type: function definition analyzed
Visibility: force_output externally_visible semantic_interposition no_reorder public
References:
Referring:
Read from file: /private/tmp/nix-shell-14976-0/cceFgUpS.o
Availability: available
Unit id: 1
Function flags:
Called by: main/6
Calls: _Z3barv/1 (can throw external)
_ZTIi/9 (_ZTIi)
Type: variable
Body removed by symtab_remove_unreachable_nodes
Visibility: semantic_interposition external public artificial
References:
Referring: _Z3barv/1 (addr)
Read from file: /private/tmp/nix-shell-14976-0/cceFgUpS.o
Availability: not_available
Varpool flags: read-only
_Z3barv/1 (bar)
Type: function definition analyzed
Visibility: force_output externally_visible semantic_interposition no_reorder public
References: _ZTIi/9 (addr)
Referring:
Read from file: /private/tmp/nix-shell-14976-0/cceFgUpS.o
Availability: available
Unit id: 1
Function flags:
Called by: _Z3foov/2 (can throw external)
Calls: __cxa_throw/8 (can throw external) __cxa_allocate_exception/7
_ZN1A6methodEv/0 (method)
Type: function definition analyzed
Visibility: semantic_interposition no_reorder prevailing_def_ironly
References:
Referring:
Read from file: /private/tmp/nix-shell-14976-0/cceFgUpS.o
Availability: local
Unit id: 1
Function flags: local
Called by: main/6
Calls:
27 changes: 27 additions & 0 deletions include/gcc_parse.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include <algorithm>
#include <cctype>
#include <cstddef>
#include <ctll/fixed_string.hpp>
#include <ctre.hpp>
#include <ctre/wrapper.hpp>
#include <ranges>
#include <string>

namespace rng = std::ranges;
namespace views = rng::views;

using string = std::string;
using std::operator""sv;

struct Node;

void parse(std::string file_path);

constexpr bool is_word_in_str(std::string_view const word,
std::string_view const full_str)
{
constexpr auto pattern = ctll::fixed_string{ "\\n| |\\t" };
return rng::any_of(ctre::split<pattern>(full_str),
[word](auto&& c) { return word == c; });
}
Loading