diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-14 14:06:37 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-15 00:34:24 -0400 |
commit | af4fb416bd355960ce93f271a0591f24f58d25ec (patch) | |
tree | 0d19fff9f0f2a9378c9d5c6ae8e30386c364af17 /clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp | |
parent | 159b2d8e62b833c472be13f15d19e54cc9c69e70 (diff) | |
download | llvm-af4fb416bd355960ce93f271a0591f24f58d25ec.zip llvm-af4fb416bd355960ce93f271a0591f24f58d25ec.tar.gz llvm-af4fb416bd355960ce93f271a0591f24f58d25ec.tar.bz2 |
clang/StaticAnalyzer: Stop using SourceManager::getBuffer
Update clang/lib/StaticAnalyzer to stop relying on a `MemoryBuffer*`,
using the `MemoryBufferRef` from `getBufferOrNone` or the
`Optional<MemoryBufferRef>` from `getBufferOrFake`, depending on whether
there's logic for checking validity of the buffer. The change to
clang/lib/StaticAnalyzer/Core/IssueHash.cpp is potentially a
functionality change, since the logic was wrong (it checked for
`nullptr`, which was never returned by the old API), but if that was
reachable the new behaviour should be better.
Differential Revision: https://reviews.llvm.org/D89414
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp index 252377f..28d3e05 100644 --- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -1141,10 +1141,9 @@ void EmptyLocalizationContextChecker::MethodCrawler::VisitObjCMessageExpr( SE = Mgr.getSourceManager().getSLocEntry(SLInfo.first); } - bool Invalid = false; - const llvm::MemoryBuffer *BF = - Mgr.getSourceManager().getBuffer(SLInfo.first, SL, &Invalid); - if (Invalid) + llvm::Optional<llvm::MemoryBufferRef> BF = + Mgr.getSourceManager().getBufferOrNone(SLInfo.first, SL); + if (!BF) return; Lexer TheLexer(SL, LangOptions(), BF->getBufferStart(), |