[C++11] Use 'nullptr'. Serialization edition.

llvm-svn: 209392
This commit is contained in:
Craig Topper 2014-05-22 05:54:18 +00:00
parent 65382d7316
commit a13603a247
12 changed files with 179 additions and 173 deletions

View File

@ -95,21 +95,21 @@ serialization::getDefinitiveDeclContext(const DeclContext *DC) {
case Decl::TranslationUnit: case Decl::TranslationUnit:
case Decl::Namespace: case Decl::Namespace:
case Decl::LinkageSpec: case Decl::LinkageSpec:
return 0; return nullptr;
// C/C++ tag types can only be defined in one place. // C/C++ tag types can only be defined in one place.
case Decl::Enum: case Decl::Enum:
case Decl::Record: case Decl::Record:
if (const TagDecl *Def = cast<TagDecl>(DC)->getDefinition()) if (const TagDecl *Def = cast<TagDecl>(DC)->getDefinition())
return Def; return Def;
return 0; return nullptr;
// FIXME: These can be defined in one place... except special member // FIXME: These can be defined in one place... except special member
// functions and out-of-line definitions. // functions and out-of-line definitions.
case Decl::CXXRecord: case Decl::CXXRecord:
case Decl::ClassTemplateSpecialization: case Decl::ClassTemplateSpecialization:
case Decl::ClassTemplatePartialSpecialization: case Decl::ClassTemplatePartialSpecialization:
return 0; return nullptr;
// Each function, method, and block declaration is its own DeclContext. // Each function, method, and block declaration is its own DeclContext.
case Decl::Function: case Decl::Function:
@ -131,14 +131,14 @@ serialization::getDefinitiveDeclContext(const DeclContext *DC) {
if (const ObjCProtocolDecl *Def if (const ObjCProtocolDecl *Def
= cast<ObjCProtocolDecl>(DC)->getDefinition()) = cast<ObjCProtocolDecl>(DC)->getDefinition())
return Def; return Def;
return 0; return nullptr;
// FIXME: These are defined in one place, but properties in class extensions // FIXME: These are defined in one place, but properties in class extensions
// end up being back-patched into the main interface. See // end up being back-patched into the main interface. See
// Sema::HandlePropertyInClassExtension for the offending code. // Sema::HandlePropertyInClassExtension for the offending code.
case Decl::ObjCInterface: case Decl::ObjCInterface:
return 0; return nullptr;
default: default:
llvm_unreachable("Unhandled DeclContext in AST reader"); llvm_unreachable("Unhandled DeclContext in AST reader");
} }

View File

@ -275,14 +275,14 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
bool Complain) { bool Complain) {
const LangOptions &ExistingLangOpts = PP.getLangOpts(); const LangOptions &ExistingLangOpts = PP.getLangOpts();
return checkLanguageOptions(LangOpts, ExistingLangOpts, return checkLanguageOptions(LangOpts, ExistingLangOpts,
Complain? &Reader.Diags : 0); Complain? &Reader.Diags : nullptr);
} }
bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts, bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts,
bool Complain) { bool Complain) {
const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts(); const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
return checkTargetOptions(TargetOpts, ExistingTargetOpts, return checkTargetOptions(TargetOpts, ExistingTargetOpts,
Complain? &Reader.Diags : 0); Complain? &Reader.Diags : nullptr);
} }
namespace { namespace {
@ -408,9 +408,10 @@ bool PCHValidator::ReadDiagnosticOptions(
/// \brief Collect the macro definitions provided by the given preprocessor /// \brief Collect the macro definitions provided by the given preprocessor
/// options. /// options.
static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, static void
MacroDefinitionsMap &Macros, collectMacroDefinitions(const PreprocessorOptions &PPOpts,
SmallVectorImpl<StringRef> *MacroNames = 0){ MacroDefinitionsMap &Macros,
SmallVectorImpl<StringRef> *MacroNames = nullptr) {
for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) { for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) {
StringRef Macro = PPOpts.Macros[I].first; StringRef Macro = PPOpts.Macros[I].first;
bool IsUndef = PPOpts.Macros[I].second; bool IsUndef = PPOpts.Macros[I].second;
@ -565,7 +566,7 @@ bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts(); const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts();
return checkPreprocessorOptions(PPOpts, ExistingPPOpts, return checkPreprocessorOptions(PPOpts, ExistingPPOpts,
Complain? &Reader.Diags : 0, Complain? &Reader.Diags : nullptr,
PP.getFileManager(), PP.getFileManager(),
SuggestedPredefines, SuggestedPredefines,
PP.getLangOpts()); PP.getLangOpts());
@ -1348,7 +1349,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
Stream.JumpToBit(Offset); Stream.JumpToBit(Offset);
RecordData Record; RecordData Record;
SmallVector<IdentifierInfo*, 16> MacroArgs; SmallVector<IdentifierInfo*, 16> MacroArgs;
MacroInfo *Macro = 0; MacroInfo *Macro = nullptr;
while (true) { while (true) {
// Advance to the next record, but if we get to the end of the block, don't // Advance to the next record, but if we get to the end of the block, don't
@ -1437,7 +1438,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
case PP_TOKEN: { case PP_TOKEN: {
// If we see a TOKEN before a PP_MACRO_*, then the file is // If we see a TOKEN before a PP_MACRO_*, then the file is
// erroneous, just pretend we didn't see this. // erroneous, just pretend we didn't see this.
if (Macro == 0) break; if (!Macro) break;
unsigned Idx = 0; unsigned Idx = 0;
Token Tok = ReadToken(F, Record, Idx); Token Tok = ReadToken(F, Record, Idx);
@ -1554,7 +1555,7 @@ ASTReader::addPendingMacroFromModule(IdentifierInfo *II, ModuleFile *M,
GlobalMacroID GMacID, GlobalMacroID GMacID,
llvm::ArrayRef<SubmoduleID> Overrides) { llvm::ArrayRef<SubmoduleID> Overrides) {
assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard"); assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard");
SubmoduleID *OverrideData = 0; SubmoduleID *OverrideData = nullptr;
if (!Overrides.empty()) { if (!Overrides.empty()) {
OverrideData = new (Context) SubmoduleID[Overrides.size() + 1]; OverrideData = new (Context) SubmoduleID[Overrides.size() + 1];
OverrideData[0] = Overrides.size(); OverrideData[0] = Overrides.size();
@ -1685,7 +1686,7 @@ void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
// If there is a global index, look there first to determine which modules // If there is a global index, look there first to determine which modules
// provably do not have any results for this identifier. // provably do not have any results for this identifier.
GlobalModuleIndex::HitSet Hits; GlobalModuleIndex::HitSet Hits;
GlobalModuleIndex::HitSet *HitsPtr = 0; GlobalModuleIndex::HitSet *HitsPtr = nullptr;
if (!loadGlobalIndex()) { if (!loadGlobalIndex()) {
if (GlobalIndex->lookupIdentifier(II.getName(), Hits)) { if (GlobalIndex->lookupIdentifier(II.getName(), Hits)) {
HitsPtr = &Hits; HitsPtr = &Hits;
@ -1729,7 +1730,7 @@ struct ASTReader::ModuleMacroInfo {
DefMacroDirective *import(Preprocessor &PP, SourceLocation ImportLoc) const { DefMacroDirective *import(Preprocessor &PP, SourceLocation ImportLoc) const {
if (!MI) if (!MI)
return 0; return nullptr;
return PP.AllocateDefMacroDirective(MI, ImportLoc, /*isImported=*/true); return PP.AllocateDefMacroDirective(MI, ImportLoc, /*isImported=*/true);
} }
}; };
@ -1742,7 +1743,7 @@ ASTReader::getModuleMacro(const PendingMacroInfo &PMInfo) {
if (ID & 1) { if (ID & 1) {
// Macro undefinition. // Macro undefinition.
Info.SubModID = getGlobalSubmoduleID(*PMInfo.M, ID >> 1); Info.SubModID = getGlobalSubmoduleID(*PMInfo.M, ID >> 1);
Info.MI = 0; Info.MI = nullptr;
} else { } else {
// Macro definition. // Macro definition.
GlobalMacroID GMacID = getGlobalMacroID(*PMInfo.M, ID >> 1); GlobalMacroID GMacID = getGlobalMacroID(*PMInfo.M, ID >> 1);
@ -1752,7 +1753,7 @@ ASTReader::getModuleMacro(const PendingMacroInfo &PMInfo) {
// FIXME: This is highly dubious. Multiple macro definitions can have the // FIXME: This is highly dubious. Multiple macro definitions can have the
// same MacroInfo (and hence the same GMacID) due to #pragma push_macro etc. // same MacroInfo (and hence the same GMacID) due to #pragma push_macro etc.
if (MacrosLoaded[GMacID - NUM_PREDEF_MACRO_IDS]) if (MacrosLoaded[GMacID - NUM_PREDEF_MACRO_IDS])
return 0; return nullptr;
Info.MI = getMacro(GMacID); Info.MI = getMacro(GMacID);
Info.SubModID = Info.MI->getOwningModuleID(); Info.SubModID = Info.MI->getOwningModuleID();
@ -1813,10 +1814,10 @@ void ASTReader::installPCHMacroDirectives(IdentifierInfo *II,
} }
// Deserialize the macro directives history in reverse source-order. // Deserialize the macro directives history in reverse source-order.
MacroDirective *Latest = 0, *Earliest = 0; MacroDirective *Latest = nullptr, *Earliest = nullptr;
unsigned Idx = 0, N = Record.size(); unsigned Idx = 0, N = Record.size();
while (Idx < N) { while (Idx < N) {
MacroDirective *MD = 0; MacroDirective *MD = nullptr;
SourceLocation Loc = ReadSourceLocation(M, Record, Idx); SourceLocation Loc = ReadSourceLocation(M, Record, Idx);
MacroDirective::Kind K = (MacroDirective::Kind)Record[Idx++]; MacroDirective::Kind K = (MacroDirective::Kind)Record[Idx++];
switch (K) { switch (K) {
@ -1856,7 +1857,7 @@ void ASTReader::installPCHMacroDirectives(IdentifierInfo *II,
static bool areDefinedInSystemModules(MacroInfo *PrevMI, MacroInfo *NewMI, static bool areDefinedInSystemModules(MacroInfo *PrevMI, MacroInfo *NewMI,
Module *NewOwner, ASTReader &Reader) { Module *NewOwner, ASTReader &Reader) {
assert(PrevMI && NewMI); assert(PrevMI && NewMI);
Module *PrevOwner = 0; Module *PrevOwner = nullptr;
if (SubmoduleID PrevModID = PrevMI->getOwningModuleID()) if (SubmoduleID PrevModID = PrevMI->getOwningModuleID())
PrevOwner = Reader.getSubmodule(PrevModID); PrevOwner = Reader.getSubmodule(PrevModID);
SourceManager &SrcMgr = Reader.getSourceManager(); SourceManager &SrcMgr = Reader.getSourceManager();
@ -1901,9 +1902,10 @@ ASTReader::removeOverriddenMacros(IdentifierInfo *II,
llvm::ArrayRef<SubmoduleID> Overrides) { llvm::ArrayRef<SubmoduleID> Overrides) {
MacroDirective *Prev = PP.getMacroDirective(II); MacroDirective *Prev = PP.getMacroDirective(II);
if (!Prev && Overrides.empty()) if (!Prev && Overrides.empty())
return 0; return nullptr;
DefMacroDirective *PrevDef = Prev ? Prev->getDefinition().getDirective() : 0; DefMacroDirective *PrevDef = Prev ? Prev->getDefinition().getDirective()
: nullptr;
if (PrevDef && PrevDef->isAmbiguous()) { if (PrevDef && PrevDef->isAmbiguous()) {
// We had a prior ambiguity. Check whether we resolve it (or make it worse). // We had a prior ambiguity. Check whether we resolve it (or make it worse).
AmbiguousMacros &Ambig = AmbiguousMacroDefs[II]; AmbiguousMacros &Ambig = AmbiguousMacroDefs[II];
@ -1931,7 +1933,7 @@ ASTReader::removeOverriddenMacros(IdentifierInfo *II,
} }
// We ended up with no ambiguity. // We ended up with no ambiguity.
return 0; return nullptr;
} }
void ASTReader::installImportedMacro(IdentifierInfo *II, ModuleMacroInfo *MMI, void ASTReader::installImportedMacro(IdentifierInfo *II, ModuleMacroInfo *MMI,
@ -2074,7 +2076,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// If we didn't find the file, resolve it relative to the // If we didn't find the file, resolve it relative to the
// original directory from which this AST file was created. // original directory from which this AST file was created.
if (File == 0 && !F.OriginalDir.empty() && !CurrentDir.empty() && if (File == nullptr && !F.OriginalDir.empty() && !CurrentDir.empty() &&
F.OriginalDir != CurrentDir) { F.OriginalDir != CurrentDir) {
std::string Resolved = resolveFileRelativeToOriginalDir(Filename, std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
F.OriginalDir, F.OriginalDir,
@ -2085,11 +2087,11 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// For an overridden file, create a virtual file with the stored // For an overridden file, create a virtual file with the stored
// size/timestamp. // size/timestamp.
if (Overridden && File == 0) { if (Overridden && File == nullptr) {
File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime); File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
} }
if (File == 0) { if (File == nullptr) {
if (Complain) { if (Complain) {
std::string ErrorStr = "could not find file '"; std::string ErrorStr = "could not find file '";
ErrorStr += Filename; ErrorStr += Filename;
@ -2168,7 +2170,7 @@ const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) {
std::string Filename = filenameStrRef; std::string Filename = filenameStrRef;
MaybeAddSystemRootToFilename(M, Filename); MaybeAddSystemRootToFilename(M, Filename);
const FileEntry *File = FileMgr.getFile(Filename); const FileEntry *File = FileMgr.getFile(Filename);
if (File == 0 && !M.OriginalDir.empty() && !CurrentDir.empty() && if (File == nullptr && !M.OriginalDir.empty() && !CurrentDir.empty() &&
M.OriginalDir != CurrentDir) { M.OriginalDir != CurrentDir) {
std::string resolved = resolveFileRelativeToOriginalDir(Filename, std::string resolved = resolveFileRelativeToOriginalDir(Filename,
M.OriginalDir, M.OriginalDir,
@ -3440,7 +3442,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
unsigned NumModules = ModuleMgr.size(); unsigned NumModules = ModuleMgr.size();
SmallVector<ImportedModule, 4> Loaded; SmallVector<ImportedModule, 4> Loaded;
switch(ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc, switch(ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc,
/*ImportedBy=*/0, Loaded, /*ImportedBy=*/nullptr, Loaded,
0, 0, 0, 0,
ClientLoadCapabilities)) { ClientLoadCapabilities)) {
case Failure: case Failure:
@ -3452,12 +3454,12 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, ModuleMgr.end(), ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, ModuleMgr.end(),
Context.getLangOpts().Modules Context.getLangOpts().Modules
? &PP.getHeaderSearchInfo().getModuleMap() ? &PP.getHeaderSearchInfo().getModuleMap()
: 0); : nullptr);
// If we find that any modules are unusable, the global index is going // If we find that any modules are unusable, the global index is going
// to be out-of-date. Just remove it. // to be out-of-date. Just remove it.
GlobalIndex.reset(); GlobalIndex.reset();
ModuleMgr.setGlobalIndex(0); ModuleMgr.setGlobalIndex(nullptr);
return ReadResult; return ReadResult;
case Success: case Success:
@ -3990,16 +3992,16 @@ namespace {
bool ReadLanguageOptions(const LangOptions &LangOpts, bool ReadLanguageOptions(const LangOptions &LangOpts,
bool Complain) override { bool Complain) override {
return checkLanguageOptions(ExistingLangOpts, LangOpts, 0); return checkLanguageOptions(ExistingLangOpts, LangOpts, nullptr);
} }
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool ReadTargetOptions(const TargetOptions &TargetOpts,
bool Complain) override { bool Complain) override {
return checkTargetOptions(ExistingTargetOpts, TargetOpts, 0); return checkTargetOptions(ExistingTargetOpts, TargetOpts, nullptr);
} }
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
bool Complain, bool Complain,
std::string &SuggestedPredefines) override { std::string &SuggestedPredefines) override {
return checkPreprocessorOptions(ExistingPPOpts, PPOpts, 0, FileMgr, return checkPreprocessorOptions(ExistingPPOpts, PPOpts, nullptr, FileMgr,
SuggestedPredefines, ExistingLangOpts); SuggestedPredefines, ExistingLangOpts);
} }
}; };
@ -4180,7 +4182,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap(); ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
bool First = true; bool First = true;
Module *CurrentModule = 0; Module *CurrentModule = nullptr;
RecordData Record; RecordData Record;
while (true) { while (true) {
llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks(); llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks();
@ -4712,7 +4714,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
if (!PP.getPreprocessingRecord()) { if (!PP.getPreprocessingRecord()) {
Error("no preprocessing record"); Error("no preprocessing record");
return 0; return nullptr;
} }
SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor); SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
@ -4721,7 +4723,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
llvm::BitstreamEntry Entry = llvm::BitstreamEntry Entry =
M.PreprocessorDetailCursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd); M.PreprocessorDetailCursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
if (Entry.Kind != llvm::BitstreamEntry::Record) if (Entry.Kind != llvm::BitstreamEntry::Record)
return 0; return nullptr;
// Read the record. // Read the record.
SourceRange Range(ReadSourceLocation(M, PPOffs.Begin), SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
@ -4735,8 +4737,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
switch (RecType) { switch (RecType) {
case PPD_MACRO_EXPANSION: { case PPD_MACRO_EXPANSION: {
bool isBuiltin = Record[0]; bool isBuiltin = Record[0];
IdentifierInfo *Name = 0; IdentifierInfo *Name = nullptr;
MacroDefinition *Def = 0; MacroDefinition *Def = nullptr;
if (isBuiltin) if (isBuiltin)
Name = getLocalIdentifier(M, Record[1]); Name = getLocalIdentifier(M, Record[1]);
else { else {
@ -4770,7 +4772,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
case PPD_INCLUSION_DIRECTIVE: { case PPD_INCLUSION_DIRECTIVE: {
const char *FullFileNameStart = Blob.data() + Record[0]; const char *FullFileNameStart = Blob.data() + Record[0];
StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]); StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
const FileEntry *File = 0; const FileEntry *File = nullptr;
if (!FullFileName.empty()) if (!FullFileName.empty())
File = PP.getFileManager().getFile(FullFileName); File = PP.getFileManager().getFile(FullFileName);
@ -5581,7 +5583,7 @@ void TypeLocReader::VisitArrayTypeLoc(ArrayTypeLoc TL) {
if (Record[Idx++]) if (Record[Idx++])
TL.setSizeExpr(Reader.ReadExpr(F)); TL.setSizeExpr(Reader.ReadExpr(F));
else else
TL.setSizeExpr(0); TL.setSizeExpr(nullptr);
} }
void TypeLocReader::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) { void TypeLocReader::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
VisitArrayTypeLoc(TL); VisitArrayTypeLoc(TL);
@ -5668,7 +5670,7 @@ void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
if (Record[Idx++]) if (Record[Idx++])
TL.setAttrExprOperand(Reader.ReadExpr(F)); TL.setAttrExprOperand(Reader.ReadExpr(F));
else else
TL.setAttrExprOperand(0); TL.setAttrExprOperand(nullptr);
} else if (TL.hasAttrEnumOperand()) } else if (TL.hasAttrEnumOperand())
TL.setAttrEnumOperandLoc(ReadSourceLocation(Record, Idx)); TL.setAttrEnumOperandLoc(ReadSourceLocation(Record, Idx));
} }
@ -5752,7 +5754,7 @@ TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F,
unsigned &Idx) { unsigned &Idx) {
QualType InfoTy = readType(F, Record, Idx); QualType InfoTy = readType(F, Record, Idx);
if (InfoTy.isNull()) if (InfoTy.isNull())
return 0; return nullptr;
TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy); TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
TypeLocReader TLR(*this, F, Record, Idx); TypeLocReader TLR(*this, F, Record, Idx);
@ -6002,7 +6004,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
unsigned RecCode = Cursor.readRecord(Code, Record); unsigned RecCode = Cursor.readRecord(Code, Record);
if (RecCode != DECL_CXX_BASE_SPECIFIERS) { if (RecCode != DECL_CXX_BASE_SPECIFIERS) {
Error("malformed AST file: missing C++ base specifiers"); Error("malformed AST file: missing C++ base specifiers");
return 0; return nullptr;
} }
unsigned Idx = 0; unsigned Idx = 0;
@ -6035,7 +6037,7 @@ bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID,
ModuleFile *ASTReader::getOwningModuleFile(const Decl *D) { ModuleFile *ASTReader::getOwningModuleFile(const Decl *D) {
if (!D->isFromASTFile()) if (!D->isFromASTFile())
return 0; return nullptr;
GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(D->getGlobalID()); GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(D->getGlobalID());
assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
return I->second; return I->second;
@ -6064,7 +6066,7 @@ Decl *ASTReader::GetExistingDecl(DeclID ID) {
if (ID < NUM_PREDEF_DECL_IDS) { if (ID < NUM_PREDEF_DECL_IDS) {
switch ((PredefinedDeclIDs)ID) { switch ((PredefinedDeclIDs)ID) {
case PREDEF_DECL_NULL_ID: case PREDEF_DECL_NULL_ID:
return 0; return nullptr;
case PREDEF_DECL_TRANSLATION_UNIT_ID: case PREDEF_DECL_TRANSLATION_UNIT_ID:
return Context.getTranslationUnitDecl(); return Context.getTranslationUnitDecl();
@ -6100,7 +6102,7 @@ Decl *ASTReader::GetExistingDecl(DeclID ID) {
if (Index >= DeclsLoaded.size()) { if (Index >= DeclsLoaded.size()) {
assert(0 && "declaration ID out-of-range for AST file"); assert(0 && "declaration ID out-of-range for AST file");
Error("declaration ID out-of-range for AST file"); Error("declaration ID out-of-range for AST file");
return 0; return nullptr;
} }
return DeclsLoaded[Index]; return DeclsLoaded[Index];
@ -6115,7 +6117,7 @@ Decl *ASTReader::GetDecl(DeclID ID) {
if (Index >= DeclsLoaded.size()) { if (Index >= DeclsLoaded.size()) {
assert(0 && "declaration ID out-of-range for AST file"); assert(0 && "declaration ID out-of-range for AST file");
Error("declaration ID out-of-range for AST file"); Error("declaration ID out-of-range for AST file");
return 0; return nullptr;
} }
if (!DeclsLoaded[Index]) { if (!DeclsLoaded[Index]) {
@ -6402,7 +6404,7 @@ static ModuleFile *getDefinitiveModuleFileFor(const DeclContext *DC,
if (const DeclContext *DefDC = getDefinitiveDeclContext(DC)) if (const DeclContext *DefDC = getDefinitiveDeclContext(DC))
return Reader.getOwningModuleFile(cast<Decl>(DefDC)); return Reader.getOwningModuleFile(cast<Decl>(DefDC));
return 0; return nullptr;
} }
bool bool
@ -6608,15 +6610,15 @@ void ASTReader::PrintStats() {
QualType()); QualType());
unsigned NumDeclsLoaded unsigned NumDeclsLoaded
= DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(), = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
(Decl *)0); (Decl *)nullptr);
unsigned NumIdentifiersLoaded unsigned NumIdentifiersLoaded
= IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(), = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
IdentifiersLoaded.end(), IdentifiersLoaded.end(),
(IdentifierInfo *)0); (IdentifierInfo *)nullptr);
unsigned NumMacrosLoaded unsigned NumMacrosLoaded
= MacrosLoaded.size() - std::count(MacrosLoaded.begin(), = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
MacrosLoaded.end(), MacrosLoaded.end(),
(MacroInfo *)0); (MacroInfo *)nullptr);
unsigned NumSelectorsLoaded unsigned NumSelectorsLoaded
= SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(), = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
SelectorsLoaded.end(), SelectorsLoaded.end(),
@ -6810,7 +6812,7 @@ IdentifierInfo* ASTReader::get(const char *NameStart, const char *NameEnd) {
// If there is a global index, look there first to determine which modules // If there is a global index, look there first to determine which modules
// provably do not have any results for this identifier. // provably do not have any results for this identifier.
GlobalModuleIndex::HitSet Hits; GlobalModuleIndex::HitSet Hits;
GlobalModuleIndex::HitSet *HitsPtr = 0; GlobalModuleIndex::HitSet *HitsPtr = nullptr;
if (!loadGlobalIndex()) { if (!loadGlobalIndex()) {
if (GlobalIndex->lookupIdentifier(Name, Hits)) { if (GlobalIndex->lookupIdentifier(Name, Hits)) {
HitsPtr = &Hits; HitsPtr = &Hits;
@ -7223,11 +7225,11 @@ ASTReader::SetGloballyVisibleDecls(IdentifierInfo *II,
IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) { IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
if (ID == 0) if (ID == 0)
return 0; return nullptr;
if (IdentifiersLoaded.empty()) { if (IdentifiersLoaded.empty()) {
Error("no identifier table in AST file"); Error("no identifier table in AST file");
return 0; return nullptr;
} }
ID -= 1; ID -= 1;
@ -7273,11 +7275,11 @@ IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
MacroInfo *ASTReader::getMacro(MacroID ID) { MacroInfo *ASTReader::getMacro(MacroID ID) {
if (ID == 0) if (ID == 0)
return 0; return nullptr;
if (MacrosLoaded.empty()) { if (MacrosLoaded.empty()) {
Error("no macro table in AST file"); Error("no macro table in AST file");
return 0; return nullptr;
} }
ID -= NUM_PREDEF_MACRO_IDS; ID -= NUM_PREDEF_MACRO_IDS;
@ -7324,12 +7326,12 @@ ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) {
Module *ASTReader::getSubmodule(SubmoduleID GlobalID) { Module *ASTReader::getSubmodule(SubmoduleID GlobalID) {
if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) { if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) {
assert(GlobalID == 0 && "Unhandled global submodule ID"); assert(GlobalID == 0 && "Unhandled global submodule ID");
return 0; return nullptr;
} }
if (GlobalID > SubmodulesLoaded.size()) { if (GlobalID > SubmodulesLoaded.size()) {
Error("submodule ID out of range in AST file"); Error("submodule ID out of range in AST file");
return 0; return nullptr;
} }
return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS]; return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
@ -7352,7 +7354,7 @@ Selector ASTReader::DecodeSelector(serialization::SelectorID ID) {
return Selector(); return Selector();
} }
if (SelectorsLoaded[ID - 1].getAsOpaquePtr() == 0) { if (SelectorsLoaded[ID - 1].getAsOpaquePtr() == nullptr) {
// Load this selector from the selector table. // Load this selector from the selector table.
GlobalSelectorMapType::iterator I = GlobalSelectorMap.find(ID); GlobalSelectorMapType::iterator I = GlobalSelectorMap.find(ID);
assert(I != GlobalSelectorMap.end() && "Corrupted global selector map"); assert(I != GlobalSelectorMap.end() && "Corrupted global selector map");
@ -7648,16 +7650,16 @@ ASTReader::ReadCXXBaseSpecifier(ModuleFile &F,
std::pair<CXXCtorInitializer **, unsigned> std::pair<CXXCtorInitializer **, unsigned>
ASTReader::ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, ASTReader::ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
unsigned &Idx) { unsigned &Idx) {
CXXCtorInitializer **CtorInitializers = 0; CXXCtorInitializer **CtorInitializers = nullptr;
unsigned NumInitializers = Record[Idx++]; unsigned NumInitializers = Record[Idx++];
if (NumInitializers) { if (NumInitializers) {
CtorInitializers CtorInitializers
= new (Context) CXXCtorInitializer*[NumInitializers]; = new (Context) CXXCtorInitializer*[NumInitializers];
for (unsigned i=0; i != NumInitializers; ++i) { for (unsigned i=0; i != NumInitializers; ++i) {
TypeSourceInfo *TInfo = 0; TypeSourceInfo *TInfo = nullptr;
bool IsBaseVirtual = false; bool IsBaseVirtual = false;
FieldDecl *Member = 0; FieldDecl *Member = nullptr;
IndirectFieldDecl *IndirectMember = 0; IndirectFieldDecl *IndirectMember = nullptr;
CtorInitializerType Type = (CtorInitializerType)Record[Idx++]; CtorInitializerType Type = (CtorInitializerType)Record[Idx++];
switch (Type) { switch (Type) {
@ -7737,7 +7739,7 @@ NestedNameSpecifier *
ASTReader::ReadNestedNameSpecifier(ModuleFile &F, ASTReader::ReadNestedNameSpecifier(ModuleFile &F,
const RecordData &Record, unsigned &Idx) { const RecordData &Record, unsigned &Idx) {
unsigned N = Record[Idx++]; unsigned N = Record[Idx++];
NestedNameSpecifier *NNS = 0, *Prev = 0; NestedNameSpecifier *NNS = nullptr, *Prev = nullptr;
for (unsigned I = 0; I != N; ++I) { for (unsigned I = 0; I != N; ++I) {
NestedNameSpecifier::SpecifierKind Kind NestedNameSpecifier::SpecifierKind Kind
= (NestedNameSpecifier::SpecifierKind)Record[Idx++]; = (NestedNameSpecifier::SpecifierKind)Record[Idx++];
@ -7764,8 +7766,8 @@ ASTReader::ReadNestedNameSpecifier(ModuleFile &F,
case NestedNameSpecifier::TypeSpecWithTemplate: { case NestedNameSpecifier::TypeSpecWithTemplate: {
const Type *T = readType(F, Record, Idx).getTypePtrOrNull(); const Type *T = readType(F, Record, Idx).getTypePtrOrNull();
if (!T) if (!T)
return 0; return nullptr;
bool Template = Record[Idx++]; bool Template = Record[Idx++];
NNS = NestedNameSpecifier::Create(Context, Prev, Template, T); NNS = NestedNameSpecifier::Create(Context, Prev, Template, T);
break; break;
@ -7912,14 +7914,14 @@ IdentifierTable &ASTReader::getIdentifierTable() {
/// \brief Record that the given ID maps to the given switch-case /// \brief Record that the given ID maps to the given switch-case
/// statement. /// statement.
void ASTReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) { void ASTReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) {
assert((*CurrSwitchCaseStmts)[ID] == 0 && assert((*CurrSwitchCaseStmts)[ID] == nullptr &&
"Already have a SwitchCase with this ID"); "Already have a SwitchCase with this ID");
(*CurrSwitchCaseStmts)[ID] = SC; (*CurrSwitchCaseStmts)[ID] = SC;
} }
/// \brief Retrieve the switch-case statement with the given ID. /// \brief Retrieve the switch-case statement with the given ID.
SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) { SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) {
assert((*CurrSwitchCaseStmts)[ID] != 0 && "No SwitchCase with this ID"); assert((*CurrSwitchCaseStmts)[ID] != nullptr && "No SwitchCase with this ID");
return (*CurrSwitchCaseStmts)[ID]; return (*CurrSwitchCaseStmts)[ID];
} }
@ -8288,11 +8290,12 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot,
bool DisableValidation, bool AllowASTWithCompilerErrors, bool DisableValidation, bool AllowASTWithCompilerErrors,
bool AllowConfigurationMismatch, bool ValidateSystemInputs, bool AllowConfigurationMismatch, bool ValidateSystemInputs,
bool UseGlobalIndex) bool UseGlobalIndex)
: Listener(new PCHValidator(PP, *this)), DeserializationListener(0), : Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()), OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
FileMgr(PP.getFileManager()), Diags(PP.getDiagnostics()), SemaObj(0), FileMgr(PP.getFileManager()), Diags(PP.getDiagnostics()),
PP(PP), Context(Context), Consumer(0), ModuleMgr(PP.getFileManager()), SemaObj(nullptr), PP(PP), Context(Context), Consumer(nullptr),
isysroot(isysroot), DisableValidation(DisableValidation), ModuleMgr(PP.getFileManager()), isysroot(isysroot),
DisableValidation(DisableValidation),
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors), AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
AllowConfigurationMismatch(AllowConfigurationMismatch), AllowConfigurationMismatch(AllowConfigurationMismatch),
ValidateSystemInputs(ValidateSystemInputs), ValidateSystemInputs(ValidateSystemInputs),

View File

@ -163,8 +163,8 @@ namespace clang {
public: public:
FindExistingResult(ASTReader &Reader) FindExistingResult(ASTReader &Reader)
: Reader(Reader), New(0), Existing(0), AddResult(false) { } : Reader(Reader), New(nullptr), Existing(nullptr), AddResult(false) {}
FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing) FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing)
: Reader(Reader), New(New), Existing(Existing), AddResult(true) { } : Reader(Reader), New(New), Existing(Existing), AddResult(true) { }
@ -648,7 +648,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
FunctionTemplateSpecializationInfo *FTInfo FunctionTemplateSpecializationInfo *FTInfo
= FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK,
TemplArgList, TemplArgList,
HasTemplateArgumentsAsWritten ? &TemplArgsInfo : 0, HasTemplateArgumentsAsWritten ? &TemplArgsInfo
: nullptr,
POI); POI);
FD->TemplateOrSpecialization = FTInfo; FD->TemplateOrSpecialization = FTInfo;
@ -665,7 +666,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
llvm::FoldingSetNodeID ID; llvm::FoldingSetNodeID ID;
FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(), FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(),
TemplArgs.size(), C); TemplArgs.size(), C);
void *InsertPos = 0; void *InsertPos = nullptr;
FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr(); FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr();
CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos); CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos);
if (InsertPos) if (InsertPos)
@ -808,8 +809,8 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
Reader.getContext()); Reader.getContext());
// We will rebuild this list lazily. // We will rebuild this list lazily.
ID->setIvarList(0); ID->setIvarList(nullptr);
// Note that we have deserialized a definition. // Note that we have deserialized a definition.
Reader.PendingDefinitions.insert(ID); Reader.PendingDefinitions.insert(ID);
@ -824,7 +825,7 @@ void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
VisitFieldDecl(IVD); VisitFieldDecl(IVD);
IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
// This field will be built lazily. // This field will be built lazily.
IVD->setNextIvar(0); IVD->setNextIvar(nullptr);
bool synth = Record[Idx++]; bool synth = Record[Idx++];
IVD->setSynthesize(synth); IVD->setSynthesize(synth);
} }
@ -1093,7 +1094,7 @@ void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
unsigned flags = Record[Idx++]; unsigned flags = Record[Idx++];
bool byRef = (flags & 1); bool byRef = (flags & 1);
bool nested = (flags & 2); bool nested = (flags & 2);
Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : 0); Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : nullptr);
captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr));
} }
@ -1278,7 +1279,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record[Idx++]); LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record[Idx++]);
switch (Kind) { switch (Kind) {
case LCK_This: case LCK_This:
*ToCapture++ = Capture(Loc, IsImplicit, Kind, 0, SourceLocation()); *ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
break; break;
case LCK_ByCopy: case LCK_ByCopy:
case LCK_ByRef: case LCK_ByRef:
@ -1386,7 +1387,7 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D) {
// allocate the appropriate DefinitionData structure. // allocate the appropriate DefinitionData structure.
bool IsLambda = Record[Idx++]; bool IsLambda = Record[Idx++];
if (IsLambda) if (IsLambda)
DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, 0, false, false, DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, nullptr, false, false,
LCD_None); LCD_None);
else else
DD = new (C) struct CXXRecordDecl::DefinitionData(D); DD = new (C) struct CXXRecordDecl::DefinitionData(D);
@ -2144,7 +2145,7 @@ void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs, void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs,
const RecordData &Record, unsigned &Idx) { const RecordData &Record, unsigned &Idx) {
for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) { for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
Attr *New = 0; Attr *New = nullptr;
attr::Kind Kind = (attr::Kind)Record[Idx++]; attr::Kind Kind = (attr::Kind)Record[Idx++];
SourceRange Range = ReadSourceRange(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx);
@ -2376,9 +2377,10 @@ static DeclContext *getPrimaryContextForMerging(DeclContext *DC) {
return RD->getDefinition(); return RD->getDefinition();
if (EnumDecl *ED = dyn_cast<EnumDecl>(DC)) if (EnumDecl *ED = dyn_cast<EnumDecl>(DC))
return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition() : 0; return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
: nullptr;
return 0; return nullptr;
} }
ASTDeclReader::FindExistingResult::~FindExistingResult() { ASTDeclReader::FindExistingResult::~FindExistingResult() {
@ -2399,7 +2401,7 @@ ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
DeclarationName Name = D->getDeclName(); DeclarationName Name = D->getDeclName();
if (!Name) { if (!Name) {
// Don't bother trying to find unnamed declarations. // Don't bother trying to find unnamed declarations.
FindExistingResult Result(Reader, D, /*Existing=*/0); FindExistingResult Result(Reader, D, /*Existing=*/nullptr);
Result.suppress(); Result.suppress();
return Result; return Result;
} }
@ -2459,7 +2461,7 @@ ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
if (Reader.MergedDeclContexts.count(D->getLexicalDeclContext())) if (Reader.MergedDeclContexts.count(D->getLexicalDeclContext()))
Reader.PendingOdrMergeChecks.push_back(D); Reader.PendingOdrMergeChecks.push_back(D);
return FindExistingResult(Reader, D, /*Existing=*/0); return FindExistingResult(Reader, D, /*Existing=*/nullptr);
} }
template<typename DeclT> template<typename DeclT>
@ -2577,7 +2579,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
unsigned Idx = 0; unsigned Idx = 0;
ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx); ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx);
Decl *D = 0; Decl *D = nullptr;
switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) { switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) {
case DECL_CONTEXT_LEXICAL: case DECL_CONTEXT_LEXICAL:
case DECL_CONTEXT_VISIBLE: case DECL_CONTEXT_VISIBLE:
@ -2759,7 +2761,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
break; break;
case DECL_CXX_BASE_SPECIFIERS: case DECL_CXX_BASE_SPECIFIERS:
Error("attempt to read a C++ base-specifier record as a declaration"); Error("attempt to read a C++ base-specifier record as a declaration");
return 0; return nullptr;
case DECL_IMPORT: case DECL_IMPORT:
// Note: last entry of the ImportDecl record is the number of stored source // Note: last entry of the ImportDecl record is the number of stored source
// locations. // locations.
@ -2798,7 +2800,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
LookupDC->setHasExternalVisibleStorage(true); LookupDC->setHasExternalVisibleStorage(true);
if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets, if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets,
Loc.F->DeclContextInfos[DC])) Loc.F->DeclContextInfos[DC]))
return 0; return nullptr;
} }
// Now add the pending visible updates for this decl context, if it has any. // Now add the pending visible updates for this decl context, if it has any.
@ -3053,7 +3055,7 @@ namespace {
unsigned PreviousGeneration) unsigned PreviousGeneration)
: Reader(Reader), InterfaceID(InterfaceID), Interface(Interface), : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface),
Deserialized(Deserialized), PreviousGeneration(PreviousGeneration), Deserialized(Deserialized), PreviousGeneration(PreviousGeneration),
Tail(0) Tail(nullptr)
{ {
// Populate the name -> category map with the set of known categories. // Populate the name -> category map with the set of known categories.
for (auto *Cat : Interface->known_categories()) { for (auto *Cat : Interface->known_categories()) {

View File

@ -129,11 +129,11 @@ class ASTIdentifierLookupTrait : public ASTIdentifierLookupTraitBase {
public: public:
typedef IdentifierInfo * data_type; typedef IdentifierInfo * data_type;
ASTIdentifierLookupTrait(ASTReader &Reader, ModuleFile &F, ASTIdentifierLookupTrait(ASTReader &Reader, ModuleFile &F,
IdentifierInfo *II = 0) IdentifierInfo *II = nullptr)
: Reader(Reader), F(F), KnownII(II) { } : Reader(Reader), F(F), KnownII(II) { }
data_type ReadData(const internal_key_type& k, data_type ReadData(const internal_key_type& k,
const unsigned char* d, const unsigned char* d,
unsigned DataLen); unsigned DataLen);

View File

@ -202,7 +202,7 @@ void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
if (Record[Idx++]) if (Record[Idx++])
S->setAllEnumCasesCovered(); S->setAllEnumCasesCovered();
SwitchCase *PrevSC = 0; SwitchCase *PrevSC = nullptr;
for (unsigned N = Record.size(); Idx != N; ++Idx) { for (unsigned N = Record.size(); Idx != N; ++Idx) {
SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
if (PrevSC) if (PrevSC)
@ -716,7 +716,7 @@ void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
E->setLBraceLoc(ReadSourceLocation(Record, Idx)); E->setLBraceLoc(ReadSourceLocation(Record, Idx));
E->setRBraceLoc(ReadSourceLocation(Record, Idx)); E->setRBraceLoc(ReadSourceLocation(Record, Idx));
bool isArrayFiller = Record[Idx++]; bool isArrayFiller = Record[Idx++];
Expr *filler = 0; Expr *filler = nullptr;
if (isArrayFiller) { if (isArrayFiller) {
filler = Reader.ReadSubExpr(); filler = Reader.ReadSubExpr();
E->ArrayFillerOrUnionFieldInit = filler; E->ArrayFillerOrUnionFieldInit = filler;
@ -1878,7 +1878,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error: case llvm::BitstreamEntry::Error:
Error("malformed block record in AST file"); Error("malformed block record in AST file");
return 0; return nullptr;
case llvm::BitstreamEntry::EndBlock: case llvm::BitstreamEntry::EndBlock:
goto Done; goto Done;
case llvm::BitstreamEntry::Record: case llvm::BitstreamEntry::Record:
@ -1886,8 +1886,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break; break;
} }
Stmt *S = nullptr;
Stmt *S = 0;
Idx = 0; Idx = 0;
Record.clear(); Record.clear();
bool Finished = false; bool Finished = false;
@ -1905,7 +1904,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break; break;
case STMT_NULL_PTR: case STMT_NULL_PTR:
S = 0; S = nullptr;
break; break;
case STMT_NULL: case STMT_NULL:
@ -2096,7 +2095,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc, S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
HasTemplateKWAndArgsInfo ? &ArgInfo : 0, HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr,
T, VK, OK); T, VK, OK);
ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc, ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
MemberD->getDeclName(), Record, Idx); MemberD->getDeclName(), Record, Idx);
@ -2290,7 +2289,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) MSDependentExistsStmt(SourceLocation(), true, S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
NestedNameSpecifierLoc(), NestedNameSpecifierLoc(),
DeclarationNameInfo(), DeclarationNameInfo(),
0); nullptr);
break; break;
case STMT_OMP_PARALLEL_DIRECTIVE: case STMT_OMP_PARALLEL_DIRECTIVE:
@ -2388,7 +2387,8 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields]; bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
if (HasOtherExprStored) { if (HasOtherExprStored) {
Expr *SubExpr = ReadSubExpr(); Expr *SubExpr = ReadSubExpr();
S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr); S = CXXDefaultArgExpr::Create(Context, SourceLocation(), nullptr,
SubExpr);
} else } else
S = new (Context) CXXDefaultArgExpr(Empty); S = new (Context) CXXDefaultArgExpr(Empty);
break; break;

View File

@ -661,7 +661,8 @@ static void EmitBlockID(unsigned ID, const char *Name,
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record); Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
// Emit the block name if present. // Emit the block name if present.
if (Name == 0 || Name[0] == 0) return; if (!Name || Name[0] == 0)
return;
Record.clear(); Record.clear();
while (*Name) while (*Name)
Record.push_back(*Name++); Record.push_back(*Name++);
@ -3001,7 +3002,7 @@ class ASTIdentifierTableTrait {
if (MacroDirective *NextMD = getPublicSubmoduleMacro(MD, ModID, Overridden)) if (MacroDirective *NextMD = getPublicSubmoduleMacro(MD, ModID, Overridden))
if (!shouldIgnoreMacro(NextMD, IsModule, PP)) if (!shouldIgnoreMacro(NextMD, IsModule, PP))
return NextMD; return NextMD;
return 0; return nullptr;
} }
MacroDirective * MacroDirective *
@ -3011,7 +3012,7 @@ class ASTIdentifierTableTrait {
getPublicSubmoduleMacro(MD->getPrevious(), ModID, Overridden)) getPublicSubmoduleMacro(MD->getPrevious(), ModID, Overridden))
if (!shouldIgnoreMacro(NextMD, IsModule, PP)) if (!shouldIgnoreMacro(NextMD, IsModule, PP))
return NextMD; return NextMD;
return 0; return nullptr;
} }
/// \brief Traverses the macro directives history and returns the latest /// \brief Traverses the macro directives history and returns the latest
@ -3027,7 +3028,7 @@ class ASTIdentifierTableTrait {
SubmoduleID &ModID, SubmoduleID &ModID,
OverriddenList &Overridden) { OverriddenList &Overridden) {
if (!MD) if (!MD)
return 0; return nullptr;
Overridden.clear(); Overridden.clear();
SubmoduleID OrigModID = ModID; SubmoduleID OrigModID = ModID;
@ -3083,7 +3084,7 @@ class ASTIdentifierTableTrait {
} }
} }
return 0; return nullptr;
} }
SubmoduleID getSubmoduleID(MacroDirective *MD) { SubmoduleID getSubmoduleID(MacroDirective *MD) {
@ -3112,7 +3113,7 @@ public:
EmitKeyDataLength(raw_ostream& Out, IdentifierInfo* II, IdentID ID) { EmitKeyDataLength(raw_ostream& Out, IdentifierInfo* II, IdentID ID) {
unsigned KeyLen = II->getLength() + 1; unsigned KeyLen = II->getLength() + 1;
unsigned DataLen = 4; // 4 bytes for the persistent ID << 1 unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
MacroDirective *Macro = 0; MacroDirective *Macro = nullptr;
if (isInterestingIdentifier(II, Macro)) { if (isInterestingIdentifier(II, Macro)) {
DataLen += 2; // 2 bytes for builtin ID DataLen += 2; // 2 bytes for builtin ID
DataLen += 2; // 2 bytes for flags DataLen += 2; // 2 bytes for flags
@ -3175,7 +3176,7 @@ public:
IdentID ID, unsigned) { IdentID ID, unsigned) {
using namespace llvm::support; using namespace llvm::support;
endian::Writer<little> LE(Out); endian::Writer<little> LE(Out);
MacroDirective *Macro = 0; MacroDirective *Macro = nullptr;
if (!isInterestingIdentifier(II, Macro)) { if (!isInterestingIdentifier(II, Macro)) {
LE.write<uint32_t>(ID << 1); LE.write<uint32_t>(ID << 1);
return; return;
@ -3922,8 +3923,8 @@ void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
} }
ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream) ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
: Stream(Stream), Context(0), PP(0), Chain(0), WritingModule(0), : Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr),
WritingAST(false), DoneWritingDeclsAndTypes(false), WritingModule(nullptr), WritingAST(false), DoneWritingDeclsAndTypes(false),
ASTHasCompilerErrors(false), ASTHasCompilerErrors(false),
FirstDeclID(NUM_PREDEF_DECL_IDS), NextDeclID(FirstDeclID), FirstDeclID(NUM_PREDEF_DECL_IDS), NextDeclID(FirstDeclID),
FirstTypeID(NUM_PREDEF_TYPE_IDS), NextTypeID(FirstTypeID), FirstTypeID(NUM_PREDEF_TYPE_IDS), NextTypeID(FirstTypeID),
@ -3970,18 +3971,18 @@ void ASTWriter::WriteAST(Sema &SemaRef,
PP = &SemaRef.PP; PP = &SemaRef.PP;
this->WritingModule = WritingModule; this->WritingModule = WritingModule;
WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule); WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
Context = 0; Context = nullptr;
PP = 0; PP = nullptr;
this->WritingModule = 0; this->WritingModule = nullptr;
WritingAST = false; WritingAST = false;
} }
template<typename Vector> template<typename Vector>
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec, static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec,
ASTWriter::RecordData &Record) { ASTWriter::RecordData &Record) {
for (typename Vector::iterator I = Vec.begin(0, true), E = Vec.end(); for (typename Vector::iterator I = Vec.begin(nullptr, true), E = Vec.end();
I != E; ++I) { I != E; ++I) {
Writer.AddDeclRef(*I, Record); Writer.AddDeclRef(*I, Record);
} }
} }
@ -3992,7 +3993,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
Module *WritingModule) { Module *WritingModule) {
using namespace llvm; using namespace llvm;
bool isModule = WritingModule != 0; bool isModule = WritingModule != nullptr;
// Make sure that the AST reader knows to finalize itself. // Make sure that the AST reader knows to finalize itself.
if (Chain) if (Chain)
@ -4631,7 +4632,7 @@ void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Recor
} }
IdentID ASTWriter::getIdentifierRef(const IdentifierInfo *II) { IdentID ASTWriter::getIdentifierRef(const IdentifierInfo *II) {
if (II == 0) if (!II)
return 0; return 0;
IdentID &ID = IdentifierIDs[II]; IdentID &ID = IdentifierIDs[II];
@ -4644,7 +4645,7 @@ MacroID ASTWriter::getMacroRef(MacroInfo *MI, const IdentifierInfo *Name) {
// Don't emit builtin macros like __LINE__ to the AST file unless they // Don't emit builtin macros like __LINE__ to the AST file unless they
// have been redefined by the header (in which case they are not // have been redefined by the header (in which case they are not
// isBuiltinMacro). // isBuiltinMacro).
if (MI == 0 || MI->isBuiltinMacro()) if (!MI || MI->isBuiltinMacro())
return 0; return 0;
MacroID &ID = MacroIDs[MI]; MacroID &ID = MacroIDs[MI];
@ -4657,7 +4658,7 @@ MacroID ASTWriter::getMacroRef(MacroInfo *MI, const IdentifierInfo *Name) {
} }
MacroID ASTWriter::getMacroID(MacroInfo *MI) { MacroID ASTWriter::getMacroID(MacroInfo *MI) {
if (MI == 0 || MI->isBuiltinMacro()) if (!MI || MI->isBuiltinMacro())
return 0; return 0;
assert(MacroIDs.find(MI) != MacroIDs.end() && "Macro not emitted!"); assert(MacroIDs.find(MI) != MacroIDs.end() && "Macro not emitted!");
@ -4674,7 +4675,7 @@ void ASTWriter::AddSelectorRef(const Selector SelRef, RecordDataImpl &Record) {
} }
SelectorID ASTWriter::getSelectorRef(Selector Sel) { SelectorID ASTWriter::getSelectorRef(Selector Sel) {
if (Sel.getAsOpaquePtr() == 0) { if (Sel.getAsOpaquePtr() == nullptr) {
return 0; return 0;
} }
@ -4752,7 +4753,7 @@ void ASTWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo,
RecordDataImpl &Record) { RecordDataImpl &Record) {
if (TInfo == 0) { if (!TInfo) {
AddTypeRef(QualType(), Record); AddTypeRef(QualType(), Record);
return; return;
} }
@ -4820,8 +4821,8 @@ void ASTWriter::AddDeclRef(const Decl *D, RecordDataImpl &Record) {
DeclID ASTWriter::GetDeclRef(const Decl *D) { DeclID ASTWriter::GetDeclRef(const Decl *D) {
assert(WritingAST && "Cannot request a declaration ID before AST writing"); assert(WritingAST && "Cannot request a declaration ID before AST writing");
if (D == 0) { if (!D) {
return 0; return 0;
} }
@ -4848,7 +4849,7 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
} }
DeclID ASTWriter::getDeclID(const Decl *D) { DeclID ASTWriter::getDeclID(const Decl *D) {
if (D == 0) if (!D)
return 0; return 0;
// If D comes from an AST file, its declaration ID is already known and // If D comes from an AST file, its declaration ID is already known and
@ -5380,7 +5381,7 @@ void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Rec
case LCK_ByCopy: case LCK_ByCopy:
case LCK_ByRef: case LCK_ByRef:
VarDecl *Var = VarDecl *Var =
Capture.capturesVariable() ? Capture.getCapturedVar() : 0; Capture.capturesVariable() ? Capture.getCapturedVar() : nullptr;
AddDeclRef(Var, Record); AddDeclRef(Var, Record);
AddSourceLocation(Capture.isPackExpansion() ? Capture.getEllipsisLoc() AddSourceLocation(Capture.isPackExpansion() ? Capture.getEllipsisLoc()
: SourceLocation(), : SourceLocation(),

View File

@ -277,7 +277,7 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
Record.push_back(MemberInfo->getTemplateSpecializationKind()); Record.push_back(MemberInfo->getTemplateSpecializationKind());
Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record); Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
} else { } else {
Writer.AddDeclRef(0, Record); Writer.AddDeclRef(nullptr, Record);
} }
if (!D->hasAttrs() && if (!D->hasAttrs() &&
@ -398,7 +398,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record); Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);
// Template args as written. // Template args as written.
Record.push_back(FTSInfo->TemplateArgumentsAsWritten != 0); Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
if (FTSInfo->TemplateArgumentsAsWritten) { if (FTSInfo->TemplateArgumentsAsWritten) {
Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs); Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs; for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
@ -449,8 +449,8 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
VisitNamedDecl(D); VisitNamedDecl(D);
// FIXME: convert to LazyStmtPtr? // FIXME: convert to LazyStmtPtr?
// Unlike C/C++, method bodies will never be in header files. // Unlike C/C++, method bodies will never be in header files.
bool HasBodyStuff = D->getBody() != 0 || bool HasBodyStuff = D->getBody() != nullptr ||
D->getSelfDecl() != 0 || D->getCmdDecl() != 0; D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
Record.push_back(HasBodyStuff); Record.push_back(HasBodyStuff);
if (HasBodyStuff) { if (HasBodyStuff) {
Writer.AddStmt(D->getBody()); Writer.AddStmt(D->getBody());
@ -757,7 +757,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
!D->hasExtInfo() && !D->hasExtInfo() &&
D->getFirstDecl() == D->getMostRecentDecl() && D->getFirstDecl() == D->getMostRecentDecl() &&
D->getInitStyle() == VarDecl::CInit && D->getInitStyle() == VarDecl::CInit &&
D->getInit() == 0 && D->getInit() == nullptr &&
!isa<ParmVarDecl>(D) && !isa<ParmVarDecl>(D) &&
!isa<VarTemplateSpecializationDecl>(D) && !isa<VarTemplateSpecializationDecl>(D) &&
!D->isConstexpr() && !D->isConstexpr() &&
@ -806,7 +806,7 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
D->getObjCDeclQualifier() == 0 && D->getObjCDeclQualifier() == 0 &&
!D->isKNRPromoted() && !D->isKNRPromoted() &&
!D->hasInheritedDefaultArg() && !D->hasInheritedDefaultArg() &&
D->getInit() == 0 && D->getInit() == nullptr &&
!D->hasUninstantiatedDefaultArg()) // No default expr. !D->hasUninstantiatedDefaultArg()) // No default expr.
AbbrevToUse = Writer.getDeclParmVarAbbrev(); AbbrevToUse = Writer.getDeclParmVarAbbrev();
@ -815,7 +815,7 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS"); assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private"); assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var"); assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
assert(D->getPreviousDecl() == 0 && "PARM_VAR_DECL can't be redecl"); assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
assert(!D->isStaticDataMember() && assert(!D->isStaticDataMember() &&
"PARM_VAR_DECL can't be static data member"); "PARM_VAR_DECL can't be static data member");
} }
@ -1104,7 +1104,7 @@ void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
Record.push_back(D->getNumTemplateParameters()); Record.push_back(D->getNumTemplateParameters());
for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i) for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record); Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);
Record.push_back(D->getFriendDecl() != 0); Record.push_back(D->getFriendDecl() != nullptr);
if (D->getFriendDecl()) if (D->getFriendDecl())
Writer.AddDeclRef(D->getFriendDecl(), Record); Writer.AddDeclRef(D->getFriendDecl(), Record);
else else
@ -1205,7 +1205,7 @@ void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl(
Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record); Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
// These are read/set from/to the first declaration. // These are read/set from/to the first declaration.
if (D->getPreviousDecl() == 0) { if (D->getPreviousDecl() == nullptr) {
Writer.AddDeclRef(D->getInstantiatedFromMember(), Record); Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
Record.push_back(D->isMemberSpecialization()); Record.push_back(D->isMemberSpecialization());
} }
@ -1281,7 +1281,7 @@ void ASTDeclWriter::VisitVarTemplatePartialSpecializationDecl(
Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record); Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
// These are read/set from/to the first declaration. // These are read/set from/to the first declaration.
if (D->getPreviousDecl() == 0) { if (D->getPreviousDecl() == nullptr) {
Writer.AddDeclRef(D->getInstantiatedFromMember(), Record); Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
Record.push_back(D->isMemberSpecialization()); Record.push_back(D->isMemberSpecialization());
} }
@ -1348,7 +1348,7 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
} else { } else {
// Rest of NonTypeTemplateParmDecl. // Rest of NonTypeTemplateParmDecl.
Record.push_back(D->isParameterPack()); Record.push_back(D->isParameterPack());
Record.push_back(D->getDefaultArgument() != 0); Record.push_back(D->getDefaultArgument() != nullptr);
if (D->getDefaultArgument()) { if (D->getDefaultArgument()) {
Writer.AddStmt(D->getDefaultArgument()); Writer.AddStmt(D->getDefaultArgument());
Record.push_back(D->defaultArgumentWasInherited()); Record.push_back(D->defaultArgumentWasInherited());

View File

@ -308,7 +308,7 @@ void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
// Captures // Captures
for (const auto &I : S->captures()) { for (const auto &I : S->captures()) {
if (I.capturesThis()) if (I.capturesThis())
Writer.AddDeclRef(0, Record); Writer.AddDeclRef(nullptr, Record);
else else
Writer.AddDeclRef(I.getCapturedVar(), Record); Writer.AddDeclRef(I.getCapturedVar(), Record);
Record.push_back(I.getCaptureKind()); Record.push_back(I.getCaptureKind());
@ -687,7 +687,7 @@ void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
// Replace them by 0 to indicate that the filler goes in that place. // Replace them by 0 to indicate that the filler goes in that place.
Expr *filler = E->getArrayFiller(); Expr *filler = E->getArrayFiller();
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
Writer.AddStmt(E->getInit(I) != filler ? E->getInit(I) : 0); Writer.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
} else { } else {
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
Writer.AddStmt(E->getInit(I)); Writer.AddStmt(E->getInit(I));
@ -1051,7 +1051,7 @@ void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Record.push_back(S->getNumCatchStmts()); Record.push_back(S->getNumCatchStmts());
Record.push_back(S->getFinallyStmt() != 0); Record.push_back(S->getFinallyStmt() != nullptr);
Writer.AddStmt(S->getTryBody()); Writer.AddStmt(S->getTryBody());
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Writer.AddStmt(S->getCatchStmt(I)); Writer.AddStmt(S->getCatchStmt(I));
@ -1397,7 +1397,7 @@ ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
if (!E->isImplicitAccess()) if (!E->isImplicitAccess())
Writer.AddStmt(E->getBase()); Writer.AddStmt(E->getBase());
else else
Writer.AddStmt(0); Writer.AddStmt(nullptr);
Writer.AddTypeRef(E->getBaseType(), Record); Writer.AddTypeRef(E->getBaseType(), Record);
Record.push_back(E->isArrow()); Record.push_back(E->isArrow());
Writer.AddSourceLocation(E->getOperatorLoc(), Record); Writer.AddSourceLocation(E->getOperatorLoc(), Record);
@ -1467,7 +1467,7 @@ void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
VisitOverloadExpr(E); VisitOverloadExpr(E);
Record.push_back(E->isArrow()); Record.push_back(E->isArrow());
Record.push_back(E->hasUnresolvedUsing()); Record.push_back(E->hasUnresolvedUsing());
Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : 0); Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
Writer.AddTypeRef(E->getBaseType(), Record); Writer.AddTypeRef(E->getBaseType(), Record);
Writer.AddSourceLocation(E->getOperatorLoc(), Record); Writer.AddSourceLocation(E->getOperatorLoc(), Record);
Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER; Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;

View File

@ -31,7 +31,7 @@ PCHGenerator::PCHGenerator(const Preprocessor &PP,
raw_ostream *OS, bool AllowASTWithErrors) raw_ostream *OS, bool AllowASTWithErrors)
: PP(PP), OutputFile(OutputFile), Module(Module), : PP(PP), OutputFile(OutputFile), Module(Module),
isysroot(isysroot.str()), Out(OS), isysroot(isysroot.str()), Out(OS),
SemaPtr(0), Stream(Buffer), Writer(Stream), SemaPtr(nullptr), Stream(Buffer), Writer(Stream),
AllowASTWithErrors(AllowASTWithErrors), AllowASTWithErrors(AllowASTWithErrors),
HasEmittedPCH(false) { HasEmittedPCH(false) {
} }

View File

@ -242,7 +242,7 @@ GlobalModuleIndex::readIndex(StringRef Path) {
std::unique_ptr<llvm::MemoryBuffer> Buffer; std::unique_ptr<llvm::MemoryBuffer> Buffer;
if (llvm::MemoryBuffer::getFile(IndexPath.c_str(), Buffer) != if (llvm::MemoryBuffer::getFile(IndexPath.c_str(), Buffer) !=
llvm::errc::success) llvm::errc::success)
return std::make_pair((GlobalModuleIndex *)0, EC_NotFound); return std::make_pair(nullptr, EC_NotFound);
/// \brief The bitstream reader from which we'll read the AST file. /// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader Reader((const unsigned char *)Buffer->getBufferStart(), llvm::BitstreamReader Reader((const unsigned char *)Buffer->getBufferStart(),
@ -256,7 +256,7 @@ GlobalModuleIndex::readIndex(StringRef Path) {
Cursor.Read(8) != 'C' || Cursor.Read(8) != 'C' ||
Cursor.Read(8) != 'G' || Cursor.Read(8) != 'G' ||
Cursor.Read(8) != 'I') { Cursor.Read(8) != 'I') {
return std::make_pair((GlobalModuleIndex *)0, EC_IOError); return std::make_pair(nullptr, EC_IOError);
} }
return std::make_pair(new GlobalModuleIndex(Buffer.release(), Cursor), return std::make_pair(new GlobalModuleIndex(Buffer.release(), Cursor),
@ -436,7 +436,7 @@ static void emitBlockID(unsigned ID, const char *Name,
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record); Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
// Emit the block name if present. // Emit the block name if present.
if (Name == 0 || Name[0] == 0) return; if (!Name || Name[0] == 0) return;
Record.clear(); Record.clear();
while (*Name) while (*Name)
Record.push_back(*Name++); Record.push_back(*Name++);

View File

@ -21,27 +21,27 @@ using namespace serialization;
using namespace reader; using namespace reader;
ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation) ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)
: Kind(Kind), File(0), DirectlyImported(false), : Kind(Kind), File(nullptr), DirectlyImported(false),
Generation(Generation), SizeInBits(0), Generation(Generation), SizeInBits(0),
LocalNumSLocEntries(0), SLocEntryBaseID(0), LocalNumSLocEntries(0), SLocEntryBaseID(0),
SLocEntryBaseOffset(0), SLocEntryOffsets(0), SLocEntryBaseOffset(0), SLocEntryOffsets(nullptr),
LocalNumIdentifiers(0), LocalNumIdentifiers(0),
IdentifierOffsets(0), BaseIdentifierID(0), IdentifierTableData(0), IdentifierOffsets(nullptr), BaseIdentifierID(0),
IdentifierLookupTable(0), IdentifierTableData(nullptr), IdentifierLookupTable(nullptr),
LocalNumMacros(0), MacroOffsets(0), LocalNumMacros(0), MacroOffsets(nullptr),
BasePreprocessedEntityID(0), BasePreprocessedEntityID(0),
PreprocessedEntityOffsets(0), NumPreprocessedEntities(0), PreprocessedEntityOffsets(nullptr), NumPreprocessedEntities(0),
LocalNumHeaderFileInfos(0), LocalNumHeaderFileInfos(0),
HeaderFileInfoTableData(0), HeaderFileInfoTable(0), HeaderFileInfoTableData(nullptr), HeaderFileInfoTable(nullptr),
LocalNumSubmodules(0), BaseSubmoduleID(0), LocalNumSubmodules(0), BaseSubmoduleID(0),
LocalNumSelectors(0), SelectorOffsets(0), BaseSelectorID(0), LocalNumSelectors(0), SelectorOffsets(nullptr), BaseSelectorID(0),
SelectorLookupTableData(0), SelectorLookupTable(0), LocalNumDecls(0), SelectorLookupTableData(nullptr), SelectorLookupTable(nullptr),
DeclOffsets(0), BaseDeclID(0), LocalNumDecls(0), DeclOffsets(nullptr), BaseDeclID(0),
LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(0), LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(nullptr),
FileSortedDecls(0), NumFileSortedDecls(0), FileSortedDecls(nullptr), NumFileSortedDecls(0),
RedeclarationsMap(0), LocalNumRedeclarationsInMap(0), RedeclarationsMap(nullptr), LocalNumRedeclarationsInMap(0),
ObjCCategoriesMap(0), LocalNumObjCCategoriesInMap(0), ObjCCategoriesMap(nullptr), LocalNumObjCCategoriesInMap(0),
LocalNumTypes(0), TypeOffsets(0), BaseTypeIndex(0) LocalNumTypes(0), TypeOffsets(nullptr), BaseTypeIndex(0)
{} {}
ModuleFile::~ModuleFile() { ModuleFile::~ModuleFile() {

View File

@ -33,14 +33,14 @@ ModuleFile *ModuleManager::lookup(StringRef Name) {
if (Entry) if (Entry)
return lookup(Entry); return lookup(Entry);
return 0; return nullptr;
} }
ModuleFile *ModuleManager::lookup(const FileEntry *File) { ModuleFile *ModuleManager::lookup(const FileEntry *File) {
llvm::DenseMap<const FileEntry *, ModuleFile *>::iterator Known llvm::DenseMap<const FileEntry *, ModuleFile *>::iterator Known
= Modules.find(File); = Modules.find(File);
if (Known == Modules.end()) if (Known == Modules.end())
return 0; return nullptr;
return Known->second; return Known->second;
} }
@ -58,7 +58,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
off_t ExpectedSize, time_t ExpectedModTime, off_t ExpectedSize, time_t ExpectedModTime,
ModuleFile *&Module, ModuleFile *&Module,
std::string &ErrorStr) { std::string &ErrorStr) {
Module = 0; Module = nullptr;
// Look for the file entry. This only fails if the expected size or // Look for the file entry. This only fails if the expected size or
// modification time differ. // modification time differ.
@ -162,7 +162,7 @@ void ModuleManager::removeModules(ModuleIterator first, ModuleIterator last,
if (modMap) { if (modMap) {
StringRef ModuleName = (*victim)->ModuleName; StringRef ModuleName = (*victim)->ModuleName;
if (Module *mod = modMap->findModule(ModuleName)) { if (Module *mod = modMap->findModule(ModuleName)) {
mod->setASTFile(0); mod->setASTFile(nullptr);
} }
} }
delete *victim; delete *victim;
@ -185,7 +185,7 @@ ModuleManager::VisitState *ModuleManager::allocateVisitState() {
if (FirstVisitState) { if (FirstVisitState) {
VisitState *Result = FirstVisitState; VisitState *Result = FirstVisitState;
FirstVisitState = FirstVisitState->NextState; FirstVisitState = FirstVisitState->NextState;
Result->NextState = 0; Result->NextState = nullptr;
return Result; return Result;
} }
@ -194,7 +194,7 @@ ModuleManager::VisitState *ModuleManager::allocateVisitState() {
} }
void ModuleManager::returnVisitState(VisitState *State) { void ModuleManager::returnVisitState(VisitState *State) {
assert(State->NextState == 0 && "Visited state is in list?"); assert(State->NextState == nullptr && "Visited state is in list?");
State->NextState = FirstVisitState; State->NextState = FirstVisitState;
FirstVisitState = State; FirstVisitState = State;
} }
@ -223,7 +223,7 @@ void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
} }
ModuleManager::ModuleManager(FileManager &FileMgr) ModuleManager::ModuleManager(FileManager &FileMgr)
: FileMgr(FileMgr), GlobalIndex(), FirstVisitState(0) { } : FileMgr(FileMgr), GlobalIndex(), FirstVisitState(nullptr) {}
ModuleManager::~ModuleManager() { ModuleManager::~ModuleManager() {
for (unsigned i = 0, e = Chain.size(); i != e; ++i) for (unsigned i = 0, e = Chain.size(); i != e; ++i)
@ -283,7 +283,7 @@ ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
assert(VisitOrder.size() == N && "Visitation order is wrong?"); assert(VisitOrder.size() == N && "Visitation order is wrong?");
delete FirstVisitState; delete FirstVisitState;
FirstVisitState = 0; FirstVisitState = nullptr;
} }
VisitState *State = allocateVisitState(); VisitState *State = allocateVisitState();