@@ -66,6 +66,10 @@ TInterp_t clang_interpreter_getInterpreterAsPtr(CXInterpreter I) {
6666 return getInterpreter (I);
6767}
6868
69+ TInterp_t clang_interpreter_takeInterpreterAsPtr (CXInterpreter I) {
70+ return static_cast <CXInterpreterImpl*>(I)->Interp .release ();
71+ }
72+
6973void clang_interpreter_dispose (CXInterpreter I) {
7074 delete I; // NOLINT(*-owning-memory)
7175}
@@ -447,19 +451,22 @@ CXQualType clang_scope_getIntegerTypeFromEnumScope(CXScope S) {
447451}
448452
449453void clang_disposeScopeSet (CXScopeSet* set) {
454+ if (!set)
455+ return ;
456+
450457 delete[] set->Scopes ; // NOLINT(*-owning-memory)
451458 delete set; // NOLINT(*-owning-memory)
452459}
453460
454461CXScopeSet* clang_scope_getEnumConstants (CXScope S) {
455462 const auto * ED = llvm::dyn_cast_or_null<clang::EnumDecl>(getDecl (S));
456463 if (!ED)
457- return nullptr ;
464+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
458465
459466 auto EI = ED->enumerator_begin ();
460467 auto EE = ED->enumerator_end ();
461468 if (EI == EE)
462- return nullptr ;
469+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
463470
464471 auto * Set = new CXScopeSet; // NOLINT(*-owning-memory)
465472 Set->Count = std::distance (EI, EE);
@@ -571,12 +578,12 @@ CXString clang_scope_getQualifiedCompleteName(CXScope S) {
571578CXScopeSet* clang_scope_getUsingNamespaces (CXScope S) {
572579 const auto * DC = llvm::dyn_cast_or_null<clang::DeclContext>(getDecl (S));
573580 if (!DC)
574- return nullptr ;
581+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
575582
576583 auto DI = DC->using_directives ().begin ();
577584 auto DE = DC->using_directives ().end ();
578585 if (DI == DE)
579- return nullptr ;
586+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
580587
581588 auto * Set = new CXScopeSet; // NOLINT(*-owning-memory)
582589 Set->Count = std::distance (DI, DE);
@@ -735,11 +742,11 @@ int64_t clang_scope_getBaseClassOffset(CXScope derived, CXScope base) {
735742
736743CXScopeSet* clang_scope_getClassMethods (CXScope S) {
737744 if (kind (S) == CXScope_Invalid)
738- return nullptr ;
745+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
739746
740747 const auto US = clang_scope_getUnderlyingScope (S);
741748 if (kind (US) == CXScope_Invalid || !clang_scope_isClass (US))
742- return nullptr ;
749+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
743750
744751 auto * CXXRD = llvm::dyn_cast<clang::CXXRecordDecl>(getDecl (US));
745752
@@ -773,11 +780,11 @@ CXScopeSet* clang_scope_getClassMethods(CXScope S) {
773780
774781CXScopeSet* clang_scope_getFunctionTemplatedDecls (CXScope S) {
775782 if (kind (S) == CXScope_Invalid)
776- return nullptr ;
783+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
777784
778785 const auto US = clang_scope_getUnderlyingScope (S);
779786 if (kind (US) == CXScope_Invalid || !clang_scope_isClass (US))
780- return nullptr ;
787+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
781788
782789 auto * CXXRD = llvm::dyn_cast<clang::CXXRecordDecl>(getDecl (US));
783790
@@ -845,7 +852,7 @@ CXScopeSet* clang_scope_getFunctionsUsingName(CXScope S, const char* name) {
845852 const auto * D = getDecl (clang_scope_getUnderlyingScope (S));
846853
847854 if (!D || !name)
848- return nullptr ;
855+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
849856
850857 const llvm::StringRef Name (name);
851858 const auto * I = getInterpreter (S);
@@ -858,7 +865,7 @@ CXScopeSet* clang_scope_getFunctionsUsingName(CXScope S, const char* name) {
858865 Cpp::Cpp_utils::Lookup::Named (&SM, R, clang::Decl::castToDeclContext (D));
859866
860867 if (R.empty ())
861- return nullptr ;
868+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
862869
863870 R.resolveKind ();
864871
@@ -995,7 +1002,7 @@ CXScopeSet* clang_scope_getClassTemplatedMethods(const char* name,
9951002 const auto * D = getDecl (clang_scope_getUnderlyingScope (parent));
9961003
9971004 if (!D || !name)
998- return nullptr ;
1005+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
9991006
10001007 const llvm::StringRef Name (name);
10011008 const auto * I = getInterpreter (parent);
@@ -1008,7 +1015,7 @@ CXScopeSet* clang_scope_getClassTemplatedMethods(const char* name,
10081015 Cpp::Cpp_utils::Lookup::Named (&SM, R, clang::Decl::castToDeclContext (D));
10091016
10101017 if (R.empty ())
1011- return nullptr ;
1018+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
10121019
10131020 R.resolveKind ();
10141021
@@ -1136,12 +1143,12 @@ CXString clang_scope_getFunctionArgName(CXScope func, size_t param_index) {
11361143CXScopeSet* clang_scope_getDatamembers (CXScope S) {
11371144 const auto * CXXRD = llvm::dyn_cast_or_null<clang::CXXRecordDecl>(getDecl (S));
11381145 if (!CXXRD)
1139- return nullptr ;
1146+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
11401147
11411148 auto FI = CXXRD->field_begin ();
11421149 auto FE = CXXRD->field_end ();
11431150 if (FI == FE)
1144- return nullptr ;
1151+ return new CXScopeSet{ nullptr , 0 }; // NOLINT(*-owning-memory)
11451152
11461153 auto * Set = new CXScopeSet; // NOLINT(*-owning-memory)
11471154 Set->Count = std::distance (FI, FE);
0 commit comments