-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix symbol visibility issues for C API #440
base: main
Are you sure you want to change the base?
Conversation
clang-tidy review says "All clean, LGTM! 👍" |
@Gnimuc Your PR which added the cpi was largely untested (see #438 (comment)). Would you mind putting in a PR which tests your C API so can get our total test coverage back up? |
Half of the untested lines are copied from libclang: Since those C interfaces are just thin wrappers, I think a more practical way to improve the coverage of the project is adding |
@vgvassilev What do you think of @Gnimuc suggestion? |
I don't have a strong opinion. Generally it is good to have tests especially for the things that are not in libclang. |
@Gnimuc I gave it some thought and think it would still be better to have the tests. Hopefully given they are just thin wrappers then I believe it shouldn't be too much to get tests written with them too. Then we can guarantee everything is working as expected. |
1b511ce
to
2b203c4
Compare
clang-tidy review says "All clean, LGTM! 👍" |
2b203c4
to
0db7431
Compare
@vgvassilev Is it OK to turn off warning C4273 as error? |
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.
Lgtm modulo the comment.
Do we understand why the warning fires and why it is not relevant? |
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.
clang-tidy made some suggestions
lib/Interpreter/CXCppInterOp.cpp
Outdated
@@ -270,7 +270,8 @@ static inline compat::Interpreter* getInterpreter(const CXInterpreterImpl* I) { | |||
return I->Interp.get(); | |||
} | |||
|
|||
CXInterpreter clang_createInterpreter(const char* const* argv, int argc) { | |||
CINDEX_LINKAGE CXInterpreter clang_createInterpreter(const char* const* argv, |
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.
warning: no header providing "CINDEX_LINKAGE" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang-c/Platform.h>
+ #include <cstring>
lib/Interpreter/CXCppInterOp.cpp
Outdated
return static_cast<CXInterpreterImpl*>(I)->Interp.release(); | ||
} | ||
|
||
enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N) { | ||
CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, |
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.
warning: no header providing "CXErrorCode" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang-c/CXErrorCode.h>
+ #include <cstring>
lib/Interpreter/CXCppInterOp.cpp
Outdated
@@ -584,22 +588,26 @@ | |||
return clang::cxscope::MakeCXScope(D, getNewTU(tmpl)); | |||
} | |||
|
|||
CXObject clang_allocate(unsigned int n) { return ::operator new(n); } | |||
CINDEX_LINKAGE CXObject clang_allocate(unsigned int n) { | |||
return ::operator new(n); |
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.
warning: no header providing "operator new" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <new>
+ #include "clang-c/CXString.h"
lib/Interpreter/CXCppInterOp.cpp
Outdated
|
||
void clang_deallocate(CXObject address) { ::operator delete(address); } | ||
CINDEX_LINKAGE void clang_deallocate(CXObject address) { | ||
::operator delete(address); |
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.
warning: no header providing "operator delete" is directly included [misc-include-cleaner]
::operator delete(address);
^
3d44235
to
d7e0fc7
Compare
clang-tidy review says "All clean, LGTM! 👍" |
It turns out that the |
clang-tidy review says "All clean, LGTM! 👍" |
d09dd1b
to
f2d2dd9
Compare
clang-tidy review says "All clean, LGTM! 👍" |
@@ -133,6 +133,8 @@ else() | |||
LINK_LIBS | |||
${link_libs} | |||
) | |||
|
|||
target_compile_definitions(clangCppInterOp PUBLIC "_CINDEX_LIB_") # workaround for the use of `CINDEX_LINKAGE` |
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.
How about using CLANG_ABI
from clang/Support/Compiler.h
?
Add the missing
CINDEX_LINKAGE
macros for C APIs