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

llcppg:refactor by preprocess #164

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

luoliwoshang
Copy link
Contributor

@luoliwoshang luoliwoshang commented Feb 6, 2025

clang -E -nobuiltininc keep same search path in libclang & clang

ensuring:
1.Correct type dependency relationships
2.Declaration nodes in proper file locations

  • libxml2
  • libxslt
  • raylib
  • sqlite
  • zlib
  • lua
  • gpgerror
  • gmp
  • gettext
  • cjson
  • z3

solutions

  1. Combine all the header files declared in the configuration files into a single header file, and use clang -E with the corresponding cflags to preprocess and obtain the preprocessed file.
  2. Process the preprocessed nodes using libclang.

question

  1. The file path parsed by libclang is inconsistent with the header files used by clang -E
  • By setting -resource-dir, ensure that both libclang and clang use the same directory during parsing.
  1. libclang 的 clang_Location_isInSystemHeader api 并不能区分一个安装在/usr/include/sqlite.h 和 /usr/include/stdio.h 是标准库还是三方库
  • 预期通过clang引用所有标准头文件去动态维护系统头文件表

refine

  • avoid recollect node by combine file
    even like havent macro define avoid reinclude
#include "impl.h"
typedef struct foo foo;
struct bar {
    foo *a;
};

impl.h

struct foo {
    long a;
};

// Forward declaration of sqlite3_file
struct sqlite3_file;
#endif

@luoliwoshang luoliwoshang marked this pull request as draft February 6, 2025 09:54
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 70.55215% with 48 lines in your changes missing coverage. Please review.

Project coverage is 96.03%. Comparing base (dec9001) to head (3ce4540).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
cmd/gogensig/convert/convert.go 76.22% 22 Missing and 7 partials ⚠️
cmd/gogensig/unmarshal/unmarshal.go 64.00% 6 Missing and 3 partials ⚠️
cmd/gogensig/convert/package.go 0.00% 6 Missing ⚠️
cmd/gogensig/config/conf.go 60.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
- Coverage   98.41%   96.03%   -2.39%     
==========================================
  Files          17       17              
  Lines        2337     2494     +157     
==========================================
+ Hits         2300     2395      +95     
- Misses         26       74      +48     
- Partials       11       25      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@luoliwoshang luoliwoshang force-pushed the clang/preprocess branch 14 times, most recently from 8f1c8cd to d7bbf5f Compare February 13, 2025 09:58
@luoliwoshang luoliwoshang changed the title llcppg:order type init by clang -E llcppg:refactor by preprocess Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant