[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

Simon Schroeder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 07:54:25 PDT 2017


schroedersi updated this revision to Diff 104649.
schroedersi added a comment.

In https://reviews.llvm.org/D30946#792798, @rsmith wrote:

> I'd be interested to see how much complexity that adds, if you're prepared to give it a try.


Thanks for your feedback :). I added a printing context and moved `TemporarySuppressScope` from `PrintingPolicy` to the printing context. The printing context is currently passed around by value. This is not ideal because changes to the context made inside a function are not available in the caller but it is sufficient for the temporary suppress scope functionality. And it gives an overview of the amount of code changes.

Passing the context around by reference would be better but it would also necessitate the creation of a overloaded version of almost each affected function. (Something like this:

  void print(const PrintingPolicy& Policy, PrintingContext& Context) { /*...*/ }
  
  void print(const PrintingPolicy& Policy) {
    PrintingContext Context;
    print(Policy, Context);
  }

).

> Yes, I think that's right -- `SuppressScope` isn't really an externally useful "print without scopes" mechanism, it's an internal mechanism / implementation detail used for printing an "inner" AST node when we've already printed a scope for it based on outer sugar (eg, the entity is a type component of a nested name specifier, or the type inside an elaborated type specifier, or the class name in a destructor name). It's not really `SuppressScope`, it's `ScopeWasAlreadyPrintedForWhateverTopLevelThingIAskedYouToPrint` =)

Thanks for clarification :)


https://reviews.llvm.org/D30946

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/NestedNameSpecifier.h
  include/clang/AST/PrettyPrinter.h
  include/clang/AST/TemplateBase.h
  include/clang/AST/TemplateName.h
  include/clang/AST/Type.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/NestedNameSpecifier.cpp
  lib/AST/TemplateBase.cpp
  lib/AST/TemplateName.cpp
  lib/AST/TypePrinter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30946.104649.patch
Type: text/x-patch
Size: 32911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170629/e08b3383/attachment-0001.bin>


More information about the cfe-commits mailing list