Commit Graph

404 Commits

Author SHA1 Message Date
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
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Argyrios Kyrtzidis
32a6d7dc2f [IDE] Make sure to disable typo-correction when doing code-completion.
Typo-correction can be expensive and we don't need it for code-completion.
2016-11-28 16:19:33 -08: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
John McCall
95eeabb025 Move the -frontend logic into its own library to allow re-use
and abstraction (to come).
2016-04-20 22:54:00 -07:00
Doug Gregor
be90d63a43 Remove the unused EnableCodeCompletionDelayedEnumConformanceHack; NFC 2016-01-13 16:53:01 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Roman Levenstein
4cef619c19 Revert "Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided"
This reverts commit r31863, which was committed by mistake.

Swift SVN r31864
2015-09-10 22:32:36 +00:00
Roman Levenstein
141b8f814d Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided
Till now, a SIL module would be only verified if an optimization has changed it. But if there were no changes, then no verification would happen and some SIL module format errors would stay unnoticed. This was happening in certain cases when reading a textual SIL module representation, which turned out to be broken, but SIL verifier wouldn't catch it.

Swift SVN r31863
2015-09-10 22:26:37 +00:00
Roman Levenstein
66e13af73e Add support for whole-module optimizations for SIL files.
To invoke the front-end on a SIL with whole-module optimizations enabled, execute:
swiftc -frontend myfile.sil

To invoke the front-end on a SIL without whole-module optimizations enabled, add a -primary-file option:
swiftc -frontend -primary-file myfile.sil

To invoke a sil-opt with whole-module optimizations enabled, use the -wmo option:
sil-opt myfile.sil -wmo

This change was need to be able to write SIL unit tests which should be compiled in the WMO mode.

Swift SVN r31862
2015-09-10 22:26:35 +00:00
Jordan Rose
d609aa461d Always serialize absolute search paths.
...and always serialize -working-directory for Clang. (But allow it to be
overridden by a later -Xcc -working-directory.)

Not having this has caused plenty of headaches for the debugger, which is the
primary client of this information. We can still get into bad situations with
search paths that don't exist at all (say, when a built framework is transferred
to another computer), but at least we won't fall over in multi-project workspaces.

This isn't an actual command-line option for a few reasons:

- SourceKit is still using frontend options directly, and they'll need something
  like this to fix rdar://problem/21912068.
- We might want to be more formal about passing this to Clang.
- I don't actually like the existence of such an option for users.

We can revisit this later if the scales tip. Fixing the debugging issue is the
priority.

rdar://problem/21857902

Swift SVN r30500
2015-07-22 20:20:33 +00:00
Ben Langmuir
3982ca5135 Extend the hack that delays enum conformance checking to code-completion
This works around a big performance regression in code completion
performance that was introduced with r25741.  This hack does not work
completely correctly with multiple file builds, but a) this should be a
minor issue for enum code completions, and b) this simply returns to the
pre-25741 behaviour.  This hack should disappear when we fix
rdar://problem/20047340.

For rdar://problem/20445407.

Swift SVN r27320
2015-04-15 16:46:31 +00:00
Erik Eckstein
460eea3b95 Let the frontend options handle multiple output files.
This will be needed for split-llvm code generation.
If multiple -o options are specified and only a single output file is needed
(currently always), the last one wins. This is NFC.



Swift SVN r25884
2015-03-09 16:24:52 +00:00
Manman Ren
a43db3621f [Driver] add InputFileKind to FrontendOptions.
Separate InputFileKind from SourceFileKind, FrontendOptions will now use
InputFileKind, while Module will use SourceFileKind.

This is in preparation for adding an input file kind for LLVM IR.

rdar://19048891


Swift SVN r25555
2015-02-26 19:13:39 +00:00
Jordan Rose
6e96e26a81 Add CompilerInvocation::loadFromSerializedAST.
This is mainly for the debugger's use, to set up CompilerInvocations that
match how a particular app was compiled in certain important ways. Today
that's the target (which is also in the binary), the SDK path (which in
the long run should probably be an SDK name), and any random -Xcc options
we need to pass (which we should probably attempt to minimize).

Because there's only one target and SDK per context, and because -Xcc
options can easily conflict, this is only intended to be used once per
CompilerInvocation.

Note that search paths are not covered by this; they are already being
added at the time the module is loaded. See r24545.

Completes rdar://problem/17670778.

Swift SVN r25227
2015-02-12 05:32:37 +00:00
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Michael Gottesman
85e2502f96 Pass in SILOptions to SILModule.
This should have been done a long time ago since SILOptions are options that
should be able to effect everything SIL related. In this case I just want to
pass in a flag on the SILModule to enable +0 self. By putting it on the
SILModule I can conveniently check it in SILFunctionType without exposing any
internal state from SILFunctionType.cpp.

Swift SVN r23647
2014-12-03 07:43:52 +00:00
Jordan Rose
fc09bd4585 Add basic reference tracking based on name lookups.
This tracks top-level qualified and unqualified lookups in the primary
source file, meaning we see all top-level names used in the file. This
is part of the intra-module dependency tracking work that can enable
incremental rebuilds.

This doesn't quite cover all of a file's dependencies. In particular, it
misses cases involving extensions  defined in terms of typealiases, and
it doesn't yet track operator lookups. The whole scheme is also very
dependent on being used to track file-level dependencies; if C is a subclass
of B and B is a subclass of A, C doesn't appear to depend on A. It only
works because changing A will mark B as dirty.

Part of rdar://problem/15353101

Swift SVN r22925
2014-10-24 22:23:03 +00:00
Jordan Rose
4cce3460c9 Have CompilerInvocation::getMainModule() lazily create the main module.
This allows clients to set up the main module before calling performSema.
This should not affect the compiler in any way.

Swift SVN r22270
2014-09-25 00:15:34 +00:00
Jordan Rose
67144bf52e CompilerInvocation::setModuleName affects both FrontendOpts and IRGenOpts.
This may be something to refactor in the future, but for now the two sets
of options need the module name for entirely different reasons.

rdar://problem/17918172, again.

Swift SVN r22150
2014-09-20 00:25:54 +00:00
Jordan Rose
0481b87ba5 Move target configuration setup into CompilerInvocation.
Without this, clients that don't use a CompilerInstance (like LLDB) won't
have target configuration options available.

Also, move minimum OS checking into the driver. This makes sure the check
happens early (and only once), and in general fits the philosophy of
allowing the frontend to use configurations that might be banned for users.

<rdar://problem/17688913>

Swift SVN r20701
2014-07-29 21:48:59 +00:00
Argyrios Kyrtzidis
65e15380b1 [AST] Introduce ASTContext::getTotalMemory().
This is used to report the memory cost when caching an AST.

Swift SVN r18367
2014-05-18 23:38:23 +00:00
Jordan Rose
2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +00:00
Jordan Rose
db872f666e [Frontend] Make CompilerInvocation::parseArgs additive.
No options should be changed because of the absence of a flag. This is
necessary for clients like LLDB which may have an initial set of options
that differs from the usual set.

Part of <rdar://problem/16776705>

Swift SVN r17819
2014-05-10 01:17:36 +00:00
Argyrios Kyrtzidis
1f430cb4b8 [Frontend] Simplify CompilerInstance::performParseOnly() by only supporting parsing a single file.
Swift SVN r17634
2014-05-07 17:55:19 +00:00
Argyrios Kyrtzidis
796afac0af [Frontend] Rename CompilerInstance::performParse() -> performSema() to make it more clear that it is doing parsing + type checking.
Swift SVN r17597
2014-05-07 02:13:49 +00:00
Argyrios Kyrtzidis
136284430c [Frontend] Separate parse-only functionality into its own function, CompilerInstance::performParseOnly().
Parse-only is a hot path; keep the semantics for it separate from normal parsing, otherwise it is very
easy to introduce something expensive without checking for Invocation.getParseOnly().

Also cleans up a bit CompilerInstance::performParse() as well.

Swift SVN r17596
2014-05-07 02:13:48 +00:00
Nadav Rotem
6a0f2cfcb8 remove more extra semicolons to clean up warnings.
Swift SVN r15486
2014-03-26 05:44:41 +00:00
Adrian Prantl
8892a36321 Emit -resource-dir in the DW_AT_APPLE_FLAGS so LLDB can find Swift Shims.
<rdar://problem/16291929> Unable to evaluate trivial expressions in Cocoa apps

Swift SVN r14938
2014-03-12 00:33:59 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +00:00
Dmitri Hrybenko
255b8e88c8 Fix a leak that I introduced in r14729: FrontendOptions does not own input
buffers, so undo 'unique_ptr'fication here


Swift SVN r14733
2014-03-06 13:53:04 +00:00
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Jordan Rose
230443ae9a [REPL] Don't recursively IRGen imported modules if source imports are off.
This was causing all the external definitions to go from SILGen through
IRGen multiple times per REPL statement. Since this only matters if we
have source modules enabled, just turn it off.

We still generate all the external definitions for every REPL /line/, which
is the cause of <rdar://problem/16164076>.

Swift SVN r14467
2014-02-27 19:28:38 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Jordan Rose
d0d4286d21 Put modules for 32-bit iOS builds in lib/swift/iphone{os,simulator}/32.
This keeps us from having to deal with fat swiftmodules for now.
In the long run we're hoping to solve this problem with build configurations,
so that a single module file can support multiple architectures.
(See <rdar://problem/15056323>)

<rdar://problem/15204953>

Swift SVN r13135
2014-01-30 03:26:50 +00:00
Jordan Rose
12fb34d60f Eliminate "Immediate" flag from CompilerInvocation.
This adds some ugliness in the current swift binary because we weren't
bothering to set a requested action before, but it keeps things simpler
elsewhere. (Thanks, Connor.)

Swift SVN r13067
2014-01-28 22:20:13 +00:00
Connor Wakamo
552558d03f [frontend] Removed the separate TargetOptions class.
TargetOptions only contained the target triple, which was duplicated in
IRGenOptions. These could get out-of-sync, which would cause issues during
IRGen. Since nothing was using TargetOptions other than CompilerInvocation,
removed TargetOptions in favor of making IRGenOptions the canonical home of the
target triple.

Swift SVN r12869
2014-01-23 19:07:55 +00:00
Connor Wakamo
947f3be6e7 [driver] Removed the limited support for -module-source-list.
This option was never honored, and the main functionality that this option
would have implemented has been subsumed by -output-file-map.

Swift SVN r12800
2014-01-22 22:37:21 +00:00
Adrian Prantl
035a1175df Debug info: Ensure that the SDK is emitted if it is implicit. Also do a
slightly better job at quoting.
<rdar://problem/15808224> Point ClangImporter at the right SDK for the target

Swift SVN r12310
2014-01-15 01:51:41 +00:00
Connor Wakamo
b0f27de6b8 [frontend] Move InputKind from CompilerInvocation to FrontendOptions, and move handling of -parse-as-library to ParseFrontendArgs().
Swift SVN r12174
2014-01-11 00:33:30 +00:00
Connor Wakamo
044be74855 [frontend] Move ParseStdlib from CompilerInvocation to FrontendOptions, and move handling of -parse-stdlib to ParseFrontendArgs().
Swift SVN r12173
2014-01-11 00:33:30 +00:00
Connor Wakamo
a35540be40 [frontend] Added CompilerInstance::getPrimarySourceFile().
During CompilerInstance::performParse(), set CompilerInstance::PrimarySourceFile if we create a SourceFile from a buffer whose ID matches the PrimaryBufferID.
This allows clients of CompilerInstance to get a SourceFile for the user-specified primary input.

Swift SVN r12156
2014-01-10 22:39:08 +00:00
Connor Wakamo
9f89b432b5 [frontend] Added CompilerInstance::PrimaryBufferID.
This maps a particular buffer ID to the PrimaryInput, which will (eventually) allow us to map a SourceFile to the PrimaryInput.

Swift SVN r12155
2014-01-10 22:39:07 +00:00
Connor Wakamo
6eb9a82465 [frontend] Switch CompilerInstance::MainBufferIndex to CompilerInstance::MainBufferID.
This matches how we will handle primary inputs.
This also fixes an issue where a file named main.swift may not be chosen as the main file if there were multiple inputs and it was replaced by an input buffer.

Swift SVN r12154
2014-01-10 22:39:07 +00:00
Connor Wakamo
d360c2d167 [frontend] Moved InputBuffers from CompilerInvocation to FrontendOptions.
Swift SVN r12147
2014-01-10 22:39:04 +00:00
Greg Parker
0e360cb26e Install stdlib into /usr/lib/swift/<OS name>/.
This reinstates r11411 with fixes for the autoconf+make build.


Swift SVN r11494
2013-12-20 01:01:35 +00:00