[PATCH] D35271: Fix printing policy for AST context loaded from file

Johann Klähn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 11:22:32 PDT 2017


jklaehn created this revision.
jklaehn added a project: clang.

In `ASTUnit::LoadFromASTFile`, the context object is set up using default-constructed
`LangOptions` (which only later get populated).  As the language options are used in the constructor
of `PrintingPolicy`, this needs to be updated explicitly after the language options are available.


https://reviews.llvm.org/D35271

Files:
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -542,6 +542,9 @@
     // Initialize the ASTContext
     Context->InitBuiltinTypes(*Target);
 
+    // Adjust printing policy based on language options.
+    Context->setPrintingPolicy(PrintingPolicy(LangOpt));
+
     // We didn't have access to the comment options when the ASTContext was
     // constructed, so register them now.
     Context->getCommentCommandTraits().registerCommentOptions(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35271.106075.patch
Type: text/x-patch
Size: 557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170711/3876a0af/attachment.bin>


More information about the cfe-commits mailing list