Skip to content

Commit db81a49

Browse files
committed
Take into account the access control when we build the ctor calls.
This patch teaches clang to ignore diagnostics due to calls to private ctors.
1 parent c8ae0da commit db81a49

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/clang/Interpreter/CppInterOpInterpreter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,20 @@ class Interpreter {
307307
}
308308
}
309309

310+
clang::LangOptions& LO
311+
= const_cast<clang::LangOptions&>(getCompilerInstance()->getLangOpts());
312+
bool SavedAccessControl = LO.AccessControl;
313+
LO.AccessControl = withAccessControl;
314+
310315
if (auto Err = ParseAndExecute(code)) {
316+
LO.AccessControl = SavedAccessControl;
311317
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(),
312318
"Failed to compileFunction: ");
313319
return nullptr;
314320
}
321+
322+
LO.AccessControl = SavedAccessControl;
323+
315324
return getAddressOfGlobal(name);
316325
}
317326

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ TEST(FunctionReflectionTest, Construct) {
673673
Sema *S = &Interp->getCI()->getSema();
674674

675675
Interp->declare(R"(
676+
#include <new>
676677
extern "C" int printf(const char*,...);
677678
class C {
678679
C() {
@@ -700,6 +701,7 @@ TEST(FunctionReflectionTest, Destruct) {
700701
Sema *S = &Interp->getCI()->getSema();
701702

702703
Interp->declare(R"(
704+
#include <new>
703705
extern "C" int printf(const char*,...);
704706
class C {
705707
C() {}

0 commit comments

Comments
 (0)