Index: clang/lib/Interpreter/IncrementalExecutor.cpp =================================================================== --- clang/lib/Interpreter/IncrementalExecutor.cpp +++ clang/lib/Interpreter/IncrementalExecutor.cpp @@ -92,12 +92,20 @@ llvm::Expected IncrementalExecutor::getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const { - auto Sym = (NameKind == LinkerName) ? Jit->lookupLinkerMangled(Name) - : Jit->lookup(Name); - - if (!Sym) - return Sym.takeError(); - return Sym; + using namespace llvm::orc; + JITDylibSearchOrder O; + JITDylibLookupFlags Flags = JITDylibLookupFlags::MatchExportedSymbolsOnly; + O.push_back({&Jit->getMainJITDylib(), Flags}); + O.push_back({Jit->getPlatformJITDylib().get(), Flags}); + O.push_back({Jit->getProcessSymbolsJITDylib().get(), Flags}); + + ExecutionSession &ES = Jit->getExecutionSession(); + + auto SymOrErr = ES.lookup( + O, ES.intern((NameKind == LinkerName) ? Name : Jit->mangle(Name))); + if (auto Err = SymOrErr.takeError()) + return std::move(Err); + return SymOrErr->getAddress(); } } // end namespace clang Index: clang/unittests/Interpreter/InterpreterTest.cpp =================================================================== --- clang/unittests/Interpreter/InterpreterTest.cpp +++ clang/unittests/Interpreter/InterpreterTest.cpp @@ -234,10 +234,16 @@ } std::string MangledName = MangleName(FD); - auto Addr = cantFail(Interp->getSymbolAddress(MangledName)); - EXPECT_NE(0U, Addr.getValue()); + auto Addr = Interp->getSymbolAddress(MangledName); + EXPECT_FALSE(!Addr); + EXPECT_NE(0U, Addr->getValue()); GlobalDecl GD(FD); - EXPECT_EQ(Addr, cantFail(Interp->getSymbolAddress(GD))); + EXPECT_EQ(*Addr, cantFail(Interp->getSymbolAddress(GD))); + cantFail( + Interp->ParseAndExecute("extern \"C\" int printf(const char*,...);")); + Addr = Interp->getSymbolAddress("printf"); + EXPECT_FALSE(!Addr); + EXPECT_EQ((unsigned long long)&printf, Addr->getValue()); } static void *AllocateObject(TypeDecl *TD, Interpreter &Interp) {