llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-static-analyzer-1 @llvm/pr-subscribers-clang-modules Author: Bill Wendling (bwendling) <details> <summary>Changes</summary> The IdentifierInfo isn't typically modified. Use 'const' wherever possible. --- Patch is 173.17 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/79365.diff 76 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+2-2) - (modified) clang/include/clang/AST/Decl.h (+20-17) - (modified) clang/include/clang/AST/DeclObjC.h (+15-14) - (modified) clang/include/clang/AST/DeclTemplate.h (+4-4) - (modified) clang/include/clang/AST/ExprCXX.h (+5-5) - (modified) clang/include/clang/AST/ExternalASTSource.h (+1-1) - (modified) clang/include/clang/AST/NestedNameSpecifier.h (+3-3) - (modified) clang/include/clang/Analysis/SelectorExtras.h (+2-2) - (modified) clang/include/clang/Basic/IdentifierTable.h (+13-12) - (modified) clang/include/clang/Lex/ExternalPreprocessorSource.h (+1-1) - (modified) clang/include/clang/Lex/MacroInfo.h (+4-4) - (modified) clang/include/clang/Lex/Preprocessor.h (+5-4) - (modified) clang/include/clang/Parse/Parser.h (+6-10) - (modified) clang/include/clang/Sema/CodeCompleteConsumer.h (+5-4) - (modified) clang/include/clang/Sema/DeclSpec.h (+11-12) - (modified) clang/include/clang/Sema/ParsedTemplate.h (+4-3) - (modified) clang/include/clang/Sema/Sema.h (+38-41) - (modified) clang/include/clang/Serialization/ASTReader.h (+5-5) - (modified) clang/lib/ARCMigrate/ObjCMT.cpp (+4-3) - (modified) clang/lib/ARCMigrate/TransAPIUses.cpp (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+4-7) - (modified) clang/lib/AST/ASTImporter.cpp (+3-3) - (modified) clang/lib/AST/Decl.cpp (+10-8) - (modified) clang/lib/AST/DeclObjC.cpp (+11-16) - (modified) clang/lib/AST/DeclTemplate.cpp (+6-8) - (modified) clang/lib/AST/NSAPI.cpp (+37-67) - (modified) clang/lib/AST/NestedNameSpecifier.cpp (+9-9) - (modified) clang/lib/AST/SelectorLocationsKind.cpp (+2-2) - (modified) clang/lib/AST/StmtPrinter.cpp (+2-2) - (modified) clang/lib/AST/StmtProfile.cpp (+3-3) - (modified) clang/lib/Analysis/ObjCNoReturn.cpp (+3-2) - (modified) clang/lib/Basic/IdentifierTable.cpp (+9-7) - (modified) clang/lib/CodeGen/CGBlocks.cpp (+2-2) - (modified) clang/lib/CodeGen/CGCUDANV.cpp (+1-1) - (modified) clang/lib/CodeGen/CGDecl.cpp (+2-2) - (modified) clang/lib/CodeGen/CGObjC.cpp (+11-12) - (modified) clang/lib/CodeGen/CGObjCMac.cpp (+6-7) - (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+1-1) - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+3-3) - (modified) clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp (+1-1) - (modified) clang/lib/Lex/HeaderSearch.cpp (+1-2) - (modified) clang/lib/Lex/MacroInfo.cpp (+1-1) - (modified) clang/lib/Lex/PPLexerChange.cpp (+4-5) - (modified) clang/lib/Lex/PPMacroExpansion.cpp (+2-2) - (modified) clang/lib/Lex/Preprocessor.cpp (+1-1) - (modified) clang/lib/Parse/ParseDecl.cpp (+1-1) - (modified) clang/lib/Parse/ParseDeclCXX.cpp (+1-1) - (modified) clang/lib/Parse/ParseExprCXX.cpp (+3-2) - (modified) clang/lib/Parse/ParseObjc.cpp (+6-6) - (modified) clang/lib/Parse/ParseTemplate.cpp (+2-2) - (modified) clang/lib/Sema/CodeCompleteConsumer.cpp (+2-1) - (modified) clang/lib/Sema/Sema.cpp (+2-3) - (modified) clang/lib/Sema/SemaCodeComplete.cpp (+53-55) - (modified) clang/lib/Sema/SemaDecl.cpp (+10-9) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+4-5) - (modified) clang/lib/Sema/SemaDeclObjC.cpp (+2-3) - (modified) clang/lib/Sema/SemaExprCXX.cpp (+11-13) - (modified) clang/lib/Sema/SemaExprObjC.cpp (+2-4) - (modified) clang/lib/Sema/SemaObjCProperty.cpp (+2-2) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+1-1) - (modified) clang/lib/Sema/SemaPseudoObject.cpp (+22-26) - (modified) clang/lib/Sema/SemaStmt.cpp (+3-5) - (modified) clang/lib/Sema/SemaTemplate.cpp (+10-16) - (modified) clang/lib/Serialization/ASTCommon.cpp (+1-1) - (modified) clang/lib/Serialization/ASTReader.cpp (+7-7) - (modified) clang/lib/Serialization/ASTWriter.cpp (+9-9) - (modified) clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (+2-2) - (modified) clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (+54-54) - (modified) clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (+2-1) - (modified) clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp (+1-1) - (modified) clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (+2-2) - (modified) clang/tools/libclang/CIndexCodeCompletion.cpp (+5-5) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h (+1-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (+4-3) - (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (+2-2) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+6-5) ``````````diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 3e46a5da3fc043f..ada8cda953261cb 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -3379,13 +3379,13 @@ const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, /// Utility function for constructing a nullary selector. inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) { - IdentifierInfo* II = &Ctx.Idents.get(name); + const IdentifierInfo *II = &Ctx.Idents.get(name); return Ctx.Selectors.getSelector(0, &II); } /// Utility function for constructing an unary selector. inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) { - IdentifierInfo* II = &Ctx.Idents.get(name); + const IdentifierInfo *II = &Ctx.Idents.get(name); return Ctx.Selectors.getSelector(1, &II); } diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index f26fb5ad5f13310..2facd5e8c12e20f 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1719,7 +1719,7 @@ class ImplicitParamDecl : public VarDecl { static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID); ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, - IdentifierInfo *Id, QualType Type, + const IdentifierInfo *Id, QualType Type, ImplicitParamKind ParamKind) : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, /*TInfo=*/nullptr, SC_None) { @@ -1753,7 +1753,7 @@ class ParmVarDecl : public VarDecl { protected: ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, QualType T, + SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg) : VarDecl(DK, C, DC, StartLoc, IdLoc, Id, T, TInfo, S) { assert(ParmVarDeclBits.HasInheritedDefaultArg == false); @@ -1765,10 +1765,10 @@ class ParmVarDecl : public VarDecl { public: static ParmVarDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, - QualType T, TypeSourceInfo *TInfo, - StorageClass S, Expr *DefArg); + SourceLocation StartLoc, SourceLocation IdLoc, + const IdentifierInfo *Id, QualType T, + TypeSourceInfo *TInfo, StorageClass S, + Expr *DefArg); static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -3075,7 +3075,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { protected: FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, QualType T, + SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle) : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), BitField(false), @@ -3091,7 +3091,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { static FieldDecl *Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, QualType T, + const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle); @@ -3312,8 +3312,9 @@ class IndirectFieldDecl : public ValueDecl, friend class ASTDeclReader; static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, IdentifierInfo *Id, - QualType T, llvm::MutableArrayRef<NamedDecl *> CH); + SourceLocation L, const IdentifierInfo *Id, + QualType T, + llvm::MutableArrayRef<NamedDecl *> CH); static IndirectFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -3361,9 +3362,9 @@ class TypeDecl : public NamedDecl { void anchor() override; protected: - TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, + TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation StartL = SourceLocation()) - : NamedDecl(DK, DC, L, Id), LocStart(StartL) {} + : NamedDecl(DK, DC, L, Id), LocStart(StartL) {} public: // Low-level accessor. If you just want the type defined by this node, @@ -3405,7 +3406,7 @@ class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> { protected: TypedefNameDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, TypeSourceInfo *TInfo) + const IdentifierInfo *Id, TypeSourceInfo *TInfo) : TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C), MaybeModedTInfo(TInfo, 0) {} @@ -3492,13 +3493,14 @@ class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> { /// type specifier. class TypedefDecl : public TypedefNameDecl { TypedefDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) + SourceLocation IdLoc, const IdentifierInfo *Id, + TypeSourceInfo *TInfo) : TypedefNameDecl(Typedef, C, DC, StartLoc, IdLoc, Id, TInfo) {} public: static TypedefDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, TypeSourceInfo *TInfo); + const IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); SourceRange getSourceRange() const override LLVM_READONLY; @@ -3515,14 +3517,15 @@ class TypeAliasDecl : public TypedefNameDecl { TypeAliasTemplateDecl *Template; TypeAliasDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) + SourceLocation IdLoc, const IdentifierInfo *Id, + TypeSourceInfo *TInfo) : TypedefNameDecl(TypeAlias, C, DC, StartLoc, IdLoc, Id, TInfo), Template(nullptr) {} public: static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, TypeSourceInfo *TInfo); + const IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); SourceRange getSourceRange() const override LLVM_READONLY; diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index f8f894b4b10d191..5bd5b9aab55f022 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -772,7 +772,7 @@ class ObjCPropertyDecl : public NamedDecl { // Synthesize ivar for this property ObjCIvarDecl *PropertyIvarDecl = nullptr; - ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, + ObjCPropertyDecl(DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl) : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), @@ -782,10 +782,12 @@ class ObjCPropertyDecl : public NamedDecl { PropertyImplementation(propControl) {} public: - static ObjCPropertyDecl * - Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, - TypeSourceInfo *TSI, PropertyControl propControl = None); + static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, const IdentifierInfo *Id, + SourceLocation AtLocation, + SourceLocation LParenLocation, QualType T, + TypeSourceInfo *TSI, + PropertyControl propControl = None); static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -1794,9 +1796,9 @@ class ObjCInterfaceDecl : public ObjCContainerDecl data().CategoryList = category; } - ObjCPropertyDecl - *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, - ObjCPropertyQueryKind QueryKind) const; + ObjCPropertyDecl * + FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, + ObjCPropertyQueryKind QueryKind) const; void collectPropertiesToImplement(PropertyMap &PM) const override; @@ -1954,8 +1956,8 @@ class ObjCIvarDecl : public FieldDecl { private: ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id, - QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW, + SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, + TypeSourceInfo *TInfo, AccessControl ac, Expr *BW, bool synthesized) : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit), @@ -1964,10 +1966,9 @@ class ObjCIvarDecl : public FieldDecl { public: static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, - IdentifierInfo *Id, QualType T, - TypeSourceInfo *TInfo, - AccessControl ac, Expr *BW = nullptr, - bool synthesized=false); + const IdentifierInfo *Id, QualType T, + TypeSourceInfo *TInfo, AccessControl ac, + Expr *BW = nullptr, bool synthesized = false); static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 832ad2de6b08a82..48413d8e6aa2f07 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1408,14 +1408,14 @@ class NonTypeTemplateParmDecl final NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, - IdentifierInfo *Id, QualType T, + const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo) : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc), TemplateParmPosition(D, P), ParameterPack(ParameterPack) {} NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, - IdentifierInfo *Id, QualType T, + const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos); @@ -1423,12 +1423,12 @@ class NonTypeTemplateParmDecl final public: static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, + SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo); static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, + SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos); diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 9a7c632c36c5e8a..c829312a0284ea7 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -2549,7 +2549,7 @@ class CXXDeleteExpr : public Expr { class PseudoDestructorTypeStorage { /// Either the type source information or the name of the type, if /// it couldn't be resolved due to type-dependence. - llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; + llvm::PointerUnion<TypeSourceInfo *, const IdentifierInfo *> Type; /// The starting source location of the pseudo-destructor type. SourceLocation Location; @@ -2557,7 +2557,7 @@ class PseudoDestructorTypeStorage { public: PseudoDestructorTypeStorage() = default; - PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) + PseudoDestructorTypeStorage(const IdentifierInfo *II, SourceLocation Loc) : Type(II), Location(Loc) {} PseudoDestructorTypeStorage(TypeSourceInfo *Info); @@ -2566,8 +2566,8 @@ class PseudoDestructorTypeStorage { return Type.dyn_cast<TypeSourceInfo *>(); } - IdentifierInfo *getIdentifier() const { - return Type.dyn_cast<IdentifierInfo *>(); + const IdentifierInfo *getIdentifier() const { + return Type.dyn_cast<const IdentifierInfo *>(); } SourceLocation getLocation() const { return Location; } @@ -2698,7 +2698,7 @@ class CXXPseudoDestructorExpr : public Expr { /// In a dependent pseudo-destructor expression for which we do not /// have full type information on the destroyed type, provides the name /// of the destroyed type. - IdentifierInfo *getDestroyedTypeIdentifier() const { + const IdentifierInfo *getDestroyedTypeIdentifier() const { return DestroyedType.getIdentifier(); } diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index 8e573965b0a3360..230c83943c22244 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -138,7 +138,7 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> { virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); /// Update an out-of-date identifier. - virtual void updateOutOfDateIdentifier(IdentifierInfo &II) {} + virtual void updateOutOfDateIdentifier(const IdentifierInfo &II) {} /// Find all declarations with the given name in the given context, /// and add them to the context by calling SetExternalVisibleDeclsForName diff --git a/clang/include/clang/AST/NestedNameSpecifier.h b/clang/include/clang/AST/NestedNameSpecifier.h index 3b6cf9721185092..7b0c21b9e7cfb15 100644 --- a/clang/include/clang/AST/NestedNameSpecifier.h +++ b/clang/include/clang/AST/NestedNameSpecifier.h @@ -124,7 +124,7 @@ class NestedNameSpecifier : public llvm::FoldingSetNode { /// cannot be resolved. static NestedNameSpecifier *Create(const ASTContext &Context, NestedNameSpecifier *Prefix, - IdentifierInfo *II); + const IdentifierInfo *II); /// Builds a nested name specifier that names a namespace. static NestedNameSpecifier *Create(const ASTContext &Context, @@ -134,7 +134,7 @@ class NestedNameSpecifier : public llvm::FoldingSetNode { /// Builds a nested name specifier that names a namespace alias. static NestedNameSpecifier *Create(const ASTContext &Context, NestedNameSpecifier *Prefix, - NamespaceAliasDecl *Alias); + const NamespaceAliasDecl *Alias); /// Builds a nested name specifier that names a type. static NestedNameSpecifier *Create(const ASTContext &Context, @@ -148,7 +148,7 @@ class NestedNameSpecifier : public llvm::FoldingSetNode { /// nested name specifier, e.g., in "x->Base::f", the "x" has a dependent /// type. static NestedNameSpecifier *Create(const ASTContext &Context, - IdentifierInfo *II); + const IdentifierInfo *II); /// Returns the nested name specifier representing the global /// scope. diff --git a/clang/include/clang/Analysis/SelectorExtras.h b/clang/include/clang/Analysis/SelectorExtras.h index 1e1daf5706bbf5a..ac2c2519beae35e 100644 --- a/clang/include/clang/Analysis/SelectorExtras.h +++ b/clang/include/clang/Analysis/SelectorExtras.h @@ -15,10 +15,10 @@ namespace clang { template <typename... IdentifierInfos> static inline Selector getKeywordSelector(ASTContext &Ctx, - IdentifierInfos *... IIs) { + const IdentifierInfos *...IIs) { static_assert(sizeof...(IdentifierInfos) > 0, "keyword selectors must have at least one argument"); - SmallVector<IdentifierInfo *, 10> II({&Ctx.Idents.get(IIs)...}); + SmallVector<const IdentifierInfo *, 10> II({&Ctx.Idents.get(IIs)...}); return Ctx.Selectors.getSelector(II.size(), &II[0]); } diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 1ac182d4fce26f6..f15be11e8f2c6ae 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -888,12 +888,13 @@ class alignas(IdentifierInfoAlignment) MultiKeywordSelector public: // Constructor for keyword selectors. - MultiKeywordSelector(unsigned nKeys, IdentifierInfo **IIV) + MultiKeywordSelector(unsigned nKeys, const IdentifierInfo **IIV) : DeclarationNameExtra(nKeys) { assert((nKeys > 1) && "not a multi-keyword selector"); // Fill in the trailing keyword array. - IdentifierInfo **KeyInfo = reinterpret_cast<IdentifierInfo **>(this + 1); + const IdentifierInfo **KeyInfo = + reinterpret_cast<const IdentifierInfo **>(this + 1); for (unsigned i = 0; i != nKeys; ++i) KeyInfo[i] = IIV[i]; } @@ -903,7 +904,7 @@ class alignas(IdentifierInfoAlignment) MultiKeywordSelector using DeclarationNameExtra::getNumArgs; - using keyword_iterator = IdentifierInfo *const *; + using keyword_iterator = const IdentifierInfo *const *; keyword_iterator keyword_begin() const { return reinterpret_cast<keyword_iterator>(this + 1); @@ -913,7 +914,7 @@ class alignas(IdentifierInfoAlignment) MultiKeywordSelector return keyword_begin() + getNumArgs(); } - IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const { + const IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const { assert(i < getNumArgs() && "getIdentifierInfoForSlot(): illegal index"); return keyword_begin()[i]; } @@ -966,10 +967,10 @@ class Selector { /// Do not reorder or add any arguments to this template /// without thoroughly understanding how tightly coupled these classes are. llvm::PointerIntPair< - llvm::PointerUnion<IdentifierInfo *, MultiKeywordSelector *>, 2> + llvm::PointerUnion<const IdentifierInfo *, MultiKeywordSelector *>, 2> InfoPtr; - Selector(IdentifierInfo *II, unsigned nArgs) { + Selector(const IdentifierInfo *II, unsigned nArgs) { assert(nArgs < 2 && "nArgs not equal to 0/1"); InfoPtr.setPointerAndInt(II, nArgs + 1); } @@ -981,8 +982,8 @@ class Selector { InfoPtr.setPointerAndInt(SI, MultiArg & 0b11); } - IdentifierInfo *getAsIdentifierInfo() const { - return InfoPtr.getPointer().dyn_cast<IdentifierInfo *>(); + const IdentifierInfo *getAsIdentifierInfo() const { + return InfoPtr.getPointer().dyn_cast<const IdentifierInfo *>(); } MultiKeywordSelector *getMultiKeywordSelector()... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/79365 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits