Reikriam

update clang patch

Jun 5th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
  2. index 6a3d2b30e46..6c1c59a4625 100644
  3. --- a/clang/lib/AST/TemplateBase.cpp
  4. +++ b/clang/lib/AST/TemplateBase.cpp
  5. @@ -352,8 +352,38 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
  6.  
  7. case Declaration: {
  8. NamedDecl *ND = getAsDecl();
  9. - if (!getParamTypeForDecl()->isReferenceType())
  10. - Out << '&';
  11. + bool needsRef = true;
  12. + if (auto *VD = dyn_cast<ValueDecl>(ND)) {
  13. + const clang::Type *ArgTy = VD->getType()->getUnqualifiedDesugaredType();
  14. + const clang::Type *ParmTy =
  15. + getParamTypeForDecl()->getUnqualifiedDesugaredType();
  16. + clang::ASTContext &Ctx = ND->getASTContext();
  17. + needsRef = !Ctx.hasSameType(ArgTy, ParmTy);
  18. + if (needsRef && (ArgTy->isArrayType() || ArgTy->isFunctionType())) {
  19. + const clang::Type *decayedArgTy =
  20. + Ctx.getDecayedType(clang::QualType(ArgTy, 0)).getTypePtr();
  21. + needsRef = !Ctx.hasSameType(decayedArgTy, ParmTy);
  22. + if (!needsRef) {
  23. + int deptharg = 0, depthparam = 0;
  24. + clang::QualType NestArgTy = VD->getType();
  25. + while (const auto *Array =
  26. + dyn_cast<ArrayType>(NestArgTy.getCanonicalType())) {
  27. + deptharg++;
  28. + NestArgTy = Array->getElementType();
  29. + }
  30. + clang::QualType NestParmTy = getParamTypeForDecl();
  31. + while (const auto *Array =
  32. + dyn_cast<ArrayType>(NestParmTy.getCanonicalType())) {
  33. + depthparam++;
  34. + NestParmTy = Array->getElementType();
  35. + }
  36. + if ((deptharg > 0) && (depthparam > 0) && (deptharg != depthparam))
  37. + needsRef = true;
  38. + }
  39. + }
  40. + }
  41. + if (!getParamTypeForDecl()->isReferenceType() && needsRef)
  42. + Out << "&";
  43. ND->printQualifiedName(Out);
  44. break;
  45. }
  46. diff --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  47. index 15f625d8832..780ef8da681 100644
  48. --- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  49. +++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  50. @@ -98,7 +98,7 @@ template <typename T, void (*)(void)>
  51. void fn_tmpl() {}
  52.  
  53. template void fn_tmpl<int, freefunc>();
  54. -// CHECK-DAG: "fn_tmpl<int,&freefunc>"
  55. +// CHECK-DAG: "fn_tmpl<int,freefunc>"
  56.  
  57. template <typename A, typename B, typename C> struct ClassTemplate { A a; B b; C c; };
  58. ClassTemplate<char, short, ClassTemplate<int, int, int> > f;
  59. diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp
  60. index a07222ace15..c79441cbb5c 100644
  61. --- a/clang/test/CodeGenCXX/debug-info-template.cpp
  62. +++ b/clang/test/CodeGenCXX/debug-info-template.cpp
  63. @@ -1,6 +1,6 @@
  64. // RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s
  65.  
  66. -// CHECK: @tci = dso_local global %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested" zeroinitializer, align 1, !dbg [[TCI:![0-9]+]]
  67. +// CHECK: @tci = dso_local global %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, foo::g, 1, 2, 3>::nested" zeroinitializer, align 1, !dbg [[TCI:![0-9]+]]
  68. // CHECK: @tcn = dso_local global %struct.TC zeroinitializer, align 1, !dbg [[TCN:![0-9]+]]
  69. // CHECK: @nn = dso_local global %struct.NN zeroinitializer, align 1, !dbg [[NN:![0-9]+]]
  70.  
  71. @@ -31,7 +31,7 @@ void func();
  72. // CHECK: ![[TCNESTED]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "nested",
  73. // CHECK-SAME: scope: ![[TC:[0-9]+]],
  74.  
  75. -// CHECK: ![[TC]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>"
  76. +// CHECK: ![[TC]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TC<unsigned int, 2, &glb, &foo::e, &foo::f, foo::g, 1, 2, 3>"
  77. // CHECK-SAME: templateParams: [[TCARGS:![0-9]*]]
  78. TC
  79. // CHECK: [[TCARGS]] = !{[[TCARG1:![0-9]*]], [[TCARG2:![0-9]*]], [[TCARG3:![0-9]*]], [[TCARG4:![0-9]*]], [[TCARG5:![0-9]*]], [[TCARG6:![0-9]*]], [[TCARG7:![0-9]*]]}
  80. diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
  81. index 460b6def5d6..cf1a352c0d9 100644
  82. --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
  83. +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
  84. @@ -65,3 +65,27 @@ namespace PR42513 {
  85.  
  86. void use() { f<X1>(); }
  87. }
  88. +
  89. +using FourChars = const char[4];
  90. +constexpr FourChars kEta = "Eta";
  91. +constexpr const char* kNull = "Phi";
  92. +
  93. +char *kDummyFiller = (char*)"Hello1";
  94. +constexpr char **kDummy = &kDummyFiller;
  95. +
  96. +template <const char*, typename T> class Column {};
  97. +template <const char[], typename T> class Dolumn {};
  98. +template <const char(*)[4], typename T> class Folumn {};
  99. +template <FourChars*, typename T> class Golumn {};
  100. +template <const char* const *, typename T> class Holumn {};
  101. +template <char** const*, typename T> class Jolumn {};
  102. +
  103. +void lookup() {
  104. + Column<kEta,double>().ls(); // expected-error {{<kEta,}}
  105. + Column<nullptr, double>().ls(); // expected-error {{<nullptr,}}
  106. + Dolumn<kEta, double>().ls(); // expected-error {{<kEta,}}
  107. + Folumn<&kEta, double>().ls(); // expected-error {{<&kEta,}}
  108. + Golumn<&kEta, double>().ls(); // expected-error {{<&kEta,}}
  109. + Holumn<&kNull, double>().ls(); // expected-error {{<&kNull,}}
  110. + Jolumn<&kDummy, double>().ls(); // expected-error {{<&kDummy,}}
  111. +}
Add Comment
Please, Sign In to add comment