[clang] [Clang][AST] Add source range for deleted and defaulted functions (PR #205408)
Shreyansh Lodha via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 15 16:49:48 PDT 2026
lodha1503 wrote:
@AaronBallman
Source range for = delete / = default
Per your suggestion, switched to PrevTokLocation unconditionally for the range end (Parser.cpp + ParseCXXInlineMethods.cpp), for both = delete/= default, with or without a message. No more getLocForEndOfToken/MeasureTokenLength arithmetic — PrevTokLocation is tracked natively as tokens are consumed, so it can't corrupt macro locations. Fixes the crash cleanly and matches the existing SetRangeEnd(PrevTokLocation) idiom used elsewhere (ParseExprCXX.cpp).
Note: this moves the range end from end-of-token to start-of-token for the no-message case.
8 pre-existing tests updated to match the new column values (all taken from actual rebuilt-compiler output, not hand-computed): SourceLocationTest.cpp, RecursiveASTVisitorTests/CXXMethodDecl.cpp (worth a look — Sema reuses getEndLoc() for compiler-synthesized code in implicit defaulted special members, so this shifts those too), ast-dump-decl.cpp, ast-dump-funcs.cpp, ast-dump-record-definition-data-json.cpp, the analyzer's path-notes.cpp.plist golden file, CoverageMapping/default-method.cpp, and this PR's own test.
Full check-clang suite: 0 failures (53,909 tests).
https://github.com/llvm/llvm-project/pull/205408
More information about the cfe-commits
mailing list