summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-27 23:30:47 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-27 23:30:47 +0000
commit75acd925d0f7c59167cab6dd0bb46458d4c337e4 (patch)
tree15031d6a85b74a4234fcae0945ccae62a6d762f7 /clang/lib/Sema/Sema.cpp
parente3e36f80f5cb9559dfbc27e04cc72376258d8f19 (diff)
downloadbcm5719-llvm-75acd925d0f7c59167cab6dd0bb46458d4c337e4.tar.gz
bcm5719-llvm-75acd925d0f7c59167cab6dd0bb46458d4c337e4.zip
Only print _Bool as 'bool' when 'bool' is defined as an object-like
macro whose only replacement token is '_Bool'. llvm-svn: 140656
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 54c4c98d4b3..679d4f65893 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud