Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/IRGen/GenClangDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {

ClangDeclRefFinder refFinder([&](const clang::DeclRefExpr *DRE) {
const clang::Decl *D = DRE->getDecl();

// Ignore local declarations.
if (auto varDecl = dyn_cast<clang::VarDecl>(D))
if (!varDecl->isFileVarDecl() && !varDecl->isStaticDataMember())
return;

// Check that this is a file-level declaration and not inside a function.
// If it's a member of a file-level decl, like a C++ static member variable,
// we want to add the entire file-level declaration because Clang doesn't
Expand Down
5 changes: 5 additions & 0 deletions test/IRGen/Inputs/c_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ static inline void log_a_thing(const a_thing thing) {
static inline unsigned int return7(void) {
return 7;
}

static inline int getExternGlobal() {
extern int global;
return global;
}
5 changes: 5 additions & 0 deletions test/IRGen/c_functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ func test_indirect_by_val_alignment() {
// i386: define hidden swiftcc void @"$s11c_functions30test_indirect_by_val_alignmentyyF"()
// s390x: define hidden swiftcc void @"$s11c_functions30test_indirect_by_val_alignmentyyF"()
// powerpc64le: define hidden swiftcc void @"$s11c_functions30test_indirect_by_val_alignmentyyF"()


func dontAssertOnExternLocal() {
let x = getExternGlobal()
}