Skip to content

Commit 1e124e4

Browse files
authored
Merge branch 'main' into wip]-add-automated-wasm-tests
2 parents 444c081 + 7caf10b commit 1e124e4

File tree

7 files changed

+105
-9
lines changed

7 files changed

+105
-9
lines changed

.github/workflows/MacOS.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ jobs:
126126
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
127127
run: |
128128
brew update
129-
brew remove [email protected]
130129
# workaround for https://github.com/actions/setup-python/issues/577
131130
for pkg in $(brew list | grep '^python@'); do
132131
brew unlink "$pkg"
@@ -322,7 +321,6 @@ jobs:
322321
- name: Install deps
323322
run: |
324323
brew update --force
325-
brew remove [email protected]
326324
brew remove swiftlint
327325
# workaround for https://github.com/actions/setup-python/issues/577
328326
for pkg in $(brew list | grep '^python@'); do

.github/workflows/emscripten.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ jobs:
241241
export ARCHITECHURE=$(uname -m)
242242
if [[ "$ARCHITECHURE" != "x86_64" ]]; then
243243
brew remove unxip
244-
else
245-
brew remove [email protected]
246244
fi
247245
# workaround for https://github.com/actions/setup-python/issues/577
248246
for pkg in $(brew list | grep '^python@'); do

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.0;dev
1+
1.7.0;dev

docs/ReleaseNotes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Introduction
22

33
This document contains the release notes for the language interoperability
4-
library CppInterOp, release 1.6.0. CppInterOp is built on top of
4+
library CppInterOp, release 1.7.0. CppInterOp is built on top of
55
[Clang](http://clang.llvm.org) and [LLVM](http://llvm.org%3E) compiler
66
infrastructure. Here we describe the status of CppInterOp in some detail,
77
including major improvements from the previous release and new feature work.
@@ -16,7 +16,7 @@ interoperability on the fly. In such scenarios CppInterOp can be used to provide
1616
the necessary introspection information to the other side helping the language
1717
cross talk.
1818

19-
## What's New in CppInterOp 1.6.0?
19+
## What's New in CppInterOp 1.7.0?
2020

2121
Some of the major new features and improvements to CppInterOp are listed here.
2222
Generic improvements to CppInterOp as a whole or to its underlying
@@ -48,7 +48,7 @@ infrastructure are described first.
4848
[XXX](https://github.com/compiler-research/CppInterOp/issues/XXX)
4949

5050
<!---Get release bugs
51-
git log v1.5.0..main | grep 'Fixes|Closes'
51+
git log v1.6.0..main | grep 'Fixes|Closes'
5252
--->
5353

5454
## Special Kudos
@@ -61,6 +61,6 @@ FirstName LastName (#commits)
6161
A B (N)
6262

6363
<!---Find contributor list for this release
64-
git log --pretty=format:"%an" v1.5.0...main | sort | uniq -c | sort -rn |\
64+
git log --pretty=format:"%an" v1.6.0...main | sort | uniq -c | sort -rn |\
6565
sed -E 's,^ *([0-9]+) (.*)$,\2 \(\1\),'
6666
--->

include/clang/Interpreter/CppInterOp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,18 @@ namespace Cpp {
504504
/// Checks if the provided parameter is a Plain Old Data Type (POD).
505505
CPPINTEROP_API bool IsPODType(TCppType_t type);
506506

507+
/// Checks if type is a pointer
508+
CPPINTEROP_API bool IsPointerType(TCppType_t type);
509+
510+
/// Get the underlying pointee type
511+
CPPINTEROP_API TCppType_t GetPointeeType(TCppType_t type);
512+
513+
/// Checks if type is a reference
514+
CPPINTEROP_API bool IsReferenceType(TCppType_t type);
515+
516+
/// Get the type that the reference refers to
517+
CPPINTEROP_API TCppType_t GetNonReferenceType(TCppType_t type);
518+
507519
/// Gets the pure, Underlying Type (as opposed to the Using Type).
508520
CPPINTEROP_API TCppType_t GetUnderlyingType(TCppType_t type);
509521

lib/Interpreter/CppInterOp.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,30 @@ namespace Cpp {
14931493
return QT.isPODType(getASTContext());
14941494
}
14951495

1496+
bool IsPointerType(TCppType_t type) {
1497+
QualType QT = QualType::getFromOpaquePtr(type);
1498+
return QT->isPointerType();
1499+
}
1500+
1501+
TCppType_t GetPointeeType(TCppType_t type) {
1502+
if (!IsPointerType(type))
1503+
return nullptr;
1504+
QualType QT = QualType::getFromOpaquePtr(type);
1505+
return QT->getPointeeType().getAsOpaquePtr();
1506+
}
1507+
1508+
bool IsReferenceType(TCppType_t type) {
1509+
QualType QT = QualType::getFromOpaquePtr(type);
1510+
return QT->isReferenceType();
1511+
}
1512+
1513+
TCppType_t GetNonReferenceType(TCppType_t type) {
1514+
if (!IsReferenceType(type))
1515+
return nullptr;
1516+
QualType QT = QualType::getFromOpaquePtr(type);
1517+
return QT.getNonReferenceType().getAsOpaquePtr();
1518+
}
1519+
14961520
TCppType_t GetUnderlyingType(TCppType_t type)
14971521
{
14981522
QualType QT = QualType::getFromOpaquePtr(type);

unittests/CppInterOp/VariableReflectionTest.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,3 +606,67 @@ TEST(VariableReflectionTest, GetEnumConstantDatamembers) {
606606
Cpp::GetEnumConstantDatamembers(MyEnumClass, datamembers2, false);
607607
EXPECT_EQ(datamembers2.size(), 6);
608608
}
609+
610+
TEST(VariableReflectionTest, Is_Get_Pointer) {
611+
Cpp::CreateInterpreter();
612+
std::vector<Decl*> Decls;
613+
std::string code = R"(
614+
class A {};
615+
int a;
616+
int *b;
617+
double c;
618+
double *d;
619+
A e;
620+
A *f;
621+
)";
622+
623+
GetAllTopLevelDecls(code, Decls);
624+
625+
EXPECT_FALSE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[1])));
626+
EXPECT_TRUE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[2])));
627+
EXPECT_FALSE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[3])));
628+
EXPECT_TRUE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[4])));
629+
EXPECT_FALSE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[5])));
630+
EXPECT_TRUE(Cpp::IsPointerType(Cpp::GetVariableType(Decls[6])));
631+
632+
EXPECT_EQ(Cpp::GetPointeeType(Cpp::GetVariableType(Decls[2])),
633+
Cpp::GetVariableType(Decls[1]));
634+
EXPECT_EQ(Cpp::GetPointeeType(Cpp::GetVariableType(Decls[4])),
635+
Cpp::GetVariableType(Decls[3]));
636+
EXPECT_EQ(Cpp::GetPointeeType(Cpp::GetVariableType(Decls[6])),
637+
Cpp::GetVariableType(Decls[5]));
638+
639+
EXPECT_FALSE(Cpp::GetPointeeType(Cpp::GetVariableType(Decls[5])));
640+
}
641+
642+
TEST(VariableReflectionTest, Is_Get_Reference) {
643+
Cpp::CreateInterpreter();
644+
std::vector<Decl*> Decls;
645+
std::string code = R"(
646+
class A {};
647+
int a;
648+
int &b = a;
649+
double c;
650+
double &d = c;
651+
A e;
652+
A &f = e;
653+
)";
654+
655+
GetAllTopLevelDecls(code, Decls);
656+
657+
EXPECT_FALSE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[1])));
658+
EXPECT_TRUE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[2])));
659+
EXPECT_FALSE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[3])));
660+
EXPECT_TRUE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[4])));
661+
EXPECT_FALSE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[5])));
662+
EXPECT_TRUE(Cpp::IsReferenceType(Cpp::GetVariableType(Decls[6])));
663+
664+
EXPECT_EQ(Cpp::GetNonReferenceType(Cpp::GetVariableType(Decls[2])),
665+
Cpp::GetVariableType(Decls[1]));
666+
EXPECT_EQ(Cpp::GetNonReferenceType(Cpp::GetVariableType(Decls[4])),
667+
Cpp::GetVariableType(Decls[3]));
668+
EXPECT_EQ(Cpp::GetNonReferenceType(Cpp::GetVariableType(Decls[6])),
669+
Cpp::GetVariableType(Decls[5]));
670+
671+
EXPECT_FALSE(Cpp::GetNonReferenceType(Cpp::GetVariableType(Decls[5])));
672+
}

0 commit comments

Comments
 (0)