Commit Graph

4565 Commits

Author SHA1 Message Date
Connor Wakamo
20e0d1c64e [frontend] Add support for parsing the action which the integrated frontend should perform.
Added an ActionType enum to FrontendOptions with the various actions that the integrated frontend will support, as well as a new RequestedAction member.
Added support for determining the user’s requested action in ParseFrontendArgs. (The integrated frontend does not yet honor this request; support for that is forthcoming.)

Swift SVN r11372
2013-12-17 02:43:27 +00:00
Connor Wakamo
3b80655e62 [driver] Switched from --help-hidden to -help-hidden.
Left --help-hidden in as an alias for consistency with clang, but -help-hidden is now the primary spelling of this option.

Swift SVN r11350
2013-12-16 19:23:16 +00:00
Connor Wakamo
40dfbc0bc8 [frontend] Add support for parsing ImmediateArgv.
These are not yet used, since the integrated frontend doesn’t yet support immediate mode, but they are ready for use once immediate mode is supported.

Swift SVN r11326
2013-12-15 00:58:28 +00:00
Connor Wakamo
620b5abc20 [frontend] Add support for -disable-diagnostic-passes.
Swift SVN r11322
2013-12-15 00:58:23 +00:00
Connor Wakamo
0d3369be03 [frontend] Add support for -help and --help-hidden.
Added PrintHelp and PrintHelpHidden to FrontendOptions.
Marked both -help and --help-hidden with the FrontendOption flag.
Updated ParseFrontendArgs to parse -help and --help-hidden.
Updated frontend_main() so that it prints the help for the frontend options.

Swift SVN r11320
2013-12-14 23:52:15 +00:00
Connor Wakamo
a1266393cd [frontend] Implemented support for verifying diagnostics with the integrated frontend.
Added a new DiagnosticOptions class to swiftBasic, and added a DiagnosticOptions member to CompilerInvocation.
Added a static ParseDiagnosticArgs function to parse diagnostic-related arguments.
Added -verify to FrontendOptions.td, and added support for parsing -verify in ParseDiagnosticArgs.
Updated frontend_main() to enable and trigger the DiagnosticVerifier when -verify is passed.

Swift SVN r11318
2013-12-14 22:08:08 +00:00
Connor Wakamo
f203e1fd96 [frontend] Moved ModuleSourceListPath from CompilerInvocation to FrontendOptions.
Also moved the handling of -module-source-list from the loop to ParseFrontendArgs.

Swift SVN r11290
2013-12-14 01:44:12 +00:00
Connor Wakamo
8f465324cf [frontend] Split target-related options out from ComplierInvocation into a new TargetOptions class.
Removed CompilerInvocation::TargetTriple and replaced it with CompilerInvocation::TargetOpts, a TargetOptions object.
Added a static ParseTargetArgs function to set up TargetOptions, and moved handling of -target into that function.

Swift SVN r11288
2013-12-14 01:28:13 +00:00
Connor Wakamo
605589922a [frontend] Fix the handling of -debug-constraints-attempt.
StringRef::getAsInteger returns true, not false, when an error occurs.
Explicitly set the radix to 10, instead of inferring the radix.
For the invalid argument value diagnostic, switch the order of the argument string and the value.

Swift SVN r11279
2013-12-13 23:56:31 +00:00
Connor Wakamo
af6da9b455 [ClangImporter] Adjusted ClangImporter::create so that it accepts a ClangImporterOptions instead of individual parameters.
Swift SVN r11240
2013-12-13 04:52:59 +00:00
Connor Wakamo
48a111b0b3 [ClangImporter] Switch ClangImporter::create from directly accepting search path information to using the ASTContext’s SearchPathOptions.
Swift SVN r11239
2013-12-13 04:52:59 +00:00
Connor Wakamo
20ce2ba390 [frontend] Moved SDKPath from CompilerInvocation to SearchPathOptions.
Swift SVN r11237
2013-12-13 04:52:58 +00:00
Jordan Rose
1011340094 Always record known protocols even when there are no source inputs.
This isn't significant yet, but it will be once we can load partial ASTs.

Swift SVN r11225
2013-12-13 00:26:12 +00:00
Connor Wakamo
9a1c706be7 [frontend] Moved FrameworkSearchPaths from CompilerInvocation to SearchPathOptions.
Swift SVN r11216
2013-12-12 22:36:42 +00:00
Connor Wakamo
1ecc5cc3e6 [frontend] Moved ImportSearchPaths out of CompilerInvocation/ASTContext and into SearchPathOptions.
Also updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to get the ImportSearchPaths from the ASTContext’s SearchPathOpts, instead of directly from the ASTContext.

Swift SVN r11214
2013-12-12 22:15:58 +00:00
Connor Wakamo
86b4a3b049 [frontend] Begin moving search path-related options into SearchPathOptions.
Added a new SearchPathOptions class to swiftAST, which will contain options like import search paths and the SDK path.
Moved the RuntimeIncludePath from CompilerInvocation into SearchPathOptions. For now, at least, the RuntimeIncludePath is handled separately from other ImportSearchPaths, since we can’t yet guarantee that RuntimeIncludePath is set up before we parse the ImportSearchPaths.
Added a SearchPathOptions member to ASTContext.
Updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to check RuntimeIncludePath after everything else if no module was found. (This matches existing behavior, which had RuntimeIncludedPath at the end of ImportSearchPaths.)

Swift SVN r11213
2013-12-12 21:38:11 +00:00
Connor Wakamo
e6b0f16ad0 [frontend] Add support for -print-stats.
Swift SVN r11190
2013-12-12 17:44:51 +00:00
Connor Wakamo
23a60d60d8 [frontend] Added support for -delayed-function-body-parsing.
Swift SVN r11188
2013-12-12 17:32:02 +00:00
Connor Wakamo
a4f766e430 [frontend] Add support for -emit-sil-protocol-witness-tables.
Swift SVN r11187
2013-12-12 17:32:01 +00:00
Connor Wakamo
04bdf73b91 [frontend] Move options for controlling the behavior of the Clang importer into a new ClangImporterOptions class.
Added a new ClangImporterOptions class which wraps the ModuleCachePath and ExtraArgs for the Clang importer.
Added a new ParseClangImporterArgs static function which fills in the passed-in ClangImporterOptions.
Updated CompilerInvocation and CompilerInvocation::parseArgs() to use ClangImporterOptions and ParseClangImporterArgs, respectively.

Swift SVN r11180
2013-12-12 03:53:20 +00:00
Connor Wakamo
adbd61d024 [frontend] Added support for -debug-constraints-attempt.
Swift SVN r11174
2013-12-12 03:17:44 +00:00
Connor Wakamo
b4ea0c8b73 [frontend] Added support for the -use-malloc flag.
Added a new static ParseLangArgs, which fills in a LangOptions object.
Also moved the handling of -debug-constraints out of the loop in CompilerInvocation::parseArgs() and into ParseLangArgs, now that it has a proper home.

Swift SVN r11172
2013-12-12 02:44:34 +00:00
Connor Wakamo
4ede1d0c23 [frontend] Added support for parsing the “-emit-verbose-sil” frontend argument.
This is not yet hooked up anywhere (beyond FrontendOptions), since the integrated frontend does not yet know how to emit SIL.

Swift SVN r11161
2013-12-12 00:48:13 +00:00
Connor Wakamo
b434cfe19a Updated comment.
Swift SVN r11158
2013-12-12 00:48:11 +00:00
Connor Wakamo
295b438d23 [frontend] Check for unknown arguments before attempting to handle other arguments.
Moved the check for unknown arguments ahead of any other attempts to handle arguments.
Added test/Frontend/unknown-arguments.swift, which tests the unknown argument handling of "swift_driver -frontend".

Swift SVN r11157
2013-12-12 00:23:35 +00:00
Connor Wakamo
59c07ab012 [frontend] Began splitting options in CompilerInvocation into separate classes.
Added a new FrontendOptions class, which will eventually contain the options for controlling the behavior of the frontend. (This is similar to Clang’s FrontendOptions class.)
Moved InputFilenames, OutputFilename, ModuleName, and SerializedDiagnosticsPath from CompilerInvocation into FrontendOptions.
Split out argument parsing for options in FrontendOptions into a separate ParseFrontendArgs static function.

Swift SVN r11155
2013-12-11 23:58:55 +00:00
Connor Wakamo
93fcbed8b6 [frontend] Switch from a default case to OPT_UNKNOWN for catching unknown arguments.
The integrated frontend already doesn't handle certain arguments which it understands (such as, for the moment, '-c'), so only emit an error in the event of an unknown option, not just unhandled options.

Swift SVN r11110
2013-12-11 01:29:18 +00:00
Connor Wakamo
c6d23228db [frontend] Updated CompilerInvocation::parseArgs() so that it emits a diagnostic when it encounters an unknown argument.
Added a test which ensures that the driver invokes the integrated frontend in a way which does not produce any errors, in order to catch mismatches between the options the driver passes to the integrated frontend and the options which the integrated frontend accepts.

Swift SVN r11105
2013-12-11 00:26:06 +00:00
Chris Lattner
ae413a8fcd restore a makefile overly zapped by r11082
Swift SVN r11091
2013-12-10 21:15:34 +00:00
Connor Wakamo
02c1532d27 Initial support for an integrated frontend in swift_driver.
- Added support for invoking the Swift frontend via "swift_driver -frontend".
- Added frontend_main.cpp, which implements the main entry point for the
  integrated frontend. (Currently, this supports compiling an input Swift file
  into an object file.)
- Removed lib/Frontend/FrontendOptions.td, and replaced its functionality with
  options in include/Swift/Driver/Options.td and a new
  include/Swift/Driver/FrontendOptions.td. Options supported by the frontend
  are denoted by the FrontendOption flag; options which are not supported by
  the driver are denoted by the NoDriverOption flag.
- Updated CompilerInvocation::parseArgs() to use the option table returned from
  createDriverOptTable(), including renaming a handful of options. (-triple is
  now -target, and -Xclang is now -Xcc.)

Swift SVN r11082
2013-12-10 18:06:54 +00:00
Argyrios Kyrtzidis
25a7832a98 [Frontend] In FrontendOptions.td, add aliases for '-I'/'-F' options with '=' as separator.
Swift SVN r11000
2013-12-08 20:32:30 +00:00
Argyrios Kyrtzidis
041a49bb95 [Frontend] Add '-module-name' to FrontendOptions.td.
Swift SVN r10991
2013-12-08 07:39:49 +00:00
Jordan Rose
439ba3e624 Accept swiftmodule files on the command line as partial AST inputs.
Each loaded file gets added to the main module, rather than being a standalone
separate module. In theory, this will be used to assemble several partial
ASTs into a complete module. In practice, there's still a ways to go...but
this can already round-trip a single module file.

This also factors out the FileUnit-creating part of SerializedModuleLoader,
which should help clients like SourceKit that don't need to search for a
swiftmodule file associated with a particular import.

Swift SVN r10952
2013-12-07 00:14:01 +00:00
Jordan Rose
b4e4b551bd Rename CompilerInstance::doIt to performParse.
'doIt' is semantically meaningless, and doesn't mention the fact that nothing
has actually been compiled yet (to SIL, to IR, or to machine code).
'performParse' matches the compiler flag -parse, which stops after
type-checking.

No functionality change.

Swift SVN r10951
2013-12-07 00:13:58 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Jordan Rose
eede5ec4f9 Begin refactoring for mixed file kinds within a single module.
The goal of this series of commits is to allow the main module to consist
of both source files and AST files, where the AST files represent files
that were already built and don't need to be rebuilt, or of Swift source
files and imported Clang headers that share a module (because they are in
the same target).

Currently modules are divided into different kinds, and that defines how
decls are looked up, how imports are managed, etc. In order to achieve the
goal above, that polymorphism should be pushed down to the individual units
within a module, so that instead of TranslationUnit, BuiltinModule,
SerializedModule, and ClangModule, we have SourceFile, BuiltinUnit,
SerializedFile, and ClangUnit. (Better names welcome.) At that point we can
hopefully collapse TranslationUnit into Module and make Module non-polymorphic.

This commit makes SourceFile the subclass of an abstract FileUnit, and
makes TranslationUnit hold an array of FileUnits instead of SourceFiles.
To demonstrate that this is actually working, the Builtin module has also
been converted to FileUnit: it is now a TranslationUnit containing a single
BuiltinUnit.

Swift SVN r10830
2013-12-05 01:51:03 +00:00
Jordan Rose
fb0fa908b6 [Frontend] Parse the main file last to make sure implicit visibility works.
Otherwise, we'll try to type-check bits of the main source file before we've
even looked at any of the supporting files.

This affects implicit multi-file mode, where "main.swift" is assumed to be
the main source file and all others are treated as library files. (See r9890.)

<rdar://problem/15526743>

Swift SVN r10795
2013-12-04 21:54:43 +00:00
Argyrios Kyrtzidis
de6cb0bcfe [Frontend] Handle '-module-source-list' in CompilerInvocation::parseArgs.
Swift SVN r10327
2013-11-10 23:49:35 +00:00
Argyrios Kyrtzidis
5a673d2e77 [Frontend] Handle '-serialize-diagnostics' in CompilerInvocation::parseArgs.
Swift SVN r10326
2013-11-10 23:49:34 +00:00
Connor Wakamo
2b3a922aa5 Move SerializedDiagnosticConsumer into swiftFrontend.
This matches where Clang implements its equivalent, and this makes it available to both swift and the new driver.

Swift SVN r10047
2013-11-08 19:26:13 +00:00
Argyrios Kyrtzidis
ac8d86d2d6 [Frontend] In CompilerInvocation::parseArgs() parse the output filename argument.
Swift SVN r10043
2013-11-08 18:29:39 +00:00
Argyrios Kyrtzidis
6fb1dce5c1 [Frontend] When setting up the buffers for a CompilerInstance, allow a memory buffer to
provide the contents of a filename, based on its buffer identifier.

Swift SVN r10042
2013-11-08 18:29:38 +00:00
Argyrios Kyrtzidis
44d46de7c9 Use swift::SourceManager's addNewSourceBuffer() instead of llvm::SourceMgr's AddNewSourceBuffer().
Also remove the SourceLoc parameter from addNewSourceBuffer(). In llvm::SourceMgr
it is used to indicate textual inclusion, which we don't have in swift.

Swift SVN r10014
2013-11-07 00:51:56 +00:00
Argyrios Kyrtzidis
5183cec03d [Frontend] In CompilerInvocation::parseArgs() handle the input filenames as well.
Swift SVN r10013
2013-11-07 00:51:54 +00:00
Jordan Rose
b43dd09107 All SourceFiles should always remember their buffer IDs, not just imports.
Swift SVN r9946
2013-11-04 23:50:48 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Jordan Rose
aeb22194a0 [driver] Treat "main.swift" as the main source file if given multiple inputs.
New rules for the driver (first match):
1. -repl: no input files allowed
2. -parse-sil: one input file allowed
3. -parse-as-library: any number of input files, all treated as Library
4. one input, extension is .sil: treated as SIL
5. one input: treated as Main
6. many inputs: treated as Library by default; "main.swift" is treated as Main

If we want more control here we can also add a -main-file option to explicitly
call out the main source file, but this at least unblocks building an entire
app target (like ListMaker) with a single Swift invocation.

Swift SVN r9890
2013-11-02 01:08:40 +00:00
Joe Groff
003709d51f SIL: Add a backreference from SILModule to its originating Swift Module.
Ideally this wouldn't be necessary, but the type substitution APIs required by generic specialization and SIL verification currently require a Module* pointer, and it's obnoxious to have to pass it down separately everywhere it's needed. Longer-term the reliance on Modules for type substitution might be able to go away.

Swift SVN r9866
2013-11-01 00:46:21 +00:00
Jordan Rose
a333b692b4 Flip the switch: multiple input files = multiple SourceFiles.
There is still plenty of fallout to get everything fully correct, but
right now we can build the standard library and run all the tests in
multiple-file mode.

Swift SVN r9673
2013-10-25 17:30:45 +00:00