Fix extern "C" declarations not being called from .x command.
This handles top-level declarations only (i.e. not nested in namespaces).
This commit is contained in:
parent
213ba748cd
commit
2bf05c5188
@ -62,12 +62,22 @@ namespace cling {
|
||||
}
|
||||
|
||||
NamedDecl* Transaction::containsNamedDecl(llvm::StringRef name) const {
|
||||
for (auto I = decls_begin(), E = decls_end(); I < E; ++I)
|
||||
for (auto I = decls_begin(), E = decls_end(); I < E; ++I) {
|
||||
for (auto DI : I->m_DGR) {
|
||||
if (NamedDecl* ND = dyn_cast<NamedDecl>(DI))
|
||||
if (NamedDecl* ND = dyn_cast<NamedDecl>(DI)) {
|
||||
if (name.equals(ND->getNameAsString()))
|
||||
return ND;
|
||||
}
|
||||
else if (LinkageSpecDecl* LSD = dyn_cast<LinkageSpecDecl>(DI)) {
|
||||
for (Decl* DI : LSD->decls()) {
|
||||
if (NamedDecl* ND = dyn_cast<NamedDecl>(DI)) {
|
||||
if (name.equals(ND->getNameAsString()))
|
||||
return ND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
22
test/Lookup/linkageSpec.C
Normal file
22
test/Lookup/linkageSpec.C
Normal file
@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// CLING - the C++ LLVM-based InterpreterG :)
|
||||
//
|
||||
// This file is dual-licensed: you can choose to license it under the University
|
||||
// of Illinois Open Source License or the GNU Lesser General Public License. See
|
||||
// LICENSE.TXT for details.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// RUN: %cling %s -Xclang -verify 2>&1 | FileCheck %s
|
||||
|
||||
// This test assures that extern "C" declarations are usable via .x
|
||||
|
||||
extern "C" int printf(const char*, ...);
|
||||
|
||||
extern "C" int linkageSpec() {
|
||||
printf("linkageSpec called %s\n", __FUNCTION__);
|
||||
return 101;
|
||||
}
|
||||
|
||||
// CHECK: linkageSpec called linkageSpec
|
||||
// CHECK: (int) 101
|
||||
// expected-no-diagnostics
|
Loading…
x
Reference in New Issue
Block a user