Skip to content

Commit b633ba7

Browse files
faze-geekvgvassilev
authored andcommitted
Fix for cppyy bug
1 parent f51dcf6 commit b633ba7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,13 +1214,22 @@ namespace Cpp {
12141214

12151215
TCppType_t GetVariableType(TCppScope_t var)
12161216
{
1217-
auto D = (Decl *) var;
1217+
auto D = (Decl *) var;
12181218

1219-
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
1220-
return DD->getType().getAsOpaquePtr();
1221-
}
1219+
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
1220+
QualType QT = DD->getType();
12221221

1223-
return 0;
1222+
// Check if the type is a typedef type
1223+
if (QT->isTypedefNameType()) {
1224+
return QT.getAsOpaquePtr();
1225+
}
1226+
1227+
// Else, return the canonical type
1228+
QT = QT.getCanonicalType();
1229+
return QT.getAsOpaquePtr();
1230+
}
1231+
1232+
return 0;
12241233
}
12251234

12261235
intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,

unittests/CppInterOp/VariableReflectionTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "clang/Sema/Sema.h"
77

88
#include "gtest/gtest.h"
9+
#include <string>
910

1011
#include <cstddef>
1112

0 commit comments

Comments
 (0)