[clang] [clang][Parser] Fix FunctionDecl source range for out-of-class '= delete'/'= default' definitions (PR #167007)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 9 06:11:29 PST 2025


================
@@ -1374,6 +1379,18 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
                                                   : MultiTemplateParamsArg(),
                                               &SkipBody, BodyKind);
 
+  auto updateFuncRangeEnd = [&](Decl *D) {
+    if (!FuncRangeEnd.isValid() || !D)
+      return;
+    if (auto *FD = dyn_cast<FunctionDecl>(D)) {
+      FD->setRangeEnd(FuncRangeEnd);
+    } else if (auto *FT = dyn_cast<FunctionTemplateDecl>(D)) {
----------------
zwuis wrote:

`ActOnStartOfFunctionDef` always returns `FunctionDecl *` or `FunctionTemplateDecl *`. You don't need to call `dyn_cast`.

https://github.com/llvm/llvm-project/pull/167007


More information about the cfe-commits mailing list