diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/CodeCompleteConsumer.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 39 | ||||
-rw-r--r-- | clang/lib/Sema/IdentifierResolver.cpp | 22 | ||||
-rw-r--r-- | clang/lib/Sema/SemaFixItUtils.cpp | 29 |
4 files changed, 44 insertions, 66 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp index f88ee1a97ac..d012e55e3da 100644 --- a/clang/lib/Sema/CodeCompleteConsumer.cpp +++ b/clang/lib/Sema/CodeCompleteConsumer.cpp @@ -285,11 +285,11 @@ CodeCompletionString::CodeCompletionString(const Chunk *Chunks, assert(NumChunks <= 0xffff); assert(NumAnnotations <= 0xffff); - auto *StoredChunks = reinterpret_cast<Chunk *>(this + 1); + Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1); for (unsigned I = 0; I != NumChunks; ++I) StoredChunks[I] = Chunks[I]; - const auto **StoredAnnotations = reinterpret_cast<const char **>(StoredChunks + NumChunks); + const char **StoredAnnotations = reinterpret_cast<const char **>(StoredChunks + NumChunks); for (unsigned I = 0; I != NumAnnotations; ++I) StoredAnnotations[I] = Annotations[I]; } @@ -340,14 +340,14 @@ const char *CodeCompletionAllocator::CopyString(const Twine &String) { // FIXME: It would be more efficient to teach Twine to tell us its size and // then add a routine there to fill in an allocated char* with the contents // of the string. - auto *Mem = (char *)Allocate(Ref.size() + 1, 1); + char *Mem = (char *)Allocate(Ref.size() + 1, 1); std::copy(Ref.begin(), Ref.end(), Mem); Mem[Ref.size()] = 0; return Mem; } StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { - const auto *ND = dyn_cast<NamedDecl>(DC); + const NamedDecl *ND = dyn_cast<NamedDecl>(DC); if (!ND) return {}; @@ -364,7 +364,7 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { // Find the interesting names. SmallVector<const DeclContext *, 2> Contexts; while (DC && !DC->isFunctionOrMethod()) { - if (const auto *ND = dyn_cast<NamedDecl>(DC)) { + if (const NamedDecl *ND = dyn_cast<NamedDecl>(DC)) { if (ND->getIdentifier()) Contexts.push_back(DC); } @@ -384,10 +384,10 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { } const DeclContext *CurDC = Contexts[I-1]; - if (const auto *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC)) + if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC)) CurDC = CatImpl->getCategoryDecl(); - if (const auto *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) { + if (const ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) { const ObjCInterfaceDecl *Interface = Cat->getClassInterface(); if (!Interface) { // Assign an empty StringRef but with non-null data to distinguish @@ -413,7 +413,7 @@ CodeCompletionString *CodeCompletionBuilder::TakeString() { sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size() + sizeof(const char *) * Annotations.size(), alignof(CodeCompletionString)); - auto *Result + CodeCompletionString *Result = new (Mem) CodeCompletionString(Chunks.data(), Chunks.size(), Priority, Availability, Annotations.data(), Annotations.size(), @@ -463,7 +463,7 @@ void CodeCompletionBuilder::addParentContext(const DeclContext *DC) { if (DC->isFunctionOrMethod()) return; - const auto *ND = dyn_cast<NamedDecl>(DC); + const NamedDecl *ND = dyn_cast<NamedDecl>(DC); if (!ND) return; @@ -655,7 +655,7 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) { break; } - if (const auto *Function = dyn_cast<FunctionDecl>(Declaration)) + if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration)) if (Function->isDeleted()) Availability = CXAvailability_NotAvailable; diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 292898cbf03..2fad5a18ba6 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -1,4 +1,4 @@ -//===- DeclSpec.cpp - Declaration Specifier Semantic Analysis -------------===// +//===--- DeclSpec.cpp - Declaration Specifier Semantic Analysis -----------===// // // The LLVM Compiler Infrastructure // @@ -13,36 +13,21 @@ #include "clang/Sema/DeclSpec.h" #include "clang/AST/ASTContext.h" -#include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Expr.h" #include "clang/AST/LocInfoType.h" -#include "clang/AST/PrettyPrinter.h" -#include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/ExceptionSpecificationType.h" -#include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" -#include "clang/Basic/OpenCLOptions.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Sema/AttributeList.h" #include "clang/Sema/ParsedTemplate.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Casting.h" -#include "llvm/Support/ErrorHandling.h" -#include <cassert> #include <cstring> -#include <utility> - using namespace clang; + void UnqualifiedId::setTemplateId(TemplateIdAnnotation *TemplateId) { assert(TemplateId && "NULL template-id annotation?"); Kind = UnqualifiedIdKind::IK_TemplateId; @@ -150,14 +135,14 @@ void CXXScopeSpec::Adopt(NestedNameSpecifierLoc Other) { SourceLocation CXXScopeSpec::getLastQualifierNameLoc() const { if (!Builder.getRepresentation()) - return {}; + return SourceLocation(); return Builder.getTemporary().getLocalBeginLoc(); } NestedNameSpecifierLoc CXXScopeSpec::getWithLocInContext(ASTContext &Context) const { if (!Builder.getRepresentation()) - return {}; + return NestedNameSpecifierLoc(); return Builder.getWithLocInContext(Context); } @@ -304,7 +289,7 @@ void Declarator::setDecompositionBindings( Name.EndLocation = RSquareLoc; // Allocate storage for bindings and stash them away. - if (!Bindings.empty()) { + if (Bindings.size()) { if (!InlineStorageUsed && Bindings.size() <= llvm::array_lengthof(InlineBindings)) { BindingGroup.Bindings = InlineBindings; @@ -321,8 +306,8 @@ void Declarator::setDecompositionBindings( } bool Declarator::isDeclarationOfFunction() const { - for (const auto &i : DeclTypeInfo) { - switch (i.Kind) { + for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) { + switch (DeclTypeInfo[i].Kind) { case DeclaratorChunk::Function: return true; case DeclaratorChunk::Paren: @@ -388,7 +373,7 @@ bool Declarator::isDeclarationOfFunction() const { if (QT.isNull()) return false; - if (const auto *LIT = dyn_cast<LocInfoType>(QT)) + if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) QT = LIT->getType(); if (QT.isNull()) @@ -422,6 +407,7 @@ bool DeclSpec::hasTagDefinition() const { /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this /// declaration specifier includes. +/// unsigned DeclSpec::getParsedSpecifiers() const { unsigned Res = 0; if (StorageClassSpec != SCS_unspecified || @@ -496,6 +482,7 @@ const char *DeclSpec::getSpecifierName(TSC C) { llvm_unreachable("Unknown typespec!"); } + const char *DeclSpec::getSpecifierName(TSS S) { switch (S) { case TSS_unspecified: return "unspecified"; @@ -790,14 +777,16 @@ bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy) { + if (TypeSpecType != TST_unspecified) { PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy); DiagID = diag::err_invalid_decl_spec_combination; return true; } - if (isPipe) + if (isPipe) { TypeSpecPipe = TSP_pipe; + } return false; } @@ -986,7 +975,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.Type = getTypeSpecType(); // Search the list of attributes for the presence of a mode attribute. writtenBS.ModeAttr = false; - AttributeList *attrs = getAttributes().getList(); + AttributeList* attrs = getAttributes().getList(); while (attrs) { if (attrs->getKind() == AttributeList::AT_Mode) { writtenBS.ModeAttr = true; diff --git a/clang/lib/Sema/IdentifierResolver.cpp b/clang/lib/Sema/IdentifierResolver.cpp index 1b3487d4c4e..f31c5174bf1 100644 --- a/clang/lib/Sema/IdentifierResolver.cpp +++ b/clang/lib/Sema/IdentifierResolver.cpp @@ -147,7 +147,7 @@ void IdentifierResolver::AddDecl(NamedDecl *D) { if (IdentifierInfo *II = Name.getAsIdentifierInfo()) updatingIdentifier(*II); - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); if (!Ptr) { Name.setFETokenInfo(D); @@ -159,7 +159,7 @@ void IdentifierResolver::AddDecl(NamedDecl *D) { if (isDeclPtr(Ptr)) { Name.setFETokenInfo(nullptr); IDI = &(*IdDeclInfos)[Name]; - auto *PrevD = static_cast<NamedDecl *>(Ptr); + NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); IDI->AddDecl(PrevD); } else IDI = toIdDeclInfo(Ptr); @@ -172,7 +172,7 @@ void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { if (IdentifierInfo *II = Name.getAsIdentifierInfo()) updatingIdentifier(*II); - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); if (!Ptr) { AddDecl(D); @@ -184,7 +184,7 @@ void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { // as appropriate. if (Pos == iterator()) { // Add the new declaration before the existing declaration. - auto *PrevD = static_cast<NamedDecl *>(Ptr); + NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); RemoveDecl(PrevD); AddDecl(D); AddDecl(PrevD); @@ -213,7 +213,7 @@ void IdentifierResolver::RemoveDecl(NamedDecl *D) { if (IdentifierInfo *II = Name.getAsIdentifierInfo()) updatingIdentifier(*II); - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); assert(Ptr && "Didn't find this decl on its identifier's chain!"); @@ -232,11 +232,11 @@ IdentifierResolver::begin(DeclarationName Name) { if (IdentifierInfo *II = Name.getAsIdentifierInfo()) readingIdentifier(*II); - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); if (!Ptr) return end(); if (isDeclPtr(Ptr)) - return iterator(static_cast<NamedDecl *>(Ptr)); + return iterator(static_cast<NamedDecl*>(Ptr)); IdDeclInfo *IDI = toIdDeclInfo(Ptr); @@ -304,7 +304,7 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ if (IdentifierInfo *II = Name.getAsIdentifierInfo()) readingIdentifier(*II); - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); if (!Ptr) { Name.setFETokenInfo(D); @@ -314,7 +314,7 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ IdDeclInfo *IDI; if (isDeclPtr(Ptr)) { - auto *PrevD = static_cast<NamedDecl *>(Ptr); + NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); switch (compareDeclarations(PrevD, D)) { case DMK_Different: @@ -397,7 +397,7 @@ void IdentifierResolver::updatingIdentifier(IdentifierInfo &II) { /// It creates a new IdDeclInfo if one was not created before for this id. IdentifierResolver::IdDeclInfo & IdentifierResolver::IdDeclInfoMap::operator[](DeclarationName Name) { - auto *Ptr = Name.getFETokenInfo<void>(); + void *Ptr = Name.getFETokenInfo<void>(); if (Ptr) return *toIdDeclInfo(Ptr); @@ -415,7 +415,7 @@ IdentifierResolver::IdDeclInfoMap::operator[](DeclarationName Name) { void IdentifierResolver::iterator::incrementSlowCase() { NamedDecl *D = **this; - auto *InfoPtr = D->getDeclName().getFETokenInfo<void>(); + void *InfoPtr = D->getDeclName().getFETokenInfo<void>(); assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?"); IdDeclInfo *Info = toIdDeclInfo(InfoPtr); diff --git a/clang/lib/Sema/SemaFixItUtils.cpp b/clang/lib/Sema/SemaFixItUtils.cpp index 3cc26c09385..714fbedf09b 100644 --- a/clang/lib/Sema/SemaFixItUtils.cpp +++ b/clang/lib/Sema/SemaFixItUtils.cpp @@ -1,4 +1,4 @@ -//===- SemaFixItUtils.cpp - Sema FixIts -----------------------------------===// +//===--- SemaFixItUtils.cpp - Sema FixIts ---------------------------------===// // // The LLVM Compiler Infrastructure // @@ -11,24 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "clang/Sema/SemaFixItUtils.h" #include "clang/AST/ASTContext.h" -#include "clang/AST/DeclCXX.h" -#include "clang/AST/DeclarationName.h" -#include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" -#include "clang/AST/Type.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/LLVM.h" -#include "clang/Basic/LangOptions.h" -#include "clang/Basic/SourceLocation.h" #include "clang/Lex/Preprocessor.h" #include "clang/Sema/Sema.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Casting.h" -#include <cassert> -#include <string> +#include "clang/Sema/SemaFixItUtils.h" using namespace clang; @@ -103,7 +91,7 @@ bool ConversionFixItGenerator::tryToFixConversion(const Expr *FullExpr, // Check if the argument needs to be dereferenced: // (type * -> type) or (type * -> type &). - if (const auto *FromPtrTy = dyn_cast<PointerType>(FromQTy)) { + if (const PointerType *FromPtrTy = dyn_cast<PointerType>(FromQTy)) { OverloadFixItKind FixKind = OFIK_Dereference; bool CanConvert = CompareTypes( @@ -115,7 +103,7 @@ bool ConversionFixItGenerator::tryToFixConversion(const Expr *FullExpr, isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)) return false; - if (const auto *UO = dyn_cast<UnaryOperator>(Expr)) { + if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) { if (UO->getOpcode() == UO_AddrOf) { FixKind = OFIK_RemoveTakeAddress; Hints.push_back(FixItHint::CreateRemoval( @@ -148,7 +136,8 @@ bool ConversionFixItGenerator::tryToFixConversion(const Expr *FullExpr, CanConvert = CompareTypes(S.Context.getPointerType(FromQTy), ToQTy, S, Begin, VK_RValue); if (CanConvert) { - if (const auto *UO = dyn_cast<UnaryOperator>(Expr)) { + + if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) { if (UO->getOpcode() == UO_Deref) { FixKind = OFIK_RemoveDereference; Hints.push_back(FixItHint::CreateRemoval( @@ -182,7 +171,7 @@ static std::string getScalarZeroExpressionForType( // Suggest "0" for non-enumeration scalar types, unless we can find a // better initializer. if (T.isEnumeralType()) - return {}; + return std::string(); if ((T.isObjCObjectPointerType() || T.isBlockPointerType()) && isMacroDefined(S, Loc, "nil")) return "nil"; @@ -219,12 +208,12 @@ Sema::getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const { const CXXRecordDecl *RD = T->getAsCXXRecordDecl(); if (!RD || !RD->hasDefinition()) - return {}; + return std::string(); if (LangOpts.CPlusPlus11 && !RD->hasUserProvidedDefaultConstructor()) return "{}"; if (RD->isAggregate()) return " = {}"; - return {}; + return std::string(); } std::string |