From 2dc23f10e4251d63405efd42c272d15a0f22f5e8 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 6 Feb 2026 09:39:09 -0800 Subject: [PATCH] Integrate LLVM at llvm/llvm-project@304f5c8c9182 Updates LLVM usage to match [304f5c8c9182](https://github.com/llvm/llvm-project/commit/304f5c8c9182) PiperOrigin-RevId: 866498334 --- bazel/llvm.bzl | 2 +- nullability/inference/eligible_ranges.cc | 28 +++++++++++++----------- nullability/test/path_sensitive.cc | 6 +---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/bazel/llvm.bzl b/bazel/llvm.bzl index b5ea32a75..0f23a090f 100644 --- a/bazel/llvm.bzl +++ b/bazel/llvm.bzl @@ -53,7 +53,7 @@ def _llvm_loader_repository(repository_ctx): executable = False, ) -LLVM_COMMIT_SHA = "b4b8d4e5d062438289c60a832ec783d34cc31fa4" +LLVM_COMMIT_SHA = "304f5c8c9182610ac8ef2c730a675e38b836670e" def llvm_loader_repository_dependencies(): # This *declares* the dependency, but it won't actually be *downloaded* unless it's used. diff --git a/nullability/inference/eligible_ranges.cc b/nullability/inference/eligible_ranges.cc index 626974940..8b3d858ba 100644 --- a/nullability/inference/eligible_ranges.cc +++ b/nullability/inference/eligible_ranges.cc @@ -124,15 +124,16 @@ static std::optional getEndOffsetOfEastQualifierAnnotation( /// annotation, returns the begin offset of the annotation. Else, returns /// std::nullopt. static std::optional getBeginOffsetOfWestQualifierAnnotation( - SourceLocation BeginningOfPtr, const SourceManager &SM, - const LangOptions &LangOpts, const FileID &DeclFID) { - Token PrevTok = utils::lexer::getPreviousToken(BeginningOfPtr, SM, LangOpts); - if (!PrevTok.is(tok::raw_identifier)) return std::nullopt; + SourceLocation BeginningOfPtr, const SourceManager& SM, + const LangOptions& LangOpts, const FileID& DeclFID) { + std::optional PrevTok = + utils::lexer::getPreviousToken(BeginningOfPtr, SM, LangOpts); + if (!PrevTok || !PrevTok->is(tok::raw_identifier)) return std::nullopt; - if (!isQualifierPositionAnnotation(PrevTok.getRawIdentifier())) + if (!isQualifierPositionAnnotation(PrevTok->getRawIdentifier())) return std::nullopt; - auto [FID, Offset] = SM.getDecomposedLoc(PrevTok.getLocation()); + auto [FID, Offset] = SM.getDecomposedLoc(PrevTok->getLocation()); if (FID != DeclFID) return std::nullopt; return Offset; @@ -147,16 +148,17 @@ static bool isCVR(llvm::StringRef ID) { } static SourceLocation includePrecedingCVRQualifiers( - SourceLocation Begin, const SourceManager &SM, const LangOptions &LangOpts, + SourceLocation Begin, const SourceManager& SM, const LangOptions& LangOpts, bool AfterNewlinePrefixesIfIdentifier = true) { std::optional FinalQualifierSeen; // Update `Begin` as we search and find qualifier tokens. - Token Tok = utils::lexer::getPreviousToken(Begin, SM, LangOpts); - while (!Tok.is(tok::unknown)) { - if (!Tok.is(tok::raw_identifier)) break; - if (!isCVR(skipEscapedNewLinePrefixes(Tok.getRawIdentifier()))) break; - FinalQualifierSeen = Tok; - Begin = Tok.getLocation(); + std::optional Tok = + utils::lexer::getPreviousToken(Begin, SM, LangOpts); + while (Tok && !Tok->is(tok::unknown)) { + if (!Tok->is(tok::raw_identifier)) break; + if (!isCVR(skipEscapedNewLinePrefixes(Tok->getRawIdentifier()))) break; + FinalQualifierSeen = *Tok; + Begin = Tok->getLocation(); Tok = utils::lexer::getPreviousToken(Begin, SM, LangOpts); } diff --git a/nullability/test/path_sensitive.cc b/nullability/test/path_sensitive.cc index 87ad55f91..1bbc89a87 100644 --- a/nullability/test/path_sensitive.cc +++ b/nullability/test/path_sensitive.cc @@ -48,11 +48,7 @@ TEST(PointerNullabilityTest, ConditionalInitialization2) { b = return_bool(); if (!b) p = produce_int(); - // TODO(b/307492164): False negative. This dereference is unsafe. - // This false negative likely happens because we don't model a return - // value for the `return_bool()` call above, so the `false` value that `b` - // is initialized with does not get overwritten. - (void)*p; + (void)*p; // [[unsafe]] } )cc")); }