diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-29 18:10:07 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-09-29 18:10:41 +0000 |
| commit | 4bbf1f460eb3fabdb7cf7cd731af0c227e6539c8 (patch) | |
| tree | 8fb51c31848f1d9835688ea1730410efb2c3f7ee /clang/lib/Sema/SemaChecking.cpp | |
| parent | 8092e001bcd76c0b9fec2311f3a515aa60d2ed07 (diff) | |
Vendor import of llvm-project branch release/17.x llvmorg-17.0.1-25-g098e653a5bed.vendor/llvm-project/llvmorg-17.0.1-25-g098e653a5bed
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index f8e48728da66..8626fc6ea16f 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -11308,7 +11308,11 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, Hints.push_back( FixItHint::CreateInsertion(E->getBeginLoc(), CastFix.str())); - SourceLocation After = S.getLocForEndOfToken(E->getEndLoc()); + // We don't use getLocForEndOfToken because it returns invalid source + // locations for macro expansions (by design). + SourceLocation EndLoc = S.SourceMgr.getSpellingLoc(E->getEndLoc()); + SourceLocation After = EndLoc.getLocWithOffset( + Lexer::MeasureTokenLength(EndLoc, S.SourceMgr, S.LangOpts)); Hints.push_back(FixItHint::CreateInsertion(After, ")")); } |
