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 = "fdd62de9a5f3c92436f91fadedc7578e295c38da"
LLVM_COMMIT_SHA = "bf2e4585d248af8f9998bff8d252a2cc0bc77a37"

def llvm_loader_repository_dependencies():
# This *declares* the dependency, but it won't actually be *downloaded* unless it's used.
Expand Down
21 changes: 21 additions & 0 deletions nullability/test/check_macros.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@ TEST void checkNERightSmartPointer(std::unique_ptr<int> P) {
nonnull(P);
}

// Test where a loop can result in Top pointer null states.
// Make sure we can still do a null check after the loop, despite the Top
// null state.
TEST void checkNEAfterLoop(int* _Nullable P, int Bound, bool B) {
int X = 17;
for (int I = 0; I < Bound; ++I) {
if (B) P = &X;
}
CHECK_NE(P, nullptr);
nonnull(P);
}

TEST void checkNEAfterLoopSmartPointer(_Nullable std::unique_ptr<int> P,
int Bound, bool B) {
for (int I = 0; I < Bound; ++I) {
if (B) P = std::make_unique<int>(17);
}
CHECK_NE(P, nullptr);
nonnull(P);
}

TEST void utilCheckNEImplModelEqualAndNull() {
int *P = nullptr;
// `P` is definitely equal to `nullptr`, so result is nonnull.
Expand Down
12 changes: 11 additions & 1 deletion nullability/value_transferer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,18 @@ static void modelGetReferenceableValue(const CallExpr& CE, Environment& Env) {
if (!CE.isGLValue()) return;
assert(CE.getNumArgs() == 1);
assert(CE.getArg(0) != nullptr);
if (StorageLocation* Loc = Env.getStorageLocation(*CE.getArg(0)))
if (StorageLocation* Loc = Env.getStorageLocation(*CE.getArg(0))) {
Env.setStorageLocation(CE, *Loc);
// Normally, we do unpackPointerValue during an LValueToRValue conversion
// for raw pointers (smart pointers are already unpacked during
// ensureSmartPointerInitialized). Since the result of GetReferenceableValue
// is passed to a helper function (`CheckNE_Impl`), the LValueToRValue
// cast is in the separate function and not in the current function.
// Unpack as if the LValueToRValue happens in the current function.
if (isSupportedRawPointerType(CE.getArg(0)->getType())) {
unpackPointerValue(*Loc, Env);
}
}
}

// Models the Abseil-logging `CheckNE_Impl` function. Essentially, associates
Expand Down