Commit Graph

199 Commits

Author SHA1 Message Date
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
20ce2ba390 [frontend] Moved SDKPath from CompilerInvocation to SearchPathOptions.
Swift SVN r11237
2013-12-13 04:52:58 +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
23a60d60d8 [frontend] Added support for -delayed-function-body-parsing.
Swift SVN r11188
2013-12-12 17:32:02 +00:00
Connor Wakamo
8661d230b4 [frontend] Added an accessor to CompilerInvocation to get the invocation's ClangImporterOptions.
Swift SVN r11181
2013-12-12 03:59:58 +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
a5a67f90ab [frontend] Added an accessor to CompilerInvocation to get the invocation’s FrontendOptions.
Swift SVN r11160
2013-12-12 00:48:12 +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
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
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
Argyrios Kyrtzidis
ac8d86d2d6 [Frontend] In CompilerInvocation::parseArgs() parse the output filename argument.
Swift SVN r10043
2013-11-08 18:29:39 +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
Jordan Rose
40c7f25c55 [driver] Pull code generation out into its own function.
No functionality change.  Paves the way for generating separate .o
files for each input file.

Swift SVN r9827
2013-10-30 23:44:56 +00:00
Jordan Rose
f7f253320a Re-add -l flag to Swift interim driver.
This is useful in -i and REPL modes, which do not have a separate linking
step. This version of the -l flag doesn't rely on TranslationUnit. I also
cleaned up the library-loading diagnostics.

Swift SVN r9488
2013-10-18 18:52:10 +00:00
Jordan Rose
ad75aa5021 Remove -l flag from Swift interim driver.
Being able to pass -l to the driver isn't so interesting, and it's an
extra field that lives on TranslationUnit for no reason. Just remove it.

This doesn't interfere with autolinking, i.e. inferring -l flags based on
imported modules.

Swift SVN r9241
2013-10-12 00:08:06 +00:00
Argyrios Kyrtzidis
de05f4570a [Frontend] Add a const version of CompilerInvocation::getLangOptions.
Swift SVN r9135
2013-10-10 14:51:36 +00:00
Jordan Rose
5ed38c0b72 Clarify SourceFile vs. TranslationUnit interfaces for SILGen and IRGen.
Once we have multiple SourceFiles in a TranslationUnit, it no longer makes
sense to say "only SILGen decls starting from element N" without specifying
which source file you mean.

Also, clarify ownership by having performSILGeneration return a unique_ptr
instead of just a bare pointer.

Swift SVN r9112
2013-10-09 23:44:43 +00:00
Jordan Rose
09787207fc Push TUKind into SourceFile (as InputKind).
Different SourceFiles in the same module will eventually have different
input kinds (at the very least Main vs. Library).

Swift SVN r9076
2013-10-09 18:38:25 +00:00
Argyrios Kyrtzidis
6ee8877fbd [frontend] Enhance CompilerInvocation to accept an array of extra arguments to pass to the clang importer.
Swift SVN r8175
2013-09-13 01:16:28 +00:00
Adrian Prantl
d929050173 Implement SerializedModuleLoader::addASTSection() to parse AST sections as
created by IrGen/SwiftASTStreamerPass.

Swift SVN r7851
2013-09-03 18:09:53 +00:00
Jordan Rose
fa3dd42c54 Don't parse function bodies in imported TUs.
...unless the functions are declared [transparent], or if we're in an
immediate mode (in which case we won't get a separate chance to link
against the imported TUs).

This is an optimization that will matter more when we start dealing with
Xcode projects with many cross-file dependencies, especially if we have
some kind of implicit import of the other source files in the project.

In the future, we may want to parse more function bodies for the purpose
of inlining, not just the transparent ones, but we weren't taking
advantage of that now, so it's not a regression. (We're still not taking
advantage of it even for [transparent] functions.)

Swift SVN r7698
2013-08-28 22:53:28 +00:00
Jordan Rose
22912bc3b3 Add a -l flag to Swift and use it to provide autolinking information.
The spelling of the flag can certainly be changed; I just wanted to get
something up and running.

Swift SVN r7582
2013-08-26 18:57:48 +00:00
Chris Lattner
af1a8205b8 rename tools/swift/Frontend.{h|cpp} -> Helpers.{h|cpp} to avoid hopelessly
confusing me with the Frontend library.  Add some more include guards around
the real Frontend.h header.


Swift SVN r7570
2013-08-26 16:08:34 +00:00
Argyrios Kyrtzidis
8c9a7a581f Introduce parsing of frontend options using LLVM's tablegen'ed Options infrastructure.
Implement CompilerInvocation::parseArgs(), which parses a list of arguments and initializes
the CompilerInvocation object.

Swift SVN r7473
2013-08-22 20:21:07 +00:00
Argyrios Kyrtzidis
ae65ab1ee0 Introduce NullClangImporter library which is for clients that don't want to link Clang.
ClangImporter::create had a 'weak' attribute but it did not actually have the desired effect,
static libraries still want to link to ClangImporter::create if it is used.
Avoiding linking ClangImporter kinda "worked" because CompilerInvocation::setSDKPath was inline,
so if you didn't call it then you didn't need to link to Clang importer, but that is avoiding
ClangImporter statically, not dynamically.
You could see this by moving CompilerInvocation::setSDKPath out-of-line and then sil-opt would fail to link.

In order to have clients avoiding linking Clang, introduce NullClangImporter which just returns null for the
ClangImporter constructor function.

Swift SVN r7465
2013-08-22 18:29:58 +00:00
Argyrios Kyrtzidis
d57a6a18f0 [frontend] Introduce CompilerInvocation::setRuntimeIncludePath()
Also have CompilerInvocation store the RuntimeIncludePath and calculate it via the MainExecutablePath
instead of the other way around (store MainExecutablePath and calculate RuntimeIncludePath when requested)

Swift SVN r7170
2013-08-12 19:20:21 +00:00
Chris Lattner
121e70f4fa Refactor diagnostic verification (-verify mode) out to its own file
in libFrontend.


Swift SVN r6985
2013-08-07 17:53:09 +00:00
Dmitri Hrybenko
849ad1a14d libFrontend, swift-ide-test: add -F option to specify framework search paths
Swift SVN r6950
2013-08-06 21:12:05 +00:00
Dmitri Hrybenko
5cea4ebf41 Code completion: put CodeCompletionOffset on SourceManager instead of passing
around everywhere

Fixes:
rdar://14585108 Code completion does not work at the beginning of the file
rdar://14592634 Code completion returns zero results at EOF in a function
                without a closing brace


Swift SVN r6820
2013-08-01 22:08:58 +00:00
Dmitri Hrybenko
e1c4ae3174 Wrap llvm::SourceMgr in swift::SourceManager so that we can add new members
to the source manager.


Swift SVN r6815
2013-08-01 20:39:22 +00:00
Dmitri Hrybenko
497ec93ec9 Code completion: generate a tok::code_complete token during the first pass of
parsing

No functionality change, this will be used by next commits.


Swift SVN r6637
2013-07-26 01:40:47 +00:00
Dmitri Hrybenko
dbb1c23930 Rename functions and variables from "Delay[...]Parsing" to
"Delayed[...]Parsing" for consistency


Swift SVN r6586
2013-07-25 04:04:46 +00:00
Argyrios Kyrtzidis
66d1e516c8 Refactor how multiple parsing passes and delayed parsing works.
-Introduce PersistentParserState to represent state persistent among multiple parsing passes.
  The advantage is that PersistentParserState is independent of a particular Parser or Lexer object.
-Use PersistentParserState to keep information about delayed function body parsing and eliminate parser-specific
  state from the AST (ParserTokenRange).
-Introduce DelayedParsingCallbacks to abstract out of the parser the logic about which functions should be delayed
  or skipped.

Many thanks to Dmitri for his valuable feedback!

Swift SVN r6580
2013-07-25 01:40:16 +00:00
Argyrios Kyrtzidis
5536e61e59 [Frontend] Keep a list of input files in CompilerInvocation and create input buffer IDs as part of CompilerInstance::setup().
Swift SVN r6497
2013-07-23 14:49:31 +00:00
Argyrios Kyrtzidis
200e64d8c2 [Frontend] Refactor CompilerInvocation to be a pure settings object.
This mainly removes the extraneous DiagnosticEngine and SourceMgr from CompilerInvocation.
Instances of these can be found via the CompilerInstance object.

Swift SVN r6496
2013-07-23 14:49:29 +00:00
Chris Lattner
a4b73c447a use a typedef+decltype to clean up an ugly type signature.
pass vectors by const& instead of using std::move on a mutable reference.


Swift SVN r6473
2013-07-22 21:25:37 +00:00
Chris Lattner
e0f19cfb4e Feedback from Dmitri
Swift SVN r6466
2013-07-22 20:42:11 +00:00
Chris Lattner
2f94493ff3 pass a variety of things by reference instead of by value in the invocation's setters.
Add a little dance in the setup of the Clang importer.  Now, clients that don't care
about the clang importer don't have to link it in, just don't call setSDKPath()


Swift SVN r6462
2013-07-22 19:51:08 +00:00
Dmitri Hrybenko
3c5b12fc0f Code completion: add a lot of infrastructure code
* Added a mode in swift-ide-test to test code completion.  Unlike c-index-test,
  the code completion token in tests is a real token -- we don't need to
  count lines and columns anymore.

* Added support in lexer to produce a code completion token.

* Added a parser interface to code completion.  It is passed down from the
  libFrontend to the parser, but its functions are not called yet.

* Added a sketch of the interface of code completion consumer and code
  completion results.

Note: all this is not doing anything useful yet.


Swift SVN r6128
2013-07-10 20:53:40 +00:00
Dmitri Hrybenko
cb98234d67 Allow the parser to persist after parseIntoTranslationUnit() returns
Swift SVN r6102
2013-07-10 00:25:37 +00:00
Dmitri Hrybenko
5be7592574 Make buildSingleTranslationUnit() an implementation detail of libFrontend
Swift SVN r6070
2013-07-08 22:24:40 +00:00
Dmitri Hrybenko
c7421211a3 Factor out logic that creates and configures all objects required for
compilation into a 'Frontend' library.

This library is still not in its best shape, but now it can be reused in
swift-index-test.


Swift SVN r6040
2013-07-06 00:46:19 +00:00
Dmitri Hrybenko
70246e8b89 Move swift::buildSingleTranslationUnit to a new library, libFrontend
It should be split and/or generalized in order to become reusable.


Swift SVN r5974
2013-07-03 20:50:21 +00:00