Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bazel/llvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 15 additions & 13 deletions nullability/inference/eligible_ranges.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,16 @@ static std::optional<unsigned> getEndOffsetOfEastQualifierAnnotation(
/// annotation, returns the begin offset of the annotation. Else, returns
/// std::nullopt.
static std::optional<unsigned> 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<Token> 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;
Expand All @@ -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<Token> 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<Token> 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);
}

Expand Down
6 changes: 1 addition & 5 deletions nullability/test/path_sensitive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down