Somewhat working

Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
This commit is contained in:
Apollo Zhu
2023-09-20 12:51:09 -07:00
parent d93d742c66
commit b09a22a9a0
40 changed files with 496 additions and 21 deletions

View File

@@ -289,7 +289,8 @@ StringRef SourceManager::getIdentifierForBuffer(
if (auto generatedInfo = getGeneratedSourceInfo(bufferID)) {
// We only care about macros, so skip everything else.
if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted)
generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
generatedInfo->kind == GeneratedSourceInfo::DefaultArgument)
return buffer->getBufferIdentifier();
if (generatedInfo->onDiskBufferCopyFileName.empty()) {
@@ -382,6 +383,7 @@ void SourceManager::setGeneratedSourceInfo(
case GeneratedSourceInfo::Name##MacroExpansion:
#include "swift/Basic/MacroRoles.def"
case GeneratedSourceInfo::PrettyPrinted:
case GeneratedSourceInfo::DefaultArgument:
break;
case GeneratedSourceInfo::ReplacedFunctionBody: