Commit Graph

80 Commits

Author SHA1 Message Date
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Adrian Prantl
2cb2760ed9 ASTPrinter: Add an option to qualify ClangImported types.
This part of a series of patches to bring ASTPrinter and Swift Demangler to
feature parity, which is needed by LLDB, which depends on using the strings
produced by either interchangibly.

rdar://problem/63700540
2020-05-29 19:04:22 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
swift-ci
ef8a0d15a5 Merge remote-tracking branch 'origin/master' into master-next 2019-08-16 08:50:45 -07:00
swift-ci
4aefbcf447 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-16 08:43:42 -07:00
Adrian Prantl
1020d8188a Add back the dummy DWARFImporter test to lldb-moduleimport-test. 2019-08-15 16:35:05 -07:00
Alex Langford
04c5ceb18c Adjust for svn r368826
LLVM svn r368826 changed the SectionRef::getName() interface to return an
Expected<StringRef> instead of filling out one that is passed to it.
Adjust accordingly.
2019-08-15 10:56:06 -07:00
swift-ci
032def3316 Merge remote-tracking branch 'origin/master' into master-next 2019-08-14 11:50:24 -07:00
swift-ci
7245d76875 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-14 11:44:30 -07:00
Adrian Prantl
c08a62764a Move DWARFImporterDelegate into ClangImporter and remove DWARFImporter.
This refactors DWARFImporter to become a part of ClangImporter, since
it needs access to many of its implementation details anyway. The
DWARFImporterDelegate is just another mechanism for deserializing
Clang ASTs and once we have a Clang AST, the processing is effectively
the same.
2019-08-14 10:28:50 -07:00
swift-ci
24d2d5fd7a Merge remote-tracking branch 'origin/master' into master-next 2019-06-14 13:09:28 -07:00
Saleem Abdulrasool
f33fa6b037 lldb-module-test: correct the output pipe
Use the error stream for error messages.
2019-05-22 07:56:12 -07:00
Gwen Mittertreiner
67cfef2d60 SectionRef::getContents() now returns Expected
Updated uses of object::SectionRef::getContents() since it now returns
an Expected<StringRef> instead of modifying the one it's passed.

See also: git-svn-id:
https://llvm.org/svn/llvm-project/llvm/trunk@360892
91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-20 16:02:41 -07:00
Adrian Prantl
807c2cfbe3 Make lldb-moduleimport more rubost when importing object files with multiple AST
blobs.
2019-05-08 11:34:21 -07:00
Adrian Prantl
b244b0928e Factor out the pre-registered MemoryBuffer functionality
form SerializedModuleLoader into its own ModuleLoader class. (NFC-ish)

This gives better control over the order in which the various module
load mechanisms are applied.
2019-04-22 09:17:08 -07:00
Saleem Abdulrasool
1fad3d60e0 lldb-moduleimport-test: handle COFF properly
lldb-moduleimport-test would only check for MachO and ELF object file
formats.  However, Windows uses COFF object files.  Add that to the list
of formats that we check.  This allows us to inspect content built for
Windows.
2019-03-22 13:13:48 -07:00
Slava Pestov
d0d5fbdf39 ASTDemangler: Introduce new getTypeDeclForMangling()
This will replace getDeclFromMangledSymbolName().

Progress on <rdar://problem/47819208>.
2019-02-22 16:13:02 -05:00
Slava Pestov
b2f0327516 IDE: Remove getTypeFromMangledSymbolname()
There was only one remaining usage other than in testing tools.

Note that when a declaration mangling was passed in, the old entry
point would (try to) return the type of the declaration.

The new entry point no longer has this behavior. I changed the
bridging-header-first test to run lldb-moduleimport-test with
-decl-from-mangled instead of -type-from-mangled-old to preserve
the behavior of the test.

Also, I removed test/DebugInfo/DumpTypeFromMangledName.swift
completely. This test only covered a handful of cases, and a bunch
of them were declaration manglings rather than type manglings.
The new tests in test/TypeDecoder/ are much more comprehensive.
2019-02-08 02:56:05 -05:00
Slava Pestov
9c8a5b599e ASTDemangler: Fix demangling of weak/unowned/unowned(unsafe)
The check here was incorrect because we might have an optional of a
reference type as well. Just remove the check to keep things simple.
2019-01-29 21:57:06 -05:00
Slava Pestov
a14f345c82 lldb-moduleimport-test: Add support for testing Demangle::getTypeForMangling()
The -type-from-mangled flag now uses the new API. The -type-from-mangled-old flag
uses the old API, ide::getTypeFromMangledSymbolname().

For now, just change all existing tests to use the -type-from-mangled-old flag;
I'll be adding new tests for the new API shortly.
2019-01-25 21:44:02 -05:00
Innovimax
335fe49b0e fix typo (#21473) 2018-12-20 21:37:55 -05:00
Adrian Prantl
d63debeb60 Experimental: Extend ClangImporter to import clang modules from DWARF
When debugging Objective-C or C++ code on Darwin, the debug info
collected by dsymutil in the .dSYM bundle is entirely
self-contained. It is possible to debug a program, set breakpoints and
print variables even without having the complete original source code
or a matching SDK available. With Swift, this is currently not the
case. Even though .dSYM bundles contain the binary .swiftmodule for
all Swift modules, any Clang modules that the Swift modules depend on,
still need to be imported from source to even get basic LLDB
functionality to work. If ClangImporter fails to import a Clang
module, effectively the entire Swift module depending on it gets
poisoned.

This patch is addressing this issue by introducing a ModuleLoader that
can ask queries about Clang Decls to LLDB, since LLDB knows how to
reconstruct Clang decls from DWARF and clang -gmodules producxes full
debug info for Clang modules that is embedded into the .dSYM budle.

This initial version does not contain any advanced functionality at
all, it merely produces an empty ModuleDecl. Intertestingly, even this
is a considerable improvement over the status quo. LLDB can now print
Swift-only variables in modules with failing Clang depenecies, and
becuase of fallback mechanisms that were implemented earlier, it can
even display the contents of pure Objective-C objects that are
imported into Swift. C structs obviously don't work yet.

rdar://problem/36032653
2018-12-05 13:54:13 -08:00
Adrian Prantl
7e6713ed76 Hide irreleveant command line options of lldb-moduleimport-test 2018-11-14 12:18:43 -08:00
Adrian Prantl
97cbd3b1cf Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()
LLDB needs the -swift-version because the -D__swift__ macro affects
how Clang modules are built. This currently has the really odd effect
that when debugging a Swift program that is not using the very latest
Swift version, the first "po" takes several seconds, because the
module cache needs to be rebuilt.

rdar://problem/40241256
2018-08-28 13:04:27 -07:00
Doug Gregor
7a6ad36c7f [lldb-moduleimport-test] Add support for -resource-dir option. 2018-06-26 13:48:13 -07:00
Davide Italiano
73d01b0fed [lldb-moduleimport-test] Improve error detection. 2018-05-14 12:16:12 -07:00
Davide Italiano
5c99c35d24 [lldb-moduleimport-test] Validate input to prevent crashes. 2018-04-17 11:22:15 -07:00
Davide Italiano
eeac130ea3 [lldb-moduleimport-test] Get informations from the module.
This now mirrors what lldb does, and allows us to test this
codepath outside of the debugger.

<rdar://problem/38867076>
2018-04-02 13:05:34 -07:00
Davide Italiano
1c6d19a33c [lldb-moduleimport-test] Remove unused options. NFCI.
<rdar://problem/38867076>
2018-04-02 11:50:12 -07:00
Davide Italiano
23d551e655 [lldb-moduleimport-test] Refactor the whole tool.
This is in preparation for fetching informations directly from
the module instead of specifying them on the cmdline. It will
serve us better as it will mimick more accurately the way lldb
is behaving.

This refactoring moves the validation of the modules earlier
so that we can use the validation info to create the CompileUnit.

<rdar://problem/38867076>
2018-03-30 18:04:02 -07:00
Davide Italiano
5e463b1bc0 [lldb-moduleimport-test] Pass a target triple as a stopgap solution.
We're going to infer all these informations from the module, but
that's a large refactoring task which I'm going to do next.
In the meanwhile, this should allow Adrian's work to be unblocked.

<rdar://problem/38720742>
2018-03-23 13:13:26 -07:00
Davide Italiano
9dbd966e73 [lldb-moduleimport] Add the logic for testing getDeclBySymbolName().
Adrian already found and reported a bug, which I'm going to fix
in a later commit. Eventually this will go away, but in the meanwhile,
we should add test for this codepath.

<rdar://problem/38720742>
2018-03-22 10:47:24 -07:00
Davide Italiano
8cd5e8026b [lldb-moduleimport-test] Address Jordan's post commit review comments. 2018-03-22 10:07:10 -07:00
Davide Italiano
92c4c492a2 [lldb-moduleimport-test] Refactor dump of types from mangled name.
In preparation for adding dump decl from mangled name.
2018-03-22 09:03:08 -07:00
Davide Italiano
9ccdbc1cfa [lldb-moduleimport-test] Introduce a --verbose flag.
<rdar://problem/38323564>
2018-03-15 14:49:48 -07:00
Davide Italiano
06ae7eeff5 [lldb-moduleimport-test] Add a way to test getTypeFromMangledSymbolName.
The only way we had to test this path was through swift-ide-test,
which takes an input a source file, instead of a serialized module.

This is not the scenario that lldb tests, hence this patch.

<rdar://problem/38323564>
2018-03-15 14:39:44 -07:00
Jordan Rose
3cd9f166bc Don't spend time initializing LLVM when running the driver (#14896)
Tiny start-up time optimization noticed while looking at how we do
PrettyStackTraceProgram. Also add PrettyStackTraceProgram to a few
more of our testing tools, via the new PROGRAM_START macro.
2018-02-28 19:56:19 -08:00
Argyrios Kyrtzidis
ca906d1e99 Add '-Fsystem' framework search option to indicate path for frameworks that should be treated as 'system'
This has the effect of propagating the search path to the clang importer as '-iframework'.
It doesn't affect whether a swift module is treated as system or not, this can be done as follow-up enhancement.
2017-02-14 16:13:25 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Mark Lacey
b044c4d74f Fixes for uses of new Expected<T> type in LLVM. 2016-05-03 17:02:54 -07:00
Jordan Rose
8f820dea2b [serialization] Diagnose loading modules from older Swifts.
...with a better message than the generic "older version of the
compiler" one, when we know it's actually a different version of
Swift proper.

This still uses the same internal module version numbers to check
if the module is compatible; the presentation of language versions
is a diagnostic thing only.

Speaking of module version numbers, this deliberately does NOT
increment VERSION_MINOR; it's implemented in a backwards-compatible
way.

This will only work going forwards, of course; all existing modules
don't have a short version string, and I don't feel comfortable
assuming all older modules we might encounter are "Swift 2.2".

rdar://problem/25680392
2016-04-29 16:25:33 -07:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Michael Gottesman
6f2a6271f5 Update lldb-moduleimport-test for changed LLVM API.
Swift SVN r31819
2015-09-09 04:37:51 +00:00
Michael Gottesman
e864f02690 In all executables make sure to completely initialize LLVM.
I also added a macro called INITIALIZE_LLVM(argc, argv) which moves this logic
into one place and should be used at the beginning of *all* binaries. It
initializes an LLVM shutdown object, sets up the pretty stack trace, and then
initializes all of the parts of LLVM. This will make it easy to update this in
the future.

The reason why a macro was required was because of llvm_shutdown_obj, an RAII
object that cleans up LLVM. It has to be at the function level scope of the main
function.

Swift SVN r31815
2015-09-09 04:37:38 +00:00