-
Notifications
You must be signed in to change notification settings - Fork 36
Add a libclang-style C API #337
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #337 +/- ##
==========================================
- Coverage 76.15% 70.56% -5.59%
==========================================
Files 8 9 +1
Lines 3137 3496 +359
==========================================
+ Hits 2389 2467 +78
- Misses 748 1029 +281
... and 2 files with indirect coverage changes
|
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
There were too many comments to post at once. Showing the first 10 out of 41. Check the log or trigger a new build to see 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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 10 out of 24. Check the log or trigger a new build to see more.
| static inline bool isNull(const CXScope& S) { return !S.data[0]; } | ||
|
|
||
| static inline clang::Decl* getDecl(const CXScope& S) { | ||
| return const_cast<clang::Decl*>(static_cast<const clang::Decl*>(S.data[0])); |
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: do not use const_cast [cppcoreguidelines-pro-type-const-cast]
return const_cast<clang::Decl*>(static_cast<const clang::Decl*>(S.data[0]));
^
lib/Interpreter/CXCppInterOp.cpp
Outdated
| auto* I = getInterpreter(scope); | ||
| if (const Cpp::JitCall JC = Cpp::MakeFunctionCallableImpl(I, getDecl(Ctor))) { | ||
| if (arena) { | ||
| JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new. |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new.
^
lib/Interpreter/CXCppInterOp.cpp
Outdated
| auto* I = getInterpreter(scope); | ||
| if (const Cpp::JitCall JC = Cpp::MakeFunctionCallableImpl(I, getDecl(Ctor))) { | ||
| if (arena) { | ||
| JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new. |
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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new.
^
vgvassilev
left a comment
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.
Looks like we are quite close. Can we silence the codecov somehow without duplicating tests? Can we move the refactorings in CppInterOp.cpp as a separate PR?
include/clang-c/CXCppInterOp.h
Outdated
| * | ||
| * \param prepend Whether to prepend the directory to the search path. | ||
| */ | ||
| void clang_interpreter_addSearchPath(CXInterpreter I, const char* dir, |
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.
Do we want to shorten these interfaces. Maybe Cpp_AddSearchPath?
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.
Since we only expose opaque pointers in the C API, I believe libclang uses this naming style to warn users about the type of the input argument. However, for historical reasons, libclang appears to lack strict rules on capitalization.
The naming convention is like clang_ + ClassName + methodName or clang_ + functionName.
Here are some examples:
typedef void *CXIndexAction;
CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
CINDEX_LINKAGE CXIdxClientContainer
clang_index_getClientContainer(const CXIdxContainerInfo *);
CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
CINDEX_LINKAGE unsigned
clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property);
CINDEX_LINKAGE void
clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
enum CXPrintingPolicyProperty Property,
unsigned Value);
CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor, CXPrintingPolicy Policy);
| /// This is similar to GetName() function, but besides | ||
| /// the name, it also gets the template arguments. | ||
| CPPINTEROP_API std::string GetCompleteName(TCppType_t klass); | ||
| CPPINTEROP_API std::string GetCompleteName(TCppScope_t klass); |
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.
Thanks! We should probably adopt the CX enum style so that the compiler could help us with finding these wrong cases. Related to compiler-research/CPyCppyy#8.
Yes. I'll make another PR for the changes in |
66ccc69 to
1bb9ead
Compare
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
There were too many comments to post at once. Showing the first 10 out of 12. Check the log or trigger a new build to see more.
| EXPECT_FALSE(Cpp::GetNamed("cppUnknown")); | ||
|
|
||
| // C API | ||
| const char* args[] = {"-std=c++14"}; |
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: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]
const char* args[] = {"-std=c++14"};
^|
|
||
| // C API | ||
| const char* args[] = {"-std=c++14"}; | ||
| auto CXI = clang_createInterpreter(args, 1); |
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: 'auto CXI' can be declared as 'auto *CXI' [llvm-qualified-auto]
| auto CXI = clang_createInterpreter(args, 1); | |
| auto *CXI = clang_createInterpreter(args, 1); |
|
|
||
| // C API | ||
| const char* args[] = {"-std=c++14"}; | ||
| auto CXI = clang_createInterpreter(args, 1); |
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: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
auto CXI = clang_createInterpreter(args, 1);
^| clang_Interpreter_dispose(CXI); | ||
|
|
||
| CXI = clang_createInterpreterFromRawPtr(I); | ||
| auto CLI = clang_Interpreter_getClangInterpreter(CXI); |
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: 'auto CLI' can be declared as 'auto *CLI' [llvm-qualified-auto]
| auto CLI = clang_Interpreter_getClangInterpreter(CXI); | |
| auto *CLI = clang_Interpreter_getClangInterpreter(CXI); |
| CXI = clang_createInterpreterFromRawPtr(I); | ||
| auto CLI = clang_Interpreter_getClangInterpreter(CXI); | ||
| EXPECT_TRUE(CLI); | ||
| auto I2 = clang_Interpreter_takeInterpreterAsPtr(CXI); |
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: 'auto I2' can be declared as 'auto *I2' [llvm-qualified-auto]
| auto I2 = clang_Interpreter_takeInterpreterAsPtr(CXI); | |
| auto *I2 = clang_Interpreter_takeInterpreterAsPtr(CXI); |
|
|
||
| void dispose_string(CXString string) { | ||
| if (string.private_flags == 1 && string.data) | ||
| free(const_cast<void*>(string.data)); |
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: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]
free(const_cast<void*>(string.data));
^|
|
||
| void dispose_string(CXString string) { | ||
| if (string.private_flags == 1 && string.data) | ||
| free(const_cast<void*>(string.data)); |
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: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc]
free(const_cast<void*>(string.data));
^|
|
||
| void dispose_string(CXString string) { | ||
| if (string.private_flags == 1 && string.data) | ||
| free(const_cast<void*>(string.data)); |
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: do not use const_cast [cppcoreguidelines-pro-type-const-cast]
free(const_cast<void*>(string.data));
^| free(const_cast<void*>(string.data)); | ||
| } | ||
|
|
||
| CXScope make_scope(const clang::Decl* D, const 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: 'I' declared with a const-qualified typedef; results in the type being 'CXInterpreterImpl *const' instead of 'const CXInterpreterImpl *' [misc-misplaced-const]
CXScope make_scope(const clang::Decl* D, const CXInterpreter I) {
^Additional context
include/clang-c/CXCppInterOp.h:25: typedef declared here
typedef struct CXInterpreterImpl* CXInterpreter;
^| #include <vector> | ||
| #include "llvm/Support/Valgrind.h" | ||
| #include "clang-c/CXCppInterOp.h" | ||
| #include "clang-c/CXString.h" |
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: #includes are not sorted properly [llvm-include-order]
| #include "clang-c/CXString.h" | |
| #include "clang-c/CXCppInterOp.h" | |
| #include "clang-c/CXString.h" | |
| #include "llvm/Support/Valgrind.h" | |
| #include <memory> | |
| #include <vector> |
1bb9ead to
bc67a64
Compare
| if (!clang_hasDefaultConstructor(S)) | ||
| return clang::cxscope::MakeCXScope(nullptr, getNewTU(S)); | ||
|
|
||
| auto* CXXRD = llvm::dyn_cast_or_null<clang::CXXRecordDecl>(getDecl(S)); | ||
| if (!CXXRD) | ||
| return clang::cxscope::MakeCXScope(nullptr, getNewTU(S)); | ||
|
|
||
| const auto* Res = | ||
| getInterpreter(S)->getSema().LookupDefaultConstructor(CXXRD); | ||
| return clang::cxscope::MakeCXScope(Res, getNewTU(S)); |
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.
Why can't we forward to Cpp::GetDefaultConstructor? I see this trend in several interfaces. Is there some limitation on the C++ side?
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 are no particular reasons. I forwarded this one to the C++ API. As for other interpreter-related APIs, the C++ implementation is also a thin wrapper, so I copied the implementation on the C API side.
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
|
|
||
| void dispose_string(CXString string); | ||
|
|
||
| CXScope make_scope(const clang::Decl* D, const 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: 'I' declared with a const-qualified typedef; results in the type being 'CXInterpreterImpl *const' instead of 'const CXInterpreterImpl *' [misc-misplaced-const]
CXScope make_scope(const clang::Decl* D, const CXInterpreter I);
^Additional context
include/clang-c/CXCppInterOp.h:25: typedef declared here
typedef struct CXInterpreterImpl* CXInterpreter;
^|
|
||
| void dispose_string(CXString string); | ||
|
|
||
| CXScope make_scope(const clang::Decl* D, const 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: parameter 'I' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
| CXScope make_scope(const clang::Decl* D, const CXInterpreter I); | |
| CXScope make_scope(const clang::Decl* D, CXInterpreter I); |
bc67a64 to
573a6a8
Compare
|
Do we know why some builds are failing? |
7be80d8 to
651ce67
Compare
| if (!D) | ||
| return CXCursor_UnexposedDecl; | ||
|
|
||
| switch (D->getKind()) { |
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.
We can use the preprocessor to expand it but I think we could steal the implementation from clang::ASTNodeKind or just forward to it...
| #define BTCASE(K) \ | ||
| case BuiltinType::K: \ | ||
| return CXType_##K | ||
| switch (BT->getKind()) { |
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.
Can't we use something like:
define BUILTIN_TYPE(Id, SingletonId) \
case BuiltinType::Id: return ...
#include "clang/AST/BuiltinTypes.def"
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.
These are copied from libclang's source code. Since we will make the merge in the upstream in the future, it would be better to submit PRs to the upstream directly.
| case Type::K: \ | ||
| return CXType_##K | ||
| switch (TP->getTypeClass()) { | ||
| case Type::Builtin: |
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.
Likewise.
b13674d to
de15348
Compare
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
There were too many comments to post at once. Showing the first 10 out of 116. Check the log or trigger a new build to see more.
| #include "clang-c/ExternC.h" | ||
| #include "clang-c/Index.h" | ||
| #include "clang-c/Platform.h" | ||
|
|
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: included header Platform.h is not used directly [misc-include-cleaner]
| #include "clang-c/Index.h" | ||
| #include "clang-c/Platform.h" | ||
|
|
||
| #include <stdbool.h> |
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: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
| #include <stdbool.h> |
| #include "clang-c/Platform.h" | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stddef.h> |
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: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead [modernize-deprecated-headers]
| #include <stddef.h> | |
| #include <cstddef> |
|
|
||
| #include <stdbool.h> | ||
| #include <stddef.h> | ||
| #include <stdint.h> |
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: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead [modernize-deprecated-headers]
| #include <stdint.h> | |
| #include <cstdint> |
| /** | ||
| * An opaque pointer representing an interpreter context. | ||
| */ | ||
| typedef struct CXInterpreterImpl* CXInterpreter; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| typedef struct CXInterpreterImpl* CXInterpreter; | |
| using CXInterpreter = struct CXInterpreterImpl *; |
| */ | ||
| CXInterpreter clang_createInterpreter(const char* const* argv, int argc); | ||
|
|
||
| typedef void* TInterp_t; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| typedef void* TInterp_t; | |
| using TInterp_t = void *; |
| * Describes the return result of the different routines that do the incremental | ||
| * compilation. | ||
| */ | ||
| typedef enum { |
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: enum 'CXInterpreter_CompilationResult' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
typedef enum {
^| * More more input is expected. | ||
| */ | ||
| CXInterpreter_MoreInputExpected = 2, | ||
| } CXInterpreter_CompilationResult; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| } CXInterpreter_CompilationResult; | |
| using CXInterpreter_CompilationResult = enum { | |
| /** | |
| * The compilation was successful. | |
| */ | |
| CXInterpreter_Success = 0, | |
| /** | |
| * The compilation failed. | |
| */ | |
| CXInterpreter_Failure = 1, | |
| /** | |
| * More more input is expected. | |
| */ | |
| CXInterpreter_MoreInputExpected = 2, | |
| }; |
| * An opaque pointer representing a lightweight struct that is used for carrying | ||
| * execution results. | ||
| */ | ||
| typedef void* CXValue; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| typedef void* CXValue; | |
| using CXValue = void *; |
| enum CXCursorKind kind; | ||
| int xdata; | ||
| const void* data[3]; | ||
| } CXScope; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| } CXScope; | |
| using CXScope = struct { | |
| enum CXCursorKind kind; | |
| int xdata; | |
| const void* data[3]; | |
| }; |
|
@Gnimuc, any chance to make progress on this pr? |
Sorry for the late response. I'll give it a look this weekend. |
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
There were too many comments to post at once. Showing the first 10 out of 106. Check the log or trigger a new build to see more.
| typedef struct { | ||
| void* Type; | ||
| const char* IntegralValue; | ||
| } CXTemplateArgInfo; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| } CXTemplateArgInfo; | |
| using CXTemplateArgInfo = struct { | |
| void* Type; | |
| const char* IntegralValue; | |
| }; |
| typedef struct { | ||
| enum CXTypeKind kind; | ||
| void* data[2]; | ||
| } CXQualType; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| } CXQualType; | |
| using CXQualType = struct { | |
| enum CXTypeKind kind; | |
| void* data[2]; | |
| }; |
| /** | ||
| * An opaque pointer representing the object of a given type (\c CXScope). | ||
| */ | ||
| typedef void* CXObject; |
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: use 'using' instead of 'typedef' [modernize-use-using]
| typedef void* CXObject; | |
| using CXObject = void *; |
| @@ -0,0 +1,627 @@ | |||
| #include "clang-c/CXCppInterOp.h" | |||
| #include "Compatibility.h" | |||
| #include "clang/AST/CXXInheritance.h" | |||
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: #includes are not sorted properly [llvm-include-order]
#include "clang/AST/CXXInheritance.h"
^this fix will not be applied because it overlaps with another fix
| #include "clang/Frontend/CompilerInstance.h" | ||
| #include "clang/Interpreter/CppInterOp.h" | ||
| #include "clang/Sema/Lookup.h" | ||
| #include "clang/Sema/Sema.h" |
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: included header Lookup.h is not used directly [misc-include-cleaner]
| #include "clang/Sema/Sema.h" | |
| #include "clang/Sema/Sema.h" |
| #include "clang/Sema/Sema.h" | ||
| #include "llvm/ADT/STLExtras.h" | ||
| #include "llvm/ExecutionEngine/Orc/LLJIT.h" | ||
| #include "llvm/Support/Casting.h" |
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: included header LLJIT.h is not used directly [misc-include-cleaner]
| #include "llvm/Support/Casting.h" | |
| #include "llvm/Support/Casting.h" |
| #include "llvm/Support/Casting.h" | ||
| #include <cstring> | ||
| #include <iterator> | ||
| #include "clang-c/CXString.h" |
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: included header iterator is not used directly [misc-include-cleaner]
| #include "clang-c/CXString.h" | |
| #include "clang-c/CXString.h" |
| // copied and tweaked from libclang | ||
| namespace clang { | ||
|
|
||
| CXCursorKind cxcursor_getCursorKindForDecl(const Decl* D) { |
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 "CXCursorKind" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang-c/Index.h>
+ #include <cstring>|
|
||
| CXCursorKind cxcursor_getCursorKindForDecl(const Decl* D) { | ||
| if (!D) | ||
| return CXCursor_UnexposedDecl; |
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 "CXCursor_UnexposedDecl" is directly included [misc-include-cleaner]
return CXCursor_UnexposedDecl;
^|
|
||
| switch (D->getKind()) { | ||
| case Decl::Enum: | ||
| return CXCursor_EnumDecl; |
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 "CXCursor_EnumDecl" is directly included [misc-include-cleaner]
return CXCursor_EnumDecl;
^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
There were too many comments to post at once. Showing the first 10 out of 92. Check the log or trigger a new build to see more.
| case Decl::Enum: | ||
| return CXCursor_EnumDecl; | ||
| case Decl::EnumConstant: | ||
| return CXCursor_EnumConstantDecl; |
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 "CXCursor_EnumConstantDecl" is directly included [misc-include-cleaner]
return CXCursor_EnumConstantDecl;
^| case Decl::EnumConstant: | ||
| return CXCursor_EnumConstantDecl; | ||
| case Decl::Field: | ||
| return CXCursor_FieldDecl; |
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 "CXCursor_FieldDecl" is directly included [misc-include-cleaner]
return CXCursor_FieldDecl;
^| case Decl::Field: | ||
| return CXCursor_FieldDecl; | ||
| case Decl::Function: | ||
| return CXCursor_FunctionDecl; |
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 "CXCursor_FunctionDecl" is directly included [misc-include-cleaner]
return CXCursor_FunctionDecl;
^| case Decl::Function: | ||
| return CXCursor_FunctionDecl; | ||
| case Decl::CXXMethod: | ||
| return CXCursor_CXXMethod; |
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 "CXCursor_CXXMethod" is directly included [misc-include-cleaner]
return CXCursor_CXXMethod;
^| case Decl::CXXMethod: | ||
| return CXCursor_CXXMethod; | ||
| case Decl::CXXConstructor: | ||
| return CXCursor_Constructor; |
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 "CXCursor_Constructor" is directly included [misc-include-cleaner]
return CXCursor_Constructor;
^| case Decl::CXXConstructor: | ||
| return CXCursor_Constructor; | ||
| case Decl::CXXDestructor: | ||
| return CXCursor_Destructor; |
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 "CXCursor_Destructor" is directly included [misc-include-cleaner]
return CXCursor_Destructor;
^| case Decl::CXXDestructor: | ||
| return CXCursor_Destructor; | ||
| case Decl::CXXConversion: | ||
| return CXCursor_ConversionFunction; |
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 "CXCursor_ConversionFunction" is directly included [misc-include-cleaner]
return CXCursor_ConversionFunction;
^| case Decl::CXXConversion: | ||
| return CXCursor_ConversionFunction; | ||
| case Decl::ParmVar: | ||
| return CXCursor_ParmDecl; |
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 "CXCursor_ParmDecl" is directly included [misc-include-cleaner]
return CXCursor_ParmDecl;
^| case Decl::ParmVar: | ||
| return CXCursor_ParmDecl; | ||
| case Decl::Typedef: | ||
| return CXCursor_TypedefDecl; |
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 "CXCursor_TypedefDecl" is directly included [misc-include-cleaner]
return CXCursor_TypedefDecl;
^| case Decl::Typedef: | ||
| return CXCursor_TypedefDecl; | ||
| case Decl::TypeAlias: | ||
| return CXCursor_TypeAliasDecl; |
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 "CXCursor_TypeAliasDecl" is directly included [misc-include-cleaner]
return CXCursor_TypeAliasDecl;
^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
There were too many comments to post at once. Showing the first 10 out of 82. Check the log or trigger a new build to see more.
| case Decl::TypeAlias: | ||
| return CXCursor_TypeAliasDecl; | ||
| case Decl::TypeAliasTemplate: | ||
| return CXCursor_TypeAliasTemplateDecl; |
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 "CXCursor_TypeAliasTemplateDecl" is directly included [misc-include-cleaner]
return CXCursor_TypeAliasTemplateDecl;
^| case Decl::TypeAliasTemplate: | ||
| return CXCursor_TypeAliasTemplateDecl; | ||
| case Decl::Var: | ||
| return CXCursor_VarDecl; |
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 "CXCursor_VarDecl" is directly included [misc-include-cleaner]
return CXCursor_VarDecl;
^| case Decl::Var: | ||
| return CXCursor_VarDecl; | ||
| case Decl::Namespace: | ||
| return CXCursor_Namespace; |
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 "CXCursor_Namespace" is directly included [misc-include-cleaner]
return CXCursor_Namespace;
^| case Decl::Namespace: | ||
| return CXCursor_Namespace; | ||
| case Decl::NamespaceAlias: | ||
| return CXCursor_NamespaceAlias; |
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 "CXCursor_NamespaceAlias" is directly included [misc-include-cleaner]
return CXCursor_NamespaceAlias;
^| case Decl::NamespaceAlias: | ||
| return CXCursor_NamespaceAlias; | ||
| case Decl::TemplateTypeParm: | ||
| return CXCursor_TemplateTypeParameter; |
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 "CXCursor_TemplateTypeParameter" is directly included [misc-include-cleaner]
return CXCursor_TemplateTypeParameter;
^| case Decl::TemplateTypeParm: | ||
| return CXCursor_TemplateTypeParameter; | ||
| case Decl::NonTypeTemplateParm: | ||
| return CXCursor_NonTypeTemplateParameter; |
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 "CXCursor_NonTypeTemplateParameter" is directly included [misc-include-cleaner]
return CXCursor_NonTypeTemplateParameter;
^| case Decl::NonTypeTemplateParm: | ||
| return CXCursor_NonTypeTemplateParameter; | ||
| case Decl::TemplateTemplateParm: | ||
| return CXCursor_TemplateTemplateParameter; |
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 "CXCursor_TemplateTemplateParameter" is directly included [misc-include-cleaner]
return CXCursor_TemplateTemplateParameter;
^| case Decl::TemplateTemplateParm: | ||
| return CXCursor_TemplateTemplateParameter; | ||
| case Decl::FunctionTemplate: | ||
| return CXCursor_FunctionTemplate; |
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 "CXCursor_FunctionTemplate" is directly included [misc-include-cleaner]
return CXCursor_FunctionTemplate;
^| case Decl::FunctionTemplate: | ||
| return CXCursor_FunctionTemplate; | ||
| case Decl::ClassTemplate: | ||
| return CXCursor_ClassTemplate; |
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 "CXCursor_ClassTemplate" is directly included [misc-include-cleaner]
return CXCursor_ClassTemplate;
^| case Decl::ClassTemplate: | ||
| return CXCursor_ClassTemplate; | ||
| case Decl::AccessSpec: | ||
| return CXCursor_CXXAccessSpecifier; |
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 "CXCursor_CXXAccessSpecifier" is directly included [misc-include-cleaner]
return CXCursor_CXXAccessSpecifier;
^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
There were too many comments to post at once. Showing the first 10 out of 68. Check the log or trigger a new build to see more.
| case Decl::AccessSpec: | ||
| return CXCursor_CXXAccessSpecifier; | ||
| case Decl::ClassTemplatePartialSpecialization: | ||
| return CXCursor_ClassTemplatePartialSpecialization; |
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 "CXCursor_ClassTemplatePartialSpecialization" is directly included [misc-include-cleaner]
return CXCursor_ClassTemplatePartialSpecialization;
^| case Decl::ClassTemplatePartialSpecialization: | ||
| return CXCursor_ClassTemplatePartialSpecialization; | ||
| case Decl::UsingDirective: | ||
| return CXCursor_UsingDirective; |
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 "CXCursor_UsingDirective" is directly included [misc-include-cleaner]
return CXCursor_UsingDirective;
^| case Decl::UsingDirective: | ||
| return CXCursor_UsingDirective; | ||
| case Decl::StaticAssert: | ||
| return CXCursor_StaticAssert; |
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 "CXCursor_StaticAssert" is directly included [misc-include-cleaner]
return CXCursor_StaticAssert;
^| case Decl::StaticAssert: | ||
| return CXCursor_StaticAssert; | ||
| case Decl::Friend: | ||
| return CXCursor_FriendDecl; |
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 "CXCursor_FriendDecl" is directly included [misc-include-cleaner]
return CXCursor_FriendDecl;
^| case Decl::Friend: | ||
| return CXCursor_FriendDecl; | ||
| case Decl::TranslationUnit: | ||
| return CXCursor_TranslationUnit; |
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 "CXCursor_TranslationUnit" is directly included [misc-include-cleaner]
return CXCursor_TranslationUnit;
^| case Decl::Using: | ||
| case Decl::UnresolvedUsingValue: | ||
| case Decl::UnresolvedUsingTypename: | ||
| return CXCursor_UsingDeclaration; |
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 "CXCursor_UsingDeclaration" is directly included [misc-include-cleaner]
return CXCursor_UsingDeclaration;
^| return CXCursor_EnumDecl; | ||
|
|
||
| default: | ||
| if (const auto* TD = dyn_cast<TagDecl>(D)) { |
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 "clang::dyn_cast" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang/Basic/LLVM.h>
+ #include <cstring>| default: | ||
| if (const auto* TD = dyn_cast<TagDecl>(D)) { | ||
| switch (TD->getTagKind()) { | ||
| #if CLANG_VERSION_MAJOR >= 18 |
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 "CLANG_VERSION_MAJOR" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang/Basic/Version.h>
+ #include <cstring>| #else | ||
| case TagTypeKind::TTK_Interface: // fall through | ||
| case TagTypeKind::TTK_Struct: | ||
| return CXCursor_StructDecl; |
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 "CXCursor_StructDecl" is directly included [misc-include-cleaner]
return CXCursor_StructDecl;
^| case TagTypeKind::TTK_Struct: | ||
| return CXCursor_StructDecl; | ||
| case TagTypeKind::TTK_Class: | ||
| return CXCursor_ClassDecl; |
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 "CXCursor_ClassDecl" is directly included [misc-include-cleaner]
return CXCursor_ClassDecl;
^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
There were too many comments to post at once. Showing the first 10 out of 60. Check the log or trigger a new build to see more.
| case TagTypeKind::TTK_Class: | ||
| return CXCursor_ClassDecl; | ||
| case TagTypeKind::TTK_Union: | ||
| return CXCursor_UnionDecl; |
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 "CXCursor_UnionDecl" is directly included [misc-include-cleaner]
return CXCursor_UnionDecl;
^| return CXCursor_UnexposedDecl; | ||
| } | ||
|
|
||
| CXTypeKind cxtype_GetBuiltinTypeKind(const BuiltinType* BT) { |
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 "CXTypeKind" is directly included [misc-include-cleaner]
CXTypeKind cxtype_GetBuiltinTypeKind(const BuiltinType* BT) {
^| } | ||
|
|
||
| CXTypeKind cxtype_GetBuiltinTypeKind(const BuiltinType* BT) { | ||
| #define BTCASE(K) \ |
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: function-like macro 'BTCASE' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define BTCASE(K) \
^| BTCASE(UInt128); | ||
| BTCASE(Char_S); | ||
| BTCASE(SChar); | ||
| case BuiltinType::WChar_S: |
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: switch has 2 consecutive identical branches [bugprone-branch-clone]
case BuiltinType::WChar_S:
^Additional context
lib/Interpreter/CXCppInterOp.cpp:140: last of these clones ends here
return CXType_WChar;
^| BTCASE(Char_S); | ||
| BTCASE(SChar); | ||
| case BuiltinType::WChar_S: | ||
| return CXType_WChar; |
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 "CXType_WChar" is directly included [misc-include-cleaner]
return CXType_WChar;
^| BTCASE(Float128); | ||
| BTCASE(NullPtr); | ||
| default: | ||
| return CXType_Unexposed; |
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 "CXType_Unexposed" is directly included [misc-include-cleaner]
return CXType_Unexposed;
^| CXTypeKind cxtype_GetTypeKind(QualType T) { | ||
| const Type* TP = T.getTypePtrOrNull(); | ||
| if (!TP) | ||
| return CXType_Invalid; |
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 "CXType_Invalid" is directly included [misc-include-cleaner]
return CXType_Invalid;
^| if (!TP) | ||
| return CXType_Invalid; | ||
|
|
||
| #define TKCASE(K) \ |
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: function-like macro 'TKCASE' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define TKCASE(K) \
^| return CXType_##K | ||
| switch (TP->getTypeClass()) { | ||
| case Type::Builtin: | ||
| return cxtype_GetBuiltinTypeKind(cast<BuiltinType>(TP)); |
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 "clang::cast" is directly included [misc-include-cleaner]
return cxtype_GetBuiltinTypeKind(cast<BuiltinType>(TP));
^| namespace cxscope { | ||
|
|
||
| CXScope MakeCXScope(const clang::Decl* D, const CXInterpreterImpl* I, | ||
| SourceRange RegionOfInterest = SourceRange(), |
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 "clang::SourceRange" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang/Basic/SourceLocation.h>
+ #include <cstring>
I added The CI only fails on cling now. This is expected because the C API is for working with |
IIUC, @aaronj0, has a patch in that area where we have |
| EXPECT_FALSE(Cpp::GetNamed("cppUnknown")); | ||
|
|
||
| // C API | ||
| auto CXI = clang_createInterpreterFromRawPtr(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.
If this fails with cling we can wrap it with #ifndef USE_CLING
Did you mean |
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
There were too many comments to post at once. Showing the first 10 out of 50. Check the log or trigger a new build to see more.
| CXScope MakeCXScope(const clang::Decl* D, const CXInterpreterImpl* I, | ||
| SourceRange RegionOfInterest = SourceRange(), | ||
| bool FirstInDeclGroup = true) { | ||
| assert(D && I && "Invalid arguments!"); |
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 "assert" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <cassert>
+ #include <cstring>|
|
||
| CXCursorKind K = cxcursor_getCursorKindForDecl(D); | ||
|
|
||
| CXScope S = {K, 0, {D, (void*)(intptr_t)(FirstInDeclGroup ? 1 : 0), 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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
CXScope S = {K, 0, {D, (void*)(intptr_t)(FirstInDeclGroup ? 1 : 0), I}};
^|
|
||
| CXCursorKind K = cxcursor_getCursorKindForDecl(D); | ||
|
|
||
| CXScope S = {K, 0, {D, (void*)(intptr_t)(FirstInDeclGroup ? 1 : 0), 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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
CXScope S = {K, 0, {D, (void*)(intptr_t)(FirstInDeclGroup ? 1 : 0), I}};
^|
|
||
| CXCursorKind K = cxcursor_getCursorKindForDecl(D); | ||
|
|
||
| CXScope S = {K, 0, {D, (void*)(intptr_t)(FirstInDeclGroup ? 1 : 0), 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 "intptr_t" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <cstdint>
+ #include <cstring>|
|
||
| } // namespace clang | ||
|
|
||
| CXString makeCXString(const std::string& S) { |
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 "std::string" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <string>
+ #include "clang-c/CXString.h"| Str.data = ""; | ||
| Str.private_flags = 0; // CXS_Unmanaged | ||
| } else { | ||
| Str.data = strdup(S.c_str()); |
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 "strdup" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <string.h>
+ #include "clang-c/CXString.h"| return Str; | ||
| } | ||
|
|
||
| CXStringSet* makeCXStringSet(const std::vector<std::string>& Strs) { |
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 "std::vector" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <vector>
+ #include "clang-c/CXString.h"| } | ||
|
|
||
| struct CXInterpreterImpl { | ||
| std::unique_ptr<compat::Interpreter> Interp; |
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 "std::unique_ptr" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <memory>
+ #include "clang-c/CXString.h"|
|
||
| CXInterpreter clang_createInterpreter(const char* const* argv, int argc) { | ||
| auto* I = new CXInterpreterImpl(); // NOLINT(*-owning-memory) | ||
| I->Interp = std::make_unique<compat::Interpreter>(argc, 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 "std::make_unique" is directly included [misc-include-cleaner]
I->Interp = std::make_unique<compat::Interpreter>(argc, argv);
^| return nullptr; | ||
| #else | ||
| auto* interp = getInterpreter(I); | ||
| auto* clInterp = &static_cast<clang::Interpreter&>(*interp); |
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 "clang::Interpreter" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang/Interpreter/Interpreter.h>
+ #include <cstring>
vgvassilev
left a comment
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!
- Add `CXScope` and `CXQualType` as a bridge between libclang types and CppInterOp's types - Add C API for interpreter and scope manipulations
cf91bf3 to
bc07bb0
Compare
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
There were too many comments to post at once. Showing the first 10 out of 40. Check the log or trigger a new build to see more.
| return static_cast<CXInterpreterImpl*>(I)->Interp.release(); | ||
| } | ||
|
|
||
| enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int 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 "CXErrorCode" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang-c/CXErrorCode.h>
+ #include <cstring>| #ifdef USE_CLING | ||
| return CXError_Failure; | ||
| #else | ||
| return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success; |
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 "CXError_Failure" is directly included [misc-include-cleaner]
return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success;
^| #ifdef USE_CLING | ||
| return CXError_Failure; | ||
| #else | ||
| return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success; |
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 "CXError_Success" is directly included [misc-include-cleaner]
return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success;
^| #ifdef USE_CLING | ||
| auto val = std::make_unique<cling::Value>(); | ||
| #else | ||
| auto val = std::make_unique<clang::Value>(); |
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 "clang::Value" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:15:
- #include <cstring>
+ #include <clang/Interpreter/Value.h>
+ #include <cstring>| namespace Cpp { | ||
| bool InsertOrReplaceJitSymbol(compat::Interpreter& I, | ||
| const char* linker_mangled_name, | ||
| uint64_t 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 "uint64_t" is directly included [misc-include-cleaner]
uint64_t address);
^| static inline bool isNull(const CXScope& S) { return !S.data[0]; } | ||
|
|
||
| static inline clang::Decl* getDecl(const CXScope& S) { | ||
| return const_cast<clang::Decl*>(static_cast<const clang::Decl*>(S.data[0])); |
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: do not use const_cast to remove const qualifier [cppcoreguidelines-pro-type-const-cast]
return const_cast<clang::Decl*>(static_cast<const clang::Decl*>(S.data[0]));
^| auto* D = getDecl(func); | ||
| if (const auto* FD = llvm::dyn_cast<clang::FunctionDecl>(D)) { | ||
| std::string Signature; | ||
| llvm::raw_string_ostream SS(Signature); |
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 "llvm::raw_string_ostream" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <llvm/Support/raw_ostream.h>
+ #include "clang-c/CXString.h"| } | ||
|
|
||
| bool clang_existsFunctionTemplate(const char* name, CXScope parent) { | ||
| if (kind(parent) == CXCursor_FirstInvalid || !name) |
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 "CXCursor_FirstInvalid" is directly included [misc-include-cleaner]
if (kind(parent) == CXCursor_FirstInvalid || !name)
^| const auto* Within = llvm::dyn_cast<clang::DeclContext>(getDecl(parent)); | ||
|
|
||
| auto& S = getInterpreter(parent)->getSema(); | ||
| auto* ND = Cpp::Cpp_utils::Lookup::Named(&S, name, Within); |
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 "Cpp::utils::Lookup::Named" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:2:
- #include "clang/AST/CXXInheritance.h"
+ #include "CppInterOpInterpreter.h"
+ #include "clang/AST/CXXInheritance.h"| size_t template_args_size) { | ||
| auto* I = getInterpreter(tmpl); | ||
|
|
||
| llvm::SmallVector<Cpp::TemplateArgInfo> Info; |
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 "llvm::SmallVector" is directly included [misc-include-cleaner]
lib/Interpreter/CXCppInterOp.cpp:17:
- #include "clang-c/CXString.h"
+ #include <llvm/ADT/SmallVector.h>
+ #include "clang-c/CXString.h"|
Thanks! |
Since there is a substantial overlap with libclang’s API, I am only exposing the API I currently use in this PR.
This PR introduces two types,
CXScopeandCXQualType, which wrapTCppScope_tandTCppType_t, respectively. The structure of these two types is the same as libclang'sCXCursor/CXType, with the only difference being that they store a handle to the interpreter instead of a CXTranslationUnit. This paves the way for upstreaming changes to libclang.