Skip to content

Commit 6dd2d6a

Browse files
committed
undo PrettyPrintCustomAttrRequest
1 parent 19e91b1 commit 6dd2d6a

File tree

4 files changed

+3
-97
lines changed

4 files changed

+3
-97
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -775,27 +775,6 @@ class PrettyPrintDeclRequest
775775
bool isCached() const { return true; }
776776
};
777777

778-
/// Pretty-print the given attribute into a buffer and return a source
779-
/// location that refers to the attribute in that buffer.
780-
class PrettyPrintCustomAttrRequest
781-
: public SimpleRequest<PrettyPrintCustomAttrRequest,
782-
SourceLoc(const CustomAttr *, const Decl *),
783-
RequestFlags::Cached> {
784-
public:
785-
using SimpleRequest::SimpleRequest;
786-
787-
private:
788-
friend SimpleRequest;
789-
790-
// Evaluation.
791-
SourceLoc evaluate(Evaluator &eval, const CustomAttr *attr,
792-
const Decl *decl) const;
793-
794-
public:
795-
// Caching
796-
bool isCached() const { return true; }
797-
};
798-
799778
// Find the type in the cache or look it up
800779
class DefaultTypeRequest
801780
: public SimpleRequest<DefaultTypeRequest,

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ SWIFT_REQUEST(TypeChecker, DefaultTypeRequest,
8181
NoLocationInfo)
8282
SWIFT_REQUEST(TypeChecker, PrettyPrintDeclRequest,
8383
SourceLoc(const Decl *), Cached, NoLocationInfo)
84-
SWIFT_REQUEST(TypeChecker, PrettyPrintCustomAttrRequest,
85-
SourceLoc(const CustomAttr *), Cached, NoLocationInfo)
8684
SWIFT_REQUEST(TypeChecker, DifferentiableAttributeTypeCheckRequest,
8785
IndexSubset *(DifferentiableAttr *),
8886
SeparatelyCached, NoLocationInfo)

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,8 +3247,9 @@ namespace {
32473247
};
32483248
}
32493249

3250-
static void collectQualifiedDeclNameComponents(
3251-
const Decl *decl, SmallVectorImpl<std::string> &nameComponents) {
3250+
SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval, const Decl *decl) const {
3251+
// Conjure a buffer name for this declaration.
3252+
SmallVector<std::string, 4> nameComponents;
32523253
DeclContext *dc;
32533254
if (auto valueDecl = dyn_cast<ValueDecl>(decl)) {
32543255
nameComponents.push_back(valueDecl->getBaseName().userFacingName().str());
@@ -3295,13 +3296,7 @@ static void collectQualifiedDeclNameComponents(
32953296

32963297
dc = dc->getParent();
32973298
}
3298-
}
32993299

3300-
SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval,
3301-
const Decl *decl) const {
3302-
// Conjure a buffer name for this declaration.
3303-
SmallVector<std::string, 4> nameComponents;
3304-
collectQualifiedDeclNameComponents(decl, nameComponents);
33053300

33063301
std::string bufferName;
33073302
{
@@ -3396,62 +3391,3 @@ SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval,
33963391

33973392
return memBufferStartLoc.getAdvancedLoc(targetDeclOffsetInBuffer);
33983393
}
3399-
3400-
//----------------------------------------------------------------------------//
3401-
// PrettyPrintCustomAttrRequest
3402-
//----------------------------------------------------------------------------//
3403-
3404-
SourceLoc PrettyPrintCustomAttrRequest::evaluate(Evaluator &eval,
3405-
const CustomAttr *attr,
3406-
const Decl *decl) const {
3407-
// Conjure a buffer name for this declaration.
3408-
SmallVector<std::string, 4> nameComponents;
3409-
nameComponents.push_back(attr->getAttrName().str());
3410-
collectQualifiedDeclNameComponents(decl, nameComponents);
3411-
3412-
std::string bufferName;
3413-
{
3414-
llvm::raw_string_ostream out(bufferName);
3415-
for (auto iter = nameComponents.rbegin(); iter != nameComponents.rend();
3416-
++iter) {
3417-
out << *iter;
3418-
3419-
if (iter + 1 != nameComponents.rend())
3420-
out << ".";
3421-
}
3422-
}
3423-
3424-
// Render the buffer contents.
3425-
ASTContext &ctx = decl->getASTContext();
3426-
llvm::SmallString<128> bufferContents;
3427-
{
3428-
llvm::raw_svector_ostream out(bufferContents);
3429-
StreamPrinter P(out);
3430-
3431-
// Print this macro attribute.
3432-
auto options = PrintOptions::printForDiagnostics(
3433-
getBufferAccessLevel(decl), ctx.TypeCheckerOpts.PrintFullConvention);
3434-
attr->print(P, options, decl);
3435-
}
3436-
3437-
// Build a buffer with the pretty-printed macro attribute.
3438-
SourceManager &sourceMgr = ctx.SourceMgr;
3439-
auto bufferID = sourceMgr.addMemBufferCopy(bufferContents, bufferName);
3440-
auto memBufferStartLoc = sourceMgr.getLocForBufferStart(bufferID);
3441-
3442-
// Note that this is a pretty-printed buffer.
3443-
sourceMgr.setGeneratedSourceInfo(
3444-
bufferID,
3445-
GeneratedSourceInfo{
3446-
GeneratedSourceInfo::PrettyPrinted, CharSourceRange(),
3447-
CharSourceRange(memBufferStartLoc, bufferContents.size()),
3448-
ASTNode(const_cast<Decl *>(decl)).getOpaqueValue(), nullptr});
3449-
3450-
// Add a source file for the buffer.
3451-
auto moduleDecl = decl->getDeclContext()->getParentModule();
3452-
auto sourceFile =
3453-
new (ctx) SourceFile(*moduleDecl, SourceFileKind::Library, bufferID);
3454-
sourceFile->setImports({});
3455-
3456-
return memBufferStartLoc;
3457-
}

lib/Sema/TypeCheckMacros.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,13 +1367,6 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo,
13671367
// This is relevant for Swift macros inferred from Clang attributes,
13681368
// since they don't have a source representation.
13691369
SourceLoc attrLoc = attr->AtLoc;
1370-
if (attrLoc.isInvalid() &&
1371-
isa<ClangModuleUnit>(dc->getModuleScopeContext())) {
1372-
attrLoc = evaluateOrDefault(ctx.evaluator,
1373-
PrettyPrintCustomAttrRequest{attr, attachedTo},
1374-
SourceLoc());
1375-
assert(attrLoc);
1376-
}
13771370

13781371
auto attrSourceFile = moduleDecl->getSourceFileContainingLocation(attrLoc);
13791372
if (!attrSourceFile)

0 commit comments

Comments
 (0)