summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-06-08 08:38:04 +0000
committerCraig Topper <craig.topper@gmail.com>2014-06-08 08:38:04 +0000
commit085452490f953a5bb7b54827d99276029be1b6c6 (patch)
tree53fa750d4bf41c242862a4b909ae968c2a5a87ac /tools
parentfe9046f3ef2a3e82ca0d9d2de72cafdafdea9294 (diff)
downloadclang-085452490f953a5bb7b54827d99276029be1b6c6.tar.gz
clang-085452490f953a5bb7b54827d99276029be1b6c6.tar.bz2
clang-085452490f953a5bb7b54827d99276029be1b6c6.tar.xz
[C++11] Use 'nullptr'. Tools edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/arcmt-test/arcmt-test.cpp6
-rw-r--r--tools/diagtool/DiagTool.cpp2
-rw-r--r--tools/diagtool/DiagnosticNames.cpp6
-rw-r--r--tools/diagtool/DiagnosticNames.h4
-rw-r--r--tools/diagtool/ShowEnabledWarnings.cpp6
-rw-r--r--tools/driver/cc1as_main.cpp8
-rw-r--r--tools/driver/driver.cpp10
-rw-r--r--tools/libclang/ARCMigrate.cpp8
-rw-r--r--tools/libclang/CIndex.cpp143
-rw-r--r--tools/libclang/CIndexCXX.cpp4
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp30
-rw-r--r--tools/libclang/CIndexDiagnostic.cpp28
-rw-r--r--tools/libclang/CIndexHigh.cpp10
-rw-r--r--tools/libclang/CLog.h4
-rw-r--r--tools/libclang/CXComment.cpp8
-rw-r--r--tools/libclang/CXComment.h2
-rw-r--r--tools/libclang/CXCompilationDatabase.cpp8
-rw-r--r--tools/libclang/CXCursor.cpp32
-rw-r--r--tools/libclang/CXCursor.h4
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp16
-rw-r--r--tools/libclang/CXSourceLocation.cpp12
-rw-r--r--tools/libclang/CXString.cpp2
-rw-r--r--tools/libclang/CXTranslationUnit.h4
-rw-r--r--tools/libclang/CXType.cpp9
-rw-r--r--tools/libclang/CursorVisitor.h16
-rw-r--r--tools/libclang/IndexBody.cpp2
-rw-r--r--tools/libclang/IndexDecl.cpp5
-rw-r--r--tools/libclang/IndexTypeSourceInfo.cpp4
-rw-r--r--tools/libclang/Indexing.cpp48
-rw-r--r--tools/libclang/IndexingContext.cpp61
-rw-r--r--tools/libclang/IndexingContext.h34
31 files changed, 271 insertions, 265 deletions
diff --git a/tools/arcmt-test/arcmt-test.cpp b/tools/arcmt-test/arcmt-test.cpp
index 28331c279b..a31d0cae19 100644
--- a/tools/arcmt-test/arcmt-test.cpp
+++ b/tools/arcmt-test/arcmt-test.cpp
@@ -81,10 +81,10 @@ class PrintTransforms : public MigrationProcess::RewriteListener {
public:
PrintTransforms(raw_ostream &OS)
- : Ctx(0), OS(OS) { }
+ : Ctx(nullptr), OS(OS) {}
void start(ASTContext &ctx) override { Ctx = &ctx; }
- void finish() override { Ctx = 0; }
+ void finish() override { Ctx = nullptr; }
void insert(SourceLocation loc, StringRef text) override {
assert(Ctx);
@@ -112,7 +112,7 @@ static bool checkForMigration(StringRef resourcesPath,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
// Chain in -verify checker, if requested.
- VerifyDiagnosticConsumer *verifyDiag = 0;
+ VerifyDiagnosticConsumer *verifyDiag = nullptr;
if (VerifyDiags) {
verifyDiag = new VerifyDiagnosticConsumer(*Diags);
Diags->setClient(verifyDiag);
diff --git a/tools/diagtool/DiagTool.cpp b/tools/diagtool/DiagTool.cpp
index c3428c9081..44bc83e545 100644
--- a/tools/diagtool/DiagTool.cpp
+++ b/tools/diagtool/DiagTool.cpp
@@ -32,7 +32,7 @@ DiagTools::~DiagTools() { delete getTools(tools); }
DiagTool *DiagTools::getTool(llvm::StringRef toolCmd) {
ToolMap::iterator it = getTools(tools)->find(toolCmd);
- return (it == getTools(tools)->end()) ? 0 : it->getValue();
+ return (it == getTools(tools)->end()) ? nullptr : it->getValue();
}
void DiagTools::registerTool(DiagTool *tool) {
diff --git a/tools/diagtool/DiagnosticNames.cpp b/tools/diagtool/DiagnosticNames.cpp
index f5df05905e..a08da89577 100644
--- a/tools/diagtool/DiagnosticNames.cpp
+++ b/tools/diagtool/DiagnosticNames.cpp
@@ -50,7 +50,7 @@ static bool orderByID(const DiagnosticRecord &Left,
}
const DiagnosticRecord &diagtool::getDiagnosticForID(short DiagID) {
- DiagnosticRecord Key = {0, DiagID, 0};
+ DiagnosticRecord Key = {nullptr, DiagID, 0};
const DiagnosticRecord *Result =
std::lower_bound(std::begin(BuiltinDiagnosticsByID),
@@ -81,7 +81,7 @@ GroupRecord::subgroup_iterator GroupRecord::subgroup_begin() const {
}
GroupRecord::subgroup_iterator GroupRecord::subgroup_end() const {
- return 0;
+ return nullptr;
}
GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const {
@@ -89,7 +89,7 @@ GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const {
}
GroupRecord::diagnostics_iterator GroupRecord::diagnostics_end() const {
- return 0;
+ return nullptr;
}
llvm::ArrayRef<GroupRecord> diagtool::getDiagnosticGroups() {
diff --git a/tools/diagtool/DiagnosticNames.h b/tools/diagtool/DiagnosticNames.h
index a3321fa681..2571b19969 100644
--- a/tools/diagtool/DiagnosticNames.h
+++ b/tools/diagtool/DiagnosticNames.h
@@ -48,7 +48,7 @@ namespace diagtool {
friend struct GroupRecord;
group_iterator(const short *Start) : CurrentID(Start) {
if (CurrentID && *CurrentID == -1)
- CurrentID = 0;
+ CurrentID = nullptr;
}
public:
@@ -70,7 +70,7 @@ namespace diagtool {
group_iterator &operator++() {
++CurrentID;
if (*CurrentID == -1)
- CurrentID = 0;
+ CurrentID = nullptr;
return *this;
}
diff --git a/tools/diagtool/ShowEnabledWarnings.cpp b/tools/diagtool/ShowEnabledWarnings.cpp
index ad56b03604..903d1f16f9 100644
--- a/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/tools/diagtool/ShowEnabledWarnings.cpp
@@ -68,14 +68,14 @@ createDiagnostics(unsigned int argc, char **argv) {
createInvocationFromCommandLine(ArrayRef<const char *>(argv, argc),
InterimDiags));
if (!Invocation)
- return NULL;
+ return nullptr;
// Build the diagnostics parser
IntrusiveRefCntPtr<DiagnosticsEngine> FinalDiags =
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts());
if (!FinalDiags)
- return NULL;
-
+ return nullptr;
+
// Flush any errors created when initializing everything. This could happen
// for invalid command lines, which will probably give non-sensical results.
DiagsBuffer->FlushDiagnostics(*FinalDiags);
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index 7b4098a2fb..b1ae100bcf 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -267,7 +267,7 @@ static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
Diags.Report(diag::err_fe_unable_to_open_output)
<< Opts.OutputPath << Error;
delete Out;
- return 0;
+ return nullptr;
}
return new formatted_raw_ostream(*Out, formatted_raw_ostream::DELETE_STREAM);
@@ -354,8 +354,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
MCInstPrinter *IP =
TheTarget->createMCInstPrinter(Opts.OutputAsmVariant, *MAI, *MCII, *MRI,
*STI);
- MCCodeEmitter *CE = 0;
- MCAsmBackend *MAB = 0;
+ MCCodeEmitter *CE = nullptr;
+ MCAsmBackend *MAB = nullptr;
if (Opts.ShowEncoding) {
CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU);
@@ -469,7 +469,7 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd,
Args[0] = "clang (LLVM option parsing)";
for (unsigned i = 0; i != NumArgs; ++i)
Args[i + 1] = Asm.LLVMArgs[i].c_str();
- Args[NumArgs + 1] = 0;
+ Args[NumArgs + 1] = nullptr;
llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args);
}
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index edb32bc96b..d2e3b64a92 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -214,15 +214,15 @@ static void ParseProgName(SmallVectorImpl<const char *> &ArgVector,
const char *Suffix;
const char *ModeFlag;
} suffixes [] = {
- { "clang", 0 },
+ { "clang", nullptr },
{ "clang++", "--driver-mode=g++" },
{ "clang-c++", "--driver-mode=g++" },
- { "clang-cc", 0 },
+ { "clang-cc", nullptr },
{ "clang-cpp", "--driver-mode=cpp" },
{ "clang-g++", "--driver-mode=g++" },
- { "clang-gcc", 0 },
+ { "clang-gcc", nullptr },
{ "clang-cl", "--driver-mode=cl" },
- { "cc", 0 },
+ { "cc", nullptr },
{ "cpp", "--driver-mode=cpp" },
{ "cl" , "--driver-mode=cl" },
{ "++", "--driver-mode=g++" },
@@ -420,7 +420,7 @@ int main(int argc_, const char **argv_) {
// Force a crash to test the diagnostics.
if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) {
Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH";
- const Command *FailingCommand = 0;
+ const Command *FailingCommand = nullptr;
FailingCommands.push_back(std::make_pair(-1, FailingCommand));
}
diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp
index dbb604d797..6ddc22f474 100644
--- a/tools/libclang/ARCMigrate.cpp
+++ b/tools/libclang/ARCMigrate.cpp
@@ -40,7 +40,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) {
if (!migrate_dir_path) {
if (Logging)
llvm::errs() << "clang_getRemappings was called with NULL parameter\n";
- return 0;
+ return nullptr;
}
bool exists = false;
@@ -51,7 +51,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) {
<< "\")\n";
llvm::errs() << "\"" << migrate_dir_path << "\" does not exist\n";
}
- return 0;
+ return nullptr;
}
TextDiagnosticBuffer diagBuffer;
@@ -67,7 +67,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) {
I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I)
llvm::errs() << I->second << '\n';
}
- return 0;
+ return nullptr;
}
return remap.release();
@@ -90,7 +90,7 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
if (Logging)
llvm::errs() << "clang_getRemappingsFromFileList was called with "
"NULL filePaths\n";
- return 0;
+ return nullptr;
}
TextDiagnosticBuffer diagBuffer;
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 9c35631625..4d296d46b7 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -63,15 +63,15 @@ using namespace clang::cxindex;
CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU) {
if (!AU)
- return 0;
+ return nullptr;
assert(CIdx);
CXTranslationUnit D = new CXTranslationUnitImpl();
D->CIdx = CIdx;
D->TheASTUnit = AU;
D->StringPool = new cxstring::CXStringPool();
- D->Diagnostics = 0;
+ D->Diagnostics = nullptr;
D->OverridenCursorsPool = createOverridenCXCursorsPool();
- D->CommentToXML = 0;
+ D->CommentToXML = nullptr;
return D;
}
@@ -321,7 +321,7 @@ bool CursorVisitor::visitDeclsFromFileRegion(FileID File,
assert(!Decls.empty());
bool VisitedAtLeastOnce = false;
- DeclContext *CurDC = 0;
+ DeclContext *CurDC = nullptr;
SmallVectorImpl<Decl *>::iterator DIt = Decls.begin();
for (SmallVectorImpl<Decl *>::iterator DE = Decls.end(); DIt != DE; ++DIt) {
Decl *D = *DIt;
@@ -350,7 +350,7 @@ bool CursorVisitor::visitDeclsFromFileRegion(FileID File,
FileDI_current = &DIt;
FileDE_current = DE;
} else {
- FileDI_current = 0;
+ FileDI_current = nullptr;
}
if (Visit(MakeCXCursor(D, TU, Range), /*CheckedRegionOfInterest=*/true))
@@ -1703,7 +1703,7 @@ class DeclVisit : public VisitorJob {
public:
DeclVisit(const Decl *D, CXCursor parent, bool isFirst) :
VisitorJob(parent, VisitorJob::DeclVisitKind,
- D, isFirst ? (void*) 1 : (void*) 0) {}
+ D, isFirst ? (void*) 1 : (void*) nullptr) {}
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == DeclVisitKind;
}
@@ -2366,7 +2366,7 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
case CXChildVisit_Continue: break;
case CXChildVisit_Recurse:
if (PostChildrenVisitor)
- WL.push_back(PostChildrenVisit(0, Cursor));
+ WL.push_back(PostChildrenVisit(nullptr, Cursor));
EnqueueWorkList(WL, S);
break;
}
@@ -2495,7 +2495,7 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
}
bool CursorVisitor::Visit(const Stmt *S) {
- VisitorWorkList *WL = 0;
+ VisitorWorkList *WL = nullptr;
if (!WorkListFreeList.empty()) {
WL = WorkListFreeList.back();
WL->clear();
@@ -2513,10 +2513,10 @@ bool CursorVisitor::Visit(const Stmt *S) {
namespace {
typedef SmallVector<SourceRange, 4> RefNamePieces;
-RefNamePieces buildPieces(unsigned NameFlags, bool IsMemberRefExpr,
- const DeclarationNameInfo &NI,
- const SourceRange &QLoc,
- const ASTTemplateArgumentListInfo *TemplateArgs = 0){
+RefNamePieces
+buildPieces(unsigned NameFlags, bool IsMemberRefExpr,
+ const DeclarationNameInfo &NI, const SourceRange &QLoc,
+ const ASTTemplateArgumentListInfo *TemplateArgs = nullptr) {
const bool WantQualifier = NameFlags & CXNameRange_WantQualifier;
const bool WantTemplateArgs = NameFlags & CXNameRange_WantTemplateArgs;
const bool WantSinglePiece = NameFlags & CXNameRange_WantSinglePiece;
@@ -2579,7 +2579,7 @@ CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
{
llvm::sys::ScopedLock L(EnableMultithreadingMutex);
if (!EnabledMultithreading) {
- llvm::install_fatal_error_handler(fatal_error_handler, 0);
+ llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
llvm::llvm_start_multithreaded();
EnabledMultithreading = true;
}
@@ -2639,7 +2639,7 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
const char *ast_filename,
CXTranslationUnit *out_TU) {
if (out_TU)
- *out_TU = NULL;
+ *out_TU = nullptr;
if (!CIdx || !ast_filename || !out_TU)
return CXError_InvalidArguments;
@@ -2705,12 +2705,12 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
// Set up the initial return values.
if (out_TU)
- *out_TU = NULL;
+ *out_TU = nullptr;
PTUI->result = CXError_Failure;
// Check arguments.
if (!CIdx || !out_TU ||
- (unsaved_files == NULL && num_unsaved_files != 0)) {
+ (unsaved_files == nullptr && num_unsaved_files != 0)) {
PTUI->result = CXError_InvalidArguments;
return;
}
@@ -3010,14 +3010,14 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
RTUI->result = CXError_InvalidArguments;
return;
}
- if (unsaved_files == NULL && num_unsaved_files != 0) {
+ if (unsaved_files == nullptr && num_unsaved_files != 0) {
RTUI->result = CXError_InvalidArguments;
return;
}
// Reset the associated diagnostics.
delete static_cast<CXDiagnosticSetImpl*>(TU->Diagnostics);
- TU->Diagnostics = 0;
+ TU->Diagnostics = nullptr;
CIndexer *CXXIdx = TU->CIdx;
if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForEditing))
@@ -3122,7 +3122,7 @@ time_t clang_getFileTime(CXFile SFile) {
CXFile clang_getFile(CXTranslationUnit TU, const char *file_name) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
- return 0;
+ return nullptr;
}
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
@@ -3209,8 +3209,8 @@ static const Decl *getDeclFromExpr(const Stmt *E) {
if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
isa<ParmVarDecl>(SizeOfPack->getPack()))
return SizeOfPack->getPack();
-
- return 0;
+
+ return nullptr;
}
static SourceLocation getLocationFromExpr(const Expr *E) {
@@ -4082,10 +4082,11 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
CXString SearchFileName, ResultFileName, KindSpelling, USR;
const char *IsDef = clang_isCursorDefinition(Result)? " (Definition)" : "";
CXSourceLocation ResultLoc = clang_getCursorLocation(Result);
-
- clang_getFileLocation(Loc, &SearchFile, &SearchLine, &SearchColumn, 0);
+
+ clang_getFileLocation(Loc, &SearchFile, &SearchLine, &SearchColumn,
+ nullptr);
clang_getFileLocation(ResultLoc, &ResultFile, &ResultLine,
- &ResultColumn, 0);
+ &ResultColumn, nullptr);
SearchFileName = clang_getFileName(SearchFile);
ResultFileName = clang_getFileName(ResultFile);
KindSpelling = clang_getCursorKindSpelling(Result.kind);
@@ -4109,7 +4110,7 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
CXFile DefinitionFile;
unsigned DefinitionLine, DefinitionColumn;
clang_getFileLocation(DefinitionLoc, &DefinitionFile,
- &DefinitionLine, &DefinitionColumn, 0);
+ &DefinitionLine, &DefinitionColumn, nullptr);
CXString DefinitionFileName = clang_getFileName(DefinitionFile);
*Log << llvm::format(" -> %s(%s:%d:%d)",
clang_getCString(DefinitionKindSpelling),
@@ -4136,9 +4137,9 @@ unsigned clang_equalCursors(CXCursor X, CXCursor Y) {
// when visiting a DeclStmt currently, the AST should be enhanced to be able
// to provide that kind of info.
if (clang_isDeclaration(X.kind))
- X.data[1] = 0;
+ X.data[1] = nullptr;
if (clang_isDeclaration(Y.kind))
- Y.data[1] = 0;
+ Y.data[1] = nullptr;
return X == Y;
}
@@ -4716,7 +4717,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
case Decl::CXXConstructor:
case Decl::CXXDestructor:
case Decl::CXXConversion: {
- const FunctionDecl *Def = 0;
+ const FunctionDecl *Def = nullptr;
if (cast<FunctionDecl>(D)->getBody(Def))
return MakeCXCursor(Def, TU);
return clang_getNullCursor();
@@ -4732,7 +4733,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
}
case Decl::FunctionTemplate: {
- const FunctionDecl *Def = 0;
+ const FunctionDecl *Def = nullptr;
if (cast<FunctionTemplateDecl>(D)->getTemplatedDecl()->getBody(Def))
return MakeCXCursor(Def->getDescribedFunctionTemplate(), TU);
return clang_getNullCursor();
@@ -5139,10 +5140,10 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
CXTok.ptr_data = II;
} else if (Tok.is(tok::comment)) {
CXTok.int_data[0] = CXToken_Comment;
- CXTok.ptr_data = 0;
+ CXTok.ptr_data = nullptr;
} else {
CXTok.int_data[0] = CXToken_Punctuation;
- CXTok.ptr_data = 0;
+ CXTok.ptr_data = nullptr;
}
CXTokens.push_back(CXTok);
previousWasAt = Tok.is(tok::at);
@@ -5156,7 +5157,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
}
if (Tokens)
- *Tokens = 0;
+ *Tokens = nullptr;
if (NumTokens)
*NumTokens = 0;
@@ -5713,7 +5714,7 @@ static void annotatePreprocessorTokens(CXTranslationUnit TU,
if (lexNext(Lex, Tok, NextIdx, NumTokens))
break;
- MacroInfo *MI = 0;
+ MacroInfo *MI = nullptr;
if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == "define") {
if (lexNext(Lex, Tok, NextIdx, NumTokens))
break;
@@ -6154,7 +6155,7 @@ CXLanguageKind clang_getCursorLanguage(CXCursor cursor) {
/// function template.
static const Decl *maybeGetTemplateCursor(const Decl *D) {
if (!D)
- return 0;
+ return nullptr;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
if (FunctionTemplateDecl *FunTmpl = FD->getDescribedFunctionTemplate())
@@ -6206,8 +6207,8 @@ CXCursor clang_getCursorLexicalParent(CXCursor cursor) {
CXFile clang_getIncludedFile(CXCursor cursor) {
if (cursor.kind != CXCursor_InclusionDirective)
- return 0;
-
+ return nullptr;
+
const InclusionDirective *ID = getCursorInclusionDirective(cursor);
return const_cast<FileEntry *>(ID->getFile());
}
@@ -6345,7 +6346,7 @@ CXModule clang_Cursor_getModule(CXCursor C) {
return ImportD->getImportedModule();
}
- return 0;
+ return nullptr;
}
CXModule clang_getModuleForFile(CXTranslationUnit TU, CXFile File) {
@@ -6370,14 +6371,14 @@ CXModule clang_getModuleForFile(CXTranslationUnit TU, CXFile File) {
CXFile clang_Module_getASTFile(CXModule CXMod) {
if (!CXMod)
- return 0;
+ return nullptr;
Module *Mod = static_cast<Module*>(CXMod);
return const_cast<FileEntry *>(Mod->getASTFile());
}
CXModule clang_Module_getParent(CXModule CXMod) {
if (!CXMod)
- return 0;
+ return nullptr;
Module *Mod = static_cast<Module*>(CXMod);
return Mod->Parent;
}
@@ -6421,10 +6422,10 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
CXModule CXMod, unsigned Index) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
- return 0;
+ return nullptr;
}
if (!CXMod)
- return 0;
+ return nullptr;
Module *Mod = static_cast<Module*>(CXMod);
FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager();
@@ -6432,7 +6433,7 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
if (Index < TopHeaders.size())
return const_cast<FileEntry *>(TopHeaders[Index]);
- return 0;
+ return nullptr;
}
} // end: extern "C"
@@ -6448,7 +6449,7 @@ unsigned clang_CXXMethod_isPureVirtual(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
- D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : 0;
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
return (Method && Method->isVirtual() && Method->isPure()) ? 1 : 0;
}
@@ -6458,7 +6459,7 @@ unsigned clang_CXXMethod_isConst(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
- D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : 0;
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
return (Method && (Method->getTypeQualifiers() & Qualifiers::Const)) ? 1 : 0;
}
@@ -6468,7 +6469,7 @@ unsigned clang_CXXMethod_isStatic(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
- D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : 0;
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
return (Method && Method->isStatic()) ? 1 : 0;
}
@@ -6478,7 +6479,7 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
- D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : 0;
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
return (Method && Method->isVirtual()) ? 1 : 0;
}
} // end: extern "C"
@@ -6566,7 +6567,7 @@ const char *clang_getTUResourceUsageName(CXTUResourceUsageKind kind) {
CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
- CXTUResourceUsage usage = { (void*) 0, 0, 0 };
+ CXTUResourceUsage usage = { (void*) nullptr, 0, nullptr };
return usage;
}
@@ -6648,10 +6649,10 @@ CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) {
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_Preprocessor_HeaderSearch,
pp.getHeaderSearchInfo().getTotalMemory());
-
+
CXTUResourceUsage usage = { (void*) entries.get(),
(unsigned) entries->size(),
- entries->size() ? &(*entries)[0] : 0 };
+ entries->size() ? &(*entries)[0] : nullptr };
entries.release();
return usage;
}
@@ -6664,7 +6665,7 @@ void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) {
CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit TU, CXFile file) {
CXSourceRangeList *skipped = new CXSourceRangeList;
skipped->count = 0;
- skipped->ranges = 0;
+ skipped->ranges = nullptr;
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
@@ -6783,9 +6784,9 @@ MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II,
SourceLocation MacroDefLoc,
CXTranslationUnit TU){
if (MacroDefLoc.isInvalid() || !TU)
- return 0;
+ return nullptr;
if (!II.hadMacroDefinition())
- return 0;
+ return nullptr;
ASTUnit *Unit = cxtu::getASTUnit(TU);
Preprocessor &PP = Unit->getPreprocessor();
@@ -6798,16 +6799,16 @@ MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II,
}
}
- return 0;
+ return nullptr;
}
const MacroInfo *cxindex::getMacroInfo(const MacroDefinition *MacroDef,
CXTranslationUnit TU) {
if (!MacroDef || !TU)
- return 0;
+ return nullptr;
const IdentifierInfo *II = MacroDef->getName();
if (!II)
- return 0;
+ return nullptr;
return getMacroInfo(*II, MacroDef->getLocation(), TU);
}
@@ -6816,12 +6817,12 @@ MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI,
const Token &Tok,
CXTranslationUnit TU) {
if (!MI || !TU)
- return 0;
+ return nullptr;
if (Tok.isNot(tok::raw_identifier))
- return 0;
+ return nullptr;
if (MI->getNumTokens() == 0)
- return 0;
+ return nullptr;
SourceRange DefRange(MI->getReplacementToken(0).getLocation(),
MI->getDefinitionEndLoc());
ASTUnit *Unit = cxtu::getASTUnit(TU);
@@ -6829,26 +6830,26 @@ MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI,
// Check that the token is inside the definition and not its argument list.
SourceManager &SM = Unit->getSourceManager();
if (SM.isBeforeInTranslationUnit(Tok.getLocation(), DefRange.getBegin()))
- return 0;
+ return nullptr;
if (SM.isBeforeInTranslationUnit(DefRange.getEnd(), Tok.getLocation()))
- return 0;
+ return nullptr;
Preprocessor &PP = Unit->getPreprocessor();
PreprocessingRecord *PPRec = PP.getPreprocessingRecord();
if (!PPRec)
- return 0;
+ return nullptr;
IdentifierInfo &II = PP.getIdentifierTable().get(Tok.getRawIdentifier());
if (!II.hadMacroDefinition())
- return 0;
+ return nullptr;
// Check that the identifier is not one of the macro arguments.
if (std::find(MI->arg_begin(), MI->arg_end(), &II) != MI->arg_end())
- return 0;
+ return nullptr;
MacroDirective *InnerMD = PP.getMacroDirectiveHistory(&II);
if (!InnerMD)
- return 0;
+ return nullptr;
return PPRec->findMacroDefinition(InnerMD->getMacroInfo());
}
@@ -6857,18 +6858,18 @@ MacroDefinition *cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI,
SourceLocation Loc,
CXTranslationUnit TU) {
if (Loc.isInvalid() || !MI || !TU)
- return 0;
+ return nullptr;
if (MI->getNumTokens() == 0)
- return 0;
+ return nullptr;
ASTUnit *Unit = cxtu::getASTUnit(TU);
Preprocessor &PP = Unit->getPreprocessor();
if (!PP.getPreprocessingRecord())
- return 0;
+ return nullptr;
Loc = Unit->getSourceManager().getSpellingLoc(Loc);
Token Tok;
if (PP.getRawToken(Loc, Tok))
- return 0;
+ return nullptr;
return checkForMacroInMacroDefinition(MI, Tok, TU);
}
@@ -6910,7 +6911,7 @@ Logger &cxindex::Logger::operator<<(CXCursor cursor) {
Logger &cxindex::Logger::operator<<(CXSourceLocation Loc) {
CXFile File;
unsigned Line, Column;
- clang_getFileLocation(Loc, &File, &Line, &Column, 0);
+ clang_getFileLocation(Loc, &File, &Line, &Column, nullptr);
CXString FileName = clang_getFileName(File);
*this << llvm::format("(%s:%d:%d)", clang_getCString(FileName), Line, Column);
clang_disposeString(FileName);
@@ -6923,11 +6924,11 @@ Logger &cxindex::Logger::operator<<(CXSourceRange range) {
CXFile BFile;
unsigned BLine, BColumn;
- clang_getFileLocation(BLoc, &BFile, &BLine, &BColumn, 0);
+ clang_getFileLocation(BLoc, &BFile, &BLine, &BColumn, nullptr);
CXFile EFile;
unsigned ELine, EColumn;
- clang_getFileLocation(ELoc, &EFile, &ELine, &EColumn, 0);
+ clang_getFileLocation(ELoc, &EFile, &ELine, &EColumn, nullptr);
CXString BFileName = clang_getFileName(BFile);
if (BFile == EFile) {
diff --git a/tools/libclang/CIndexCXX.cpp b/tools/libclang/CIndexCXX.cpp
index a3d236446f..78e89d94d3 100644
--- a/tools/libclang/CIndexCXX.cpp
+++ b/tools/libclang/CIndexCXX.cpp
@@ -89,8 +89,8 @@ CXCursor clang_getSpecializedCursorTemplate(CXCursor C) {
const Decl *D = getCursorDecl(C);
if (!D)
return clang_getNullCursor();
-
- Decl *Template = 0;
+
+ Decl *Template = nullptr;
if (const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
if (const ClassTemplatePartialSpecializationDecl *PartialSpec
= dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord))
diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index dbf54a1a8c..edc8368ca3 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/tools/libclang/CIndexCodeCompletion.cpp
@@ -153,7 +153,7 @@ clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
unsigned chunk_number) {
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
if (!CCStr || chunk_number >= CCStr->size())
- return 0;
+ return nullptr;
switch ((*CCStr)[chunk_number].Kind) {
case CodeCompletionString::CK_TypedText:
@@ -176,7 +176,7 @@ clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
case CodeCompletionString::CK_Equal:
case CodeCompletionString::CK_HorizontalSpace:
case CodeCompletionString::CK_VerticalSpace:
- return 0;
+ return nullptr;
case CodeCompletionString::CK_Optional:
// Note: treated as an empty text block.
@@ -568,8 +568,8 @@ namespace {
}
QualType baseType = Context.getBaseType();
- NamedDecl *D = NULL;
-
+ NamedDecl *D = nullptr;
+
if (!baseType.isNull()) {
// Get the declaration for a class/struct/union/enum type
if (const TagType *Tag = baseType->getAs<TagType>())
@@ -587,8 +587,8 @@ namespace {
baseType->getAs<InjectedClassNameType>())
D = Injected->getDecl();
}
-
- if (D != NULL) {
+
+ if (D != nullptr) {
CXCursor cursor = cxcursor::MakeCXCursor(D, *TU);
AllocatedResults.ContainerKind = clang_getCursorKind(cursor);
@@ -598,7 +598,7 @@ namespace {
clang_disposeString(CursorUSR);
const Type *type = baseType.getTypePtrOrNull();
- if (type != NULL) {
+ if (type) {
AllocatedResults.ContainerIsIncomplete = type->isIncompleteType();
}
else {
@@ -666,7 +666,7 @@ void clang_codeCompleteAt_Impl(void *UserData) {
unsigned num_unsaved_files = CCAI->num_unsaved_files;
unsigned options = CCAI->options;
bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
- CCAI->result = 0;
+ CCAI->result = nullptr;
#ifdef UDP_CODE_COMPLETION_LOGGER
#ifdef UDP_CODE_COMPLETION_LOGGER_PORT
@@ -674,7 +674,7 @@ void clang_codeCompleteAt_Impl(void *UserData) {
#endif
#endif
- bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != 0;
+ bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
if (cxtu::isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
@@ -708,7 +708,7 @@ void clang_codeCompleteAt_Impl(void *UserData) {
// Parse the resulting source file to find code-completion results.
AllocatedCXCodeCompleteResults *Results = new AllocatedCXCodeCompleteResults(
&AST->getFileManager());
- Results->Results = 0;
+ Results->Results = nullptr;
Results->NumResults = 0;
// Create a code-completion consumer to capture the results.
@@ -825,7 +825,7 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
CodeCompleteAtInfo CCAI = { TU, complete_filename, complete_line,
complete_column, unsaved_files, num_unsaved_files,
- options, 0 };
+ options, nullptr };
if (getenv("LIBCLANG_NOTHREADS")) {
clang_codeCompleteAt_Impl(&CCAI);
@@ -837,7 +837,7 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
if (!RunSafely(CRC, clang_codeCompleteAt_Impl, &CCAI)) {
fprintf(stderr, "libclang: crash detected in code completion\n");
cxtu::getASTUnit(TU)->setUnsafeToFree(true);
- return 0;
+ return nullptr;
} else if (getenv("LIBCLANG_RESOURCE_USAGE"))
PrintLibclangResourceUsage(TU);
@@ -873,7 +873,7 @@ clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *ResultsIn,
AllocatedCXCodeCompleteResults *Results
= static_cast<AllocatedCXCodeCompleteResults*>(ResultsIn);
if (!Results || Index >= Results->Diagnostics.size())
- return 0;
+ return nullptr;
CXStoredDiagnostic *Diag = Results->DiagnosticsWrappers[Index];
if (!Diag)
@@ -899,8 +899,8 @@ enum CXCursorKind clang_codeCompleteGetContainerKind(
static_cast<AllocatedCXCodeCompleteResults *>(ResultsIn);
if (!Results)
return CXCursor_InvalidCode;
-
- if (IsIncomplete != NULL) {
+
+ if (IsIncomplete != nullptr) {
*IsIncomplete = Results->ContainerIsIncomplete;
}
diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp
index 8a57d7dfff..cb977ec3b1 100644
--- a/tools/libclang/CIndexDiagnostic.cpp
+++ b/tools/libclang/CIndexDiagnostic.cpp
@@ -186,7 +186,7 @@ CXDiagnosticSetImpl *cxdiag::lazyCreateDiags(CXTranslationUnit TU,
// Diagnostics in the ASTUnit were updated, reset the associated
// diagnostics.
delete Set;
- TU->Diagnostics = 0;
+ TU->Diagnostics = nullptr;
}
}
@@ -223,16 +223,16 @@ unsigned clang_getNumDiagnostics(CXTranslationUnit Unit) {
CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index) {
if (cxtu::isNotUsableTU(Unit)) {
LOG_BAD_TU(Unit);
- return 0;
+ return nullptr;
}
CXDiagnosticSet D = clang_getDiagnosticSetFromTU(Unit);
if (!D)
- return 0;
+ return nullptr;
CXDiagnosticSetImpl *Diags = static_cast<CXDiagnosticSetImpl*>(D);
if (Index >= Diags->getNumDiagnostics())
- return 0;
+ return nullptr;
return Diags->getDiagnostic(Index);
}
@@ -240,10 +240,10 @@ CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index) {
CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) {
if (cxtu::isNotUsableTU(Unit)) {
LOG_BAD_TU(Unit);
- return 0;
+ return nullptr;
}
if (!cxtu::getASTUnit(Unit))
- return 0;
+ return nullptr;
return static_cast<CXDiagnostic>(lazyCreateDiags(Unit));
}
@@ -267,7 +267,7 @@ CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options) {
CXFile File;
unsigned Line, Column;
clang_getSpellingLocation(clang_getDiagnosticLocation(Diagnostic),
- &File, &Line, &Column, 0);
+ &File, &Line, &Column, nullptr);
if (File) {
CXString FName = clang_getFileName(File);
Out << clang_getCString(FName) << ":" << Line << ":";
@@ -285,10 +285,10 @@ CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options) {
unsigned StartLine, StartColumn, EndLine, EndColumn;
clang_getSpellingLocation(clang_getRangeStart(Range),
&StartFile, &StartLine, &StartColumn,
- 0);
+ nullptr);
clang_getSpellingLocation(clang_getRangeEnd(Range),
- &EndFile, &EndLine, &EndColumn, 0);
-
+ &EndFile, &EndLine, &EndColumn, nullptr);
+
if (StartFile != EndFile || StartFile != File)
continue;
@@ -326,7 +326,7 @@ CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options) {
bool NeedComma = false;
if (Options & CXDiagnostic_DisplayOption) {
- CXString OptionName = clang_getDiagnosticOption(Diagnostic, 0);
+ CXString OptionName = clang_getDiagnosticOption(Diagnostic, nullptr);
if (const char *OptionText = clang_getCString(OptionName)) {
if (OptionText[0]) {
Out << " [" << OptionText;
@@ -464,15 +464,15 @@ CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
if (CXDiagnosticSetImpl *D = static_cast<CXDiagnosticSetImpl*>(Diags))
if (Index < D->getNumDiagnostics())
return D->getDiagnostic(Index);
- return 0;
+ return nullptr;
}
CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic Diag) {
if (CXDiagnosticImpl *D = static_cast<CXDiagnosticImpl *>(Diag)) {
CXDiagnosticSetImpl &ChildDiags = D->getChildDiagnostics();
- return ChildDiags.empty() ? 0 : (CXDiagnosticSet) &ChildDiags;
+ return ChildDiags.empty() ? nullptr : (CXDiagnosticSet) &ChildDiags;
}
- return 0;
+ return nullptr;
}
unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) {
diff --git a/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp
index 322f723b41..d2baa13be9 100644
--- a/tools/libclang/CIndexHigh.cpp
+++ b/tools/libclang/CIndexHigh.cpp
@@ -78,7 +78,7 @@ struct FindFileIdRefVisitData {
/// itself, so both 'C' can be highlighted.
const Decl *getCanonical(const Decl *D) const {
if (!D)
- return 0;
+ return nullptr;
D = D->getCanonicalDecl();
@@ -265,7 +265,7 @@ struct FindFileMacroRefVisitData {
static enum CXChildVisitResult findFileMacroRefVisit(CXCursor cursor,
CXCursor parent,
CXClientData client_data) {
- const IdentifierInfo *Macro = 0;
+ const IdentifierInfo *Macro = nullptr;
if (cursor.kind == CXCursor_MacroDefinition)
Macro = getCursorMacroDefinition(cursor)->getName();
else if (cursor.kind == CXCursor_MacroExpansion)
@@ -317,7 +317,7 @@ static bool findMacroRefsInFile(CXTranslationUnit TU, CXCursor Cursor,
SourceManager &SM = Unit->getSourceManager();
FileID FID = SM.translateFile(File);
- const IdentifierInfo *Macro = 0;
+ const IdentifierInfo *Macro = nullptr;
if (Cursor.kind == CXCursor_MacroDefinition)
Macro = getCursorMacroDefinition(Cursor)->getName();
else
@@ -522,7 +522,7 @@ CXResult clang_findReferencesInFileWithBlock(CXCursor cursor,
CXFile file,
CXCursorAndRangeVisitorBlock block) {
CXCursorAndRangeVisitor visitor = { block,
- block ? _visitCursorAndRange : 0 };
+ block ? _visitCursorAndRange : nullptr };
return clang_findReferencesInFile(cursor, file, visitor);
}
@@ -530,7 +530,7 @@ CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit TU,
CXFile file,
CXCursorAndRangeVisitorBlock block) {
CXCursorAndRangeVisitor visitor = { block,
- block ? _visitCursorAndRange : 0 };
+ block ? _visitCursorAndRange : nullptr };
return clang_findIncludesInFile(TU, file, visitor);
}
diff --git a/tools/libclang/CLog.h b/tools/libclang/CLog.h
index fe6c218bba..e7419b71f8 100644
--- a/tools/libclang/CLog.h
+++ b/tools/libclang/CLog.h
@@ -48,7 +48,7 @@ public:
static const char *sCachedVar = ::getenv("LIBCLANG_LOGGING");
return sCachedVar;
}
- static bool isLoggingEnabled() { return getEnvVar() != 0; }
+ static bool isLoggingEnabled() { return getEnvVar() != nullptr; }
static bool isStackTracingEnabled() {
if (const char *EnvOpt = Logger::getEnvVar())
return llvm::StringRef(EnvOpt) == "2";
@@ -58,7 +58,7 @@ public:
bool trace = isStackTracingEnabled()) {
if (isLoggingEnabled())
return new Logger(name, trace);
- return 0;
+ return nullptr;
}
explicit Logger(llvm::StringRef name, bool trace)
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index 8fb7c0a5c4..454703149c 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -33,11 +33,11 @@ CXComment clang_Cursor_getParsedComment(CXCursor C) {
using namespace clang::cxcursor;
if (!clang_isDeclaration(C.kind))
- return createCXComment(NULL, NULL);
+ return createCXComment(nullptr, nullptr);
const Decl *D = getCursorDecl(C);
const ASTContext &Context = getCursorContext(C);
- const FullComment *FC = Context.getCommentForDecl(D, /*PP=*/NULL);
+ const FullComment *FC = Context.getCommentForDecl(D, /*PP=*/nullptr);
return createCXComment(FC, getCursorTU(C));
}
@@ -101,7 +101,7 @@ unsigned clang_Comment_getNumChildren(CXComment CXC) {
CXComment clang_Comment_getChild(CXComment CXC, unsigned ChildIdx) {
const Comment *C = getASTNode(CXC);
if (!C || ChildIdx >= C->child_count())
- return createCXComment(NULL, NULL);
+ return createCXComment(nullptr, nullptr);
return createCXComment(*(C->child_begin() + ChildIdx), CXC.TranslationUnit);
}
@@ -253,7 +253,7 @@ CXString clang_BlockCommandComment_getArgText(CXComment CXC,
CXComment clang_BlockCommandComment_getParagraph(CXComment CXC) {
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
if (!BCC)
- return createCXComment(NULL, NULL);
+ return createCXComment(nullptr, nullptr);
return createCXComment(BCC->getParagraph(), CXC.TranslationUnit);
}
diff --git a/tools/libclang/CXComment.h b/tools/libclang/CXComment.h
index 606ee26bb6..d9d2bdef41 100644
--- a/tools/libclang/CXComment.h
+++ b/tools/libclang/CXComment.h
@@ -44,7 +44,7 @@ template<typename T>
static inline const T *getASTNodeAs(CXComment CXC) {
const comments::Comment *C = getASTNode(CXC);
if (!C)
- return NULL;
+ return nullptr;
return dyn_cast<T>(C);
}
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp
index f4728fe0a1..51677e7210 100644
--- a/tools/libclang/CXCompilationDatabase.cpp
+++ b/tools/libclang/CXCompilationDatabase.cpp
@@ -54,7 +54,7 @@ clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase CDb,
return new AllocatedCXCompileCommands(std::move(CCmd));
}
- return 0;
+ return nullptr;
}
CXCompileCommands
@@ -65,7 +65,7 @@ clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase CDb) {
return new AllocatedCXCompileCommands(std::move(CCmd));
}
- return 0;
+ return nullptr;
}
void
@@ -90,13 +90,13 @@ CXCompileCommand
clang_CompileCommands_getCommand(CXCompileCommands Cmds, unsigned I)
{
if (!Cmds)
- return 0;
+ return nullptr;
AllocatedCXCompileCommands *ACC =
static_cast<AllocatedCXCompileCommands *>(Cmds);
if (I >= ACC->CCmd.size())
- return 0;
+ return nullptr;
return &ACC->CCmd[I];
}
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index 1d4d14ef91..8c9945c3ae 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -34,7 +34,7 @@ using namespace cxcursor;
CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU) {
assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid);
- CXCursor C = { K, 0, { 0, 0, TU } };
+ CXCursor C = { K, 0, { nullptr, nullptr, TU } };
return C;
}
@@ -659,7 +659,7 @@ cxcursor::getCursorMemberRef(CXCursor C) {
CXCursor cxcursor::MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B,
CXTranslationUnit TU){
- CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, 0, TU } };
+ CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, nullptr, TU } };
return C;
}
@@ -688,7 +688,7 @@ SourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) {
CXCursor cxcursor::MakeMacroDefinitionCursor(const MacroDefinition *MI,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_MacroDefinition, 0, { MI, 0, TU } };
+ CXCursor C = { CXCursor_MacroDefinition, 0, { MI, nullptr, TU } };
return C;
}
@@ -699,7 +699,7 @@ const MacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) {
CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_MacroExpansion, 0, { MI, 0, TU } };
+ CXCursor C = { CXCursor_MacroExpansion, 0, { MI, nullptr, TU } };
return C;
}
@@ -729,7 +729,7 @@ SourceRange cxcursor::MacroExpansionCursor::getSourceRange() const {
CXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_InclusionDirective, 0, { ID, 0, TU } };
+ CXCursor C = { CXCursor_InclusionDirective, 0, { ID, nullptr, TU } };
return C;
}
@@ -812,7 +812,7 @@ const Stmt *cxcursor::getCursorStmt(CXCursor Cursor) {
if (Cursor.kind == CXCursor_ObjCSuperClassRef ||
Cursor.kind == CXCursor_ObjCProtocolRef ||
Cursor.kind == CXCursor_ObjCClassRef)
- return 0;
+ return nullptr;
return static_cast<const Stmt *>(Cursor.data[1]);
}
@@ -832,7 +832,7 @@ ASTContext &cxcursor::getCursorContext(CXCursor Cursor) {
ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) {
CXTranslationUnit TU = getCursorTU(Cursor);
if (!TU)
- return 0;
+ return nullptr;
return cxtu::getASTUnit(TU);
}
@@ -906,7 +906,7 @@ CXCursor cxcursor::getTypeRefCursor(CXCursor cursor) {
return cursor;
const Expr *E = getCursorExpr(cursor);
- TypeSourceInfo *Type = 0;
+ TypeSourceInfo *Type = nullptr;
if (const CXXUnresolvedConstructExpr *
UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) {
Type = UnCtor->getTypeSourceInfo();
@@ -1107,7 +1107,7 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
false);
return String;
}
- return NULL;
+ return nullptr;
}
} // end: extern C.
@@ -1139,7 +1139,7 @@ void clang_getOverriddenCursors(CXCursor cursor,
CXCursor **overridden,
unsigned *num_overridden) {
if (overridden)
- *overridden = 0;
+ *overridden = nullptr;
if (num_overridden)
*num_overridden = 0;
@@ -1153,9 +1153,9 @@ void clang_getOverriddenCursors(CXCursor cursor,
OverridenCursorsPool &pool =
*static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool);
-
- OverridenCursorsPool::CursorVec *Vec = 0;
-
+
+ OverridenCursorsPool::CursorVec *Vec = nullptr;
+
if (!pool.AvailableCursors.empty()) {
Vec = pool.AvailableCursors.back();
pool.AvailableCursors.pop_back();
@@ -1213,7 +1213,7 @@ void clang_disposeOverriddenCursors(CXCursor *overridden) {
}
int clang_Cursor_isDynamicCall(CXCursor C) {
- const Expr *E = 0;
+ const Expr *E = nullptr;
if (clang_isExpression(C.kind))
E = getCursorExpr(C);
if (!E)
@@ -1222,7 +1222,7 @@ int clang_Cursor_isDynamicCall(CXCursor C) {
if (const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E))
return MsgE->getReceiverKind() == ObjCMessageExpr::Instance;
- const MemberExpr *ME = 0;
+ const MemberExpr *ME = nullptr;
if (isa<MemberExpr>(E))
ME = cast<MemberExpr>(E);
else if (const CallExpr *CE = dyn_cast<CallExpr>(E))
@@ -1239,7 +1239,7 @@ int clang_Cursor_isDynamicCall(CXCursor C) {
CXType clang_Cursor_getReceiverType(CXCursor C) {
CXTranslationUnit TU = cxcursor::getCursorTU(C);
- const Expr *E = 0;
+ const Expr *E = nullptr;
if (clang_isExpression(C.kind))
E = getCursorExpr(C);
diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h
index 957d51961a..fee3bac953 100644
--- a/tools/libclang/CXCursor.h
+++ b/tools/libclang/CXCursor.h
@@ -56,7 +56,7 @@ CXCursor MakeCXCursor(const clang::Decl *D, CXTranslationUnit TU,
CXCursor MakeCXCursor(const clang::Stmt *S, const clang::Decl *Parent,
CXTranslationUnit TU,
SourceRange RegionOfInterest = SourceRange());
-CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = 0);
+CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = nullptr);
/// \brief Create an Objective-C superclass reference at the given location.
CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
@@ -172,7 +172,7 @@ class MacroExpansionCursor {
CXCursor C;
bool isPseudo() const {
- return C.data[1] != 0;
+ return C.data[1] != nullptr;
}
const MacroDefinition *getAsMacroDefinition() const {
assert(isPseudo());
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index 8385f242d4..ddf374903a 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -92,7 +92,7 @@ static CXSourceLocation makeLocation(const CXLoadedDiagnostic::Location *DLoc) {
// is a persistent diagnostic.
uintptr_t V = (uintptr_t) DLoc;
V |= 0x1;
- CXSourceLocation Loc = { { (void*) V, 0 }, 0 };
+ CXSourceLocation Loc = { { (void*) V, nullptr }, 0 };
return Loc;
}
@@ -265,7 +265,7 @@ CXDiagnosticSet DiagLoader::load(const char *file) {
if (!Buffer) {
reportBad(CXLoadDiag_CannotLoad, ErrStr);
- return 0;
+ return nullptr;
}
llvm::BitstreamReader StreamFile;
@@ -282,7 +282,7 @@ CXDiagnosticSet DiagLoader::load(const char *file) {
Stream.Read(8) != 'G') {
reportBad(CXLoadDiag_InvalidFile,
"Bad header in diagnostics file");
- return 0;
+ return nullptr;
}
std::unique_ptr<CXLoadedDiagnosticSetImpl> Diags(
@@ -296,7 +296,7 @@ CXDiagnosticSet DiagLoader::load(const char *file) {
case Read_EndOfStream:
return (CXDiagnosticSet)Diags.release();
case Read_Failure:
- return 0;
+ return nullptr;
case Read_Record:
llvm_unreachable("Top-level does not have records");
case Read_BlockEnd:
@@ -308,16 +308,16 @@ CXDiagnosticSet DiagLoader::load(const char *file) {
switch (BlockID) {
case serialized_diags::BLOCK_META:
if (readMetaBlock(Stream))
- return 0;
+ return nullptr;
break;
case serialized_diags::BLOCK_DIAG:
if (readDiagnosticBlock(Stream, *Diags.get(), *Diags.get()))
- return 0;
+ return nullptr;
break;
default:
if (!Stream.SkipBlock()) {
reportInvalidFile("Malformed block at top-level of diagnostics file");
- return 0;
+ return nullptr;
}
break;
}
@@ -495,7 +495,7 @@ LoadResult DiagLoader::readLocation(CXLoadedDiagnosticSetImpl &TopDiags,
unsigned fileID = Record[offset++];
if (fileID == 0) {
// Sentinel value.
- Loc.file = 0;
+ Loc.file = nullptr;
Loc.line = 0;
Loc.column = 0;
Loc.offset = 0;
diff --git a/tools/libclang/CXSourceLocation.cpp b/tools/libclang/CXSourceLocation.cpp
index f78b687a69..64a441e128 100644
--- a/tools/libclang/CXSourceLocation.cpp
+++ b/tools/libclang/CXSourceLocation.cpp
@@ -41,7 +41,7 @@ static bool isASTUnitSourceLocation(const CXSourceLocation &L) {
extern "C" {
CXSourceLocation clang_getNullLocation() {
- CXSourceLocation Result = { { 0, 0 }, 0 };
+ CXSourceLocation Result = { { nullptr, nullptr }, 0 };
return Result;
}
@@ -52,7 +52,7 @@ unsigned clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) {
}
CXSourceRange clang_getNullRange() {
- CXSourceRange Result = { { 0, 0 }, 0, 0 };
+ CXSourceRange Result = { { nullptr, nullptr }, 0, 0 };
return Result;
}
@@ -89,7 +89,7 @@ int clang_Range_isNull(CXSourceRange range) {
CXSourceLocation clang_getRangeStart(CXSourceRange range) {
// Special decoding for CXSourceLocations for CXLoadedDiagnostics.
if ((uintptr_t)range.ptr_data[0] & 0x1) {
- CXSourceLocation Result = { { range.ptr_data[0], 0 }, 0 };
+ CXSourceLocation Result = { { range.ptr_data[0], nullptr }, 0 };
return Result;
}
@@ -101,7 +101,7 @@ CXSourceLocation clang_getRangeStart(CXSourceRange range) {
CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
// Special decoding for CXSourceLocations for CXLoadedDiagnostics.
if ((uintptr_t)range.ptr_data[0] & 0x1) {
- CXSourceLocation Result = { { range.ptr_data[1], 0 }, 0 };
+ CXSourceLocation Result = { { range.ptr_data[1], nullptr }, 0 };
return Result;
}
@@ -183,7 +183,7 @@ CXSourceLocation clang_getLocationForOffset(CXTranslationUnit TU,
static void createNullLocation(CXFile *file, unsigned *line,
unsigned *column, unsigned *offset) {
if (file)
- *file = 0;
+ *file = nullptr;
if (line)
*line = 0;
if (column)
@@ -194,7 +194,7 @@ static void createNullLocation(CXFile *file, unsigned *line,
}
static void createNullLocation(CXString *filename, unsigned *line,
- unsigned *column, unsigned *offset = 0) {
+ unsigned *column, unsigned *offset = nullptr) {
if (filename)
*filename = cxstring::createEmpty();
if (line)
diff --git a/tools/libclang/CXString.cpp b/tools/libclang/CXString.cpp
index 662b0f94db..dec8ebcd98 100644
--- a/tools/libclang/CXString.cpp
+++ b/tools/libclang/CXString.cpp
@@ -51,7 +51,7 @@ CXString createEmpty() {
CXString createNull() {
CXString Str;
- Str.data = 0;
+ Str.data = nullptr;
Str.private_flags = CXS_Unmanaged;
return Str;
}
diff --git a/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h
index 13183becf7..d86ed2b8d3 100644
--- a/tools/libclang/CXTranslationUnit.h
+++ b/tools/libclang/CXTranslationUnit.h
@@ -42,7 +42,7 @@ CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
if (!TU)
- return 0;
+ return nullptr;
return TU->TheASTUnit;
}
@@ -72,7 +72,7 @@ public:
CXTranslationUnitImpl *takeTU() {
CXTranslationUnitImpl *retTU = TU;
- TU = 0;
+ TU = nullptr;
return retTU;
}
};
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index 82c30bfed4..fe45899ad5 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -120,7 +120,8 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
if (TK == CXType_Invalid)
TK = GetTypeKind(T);
- CXType CT = { TK, { TK == CXType_Invalid ? 0 : T.getAsOpaquePtr(), TU }};
+ CXType CT = { TK, { TK == CXType_Invalid ? nullptr
+ : T.getAsOpaquePtr(), TU } };
return CT;
}
@@ -386,7 +387,7 @@ CXCursor clang_getTypeDeclaration(CXType CT) {
if (!TP)
return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
- Decl *D = 0;
+ Decl *D = nullptr;
try_again:
switch (TP->getTypeClass()) {
@@ -432,7 +433,7 @@ try_again:
}
CXString clang_getTypeKindSpelling(enum CXTypeKind K) {
- const char *s = 0;
+ const char *s = nullptr;
#define TKIND(X) case CXType_##X: s = "" #X ""; break
switch (K) {
TKIND(Invalid);
@@ -854,7 +855,7 @@ CXString clang_getDeclObjCTypeEncoding(CXCursor C) {
if (Ctx.getObjCEncodingForMethodDecl(OMD, encoding))
return cxstring::createRef("?");
} else if (const ObjCPropertyDecl *OPD = dyn_cast<ObjCPropertyDecl>(D))
- Ctx.getObjCEncodingForPropertyDecl(OPD, NULL, encoding);
+ Ctx.getObjCEncodingForPropertyDecl(OPD, nullptr, encoding);
else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
Ctx.getObjCEncodingForFunctionDecl(FD, encoding);
else {
diff --git a/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h
index 53d864d942..c4ec7b6937 100644
--- a/tools/libclang/CursorVisitor.h
+++ b/tools/libclang/CursorVisitor.h
@@ -36,8 +36,8 @@ protected:
const void *data[3];
CXCursor parent;
Kind K;
- VisitorJob(CXCursor C, Kind k, const void *d1, const void *d2 = 0,
- const void *d3 = 0)
+ VisitorJob(CXCursor C, Kind k, const void *d1, const void *d2 = nullptr,
+ const void *d3 = nullptr)
: parent(C), K(k) {
data[0] = d1;
data[1] = d2;
@@ -147,7 +147,7 @@ public:
bool VisitIncludedPreprocessingEntries = false,
SourceRange RegionOfInterest = SourceRange(),
bool VisitDeclsOnly = false,
- PostChildrenVisitorTy PostChildrenVisitor = 0)
+ PostChildrenVisitorTy PostChildrenVisitor = nullptr)
: TU(TU), AU(cxtu::getASTUnit(TU)),
Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
ClientData(ClientData),
@@ -155,13 +155,13 @@ public:
VisitIncludedEntities(VisitIncludedPreprocessingEntries),
RegionOfInterest(RegionOfInterest),
VisitDeclsOnly(VisitDeclsOnly),
- DI_current(0), FileDI_current(0)
+ DI_current(nullptr), FileDI_current(nullptr)
{
Parent.kind = CXCursor_NoDeclFound;
- Parent.data[0] = 0;
- Parent.data[1] = 0;
- Parent.data[2] = 0;
- StmtParent = 0;
+ Parent.data[0] = nullptr;
+ Parent.data[1] = nullptr;
+ Parent.data[2] = nullptr;
+ StmtParent = nullptr;
}
~CursorVisitor() {
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp
index fbec3d7c01..7dc53a6275 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -170,7 +170,7 @@ void IndexingContext::indexBody(const Stmt *S, const NamedDecl *Parent,
if (!S)
return;
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
BodyIndexer(*this, Parent, DC).TraverseStmt(const_cast<Stmt*>(S));
}
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index 64052ed309..c8cf1d3621 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -31,7 +31,8 @@ public:
return MD && !MD->isImplicit() && MD->isThisDeclarationADefinition();
}
- void handleDeclarator(const DeclaratorDecl *D, const NamedDecl *Parent = 0) {
+ void handleDeclarator(const DeclaratorDecl *D,
+ const NamedDecl *Parent = nullptr) {
if (!Parent) Parent = D;
if (!IndexCtx.shouldIndexFunctionLocalSymbols()) {
@@ -227,7 +228,7 @@ public:
if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) {
if (!IvarD->getSynthesize())
- IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), 0,
+ IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
D->getDeclContext());
}
diff --git a/tools/libclang/IndexTypeSourceInfo.cpp b/tools/libclang/IndexTypeSourceInfo.cpp
index 4f8d4e5925..f13c0aff0d 100644
--- a/tools/libclang/IndexTypeSourceInfo.cpp
+++ b/tools/libclang/IndexTypeSourceInfo.cpp
@@ -108,7 +108,7 @@ void IndexingContext::indexTypeLoc(TypeLoc TL,
if (TL.isNull())
return;
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
TypeIndexer(*this, Parent, DC).TraverseTypeLoc(TL);
}
@@ -122,7 +122,7 @@ void IndexingContext::indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
indexNestedNameSpecifierLoc(Prefix, Parent, DC);
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
SourceLocation Loc = NNS.getSourceRange().getBegin();
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 47ba97bd9a..6bb995ae5a 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -511,8 +511,8 @@ static void clang_indexSourceFile_Impl(void *UserData) {
ITUI->result = CXError_Failure;
if (out_TU)
- *out_TU = 0;
- bool requestedToGetTU = (out_TU != 0);
+ *out_TU = nullptr;
+ bool requestedToGetTU = (out_TU != nullptr);
if (!cxIdxAction) {
ITUI->result = CXError_InvalidArguments;
@@ -537,7 +537,7 @@ static void clang_indexSourceFile_Impl(void *UserData) {
bool CaptureDiagnostics = !Logger::isLoggingEnabled();
- CaptureDiagnosticConsumer *CaptureDiag = 0;
+ CaptureDiagnosticConsumer *CaptureDiag = nullptr;
if (CaptureDiagnostics)
CaptureDiag = new CaptureDiagnosticConsumer();
@@ -632,7 +632,7 @@ static void clang_indexSourceFile_Impl(void *UserData) {
std::unique_ptr<IndexingFrontendAction> IndexAction;
IndexAction.reset(new IndexingFrontendAction(client_data, CB,
index_options, CXTU->getTU(),
- SkipBodies ? IdxSession->SkipBodyData.get() : 0));
+ SkipBodies ? IdxSession->SkipBodyData.get() : nullptr));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<IndexingFrontendAction>
@@ -796,7 +796,7 @@ static void clang_indexTranslationUnit_Impl(void *UserData) {
IndexCtxCleanup(IndexCtx.get());
std::unique_ptr<IndexingConsumer> IndexConsumer;
- IndexConsumer.reset(new IndexingConsumer(*IndexCtx, 0));
+ IndexConsumer.reset(new IndexingConsumer(*IndexCtx, nullptr));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<IndexingConsumer>
@@ -814,7 +814,7 @@ static void clang_indexTranslationUnit_Impl(void *UserData) {
FileManager &FileMgr = Unit->getFileManager();
if (Unit->getOriginalSourceFileName().empty())
- IndexCtx->enteredMainFile(0);
+ IndexCtx->enteredMainFile(nullptr);
else
IndexCtx->enteredMainFile(FileMgr.getFile(Unit->getOriginalSourceFileName()));
@@ -840,46 +840,46 @@ int clang_index_isEntityObjCContainerKind(CXIdxEntityKind K) {
const CXIdxObjCContainerDeclInfo *
clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *DInfo) {
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
if (const ObjCContainerDeclInfo *
ContInfo = dyn_cast<ObjCContainerDeclInfo>(DI))
return &ContInfo->ObjCContDeclInfo;
- return 0;
+ return nullptr;
}
const CXIdxObjCInterfaceDeclInfo *
clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *DInfo) {
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
if (const ObjCInterfaceDeclInfo *
InterInfo = dyn_cast<ObjCInterfaceDeclInfo>(DI))
return &InterInfo->ObjCInterDeclInfo;
- return 0;
+ return nullptr;
}
const CXIdxObjCCategoryDeclInfo *
clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *DInfo){
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
if (const ObjCCategoryDeclInfo *
CatInfo = dyn_cast<ObjCCategoryDeclInfo>(DI))
return &CatInfo->ObjCCatDeclInfo;
- return 0;
+ return nullptr;
}
const CXIdxObjCProtocolRefListInfo *
clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *DInfo) {
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
@@ -894,50 +894,50 @@ clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *DInfo) {
if (const ObjCCategoryDeclInfo *CatInfo = dyn_cast<ObjCCategoryDeclInfo>(DI))
return CatInfo->ObjCCatDeclInfo.protocols;
- return 0;
+ return nullptr;
}
const CXIdxObjCPropertyDeclInfo *
clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *DInfo) {
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
if (const ObjCPropertyDeclInfo *PropInfo = dyn_cast<ObjCPropertyDeclInfo>(DI))
return &PropInfo->ObjCPropDeclInfo;
- return 0;
+ return nullptr;
}
const CXIdxIBOutletCollectionAttrInfo *
clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *AInfo) {
if (!AInfo)
- return 0;
+ return nullptr;
const AttrInfo *DI = static_cast<const AttrInfo *>(AInfo);
if (const IBOutletCollectionInfo *
IBInfo = dyn_cast<IBOutletCollectionInfo>(DI))
return &IBInfo->IBCollInfo;
- return 0;
+ return nullptr;
}
const CXIdxCXXClassDeclInfo *
clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *DInfo) {
if (!DInfo)
- return 0;
+ return nullptr;
const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
if (const CXXClassDeclInfo *ClassInfo = dyn_cast<CXXClassDeclInfo>(DI))
return &ClassInfo->CXXClassInfo;
- return 0;
+ return nullptr;
}
CXIdxClientContainer
clang_index_getClientContainer(const CXIdxContainerInfo *info) {
if (!info)
- return 0;
+ return nullptr;
const ContainerInfo *Container = static_cast<const ContainerInfo *>(info);
return Container->IndexCtx->getClientContainerForDC(Container->DC);
}
@@ -952,7 +952,7 @@ void clang_index_setClientContainer(const CXIdxContainerInfo *info,
CXIdxClientEntity clang_index_getClientEntity(const CXIdxEntityInfo *info) {
if (!info)
- return 0;
+ return nullptr;
const EntityInfo *Entity = static_cast<const EntityInfo *>(info);
return Entity->IndexCtx->getClientEntity(Entity->Dcl);
}
@@ -1072,8 +1072,8 @@ void clang_indexLoc_getFileLocation(CXIdxLoc location,
unsigned *line,
unsigned *column,
unsigned *offset) {
- if (indexFile) *indexFile = 0;
- if (file) *file = 0;
+ if (indexFile) *indexFile = nullptr;
+ if (file) *file = nullptr;
if (line) *line = 0;
if (column) *column = 0;
if (offset) *offset = 0;
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 1637843a1b..bf6e172fc0 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -30,7 +30,7 @@ IndexingContext::ObjCProtocolListInfo::ObjCProtocolListInfo(
ObjCProtocolDecl *PD = *I;
ProtEntities.push_back(EntityInfo());
IdxCtx.getEntityInfo(PD, ProtEntities.back(), SA);
- CXIdxObjCProtocolRefInfo ProtInfo = { 0,
+ CXIdxObjCProtocolRefInfo ProtInfo = { nullptr,
MakeCursorObjCProtocolRef(PD, Loc, IdxCtx.CXTU),
IdxCtx.getIndexLoc(Loc) };
ProtInfos.push_back(ProtInfo);
@@ -58,7 +58,7 @@ IBOutletCollectionInfo::IBOutletCollectionInfo(
ClassInfo = other.ClassInfo;
IBCollInfo.objcClass = &ClassInfo;
} else
- IBCollInfo.objcClass = 0;
+ IBCollInfo.objcClass = nullptr;
}
AttrListInfo::AttrListInfo(const Decl *D, IndexingContext &IdxCtx)
@@ -96,7 +96,7 @@ AttrListInfo::AttrListInfo(const Decl *D, IndexingContext &IdxCtx)
IBAttr->getInterfaceLoc()->getTypeLoc().getLocStart();
IBInfo.IBCollInfo.attrInfo = &IBInfo;
IBInfo.IBCollInfo.classLoc = IdxCtx.getIndexLoc(InterfaceLocStart);
- IBInfo.IBCollInfo.objcClass = 0;
+ IBInfo.IBCollInfo.objcClass = nullptr;
IBInfo.IBCollInfo.classCursor = clang_getNullCursor();
QualType Ty = IBAttr->getInterface();
if (const ObjCObjectType *ObjectTy = Ty->getAs<ObjCObjectType>()) {
@@ -125,7 +125,7 @@ IndexingContext::CXXBasesListInfo::CXXBasesListInfo(const CXXRecordDecl *D,
ScratchAlloc &SA) {
for (const auto &Base : D->bases()) {
BaseEntities.push_back(EntityInfo());
- const NamedDecl *BaseD = 0;
+ const NamedDecl *BaseD = nullptr;
QualType T = Base.getType();
SourceLocation Loc = getBaseLoc(Base);
@@ -140,7 +140,7 @@ IndexingContext::CXXBasesListInfo::CXXBasesListInfo(const CXXRecordDecl *D,
if (BaseD)
IdxCtx.getEntityInfo(BaseD, BaseEntities.back(), SA);
- CXIdxBaseClassInfo BaseInfo = { 0,
+ CXIdxBaseClassInfo BaseInfo = { nullptr,
MakeCursorCXXBaseSpecifier(&Base, IdxCtx.CXTU),
IdxCtx.getIndexLoc(Loc) };
BaseInfos.push_back(BaseInfo);
@@ -227,14 +227,15 @@ bool IndexingContext::isFunctionLocalDecl(const Decl *D) {
bool IndexingContext::shouldAbort() {
if (!CB.abortQuery)
return false;
- return CB.abortQuery(ClientData, 0);
+ return CB.abortQuery(ClientData, nullptr);
}
void IndexingContext::enteredMainFile(const FileEntry *File) {
if (File && CB.enteredMainFile) {
CXIdxClientFile idxFile =
CB.enteredMainFile(ClientData,
- static_cast<CXFile>(const_cast<FileEntry *>(File)), 0);
+ static_cast<CXFile>(const_cast<FileEntry *>(File)),
+ nullptr);
FileMap[File] = idxFile;
}
}
@@ -283,7 +284,7 @@ void IndexingContext::importedPCH(const FileEntry *File) {
CXIdxImportedASTFileInfo Info = {
static_cast<CXFile>(
const_cast<FileEntry *>(File)),
- /*module=*/NULL,
+ /*module=*/nullptr,
getIndexLoc(SourceLocation()),
/*isImplicit=*/false
};
@@ -292,9 +293,9 @@ void IndexingContext::importedPCH(const FileEntry *File) {
}
void IndexingContext::startedTranslationUnit() {
- CXIdxClientContainer idxCont = 0;
+ CXIdxClientContainer idxCont = nullptr;
if (CB.startedTranslationUnit)
- idxCont = CB.startedTranslationUnit(ClientData, 0);
+ idxCont = CB.startedTranslationUnit(ClientData, nullptr);
addContainerInMap(Ctx->getTranslationUnitDecl(), idxCont);
}
@@ -302,7 +303,7 @@ void IndexingContext::handleDiagnosticSet(CXDiagnostic CXDiagSet) {
if (!CB.diagnostic)
return;
- CB.diagnostic(ClientData, CXDiagSet, 0);
+ CB.diagnostic(ClientData, CXDiagSet, nullptr);
}
bool IndexingContext::handleDecl(const NamedDecl *D,
@@ -464,7 +465,8 @@ bool IndexingContext::handleObjCInterface(const ObjCInterfaceDecl *D) {
ObjCInterfaceDeclInfo InterInfo(D);
InterInfo.ObjCProtoListInfo = ProtInfo.getListInfo();
InterInfo.ObjCInterDeclInfo.containerInfo = &InterInfo.ObjCContDeclInfo;
- InterInfo.ObjCInterDeclInfo.superInfo = D->getSuperClass() ? &BaseClass : 0;
+ InterInfo.ObjCInterDeclInfo.superInfo = D->getSuperClass() ? &BaseClass
+ : nullptr;
InterInfo.ObjCInterDeclInfo.protocols = &InterInfo.ObjCProtoListInfo;
return handleObjCContainer(D, D->getLocation(), getCursor(D), InterInfo);
@@ -529,7 +531,7 @@ bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
CatDInfo.ObjCCatDeclInfo.classCursor =
MakeCursorObjCClassRef(IFaceD, ClassLoc, CXTU);
} else {
- CatDInfo.ObjCCatDeclInfo.objcClass = 0;
+ CatDInfo.ObjCCatDeclInfo.objcClass = nullptr;
CatDInfo.ObjCCatDeclInfo.classCursor = clang_getNullCursor();
}
CatDInfo.ObjCCatDeclInfo.classLoc = getIndexLoc(ClassLoc);
@@ -559,11 +561,11 @@ bool IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
CatDInfo.ObjCCatDeclInfo.classCursor =
MakeCursorObjCClassRef(IFaceD, ClassLoc, CXTU);
} else {
- CatDInfo.ObjCCatDeclInfo.objcClass = 0;
+ CatDInfo.ObjCCatDeclInfo.objcClass = nullptr;
CatDInfo.ObjCCatDeclInfo.classCursor = clang_getNullCursor();
}
CatDInfo.ObjCCatDeclInfo.classLoc = getIndexLoc(ClassLoc);
- CatDInfo.ObjCCatDeclInfo.protocols = 0;
+ CatDInfo.ObjCCatDeclInfo.protocols = nullptr;
return handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
}
@@ -587,7 +589,8 @@ bool IndexingContext::handleObjCMethod(const ObjCMethodDecl *D) {
bool IndexingContext::handleSynthesizedObjCProperty(
const ObjCPropertyImplDecl *D) {
ObjCPropertyDecl *PD = D->getPropertyDecl();
- return handleReference(PD, D->getLocation(), getCursor(D), 0, D->getDeclContext());
+ return handleReference(PD, D->getLocation(), getCursor(D), nullptr,
+ D->getDeclContext());
}
bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
@@ -611,13 +614,13 @@ bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
getEntityInfo(Getter, GetterEntity, SA);
DInfo.ObjCPropDeclInfo.getter = &GetterEntity;
} else {
- DInfo.ObjCPropDeclInfo.getter = 0;
+ DInfo.ObjCPropDeclInfo.getter = nullptr;
}
if (ObjCMethodDecl *Setter = D->getSetterMethodDecl()) {
getEntityInfo(Setter, SetterEntity, SA);
DInfo.ObjCPropDeclInfo.setter = &SetterEntity;
} else {
- DInfo.ObjCPropDeclInfo.setter = 0;
+ DInfo.ObjCPropDeclInfo.setter = nullptr;
}
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
@@ -700,7 +703,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
Cursor,
getIndexLoc(Loc),
&RefEntity,
- Parent ? &ParentEntity : 0,
+ Parent ? &ParentEntity : nullptr,
&Container };
CB.indexEntityReference(ClientData, &Info);
return true;
@@ -712,7 +715,7 @@ bool IndexingContext::isNotFromSourceFile(SourceLocation Loc) const {
SourceManager &SM = Ctx->getSourceManager();
SourceLocation FileLoc = SM.getFileLoc(Loc);
FileID FID = SM.getFileID(FileLoc);
- return SM.getFileEntryForID(FID) == 0;
+ return SM.getFileEntryForID(FID) == nullptr;
}
void IndexingContext::addContainerInMap(const DeclContext *DC,
@@ -736,10 +739,10 @@ void IndexingContext::addContainerInMap(const DeclContext *DC,
CXIdxClientEntity IndexingContext::getClientEntity(const Decl *D) const {
if (!D)
- return 0;
+ return nullptr;
EntityMapTy::const_iterator I = EntityMap.find(D);
if (I == EntityMap.end())
- return 0;
+ return nullptr;
return I->second;
}
@@ -848,28 +851,28 @@ IndexingContext::getEntityContainer(const Decl *D) const {
CXIdxClientContainer
IndexingContext::getClientContainerForDC(const DeclContext *DC) const {
if (!DC)
- return 0;
+ return nullptr;
ContainerMapTy::const_iterator I = ContainerMap.find(DC);
if (I == ContainerMap.end())
- return 0;
+ return nullptr;
return I->second;
}
CXIdxClientFile IndexingContext::getIndexFile(const FileEntry *File) {
if (!File)
- return 0;
+ return nullptr;
FileMapTy::iterator FI = FileMap.find(File);
if (FI != FileMap.end())
return FI->second;
- return 0;
+ return nullptr;
}
CXIdxLoc IndexingContext::getIndexLoc(SourceLocation Loc) const {
- CXIdxLoc idxLoc = { {0, 0}, 0 };
+ CXIdxLoc idxLoc = { {nullptr, nullptr}, 0 };
if (Loc.isInvalid())
return idxLoc;
@@ -1093,7 +1096,7 @@ void IndexingContext::getEntityInfo(const NamedDecl *D,
EntityInfo.name = SA.toCStr(II->getName());
} else if (isa<TagDecl>(D) || isa<FieldDecl>(D) || isa<NamespaceDecl>(D)) {
- EntityInfo.name = 0; // anonymous tag/field/namespace.
+ EntityInfo.name = nullptr; // anonymous tag/field/namespace.
} else {
SmallString<256> StrBuf;
@@ -1108,7 +1111,7 @@ void IndexingContext::getEntityInfo(const NamedDecl *D,
SmallString<512> StrBuf;
bool Ignore = getDeclCursorUSR(D, StrBuf);
if (Ignore) {
- EntityInfo.USR = 0;
+ EntityInfo.USR = nullptr;
} else {
EntityInfo.USR = SA.copyCStr(StrBuf.str());
}
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index 88d623f42a..c3851cd7e9 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -49,8 +49,8 @@ struct EntityInfo : public CXIdxEntityInfo {
IntrusiveRefCntPtr<AttrListInfo> AttrList;
EntityInfo() {
- name = USR = 0;
- attributes = 0;
+ name = USR = nullptr;
+ attributes = nullptr;
numAttributes = 0;
}
};
@@ -86,9 +86,9 @@ struct DeclInfo : public CXIdxDeclInfo {
this->isRedeclaration = isRedeclaration;
this->isDefinition = isDefinition;
this->isContainer = isContainer;
- attributes = 0;
+ attributes = nullptr;
numAttributes = 0;
- declAsContainer = semanticContainer = lexicalContainer = 0;
+ declAsContainer = semanticContainer = lexicalContainer = nullptr;
flags = 0;
}
DeclInfo(DInfoKind K,
@@ -97,9 +97,9 @@ struct DeclInfo : public CXIdxDeclInfo {
this->isRedeclaration = isRedeclaration;
this->isDefinition = isDefinition;
this->isContainer = isContainer;
- attributes = 0;
+ attributes = nullptr;
numAttributes = 0;
- declAsContainer = semanticContainer = lexicalContainer = 0;
+ declAsContainer = semanticContainer = lexicalContainer = nullptr;
flags = 0;
}
};
@@ -145,7 +145,7 @@ struct ObjCInterfaceDeclInfo : public ObjCContainerDeclInfo {
ObjCInterfaceDeclInfo(const ObjCInterfaceDecl *D)
: ObjCContainerDeclInfo(Info_ObjCInterface,
/*isForwardRef=*/false,
- /*isRedeclaration=*/D->getPreviousDecl() != 0,
+ /*isRedeclaration=*/D->getPreviousDecl() != nullptr,
/*isImplementation=*/false) { }
static bool classof(const DeclInfo *D) {
@@ -224,7 +224,7 @@ struct IBOutletCollectionInfo : public AttrInfo {
IBOutletCollectionInfo(CXCursor C, CXIdxLoc Loc, const Attr *A) :
AttrInfo(CXIdxAttr_IBOutletCollection, C, Loc, A) {
assert(C.kind == CXCursor_IBOutletCollectionAttr);
- IBCollInfo.objcClass = 0;
+ IBCollInfo.objcClass = nullptr;
}
IBOutletCollectionInfo(const IBOutletCollectionInfo &other);
@@ -252,7 +252,7 @@ public:
const CXIdxAttrInfo *const *getAttrs() const {
if (CXAttrs.empty())
- return 0;
+ return nullptr;
return CXAttrs.data();
}
unsigned getNumAttrs() const { return (unsigned)CXAttrs.size(); }
@@ -333,7 +333,7 @@ class IndexingContext {
public:
IndexingContext(CXClientData clientData, IndexerCallbacks &indexCallbacks,
unsigned indexOptions, CXTranslationUnit cxTU)
- : Ctx(0), ClientData(clientData), CB(indexCallbacks),
+ : Ctx(nullptr), ClientData(clientData), CB(indexCallbacks),
IndexOptions(indexOptions), CXTU(cxTU),
StrScratch(), StrAdapterCount(0) { }
@@ -376,19 +376,19 @@ public:
void indexTagDecl(const TagDecl *D);
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
- const DeclContext *DC = 0);
+ const DeclContext *DC = nullptr);
void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
- const DeclContext *DC = 0);
+ const DeclContext *DC = nullptr);
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
const NamedDecl *Parent,
- const DeclContext *DC = 0);
+ const DeclContext *DC = nullptr);
void indexDeclContext(const DeclContext *DC);
void indexBody(const Stmt *S, const NamedDecl *Parent,
- const DeclContext *DC = 0);
+ const DeclContext *DC = nullptr);
void handleDiagnosticSet(CXDiagnosticSet CXDiagSet);
@@ -431,13 +431,13 @@ public:
bool handleReference(const NamedDecl *D, SourceLocation Loc, CXCursor Cursor,
const NamedDecl *Parent,
const DeclContext *DC,
- const Expr *E = 0,
+ const Expr *E = nullptr,
CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct);
bool handleReference(const NamedDecl *D, SourceLocation Loc,
const NamedDecl *Parent,
const DeclContext *DC,
- const Expr *E = 0,
+ const Expr *E = nullptr,
CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct);
bool isNotFromSourceFile(SourceLocation Loc) const;
@@ -465,7 +465,7 @@ private:
bool handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
DeclInfo &DInfo,
- const DeclContext *LexicalDC = 0);
+ const DeclContext *LexicalDC = nullptr);
bool handleObjCContainer(const ObjCContainerDecl *D,
SourceLocation Loc, CXCursor Cursor,