Commit Graph

519 Commits

Author SHA1 Message Date
Chris Lattner
a476f65471 Abolish the old attribute syntax for type attributes (and SIL type attrs)
- Change type attribute printing logic (in astprinter and the demangler) 
  to print in the new syntax
- Change the swift parser to only accept type attributes in the new syntax.
- Update canParseTypeTupleBody to lookahead over new-syntax type attributes.
- Update the testsuite to use the new syntax.



Swift SVN r9273
2013-10-13 05:39:46 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Enrico Granata
d967efd2d2 Give the same love to swift.Bool which is also an enum that we were vending as a struct
Swift SVN r8610
2013-09-24 22:20:53 +00:00
Enrico Granata
44ec002ffb Fixing up the demangling for swift.Optional<T> to be an Enum instead of a struct
(Optional is an hardcoded substitution, so even if its definition changes, the mangling won't change, and the demangler has to keep up!)



Swift SVN r8609
2013-09-24 22:17:32 +00:00
Argyrios Kyrtzidis
9e0cfb811d [AST] Allow the mangler to handle declarations with error types in them.
This is only useful for unique-identification uses of the mangler, like in SourceKit,
which has to deal with invalid code.
Since this is not related to ABI, we can change the encoding anytime we want.

Swift SVN r8557
2013-09-23 16:11:26 +00:00
Doug Gregor
bc3f655105 s/constructor/init in a few more places.
Swift SVN r8504
2013-09-20 18:37:15 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Enrico Granata
d33691a051 <rdar://problem/15013536>
Fixing the demangler to correctly deal with weak/unowned refs
Also, enhancing the node structure



Swift SVN r8454
2013-09-19 18:29:39 +00:00
Enrico Granata
60f5503c9d Making ProtocolList have a TypeList child
This makes it easier for the LLDB side to obtain a ProtocolCompositionType from a demangled tree



Swift SVN r8294
2013-09-16 20:53:39 +00:00
Joe Groff
c65f4c3f43 Rework archetype mangling to follow parent hierarchy.
Use the ordinal archetype manglings only for the primary archetypes of a generic context, and define a mangling for associated types relative to their parent archetype. This will make the archetype mangling resilient in the face of our planned improvements to associated type and protocol conformance ABI. It also correctly mangles self and associated types of protocols, which my previous attempt utterly failed to accomplish.

Swift SVN r8174
2013-09-13 01:16:27 +00:00
Enrico Granata
a1ac2dd16f <rdar://problem/14971418>
This one-liner fixes an issue where protocol contexts were demangling incorrectly, essentially stripping out the protocol



Swift SVN r8170
2013-09-12 23:14:06 +00:00
Joe Groff
6dbc1a8835 Add manglings for associated types.
This should allow declarations inside protocols to mangle successfully, which is needed by SourceKit to be able to use mangled names as unique decl identifiers. I'm also planning to use mangled protocol decls to name generic curry thunk symbols.

This only introduces a mangling for independent associated types. I think we will eventually want to mangle dependent associated types (such as T.AssocType for an archetype T : SomeProtocol) with a non-indexed mangling too, but this doesn't do that yet.

Swift SVN r8148
2013-09-12 15:29:08 +00:00
Enrico Granata
b3576d8599 Replacing the GenericTypeApplication node with more specific BoundGeneric{Class|Structure|Union} nodes
Removing the TypeList node underneath a TypeList, a TypeList just needs to wrap a list of Type nodes



Swift SVN r7990
2013-09-06 17:47:06 +00:00
Enrico Granata
80278dfedc Simplifying the demangling for UncurriedFunctionType objects, from:
k = UncurriedFunctionType
  k = UncurriedFunctionMetaType
    k = Type
      k = MetaType

to:
k = UncurriedFunctionType
  k = MetaType

This should help Greg parse uncurried functions with greater ease



Swift SVN r7964
2013-09-05 23:09:10 +00:00
Enrico Granata
60163b464e Removing the : between name and type for function declarations, since that does not exist in the language.
A function will now be demangled as:

module.function (args) -> retType vs. module.function : (args) -> retType

Also clearing out a couple warnings that Greg pointed out



Swift SVN r7725
2013-08-29 18:39:25 +00:00
Enrico Granata
389c867551 Making the Demangler work properly with nested types, in the sense that Paths that represent nested types need to come out flat instead of hierarchical
Adding a couple test cases for this



Swift SVN r7724
2013-08-29 18:20:09 +00:00
Enrico Granata
72112bf575 More demangler changes - these introduce a new structure to the demangling that is better suited to Greg\'s need to produce types and decls out of demangled trees
Swift SVN r7714
2013-08-29 01:52:58 +00:00
Enrico Granata
a199242321 Sending 7641 again + a fix for the inf loop that Dmitri found
I also added that one as a test case



Swift SVN r7656
2013-08-28 01:02:01 +00:00
Dmitri Hrybenko
6eb5bc58d2 Revert r7641. It causes an infloop while demangling a name in test/SILGen/class_bound_protocols.swift
Swift SVN r7647
2013-08-27 23:36:35 +00:00
Enrico Granata
ff3ea6e3ce <rdar://problem/14830080> & <rdar://problem/14822344>
The previous implementation of the tree structure for the demangler had a bug in the low-level tree management code which caused the tree structure to diverge depending on whether
nodes were added as siblings or children. This checkin fixes the issue by making sure that the tree of nodes is kept coherent at all times.
Some adjustments are necessary to ensure the nodes were still generated properly and correctly turned into strings
Added a new test case



Swift SVN r7643
2013-08-27 22:56:48 +00:00
Enrico Granata
f2ba4c8c59 This commit changes the way the Demangler handles substitutions
Previously, substitutions were treated as unstructured text chunks, but this was causing problems when using the demangler as a source of structured type information
This patch ensures that substitutions are properly stored as the type they represent for later semantic reconstruction



Swift SVN r7494
2013-08-23 00:21:26 +00:00
Joe Groff
80bec3d955 Give swift.Option a standard mangling substitution.
Swift SVN r7455
2013-08-22 17:36:58 +00:00
Enrico Granata
687b142101 Undoing the damage of clang-format + first round of demangler cleanup
Swift SVN r7342
2013-08-19 23:15:51 +00:00
Enrico Granata
2d97d22d33 clang-formatted the Demangler
Swift SVN r7334
2013-08-19 22:34:30 +00:00
Enrico Granata
74f111d310 The space here was needed
Swift SVN r7333
2013-08-19 22:26:19 +00:00
Enrico Granata
de0e9c7f6f Fixing a crasher where the demangler was not checking a substitution for NULL
Swift SVN r7331
2013-08-19 21:38:29 +00:00
Enrico Granata
c127e98f1c Removing non doxygen-kosher comments
Swift SVN r7298
2013-08-16 22:46:39 +00:00
Enrico Granata
47d1a137b5 Major demangler changes.
This commit changes the Swift demangler to produce a tree-like list of tokens instead of a string.
This is mostly useful for LLDB since we can use the inherent structure in a Swift mangled name to make more informed decisions about matters such as type information extraction from modules
The ability to convert the tokenized output into a plain string for viewing purposes is of course preserved



Swift SVN r7297
2013-08-16 22:30:58 +00:00
Joe Groff
a94489473c IRGen: Add ValueWitness enumerators for union layout and access.
These value witness table entries will be conditionally available for types that support specialized union representation through extra inhabitants and/or spare bits and for union value witnesses:

- storeExtraInhabitant, to store an extra inhabitant representation;
- getExtraInhabitantIndex, to recognize an extra inhabitant representation;
- getUnionTag, to get a union's discriminator; and
- inplaceProjectUnionData, to extract the value in place from a union.

This just sets up the enumerators and related IR types and mangling; nothing emits these witnesses yet.

Swift SVN r7234
2013-08-14 21:01:21 +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
3d37954e81 Remove SourceManager::decompose() and switch its clients to normal location and
range printing


Swift SVN r7122
2013-08-10 02:19:50 +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
09837a1b88 Simplify the implementation of SourceManager::decompose() and its client
Swift SVN r7119
2013-08-10 01:32:42 +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
aacef757ed Move decompose from PrettyStackTrace.cpp to the SourceManager
It requires direct access to the SourceLoc internals and is generally useful
anyway.


Swift SVN r7111
2013-08-09 22:50:58 +00:00
Dmitri Hrybenko
db08a32a95 Factor out SourceManager::getLocOffsetInBuffer()
and remove some abuse of SourceLoc::Value::getPointer()


Swift SVN r7105
2013-08-09 21:53:32 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Dmitri Hrybenko
f42d4dba87 Factor out SourceManager::getLocForBufferStart()
Swift SVN r7058
2013-08-08 22:06:21 +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
Joe Groff
4316239f5d Kill Builtin.OpaquePointer.
It's not needed by SIL anymore.

Swift SVN r6873
2013-08-03 01:56:06 +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
5cea4ebf41 Code completion: put CodeCompletionOffset on SourceManager instead of passing
around everywhere

Fixes:
rdar://14585108 Code completion does not work at the beginning of the file
rdar://14592634 Code completion returns zero results at EOF in a function
                without a closing brace


Swift SVN r6820
2013-08-01 22:08:58 +00:00
Enrico Granata
c3d42b5f86 Removing the demangleType() API and the --type flag to swift-demangle
Types now have proper mangled names of the form _Tt<...> so they don't need any special treatment



Swift SVN r6816
2013-08-01 21:00:05 +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
Joe Groff
827c516b0c Demangler: Include protocol context when it comes from a substitution.
Swift SVN r6808
2013-08-01 16:42:48 +00:00
Joe Groff
3503ffe4fa IRGen: Set up LinkEntities for protocol witness tables.
We need to handle three cases:

- If a protocol conformance has no associated types, or the associated type witnesses all have statically resolvable metadata, we can expose a *direct* witness table symbol.
- If a protocol conformance has associated types with runtime-instantiated metadata, we need to gate the witness table behind a *lazy* initializer function to fill in the metadata fields.
- If a protocol conformance has associated types where the type or one of its conformances are *dependent* on its parent's generic parameters, we need to instantiate multiple witness tables at runtime.

Swift SVN r6805
2013-08-01 05:25:32 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Adrian Prantl
5b5ba6d78a Name mangling: Add a "_Tt" prefix to all type names that are output in
the debug info, to aid the debugger in figuring out the implementation
language of a given type in multi-language environments.
FYI, where applicable, we also emit the
DW_AT_APPLE_runtime_class(DW_AT_lang_Swift) attribute.
The demangler accepts type names with the "_Tt" prefix without the --type
switch.

Swift SVN r6714
2013-07-29 22:03:15 +00:00
Enrico Granata
c75fe924a1 Moving the Swift demangler from libSIL to libBasic
Plus, a couple of minor cosmetic changes that I had held off for a couple days now



Swift SVN r6691
2013-07-29 17:42:57 +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