|
12 | 12 | /// |
13 | 13 | //===----------------------------------------------------------------------===// |
14 | 14 |
|
| 15 | +#include "clang/AST/ASTContext.h" |
15 | 16 | #include "clang/AST/Decl.h" |
16 | 17 | #include "clang/AST/Expr.h" |
17 | 18 | #include "clang/AST/StmtVisitor.h" |
@@ -243,25 +244,25 @@ bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, |
243 | 244 |
|
244 | 245 | // FIXME: for some reason diagnostics highlight the end character, while |
245 | 246 | // getSourceText() does not include the end character. |
246 | | -static SourceRange getAttrNameRangeImpl(Sema &S, SourceLocation Begin, |
| 247 | +static SourceRange getAttrNameRangeImpl(const ASTContext &Ctx, SourceLocation Begin, |
247 | 248 | bool IsForDiagnostics) { |
248 | | - SourceManager &SM = S.getSourceManager(); |
| 249 | + const SourceManager &SM = Ctx.getSourceManager(); |
249 | 250 | SourceLocation TokenStart = Begin; |
250 | 251 | while (TokenStart.isMacroID()) |
251 | 252 | TokenStart = SM.getImmediateExpansionRange(TokenStart).getBegin(); |
252 | 253 | unsigned Offset = IsForDiagnostics ? 1 : 0; |
253 | | - SourceLocation End = S.getLocForEndOfToken(TokenStart, Offset); |
| 254 | + SourceLocation End = Lexer::getLocForEndOfToken(TokenStart, Offset, SM, Ctx.getLangOpts()); |
254 | 255 | return {TokenStart, End}; |
255 | 256 | } |
256 | 257 |
|
257 | | -StringRef BoundsAttributedTypeLoc::getAttrNameAsWritten(Sema &S) const { |
258 | | - SourceRange Range = getAttrNameRangeImpl(S, getAttrRange().getBegin(), false); |
| 258 | +StringRef BoundsAttributedTypeLoc::getAttrNameAsWritten(const ASTContext &Ctx) const { |
| 259 | + SourceRange Range = getAttrNameRangeImpl(Ctx, getAttrRange().getBegin(), false); |
259 | 260 | CharSourceRange NameRange = CharSourceRange::getCharRange(Range); |
260 | | - return Lexer::getSourceText(NameRange, S.getSourceManager(), S.getLangOpts()); |
| 261 | + return Lexer::getSourceText(NameRange, Ctx.getSourceManager(), Ctx.getLangOpts()); |
261 | 262 | } |
262 | 263 |
|
263 | | -SourceRange BoundsAttributedTypeLoc::getAttrNameRange(Sema &S) const { |
264 | | - return getAttrNameRangeImpl(S, getAttrRange().getBegin(), true); |
| 264 | +SourceRange BoundsAttributedTypeLoc::getAttrNameRange(const ASTContext &Ctx) const { |
| 265 | + return getAttrNameRangeImpl(Ctx, getAttrRange().getBegin(), true); |
265 | 266 | } |
266 | 267 |
|
267 | 268 | static TypeSourceInfo *getTSI(const Decl *D) { |
@@ -333,9 +334,9 @@ static void EmitIncompleteCountedByPointeeNotes(Sema &S, |
333 | 334 | << CATy->isOrNull(); |
334 | 335 | return; |
335 | 336 | } |
336 | | - SourceRange AttrSrcRange = CATL.getAttrNameRange(S); |
| 337 | + SourceRange AttrSrcRange = CATL.getAttrNameRange(S.getASTContext()); |
337 | 338 |
|
338 | | - StringRef Spelling = CATL.getAttrNameAsWritten(S); |
| 339 | + StringRef Spelling = CATL.getAttrNameAsWritten(S.getASTContext()); |
339 | 340 | StringRef FixedSpelling = |
340 | 341 | llvm::StringSwitch<StringRef>(Spelling) |
341 | 342 | .Case("__counted_by", "__sized_by") |
|
0 commit comments