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);
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);
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) {
}
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),
}
GroupRecord::subgroup_iterator GroupRecord::subgroup_end() const {
- return 0;
+ return nullptr;
}
GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const {
}
GroupRecord::diagnostics_iterator GroupRecord::diagnostics_end() const {
- return 0;
+ return nullptr;
}
llvm::ArrayRef<GroupRecord> diagtool::getDiagnosticGroups() {
friend struct GroupRecord;
group_iterator(const short *Start) : CurrentID(Start) {
if (CurrentID && *CurrentID == -1)
- CurrentID = 0;
+ CurrentID = nullptr;
}
public:
group_iterator &operator++() {
++CurrentID;
if (*CurrentID == -1)
- CurrentID = 0;
+ CurrentID = nullptr;
return *this;
}
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);
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);
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);
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);
}
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++" },
// 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));
}
if (!migrate_dir_path) {
if (Logging)
llvm::errs() << "clang_getRemappings was called with NULL parameter\n";
- return 0;
+ return nullptr;
}
bool exists = false;
<< "\")\n";
llvm::errs() << "\"" << migrate_dir_path << "\" does not exist\n";
}
- return 0;
+ return nullptr;
}
TextDiagnosticBuffer diagBuffer;
I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I)
llvm::errs() << I->second << '\n';
}
- return 0;
+ return nullptr;
}
return remap.release();
if (Logging)
llvm::errs() << "clang_getRemappingsFromFileList was called with "
"NULL filePaths\n";
- return 0;
+ return nullptr;
}
TextDiagnosticBuffer diagBuffer;
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;
}
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;
FileDI_current = &DIt;
FileDE_current = DE;
} else {
- FileDI_current = 0;
+ FileDI_current = nullptr;
}
if (Visit(MakeCXCursor(D, TU, Range), /*CheckedRegionOfInterest=*/true))
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;
}
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;
}
}
bool CursorVisitor::Visit(const Stmt *S) {
- VisitorWorkList *WL = 0;
+ VisitorWorkList *WL = nullptr;
if (!WorkListFreeList.empty()) {
WL = WorkListFreeList.back();
WL->clear();
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;
{
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;
}
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;
// 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;
}
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))
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);
if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
isa<ParmVarDecl>(SizeOfPack->getPack()))
return SizeOfPack->getPack();
-
- return 0;
+
+ return nullptr;
}
static SourceLocation getLocationFromExpr(const Expr *E) {
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);
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),
// 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;
}
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();
}
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();
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);
}
if (Tokens)
- *Tokens = 0;
+ *Tokens = nullptr;
if (NumTokens)
*NumTokens = 0;
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;
/// 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())
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());
}
return ImportD->getImportedModule();
}
- return 0;
+ return nullptr;
}
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;
}
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();
if (Index < TopHeaders.size())
return const_cast<FileEntry *>(TopHeaders[Index]);
- return 0;
+ return nullptr;
}
} // end: extern "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;
}
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;
}
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;
}
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"
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;
}
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;
}
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);
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();
}
}
- 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);
}
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);
// 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());
}
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);
}
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);
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) {
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))
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:
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.
}
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>())
baseType->getAs<InjectedClassNameType>())
D = Injected->getDecl();
}
-
- if (D != NULL) {
+
+ if (D != nullptr) {
CXCursor cursor = cxcursor::MakeCXCursor(D, *TU);
AllocatedResults.ContainerKind = clang_getCursorKind(cursor);
clang_disposeString(CursorUSR);
const Type *type = baseType.getTypePtrOrNull();
- if (type != NULL) {
+ if (type) {
AllocatedResults.ContainerIsIncomplete = type->isIncompleteType();
}
else {
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
#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);
// 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.
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);
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);
AllocatedCXCodeCompleteResults *Results
= static_cast<AllocatedCXCodeCompleteResults*>(ResultsIn);
if (!Results || Index >= Results->Diagnostics.size())
- return 0;
+ return nullptr;
CXStoredDiagnostic *Diag = Results->DiagnosticsWrappers[Index];
if (!Diag)
static_cast<AllocatedCXCodeCompleteResults *>(ResultsIn);
if (!Results)
return CXCursor_InvalidCode;
-
- if (IsIncomplete != NULL) {
+
+ if (IsIncomplete != nullptr) {
*IsIncomplete = Results->ContainerIsIncomplete;
}
// Diagnostics in the ASTUnit were updated, reset the associated
// diagnostics.
delete Set;
- TU->Diagnostics = 0;
+ TU->Diagnostics = nullptr;
}
}
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);
}
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));
}
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 << ":";
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;
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;
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) {
/// itself, so both 'C' can be highlighted.
const Decl *getCanonical(const Decl *D) const {
if (!D)
- return 0;
+ return nullptr;
D = D->getCanonicalDecl();
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)
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
CXFile file,
CXCursorAndRangeVisitorBlock block) {
CXCursorAndRangeVisitor visitor = { block,
- block ? _visitCursorAndRange : 0 };
+ block ? _visitCursorAndRange : nullptr };
return clang_findReferencesInFile(cursor, file, visitor);
}
CXFile file,
CXCursorAndRangeVisitorBlock block) {
CXCursorAndRangeVisitor visitor = { block,
- block ? _visitCursorAndRange : 0 };
+ block ? _visitCursorAndRange : nullptr };
return clang_findIncludesInFile(TU, file, visitor);
}
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";
bool trace = isStackTracingEnabled()) {
if (isLoggingEnabled())
return new Logger(name, trace);
- return 0;
+ return nullptr;
}
explicit Logger(llvm::StringRef name, bool trace)
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));
}
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);
}
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);
}
static inline const T *getASTNodeAs(CXComment CXC) {
const comments::Comment *C = getASTNode(CXC);
if (!C)
- return NULL;
+ return nullptr;
return dyn_cast<T>(C);
}
return new AllocatedCXCompileCommands(std::move(CCmd));
}
- return 0;
+ return nullptr;
}
CXCompileCommands
return new AllocatedCXCompileCommands(std::move(CCmd));
}
- return 0;
+ return nullptr;
}
void
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];
}
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;
}
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;
}
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;
}
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;
}
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;
}
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]);
}
ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) {
CXTranslationUnit TU = getCursorTU(Cursor);
if (!TU)
- return 0;
+ return nullptr;
return cxtu::getASTUnit(TU);
}
return cursor;
const Expr *E = getCursorExpr(cursor);
- TypeSourceInfo *Type = 0;
+ TypeSourceInfo *Type = nullptr;
if (const CXXUnresolvedConstructExpr *
UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) {
Type = UnCtor->getTypeSourceInfo();
false);
return String;
}
- return NULL;
+ return nullptr;
}
} // end: extern C.
CXCursor **overridden,
unsigned *num_overridden) {
if (overridden)
- *overridden = 0;
+ *overridden = nullptr;
if (num_overridden)
*num_overridden = 0;
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();
}
int clang_Cursor_isDynamicCall(CXCursor C) {
- const Expr *E = 0;
+ const Expr *E = nullptr;
if (clang_isExpression(C.kind))
E = getCursorExpr(C);
if (!E)
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))
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);
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,
CXCursor C;
bool isPseudo() const {
- return C.data[1] != 0;
+ return C.data[1] != nullptr;
}
const MacroDefinition *getAsMacroDefinition() const {
assert(isPseudo());
// 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;
}
if (!Buffer) {
reportBad(CXLoadDiag_CannotLoad, ErrStr);
- return 0;
+ return nullptr;
}
llvm::BitstreamReader StreamFile;
Stream.Read(8) != 'G') {
reportBad(CXLoadDiag_InvalidFile,
"Bad header in diagnostics file");
- return 0;
+ return nullptr;
}
std::unique_ptr<CXLoadedDiagnosticSetImpl> Diags(
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:
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;
}
unsigned fileID = Record[offset++];
if (fileID == 0) {
// Sentinel value.
- Loc.file = 0;
+ Loc.file = nullptr;
Loc.line = 0;
Loc.column = 0;
Loc.offset = 0;
extern "C" {
CXSourceLocation clang_getNullLocation() {
- CXSourceLocation Result = { { 0, 0 }, 0 };
+ CXSourceLocation Result = { { nullptr, nullptr }, 0 };
return Result;
}
}
CXSourceRange clang_getNullRange() {
- CXSourceRange Result = { { 0, 0 }, 0, 0 };
+ CXSourceRange Result = { { nullptr, nullptr }, 0, 0 };
return Result;
}
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;
}
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;
}
static void createNullLocation(CXFile *file, unsigned *line,
unsigned *column, unsigned *offset) {
if (file)
- *file = 0;
+ *file = nullptr;
if (line)
*line = 0;
if (column)
}
static void createNullLocation(CXString *filename, unsigned *line,
- unsigned *column, unsigned *offset = 0) {
+ unsigned *column, unsigned *offset = nullptr) {
if (filename)
*filename = cxstring::createEmpty();
if (line)
CXString createNull() {
CXString Str;
- Str.data = 0;
+ Str.data = nullptr;
Str.private_flags = CXS_Unmanaged;
return Str;
}
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
if (!TU)
- return 0;
+ return nullptr;
return TU->TheASTUnit;
}
CXTranslationUnitImpl *takeTU() {
CXTranslationUnitImpl *retTU = TU;
- TU = 0;
+ TU = nullptr;
return retTU;
}
};
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;
}
if (!TP)
return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
- Decl *D = 0;
+ Decl *D = nullptr;
try_again:
switch (TP->getTypeClass()) {
}
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);
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 {
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;
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),
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() {
if (!S)
return;
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
BodyIndexer(*this, Parent, DC).TraverseStmt(const_cast<Stmt*>(S));
}
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()) {
if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) {
if (!IvarD->getSynthesize())
- IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), 0,
+ IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
D->getDeclContext());
}
if (TL.isNull())
return;
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
TypeIndexer(*this, Parent, DC).TraverseTypeLoc(TL);
}
if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
indexNestedNameSpecifierLoc(Prefix, Parent, DC);
- if (DC == 0)
+ if (!DC)
DC = Parent->getLexicalDeclContext();
SourceLocation Loc = NNS.getSourceRange().getBegin();
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;
bool CaptureDiagnostics = !Logger::isLoggingEnabled();
- CaptureDiagnosticConsumer *CaptureDiag = 0;
+ CaptureDiagnosticConsumer *CaptureDiag = nullptr;
if (CaptureDiagnostics)
CaptureDiag = new CaptureDiagnosticConsumer();
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>
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>
FileManager &FileMgr = Unit->getFileManager();
if (Unit->getOriginalSourceFileName().empty())
- IndexCtx->enteredMainFile(0);
+ IndexCtx->enteredMainFile(nullptr);
else
IndexCtx->enteredMainFile(FileMgr.getFile(Unit->getOriginalSourceFileName()));
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);
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);
}
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);
}
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;
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);
ClassInfo = other.ClassInfo;
IBCollInfo.objcClass = &ClassInfo;
} else
- IBCollInfo.objcClass = 0;
+ IBCollInfo.objcClass = nullptr;
}
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>()) {
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);
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);
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;
}
}
CXIdxImportedASTFileInfo Info = {
static_cast<CXFile>(
const_cast<FileEntry *>(File)),
- /*module=*/NULL,
+ /*module=*/nullptr,
getIndexLoc(SourceLocation()),
/*isImplicit=*/false
};
}
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);
}
if (!CB.diagnostic)
return;
- CB.diagnostic(ClientData, CXDiagSet, 0);
+ CB.diagnostic(ClientData, CXDiagSet, nullptr);
}
bool IndexingContext::handleDecl(const NamedDecl *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);
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.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);
}
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,
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);
Cursor,
getIndexLoc(Loc),
&RefEntity,
- Parent ? &ParentEntity : 0,
+ Parent ? &ParentEntity : nullptr,
&Container };
CB.indexEntityReference(ClientData, &Info);
return true;
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,
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;
}
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;
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;
SmallString<512> StrBuf;
bool Ignore = getDeclCursorUSR(D, StrBuf);
if (Ignore) {
- EntityInfo.USR = 0;
+ EntityInfo.USR = nullptr;
} else {
EntityInfo.USR = SA.copyCStr(StrBuf.str());
}
IntrusiveRefCntPtr<AttrListInfo> AttrList;
EntityInfo() {
- name = USR = 0;
- attributes = 0;
+ name = USR = nullptr;
+ attributes = nullptr;
numAttributes = 0;
}
};
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,
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;
}
};
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) {
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);
const CXIdxAttrInfo *const *getAttrs() const {
if (CXAttrs.empty())
- return 0;
+ return nullptr;
return CXAttrs.data();
}
unsigned getNumAttrs() const { return (unsigned)CXAttrs.size(); }
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) { }
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);
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;
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,