typedef RecursiveASTVisitor<ASTPrinter> 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) {}
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);
class ASTDeclNodeLister : public ASTConsumer,
public RecursiveASTVisitor<ASTDeclNodeLister> {
public:
- ASTDeclNodeLister(raw_ostream *Out = NULL)
+ ASTDeclNodeLister(raw_ostream *Out = nullptr)
: Out(Out ? *Out : llvm::outs()) {}
void HandleTranslationUnit(ASTContext &Context) override {
}
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);
}
//===----------------------------------------------------------------------===//
static std::atomic<unsigned> 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),
void ASTUnit::ClearCachedCompletionResults() {
CachedCompletionResults.clear();
CachedCompletionTypes.clear();
- CachedCompletionAllocator = 0;
+ CachedCompletionAllocator = nullptr;
}
namespace {
public:
explicit StoredDiagnosticConsumer(
SmallVectorImpl<StoredDiagnostic> &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();
}
public:
CaptureDroppedDiagnostics(bool RequestCapture, DiagnosticsEngine &Diags,
SmallVectorImpl<StoredDiagnostic> &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);
}
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,
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(),
llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
DiagCleanup(Diags.getPtr());
- ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
+ ConfigureDiags(Diags, nullptr, nullptr, *AST, CaptureDiagnostics);
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
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();
AST->PP =
new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts,
AST->getSourceManager(), HeaderInfo, *AST,
- /*IILookup=*/0,
+ /*IILookup=*/nullptr,
/*OwnsHeaderSearch=*/false);
Preprocessor &PP = *AST->PP;
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();
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;
}
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();
/// 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;
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();
// 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
// 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)) {
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;
}
}
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;
}
// The next time we actually see a preamble, precompile it.
PreambleRebuildCounter = 1;
- return 0;
+ return nullptr;
}
if (!Preamble.empty()) {
// 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();
} 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
// 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
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.
PreambleRebuildCounter = DefaultPreambleRebuildInterval;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
- return 0;
+ return nullptr;
}
// Inform the target of the language options.
PreambleRebuildCounter = DefaultPreambleRebuildInterval;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
- return 0;
+ return nullptr;
}
Act->Execute();
PreambleRebuildCounter = DefaultPreambleRebuildInterval;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
- return 0;
+ return nullptr;
}
// Keep track of the preamble we precompiled.
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();
bool UserFilesAreVolatile) {
std::unique_ptr<ASTUnit> 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();
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
&Clang->getTargetOpts()));
if (!Clang->hasTarget())
- return 0;
+ return nullptr;
// Inform the target of the language options.
//
// 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());
if (OwnAST && ErrAST)
ErrAST->swap(OwnAST);
- return 0;
+ return nullptr;
}
if (Persistent && !TrackerAct) {
if (OwnAST && ErrAST)
ErrAST->swap(OwnAST);
- return 0;
+ return nullptr;
}
// Steal the created target, context, and preprocessor.
Invocation->getFrontendOpts().DisableFree = false;
ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
- llvm::MemoryBuffer *OverrideMainBuffer = 0;
+ llvm::MemoryBuffer *OverrideMainBuffer = nullptr;
if (PrecompilePreamble) {
PreambleRebuildCounter = 2;
OverrideMainBuffer
bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile) {
// Create the AST unit.
std::unique_ptr<ASTUnit> 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;
llvm::makeArrayRef(ArgBegin, ArgEnd),
Diags);
if (!CI)
- return 0;
+ return nullptr;
}
// Override any files that need remapping
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::FileSystem> VFS =
createVFSFromCompilerInvocation(*CI, *Diags);
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<ASTUnit>
ASTUnitCleanup(AST.get());
AST->StoredDiagnostics.swap(AST->FailedParseDiagnostics);
ErrAST->swap(AST);
}
- return 0;
+ return nullptr;
}
return AST.release();
// 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);
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
&Clang->getTargetOpts()));
if (!Clang->hasTarget()) {
- Clang->setInvocation(0);
+ Clang->setInvocation(nullptr);
return;
}
// 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;
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())
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;
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;
namespace {
struct PCHLocatorInfo {
serialization::ModuleFile *Mod;
- PCHLocatorInfo() : Mod(0) {}
+ PCHLocatorInfo() : Mod(nullptr) {}
};
}
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() {
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; }
Token Tmp = Tok;
Tmp.setKind(tok::eod);
Tmp.clearFlag(Token::StartOfLine);
- Tmp.setIdentifierInfo(0);
+ Tmp.setIdentifierInfo(nullptr);
EmitToken(Tmp);
ParsingPreprocessorDirective = false;
}
using namespace clang;
-static ASTReader *createASTReader(CompilerInstance &CI,
- StringRef pchFile,
- SmallVectorImpl<llvm::MemoryBuffer *> &memBufs,
- SmallVectorImpl<std::string> &bufNames,
- ASTDeserializationListener *deserialListener = 0) {
+static ASTReader *
+createASTReader(CompilerInstance &CI, StringRef pchFile,
+ SmallVectorImpl<llvm::MemoryBuffer *> &memBufs,
+ SmallVectorImpl<std::string> &bufNames,
+ ASTDeserializationListener *deserialListener = nullptr) {
Preprocessor &PP = CI.getPreprocessor();
std::unique_ptr<ASTReader> Reader;
Reader.reset(new ASTReader(PP, CI.getASTContext(), /*isysroot=*/"",
case ASTReader::HadErrors:
break;
}
- return 0;
+ return nullptr;
}
ChainedIncludesSource::~ChainedIncludesSource() {
SmallVector<char, 256> serialAST;
llvm::raw_svector_ostream OS(serialAST);
std::unique_ptr<ASTConsumer> 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();
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();
IntrusiveRefCntPtr<ASTReader> Reader;
Reader = createASTReader(CI, pchName, serialBufs, serialBufNames);
if (!Reader)
- return 0;
+ return nullptr;
source->FinalReader = Reader;
return source;
CompilerInstance::CompilerInstance(bool BuildingModule)
: ModuleLoader(BuildingModule),
- Invocation(new CompilerInvocation()), ModuleManager(0),
+ Invocation(new CompilerInvocation()), ModuleManager(nullptr),
BuildGlobalModuleIndex(false), HaveFullGlobalModuleIndex(false),
ModuleBuildFailed(false) {
}
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());
break;
}
- return 0;
+ return nullptr;
}
// Code Completion
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);
}
}
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);
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
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'
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.
// 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;
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<const IdentifierInfo *, clang::Module *>::iterator Known
if (getPreprocessorOpts().FailedModules)
getPreprocessorOpts().FailedModules->addFailed(ModuleName);
- KnownModules[Path[0].first] = 0;
+ KnownModules[Path[0].first] = nullptr;
ModuleBuildFailed = true;
return ModuleLoadResult();
}
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();
}
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.
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();
}
IntrusiveRefCntPtr<vfs::FileSystem> 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<vfs::FileSystem>();
// 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
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<driver::Command>(*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();
const_cast<const char **>(CCArgs.data()) +
CCArgs.size(),
*Diags))
- return 0;
+ return nullptr;
return CI.release();
}
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.
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))
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);
emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
Diag.getRanges(), Diag.getFixIts(),
Diag.getLocation().isValid() ? &Diag.getLocation().getManager()
- : 0,
+ : nullptr,
&Diag);
}
void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) {
- emitNote(SourceLocation(), Message, 0);
+ emitNote(SourceLocation(), Message, nullptr);
}
} // end anonymous namespace
-FrontendAction::FrontendAction() : Instance(0) {}
+FrontendAction::FrontendAction() : Instance(nullptr) {}
FrontendAction::~FrontendAction() {}
StringRef InFile) {
ASTConsumer* Consumer = CreateASTConsumer(CI, InFile);
if (!Consumer)
- return 0;
+ return nullptr;
if (CI.getFrontendOpts().AddPluginActions.size() == 0)
return Consumer;
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
"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.
// 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;
}
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.
CI.resetAndLeakFileManager();
}
- setCompilerInstance(0);
+ setCompilerInstance(nullptr);
setCurrentInput(FrontendInputFile());
}
CI.createCodeCompletionConsumer();
// Use a code completion consumer?
- CodeCompleteConsumer *CompletionConsumer = 0;
+ CodeCompleteConsumer *CompletionConsumer = nullptr;
if (CI.hasCodeCompletionConsumer())
CompletionConsumer = &CI.getCodeCompletionConsumer();
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,
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,
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);
}
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)
#include "clang/Frontend/LangStandards.def"
.Default(lang_unspecified);
if (K == lang_unspecified)
- return 0;
+ return nullptr;
return &getLangStandardForKind(K);
}
LogDiagnosticPrinter::LogDiagnosticPrinter(raw_ostream &os,
DiagnosticOptions *diags,
bool _OwnsOutputStream)
- : OS(os), LangOpts(0), DiagOpts(diags),
+ : OS(os), LangOpts(nullptr), DiagOpts(diags),
OwnsOutputStream(_OwnsOutputStream) {
}
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);
}
} 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.
struct SharedState;
explicit SDiagsWriter(IntrusiveRefCntPtr<SharedState> 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();
}
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();
EnterDiagBlock();
EmitDiagnosticMessage(SourceLocation(), PresumedLoc(), DiagLevel,
- State->diagBuf, 0, &Info);
+ State->diagBuf, nullptr, &Info);
if (DiagLevel == DiagnosticsEngine::Note)
ExitDiagBlock();
State->OS->write((char *)&State->Buffer.front(), State->Buffer.size());
State->OS->flush();
- State->OS.reset(0);
+ State->OS.reset(nullptr);
}
}
void TextDiagnosticPrinter::EndSourceFile() {
- TextDiag.reset(0);
+ TextDiag.reset(nullptr);
}
/// \brief Print any diagnostic option information to a raw_ostream.
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())
VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() {
assert(!ActiveSourceFiles && "Incomplete parsing of source files!");
assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!");
- SrcManager = 0;
+ SrcManager = nullptr;
CheckDiagnostics();
Diags.takeClient();
if (OwnsPrimaryClient)
// Check diagnostics once last file completed.
CheckDiagnostics();
- CurrentPreprocessor = 0;
- LangOpts = 0;
+ CurrentPreprocessor = nullptr;
+ LangOpts = nullptr;
}
}
{
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) {
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)
// 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;
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;
// 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"));
}