Ensure that buffers containing Clang swift_attr attributes are parsed as attributes

Previously, they were being parsed as top-level code, which would cause
errors because there are no definitions. Introduce a new
GeneratedSourceInfo kind to mark the purpose of these buffers so the
parser can handle them appropriately.
This commit is contained in:
Doug Gregor
2024-11-12 22:15:36 -08:00
parent 29315e656b
commit 989c73d014
15 changed files with 45 additions and 5 deletions

View File

@@ -862,6 +862,7 @@ ModuleDecl::getOriginalLocation(SourceLoc loc) const {
// replaced function bodies. The body is actually different code to the
// original file.
case GeneratedSourceInfo::PrettyPrinted:
case GeneratedSourceInfo::Attribute:
// No original location, return the original buffer/location
return {startBufferID, startLoc};
}
@@ -1148,6 +1149,7 @@ std::optional<MacroRole> SourceFile::getFulfilledMacroRole() const {
case GeneratedSourceInfo::ReplacedFunctionBody:
case GeneratedSourceInfo::PrettyPrinted:
case GeneratedSourceInfo::DefaultArgument:
case GeneratedSourceInfo::Attribute:
return std::nullopt;
}
}