@@ -3247,8 +3247,9 @@ namespace {
3247
3247
};
3248
3248
}
3249
3249
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;
3252
3253
DeclContext *dc;
3253
3254
if (auto valueDecl = dyn_cast<ValueDecl>(decl)) {
3254
3255
nameComponents.push_back (valueDecl->getBaseName ().userFacingName ().str ());
@@ -3295,13 +3296,7 @@ static void collectQualifiedDeclNameComponents(
3295
3296
3296
3297
dc = dc->getParent ();
3297
3298
}
3298
- }
3299
3299
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);
3305
3300
3306
3301
std::string bufferName;
3307
3302
{
@@ -3396,62 +3391,3 @@ SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval,
3396
3391
3397
3392
return memBufferStartLoc.getAdvancedLoc (targetDeclOffsetInBuffer);
3398
3393
}
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
- }
0 commit comments