)]}'
{
  "commit": "1cb47c19f8eca4badd8fb5e1a1b1cf4aaab607b8",
  "tree": "d93a81d4d8c5b14cc7c416039397fff7b334f8d3",
  "parents": [
    "f6e8b26eab8324a60f437fdb3e88e5d5105c9845"
  ],
  "author": {
    "name": "Andrey Ali Khan Bolshakov",
    "email": "bolsh.andrey@yandex.ru",
    "time": "Thu Sep 04 18:32:12 2025 +0300"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Sep 04 15:32:12 2025 +0000"
  },
  "message": "[clang] Remove written template args from implicit var tpl spec (#156329)\n\n`VarTemplateSpecializationDecl::getTemplateArgsAsWritten()` function\nshould return `nullptr` in the case of implicit instantiation, as its\n`ClassTemplateSpecializationDecl` counterpart does, and not the\narguments written in `DeclRefExpr` referencing the specialization in the\nfirst place. Otherwise, for such code:\n```cpp\ntemplate \u003ctypename\u003e\nint VarTpl;\n\ntemplate \u003ctypename T\u003e\nvoid tplFn() {\n  (void)VarTpl\u003cT\u003e;  // (1)\n}\n\nvoid fn() {\n  tplFn\u003cchar\u003e();\n}\n```\nClang treats the `char` argument of the `VarTpl` specialization as if it\nwere written in the line marked as (1), which is misleading and hardly\nmakes sense.\n\nMoreover, \"template args as written\" are stored inside `ExplicitInfo`\nfield of `VarTemplateSpecializationDecl`, but it is\n[documented](https://github.com/llvm/llvm-project/blob/13357e8a12c1a45364a0c4d3137b6d21ee6ac40c/clang/include/clang/AST/DeclTemplate.h#L2653)\nthat it is not for implicit instantiations.\n\nMoreover, it is assumed in `TraverseVarTemplateSpecializationDecl`\nmethod of `RecursiveASTVisitor` that `getTemplateArgsAsWritten()`\nreturns `nullptr` for implicit instantiations, as it is stated in the\ncomment\n[there](https://github.com/llvm/llvm-project/blob/13357e8a12c1a45364a0c4d3137b6d21ee6ac40c/clang/include/clang/AST/RecursiveASTVisitor.h#L2196).\n\nThat said, `setTemplateArgsAsWritten` should be called only for variable\ntemplate explicit specializations (it is [already done inside\n`Sema::ActOnVarTemplateSpecialization`](https://github.com/llvm/llvm-project/blob/4c916273041ff5ed7b2af20bec787ffc42871c9f/clang/lib/Sema/SemaTemplate.cpp#L4459))\nand explicit instantiations (hence `true` is passed to the new\n`SetWrittenArgs` parameter of `CheckVarTemplateId` function inside\n`Sema::ActOnExplicitInstantiation`, but not when handling expressions\nreferencing a variable template specialization).\n`InstantiateVariableDefinition` function just passes the arguments from\nthe corresponding declaration. I\u0027m not sure about instantiating a class\ntemplate containing a variable template explicit specialization and thus\nhave tried to leave the logic of the first overload of\n`TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl` as it\nwas.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e13de5ecb8d159f0860c0c1749fa3f2aed2c3731",
      "old_mode": 33188,
      "old_path": "clang/docs/ReleaseNotes.rst",
      "new_id": "bec001bf8e3536d813ecd069ae7c84c5973ef10d",
      "new_mode": 33188,
      "new_path": "clang/docs/ReleaseNotes.rst"
    },
    {
      "type": "modify",
      "old_id": "059ea4e066fcbe77510cc889dc14dd7e3c7e1b8c",
      "old_mode": 33188,
      "old_path": "clang/include/clang/Sema/Sema.h",
      "new_id": "88b67eed5fd3773824c6e0814734dec78b9f3655",
      "new_mode": 33188,
      "new_path": "clang/include/clang/Sema/Sema.h"
    },
    {
      "type": "modify",
      "old_id": "fe907078af275466d5fe297e02d3ed690553d126",
      "old_mode": 33188,
      "old_path": "clang/include/clang/Sema/Template.h",
      "new_id": "115c19d4f1540fc4157dfeafa73e06c0e5197eb4",
      "new_mode": 33188,
      "new_path": "clang/include/clang/Sema/Template.h"
    },
    {
      "type": "modify",
      "old_id": "4a31a139eaf4f450c5f309d8340dd8ab2b2b9ca8",
      "old_mode": 33188,
      "old_path": "clang/lib/Sema/SemaExprMember.cpp",
      "new_id": "aedfc5e88b1c6adba1873e0a985daff99e4a9b4d",
      "new_mode": 33188,
      "new_path": "clang/lib/Sema/SemaExprMember.cpp"
    },
    {
      "type": "modify",
      "old_id": "3d8416ac7dc1bc30933db83ec728f8863b1ae2c7",
      "old_mode": 33188,
      "old_path": "clang/lib/Sema/SemaTemplate.cpp",
      "new_id": "3533871ad4dad58cb6432cb14355748365a00bac",
      "new_mode": 33188,
      "new_path": "clang/lib/Sema/SemaTemplate.cpp"
    },
    {
      "type": "modify",
      "old_id": "ee1b520fa46e9464a828b5a8f68f26a5c1ccf0e1",
      "old_mode": 33188,
      "old_path": "clang/lib/Sema/SemaTemplateInstantiateDecl.cpp",
      "new_id": "910f99d3eb1606363438c91f700e15b7ec456453",
      "new_mode": 33188,
      "new_path": "clang/lib/Sema/SemaTemplateInstantiateDecl.cpp"
    },
    {
      "type": "modify",
      "old_id": "4c83ff9142e8726b41453e91ce5d1cb893cb2b81",
      "old_mode": 33188,
      "old_path": "clang/unittests/AST/DeclTest.cpp",
      "new_id": "e76edbfe95b687aac37e3e2f111cca2291456efc",
      "new_mode": 33188,
      "new_path": "clang/unittests/AST/DeclTest.cpp"
    }
  ]
}
