From eba660f596a9acf8e0fa7f576ed8711ae71c7220 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Sat, 3 May 2014 03:45:55 +0000 Subject: [PATCH] Fix a bunch of mislayered clang/Lex includes from Sema git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207896 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 10 ++++++- lib/Sema/AnalysisBasedWarnings.cpp | 6 ++-- lib/Sema/CodeCompleteConsumer.cpp | 1 - lib/Sema/Sema.cpp | 8 ++++- lib/Sema/SemaAttr.cpp | 2 +- lib/Sema/SemaChecking.cpp | 34 +++++++++------------ lib/Sema/SemaDecl.cpp | 38 ++++++++++++------------ lib/Sema/SemaDeclObjC.cpp | 3 +- lib/Sema/SemaExceptionSpec.cpp | 3 +- lib/Sema/SemaExpr.cpp | 4 +-- lib/Sema/SemaInit.cpp | 25 ++++++++-------- lib/Sema/SemaLambda.cpp | 28 ++++++++--------- lib/Sema/SemaLookup.cpp | 4 +-- lib/Sema/SemaObjCProperty.cpp | 3 +- lib/Sema/SemaOpenMP.cpp | 1 - lib/Sema/SemaOverload.cpp | 3 +- lib/Sema/SemaStmtAsm.cpp | 1 - lib/Sema/SemaStmtAttr.cpp | 4 +-- lib/Sema/SemaTemplate.cpp | 7 ++--- lib/Sema/SemaTemplateInstantiateDecl.cpp | 1 - lib/Sema/SemaType.cpp | 9 +++--- lib/Sema/TreeTransform.h | 14 ++++----- 22 files changed, 100 insertions(+), 109 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 4e754caad1..7e5dcbdb96 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -26,11 +26,11 @@ #include "clang/AST/TypeLoc.h" #include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/Module.h" #include "clang/Basic/OpenMPKinds.h" #include "clang/Basic/Specifiers.h" #include "clang/Basic/TemplateKinds.h" #include "clang/Basic/TypeTraits.h" -#include "clang/Lex/ModuleLoader.h" #include "clang/Sema/AnalysisBasedWarnings.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/ExternalSemaSource.h" @@ -124,6 +124,8 @@ namespace clang { class LocalInstantiationScope; class LookupResult; class MacroInfo; + typedef ArrayRef> ModuleIdPath; + class ModuleLoader; class MultiLevelTemplateArgumentList; class NamedDecl; class NonNullAttr; @@ -1022,6 +1024,12 @@ public: getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const; std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const; + /// \brief Calls \c Lexer::getLocForEndOfToken() + SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + + /// \brief Retrieve the module loader associated with the preprocessor. + ModuleLoader &getModuleLoader() const; + ExprResult Owned(Expr* E) { return E; } ExprResult Owned(ExprResult R) { return R; } StmtResult Owned(Stmt* S) { return S; } diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index fc591bd77c..9b6b470e63 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -89,8 +89,8 @@ namespace { SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { - SourceLocation Close = SilenceableCondVal.getEnd(); - Close = S.PP.getLocForEndOfToken(Close); + SourceLocation Close = SilenceableCondVal.getEnd(); + Close = S.getLocForEndOfToken(Close); if (Close.isValid()) { S.Diag(Open, diag::note_unreachable_silence) << FixItHint::CreateInsertion(Open, "/* DISABLES CODE */ (") @@ -617,7 +617,7 @@ static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) { if (VD->getLocEnd().isMacroID()) return false; - SourceLocation Loc = S.PP.getLocForEndOfToken(VD->getLocEnd()); + SourceLocation Loc = S.getLocForEndOfToken(VD->getLocEnd()); // Suggest possible initialization (if any). std::string Init = S.getFixItZeroInitializerForType(VariableTy, Loc); diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index 19be1cb42f..0049d4c074 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -15,7 +15,6 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Scope.h" #include "clang/Sema/Sema.h" #include "llvm/ADT/STLExtras.h" diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 8faf29556e..eafd1dcf11 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -43,6 +43,12 @@ using namespace clang; using namespace sema; +SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { + return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts); +} + +ModuleLoader &Sema::getModuleLoader() const { return PP.getModuleLoader(); } + PrintingPolicy Sema::getPrintingPolicy(const ASTContext &Context, const Preprocessor &PP) { PrintingPolicy Policy = Context.getPrintingPolicy(); @@ -144,7 +150,7 @@ void Sema::Initialize() { ExternalSema->InitializeSema(*this); // Initialize predefined 128-bit integer types, if needed. - if (PP.getTargetInfo().hasInt128Type()) { + if (Context.getTargetInfo().hasInt128Type()) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index f5905842fd..bb25be7da1 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -168,7 +168,7 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, case POAK_Mac68k: // Check if the target supports this. - if (!PP.getTargetInfo().hasAlignMac68kSupport()) { + if (!this->Context.getTargetInfo().hasAlignMac68kSupport()) { Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported); return; } diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 1b44fe9822..ca7a92e0e1 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -27,7 +27,7 @@ #include "clang/Basic/CharInfo.h" #include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/Lexer.h" // TODO: Extract static functions to fix layering. #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/ScopeInfo.h" @@ -43,8 +43,8 @@ using namespace sema; SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const { - return SL->getLocationOfByte(ByteNo, PP.getSourceManager(), - PP.getLangOpts(), PP.getTargetInfo()); + return SL->getLocationOfByte(ByteNo, getSourceManager(), LangOpts, + Context.getTargetInfo()); } /// Checks that a call expression's argument count is the desired number. @@ -2860,7 +2860,7 @@ CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty) { if (!RD || !RD->getDefinition()) return Results; - LookupResult R(S, &S.PP.getIdentifierTable().get(Name), SourceLocation(), + LookupResult R(S, &S.Context.Idents.get(Name), SourceLocation(), Sema::LookupMemberName); R.suppressDiagnostics(); @@ -2906,8 +2906,7 @@ bool CheckPrintfHandler::checkForCStrMembers( if (Method->getMinRequiredArguments() == 0 && AT.matchesType(S.Context, Method->getReturnType())) { // FIXME: Suggest parens if the expression needs them. - SourceLocation EndLoc = - S.getPreprocessor().getLocForEndOfToken(E->getLocEnd()); + SourceLocation EndLoc = S.getLocForEndOfToken(E->getLocEnd()); S.Diag(E->getLocStart(), diag::note_printf_c_str) << "c_str()" << FixItHint::CreateInsertion(EndLoc, ".c_str()"); @@ -3236,7 +3235,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, Hints.push_back(FixItHint::CreateInsertion(E->getLocStart(), CastFix.str())); - SourceLocation After = S.PP.getLocForEndOfToken(E->getLocEnd()); + SourceLocation After = S.getLocForEndOfToken(E->getLocEnd()); Hints.push_back(FixItHint::CreateInsertion(After, ")")); } @@ -3786,8 +3785,7 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, // Lookup all std::abs if (NamespaceDecl *Std = S.getStdNamespace()) { - LookupResult R(S, &S.PP.getIdentifierTable().get("abs"), Loc, - Sema::LookupAnyName); + LookupResult R(S, &S.Context.Idents.get("abs"), Loc, Sema::LookupAnyName); R.suppressDiagnostics(); S.LookupQualifiedName(R, Std); @@ -3960,20 +3958,17 @@ static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E, if (!Size->isComparisonOp() && !Size->isEqualityOp() && !Size->isLogicalOp()) return false; - Preprocessor &PP = S.getPreprocessor(); SourceRange SizeRange = Size->getSourceRange(); S.Diag(Size->getOperatorLoc(), diag::warn_memsize_comparison) << SizeRange << FnName; S.Diag(FnLoc, diag::warn_memsize_comparison_paren_note) - << FnName - << FixItHint::CreateInsertion( - PP.getLocForEndOfToken(Size->getLHS()->getLocEnd()), - ")") + << FnName << FixItHint::CreateInsertion( + S.getLocForEndOfToken(Size->getLHS()->getLocEnd()), ")") << FixItHint::CreateRemoval(RParenLoc); S.Diag(SizeRange.getBegin(), diag::warn_memsize_comparison_cast_note) << FixItHint::CreateInsertion(SizeRange.getBegin(), "(size_t)(") - << FixItHint::CreateInsertion( - PP.getLocForEndOfToken(SizeRange.getEnd()), ")"); + << FixItHint::CreateInsertion(S.getLocForEndOfToken(SizeRange.getEnd()), + ")"); return true; } @@ -4087,7 +4082,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call, SourceLocation SL = SizeOfArg->getExprLoc(); SourceRange DSR = Dest->getSourceRange(); SourceRange SSR = SizeOfArg->getSourceRange(); - SourceManager &SM = PP.getSourceManager(); + SourceManager &SM = getSourceManager(); if (SM.isMacroArgExpansion(SL)) { ReadableName = Lexer::getImmediateMacroName(SL, SM, LangOpts); @@ -4340,7 +4335,7 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, // Generate the diagnostic. SourceLocation SL = LenArg->getLocStart(); SourceRange SR = LenArg->getSourceRange(); - SourceManager &SM = PP.getSourceManager(); + SourceManager &SM = getSourceManager(); // If the function is defined as a builtin macro, do not show macro expansion. if (SM.isMacroArgExpansion(SL)) { @@ -6275,8 +6270,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, return; } Diag(E->getExprLoc(), diag::note_function_to_function_call) - << FixItHint::CreateInsertion( - getPreprocessor().getLocForEndOfToken(E->getLocEnd()), "()"); + << FixItHint::CreateInsertion(getLocForEndOfToken(E->getLocEnd()), "()"); } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 68e4ad5892..3404e7de20 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -25,12 +25,14 @@ #include "clang/AST/EvaluatedExprVisitor.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" +#include "clang/Basic/Builtins.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/HeaderSearch.h" // FIXME: Sema shouldn't depend on Lex -#include "clang/Lex/ModuleLoader.h" // FIXME: Sema shouldn't depend on Lex -#include "clang/Lex/Preprocessor.h" // FIXME: Sema shouldn't depend on Lex +#include "clang/Lex/HeaderSearch.h" // TODO: Sema shouldn't depend on Lex +#include "clang/Lex/Lexer.h" // TODO: Extract static functions to fix layering. +#include "clang/Lex/ModuleLoader.h" // TODO: Sema shouldn't depend on Lex +#include "clang/Lex/Preprocessor.h" // Included for isCodeCompletionEnabled() #include "clang/Parse/ParseDiagnostic.h" #include "clang/Sema/CXXFieldCollector.h" #include "clang/Sema/DeclSpec.h" @@ -6765,7 +6767,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, SourceLocation InsertLoc; if (D.getName().getKind() != UnqualifiedId::IK_TemplateId) { InsertLoc = D.getName().getSourceRange().getEnd(); - InsertLoc = PP.getLocForEndOfToken(InsertLoc); + InsertLoc = getLocForEndOfToken(InsertLoc); } Diag(D.getIdentifierLoc(), diag::err_template_spec_decl_friend) @@ -7590,7 +7592,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, SourceLocation AddConstLoc; if (FunctionTypeLoc FTL = MD->getTypeSourceInfo()->getTypeLoc() .IgnoreParens().getAs()) - AddConstLoc = PP.getLocForEndOfToken(FTL.getRParenLoc()); + AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc()); Diag(MD->getLocation(), diag::warn_cxx1y_compat_constexpr_not_const) << FixItHint::CreateInsertion(AddConstLoc, " const"); @@ -7786,8 +7788,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) { << FixItHint::CreateRemoval(DS.getInlineSpecLoc()); if (DS.isNoreturnSpecified()) { SourceLocation NoreturnLoc = DS.getNoreturnSpecLoc(); - SourceRange NoreturnRange(NoreturnLoc, - PP.getLocForEndOfToken(NoreturnLoc)); + SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc)); Diag(NoreturnLoc, diag::ext_noreturn_main); Diag(NoreturnLoc, diag::note_main_remove_noreturn) << FixItHint::CreateRemoval(NoreturnRange); @@ -10014,11 +10015,11 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // If any errors have occurred, clear out any temporaries that may have // been leftover. This ensures that these temporaries won't be picked up for // deletion in some later function. - if (PP.getDiagnostics().hasErrorOccurred() || - PP.getDiagnostics().getSuppressAllDiagnostics()) { + if (getDiagnostics().hasErrorOccurred() || + getDiagnostics().getSuppressAllDiagnostics()) { DiscardCleanupsInEvaluationContext(); } - if (!PP.getDiagnostics().hasUncompilableErrorOccurred() && + if (!getDiagnostics().hasUncompilableErrorOccurred() && !isa(dcl)) { // Since the body is valid, issue any analysis-based warnings that are // enabled. @@ -10315,8 +10316,7 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, Diag(D.getIdentifierLoc(), diag::err_typedef_changes_linkage); SourceLocation tagLoc = D.getDeclSpec().getTypeSpecTypeLoc(); - tagLoc = Lexer::getLocForEndOfToken(tagLoc, 0, getSourceManager(), - getLangOpts()); + tagLoc = getLocForEndOfToken(tagLoc); llvm::SmallString<40> textToInsert; textToInsert += ' '; @@ -13136,9 +13136,9 @@ static void checkModuleImportContext(Sema &S, Module *M, DeclResult Sema::ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path) { - Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path, - Module::AllVisible, - /*IsIncludeDirective=*/false); + Module *Mod = + getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible, + /*IsIncludeDirective=*/false); if (!Mod) return true; @@ -13168,8 +13168,8 @@ void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) { checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext); // FIXME: Should we synthesize an ImportDecl here? - PP.getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, DirectiveLoc, - /*Complain=*/true); + getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, DirectiveLoc, + /*Complain=*/true); } void Sema::createImplicitModuleImport(SourceLocation Loc, Module *Mod) { @@ -13181,8 +13181,8 @@ void Sema::createImplicitModuleImport(SourceLocation Loc, Module *Mod) { Consumer.HandleImplicitImportDecl(ImportD); // Make the module visible. - PP.getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, Loc, - /*Complain=*/false); + getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, Loc, + /*Complain=*/false); } void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7fbca6aadb..89878fbe9c 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -20,7 +20,6 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprObjC.h" #include "clang/Basic/SourceManager.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/ExternalSemaSource.h" #include "clang/Sema/Lookup.h" @@ -2681,7 +2680,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, // __attribute((objc_root_class)). if (!HasRootClassAttr) { SourceLocation DeclLoc(IDecl->getLocation()); - SourceLocation SuperClassLoc(PP.getLocForEndOfToken(DeclLoc)); + SourceLocation SuperClassLoc(getLocForEndOfToken(DeclLoc)); Diag(DeclLoc, diag::warn_objc_root_class_missing) << IDecl->getIdentifier(); // See if NSObject is in the current scope, and if it is, suggest diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 59fd85ef71..531c71f3c2 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -19,7 +19,6 @@ #include "clang/AST/TypeLoc.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" -#include "clang/Lex/Preprocessor.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" @@ -297,7 +296,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { if (TypeSourceInfo *TSInfo = New->getTypeSourceInfo()) { TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens(); if (FunctionTypeLoc FTLoc = TL.getAs()) - FixItLoc = PP.getLocForEndOfToken(FTLoc.getLocalRangeEnd()); + FixItLoc = getLocForEndOfToken(FTLoc.getLocalRangeEnd()); } if (FixItLoc.isInvalid()) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index b28165b168..7c8a8dd5d1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3130,7 +3130,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // FIXME: Actually, they don't. We seem to have accidentally invented the // i128 suffix. if (Literal.isMicrosoftInteger && MaxWidth < 128 && - PP.getTargetInfo().hasInt128Type()) + Context.getTargetInfo().hasInt128Type()) MaxWidth = 128; llvm::APInt ResultVal(MaxWidth, 0); @@ -3201,7 +3201,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // If it doesn't fit in unsigned long long, and we're using Microsoft // extensions, then its a 128-bit integer literal. if (Ty.isNull() && Literal.isMicrosoftInteger && - PP.getTargetInfo().hasInt128Type()) { + Context.getTargetInfo().hasInt128Type()) { if (Literal.isUnsigned) Ty = Context.UnsignedInt128Ty; else diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 68f0cc3830..77bc4d38d2 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -17,7 +17,6 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/TypeLoc.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Designator.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/SemaInternal.h" @@ -654,13 +653,13 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, if (T->isArrayType() || T->isRecordType()) { SemaRef.Diag(StructuredSubobjectInitList->getLocStart(), diag::warn_missing_braces) - << StructuredSubobjectInitList->getSourceRange() - << FixItHint::CreateInsertion( - StructuredSubobjectInitList->getLocStart(), "{") - << FixItHint::CreateInsertion( - SemaRef.PP.getLocForEndOfToken( - StructuredSubobjectInitList->getLocEnd()), - "}"); + << StructuredSubobjectInitList->getSourceRange() + << FixItHint::CreateInsertion( + StructuredSubobjectInitList->getLocStart(), "{") + << FixItHint::CreateInsertion( + SemaRef.getLocForEndOfToken( + StructuredSubobjectInitList->getLocEnd()), + "}"); } } } @@ -6513,7 +6512,7 @@ bool InitializationSequence::Diagnose(Sema &S, else R = SourceRange(Args.front()->getLocEnd(), Args.back()->getLocEnd()); - R.setBegin(S.PP.getLocForEndOfToken(R.getBegin())); + R.setBegin(S.getLocForEndOfToken(R.getBegin())); if (Kind.isCStyleOrFunctionalCast()) S.Diag(Kind.getLocation(), diag::err_builtin_func_cast_more_than_one_arg) << R; @@ -7056,10 +7055,10 @@ static void DiagnoseNarrowingInInitList(Sema &S, } OS << ">("; S.Diag(PostInit->getLocStart(), diag::note_init_list_narrowing_override) - << PostInit->getSourceRange() - << FixItHint::CreateInsertion(PostInit->getLocStart(), OS.str()) - << FixItHint::CreateInsertion( - S.getPreprocessor().getLocForEndOfToken(PostInit->getLocEnd()), ")"); + << PostInit->getSourceRange() + << FixItHint::CreateInsertion(PostInit->getLocStart(), OS.str()) + << FixItHint::CreateInsertion( + S.getLocForEndOfToken(PostInit->getLocEnd()), ")"); } //===----------------------------------------------------------------------===// diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index 537f1ec8ab..d75cf4b2bb 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -15,7 +15,6 @@ #include "clang/AST/ASTLambda.h" #include "clang/AST/ExprCXX.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Scope.h" @@ -968,11 +967,10 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // An identifier or this shall not appear more than once in a // lambda-capture. if (LSI->isCXXThisCaptured()) { - Diag(C->Loc, diag::err_capture_more_than_once) - << "'this'" - << SourceRange(LSI->getCXXThisCapture().getLocation()) - << FixItHint::CreateRemoval( - SourceRange(PP.getLocForEndOfToken(PrevCaptureLoc), C->Loc)); + Diag(C->Loc, diag::err_capture_more_than_once) + << "'this'" << SourceRange(LSI->getCXXThisCapture().getLocation()) + << FixItHint::CreateRemoval( + SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc)); continue; } @@ -981,8 +979,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // lambda-capture shall not contain this [...]. if (Intro.Default == LCD_ByCopy) { Diag(C->Loc, diag::err_this_capture_with_copy_default) - << FixItHint::CreateRemoval( - SourceRange(PP.getLocForEndOfToken(PrevCaptureLoc), C->Loc)); + << FixItHint::CreateRemoval( + SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc)); continue; } @@ -1035,13 +1033,13 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // each identifier it contains shall be preceded by &. if (C->Kind == LCK_ByRef && Intro.Default == LCD_ByRef) { Diag(C->Loc, diag::err_reference_capture_with_reference_default) - << FixItHint::CreateRemoval( - SourceRange(PP.getLocForEndOfToken(PrevCaptureLoc), C->Loc)); + << FixItHint::CreateRemoval( + SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc)); continue; } else if (C->Kind == LCK_ByCopy && Intro.Default == LCD_ByCopy) { Diag(C->Loc, diag::err_copy_capture_with_copy_default) - << FixItHint::CreateRemoval( - SourceRange(PP.getLocForEndOfToken(PrevCaptureLoc), C->Loc)); + << FixItHint::CreateRemoval( + SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc)); continue; } @@ -1072,9 +1070,9 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, if (!CaptureNames.insert(C->Id)) { if (Var && LSI->isCaptured(Var)) { Diag(C->Loc, diag::err_capture_more_than_once) - << C->Id << SourceRange(LSI->getCapture(Var).getLocation()) - << FixItHint::CreateRemoval( - SourceRange(PP.getLocForEndOfToken(PrevCaptureLoc), C->Loc)); + << C->Id << SourceRange(LSI->getCapture(Var).getLocation()) + << FixItHint::CreateRemoval( + SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc)); } else // Previous capture captured something different (one or both was // an init-cpature): no fixit. diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index e8ef5ac6b9..db7fe6e614 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -23,7 +23,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/LangOptions.h" -#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/ModuleLoader.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/ExternalSemaSource.h" #include "clang/Sema/Overload.h" @@ -3984,7 +3984,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, if ((Mode == CTK_ErrorRecovery) && getLangOpts().Modules && getLangOpts().ModulesSearchAll) { - if (PP.getModuleLoader().lookupMissingImports(Typo->getName(), + if (getModuleLoader().lookupMissingImports(Typo->getName(), TypoName.getLocStart())) { TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0, 0); TC.setCorrectionRange(SS, TypoName); diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 75dc5cfd90..1b49c2abdc 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -19,7 +19,6 @@ #include "clang/AST/ExprObjC.h" #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallString.h" @@ -550,7 +549,7 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, if (T->isObjCObjectType()) { SourceLocation StarLoc = TInfo->getTypeLoc().getLocEnd(); - StarLoc = PP.getLocForEndOfToken(StarLoc); + StarLoc = getLocForEndOfToken(StarLoc); Diag(FD.D.getIdentifierLoc(), diag::err_statically_allocated_object) << FixItHint::CreateInsertion(StarLoc, "*"); T = Context.getObjCObjectPointerType(T); diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index b4d359edb4..b41f7e35d1 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -19,7 +19,6 @@ #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtOpenMP.h" #include "clang/AST/StmtVisitor.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Scope.h" diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index c74319ac63..70f5dba56d 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -22,7 +22,6 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/SemaInternal.h" @@ -5188,7 +5187,7 @@ diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, << FixItHint::CreateInsertion(From->getLocStart(), "static_cast<" + TypeStr + ">(") << FixItHint::CreateInsertion( - SemaRef.PP.getLocForEndOfToken(From->getLocEnd()), ")"); + SemaRef.getLocForEndOfToken(From->getLocEnd()), ")"); Converter.noteExplicitConv(SemaRef, Conversion, ConvTy); // If we aren't in a SFINAE context, build a call to the diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 9169032178..1cbc901da6 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -15,7 +15,6 @@ #include "clang/AST/RecordLayout.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Scope.h" diff --git a/lib/Sema/SemaStmtAttr.cpp b/lib/Sema/SemaStmtAttr.cpp index 9bb191d52b..68d1f62280 100644 --- a/lib/Sema/SemaStmtAttr.cpp +++ b/lib/Sema/SemaStmtAttr.cpp @@ -14,7 +14,6 @@ #include "clang/Sema/SemaInternal.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/SourceManager.h" -#include "clang/Lex/Lexer.h" #include "clang/Sema/DelayedDiagnostic.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/ScopeInfo.h" @@ -29,8 +28,7 @@ static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_wrong_target) << St->getLocStart(); if (isa(St)) { - SourceLocation L = Lexer::getLocForEndOfToken(Range.getEnd(), 0, - S.getSourceManager(), S.getLangOpts()); + SourceLocation L = S.getLocForEndOfToken(Range.getEnd()); S.Diag(L, diag::note_fallthrough_insert_semi_fixit) << FixItHint::CreateInsertion(L, ";"); } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index fb35f9084f..e21d1eef46 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4215,10 +4215,9 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param, if (Arg->isNullPointerConstant(S.Context, Expr::NPC_NeverValueDependent)) { std::string Code = "static_cast<" + ParamType.getAsString() + ">("; S.Diag(Arg->getExprLoc(), diag::err_template_arg_untyped_null_constant) - << ParamType - << FixItHint::CreateInsertion(Arg->getLocStart(), Code) - << FixItHint::CreateInsertion(S.PP.getLocForEndOfToken(Arg->getLocEnd()), - ")"); + << ParamType << FixItHint::CreateInsertion(Arg->getLocStart(), Code) + << FixItHint::CreateInsertion(S.getLocForEndOfToken(Arg->getLocEnd()), + ")"); S.Diag(Param->getLocation(), diag::note_template_param_here); return NPV_NullPointer; } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index de23a1952f..66afaaa458 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -19,7 +19,6 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/TypeLoc.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/PrettyDeclStackTrace.h" #include "clang/Sema/Template.h" diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index b8a1a3851c..3f03d43f79 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -24,7 +24,6 @@ #include "clang/AST/TypeLocVisitor.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Parse/ParseDiagnostic.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/DelayedDiagnostic.h" @@ -852,7 +851,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { break; } case DeclSpec::TST_int128: - if (!S.PP.getTargetInfo().hasInt128Type()) + if (!S.Context.getTargetInfo().hasInt128Type()) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_int128_unsupported); if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) Result = Context.UnsignedInt128Ty; @@ -2396,7 +2395,7 @@ static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, // declaration. SourceRange Range = FTI.Params[0].Param->getSourceRange(); SourceLocation B = Range.getBegin(); - SourceLocation E = S.PP.getLocForEndOfToken(Range.getEnd()); + SourceLocation E = S.getLocForEndOfToken(Range.getEnd()); // FIXME: Maybe we should suggest adding braces instead of parens // in C++11 for classes that don't have an initializer_list constructor. S.Diag(B, diag::note_additional_parens_for_variable_declaration) @@ -2763,10 +2762,10 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, SourceLocation DiagLoc, FixitLoc; if (TInfo) { DiagLoc = TInfo->getTypeLoc().getLocStart(); - FixitLoc = S.PP.getLocForEndOfToken(TInfo->getTypeLoc().getLocEnd()); + FixitLoc = S.getLocForEndOfToken(TInfo->getTypeLoc().getLocEnd()); } else { DiagLoc = D.getDeclSpec().getTypeSpecTypeLoc(); - FixitLoc = S.PP.getLocForEndOfToken(D.getDeclSpec().getLocEnd()); + FixitLoc = S.getLocForEndOfToken(D.getDeclSpec().getLocEnd()); } S.Diag(DiagLoc, diag::err_object_cannot_be_passed_returned_by_value) << 0 << T diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 46f97ee9f0..9d62e7c4da 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -25,7 +25,6 @@ #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" #include "clang/AST/StmtOpenMP.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Designator.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Ownership.h" @@ -6905,8 +6904,8 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { } // FIXME: Bogus source location for the operator - SourceLocation FakeOperatorLoc - = SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd()); + SourceLocation FakeOperatorLoc = + SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd()); // FIXME: to do this check properly, we will need to preserve the // first-qualifier-in-scope here, just in case we had a dependent @@ -7079,8 +7078,8 @@ TreeTransform::TransformExtVectorElementExpr(ExtVectorElementExpr *E) { return SemaRef.Owned(E); // FIXME: Bad source location - SourceLocation FakeOperatorLoc - = SemaRef.PP.getLocForEndOfToken(E->getBase()->getLocEnd()); + SourceLocation FakeOperatorLoc = + SemaRef.getLocForEndOfToken(E->getBase()->getLocEnd()); return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc, E->getAccessorLoc(), E->getAccessor()); @@ -7316,9 +7315,8 @@ TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { return ExprError(); // FIXME: Poor location information - SourceLocation FakeLParenLoc - = SemaRef.PP.getLocForEndOfToken( - static_cast(Object.get())->getLocEnd()); + SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken( + static_cast(Object.get())->getLocEnd()); // Transform the call arguments. SmallVector Args; -- 2.40.0