Skip to content

Commit e21372a

Browse files
committed
Fix for cppyy bug
1 parent 95e7b00 commit e21372a

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
@@ -1204,13 +1204,22 @@ namespace Cpp {
12041204

12051205
TCppType_t GetVariableType(TCppScope_t var)
12061206
{
1207-
auto D = (Decl *) var;
1207+
auto D = (Decl *) var;
12081208

1209-
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
1210-
return DD->getType().getAsOpaquePtr();
1211-
}
1209+
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
1210+
QualType QT = DD->getType();
12121211

1213-
return 0;
1212+
// Check if the type is a typedef type
1213+
if (QT->isTypedefNameType()) {
1214+
return QT.getAsOpaquePtr();
1215+
}
1216+
1217+
// Else, return the canonical type
1218+
QT = QT.getCanonicalType();
1219+
return QT.getAsOpaquePtr();
1220+
}
1221+
1222+
return 0;
12141223
}
12151224

12161225
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
using namespace TestUtils;
1112
using namespace llvm;

0 commit comments

Comments
 (0)