Skip to content

Commit 1172138

Browse files
committed
wip do not merge
1 parent 0355261 commit 1172138

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,10 @@ importer::getNormalInvocationArguments(
704704
}
705705

706706
if (searchPathOpts.getSDKPath().empty()) {
707-
invocationArgStrs.push_back("-Xclang");
708-
invocationArgStrs.push_back("-nostdsysteminc");
707+
if (!triple.isOSLinux()) {
708+
invocationArgStrs.push_back("-Xclang");
709+
invocationArgStrs.push_back("-nostdsysteminc");
710+
}
709711
} else {
710712
if (triple.isWindowsMSVCEnvironment()) {
711713
llvm::SmallString<261> path; // MAX_PATH + 1

lib/Driver/UnixToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
324324
Arguments.push_back(
325325
context.Args.MakeArgString(Twine("-stdlib=") + A->getValue()));
326326
}
327+
if (getTriple().isOSLinux())
328+
Arguments.push_back("-lstdc++");
327329

328330
// Explicitly pass the target to the linker
329331
Arguments.push_back(

lib/IRGen/GenClangDecl.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ class ClangDeclFinder
8686
// the initializer of the variable.
8787
clang::Decl *getDeclWithExecutableCode(clang::Decl *decl) {
8888
if (auto fd = dyn_cast<clang::FunctionDecl>(decl)) {
89-
// If this is a potentially not-yet-instanciated template, we might
90-
// still have a body.
91-
if (fd->getTemplateInstantiationPattern())
92-
return fd;
93-
9489
const clang::FunctionDecl *definition;
9590
if (fd->hasBody(definition)) {
9691
return const_cast<clang::FunctionDecl *>(definition);
9792
}
93+
94+
// If this is a potentially not-yet-instanciated template, we might
95+
// still have a body.
96+
if (fd->getTemplateInstantiationPattern())
97+
return fd;
9898
} else if (auto vd = dyn_cast<clang::VarDecl>(decl)) {
9999
clang::VarDecl *initializingDecl = vd->getInitializingDeclaration();
100100
if (initializingDecl) {
@@ -120,6 +120,9 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
120120
if (getDeclWithExecutableCode(const_cast<clang::Decl *>(decl)) == nullptr) {
121121
ClangCodeGen->HandleTopLevelDecl(
122122
clang::DeclGroupRef(const_cast<clang::Decl*>(decl)));
123+
llvm::errs() << "SKIPPING code\n";
124+
decl->dump(llvm::errs());
125+
llvm::errs() << "===============";
123126
return;
124127
}
125128

@@ -159,12 +162,26 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
159162
if (fn->getTemplateInstantiationPattern())
160163
Context.getClangModuleLoader()
161164
->getClangSema()
162-
.InstantiateFunctionDefinition(fn->getLocation(), fn);
165+
.InstantiateFunctionDefinition(fn->getLocation(), fn, true);
163166
}
164167

165168
if (clang::Decl *executableDecl = getDeclWithExecutableCode(next)) {
169+
llvm::errs() << "TraverseDecl for:\n";
170+
executableDecl->dump(llvm::errs());
171+
llvm::errs() << "================\n";
172+
if (auto nd = dyn_cast<clang::NamedDecl>(executableDecl)) {
173+
if (nd->getIdentifier() && nd->getName() == "_M_destroy") {
174+
llvm::errs() << "!!! emit _M_destroy while called with\n";
175+
decl->dump(llvm::errs());
176+
llvm::errs() << "!!! =================================\n";
177+
}
178+
}
166179
refFinder.TraverseDecl(executableDecl);
167180
next = executableDecl;
181+
} else {
182+
llvm::errs() << "!!! Skipping \n";
183+
next->dump(llvm::errs());
184+
llvm::errs() << "===============\n";
168185
}
169186

170187
// Unfortunately, implicitly defined CXXDestructorDecls don't have a real

lib/IRGen/GenStruct.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@ namespace {
604604
IRGenFunction &IGF, SILType T,
605605
const clang::CXXConstructorDecl *copyConstructor, llvm::Value *src,
606606
llvm::Value *dest) const {
607+
llvm::errs() << "emitCopyWithCopyConstructor:\n";
608+
copyConstructor->dump(llvm::errs());
609+
llvm::errs() << "===========================\n";
607610
auto fnType = createCXXCopyConstructorFunctionType(IGF, T);
608611
auto globalDecl =
609612
clang::GlobalDecl(copyConstructor, clang::Ctor_Complete);

stdlib/public/Cxx/libstdcxx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include <algorithm>
22
#include <bitset>
3+
#include <bits/stl_iterator_base_types.h>
34
#include <complex>
45
#include <deque>
56
#include <exception>
7+
#include <ext/type_traits.h>
68
#include <fstream>
79
#include <functional>
810
#include <iomanip>

test/Interop/Cxx/stdlib/use-std-string.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop -v -Xcc -v)
22
//
33
// REQUIRES: executable_test
44
//

0 commit comments

Comments
 (0)