diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 82d2811..19da55c 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -50,12 +50,12 @@
   Policy.Bool = Context.getLangOpts().Bool;
   if (!Policy.Bool) {
     if (MacroInfo *BoolMacro = PP.getMacroInfo(&Context.Idents.get("bool"))) {
-      Policy.Bool = BoolMacro->isObjectLike() && 
+      Policy.Bool = BoolMacro->isObjectLike() &&
         BoolMacro->getNumTokens() == 1 &&
         BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
     }
   }
-  
+
   return Policy;
 }
 
@@ -69,7 +69,7 @@
 Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
            TranslationUnitKind TUKind,
            CodeCompleteConsumer *CodeCompleter)
-  : TheTargetAttributesSema(0), ExternalSource(0), 
+  : TheTargetAttributesSema(0), ExternalSource(0),
     isMultiplexExternalSource(false), FPFeatures(pp.getLangOpts()),
     LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer),
     Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
@@ -83,7 +83,7 @@
     NSStringDecl(0), StringWithUTF8StringMethod(0),
     NSArrayDecl(0), ArrayWithObjectsMethod(0),
     NSDictionaryDecl(0), DictionaryWithObjectsMethod(0),
-    GlobalNewDeleteDeclared(false), 
+    GlobalNewDeleteDeclared(false),
     TUKind(TUKind),
     NumSFINAEErrors(0), InFunctionDeclarator(0),
     AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
@@ -92,7 +92,7 @@
     AnalysisWarnings(*this)
 {
   TUScope = 0;
-  
+
   LoadedExternalKnownNamespaces = false;
   for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I)
     NSNumberLiteralMethods[I] = 0;
@@ -104,7 +104,7 @@
     FieldCollector.reset(new CXXFieldCollector());
 
   // Tell diagnostics how to render things from the AST library.
-  PP.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument, 
+  PP.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
                                        &Context);
 
   ExprEvalContexts.push_back(
@@ -117,11 +117,11 @@
 void Sema::Initialize() {
   // Tell the AST consumer about this Sema object.
   Consumer.Initialize(Context);
-  
+
   // FIXME: Isn't this redundant with the initialization above?
   if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
     SC->InitializeSema(*this);
-  
+
   // Tell the external Sema source about this Sema object.
   if (ExternalSemaSource *ExternalSema
       = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
@@ -139,7 +139,7 @@
     if (IdResolver.begin(UInt128) == IdResolver.end())
       PushOnScopeChains(Context.getUInt128Decl(), TUScope);
   }
-  
+
 
   // Initialize predefined Objective-C types:
   if (PP.getLangOpts().ObjC1) {
@@ -154,7 +154,7 @@
     DeclarationName Id = &Context.Idents.get("id");
     if (IdResolver.begin(Id) == IdResolver.end())
       PushOnScopeChains(Context.getObjCIdDecl(), TUScope);
-    
+
     // Create the built-in typedef for 'Class'.
     DeclarationName Class = &Context.Idents.get("Class");
     if (IdResolver.begin(Class) == IdResolver.end())
@@ -181,7 +181,7 @@
     delete FunctionScopes[I];
   if (FunctionScopes.size() == 1)
     delete FunctionScopes[0];
-  
+
   // Tell the SemaConsumer to forget about us; we're going out of scope.
   if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
     SC->ForgetSema();
@@ -209,7 +209,7 @@
   // If we're in template instantiation, it's an error.
   if (!ActiveTemplateInstantiations.empty())
     return false;
-  
+
   // If that function's not in a system header, it's an error.
   if (!Context.getSourceManager().isInSystemHeader(loc))
     return false;
@@ -288,13 +288,13 @@
 
   // If this is a derived-to-base cast to a through a virtual base, we
   // need a vtable.
-  if (Kind == CK_DerivedToBase && 
+  if (Kind == CK_DerivedToBase &&
       BasePathInvolvesVirtualBase(*BasePath)) {
     QualType T = E->getType();
     if (const PointerType *Pointer = T->getAs<PointerType>())
       T = Pointer->getPointeeType();
     if (const RecordType *RecordTy = T->getAs<RecordType>())
-      MarkVTableUsed(E->getLocStart(), 
+      MarkVTableUsed(E->getLocStart(),
                      cast<CXXRecordDecl>(RecordTy->getDecl()));
   }
 
@@ -348,7 +348,7 @@
   if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
     // UnusedFileScopedDecls stores the first declaration.
     // The declaration may have become definition so check again.
-    const VarDecl *DeclToCheck = VD->getDefinition(); 
+    const VarDecl *DeclToCheck = VD->getDefinition();
     if (DeclToCheck)
       return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
 
@@ -430,7 +430,7 @@
 void Sema::LoadExternalWeakUndeclaredIdentifiers() {
   if (!ExternalSource)
     return;
-  
+
   SmallVector<std::pair<IdentifierInfo *, WeakInfo>, 4> WeakIDs;
   ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs);
   for (unsigned I = 0, N = WeakIDs.size(); I != N; ++I) {
@@ -438,7 +438,7 @@
       = WeakUndeclaredIdentifiers.find(WeakIDs[I].first);
     if (Pos != WeakUndeclaredIdentifiers.end())
       continue;
-    
+
     WeakUndeclaredIdentifiers.insert(WeakIDs[I]);
   }
 }
@@ -567,9 +567,9 @@
     // or we need to perform template instantiations earlier.
     PerformPendingInstantiations();
   }
-  
+
   // Remove file scoped decls that turned out to be used.
-  UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(0, 
+  UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(0,
                                                                          true),
                                              UnusedFileScopedDecls.end(),
                               std::bind1st(std::ptr_fun(ShouldRemoveFromUnused),
@@ -600,19 +600,19 @@
     // now.
     if (Module *CurrentModule = PP.getCurrentModule()) {
       ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
-      
+
       SmallVector<Module *, 2> Stack;
       Stack.push_back(CurrentModule);
       while (!Stack.empty()) {
         Module *Mod = Stack.back();
         Stack.pop_back();
-        
+
         // Resolve the exported declarations.
         // FIXME: Actually complain, once we figure out how to teach the
         // diagnostic client to deal with complains in the module map at this
         // point.
         ModMap.resolveExports(Mod, /*Complain=*/false);
-        
+
         // Queue the submodules, so their exports will also be resolved.
         for (Module::submodule_iterator Sub = Mod->submodule_begin(),
                                      SubEnd = Mod->submodule_end();
@@ -621,12 +621,12 @@
         }
       }
     }
-    
+
     // Modules don't need any of the checking below.
     TUScope = 0;
     return;
   }
-  
+
   // C99 6.9.2p2:
   //   A declaration of an identifier for an object that has file
   //   scope without an initializer, and without a storage-class
@@ -639,10 +639,10 @@
   //   identifier, with the composite type as of the end of the
   //   translation unit, with an initializer equal to 0.
   llvm::SmallSet<VarDecl *, 32> Seen;
-  for (TentativeDefinitionsType::iterator 
+  for (TentativeDefinitionsType::iterator
             T = TentativeDefinitions.begin(ExternalSource),
          TEnd = TentativeDefinitions.end();
-       T != TEnd; ++T) 
+       T != TEnd; ++T)
   {
     VarDecl *VD = (*T)->getActingDefinition();
 
@@ -694,7 +694,7 @@
            E = UnusedFileScopedDecls.end(); I != E; ++I) {
       if (ShouldRemoveFromUnused(this, *I))
         continue;
-      
+
       if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
         const FunctionDecl *DiagD;
         if (!FD->hasBody(DiagD))
@@ -821,7 +821,7 @@
     case DiagnosticIDs::SFINAE_Report:
       // We'll report the diagnostic below.
       break;
-      
+
     case DiagnosticIDs::SFINAE_SubstitutionFailure:
       // Count this failure so that we know that template argument deduction
       // has failed.
@@ -838,7 +838,7 @@
       Diags.setLastDiagnosticIgnored();
       Diags.Clear();
       return;
-      
+
     case DiagnosticIDs::SFINAE_AccessControl: {
       // Per C++ Core Issue 1170, access control is part of SFINAE.
       // Additionally, the AccessCheckingSFINAE flag can be used to temporarily
@@ -888,10 +888,10 @@
       return;
     }
   }
-  
+
   // Set up the context's printing policy based on our current state.
   Context.setPrintingPolicy(getPrintingPolicy());
-  
+
   // Emit the diagnostic.
   if (!Diags.EmitCurrentDiagnostic())
     return;
@@ -950,10 +950,10 @@
 /// \returns The scope corresponding to the given declaraion context, or NULL
 /// if no such scope is open.
 Scope *Sema::getScopeForContext(DeclContext *Ctx) {
-  
+
   if (!Ctx)
     return 0;
-  
+
   Ctx = Ctx->getPrimaryContext();
   for (Scope *S = getCurScope(); S; S = S->getParent()) {
     // Ignore scopes that cannot have declarations. This is important for
@@ -963,7 +963,7 @@
         if (Ctx == Entity->getPrimaryContext())
           return S;
   }
-  
+
   return 0;
 }
 
@@ -976,7 +976,7 @@
     FunctionScopes.push_back(FunctionScopes.back());
     return;
   }
-  
+
   FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
 }
 
@@ -985,7 +985,7 @@
                                               BlockScope, Block));
 }
 
-void Sema::PushLambdaScope(CXXRecordDecl *Lambda, 
+void Sema::PushLambdaScope(CXXRecordDecl *Lambda,
                            CXXMethodDecl *CallOperator) {
   FunctionScopes.push_back(new LambdaScopeInfo(getDiagnostics(), Lambda,
                                                CallOperator));
@@ -993,9 +993,9 @@
 
 void Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
                                 const Decl *D, const BlockExpr *blkExpr) {
-  FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();  
+  FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
   assert(!FunctionScopes.empty() && "mismatched push/pop!");
-  
+
   // Issue any analysis-based warnings.
   if (WP && D)
     AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);
@@ -1034,15 +1034,15 @@
 BlockScopeInfo *Sema::getCurBlock() {
   if (FunctionScopes.empty())
     return 0;
-  
-  return dyn_cast<BlockScopeInfo>(FunctionScopes.back());  
+
+  return dyn_cast<BlockScopeInfo>(FunctionScopes.back());
 }
 
 LambdaScopeInfo *Sema::getCurLambda() {
   if (FunctionScopes.empty())
     return 0;
-  
-  return dyn_cast<LambdaScopeInfo>(FunctionScopes.back());  
+
+  return dyn_cast<LambdaScopeInfo>(FunctionScopes.back());
 }
 
 void Sema::ActOnComment(SourceRange Comment) {
@@ -1077,7 +1077,7 @@
 void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
 
 void ExternalSemaSource::ReadKnownNamespaces(
-                           SmallVectorImpl<NamespaceDecl *> &Namespaces) {  
+                           SmallVectorImpl<NamespaceDecl *> &Namespaces) {
 }
 
 void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
@@ -1254,7 +1254,7 @@
     // actually a CallExpr.
     SourceLocation ParenInsertionLoc =
       PP.getLocForEndOfToken(Range.getEnd());
-    Diag(Loc, PD) 
+    Diag(Loc, PD)
       << /*zero-arg*/ 1 << Range
       << (IsCallableWithAppend(E.get())
           ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
