22 #include "llvm/Support/raw_ostream.h" 24 using namespace clang;
40 if (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
51 dyn_cast<SubstTemplateTypeParmType>(Ty)) {
61 if (
const AdjustedType *AT = dyn_cast<AdjustedType>(Ty)) {
66 if (
const AutoType *AT = dyn_cast<AutoType>(Ty)) {
75 if (
const FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
76 bool DesugarReturn =
false;
77 QualType SugarRT = FT->getReturnType();
84 bool DesugarArgument =
false;
90 if (
auto nullability =
99 if (DesugarReturn || DesugarArgument) {
110 dyn_cast<TemplateSpecializationType>(Ty)) {
111 if (!TST->isTypeAlias()) {
112 bool DesugarArgument =
false;
114 for (
unsigned I = 0, N = TST->getNumArgs(); I != N; ++I) {
122 if (DesugarArgument) {
125 TST->getTemplateName(), Args, QT);
145 bool IsSugar =
false;
147 #define ABSTRACT_TYPE(Class, Base) 148 #define TYPE(Class, Base) \ 149 case Type::Class: { \ 150 const Class##Type *CTy = cast<Class##Type>(Ty); \ 151 if (CTy->isSugared()) { \ 153 Underlying = CTy->desugar(); \ 157 #include "clang/AST/TypeNodes.def" 166 if (isa<VectorType>(Underlying))
171 if (
const TypedefType *QTT = dyn_cast<TypedefType>(QT))
172 if (UTT->getDecl()->getTypedefNameForAnonDecl() == QTT->getDecl())
195 if (Ty->getBaseType().getTypePtr() != Ty && !ShouldAKA) {
198 llvm::makeArrayRef(Ty->qual_begin(),
199 Ty->getNumProtocols()),
200 Ty->isKindOfTypeAsWritten());
204 return QC.
apply(Context, QT);
236 bool ForceAKA =
false;
241 for (
unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
249 if (CompareCanTy == CanTy)
252 bool ShouldAKA =
false;
254 std::string CompareDesugarStr =
256 if (CompareS != S && CompareDesugarStr != S)
259 std::string CompareCanS =
262 if (CompareCanS == CanS)
271 bool Repeated =
false;
272 for (
unsigned i = 0, e = PrevArgs.size();
i != e; ++
i) {
275 void *Ptr = (
void*)PrevArgs[
i].second;
287 bool ShouldAKA =
false;
289 if (ShouldAKA || ForceAKA) {
290 if (DesugaredTy == Ty) {
295 S =
"'" + S +
"' (aka '" + akaStr +
"')";
305 std::string DecoratedString;
306 llvm::raw_string_ostream OS(DecoratedString);
307 const char *Values = VTy->
getNumElements() > 1 ?
"values" :
"value";
308 OS <<
"'" << S <<
"' (vector of " << VTy->
getNumElements() <<
" '" 310 <<
"' " << Values <<
")";
321 bool PrintFromType,
bool ElideType,
322 bool ShowColors, raw_ostream &OS);
335 size_t OldEnd = Output.size();
336 llvm::raw_svector_ostream OS(Output);
337 bool NeedQuotes =
true;
340 default: llvm_unreachable(
"unknown ArgumentKind");
342 assert(Modifier.empty() && Argument.empty() &&
343 "Invalid modifier for Qualfiers argument");
346 auto S = Q.getAsString();
351 OS << Q.getAsString();
378 Modifier = StringRef();
379 Argument = StringRef();
384 assert(Modifier.empty() && Argument.empty() &&
385 "Invalid modifier for QualType argument");
393 if (Modifier ==
"objcclass" && Argument.empty())
395 else if (Modifier ==
"objcinstance" && Argument.empty())
398 assert(Modifier.empty() && Argument.empty() &&
399 "Invalid modifier for DeclarationName argument");
406 if (Modifier ==
"q" && Argument.empty())
409 assert(Modifier.empty() && Argument.empty() &&
410 "Invalid modifier for NamedDecl* argument");
425 assert(DC &&
"Should never have a null declaration context");
431 OS <<
"the global namespace";
433 OS <<
"the global scope";
435 OS <<
"block literal";
437 OS <<
"lambda expression";
441 PrevArgs, QualTypeVals);
443 assert(isa<NamedDecl>(DC) &&
"Expected a NamedDecl");
445 if (isa<NamespaceDecl>(ND))
447 else if (isa<ObjCMethodDecl>(ND))
449 else if (isa<FunctionDecl>(ND))
459 const Attr *At =
reinterpret_cast<Attr *
>(Val);
460 assert(At &&
"Received null Attr object!");
468 Output.insert(Output.begin()+OldEnd,
'\'');
469 Output.push_back(
'\'');
534 FromIntegerAndToDeclaration,
535 FromDeclarationAndToInteger
542 struct TemplateArgumentInfo {
546 bool IsValidInt =
false;
547 Expr *ArgExpr =
nullptr;
550 bool NeedAddressOf =
false;
551 bool IsNullPtr =
false;
552 bool IsDefault =
false;
559 DiffKind
Kind = Invalid;
562 unsigned NextNode = 0;
565 unsigned ChildNode = 0;
568 unsigned ParentNode = 0;
570 TemplateArgumentInfo FromArgInfo, ToArgInfo;
575 DiffNode(
unsigned ParentNode = 0) : ParentNode(ParentNode) {}
582 unsigned CurrentNode;
586 unsigned NextFreeNode;
593 CurrentNode(0), NextFreeNode(1) {
594 FlatTree.push_back(DiffNode());
600 bool FromDefault,
bool ToDefault) {
601 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
602 FlatTree[CurrentNode].Kind = Template;
603 FlatTree[CurrentNode].FromArgInfo.TD = FromTD;
604 FlatTree[CurrentNode].ToArgInfo.TD = ToTD;
605 FlatTree[CurrentNode].FromArgInfo.Qual = FromQual;
606 FlatTree[CurrentNode].ToArgInfo.Qual = ToQual;
607 SetDefault(FromDefault, ToDefault);
612 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
613 FlatTree[CurrentNode].Kind =
Type;
614 FlatTree[CurrentNode].FromArgInfo.ArgType = FromType;
615 FlatTree[CurrentNode].ToArgInfo.ArgType = ToType;
616 SetDefault(FromDefault, ToDefault);
619 void SetExpressionDiff(
Expr *FromExpr,
Expr *ToExpr,
bool FromDefault,
621 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
622 FlatTree[CurrentNode].Kind = Expression;
623 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
624 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
625 SetDefault(FromDefault, ToDefault);
629 bool FromDefault,
bool ToDefault) {
630 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
631 FlatTree[CurrentNode].Kind = TemplateTemplate;
632 FlatTree[CurrentNode].FromArgInfo.TD = FromTD;
633 FlatTree[CurrentNode].ToArgInfo.TD = ToTD;
634 SetDefault(FromDefault, ToDefault);
637 void SetIntegerDiff(
const llvm::APSInt &FromInt,
const llvm::APSInt &ToInt,
638 bool IsValidFromInt,
bool IsValidToInt,
640 Expr *FromExpr,
Expr *ToExpr,
bool FromDefault,
642 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
643 FlatTree[CurrentNode].Kind =
Integer;
644 FlatTree[CurrentNode].FromArgInfo.Val = FromInt;
645 FlatTree[CurrentNode].ToArgInfo.Val = ToInt;
646 FlatTree[CurrentNode].FromArgInfo.IsValidInt = IsValidFromInt;
647 FlatTree[CurrentNode].ToArgInfo.IsValidInt = IsValidToInt;
648 FlatTree[CurrentNode].FromArgInfo.ArgType = FromIntType;
649 FlatTree[CurrentNode].ToArgInfo.ArgType = ToIntType;
650 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
651 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
652 SetDefault(FromDefault, ToDefault);
656 bool FromAddressOf,
bool ToAddressOf,
657 bool FromNullPtr,
bool ToNullPtr,
Expr *FromExpr,
658 Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
659 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
660 FlatTree[CurrentNode].Kind = Declaration;
661 FlatTree[CurrentNode].FromArgInfo.VD = FromValueDecl;
662 FlatTree[CurrentNode].ToArgInfo.VD = ToValueDecl;
663 FlatTree[CurrentNode].FromArgInfo.NeedAddressOf = FromAddressOf;
664 FlatTree[CurrentNode].ToArgInfo.NeedAddressOf = ToAddressOf;
665 FlatTree[CurrentNode].FromArgInfo.IsNullPtr = FromNullPtr;
666 FlatTree[CurrentNode].ToArgInfo.IsNullPtr = ToNullPtr;
667 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
668 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
669 SetDefault(FromDefault, ToDefault);
672 void SetFromDeclarationAndToIntegerDiff(
673 ValueDecl *FromValueDecl,
bool FromAddressOf,
bool FromNullPtr,
674 Expr *FromExpr,
const llvm::APSInt &ToInt,
bool IsValidToInt,
675 QualType ToIntType,
Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
676 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
677 FlatTree[CurrentNode].Kind = FromDeclarationAndToInteger;
678 FlatTree[CurrentNode].FromArgInfo.VD = FromValueDecl;
679 FlatTree[CurrentNode].FromArgInfo.NeedAddressOf = FromAddressOf;
680 FlatTree[CurrentNode].FromArgInfo.IsNullPtr = FromNullPtr;
681 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
682 FlatTree[CurrentNode].ToArgInfo.Val = ToInt;
683 FlatTree[CurrentNode].ToArgInfo.IsValidInt = IsValidToInt;
684 FlatTree[CurrentNode].ToArgInfo.ArgType = ToIntType;
685 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
686 SetDefault(FromDefault, ToDefault);
689 void SetFromIntegerAndToDeclarationDiff(
690 const llvm::APSInt &FromInt,
bool IsValidFromInt,
QualType FromIntType,
692 bool ToNullPtr,
Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
693 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
694 FlatTree[CurrentNode].Kind = FromIntegerAndToDeclaration;
695 FlatTree[CurrentNode].FromArgInfo.Val = FromInt;
696 FlatTree[CurrentNode].FromArgInfo.IsValidInt = IsValidFromInt;
697 FlatTree[CurrentNode].FromArgInfo.ArgType = FromIntType;
698 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
699 FlatTree[CurrentNode].ToArgInfo.VD = ToValueDecl;
700 FlatTree[CurrentNode].ToArgInfo.NeedAddressOf = ToAddressOf;
701 FlatTree[CurrentNode].ToArgInfo.IsNullPtr = ToNullPtr;
702 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
703 SetDefault(FromDefault, ToDefault);
707 void SetDefault(
bool FromDefault,
bool ToDefault) {
708 assert((!FromDefault || !ToDefault) &&
"Both arguments cannot be default.");
709 FlatTree[CurrentNode].FromArgInfo.IsDefault = FromDefault;
710 FlatTree[CurrentNode].ToArgInfo.IsDefault = ToDefault;
714 void SetSame(
bool Same) {
715 FlatTree[CurrentNode].Same = Same;
719 void SetKind(DiffKind
Kind) {
720 FlatTree[CurrentNode].Kind =
Kind;
725 assert(FlatTree[CurrentNode].Kind != Invalid &&
726 "Cannot exit node before setting node information.");
727 CurrentNode = FlatTree[CurrentNode].ParentNode;
733 assert(FlatTree[CurrentNode].Kind == Template &&
734 "Only Template nodes can have children nodes.");
735 FlatTree.push_back(DiffNode(CurrentNode));
736 DiffNode &
Node = FlatTree[CurrentNode];
737 if (Node.ChildNode == 0) {
739 Node.ChildNode = NextFreeNode;
744 for (i = Node.ChildNode; FlatTree[i].NextNode != 0;
745 i = FlatTree[i].NextNode) {
747 FlatTree[
i].NextNode = NextFreeNode;
749 CurrentNode = NextFreeNode;
755 void StartTraverse() {
757 CurrentNode = NextFreeNode;
763 ReadNode = FlatTree[ReadNode].ParentNode;
768 assert(FlatTree[ReadNode].Kind == Template &&
"Unexpected kind.");
769 FromTD = FlatTree[ReadNode].FromArgInfo.TD;
770 ToTD = FlatTree[ReadNode].ToArgInfo.TD;
771 FromQual = FlatTree[ReadNode].FromArgInfo.Qual;
772 ToQual = FlatTree[ReadNode].ToArgInfo.Qual;
776 assert(FlatTree[ReadNode].Kind ==
Type &&
"Unexpected kind");
777 FromType = FlatTree[ReadNode].FromArgInfo.ArgType;
778 ToType = FlatTree[ReadNode].ToArgInfo.ArgType;
781 void GetExpressionDiff(
Expr *&FromExpr,
Expr *&ToExpr) {
782 assert(FlatTree[ReadNode].Kind == Expression &&
"Unexpected kind");
783 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
784 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
788 assert(FlatTree[ReadNode].Kind == TemplateTemplate &&
"Unexpected kind.");
789 FromTD = FlatTree[ReadNode].FromArgInfo.TD;
790 ToTD = FlatTree[ReadNode].ToArgInfo.TD;
793 void GetIntegerDiff(llvm::APSInt &FromInt, llvm::APSInt &ToInt,
794 bool &IsValidFromInt,
bool &IsValidToInt,
797 assert(FlatTree[ReadNode].Kind ==
Integer &&
"Unexpected kind.");
798 FromInt = FlatTree[ReadNode].FromArgInfo.Val;
799 ToInt = FlatTree[ReadNode].ToArgInfo.Val;
800 IsValidFromInt = FlatTree[ReadNode].FromArgInfo.IsValidInt;
801 IsValidToInt = FlatTree[ReadNode].ToArgInfo.IsValidInt;
802 FromIntType = FlatTree[ReadNode].FromArgInfo.ArgType;
803 ToIntType = FlatTree[ReadNode].ToArgInfo.ArgType;
804 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
805 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
809 bool &FromAddressOf,
bool &ToAddressOf,
810 bool &FromNullPtr,
bool &ToNullPtr,
Expr *&FromExpr,
812 assert(FlatTree[ReadNode].Kind == Declaration &&
"Unexpected kind.");
813 FromValueDecl = FlatTree[ReadNode].FromArgInfo.VD;
814 ToValueDecl = FlatTree[ReadNode].ToArgInfo.VD;
815 FromAddressOf = FlatTree[ReadNode].FromArgInfo.NeedAddressOf;
816 ToAddressOf = FlatTree[ReadNode].ToArgInfo.NeedAddressOf;
817 FromNullPtr = FlatTree[ReadNode].FromArgInfo.IsNullPtr;
818 ToNullPtr = FlatTree[ReadNode].ToArgInfo.IsNullPtr;
819 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
820 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
823 void GetFromDeclarationAndToIntegerDiff(
824 ValueDecl *&FromValueDecl,
bool &FromAddressOf,
bool &FromNullPtr,
825 Expr *&FromExpr, llvm::APSInt &ToInt,
bool &IsValidToInt,
827 assert(FlatTree[ReadNode].Kind == FromDeclarationAndToInteger &&
829 FromValueDecl = FlatTree[ReadNode].FromArgInfo.VD;
830 FromAddressOf = FlatTree[ReadNode].FromArgInfo.NeedAddressOf;
831 FromNullPtr = FlatTree[ReadNode].FromArgInfo.IsNullPtr;
832 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
833 ToInt = FlatTree[ReadNode].ToArgInfo.Val;
834 IsValidToInt = FlatTree[ReadNode].ToArgInfo.IsValidInt;
835 ToIntType = FlatTree[ReadNode].ToArgInfo.ArgType;
836 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
839 void GetFromIntegerAndToDeclarationDiff(
840 llvm::APSInt &FromInt,
bool &IsValidFromInt,
QualType &FromIntType,
842 bool &ToNullPtr,
Expr *&ToExpr) {
843 assert(FlatTree[ReadNode].Kind == FromIntegerAndToDeclaration &&
845 FromInt = FlatTree[ReadNode].FromArgInfo.Val;
846 IsValidFromInt = FlatTree[ReadNode].FromArgInfo.IsValidInt;
847 FromIntType = FlatTree[ReadNode].FromArgInfo.ArgType;
848 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
849 ToValueDecl = FlatTree[ReadNode].ToArgInfo.VD;
850 ToAddressOf = FlatTree[ReadNode].ToArgInfo.NeedAddressOf;
851 ToNullPtr = FlatTree[ReadNode].ToArgInfo.IsNullPtr;
852 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
857 return FlatTree[ReadNode].FromArgInfo.IsDefault;
862 return FlatTree[ReadNode].ToArgInfo.IsDefault;
867 return FlatTree[ReadNode].Same;
872 return FlatTree[ReadNode].ChildNode != 0;
877 ReadNode = FlatTree[ReadNode].ChildNode;
882 bool AdvanceSibling() {
883 if (FlatTree[ReadNode].NextNode == 0)
886 ReadNode = FlatTree[ReadNode].NextNode;
891 bool HasNextSibling() {
892 return FlatTree[ReadNode].NextNode != 0;
897 return GetKind() == Invalid;
902 return FlatTree[ReadNode].Kind;
919 struct InternalIterator {
937 : TST(TST), Index(0), CurrentTA(
nullptr), EndTA(
nullptr) {
951 if (CurrentTA != EndTA)
return;
959 bool isValid()
const {
return TST; }
963 assert(TST &&
"InternalIterator is invalid with a null TST.");
968 InternalIterator &operator++() {
969 assert(TST &&
"InternalIterator is invalid with a null TST.");
975 if (CurrentTA != EndTA) {
977 if (CurrentTA != EndTA)
997 if (CurrentTA != EndTA)
1005 assert(TST &&
"InternalIterator is invalid with a null TST.");
1006 assert(!isEnd() &&
"Index exceeds number of arguments.");
1007 if (CurrentTA == EndTA)
1008 return TST->
getArg(Index);
1014 pointer operator->()
const {
1015 assert(TST &&
"InternalIterator is invalid with a null TST.");
1020 InternalIterator SugaredIterator;
1021 InternalIterator DesugaredIterator;
1025 : SugaredIterator(TST),
1028 ? GetTemplateSpecializationType(Context, TST->
desugar())
1032 TSTiterator &operator++() {
1034 if (DesugaredIterator.isValid())
1035 ++DesugaredIterator;
1041 return *SugaredIterator;
1045 pointer operator->()
const {
1050 bool isEnd()
const {
1051 return SugaredIterator.isEnd();
1056 bool hasDesugaredTA()
const {
1057 return DesugaredIterator.isValid() && !DesugaredIterator.isEnd();
1061 reference getDesugaredTA()
const {
1062 assert(DesugaredIterator.isValid() &&
1063 "Desugared TemplateArgument should not be used.");
1064 return *DesugaredIterator;
1107 FromArgTST = GetTemplateSpecializationType(Context, FromType);
1108 ToArgTST = GetTemplateSpecializationType(Context, ToType);
1110 if (!FromArgTST || !ToArgTST)
1113 if (!hasSameTemplate(FromArgTST, ToArgTST))
1120 void DiffTypes(
const TSTiterator &FromIter,
const TSTiterator &ToIter) {
1121 QualType FromType = GetType(FromIter);
1124 bool FromDefault = FromIter.isEnd() && !FromType.
isNull();
1125 bool ToDefault = ToIter.isEnd() && !ToType.
isNull();
1129 if (OnlyPerformTypeDiff(Context, FromType, ToType, FromArgTST, ToArgTST)) {
1130 Tree.SetTypeDiff(FromType, ToType, FromDefault, ToDefault);
1134 assert(FromArgTST && ToArgTST &&
1135 "Both template specializations need to be valid.");
1142 FromQual, ToQual, FromDefault, ToDefault);
1143 DiffTemplate(FromArgTST, ToArgTST);
1149 void DiffTemplateTemplates(
const TSTiterator &FromIter,
1150 const TSTiterator &ToIter) {
1153 Tree.SetTemplateTemplateDiff(FromDecl, ToDecl, FromIter.isEnd() &&
FromDecl,
1154 ToIter.isEnd() && ToDecl);
1155 Tree.SetSame(FromDecl && ToDecl &&
1160 static void InitializeNonTypeDiffVariables(
ASTContext &Context,
1161 const TSTiterator &Iter,
1163 llvm::APSInt &
Value,
bool &HasInt,
1164 QualType &IntType,
bool &IsNullPtr,
1166 bool &NeedAddressOf) {
1167 if (!Iter.isEnd()) {
1168 switch (Iter->getKind()) {
1170 llvm_unreachable(
"unknown ArgumentKind");
1172 Value = Iter->getAsIntegral();
1174 IntType = Iter->getIntegralType();
1177 VD = Iter->getAsDecl();
1178 QualType ArgType = Iter->getParamTypeForDecl();
1182 NeedAddressOf =
true;
1189 E = Iter->getAsExpr();
1195 if (!Iter.hasDesugaredTA())
return;
1200 llvm_unreachable(
"unknown ArgumentKind");
1212 NeedAddressOf =
true;
1230 void DiffNonTypes(
const TSTiterator &FromIter,
const TSTiterator &ToIter,
1233 Expr *FromExpr =
nullptr, *ToExpr =
nullptr;
1234 llvm::APSInt FromInt, ToInt;
1236 ValueDecl *FromValueDecl =
nullptr, *ToValueDecl =
nullptr;
1237 bool HasFromInt =
false, HasToInt =
false, FromNullPtr =
false,
1238 ToNullPtr =
false, NeedFromAddressOf =
false, NeedToAddressOf =
false;
1239 InitializeNonTypeDiffVariables(
1240 Context, FromIter, FromDefaultNonTypeDecl, FromInt, HasFromInt,
1241 FromIntType, FromNullPtr, FromExpr, FromValueDecl, NeedFromAddressOf);
1242 InitializeNonTypeDiffVariables(Context, ToIter, ToDefaultNonTypeDecl, ToInt,
1243 HasToInt, ToIntType, ToNullPtr, ToExpr,
1244 ToValueDecl, NeedToAddressOf);
1246 bool FromDefault = FromIter.isEnd() &&
1247 (FromExpr || FromValueDecl || HasFromInt || FromNullPtr);
1248 bool ToDefault = ToIter.isEnd() &&
1249 (ToExpr || ToValueDecl || HasToInt || ToNullPtr);
1251 bool FromDeclaration = FromValueDecl || FromNullPtr;
1252 bool ToDeclaration = ToValueDecl || ToNullPtr;
1254 if (FromDeclaration && HasToInt) {
1255 Tree.SetFromDeclarationAndToIntegerDiff(
1256 FromValueDecl, NeedFromAddressOf, FromNullPtr, FromExpr, ToInt,
1257 HasToInt, ToIntType, ToExpr, FromDefault, ToDefault);
1258 Tree.SetSame(
false);
1263 if (HasFromInt && ToDeclaration) {
1264 Tree.SetFromIntegerAndToDeclarationDiff(
1265 FromInt, HasFromInt, FromIntType, FromExpr, ToValueDecl,
1266 NeedToAddressOf, ToNullPtr, ToExpr, FromDefault, ToDefault);
1267 Tree.SetSame(
false);
1271 if (HasFromInt || HasToInt) {
1272 Tree.SetIntegerDiff(FromInt, ToInt, HasFromInt, HasToInt, FromIntType,
1273 ToIntType, FromExpr, ToExpr, FromDefault, ToDefault);
1274 if (HasFromInt && HasToInt) {
1275 Tree.SetSame(Context.
hasSameType(FromIntType, ToIntType) &&
1281 if (FromDeclaration || ToDeclaration) {
1282 Tree.SetDeclarationDiff(FromValueDecl, ToValueDecl, NeedFromAddressOf,
1283 NeedToAddressOf, FromNullPtr, ToNullPtr, FromExpr,
1284 ToExpr, FromDefault, ToDefault);
1285 bool BothNull = FromNullPtr && ToNullPtr;
1286 bool SameValueDecl =
1287 FromValueDecl && ToValueDecl &&
1288 NeedFromAddressOf == NeedToAddressOf &&
1290 Tree.SetSame(BothNull || SameValueDecl);
1294 assert((FromExpr || ToExpr) &&
"Both template arguments cannot be empty.");
1295 Tree.SetExpressionDiff(FromExpr, ToExpr, FromDefault, ToDefault);
1296 Tree.SetSame(IsEqualExpr(Context, FromExpr, ToExpr));
1308 unsigned TotalArgs = 0;
1309 for (TSTiterator FromIter(Context, FromTST), ToIter(Context, ToTST);
1310 !FromIter.isEnd() || !ToIter.isEnd(); ++TotalArgs) {
1316 unsigned FromParamIndex =
std::min(TotalArgs, ParamsFrom->
size() - 1);
1317 unsigned ToParamIndex =
std::min(TotalArgs, ParamsTo->
size() - 1);
1321 assert(FromParamND->getKind() == ToParamND->
getKind() &&
1322 "Parameter Decl are not the same kind.");
1324 if (isa<TemplateTypeParmDecl>(FromParamND)) {
1325 DiffTypes(FromIter, ToIter);
1326 }
else if (isa<TemplateTemplateParmDecl>(FromParamND)) {
1327 DiffTemplateTemplates(FromIter, ToIter);
1328 }
else if (isa<NonTypeTemplateParmDecl>(FromParamND)) {
1330 cast<NonTypeTemplateParmDecl>(FromParamND);
1332 cast<NonTypeTemplateParmDecl>(ToParamND);
1333 DiffNonTypes(FromIter, ToIter, FromDefaultNonTypeDecl,
1334 ToDefaultNonTypeDecl);
1336 llvm_unreachable(
"Unexpected Decl type.");
1346 static void makeTemplateList(
1350 TemplateList.push_back(TST);
1372 if (hasSameBaseTemplate(FromTST, ToTST))
1379 makeTemplateList(FromTemplateList, FromTST);
1380 makeTemplateList(ToTemplateList, ToTST);
1383 FromIter = FromTemplateList.rbegin(), FromEnd = FromTemplateList.rend(),
1384 ToIter = ToTemplateList.rbegin(), ToEnd = ToTemplateList.rend();
1387 if (!hasSameBaseTemplate(*FromIter, *ToIter))
1393 for (; FromIter != FromEnd && ToIter != ToEnd; ++FromIter, ++ToIter) {
1394 if (!hasSameBaseTemplate(*FromIter, *ToIter))
1398 FromTST = FromIter[-1];
1406 static QualType GetType(
const TSTiterator &Iter) {
1408 return Iter->getAsType();
1409 if (Iter.hasDesugaredTA())
1410 return Iter.getDesugaredTA().getAsType();
1416 static TemplateDecl *GetTemplateDecl(
const TSTiterator &Iter) {
1418 return Iter->getAsTemplate().getAsTemplateDecl();
1419 if (Iter.hasDesugaredTA())
1420 return Iter.getDesugaredTA().getAsTemplate().getAsTemplateDecl();
1428 if (FromExpr == ToExpr)
1431 if (!FromExpr || !ToExpr)
1434 llvm::FoldingSetNodeID FromID, ToID;
1435 FromExpr->
Profile(FromID, Context,
true);
1436 ToExpr->
Profile(ToID, Context,
true);
1437 return FromID == ToID;
1445 void TreeToString(
int Indent = 1) {
1454 switch (Tree.GetKind()) {
1455 case DiffTree::Invalid:
1456 llvm_unreachable(
"Template diffing failed with bad DiffNode");
1459 Tree.GetTypeDiff(FromType, ToType);
1460 PrintTypeNames(FromType, ToType, Tree.FromDefault(), Tree.ToDefault(),
1464 case DiffTree::Expression: {
1465 Expr *FromExpr, *ToExpr;
1466 Tree.GetExpressionDiff(FromExpr, ToExpr);
1467 PrintExpr(FromExpr, ToExpr, Tree.FromDefault(), Tree.ToDefault(),
1471 case DiffTree::TemplateTemplate: {
1473 Tree.GetTemplateTemplateDiff(FromTD, ToTD);
1474 PrintTemplateTemplate(FromTD, ToTD, Tree.FromDefault(),
1475 Tree.ToDefault(), Tree.NodeIsSame());
1478 case DiffTree::Integer: {
1479 llvm::APSInt FromInt, ToInt;
1480 Expr *FromExpr, *ToExpr;
1481 bool IsValidFromInt, IsValidToInt;
1483 Tree.GetIntegerDiff(FromInt, ToInt, IsValidFromInt, IsValidToInt,
1484 FromIntType, ToIntType, FromExpr, ToExpr);
1485 PrintAPSInt(FromInt, ToInt, IsValidFromInt, IsValidToInt, FromIntType,
1486 ToIntType, FromExpr, ToExpr, Tree.FromDefault(),
1487 Tree.ToDefault(), Tree.NodeIsSame());
1490 case DiffTree::Declaration: {
1492 bool FromAddressOf, ToAddressOf;
1493 bool FromNullPtr, ToNullPtr;
1494 Expr *FromExpr, *ToExpr;
1495 Tree.GetDeclarationDiff(FromValueDecl, ToValueDecl, FromAddressOf,
1496 ToAddressOf, FromNullPtr, ToNullPtr, FromExpr,
1498 PrintValueDecl(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf,
1499 FromNullPtr, ToNullPtr, FromExpr, ToExpr,
1500 Tree.FromDefault(), Tree.ToDefault(), Tree.NodeIsSame());
1503 case DiffTree::FromDeclarationAndToInteger: {
1512 Tree.GetFromDeclarationAndToIntegerDiff(
1513 FromValueDecl, FromAddressOf, FromNullPtr, FromExpr, ToInt,
1514 IsValidToInt, ToIntType, ToExpr);
1515 assert((FromValueDecl || FromNullPtr) && IsValidToInt);
1516 PrintValueDeclAndInteger(FromValueDecl, FromAddressOf, FromNullPtr,
1517 FromExpr, Tree.FromDefault(), ToInt, ToIntType,
1518 ToExpr, Tree.ToDefault());
1521 case DiffTree::FromIntegerAndToDeclaration: {
1522 llvm::APSInt FromInt;
1523 bool IsValidFromInt;
1530 Tree.GetFromIntegerAndToDeclarationDiff(
1531 FromInt, IsValidFromInt, FromIntType, FromExpr, ToValueDecl,
1532 ToAddressOf, ToNullPtr, ToExpr);
1533 assert(IsValidFromInt && (ToValueDecl || ToNullPtr));
1534 PrintIntegerAndValueDecl(FromInt, FromIntType, FromExpr,
1535 Tree.FromDefault(), ToValueDecl, ToAddressOf,
1536 ToNullPtr, ToExpr, Tree.ToDefault());
1539 case DiffTree::Template: {
1543 Tree.GetTemplateDiff(FromTD, ToTD, FromQual, ToQual);
1545 PrintQualifiers(FromQual, ToQual);
1547 if (!Tree.HasChildren()) {
1556 unsigned NumElideArgs = 0;
1557 bool AllArgsElided =
true;
1560 if (Tree.NodeIsSame()) {
1564 AllArgsElided =
false;
1565 if (NumElideArgs > 0) {
1566 PrintElideArgs(NumElideArgs,
Indent);
1572 if (Tree.HasNextSibling())
1574 }
while (Tree.AdvanceSibling());
1575 if (NumElideArgs > 0) {
1579 PrintElideArgs(NumElideArgs,
Indent);
1595 assert(!IsBold &&
"Attempting to bold text that is already bold.");
1603 assert(IsBold &&
"Attempting to remove bold from unbold text.");
1615 bool FromDefault,
bool ToDefault,
bool Same) {
1617 "Only one template argument may be missing.");
1629 PrintQualifiers(FromQual, ToQual);
1634 std::string FromTypeStr = FromType.
isNull() ?
"(no argument)" 1636 std::string ToTypeStr = ToType.
isNull() ?
"(no argument)" 1640 if (FromTypeStr == ToTypeStr) {
1641 std::string FromCanTypeStr =
1644 if (FromCanTypeStr != ToCanTypeStr) {
1645 FromTypeStr = FromCanTypeStr;
1646 ToTypeStr = ToCanTypeStr;
1650 if (PrintTree) OS <<
'[';
1651 OS << (FromDefault ?
"(default) " :
"");
1656 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1666 void PrintExpr(
const Expr *FromExpr,
const Expr *ToExpr,
bool FromDefault,
1667 bool ToDefault,
bool Same) {
1668 assert((FromExpr || ToExpr) &&
1669 "Only one template argument may be missing.");
1671 PrintExpr(FromExpr);
1672 }
else if (!PrintTree) {
1673 OS << (FromDefault ?
"(default) " :
"");
1675 PrintExpr(FromExpr);
1678 OS << (FromDefault ?
"[(default) " :
"[");
1680 PrintExpr(FromExpr);
1682 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1691 void PrintExpr(
const Expr *E) {
1696 OS <<
"(no argument)";
1702 bool FromDefault,
bool ToDefault,
bool Same) {
1703 assert((FromTD || ToTD) &&
"Only one template argument may be missing.");
1705 std::string FromName = FromTD ? FromTD->
getName() :
"(no argument)";
1706 std::string ToName = ToTD ? ToTD->
getName() :
"(no argument)";
1707 if (FromTD && ToTD && FromName == ToName) {
1714 }
else if (!PrintTree) {
1715 OS << (FromDefault ?
"(default) template " :
"template ");
1720 OS << (FromDefault ?
"[(default) template " :
"[template ");
1724 OS <<
" != " << (ToDefault ?
"(default) template " :
"template ");
1734 void PrintAPSInt(
const llvm::APSInt &FromInt,
const llvm::APSInt &ToInt,
1735 bool IsValidFromInt,
bool IsValidToInt,
QualType FromIntType,
1737 bool FromDefault,
bool ToDefault,
bool Same) {
1738 assert((IsValidFromInt || IsValidToInt) &&
1739 "Only one integral argument may be missing.");
1743 OS << ((FromInt == 0) ?
"false" :
"true");
1745 OS << FromInt.toString(10);
1750 bool PrintType = IsValidFromInt && IsValidToInt &&
1754 OS << (FromDefault ?
"(default) " :
"");
1755 PrintAPSInt(FromInt, FromExpr, IsValidFromInt, FromIntType, PrintType);
1757 OS << (FromDefault ?
"[(default) " :
"[");
1758 PrintAPSInt(FromInt, FromExpr, IsValidFromInt, FromIntType, PrintType);
1759 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1760 PrintAPSInt(ToInt, ToExpr, IsValidToInt, ToIntType, PrintType);
1767 void PrintAPSInt(
const llvm::APSInt &Val,
Expr *E,
bool Valid,
1768 QualType IntType,
bool PrintType) {
1771 if (HasExtraInfo(E)) {
1787 OS << ((Val == 0) ?
"false" :
"true");
1789 OS << Val.toString(10);
1794 OS <<
"(no argument)";
1801 bool HasExtraInfo(
Expr *E) {
1802 if (!E)
return false;
1806 if (isa<IntegerLiteral>(E))
return false;
1809 if (UO->getOpcode() == UO_Minus)
1810 if (isa<IntegerLiteral>(UO->getSubExpr()))
1813 if (isa<CXXBoolLiteralExpr>(E))
1819 void PrintValueDecl(
ValueDecl *VD,
bool AddressOf,
Expr *E,
bool NullPtr) {
1828 if (E && !isa<CXXNullPtrLiteralExpr>(E)) {
1843 OS <<
"(no argument)";
1849 bool FromAddressOf,
bool ToAddressOf,
bool FromNullPtr,
1850 bool ToNullPtr,
Expr *FromExpr,
Expr *ToExpr,
1851 bool FromDefault,
bool ToDefault,
bool Same) {
1852 assert((FromValueDecl || FromNullPtr || ToValueDecl || ToNullPtr) &&
1853 "Only one Decl argument may be NULL");
1856 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1857 }
else if (!PrintTree) {
1858 OS << (FromDefault ?
"(default) " :
"");
1860 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1863 OS << (FromDefault ?
"[(default) " :
"[");
1865 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1867 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1869 PrintValueDecl(ToValueDecl, ToAddressOf, ToExpr, ToNullPtr);
1877 void PrintValueDeclAndInteger(
ValueDecl *VD,
bool NeedAddressOf,
1878 bool IsNullPtr,
Expr *VDExpr,
bool DefaultDecl,
1879 const llvm::APSInt &Val,
QualType IntType,
1880 Expr *IntExpr,
bool DefaultInt) {
1882 OS << (DefaultDecl ?
"(default) " :
"");
1884 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1887 OS << (DefaultDecl ?
"[(default) " :
"[");
1889 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1891 OS <<
" != " << (DefaultInt ?
"(default) " :
"");
1892 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1899 void PrintIntegerAndValueDecl(
const llvm::APSInt &Val,
QualType IntType,
1901 bool NeedAddressOf,
bool IsNullPtr,
1902 Expr *VDExpr,
bool DefaultDecl) {
1904 OS << (DefaultInt ?
"(default) " :
"");
1905 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1907 OS << (DefaultInt ?
"[(default) " :
"[");
1908 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1909 OS <<
" != " << (DefaultDecl ?
"(default) " :
"");
1911 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1918 void PrintElideArgs(
unsigned NumElideArgs,
unsigned Indent) {
1924 if (NumElideArgs == 0)
return;
1925 if (NumElideArgs == 1)
1928 OS <<
"[" << NumElideArgs <<
" * ...]";
1938 if (FromQual == ToQual) {
1939 PrintQualifier(FromQual,
false);
1959 if (CommonQual.
empty() && FromQual.
empty()) {
1961 OS <<
"(no qualifiers) ";
1964 PrintQualifier(CommonQual,
false);
1965 PrintQualifier(FromQual,
true);
1970 OS <<
"(no qualifiers)";
1973 PrintQualifier(CommonQual,
false,
1975 PrintQualifier(ToQual,
true,
1980 PrintQualifier(CommonQual,
false);
1981 PrintQualifier(FromQual,
true);
1985 void PrintQualifier(
Qualifiers Q,
bool ApplyBold,
1986 bool AppendSpaceIfNonEmpty =
true) {
1987 if (Q.
empty())
return;
1988 if (ApplyBold) Bold();
1989 Q.
print(OS, Policy, AppendSpaceIfNonEmpty);
1990 if (ApplyBold) Unbold();
1996 QualType ToType,
bool PrintTree,
bool PrintFromType,
1997 bool ElideType,
bool ShowColor)
2000 ElideType(ElideType),
2001 PrintTree(PrintTree),
2002 ShowColor(ShowColor),
2004 FromTemplateType(PrintFromType ? FromType : ToType),
2005 ToTemplateType(PrintFromType ? ToType : FromType),
2011 void DiffTemplate() {
2016 GetTemplateSpecializationType(Context, FromTemplateType);
2018 GetTemplateSpecializationType(Context, ToTemplateType);
2021 if (!FromOrigTST || !ToOrigTST)
2025 if (!hasSameTemplate(FromOrigTST, ToOrigTST)) {
2035 FromQual, ToQual,
false ,
2038 DiffTemplate(FromOrigTST, ToOrigTST);
2045 Tree.StartTraverse();
2050 assert(!IsBold &&
"Bold is applied to end of string.");
2061 bool PrintFromType,
bool ElideType,
2062 bool ShowColors, raw_ostream &OS) {
2064 PrintFromType =
true;
2065 TemplateDiff TD(OS, Context, FromType, ToType, PrintTree, PrintFromType,
2066 ElideType, ShowColors);
Defines the clang::ASTContext interface.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
const char * getSpelling() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
C Language Family Type Representation.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
The base class of the type hierarchy.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamedDecl * getParam(unsigned Idx)
This file provides some common utility functions for processing Lambda related AST Constructs...
static Qualifiers fromOpaqueValue(unsigned opaque)
const T * getAs() const
Member-template getAs<specific type>'.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
QualType getObjCClassType() const
Represents the Objective-C Class type.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents the result of substituting a type for a template type parameter.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
The collection of all-type qualifiers we support.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
static std::string ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, ArrayRef< intptr_t > QualTypeVals)
Convert the given type to a string suitable for printing as part of a diagnostic. ...
Represents a class template specialization, which refers to a class template with a given set of temp...
Represents a class type in Objective C.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
QualType getParamTypeForDecl() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
An rvalue reference type, per C++11 [dcl.ref].
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation...
const clang::PrintingPolicy & getPrintingPolicy() const
Represents a declaration of a type.
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
Represents a prototype with parameter type info, e.g.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
unsigned TemplateDiffUsed
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
static DeclarationName getFromOpaqueInteger(uintptr_t P)
Get a declaration name from an opaque integer returned by getAsOpaqueInteger.
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
const NamedDecl * FromDecl
RecordDecl * getDecl() const
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
QualType getCanonicalType() const
param_type_range param_types() const
ExtProtoInfo getExtProtoInfo() const
Sugar for parentheses used when specifying types.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
QualType getElementType() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
const char ToggleHighlight
Special character that the diagnostic printer will use to toggle the bold attribute.
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
TypeClass getTypeClass() const
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
bool isVectorType() const
static QualType getFromOpaquePtr(const void *Ptr)
ast_type_traits::DynTypedNode Node
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Optional< types::ID > Type
Dataflow Directional Tag Classes.
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
A qualifier set is used to build a set of qualifiers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Represents a pointer to an Objective C object.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
DiagnosticsEngine argument formatting function for diagnostics that involve AST nodes.
unsigned getNumArgs() const
Retrieve the number of template arguments.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
The template argument is a type.
The template argument is actually a parameter pack.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
ArgKind getKind() const
Return the kind of stored template argument.
An attributed type is a type to which a type attribute has been applied.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
QualType getAliasedType() const
Get the aliased type, if this is a specialization of a type alias template.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
__DEVICE__ int min(int __a, int __b)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
std::string getQualifiedNameAsString() const
unsigned getNumElements() const
QualType getAsType() const
Retrieve the type for a type template argument.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Represents a type template specialization; the template must be a class template, a type alias templa...
bool isPointerType() const
This represents a decl that may have a name.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
static bool FormatTemplateTypeDiff(ASTContext &Context, QualType FromType, QualType ToType, bool PrintTree, bool PrintFromType, bool ElideType, bool ShowColors, raw_ostream &OS)
FormatTemplateTypeDiff - A helper static function to start the template diff and return the properly ...
const LangOptions & getLangOpts() const
Attr - This represents one attribute.