Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class InstallOptions:
llvm_build_dir: str = "<llvm-src-dir>/build/<llvm-build-type:lower><\"-\":if(cc)><cc:basename><\"-\":if(sanitizer)><sanitizer:lower>"
llvm_install_dir: str = "<llvm-src-dir>/install/<llvm-build-type:lower><\"-\":if(cc)><cc:basename><\"-\":if(sanitizer)><sanitizer:lower>"
llvm_repo: str = "https://github.com/llvm/llvm-project.git"
llvm_commit: str = "dd7a3d4d798e30dfe53b5bbbbcd9a23c24ea1af9"
llvm_commit: str = "a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b"

# Libxml2
libxml2_src_dir: str = "<third-party-src-dir>/libxml2"
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand All @@ -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 <.>
----

Expand Down
85 changes: 29 additions & 56 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ASTVisitor(
// ASTContext::setTraversalScope is being (erroneously)
// used somewhere
MRDOCS_ASSERT(context_.getTraversalScope() ==
std::vector<Decl*>{context_.getTranslationUnitDecl()});
ArrayRef<Decl *>{context_.getTranslationUnitDecl()});
}

void
Expand Down Expand Up @@ -466,7 +466,7 @@ generateUSR(Decl const* D) const
if(auto* FD = dyn_cast<FunctionDecl>(Templated);
FD && FD->getTrailingRequiresClause())
{
Expr const* RC = FD->getTrailingRequiresClause();
Expr const* RC = FD->getTrailingRequiresClause().ConstraintExpr;
RC = SubstituteConstraintExpressionWithoutSatisfaction(
sema_, cast<NamedDecl>(Described ? Described : Templated), RC);
if (!RC)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -1478,7 +1478,7 @@ populate(
}
if(TypeConstraint const* TC = P->getTypeConstraint())
{
NestedNameSpecifier const* NNS =
NestedNameSpecifier NNS =
TC->getNestedNameSpecifierLoc().getNestedNameSpecifier();
std::optional<ASTTemplateArgumentListInfo const*> TArgs;
if (TC->hasExplicitTemplateArgs())
Expand Down Expand Up @@ -2009,63 +2009,45 @@ toTypeInfo(QualType const qt, TraversalMode const mode)
return Builder.result();
}

Polymorphic<NameInfo>
ASTVisitor::
toNameInfo(
NestedNameSpecifier const* NNS)
Polymorphic<NameInfo> ASTVisitor::toNameInfo(NestedNameSpecifier NNS)
{
if (!NNS)
{
return std::nullopt;
}
MRDOCS_SYMBOL_TRACE(NNS, context_);

ScopeExitRestore scope(mode_, Dependency);
Polymorphic<NameInfo> 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<NameInfo>();
I->Name = II->getName();
I->Prefix = toNameInfo(NNS->getPrefix());
}
else if(NamespaceDecl const* ND = NNS->getAsNamespace())
{
I = Polymorphic<NameInfo>();
case NestedNameSpecifier::Kind::Namespace: {
auto I = Polymorphic<NameInfo>();
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<Decl*>(ID)))
{
I->id = info->id;
}
return I;
}
else if(NamespaceAliasDecl const* NAD = NNS->getAsNamespaceAlias())
{
I = Polymorphic<NameInfo>();
I->Name = NAD->getIdentifier()->getName();
I->Prefix = toNameInfo(NNS->getPrefix());
Decl const* ID = getInstantiatedFrom(NAD);
if (Info* info = findOrTraverse(const_cast<Decl*>(ID)))
{
I->id = info->id;
}
case NestedNameSpecifier::Kind::Global:
case NestedNameSpecifier::Kind::MicrosoftSuper:
// FIXME: Unimplemented.
return std::nullopt;
}
return I;
MRDOCS_UNREACHABLE();
}

template <class TArgRange>
Polymorphic<NameInfo>
ASTVisitor::
toNameInfo(
DeclarationName const Name,
toNameInfo(DeclarationName const Name,
std::optional<TArgRange> TArgs,
NestedNameSpecifier const* NNS)
NestedNameSpecifier NNS)
{
if (Name.isEmpty())
{
Expand All @@ -2082,10 +2064,7 @@ toNameInfo(
I = Polymorphic<NameInfo>();
}
I->Name = extractName(Name);
if (NNS)
{
I->Prefix = toNameInfo(NNS);
}
I->Prefix = toNameInfo(NNS);
return I;
}

Expand All @@ -2095,7 +2074,7 @@ ASTVisitor::
toNameInfo(
Decl const* D,
std::optional<TArgRange> TArgs,
NestedNameSpecifier const* NNS)
NestedNameSpecifier NNS)
{
auto const* ND = dyn_cast_if_present<NamedDecl>(D);
if (!ND)
Expand Down Expand Up @@ -2123,7 +2102,7 @@ ASTVisitor::
toNameInfo<llvm::ArrayRef<clang::TemplateArgument>>(
Decl const* D,
std::optional<llvm::ArrayRef<clang::TemplateArgument>> TArgs,
NestedNameSpecifier const* NNS);
NestedNameSpecifier NNS);

Polymorphic<TArg>
ASTVisitor::
Expand Down Expand Up @@ -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<ElaboratedType>())
{
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;
Expand All @@ -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())
Expand Down
8 changes: 3 additions & 5 deletions src/lib/AST/ASTVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,23 +771,21 @@ class ASTVisitor
return toTypeInfo(qt, TraversalMode::Dependency);
}

Polymorphic<NameInfo>
toNameInfo(
NestedNameSpecifier const* NNS);
Polymorphic<NameInfo> toNameInfo(NestedNameSpecifier NNS);

template <class TArgRange = ArrayRef<TemplateArgument>>
Polymorphic<NameInfo>
toNameInfo(
DeclarationName Name,
std::optional<TArgRange> TArgs = std::nullopt,
NestedNameSpecifier const* NNS = nullptr);
NestedNameSpecifier NNS = std::nullopt);

template <class TArgRange = ArrayRef<TemplateArgument>>
Polymorphic<NameInfo>
toNameInfo(
Decl const* D,
std::optional<TArgRange> TArgs = std::nullopt,
NestedNameSpecifier const* NNS = nullptr);
NestedNameSpecifier NNS = std::nullopt);

Polymorphic<TArg>
toTArg(TemplateArgument const& A);
Expand Down
9 changes: 2 additions & 7 deletions src/lib/AST/NameInfoBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,18 @@ buildDecltype(
void
NameInfoBuilder::
buildTerminal(
NestedNameSpecifier const* NNS,
Type const* T,
unsigned,
bool)
{
Result = Polymorphic<NameInfo>();
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<ArrayRef<TemplateArgument>> TArgs,
unsigned,
Expand Down Expand Up @@ -79,7 +74,7 @@ buildTerminal(
void
NameInfoBuilder::
buildTerminal(
NestedNameSpecifier const* NNS,
NestedNameSpecifier NNS,
NamedDecl const* D,
std::optional<ArrayRef<TemplateArgument>> const& TArgs,
unsigned,
Expand Down
5 changes: 2 additions & 3 deletions src/lib/AST/NameInfoBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,21 @@ 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<ArrayRef<TemplateArgument>> TArgs,
unsigned quals,
bool pack);

void
buildTerminal(
NestedNameSpecifier const* NNS,
NestedNameSpecifier NNS,
NamedDecl const* D,
std::optional<ArrayRef<TemplateArgument>> const& TArgs,
unsigned quals,
Expand Down
Loading
Loading