Commit Graph

40 Commits

Author SHA1 Message Date
Hamish Knight
fd7c2595f2 [Basic] Introduce abortWithPrettyStackTraceMessage
Introduce a convenience for aborting while printing a given message
to a frame of the pretty stack trace. Use this in the existing places
where we're currently doing this.
2025-04-07 17:05:35 +01:00
Hamish Knight
6d89ed3d73 [ASTScope] Use PrettyStackTraceString to print verification errors
Use the same approach as `ModuleFileSharedCore::fatal`, ensuring the
verification error ends up in the crash log.
2025-03-28 17:00:35 +00:00
Becca Royal-Gordon
9f0130b6b6 [NFC] Dump an ASTScopeImpl’s parent nodes 2024-12-19 15:47:07 -08:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Pavel Yaskevich
955e1166d3 [AST] ASTScope: Pass parent module to all search methods
Addresses recently discovered performance regression.
`findChildContaining` has to handle macros and for that
it needs a parent module, looking it up every time is
expensive because it involves walking up back to a source
file scope.

Resolves: rdar://114667408
Resolves: rdar://114667496
2023-08-31 10:08:23 -07:00
Slava Pestov
0e465deaae Fix and re-enable bitrotted ASTScope test 2023-05-12 15:43:49 -04:00
Doug Gregor
82de47c494 [Macros] Fix name lookup in macro expansion declaration arguments.
Teach ASTScope to create child nodes for each of the arguments of a
macro expansion declaration, so that we can perform name lookup into
them. Otherwise, we cannot have nontrivial closures in arguments to a
macro expansion declaration.

Fixes rdar://107388151.
2023-03-30 00:10:20 -07:00
Doug Gregor
b29fcb4e58 [Macros] Parse macro declarations fully, and treat them as normal declarations 2022-11-28 18:32:43 -08:00
Slava Pestov
771fd6e9d1 ASTScope: Redo assertions to look at CharSourceRanges 2020-10-07 12:33:58 -04:00
Slava Pestov
2e67c135fd ASTScope: Rework ConditionalClauseScopes
The top-level scope for a conditional clause with a pattern is now
ConditionalClausePatternUseScope, which introduces the pattern's
bindings.

Since the patterns are not visible in their own initializer, a new
ConditionalClauseInitializerScope is used for the initializer.
While it is nested inside of the ConditionalClausePatternUseScope,
it's lookup parent skips one level, giving us the desired behavior.
2020-10-07 12:33:29 -04:00
Slava Pestov
445d747622 AST: Move GenericParamList and friends to GenericParamList.{h,cpp} 2020-09-29 19:51:03 -04:00
Slava Pestov
f8fb071f0f ASTScope: Remove ASTScopeImpl::getDeclContext() 2020-09-25 02:40:13 -04:00
Slava Pestov
32957259e8 ASTScope: Remove VarDeclScope 2020-09-23 13:09:01 -04:00
Slava Pestov
b7bd4fb8b3 ASTScope: Remove 'history' vector 2020-09-22 13:42:48 -04:00
Owen Voorhees
45bc578ae5 [SourceManager] Rename line and column APIs for clarity 2020-05-21 12:54:07 -05:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Michael Forster
fae87c96d7 Move interleave(...) to the llvm namespace
This simplifies fixing the master-next build. Upstream LLVM already
has a copy of this function, so on master-next we only need to delete
the Swift copy, reducing the potential for merge conflicts.
2020-04-17 11:20:50 +02:00
David Ungar
a9ab4aa8c2 Use SeparateCaching 2019-10-09 22:33:39 -07:00
David Ungar
86ec6a00da Remove include order dependency 2019-10-08 14:08:43 -07:00
David Ungar
5908cfc5ba First cut at ASTScope expansion requestification 2019-10-08 09:05:19 -07:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
David Ungar
7992e1c6c4 Lots of cleanups, renamings, etc. 2019-08-26 16:55:18 -07:00
David Ungar
f64033a2d2 Manual rebase with master 2019-08-06 22:13:20 -07:00
David Ungar
3a3145c0f4 Alternate SelfDC computation, fixes, and cleanups.
ASTScopeLookup by default
Create empty fn bodies for IDE tests.
Include initializer source range for property wrappers.
Add -disable-astscope-lookup
2019-06-23 09:17:09 -07:00
David Ungar
16ca723b00 Explain source ranges 2019-06-12 10:34:44 -07:00
David Ungar
6cdb14719a Printing tweaks 2019-06-10 18:06:44 -07:00
David Ungar
f203509250 fixes, unfmted, rm startLocAccordingToCondition 2019-06-10 14:03:34 -07:00
David Ungar
6a8d91f673 fmt 2019-06-10 13:18:58 -07:00
David Ungar
17bb03112e new cond use scheme 2019-06-10 13:18:18 -07:00
David Ungar
7d1f024e07 WIP unfmt 2019-06-10 12:10:21 -07:00
David Ungar
bbd1f7618c WIP 2019-06-08 10:05:26 -07:00
David Ungar
3abfa1f384 WIP 2019-06-08 09:08:49 -07:00
David Ungar
670eb61f8e Spell out GTX 2019-06-05 15:54:10 -07:00
David Ungar
73279c99fb Upto findLookupParentForUse 2019-06-05 09:04:38 -07:00
David Ungar
ad77af1b87 Catch top-level dependency for use under pattern.
var x = 3
_ = x
2019-06-03 21:13:25 -07:00
David Ungar
d652360fd9 Better pattern printing 2019-06-01 21:35:34 -07:00
David Ungar
3f820c374e Some review tweaks. 2019-05-28 11:12:12 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00