forked from OSchip/llvm-project
Fix null ptr crash dumping TemplateTemplateParmDecl
The following program winds up with D->getDefaultArgStorage().getInheritedFrom() == nullptr during dumping the TemplateTemplateParmDecl corresponding to the template parameter of i. template <typename> struct R; template <template <typename> class = R> void i(); This patch fixes the null pointer dereference.
This commit is contained in:
parent
de3fa35cdb
commit
967ebad125
|
@ -887,9 +887,10 @@ void JSONNodeDumper::VisitTemplateTemplateParmDecl(
|
|||
|
||||
if (D->hasDefaultArgument())
|
||||
JOS.attributeObject("defaultArg", [=] {
|
||||
const auto *InheritedFrom = D->getDefaultArgStorage().getInheritedFrom();
|
||||
Visit(D->getDefaultArgument().getArgument(),
|
||||
D->getDefaultArgStorage().getInheritedFrom()->getSourceRange(),
|
||||
D->getDefaultArgStorage().getInheritedFrom(),
|
||||
InheritedFrom ? InheritedFrom->getSourceRange() : SourceLocation{},
|
||||
InheritedFrom,
|
||||
D->defaultArgumentWasInherited() ? "inherited from" : "previous");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ template <typename Ty>
|
|||
template <typename Uy>
|
||||
void V<Ty>::f() {}
|
||||
|
||||
template <template <typename> class = R>
|
||||
void i();
|
||||
|
||||
// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
|
||||
|
||||
|
||||
|
@ -2578,6 +2581,127 @@ void V<Ty>::f() {}
|
|||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "FunctionTemplateDecl",
|
||||
// CHECK-NEXT: "loc": {
|
||||
// CHECK-NEXT: "offset": 922,
|
||||
// CHECK-NEXT: "line": 59,
|
||||
// CHECK-NEXT: "col": 6,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 876,
|
||||
// CHECK-NEXT: "line": 58,
|
||||
// CHECK-NEXT: "col": 1,
|
||||
// CHECK-NEXT: "tokLen": 8
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 924,
|
||||
// CHECK-NEXT: "line": 59,
|
||||
// CHECK-NEXT: "col": 8,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "name": "i",
|
||||
// CHECK-NEXT: "inner": [
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "TemplateTemplateParmDecl",
|
||||
// CHECK-NEXT: "loc": {
|
||||
// CHECK-NEXT: "offset": 912,
|
||||
// CHECK-NEXT: "line": 58,
|
||||
// CHECK-NEXT: "col": 37,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 886,
|
||||
// CHECK-NEXT: "col": 11,
|
||||
// CHECK-NEXT: "tokLen": 8
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 914,
|
||||
// CHECK-NEXT: "col": 39,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "depth": 0,
|
||||
// CHECK-NEXT: "index": 0,
|
||||
// CHECK-NEXT: "defaultArg": {
|
||||
// CHECK-NEXT: "kind": "TemplateArgument"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "inner": [
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "TemplateTypeParmDecl",
|
||||
// CHECK-NEXT: "loc": {
|
||||
// CHECK-NEXT: "offset": 904,
|
||||
// CHECK-NEXT: "col": 29,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 896,
|
||||
// CHECK-NEXT: "col": 21,
|
||||
// CHECK-NEXT: "tokLen": 8
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 896,
|
||||
// CHECK-NEXT: "col": 21,
|
||||
// CHECK-NEXT: "tokLen": 8
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "tagUsed": "typename",
|
||||
// CHECK-NEXT: "depth": 1,
|
||||
// CHECK-NEXT: "index": 0
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "kind": "TemplateArgument",
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 914,
|
||||
// CHECK-NEXT: "col": 39,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 914,
|
||||
// CHECK-NEXT: "col": 39,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "FunctionDecl",
|
||||
// CHECK-NEXT: "loc": {
|
||||
// CHECK-NEXT: "offset": 922,
|
||||
// CHECK-NEXT: "line": 59,
|
||||
// CHECK-NEXT: "col": 6,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 917,
|
||||
// CHECK-NEXT: "col": 1,
|
||||
// CHECK-NEXT: "tokLen": 4
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 924,
|
||||
// CHECK-NEXT: "col": 8,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "name": "i",
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "void ()"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
||||
|
|
Loading…
Reference in New Issue