Skip to content

Commit 11047e1

Browse files
committed
[testutils] Add check for x86 target
1 parent 6abeffe commit 11047e1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

unittests/CppInterOp/Utils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "clang/Sema/Lookup.h"
1010
#include "clang/Sema/Sema.h"
1111

12+
#include "llvm/TargetParser/Triple.h"
13+
1214
#include <algorithm>
1315
#include <string>
1416
#include <vector>
@@ -57,6 +59,15 @@ void TestUtils::GetAllSubDecls(Decl *D, std::vector<Decl*>& SubDecls,
5759
}
5860
}
5961

62+
bool IsTargetX86() {
63+
#ifndef CPPINTEROP_USE_CLING
64+
llvm::Triple triple(Interp->getCompilerInstance()->getTargetOpts().Triple);
65+
#else
66+
llvm::Triple triple(Interp->getCI()->getTargetOpts().Triple);
67+
#endif
68+
return triple.isX86();
69+
}
70+
6071
const char* get_c_string(CXString string) {
6172
return static_cast<const char*>(string.data);
6273
}

unittests/CppInterOp/Utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ void dispose_string(CXString string);
3434

3535
CXScope make_scope(const clang::Decl* D, const CXInterpreter I);
3636

37+
bool IsTargetX86();
38+
3739
#endif // CPPINTEROP_UNITTESTS_LIBCPPINTEROP_UTILS_H

0 commit comments

Comments
 (0)