Commit Graph

4565 Commits

Author SHA1 Message Date
Jordan Rose
32130d3cc3 Teach delayed parsing to get its SourceFile from the saved DeclContext.
This makes it possible to delay decls in more than one source file.

Swift SVN r9672
2013-10-25 17:30:43 +00:00
Jordan Rose
28e01f3c3a Eliminate "MainSourceFile" from TranslationUnit in favor of an array.
Anywhere that assumes a single input file per TU now has to do so explicitly.
Parsing still puts all files in a single SourceFile instance; that's next on
the list.

There are a lot of issues still to go, but the design is now in place.

Swift SVN r9669
2013-10-25 17:30:37 +00:00
Jordan Rose
2aeba96d53 Use SourceFile in a few more places.
- Local name lookup
- AST verification
- Delayed parsing
- Type checker, for the file kind
- Context of synthesized REPL decls

Swift SVN r9648
2013-10-24 18:59:26 +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
Mon Ping Wang
00467ba953 Reintroduce "Add support for Axle library." from 9292. Added an dependency to prevent building the
core and axle core at the same time.


Swift SVN r9309
2013-10-14 07:51:19 +00:00
Joe Groff
cf457d2210 Revert "Add support for Axle library." It breaks the build.
This reverts commit r9292.

Swift SVN r9296
2013-10-13 22:38:22 +00:00
Mon Ping Wang
41aca3e7e6 Add support for Axle library. Please note that AxeBuiltins.gyb will be
expanded soon for the other graphics builtins.


Swift SVN r9294
2013-10-13 19:54:01 +00:00
Argyrios Kyrtzidis
84b0664dab [Frontend] For verifying diagnostics, allow this format: "expected-error@<Relative line offset>{{text}}".
This is similar to clang's diagnostic verifier.

Swift SVN r9292
2013-10-13 18:50:52 +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
Jordan Rose
ce612d3231 Remove TranslationUnit's HasBuiltinModuleAccess field.
This information is important when a SourceFile is created, and never
again after that.

Swift SVN r9240
2013-10-12 00:08:04 +00:00
Argyrios Kyrtzidis
b4f0a4bec0 [Frontend] Introduce "-Xclang" option to pass extra flags to the clang importer.
Swift SVN r9199
2013-10-11 16:28:24 +00:00
Jordan Rose
7b936e2b85 Remove unfinished notion of "Component" (originally for resilience).
docs/Resilience.rst describes the notion of a resilience component:
if the current source file is in the same component as a module being
used, it can use fragile access for everything in the other module,
with the assumption that everything in a component will always be
recompiled together.

However, nothing is actually using this today, and the interface we
have is probably not what we'll want in 2.0, when we actually implement
resilience.

Swift SVN r9174
2013-10-10 21:41:57 +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
9d09d9c7a5 Adopt SourceFile for type checking.
Swift SVN r9106
2013-10-09 22:44:33 +00:00
Jordan Rose
9f7ea273d6 Make performAutoImport work in terms of SourceFiles.
Swift SVN r9078
2013-10-09 18:38:27 +00:00
Jordan Rose
55d4d05b23 Don't automatically create one SourceFile for every TranslationUnit.
Many places are still relying on having one, though.

Swift SVN r9077
2013-10-09 18:38:26 +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
Jordan Rose
f5de2e43d7 Push SourceFile into Parser and REPL somewhat.
Swift SVN r9073
2013-10-09 18:38:17 +00:00
Jordan Rose
597640a5d2 Introduce "SourceFile" within a TranslationUnit.
Right now this is just an extra layer of indirection for the decls,
operators, and imports in a TU, but it's the first step towards compiling
multiple source files at once without pretending they're all in a single
file. This is important for the "implicit visibility" feature, where
declarations from other source files in the same module are accessible
from the file currently being compiled.

Swift SVN r9072
2013-10-09 18:38:15 +00:00
John Garvin
be87761670 Change name to Axle everywhere.
Swift SVN r8686
2013-09-26 01:24:38 +00:00
Anna Zaks
59175bdc08 [SIL] Remove TranslationUnit pointer from SILModule.
This reverts r8624 and compensates by passing the TU to the SILModule printer when needed.

This addresses concerns that Jordan and Sean had raised.

Swift SVN r8678
2013-09-25 23:52:04 +00:00
John Garvin
4a8ac0d752 Parse kernel, vertex, and fragment function attributes. Metadata is not yet being generated.
This is part of <rdar://problem/14951602> AGP5 bring up: Parse AGP5 kernel function attributes.



Swift SVN r8670
2013-09-25 22:16:57 +00:00
Anna Zaks
4c61550b20 [SIL] Use TranslationUnit instead of ASTContext when creating a SILModule.
TU contains Decls that will need to be serialized when we print the SILModule.

Swift SVN r8626
2013-09-25 17:08:40 +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
Chris Lattner
dea8213ef9 remove the -enable-definite-init command line option. Definite init
seems to have stuck.


Swift SVN r7956
2013-09-05 20:37:41 +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
Argyrios Kyrtzidis
019f6dd509 [frontend] For "-I" and "-F" options stick to the space separated form.
Swift SVN r7809
2013-08-30 22:58:35 +00:00
Argyrios Kyrtzidis
cf2928f001 [frontend] For "-I" and "-F" options add aliases to parse them as space separated too.
Swift SVN r7808
2013-08-30 22:44:57 +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
Argyrios Kyrtzidis
ad38cb384b [frontend] Add '-parse-as-library' at the tablegen'ed frontend options.
Swift SVN r7500
2013-08-23 16:46:09 +00:00
Argyrios Kyrtzidis
0306a7f416 [ClangImporter] Stop ClangImporter from trying to figure out where the swift runtime library is,
this should be the responsibility of the caller to provide it.

Swift SVN r7480
2013-08-22 21:49:30 +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
7b3988f74b [frontend] Put CompilerInvocation implementation into its own file.
Swift SVN r7464
2013-08-22 18:29:54 +00:00
Dmitri Hrybenko
70f2b64ad9 Add CharSourceRange -- a half-open character range, which will be used in IDE
integration

Motivation: libIDE clients should be simple, and they should not have to
translate token-based SourceRanges to character locations.

This also allows us to remove the dependency of DiagnosticConsumer on the
Lexer.  Now the DiagnosticEngine translates the diagnostics to CharSourceRanges
and passes character-based ranges to the DiagnosticConsumer.


Swift SVN r7173
2013-08-12 20:15:51 +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
Dmitri Hrybenko
9c57f8454c Do the final cleanups and make SourceLoc::Value private
Swift SVN r7115
2013-08-09 23:52:01 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +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
Sean Callanan
f9a446b410 Added the option to override Clang's resource
directory when constructing a ClangImporter.
This is for lldb, which keeps Clang's resource
directory inside its own framework bundle.


Swift SVN r6833
2013-08-02 02:25:42 +00:00
Dmitri Hrybenko
7684d6dc2a Add a good diagnostic for a hashbang line when it is not allowed
Also centralizes the knowledge about whether the hashbang is allowed in the
SourceManager.  This fixes a bug in tokenize() because previously it just had
to guess.


Swift SVN r6822
2013-08-01 23:07:43 +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
f92237b12a tools/swift: Refactor REPLEnvironment so that it uses libFrontend to create
the TranslationUnit


Swift SVN r6789
2013-08-01 00:03:36 +00:00
Jordan Rose
ecc47bad85 Frontend no longer depends on ClangImporter. Weakly link the entry point.
This closes out <rdar://problem/14513108> -- sil-opt no longer depends on
ClangImporter or any Clang libraries. In theory, however, forcing a load
of a libSwiftClangImporter.dylib would allow sil-opt to process SIL files
containing Clang imports.

Swift SVN r6700
2013-07-29 18:57:10 +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
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