diff options
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 54c4c98d4b..679d4f6589 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -55,6 +55,20 @@ void FunctionScopeInfo::Clear() { BlockScopeInfo::~BlockScopeInfo() { } +PrintingPolicy Sema::getPrintingPolicy() const { + PrintingPolicy Policy = Context.getPrintingPolicy(); + Policy.Bool = getLangOptions().Bool; + if (!Policy.Bool) { + if (MacroInfo *BoolMacro = PP.getMacroInfo(&Context.Idents.get("bool"))) { + Policy.Bool = BoolMacro->isObjectLike() && + BoolMacro->getNumTokens() == 1 && + BoolMacro->getReplacementToken(0).is(tok::kw__Bool); + } + } + + return Policy; +} + void Sema::ActOnTranslationUnitScope(Scope *S) { TUScope = S; PushDeclContext(S, Context.getTranslationUnitDecl()); @@ -678,6 +692,9 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() { } } + // Set up the context's printing policy based on our current state. + SemaRef.Context.setPrintingPolicy(SemaRef.getPrintingPolicy()); + // Emit the diagnostic. if (!this->Emit()) return; |