From 9f6f6335cca6c43e564338b41fe5d7d69ba05951 Mon Sep 17 00:00:00 2001 From: yangdiangzb Date: Thu, 23 Feb 2023 10:50:13 +0000 Subject: [PATCH 1/3] [BSC] bugfix for unqualified call --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- clang/lib/Sema/SemaDecl.cpp | 5 +++++ clang/test/BSC/Driver/std_option.cbs | 12 ++++++++++++ .../BSC/Method/Struct/struct_toplevel_func.cbs | 18 ++++++++++++++++++ .../Struct/struct_toplevel_func_not_found.cbs | 12 ++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 clang/test/BSC/Driver/std_option.cbs create mode 100644 clang/test/BSC/Method/Struct/struct_toplevel_func.cbs create mode 100644 clang/test/BSC/Method/Struct/struct_toplevel_func_not_found.cbs diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 03f75ca2d0e2..8d4235cc2ec2 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2125,7 +2125,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, return S.getLanguage() == Language::CXX || S.getLanguage() == Language::HIP; case Language::BSC: - return S.getLanguage() == Language::BSC; + return S.getLanguage() == Language::C || S.getLanguage() == Language::BSC; case Language::Asm: // Accept (and ignore) all -std= values. diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 23c28150ae24..1fbf8c3ad642 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1479,6 +1479,11 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { if (getLangOpts().CPlusPlus && D->isOutOfLine() && !S->getFnParent()) return; + // BSCMethodDecls shouldn't be pushed into scope in BSC. + if (getLangOpts().BSC && isa(D)) { + return; + } + // Template instantiations should also not be pushed into scope. if (isa(D) && cast(D)->isFunctionTemplateSpecialization()) diff --git a/clang/test/BSC/Driver/std_option.cbs b/clang/test/BSC/Driver/std_option.cbs new file mode 100644 index 000000000000..d60bdae7ad7d --- /dev/null +++ b/clang/test/BSC/Driver/std_option.cbs @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c11 -verify %s +// RUN: %clang_cc1 -std=c89 -verify %s +// RUN: %clang_cc1 -std=c99 -verify %s +// RUN: %clang_cc1 -std=c17 -verify %s + +struct Foo { +}; +// expected-error@+2 {{cannot combine with previous 'int' declaration specifier}} +// expected-error@+1 {{expected identifier or '('}} +int struct Foo::getA(struct Foo* this) { + return 1; +} diff --git a/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs b/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs new file mode 100644 index 000000000000..268989fa775b --- /dev/null +++ b/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs @@ -0,0 +1,18 @@ +// RUN: %clang %s -o %t.output +// RUN: %t.output +// expected-no-diagnostics + +struct F { +}; + +int struct F::increase() { + return 2; +} + +int increase() { + return 0; +} + +int main() { + return increase(); +} \ No newline at end of file diff --git a/clang/test/BSC/Method/Struct/struct_toplevel_func_not_found.cbs b/clang/test/BSC/Method/Struct/struct_toplevel_func_not_found.cbs new file mode 100644 index 000000000000..1086c2c0007c --- /dev/null +++ b/clang/test/BSC/Method/Struct/struct_toplevel_func_not_found.cbs @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -verify %s + +struct F { +}; +void struct F::increase(struct F* this) { + +} + +int main() { + increase(); // expected-warning {{implicit declaration of function 'increase' is invalid in C99}} + return 0; +} \ No newline at end of file -- Gitee From 7dd378d1e2f41b14ab85b5eee6dbc09eb46eab06 Mon Sep 17 00:00:00 2001 From: Healing Date: Thu, 23 Feb 2023 11:25:25 +0000 Subject: [PATCH 2/3] [BSC] support mangle for BSCMethod --- clang/lib/AST/Mangle.cpp | 12 ++++++++++++ clang/lib/Serialization/ASTReaderDecl.cpp | 3 ++- clang/lib/Serialization/ASTWriterDecl.cpp | 9 ++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 3282fcbd584f..3e4a497aef98 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -107,6 +107,10 @@ static CCMangling getCallingConvMangling(const ASTContext &Context, bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { const ASTContext &ASTContext = getASTContext(); + const auto *MD = dyn_cast(D); + if (MD && !MD->getExtendedType().isNull()) + return true; + CCMangling CC = getCallingConvMangling(ASTContext, D); if (CC != CCM_Other) return true; @@ -171,6 +175,14 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { return; } + const auto *MD = dyn_cast(D); + if (MD && !MD->getExtendedType().isNull()) { + Out << "_ZN"; + mangleTypeName(MD->getExtendedType(), Out); + Out << D->getIdentifier()->getName(); + return; + } + bool MCXX = shouldMangleCXXName(D); const TargetInfo &TI = Context.getTargetInfo(); if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) { diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 91ec268465da..e2dc84e848f5 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1962,7 +1962,8 @@ void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { void ASTDeclReader::VisitBSCMethodDecl(BSCMethodDecl *D) { VisitFunctionDecl(D); - Record.readInt(); + D->setExtendedType(Record.readQualType()); + D->setHasThisParam(Record.readInt()); } void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index ca8d5fd323ea..4fb45e45c672 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1368,7 +1368,8 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) { void ASTDeclWriter::VisitBSCMethodDecl(BSCMethodDecl *D) { VisitFunctionDecl(D); - Record.AddDeclRef(D); + Record.AddTypeRef(D->getExtendedType()); + Record.push_back(D->getHasThisParam()); if (D->getDeclContext() == D->getLexicalDeclContext() && D->getFirstDecl() == D->getMostRecentDecl() && @@ -2338,12 +2339,14 @@ void ASTWriter::WriteDeclAbbrevs() { // (nearly) all the remaining (variable number of) fields in the same way. // // This is the function template information if any, then - // NumParams and Params[] from FunctionDecl, and - // NumOverriddenMethods, OverriddenMethods[] from BSCMethodDecl. + // NumParams and Params[] from FunctionDecl // // Add an AbbrevOp for 'size then elements' and use it here. Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); + // BSCMethodDecl + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ExtendedType + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasThisParam DeclBSCMethodAbbrev = Stream.EmitAbbrev(std::move(Abv)); // Abbreviation for EXPR_DECL_REF -- Gitee From 9627abb29a7372c364960bfa2a4679eeb5c5644f Mon Sep 17 00:00:00 2001 From: yangdian Date: Fri, 24 Feb 2023 17:30:15 +0800 Subject: [PATCH 3/3] [BSC] auto format code --- clang/include/clang/AST/ASTContext.h | 2 +- clang/include/clang/AST/DeclCXX.h | 20 +++-- clang/include/clang/Parse/Parser.h | 8 +- .../clang/Parse/RAIIObjectsForParser.h | 15 ++-- clang/include/clang/Sema/DeclSpec.h | 10 ++- clang/include/clang/Sema/Sema.h | 2 +- clang/include/clang/Sema/Template.h | 8 +- clang/lib/AST/Decl.cpp | 3 +- clang/lib/AST/DeclCXX.cpp | 20 ++--- clang/lib/Parse/ParseDecl.cpp | 36 ++++----- clang/lib/Sema/SemaDecl.cpp | 19 +++-- clang/lib/Sema/SemaExpr.cpp | 73 +++++++++++-------- clang/lib/Sema/SemaExprMember.cpp | 49 +++++++------ clang/lib/Sema/SemaLookup.cpp | 9 +-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +- clang/lib/Sema/SemaType.cpp | 26 ++++--- clang/lib/Serialization/ASTWriterDecl.cpp | 67 ++++++++--------- 17 files changed, 191 insertions(+), 178 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d24f00694f7f..359f666c7f49 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -447,7 +447,7 @@ public: using TemplateOrSpecializationInfo = llvm::PointerUnion; - mutable llvm::DenseMap BSCDeclContextMap; + mutable llvm::DenseMap BSCDeclContextMap; private: friend class ASTDeclReader; diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 5da1097e8a7a..499320e554df 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1945,21 +1945,19 @@ protected: } public: - static BSCMethodDecl *Create(ASTContext &C, DeclContext *RD, - SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, StorageClass SC, - bool isInline, ConstexprSpecKind ConstexprKind, - SourceLocation EndLocation, - Expr *TrailingRequiresClause = nullptr); + static BSCMethodDecl * + Create(ASTContext &C, DeclContext *RD, SourceLocation StartLoc, + const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, + StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, + SourceLocation EndLocation, Expr *TrailingRequiresClause = nullptr); static BSCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); - bool getHasThisParam() const { - return hasThisParam; - } + bool getHasThisParam() const { return hasThisParam; } void setHasThisParam(bool hasThisParam) { this->hasThisParam = hasThisParam; } QualType getExtendedType() const { return ExtendedType; } - void setExtendedType(QualType ExtendedType) { this->ExtendedType = ExtendedType; } + void setExtendedType(QualType ExtendedType) { + this->ExtendedType = ExtendedType; + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index ad9bb0a6b91f..eb4a0488341d 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2921,11 +2921,9 @@ private: Declarator &D, SmallVectorImpl &ParamInfo); void ParseParameterDeclarationClause( - DeclaratorContext DeclaratorContext, - ParsedAttributes &attrs, - SmallVectorImpl &ParamInfo, - SourceLocation &EllipsisLoc, - const Type *typePtr = nullptr); + DeclaratorContext DeclaratorContext, ParsedAttributes &attrs, + SmallVectorImpl &ParamInfo, + SourceLocation &EllipsisLoc, const Type *typePtr = nullptr); void ParseBracketDeclarator(Declarator &D); void ParseMisplacedBracketDeclarator(Declarator &D); diff --git a/clang/include/clang/Parse/RAIIObjectsForParser.h b/clang/include/clang/Parse/RAIIObjectsForParser.h index e02815bfe54c..7f8040d78b90 100644 --- a/clang/include/clang/Parse/RAIIObjectsForParser.h +++ b/clang/include/clang/Parse/RAIIObjectsForParser.h @@ -202,23 +202,18 @@ namespace clang { public: BSCScopeSpec(Parser &P) - : DeclSpec(P.getAttrFactory()), - ParsingRAII(P, ParsingDeclRAIIObject::NoParent) {} + : DeclSpec(P.getAttrFactory()), + ParsingRAII(P, ParsingDeclRAIIObject::NoParent) {} BSCScopeSpec(Parser &P, ParsingDeclRAIIObject *RAII) - : DeclSpec(P.getAttrFactory()), - ParsingRAII(P, RAII) {} + : DeclSpec(P.getAttrFactory()), ParsingRAII(P, RAII) {} const sema::DelayedDiagnosticPool &getDelayedDiagnosticPool() const { return ParsingRAII.getDelayedDiagnosticPool(); } - void complete(Decl *D) { - ParsingRAII.complete(D); - } + void complete(Decl *D) { ParsingRAII.complete(D); } - void abort() { - ParsingRAII.abort(); - } + void abort() { ParsingRAII.abort(); } }; /// A class for parsing a declarator. diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 11c359717ff8..e797da753ad7 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -1824,7 +1824,7 @@ class Declarator { private: const DeclSpec &DS; CXXScopeSpec SS; - DeclSpec *BSCDS=nullptr; + DeclSpec *BSCDS = nullptr; QualType ExtendedType; // BSC only UnqualifiedId Name; @@ -1933,13 +1933,15 @@ public: /// declared with. const DeclSpec &getDeclSpec() const { return DS; } - /// getBSCScopeSpec - Return the BSCMethod declaration-specifier that this declarator was - /// declared with. + /// getBSCScopeSpec - Return the BSCMethod declaration-specifier that this + /// declarator was declared with. DeclSpec *getBSCScopeSpec() { return BSCDS; } void setBSCScopeSpec(DeclSpec *ScopeSpec) { BSCDS = ScopeSpec; } QualType getExtendedType() const { return ExtendedType; } - void setExtendedType(QualType ExtendedType) { this->ExtendedType = ExtendedType; } + void setExtendedType(QualType ExtendedType) { + this->ExtendedType = ExtendedType; + } /// getMutableDeclSpec - Return a non-const version of the DeclSpec. This /// should be used with extreme care: declspecs can often be shared between diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index d9c176327317..5809edddd755 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -11313,7 +11313,7 @@ public: bool AllowExplicit = false, bool IsListInitialization = false, bool IsBSCInstanceFunc = false, - CallExpr* Call = nullptr); + CallExpr *Call = nullptr); // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but // will create a runtime trap if the resulting type is not a POD type. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 880412cd3725..8c3fc70d26be 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -532,10 +532,10 @@ enum class TemplateSubstitutionKind : char { ClassScopeSpecializationArgs = llvm::None, RewriteKind RK = RewriteKind::None); Decl *VisitBSCMethodDecl(BSCMethodDecl *D, - TemplateParameterList *TemplateParams, - Optional - ClassScopeSpecializationArgs = llvm::None, - RewriteKind RK = RewriteKind::None); + TemplateParameterList *TemplateParams, + Optional + ClassScopeSpecializationArgs = llvm::None, + RewriteKind RK = RewriteKind::None); Decl *VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams, RewriteKind RK = RewriteKind::None); diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 36c0d620b473..9c4b8959111f 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2074,7 +2074,8 @@ static bool isDeclExternC(const T &D) { // language linkage or no language linkage. const DeclContext *DC = D.getDeclContext(); if (DC->isRecord()) { - assert(D.getASTContext().getLangOpts().CPlusPlus || D.getASTContext().getLangOpts().BSC); + assert(D.getASTContext().getLangOpts().CPlusPlus || + D.getASTContext().getLangOpts().BSC); return false; } diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 1386504b436d..ec71d0fabe90 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2190,18 +2190,14 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, return FinalOverriders.size() == 1 ? FinalOverriders.front() : nullptr; } -BSCMethodDecl *BSCMethodDecl::Create(ASTContext &C, DeclContext *RD, - SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, - QualType T, TypeSourceInfo *TInfo, - StorageClass SC, bool isInline, - ConstexprSpecKind ConstexprKind, - SourceLocation EndLocation, - Expr *TrailingRequiresClause) { - return new (C, RD) - BSCMethodDecl(BSCMethod, C, RD, StartLoc, NameInfo, T, TInfo, SC, - isInline, ConstexprKind, EndLocation, - TrailingRequiresClause); +BSCMethodDecl *BSCMethodDecl::Create( + ASTContext &C, DeclContext *RD, SourceLocation StartLoc, + const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, + StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, + SourceLocation EndLocation, Expr *TrailingRequiresClause) { + return new (C, RD) BSCMethodDecl(BSCMethod, C, RD, StartLoc, NameInfo, T, + TInfo, SC, isInline, ConstexprKind, + EndLocation, TrailingRequiresClause); } BSCMethodDecl *BSCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 20b40259a8c8..22be56c90274 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1977,10 +1977,10 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, &LateParsedAttrs); if (!D.getExtendedType().isNull()) { if (auto *MD = dyn_cast(TheDecl)) { - MD->setExtendedType(D.getExtendedType()); + MD->setExtendedType(D.getExtendedType()); MD->setHasThisParam(D.hasThisParam); } - } + } return Actions.ConvertDeclToDeclGroup(TheDecl); } @@ -2043,7 +2043,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, SmallVector DeclsInGroup; Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes( D, ParsedTemplateInfo(), FRI); - + if (LateParsedAttrs.size() > 0) ParseLexedAttributeList(LateParsedAttrs, FirstDecl, true, false); D.complete(FirstDecl); @@ -2051,7 +2051,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, if (auto FD = dyn_cast(FirstDecl)) FD->setHasThisParam(D.hasThisParam); DeclsInGroup.push_back(FirstDecl); - } + } bool ExpectSemi = Context != DeclaratorContext::ForInit; @@ -2967,8 +2967,8 @@ static void SetupFixedPointError(const LangOptions &LangOpts, void Parser::ParseBSCScopeSpecifiers(DeclSpec &DS) { bool BSCMethodFlag = true; ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none, - DeclSpecContext::DSC_normal, nullptr, - BSCMethodFlag); + DeclSpecContext::DSC_normal, nullptr, + BSCMethodFlag); } /// ParseDeclarationSpecifiers @@ -3003,7 +3003,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, AccessSpecifier AS, DeclSpecContext DSContext, LateParsedAttrList *LateAttrs, - bool BSCMethodFlag) { + bool BSCMethodFlag) { if (DS.getSourceRange().isInvalid()) { // Start the range at the current token but make the end of the range // invalid. This will make the entire range invalid unless we successfully @@ -5695,7 +5695,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, D.setExtension(); // BSC - if (getLangOpts().BSC && (NextToken().is(tok::coloncolon) || GetLookAheadToken(2).is(tok::coloncolon))) { + if (getLangOpts().BSC && (NextToken().is(tok::coloncolon) || + GetLookAheadToken(2).is(tok::coloncolon))) { BSCScopeSpec BSS(*this); ParseBSCScopeSpecifiers(BSS); TryConsumeToken(tok::coloncolon); @@ -6543,12 +6544,12 @@ void Parser::ParseFunctionDeclarator(Declarator &D, } ParseParameterDeclarationClause(D.getContext(), FirstArgAttrs, ParamInfo, EllipsisLoc, typePtr); - } - else if (RequiresArg) + } else if (RequiresArg) Diag(Tok, diag::err_argument_required_after_attribute); - + if (ParamInfo.size() > 0) { - ParmVarDecl* PD = dyn_cast_or_null(ParamInfo.data()[0].Param); + ParmVarDecl *PD = + dyn_cast_or_null(ParamInfo.data()[0].Param); if (PD && D.getBSCScopeSpec()) D.hasThisParam = PD->isThisParam; } @@ -6799,11 +6800,9 @@ void Parser::ParseFunctionDeclaratorIdentifierList( /// [C++11] attribute-specifier-seq parameter-declaration /// void Parser::ParseParameterDeclarationClause( - DeclaratorContext DeclaratorCtx, - ParsedAttributes &FirstArgAttrs, - SmallVectorImpl &ParamInfo, - SourceLocation &EllipsisLoc, - const Type *typePtr) { + DeclaratorContext DeclaratorCtx, ParsedAttributes &FirstArgAttrs, + SmallVectorImpl &ParamInfo, + SourceLocation &EllipsisLoc, const Type *typePtr) { // Avoid exceeding the maximum function scope depth. // See https://bugs.llvm.org/show_bug.cgi?id=19607 @@ -6923,7 +6922,8 @@ void Parser::ParseParameterDeclarationClause( } // Inform the actions module about the parameter declarator, so it gets // added to the current scope. - Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDeclarator, ParamInfo.size(), typePtr); + Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDeclarator, + ParamInfo.size(), typePtr); // Parse the default argument, if any. We parse the default // arguments in all dialects; the semantic analysis in // ActOnParamDefaultArgument will reject the default argument in diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1fbf8c3ad642..1f46f0c784df 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5769,7 +5769,8 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, D.setInvalidType(); } } else if (!D.getExtendedType().isNull()) { - DC = getASTContext().BSCDeclContextMap[D.getExtendedType().getCanonicalType().getTypePtr()]; + DC = getASTContext().BSCDeclContextMap + [D.getExtendedType().getCanonicalType().getTypePtr()]; } TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); @@ -8454,7 +8455,7 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, ConstexprSpecKind ConstexprKind = D.getDeclSpec().getConstexprSpecifier(); if (ConstexprKind == ConstexprSpecKind::Constinit) { SemaRef.Diag(D.getDeclSpec().getConstexprSpecLoc(), - diag::err_constexpr_wrong_decl_kind) + diag::err_constexpr_wrong_decl_kind) << static_cast(ConstexprKind); ConstexprKind = ConstexprSpecKind::Unspecified; D.getMutableDeclSpec().ClearConstexprSpec(); @@ -8463,9 +8464,8 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, // This is a bsc method declaration. BSCMethodDecl *Ret = BSCMethodDecl::Create( - SemaRef.Context, DC, D.getBeginLoc(), NameInfo, R, - TInfo, SC, isInline, ConstexprKind, SourceLocation(), - TrailingRequiresClause); + SemaRef.Context, DC, D.getBeginLoc(), NameInfo, R, TInfo, SC, + isInline, ConstexprKind, SourceLocation(), TrailingRequiresClause); return Ret; } bool HasPrototype = @@ -13617,15 +13617,18 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D, int ParamSize, bool isThisParam = false; if (typePtr != nullptr && DeclarationName(II).getAsString() == "this") { if (ParamSize == 0) { - auto thisTypePtr = parmDeclType.getTypePtr()->getPointeeType()->getCanonicalTypeUnqualified().getTypePtr(); + auto thisTypePtr = parmDeclType.getTypePtr() + ->getPointeeType() + ->getCanonicalTypeUnqualified() + .getTypePtr(); if (typePtr == nullptr || typePtr != thisTypePtr) { Diag(D.getBeginLoc(), diag::err_type_unsupported) - << parmDeclType.getAsString(); + << parmDeclType.getAsString(); } isThisParam = true; } else { Diag(D.getIdentifierLoc(), diag::err_bad_parameter_name) - << GetNameForDeclarator(D).getName(); + << GetNameForDeclarator(D).getName(); } } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 27d3901d3d0f..aea9cacdfa53 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3411,13 +3411,13 @@ ExprResult Sema::BuildDeclarationNameExpr( // capture in OpenMP, or duplicated between host and device? valueKind = VK_LValue; break; - + case Decl::BSCMethod: // If we're referring to a method with an __unknown_anytype // result type, make the entire expression __unknown_anytype. // This should only be possible with a type written directly. - if (const FunctionProtoType *proto - = dyn_cast(VD->getType())) + if (const FunctionProtoType *proto = + dyn_cast(VD->getType())) if (proto->getReturnType() == Context.UnknownAnyTy) { type = Context.UnknownAnyTy; valueKind = VK_RValue; @@ -5781,7 +5781,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, : 0 /* function */); bool isBSCInstanceFunc = false; if (FDecl) { - BSCMethodDecl* MD = dyn_cast_or_null(FDecl); + BSCMethodDecl *MD = dyn_cast_or_null(FDecl); if (MD && MD->getHasThisParam()) { isBSCInstanceFunc = true; NumParams = NumParams - 1; @@ -5872,7 +5872,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn); Invalid = GatherArgumentsForCall(Call->getBeginLoc(), FDecl, Proto, 0, Args, - AllArgs, CallType, false, false, isBSCInstanceFunc, Call); + AllArgs, CallType, false, false, + isBSCInstanceFunc, Call); if (Invalid) return true; unsigned TotalNumArgs = AllArgs.size(); @@ -5888,48 +5889,58 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, SmallVectorImpl &AllArgs, VariadicCallType CallType, bool AllowExplicit, bool IsListInitialization, - bool IsBSCInstanceFunc, CallExpr* Call) { + bool IsBSCInstanceFunc, CallExpr *Call) { unsigned NumParams = Proto->getNumParams(); bool Invalid = false; size_t ArgIx = 0; - // If the BSCMethod contains `this` parameter, the function is an instance member function, - // It does not need to explicitly pass parameters when calling, - // So we need to build an ast for `this` parameter. - if (IsBSCInstanceFunc) { - Expr* Callee = Call->getCallee(); - if (ImplicitCastExpr* ICE = dyn_cast(Callee)) { // Hack, if Callee is ImplicitCastExpr* - Expr* SE = ICE->getSubExpr(); - MemberExpr* Member = dyn_cast(SE); // MemberExpr foo.getA or foo->getA + // If the BSCMethod contains `this` parameter, the function is an instance + // member function, It does not need to explicitly pass parameters when + // calling, So we need to build an ast for `this` parameter. + if (IsBSCInstanceFunc) { + Expr *Callee = Call->getCallee(); + if (ImplicitCastExpr *ICE = dyn_cast( + Callee)) { // Hack, if Callee is ImplicitCastExpr* + Expr *SE = ICE->getSubExpr(); + MemberExpr *Member = + dyn_cast(SE); // MemberExpr foo.getA or foo->getA if (!Member) return true; - - Expr* ImplicitArg = nullptr; + + Expr *ImplicitArg = nullptr; if (Member->isArrow()) { // foo->getA - DeclRefExpr* DRE = nullptr; - if (auto BaseExpr = dyn_cast(Member->getBase())) { + DeclRefExpr *DRE = nullptr; + if (auto BaseExpr = dyn_cast(Member->getBase())) { DRE = dyn_cast(BaseExpr->getSubExpr()); - } + } if (!DRE) return true; ImplicitArg = DeclRefExpr::Create( - this->Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(), - DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(), - DRE->getNameInfo(), DRE->getType(), VK_RValue, - DRE->getFoundDecl(), nullptr); + this->Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(), + DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(), + DRE->getNameInfo(), DRE->getType(), VK_RValue, DRE->getFoundDecl(), + nullptr); } else { // foo.getA - DeclRefExpr* DRE = dyn_cast(Member->getBase()); + DeclRefExpr *DRE = dyn_cast(Member->getBase()); if (!DRE) return true; - ImplicitArg = UnaryOperator::Create( - this->Context, DRE, UO_AddrOf, this->Context.getPointerType(DRE->getType()), - VK_RValue, OK_Ordinary, SourceLocation(), false, this->CurFPFeatureOverrides()); + ImplicitArg = + UnaryOperator::Create(this->Context, DRE, UO_AddrOf, + this->Context.getPointerType(DRE->getType()), + VK_RValue, OK_Ordinary, SourceLocation(), + false, this->CurFPFeatureOverrides()); } - - const FunctionProtoType* FPT = dyn_cast(Member->getType()); - auto typeQual = FPT->getParamType(0).getTypePtr()->getPointeeType().getCVRQualifiers(); + + const FunctionProtoType *FPT = + dyn_cast(Member->getType()); + auto typeQual = FPT->getParamType(0) + .getTypePtr() + ->getPointeeType() + .getCVRQualifiers(); if (typeQual & Qualifiers::Const || typeQual & Qualifiers::Volatile) { - ImplicitCastExpr* Implict = ImplicitCastExpr::Create(this->Context, FPT->getParamType(0), CK_NoOp, ImplicitArg, nullptr, VK_RValue, FPOptionsOverride()); + ImplicitCastExpr *Implict = ImplicitCastExpr::Create( + this->Context, FPT->getParamType(0), CK_NoOp, ImplicitArg, nullptr, + VK_RValue, FPOptionsOverride()); AllArgs.push_back(Implict); } else { AllArgs.push_back(ImplicitArg); diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 7c11569ddbdc..c994594ef2bd 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -635,7 +635,7 @@ private: }; // Callback to only accept typo corrections that are either a ValueDecl or a -// and are declared in the current enum or, for a C++ classes, one of its +// and are declared in the current enum or, for a C++ classes, one of its // base classes. class EnumMemberExprValidatorCCC final : public CorrectionCandidateCallback { public: @@ -835,10 +835,9 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType, } static bool LookupMemberExprInEnum(Sema &SemaRef, LookupResult &R, - Expr *BaseExpr, - const EnumType *ETy, - SourceLocation OpLoc, bool IsArrow, - CXXScopeSpec &SS, TypoExpr *&TE) { + Expr *BaseExpr, const EnumType *ETy, + SourceLocation OpLoc, bool IsArrow, + CXXScopeSpec &SS, TypoExpr *&TE) { SourceRange BaseRange = BaseExpr ? BaseExpr->getSourceRange() : SourceRange(); EnumDecl *EDecl = ETy->getDecl(); @@ -1228,7 +1227,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, MemberFn, FoundDecl, /*HadMultipleCandidates=*/false, MemberNameInfo, type, valueKind, OK_Ordinary); } - + if (BSCMethodDecl *MemberFn = dyn_cast(MemberDecl)) { ExprValueKind valueKind; QualType type; @@ -1239,7 +1238,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, MemberFn, FoundDecl, /*HadMultipleCandidates=*/false, MemberNameInfo, type, valueKind, OK_Ordinary); } - + assert(!isa(MemberDecl) && "member function not C++ method?"); if (EnumConstantDecl *Enum = dyn_cast(MemberDecl)) { @@ -1416,37 +1415,43 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, } if (S.getLangOpts().BSC) { - if (const BuiltinType *BTy = BaseType->getAs()) { - if (S.getASTContext().BSCDeclContextMap.find(BTy) != S.getASTContext().BSCDeclContextMap.end()) { + if (const BuiltinType *BTy = BaseType->getAs()) { + if (S.getASTContext().BSCDeclContextMap.find(BTy) != + S.getASTContext().BSCDeclContextMap.end()) { TypoExpr *TE = nullptr; auto DeclContext = S.getASTContext().BSCDeclContextMap[BTy]; // TODO: add assert - RecordDecl* Rdecl = dyn_cast(DeclContext); - const RecordType* RTy = dyn_cast(Rdecl->getTypeForDecl()); - if (LookupMemberExprInRecord(S, R, BaseExpr.get(), RTy, OpLoc, IsArrow, SS, - HasTemplateArgs, TemplateKWLoc, TE)) + RecordDecl *Rdecl = dyn_cast(DeclContext); + const RecordType *RTy = dyn_cast(Rdecl->getTypeForDecl()); + if (LookupMemberExprInRecord(S, R, BaseExpr.get(), RTy, OpLoc, IsArrow, + SS, HasTemplateArgs, TemplateKWLoc, TE)) return ExprError(); // Returning valid-but-null is how we indicate to the caller that // the lookup result was filled in. If typo correction was attempted and - // failed, the lookup result will have been cleared--that combined with the - // valid-but-null ExprResult will trigger the appropriate diagnostics. + // failed, the lookup result will have been cleared--that combined with + // the valid-but-null ExprResult will trigger the appropriate + // diagnostics. return ExprResult(TE); } } if (const EnumType *ETy = BaseType->getAs()) { - if (S.getASTContext().BSCDeclContextMap.find(ETy) != S.getASTContext().BSCDeclContextMap.end()) { + if (S.getASTContext().BSCDeclContextMap.find(ETy) != + S.getASTContext().BSCDeclContextMap.end()) { TypoExpr *TE = nullptr; // TODO: add assert - if (LookupMemberExprInEnum(S, R, BaseExpr.get(), ETy, OpLoc, IsArrow, SS, TE)) + if (LookupMemberExprInEnum(S, R, BaseExpr.get(), ETy, OpLoc, IsArrow, + SS, TE)) return ExprError(); - - if (!R.empty() && dyn_cast(R.getFoundDecl()) != nullptr) { + + if (!R.empty() && + dyn_cast(R.getFoundDecl()) != nullptr) { // Returning valid-but-null is how we indicate to the caller that - // the lookup result was filled in. If typo correction was attempted and - // failed, the lookup result will have been cleared--that combined with the - // valid-but-null ExprResult will trigger the appropriate diagnostics. + // the lookup result was filled in. If typo correction was attempted + // and failed, the lookup result will have been cleared--that combined + // with the valid-but-null ExprResult will trigger the appropriate + // diagnostics. return ExprResult(TE); } } diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2a5206ca6a97..2d8a65dcaae6 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -206,9 +206,8 @@ namespace { // Retrieve the set of identifier namespaces that correspond to a // specific kind of name lookup. -static inline unsigned getIDNS(Sema::LookupNameKind NameKind, - bool CPlusPlus, bool BSC, - bool Redeclaration) { +static inline unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, + bool BSC, bool Redeclaration) { unsigned IDNS = 0; switch (NameKind) { case Sema::LookupObjCImplicitSelfParam: @@ -298,8 +297,8 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind, } void LookupResult::configure() { - IDNS = getIDNS(LookupKind, getSema().getLangOpts().CPlusPlus, - getSema().getLangOpts().BSC, isForRedeclaration()); + IDNS = getIDNS(LookupKind, getSema().getLangOpts().CPlusPlus, + getSema().getLangOpts().BSC, isForRedeclaration()); // If we're looking for one of the allocation or deallocation // operators, make sure that the implicitly-declared new and delete diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index a9a77cca36a0..5cbb2039bf00 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2234,7 +2234,7 @@ Decl *TemplateDeclInstantiator::VisitBSCMethodDecl( BSCMethodDecl *D, TemplateParameterList *TemplateParams, Optional ClassScopeSpecializationArgs, RewriteKind FunctionRewriteKind) { - return VisitFunctionDecl(D, TemplateParams, FunctionRewriteKind); + return VisitFunctionDecl(D, TemplateParams, FunctionRewriteKind); } Decl *TemplateDeclInstantiator::VisitCXXMethodDecl( diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index c5dd268dd134..52b0fecf8551 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1282,13 +1282,15 @@ static QualType ConvertConstrainedAutoDeclSpecToType(Sema &S, DeclSpec &DS, /// to be converted, along with other associated processing state. /// \returns The type described by the declaration specifiers. This function /// never returns null. -static QualType ConvertDeclSpecToType(TypeProcessingState &state, bool BSCMethodFlag = false) { +static QualType ConvertDeclSpecToType(TypeProcessingState &state, + bool BSCMethodFlag = false) { // FIXME: Should move the logic from DeclSpec::Finish to here for validity // checking. Sema &S = state.getSema(); Declarator &declarator = state.getDeclarator(); - DeclSpec &DS = BSCMethodFlag ? *(declarator.getBSCScopeSpec()) : declarator.getMutableDeclSpec(); + DeclSpec &DS = BSCMethodFlag ? *(declarator.getBSCScopeSpec()) + : declarator.getMutableDeclSpec(); SourceLocation DeclLoc = declarator.getIdentifierLoc(); if (DeclLoc.isInvalid()) DeclLoc = DS.getBeginLoc(); @@ -1845,17 +1847,23 @@ void Sema::ConvertBSCScopeSpecToType(Declarator &D, SourceLocation Loc) { Diagnoser.diagnose(*this, Loc, T); } else { D.setExtendedType(T); - const Type* BasedType = T.getCanonicalType().getTypePtr(); + const Type *BasedType = T.getCanonicalType().getTypePtr(); // build declcontext map - if (getASTContext().BSCDeclContextMap.find(BasedType) == getASTContext().BSCDeclContextMap.end()) { - if (const RecordType* RTy = dyn_cast(BasedType)) { // struct type or union type + if (getASTContext().BSCDeclContextMap.find(BasedType) == + getASTContext().BSCDeclContextMap.end()) { + if (const RecordType *RTy = dyn_cast( + BasedType)) { // struct type or union type getASTContext().BSCDeclContextMap[BasedType] = RTy->getDecl(); - } else if (const EnumType* ETy = dyn_cast(BasedType)) { // enum type + } else if (const EnumType *ETy = + dyn_cast(BasedType)) { // enum type getASTContext().BSCDeclContextMap[BasedType] = ETy->getDecl(); - } else if (const BuiltinType* BTy = dyn_cast(BasedType)){ // builtin type + } else if (const BuiltinType *BTy = + dyn_cast(BasedType)) { // builtin type std::string Prefix = "__"; - std::string BuiltinTypeName = Prefix + BTy->getNameAsCString(getPrintingPolicy()); - auto TmpRecord = getASTContext().buildImplicitRecord(StringRef(BuiltinTypeName)); + std::string BuiltinTypeName = + Prefix + BTy->getNameAsCString(getPrintingPolicy()); + auto TmpRecord = + getASTContext().buildImplicitRecord(StringRef(BuiltinTypeName)); TmpRecord->startDefinition(); TmpRecord->completeDefinition(); getASTContext().BSCDeclContextMap[BasedType] = TmpRecord; diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 4fb45e45c672..70f5002fd9d7 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1372,13 +1372,10 @@ void ASTDeclWriter::VisitBSCMethodDecl(BSCMethodDecl *D) { Record.push_back(D->getHasThisParam()); if (D->getDeclContext() == D->getLexicalDeclContext() && - D->getFirstDecl() == D->getMostRecentDecl() && - !D->isInvalidDecl() && - !D->hasAttrs() && - !D->isTopLevelDeclInObjCContainer() && + D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() && + !D->hasAttrs() && !D->isTopLevelDeclInObjCContainer() && D->getDeclName().getNameKind() == DeclarationName::Identifier && - !D->hasExtInfo() && - !D->hasInheritedPrototype() && + !D->hasExtInfo() && !D->hasInheritedPrototype() && D->hasWrittenPrototype()) AbbrevToUse = Writer.getDeclBSCMethodAbbrev(); @@ -2284,11 +2281,11 @@ void ASTWriter::WriteDeclAbbrevs() { Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv)); - // Abbreviation for DECL_BSC_METHOD + // Abbreviation for DECL_BSC_METHOD Abv = std::make_shared(); Abv->Add(BitCodeAbbrevOp(serialization::DECL_BSC_METHOD)); // RedeclarableDecl - Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl + Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl // Decl Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext @@ -2303,38 +2300,38 @@ void ASTWriter::WriteDeclAbbrevs() { Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID // NamedDecl Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier - Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier + Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber // ValueDecl - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type // DeclaratorDecl - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart - Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart + Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType // FunctionDecl Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure - Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto - Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // TrivialForCall - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure + Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto + Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // TrivialForCall + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash - Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind // This Array slurps the rest of the record. Fortunately we want to encode // (nearly) all the remaining (variable number of) fields in the same way. // -- Gitee