From 193575455e00eca03fd7177f60e3f2e6263cb661 Mon Sep 17 00:00:00 2001 From: Kovarththanan Rajaratnam Date: Sat, 13 Mar 2010 10:17:05 +0000 Subject: [PATCH] Use SmallString instead of SmallVector git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98436 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/Preprocessor.h | 2 +- lib/CodeGen/Mangle.cpp | 104 +++---- lib/Frontend/HTMLDiagnostics.cpp | 12 +- lib/Frontend/PrintPreprocessedOutput.cpp | 2 +- lib/Frontend/TextDiagnosticPrinter.cpp | 14 +- lib/Lex/PPDirectives.cpp | 10 +- lib/Lex/Preprocessor.cpp | 46 +-- lib/Lex/TokenLexer.cpp | 2 +- lib/Parse/ParseDeclCXX.cpp | 94 +++--- lib/Sema/SemaExpr.cpp | 346 +++++++++++------------ 10 files changed, 316 insertions(+), 316 deletions(-) diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 532d8e4b46..e29ece1da6 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -730,7 +730,7 @@ public: /// This code concatenates and consumes tokens up to the '>' token. It returns /// false if the > was found, otherwise it returns true if it finds and consumes /// the EOM marker. - bool ConcatenateIncludeName(llvm::SmallVector &FilenameBuffer); + bool ConcatenateIncludeName(llvm::SmallString<128> &FilenameBuffer); private: diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index b18e4bb9df..32555ab705 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -53,19 +53,19 @@ static const DeclContext *GetLocalClassFunctionDeclContext( static const CXXMethodDecl *getStructor(const CXXMethodDecl *MD) { assert((isa(MD) || isa(MD)) && "Passed in decl is not a ctor or dtor!"); - + if (const TemplateDecl *TD = MD->getPrimaryTemplate()) { MD = cast(TD->getTemplatedDecl()); assert((isa(MD) || isa(MD)) && "Templated decl is not a ctor or dtor!"); } - + return MD; } static const unsigned UnknownArity = ~0U; - + /// CXXNameMangler - Manage the mangling of a single name. class CXXNameMangler { MangleContext &Context; @@ -73,7 +73,7 @@ class CXXNameMangler { const CXXMethodDecl *Structor; unsigned StructorType; - + llvm::DenseMap Substitutions; ASTContext &getASTContext() const { return Context.getASTContext(); } @@ -92,7 +92,7 @@ public: ~CXXNameMangler() { if (Out.str()[0] == '\01') return; - + int status = 0; char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status); assert(status == 0 && "Could not demangle mangled name!"); @@ -151,7 +151,7 @@ private: void mangleQualifiers(Qualifiers Quals); void mangleObjCMethodName(const ObjCMethodDecl *MD); - + // Declare manglers for every type class. #define ABSTRACT_TYPE(CLASS, PARENT) #define NON_CANONICAL_TYPE(CLASS, PARENT) @@ -310,7 +310,7 @@ static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) { LinkageSpecDecl::lang_cxx && "Unexpected linkage decl!"); DC = DC->getParent(); } - + return DC; } @@ -319,10 +319,10 @@ static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) { static bool isStdNamespace(const DeclContext *DC) { if (!DC->isNamespace()) return false; - + if (!IgnoreLinkageSpecDecls(DC->getParent())->isTranslationUnit()) return false; - + return isStd(cast(DC)); } @@ -353,12 +353,12 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) { // ::= // const DeclContext *DC = ND->getDeclContext(); - + if (GetLocalClassFunctionDeclContext(DC)) { mangleLocalName(ND); return; } - + // If this is an extern variable declared locally, the relevant DeclContext // is that of the containing namespace, or the translation unit. if (isa(DC) && ND->hasLinkage()) @@ -423,7 +423,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(const TemplateDecl *ND) { = dyn_cast(ND)) { mangleTemplateParameter(TTP->getIndex()); return; - } + } mangleUnscopedName(ND->getTemplatedDecl()); addSubstitution(ND); @@ -435,7 +435,7 @@ void CXXNameMangler::mangleNumber(int64_t Number) { Out << 'n'; Number = -Number; } - + Out << Number; } @@ -451,7 +451,7 @@ void CXXNameMangler::mangleCallOffset(const ThunkAdjustment &Adjustment) { Out << '_'; return; } - + Out << 'v'; mangleNumber(Adjustment.NonVirtual); Out << '_'; @@ -502,7 +502,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, case DeclarationName::Identifier: { if (const IdentifierInfo *II = Name.getAsIdentifierInfo()) { // We must avoid conflicts between internally- and externally- - // linked variable declaration names in the same TU. + // linked variable declaration names in the same TU. // This naming convention is the same as that followed by GCC, though it // shouldn't actually matter. if (ND && isa(ND) && ND->getLinkage() == InternalLinkage && @@ -588,7 +588,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, unsigned Arity; if (ND) { Arity = cast(ND)->getNumParams(); - + // If we have a C++ member function, we need to include the 'this' pointer. // FIXME: This does not make sense for operators that are static, but their // names stay the same regardless of the arity (operator new for instance). @@ -664,26 +664,26 @@ void CXXNameMangler::mangleLocalName(const NamedDecl *ND) { // := _ const DeclContext *DC = ND->getDeclContext(); Out << 'Z'; - + if (const ObjCMethodDecl *MD = dyn_cast(DC)) mangleObjCMethodName(MD); else if (const DeclContext *CDC = GetLocalClassFunctionDeclContext(DC)) { mangleFunctionEncoding(cast(CDC)); Out << 'E'; mangleNestedName(ND, DC, true /*NoFunction*/); - + // FIXME. This still does not cover all cases. unsigned disc; if (Context.getNextDiscriminator(ND, disc)) { if (disc < 10) Out << '_' << disc; - else + else Out << "__" << disc << '_'; } return; } - else + else mangleFunctionEncoding(cast(DC)); Out << 'E'; @@ -738,7 +738,7 @@ void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND) { = dyn_cast(ND)) { mangleTemplateParameter(TTP->getIndex()); return; - } + } manglePrefix(ND->getDeclContext()); mangleUnqualifiedName(ND->getTemplatedDecl()); @@ -758,22 +758,22 @@ CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) { case OO_Array_Delete: Out << "da"; break; // ::= ps # + (unary) // ::= pl # + - case OO_Plus: + case OO_Plus: assert((Arity == 1 || Arity == 2) && "Invalid arity!"); Out << (Arity == 1? "ps" : "pl"); break; // ::= ng # - (unary) // ::= mi # - - case OO_Minus: + case OO_Minus: assert((Arity == 1 || Arity == 2) && "Invalid arity!"); Out << (Arity == 1? "ng" : "mi"); break; // ::= ad # & (unary) // ::= an # & - case OO_Amp: + case OO_Amp: assert((Arity == 1 || Arity == 2) && "Invalid arity!"); Out << (Arity == 1? "ad" : "an"); break; // ::= de # * (unary) // ::= ml # * - case OO_Star: + case OO_Star: assert((Arity == 1 || Arity == 2) && "Invalid arity!"); Out << (Arity == 1? "de" : "ml"); break; // ::= co # ~ @@ -872,15 +872,15 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals) { void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) { llvm::SmallString<64> Name; llvm::raw_svector_ostream OS(Name); - - const ObjCContainerDecl *CD = + + const ObjCContainerDecl *CD = dyn_cast(MD->getDeclContext()); assert (CD && "Missing container decl in GetNameForMethod"); OS << (MD->isInstanceMethod() ? '-' : '+') << '[' << CD->getName(); if (const ObjCCategoryImplDecl *CID = dyn_cast(CD)) OS << '(' << CID->getNameAsString() << ')'; OS << ' ' << MD->getSelector().getAsString() << ']'; - + Out << OS.str().size() << OS.str(); } @@ -1184,7 +1184,7 @@ void CXXNameMangler::mangleType(const TypeOfExprType *T) { void CXXNameMangler::mangleType(const DecltypeType *T) { Expr *E = T->getUnderlyingExpr(); - + // type ::= Dt E # decltype of an id-expression // # or class member access // ::= DT E # decltype of an expression @@ -1206,11 +1206,11 @@ void CXXNameMangler::mangleType(const DecltypeType *T) { Out << 'E'; } -void CXXNameMangler::mangleIntegerLiteral(QualType T, +void CXXNameMangler::mangleIntegerLiteral(QualType T, const llvm::APSInt &Value) { // ::= L E # integer literal Out << 'L'; - + mangleType(T); if (T->isBooleanType()) { // Boolean values are encoded as 0/1. @@ -1221,7 +1221,7 @@ void CXXNameMangler::mangleIntegerLiteral(QualType T, Value.abs().print(Out, false); } Out << 'E'; - + } void CXXNameMangler::mangleCalledExpression(const Expr *E, unsigned Arity) { @@ -1325,7 +1325,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { break; } - case Expr::CXXUnresolvedConstructExprClass: { + case Expr::CXXUnresolvedConstructExprClass: { const CXXUnresolvedConstructExpr *CE = cast(E); unsigned N = CE->arg_size(); @@ -1334,7 +1334,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { if (N != 1) Out << "_"; for (unsigned I = 0; I != N; ++I) mangleExpression(CE->getArg(I)); if (N != 1) Out << "E"; - break; + break; } case Expr::CXXTemporaryObjectExprClass: @@ -1366,18 +1366,18 @@ void CXXNameMangler::mangleExpression(const Expr *E) { case Expr::UnaryOperatorClass: { const UnaryOperator *UO = cast(E); - mangleOperatorName(UnaryOperator::getOverloadedOperator(UO->getOpcode()), + mangleOperatorName(UnaryOperator::getOverloadedOperator(UO->getOpcode()), /*Arity=*/1); mangleExpression(UO->getSubExpr()); break; } - + case Expr::BinaryOperatorClass: { const BinaryOperator *BO = cast(E); - mangleOperatorName(BinaryOperator::getOverloadedOperator(BO->getOpcode()), + mangleOperatorName(BinaryOperator::getOverloadedOperator(BO->getOpcode()), /*Arity=*/2); mangleExpression(BO->getLHS()); - mangleExpression(BO->getRHS()); + mangleExpression(BO->getRHS()); break; } @@ -1407,7 +1407,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { mangleExpression(ECE->getSubExpr()); break; } - + case Expr::CXXOperatorCallExprClass: { const CXXOperatorCallExpr *CE = cast(E); unsigned NumArgs = CE->getNumArgs(); @@ -1417,7 +1417,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { mangleExpression(CE->getArg(i)); break; } - + case Expr::ParenExprClass: mangleExpression(cast(E)->getSubExpr()); break; @@ -1426,7 +1426,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { const NamedDecl *D = cast(E)->getDecl(); switch (D->getKind()) { - default: + default: // ::= L E # external name Out << 'L'; mangle(D, "_Z"); @@ -1477,7 +1477,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { mangleType(FL->getType()); // TODO: avoid this copy with careful stream management. - llvm::SmallVector Buffer; + llvm::SmallString<20> Buffer; FL->getValue().bitcastToAPInt().toString(Buffer, 16, false); Out.write(Buffer.data(), Buffer.size()); @@ -1486,7 +1486,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { } case Expr::IntegerLiteralClass: - mangleIntegerLiteral(E->getType(), + mangleIntegerLiteral(E->getType(), llvm::APSInt(cast(E)->getValue())); break; @@ -1568,7 +1568,7 @@ void CXXNameMangler::mangleTemplateArg(const NamedDecl *P, assert(A.getAsTemplate().getAsTemplateDecl() && "FIXME: Support dependent template names"); mangleName(A.getAsTemplate().getAsTemplateDecl()); - break; + break; case TemplateArgument::Expression: Out << 'X'; mangleExpression(A.getAsExpr()); @@ -1718,20 +1718,20 @@ bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char (&Str)[StrLen]) { if (!SD->getIdentifier()->isStr(Str)) return false; - + const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); if (TemplateArgs.size() != 2) return false; - + if (!isCharType(TemplateArgs[0].getAsType())) return false; - + if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits")) return false; - + return true; } - + bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { // ::= St # ::std:: if (const NamespaceDecl *NS = dyn_cast(ND)) { @@ -1798,7 +1798,7 @@ bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { Out << "So"; return true; } - + // ::= Sd # ::std::basic_iostream > if (isStreamCharSpecialization(SD, "basic_iostream")) { @@ -1867,7 +1867,7 @@ void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, /// \brief Mangles the a thunk with the offset n for the declaration D and /// emits that name to the given output stream. -void MangleContext::mangleThunk(const FunctionDecl *FD, +void MangleContext::mangleThunk(const FunctionDecl *FD, const ThunkAdjustment &ThisAdjustment, llvm::SmallVectorImpl &Res) { assert(!isa(FD) && @@ -1895,7 +1895,7 @@ void MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *D, /// \brief Mangles the a covariant thunk for the declaration D and emits that /// name to the given output stream. -void +void MangleContext::mangleCovariantThunk(const FunctionDecl *FD, const CovariantThunkAdjustment& Adjustment, llvm::SmallVectorImpl &Res) { diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp index f695254cb4..fddd36e4ec 100644 --- a/lib/Frontend/HTMLDiagnostics.cpp +++ b/lib/Frontend/HTMLDiagnostics.cpp @@ -40,13 +40,13 @@ class HTMLDiagnostics : public PathDiagnosticClient { std::vector BatchedDiags; public: HTMLDiagnostics(const std::string& prefix, const Preprocessor &pp); - + virtual ~HTMLDiagnostics() { FlushDiagnostics(NULL); } - + virtual void FlushDiagnostics(llvm::SmallVectorImpl *FilesMade); virtual void HandlePathDiagnostic(const PathDiagnostic* D); - + virtual llvm::StringRef getName() const { return "HTMLDiagnostics"; } @@ -108,7 +108,7 @@ HTMLDiagnostics::FlushDiagnostics(llvm::SmallVectorImpl *FilesMade) ReportDiag(*D, FilesMade); delete D; } - + BatchedDiags.clear(); } @@ -294,7 +294,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, llvm::raw_fd_ostream os(H.c_str(), ErrorMsg); if (!ErrorMsg.empty()) { - (llvm::errs() << "warning: could not create file '" << F.str() + (llvm::errs() << "warning: could not create file '" << F.str() << "'\n").flush(); return; } @@ -502,7 +502,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, } static void EmitAlphaCounter(llvm::raw_ostream& os, unsigned n) { - llvm::SmallVector buf; + llvm::SmallString<10> buf; do { unsigned x = n % ('z' - 'a'); diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index be5bb0dade..44e0e13906 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -61,7 +61,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI, if (MI.tokens_empty() || !MI.tokens_begin()->hasLeadingSpace()) OS << ' '; - llvm::SmallVector SpellingBuffer; + llvm::SmallString<128> SpellingBuffer; for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end(); I != E; ++I) { if (I->hasLeadingSpace()) diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index d2aa5480b4..60c1f4b9b8 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -119,19 +119,19 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, } assert(StartColNo <= EndColNo && "Invalid range!"); - + // Pick the first non-whitespace column. while (StartColNo < SourceLine.size() && (SourceLine[StartColNo] == ' ' || SourceLine[StartColNo] == '\t')) ++StartColNo; - + // Pick the last non-whitespace column. if (EndColNo > SourceLine.size()) EndColNo = SourceLine.size(); while (EndColNo-1 && (SourceLine[EndColNo-1] == ' ' || SourceLine[EndColNo-1] == '\t')) --EndColNo; - + // If the start/end passed each other, then we are trying to highlight a range // that just exists in whitespace, which must be some sort of other bug. assert(StartColNo <= EndColNo && "Trying to highlight whitespace??"); @@ -300,10 +300,10 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, if (E.isMacroID()) E = SM.getImmediateSpellingLoc(E); Ranges[i] = SourceRange(S, E); } - + // Get the pretty name, according to #line directives etc. PresumedLoc PLoc = SM.getPresumedLoc(Loc); - + // If this diagnostic is not in the main file, print out the "included from" // lines. if (LastWarningLoc != PLoc.getIncludeLoc()) { @@ -563,7 +563,7 @@ static unsigned findEndOfWord(unsigned Start, // We have the start of a balanced punctuation sequence (quotes, // parentheses, etc.). Determine the full sequence is. - llvm::SmallVector PunctuationEndStack; + llvm::SmallString<16> PunctuationEndStack; PunctuationEndStack.push_back(EndPunct); while (End < Length && !PunctuationEndStack.empty()) { if (Str[End] == PunctuationEndStack.back()) @@ -704,7 +704,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, if (DiagOpts->ShowLocation) { if (DiagOpts->ShowColors) OS.changeColor(savedColor, true); - + // Emit a Visual Studio compatible line number syntax. if (LangOpts && LangOpts->Microsoft) { OS << PLoc.getFilename() << '(' << LineNo << ')'; diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 976c94eda3..cddc6cff72 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -471,7 +471,7 @@ void Preprocessor::HandleDirective(Token &Result) { CurPPLexer->ParsingPreprocessorDirective = true; ++NumDirectives; - + // We are about to read a token. For the multiple-include optimization FA to // work, we have to remember if we had read any tokens *before* this // pp-directive. @@ -964,7 +964,7 @@ bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc, /// false if the > was found, otherwise it returns true if it finds and consumes /// the EOM marker. bool Preprocessor::ConcatenateIncludeName( - llvm::SmallVector &FilenameBuffer) { + llvm::SmallString<128> &FilenameBuffer) { Token CurTok; Lex(CurTok); @@ -1042,7 +1042,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok, return; } - bool isAngled = + bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename); // If GetIncludeFilenameSpelling set the start ptr to null, there was an // error. @@ -1070,7 +1070,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok, Diag(FilenameTok, diag::err_pp_file_not_found) << Filename; return; } - + // Ask HeaderInfo if we should enter this #include file. If not, #including // this file will have no effect. if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) @@ -1512,7 +1512,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, IdentifierInfo *MII = MacroNameTok.getIdentifierInfo(); MacroInfo *MI = getMacroInfo(MII); - + if (CurPPLexer->getConditionalStackDepth() == 0) { // If the start of a top-level #ifdef and if the macro is not defined, // inform MIOpt that this might be the start of a proper include guard. diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 2c6ad6ee46..a6efe7f5bc 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -52,7 +52,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, bool OwnsHeaders) : Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), ExternalSource(0), - Identifiers(opts, IILookup), BuiltinInfo(Target), CodeCompletionFile(0), + Identifiers(opts, IILookup), BuiltinInfo(Target), CodeCompletionFile(0), CurPPLexer(0), CurDirLookup(0), Callbacks(0), MacroArgCache(0) { ScratchBuf = new ScratchBuffer(SourceMgr); CounterValue = 0; // __COUNTER__ starts at 0. @@ -80,7 +80,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, // We haven't read anything from the external source. ReadMacrosFromExternalSource = false; - + // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro. // This gets unpoisoned where it is allowed. (Ident__VA_ARGS__ = getIdentifierInfo("__VA_ARGS__"))->setIsPoisoned(); @@ -116,7 +116,7 @@ Preprocessor::~Preprocessor() { // Free any cached macro expanders. for (unsigned i = 0, e = NumCachedTokenLexers; i != e; ++i) delete TokenLexerCache[i]; - + // Free any cached MacroArgs. for (MacroArgs *ArgList = MacroArgCache; ArgList; ) ArgList = ArgList->deallocate(); @@ -198,30 +198,30 @@ void Preprocessor::PrintStats() { << NumFastTokenPaste << " on the fast path.\n"; } -Preprocessor::macro_iterator -Preprocessor::macro_begin(bool IncludeExternalMacros) const { - if (IncludeExternalMacros && ExternalSource && +Preprocessor::macro_iterator +Preprocessor::macro_begin(bool IncludeExternalMacros) const { + if (IncludeExternalMacros && ExternalSource && !ReadMacrosFromExternalSource) { ReadMacrosFromExternalSource = true; ExternalSource->ReadDefinedMacros(); } - - return Macros.begin(); + + return Macros.begin(); } -Preprocessor::macro_iterator -Preprocessor::macro_end(bool IncludeExternalMacros) const { - if (IncludeExternalMacros && ExternalSource && +Preprocessor::macro_iterator +Preprocessor::macro_end(bool IncludeExternalMacros) const { + if (IncludeExternalMacros && ExternalSource && !ReadMacrosFromExternalSource) { ReadMacrosFromExternalSource = true; ExternalSource->ReadDefinedMacros(); } - - return Macros.end(); + + return Macros.end(); } -bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, - unsigned TruncateAtLine, +bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, + unsigned TruncateAtLine, unsigned TruncateAtColumn) { using llvm::MemoryBuffer; @@ -242,7 +242,7 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, for (; *Position; ++Position) { if (*Position != '\r' && *Position != '\n') continue; - + // Eat \r\n or \n\r as a single line. if ((Position[1] == '\r' || Position[1] == '\n') && Position[0] != Position[1]) @@ -251,13 +251,13 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, break; } } - + Position += TruncateAtColumn - 1; - + // Truncate the buffer. if (Position < Buffer->getBufferEnd()) { - MemoryBuffer *TruncatedBuffer - = MemoryBuffer::getMemBufferCopy(Buffer->getBufferStart(), Position, + MemoryBuffer *TruncatedBuffer + = MemoryBuffer::getMemBufferCopy(Buffer->getBufferStart(), Position, Buffer->getBufferIdentifier()); SourceMgr.overrideFileContents(File, TruncatedBuffer); } @@ -446,7 +446,7 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart, return TokStart.getFileLocWithOffset(PhysOffset); } -SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc, +SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) { if (Loc.isInvalid() || !Loc.isFileID()) return SourceLocation(); @@ -456,7 +456,7 @@ SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc, Len = Len - Offset; else return Loc; - + return AdvanceToTokenCharacter(Loc, Len); } @@ -519,7 +519,7 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier, II = getIdentifierInfo(llvm::StringRef(BufPtr, Identifier.getLength())); } else { // Cleaning needed, alloca a buffer, clean into it, then use the buffer. - llvm::SmallVector IdentifierBuffer; + llvm::SmallString<64> IdentifierBuffer; llvm::StringRef CleanedStr = getSpelling(Identifier, IdentifierBuffer); II = getIdentifierInfo(CleanedStr); } diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index aae735213d..efd1efed29 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -379,7 +379,7 @@ void TokenLexer::Lex(Token &Tok) { /// are more ## after it, chomp them iteratively. Return the result as Tok. /// If this returns true, the caller should immediately return the token. bool TokenLexer::PasteTokens(Token &Tok) { - llvm::SmallVector Buffer; + llvm::SmallString<128> Buffer; const char *ResultTokStrPtr = 0; do { // Consume the ## operator. diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index bfb75d2dd3..b92e7539de 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -52,7 +52,7 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context, Actions.CodeCompleteNamespaceDecl(CurScope); ConsumeToken(); } - + SourceLocation IdentLoc; IdentifierInfo *Ident = 0; @@ -130,7 +130,7 @@ Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc, Actions.CodeCompleteNamespaceAliasDecl(CurScope); ConsumeToken(); } - + CXXScopeSpec SS; // Parse (optional) nested-name-specifier. ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false); @@ -165,7 +165,7 @@ Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc, Parser::DeclPtrTy Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) { assert(Tok.is(tok::string_literal) && "Not a string literal!"); - llvm::SmallVector LangBuffer; + llvm::SmallString<8> LangBuffer; // LangBuffer is guaranteed to be big enough. llvm::StringRef Lang = PP.getSpelling(Tok, LangBuffer); @@ -183,7 +183,7 @@ Parser::DeclPtrTy Parser::ParseLinkage(ParsingDeclSpec &DS, if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) { Attr = ParseCXX0XAttributes(); } - + if (Tok.isNot(tok::l_brace)) { ParseDeclarationOrFunctionDefinition(DS, Attr.AttrList); return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec, @@ -222,7 +222,7 @@ Parser::DeclPtrTy Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, Actions.CodeCompleteUsing(CurScope); ConsumeToken(); } - + if (Tok.is(tok::kw_namespace)) // Next token after 'using' is 'namespace' so it must be using-directive return ParseUsingDirective(Context, UsingLoc, DeclEnd, Attr.AttrList); @@ -259,7 +259,7 @@ Parser::DeclPtrTy Parser::ParseUsingDirective(unsigned Context, Actions.CodeCompleteUsingDirective(CurScope); ConsumeToken(); } - + CXXScopeSpec SS; // Parse (optional) nested-name-specifier. ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false); @@ -332,20 +332,20 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context, return DeclPtrTy(); } - // Parse the unqualified-id. We allow parsing of both constructor and + // Parse the unqualified-id. We allow parsing of both constructor and // destructor names and allow the action module to diagnose any semantic // errors. UnqualifiedId Name; - if (ParseUnqualifiedId(SS, + if (ParseUnqualifiedId(SS, /*EnteringContext=*/false, /*AllowDestructorName=*/true, - /*AllowConstructorName=*/true, - /*ObjectType=*/0, + /*AllowConstructorName=*/true, + /*ObjectType=*/0, Name)) { SkipUntil(tok::semi); return DeclPtrTy(); } - + // Parse (optional) attributes (most likely GNU strong-using extension). llvm::OwningPtr AttrList; if (Tok.is(tok::kw___attribute)) @@ -354,7 +354,7 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context, // Eat ';'. DeclEnd = Tok.getLocation(); ExpectAndConsume(tok::semi, diag::err_expected_semi_after, - AttrList ? "attributes list" : "using declaration", + AttrList ? "attributes list" : "using declaration", tok::semi); return Actions.ActOnUsingDeclaration(CurScope, AS, true, UsingLoc, SS, Name, @@ -502,26 +502,26 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation, Diag(IdLoc, diag::err_unknown_template_name) << Id; } - + if (!Template) return true; - // Form the template name + // Form the template name UnqualifiedId TemplateName; TemplateName.setIdentifier(Id, IdLoc); - + // Parse the full template-id, then turn it into a type. if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateName, SourceLocation(), true)) return true; if (TNK == TNK_Dependent_template_name) AnnotateTemplateIdTokenAsType(SS); - + // If we didn't end up with a typename token, there's nothing more we // can do. if (Tok.isNot(tok::annot_typename)) return true; - + // Retrieve the type from the annotation token, consume that token, and // return. EndLocation = Tok.getAnnotationEndLoc(); @@ -532,7 +532,7 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation, // We have an identifier; check whether it is actually a type. TypeTy *Type = Actions.getTypeName(*Id, IdLoc, CurScope, SS, true); - if (!Type) { + if (!Type) { Diag(IdLoc, diag::err_expected_class_name); return true; } @@ -601,7 +601,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, Actions.CodeCompleteTag(CurScope, TagType); ConsumeToken(); } - + AttributeList *AttrList = 0; // If attributes exist after tag, parse them. if (Tok.is(tok::kw___attribute)) @@ -610,7 +610,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // If declspecs exist after tag, parse them. if (Tok.is(tok::kw___declspec)) AttrList = ParseMicrosoftDeclSpec(AttrList); - + // If C++0x attributes exist here, parse them. // FIXME: Are we consistent with the ordering of parsing of different // styles of attributes? @@ -642,7 +642,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, if (getLang().CPlusPlus) { // "FOO : BAR" is not a potential typo for "FOO::BAR". ColonProtectionRAIIObject X(*this); - + ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true); if (SS.isSet()) if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) @@ -658,21 +658,21 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, if (Tok.is(tok::identifier)) { Name = Tok.getIdentifierInfo(); NameLoc = ConsumeToken(); - + if (Tok.is(tok::less)) { - // The name was supposed to refer to a template, but didn't. + // The name was supposed to refer to a template, but didn't. // Eat the template argument list and try to continue parsing this as // a class (or template thereof). TemplateArgList TemplateArgs; SourceLocation LAngleLoc, RAngleLoc; - if (ParseTemplateIdAfterTemplateName(TemplateTy(), NameLoc, &SS, + if (ParseTemplateIdAfterTemplateName(TemplateTy(), NameLoc, &SS, true, LAngleLoc, TemplateArgs, RAngleLoc)) { // We couldn't parse the template argument list at all, so don't // try to give any location information for the list. LAngleLoc = RAngleLoc = SourceLocation(); } - + Diag(NameLoc, diag::err_explicit_spec_non_template) << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) << (TagType == DeclSpec::TST_class? 0 @@ -680,30 +680,30 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, : 2) << Name << SourceRange(LAngleLoc, RAngleLoc); - - // Strip off the last template parameter list if it was empty, since + + // Strip off the last template parameter list if it was empty, since // we've removed its template argument list. if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) { if (TemplateParams && TemplateParams->size() > 1) { TemplateParams->pop_back(); } else { TemplateParams = 0; - const_cast(TemplateInfo).Kind + const_cast(TemplateInfo).Kind = ParsedTemplateInfo::NonTemplate; } } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) { // Pretend this is just a forward declaration. TemplateParams = 0; - const_cast(TemplateInfo).Kind + const_cast(TemplateInfo).Kind = ParsedTemplateInfo::NonTemplate; - const_cast(TemplateInfo).TemplateLoc + const_cast(TemplateInfo).TemplateLoc = SourceLocation(); const_cast(TemplateInfo).ExternLoc = SourceLocation(); } - - + + } } else if (Tok.is(tok::annot_template_id)) { TemplateId = static_cast(Tok.getAnnotationValue()); @@ -896,7 +896,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // less common call. if (IsDependent) TypeResult = Actions.ActOnDependentTag(CurScope, TagType, TUK, - SS, Name, StartLoc, NameLoc); + SS, Name, StartLoc, NameLoc); } // If there is a body, parse it and inform the actions module. @@ -927,11 +927,11 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // FIXME: The DeclSpec should keep the locations of both the keyword and the // name (if there is one). SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc; - + if (DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID, Result, Owned)) Diag(StartLoc, DiagID) << PrevSpec; - + // At this point, we've successfully parsed a class-specifier in 'definition' // form (e.g. "struct foo { int x; }". While we could just return here, we're // going to look at what comes after it to improve error recovery. If an @@ -984,14 +984,14 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, if (!isKnownToBeTypeSpecifier(NextToken())) ExpectedSemi = false; break; - - case tok::r_brace: // struct bar { struct foo {...} } + + case tok::r_brace: // struct bar { struct foo {...} } // Missing ';' at end of struct is accepted as an extension in C mode. if (!getLang().CPlusPlus) ExpectedSemi = false; break; } - + if (ExpectedSemi) { ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl, TagType == DeclSpec::TST_class ? "class" @@ -1000,7 +1000,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // to ';' so that the rest of the code recovers as though there were an // ';' after the definition. PP.EnterToken(Tok); - Tok.setKind(tok::semi); + Tok.setKind(tok::semi); } } } @@ -1084,7 +1084,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) { // Parse optional '::' and optional nested-name-specifier. CXXScopeSpec SS; - ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, + ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, /*EnteringContext=*/false); // The location of the base class itself. @@ -1251,7 +1251,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // Don't parse FOO:BAR as if it were a typo for FOO::BAR, in this context it // is a bitfield. ColonProtectionRAIIObject X(*this); - + CXX0XAttributeList AttrList; // Optional C++0x attribute-specifier if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) @@ -1259,7 +1259,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, if (Tok.is(tok::kw_using)) { // FIXME: Check for template aliases - + if (AttrList.HasAttr) Diag(AttrList.Range.getBegin(), diag::err_attributes_not_allowed) << AttrList.Range; @@ -1628,14 +1628,14 @@ void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) { llvm::SmallVector MemInitializers; bool AnyErrors = false; - + do { MemInitResult MemInit = ParseMemInitializer(ConstructorDecl); if (!MemInit.isInvalid()) MemInitializers.push_back(MemInit.get()); else AnyErrors = true; - + if (Tok.is(tok::comma)) ConsumeToken(); else if (Tok.is(tok::l_brace)) @@ -1869,7 +1869,7 @@ CXX0XAttributeList Parser::ParseCXX0XAttributes(SourceLocation *EndLoc) { ConsumeBracket(); ConsumeBracket(); - + if (Tok.is(tok::comma)) { Diag(Tok.getLocation(), diag::err_expected_ident); ConsumeToken(); @@ -1884,7 +1884,7 @@ CXX0XAttributeList Parser::ParseCXX0XAttributes(SourceLocation *EndLoc) { IdentifierInfo *ScopeName = 0, *AttrName = Tok.getIdentifierInfo(); SourceLocation ScopeLoc, AttrLoc = ConsumeToken(); - + // scoped attribute if (Tok.is(tok::coloncolon)) { ConsumeToken(); @@ -1894,7 +1894,7 @@ CXX0XAttributeList Parser::ParseCXX0XAttributes(SourceLocation *EndLoc) { SkipUntil(tok::r_square, tok::comma, true, true); continue; } - + ScopeName = AttrName; ScopeLoc = AttrLoc; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 5d352ceb04..cd049a27c1 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -58,7 +58,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { Diag(Loc, diag::warn_unavailable) << D->getDeclName(); Diag(D->getLocation(), diag::note_unavailable_here) << 0; } - + // See if this is a deleted function. if (FunctionDecl *FD = dyn_cast(D)) { if (FD->isDeleted()) { @@ -202,7 +202,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { void Sema::DefaultFunctionArrayLvalueConversion(Expr *&E) { DefaultFunctionArrayConversion(E); - + QualType Ty = E->getType(); assert(!Ty.isNull() && "DefaultFunctionArrayLvalueConversion - missing type"); if (!Ty->isDependentType() && Ty.hasQualifiers() && @@ -214,8 +214,8 @@ void Sema::DefaultFunctionArrayLvalueConversion(Expr *&E) { // rvalue is T // // C99 6.3.2.1p2: - // If the lvalue has qualified type, the value has the unqualified - // version of the type of the lvalue; otherwise, the value has the + // If the lvalue has qualified type, the value has the unqualified + // version of the type of the lvalue; otherwise, the value has the // type of the lvalue. ImpCastExprToType(E, Ty.getUnqualifiedType(), CastExpr::CK_NoOp); } @@ -289,7 +289,7 @@ bool Sema::DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT) { return true; if (!Expr->getType()->isPODType() && - DiagRuntimeBehavior(Expr->getLocStart(), + DiagRuntimeBehavior(Expr->getLocStart(), PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg) << Expr->getType() << CT)) return true; @@ -423,10 +423,10 @@ static bool ShouldSnapshotBlockValueReference(Sema &S, BlockScopeInfo *CurBlock, // all get the bit). Walk the nesting chain. for (unsigned I = S.FunctionScopes.size() - 1; I; --I) { BlockScopeInfo *NextBlock = dyn_cast(S.FunctionScopes[I]); - + if (!NextBlock) continue; - + // If we found the defining block for the variable, don't mark the block as // having a reference outside it. if (NextBlock->TheDecl == VD->getDeclContext()) @@ -469,9 +469,9 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, SourceLocation Loc, MarkDeclarationReferenced(Loc, D); - return Owned(DeclRefExpr::Create(Context, - SS? (NestedNameSpecifier *)SS->getScopeRep() : 0, - SS? SS->getRange() : SourceRange(), + return Owned(DeclRefExpr::Create(Context, + SS? (NestedNameSpecifier *)SS->getScopeRep() : 0, + SS? SS->getRange() : SourceRange(), D, Loc, Ty)); } @@ -768,14 +768,14 @@ static bool IsProvablyNotDerivedFrom(Sema &SemaRef, return true; } - + /// Determines if this is an instance member of a class. static bool IsInstanceMember(NamedDecl *D) { assert(D->isCXXClassMember() && "checking whether non-member is instance member"); if (isa(D)) return true; - + if (isa(D)) return !cast(D)->isStatic(); @@ -971,7 +971,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, Diag(R.getNameLoc(), diagnostic_suggest) << Name << R.getLookupName() << CodeModificationHint::CreateReplacement(R.getNameLoc(), R.getLookupName().getAsString()); - else + else Diag(R.getNameLoc(), diag::err_no_member_suggest) << Name << computeDeclContext(SS, false) << R.getLookupName() << SS.getRange() @@ -980,7 +980,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, if (NamedDecl *ND = R.getAsSingle()) Diag(ND->getLocation(), diag::note_previous_decl) << ND->getDeclName(); - + // Tell the callee to try to recover. return false; } @@ -993,7 +993,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, // to recover well anyway. if (SS.isEmpty()) Diag(R.getNameLoc(), diagnostic_suggest) << Name << R.getLookupName(); - else + else Diag(R.getNameLoc(), diag::err_no_member_suggest) << Name << computeDeclContext(SS, false) << R.getLookupName() << SS.getRange(); @@ -1107,7 +1107,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S, // If we found an Objective-C instance variable, let // LookupInObjCMethod build the appropriate expression to - // reference the ivar. + // reference the ivar. if (ObjCIvarDecl *Ivar = R.getAsSingle()) { R.clear(); OwningExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier())); @@ -1303,7 +1303,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, // turn this into Self->ivar, just return a BareIVarExpr or something. IdentifierInfo &II = Context.Idents.get("self"); UnqualifiedId SelfName; - SelfName.setIdentifier(&II, SourceLocation()); + SelfName.setIdentifier(&II, SourceLocation()); CXXScopeSpec SelfScopeSpec; OwningExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, SelfName, false, false); @@ -1326,7 +1326,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, // Needed to implement property "super.method" notation. if (Lookup.empty() && II->isStr("super")) { QualType T; - + if (getCurMethodDecl()->isInstanceMethod()) T = Context.getObjCObjectPointerType(Context.getObjCInterfaceType( getCurMethodDecl()->getClassInterface())); @@ -1363,7 +1363,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, CXXRecordDecl *RD = dyn_cast(Member->getDeclContext()); if (!RD) return false; - + QualType DestRecordType; QualType DestType; QualType FromRecordType; @@ -1371,7 +1371,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, bool PointerConversions = false; if (isa(Member)) { DestRecordType = Context.getCanonicalType(Context.getTypeDeclType(RD)); - + if (FromType->getAs()) { DestType = Context.getPointerType(DestRecordType); FromRecordType = FromType->getPointeeType(); @@ -1383,10 +1383,10 @@ Sema::PerformObjectMemberConversion(Expr *&From, } else if (CXXMethodDecl *Method = dyn_cast(Member)) { if (Method->isStatic()) return false; - + DestType = Method->getThisType(Context); DestRecordType = DestType->getPointeeType(); - + if (FromType->getAs()) { FromRecordType = FromType->getPointeeType(); PointerConversions = true; @@ -1398,16 +1398,16 @@ Sema::PerformObjectMemberConversion(Expr *&From, // No conversion necessary. return false; } - + if (DestType->isDependentType() || FromType->isDependentType()) return false; - + // If the unqualified types are the same, no conversion is necessary. if (Context.hasSameUnqualifiedType(FromRecordType, DestRecordType)) return false; - + // C++ [class.member.lookup]p8: - // [...] Ambiguities can often be resolved by qualifying a name with its + // [...] Ambiguities can often be resolved by qualifying a name with its // class name. // // If the member was a qualified name and the qualified referred to a @@ -1435,7 +1435,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, IntermediateType = Context.getPointerType(IntermediateType); } } - + if (!IntermediateType.isNull() && IsDerivedFrom(FromRecordType, IntermediateRecordType) && IsDerivedFrom(IntermediateRecordType, DestRecordType)) { @@ -1448,18 +1448,18 @@ Sema::PerformObjectMemberConversion(Expr *&From, return true; ImpCastExprToType(From, IntermediateType, CastExpr::CK_DerivedToBase, - /*isLvalue=*/!PointerConversions); + /*isLvalue=*/!PointerConversions); ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase, /*isLvalue=*/!PointerConversions); return false; } - + if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType, From->getSourceRange().getBegin(), From->getSourceRange())) return true; - + ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase, /*isLvalue=*/true); return false; @@ -1633,7 +1633,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, return Owned(ULE); } - + /// \brief Complete semantic analysis for a reference to the given declaration. Sema::OwningExprResult @@ -1658,7 +1658,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, // Make sure that we're referring to a value. ValueDecl *VD = dyn_cast(D); if (!VD) { - Diag(Loc, diag::err_ref_non_value) + Diag(Loc, diag::err_ref_non_value) << D << SS.getRange(); Diag(D->getLocation(), diag::note_declared_at); return ExprError(); @@ -1683,7 +1683,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, // We do not do this for things like enum constants, global variables, etc, // as they do not get snapshotted. // - if (getCurBlock() && + if (getCurBlock() && ShouldSnapshotBlockValueReference(*this, getCurBlock(), VD)) { if (VD->getType().getTypePtr()->isVariablyModifiedType()) { Diag(Loc, diag::err_ref_vm_type); @@ -1819,7 +1819,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) { if ((result & APFloat::opOverflow) || ((result & APFloat::opUnderflow) && Val.isZero())) { unsigned diagnostic; - llvm::SmallVector buffer; + llvm::SmallString<20> buffer; if (result & APFloat::opOverflow) { diagnostic = diag::warn_float_overflow; APFloat::getLargest(Format).toString(buffer); @@ -2531,7 +2531,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, } assert(DC && "Cannot handle non-computable dependent contexts in lookup"); - + if (!isa(DC)) { SemaRef.Diag(R.getNameLoc(), diag::err_qualified_member_nonclass) << DC << SS.getRange(); @@ -2548,7 +2548,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, // We didn't find anything with the given name, so try to correct // for typos. DeclarationName Name = R.getLookupName(); - if (SemaRef.CorrectTypo(R, 0, &SS, DC) && + if (SemaRef.CorrectTypo(R, 0, &SS, DC) && (isa(*R.begin()) || isa(*R.begin()))) { SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest) << Name << DC << R.getLookupName() << SS.getRange() @@ -2685,7 +2685,7 @@ Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType, return Owned(MemExpr); } - assert(R.isSingleResult()); + assert(R.isSingleResult()); NamedDecl *MemberDecl = R.getFoundDecl(); // FIXME: diagnose the presence of template arguments now. @@ -2831,13 +2831,13 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, Diag(Loc, diag::err_member_reference_needs_call) << QualType(Fun, 0) << CodeModificationHint::CreateInsertion(Loc, "()"); - + OwningExprResult NewBase - = ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc, + = ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc, MultiExprArg(*this, 0, 0), 0, Loc); if (NewBase.isInvalid()) return ExprError(); - + BaseExpr = NewBase.takeAs(); DefaultFunctionArrayConversion(BaseExpr); BaseType = BaseExpr->getType(); @@ -2907,20 +2907,20 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, // Look through local category implementations associated with the class. if (!Setter) Setter = IFace->getCategoryClassMethod(SetterSel); - + if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc)) return ExprError(); - + if (Getter || Setter) { QualType PType; - + if (Getter) PType = Getter->getResultType(); else // Get the expression type from Setter's incoming parameter. PType = (*(Setter->param_end() -1))->getType(); // FIXME: we must check that the setter has property type. - return Owned(new (Context) ObjCImplicitSetterGetterRefExpr(Getter, + return Owned(new (Context) ObjCImplicitSetterGetterRefExpr(Getter, PType, Setter, MemberLoc, BaseExpr)); } @@ -2928,7 +2928,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, << MemberName << BaseType); } } - + if (BaseType->isObjCClassType() && BaseType != Context.ObjCClassRedefinitionType) { BaseType = Context.ObjCClassRedefinitionType; @@ -2975,7 +2975,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, } } } - + // Handle field access to simple records. This also handles access // to fields of the ObjC 'id' struct. if (const RecordType *RTy = BaseType->getAs()) { @@ -3005,13 +3005,13 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, LookupMemberName); if (CorrectTypo(Res, 0, 0, IDecl) && (IV = Res.getAsSingle())) { - Diag(R.getNameLoc(), + Diag(R.getNameLoc(), diag::err_typecheck_member_reference_ivar_suggest) << IDecl->getDeclName() << MemberName << IV->getDeclName() << CodeModificationHint::CreateReplacement(R.getNameLoc(), IV->getNameAsString()); Diag(IV->getLocation(), diag::note_previous_decl) - << IV->getDeclName(); + << IV->getDeclName(); } } @@ -3179,7 +3179,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, // Attempt to correct for typos in property names. LookupResult Res(*this, R.getLookupName(), R.getNameLoc(), LookupOrdinaryName); - if (CorrectTypo(Res, 0, 0, IFace, false, OPT) && + if (CorrectTypo(Res, 0, 0, IFace, false, OPT) && Res.getAsSingle()) { Diag(R.getNameLoc(), diag::err_property_not_found_suggest) << MemberName << BaseType << Res.getLookupName() @@ -3187,7 +3187,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, Res.getLookupName().getAsString()); ObjCPropertyDecl *Property = Res.getAsSingle(); Diag(Property->getLocation(), diag::note_previous_decl) - << Property->getDeclName(); + << Property->getDeclName(); return LookupMemberExpr(Res, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl); @@ -3216,7 +3216,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, return Owned(new (Context) ExtVectorElementExpr(ret, BaseExpr, *Member, MemberLoc)); } - + Diag(MemberLoc, diag::err_typecheck_member_reference_struct_union) << BaseType << BaseExpr->getSourceRange(); @@ -3341,11 +3341,11 @@ Sema::OwningExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Expr *ResultE = Result.takeAs(); InitializationSequence InitSeq(*this, Entity, Kind, &ResultE, 1); - Result = InitSeq.Perform(*this, Entity, Kind, + Result = InitSeq.Perform(*this, Entity, Kind, MultiExprArg(*this, (void**)&ResultE, 1)); if (Result.isInvalid()) return ExprError(); - + // Build the default argument expression. return Owned(CXXDefaultArgExpr::Create(Context, CallLoc, Param, Result.takeAs())); @@ -3380,7 +3380,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // assignment, to the types of the corresponding parameter, ... unsigned NumArgsInProto = Proto->getNumArgs(); bool Invalid = false; - + // If too few arguments are available (and we don't have default // arguments for the remaining parameters), don't make the call. if (NumArgs < NumArgsInProto) { @@ -3405,7 +3405,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, } } llvm::SmallVector AllArgs; - VariadicCallType CallType = + VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; if (Fn->getType()->isBlockPointerType()) CallType = VariadicBlock; // Block @@ -3418,7 +3418,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, unsigned TotalNumArgs = AllArgs.size(); for (unsigned i = 0; i < TotalNumArgs; ++i) Call->setArg(i, AllArgs[i]); - + return false; } @@ -3439,23 +3439,23 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, // Continue to check argument types (even if we have too few/many args). for (unsigned i = FirstProtoArg; i != NumArgsToCheck; i++) { QualType ProtoArgType = Proto->getArgType(i); - + Expr *Arg; if (ArgIx < NumArgs) { Arg = Args[ArgIx++]; - + if (RequireCompleteType(Arg->getSourceRange().getBegin(), ProtoArgType, PDiag(diag::err_call_incomplete_argument) << Arg->getSourceRange())) return true; - + // Pass the argument ParmVarDecl *Param = 0; if (FDecl && i < FDecl->getNumParams()) Param = FDecl->getParamDecl(i); - + InitializedEntity Entity = Param? InitializedEntity::InitializeParameter(Param) : InitializedEntity::InitializeParameter(ProtoArgType); @@ -3468,17 +3468,17 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, Arg = ArgE.takeAs(); } else { ParmVarDecl *Param = FDecl->getParamDecl(i); - + OwningExprResult ArgExpr = BuildCXXDefaultArgExpr(CallLoc, FDecl, Param); if (ArgExpr.isInvalid()) return true; - + Arg = ArgExpr.takeAs(); } AllArgs.push_back(Arg); } - + // If this is a variadic call, handle args passed through "...". if (CallType != VariadicDoesNotApply) { // Promote the arguments (C99 6.5.2.2p7). @@ -3570,32 +3570,32 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, return BuildCallToMemberFunction(S, Fn, LParenLoc, Args, NumArgs, CommaLocs, RParenLoc); } - + // Determine whether this is a call to a pointer-to-member function. if (BinaryOperator *BO = dyn_cast(NakedFn)) { if (BO->getOpcode() == BinaryOperator::PtrMemD || BO->getOpcode() == BinaryOperator::PtrMemI) { - if (const FunctionProtoType *FPT = + if (const FunctionProtoType *FPT = dyn_cast(BO->getType())) { QualType ResultTy = FPT->getResultType().getNonReferenceType(); - - ExprOwningPtr - TheCall(this, new (Context) CXXMemberCallExpr(Context, BO, Args, + + ExprOwningPtr + TheCall(this, new (Context) CXXMemberCallExpr(Context, BO, Args, NumArgs, ResultTy, RParenLoc)); - - if (CheckCallReturnType(FPT->getResultType(), - BO->getRHS()->getSourceRange().getBegin(), + + if (CheckCallReturnType(FPT->getResultType(), + BO->getRHS()->getSourceRange().getBegin(), TheCall.get(), 0)) return ExprError(); - if (ConvertArgumentsForCall(&*TheCall, BO, 0, FPT, Args, NumArgs, + if (ConvertArgumentsForCall(&*TheCall, BO, 0, FPT, Args, NumArgs, RParenLoc)) return ExprError(); return Owned(MaybeBindToTemporary(TheCall.release()).release()); } - return ExprError(Diag(Fn->getLocStart(), + return ExprError(Diag(Fn->getLocStart(), diag::err_typecheck_call_not_function) << Fn->getType() << Fn->getSourceRange()); } @@ -3661,7 +3661,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, << Fn->getType() << Fn->getSourceRange()); // Check for a valid return type - if (CheckCallReturnType(FuncT->getResultType(), + if (CheckCallReturnType(FuncT->getResultType(), Fn->getSourceRange().getBegin(), TheCall.get(), FDecl)) return ExprError(); @@ -3762,7 +3762,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, InitializedEntity Entity = InitializedEntity::InitializeTemporary(literalType); InitializationKind Kind - = InitializationKind::CreateCast(SourceRange(LParenLoc, RParenLoc), + = InitializationKind::CreateCast(SourceRange(LParenLoc, RParenLoc), /*IsCStyleCast=*/true); InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1); OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, @@ -3780,7 +3780,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, } Result.release(); - + return Owned(new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, literalExpr, isFileScope)); } @@ -3807,13 +3807,13 @@ static CastExpr::CastKind getScalarCastKind(ASTContext &Context, if (SrcTy->hasPointerRepresentation()) { if (DestTy->hasPointerRepresentation()) - return DestTy->isObjCObjectPointerType() ? - CastExpr::CK_AnyPointerToObjCPointerCast : + return DestTy->isObjCObjectPointerType() ? + CastExpr::CK_AnyPointerToObjCPointerCast : CastExpr::CK_BitCast; if (DestTy->isIntegerType()) return CastExpr::CK_PointerToIntegral; } - + if (SrcTy->isIntegerType()) { if (DestTy->isIntegerType()) return CastExpr::CK_IntegralCast; @@ -3822,14 +3822,14 @@ static CastExpr::CastKind getScalarCastKind(ASTContext &Context, if (DestTy->isRealFloatingType()) return CastExpr::CK_IntegralToFloating; } - + if (SrcTy->isRealFloatingType()) { if (DestTy->isRealFloatingType()) return CastExpr::CK_FloatingCast; if (DestTy->isIntegerType()) return CastExpr::CK_FloatingToIntegral; } - + // FIXME: Assert here. // assert(false && "Unhandled cast combination!"); return CastExpr::CK_Unknown; @@ -3853,7 +3853,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, Kind = CastExpr::CK_ToVoid; return false; } - + if (!castType->isScalarType() && !castType->isVectorType()) { if (Context.hasSameUnqualifiedType(castType, castExpr->getType()) && (castType->isStructureType() || castType->isUnionType())) { @@ -3864,14 +3864,14 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, Kind = CastExpr::CK_NoOp; return false; } - + if (castType->isUnionType()) { // GCC cast to union extension RecordDecl *RD = castType->getAs()->getDecl(); RecordDecl::field_iterator Field, FieldEnd; for (Field = RD->field_begin(), FieldEnd = RD->field_end(); Field != FieldEnd; ++Field) { - if (Context.hasSameUnqualifiedType(Field->getType(), + if (Context.hasSameUnqualifiedType(Field->getType(), castExpr->getType())) { Diag(TyR.getBegin(), diag::ext_typecheck_cast_to_union) << castExpr->getSourceRange(); @@ -3884,22 +3884,22 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, Kind = CastExpr::CK_ToUnion; return false; } - + // Reject any other conversions to non-scalar types. return Diag(TyR.getBegin(), diag::err_typecheck_cond_expect_scalar) << castType << castExpr->getSourceRange(); } - - if (!castExpr->getType()->isScalarType() && + + if (!castExpr->getType()->isScalarType() && !castExpr->getType()->isVectorType()) { return Diag(castExpr->getLocStart(), diag::err_typecheck_expect_scalar_operand) << castExpr->getType() << castExpr->getSourceRange(); } - - if (castType->isExtVectorType()) + + if (castType->isExtVectorType()) return CheckExtVectorCast(TyR, castType, castExpr, Kind); - + if (castType->isVectorType()) return CheckVectorCast(TyR, castType, castExpr->getType(), Kind); if (castExpr->getType()->isVectorType()) @@ -3907,10 +3907,10 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, if (getLangOptions().ObjC1 && isa(castExpr)) return Diag(castExpr->getLocStart(), diag::err_illegal_super_cast) << TyR; - + if (isa(castExpr)) return Diag(castExpr->getLocStart(), diag::err_cast_selector_expr); - + if (!castType->isArithmeticType()) { QualType castExprType = castExpr->getType(); if (!castExprType->isIntegralType() && castExprType->isArithmeticType()) @@ -3948,12 +3948,12 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, return false; } -bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, +bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, CastExpr::CastKind &Kind) { assert(DestTy->isExtVectorType() && "Not an extended vector type!"); - + QualType SrcTy = CastExpr->getType(); - + // If SrcTy is a VectorType, the total size must match to explicitly cast to // an ExtVectorType. if (SrcTy->isVectorType()) { @@ -3975,7 +3975,7 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, QualType DestElemTy = DestTy->getAs()->getElementType(); ImpCastExprToType(CastExpr, DestElemTy, getScalarCastKind(Context, SrcTy, DestElemTy)); - + Kind = CastExpr::CK_VectorSplat; return false; } @@ -4169,14 +4169,14 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, ImpCastExprToType(LHS, RHSTy, CastExpr::CK_Unknown); return RHSTy; } - + // All objective-c pointer type analysis is done here. QualType compositeType = FindCompositeObjCPointerType(LHS, RHS, QuestionLoc); if (!compositeType.isNull()) return compositeType; - - + + // Handle block pointer types. if (LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType()) { if (!LHSTy->isBlockPointerType() || !RHSTy->isBlockPointerType()) { @@ -4198,7 +4198,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // The block pointer types aren't identical, continue checking. QualType lhptee = LHSTy->getAs()->getPointeeType(); QualType rhptee = RHSTy->getAs()->getPointeeType(); - + if (!Context.typesAreCompatible(lhptee.getUnqualifiedType(), rhptee.getUnqualifiedType())) { Diag(QuestionLoc, diag::warn_typecheck_cond_incompatible_pointers) @@ -4216,7 +4216,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); return LHSTy; } - + // Check constraints for C object pointers types (C99 6.5.15p3,6). if (LHSTy->isPointerType() && RHSTy->isPointerType()) { // get the "pointed to" types @@ -4300,7 +4300,7 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, SourceLocation QuestionLoc) { QualType LHSTy = LHS->getType(); QualType RHSTy = RHS->getType(); - + // Handle things like Class and struct objc_class*. Here we case the result // to the pseudo-builtin, because that will be implicitly cast back to the // redefinition type if an attempt is made to access its fields. @@ -4338,7 +4338,7 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, } // Check constraints for Objective-C object pointers types. if (LHSTy->isObjCObjectPointerType() && RHSTy->isObjCObjectPointerType()) { - + if (Context.getCanonicalType(LHSTy) == Context.getCanonicalType(RHSTy)) { // Two identical object pointer types are always compatible. return LHSTy; @@ -4346,7 +4346,7 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, const ObjCObjectPointerType *LHSOPT = LHSTy->getAs(); const ObjCObjectPointerType *RHSOPT = RHSTy->getAs(); QualType compositeType = LHSTy; - + // If both operands are interfaces and either operand can be // assigned to the other, use that type as the composite // type. This allows @@ -4357,7 +4357,7 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, // allow silent coercion. Finally, if the types are // incompatible then make sure to use 'id' as the composite // type so the result is acceptable for sending messages to. - + // FIXME: Consider unifying with 'areComparableObjCPointerTypes'. // It could return the composite type. if (Context.canAssignObjCInterfaces(LHSOPT, RHSOPT)) { @@ -4374,7 +4374,7 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, compositeType = Context.getObjCIdType(); } else if (LHSTy->isObjCIdType() || RHSTy->isObjCIdType()) { compositeType = Context.getObjCIdType(); - } else if (!(compositeType = + } else if (!(compositeType = Context.areCommonBaseCompatible(LHSOPT, RHSOPT)).isNull()) ; else { @@ -4512,7 +4512,7 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) { lhptee = Context.UnsignedCharTy; else if (lhptee->isSignedIntegerType()) lhptee = Context.getCorrespondingUnsignedType(lhptee); - + if (rhptee->isCharType()) rhptee = Context.UnsignedCharTy; else if (rhptee->isSignedIntegerType()) @@ -4526,7 +4526,7 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) { return ConvTy; return IncompatiblePointerSign; } - + // If we are a multi-level pointer, it's possible that our issue is simply // one of qualification - e.g. char ** -> const char ** is not allowed. If // the eventual target type is the same and the pointers have the same @@ -4535,15 +4535,15 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) { do { lhptee = lhptee->getAs()->getPointeeType(); rhptee = rhptee->getAs()->getPointeeType(); - + lhptee = Context.getCanonicalType(lhptee); rhptee = Context.getCanonicalType(rhptee); } while (lhptee->isPointerType() && rhptee->isPointerType()); - + if (Context.hasSameUnqualifiedType(lhptee, rhptee)) return IncompatibleNestedPointerQualifiers; } - + // General pointer incompatibility takes priority over qualifiers. return IncompatiblePointer; } @@ -4584,21 +4584,21 @@ Sema::AssignConvertType Sema::CheckObjCPointerTypesForAssignment(QualType lhsType, QualType rhsType) { if (lhsType->isObjCBuiltinType() || rhsType->isObjCBuiltinType()) return Compatible; - QualType lhptee = + QualType lhptee = lhsType->getAs()->getPointeeType(); - QualType rhptee = + QualType rhptee = rhsType->getAs()->getPointeeType(); // make sure we operate on the canonical type lhptee = Context.getCanonicalType(lhptee); rhptee = Context.getCanonicalType(rhptee); if (!lhptee.isAtLeastAsQualifiedAs(rhptee)) return CompatiblePointerDiscardsQualifiers; - + if (Context.typesAreCompatible(lhsType, rhsType)) return Compatible; if (lhsType->isObjCQualifiedIdType() || rhsType->isObjCQualifiedIdType()) return IncompatibleObjCQualifiedId; - return IncompatiblePointer; + return IncompatiblePointer; } /// CheckAssignmentConstraints (C99 6.5.16) - This routine currently @@ -4824,7 +4824,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) { break; } - if (rExpr->isNullPointerConstant(Context, + if (rExpr->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { ImpCastExprToType(rExpr, it->getType(), CastExpr::CK_IntegralToPointer); InitField = *it; @@ -4868,7 +4868,7 @@ Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) { if ((lhsType->isPointerType() || lhsType->isObjCObjectPointerType() || lhsType->isBlockPointerType()) - && rExpr->isNullPointerConstant(Context, + && rExpr->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { ImpCastExprToType(rExpr, lhsType, CastExpr::CK_Unknown); return Compatible; @@ -4976,13 +4976,13 @@ QualType Sema::CheckMultiplyDivideOperands( if (!lex->getType()->isArithmeticType() || !rex->getType()->isArithmeticType()) return InvalidOperands(Loc, lex, rex); - + // Check for division by zero. if (isDiv && rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull)) - DiagRuntimeBehavior(Loc, PDiag(diag::warn_division_by_zero) + DiagRuntimeBehavior(Loc, PDiag(diag::warn_division_by_zero) << rex->getSourceRange()); - + return compType; } @@ -4998,12 +4998,12 @@ QualType Sema::CheckRemainderOperands( if (!lex->getType()->isIntegerType() || !rex->getType()->isIntegerType()) return InvalidOperands(Loc, lex, rex); - + // Check for remainder by zero. if (rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull)) DiagRuntimeBehavior(Loc, PDiag(diag::warn_remainder_by_zero) << rex->getSourceRange()); - + return compType; } @@ -5319,13 +5319,13 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, Expr *literalString = 0; Expr *literalStringStripped = 0; if ((isa(LHSStripped) || isa(LHSStripped)) && - !RHSStripped->isNullPointerConstant(Context, + !RHSStripped->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { literalString = lex; literalStringStripped = LHSStripped; } else if ((isa(RHSStripped) || isa(RHSStripped)) && - !LHSStripped->isNullPointerConstant(Context, + !LHSStripped->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { literalString = rex; literalStringStripped = RHSStripped; @@ -5342,7 +5342,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, case BinaryOperator::NE: resultComparison = ") != 0"; break; default: assert(false && "Invalid comparison operator"); } - + DiagRuntimeBehavior(Loc, PDiag(diag::warn_stringcompare) << isa(literalStringStripped) @@ -5371,9 +5371,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, return ResultTy; } - bool LHSIsNull = lex->isNullPointerConstant(Context, + bool LHSIsNull = lex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull); - bool RHSIsNull = rex->isNullPointerConstant(Context, + bool RHSIsNull = rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull); // All of the following pointer related warnings are GCC extensions, except @@ -5416,9 +5416,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, << lType << rType << lex->getSourceRange() << rex->getSourceRange(); return QualType(); } else if (NonStandardCompositeType) { - Diag(Loc, + Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers_nonstandard) - << lType << rType << T + << lType << rType << T << lex->getSourceRange() << rex->getSourceRange(); } @@ -5489,9 +5489,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, << lType << rType << lex->getSourceRange() << rex->getSourceRange(); return QualType(); } else if (NonStandardCompositeType) { - Diag(Loc, + Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers_nonstandard) - << lType << rType << T + << lType << rType << T << lex->getSourceRange() << rex->getSourceRange(); } @@ -5677,10 +5677,10 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14] if (!lex->getType()->isScalarType() || !rex->getType()->isScalarType()) return InvalidOperands(Loc, lex, rex); - + return Context.IntTy; } - + // C++ [expr.log.and]p1 // C++ [expr.log.or]p1 // The operands are both implicitly converted to type bool (clause 4). @@ -5692,16 +5692,16 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14] if (PerformImplicitConversion(lex, Context.BoolTy, LHS, AA_Passing, /*IgnoreBaseAccess=*/false)) return InvalidOperands(Loc, lex, rex); - + StandardConversionSequence RHS; if (!IsStandardConversion(rex, Context.BoolTy, /*InOverloadResolution=*/false, RHS)) return InvalidOperands(Loc, lex, rex); - + if (PerformImplicitConversion(rex, Context.BoolTy, RHS, AA_Passing, /*IgnoreBaseAccess=*/false)) return InvalidOperands(Loc, lex, rex); - + // C++ [expr.log.and]p2 // C++ [expr.log.or]p2 // The result is a bool. @@ -6341,10 +6341,10 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc, Self.Diag(Loc, PD) << CodeModificationHint::CreateInsertion(ParenRange.getBegin(), "(") << CodeModificationHint::CreateInsertion(EndLoc, ")"); - + if (!SecondPD.getDiagID()) return; - + EndLoc = Self.PP.getLocForEndOfToken(SecondParenRange.getEnd()); if (!SecondParenRange.getEnd().isFileID() || EndLoc.isInvalid()) { // We can't display the parentheses, so just dig the @@ -6352,7 +6352,7 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc, Self.Diag(Loc, SecondPD); return; } - + Self.Diag(Loc, SecondPD) << CodeModificationHint::CreateInsertion(SecondParenRange.getBegin(), "(") << CodeModificationHint::CreateInsertion(EndLoc, ")"); @@ -6442,12 +6442,12 @@ Action::OwningExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc, if (S && OverOp != OO_None) LookupOverloadedOperatorName(OverOp, S, lhs->getType(), rhs->getType(), Functions); - + // Build the (potentially-overloaded, potentially-dependent) // binary operation. return CreateOverloadedBinOp(OpLoc, Opc, Functions, lhs, rhs); } - + // Build a built-in binary operation. return CreateBuiltinBinOp(OpLoc, Opc, lhs, rhs); } @@ -6555,10 +6555,10 @@ Action::OwningExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc, if (S && OverOp != OO_None) LookupOverloadedOperatorName(OverOp, S, Input->getType(), QualType(), Functions); - + return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, move(input)); } - + return CreateBuiltinUnaryOp(OpLoc, Opc, move(input)); } @@ -6818,7 +6818,7 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *BlockScope) { void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { assert(ParamInfo.getIdentifier()==0 && "block-id should have no identifier!"); BlockScopeInfo *CurBlock = getCurBlock(); - + if (ParamInfo.getNumTypeObjects() == 0 || ParamInfo.getTypeObject(0).Kind != DeclaratorChunk::Function) { ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo); @@ -6985,13 +6985,13 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, PopFunctionOrBlockScope(); return ExprError(); } - + AnalysisContext AC(BSI->TheDecl); CheckFallThroughForBlock(BlockTy, BSI->TheDecl->getBody(), AC); CheckUnreachable(AC); Expr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy, BSI->hasBlockDeclRefExprs); - PopFunctionOrBlockScope(); + PopFunctionOrBlockScope(); return Owned(Result); } @@ -7048,14 +7048,14 @@ Sema::OwningExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) { return Owned(new (Context) GNUNullExpr(Ty, TokenLoc)); } -static void +static void MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef, QualType DstType, Expr *SrcExpr, CodeModificationHint &Hint) { if (!SemaRef.getLangOptions().ObjC1) return; - + const ObjCObjectPointerType *PT = DstType->getAs(); if (!PT) return; @@ -7067,12 +7067,12 @@ MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef, if (!ID || !ID->getIdentifier()->isStr("NSString")) return; } - + // Strip off any parens and casts. StringLiteral *SL = dyn_cast(SrcExpr->IgnoreParenCasts()); if (!SL || SL->isWide()) return; - + Hint = CodeModificationHint::CreateInsertion(SL->getLocStart(), "@"); } @@ -7084,7 +7084,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, bool isInvalid = false; unsigned DiagKind; CodeModificationHint Hint; - + switch (ConvTy) { default: assert(0 && "Unknown conversion type"); case Compatible: return false; @@ -7201,7 +7201,7 @@ Sema::PopExpressionEvaluationContext() { // Mark any remaining declarations in the current position of the stack // as "referenced". If they were not meant to be referenced, semantic // analysis would have eliminated them (e.g., in ActOnCXXTypeId). - for (PotentiallyReferencedDecls::iterator + for (PotentiallyReferencedDecls::iterator I = Rec.PotentiallyReferenced->begin(), IEnd = Rec.PotentiallyReferenced->end(); I != IEnd; ++I) @@ -7216,13 +7216,13 @@ Sema::PopExpressionEvaluationContext() { I != IEnd; ++I) Diag(I->first, I->second); } - } + } // When are coming out of an unevaluated context, clear out any // temporaries that we may have created as part of the evaluation of // the expression in that context: they aren't relevant because they // will never be constructed. - if (Rec.Context == Unevaluated && + if (Rec.Context == Unevaluated && ExprTemporaries.size() > Rec.NumTemporaries) ExprTemporaries.erase(ExprTemporaries.begin() + Rec.NumTemporaries, ExprTemporaries.end()); @@ -7251,7 +7251,7 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { // template or not. The reason for this is that unevaluated expressions // (e.g. (void)sizeof()) constitute a use for warning purposes (-Wunused-variables and // -Wunused-parameters) - if (isa(D) || + if (isa(D) || (isa(D) && D->getDeclContext()->isFunctionOrMethod())) D->setUsed(true); @@ -7289,7 +7289,7 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { if (!Constructor->isUsed()) DefineImplicitCopyConstructor(Loc, Constructor, TypeQuals); } - + MaybeMarkVirtualMembersReferenced(Loc, Constructor); } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) { if (Destructor->isImplicit() && !Destructor->isUsed()) @@ -7311,32 +7311,32 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { = Function->getTemplateSpecializationInfo()) { if (SpecInfo->getPointOfInstantiation().isInvalid()) SpecInfo->setPointOfInstantiation(Loc); - else if (SpecInfo->getTemplateSpecializationKind() + else if (SpecInfo->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) AlreadyInstantiated = true; - } else if (MemberSpecializationInfo *MSInfo + } else if (MemberSpecializationInfo *MSInfo = Function->getMemberSpecializationInfo()) { if (MSInfo->getPointOfInstantiation().isInvalid()) MSInfo->setPointOfInstantiation(Loc); - else if (MSInfo->getTemplateSpecializationKind() + else if (MSInfo->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) AlreadyInstantiated = true; } - + if (!AlreadyInstantiated) { if (isa(Function->getDeclContext()) && cast(Function->getDeclContext())->isLocalClass()) PendingLocalImplicitInstantiations.push_back(std::make_pair(Function, Loc)); else - PendingImplicitInstantiations.push_back(std::make_pair(Function, + PendingImplicitInstantiations.push_back(std::make_pair(Function, Loc)); } } - + // FIXME: keep track of references to static functions Function->setUsed(true); - + return; } @@ -7364,29 +7364,29 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { /// of the program being compiled. /// /// This routine emits the given diagnostic when the code currently being -/// type-checked is "potentially evaluated", meaning that there is a +/// type-checked is "potentially evaluated", meaning that there is a /// possibility that the code will actually be executable. Code in sizeof() /// expressions, code used only during overload resolution, etc., are not /// potentially evaluated. This routine will suppress such diagnostics or, /// in the absolutely nutty case of potentially potentially evaluated -/// expressions (C++ typeid), queue the diagnostic to potentially emit it +/// expressions (C++ typeid), queue the diagnostic to potentially emit it /// later. -/// +/// /// This routine should be used for all diagnostics that describe the run-time /// behavior of a program, such as passing a non-POD value through an ellipsis. /// Failure to do so will likely result in spurious diagnostics or failures /// during overload resolution or within sizeof/alignof/typeof/typeid. -bool Sema::DiagRuntimeBehavior(SourceLocation Loc, +bool Sema::DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD) { switch (ExprEvalContexts.back().Context ) { case Unevaluated: // The argument will never be evaluated, so don't complain. break; - + case PotentiallyEvaluated: Diag(Loc, PD); return true; - + case PotentiallyPotentiallyEvaluated: ExprEvalContexts.back().addDiagnostic(Loc, PD); break; @@ -7404,12 +7404,12 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc, FD ? PDiag(diag::note_function_with_incomplete_return_type_declared_here) << FD->getDeclName() : PDiag(); SourceLocation NoteLoc = FD ? FD->getLocation() : SourceLocation(); - + if (RequireCompleteType(Loc, ReturnType, - FD ? + FD ? PDiag(diag::err_call_function_incomplete_return) << CE->getSourceRange() << FD->getDeclName() : - PDiag(diag::err_call_incomplete_return) + PDiag(diag::err_call_incomplete_return) << CE->getSourceRange(), std::make_pair(NoteLoc, Note))) return true; @@ -7459,7 +7459,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { SourceLocation Open = E->getSourceRange().getBegin(); SourceLocation Close = PP.getLocForEndOfToken(E->getSourceRange().getEnd()); - + Diag(Loc, diagnostic) << E->getSourceRange() << CodeModificationHint::CreateInsertion(Open, "(") -- 2.40.0