From d98114647e16796a976b04af79975b4f0eacf22b Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 21 Nov 2010 14:11:41 +0000 Subject: [PATCH] Fix a bunch of IndirectFieldDecl-related warnings. - Negative ChainingSize doesn't make sense, make it unsigned. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119943 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Decl.h | 8 ++++---- lib/AST/Decl.cpp | 7 ++++--- lib/Sema/SemaExpr.cpp | 2 +- tools/libclang/CIndex.cpp | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index a5e29c6146..9540804e3a 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1799,23 +1799,23 @@ public: /// IndirectFieldDecl are always implicit. class IndirectFieldDecl : public ValueDecl { NamedDecl **Chaining; - int ChainingSize; + unsigned ChainingSize; IndirectFieldDecl(DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, - NamedDecl **CH, int CHS) + NamedDecl **CH, unsigned CHS) : ValueDecl(IndirectField, DC, L, N, T), Chaining(CH), ChainingSize(CHS) {} public: static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - QualType T, NamedDecl **CH, int CHS); + QualType T, NamedDecl **CH, unsigned CHS); typedef NamedDecl * const *chain_iterator; chain_iterator chain_begin() const { return Chaining; } chain_iterator chain_end() const { return Chaining+ChainingSize; } - int getChainingSize() const { return ChainingSize; } + unsigned getChainingSize() const { return ChainingSize; } FieldDecl *getAnonField() const { assert(ChainingSize >= 2); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index ef8f16861e..9664fe2684 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2030,9 +2030,10 @@ EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, return new (C) EnumConstantDecl(CD, L, Id, T, E, V); } -IndirectFieldDecl *IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, IdentifierInfo *Id, - QualType T, NamedDecl **CH, int CHS) { +IndirectFieldDecl * +IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, + IdentifierInfo *Id, QualType T, NamedDecl **CH, + unsigned CHS) { return new (C) IndirectFieldDecl(DC, L, Id, T, CH, CHS); } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 37561028c2..d8f3ccf8a4 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7913,7 +7913,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, FieldDecl *MemberDecl = R.getAsSingle(); IndirectFieldDecl *IndirectMemberDecl = 0; if (!MemberDecl) { - if (IndirectMemberDecl = R.getAsSingle()) + if ((IndirectMemberDecl = R.getAsSingle())) MemberDecl = IndirectMemberDecl->getAnonField(); } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 55331f6db4..2bc362adfc 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3555,6 +3555,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) { case Decl::TemplateTypeParm: case Decl::EnumConstant: case Decl::Field: + case Decl::IndirectField: case Decl::ObjCIvar: case Decl::ObjCAtDefsField: case Decl::ImplicitParam: -- 2.40.0