Commit Graph

351 Commits

Author SHA1 Message Date
Harlan Haskins
ca5b94f7d9 [Frontend] Re-add FrontendObserver methods (#24917)
These observer methods were used by external clients. Since we no longer
have the granularity between diagnostics and optimization, they're
rolled into a new observer callback, `performedSILProcessing`.

This (effectively) reverts commit 7b43e1d04d.
2019-05-20 21:33:33 -07:00
Harlan Haskins
5cb98bfe80 [ModuleInterface] Pass -Rmodule-interface-rebuild to sub-invocation (#24737)
Previously, we wouldn't pass this flag to sub-invocations, which means
that if we had to fall back and recompile a transitive import, we
wouldn't get a remark.

rdar://50729662
2019-05-13 12:56:18 -07:00
Jordan Rose
3eff026bbf [ModuleInterfaces] Warn emitting without -enable-library-evolution
Module interfaces don't yet carry enough information to correctly
describe the binary interface of a module compiled without
-enable-library-evolution, but we don't want to make this an error
because that would make it harder to work towards getting it in the
future.
2019-05-01 17:32:12 -07:00
Jordan Rose
73b7185a3d [ModuleInterfaces] Warn emitting an interface in -swift-version 4[.2]
If the project ever drops Swift 4 mode or Swift 4.2 mode, that would
break modules using those modes in their interface, so put an
unsilenceable warning in for using those modes to nudge interface
emitters to Swift 5.

rdar://problem/47792595
2019-05-01 17:32:12 -07:00
Slava Pestov
33b548f8b0 AST: Remove SourceFile::UsedConformances
Sema no longer adds conformances to a per-SourceFile list that it thinks
are going to be "used" by SILGen, IRGen and the runtime. Instead, previous
commits already ensure that SILGen determines the set of conformances to be
emitted, triggering conformance checking as needed.
2019-04-25 22:32:27 -04:00
Harlan Haskins
e5456984f7 [ModuleInterfaces] Remove 'parseable' from command-line flags
Leave the old flag in as an alias to the new flag, for transition
purposes. Also go ahead and remove the long-deprecated and unused
`emit-interface-path`.

Part of rdar://49359734
2019-04-11 18:05:09 -07:00
David Ungar
cf5d81c889 Merge pull request #23735 from davidungar/tracking-primary
[Batch mode] Cope with bugs that cause error  suppression.
2019-04-05 17:45:20 -07:00
David Ungar
c8cd0f3bc0 Move location lookup to RAII object. 2019-04-04 22:41:53 -07:00
David Ungar
240b573966 WIP 2019-04-04 21:55:25 -07:00
David Ungar
aafc2a3dda Better idiom for sometimes RAII. 2019-04-04 16:59:32 -07:00
David Ungar
8448da303d Use MSF not mainInputFilenameForDebugInfo 2019-04-04 15:36:53 -07:00
David Ungar
5c837323a0 WIP 2019-04-04 13:58:08 -07:00
David Ungar
7428feef72 Format 2019-04-03 16:21:20 -07:00
David Ungar
d0330523d0 suppress non-primary errors if there is no responsible primary 2019-04-03 16:19:45 -07:00
David Ungar
44daa88ebd Format 2019-04-03 12:53:31 -07:00
David Ungar
9cc3a4a9d8 Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic. 2019-04-03 12:52:49 -07:00
David Ungar
fd63a1ea73 Change strategy for non-primaries
No more vacuous subconsumers. Output into active primary or everywhere.
2019-04-03 11:38:58 -07:00
Nathan Hawes
f683373116 [ParseableInterface] Respect -track-system-dependencies with -build-module-from-parseable-interface
Updates the subinvocation that builds the parseable interface to respect the
-track-system-dependencies flag of the top-level invocation if present, by
including system dependencies in the produced .swiftmodule.
2019-04-03 06:34:29 -07:00
David Ungar
0baa668920 Format 2019-04-02 22:28:38 -07:00
David Ungar
c139c5909a Pass defaultDiagnosticLoc to handleDiagnostic, not currentPrimaryInput. 2019-04-02 22:27:55 -07:00
David Ungar
c90d9e69b6 Format 2019-04-02 00:43:59 -07:00
David Ungar
7a0e0ffc8a Store current primary in diagnostic engine, pass it down via handleDiagnostic. Unformmated. 2019-04-02 00:43:28 -07:00
Harlan Haskins
366bbf48b9 [ParseableInterface] Add ‘forwarding modules’
A ‘forwarding module’ is a YAML file that’s meant to stand in for a .swiftmodule file and provide an up-to-date description of its dependencies, always using modification times.

When a ‘prebuilt module’ is first loaded, we verify that it’s up-to-date by hashing all of its dependencies. Since this is orders of magnitude slower than reading mtimes, we’ll install a `forwarding module` containing the mtimes of the now-validated dependencies.
2019-03-07 11:36:15 -08:00
Saleem Abdulrasool
d30a2ababd FrontendTool: fix escaping of filenames in Makefile
The dependency file that is being generated should not escape : and # in
the filename.  This makes the behaviour of the filename escaping similar
to clang and GCC and fixes incorrect quoting of paths on Windows.
2019-02-19 10:51:26 -08:00
David Ungar
26ef59f576 Fixes from master 2019-01-24 18:46:49 -08:00
David Ungar
b520b242dc Collapsed lots of changes. 2019-01-24 18:46:49 -08:00
Michael Gottesman
4fd45930f8 [sil-optimizer] At -Onone serialize when running the Onone optimization pipeline instead of after running SIL passes.
NOTE: This is not in the mandatory passes (which run before this). This will
enable me to strip out ownership after we serialize without touching frontend
code. It also makes Onone and O use the same code paths for serialization
instead of one happening in the driver (Onone today) and the other in a SIL pass
(-O, -Osize).

The reason that I updated the sil-func-extractor test is that I found a bug in
how we emit sib files, namely if you try to emit a sib file to stdout, the
llvm-bcanalyzer flags it as malformed. If I output the .sib into a file rather
than trying to use stdout, everything works.
2019-01-14 10:33:58 -08:00
Jordan Rose
614deb640b [ParseableInterface] Pass prebuilt cache path down to sub-invocations
Otherwise, the top-level compilation gets the benefit of the prebuilt
cache path, but the sub-invocations for swiftinterfaces that /do/
need to be compiled do not.
2018-12-21 15:41:17 -08:00
Jordan Rose
37708ede6e Add frontend mode -build-module-from-parseable-interface
Makes it easier to test the caching behavior, and may also be useful
for "prebuilding" swiftinterfaces in the future, or having the Driver
kick off a bunch of separate builds as proper tasks.
2018-12-13 11:18:05 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Harlan Haskins
f5cf517f6a [Frontend] Factor out SIL processing code to Frontend
This lets us reuse the logic for running optimization passes between regular frontend invocations and parseable interface compilation.
2018-12-03 13:17:35 -08:00
Harlan Haskins
7b43e1d04d [FrontendTool] [NFC] Reduce scope of FrontendObserver
These APIs weren't used.
2018-11-29 19:18:56 -08:00
Saleem Abdulrasool
19a76ea042 FrontendTool: fix a use-after-move on Windows
The order of evaluation of arguments is undefined by the language
specification.  Windows evaluates right to left rather than left to
right.  This means that the argument was getting moved away before
initializing the first formal argument.  Use a temporary to construct
the value to avoid the use-after-move.
2018-11-21 14:23:59 -08:00
Vinicius Vendramini
39d3963131 Fix broken tests
- Many tests got broken because of two things:
  - AST dump now outputs to stdout, but many tests expected stderr. This was a straightforward fix.
  - Many tests call swift with specific parameters; specifically, many call `swift frontend` directly. This makes them go through the compiler in unexpected ways, and specifically it makes them not have primary files, which breaks the new AST dump implementation. This commit adds the old implementation as a fallback for those cases, except it dumps to `stdout` to maintain some consistence.

Finally, the `/test/Driver/filelists.swift` failed for unknown reasons. It seems its output now had some lines out of order, and fixing the order made the test pass. However, as the reasons why it failed are unknown, this fix might not have been a good idea. Corrections are welcome.
2018-11-14 13:38:01 -02:00
Vinicius Vendramini
5e9997d7f0 Add a FIXME to warn about potential WMO bugs. 2018-11-14 13:38:01 -02:00
Vinicius Vendramini
d392c2af04 Fixes from the code review.
- Adds a space after the `for`;
- Changes `Instance` to use `getASTContext` directly.
- The `getFileOutputStream` method already checks for the `"-"` file name and returns `stdout` in that case. Replace the current (redundant) check with that one, and therefore replace the current default (`stderr`) with `stdout`.
2018-11-14 13:38:01 -02:00
Vinicius Vendramini
9843349503 Fix the dumpAST function to work in batch mode.
Also removes the unnecessary `Invocation` parameter.
2018-11-14 13:38:01 -02:00
Vinicius Vendramini
e123750c12 Add option to dump AST to files
This adds two things:
- Calling `swiftc -dump-ast foo.swift [...] -o foo.ast` will dump the AST to the file `foo.ast`, instead of dumping it to `stderr` as usual.
- Calling `swiftc -dump-ast -output-file-map=outputFileMap.json *.swift [...]`, given an `outputFileMap.json` file that contains entries in the form `"ast-dump": "foo.ast"`, will dump the ASTs of the input files to their respective output files in the file map.

This should serve as a valid workaround to a bug mentioned in [the forums](https://forums.swift.org/t/error-when-dumping-the-ast-for-hundreds-of-files/17578) where the AST dump functionality crashes when called with too many input files. A few implementation details were also discussed in the same forum post.

As an aside, this also fixes a comment in `include/swift/Basic/PrimarySpecificPaths.h` that was incorrect.
2018-11-14 13:38:01 -02:00
Graydon Hoare
fa95f7aebd [ModuleInterface] Factor out common AST-layer withOutputFile helper. 2018-10-18 00:31:24 -07:00
Graydon Hoare
5e202697a3 [ModuleInterface] Mop up remaining "textual interface" terminology. 2018-10-11 23:56:19 -07:00
Graydon Hoare
86cd6ed909 [ModuleInterface] Move computeSerializationOptions to CompilerInvocation. 2018-10-11 16:43:52 -07:00
Graydon Hoare
45e6b25da4 [ModuleInterface] Rename TextualInterfaceGeneration.{cpp,h} to TextualInterfaceSupport.{cpp,h} 2018-10-11 16:43:51 -07:00
Graydon Hoare
c0f8dd20dd [ModuleInterface] Call printToolVersionAndFlagsComment when emitting .swiftinterface. 2018-10-11 16:43:49 -07:00
Graydon Hoare
196fbbfc46 [ModuleInterface] Add new TextualInterfaceOption flag, move TextualInterfaceGeneration.{h,cpp} 2018-10-11 16:43:48 -07:00
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00
Jordan Rose
3ea754481e [Frontend] Allow -emit-interface with -typecheck (#19676)
Textual module interfaces don't actually depend on SILGen, so we
shouldn't need to run SILGen (or serialize an entire binary module) if
we're just trying to emit a textual interface. On the other hand, if
we /are/ going to run SILGen and then SIL diagnostics, we shouldn't
delay those diagnostics by spending time emitting a textual interface,
or for that matter a TBD file.

Using this, update all the ModuleInterface tests that use
`-emit-module -o /dev/null` to use `-typecheck` instead, except for
those using `-merge-modules`.
2018-10-03 15:07:31 -07:00
Jordan Rose
91d1abf8b0 [Stats] Track NumASTBytesAllocated continuously
...so it can be used with flamegraphs.
2018-09-28 13:43:36 -07:00
Jordan Rose
a9bbaf751f Assume a SILModule is whole-module when SILGen-ing from a ModuleDecl
No functionality change. Unfortunately we still need the flag in
SILModule itself because of the ability to create an empty SILModule
and parse SIL into it incrementally, which can happen before there's
a FileUnit to use as the associated DeclContext instead of a
CompilerInstance's main module.
2018-09-25 09:13:52 -07:00
Jordan Rose
de07fdfb04 Remove "StartElem" from perform{SIL,IR}Generation
This was only used by the integrated REPL, and is now a dead option.

The "StartElem" option for performTypeChecking is still used for
reading SIL files, which have AST and SIL blocks alternate.
2018-09-25 09:13:52 -07:00
Xi Ge
a7a06d7ce3 FrontendTool: parse all delayed member decls when we're dumping parse tree or verifying parse diagnostics. 2018-09-12 19:40:28 -07:00