Commit Graph

30 Commits

Author SHA1 Message Date
Dan Raviv
29d76f3b68 Canonize swift header files headers and footers
- Added missing ifdef guard in PointerIntEnum header
- Consistent naming convention for ifdef guards
- Consistent 'end namespace swift'
- Consistent single EOL at end of header files
2016-03-23 09:04:12 +02:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Adrian Prantl
8ab1e2dd50 Unify debug scope and location handling in SILInstruction and SILBuilder.
The drivers for this change are providing a simpler API to SIL pass
authors, having a more efficient of the in-memory representation,
and ruling out an entire class of common bugs that usually result
in hard-to-debug backend crashes.

Summary
-------

SILInstruction

Old                   New
+---------------+     +------------------+    +-----------------+
|SILInstruction |     |SILInstruction    |    |SILDebugLocation |
+---------------+     +------------------+    +-----------------+
| ...           |     | ...              |    | ...             |
|SILLocation    |     |SILDebugLocation *| -> |SILLocation      |
|SILDebugScope *|     +------------------+    |SILDebugScope *  |
+---------------+                             +-----------------+

We’re introducing a new class SILDebugLocation which represents the
combination of a SILLocation and a SILDebugScope.
Instead of storing an inline SILLocation and a SILDebugScope pointer,
SILInstruction now only has one SILDebugLocation pointer. The APIs of
SILBuilder and SILDebugLocation guarantees that every SILInstruction
has a nonempty SILDebugScope.

Developer-visible changes include:

SILBuilder
----------

In the old design SILBuilder populated the InsertedInstrs list to
allow setting the debug scopes of all built instructions in bulk
at the very end (as the responsibility of the user). In the new design,
SILBuilder now carries a "current debug scope" state and immediately
sets the debug scope when an instruction is inserted.
This fixes a use-after-free issue with with SIL passes that delete
instructions before destroying the SILBuilder that created them.

Because of this, SILBuilderWithScopes no longer needs to be a template,
which simplifies its call sites.

SILInstruction
--------------

It is neither possible or necessary to manually call setDebugScope()
on a SILInstruction any more. The function still exists as a private
method, but is only used when splicing instructions from one function
to another.

Efficiency
----------

In addition to dropping 20 bytes from each SILInstruction,
SILDebugLocations are now allocated in the SILModule's bump pointer
allocator and are uniqued by SILBuilder. Unfortunately repeat compiles
of the standard library already vary by about 5% so I couldn’t yet
produce reliable numbers for how much this saves overall.

rdar://problem/22017421
2015-11-19 09:31:26 -08:00
Xi Ge
f3c5692092 Add the missing include.
Swift SVN r32322
2015-09-29 23:47:15 +00:00
Xi Ge
71fdf73663 Allow CharSourceRange to peek the underlying text, need this for rdar://22857642
Swift SVN r32320
2015-09-29 23:32:40 +00:00
Xi Ge
42aeba54a4 Suggested by Jordan and Michael, use '=delete' to prevent constructor from being called.
Swift SVN r32040
2015-09-17 18:08:20 +00:00
Xi Ge
2ba154093d Make sure a problematic constructor will not be added in future.
Swift SVN r32039
2015-09-17 17:40:37 +00:00
Xi Ge
7f6a8b1315 Remove the constructor of CharSourceRange that takes SourceRange;
And add a utility function at lexer that converts SourceRange to CharSourceRange.

Swift SVN r32023
2015-09-17 01:15:34 +00:00
Dave Abrahams
51637bb411 New capabilities for CharSourceRange
dump(), overlaps(other), widen(other), and construction from a
SourceRange.

(Pair-programmed with Dmitri Hrybenko)

Swift SVN r26465
2015-03-24 00:50:42 +00:00
Argyrios Kyrtzidis
f8e5b6b3e2 [IDE] Modify structure testing to tag the relevant ranges directly on the source,
instead of outputting the info with lines/columns.

This make the structure more clear and testing more convenient.

Swift SVN r25865
2015-03-09 00:42:38 +00:00
Jordan Rose
29f8c25d63 Move #line state into the Parser and out of the SourceManager.
As part of this change, allow #line directives to extend to the end of the
file, rather than requiring a reset.

Note that #line regions that start or end within function bodies will not
behave correctly when in delayed parsing modes. This was true before and
after this commit. (#line regions contained entirely within a function and
not within any other #line regions should be fine.)

Swift SVN r20571
2014-07-25 23:01:43 +00:00
Dmitri Hrybenko
c1d96e579e Comment parsing: allow parsing comments with invalid source locations -- these
come from serialized modules


Swift SVN r15104
2014-03-15 14:58:29 +00:00
Sonny Falk
df693fd744 Make the CharSourceRange constructor take the SourceManager parameter as const.
Swift SVN r9596
2013-10-22 20:48:15 +00:00
Argyrios Kyrtzidis
0d7fc0aa1d [ide] Use the newly introduce CharSourceRange inside ide::SyntaxNode.
Swift SVN r7174
2013-08-12 20:58:20 +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
Dmitri Hrybenko
efd688dcd9 Now findBufferContainingLoc() can not fail, so store Buffer IDs in unsigned
variables.


Swift SVN r7121
2013-08-10 02:12:59 +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
469c01cc46 Update comment and parameter names: SourceLoc::getAdvancedLoc():
it accepts the offset in bytes, not in characters


Swift SVN r7057
2013-08-08 22:05:32 +00:00
Anna Zaks
aaa4b2c332 [SIL Printer] Add optional source location printing.
Added a -v(verbose) option to swift that will trigger verbose printing in SIL
Printer. SIL Printer will print the location info only in the verbose mode.

Here is the example of the format - only the line and colon are displayed for
brevity:

%24 = apply %13(%22) : $[cc(method), thin] ((), [byref] Bool) -> Builtin.Int1 // user: %26 line:46:10

(This will be used to test the validity of SILLocation info.)

Swift SVN r6991
2013-08-07 18:39:48 +00:00
Argyrios Kyrtzidis
99512e4220 When printing SourceRanges, add an option to not print the text as well.
Swift SVN r6836
2013-08-02 02:50:32 +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
Argyrios Kyrtzidis
f478157ab4 Revert "Print source ranges of the AST nodes when dumping the AST."
See if it fixes the buildbot.
This reverts commit 5957.

Swift SVN r5960
2013-07-02 16:45:07 +00:00
Argyrios Kyrtzidis
0a3fc1b195 Print source ranges of the AST nodes when dumping the AST.
Swift SVN r5959
2013-07-02 00:42:01 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
Chris Lattner
3ae29d8c82 provide facilities to elide the filename for a sourceloc if it matches the previous sourceloc. We now
print ranges as: [t.swift:22 - :23] instead of [t.swift:22 - t.swift:23].


Swift SVN r1753
2012-05-05 21:14:36 +00:00
Chris Lattner
d77d0d3fe3 refactor SourceRange printing out of Verifier.cpp into methods on SourceRange and SourceLoc.
Swift SVN r1752
2012-05-05 21:08:44 +00:00
Doug Gregor
0223f3edf1 Implement Expr::getSourceRange() and introduce proper support for this
function into all of the expression nodes. Re-implement
Expr::getStartLoc() in terms of this function, and add it's brother
Expr::getEndLoc(), removing the specialized implementations.

Clean up the source ranges of implicitly-created tuple expressions in
the process.


Swift SVN r855
2011-11-10 00:25:48 +00:00
Doug Gregor
d4d7ac1e6b SMRange is inclusive of the end location, so adjust our end location
accordingly when printing diagnostics.


Swift SVN r854
2011-11-09 22:07:29 +00:00
Chris Lattner
3ec9a9720a Add datatypes for swift to represent source locations and ranges, which are
distinct from the SMXXX types.  This is important because SMRange and
SourceRange have subtly different semantics, and is also nice to isolate
SMLoc from swift.


Swift SVN r749
2011-10-18 01:21:29 +00:00