Skip to content

Commit 2585d0d

Browse files
committed
Add const-correctness to the scope of destruct call
1 parent 377c5c4 commit 2585d0d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

include/CppInterOp/CppInterOp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
namespace Cpp {
3636
using TCppIndex_t = size_t;
3737
using TCppScope_t = void*;
38+
using TCppConstScope_t = const void*;
3839
using TCppType_t = void*;
3940
using TCppFunction_t = void*;
4041
using TCppConstFunction_t = const void*;
@@ -868,7 +869,7 @@ CPPINTEROP_API TCppObject_t Construct(TCppScope_t scope, void* arena = nullptr,
868869
/// \param[in] count indicate the number of objects to destruct, if \c This
869870
/// points to an array of objects
870871
/// \returns true if wrapper generation and invocation succeeded.
871-
CPPINTEROP_API bool Destruct(TCppObject_t This, TCppScope_t type,
872+
CPPINTEROP_API bool Destruct(TCppObject_t This, TCppConstScope_t type,
872873
bool withFree = true, TCppIndex_t count = 0UL);
873874

874875
/// @name Stream Redirection

lib/CppInterOp/CXCppInterOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ void clang_invoke(CXScope func, void* result, void** args, size_t n,
614614

615615
namespace Cpp {
616616
bool Destruct(compat::Interpreter& interp, TCppObject_t This,
617-
clang::Decl* Class, bool withFree, size_t nary);
617+
const clang::Decl* Class, bool withFree, size_t nary);
618618
} // namespace Cpp
619619

620620
bool clang_destruct(CXObject This, CXScope S, bool withFree, size_t nary) {

lib/CppInterOp/CppInterOp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,7 +3812,7 @@ TCppObject_t Construct(TCppScope_t scope, void* arena /*=nullptr*/,
38123812
return Construct(getInterp(), scope, arena, count);
38133813
}
38143814

3815-
bool Destruct(compat::Interpreter& interp, TCppObject_t This, Decl* Class,
3815+
bool Destruct(compat::Interpreter& interp, TCppObject_t This, const Decl* Class,
38163816
bool withFree, TCppIndex_t nary) {
38173817
if (auto wrapper = make_dtor_wrapper(interp, Class)) {
38183818
(*wrapper)(This, nary, withFree);
@@ -3822,9 +3822,9 @@ bool Destruct(compat::Interpreter& interp, TCppObject_t This, Decl* Class,
38223822
// FIXME: Enable stronger diagnostics
38233823
}
38243824

3825-
bool Destruct(TCppObject_t This, TCppScope_t scope, bool withFree /*=true*/,
3826-
TCppIndex_t count /*=0UL*/) {
3827-
auto* Class = static_cast<Decl*>(scope);
3825+
bool Destruct(TCppObject_t This, TCppConstScope_t scope,
3826+
bool withFree /*=true*/, TCppIndex_t count /*=0UL*/) {
3827+
const auto* Class = static_cast<const Decl*>(scope);
38283828
return Destruct(getInterp(), This, Class, withFree, count);
38293829
}
38303830

0 commit comments

Comments
 (0)