Commit Graph

336 Commits

Author SHA1 Message Date
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
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
Graydon Hoare
1c87229104 [Stats] Flush Stats profiles and tracers at SILModule lifecycle boundary. 2018-09-01 00:05:58 -07:00
Xi Ge
ce29c64964 [Evaluator] Refactor evaluator's GraphViz output to the destructor of the evaluator. NFC
This allows us to output dependency-graph while using the compiler in
other tools, like swift-ide-test, sourcekitd-test, etc.
2018-08-28 18:16:44 -07:00
Ben Cohen
428c580158 Fix unused variable warnings in release builds. (#18755) 2018-08-16 11:46:45 -06:00
Harlan Haskins
75e219543e [TBDGen] Enable TBD generation after -typecheck 2018-08-15 15:33:26 -07:00
Harlan Haskins
14a7ae56db [TBDGen] Remove TBD options from FrontendOptions
This patch removes the duplication between FrontendOptions and
TBDGenOptions by parsing the TBDGenOptions up front similarly to IRGen
and SIL options.
2018-08-15 14:53:44 -07:00
Harlan
7318efe49d [TBDGen] Allow user-provided dylib version flags (#18716)
* [TBDGen] Allow user-provided dylib version flags

This patch adds two frontend arguments, -tbd-compatibility-version and
-tbd-current-version, both of which accept SemVer versions.

These will show up in the generated TBD file for a given module as

current-version: 2.7
compatibility-version: 2.0

These flags both default to `1.0.0`.

* Reword some comments

* Add test for invalid version string

* Expand on comments for TBD flags
2018-08-15 11:42:42 -07:00
Jordan Rose
061204c704 Remove "IFK_" prefix from enum class InputFileKind
I suspect this was converted from a non-scoped enum in the past.
No functionality change.
2018-08-07 08:54:31 -07:00
David Ungar
f74b7e5178 Merge pull request #18489 from davidungar/rdar-42314665-fix-batch-mode-truncation-bug
[Batch Mode] Rdar 42314665 fix batch mode truncation bug
2018-08-06 22:04:36 -07:00
David Ungar
b4d942945a Rename local variable. 2018-08-06 10:12:04 -07:00
David Ungar
11c1f0f01e Format 2018-08-03 22:49:09 -07:00
David Ungar
cd3c82d9e2 Addressing comments. 2018-08-03 22:48:13 -07:00
David Ungar
1af9741dc7 format 2018-08-03 09:11:09 -07:00
David Ungar
cb3af7c0d4 factoring and commenting 2018-08-03 09:10:43 -07:00
David Ungar
dc952441a0 Format 2018-08-02 21:15:21 -07:00
David Ungar
67c8d9c357 Make Subconsumer into a class. 2018-08-02 21:14:49 -07:00