Commit Graph

110 Commits

Author SHA1 Message Date
Doug Gregor
0407610162 [Macros] Don't parse the macro expansion buffer twice.
Each macro expansion buffer was getting parsed twice: once by
ParseSourceFileRequest (which is used by unqualified name lookup) and
once to parse the expression when type-checking the expanded macro.
This meant that the same code had two ASTs. Hilarity ensures.

Stop directly invoking the parser on macro-expanded code. Instead, go
through ParseSourceFileRequest *as is always the right way*, and dig
out the expression we want.
2023-01-02 21:22:04 -08:00
Doug Gregor
0e691c45d2 Merge pull request #62747 from DougGregor/expression-macro-attr
[Macro] Add the expression attribute for macro declarations
2023-01-02 21:19:07 -08:00
Doug Gregor
d3540e6b59 [ASTScope] Remove a now-incorrect and not-actually-useful assertion.
This assertion is incorrect now that we have macro expansion buffers, which
don't meet the narrow definition of "inside" from this check.
2022-12-22 10:06:40 -08:00
Doug Gregor
f78f5729c3 Start requiring expression macros to be marked with @expression 2022-12-22 09:18:05 -08:00
Doug Gregor
4ef35c5f14 Embrace the swift-syntax notion of Fix-Its as separate notes.
The swift-syntax diagnostic system always treats Fix-Its as separate
notes, which are never attached to the primary diagnostic. Embrace this
module in the mapping over to the existing C++ diagnostic engine.
2022-12-15 21:24:44 -08:00
Doug Gregor
921e61b2fa Emit "in expansion of macro" notes for diagnostics within macro expansion buffers 2022-12-15 13:37:29 -08:00
Doug Gregor
cb3a24edda [Macros] Note when diagnostics came from the implementation of a macro 2022-12-14 16:18:58 -08:00
Doug Gregor
387a79c47b [Macro test] Handle source locations in macro diagnostics better.
"Relink" the folded syntax node back into the primary syntax node. When
we do this, we get consistent source locations that do not require any
adjustment.

Test this by adding a Fix-It to the silly AddBlocker macro, replacing
the `+` with a `-`.
2022-12-14 16:13:49 -08:00
Doug Gregor
a2dfd90516 [Macros] Fix test case after rename 2022-12-05 18:18:02 -08:00
Doug Gregor
1253bdd900 Rename test to something more sensible 2022-12-05 12:55:45 -08:00