Commit Graph

17229 Commits

Author SHA1 Message Date
Michael Gottesman
234fcc1771 [pass-manager] notifyDeleteFunction => notifyWillDeleteFunction.
This name makes it clear that the function has not yet been deleted and also
contrasts with the past tense used in the API notifyAddedOrModifiedFunction to
show that said function has already added/modified the function.
2018-07-16 14:11:06 -07:00
Michael Gottesman
190008418e [pass-manager] notifyAddFunction => notifyAddedOrModifiedFunction.
The name notifyAddFunction is actively harmful since the pass manager uses this
entrypoint to notify analyses of added *OR* modified functions. It is up to the
caller analysis to distinguish in between these cases.

I am not vouching for the design, just trying to make names match the
current behavior.
2018-07-16 13:10:28 -07:00
Robert Widmann
c3867c8c48 Merge pull request #17964 from mdiep/enum-case-not-enum-element
Change "enum element" to "enum case" in diagnostics
2018-07-15 16:35:16 -07:00
Matt Diephouse
35592747db Change "enum element" to "enum case" in diagnostics
From the perspective of the compiler implementation, they're elements. But users will think of these as cases—and many diagnostics already refer to these as enum cases.
2018-07-15 16:01:10 -04:00
Michael Gottesman
87b847da0b [analysis] FunctionAnalysisBase's parameter SILAnalysisTy is actually a FunctionInfoTy.
I believe that this was just a typo from a long time ago. Calling this parameter
a SILAnalysisTy is actively misleading since as a result it seems to a naive
reading that one should be writing a recursive template:

```
class MyAnalysis : public FunctionAnalysisBase<MyAnalysis> { ... }
```

Instead of passing in the function info of the derived analysis, i.e.:

```
class MyAnalysisFunctionInfo { ... }
class MyAnalysis : public FunctionAnalysisBase<MyAnalysisFunctionInfo> { ... }
```

I also added some documentation to that affect onto FunctionAnalysisBase.
2018-07-15 12:21:10 -07:00
Michael Gottesman
56d100f493 [analysis] Standardize AnalysisKind by moving it out of SILAnalysis into its own "struct enum" in a non-nested scope.
Generally in the SIL/SILOptimizer libraries we have been putting kinds in the
swift namespace, not a nested scope in a type in swift (see ValueKind as an
example of this).
2018-07-15 11:00:33 -07:00
swift-ci
c911a4359f Merge pull request #17963 from gottesmm/pr-56b43cbc33e1c180f9a204470ac9c251f952788c 2018-07-15 10:32:37 -07:00
Michael Gottesman
42b26ed96f Merge pull request #17962 from gottesmm/pr-32867ca49fd7c7817ef633c1ab4042bac67051ba
[gardening] Add a missing const to a const method.
2018-07-15 09:59:24 -07:00
Michael Gottesman
7759b29a6d [gardening] Eliminate \ from macro that is < 80 lines. 2018-07-15 09:27:55 -07:00
Michael Gottesman
097e8778fc [gardening] Add a missing const to a const method. 2018-07-15 09:04:03 -07:00
Michael Gottesman
cfd177890c [gardening] Fixup a couple of doxygen comments. 2018-07-15 09:03:42 -07:00
Mark Lacey
eb57e209e3 Merge pull request #17691 from rudkx/remove-swift-3-in-expr-typechecking
Remove support for -swift-version 3 from the expression type checker.
2018-07-14 19:03:56 -07:00
Doug Gregor
44088fa265 Merge pull request #17921 from DougGregor/optional-not-unwrapped-diags
[Type checker] Improve diagnostics when an optional value is not unwrapped
2018-07-13 23:43:25 -07:00
Alex Hoppen
8430eff670 [libSyntax] Add syntax coloring based on the syntax tree 2018-07-13 17:48:47 -07:00
Alex Hoppen
9d59cd286b [incrParse] Add a stable id to the syntax nodes
The id is meant to be stable across incremental parses
2018-07-13 16:56:03 -07:00
Alex Hoppen
dfad6f787f [Basic] Extract isEditorPlaceholder from Identifier to standalone function 2018-07-13 16:56:03 -07:00
Doug Gregor
5db1901d57 [Type checker] Emit coalesce-or-force-unwrap Fix-Its for necessary unwraps more consistently.
Replace the last (and most obscure) use of the poor “use ‘?’ or ‘!’” diagnostic with the
new, more explanatory version that provides separate notes with Fix-Its for coalescing or
force-unwrapping the value.

Finishes rdar://problem/42081852.
2018-07-13 16:48:15 -07:00
Doug Gregor
9ec3b00ea4 [Type Checker] Improve diagnostic when referencing a member of an optional base.
Improve diagnostics when referencing a member of an optional base, where the
Optional type does not have the member but the wrapped type does. Specifically,
suggest both the chaining ‘?’ and the force-unwrapping ‘!’ Fix-Its via explanatory
notes, e.g.:

  error: value of optional type '[Int]?' must be unwrapped to refer to member 'subscript' of wrapped base type '[Int]'
    return foo.array[0]
               ^
  note: chain the optional using '?' to access member 'subscript' only for non-'nil' base values
    return foo.array[0]
               ^
                    ?
  note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
    return foo.array[0]
               ^
                    !

More of rdar://problem/42081852.
2018-07-13 15:22:56 -07:00
swift-ci
751ffa42fc Merge pull request #17645 from CodaFi/name-binding-arbitration 2018-07-13 14:29:41 -07:00
swift-ci
ef0b91d1bc Merge pull request #17941 from gottesmm/pr-e25f39567ef78cb6f5e33ce2a73f85bc09dd55f2 2018-07-13 13:55:51 -07:00
Michael Gottesman
28d7f6a298 [caller-analysis] Eliminate NDEBUG that snuck in while I was rebasing this commit.
This broke the non-asserts bots... sorry!

rdar://42174943
2018-07-13 12:55:13 -07:00
Michael Gottesman
7167399984 [gardening] Standardize SILAnalysis.h to use consistent style.
Some parts were using the more modern style that we are using in the optimizer
that involves having ivars and local variables be camelCase instead of
CamelCase.
2018-07-13 12:51:00 -07:00
Michael Gottesman
54b3af6506 [gardening] LLVM style suggests not indenting large namespace blocks. 2018-07-13 12:51:00 -07:00
Doug Gregor
945c09b1cc [Type checker] Improve diagnostics when an optional value is not unwrapped.
When we determine that an optional value needs to be unwrapped to make
an expression type check, use notes to provide several different
Fix-It options (with descriptions) rather than always pushing users
toward '!'. Specifically, the errors + Fix-Its now looks like this:

    error: value of optional type 'X?' must be unwrapped to a value of
        type 'X'
      f(x)
        ^
    note: coalesce using '??' to provide a default when the optional
        value contains 'nil'
      f(x)
        ^
          ?? <#default value#>
    note: force-unwrap using '!' to abort execution if the optional
        value contains 'nil'
      f(x)
         ^
         !

Fixes rdar://problem/42081852.
2018-07-13 11:02:04 -07:00
Robert Widmann
2282065197 Rename "Name Binding" action to "Resolve Imports" 2018-07-13 11:00:48 -07:00
Robert Widmann
cb1e9dd821 Introduce Name Binding as a Frontend Action
Introduces the -name-bind frontend action that is intended as an intermediary between the parse-only actions and a full typechecking pass.  In this phase, module imports will be validated and resolved, making it possible to emit full make-style dependencies files among other things.

Note that all information available to a parse-only pass is available to name binding, but because it does not continue-on to typecheck input files, full semantic information is not.
2018-07-13 10:56:03 -07:00
Robert Widmann
c440b0ba5a Diagnose parse-only invocations trying to emit dependency information
Parse-only invocations do not support the proper creation of dependency files or reference dependency files because they have not yet run name binding.  Ban these invocations by diagnostic and add a new diagnostic specifically for reference dependencies.
2018-07-13 10:56:03 -07:00
Michael Gottesman
979cb9c954 Merge pull request #17925 from gottesmm/pr-ee4013a4ba1a0f471cdc45bf15601a2c55002cdd
[caller-analysis] Change the dumping format to be a yaml format and u…
2018-07-13 08:38:09 -07:00
swift-ci
56f322f6f5 Merge pull request #17924 from gottesmm/pr-d6624e8a5116449b223f6e20308318db062511dd 2018-07-13 00:03:01 -07:00
Michael Gottesman
3051cd3f60 [caller-analysis] Change the dumping format to be a yaml format and update tests to use that format.
The current dumping format consists of 1 row of information per function. This
will become unweildy to write patterns for when I add additional state to
FunctionInfo.

Instead, this commit converts the dumping format of the caller analysis into a
multi line yaml format. This yaml format looks as follows:

  ---
  calleeName:      closure1
  hasCaller:       false
  minPartialAppliedArgs: 1
  partialAppliers:
    - partial_apply_one_arg
    - partial_apply_two_args1
  fullAppliers:
  ...

This can easily expand over time as we expand the queries that caller analysis
can answer.

As an additional advantage, there are definitely yaml parsers that can handle
multiple yaml documents in sequence in a stream. This means that by running via
sil-opt the caller-analysis-printer pass, one now will get a yaml description of
the caller analysis state, perfect and ready for analysis.
2018-07-12 22:43:23 -07:00
Michael Gottesman
dd1a201ed9 [caller-analysis] Improve memory usage of FunctionInfo structs by using small data structures instead of large.
This converts a DenseMap to a SmallMapVector and a SetVector to a
SmallSetVector. Both of these create large malloced data structures by
default. This really makes no sense when there are many functions that don't use
a partial apply or many applies.

Additionally, by changing the DenseMap to a MapVector container, this commit is
eliminating a potential source of non-determinism in the compiler since often
times we are iterating over the DenseMap to produce the results. Today all of
the usages of the DenseMap in this way are safe, but to defensively future proof
this analysis, it makes sense to use a MapVector here.
2018-07-12 22:35:09 -07:00
Jordan Rose
07e56a4351 Sprinkle LLVM_READONLY on some potentially recursive accessors (#17913)
I picked accessors that not only return the same result every time,
but also do no interesting validation work with possible side effects.
We have a lot more accessors that return the same result but also
force a bunch of things to be loaded or diagnostics to be emitted, and
I didn't want to change the behavior of any of those.

No intended functionality change; this is just supposed to be a small
optimization hint.
2018-07-12 14:16:29 -07:00
David Zarzycki
b29d2784ed [AST] NFC: Formalize Decl validation tracking via RAII
After this change, RAII ensures that the validation state is accurate as
possible.
2018-07-12 10:30:26 -04:00
Mark Lacey
efb173857a Merge branch 'master' into remove-swift-3-in-expr-typechecking 2018-07-11 23:49:44 -07:00
Rintaro Ishizaki
274114d4a2 Merge pull request #17852 from rintaro/parse-attr-invalid-sr8202
[Parse/Sema] Diagnose invalid attributes for ParamDecl and GenericTypeParamDecl
2018-07-12 14:12:45 +09:00
Mark Lacey
aa30cc5adc Merge branch 'master' into remove-swift-3-in-expr-typechecking 2018-07-11 20:55:32 -07:00
Slava Pestov
238928691d Merge pull request #17892 from slavapestov/unique-id-be-gone
SILOptimizer: Remove 'unique ID' from FSO mangling
2018-07-11 19:09:32 -07:00
Jordan Rose
b02d5543d4 Merge pull request #17843 from jrose-apple/batteries-included
[Driver] Always link compiler_rt on Darwin (when available)

rdar://problem/41911599
2018-07-11 17:35:06 -07:00
Slava Pestov
3906b35e44 Merge pull request #17893 from slavapestov/sil-combiner-cleanup
Small SILCombiner cleanup
2018-07-11 16:31:32 -07:00
Michael Gottesman
61ee1359f6 Merge pull request #17867 from bgogul/view_cfg_only
Add a viewCFGOnly function for debugging purposes.
2018-07-11 16:21:10 -07:00
Brent Royal-Gordon
70f788ed7f Merge pull request #17656 from brentdax/thats-what-a-diagnostics-all-about
[Sema] Improve error for inout on conversion
2018-07-11 16:19:34 -07:00
Xi Ge
6d517e144a Merge pull request #17888 from nkcsgexi/local-parameter-bridge
migrator: handle changed parameter declarations by introducing bridging local variables.
2018-07-11 15:33:32 -07:00
Slava Pestov
f573b513c7 SILOptimizer: Remove unused ExistentialConformances field from ConcreteExistentialInfo 2018-07-11 15:31:38 -07:00
Slava Pestov
330be4a38e SILOptimizer: Remove 'unique ID' from FSO mangling 2018-07-11 15:29:45 -07:00
Jordan Rose
d11704bcc9 Add swift::getNonSimulatorPlatform for DarwinPlatformKind
And use it in getDarwinLibraryNameSuffixForTriple, making the logic
there clearer.

Suggested by David U!
2018-07-11 15:09:53 -07:00
Slava Pestov
4bcf8f6320 Merge pull request #17361 from rajbarik/raj-globaladdr-refactor
Extend findInitExistential for cases when ApplySite argument is a global_addr
2018-07-11 14:18:07 -07:00
Xi Ge
f83ccd6438 migrator: handle changed parameter declarations by introducing bridging local variables.
When users override a SDK function whose parameter types have been changed,
we should introduce a local variable in the body of the function definition
to shadow the changed parameter. Also, a proper conversion function should
be applied to bridge the parameter to the local variable.

rdar://41828411
2018-07-11 13:41:37 -07:00
David Zarzycki
71472cfa96 Enable optional unowned/unowned(unsafe) references
John okayed this change in a comment on GitHub pull request: #16237
2018-07-11 14:33:23 -04:00
Ben Langmuir
62d93aea6f Merge pull request #17857 from benlangmuir/cc-if-else-if
[codecomplete] Add completion of `if` after `else`
2018-07-11 10:54:10 -07:00
Gogul Balakrishnan
9e26f0a8cb Made the helper into static function and addressed cosmetic changes. 2018-07-10 22:37:05 -07:00