diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 448cc7156d..921c5961f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev g++-14=14.2.0-4ubuntu2~24.04 msvc: '' extra-values: | - llvm-hash: dd7a3d4d798e30dfe53b5bbbbcd9a23c24ea1af9 + llvm-hash: a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{{lowercase build-type}}}{{/if}} llvm-build-preset-os: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}} llvm-sanitizer: {{#if (eq compiler 'gcc')}}{{else if ubsan}}-UBSan{{else if asan}}-ASan{{else if msan}}-MSan{{/if}} diff --git a/bootstrap.py b/bootstrap.py index c80d6f98aa..79af93f1a1 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -97,7 +97,7 @@ class InstallOptions: llvm_build_dir: str = "/build/<\"-\":if(cc)><\"-\":if(sanitizer)>" llvm_install_dir: str = "/install/<\"-\":if(cc)><\"-\":if(sanitizer)>" llvm_repo: str = "https://github.com/llvm/llvm-project.git" - llvm_commit: str = "dd7a3d4d798e30dfe53b5bbbbcd9a23c24ea1af9" + llvm_commit: str = "a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b" # Libxml2 libxml2_src_dir: str = "/libxml2" diff --git a/docs/modules/ROOT/pages/install.adoc b/docs/modules/ROOT/pages/install.adoc index 2aca838def..9c77e3bf63 100644 --- a/docs/modules/ROOT/pages/install.adoc +++ b/docs/modules/ROOT/pages/install.adoc @@ -259,7 +259,7 @@ cd .. === LLVM MrDocs uses LLVM to parse C++ code and extract documentation from it. -It depends on a recent version of LLVM: https://github.com/llvm/llvm-project/tree/dd7a3d4d798e30dfe53b5bbbbcd9a23c24ea1af9[dd7a3d4] +It depends on a recent version of LLVM: https://github.com/llvm/llvm-project/tree/a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b[a1b6e7f] **Download**: @@ -272,7 +272,7 @@ mkdir -p llvm-project <.> cd llvm-project git init <.> git remote add origin https://github.com/llvm/llvm-project.git <.> -git fetch --depth 1 origin dd7a3d4d798e30dfe53b5bbbbcd9a23c24ea1af9 <.> +git fetch --depth 1 origin a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b <.> git checkout FETCH_HEAD <.> ---- diff --git a/src/lib/AST/ASTVisitor.cpp b/src/lib/AST/ASTVisitor.cpp index 25bc5dee25..9bd9c84f54 100644 --- a/src/lib/AST/ASTVisitor.cpp +++ b/src/lib/AST/ASTVisitor.cpp @@ -67,7 +67,7 @@ ASTVisitor( // ASTContext::setTraversalScope is being (erroneously) // used somewhere MRDOCS_ASSERT(context_.getTraversalScope() == - std::vector{context_.getTranslationUnitDecl()}); + ArrayRef{context_.getTranslationUnitDecl()}); } void @@ -466,7 +466,7 @@ generateUSR(Decl const* D) const if(auto* FD = dyn_cast(Templated); FD && FD->getTrailingRequiresClause()) { - Expr const* RC = FD->getTrailingRequiresClause(); + Expr const* RC = FD->getTrailingRequiresClause().ConstraintExpr; RC = SubstituteConstraintExpressionWithoutSatisfaction( sema_, cast(Described ? Described : Templated), RC); if (!RC) @@ -897,7 +897,7 @@ populate( MRDOCS_SYMBOL_TRACE(RT, context_); I.ReturnType = toTypeInfo(RT); - if (auto* TRC = D->getTrailingRequiresClause()) + if (auto* TRC = D->getTrailingRequiresClause().ConstraintExpr) { populate(I.Requires, TRC); } @@ -1214,7 +1214,7 @@ populate( NamespaceAliasDecl const* D) { NamedDecl const* Aliased = D->getAliasedNamespace(); - NestedNameSpecifier const* NNS = D->getQualifier(); + NestedNameSpecifier NNS = D->getQualifier(); I.AliasedSymbol = toNameInfo(Aliased, {}, NNS); } @@ -1478,7 +1478,7 @@ populate( } if(TypeConstraint const* TC = P->getTypeConstraint()) { - NestedNameSpecifier const* NNS = + NestedNameSpecifier NNS = TC->getNestedNameSpecifierLoc().getNestedNameSpecifier(); std::optional TArgs; if (TC->hasExplicitTemplateArgs()) @@ -2009,63 +2009,45 @@ toTypeInfo(QualType const qt, TraversalMode const mode) return Builder.result(); } -Polymorphic -ASTVisitor:: -toNameInfo( - NestedNameSpecifier const* NNS) +Polymorphic ASTVisitor::toNameInfo(NestedNameSpecifier NNS) { - if (!NNS) - { - return std::nullopt; - } MRDOCS_SYMBOL_TRACE(NNS, context_); - ScopeExitRestore scope(mode_, Dependency); - Polymorphic I = std::nullopt; - if (Type const* T = NNS->getAsType()) - { - NameInfoBuilder Builder(*this, NNS->getPrefix()); + switch(NNS.getKind()) { + case NestedNameSpecifier::Kind::Null: + return std::nullopt; + case NestedNameSpecifier::Kind::Type: { + const Type *T = NNS.getAsType(); + NameInfoBuilder Builder(*this); Builder.Visit(T); - I = Builder.result(); + return Builder.result(); } - else if(IdentifierInfo const* II = NNS->getAsIdentifier()) - { - I = Polymorphic(); - I->Name = II->getName(); - I->Prefix = toNameInfo(NNS->getPrefix()); - } - else if(NamespaceDecl const* ND = NNS->getAsNamespace()) - { - I = Polymorphic(); + case NestedNameSpecifier::Kind::Namespace: { + auto I = Polymorphic(); + auto [ND, Prefix] = NNS.getAsNamespaceAndPrefix(); I->Name = ND->getIdentifier()->getName(); - I->Prefix = toNameInfo(NNS->getPrefix()); + I->Prefix = toNameInfo(Prefix); Decl const* ID = getInstantiatedFrom(ND); if (Info* info = findOrTraverse(const_cast(ID))) { I->id = info->id; } + return I; } - else if(NamespaceAliasDecl const* NAD = NNS->getAsNamespaceAlias()) - { - I = Polymorphic(); - I->Name = NAD->getIdentifier()->getName(); - I->Prefix = toNameInfo(NNS->getPrefix()); - Decl const* ID = getInstantiatedFrom(NAD); - if (Info* info = findOrTraverse(const_cast(ID))) - { - I->id = info->id; - } + case NestedNameSpecifier::Kind::Global: + case NestedNameSpecifier::Kind::MicrosoftSuper: + // FIXME: Unimplemented. + return std::nullopt; } - return I; + MRDOCS_UNREACHABLE(); } template Polymorphic ASTVisitor:: -toNameInfo( - DeclarationName const Name, +toNameInfo(DeclarationName const Name, std::optional TArgs, - NestedNameSpecifier const* NNS) + NestedNameSpecifier NNS) { if (Name.isEmpty()) { @@ -2082,10 +2064,7 @@ toNameInfo( I = Polymorphic(); } I->Name = extractName(Name); - if (NNS) - { - I->Prefix = toNameInfo(NNS); - } + I->Prefix = toNameInfo(NNS); return I; } @@ -2095,7 +2074,7 @@ ASTVisitor:: toNameInfo( Decl const* D, std::optional TArgs, - NestedNameSpecifier const* NNS) + NestedNameSpecifier NNS) { auto const* ND = dyn_cast_if_present(D); if (!ND) @@ -2123,7 +2102,7 @@ ASTVisitor:: toNameInfo>( Decl const* D, std::optional> TArgs, - NestedNameSpecifier const* NNS); + NestedNameSpecifier NNS); Polymorphic ASTVisitor:: @@ -2659,12 +2638,6 @@ ASTVisitor::getSFINAETemplateInfo(QualType T, bool const AllowDependentNames) co MRDOCS_SYMBOL_TRACE(T, context_); MRDOCS_ASSERT(!T.isNull()); - // If the type is an elaborated type, get the named type - if (auto* ET = T->getAs()) - { - T = ET->getNamedType(); - } - // If the type is a dependent name type and dependent names are allowed, // extract the identifier and the qualifier's type SFINAETemplateInfo SFINAE; @@ -2673,7 +2646,7 @@ ASTVisitor::getSFINAETemplateInfo(QualType T, bool const AllowDependentNames) co { SFINAE.Member = DNT->getIdentifier(); MRDOCS_SYMBOL_TRACE(SFINAE.Member, context_); - T = QualType(DNT->getQualifier()->getAsType(), 0); + T = QualType(DNT->getQualifier().getAsType(), 0); MRDOCS_SYMBOL_TRACE(T, context_); } if (!T.getTypePtrOrNull()) diff --git a/src/lib/AST/ASTVisitor.hpp b/src/lib/AST/ASTVisitor.hpp index b97ba06eaa..a06e557fb9 100644 --- a/src/lib/AST/ASTVisitor.hpp +++ b/src/lib/AST/ASTVisitor.hpp @@ -771,23 +771,21 @@ class ASTVisitor return toTypeInfo(qt, TraversalMode::Dependency); } - Polymorphic - toNameInfo( - NestedNameSpecifier const* NNS); + Polymorphic toNameInfo(NestedNameSpecifier NNS); template > Polymorphic toNameInfo( DeclarationName Name, std::optional TArgs = std::nullopt, - NestedNameSpecifier const* NNS = nullptr); + NestedNameSpecifier NNS = std::nullopt); template > Polymorphic toNameInfo( Decl const* D, std::optional TArgs = std::nullopt, - NestedNameSpecifier const* NNS = nullptr); + NestedNameSpecifier NNS = std::nullopt); Polymorphic toTArg(TemplateArgument const& A); diff --git a/src/lib/AST/NameInfoBuilder.cpp b/src/lib/AST/NameInfoBuilder.cpp index 52a42e7b10..70bb3f60a5 100644 --- a/src/lib/AST/NameInfoBuilder.cpp +++ b/src/lib/AST/NameInfoBuilder.cpp @@ -29,23 +29,18 @@ buildDecltype( void NameInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, Type const* T, unsigned, bool) { Result = Polymorphic(); Result->Name = getASTVisitor().toString(T); - if (NNS) - { - Result->Prefix = getASTVisitor().toNameInfo(NNS); - } } void NameInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, IdentifierInfo const* II, std::optional> TArgs, unsigned, @@ -79,7 +74,7 @@ buildTerminal( void NameInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, NamedDecl const* D, std::optional> const& TArgs, unsigned, diff --git a/src/lib/AST/NameInfoBuilder.hpp b/src/lib/AST/NameInfoBuilder.hpp index d544060dd2..515a093bd9 100644 --- a/src/lib/AST/NameInfoBuilder.hpp +++ b/src/lib/AST/NameInfoBuilder.hpp @@ -42,14 +42,13 @@ class NameInfoBuilder void buildTerminal( - NestedNameSpecifier const* NNS, Type const* T, unsigned quals, bool pack); void buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, IdentifierInfo const* II, std::optional> TArgs, unsigned quals, @@ -57,7 +56,7 @@ class NameInfoBuilder void buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, NamedDecl const* D, std::optional> const& TArgs, unsigned quals, diff --git a/src/lib/AST/TerminalTypeVisitor.hpp b/src/lib/AST/TerminalTypeVisitor.hpp index b6f3549d6d..23431d019e 100644 --- a/src/lib/AST/TerminalTypeVisitor.hpp +++ b/src/lib/AST/TerminalTypeVisitor.hpp @@ -84,9 +84,6 @@ class TerminalTypeVisitor // Whether the type is a pack expansion. bool IsPack_ = false; - // The optional NestedNameSpecifier. - NestedNameSpecifier const* NNS_ = nullptr; - protected: // Constraints associated with the type (e.g., SFINAE) std::vector Constraints; @@ -102,10 +99,8 @@ class TerminalTypeVisitor */ explicit TerminalTypeVisitor( - ASTVisitor& Visitor, - NestedNameSpecifier const* NNS = nullptr) + ASTVisitor& Visitor) : Visitor_(Visitor) - , NNS_(NNS) { } @@ -368,7 +363,7 @@ class TerminalTypeVisitor bool VisitUsingType(UsingType const* T) { - QualType UT = T->getUnderlyingType(); + QualType UT = T->desugar(); return Visit(UT); } @@ -390,30 +385,6 @@ class TerminalTypeVisitor // ---------------------------------------------------------------- - - - /** Visit an elaborated type. - - This function unwraps the named type from the elaborated type: - a type that was referred to using an elaborated type keyword, - e.g., `struct S`, or via a qualified name, e.g., `N::M::type`. - - Example: - - Wrapped type: `struct S` - - Unwrapped type: `S` - */ - bool - VisitElaboratedType( - ElaboratedType const* T) - { - MRDOCS_SYMBOL_TRACE(T, Visitor_.context_); - NNS_ = T->getQualifier(); - MRDOCS_SYMBOL_TRACE(NNS_, Visitor_.context_); - QualType NT = T->getNamedType(); - MRDOCS_SYMBOL_TRACE(NT, Visitor_.context_); - return Visit(NT); - } - /** Visit a pack expansion type. This function unwraps the pattern type from the pack expansion. @@ -564,7 +535,7 @@ class TerminalTypeVisitor TemplateName const TN = T->getTemplateName(); MRDOCS_ASSERT(! TN.isNull()); NamedDecl* ND = TN.getAsTemplateDecl(); - getDerived().buildTerminal(NNS_, ND, + getDerived().buildTerminal(TN.getQualifier(), ND, std::nullopt, Quals_, IsPack_); return true; } @@ -575,16 +546,11 @@ class TerminalTypeVisitor { if (auto SFINAE = getASTVisitor().extractSFINAEInfo(T)) { - NNS_ = nullptr; Constraints = SFINAE->Constraints; return getDerived().Visit(SFINAE->Type); } - if (auto const* NNS = T->getQualifier()) - { - NNS_ = NNS; - } - getDerived().buildTerminal(NNS_, T->getIdentifier(), + getDerived().buildTerminal(T->getQualifier(), T->getIdentifier(), std::nullopt, Quals_, IsPack_); return true; } @@ -594,12 +560,9 @@ class TerminalTypeVisitor DependentTemplateSpecializationType const* T) { MRDOCS_SYMBOL_TRACE(T, Visitor_.context_); - if (auto const* NNS = T->getQualifier()) - { - NNS_ = NNS; - } - getDerived().buildTerminal(NNS_, T->getIdentifier(), - T->template_arguments(), Quals_, IsPack_); + const DependentTemplateStorage &S = T->getDependentTemplateName(); + getDerived().buildTerminal(S.getQualifier(), S.getName().getIdentifier(), + T->template_arguments(), Quals_, IsPack_); return true; } @@ -611,7 +574,6 @@ class TerminalTypeVisitor MRDOCS_SYMBOL_TRACE(T, Visitor_.context_); if (auto SFINAE = getASTVisitor().extractSFINAEInfo(T)) { - NNS_ = nullptr; Constraints = SFINAE->Constraints; return getDerived().Visit(SFINAE->Type); } @@ -632,22 +594,16 @@ class TerminalTypeVisitor if (!T->isTypeAlias()) { - auto* CT = T->getCanonicalTypeInternal().getTypePtrOrNull(); - MRDOCS_SYMBOL_TRACE(CT, Visitor_.context_); - if (auto* ICT = dyn_cast_or_null(CT)) - { - D = ICT->getDecl(); - MRDOCS_SYMBOL_TRACE(D, Visitor_.context_); - } - else if (auto* RT = dyn_cast_or_null(CT)) + if (auto* CT = dyn_cast(T->getCanonicalTypeInternal())) { - D = RT->getDecl(); + MRDOCS_SYMBOL_TRACE(CT, Visitor_.context_); + D = CT->getOriginalDecl()->getDefinitionOrSelf(); MRDOCS_SYMBOL_TRACE(D, Visitor_.context_); } } getDerived().buildTerminal( - NNS_, D, + TN.getQualifier(), D, T->template_arguments(), Quals_, IsPack_); return true; @@ -657,7 +613,7 @@ class TerminalTypeVisitor VisitRecordType( RecordType const* T) { - RecordDecl* RD = T->getDecl(); + RecordDecl* RD = T->getOriginalDecl()->getDefinitionOrSelf(); // if this is an instantiation of a class template, // create a SpecializationTypeInfo & extract the template arguments std::optional> TArgs = std::nullopt; @@ -665,8 +621,8 @@ class TerminalTypeVisitor { TArgs = CTSD->getTemplateArgs().asArray(); } - getDerived().buildTerminal(NNS_, RD, - TArgs, Quals_, IsPack_); + getDerived().buildTerminal(T->getQualifier(), RD, TArgs, Quals_, + IsPack_); return true; } @@ -674,7 +630,7 @@ class TerminalTypeVisitor VisitInjectedClassNameType( InjectedClassNameType const* T) { - getDerived().buildTerminal(NNS_, T->getDecl(), + getDerived().buildTerminal(T->getQualifier(), T->getOriginalDecl()->getDefinitionOrSelf(), std::nullopt, Quals_, IsPack_); return true; } @@ -683,7 +639,7 @@ class TerminalTypeVisitor VisitEnumType( EnumType const* T) { - getDerived().buildTerminal(NNS_, T->getDecl(), + getDerived().buildTerminal(T->getQualifier(), T->getOriginalDecl()->getDefinitionOrSelf(), std::nullopt, Quals_, IsPack_); return true; } @@ -692,7 +648,7 @@ class TerminalTypeVisitor VisitTypedefType( TypedefType const* T) { - getDerived().buildTerminal(NNS_, T->getDecl(), + getDerived().buildTerminal(T->getQualifier(), T->getDecl(), std::nullopt, Quals_, IsPack_); return true; } @@ -711,12 +667,12 @@ class TerminalTypeVisitor // special case for implicit template parameters // resulting from abbreviated function templates getDerived().buildTerminal( - NNS_, T, Quals_, IsPack_); + T, Quals_, IsPack_); return true; } II = D->getIdentifier(); } - getDerived().buildTerminal(NNS_, II, + getDerived().buildTerminal(std::nullopt, II, std::nullopt, Quals_, IsPack_); return true; } @@ -725,7 +681,7 @@ class TerminalTypeVisitor VisitSubstTemplateTypeParmPackType( SubstTemplateTypeParmPackType const* T) { - getDerived().buildTerminal(NNS_, T->getIdentifier(), + getDerived().buildTerminal(std::nullopt, T->getIdentifier(), std::nullopt, Quals_, IsPack_); return true; } @@ -734,7 +690,7 @@ class TerminalTypeVisitor VisitType(Type const* T) { getDerived().buildTerminal( - NNS_, T, Quals_, IsPack_); + T, Quals_, IsPack_); return true; } }; diff --git a/src/lib/AST/TypeInfoBuilder.cpp b/src/lib/AST/TypeInfoBuilder.cpp index 3931d1e102..30527d5de8 100644 --- a/src/lib/AST/TypeInfoBuilder.cpp +++ b/src/lib/AST/TypeInfoBuilder.cpp @@ -54,7 +54,8 @@ buildMemberPointer( I.IsVolatile = quals & Qualifiers::Volatile; // do not set NNS because the parent type is *not* // a nested-name-specifier which qualifies the pointee type - I.ParentType = getASTVisitor().toTypeInfo(QualType(T->getClass(), 0)); + I.ParentType = + getASTVisitor().toTypeInfo(QualType(T->getQualifier().getAsType(), 0)); Inner = &I.PointeeType; } @@ -151,7 +152,6 @@ buildAuto( void TypeInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, Type const* T, unsigned quals, bool pack) @@ -166,7 +166,6 @@ buildTerminal( TI.IsVolatile = quals & Qualifiers::Volatile; TI.Name = Polymorphic(); TI.Name->Name = getASTVisitor().toString(T); - TI.Name->Prefix = getASTVisitor().toNameInfo(NNS); if (isa(T)) { auto const* FT = cast(T); @@ -179,7 +178,7 @@ buildTerminal( void TypeInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, IdentifierInfo const* II, std::optional> TArgs, unsigned quals, @@ -221,7 +220,7 @@ buildTerminal( void TypeInfoBuilder:: buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, NamedDecl* D, std::optional> TArgs, unsigned quals, diff --git a/src/lib/AST/TypeInfoBuilder.hpp b/src/lib/AST/TypeInfoBuilder.hpp index 5bd84bd9ed..7d103f2530 100644 --- a/src/lib/AST/TypeInfoBuilder.hpp +++ b/src/lib/AST/TypeInfoBuilder.hpp @@ -189,7 +189,6 @@ class TypeInfoBuilder @param pack Whether the terminal type is a pack. */ void buildTerminal( - NestedNameSpecifier const* NNS, Type const* T, unsigned quals, bool pack); @@ -210,7 +209,7 @@ class TypeInfoBuilder @param pack Whether the terminal type is a pack. */ void buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, IdentifierInfo const* II, std::optional> TArgs, unsigned quals, @@ -232,7 +231,7 @@ class TypeInfoBuilder @param pack Whether the terminal type is a pack. */ void buildTerminal( - NestedNameSpecifier const* NNS, + NestedNameSpecifier NNS, NamedDecl* D, std::optional> TArgs, unsigned quals, diff --git a/test-files/golden-tests/config/sfinae/redeclare.xml b/test-files/golden-tests/config/sfinae/redeclare.xml index b5ac1efab8..0aca10febd 100644 --- a/test-files/golden-tests/config/sfinae/redeclare.xml +++ b/test-files/golden-tests/config/sfinae/redeclare.xml @@ -4,7 +4,7 @@