This revision was automatically updated to reflect the committed changes. Closed by commit rG333771f3558c: [Sema] Avoid isNullPointerConstant invocation (authored by justinstitt, committed by nickdesaulniers).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131532/new/ https://reviews.llvm.org/D131532 Files: clang/lib/Sema/SemaChecking.cpp Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13355,9 +13355,10 @@ return; // Check for NULL (GNUNull) or nullptr (CXX11_nullptr). - const Expr::NullPointerConstantKind NullKind = - E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull); - if (NullKind != Expr::NPCK_GNUNull && NullKind != Expr::NPCK_CXX11_nullptr) + const Expr *NewE = E->IgnoreParenImpCasts(); + bool IsGNUNullExpr = isa<GNUNullExpr>(NewE); + bool HasNullPtrType = NewE->getType()->isNullPtrType(); + if (!IsGNUNullExpr && !HasNullPtrType) return; // Return if target type is a safe conversion. @@ -13374,7 +13375,7 @@ CC = S.SourceMgr.getTopMacroCallerLoc(CC); // __null is usually wrapped in a macro. Go up a macro if that is the case. - if (NullKind == Expr::NPCK_GNUNull && Loc.isMacroID()) { + if (IsGNUNullExpr && Loc.isMacroID()) { StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics( Loc, S.SourceMgr, S.getLangOpts()); if (MacroName == "NULL") @@ -13386,7 +13387,7 @@ return; S.Diag(Loc, diag::warn_impcast_null_pointer_to_integer) - << (NullKind == Expr::NPCK_CXX11_nullptr) << T << SourceRange(CC) + << HasNullPtrType << T << SourceRange(CC) << FixItHint::CreateReplacement(Loc, S.getFixItZeroLiteralForType(T, Loc)); }
Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13355,9 +13355,10 @@ return; // Check for NULL (GNUNull) or nullptr (CXX11_nullptr). - const Expr::NullPointerConstantKind NullKind = - E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull); - if (NullKind != Expr::NPCK_GNUNull && NullKind != Expr::NPCK_CXX11_nullptr) + const Expr *NewE = E->IgnoreParenImpCasts(); + bool IsGNUNullExpr = isa<GNUNullExpr>(NewE); + bool HasNullPtrType = NewE->getType()->isNullPtrType(); + if (!IsGNUNullExpr && !HasNullPtrType) return; // Return if target type is a safe conversion. @@ -13374,7 +13375,7 @@ CC = S.SourceMgr.getTopMacroCallerLoc(CC); // __null is usually wrapped in a macro. Go up a macro if that is the case. - if (NullKind == Expr::NPCK_GNUNull && Loc.isMacroID()) { + if (IsGNUNullExpr && Loc.isMacroID()) { StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics( Loc, S.SourceMgr, S.getLangOpts()); if (MacroName == "NULL") @@ -13386,7 +13387,7 @@ return; S.Diag(Loc, diag::warn_impcast_null_pointer_to_integer) - << (NullKind == Expr::NPCK_CXX11_nullptr) << T << SourceRange(CC) + << HasNullPtrType << T << SourceRange(CC) << FixItHint::CreateReplacement(Loc, S.getFixItZeroLiteralForType(T, Loc)); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits