diff options
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index ea4f3476b6c..fe47bfb12e9 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -6748,6 +6748,17 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, << FixItHint::CreateInsertion(getLocForEndOfToken(E->getLocEnd()), "()"); } +void Sema::CheckAlwaysNonNullPointer(Expr *OrigExpr) { + if (const UnaryOperator *U = dyn_cast<UnaryOperator>(OrigExpr)) + if (U->getOpcode() == UO_LNot) + return CheckAlwaysNonNullPointer(U->getSubExpr()); + + Expr *E = OrigExpr->IgnoreParenImpCasts(); + QualType Source = E->getType(); + if (Source->isPointerType() || Source->canDecayToPointerType()) + DiagnoseAlwaysNonNullPointer(E, Expr::NPCK_NotNull, /*IsEqual*/ false, + SourceRange()); +} /// Diagnoses "dangerous" implicit conversions within the given /// expression (which is a full expression). Implements -Wconversion |