[clang] 298367e - [clang] Use nullptr instead of 0 or NULL (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 29 08:34:26 PST 2021
Author: Kazu Hirata
Date: 2021-12-29T08:34:20-08:00
New Revision: 298367ee6e36eeb1b193ad9fa92082c2ef2345a3
URL: https://github.com/llvm/llvm-project/commit/298367ee6e36eeb1b193ad9fa92082c2ef2345a3
DIFF: https://github.com/llvm/llvm-project/commit/298367ee6e36eeb1b193ad9fa92082c2ef2345a3.diff
LOG: [clang] Use nullptr instead of 0 or NULL (NFC)
Identified with modernize-use-nullptr.
Added:
Modified:
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/tools/libclang/CIndex.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 008b703d4c1a9..ac6f98e91f755 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8476,8 +8476,8 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const ASTContext *Context) {
FieldDecl *Field = FieldDecl::Create(
const_cast<ASTContext &>(*Context), VaListTagDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
- /*TInfo=*/0,
- /*BitWidth=*/0,
+ /*TInfo=*/nullptr,
+ /*BitWidth=*/nullptr,
/*Mutable=*/false, ICIS_NoInit);
Field->setAccess(AS_public);
VaListTagDecl->addDecl(Field);
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index c771fe264b0c8..774b3e94159db 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -194,7 +194,7 @@ void ConstantArrayType::Profile(llvm::FoldingSetNodeID &ID,
ID.AddInteger(ArraySize.getZExtValue());
ID.AddInteger(SizeMod);
ID.AddInteger(TypeQuals);
- ID.AddBoolean(SizeExpr != 0);
+ ID.AddBoolean(SizeExpr != nullptr);
if (SizeExpr)
SizeExpr->Profile(ID, Context, true);
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index e6adec6948aff..4814962a472d4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1595,9 +1595,9 @@ void CodeGenFunction::EmitBranchToCounterBlock(
if (!InstrumentRegions || !isInstrumentedCondition(Cond))
return EmitBranchOnBoolExpr(Cond, TrueBlock, FalseBlock, TrueCount, LH);
- llvm::BasicBlock *ThenBlock = NULL;
- llvm::BasicBlock *ElseBlock = NULL;
- llvm::BasicBlock *NextBlock = NULL;
+ llvm::BasicBlock *ThenBlock = nullptr;
+ llvm::BasicBlock *ElseBlock = nullptr;
+ llvm::BasicBlock *NextBlock = nullptr;
// Create the block we'll use to increment the appropriate counter.
llvm::BasicBlock *CounterIncrBlock = createBasicBlock("lop.rhscnt");
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 85089cdb2200e..d0ba4e44bffa5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8693,7 +8693,7 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
llvm::ConstantInt::get(CGF.Int32Ty, ArgSize),
"__new_saved_reg_area_pointer");
- llvm::Value *UsingStack = 0;
+ llvm::Value *UsingStack = nullptr;
UsingStack = CGF.Builder.CreateICmpSGT(__new_saved_reg_area_pointer,
__saved_reg_area_end_pointer);
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3b551ea94cc24..a4a53d989851c 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -437,7 +437,7 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
// Enforce -static if -miamcu is present.
if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false))
- DAL->AddFlagArg(0, Opts.getOption(options::OPT_static));
+ DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_static));
// Add a default value of -mlinker-version=, if one was given and the user
// didn't specify one.
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index a7298a9a71bfb..3614272a5f747 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -76,7 +76,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
const char *Crt1 = "crt1.o";
- const char *Entry = NULL;
+ const char *Entry = nullptr;
// If crt1-command.o exists, it supports new-style commands, so use it.
// Otherwise, use the old crt1.o. This is a temporary transition measure.
diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index 84eabc3a210f7..4ade8b8bb0741 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -256,7 +256,7 @@ IncrementalParser::Parse(llvm::StringRef input) {
/*LoadedOffset=*/0, NewLoc);
// NewLoc only used for diags.
- if (PP.EnterSourceFile(FID, /*DirLookup=*/0, NewLoc))
+ if (PP.EnterSourceFile(FID, /*DirLookup=*/nullptr, NewLoc))
return llvm::make_error<llvm::StringError>("Parsing failed. "
"Cannot enter source file.",
std::error_code());
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 38467a1835d0c..89e89c7c1f172 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2548,9 +2548,9 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
assert(CurPtr[0] == '\n' || CurPtr[0] == '\r');
// Position of the first trigraph in the ending sequence.
- const char *TrigraphPos = 0;
+ const char *TrigraphPos = nullptr;
// Position of the first whitespace after a '\' in the ending sequence.
- const char *SpacePos = 0;
+ const char *SpacePos = nullptr;
while (true) {
// Back up off the newline.
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index b957bec7493e1..e13387fb1fc8e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2804,7 +2804,8 @@ bool ConditionBRVisitor::patternMatch(const Expr *Ex,
Out << '\''
<< Lexer::getSourceText(
CharSourceRange::getTokenRange(Ex->getSourceRange()),
- BRC.getSourceManager(), BRC.getASTContext().getLangOpts(), 0)
+ BRC.getSourceManager(), BRC.getASTContext().getLangOpts(),
+ nullptr)
<< '\'';
}
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 4722bece7a1db..53494ecc7ae9d 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4949,7 +4949,7 @@ CXStringSet *clang_Cursor_getObjCManglings(CXCursor C) {
CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor C) {
if (clang_Cursor_isNull(C))
- return 0;
+ return nullptr;
return new PrintingPolicy(getCursorContext(C).getPrintingPolicy());
}
@@ -6975,16 +6975,16 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
- return NULL;
+ return nullptr;
}
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
if (!CXXUnit)
- return NULL;
+ return nullptr;
SourceLocation Begin = cxloc::translateSourceLocation(Location);
if (Begin.isInvalid())
- return NULL;
+ return nullptr;
SourceManager &SM = CXXUnit->getSourceManager();
std::pair<FileID, unsigned> DecomposedEnd = SM.getDecomposedLoc(Begin);
DecomposedEnd.second +=
@@ -6997,7 +6997,7 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
getTokens(CXXUnit, SourceRange(Begin, End), CXTokens);
if (CXTokens.empty())
- return NULL;
+ return nullptr;
CXTokens.resize(1);
CXToken *Token = static_cast<CXToken *>(llvm::safe_malloc(sizeof(CXToken)));
More information about the cfe-commits
mailing list