Commit Graph

51 Commits

Author SHA1 Message Date
Slava Pestov
65088cc139 AST: Clean up usages of getDeclaredTypeInContext() and getExtensionType() 2016-12-04 21:15:02 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
4552fc8f88 [gardening] Use American English: "behaviour" → "behavior" 2016-11-05 20:33:57 +01:00
Vedant Kumar
9c44714561 [Coverage] Do not map function decls with no body
We can't place counters on function decls with no bodies. The old
behavior was to map a fresh counter to a null AST node, which is highly
suspicious at best.
2016-09-12 14:06:17 -07:00
Michael Gottesman
b48b4d96fe Merge remote-tracking branch 'origin/master' into master-next 2016-09-07 15:35:07 -07:00
Vedant Kumar
609de86f94 [Coverage] Emit mappings for top-level code decls
Make sure that code in top-level decls gets decent coverage reporting.

rdar://problem/27874041
2016-09-07 11:49:22 -07:00
Vedant Kumar
3d9b90831a [Coverage] Don't assign counter expressions to non-existent AST nodes (NFC) 2016-09-06 08:23:34 -07:00
Michael Gottesman
8d00a6cb59 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	stdlib/public/SDK/GameplayKit/CMakeLists.txt
	test/DebugInfo/bound-namealiastype.swift
	test/DebugInfo/structs.swift
	test/IRGen/c_globals.swift
	test/SourceKit/DocSupport/doc_clang_module.swift
	test/SourceKit/Indexing/index_with_clang_module.swift
	utils/update-checkout
2016-06-25 01:13:50 -07:00
Vedant Kumar
348b78a440 [Coverage] Handle non-local exits out of DoStmt's properly
First, assign counter expressions to the DoStmt and its body. Next,
fix the count associated to the DoStmt when handling a non-local exit.

This fixes SR-1850.
2016-06-21 11:49:46 -07:00
Vedant Kumar
ef69fdbef4 [Coverage] Visit the PatternBindingDecl in a ForEachStmt
This fixes a crash which occurs because there is no mapping region
associated with non-static initializers in the loop's iterator.
2016-05-17 13:38:50 -07:00
Mark Lacey
4dbf8d70dd Fixes for moved LLVM header files
The latest merge brought in changes that move some LLVM header
files.
2016-05-03 17:00:22 -07:00
Vedant Kumar
c5873f3683 [Coverage] Make ~ProfilerRAII restore the correct context
Swift permits function decls within function decls. ~ProfilerRAII would
destroy the current profiling context upon entering a nested function
decl instead of preserving it for later use. Fix the issue by recording
the correct context in ProfilerRAII.
2016-04-28 16:48:58 -07:00
Vedant Kumar
7b34ea9296 [Coverage] Do not emit increments in certain implicitly-generated regions
Outside of constructors and destructors, it's wasteful to generate
coverage mappings for implicitly-generated regions. Get rid of these
mappings and any counter increments associated with them.
2016-04-28 13:49:03 -07:00
Vedant Kumar
bcc54bf209 Do not check the top/bottom values in the switch 2016-03-24 17:13:29 -07:00
Vedant Kumar
43abe6fa1b [Coverage] Make getEquivalentPGOLinkage exhaustive 2016-03-24 16:57:08 -07:00
Vedant Kumar
dc11f8bf01 [Coverage] Re-apply "Respect function linkage in PGO name variables"
Fix a crash in emitBuiltinCall() which occurs because we drop function
linkage information when creating SILCoverageMaps.

This re-applies 45c7e4e86 with the MachO-specific checks in the test
case removed.
2016-03-17 22:44:35 -07:00
Vedant Kumar
c59b266f93 Revert "[Coverage] Respect function linkage in PGO name variables"
This reverts commit 45c7e4e861.

The IR CHECK lines in coverage.swift are flaky.
2016-03-17 18:21:32 -07:00
Vedant Kumar
45c7e4e861 [Coverage] Respect function linkage in PGO name variables
Fix a crash in emitBuiltinCall() which occurs because we drop function
linkage information when creating SILCoverageMaps.
2016-03-17 18:06:39 -07:00
Mark Lacey
57b2db0648 Silence some unused variable warnings. 2016-02-19 14:51:12 -08:00
Vedant Kumar
992d3aae15 [IRGen] Fix lowering of int_instrprof_increment
Update our usage of llvm's coverage API and fix the way we lower
instrprof_increment intrinsics.

This keeps us up-to-date with llvm/stable and makes instrumented IR
easier to read.
2016-02-15 15:49:38 -08:00
Vedant Kumar
376870e357 [Coverage] Fix handling of return statements within repeat-while loops
In 2a34b7c6, we introduced an incorrect test case for return statements
within repeat-while loops. Consider this situation:

repeat {     // Region 1
  return
} while C1   // Should be "zero", not "Region 1"

The fix requires maintaining a stack of active repeat-while loops. This
is an accepted idiom (c.f the clang CoverageMapping implementation). To
see why a stack is needed, consider:

repeat {       // Region 1
  repeat {     // Region 2
    if (C1) {  // Region 3
      return
    }
  } while C2   // Should be "Region 2 - *Region 3*", not "Region 2"
} while C3     // Should be "Region 1 - *Region 3*", not "Region 1"

rdar://problem/24572268
2016-02-09 16:16:49 -08:00
Vedant Kumar
2a34b7c641 [Coverage] Fix handling of abnormal exits through repeat blocks
We do not correctly update the counter expression for conditionals in
repeat-while blocks in the following two situations:

Situation 1:

repeat {     // Region 1
  if (C1) {  // Region 2
    break
  }
} while C2   // Should be "Region 1 - Region 2", not "Region 1"

Situation 2:

repeat {     // Region 1
  if (C1) {  // Region 2
    continue
  }
} while C2   // Should be "Region 1", not "Region 1 + Region 2"

Fix both of these problems and add thorough regression tests.

Closes Swift PR #1244, rdar://problem/24572268
2016-02-09 13:19:22 -08:00
Vedant Kumar
f7029d901c [Coverage] Fix crash when assigning counter to orphan if_expr
When visited by an ASTWalker, an if_expr nested within a
patter_binding_decl has no Parent. This leads to a crash while assigning
counters for the if_expr's "else" branch: there is no enclosing region,
so grabbing the current region is impossible.

We can handle this case safely by using a new leaf counter for the
"else" branch.

Swift PR-1116, rdar://problem/23256795
2016-01-27 14:53:38 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Nadav Rotem
07d4558c1c [Mangler] Change the Swift mangler into a symbol builder.
This commit changes the Swift mangler from a utility that writes tokens into a
stream into a name-builder that has two phases: "building a name", and "ready".
This clear separation is needed for the implementation of the compression layer.

Users of the mangler can continue to build the name using the mangleXXX methods,
but to access the results the users of the mangler need to call the finalize()
method. This method can write the result into a stream, like before, or return
an std::string.
2015-12-25 21:40:25 -08:00
Justin Bogner
086c2d49ea InstrProf: Handle IfExpr correctly for coverage maps
We were creating counters for IfExpr coverage, but weren't actually
mapping these when emitting coverage. Handle this.

rdar://problem/21720161

Swift SVN r29971
2015-07-08 07:17:08 +00:00
Justin Bogner
2b0df48945 Fix an unused variable from r29965
Swift SVN r29967
2015-07-08 06:28:20 +00:00
Justin Bogner
80f4156bf4 InstrProf: Fix coverage mapping for GuardStmt
We were creating a coverage mapping for GuardStmt, but we were never
incrementing its counter, so the results were quite strange. This
moves the counter to the body of the guard (instead of the
non-existent "then" clause) and increments the counter in the obvious
place.

rdar://problem/21291670

Swift SVN r29965
2015-07-08 06:13:37 +00:00
Joe Groff
d84993108b SILGen: Emit Clang-imported witness tables by need too.
The other part of rdar://problem/21444126. This is a little trickier since SIL doesn't track uses of witness tables in a principled way. Track uses in SILGen by putting a "SILGenBuilder" wrapper in front of SILBuilder, which marks conformances from apply, existential erasure, and metatype lookup instructions as used, so we can avoid emitting shared Clang importer witnesses when they aren't needed.

Swift SVN r29544
2015-06-22 03:08:41 +00:00
Chris Willmore
52d441ba61 Have a bit per PatternBindingEntry saying whether the corresponding
initializer has been type-checked, rather than a bit for the entire
PatternBindingDecl.

<rdar://problem/21057425> Crash while compiling attached test-app.

Swift SVN r29049
2015-05-27 01:31:28 +00:00
Justin Bogner
10a841650c InstrProf: Handle profiling of member initializers as part of the constructor
We generate the code for member initializers in the constructors of
objects, so we need to handle profiling and coverage for them there as
well.

rdar://problem/21009702

Swift SVN r28799
2015-05-19 23:30:35 +00:00
Chris Lattner
e517ad9182 Fix unreachable code handling to properly diagnose things like:
throw x 
whatever()  

as being unreachable after the throw.



Swift SVN r28680
2015-05-17 15:13:35 +00:00
Dmitri Hrybenko
0a1f7c09df Revert "Fix unreachable code handling to properly diagnose things like:"
This reverts commit 28678.  It broke the IDE/complete_exception.swift
test.

Swift SVN r28679
2015-05-17 12:27:57 +00:00
Chris Lattner
5ead9764bd Fix unreachable code handling to properly diagnose things like:
throw x
  whatever()

as being unreachable after the throw.



Swift SVN r28678
2015-05-17 05:56:02 +00:00
Chris Lattner
8a7b3f414e Revise the parser and AST representation of #available to be part of StmtCondition
instead of being an expression.

To the user, this has a couple of behavior changes, stemming from its non-expression-likeness.
 - #available cannot be parenthesized anymore
 - #available is in its own clause, not used in a 'where' clause of if/let.

Also, the implementation in the compiler is simpler and fits the model better.  This
fixes:
<rdar://problem/20904820> Following a "let" condition with #available is incorrectly rejected



Swift SVN r28521
2015-05-13 19:00:40 +00:00
Justin Bogner
330fb77e5f InstrProf: Fix a crash when instrumentation hits an implicit return
Exception handling in an init block was hitting an assert when we
ended a coverage range inside the implicit return decl. It doesn't
actually make sense to generate coverage mappings in implicit stmts
anyway, but this is the first test case that came across that.

Swift SVN r28508
2015-05-13 07:07:47 +00:00
Chris Lattner
37f5452d15 require -> guard.
Swift SVN r28223
2015-05-06 22:53:38 +00:00
Chris Lattner
0011b3ae21 rename "unless" to "require" and give it an 'else' keyword.
Swift SVN r28059
2015-05-02 00:16:44 +00:00
Chris Lattner
c6aa041fb9 Add parser/ast/sema/sourcekit/etc support for 'unless' statement.
SILGen support still missing.



Swift SVN r27961
2015-04-30 05:55:11 +00:00
Justin Bogner
569273a507 InstrProf: Add support for the do-catch construct
Add a counter in each catch block and one for the fallthrough out of
the entire do-catch block, and implement the logic to handle these and
throw statements in the coverage mapping.

Swift SVN r27950
2015-04-30 00:11:53 +00:00
Justin Bogner
5fe447dd8d InstrProf: Fix the coverage of the condition in repeat-while
Swift SVN r27883
2015-04-28 21:56:55 +00:00
Chris Willmore
c7c7388cf2 Change do-while to repeat-while.
Change all uses of "do { ... } while <cond>" to use "repeat" instead.
Rename DoWhileStmt to RepeatWhileStmt. Add diagnostic suggesting change
of 'do' to 'repeat' if a condition is found afterwards.

<rdar://problem/20336424> rename do/while loops to repeat/while & introduce "repeat <count> {}" loops

Swift SVN r27650
2015-04-23 22:48:31 +00:00
Chris Lattner
da1dfcd55c implement <rdar://problem/19150249> Allow labeled "break" from an "if" statement
This doesn't allow 'continue' out of an if statement for the same reason we don't
allow it on switch: we'd prefer people to write loops more explicitly.



Swift SVN r25565
2015-02-26 22:32:30 +00:00
Justin Bogner
99d6486f4b InstrProf: Add profiling and coverage for members of nominal types
Move the profiler setup logic into an RAII object and use it to set up
profiling for contructors, destructors, and methods.

Swift SVN r25473
2015-02-21 20:15:23 +00:00
Justin Bogner
2311b939ea InstrProf: Improve handling of while conditions
Fix a crash in coverage when a while's condition consists only of let
clauses. This degrades to simply not showing the coverage for the
condition in that case for now, since we don't handle Patterns yet.

Swift SVN r25456
2015-02-21 02:05:49 +00:00
Justin Bogner
783c47620e InstrProf: Fix handling of default arguments
Since we weren't assigning region counters until we were emitting
function bodies, we would crash while walking the expressions in
default arguments. This assigns the counters earlier and fixes up the
ASTWalker to expect that.

Swift SVN r25445
2015-02-21 00:18:45 +00:00
Justin Bogner
322005d027 InstrProf: Track the filename in coverage maps
If multiple swift files are compiled together, then guessing as to the
file when we emit IR obviously doesn't work. Find the filename when we
generate a function's coverage map and propagate it through SIL.

Swift SVN r25436
2015-02-20 21:26:20 +00:00
Justin Bogner
3dbd6ea9bd InstrProf: SILFunction doesn't live long enough for SILCoverageMap
Keeping a reference to the function here is dangerous. We only
actually care about the name, so save ourselves a copy of that
instead.

This fixes a crash that seems to happen only when the coverage data is
very large.

Swift SVN r25433
2015-02-20 19:36:33 +00:00
Justin Bogner
64c3333bcd InstrProf: Don't try to show coverage for implicit declarations
Implicit decls don't have any interesting source locations, so we
shouldn't include them in the coverage map.

Swift SVN r25432
2015-02-20 19:29:02 +00:00
Justin Bogner
d44090d29e InstrProf: Optionally generate coverage maps when profiling
This adds the -profile-coverage-mapping option to swift, and teaches
SILGenProfiling to generate mappings from source ranges to counters.

Swift SVN r25266
2015-02-13 08:42:15 +00:00