23 #include "llvm/Support/raw_ostream.h" 25 using namespace clang;
41 if (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
47 dyn_cast<SubstTemplateTypeParmType>(Ty)) {
57 if (
const AdjustedType *AT = dyn_cast<AdjustedType>(Ty)) {
62 if (
const AutoType *AT = dyn_cast<AutoType>(Ty)) {
71 if (
const FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
72 bool DesugarReturn =
false;
73 QualType SugarRT = FT->getReturnType();
80 bool DesugarArgument =
false;
86 if (
auto nullability =
95 if (DesugarReturn || DesugarArgument) {
106 dyn_cast<TemplateSpecializationType>(Ty)) {
107 if (!TST->isTypeAlias()) {
108 bool DesugarArgument =
false;
110 for (
unsigned I = 0, N = TST->getNumArgs(); I != N; ++I) {
118 if (DesugarArgument) {
121 TST->getTemplateName(), Args, QT);
141 bool IsSugar =
false;
143 #define ABSTRACT_TYPE(Class, Base) 144 #define TYPE(Class, Base) \ 145 case Type::Class: { \ 146 const Class##Type *CTy = cast<Class##Type>(Ty); \ 147 if (CTy->isSugared()) { \ 149 Underlying = CTy->desugar(); \ 153 #include "clang/AST/TypeNodes.def" 162 if (isa<VectorType>(Underlying))
167 if (
const TypedefType *QTT = dyn_cast<TypedefType>(QT))
168 if (UTT->getDecl()->getTypedefNameForAnonDecl() == QTT->getDecl())
191 if (Ty->getBaseType().getTypePtr() != Ty && !ShouldAKA) {
194 llvm::makeArrayRef(Ty->qual_begin(),
195 Ty->getNumProtocols()),
196 Ty->isKindOfTypeAsWritten());
200 return QC.
apply(Context, QT);
232 bool ForceAKA =
false;
237 for (
unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
245 if (CompareCanTy == CanTy)
248 bool ShouldAKA =
false;
250 std::string CompareDesugarStr =
252 if (CompareS != S && CompareDesugarStr != S)
255 std::string CompareCanS =
258 if (CompareCanS == CanS)
267 bool Repeated =
false;
268 for (
unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
271 void *Ptr = (
void*)PrevArgs[i].second;
283 bool ShouldAKA =
false;
285 if (ShouldAKA || ForceAKA) {
286 if (DesugaredTy == Ty) {
291 S =
"'" + S +
"' (aka '" + akaStr +
"')";
301 std::string DecoratedString;
302 llvm::raw_string_ostream OS(DecoratedString);
303 const char *Values = VTy->
getNumElements() > 1 ?
"values" :
"value";
304 OS <<
"'" << S <<
"' (vector of " << VTy->
getNumElements() <<
" '" 306 <<
"' " << Values <<
")";
317 bool PrintFromType,
bool ElideType,
318 bool ShowColors, raw_ostream &OS);
331 size_t OldEnd = Output.size();
332 llvm::raw_svector_ostream OS(Output);
333 bool NeedQuotes =
true;
336 default: llvm_unreachable(
"unknown ArgumentKind");
338 assert(Modifier.empty() && Argument.empty() &&
339 "Invalid modifier for Qualfiers argument");
342 auto S = Q.getAsString();
347 OS << Q.getAsString();
374 Modifier = StringRef();
375 Argument = StringRef();
380 assert(Modifier.empty() && Argument.empty() &&
381 "Invalid modifier for QualType argument");
389 if (Modifier ==
"objcclass" && Argument.empty())
391 else if (Modifier ==
"objcinstance" && Argument.empty())
394 assert(Modifier.empty() && Argument.empty() &&
395 "Invalid modifier for DeclarationName argument");
402 if (Modifier ==
"q" && Argument.empty())
405 assert(Modifier.empty() && Argument.empty() &&
406 "Invalid modifier for NamedDecl* argument");
421 assert(DC &&
"Should never have a null declaration context");
427 OS <<
"the global namespace";
429 OS <<
"the global scope";
431 OS <<
"block literal";
433 OS <<
"lambda expression";
437 PrevArgs, QualTypeVals);
439 assert(isa<NamedDecl>(DC) &&
"Expected a NamedDecl");
441 if (isa<NamespaceDecl>(ND))
443 else if (isa<ObjCMethodDecl>(ND))
445 else if (isa<FunctionDecl>(ND))
455 const Attr *At =
reinterpret_cast<Attr *
>(Val);
456 assert(At &&
"Received null Attr object!");
464 Output.insert(Output.begin()+OldEnd,
'\'');
465 Output.push_back(
'\'');
530 FromIntegerAndToDeclaration,
531 FromDeclarationAndToInteger
538 struct TemplateArgumentInfo {
542 bool IsValidInt =
false;
543 Expr *ArgExpr =
nullptr;
546 bool NeedAddressOf =
false;
547 bool IsNullPtr =
false;
548 bool IsDefault =
false;
555 DiffKind
Kind = Invalid;
558 unsigned NextNode = 0;
561 unsigned ChildNode = 0;
564 unsigned ParentNode = 0;
566 TemplateArgumentInfo FromArgInfo, ToArgInfo;
571 DiffNode(
unsigned ParentNode = 0) : ParentNode(ParentNode) {}
578 unsigned CurrentNode;
582 unsigned NextFreeNode;
589 CurrentNode(0), NextFreeNode(1) {
590 FlatTree.push_back(DiffNode());
596 bool FromDefault,
bool ToDefault) {
597 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
598 FlatTree[CurrentNode].Kind = Template;
599 FlatTree[CurrentNode].FromArgInfo.TD = FromTD;
600 FlatTree[CurrentNode].ToArgInfo.TD = ToTD;
601 FlatTree[CurrentNode].FromArgInfo.Qual = FromQual;
602 FlatTree[CurrentNode].ToArgInfo.Qual = ToQual;
603 SetDefault(FromDefault, ToDefault);
608 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
609 FlatTree[CurrentNode].Kind =
Type;
610 FlatTree[CurrentNode].FromArgInfo.ArgType = FromType;
611 FlatTree[CurrentNode].ToArgInfo.ArgType = ToType;
612 SetDefault(FromDefault, ToDefault);
615 void SetExpressionDiff(
Expr *FromExpr,
Expr *ToExpr,
bool FromDefault,
617 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
618 FlatTree[CurrentNode].Kind = Expression;
619 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
620 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
621 SetDefault(FromDefault, ToDefault);
625 bool FromDefault,
bool ToDefault) {
626 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
627 FlatTree[CurrentNode].Kind = TemplateTemplate;
628 FlatTree[CurrentNode].FromArgInfo.TD = FromTD;
629 FlatTree[CurrentNode].ToArgInfo.TD = ToTD;
630 SetDefault(FromDefault, ToDefault);
633 void SetIntegerDiff(
const llvm::APSInt &FromInt,
const llvm::APSInt &ToInt,
634 bool IsValidFromInt,
bool IsValidToInt,
636 Expr *FromExpr,
Expr *ToExpr,
bool FromDefault,
638 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
639 FlatTree[CurrentNode].Kind =
Integer;
640 FlatTree[CurrentNode].FromArgInfo.Val = FromInt;
641 FlatTree[CurrentNode].ToArgInfo.Val = ToInt;
642 FlatTree[CurrentNode].FromArgInfo.IsValidInt = IsValidFromInt;
643 FlatTree[CurrentNode].ToArgInfo.IsValidInt = IsValidToInt;
644 FlatTree[CurrentNode].FromArgInfo.ArgType = FromIntType;
645 FlatTree[CurrentNode].ToArgInfo.ArgType = ToIntType;
646 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
647 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
648 SetDefault(FromDefault, ToDefault);
652 bool FromAddressOf,
bool ToAddressOf,
653 bool FromNullPtr,
bool ToNullPtr,
Expr *FromExpr,
654 Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
655 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
656 FlatTree[CurrentNode].Kind = Declaration;
657 FlatTree[CurrentNode].FromArgInfo.VD = FromValueDecl;
658 FlatTree[CurrentNode].ToArgInfo.VD = ToValueDecl;
659 FlatTree[CurrentNode].FromArgInfo.NeedAddressOf = FromAddressOf;
660 FlatTree[CurrentNode].ToArgInfo.NeedAddressOf = ToAddressOf;
661 FlatTree[CurrentNode].FromArgInfo.IsNullPtr = FromNullPtr;
662 FlatTree[CurrentNode].ToArgInfo.IsNullPtr = ToNullPtr;
663 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
664 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
665 SetDefault(FromDefault, ToDefault);
668 void SetFromDeclarationAndToIntegerDiff(
669 ValueDecl *FromValueDecl,
bool FromAddressOf,
bool FromNullPtr,
670 Expr *FromExpr,
const llvm::APSInt &ToInt,
bool IsValidToInt,
671 QualType ToIntType,
Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
672 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
673 FlatTree[CurrentNode].Kind = FromDeclarationAndToInteger;
674 FlatTree[CurrentNode].FromArgInfo.VD = FromValueDecl;
675 FlatTree[CurrentNode].FromArgInfo.NeedAddressOf = FromAddressOf;
676 FlatTree[CurrentNode].FromArgInfo.IsNullPtr = FromNullPtr;
677 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
678 FlatTree[CurrentNode].ToArgInfo.Val = ToInt;
679 FlatTree[CurrentNode].ToArgInfo.IsValidInt = IsValidToInt;
680 FlatTree[CurrentNode].ToArgInfo.ArgType = ToIntType;
681 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
682 SetDefault(FromDefault, ToDefault);
685 void SetFromIntegerAndToDeclarationDiff(
686 const llvm::APSInt &FromInt,
bool IsValidFromInt,
QualType FromIntType,
688 bool ToNullPtr,
Expr *ToExpr,
bool FromDefault,
bool ToDefault) {
689 assert(FlatTree[CurrentNode].
Kind == Invalid &&
"Node is not empty.");
690 FlatTree[CurrentNode].Kind = FromIntegerAndToDeclaration;
691 FlatTree[CurrentNode].FromArgInfo.Val = FromInt;
692 FlatTree[CurrentNode].FromArgInfo.IsValidInt = IsValidFromInt;
693 FlatTree[CurrentNode].FromArgInfo.ArgType = FromIntType;
694 FlatTree[CurrentNode].FromArgInfo.ArgExpr = FromExpr;
695 FlatTree[CurrentNode].ToArgInfo.VD = ToValueDecl;
696 FlatTree[CurrentNode].ToArgInfo.NeedAddressOf = ToAddressOf;
697 FlatTree[CurrentNode].ToArgInfo.IsNullPtr = ToNullPtr;
698 FlatTree[CurrentNode].ToArgInfo.ArgExpr = ToExpr;
699 SetDefault(FromDefault, ToDefault);
703 void SetDefault(
bool FromDefault,
bool ToDefault) {
704 assert((!FromDefault || !ToDefault) &&
"Both arguments cannot be default.");
705 FlatTree[CurrentNode].FromArgInfo.IsDefault = FromDefault;
706 FlatTree[CurrentNode].ToArgInfo.IsDefault = ToDefault;
710 void SetSame(
bool Same) {
711 FlatTree[CurrentNode].Same = Same;
715 void SetKind(DiffKind
Kind) {
716 FlatTree[CurrentNode].Kind =
Kind;
721 assert(FlatTree[CurrentNode].Kind != Invalid &&
722 "Cannot exit node before setting node information.");
723 CurrentNode = FlatTree[CurrentNode].ParentNode;
729 assert(FlatTree[CurrentNode].Kind == Template &&
730 "Only Template nodes can have children nodes.");
731 FlatTree.push_back(DiffNode(CurrentNode));
732 DiffNode &
Node = FlatTree[CurrentNode];
733 if (Node.ChildNode == 0) {
735 Node.ChildNode = NextFreeNode;
740 for (i = Node.ChildNode; FlatTree[i].NextNode != 0;
741 i = FlatTree[i].NextNode) {
743 FlatTree[i].NextNode = NextFreeNode;
745 CurrentNode = NextFreeNode;
751 void StartTraverse() {
753 CurrentNode = NextFreeNode;
759 ReadNode = FlatTree[ReadNode].ParentNode;
764 assert(FlatTree[ReadNode].Kind == Template &&
"Unexpected kind.");
765 FromTD = FlatTree[ReadNode].FromArgInfo.TD;
766 ToTD = FlatTree[ReadNode].ToArgInfo.TD;
767 FromQual = FlatTree[ReadNode].FromArgInfo.Qual;
768 ToQual = FlatTree[ReadNode].ToArgInfo.Qual;
772 assert(FlatTree[ReadNode].Kind ==
Type &&
"Unexpected kind");
773 FromType = FlatTree[ReadNode].FromArgInfo.ArgType;
774 ToType = FlatTree[ReadNode].ToArgInfo.ArgType;
777 void GetExpressionDiff(
Expr *&FromExpr,
Expr *&ToExpr) {
778 assert(FlatTree[ReadNode].Kind == Expression &&
"Unexpected kind");
779 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
780 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
784 assert(FlatTree[ReadNode].Kind == TemplateTemplate &&
"Unexpected kind.");
785 FromTD = FlatTree[ReadNode].FromArgInfo.TD;
786 ToTD = FlatTree[ReadNode].ToArgInfo.TD;
789 void GetIntegerDiff(llvm::APSInt &FromInt, llvm::APSInt &ToInt,
790 bool &IsValidFromInt,
bool &IsValidToInt,
793 assert(FlatTree[ReadNode].Kind ==
Integer &&
"Unexpected kind.");
794 FromInt = FlatTree[ReadNode].FromArgInfo.Val;
795 ToInt = FlatTree[ReadNode].ToArgInfo.Val;
796 IsValidFromInt = FlatTree[ReadNode].FromArgInfo.IsValidInt;
797 IsValidToInt = FlatTree[ReadNode].ToArgInfo.IsValidInt;
798 FromIntType = FlatTree[ReadNode].FromArgInfo.ArgType;
799 ToIntType = FlatTree[ReadNode].ToArgInfo.ArgType;
800 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
801 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
805 bool &FromAddressOf,
bool &ToAddressOf,
806 bool &FromNullPtr,
bool &ToNullPtr,
Expr *&FromExpr,
808 assert(FlatTree[ReadNode].Kind == Declaration &&
"Unexpected kind.");
809 FromValueDecl = FlatTree[ReadNode].FromArgInfo.VD;
810 ToValueDecl = FlatTree[ReadNode].ToArgInfo.VD;
811 FromAddressOf = FlatTree[ReadNode].FromArgInfo.NeedAddressOf;
812 ToAddressOf = FlatTree[ReadNode].ToArgInfo.NeedAddressOf;
813 FromNullPtr = FlatTree[ReadNode].FromArgInfo.IsNullPtr;
814 ToNullPtr = FlatTree[ReadNode].ToArgInfo.IsNullPtr;
815 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
816 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
819 void GetFromDeclarationAndToIntegerDiff(
820 ValueDecl *&FromValueDecl,
bool &FromAddressOf,
bool &FromNullPtr,
821 Expr *&FromExpr, llvm::APSInt &ToInt,
bool &IsValidToInt,
823 assert(FlatTree[ReadNode].Kind == FromDeclarationAndToInteger &&
825 FromValueDecl = FlatTree[ReadNode].FromArgInfo.VD;
826 FromAddressOf = FlatTree[ReadNode].FromArgInfo.NeedAddressOf;
827 FromNullPtr = FlatTree[ReadNode].FromArgInfo.IsNullPtr;
828 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
829 ToInt = FlatTree[ReadNode].ToArgInfo.Val;
830 IsValidToInt = FlatTree[ReadNode].ToArgInfo.IsValidInt;
831 ToIntType = FlatTree[ReadNode].ToArgInfo.ArgType;
832 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
835 void GetFromIntegerAndToDeclarationDiff(
836 llvm::APSInt &FromInt,
bool &IsValidFromInt,
QualType &FromIntType,
838 bool &ToNullPtr,
Expr *&ToExpr) {
839 assert(FlatTree[ReadNode].Kind == FromIntegerAndToDeclaration &&
841 FromInt = FlatTree[ReadNode].FromArgInfo.Val;
842 IsValidFromInt = FlatTree[ReadNode].FromArgInfo.IsValidInt;
843 FromIntType = FlatTree[ReadNode].FromArgInfo.ArgType;
844 FromExpr = FlatTree[ReadNode].FromArgInfo.ArgExpr;
845 ToValueDecl = FlatTree[ReadNode].ToArgInfo.VD;
846 ToAddressOf = FlatTree[ReadNode].ToArgInfo.NeedAddressOf;
847 ToNullPtr = FlatTree[ReadNode].ToArgInfo.IsNullPtr;
848 ToExpr = FlatTree[ReadNode].ToArgInfo.ArgExpr;
853 return FlatTree[ReadNode].FromArgInfo.IsDefault;
858 return FlatTree[ReadNode].ToArgInfo.IsDefault;
863 return FlatTree[ReadNode].Same;
868 return FlatTree[ReadNode].ChildNode != 0;
873 ReadNode = FlatTree[ReadNode].ChildNode;
878 bool AdvanceSibling() {
879 if (FlatTree[ReadNode].NextNode == 0)
882 ReadNode = FlatTree[ReadNode].NextNode;
887 bool HasNextSibling() {
888 return FlatTree[ReadNode].NextNode != 0;
893 return GetKind() == Invalid;
898 return FlatTree[ReadNode].Kind;
915 struct InternalIterator {
933 : TST(TST), Index(0), CurrentTA(
nullptr), EndTA(
nullptr) {
947 if (CurrentTA != EndTA)
return;
955 bool isValid()
const {
return TST; }
959 assert(TST &&
"InternalIterator is invalid with a null TST.");
964 InternalIterator &operator++() {
965 assert(TST &&
"InternalIterator is invalid with a null TST.");
971 if (CurrentTA != EndTA) {
973 if (CurrentTA != EndTA)
993 if (CurrentTA != EndTA)
1001 assert(TST &&
"InternalIterator is invalid with a null TST.");
1002 assert(!isEnd() &&
"Index exceeds number of arguments.");
1003 if (CurrentTA == EndTA)
1004 return TST->
getArg(Index);
1010 pointer operator->()
const {
1011 assert(TST &&
"InternalIterator is invalid with a null TST.");
1016 InternalIterator SugaredIterator;
1017 InternalIterator DesugaredIterator;
1021 : SugaredIterator(TST),
1024 ? GetTemplateSpecializationType(Context, TST->
desugar())
1028 TSTiterator &operator++() {
1030 if (DesugaredIterator.isValid())
1031 ++DesugaredIterator;
1037 return *SugaredIterator;
1041 pointer operator->()
const {
1046 bool isEnd()
const {
1047 return SugaredIterator.isEnd();
1052 bool hasDesugaredTA()
const {
1053 return DesugaredIterator.isValid() && !DesugaredIterator.isEnd();
1057 reference getDesugaredTA()
const {
1058 assert(DesugaredIterator.isValid() &&
1059 "Desugared TemplateArgument should not be used.");
1060 return *DesugaredIterator;
1103 FromArgTST = GetTemplateSpecializationType(Context, FromType);
1104 ToArgTST = GetTemplateSpecializationType(Context, ToType);
1106 if (!FromArgTST || !ToArgTST)
1109 if (!hasSameTemplate(FromArgTST, ToArgTST))
1116 void DiffTypes(
const TSTiterator &FromIter,
const TSTiterator &ToIter) {
1117 QualType FromType = GetType(FromIter);
1120 bool FromDefault = FromIter.isEnd() && !FromType.
isNull();
1121 bool ToDefault = ToIter.isEnd() && !ToType.
isNull();
1125 if (OnlyPerformTypeDiff(Context, FromType, ToType, FromArgTST, ToArgTST)) {
1126 Tree.SetTypeDiff(FromType, ToType, FromDefault, ToDefault);
1130 assert(FromArgTST && ToArgTST &&
1131 "Both template specializations need to be valid.");
1138 FromQual, ToQual, FromDefault, ToDefault);
1139 DiffTemplate(FromArgTST, ToArgTST);
1145 void DiffTemplateTemplates(
const TSTiterator &FromIter,
1146 const TSTiterator &ToIter) {
1149 Tree.SetTemplateTemplateDiff(FromDecl, ToDecl, FromIter.isEnd() &&
FromDecl,
1150 ToIter.isEnd() && ToDecl);
1151 Tree.SetSame(FromDecl && ToDecl &&
1156 static void InitializeNonTypeDiffVariables(
ASTContext &Context,
1157 const TSTiterator &Iter,
1159 llvm::APSInt &
Value,
bool &HasInt,
1160 QualType &IntType,
bool &IsNullPtr,
1162 bool &NeedAddressOf) {
1163 if (!Iter.isEnd()) {
1164 switch (Iter->getKind()) {
1166 llvm_unreachable(
"unknown ArgumentKind");
1168 Value = Iter->getAsIntegral();
1170 IntType = Iter->getIntegralType();
1173 VD = Iter->getAsDecl();
1174 QualType ArgType = Iter->getParamTypeForDecl();
1178 NeedAddressOf =
true;
1185 E = Iter->getAsExpr();
1191 if (!Iter.hasDesugaredTA())
return;
1196 llvm_unreachable(
"unknown ArgumentKind");
1208 NeedAddressOf =
true;
1226 void DiffNonTypes(
const TSTiterator &FromIter,
const TSTiterator &ToIter,
1229 Expr *FromExpr =
nullptr, *ToExpr =
nullptr;
1230 llvm::APSInt FromInt, ToInt;
1232 ValueDecl *FromValueDecl =
nullptr, *ToValueDecl =
nullptr;
1233 bool HasFromInt =
false, HasToInt =
false, FromNullPtr =
false,
1234 ToNullPtr =
false, NeedFromAddressOf =
false, NeedToAddressOf =
false;
1235 InitializeNonTypeDiffVariables(
1236 Context, FromIter, FromDefaultNonTypeDecl, FromInt, HasFromInt,
1237 FromIntType, FromNullPtr, FromExpr, FromValueDecl, NeedFromAddressOf);
1238 InitializeNonTypeDiffVariables(Context, ToIter, ToDefaultNonTypeDecl, ToInt,
1239 HasToInt, ToIntType, ToNullPtr, ToExpr,
1240 ToValueDecl, NeedToAddressOf);
1242 bool FromDefault = FromIter.isEnd() &&
1243 (FromExpr || FromValueDecl || HasFromInt || FromNullPtr);
1244 bool ToDefault = ToIter.isEnd() &&
1245 (ToExpr || ToValueDecl || HasToInt || ToNullPtr);
1247 bool FromDeclaration = FromValueDecl || FromNullPtr;
1248 bool ToDeclaration = ToValueDecl || ToNullPtr;
1250 if (FromDeclaration && HasToInt) {
1251 Tree.SetFromDeclarationAndToIntegerDiff(
1252 FromValueDecl, NeedFromAddressOf, FromNullPtr, FromExpr, ToInt,
1253 HasToInt, ToIntType, ToExpr, FromDefault, ToDefault);
1254 Tree.SetSame(
false);
1259 if (HasFromInt && ToDeclaration) {
1260 Tree.SetFromIntegerAndToDeclarationDiff(
1261 FromInt, HasFromInt, FromIntType, FromExpr, ToValueDecl,
1262 NeedToAddressOf, ToNullPtr, ToExpr, FromDefault, ToDefault);
1263 Tree.SetSame(
false);
1267 if (HasFromInt || HasToInt) {
1268 Tree.SetIntegerDiff(FromInt, ToInt, HasFromInt, HasToInt, FromIntType,
1269 ToIntType, FromExpr, ToExpr, FromDefault, ToDefault);
1270 if (HasFromInt && HasToInt) {
1271 Tree.SetSame(Context.
hasSameType(FromIntType, ToIntType) &&
1277 if (FromDeclaration || ToDeclaration) {
1278 Tree.SetDeclarationDiff(FromValueDecl, ToValueDecl, NeedFromAddressOf,
1279 NeedToAddressOf, FromNullPtr, ToNullPtr, FromExpr,
1280 ToExpr, FromDefault, ToDefault);
1281 bool BothNull = FromNullPtr && ToNullPtr;
1282 bool SameValueDecl =
1283 FromValueDecl && ToValueDecl &&
1284 NeedFromAddressOf == NeedToAddressOf &&
1286 Tree.SetSame(BothNull || SameValueDecl);
1290 assert((FromExpr || ToExpr) &&
"Both template arguments cannot be empty.");
1291 Tree.SetExpressionDiff(FromExpr, ToExpr, FromDefault, ToDefault);
1292 Tree.SetSame(IsEqualExpr(Context, FromExpr, ToExpr));
1304 unsigned TotalArgs = 0;
1305 for (TSTiterator FromIter(Context, FromTST), ToIter(Context, ToTST);
1306 !FromIter.isEnd() || !ToIter.isEnd(); ++TotalArgs) {
1312 unsigned FromParamIndex =
std::min(TotalArgs, ParamsFrom->
size() - 1);
1313 unsigned ToParamIndex =
std::min(TotalArgs, ParamsTo->
size() - 1);
1317 assert(FromParamND->getKind() == ToParamND->
getKind() &&
1318 "Parameter Decl are not the same kind.");
1320 if (isa<TemplateTypeParmDecl>(FromParamND)) {
1321 DiffTypes(FromIter, ToIter);
1322 }
else if (isa<TemplateTemplateParmDecl>(FromParamND)) {
1323 DiffTemplateTemplates(FromIter, ToIter);
1324 }
else if (isa<NonTypeTemplateParmDecl>(FromParamND)) {
1326 cast<NonTypeTemplateParmDecl>(FromParamND);
1328 cast<NonTypeTemplateParmDecl>(ToParamND);
1329 DiffNonTypes(FromIter, ToIter, FromDefaultNonTypeDecl,
1330 ToDefaultNonTypeDecl);
1332 llvm_unreachable(
"Unexpected Decl type.");
1342 static void makeTemplateList(
1346 TemplateList.push_back(TST);
1368 if (hasSameBaseTemplate(FromTST, ToTST))
1375 makeTemplateList(FromTemplateList, FromTST);
1376 makeTemplateList(ToTemplateList, ToTST);
1379 FromIter = FromTemplateList.rbegin(), FromEnd = FromTemplateList.rend(),
1380 ToIter = ToTemplateList.rbegin(), ToEnd = ToTemplateList.rend();
1383 if (!hasSameBaseTemplate(*FromIter, *ToIter))
1389 for (; FromIter != FromEnd && ToIter != ToEnd; ++FromIter, ++ToIter) {
1390 if (!hasSameBaseTemplate(*FromIter, *ToIter))
1394 FromTST = FromIter[-1];
1402 static QualType GetType(
const TSTiterator &Iter) {
1404 return Iter->getAsType();
1405 if (Iter.hasDesugaredTA())
1406 return Iter.getDesugaredTA().getAsType();
1412 static TemplateDecl *GetTemplateDecl(
const TSTiterator &Iter) {
1414 return Iter->getAsTemplate().getAsTemplateDecl();
1415 if (Iter.hasDesugaredTA())
1416 return Iter.getDesugaredTA().getAsTemplate().getAsTemplateDecl();
1424 if (FromExpr == ToExpr)
1427 if (!FromExpr || !ToExpr)
1430 llvm::FoldingSetNodeID FromID, ToID;
1431 FromExpr->
Profile(FromID, Context,
true);
1432 ToExpr->
Profile(ToID, Context,
true);
1433 return FromID == ToID;
1441 void TreeToString(
int Indent = 1) {
1444 OS.indent(2 * Indent);
1450 switch (Tree.GetKind()) {
1451 case DiffTree::Invalid:
1452 llvm_unreachable(
"Template diffing failed with bad DiffNode");
1455 Tree.GetTypeDiff(FromType, ToType);
1456 PrintTypeNames(FromType, ToType, Tree.FromDefault(), Tree.ToDefault(),
1460 case DiffTree::Expression: {
1461 Expr *FromExpr, *ToExpr;
1462 Tree.GetExpressionDiff(FromExpr, ToExpr);
1463 PrintExpr(FromExpr, ToExpr, Tree.FromDefault(), Tree.ToDefault(),
1467 case DiffTree::TemplateTemplate: {
1469 Tree.GetTemplateTemplateDiff(FromTD, ToTD);
1470 PrintTemplateTemplate(FromTD, ToTD, Tree.FromDefault(),
1471 Tree.ToDefault(), Tree.NodeIsSame());
1474 case DiffTree::Integer: {
1475 llvm::APSInt FromInt, ToInt;
1476 Expr *FromExpr, *ToExpr;
1477 bool IsValidFromInt, IsValidToInt;
1479 Tree.GetIntegerDiff(FromInt, ToInt, IsValidFromInt, IsValidToInt,
1480 FromIntType, ToIntType, FromExpr, ToExpr);
1481 PrintAPSInt(FromInt, ToInt, IsValidFromInt, IsValidToInt, FromIntType,
1482 ToIntType, FromExpr, ToExpr, Tree.FromDefault(),
1483 Tree.ToDefault(), Tree.NodeIsSame());
1486 case DiffTree::Declaration: {
1488 bool FromAddressOf, ToAddressOf;
1489 bool FromNullPtr, ToNullPtr;
1490 Expr *FromExpr, *ToExpr;
1491 Tree.GetDeclarationDiff(FromValueDecl, ToValueDecl, FromAddressOf,
1492 ToAddressOf, FromNullPtr, ToNullPtr, FromExpr,
1494 PrintValueDecl(FromValueDecl, ToValueDecl, FromAddressOf, ToAddressOf,
1495 FromNullPtr, ToNullPtr, FromExpr, ToExpr,
1496 Tree.FromDefault(), Tree.ToDefault(), Tree.NodeIsSame());
1499 case DiffTree::FromDeclarationAndToInteger: {
1508 Tree.GetFromDeclarationAndToIntegerDiff(
1509 FromValueDecl, FromAddressOf, FromNullPtr, FromExpr, ToInt,
1510 IsValidToInt, ToIntType, ToExpr);
1511 assert((FromValueDecl || FromNullPtr) && IsValidToInt);
1512 PrintValueDeclAndInteger(FromValueDecl, FromAddressOf, FromNullPtr,
1513 FromExpr, Tree.FromDefault(), ToInt, ToIntType,
1514 ToExpr, Tree.ToDefault());
1517 case DiffTree::FromIntegerAndToDeclaration: {
1518 llvm::APSInt FromInt;
1519 bool IsValidFromInt;
1526 Tree.GetFromIntegerAndToDeclarationDiff(
1527 FromInt, IsValidFromInt, FromIntType, FromExpr, ToValueDecl,
1528 ToAddressOf, ToNullPtr, ToExpr);
1529 assert(IsValidFromInt && (ToValueDecl || ToNullPtr));
1530 PrintIntegerAndValueDecl(FromInt, FromIntType, FromExpr,
1531 Tree.FromDefault(), ToValueDecl, ToAddressOf,
1532 ToNullPtr, ToExpr, Tree.ToDefault());
1535 case DiffTree::Template: {
1539 Tree.GetTemplateDiff(FromTD, ToTD, FromQual, ToQual);
1541 PrintQualifiers(FromQual, ToQual);
1543 if (!Tree.HasChildren()) {
1552 unsigned NumElideArgs = 0;
1553 bool AllArgsElided =
true;
1556 if (Tree.NodeIsSame()) {
1560 AllArgsElided =
false;
1561 if (NumElideArgs > 0) {
1562 PrintElideArgs(NumElideArgs, Indent);
1567 TreeToString(Indent);
1568 if (Tree.HasNextSibling())
1570 }
while (Tree.AdvanceSibling());
1571 if (NumElideArgs > 0) {
1575 PrintElideArgs(NumElideArgs, Indent);
1591 assert(!IsBold &&
"Attempting to bold text that is already bold.");
1599 assert(IsBold &&
"Attempting to remove bold from unbold text.");
1611 bool FromDefault,
bool ToDefault,
bool Same) {
1613 "Only one template argument may be missing.");
1625 PrintQualifiers(FromQual, ToQual);
1630 std::string FromTypeStr = FromType.
isNull() ?
"(no argument)" 1632 std::string ToTypeStr = ToType.
isNull() ?
"(no argument)" 1636 if (FromTypeStr == ToTypeStr) {
1637 std::string FromCanTypeStr =
1640 if (FromCanTypeStr != ToCanTypeStr) {
1641 FromTypeStr = FromCanTypeStr;
1642 ToTypeStr = ToCanTypeStr;
1646 if (PrintTree) OS <<
'[';
1647 OS << (FromDefault ?
"(default) " :
"");
1652 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1662 void PrintExpr(
const Expr *FromExpr,
const Expr *ToExpr,
bool FromDefault,
1663 bool ToDefault,
bool Same) {
1664 assert((FromExpr || ToExpr) &&
1665 "Only one template argument may be missing.");
1667 PrintExpr(FromExpr);
1668 }
else if (!PrintTree) {
1669 OS << (FromDefault ?
"(default) " :
"");
1671 PrintExpr(FromExpr);
1674 OS << (FromDefault ?
"[(default) " :
"[");
1676 PrintExpr(FromExpr);
1678 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1687 void PrintExpr(
const Expr *E) {
1692 OS <<
"(no argument)";
1698 bool FromDefault,
bool ToDefault,
bool Same) {
1699 assert((FromTD || ToTD) &&
"Only one template argument may be missing.");
1701 std::string FromName = FromTD ? FromTD->
getName() :
"(no argument)";
1702 std::string ToName = ToTD ? ToTD->
getName() :
"(no argument)";
1703 if (FromTD && ToTD && FromName == ToName) {
1710 }
else if (!PrintTree) {
1711 OS << (FromDefault ?
"(default) template " :
"template ");
1716 OS << (FromDefault ?
"[(default) template " :
"[template ");
1720 OS <<
" != " << (ToDefault ?
"(default) template " :
"template ");
1730 void PrintAPSInt(
const llvm::APSInt &FromInt,
const llvm::APSInt &ToInt,
1731 bool IsValidFromInt,
bool IsValidToInt,
QualType FromIntType,
1733 bool FromDefault,
bool ToDefault,
bool Same) {
1734 assert((IsValidFromInt || IsValidToInt) &&
1735 "Only one integral argument may be missing.");
1739 OS << ((FromInt == 0) ?
"false" :
"true");
1741 OS << FromInt.toString(10);
1746 bool PrintType = IsValidFromInt && IsValidToInt &&
1750 OS << (FromDefault ?
"(default) " :
"");
1751 PrintAPSInt(FromInt, FromExpr, IsValidFromInt, FromIntType, PrintType);
1753 OS << (FromDefault ?
"[(default) " :
"[");
1754 PrintAPSInt(FromInt, FromExpr, IsValidFromInt, FromIntType, PrintType);
1755 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1756 PrintAPSInt(ToInt, ToExpr, IsValidToInt, ToIntType, PrintType);
1763 void PrintAPSInt(
const llvm::APSInt &Val,
Expr *E,
bool Valid,
1764 QualType IntType,
bool PrintType) {
1767 if (HasExtraInfo(E)) {
1783 OS << ((Val == 0) ?
"false" :
"true");
1785 OS << Val.toString(10);
1790 OS <<
"(no argument)";
1797 bool HasExtraInfo(
Expr *E) {
1798 if (!E)
return false;
1802 if (isa<IntegerLiteral>(E))
return false;
1805 if (UO->getOpcode() == UO_Minus)
1806 if (isa<IntegerLiteral>(UO->getSubExpr()))
1809 if (isa<CXXBoolLiteralExpr>(E))
1815 void PrintValueDecl(
ValueDecl *VD,
bool AddressOf,
Expr *E,
bool NullPtr) {
1824 if (E && !isa<CXXNullPtrLiteralExpr>(E)) {
1839 OS <<
"(no argument)";
1845 bool FromAddressOf,
bool ToAddressOf,
bool FromNullPtr,
1846 bool ToNullPtr,
Expr *FromExpr,
Expr *ToExpr,
1847 bool FromDefault,
bool ToDefault,
bool Same) {
1848 assert((FromValueDecl || FromNullPtr || ToValueDecl || ToNullPtr) &&
1849 "Only one Decl argument may be NULL");
1852 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1853 }
else if (!PrintTree) {
1854 OS << (FromDefault ?
"(default) " :
"");
1856 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1859 OS << (FromDefault ?
"[(default) " :
"[");
1861 PrintValueDecl(FromValueDecl, FromAddressOf, FromExpr, FromNullPtr);
1863 OS <<
" != " << (ToDefault ?
"(default) " :
"");
1865 PrintValueDecl(ToValueDecl, ToAddressOf, ToExpr, ToNullPtr);
1873 void PrintValueDeclAndInteger(
ValueDecl *VD,
bool NeedAddressOf,
1874 bool IsNullPtr,
Expr *VDExpr,
bool DefaultDecl,
1875 const llvm::APSInt &Val,
QualType IntType,
1876 Expr *IntExpr,
bool DefaultInt) {
1878 OS << (DefaultDecl ?
"(default) " :
"");
1880 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1883 OS << (DefaultDecl ?
"[(default) " :
"[");
1885 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1887 OS <<
" != " << (DefaultInt ?
"(default) " :
"");
1888 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1895 void PrintIntegerAndValueDecl(
const llvm::APSInt &Val,
QualType IntType,
1897 bool NeedAddressOf,
bool IsNullPtr,
1898 Expr *VDExpr,
bool DefaultDecl) {
1900 OS << (DefaultInt ?
"(default) " :
"");
1901 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1903 OS << (DefaultInt ?
"[(default) " :
"[");
1904 PrintAPSInt(Val, IntExpr,
true , IntType,
false );
1905 OS <<
" != " << (DefaultDecl ?
"(default) " :
"");
1907 PrintValueDecl(VD, NeedAddressOf, VDExpr, IsNullPtr);
1914 void PrintElideArgs(
unsigned NumElideArgs,
unsigned Indent) {
1917 for (
unsigned i = 0; i < Indent; ++i)
1920 if (NumElideArgs == 0)
return;
1921 if (NumElideArgs == 1)
1924 OS <<
"[" << NumElideArgs <<
" * ...]";
1934 if (FromQual == ToQual) {
1935 PrintQualifier(FromQual,
false);
1955 if (CommonQual.
empty() && FromQual.
empty()) {
1957 OS <<
"(no qualifiers) ";
1960 PrintQualifier(CommonQual,
false);
1961 PrintQualifier(FromQual,
true);
1966 OS <<
"(no qualifiers)";
1969 PrintQualifier(CommonQual,
false,
1971 PrintQualifier(ToQual,
true,
1976 PrintQualifier(CommonQual,
false);
1977 PrintQualifier(FromQual,
true);
1981 void PrintQualifier(
Qualifiers Q,
bool ApplyBold,
1982 bool AppendSpaceIfNonEmpty =
true) {
1983 if (Q.
empty())
return;
1984 if (ApplyBold) Bold();
1985 Q.
print(OS, Policy, AppendSpaceIfNonEmpty);
1986 if (ApplyBold) Unbold();
1992 QualType ToType,
bool PrintTree,
bool PrintFromType,
1993 bool ElideType,
bool ShowColor)
1996 ElideType(ElideType),
1997 PrintTree(PrintTree),
1998 ShowColor(ShowColor),
2000 FromTemplateType(PrintFromType ? FromType : ToType),
2001 ToTemplateType(PrintFromType ? ToType : FromType),
2007 void DiffTemplate() {
2012 GetTemplateSpecializationType(Context, FromTemplateType);
2014 GetTemplateSpecializationType(Context, ToTemplateType);
2017 if (!FromOrigTST || !ToOrigTST)
2021 if (!hasSameTemplate(FromOrigTST, ToOrigTST)) {
2031 FromQual, ToQual,
false ,
2034 DiffTemplate(FromOrigTST, ToOrigTST);
2041 Tree.StartTraverse();
2046 assert(!IsBold &&
"Bold is applied to end of string.");
2057 bool PrintFromType,
bool ElideType,
2058 bool ShowColors, raw_ostream &OS) {
2060 PrintFromType =
true;
2061 TemplateDiff TD(OS, Context, FromType, ToType, PrintTree, PrintFromType,
2062 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.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
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...
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.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
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.
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.
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.
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.
Represents a type template specialization; the template must be a class template, a type alias templa...
bool isPointerType() const
__DEVICE__ int min(int __a, int __b)
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.