-
Notifications
You must be signed in to change notification settings - Fork 4
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
llcppcfg: sort includes #121
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #121 +/- ##
=======================================
Coverage 98.01% 98.01%
=======================================
Files 15 15
Lines 1864 1864
=======================================
Hits 1827 1827
Misses 26 26
Partials 11 11 ☔ View full report in Codecov by Sentry. |
629022a
to
4371d4a
Compare
1eb4b47
to
4b1e1bc
Compare
cmd/llcppcfg/llcppgcfg/cfg.go
Outdated
sort.Slice(cflagEntry.ObjFiles, func(i, j int) bool { | ||
return len(cflagEntry.ObjFiles[i].Deps) > len(cflagEntry.ObjFiles[j].Deps) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个实现看起来是通过头文件的依赖数量来决定其生成的include顺序,按照依赖数量排序,并不能反映适合的文件处理顺序。
考虑以下场景
main.h
#include "common_type.h"
#include a.h
common_type.h
typedef struct Foo {
int a;
} Foo;
a.h
#include "a_common.h"
#include "a_type.h"
#include "a_compact.h"
Foo *fn();
按照这个由 头文件的依赖数量 的逻辑来输出的include顺序会是 a.h
(3) , main.h
(2), common_type.h
(0),但这个处理顺序一定是非预期的 ,a.h 这里使用Foo时,还没定义Foo类型。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无论怎么处理,都必须要有这个,同级头文件,根据什么来判断?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无论怎么处理,都必须要有这个,同级头文件,根据什么来判断?
-
同级别的头文件通过其引用include关系来处理其顺序。
-
当前根据依赖数量的逻辑来给出include处理顺序并不合适,该逻辑对于我上面提出的用例已经不能正确表达了。
354d76f
to
81a0e1a
Compare
5d6c99d
to
6c6d1f5
Compare
No description provided.