003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/AST
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
AST
/
📁
..
📄
APValue.cpp
(23.33 KB)
📄
ASTConcept.cpp
(2.7 KB)
📄
ASTConsumer.cpp
(954 B)
📄
ASTContext.cpp
(407.36 KB)
📄
ASTDiagnostic.cpp
(75.78 KB)
📄
ASTDumper.cpp
(9.52 KB)
📄
ASTImporter.cpp
(323.93 KB)
📄
ASTImporterLookupTable.cpp
(4.85 KB)
📄
ASTStructuralEquivalence.cpp
(73.55 KB)
📄
ASTTypeTraits.cpp
(6.42 KB)
📄
AttrImpl.cpp
(5.3 KB)
📄
CXXABI.h
(2.66 KB)
📄
CXXInheritance.cpp
(28.55 KB)
📄
Comment.cpp
(11.94 KB)
📄
CommentBriefParser.cpp
(4.19 KB)
📄
CommentCommandTraits.cpp
(4.63 KB)
📄
CommentLexer.cpp
(25.38 KB)
📄
CommentParser.cpp
(23.52 KB)
📄
CommentSema.cpp
(40.88 KB)
📄
ComparisonCategories.cpp
(7.23 KB)
📄
ComputeDependence.cpp
(28.3 KB)
📄
DataCollection.cpp
(1.83 KB)
📄
Decl.cpp
(177.21 KB)
📄
DeclBase.cpp
(63.37 KB)
📄
DeclCXX.cpp
(127.53 KB)
📄
DeclFriend.cpp
(2.76 KB)
📄
DeclGroup.cpp
(1.16 KB)
📄
DeclObjC.cpp
(82.05 KB)
📄
DeclOpenMP.cpp
(10.04 KB)
📄
DeclPrinter.cpp
(52.6 KB)
📄
DeclTemplate.cpp
(57.75 KB)
📄
DeclarationName.cpp
(17.52 KB)
📄
Expr.cpp
(176.93 KB)
📄
ExprCXX.cpp
(69.03 KB)
📄
ExprClassification.cpp
(28.48 KB)
📄
ExprConcepts.cpp
(9.43 KB)
📄
ExprConstant.cpp
(538.88 KB)
📄
ExprObjC.cpp
(14.25 KB)
📄
ExternalASTMerger.cpp
(22.13 KB)
📄
ExternalASTSource.cpp
(3.85 KB)
📄
FormatString.cpp
(29.64 KB)
📄
FormatStringParsing.h
(3.17 KB)
📄
InheritViz.cpp
(5.1 KB)
📁
Interp
📄
ItaniumCXXABI.cpp
(8.92 KB)
📄
ItaniumMangle.cpp
(182.64 KB)
📄
JSONNodeDumper.cpp
(58.07 KB)
📄
Linkage.h
(6 KB)
📄
Mangle.cpp
(17.71 KB)
📄
MicrosoftCXXABI.cpp
(9.12 KB)
📄
MicrosoftMangle.cpp
(133.01 KB)
📄
NSAPI.cpp
(18.12 KB)
📄
NestedNameSpecifier.cpp
(23.31 KB)
📄
ODRHash.cpp
(29.78 KB)
📄
OSLog.cpp
(7.61 KB)
📄
OpenMPClause.cpp
(82.03 KB)
📄
ParentMap.cpp
(5.97 KB)
📄
ParentMapContext.cpp
(10.7 KB)
📄
PrintfFormatString.cpp
(35.8 KB)
📄
QualTypeNames.cpp
(18.46 KB)
📄
RawCommentList.cpp
(15.52 KB)
📄
RecordLayout.cpp
(3.95 KB)
📄
RecordLayoutBuilder.cpp
(132.78 KB)
📄
ScanfFormatString.cpp
(18.62 KB)
📄
SelectorLocationsKind.cpp
(4.48 KB)
📄
Stmt.cpp
(45.04 KB)
📄
StmtCXX.cpp
(5 KB)
📄
StmtIterator.cpp
(2.92 KB)
📄
StmtObjC.cpp
(2.75 KB)
📄
StmtOpenMP.cpp
(98.6 KB)
📄
StmtPrinter.cpp
(70.34 KB)
📄
StmtProfile.cpp
(60.24 KB)
📄
StmtViz.cpp
(1.75 KB)
📄
TemplateBase.cpp
(16.19 KB)
📄
TemplateName.cpp
(9.96 KB)
📄
TextNodeDumper.cpp
(61.83 KB)
📄
Type.cpp
(144.42 KB)
📄
TypeLoc.cpp
(20.52 KB)
📄
TypePrinter.cpp
(63.28 KB)
📄
VTTBuilder.cpp
(7.25 KB)
📄
VTableBuilder.cpp
(139.78 KB)
Editing: ASTTypeTraits.cpp
//===--- ASTTypeTraits.cpp --------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Provides a dynamic type identifier and a dynamically typed node container // that can be used to store an AST base node at runtime in the same storage in // a type safe way. // //===----------------------------------------------------------------------===// #include "clang/AST/ASTTypeTraits.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/OpenMPClause.h" using namespace clang; const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = { { NKI_None, "<None>" }, { NKI_None, "TemplateArgument" }, { NKI_None, "TemplateName" }, { NKI_None, "NestedNameSpecifierLoc" }, { NKI_None, "QualType" }, { NKI_None, "TypeLoc" }, { NKI_None, "CXXBaseSpecifier" }, { NKI_None, "CXXCtorInitializer" }, { NKI_None, "NestedNameSpecifier" }, { NKI_None, "Decl" }, #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" }, #include "clang/AST/DeclNodes.inc" { NKI_None, "Stmt" }, #define STMT(DERIVED, BASE) { NKI_##BASE, #DERIVED }, #include "clang/AST/StmtNodes.inc" { NKI_None, "Type" }, #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" }, #include "clang/AST/TypeNodes.inc" { NKI_None, "OMPClause" }, #define OMP_CLAUSE_CLASS(Enum, Str, Class) {NKI_OMPClause, #Class}, #include "llvm/Frontend/OpenMP/OMPKinds.def" }; bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const { return isBaseOf(KindId, Other.KindId, Distance); } bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived, unsigned *Distance) { if (Base == NKI_None || Derived == NKI_None) return false; unsigned Dist = 0; while (Derived != Base && Derived != NKI_None) { Derived = AllKindInfo[Derived].ParentId; ++Dist; } if (Distance) *Distance = Dist; return Derived == Base; } StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; } ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2) { if (Kind1.isBaseOf(Kind2)) return Kind2; if (Kind2.isBaseOf(Kind1)) return Kind1; return ASTNodeKind(); } ASTNodeKind ASTNodeKind::getMostDerivedCommonAncestor(ASTNodeKind Kind1, ASTNodeKind Kind2) { NodeKindId Parent = Kind1.KindId; while (!isBaseOf(Parent, Kind2.KindId, nullptr) && Parent != NKI_None) { Parent = AllKindInfo[Parent].ParentId; } return ASTNodeKind(Parent); } ASTNodeKind ASTNodeKind::getFromNode(const Decl &D) { switch (D.getKind()) { #define DECL(DERIVED, BASE) \ case Decl::DERIVED: return ASTNodeKind(NKI_##DERIVED##Decl); #define ABSTRACT_DECL(D) #include "clang/AST/DeclNodes.inc" }; llvm_unreachable("invalid decl kind"); } ASTNodeKind ASTNodeKind::getFromNode(const Stmt &S) { switch (S.getStmtClass()) { case Stmt::NoStmtClass: return NKI_None; #define STMT(CLASS, PARENT) \ case Stmt::CLASS##Class: return ASTNodeKind(NKI_##CLASS); #define ABSTRACT_STMT(S) #include "clang/AST/StmtNodes.inc" } llvm_unreachable("invalid stmt kind"); } ASTNodeKind ASTNodeKind::getFromNode(const Type &T) { switch (T.getTypeClass()) { #define TYPE(Class, Base) \ case Type::Class: return ASTNodeKind(NKI_##Class##Type); #define ABSTRACT_TYPE(Class, Base) #include "clang/AST/TypeNodes.inc" } llvm_unreachable("invalid type kind"); } ASTNodeKind ASTNodeKind::getFromNode(const OMPClause &C) { switch (C.getClauseKind()) { #define OMP_CLAUSE_CLASS(Enum, Str, Class) \ case llvm::omp::Clause::Enum: \ return ASTNodeKind(NKI_##Class); #define OMP_CLAUSE_NO_CLASS(Enum, Str) \ case llvm::omp::Clause::Enum: \ llvm_unreachable("unexpected OpenMP clause kind"); default: break; #include "llvm/Frontend/OpenMP/OMPKinds.def" } llvm_unreachable("invalid stmt kind"); } void DynTypedNode::print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const { if (const TemplateArgument *TA = get<TemplateArgument>()) TA->print(PP, OS); else if (const TemplateName *TN = get<TemplateName>()) TN->print(OS, PP); else if (const NestedNameSpecifier *NNS = get<NestedNameSpecifier>()) NNS->print(OS, PP); else if (const NestedNameSpecifierLoc *NNSL = get<NestedNameSpecifierLoc>()) { if (const NestedNameSpecifier *NNS = NNSL->getNestedNameSpecifier()) NNS->print(OS, PP); else OS << "(empty NestedNameSpecifierLoc)"; } else if (const QualType *QT = get<QualType>()) QT->print(OS, PP); else if (const TypeLoc *TL = get<TypeLoc>()) TL->getType().print(OS, PP); else if (const Decl *D = get<Decl>()) D->print(OS, PP); else if (const Stmt *S = get<Stmt>()) S->printPretty(OS, nullptr, PP); else if (const Type *T = get<Type>()) QualType(T, 0).print(OS, PP); else OS << "Unable to print values of type " << NodeKind.asStringRef() << "\n"; } void DynTypedNode::dump(llvm::raw_ostream &OS, const ASTContext &Context) const { if (const Decl *D = get<Decl>()) D->dump(OS); else if (const Stmt *S = get<Stmt>()) S->dump(OS, Context); else if (const Type *T = get<Type>()) T->dump(OS, Context); else OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n"; } SourceRange DynTypedNode::getSourceRange() const { if (const CXXCtorInitializer *CCI = get<CXXCtorInitializer>()) return CCI->getSourceRange(); if (const NestedNameSpecifierLoc *NNSL = get<NestedNameSpecifierLoc>()) return NNSL->getSourceRange(); if (const TypeLoc *TL = get<TypeLoc>()) return TL->getSourceRange(); if (const Decl *D = get<Decl>()) return D->getSourceRange(); if (const Stmt *S = get<Stmt>()) return S->getSourceRange(); if (const auto *C = get<OMPClause>()) return SourceRange(C->getBeginLoc(), C->getEndLoc()); return SourceRange(); }
Upload File
Create Folder