Browse Source

Merge c28a6d7539 into 9621e88ad3

pull/1922/merge
Jelle 4 months ago committed by GitHub
parent
commit
b6fb64532c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      src/Core/Diagnostics.cs
  2. 2254
      src/CppParser/AST.cpp
  3. 2352
      src/CppParser/ASTNodeVisitor.cpp
  4. 541
      src/CppParser/ASTNodeVisitor.h
  5. 52
      src/CppParser/Decl.h
  6. 38
      src/CppParser/Parser.cpp
  7. 12
      src/CppParser/Parser.h
  8. 2
      src/CppParser/ParserGen/ParserGen.cs
  9. 923
      src/CppParser/StmtNodes.inc
  10. 618
      src/CppParser/Types.h
  11. 1
      src/Generator.Tests/GeneratorTest.cs

4
src/Core/Diagnostics.cs

@ -128,7 +128,9 @@ namespace CppSharp @@ -128,7 +128,9 @@ namespace CppSharp
{
Console.WriteLine(message);
}
Debug.WriteLine(message);
// Super slow, don't use this for now
// Debug.WriteLine(message);
}
public void PushIndent(int level)

2254
src/CppParser/AST.cpp

File diff suppressed because it is too large Load Diff

2352
src/CppParser/ASTNodeVisitor.cpp

File diff suppressed because it is too large Load Diff

541
src/CppParser/ASTNodeVisitor.h

@ -0,0 +1,541 @@ @@ -0,0 +1,541 @@
/************************************************************************
*
* CppSharp
* Licensed under the simplified BSD license. All rights reserved.
*
************************************************************************/
#pragma once
#include <llvm/Support/JSON.h>
#include "ASTNameMangler.h"
#include "Types.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDumperUtils.h"
#include "clang/AST/ASTNodeTraverser.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/AttrVisitor.h"
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/CommentVisitor.h"
#include "clang/AST/ExprConcepts.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Type.h"
#include <unordered_set>
#include "Decl.h"
#include "Expr.h"
#include "Stmt.h"
namespace CppSharp::CppParser {
namespace AST {
class Stmt;
} // namespace AST
class Parser;
class NodeStreamer
{
bool FirstChild = true;
bool TopLevel = true;
llvm::SmallVector<std::function<void(bool IsLastChild)>, 32> Pending;
protected:
llvm::json::OStream JOS;
public:
/// Add a child of the current node. Calls DoAddChild without arguments
template <typename Fn>
void AddChild(Fn DoAddChild)
{
return AddChild("", DoAddChild);
}
/// Add a child of the current node with an optional label.
/// Calls DoAddChild without arguments.
template <typename Fn>
void AddChild(llvm::StringRef Label, Fn DoAddChild)
{
// If we're at the top level, there's nothing interesting to do; just
// run the dumper.
if (TopLevel)
{
TopLevel = false;
JOS.objectBegin();
DoAddChild();
while (!Pending.empty())
{
Pending.back()(true);
Pending.pop_back();
}
JOS.objectEnd();
TopLevel = true;
return;
}
// We need to capture an owning-string in the lambda because the lambda
// is invoked in a deferred manner.
std::string LabelStr(!Label.empty() ? Label : "inner");
bool WasFirstChild = FirstChild;
auto DumpWithIndent = [=](bool IsLastChild)
{
if (WasFirstChild)
{
JOS.attributeBegin(LabelStr);
JOS.arrayBegin();
}
FirstChild = true;
unsigned Depth = Pending.size();
JOS.objectBegin();
DoAddChild();
// If any children are left, they're the last at their nesting level.
// Dump those ones out now.
while (Depth < Pending.size())
{
Pending.back()(true);
this->Pending.pop_back();
}
JOS.objectEnd();
if (IsLastChild)
{
JOS.arrayEnd();
JOS.attributeEnd();
}
};
if (FirstChild)
{
Pending.push_back(std::move(DumpWithIndent));
}
else
{
Pending.back()(false);
Pending.back() = std::move(DumpWithIndent);
}
FirstChild = false;
}
NodeStreamer(llvm::raw_ostream& OS)
: JOS(OS, 2)
{
}
};
// Dumps AST nodes in JSON format. There is no implied stability for the
// content or format of the dump between major releases of Clang, other than it
// being valid JSON output. Further, there is no requirement that the
// information dumped is a complete representation of the AST, only that the
// information presented is correct.
class ASTNodeVisitor
: public clang::ConstAttrVisitor<ASTNodeVisitor>,
public clang::comments::ConstCommentVisitor<ASTNodeVisitor, void, const clang::comments::FullComment*>,
public clang::ConstTemplateArgumentVisitor<ASTNodeVisitor>,
public clang::ConstStmtVisitor<ASTNodeVisitor>,
public clang::TypeVisitor<ASTNodeVisitor>,
public clang::ConstDeclVisitor<ASTNodeVisitor, AST::Declaration*>,
public NodeStreamer
{
friend class ASTNodeDumper;
using InnerAttrVisitor = ConstAttrVisitor;
using InnerCommentVisitor = ConstCommentVisitor;
using InnerTemplateArgVisitor = ConstTemplateArgumentVisitor;
using InnerStmtVisitor = ConstStmtVisitor;
using InnerTypeVisitor = TypeVisitor;
using InnerDeclVisitor = ConstDeclVisitor;
public:
ASTNodeVisitor(llvm::raw_ostream& OS, clang::ASTContext& Ctx, Parser& parser)
: NodeStreamer(OS)
, parser(parser)
, SM(Ctx.getSourceManager())
, Ctx(Ctx)
, NameMangler(Ctx)
, PrintPolicy(Ctx.getPrintingPolicy())
, Traits(Ctx.getCommentCommandTraits())
, LastLocLine(0)
, LastLocPresumedLine(0)
{
declMap.reserve(32768);
typeMap.reserve(32768);
stmtMap.reserve(32768);
}
void Visit(const clang::Attr* A);
void Visit(const clang::Stmt* S);
void Visit(const clang::Type* T);
void Visit(clang::QualType T);
AST::Declaration* Visit(const clang::Decl* D);
void Visit(clang::TypeLoc TL);
void Visit(const clang::comments::Comment* C, const clang::comments::FullComment* FC);
void Visit(const clang::TemplateArgument& TA, clang::SourceRange R = {}, const clang::Decl* From = nullptr, llvm::StringRef Label = {});
void Visit(const clang::CXXCtorInitializer* Init);
// void Visit(const OpenACCClause* C) {}
void Visit(const clang::OMPClause* C) {}
void Visit(const clang::BlockDecl::Capture& C);
void Visit(const clang::GenericSelectionExpr::ConstAssociation& A);
void Visit(const clang::concepts::Requirement* R);
void Visit(const clang::APValue& Value, clang::QualType Ty);
void Visit(const clang::ConceptReference*);
void VisitAliasAttr(const clang::AliasAttr* AA);
void VisitCleanupAttr(const clang::CleanupAttr* CA);
void VisitDeprecatedAttr(const clang::DeprecatedAttr* DA);
void VisitUnavailableAttr(const clang::UnavailableAttr* UA);
void VisitSectionAttr(const clang::SectionAttr* SA);
void VisitVisibilityAttr(const clang::VisibilityAttr* VA);
void VisitTLSModelAttr(const clang::TLSModelAttr* TA);
void VisitTypedefType(const clang::TypedefType* TT);
void VisitUsingType(const clang::UsingType* TT);
void VisitFunctionType(const clang::FunctionType* T);
void VisitFunctionProtoType(const clang::FunctionProtoType* T);
void VisitRValueReferenceType(const clang::ReferenceType* RT);
void VisitArrayType(const clang::ArrayType* AT);
void VisitConstantArrayType(const clang::ConstantArrayType* CAT);
void VisitDependentSizedExtVectorType(const clang::DependentSizedExtVectorType* VT);
void VisitVectorType(const clang::VectorType* VT);
void VisitUnresolvedUsingType(const clang::UnresolvedUsingType* UUT);
void VisitUnaryTransformType(const clang::UnaryTransformType* UTT);
void VisitTagType(const clang::TagType* TT);
void VisitTemplateTypeParmType(const clang::TemplateTypeParmType* TTPT);
void VisitSubstTemplateTypeParmType(const clang::SubstTemplateTypeParmType* STTPT);
void VisitSubstTemplateTypeParmPackType(const clang::SubstTemplateTypeParmPackType* T);
void VisitAutoType(const clang::AutoType* AT);
void VisitTemplateSpecializationType(const clang::TemplateSpecializationType* TST);
void VisitInjectedClassNameType(const clang::InjectedClassNameType* ICNT);
void VisitObjCInterfaceType(const clang::ObjCInterfaceType* OIT);
void VisitPackExpansionType(const clang::PackExpansionType* PET);
void VisitElaboratedType(const clang::ElaboratedType* ET);
void VisitMacroQualifiedType(const clang::MacroQualifiedType* MQT);
void VisitMemberPointerType(const clang::MemberPointerType* MPT);
AST::Declaration* VisitTranslationUnitDecl(const clang::TranslationUnitDecl* D);
AST::Declaration* VisitNamedDecl(const clang::NamedDecl* ND);
void HandleNamedDecl(AST::Declaration& AST_ND, const clang::NamedDecl* ND);
AST::Declaration* VisitTypedefDecl(const clang::TypedefDecl* TD);
AST::Declaration* VisitTypeAliasDecl(const clang::TypeAliasDecl* TAD);
AST::Declaration* VisitNamespaceDecl(const clang::NamespaceDecl* ND);
AST::Declaration* VisitUsingDirectiveDecl(const clang::UsingDirectiveDecl* UDD);
AST::Declaration* VisitNamespaceAliasDecl(const clang::NamespaceAliasDecl* NAD);
AST::Declaration* VisitUsingDecl(const clang::UsingDecl* UD);
AST::Declaration* VisitUsingEnumDecl(const clang::UsingEnumDecl* UED);
AST::Declaration* VisitUsingShadowDecl(const clang::UsingShadowDecl* USD);
AST::Declaration* VisitVarDecl(const clang::VarDecl* VD);
AST::Declaration* VisitFieldDecl(const clang::FieldDecl* FD);
AST::Declaration* VisitFunctionDecl(const clang::FunctionDecl* FD);
AST::Declaration* VisitEnumDecl(const clang::EnumDecl* ED);
AST::Declaration* VisitEnumConstantDecl(const clang::EnumConstantDecl* ECD);
AST::Declaration* VisitRecordDecl(const clang::RecordDecl* RD);
AST::Declaration* VisitCXXRecordDecl(const clang::CXXRecordDecl* RD);
AST::Declaration* VisitHLSLBufferDecl(const clang::HLSLBufferDecl* D);
AST::Declaration* VisitTemplateTypeParmDecl(const clang::TemplateTypeParmDecl* D);
AST::Declaration* VisitNonTypeTemplateParmDecl(const clang::NonTypeTemplateParmDecl* D);
AST::Declaration* VisitTemplateTemplateParmDecl(const clang::TemplateTemplateParmDecl* D);
AST::Declaration* VisitLinkageSpecDecl(const clang::LinkageSpecDecl* LSD);
AST::Declaration* VisitAccessSpecDecl(const clang::AccessSpecDecl* ASD);
AST::Declaration* VisitFriendDecl(const clang::FriendDecl* FD);
AST::Declaration* VisitObjCIvarDecl(const clang::ObjCIvarDecl* D);
AST::Declaration* VisitObjCMethodDecl(const clang::ObjCMethodDecl* D);
AST::Declaration* VisitObjCTypeParamDecl(const clang::ObjCTypeParamDecl* D);
AST::Declaration* VisitObjCCategoryDecl(const clang::ObjCCategoryDecl* D);
AST::Declaration* VisitObjCCategoryImplDecl(const clang::ObjCCategoryImplDecl* D);
AST::Declaration* VisitObjCProtocolDecl(const clang::ObjCProtocolDecl* D);
AST::Declaration* VisitObjCInterfaceDecl(const clang::ObjCInterfaceDecl* D);
AST::Declaration* VisitObjCImplementationDecl(const clang::ObjCImplementationDecl* D);
AST::Declaration* VisitObjCCompatibleAliasDecl(const clang::ObjCCompatibleAliasDecl* D);
AST::Declaration* VisitObjCPropertyDecl(const clang::ObjCPropertyDecl* D);
AST::Declaration* VisitObjCPropertyImplDecl(const clang::ObjCPropertyImplDecl* D);
AST::Declaration* VisitBlockDecl(const clang::BlockDecl* D);
/*#define DECL(CLASS, BASE) \
void Convert##CLASS##DeclImpl(const clang::CLASS##Decl* Src, AST::CLASS##Decl& Dst); \
void Convert##CLASS##Decl(const clang::CLASS##Decl* Src, AST::CLASS##Decl& Dst) \
{ \
Convert##BASE##Decl(Src, Dst); \
Convert##CLASS##DeclImpl(Src, Dst); \
}
#include "clang/AST/DeclNodes.inc"
// Declare Visit*() for all concrete Decl classes.
#define ABSTRACT_DECL(DECL)
#define DECL(CLASS, BASE) \
void Visit##CLASS##Decl(const CLASS##Decl* D) \
{ \
if (declMap.find(D) != declMap.end()) \
return; \
\
auto res = declMap.emplace(D, new AST::CLASS##Decl()); \
Convert##CLASS##Decl(D, res.first->second); \
}
#include "clang/AST/DeclNodes.inc"
// The above header #undefs ABSTRACT_DECL and DECL upon exit.*/
void ConvertStmt(const clang::Stmt* Src, AST::Stmt& Dst);
#define STMT(CLASS, BASE) \
void Convert##CLASS##Impl(const clang::CLASS* Src, AST::CLASS& Dst); \
void Convert##CLASS(const clang::CLASS* Src, AST::CLASS& Dst) \
{ \
Convert##BASE(Src, Dst); \
Convert##CLASS##Impl(Src, Dst); \
}
#include "StmtNodes.inc"
// Declare Visit*() for all concrete Stmt classes.
#define ABSTRACT_STMT(STMT)
#define STMT(CLASS, BASE) \
void Visit##CLASS(const clang::CLASS* S) \
{ \
if (!S || stmtMap.find(S) != stmtMap.end()) \
return; \
\
auto res = stmtMap.emplace(S, new AST::CLASS()); \
Convert##CLASS(S, static_cast<AST::CLASS&>(*res.first->second)); \
}
#include "StmtNodes.inc"
// The above header #undefs ABSTRACT_STMT and STMT upon exit.
void VisitNullTemplateArgument(const clang::TemplateArgument& TA);
void VisitTypeTemplateArgument(const clang::TemplateArgument& TA);
void VisitDeclarationTemplateArgument(const clang::TemplateArgument& TA);
void VisitNullPtrTemplateArgument(const clang::TemplateArgument& TA);
void VisitIntegralTemplateArgument(const clang::TemplateArgument& TA);
void VisitTemplateTemplateArgument(const clang::TemplateArgument& TA);
void VisitTemplateExpansionTemplateArgument(const clang::TemplateArgument& TA);
void VisitExpressionTemplateArgument(const clang::TemplateArgument& TA);
void VisitPackTemplateArgument(const clang::TemplateArgument& TA);
void visitTextComment(const clang::comments::TextComment* C, const clang::comments::FullComment*);
void visitInlineCommandComment(const clang::comments::InlineCommandComment* C, const clang::comments::FullComment*);
void visitHTMLStartTagComment(const clang::comments::HTMLStartTagComment* C, const clang::comments::FullComment*);
void visitHTMLEndTagComment(const clang::comments::HTMLEndTagComment* C, const clang::comments::FullComment*);
void visitBlockCommandComment(const clang::comments::BlockCommandComment* C, const clang::comments::FullComment*);
void visitParamCommandComment(const clang::comments::ParamCommandComment* C, const clang::comments::FullComment* FC);
void visitTParamCommandComment(const clang::comments::TParamCommandComment* C, const clang::comments::FullComment* FC);
void visitVerbatimBlockComment(const clang::comments::VerbatimBlockComment* C, const clang::comments::FullComment*);
void visitVerbatimBlockLineComment(const clang::comments::VerbatimBlockLineComment* C, const clang::comments::FullComment*);
void visitVerbatimLineComment(const clang::comments::VerbatimLineComment* C, const clang::comments::FullComment*);
private:
void attributeOnlyIfTrue(llvm::StringRef Key, bool Value)
{
if (Value)
JOS.attribute(Key, Value);
}
void writeIncludeStack(clang::PresumedLoc Loc, bool JustFirst = false);
// Writes the attributes of a SourceLocation object without.
void writeBareSourceLocation(clang::SourceLocation Loc, bool IsSpelling, bool addFileInfo);
// Writes the attributes of a SourceLocation to JSON based on its presumed
// spelling location. If the given location represents a macro invocation,
// this outputs two sub-objects: one for the spelling and one for the
// expansion location.
void writeSourceLocation(clang::SourceLocation Loc, bool addFileInfo = true);
void writeSourceRange(clang::SourceRange R);
std::string createPointerRepresentation(const void* Ptr);
llvm::json::Object createQualType(clang::QualType QT, bool Desugar = true);
AST::QualifiedType CreateQualifiedType(clang::QualType QT, bool Desugar = true);
llvm::json::Object createBareDeclRef(const clang::Decl* D);
llvm::json::Object createFPOptions(clang::FPOptionsOverride FPO);
void writeBareDeclRef(const clang::Decl* D);
llvm::json::Object createCXXRecordDefinitionData(const clang::CXXRecordDecl* RD);
llvm::json::Object createCXXBaseSpecifier(const clang::CXXBaseSpecifier& BS);
std::string createAccessSpecifier(clang::AccessSpecifier AS);
llvm::json::Array createCastPath(const clang::CastExpr* C);
void writePreviousDeclImpl(...) {}
template <typename T>
void writePreviousDeclImpl(const clang::Mergeable<T>* D)
{
const T* First = D->getFirstDecl();
if (First != D)
JOS.attribute("firstRedecl", createPointerRepresentation(First));
}
template <typename T>
void writePreviousDeclImpl(const clang::Redeclarable<T>* D)
{
const T* Prev = D->getPreviousDecl();
if (Prev)
JOS.attribute("previousDecl", createPointerRepresentation(Prev));
}
[[nodiscard]] std::string GetMangledName(const clang::NamedDecl& ND) const;
void ConvertNamedRecord(AST::Declaration& dst, const clang::NamedDecl& src) const;
void addPreviousDeclaration(const clang::Decl* D);
llvm::StringRef getCommentCommandName(unsigned CommandID) const;
template <typename Fn>
AST::Declaration* FindOrInsertLazy(const clang::Decl* D, Fn&& inserter)
{
if (auto it = declMap.find(D); it != declMap.end())
return it->second;
auto res = declMap.emplace(D, std::invoke(inserter));
return res.first->second;
}
std::unordered_map<const clang::Decl*, AST::Declaration*> declMap;
std::unordered_set<const clang::Type*> typeMap;
std::unordered_map<const clang::Stmt*, AST::Stmt*> stmtMap;
Parser& parser;
const clang::SourceManager& SM;
clang::ASTContext& Ctx;
ASTNameMangler NameMangler; // TODO: Remove this, or the parser one
clang::PrintingPolicy PrintPolicy;
const clang::comments::CommandTraits& Traits;
llvm::StringRef LastLocFilename, LastLocPresumedFilename;
unsigned LastLocLine, LastLocPresumedLine;
};
class ASTNodeDumper : public clang::ASTNodeTraverser<ASTNodeDumper, ASTNodeVisitor>
{
public:
ASTNodeDumper(llvm::raw_ostream& OS, clang::ASTContext& Ctx, Parser& parser)
: NodeVisitor(OS, Ctx, parser)
{
setDeserialize(true);
}
ASTNodeVisitor& doGetNodeDelegate() { return NodeVisitor; }
void VisitFunctionTemplateDecl(const clang::FunctionTemplateDecl* FTD)
{
writeTemplateDecl(FTD, true);
}
void VisitClassTemplateDecl(const clang::ClassTemplateDecl* CTD)
{
writeTemplateDecl(CTD, false);
}
void VisitVarTemplateDecl(const clang::VarTemplateDecl* VTD)
{
writeTemplateDecl(VTD, false);
}
private:
template <typename SpecializationDecl>
void writeTemplateDeclSpecialization(const SpecializationDecl* SD, bool DumpExplicitInst, bool DumpRefOnly)
{
bool DumpedAny = false;
for (const auto* RedeclWithBadType : SD->redecls())
{
// FIXME: The redecls() range sometimes has elements of a less-specific
// type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
// us TagDecls, and should give CXXRecordDecls).
const auto* Redecl = clang::dyn_cast<SpecializationDecl>(RedeclWithBadType);
if (!Redecl)
{
// Found the injected-class-name for a class template. This will be
// dumped as part of its surrounding class so we don't need to dump it
// here.
assert(clang::isa<clang::CXXRecordDecl>(RedeclWithBadType) &&
"expected an injected-class-name");
continue;
}
switch (Redecl->getTemplateSpecializationKind())
{
case clang::TSK_ExplicitInstantiationDeclaration:
case clang::TSK_ExplicitInstantiationDefinition:
if (!DumpExplicitInst)
break;
[[fallthrough]];
case clang::TSK_Undeclared:
case clang::TSK_ImplicitInstantiation:
if (DumpRefOnly)
NodeVisitor.AddChild([=]
{
NodeVisitor.writeBareDeclRef(Redecl);
});
else
Visit(Redecl);
DumpedAny = true;
break;
case clang::TSK_ExplicitSpecialization:
break;
}
}
// Ensure we dump at least one decl for each specialization.
if (!DumpedAny)
NodeVisitor.AddChild([=]
{
NodeVisitor.writeBareDeclRef(SD);
});
}
template <typename TemplateDecl>
void writeTemplateDecl(const TemplateDecl* TD, bool DumpExplicitInst)
{
// FIXME: it would be nice to dump template parameters and specializations
// to their own named arrays rather than shoving them into the "inner"
// array. However, template declarations are currently being handled at the
// wrong "level" of the traversal hierarchy and so it is difficult to
// achieve without losing information elsewhere.
dumpTemplateParameters(TD->getTemplateParameters());
Visit(TD->getTemplatedDecl());
// TODO: Fixme. Crash in specializations iterator (clang bug?)
// for (const auto* Child : TD->specializations())
// writeTemplateDeclSpecialization(Child, DumpExplicitInst, !TD->isCanonicalDecl());
}
ASTNodeVisitor NodeVisitor;
};
class ASTParser : public clang::RecursiveASTVisitor<ASTParser>
{
bool shouldVisitTemplateInstantiations() const { return true; }
bool shouldWalkTypesOfTypeLocs() const { return true; }
bool shouldVisitImplicitCode() const { return true; }
bool shouldVisitLambdaBody() const { return true; }
bool shouldTraversePostOrder() const { return true; }
/*void HandleNamedDecl(AST::Declaration& AST_ND, const clang::NamedDecl* ND);
bool VisitTranslationUnitDecl(const clang::TranslationUnitDecl* D);
bool VisitNamedDecl(const clang::NamedDecl* ND);
bool VisitTypedefDecl(const clang::TypedefDecl* TD);
bool VisitTypeAliasDecl(const clang::TypeAliasDecl* TAD);
bool VisitNamespaceDecl(const clang::NamespaceDecl* ND);
bool VisitUsingDirectiveDecl(const clang::UsingDirectiveDecl* UDD);
bool VisitNamespaceAliasDecl(const clang::NamespaceAliasDecl* NAD);
bool VisitUsingDecl(const clang::UsingDecl* UD);
bool VisitUsingEnumDecl(const clang::UsingEnumDecl* UED);
bool VisitUsingShadowDecl(const clang::UsingShadowDecl* USD);
bool VisitVarDecl(const clang::VarDecl* VD);
bool VisitFieldDecl(const clang::FieldDecl* FD);
bool VisitFunctionDecl(const clang::FunctionDecl* FD);
bool VisitEnumDecl(const clang::EnumDecl* ED);
bool VisitEnumConstantDecl(const clang::EnumConstantDecl* ECD);
bool VisitRecordDecl(const clang::RecordDecl* RD);
bool VisitCXXRecordDecl(const clang::CXXRecordDecl* RD);
bool VisitHLSLBufferDecl(const clang::HLSLBufferDecl* D);
bool VisitTemplateTypeParmDecl(const clang::TemplateTypeParmDecl* D);
bool VisitNonTypeTemplateParmDecl(const clang::NonTypeTemplateParmDecl* D);
bool VisitTemplateTemplateParmDecl(const clang::TemplateTemplateParmDecl* D);
bool VisitLinkageSpecDecl(const clang::LinkageSpecDecl* LSD);
bool VisitAccessSpecDecl(const clang::AccessSpecDecl* ASD);
bool VisitFriendDecl(const clang::FriendDecl* FD);*/
};
} // namespace CppSharp::CppParser

52
src/CppParser/Decl.h

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "Sources.h"
#include "Types.h"
#include <algorithm>
#include <unordered_map>
namespace CppSharp {
namespace CppParser {
@ -82,6 +83,7 @@ namespace AST { @@ -82,6 +83,7 @@ namespace AST {
int lineNumberStart;
int lineNumberEnd;
std::string name;
std::string mangledName;
std::string USR;
std::string debugText;
bool isIncomplete;
@ -89,6 +91,9 @@ namespace AST { @@ -89,6 +91,9 @@ namespace AST {
bool isImplicit;
bool isInvalid;
bool isDeprecated;
bool isHidden;
bool isUsed;
bool isReferenced;
Declaration* completeDeclaration;
unsigned definitionOrder;
VECTOR(PreprocessedEntity*, PreprocessedEntities)
@ -115,32 +120,32 @@ namespace AST { @@ -115,32 +120,32 @@ namespace AST {
public:
DeclarationContext(DeclarationKind kind);
CS_IGNORE Declaration* FindAnonymous(const std::string& USR);
CS_IGNORE Declaration* FindAnonymous(const std::string_view& USR);
CS_IGNORE Namespace* FindNamespace(const std::string& Name);
CS_IGNORE Namespace* FindNamespace(const std::vector<std::string>&);
CS_IGNORE Namespace* FindCreateNamespace(const std::string& Name);
CS_IGNORE Namespace* FindNamespace(const std::string_view& name);
CS_IGNORE Namespace* FindNamespace(const std::vector<std::string_view>&);
CS_IGNORE Namespace& FindCreateNamespace(const std::string_view& Name);
CS_IGNORE Class* CreateClass(const std::string& Name, bool IsComplete);
CS_IGNORE Class* FindClass(const void* OriginalPtr, const std::string& Name, bool IsComplete);
CS_IGNORE Class* FindClass(const void* OriginalPtr, const std::string& Name, bool IsComplete, bool Create);
CS_IGNORE Class* CreateClass(const std::string_view& Name, bool IsComplete);
CS_IGNORE Class* FindClass(const void* OriginalPtr, const std::string_view& Name, bool IsComplete);
CS_IGNORE Class* FindClass(const void* OriginalPtr, const std::string_view& Name, bool IsComplete, bool Create);
CS_IGNORE template <typename T>
T* FindTemplate(const std::string& USR);
T* FindTemplate(const std::string_view& USR);
CS_IGNORE Enumeration* FindEnum(const void* OriginalPtr);
CS_IGNORE Enumeration* FindEnum(const std::string& Name, bool Create = false);
CS_IGNORE Enumeration* FindEnumWithItem(const std::string& Name);
CS_IGNORE Enumeration* FindEnum(const std::string_view& Name, bool Create = false);
CS_IGNORE Enumeration* FindEnumWithItem(const std::string_view& Name);
CS_IGNORE Function* FindFunction(const std::string& USR);
CS_IGNORE Function* FindFunction(const std::string_view& USR);
CS_IGNORE TypedefDecl* FindTypedef(const std::string& Name, bool Create = false);
CS_IGNORE TypedefDecl* FindTypedef(const std::string_view& Name, bool Create = false);
CS_IGNORE TypeAlias* FindTypeAlias(const std::string& Name, bool Create = false);
CS_IGNORE TypeAlias* FindTypeAlias(const std::string_view& Name, bool Create = false);
CS_IGNORE Variable* FindVariable(const std::string& USR);
CS_IGNORE Variable* FindVariable(const std::string_view& USR);
CS_IGNORE Friend* FindFriend(const std::string& USR);
CS_IGNORE Friend* FindFriend(const std::string_view& USR);
VECTOR(Namespace*, Namespaces)
VECTOR(Enumeration*, Enums)
@ -152,7 +157,7 @@ namespace AST { @@ -152,7 +157,7 @@ namespace AST {
VECTOR(Variable*, Variables)
VECTOR(Friend*, Friends)
std::map<std::string, Declaration*> anonymous;
std::map<std::string, Declaration*, std::less<>> anonymous;
bool isAnonymous;
};
@ -203,7 +208,7 @@ namespace AST { @@ -203,7 +208,7 @@ namespace AST {
class CS_API StatementObsolete
{
public:
StatementObsolete(const std::string& str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration* decl = 0);
StatementObsolete(const std::string& str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration* decl = nullptr);
StatementClassObsolete _class;
Declaration* decl;
std::string string;
@ -212,7 +217,7 @@ namespace AST { @@ -212,7 +217,7 @@ namespace AST {
class CS_API ExpressionObsolete : public StatementObsolete
{
public:
ExpressionObsolete(const std::string& str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration* decl = 0);
ExpressionObsolete(const std::string& str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration* decl = nullptr);
};
class Expr;
@ -238,7 +243,7 @@ namespace AST { @@ -238,7 +243,7 @@ namespace AST {
class CS_API CXXConstructExprObsolete : public ExpressionObsolete
{
public:
CXXConstructExprObsolete(const std::string& str, Declaration* decl = 0);
CXXConstructExprObsolete(const std::string& str, Declaration* decl = nullptr);
~CXXConstructExprObsolete();
VECTOR(ExpressionObsolete*, Arguments)
};
@ -417,7 +422,7 @@ namespace AST { @@ -417,7 +422,7 @@ namespace AST {
BuiltinType* builtinType;
VECTOR(Item*, Items)
Item* FindItemByName(const std::string& Name);
Item* FindItemByName(const std::string_view& Name);
};
class CS_API Variable : public Declaration
@ -611,10 +616,10 @@ namespace AST { @@ -611,10 +616,10 @@ namespace AST {
};
template <typename T>
T* DeclarationContext::FindTemplate(const std::string& USR)
T* DeclarationContext::FindTemplate(const std::string_view& USR)
{
auto foundTemplate = std::find_if(Templates.begin(), Templates.end(),
[&](Template* t)
auto foundTemplate = std::find_if(Templates.cbegin(), Templates.cend(),
[&](const Template* t)
{
return t->USR == USR;
});
@ -782,6 +787,7 @@ namespace AST { @@ -782,6 +787,7 @@ namespace AST {
Namespace();
~Namespace();
bool isInline;
bool isNested;
};
enum class MacroLocation

38
src/CppParser/Parser.cpp

@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
#include <Driver/ToolChains/MSVC.h>
#include "ASTNameMangler.h"
#include "ASTNodeVisitor.h"
#if defined(__APPLE__) || defined(__linux__)
#ifndef _GNU_SOURCE
@ -515,12 +516,6 @@ std::string Parser::GetDeclMangledName(const clang::Decl* D) const @@ -515,12 +516,6 @@ std::string Parser::GetDeclMangledName(const clang::Decl* D) const
if (ND->isTemplated())
return {};
/*bool CanMangle = isa<FunctionDecl>(D) || isa<VarDecl>(D)
|| isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D);
if (!CanMangle)
return {};*/
// FIXME: There are likely other contexts in which it makes no sense to ask
// for a mangled name.
if (isa<RequiresExprBodyDecl>(ND->getDeclContext()))
@ -990,6 +985,8 @@ static clang::CXXRecordDecl* GetCXXRecordDeclFromBaseType(const clang::ASTContex @@ -990,6 +985,8 @@ static clang::CXXRecordDecl* GetCXXRecordDeclFromBaseType(const clang::ASTContex
return dyn_cast<CXXRecordDecl>(RT->getDecl());
else if (auto TST = Ty->getAs<clang::TemplateSpecializationType>())
return GetCXXRecordDeclFromTemplateName(TST->getTemplateName());
else if (auto DTST = Ty->getAs<clang::DependentTemplateSpecializationType>())
return nullptr;
else if (auto Injected = Ty->getAs<clang::InjectedClassNameType>())
return Injected->getDecl();
else if (auto TTPT = Ty->getAs<TemplateTypeParmType>())
@ -2126,8 +2123,8 @@ Field* Parser::WalkFieldCXX(const clang::FieldDecl* FD, Class* Class) @@ -2126,8 +2123,8 @@ Field* Parser::WalkFieldCXX(const clang::FieldDecl* FD, Class* Class)
//-----------------------------------//
TranslationUnit* Parser::GetTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind* Kind)
TranslationUnit* Parser::GetOrCreateTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind* Kind)
{
using namespace clang;
@ -2172,12 +2169,12 @@ TranslationUnit* Parser::GetTranslationUnit(clang::SourceLocation Loc, @@ -2172,12 +2169,12 @@ TranslationUnit* Parser::GetTranslationUnit(clang::SourceLocation Loc,
//-----------------------------------//
TranslationUnit* Parser::GetTranslationUnit(const clang::Decl* D)
TranslationUnit* Parser::GetOrCreateTranslationUnit(const clang::Decl* D)
{
clang::SourceLocation Loc = D->getLocation();
SourceLocationKind Kind;
TranslationUnit* Unit = GetTranslationUnit(Loc, &Kind);
TranslationUnit* Unit = GetOrCreateTranslationUnit(Loc, &Kind);
return Unit;
}
@ -2191,13 +2188,13 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D, @@ -2191,13 +2188,13 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
// If the declaration is at global scope, just early exit.
if (Context->isTranslationUnit())
return GetTranslationUnit(D);
return GetOrCreateTranslationUnit(D);
auto NS = walkedNamespaces[Context];
if (NS)
return NS;
TranslationUnit* Unit = GetTranslationUnit(cast<Decl>(Context));
TranslationUnit* Unit = GetOrCreateTranslationUnit(cast<Decl>(Context));
// Else we need to do a more expensive check to get all the namespaces,
// and then perform a reverse iteration to get the namespaces in order.
@ -2231,8 +2228,7 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D, @@ -2231,8 +2228,7 @@ DeclarationContext* Parser::GetNamespace(const clang::Decl* D,
if (ND->isAnonymousNamespace())
break;
auto Name = ND->getName();
DC = DC->FindCreateNamespace(Name.str());
DC = &DC->FindCreateNamespace(ND->getName());
((Namespace*)DC)->isAnonymous = ND->isAnonymousNamespace();
((Namespace*)DC)->isInline = ND->isInline();
HandleDeclaration(ND, DC);
@ -3890,7 +3886,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity( @@ -3890,7 +3886,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity(
return nullptr;
Entity->originalPtr = PPEntity;
auto Namespace = GetTranslationUnit(PPEntity->getSourceRange().getBegin());
auto Namespace = GetOrCreateTranslationUnit(PPEntity->getSourceRange().getBegin());
if (Decl->kind == DeclarationKind::TranslationUnit)
{
@ -4403,7 +4399,7 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D) @@ -4403,7 +4399,7 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D)
}
case Decl::TranslationUnit:
{
Decl = GetTranslationUnit(D);
Decl = GetOrCreateTranslationUnit(D);
break;
}
case Decl::Namespace:
@ -4677,6 +4673,16 @@ void SemaConsumer::HandleTranslationUnit(clang::ASTContext& Ctx) @@ -4677,6 +4673,16 @@ void SemaConsumer::HandleTranslationUnit(clang::ASTContext& Ctx)
if (Unit->originalPtr == nullptr)
Unit->originalPtr = (void*)FileEntry;
std::string Text;
Text.reserve(200000000);
{
llvm::raw_string_ostream OS(Text);
ASTNodeDumper Dumper(OS, Ctx, Parser);
Dumper.Visit(TU);
debug_break();
}
Parser.WalkAST(TU);
}

12
src/CppParser/Parser.h

@ -97,8 +97,8 @@ namespace CppSharp { namespace CppParser { @@ -97,8 +97,8 @@ namespace CppSharp { namespace CppParser {
void WalkVariable(const clang::VarDecl* VD, AST::Variable* Var);
AST::Friend* WalkFriend(const clang::FriendDecl* FD);
AST::RawComment* WalkRawComment(const clang::RawComment* RC);
AST::Type* WalkType(clang::QualType QualType, const clang::TypeLoc* TL = 0, bool DesugarType = false);
AST::TemplateArgument WalkTemplateArgument(const clang::TemplateArgument& TA, clang::TemplateArgumentLoc* ArgLoc = 0);
AST::Type* WalkType(clang::QualType QualType, const clang::TypeLoc* TL = nullptr, bool DesugarType = false);
AST::TemplateArgument WalkTemplateArgument(const clang::TemplateArgument& TA, clang::TemplateArgumentLoc* ArgLoc = nullptr);
AST::TemplateTemplateParameter* WalkTemplateTemplateParameter(const clang::TemplateTemplateParmDecl* TTP);
AST::TypeTemplateParameter* WalkTypeTemplateParameter(const clang::TemplateTypeParmDecl* TTPD);
AST::NonTypeTemplateParameter* WalkNonTypeTemplateParameter(const clang::NonTypeTemplateParmDecl* TTPD);
@ -116,7 +116,7 @@ namespace CppSharp { namespace CppParser { @@ -116,7 +116,7 @@ namespace CppSharp { namespace CppParser {
std::vector<AST::TemplateArgument> WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, TypeLoc* TSTL);
std::vector<AST::TemplateArgument> WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, const clang::ASTTemplateArgumentListInfo* TSTL);
void WalkVTable(const clang::CXXRecordDecl* RD, AST::Class* C);
AST::QualifiedType GetQualifiedType(clang::QualType qual, const clang::TypeLoc* TL = 0);
AST::QualifiedType GetQualifiedType(clang::QualType qual, const clang::TypeLoc* TL = nullptr);
void ReadClassLayout(AST::Class* Class, const clang::RecordDecl* RD, clang::CharUnits Offset, bool IncludeVirtualBases);
AST::LayoutField WalkVTablePointer(AST::Class* Class, const clang::CharUnits& Offset, const std::string& prefix);
AST::VTableLayout WalkVTableLayout(const clang::VTableLayout& VTLayout);
@ -150,9 +150,9 @@ namespace CppSharp { namespace CppParser { @@ -150,9 +150,9 @@ namespace CppSharp { namespace CppParser {
bool GetDeclText(clang::SourceRange SR, std::string& Text);
bool HasLayout(const clang::RecordDecl* Record);
AST::TranslationUnit* GetTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind* Kind = 0);
AST::TranslationUnit* GetTranslationUnit(const clang::Decl* D);
AST::TranslationUnit* GetOrCreateTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind* Kind = nullptr);
AST::TranslationUnit* GetOrCreateTranslationUnit(const clang::Decl* D);
AST::DeclarationContext* GetNamespace(const clang::Decl* D, const clang::DeclContext* Ctx);
AST::DeclarationContext* GetNamespace(const clang::Decl* D);

2
src/CppParser/ParserGen/ParserGen.cs

@ -28,6 +28,8 @@ namespace CppSharp @@ -28,6 +28,8 @@ namespace CppSharp
Kind = kind;
Triple = triple;
IsGnuCpp11Abi = isGnuCpp11Abi;
Diagnostics.Level = DiagnosticKind.Debug;
}
static string GetSourceDirectory(string dir)

923
src/CppParser/StmtNodes.inc

@ -0,0 +1,923 @@ @@ -0,0 +1,923 @@
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* List of AST nodes of a particular kind *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef ABSTRACT_STMT
# define ABSTRACT_STMT(Type) Type
#endif
#ifndef STMT_RANGE
# define STMT_RANGE(Base, First, Last)
#endif
#ifndef LAST_STMT_RANGE
# define LAST_STMT_RANGE(Base, First, Last) STMT_RANGE(Base, First, Last)
#endif
#ifndef ASMSTMT
# define ASMSTMT(Type, Base) STMT(Type, Base)
#endif
ABSTRACT_STMT(ASMSTMT(AsmStmt, Stmt))
#ifndef GCCASMSTMT
# define GCCASMSTMT(Type, Base) ASMSTMT(Type, Base)
#endif
GCCASMSTMT(GCCAsmStmt, AsmStmt)
#undef GCCASMSTMT
#ifndef MSASMSTMT
# define MSASMSTMT(Type, Base) ASMSTMT(Type, Base)
#endif
MSASMSTMT(MSAsmStmt, AsmStmt)
#undef MSASMSTMT
STMT_RANGE(AsmStmt, GCCAsmStmt, MSAsmStmt)
#undef ASMSTMT
#ifndef BREAKSTMT
# define BREAKSTMT(Type, Base) STMT(Type, Base)
#endif
BREAKSTMT(BreakStmt, Stmt)
#undef BREAKSTMT
#ifndef CXXCATCHSTMT
# define CXXCATCHSTMT(Type, Base) STMT(Type, Base)
#endif
CXXCATCHSTMT(CXXCatchStmt, Stmt)
#undef CXXCATCHSTMT
#ifndef CXXFORRANGESTMT
# define CXXFORRANGESTMT(Type, Base) STMT(Type, Base)
#endif
CXXFORRANGESTMT(CXXForRangeStmt, Stmt)
#undef CXXFORRANGESTMT
#ifndef CXXTRYSTMT
# define CXXTRYSTMT(Type, Base) STMT(Type, Base)
#endif
CXXTRYSTMT(CXXTryStmt, Stmt)
#undef CXXTRYSTMT
#ifndef CAPTUREDSTMT
# define CAPTUREDSTMT(Type, Base) STMT(Type, Base)
#endif
CAPTUREDSTMT(CapturedStmt, Stmt)
#undef CAPTUREDSTMT
#ifndef COMPOUNDSTMT
# define COMPOUNDSTMT(Type, Base) STMT(Type, Base)
#endif
COMPOUNDSTMT(CompoundStmt, Stmt)
#undef COMPOUNDSTMT
#ifndef CONTINUESTMT
# define CONTINUESTMT(Type, Base) STMT(Type, Base)
#endif
CONTINUESTMT(ContinueStmt, Stmt)
#undef CONTINUESTMT
#ifndef CORETURNSTMT
# define CORETURNSTMT(Type, Base) STMT(Type, Base)
#endif
CORETURNSTMT(CoreturnStmt, Stmt)
#undef CORETURNSTMT
#ifndef COROUTINEBODYSTMT
# define COROUTINEBODYSTMT(Type, Base) STMT(Type, Base)
#endif
COROUTINEBODYSTMT(CoroutineBodyStmt, Stmt)
#undef COROUTINEBODYSTMT
#ifndef DECLSTMT
# define DECLSTMT(Type, Base) STMT(Type, Base)
#endif
DECLSTMT(DeclStmt, Stmt)
#undef DECLSTMT
#ifndef DOSTMT
# define DOSTMT(Type, Base) STMT(Type, Base)
#endif
DOSTMT(DoStmt, Stmt)
#undef DOSTMT
#ifndef FORSTMT
# define FORSTMT(Type, Base) STMT(Type, Base)
#endif
FORSTMT(ForStmt, Stmt)
#undef FORSTMT
#ifndef GOTOSTMT
# define GOTOSTMT(Type, Base) STMT(Type, Base)
#endif
GOTOSTMT(GotoStmt, Stmt)
#undef GOTOSTMT
#ifndef IFSTMT
# define IFSTMT(Type, Base) STMT(Type, Base)
#endif
IFSTMT(IfStmt, Stmt)
#undef IFSTMT
#ifndef INDIRECTGOTOSTMT
# define INDIRECTGOTOSTMT(Type, Base) STMT(Type, Base)
#endif
INDIRECTGOTOSTMT(IndirectGotoStmt, Stmt)
#undef INDIRECTGOTOSTMT
#ifndef MSDEPENDENTEXISTSSTMT
# define MSDEPENDENTEXISTSSTMT(Type, Base) STMT(Type, Base)
#endif
MSDEPENDENTEXISTSSTMT(MSDependentExistsStmt, Stmt)
#undef MSDEPENDENTEXISTSSTMT
#ifndef NULLSTMT
# define NULLSTMT(Type, Base) STMT(Type, Base)
#endif
NULLSTMT(NullStmt, Stmt)
#undef NULLSTMT
// Removed OMP nodes
// Removed OBJC nodes
#ifndef RETURNSTMT
# define RETURNSTMT(Type, Base) STMT(Type, Base)
#endif
RETURNSTMT(ReturnStmt, Stmt)
#undef RETURNSTMT
#ifndef SEHEXCEPTSTMT
# define SEHEXCEPTSTMT(Type, Base) STMT(Type, Base)
#endif
SEHEXCEPTSTMT(SEHExceptStmt, Stmt)
#undef SEHEXCEPTSTMT
#ifndef SEHFINALLYSTMT
# define SEHFINALLYSTMT(Type, Base) STMT(Type, Base)
#endif
SEHFINALLYSTMT(SEHFinallyStmt, Stmt)
#undef SEHFINALLYSTMT
#ifndef SEHLEAVESTMT
# define SEHLEAVESTMT(Type, Base) STMT(Type, Base)
#endif
SEHLEAVESTMT(SEHLeaveStmt, Stmt)
#undef SEHLEAVESTMT
#ifndef SEHTRYSTMT
# define SEHTRYSTMT(Type, Base) STMT(Type, Base)
#endif
SEHTRYSTMT(SEHTryStmt, Stmt)
#undef SEHTRYSTMT
#ifndef SWITCHCASE
# define SWITCHCASE(Type, Base) STMT(Type, Base)
#endif
ABSTRACT_STMT(SWITCHCASE(SwitchCase, Stmt))
#ifndef CASESTMT
# define CASESTMT(Type, Base) SWITCHCASE(Type, Base)
#endif
CASESTMT(CaseStmt, SwitchCase)
#undef CASESTMT
#ifndef DEFAULTSTMT
# define DEFAULTSTMT(Type, Base) SWITCHCASE(Type, Base)
#endif
DEFAULTSTMT(DefaultStmt, SwitchCase)
#undef DEFAULTSTMT
STMT_RANGE(SwitchCase, CaseStmt, DefaultStmt)
#undef SWITCHCASE
#ifndef SWITCHSTMT
# define SWITCHSTMT(Type, Base) STMT(Type, Base)
#endif
SWITCHSTMT(SwitchStmt, Stmt)
#undef SWITCHSTMT
#ifndef VALUESTMT
# define VALUESTMT(Type, Base) STMT(Type, Base)
#endif
ABSTRACT_STMT(VALUESTMT(ValueStmt, Stmt))
#ifndef ATTRIBUTEDSTMT
# define ATTRIBUTEDSTMT(Type, Base) VALUESTMT(Type, Base)
#endif
ATTRIBUTEDSTMT(AttributedStmt, ValueStmt)
#undef ATTRIBUTEDSTMT
#ifndef EXPR
# define EXPR(Type, Base) VALUESTMT(Type, Base)
#endif
ABSTRACT_STMT(EXPR(Expr, ValueStmt))
#ifndef ABSTRACTCONDITIONALOPERATOR
# define ABSTRACTCONDITIONALOPERATOR(Type, Base) EXPR(Type, Base)
#endif
ABSTRACT_STMT(ABSTRACTCONDITIONALOPERATOR(AbstractConditionalOperator, Expr))
#ifndef BINARYCONDITIONALOPERATOR
# define BINARYCONDITIONALOPERATOR(Type, Base) ABSTRACTCONDITIONALOPERATOR(Type, Base)
#endif
BINARYCONDITIONALOPERATOR(BinaryConditionalOperator, AbstractConditionalOperator)
#undef BINARYCONDITIONALOPERATOR
#ifndef CONDITIONALOPERATOR
# define CONDITIONALOPERATOR(Type, Base) ABSTRACTCONDITIONALOPERATOR(Type, Base)
#endif
CONDITIONALOPERATOR(ConditionalOperator, AbstractConditionalOperator)
#undef CONDITIONALOPERATOR
STMT_RANGE(AbstractConditionalOperator, BinaryConditionalOperator, ConditionalOperator)
#undef ABSTRACTCONDITIONALOPERATOR
#ifndef ADDRLABELEXPR
# define ADDRLABELEXPR(Type, Base) EXPR(Type, Base)
#endif
ADDRLABELEXPR(AddrLabelExpr, Expr)
#undef ADDRLABELEXPR
#ifndef ARRAYINITINDEXEXPR
# define ARRAYINITINDEXEXPR(Type, Base) EXPR(Type, Base)
#endif
ARRAYINITINDEXEXPR(ArrayInitIndexExpr, Expr)
#undef ARRAYINITINDEXEXPR
#ifndef ARRAYINITLOOPEXPR
# define ARRAYINITLOOPEXPR(Type, Base) EXPR(Type, Base)
#endif
ARRAYINITLOOPEXPR(ArrayInitLoopExpr, Expr)
#undef ARRAYINITLOOPEXPR
#ifndef ARRAYSUBSCRIPTEXPR
# define ARRAYSUBSCRIPTEXPR(Type, Base) EXPR(Type, Base)
#endif
ARRAYSUBSCRIPTEXPR(ArraySubscriptExpr, Expr)
#undef ARRAYSUBSCRIPTEXPR
#ifndef ARRAYTYPETRAITEXPR
# define ARRAYTYPETRAITEXPR(Type, Base) EXPR(Type, Base)
#endif
ARRAYTYPETRAITEXPR(ArrayTypeTraitExpr, Expr)
#undef ARRAYTYPETRAITEXPR
#ifndef ASTYPEEXPR
# define ASTYPEEXPR(Type, Base) EXPR(Type, Base)
#endif
ASTYPEEXPR(AsTypeExpr, Expr)
#undef ASTYPEEXPR
#ifndef ATOMICEXPR
# define ATOMICEXPR(Type, Base) EXPR(Type, Base)
#endif
ATOMICEXPR(AtomicExpr, Expr)
#undef ATOMICEXPR
#ifndef BINARYOPERATOR
# define BINARYOPERATOR(Type, Base) EXPR(Type, Base)
#endif
BINARYOPERATOR(BinaryOperator, Expr)
#ifndef COMPOUNDASSIGNOPERATOR
# define COMPOUNDASSIGNOPERATOR(Type, Base) BINARYOPERATOR(Type, Base)
#endif
COMPOUNDASSIGNOPERATOR(CompoundAssignOperator, BinaryOperator)
#undef COMPOUNDASSIGNOPERATOR
STMT_RANGE(BinaryOperator, BinaryOperator, CompoundAssignOperator)
#undef BINARYOPERATOR
#ifndef BLOCKEXPR
# define BLOCKEXPR(Type, Base) EXPR(Type, Base)
#endif
BLOCKEXPR(BlockExpr, Expr)
#undef BLOCKEXPR
#ifndef CXXBINDTEMPORARYEXPR
# define CXXBINDTEMPORARYEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXBINDTEMPORARYEXPR(CXXBindTemporaryExpr, Expr)
#undef CXXBINDTEMPORARYEXPR
#ifndef CXXBOOLLITERALEXPR
# define CXXBOOLLITERALEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXBOOLLITERALEXPR(CXXBoolLiteralExpr, Expr)
#undef CXXBOOLLITERALEXPR
#ifndef CXXCONSTRUCTEXPR
# define CXXCONSTRUCTEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXCONSTRUCTEXPR(CXXConstructExpr, Expr)
#ifndef CXXTEMPORARYOBJECTEXPR
# define CXXTEMPORARYOBJECTEXPR(Type, Base) CXXCONSTRUCTEXPR(Type, Base)
#endif
CXXTEMPORARYOBJECTEXPR(CXXTemporaryObjectExpr, CXXConstructExpr)
#undef CXXTEMPORARYOBJECTEXPR
STMT_RANGE(CXXConstructExpr, CXXConstructExpr, CXXTemporaryObjectExpr)
#undef CXXCONSTRUCTEXPR
#ifndef CXXDEFAULTARGEXPR
# define CXXDEFAULTARGEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXDEFAULTARGEXPR(CXXDefaultArgExpr, Expr)
#undef CXXDEFAULTARGEXPR
#ifndef CXXDEFAULTINITEXPR
# define CXXDEFAULTINITEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXDEFAULTINITEXPR(CXXDefaultInitExpr, Expr)
#undef CXXDEFAULTINITEXPR
#ifndef CXXDELETEEXPR
# define CXXDELETEEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXDELETEEXPR(CXXDeleteExpr, Expr)
#undef CXXDELETEEXPR
#ifndef CXXDEPENDENTSCOPEMEMBEREXPR
# define CXXDEPENDENTSCOPEMEMBEREXPR(Type, Base) EXPR(Type, Base)
#endif
CXXDEPENDENTSCOPEMEMBEREXPR(CXXDependentScopeMemberExpr, Expr)
#undef CXXDEPENDENTSCOPEMEMBEREXPR
#ifndef CXXFOLDEXPR
# define CXXFOLDEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXFOLDEXPR(CXXFoldExpr, Expr)
#undef CXXFOLDEXPR
#ifndef CXXINHERITEDCTORINITEXPR
# define CXXINHERITEDCTORINITEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXINHERITEDCTORINITEXPR(CXXInheritedCtorInitExpr, Expr)
#undef CXXINHERITEDCTORINITEXPR
#ifndef CXXNEWEXPR
# define CXXNEWEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXNEWEXPR(CXXNewExpr, Expr)
#undef CXXNEWEXPR
#ifndef CXXNOEXCEPTEXPR
# define CXXNOEXCEPTEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXNOEXCEPTEXPR(CXXNoexceptExpr, Expr)
#undef CXXNOEXCEPTEXPR
#ifndef CXXNULLPTRLITERALEXPR
# define CXXNULLPTRLITERALEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXNULLPTRLITERALEXPR(CXXNullPtrLiteralExpr, Expr)
#undef CXXNULLPTRLITERALEXPR
#ifndef CXXPARENLISTINITEXPR
# define CXXPARENLISTINITEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXPARENLISTINITEXPR(CXXParenListInitExpr, Expr)
#undef CXXPARENLISTINITEXPR
#ifndef CXXPSEUDODESTRUCTOREXPR
# define CXXPSEUDODESTRUCTOREXPR(Type, Base) EXPR(Type, Base)
#endif
CXXPSEUDODESTRUCTOREXPR(CXXPseudoDestructorExpr, Expr)
#undef CXXPSEUDODESTRUCTOREXPR
#ifndef CXXREWRITTENBINARYOPERATOR
# define CXXREWRITTENBINARYOPERATOR(Type, Base) EXPR(Type, Base)
#endif
CXXREWRITTENBINARYOPERATOR(CXXRewrittenBinaryOperator, Expr)
#undef CXXREWRITTENBINARYOPERATOR
#ifndef CXXSCALARVALUEINITEXPR
# define CXXSCALARVALUEINITEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXSCALARVALUEINITEXPR(CXXScalarValueInitExpr, Expr)
#undef CXXSCALARVALUEINITEXPR
#ifndef CXXSTDINITIALIZERLISTEXPR
# define CXXSTDINITIALIZERLISTEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXSTDINITIALIZERLISTEXPR(CXXStdInitializerListExpr, Expr)
#undef CXXSTDINITIALIZERLISTEXPR
#ifndef CXXTHISEXPR
# define CXXTHISEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXTHISEXPR(CXXThisExpr, Expr)
#undef CXXTHISEXPR
#ifndef CXXTHROWEXPR
# define CXXTHROWEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXTHROWEXPR(CXXThrowExpr, Expr)
#undef CXXTHROWEXPR
#ifndef CXXTYPEIDEXPR
# define CXXTYPEIDEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXTYPEIDEXPR(CXXTypeidExpr, Expr)
#undef CXXTYPEIDEXPR
#ifndef CXXUNRESOLVEDCONSTRUCTEXPR
# define CXXUNRESOLVEDCONSTRUCTEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXUNRESOLVEDCONSTRUCTEXPR(CXXUnresolvedConstructExpr, Expr)
#undef CXXUNRESOLVEDCONSTRUCTEXPR
#ifndef CXXUUIDOFEXPR
# define CXXUUIDOFEXPR(Type, Base) EXPR(Type, Base)
#endif
CXXUUIDOFEXPR(CXXUuidofExpr, Expr)
#undef CXXUUIDOFEXPR
#ifndef CALLEXPR
# define CALLEXPR(Type, Base) EXPR(Type, Base)
#endif
CALLEXPR(CallExpr, Expr)
#ifndef CUDAKERNELCALLEXPR
# define CUDAKERNELCALLEXPR(Type, Base) CALLEXPR(Type, Base)
#endif
CUDAKERNELCALLEXPR(CUDAKernelCallExpr, CallExpr)
#undef CUDAKERNELCALLEXPR
#ifndef CXXMEMBERCALLEXPR
# define CXXMEMBERCALLEXPR(Type, Base) CALLEXPR(Type, Base)
#endif
CXXMEMBERCALLEXPR(CXXMemberCallExpr, CallExpr)
#undef CXXMEMBERCALLEXPR
#ifndef CXXOPERATORCALLEXPR
# define CXXOPERATORCALLEXPR(Type, Base) CALLEXPR(Type, Base)
#endif
CXXOPERATORCALLEXPR(CXXOperatorCallExpr, CallExpr)
#undef CXXOPERATORCALLEXPR
#ifndef USERDEFINEDLITERAL
# define USERDEFINEDLITERAL(Type, Base) CALLEXPR(Type, Base)
#endif
USERDEFINEDLITERAL(UserDefinedLiteral, CallExpr)
#undef USERDEFINEDLITERAL
STMT_RANGE(CallExpr, CallExpr, UserDefinedLiteral)
#undef CALLEXPR
#ifndef CASTEXPR
# define CASTEXPR(Type, Base) EXPR(Type, Base)
#endif
ABSTRACT_STMT(CASTEXPR(CastExpr, Expr))
#ifndef EXPLICITCASTEXPR
# define EXPLICITCASTEXPR(Type, Base) CASTEXPR(Type, Base)
#endif
ABSTRACT_STMT(EXPLICITCASTEXPR(ExplicitCastExpr, CastExpr))
#ifndef BUILTINBITCASTEXPR
# define BUILTINBITCASTEXPR(Type, Base) EXPLICITCASTEXPR(Type, Base)
#endif
BUILTINBITCASTEXPR(BuiltinBitCastExpr, ExplicitCastExpr)
#undef BUILTINBITCASTEXPR
#ifndef CSTYLECASTEXPR
# define CSTYLECASTEXPR(Type, Base) EXPLICITCASTEXPR(Type, Base)
#endif
CSTYLECASTEXPR(CStyleCastExpr, ExplicitCastExpr)
#undef CSTYLECASTEXPR
#ifndef CXXFUNCTIONALCASTEXPR
# define CXXFUNCTIONALCASTEXPR(Type, Base) EXPLICITCASTEXPR(Type, Base)
#endif
CXXFUNCTIONALCASTEXPR(CXXFunctionalCastExpr, ExplicitCastExpr)
#undef CXXFUNCTIONALCASTEXPR
#ifndef CXXNAMEDCASTEXPR
# define CXXNAMEDCASTEXPR(Type, Base) EXPLICITCASTEXPR(Type, Base)
#endif
ABSTRACT_STMT(CXXNAMEDCASTEXPR(CXXNamedCastExpr, ExplicitCastExpr))
#ifndef CXXADDRSPACECASTEXPR
# define CXXADDRSPACECASTEXPR(Type, Base) CXXNAMEDCASTEXPR(Type, Base)
#endif
CXXADDRSPACECASTEXPR(CXXAddrspaceCastExpr, CXXNamedCastExpr)
#undef CXXADDRSPACECASTEXPR
#ifndef CXXCONSTCASTEXPR
# define CXXCONSTCASTEXPR(Type, Base) CXXNAMEDCASTEXPR(Type, Base)
#endif
CXXCONSTCASTEXPR(CXXConstCastExpr, CXXNamedCastExpr)
#undef CXXCONSTCASTEXPR
#ifndef CXXDYNAMICCASTEXPR
# define CXXDYNAMICCASTEXPR(Type, Base) CXXNAMEDCASTEXPR(Type, Base)
#endif
CXXDYNAMICCASTEXPR(CXXDynamicCastExpr, CXXNamedCastExpr)
#undef CXXDYNAMICCASTEXPR
#ifndef CXXREINTERPRETCASTEXPR
# define CXXREINTERPRETCASTEXPR(Type, Base) CXXNAMEDCASTEXPR(Type, Base)
#endif
CXXREINTERPRETCASTEXPR(CXXReinterpretCastExpr, CXXNamedCastExpr)
#undef CXXREINTERPRETCASTEXPR
#ifndef CXXSTATICCASTEXPR
# define CXXSTATICCASTEXPR(Type, Base) CXXNAMEDCASTEXPR(Type, Base)
#endif
CXXSTATICCASTEXPR(CXXStaticCastExpr, CXXNamedCastExpr)
#undef CXXSTATICCASTEXPR
STMT_RANGE(CXXNamedCastExpr, CXXAddrspaceCastExpr, CXXStaticCastExpr)
#undef CXXNAMEDCASTEXPR
STMT_RANGE(ExplicitCastExpr, BuiltinBitCastExpr, ObjCBridgedCastExpr)
#undef EXPLICITCASTEXPR
#ifndef IMPLICITCASTEXPR
# define IMPLICITCASTEXPR(Type, Base) CASTEXPR(Type, Base)
#endif
IMPLICITCASTEXPR(ImplicitCastExpr, CastExpr)
#undef IMPLICITCASTEXPR
STMT_RANGE(CastExpr, BuiltinBitCastExpr, ImplicitCastExpr)
#undef CASTEXPR
#ifndef CHARACTERLITERAL
# define CHARACTERLITERAL(Type, Base) EXPR(Type, Base)
#endif
CHARACTERLITERAL(CharacterLiteral, Expr)
#undef CHARACTERLITERAL
#ifndef CHOOSEEXPR
# define CHOOSEEXPR(Type, Base) EXPR(Type, Base)
#endif
CHOOSEEXPR(ChooseExpr, Expr)
#undef CHOOSEEXPR
#ifndef COMPOUNDLITERALEXPR
# define COMPOUNDLITERALEXPR(Type, Base) EXPR(Type, Base)
#endif
COMPOUNDLITERALEXPR(CompoundLiteralExpr, Expr)
#undef COMPOUNDLITERALEXPR
#ifndef CONVERTVECTOREXPR
# define CONVERTVECTOREXPR(Type, Base) EXPR(Type, Base)
#endif
CONVERTVECTOREXPR(ConvertVectorExpr, Expr)
#undef CONVERTVECTOREXPR
#ifndef COROUTINESUSPENDEXPR
# define COROUTINESUSPENDEXPR(Type, Base) EXPR(Type, Base)
#endif
ABSTRACT_STMT(COROUTINESUSPENDEXPR(CoroutineSuspendExpr, Expr))
#ifndef COAWAITEXPR
# define COAWAITEXPR(Type, Base) COROUTINESUSPENDEXPR(Type, Base)
#endif
COAWAITEXPR(CoawaitExpr, CoroutineSuspendExpr)
#undef COAWAITEXPR
#ifndef COYIELDEXPR
# define COYIELDEXPR(Type, Base) COROUTINESUSPENDEXPR(Type, Base)
#endif
COYIELDEXPR(CoyieldExpr, CoroutineSuspendExpr)
#undef COYIELDEXPR
STMT_RANGE(CoroutineSuspendExpr, CoawaitExpr, CoyieldExpr)
#undef COROUTINESUSPENDEXPR
#ifndef DECLREFEXPR
# define DECLREFEXPR(Type, Base) EXPR(Type, Base)
#endif
DECLREFEXPR(DeclRefExpr, Expr)
#undef DECLREFEXPR
#ifndef DEPENDENTCOAWAITEXPR
# define DEPENDENTCOAWAITEXPR(Type, Base) EXPR(Type, Base)
#endif
DEPENDENTCOAWAITEXPR(DependentCoawaitExpr, Expr)
#undef DEPENDENTCOAWAITEXPR
#ifndef DEPENDENTSCOPEDECLREFEXPR
# define DEPENDENTSCOPEDECLREFEXPR(Type, Base) EXPR(Type, Base)
#endif
DEPENDENTSCOPEDECLREFEXPR(DependentScopeDeclRefExpr, Expr)
#undef DEPENDENTSCOPEDECLREFEXPR
#ifndef DESIGNATEDINITEXPR
# define DESIGNATEDINITEXPR(Type, Base) EXPR(Type, Base)
#endif
DESIGNATEDINITEXPR(DesignatedInitExpr, Expr)
#undef DESIGNATEDINITEXPR
#ifndef DESIGNATEDINITUPDATEEXPR
# define DESIGNATEDINITUPDATEEXPR(Type, Base) EXPR(Type, Base)
#endif
DESIGNATEDINITUPDATEEXPR(DesignatedInitUpdateExpr, Expr)
#undef DESIGNATEDINITUPDATEEXPR
#ifndef EXPRESSIONTRAITEXPR
# define EXPRESSIONTRAITEXPR(Type, Base) EXPR(Type, Base)
#endif
EXPRESSIONTRAITEXPR(ExpressionTraitExpr, Expr)
#undef EXPRESSIONTRAITEXPR
#ifndef EXTVECTORELEMENTEXPR
# define EXTVECTORELEMENTEXPR(Type, Base) EXPR(Type, Base)
#endif
EXTVECTORELEMENTEXPR(ExtVectorElementExpr, Expr)
#undef EXTVECTORELEMENTEXPR
#ifndef FIXEDPOINTLITERAL
# define FIXEDPOINTLITERAL(Type, Base) EXPR(Type, Base)
#endif
FIXEDPOINTLITERAL(FixedPointLiteral, Expr)
#undef FIXEDPOINTLITERAL
#ifndef FLOATINGLITERAL
# define FLOATINGLITERAL(Type, Base) EXPR(Type, Base)
#endif
FLOATINGLITERAL(FloatingLiteral, Expr)
#undef FLOATINGLITERAL
#ifndef FULLEXPR
# define FULLEXPR(Type, Base) EXPR(Type, Base)
#endif
ABSTRACT_STMT(FULLEXPR(FullExpr, Expr))
#ifndef CONSTANTEXPR
# define CONSTANTEXPR(Type, Base) FULLEXPR(Type, Base)
#endif
CONSTANTEXPR(ConstantExpr, FullExpr)
#undef CONSTANTEXPR
#ifndef EXPRWITHCLEANUPS
# define EXPRWITHCLEANUPS(Type, Base) FULLEXPR(Type, Base)
#endif
EXPRWITHCLEANUPS(ExprWithCleanups, FullExpr)
#undef EXPRWITHCLEANUPS
STMT_RANGE(FullExpr, ConstantExpr, ExprWithCleanups)
#undef FULLEXPR
#ifndef FUNCTIONPARMPACKEXPR
# define FUNCTIONPARMPACKEXPR(Type, Base) EXPR(Type, Base)
#endif
FUNCTIONPARMPACKEXPR(FunctionParmPackExpr, Expr)
#undef FUNCTIONPARMPACKEXPR
#ifndef GNUNULLEXPR
# define GNUNULLEXPR(Type, Base) EXPR(Type, Base)
#endif
GNUNULLEXPR(GNUNullExpr, Expr)
#undef GNUNULLEXPR
#ifndef GENERICSELECTIONEXPR
# define GENERICSELECTIONEXPR(Type, Base) EXPR(Type, Base)
#endif
GENERICSELECTIONEXPR(GenericSelectionExpr, Expr)
#undef GENERICSELECTIONEXPR
#ifndef IMAGINARYLITERAL
# define IMAGINARYLITERAL(Type, Base) EXPR(Type, Base)
#endif
IMAGINARYLITERAL(ImaginaryLiteral, Expr)
#undef IMAGINARYLITERAL
#ifndef IMPLICITVALUEINITEXPR
# define IMPLICITVALUEINITEXPR(Type, Base) EXPR(Type, Base)
#endif
IMPLICITVALUEINITEXPR(ImplicitValueInitExpr, Expr)
#undef IMPLICITVALUEINITEXPR
#ifndef INITLISTEXPR
# define INITLISTEXPR(Type, Base) EXPR(Type, Base)
#endif
INITLISTEXPR(InitListExpr, Expr)
#undef INITLISTEXPR
#ifndef INTEGERLITERAL
# define INTEGERLITERAL(Type, Base) EXPR(Type, Base)
#endif
INTEGERLITERAL(IntegerLiteral, Expr)
#undef INTEGERLITERAL
#ifndef LAMBDAEXPR
# define LAMBDAEXPR(Type, Base) EXPR(Type, Base)
#endif
LAMBDAEXPR(LambdaExpr, Expr)
#undef LAMBDAEXPR
#ifndef MSPROPERTYREFEXPR
# define MSPROPERTYREFEXPR(Type, Base) EXPR(Type, Base)
#endif
MSPROPERTYREFEXPR(MSPropertyRefExpr, Expr)
#undef MSPROPERTYREFEXPR
#ifndef MSPROPERTYSUBSCRIPTEXPR
# define MSPROPERTYSUBSCRIPTEXPR(Type, Base) EXPR(Type, Base)
#endif
MSPROPERTYSUBSCRIPTEXPR(MSPropertySubscriptExpr, Expr)
#undef MSPROPERTYSUBSCRIPTEXPR
#ifndef MATERIALIZETEMPORARYEXPR
# define MATERIALIZETEMPORARYEXPR(Type, Base) EXPR(Type, Base)
#endif
MATERIALIZETEMPORARYEXPR(MaterializeTemporaryExpr, Expr)
#undef MATERIALIZETEMPORARYEXPR
#ifndef MATRIXSUBSCRIPTEXPR
# define MATRIXSUBSCRIPTEXPR(Type, Base) EXPR(Type, Base)
#endif
MATRIXSUBSCRIPTEXPR(MatrixSubscriptExpr, Expr)
#undef MATRIXSUBSCRIPTEXPR
#ifndef MEMBEREXPR
# define MEMBEREXPR(Type, Base) EXPR(Type, Base)
#endif
MEMBEREXPR(MemberExpr, Expr)
#undef MEMBEREXPR
#ifndef NOINITEXPR
# define NOINITEXPR(Type, Base) EXPR(Type, Base)
#endif
NOINITEXPR(NoInitExpr, Expr)
#undef NOINITEXPR
// Removed OMP nodes
// Removed OBJC nodes
#ifndef OFFSETOFEXPR
# define OFFSETOFEXPR(Type, Base) EXPR(Type, Base)
#endif
OFFSETOFEXPR(OffsetOfExpr, Expr)
#undef OFFSETOFEXPR
#ifndef OPAQUEVALUEEXPR
# define OPAQUEVALUEEXPR(Type, Base) EXPR(Type, Base)
#endif
OPAQUEVALUEEXPR(OpaqueValueExpr, Expr)
#undef OPAQUEVALUEEXPR
#ifndef OVERLOADEXPR
# define OVERLOADEXPR(Type, Base) EXPR(Type, Base)
#endif
ABSTRACT_STMT(OVERLOADEXPR(OverloadExpr, Expr))
#ifndef UNRESOLVEDLOOKUPEXPR
# define UNRESOLVEDLOOKUPEXPR(Type, Base) OVERLOADEXPR(Type, Base)
#endif
UNRESOLVEDLOOKUPEXPR(UnresolvedLookupExpr, OverloadExpr)
#undef UNRESOLVEDLOOKUPEXPR
#ifndef UNRESOLVEDMEMBEREXPR
# define UNRESOLVEDMEMBEREXPR(Type, Base) OVERLOADEXPR(Type, Base)
#endif
UNRESOLVEDMEMBEREXPR(UnresolvedMemberExpr, OverloadExpr)
#undef UNRESOLVEDMEMBEREXPR
STMT_RANGE(OverloadExpr, UnresolvedLookupExpr, UnresolvedMemberExpr)
#undef OVERLOADEXPR
#ifndef PACKEXPANSIONEXPR
# define PACKEXPANSIONEXPR(Type, Base) EXPR(Type, Base)
#endif
PACKEXPANSIONEXPR(PackExpansionExpr, Expr)
#undef PACKEXPANSIONEXPR
#ifndef PARENEXPR
# define PARENEXPR(Type, Base) EXPR(Type, Base)
#endif
PARENEXPR(ParenExpr, Expr)
#undef PARENEXPR
#ifndef PARENLISTEXPR
# define PARENLISTEXPR(Type, Base) EXPR(Type, Base)
#endif
PARENLISTEXPR(ParenListExpr, Expr)
#undef PARENLISTEXPR
#ifndef PREDEFINEDEXPR
# define PREDEFINEDEXPR(Type, Base) EXPR(Type, Base)
#endif
PREDEFINEDEXPR(PredefinedExpr, Expr)
#undef PREDEFINEDEXPR
#ifndef PSEUDOOBJECTEXPR
# define PSEUDOOBJECTEXPR(Type, Base) EXPR(Type, Base)
#endif
PSEUDOOBJECTEXPR(PseudoObjectExpr, Expr)
#undef PSEUDOOBJECTEXPR
#ifndef RECOVERYEXPR
# define RECOVERYEXPR(Type, Base) EXPR(Type, Base)
#endif
RECOVERYEXPR(RecoveryExpr, Expr)
#undef RECOVERYEXPR
#ifndef SYCLUNIQUESTABLENAMEEXPR
# define SYCLUNIQUESTABLENAMEEXPR(Type, Base) EXPR(Type, Base)
#endif
SYCLUNIQUESTABLENAMEEXPR(SYCLUniqueStableNameExpr, Expr)
#undef SYCLUNIQUESTABLENAMEEXPR
#ifndef SHUFFLEVECTOREXPR
# define SHUFFLEVECTOREXPR(Type, Base) EXPR(Type, Base)
#endif
SHUFFLEVECTOREXPR(ShuffleVectorExpr, Expr)
#undef SHUFFLEVECTOREXPR
#ifndef SIZEOFPACKEXPR
# define SIZEOFPACKEXPR(Type, Base) EXPR(Type, Base)
#endif
SIZEOFPACKEXPR(SizeOfPackExpr, Expr)
#undef SIZEOFPACKEXPR
#ifndef SOURCELOCEXPR
# define SOURCELOCEXPR(Type, Base) EXPR(Type, Base)
#endif
SOURCELOCEXPR(SourceLocExpr, Expr)
#undef SOURCELOCEXPR
#ifndef STMTEXPR
# define STMTEXPR(Type, Base) EXPR(Type, Base)
#endif
STMTEXPR(StmtExpr, Expr)
#undef STMTEXPR
#ifndef STRINGLITERAL
# define STRINGLITERAL(Type, Base) EXPR(Type, Base)
#endif
STRINGLITERAL(StringLiteral, Expr)
#undef STRINGLITERAL
#ifndef SUBSTNONTYPETEMPLATEPARMEXPR
# define SUBSTNONTYPETEMPLATEPARMEXPR(Type, Base) EXPR(Type, Base)
#endif
SUBSTNONTYPETEMPLATEPARMEXPR(SubstNonTypeTemplateParmExpr, Expr)
#undef SUBSTNONTYPETEMPLATEPARMEXPR
#ifndef SUBSTNONTYPETEMPLATEPARMPACKEXPR
# define SUBSTNONTYPETEMPLATEPARMPACKEXPR(Type, Base) EXPR(Type, Base)
#endif
SUBSTNONTYPETEMPLATEPARMPACKEXPR(SubstNonTypeTemplateParmPackExpr, Expr)
#undef SUBSTNONTYPETEMPLATEPARMPACKEXPR
#ifndef TYPETRAITEXPR
# define TYPETRAITEXPR(Type, Base) EXPR(Type, Base)
#endif
TYPETRAITEXPR(TypeTraitExpr, Expr)
#undef TYPETRAITEXPR
#ifndef TYPOEXPR
# define TYPOEXPR(Type, Base) EXPR(Type, Base)
#endif
TYPOEXPR(TypoExpr, Expr)
#undef TYPOEXPR
#ifndef UNARYEXPRORTYPETRAITEXPR
# define UNARYEXPRORTYPETRAITEXPR(Type, Base) EXPR(Type, Base)
#endif
UNARYEXPRORTYPETRAITEXPR(UnaryExprOrTypeTraitExpr, Expr)
#undef UNARYEXPRORTYPETRAITEXPR
#ifndef UNARYOPERATOR
# define UNARYOPERATOR(Type, Base) EXPR(Type, Base)
#endif
UNARYOPERATOR(UnaryOperator, Expr)
#undef UNARYOPERATOR
#ifndef VAARGEXPR
# define VAARGEXPR(Type, Base) EXPR(Type, Base)
#endif
VAARGEXPR(VAArgExpr, Expr)
#undef VAARGEXPR
STMT_RANGE(Expr, BinaryConditionalOperator, VAArgExpr)
#undef EXPR
#ifndef LABELSTMT
# define LABELSTMT(Type, Base) VALUESTMT(Type, Base)
#endif
LABELSTMT(LabelStmt, ValueStmt)
#undef LABELSTMT
STMT_RANGE(ValueStmt, AttributedStmt, LabelStmt)
#undef VALUESTMT
#ifndef WHILESTMT
# define WHILESTMT(Type, Base) STMT(Type, Base)
#endif
WHILESTMT(WhileStmt, Stmt)
#undef WHILESTMT
LAST_STMT_RANGE(Stmt, GCCAsmStmt, WhileStmt)
#undef STMT
#undef STMT_RANGE
#undef LAST_STMT_RANGE
#undef ABSTRACT_STMT

618
src/CppParser/Types.h

@ -9,324 +9,326 @@ @@ -9,324 +9,326 @@
#include "Helpers.h"
namespace CppSharp { namespace CppParser { namespace AST {
enum class TypeKind
{
Tag,
Array,
Function,
Pointer,
MemberPointer,
Typedef,
Attributed,
Decayed,
TemplateSpecialization,
DependentTemplateSpecialization,
TemplateParameter,
TemplateParameterSubstitution,
InjectedClassName,
DependentName,
PackExpansion,
Builtin,
UnaryTransform,
UnresolvedUsing,
Vector
};
namespace CppSharp::CppParser::AST {
enum class TypeKind
{
Tag,
Array,
Function,
Pointer,
MemberPointer,
Typedef,
Attributed,
Decayed,
TemplateSpecialization,
DependentTemplateSpecialization,
TemplateParameter,
TemplateParameterSubstitution,
InjectedClassName,
DependentName,
PackExpansion,
Builtin,
UnaryTransform,
UnresolvedUsing,
Vector
};
#define DECLARE_TYPE_KIND(kind) \
kind##Type();
class CS_API Type
{
public:
Type(TypeKind kind);
Type(const Type&);
TypeKind kind;
bool isDependent;
};
struct CS_API TypeQualifiers
{
bool isConst;
bool isVolatile;
bool isRestrict;
};
struct CS_API QualifiedType
{
QualifiedType();
Type* type;
TypeQualifiers qualifiers;
};
class Declaration;
class CS_API TagType : public Type
{
public:
DECLARE_TYPE_KIND(Tag)
Declaration* declaration;
};
class CS_API ArrayType : public Type
{
public:
enum class ArraySize
{
Constant,
Variable,
Dependent,
Incomplete
};
DECLARE_TYPE_KIND(Array)
QualifiedType qualifiedType;
ArraySize sizeType;
long size;
long elementSize;
};
class Parameter;
enum class CallingConvention
{
Default,
C,
StdCall,
ThisCall,
FastCall,
Unknown
};
enum class ExceptionSpecType
class CS_API Type
{
public:
Type(TypeKind kind);
Type(const Type&);
TypeKind kind;
bool isDependent = false;
};
struct CS_API TypeQualifiers
{
bool isConst = false;
bool isVolatile = false;
bool isRestrict = false;
};
struct CS_API QualifiedType
{
QualifiedType();
Type* type = nullptr;
Type* desugaredType = nullptr;
void* typeAliasDeclId = nullptr;
TypeQualifiers qualifiers;
};
class Declaration;
class CS_API TagType : public Type
{
public:
DECLARE_TYPE_KIND(Tag)
Declaration* declaration;
};
class CS_API ArrayType : public Type
{
public:
enum class ArraySize
{
None,
DynamicNone,
Dynamic,
MSAny,
BasicNoexcept,
DependentNoexcept,
NoexceptFalse,
NoexceptTrue,
Unevaluated,
Uninstantiated,
Unparsed
Constant,
Variable,
Dependent,
Incomplete
};
class CS_API FunctionType : public Type
DECLARE_TYPE_KIND(Array)
QualifiedType qualifiedType;
ArraySize sizeType;
long size;
long elementSize;
};
class Parameter;
enum class CallingConvention
{
Default,
C,
StdCall,
ThisCall,
FastCall,
Unknown
};
enum class ExceptionSpecType
{
None,
DynamicNone,
Dynamic,
MSAny,
BasicNoexcept,
DependentNoexcept,
NoexceptFalse,
NoexceptTrue,
Unevaluated,
Uninstantiated,
Unparsed
};
class CS_API FunctionType : public Type
{
public:
DECLARE_TYPE_KIND(Function)
~FunctionType();
QualifiedType returnType;
CallingConvention callingConvention;
ExceptionSpecType exceptionSpecType;
VECTOR(Parameter*, Parameters)
};
class CS_API PointerType : public Type
{
public:
enum struct TypeModifier
{
public:
DECLARE_TYPE_KIND(Function)
~FunctionType();
QualifiedType returnType;
CallingConvention callingConvention;
ExceptionSpecType exceptionSpecType;
VECTOR(Parameter*, Parameters)
};
class CS_API PointerType : public Type
{
public:
enum struct TypeModifier
{
Value,
Pointer,
LVReference,
RVReference
};
DECLARE_TYPE_KIND(Pointer)
QualifiedType qualifiedPointee;
TypeModifier modifier;
};
class CS_API MemberPointerType : public Type
{
public:
DECLARE_TYPE_KIND(MemberPointer)
QualifiedType pointee;
};
class TypedefNameDecl;
class CS_API TypedefType : public Type
{
public:
TypedefType();
TypedefNameDecl* declaration;
};
class CS_API AttributedType : public Type
{
public:
DECLARE_TYPE_KIND(Attributed)
QualifiedType modified;
QualifiedType equivalent;
};
class CS_API DecayedType : public Type
{
public:
DECLARE_TYPE_KIND(Decayed)
QualifiedType decayed;
QualifiedType original;
QualifiedType pointee;
};
struct CS_API TemplateArgument
{
TemplateArgument();
enum struct ArgumentKind
{
Type,
Declaration,
NullPtr,
Integral,
Template,
TemplateExpansion,
Expression,
Pack
};
ArgumentKind kind;
QualifiedType type;
Declaration* declaration;
long integral;
};
class Template;
class CS_API TemplateSpecializationType : public Type
{
public:
TemplateSpecializationType();
TemplateSpecializationType(const TemplateSpecializationType&);
~TemplateSpecializationType();
VECTOR(TemplateArgument, Arguments)
Template* _template;
QualifiedType desugared;
};
class CS_API DependentTemplateSpecializationType : public Type
{
public:
DependentTemplateSpecializationType();
DependentTemplateSpecializationType(const DependentTemplateSpecializationType&);
~DependentTemplateSpecializationType();
VECTOR(TemplateArgument, Arguments)
QualifiedType desugared;
};
class TypeTemplateParameter;
class CS_API TemplateParameterType : public Type
{
public:
DECLARE_TYPE_KIND(TemplateParameter)
~TemplateParameterType();
TypeTemplateParameter* parameter;
unsigned int depth;
unsigned int index;
bool isParameterPack;
};
class CS_API TemplateParameterSubstitutionType : public Type
{
public:
DECLARE_TYPE_KIND(TemplateParameterSubstitution)
QualifiedType replacement;
TemplateParameterType* replacedParameter;
};
class Class;
class CS_API InjectedClassNameType : public Type
{
public:
DECLARE_TYPE_KIND(InjectedClassName)
QualifiedType injectedSpecializationType;
Class* _class;
};
class CS_API DependentNameType : public Type
{
public:
DECLARE_TYPE_KIND(DependentName)
~DependentNameType();
QualifiedType qualifier;
std::string identifier;
};
class CS_API PackExpansionType : public Type
{
public:
DECLARE_TYPE_KIND(PackExpansion)
};
class CS_API UnaryTransformType : public Type
{
public:
DECLARE_TYPE_KIND(UnaryTransform)
QualifiedType desugared;
QualifiedType baseType;
};
class UnresolvedUsingTypename;
class CS_API UnresolvedUsingType : public Type
{
public:
DECLARE_TYPE_KIND(UnresolvedUsing)
UnresolvedUsingTypename* declaration;
};
class CS_API VectorType : public Type
{
public:
DECLARE_TYPE_KIND(Vector)
QualifiedType elementType;
unsigned numElements;
};
enum class PrimitiveType
{
Null,
Void,
Bool,
WideChar,
Char,
SChar,
UChar,
Char16,
Char32,
Short,
UShort,
Int,
UInt,
Long,
ULong,
LongLong,
ULongLong,
Int128,
UInt128,
Half,
Float,
Double,
LongDouble,
Float128,
IntPtr
Value,
Pointer,
LVReference,
RVReference
};
class CS_API BuiltinType : public Type
DECLARE_TYPE_KIND(Pointer)
QualifiedType qualifiedPointee;
TypeModifier modifier;
};
class CS_API MemberPointerType : public Type
{
public:
DECLARE_TYPE_KIND(MemberPointer)
QualifiedType pointee;
};
class TypedefNameDecl;
class CS_API TypedefType : public Type
{
public:
TypedefType();
TypedefNameDecl* declaration;
};
class CS_API AttributedType : public Type
{
public:
DECLARE_TYPE_KIND(Attributed)
QualifiedType modified;
QualifiedType equivalent;
};
class CS_API DecayedType : public Type
{
public:
DECLARE_TYPE_KIND(Decayed)
QualifiedType decayed;
QualifiedType original;
QualifiedType pointee;
};
struct CS_API TemplateArgument
{
TemplateArgument();
enum struct ArgumentKind
{
public:
DECLARE_TYPE_KIND(Builtin)
PrimitiveType type;
Type,
Declaration,
NullPtr,
Integral,
Template,
TemplateExpansion,
Expression,
Pack
};
}}} // namespace CppSharp::CppParser::AST
ArgumentKind kind;
QualifiedType type;
Declaration* declaration;
long integral;
};
class Template;
class CS_API TemplateSpecializationType : public Type
{
public:
TemplateSpecializationType();
TemplateSpecializationType(const TemplateSpecializationType&);
~TemplateSpecializationType();
VECTOR(TemplateArgument, Arguments)
Template* _template;
QualifiedType desugared;
};
class CS_API DependentTemplateSpecializationType : public Type
{
public:
DependentTemplateSpecializationType();
DependentTemplateSpecializationType(const DependentTemplateSpecializationType&);
~DependentTemplateSpecializationType();
VECTOR(TemplateArgument, Arguments)
QualifiedType desugared;
};
class TypeTemplateParameter;
class CS_API TemplateParameterType : public Type
{
public:
DECLARE_TYPE_KIND(TemplateParameter)
~TemplateParameterType();
TypeTemplateParameter* parameter;
unsigned int depth;
unsigned int index;
bool isParameterPack;
};
class CS_API TemplateParameterSubstitutionType : public Type
{
public:
DECLARE_TYPE_KIND(TemplateParameterSubstitution)
QualifiedType replacement;
TemplateParameterType* replacedParameter;
};
class Class;
class CS_API InjectedClassNameType : public Type
{
public:
DECLARE_TYPE_KIND(InjectedClassName)
QualifiedType injectedSpecializationType;
Class* _class;
};
class CS_API DependentNameType : public Type
{
public:
DECLARE_TYPE_KIND(DependentName)
~DependentNameType();
QualifiedType qualifier;
std::string identifier;
};
class CS_API PackExpansionType : public Type
{
public:
DECLARE_TYPE_KIND(PackExpansion)
};
class CS_API UnaryTransformType : public Type
{
public:
DECLARE_TYPE_KIND(UnaryTransform)
QualifiedType desugared;
QualifiedType baseType;
};
class UnresolvedUsingTypename;
class CS_API UnresolvedUsingType : public Type
{
public:
DECLARE_TYPE_KIND(UnresolvedUsing)
UnresolvedUsingTypename* declaration;
};
class CS_API VectorType : public Type
{
public:
DECLARE_TYPE_KIND(Vector)
QualifiedType elementType;
unsigned numElements;
};
enum class PrimitiveType
{
Null,
Void,
Bool,
WideChar,
Char,
SChar,
UChar,
Char16,
Char32,
Short,
UShort,
Int,
UInt,
Long,
ULong,
LongLong,
ULongLong,
Int128,
UInt128,
Half,
Float,
Double,
LongDouble,
Float128,
IntPtr
};
class CS_API BuiltinType : public Type
{
public:
DECLARE_TYPE_KIND(Builtin)
PrimitiveType type;
};
} // namespace CppSharp::CppParser::AST

1
src/Generator.Tests/GeneratorTest.cs

@ -28,6 +28,7 @@ namespace CppSharp.Utils @@ -28,6 +28,7 @@ namespace CppSharp.Utils
options.Quiet = true;
options.GenerateDebugOutput = true;
options.CheckSymbols = true;
driver.ParserOptions.SkipSystemHeaders = false;
var testModule = options.AddModule(name);
Diagnostics.Message("");

Loading…
Cancel
Save