From d24fb6c9472187a9e77ea371fd73d92a4f6c69f0 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 22 May 2014 04:46:25 +0000 Subject: [PATCH] [C++11] Use 'nullptr'. Frontend edition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209389 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/ASTConsumers.cpp | 10 +- lib/Frontend/ASTUnit.cpp | 130 +++++++++--------- lib/Frontend/CacheTokens.cpp | 6 +- lib/Frontend/ChainedIncludesSource.cpp | 22 +-- lib/Frontend/CompilerInstance.cpp | 34 ++--- lib/Frontend/CompilerInvocation.cpp | 2 +- .../CreateInvocationFromCommandLine.cpp | 8 +- lib/Frontend/DependencyFile.cpp | 4 +- lib/Frontend/DependencyGraph.cpp | 2 +- lib/Frontend/DiagnosticRenderer.cpp | 4 +- lib/Frontend/FrontendAction.cpp | 28 ++-- lib/Frontend/FrontendActions.cpp | 15 +- lib/Frontend/InitPreprocessor.cpp | 2 +- lib/Frontend/LangStandards.cpp | 2 +- lib/Frontend/LogDiagnosticPrinter.cpp | 2 +- lib/Frontend/PrintPreprocessedOutput.cpp | 5 +- lib/Frontend/SerializedDiagnosticPrinter.cpp | 11 +- lib/Frontend/TextDiagnosticPrinter.cpp | 2 +- lib/Frontend/VerifyDiagnosticConsumer.cpp | 36 ++--- 19 files changed, 165 insertions(+), 160 deletions(-) diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp index f90c0a93b1..54a6d474c1 100644 --- a/lib/Frontend/ASTConsumers.cpp +++ b/lib/Frontend/ASTConsumers.cpp @@ -36,7 +36,7 @@ namespace { typedef RecursiveASTVisitor base; public: - ASTPrinter(raw_ostream *Out = NULL, bool Dump = false, + ASTPrinter(raw_ostream *Out = nullptr, bool Dump = false, StringRef FilterString = "", bool DumpLookups = false) : Out(Out ? *Out : llvm::outs()), Dump(Dump), FilterString(FilterString), DumpLookups(DumpLookups) {} @@ -53,7 +53,7 @@ namespace { bool shouldWalkTypesOfTypeLocs() const { return false; } bool TraverseDecl(Decl *D) { - if (D != NULL && filterMatches(D)) { + if (D && filterMatches(D)) { bool ShowColors = Out.has_colors(); if (ShowColors) Out.changeColor(raw_ostream::BLUE); @@ -98,7 +98,7 @@ namespace { class ASTDeclNodeLister : public ASTConsumer, public RecursiveASTVisitor { public: - ASTDeclNodeLister(raw_ostream *Out = NULL) + ASTDeclNodeLister(raw_ostream *Out = nullptr) : Out(Out ? *Out : llvm::outs()) {} void HandleTranslationUnit(ASTContext &Context) override { @@ -124,11 +124,11 @@ ASTConsumer *clang::CreateASTPrinter(raw_ostream *Out, } ASTConsumer *clang::CreateASTDumper(StringRef FilterString, bool DumpLookups) { - return new ASTPrinter(0, /*Dump=*/ true, FilterString, DumpLookups); + return new ASTPrinter(nullptr, /*Dump=*/true, FilterString, DumpLookups); } ASTConsumer *clang::CreateASTDeclNodeLister() { - return new ASTDeclNodeLister(0); + return new ASTDeclNodeLister(nullptr); } //===----------------------------------------------------------------------===// diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 2532d26d6e..49487d9975 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -214,14 +214,14 @@ const unsigned DefaultPreambleRebuildInterval = 5; static std::atomic ActiveASTUnitObjects; ASTUnit::ASTUnit(bool _MainFileIsAST) - : Reader(0), HadModuleLoaderFatalFailure(false), + : Reader(nullptr), HadModuleLoaderFatalFailure(false), OnlyLocalDecls(false), CaptureDiagnostics(false), MainFileIsAST(_MainFileIsAST), TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")), OwnsRemappedFileBuffers(true), NumStoredDiagnosticsFromDriver(0), - PreambleRebuildCounter(0), SavedMainFileBuffer(0), PreambleBuffer(0), - NumWarningsInPreamble(0), + PreambleRebuildCounter(0), SavedMainFileBuffer(nullptr), + PreambleBuffer(nullptr), NumWarningsInPreamble(0), ShouldCacheCodeCompletionResults(false), IncludeBriefCommentsInCodeCompletion(false), UserFilesAreVolatile(false), CompletionCacheTopLevelHashValue(0), @@ -493,7 +493,7 @@ void ASTUnit::CacheCodeCompletionResults() { void ASTUnit::ClearCachedCompletionResults() { CachedCompletionResults.clear(); CachedCompletionTypes.clear(); - CachedCompletionAllocator = 0; + CachedCompletionAllocator = nullptr; } namespace { @@ -582,10 +582,10 @@ class StoredDiagnosticConsumer : public DiagnosticConsumer { public: explicit StoredDiagnosticConsumer( SmallVectorImpl &StoredDiags) - : StoredDiags(StoredDiags), SourceMgr(0) { } + : StoredDiags(StoredDiags), SourceMgr(nullptr) {} void BeginSourceFile(const LangOptions &LangOpts, - const Preprocessor *PP = 0) override { + const Preprocessor *PP = nullptr) override { if (PP) SourceMgr = &PP->getSourceManager(); } @@ -604,9 +604,9 @@ class CaptureDroppedDiagnostics { public: CaptureDroppedDiagnostics(bool RequestCapture, DiagnosticsEngine &Diags, SmallVectorImpl &StoredDiags) - : Diags(Diags), Client(StoredDiags), PreviousClient(0) + : Diags(Diags), Client(StoredDiags), PreviousClient(nullptr) { - if (RequestCapture || Diags.getClient() == 0) { + if (RequestCapture || Diags.getClient() == nullptr) { PreviousClient = Diags.takeClient(); Diags.setClient(&Client); } @@ -637,13 +637,13 @@ void StoredDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level Level, ASTMutationListener *ASTUnit::getASTMutationListener() { if (WriterData) return &WriterData->Writer; - return 0; + return nullptr; } ASTDeserializationListener *ASTUnit::getDeserializationListener() { if (WriterData) return &WriterData->Writer; - return 0; + return nullptr; } llvm::MemoryBuffer *ASTUnit::getBufferForFile(StringRef Filename, @@ -659,7 +659,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr &Diags, if (!Diags.getPtr()) { // No diagnostics engine was provided, so create our own diagnostics object // with the default options. - DiagnosticConsumer *Client = 0; + DiagnosticConsumer *Client = nullptr; if (CaptureDiagnostics) Client = new StoredDiagnosticConsumer(AST.StoredDiagnostics); Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(), @@ -687,7 +687,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, llvm::CrashRecoveryContextReleaseRefCleanup > DiagCleanup(Diags.getPtr()); - ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics); + ConfigureDiags(Diags, nullptr, nullptr, *AST, CaptureDiagnostics); AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; @@ -699,12 +699,12 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, AST->getFileManager(), UserFilesAreVolatile); AST->HSOpts = new HeaderSearchOptions(); - + AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts, AST->getSourceManager(), AST->getDiagnostics(), AST->ASTFileLangOpts, - /*Target=*/0)); + /*Target=*/nullptr)); PreprocessorOptions *PPOpts = new PreprocessorOptions(); @@ -719,7 +719,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, AST->PP = new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts, AST->getSourceManager(), HeaderInfo, *AST, - /*IILookup=*/0, + /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false); Preprocessor &PP = *AST->PP; @@ -753,7 +753,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, case ASTReader::ConfigurationMismatch: case ASTReader::HadErrors: AST->getDiagnostics().Report(diag::err_fe_unable_to_load_pch); - return NULL; + return nullptr; } AST->OriginalSourceFile = AST->Reader->getOriginalSourceFile(); @@ -945,7 +945,7 @@ public: PrecompilePreambleConsumer(ASTUnit &Unit, PrecompilePreambleAction *Action, const Preprocessor &PP, StringRef isysroot, raw_ostream *Out) - : PCHGenerator(PP, "", 0, isysroot, Out, /*AllowASTWithErrors=*/true), + : PCHGenerator(PP, "", nullptr, isysroot, Out, /*AllowASTWithErrors=*/true), Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action) { Hash = 0; } @@ -991,10 +991,10 @@ ASTConsumer *PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; std::string OutputFile; - raw_ostream *OS = 0; + raw_ostream *OS = nullptr; if (GeneratePCHAction::ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS)) - return 0; + return nullptr; if (!CI.getFrontendOpts().RelocatablePCH) Sysroot.clear(); @@ -1041,8 +1041,8 @@ static void checkAndSanitizeDiags(SmallVectorImpl & /// contain any translation-unit information, false otherwise. bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { delete SavedMainFileBuffer; - SavedMainFileBuffer = 0; - + SavedMainFileBuffer = nullptr; + if (!Invocation) { delete OverrideMainBuffer; return true; @@ -1093,10 +1093,10 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { SourceMgr = new SourceManager(getDiagnostics(), *FileMgr, UserFilesAreVolatile); TheSema.reset(); - Ctx = 0; - PP = 0; - Reader = 0; - + Ctx = nullptr; + PP = nullptr; + Reader = nullptr; + // Clear out old caches and data. TopLevelDecls.clear(); clearFileLevelDecls(); @@ -1166,7 +1166,7 @@ error: // Remove the overridden buffer we used for the preamble. if (OverrideMainBuffer) { delete OverrideMainBuffer; - SavedMainFileBuffer = 0; + SavedMainFileBuffer = nullptr; } // Keep the ownership of the data in the ASTUnit because the client may @@ -1206,7 +1206,7 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation, // Try to determine if the main file has been remapped, either from the // command line (to another file) or directly through the compiler invocation // (to a memory buffer). - llvm::MemoryBuffer *Buffer = 0; + llvm::MemoryBuffer *Buffer = nullptr; std::string MainFilePath(FrontendOpts.Inputs[0].getFile()); llvm::sys::fs::UniqueID MainFileID; if (!llvm::sys::fs::getUniqueID(MainFilePath, MainFileID)) { @@ -1228,8 +1228,7 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation, Buffer = getBufferForFile(M->second); if (!Buffer) - return std::make_pair((llvm::MemoryBuffer*)0, - std::make_pair(0, true)); + return std::make_pair(nullptr, std::make_pair(0, true)); CreatedBuffer = true; } } @@ -1262,8 +1261,8 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation, if (!Buffer) { Buffer = getBufferForFile(FrontendOpts.Inputs[0].getFile()); if (!Buffer) - return std::make_pair((llvm::MemoryBuffer*)0, std::make_pair(0, true)); - + return std::make_pair(nullptr, std::make_pair(0, true)); + CreatedBuffer = true; } @@ -1397,7 +1396,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( // The next time we actually see a preamble, precompile it. PreambleRebuildCounter = 1; - return 0; + return nullptr; } if (!Preamble.empty()) { @@ -1487,7 +1486,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( // If we aren't allowed to rebuild the precompiled preamble, just // return now. if (!AllowRebuild) - return 0; + return nullptr; // We can't reuse the previously-computed preamble. Build a new one. Preamble.clear(); @@ -1497,7 +1496,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( } else if (!AllowRebuild) { // We aren't allowed to rebuild the precompiled preamble; just // return now. - return 0; + return nullptr; } // If the preamble rebuild counter > 1, it's because we previously @@ -1505,7 +1504,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( // again. Decrement the counter and return a failure. if (PreambleRebuildCounter > 1) { --PreambleRebuildCounter; - return 0; + return nullptr; } // Create a temporary file for the precompiled preamble. In rare @@ -1514,7 +1513,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( if (PreamblePCHPath.empty()) { // Try again next time. PreambleRebuildCounter = 1; - return 0; + return nullptr; } // We did not previously compute a preamble, or it can't be reused anyway. @@ -1568,7 +1567,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( PreambleRebuildCounter = DefaultPreambleRebuildInterval; PreprocessorOpts.eraseRemappedFile( PreprocessorOpts.remapped_file_buffer_end() - 1); - return 0; + return nullptr; } // Inform the target of the language options. @@ -1612,7 +1611,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( PreambleRebuildCounter = DefaultPreambleRebuildInterval; PreprocessorOpts.eraseRemappedFile( PreprocessorOpts.remapped_file_buffer_end() - 1); - return 0; + return nullptr; } Act->Execute(); @@ -1641,7 +1640,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( PreambleRebuildCounter = DefaultPreambleRebuildInterval; PreprocessorOpts.eraseRemappedFile( PreprocessorOpts.remapped_file_buffer_end() - 1); - return 0; + return nullptr; } // Keep track of the preamble we precompiled. @@ -1717,8 +1716,8 @@ void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) { Ctx = &CI.getASTContext(); if (CI.hasPreprocessor()) PP = &CI.getPreprocessor(); - CI.setSourceManager(0); - CI.setFileManager(0); + CI.setSourceManager(nullptr); + CI.setFileManager(nullptr); if (CI.hasTarget()) Target = &CI.getTarget(); Reader = CI.getModuleManager(); @@ -1758,7 +1757,7 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI, bool UserFilesAreVolatile) { std::unique_ptr AST; AST.reset(new ASTUnit(false)); - ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics); + ConfigureDiags(Diags, nullptr, nullptr, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; AST->Invocation = CI; AST->FileSystemOpts = CI->getFileSystemOpts(); @@ -1836,7 +1835,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), &Clang->getTargetOpts())); if (!Clang->hasTarget()) - return 0; + return nullptr; // Inform the target of the language options. // @@ -1853,10 +1852,10 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( // Configure the various subsystems. AST->TheSema.reset(); - AST->Ctx = 0; - AST->PP = 0; - AST->Reader = 0; - + AST->Ctx = nullptr; + AST->PP = nullptr; + AST->Reader = nullptr; + // Create a file manager object to provide access to and cache the filesystem. Clang->setFileManager(&AST->getFileManager()); @@ -1880,7 +1879,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( if (OwnAST && ErrAST) ErrAST->swap(OwnAST); - return 0; + return nullptr; } if (Persistent && !TrackerAct) { @@ -1898,7 +1897,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( if (OwnAST && ErrAST) ErrAST->swap(OwnAST); - return 0; + return nullptr; } // Steal the created target, context, and preprocessor. @@ -1921,7 +1920,7 @@ bool ASTUnit::LoadFromCompilerInvocation(bool PrecompilePreamble) { Invocation->getFrontendOpts().DisableFree = false; ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts()); - llvm::MemoryBuffer *OverrideMainBuffer = 0; + llvm::MemoryBuffer *OverrideMainBuffer = nullptr; if (PrecompilePreamble) { PreambleRebuildCounter = 2; OverrideMainBuffer @@ -1945,7 +1944,7 @@ std::unique_ptr ASTUnit::LoadFromCompilerInvocation( bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile) { // Create the AST unit. std::unique_ptr AST(new ASTUnit(false)); - ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics); + ConfigureDiags(Diags, nullptr, nullptr, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; @@ -2003,7 +2002,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( llvm::makeArrayRef(ArgBegin, ArgEnd), Diags); if (!CI) - return 0; + return nullptr; } // Override any files that need remapping @@ -2025,7 +2024,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( AST.reset(new ASTUnit(false)); ConfigureDiags(Diags, ArgBegin, ArgEnd, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; - Diags = 0; // Zero out now to ease cleanup during crash recovery. + Diags = nullptr; // Zero out now to ease cleanup during crash recovery. AST->FileSystemOpts = CI->getFileSystemOpts(); IntrusiveRefCntPtr VFS = createVFSFromCompilerInvocation(*CI, *Diags); @@ -2044,8 +2043,8 @@ ASTUnit *ASTUnit::LoadFromCommandLine( AST->Invocation = CI; if (ForSerialization) AST->WriterData.reset(new ASTWriterData()); - CI = 0; // Zero out now to ease cleanup during crash recovery. - + CI = nullptr; // Zero out now to ease cleanup during crash recovery. + // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar ASTUnitCleanup(AST.get()); @@ -2057,7 +2056,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( AST->StoredDiagnostics.swap(AST->FailedParseDiagnostics); ErrAST->swap(AST); } - return 0; + return nullptr; } return AST.release(); @@ -2089,7 +2088,7 @@ bool ASTUnit::Reparse(ArrayRef RemappedFiles) { // If we have a preamble file lying around, or if we might try to // build a precompiled preamble, do so now. - llvm::MemoryBuffer *OverrideMainBuffer = 0; + llvm::MemoryBuffer *OverrideMainBuffer = nullptr; if (!getPreambleFile(this).empty() || PreambleRebuildCounter > 0) OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(*Invocation); @@ -2413,7 +2412,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column, Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), &Clang->getTargetOpts())); if (!Clang->hasTarget()) { - Clang->setInvocation(0); + Clang->setInvocation(nullptr); return; } @@ -2454,7 +2453,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column, // the use of the precompiled preamble if we're if the completion // point is within the main file, after the end of the precompiled // preamble. - llvm::MemoryBuffer *OverrideMainBuffer = 0; + llvm::MemoryBuffer *OverrideMainBuffer = nullptr; if (!getPreambleFile(this).empty()) { std::string CompleteFilePath(File); llvm::sys::fs::UniqueID CompleteFileID; @@ -2536,7 +2535,7 @@ static bool serializeUnit(ASTWriter &Writer, Sema &S, bool hasErrors, raw_ostream &OS) { - Writer.WriteAST(S, std::string(), 0, "", hasErrors); + Writer.WriteAST(S, std::string(), nullptr, "", hasErrors); // Write the generated bitstream to "Out". if (!Buffer.empty()) @@ -2677,7 +2676,8 @@ void ASTUnit::findFileRegionDecls(FileID File, unsigned Offset, unsigned Length, LocDeclsTy::iterator BeginIt = std::lower_bound(LocDecls.begin(), LocDecls.end(), - std::make_pair(Offset, (Decl *)0), llvm::less_first()); + std::make_pair(Offset, (Decl *)nullptr), + llvm::less_first()); if (BeginIt != LocDecls.begin()) --BeginIt; @@ -2690,7 +2690,7 @@ void ASTUnit::findFileRegionDecls(FileID File, unsigned Offset, unsigned Length, LocDeclsTy::iterator EndIt = std::upper_bound( LocDecls.begin(), LocDecls.end(), - std::make_pair(Offset + Length, (Decl *)0), llvm::less_first()); + std::make_pair(Offset + Length, (Decl *)nullptr), llvm::less_first()); if (EndIt != LocDecls.end()) ++EndIt; @@ -2840,7 +2840,7 @@ bool ASTUnit::visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn) { namespace { struct PCHLocatorInfo { serialization::ModuleFile *Mod; - PCHLocatorInfo() : Mod(0) {} + PCHLocatorInfo() : Mod(nullptr) {} }; } @@ -2863,14 +2863,14 @@ static bool PCHLocator(serialization::ModuleFile &M, void *UserData) { const FileEntry *ASTUnit::getPCHFile() { if (!Reader) - return 0; + return nullptr; PCHLocatorInfo Info; Reader->getModuleManager().visit(PCHLocator, &Info); if (Info.Mod) return Info.Mod->File; - return 0; + return nullptr; } bool ASTUnit::isModuleFile() { diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index bf1c968da1..d30196d6df 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -63,13 +63,13 @@ class PTHEntryKeyVariant { FileData *Data; public: - PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(0) {} + PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(nullptr) {} PTHEntryKeyVariant(FileData *Data, const char *path) : Path(path), Kind(IsDE), Data(new FileData(*Data)) {} explicit PTHEntryKeyVariant(const char *path) - : Path(path), Kind(IsNoExist), Data(0) {} + : Path(path), Kind(IsNoExist), Data(nullptr) {} bool isFile() const { return Kind == IsFE; } @@ -317,7 +317,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) { Token Tmp = Tok; Tmp.setKind(tok::eod); Tmp.clearFlag(Token::StartOfLine); - Tmp.setIdentifierInfo(0); + Tmp.setIdentifierInfo(nullptr); EmitToken(Tmp); ParsingPreprocessorDirective = false; } diff --git a/lib/Frontend/ChainedIncludesSource.cpp b/lib/Frontend/ChainedIncludesSource.cpp index 674116034b..6dc3fd450f 100644 --- a/lib/Frontend/ChainedIncludesSource.cpp +++ b/lib/Frontend/ChainedIncludesSource.cpp @@ -25,11 +25,11 @@ using namespace clang; -static ASTReader *createASTReader(CompilerInstance &CI, - StringRef pchFile, - SmallVectorImpl &memBufs, - SmallVectorImpl &bufNames, - ASTDeserializationListener *deserialListener = 0) { +static ASTReader * +createASTReader(CompilerInstance &CI, StringRef pchFile, + SmallVectorImpl &memBufs, + SmallVectorImpl &bufNames, + ASTDeserializationListener *deserialListener = nullptr) { Preprocessor &PP = CI.getPreprocessor(); std::unique_ptr Reader; Reader.reset(new ASTReader(PP, CI.getASTContext(), /*isysroot=*/"", @@ -54,7 +54,7 @@ static ASTReader *createASTReader(CompilerInstance &CI, case ASTReader::HadErrors: break; } - return 0; + return nullptr; } ChainedIncludesSource::~ChainedIncludesSource() { @@ -112,12 +112,12 @@ ChainedIncludesSource::create(CompilerInstance &CI) { SmallVector serialAST; llvm::raw_svector_ostream OS(serialAST); std::unique_ptr consumer; - consumer.reset(new PCHGenerator(Clang->getPreprocessor(), "-", 0, + consumer.reset(new PCHGenerator(Clang->getPreprocessor(), "-", nullptr, /*isysroot=*/"", &OS)); Clang->getASTContext().setASTMutationListener( consumer->GetASTMutationListener()); Clang->setASTConsumer(consumer.release()); - Clang->createSema(TU_Prefix, 0); + Clang->createSema(TU_Prefix, nullptr); if (firstInclude) { Preprocessor &PP = Clang->getPreprocessor(); @@ -142,13 +142,13 @@ ChainedIncludesSource::create(CompilerInstance &CI) { Reader = createASTReader(*Clang, pchName, bufs, serialBufNames, Clang->getASTConsumer().GetASTDeserializationListener()); if (!Reader) - return 0; + return nullptr; Clang->setModuleManager(Reader); Clang->getASTContext().setExternalSource(Reader); } if (!Clang->InitializeSourceManager(InputFile)) - return 0; + return nullptr; ParseAST(Clang->getSema()); OS.flush(); @@ -165,7 +165,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { IntrusiveRefCntPtr Reader; Reader = createASTReader(CI, pchName, serialBufs, serialBufNames); if (!Reader) - return 0; + return nullptr; source->FinalReader = Reader; return source; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 822b44e442..c65d34bd2a 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -52,7 +52,7 @@ using namespace clang; CompilerInstance::CompilerInstance(bool BuildingModule) : ModuleLoader(BuildingModule), - Invocation(new CompilerInvocation()), ModuleManager(0), + Invocation(new CompilerInvocation()), ModuleManager(nullptr), BuildGlobalModuleIndex(false), HaveFullGlobalModuleIndex(false), ModuleBuildFailed(false) { } @@ -229,7 +229,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { const PreprocessorOptions &PPOpts = getPreprocessorOpts(); // Create a PTH manager if we are using some form of a token cache. - PTHManager *PTHMgr = 0; + PTHManager *PTHMgr = nullptr; if (!PPOpts.TokenCache.empty()) PTHMgr = PTHManager::Create(PPOpts.TokenCache, getDiagnostics()); @@ -364,7 +364,7 @@ ExternalASTSource *CompilerInstance::createPCHExternalASTSource( break; } - return 0; + return nullptr; } // Code Completion @@ -399,14 +399,14 @@ void CompilerInstance::createCodeCompletionConsumer() { return; } else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName, Loc.Line, Loc.Column)) { - setCodeCompletionConsumer(0); + setCodeCompletionConsumer(nullptr); return; } if (CompletionConsumer->isOutputBinary() && llvm::sys::ChangeStdoutToBinary()) { getPreprocessor().getDiagnostics().Report(diag::err_fe_stdout_binary); - setCodeCompletionConsumer(0); + setCodeCompletionConsumer(nullptr); } } @@ -422,7 +422,7 @@ CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP, const CodeCompleteOptions &Opts, raw_ostream &OS) { if (EnableCodeCompletion(PP, Filename, Line, Column)) - return 0; + return nullptr; // Set up the creation routine for code-completion. return new PrintingCodeCompleteConsumer(Opts, OS); @@ -496,7 +496,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, if (!OS) { getDiagnostics().Report(diag::err_fe_unable_to_open_output) << OutputPath << Error; - return 0; + return nullptr; } // Add the output file -- but don't try to remove "-", since this means we are @@ -546,7 +546,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, if (llvm::sys::fs::exists(Status)) { // Fail early if we can't write to the final destination. if (!llvm::sys::fs::can_write(OutputPath)) - return 0; + return nullptr; // Don't use a temporary if the output is a special file. This handles // things like '-o /dev/null' @@ -589,7 +589,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, OSFile.c_str(), Error, (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text))); if (!Error.empty()) - return 0; + return nullptr; } // Make sure the out stream file gets removed if we crash. @@ -1034,7 +1034,7 @@ static void pruneModuleCache(const HeaderSearchOptions &HSOpts) { // Check whether the time stamp is older than our pruning interval. // If not, do nothing. time_t TimeStampModTime = StatBuf.st_mtime; - time_t CurrentTime = time(0); + time_t CurrentTime = time(nullptr); if (CurrentTime - TimeStampModTime <= time_t(HSOpts.ModuleCachePruneInterval)) return; @@ -1149,7 +1149,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, return LastModuleImportResult; } - clang::Module *Module = 0; + clang::Module *Module = nullptr; // If we don't already have information on this module, load the module now. llvm::DenseMap::iterator Known @@ -1247,7 +1247,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, if (getPreprocessorOpts().FailedModules) getPreprocessorOpts().FailedModules->addFailed(ModuleName); - KnownModules[Path[0].first] = 0; + KnownModules[Path[0].first] = nullptr; ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -1262,13 +1262,13 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ModuleLoader::HadFatalFailure = true; // FIXME: The ASTReader will already have complained, but can we showhorn // that diagnostic information into a more useful form? - KnownModules[Path[0].first] = 0; + KnownModules[Path[0].first] = nullptr; return ModuleLoadResult(); case ASTReader::Failure: ModuleLoader::HadFatalFailure = true; // Already complained, but note now that we failed. - KnownModules[Path[0].first] = 0; + KnownModules[Path[0].first] = nullptr; ModuleBuildFailed = true; return ModuleLoadResult(); } @@ -1348,8 +1348,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, getDiagnostics().Report(ImportLoc, diag::warn_missing_submodule) << Module->getFullModuleName() << SourceRange(Path.front().second, Path.back().second); - - return ModuleLoadResult(0, true); + + return ModuleLoadResult(nullptr, true); } // Check whether this module is available. @@ -1413,7 +1413,7 @@ GlobalModuleIndex *CompilerInstance::loadGlobalModuleIndex( createModuleManager(); // Can't do anything if we don't have the module manager. if (!ModuleManager) - return 0; + return nullptr; // Get an existing global index. This loads it if not already // loaded. ModuleManager->loadGlobalIndex(); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 6aeb9c6502..2ba9450c0f 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1955,7 +1955,7 @@ createVFSFromCompilerInvocation(const CompilerInvocation &CI, } IntrusiveRefCntPtr FS = - vfs::getVFSFromYAML(Buffer.release(), /*DiagHandler*/0); + vfs::getVFSFromYAML(Buffer.release(), /*DiagHandler*/nullptr); if (!FS.getPtr()) { Diags.Report(diag::err_invalid_vfs_overlay) << File; return IntrusiveRefCntPtr(); diff --git a/lib/Frontend/CreateInvocationFromCommandLine.cpp b/lib/Frontend/CreateInvocationFromCommandLine.cpp index f108e55b57..45f7aa3acd 100644 --- a/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -57,7 +57,7 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, // Just print the cc1 options if -### was present. if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) { C->getJobs().Print(llvm::errs(), "\n", true); - return 0; + return nullptr; } // We expect to get back exactly one command job, if we didn't something @@ -68,13 +68,13 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, llvm::raw_svector_ostream OS(Msg); Jobs.Print(OS, "; ", true); Diags->Report(diag::err_fe_expected_compiler_job) << OS.str(); - return 0; + return nullptr; } const driver::Command *Cmd = cast(*Jobs.begin()); if (StringRef(Cmd->getCreator().getName()) != "clang") { Diags->Report(diag::err_fe_expected_clang_command); - return 0; + return nullptr; } const ArgStringList &CCArgs = Cmd->getArguments(); @@ -84,6 +84,6 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, const_cast(CCArgs.data()) + CCArgs.size(), *Diags)) - return 0; + return nullptr; return CI.release(); } diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp index b472eaaae0..e72be89b4e 100644 --- a/lib/Frontend/DependencyFile.cpp +++ b/lib/Frontend/DependencyFile.cpp @@ -96,7 +96,7 @@ DependencyFileGenerator *DependencyFileGenerator::CreateAndAttachToPreprocessor( if (Opts.Targets.empty()) { PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT); - return NULL; + return nullptr; } // Disable the "file not found" diagnostic if the -MG option was given. @@ -141,7 +141,7 @@ void DFGImpl::FileChanged(SourceLocation Loc, const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc))); - if (FE == 0) return; + if (!FE) return; StringRef Filename = FE->getName(); if (!FileMatchesDepCriteria(Filename.data(), FileType)) diff --git a/lib/Frontend/DependencyGraph.cpp b/lib/Frontend/DependencyGraph.cpp index 4bff3dba9e..051b7f9e14 100644 --- a/lib/Frontend/DependencyGraph.cpp +++ b/lib/Frontend/DependencyGraph.cpp @@ -79,7 +79,7 @@ void DependencyGraphCallback::InclusionDirective(SourceLocation HashLoc, SourceManager &SM = PP->getSourceManager(); const FileEntry *FromFile = SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(HashLoc))); - if (FromFile == 0) + if (!FromFile) return; Dependencies[FromFile].push_back(File); diff --git a/lib/Frontend/DiagnosticRenderer.cpp b/lib/Frontend/DiagnosticRenderer.cpp index 85e87a21ed..ce9fc0548c 100644 --- a/lib/Frontend/DiagnosticRenderer.cpp +++ b/lib/Frontend/DiagnosticRenderer.cpp @@ -186,7 +186,7 @@ void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) { emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(), Diag.getRanges(), Diag.getFixIts(), Diag.getLocation().isValid() ? &Diag.getLocation().getManager() - : 0, + : nullptr, &Diag); } @@ -509,5 +509,5 @@ DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc, void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) { - emitNote(SourceLocation(), Message, 0); + emitNote(SourceLocation(), Message, nullptr); } diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index ade23b87d1..b085749074 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -123,7 +123,7 @@ public: } // end anonymous namespace -FrontendAction::FrontendAction() : Instance(0) {} +FrontendAction::FrontendAction() : Instance(nullptr) {} FrontendAction::~FrontendAction() {} @@ -137,7 +137,7 @@ ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, StringRef InFile) { ASTConsumer* Consumer = CreateASTConsumer(CI, InFile); if (!Consumer) - return 0; + return nullptr; if (CI.getFrontendOpts().AddPluginActions.size() == 0) return Consumer; @@ -196,7 +196,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, setCurrentInput(Input, AST); // Inform the diagnostic client we are processing a source file. - CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0); + CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr); HasBegunSourceFile = true; // Set the shared objects, these are reset when we finish processing the @@ -239,7 +239,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, "This action does not have IR file support!"); // Inform the diagnostic client we are processing a source file. - CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0); + CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr); HasBegunSourceFile = true; // Initialize the action. @@ -391,17 +391,17 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, // matching EndSourceFile(). failure: if (isCurrentFileAST()) { - CI.setASTContext(0); - CI.setPreprocessor(0); - CI.setSourceManager(0); - CI.setFileManager(0); + CI.setASTContext(nullptr); + CI.setPreprocessor(nullptr); + CI.setSourceManager(nullptr); + CI.setFileManager(nullptr); } if (HasBegunSourceFile) CI.getDiagnosticClient().EndSourceFile(); CI.clearOutputFiles(/*EraseFiles=*/true); setCurrentInput(FrontendInputFile()); - setCompilerInstance(0); + setCompilerInstance(nullptr); return false; } @@ -447,10 +447,10 @@ void FrontendAction::EndSourceFile() { BuryPointer(CI.takeASTConsumer()); } else { if (!isCurrentFileAST()) { - CI.setSema(0); - CI.setASTContext(0); + CI.setSema(nullptr); + CI.setASTContext(nullptr); } - CI.setASTConsumer(0); + CI.setASTConsumer(nullptr); } // Inform the preprocessor we are done. @@ -479,7 +479,7 @@ void FrontendAction::EndSourceFile() { CI.resetAndLeakFileManager(); } - setCompilerInstance(0); + setCompilerInstance(nullptr); setCurrentInput(FrontendInputFile()); } @@ -503,7 +503,7 @@ void ASTFrontendAction::ExecuteAction() { CI.createCodeCompletionConsumer(); // Use a code completion consumer? - CodeCompleteConsumer *CompletionConsumer = 0; + CodeCompleteConsumer *CompletionConsumer = nullptr; if (CI.hasCodeCompletionConsumer()) CompletionConsumer = &CI.getCodeCompletionConsumer(); diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 4cafa237ff..5c56ee399c 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -49,7 +49,7 @@ ASTConsumer *ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile)) return CreateASTPrinter(OS, CI.getFrontendOpts().ASTDumpFilter); - return 0; + return nullptr; } ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, @@ -77,13 +77,14 @@ ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; std::string OutputFile; - raw_ostream *OS = 0; + raw_ostream *OS = nullptr; if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS)) - return 0; + return nullptr; if (!CI.getFrontendOpts().RelocatablePCH) Sysroot.clear(); - return new PCHGenerator(CI.getPreprocessor(), OutputFile, 0, Sysroot, OS); + return new PCHGenerator(CI.getPreprocessor(), OutputFile, nullptr, Sysroot, + OS); } bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, @@ -114,10 +115,10 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; std::string OutputFile; - raw_ostream *OS = 0; + raw_ostream *OS = nullptr; if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS)) - return 0; - + return nullptr; + return new PCHGenerator(CI.getPreprocessor(), OutputFile, Module, Sysroot, OS); } diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index a86fe51426..fb52eb489e 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -86,7 +86,7 @@ static void AddImplicitIncludePTH(MacroBuilder &Builder, Preprocessor &PP, StringRef ImplicitIncludePTH) { PTHManager *P = PP.getPTHManager(); // Null check 'P' in the corner case where it couldn't be created. - const char *OriginalFile = P ? P->getOriginalSourceFile() : 0; + const char *OriginalFile = P ? P->getOriginalSourceFile() : nullptr; if (!OriginalFile) { PP.getDiagnostics().Report(diag::err_fe_pth_file_has_no_source_header) diff --git a/lib/Frontend/LangStandards.cpp b/lib/Frontend/LangStandards.cpp index f86a574c30..f133327f42 100644 --- a/lib/Frontend/LangStandards.cpp +++ b/lib/Frontend/LangStandards.cpp @@ -35,7 +35,7 @@ const LangStandard *LangStandard::getLangStandardForName(StringRef Name) { #include "clang/Frontend/LangStandards.def" .Default(lang_unspecified); if (K == lang_unspecified) - return 0; + return nullptr; return &getLangStandardForKind(K); } diff --git a/lib/Frontend/LogDiagnosticPrinter.cpp b/lib/Frontend/LogDiagnosticPrinter.cpp index 53b13fc6f9..917c13feb7 100644 --- a/lib/Frontend/LogDiagnosticPrinter.cpp +++ b/lib/Frontend/LogDiagnosticPrinter.cpp @@ -19,7 +19,7 @@ using namespace clang; LogDiagnosticPrinter::LogDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags, bool _OwnsOutputStream) - : OS(os), LangOpts(0), DiagOpts(diags), + : OS(os), LangOpts(nullptr), DiagOpts(diags), OwnsOutputStream(_OwnsOutputStream) { } diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index 94b327534f..8c32c2458f 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -162,7 +162,8 @@ public: const Token &Tok) { return ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, Tok); } - void WriteLineInfo(unsigned LineNo, const char *Extra=0, unsigned ExtraLen=0); + void WriteLineInfo(unsigned LineNo, const char *Extra=nullptr, + unsigned ExtraLen=0); bool LineMarkersAreDisabled() const { return DisableLineMarkers; } void HandleNewlinesInToken(const char *TokStr, unsigned Len); @@ -220,7 +221,7 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo) { } } else if (!DisableLineMarkers) { // Emit a #line or line marker. - WriteLineInfo(LineNo, 0, 0); + WriteLineInfo(LineNo, nullptr, 0); } else { // Okay, we're in -P mode, which turns off line markers. However, we still // need to emit a newline between tokens on different lines. diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp index 527f727b37..b4178f89e9 100644 --- a/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -93,11 +93,12 @@ class SDiagsWriter : public DiagnosticConsumer { struct SharedState; explicit SDiagsWriter(IntrusiveRefCntPtr State) - : LangOpts(0), OriginalInstance(false), State(State) { } + : LangOpts(nullptr), OriginalInstance(false), State(State) {} public: SDiagsWriter(raw_ostream *os, DiagnosticOptions *diags) - : LangOpts(0), OriginalInstance(true), State(new SharedState(os, diags)) + : LangOpts(nullptr), OriginalInstance(true), + State(new SharedState(os, diags)) { EmitPreamble(); } @@ -254,7 +255,7 @@ static void EmitBlockID(unsigned ID, const char *Name, Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record); // Emit the block name if present. - if (Name == 0 || Name[0] == 0) + if (!Name || Name[0] == 0) return; Record.clear(); @@ -545,7 +546,7 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, EnterDiagBlock(); EmitDiagnosticMessage(SourceLocation(), PresumedLoc(), DiagLevel, - State->diagBuf, 0, &Info); + State->diagBuf, nullptr, &Info); if (DiagLevel == DiagnosticsEngine::Note) ExitDiagBlock(); @@ -702,5 +703,5 @@ void SDiagsWriter::finish() { State->OS->write((char *)&State->Buffer.front(), State->Buffer.size()); State->OS->flush(); - State->OS.reset(0); + State->OS.reset(nullptr); } diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index e0516146b1..7a2677b540 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -43,7 +43,7 @@ void TextDiagnosticPrinter::BeginSourceFile(const LangOptions &LO, } void TextDiagnosticPrinter::EndSourceFile() { - TextDiag.reset(0); + TextDiag.reset(nullptr); } /// \brief Print any diagnostic option information to a raw_ostream. diff --git a/lib/Frontend/VerifyDiagnosticConsumer.cpp b/lib/Frontend/VerifyDiagnosticConsumer.cpp index 9df39782ab..856b51db3d 100644 --- a/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -30,8 +30,9 @@ typedef VerifyDiagnosticConsumer::ExpectedData ExpectedData; VerifyDiagnosticConsumer::VerifyDiagnosticConsumer(DiagnosticsEngine &_Diags) : Diags(_Diags), PrimaryClient(Diags.getClient()), OwnsPrimaryClient(Diags.ownsClient()), - Buffer(new TextDiagnosticBuffer()), CurrentPreprocessor(0), - LangOpts(0), SrcManager(0), ActiveSourceFiles(0), Status(HasNoDirectives) + Buffer(new TextDiagnosticBuffer()), CurrentPreprocessor(nullptr), + LangOpts(nullptr), SrcManager(nullptr), ActiveSourceFiles(0), + Status(HasNoDirectives) { Diags.takeClient(); if (Diags.hasSourceManager()) @@ -41,7 +42,7 @@ VerifyDiagnosticConsumer::VerifyDiagnosticConsumer(DiagnosticsEngine &_Diags) VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() { assert(!ActiveSourceFiles && "Incomplete parsing of source files!"); assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!"); - SrcManager = 0; + SrcManager = nullptr; CheckDiagnostics(); Diags.takeClient(); if (OwnsPrimaryClient) @@ -104,8 +105,8 @@ void VerifyDiagnosticConsumer::EndSourceFile() { // Check diagnostics once last file completed. CheckDiagnostics(); - CurrentPreprocessor = 0; - LangOpts = 0; + CurrentPreprocessor = nullptr; + LangOpts = nullptr; } } @@ -202,7 +203,7 @@ class ParseHelper { public: ParseHelper(StringRef S) - : Begin(S.begin()), End(S.end()), C(Begin), P(Begin), PEnd(NULL) { } + : Begin(S.begin()), End(S.end()), C(Begin), P(Begin), PEnd(nullptr) {} // Return true if string literal is next. bool Next(StringRef S) { @@ -325,15 +326,15 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, PH.Advance(); // Next token: { error | warning | note } - DirectiveList* DL = NULL; + DirectiveList *DL = nullptr; if (PH.Next("error")) - DL = ED ? &ED->Errors : NULL; + DL = ED ? &ED->Errors : nullptr; else if (PH.Next("warning")) - DL = ED ? &ED->Warnings : NULL; + DL = ED ? &ED->Warnings : nullptr; else if (PH.Next("remark")) - DL = ED ? &ED->Remarks : NULL; + DL = ED ? &ED->Remarks : nullptr; else if (PH.Next("note")) - DL = ED ? &ED->Notes : NULL; + DL = ED ? &ED->Notes : nullptr; else if (PH.Next("no-diagnostics")) { if (Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) Diags.Report(Pos, diag::err_verify_invalid_no_diags) @@ -397,8 +398,8 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, // Lookup file via Preprocessor, like a #include. const DirectoryLookup *CurDir; - const FileEntry *FE = PP->LookupFile(Pos, Filename, false, NULL, CurDir, - NULL, NULL, 0); + const FileEntry *FE = PP->LookupFile(Pos, Filename, false, nullptr, + CurDir, nullptr, nullptr, nullptr); if (!FE) { Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), diag::err_verify_missing_file) << Filename << KindStr; @@ -596,7 +597,8 @@ static bool findDirectives(SourceManager &SM, FileID FID, if (Comment.empty()) continue; // Find first directive. - if (ParseDirective(Comment, 0, SM, 0, Tok.getLocation(), Status)) + if (ParseDirective(Comment, nullptr, SM, nullptr, Tok.getLocation(), + Status)) return true; } return false; @@ -840,11 +842,11 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Check that the expected diagnostics occurred. NumErrors += CheckResults(Diags, *SrcManager, *Buffer, ED); } else { - NumErrors += (PrintUnexpected(Diags, 0, Buffer->err_begin(), + NumErrors += (PrintUnexpected(Diags, nullptr, Buffer->err_begin(), Buffer->err_end(), "error") + - PrintUnexpected(Diags, 0, Buffer->warn_begin(), + PrintUnexpected(Diags, nullptr, Buffer->warn_begin(), Buffer->warn_end(), "warn") + - PrintUnexpected(Diags, 0, Buffer->note_begin(), + PrintUnexpected(Diags, nullptr, Buffer->note_begin(), Buffer->note_end(), "note")); } -- 2.40.0