diff options
| author | Richard Trieu <rtrieu@google.com> | 2016-01-15 05:48:38 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2016-01-15 05:48:38 +0000 |
| commit | 2331c8bdd3df632891fa4bc066b76e69ce3bb8e6 (patch) | |
| tree | 385142cdf4a387349294583921e849b047458e80 /clang/lib | |
| parent | 9213ce559a17138b67270b2cea0ec38e6bce5096 (diff) | |
| download | bcm5719-llvm-2331c8bdd3df632891fa4bc066b76e69ce3bb8e6.tar.gz bcm5719-llvm-2331c8bdd3df632891fa4bc066b76e69ce3bb8e6.zip | |
Fixing more issues with template type diffing
1) Print qualifiers for templates with zero arguments
2) Add a few more tests for the template type diffing refactoring.
Specifically, PR24587 has been fixed and has a test case from
http://reviews.llvm.org/D15384
3) Adds asserts to check the DiffTree is in correct state when moving nodes
4) Rename the field FromType and ToType since it is heavily used within
member functions.
llvm-svn: 257870
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTDiagnostic.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 12774c67233..cff92513298 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -473,14 +473,14 @@ class TemplateDiff { /// ShowColor - Diagnostics support color, so bolding will be used. bool ShowColor; - /// FromType - When single type printing is selected, this is the type to be - /// be printed. When tree printing is selected, this type will show up first - /// in the tree. - QualType FromType; + /// FromTemplateType - When single type printing is selected, this is the + /// type to be be printed. When tree printing is selected, this type will + /// show up first in the tree. + QualType FromTemplateType; - /// ToType - The type that FromType is compared to. Only in tree printing - /// will this type be outputed. - QualType ToType; + /// ToTemplateType - The type that FromType is compared to. Only in tree + /// printing will this type be outputed. + QualType ToTemplateType; /// OS - The stream used to construct the output strings. raw_ostream &OS; @@ -704,12 +704,16 @@ class TemplateDiff { /// Up - Changes the node to the parent of the current node. void Up() { + assert(FlatTree[CurrentNode].Kind != Invalid && + "Cannot exit node before setting node information."); CurrentNode = FlatTree[CurrentNode].ParentNode; } /// AddNode - Adds a child node to the current node, then sets that node /// node as the current node. void AddNode() { + assert(FlatTree[CurrentNode].Kind == Template && + "Only Template nodes can have children nodes."); FlatTree.push_back(DiffNode(CurrentNode)); DiffNode &Node = FlatTree[CurrentNode]; if (Node.ChildNode == 0) { @@ -1032,7 +1036,7 @@ class TemplateDiff { // These functions build up the template diff tree, including functions to // retrieve and compare template arguments. - static const TemplateSpecializationType * GetTemplateSpecializationType( + static const TemplateSpecializationType *GetTemplateSpecializationType( ASTContext &Context, QualType Ty) { if (const TemplateSpecializationType *TST = Ty->getAs<TemplateSpecializationType>()) @@ -1507,6 +1511,8 @@ class TemplateDiff { Qualifiers FromQual, ToQual; Tree.GetTemplateDiff(FromTD, ToTD, FromQual, ToQual); + PrintQualifiers(FromQual, ToQual); + if (!Tree.HasChildren()) { // If we're dealing with a template specialization with zero // arguments, there are no children; special-case this. @@ -1514,8 +1520,6 @@ class TemplateDiff { return; } - PrintQualifiers(FromQual, ToQual); - OS << FromTD->getNameAsString() << '<'; Tree.MoveToChild(); unsigned NumElideArgs = 0; @@ -1962,21 +1966,21 @@ public: PrintTree(PrintTree), ShowColor(ShowColor), // When printing a single type, the FromType is the one printed. - FromType(PrintFromType ? FromType : ToType), - ToType(PrintFromType ? ToType : FromType), + FromTemplateType(PrintFromType ? FromType : ToType), + ToTemplateType(PrintFromType ? ToType : FromType), OS(OS), IsBold(false) { } /// DiffTemplate - Start the template type diffing. void DiffTemplate() { - Qualifiers FromQual = FromType.getQualifiers(), - ToQual = ToType.getQualifiers(); + Qualifiers FromQual = FromTemplateType.getQualifiers(), + ToQual = ToTemplateType.getQualifiers(); const TemplateSpecializationType *FromOrigTST = - GetTemplateSpecializationType(Context, FromType); + GetTemplateSpecializationType(Context, FromTemplateType); const TemplateSpecializationType *ToOrigTST = - GetTemplateSpecializationType(Context, ToType); + GetTemplateSpecializationType(Context, ToTemplateType); // Only checking templates. if (!FromOrigTST || !ToOrigTST) |

