ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n";
}
ErrorMessage = ErrorStream.str();
- return NULL;
+ return nullptr;
}
static CompilationDatabase *
Directory = llvm::sys::path::parent_path(Directory);
}
ErrorMessage = ErrorStream.str();
- return NULL;
+ return nullptr;
}
CompilationDatabase *
// options.
class UnusedInputDiagConsumer : public DiagnosticConsumer {
public:
- UnusedInputDiagConsumer() : Other(0) {}
+ UnusedInputDiagConsumer() : Other(nullptr) {}
// Useful for debugging, chain diagnostics to another consumer after
// recording for our own purposes.
Twine Directory) {
const char **DoubleDash = std::find(Argv, Argv + Argc, StringRef("--"));
if (DoubleDash == Argv + Argc)
- return NULL;
+ return nullptr;
std::vector<const char *> CommandLine(DoubleDash + 1, Argv + Argc);
Argc = DoubleDash - Argv;
std::vector<std::string> StrippedArgs;
if (!stripPositionalArgs(CommandLine, StrippedArgs))
- return 0;
+ return nullptr;
return new FixedCompilationDatabase(Directory, StrippedArgs);
}
std::unique_ptr<CompilationDatabase> Database(
JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage));
if (!Database)
- return NULL;
+ return nullptr;
return Database.release();
}
};
std::unique_ptr<llvm::MemoryBuffer> DatabaseBuffer;
llvm::error_code Result =
llvm::MemoryBuffer::getFile(FilePath, DatabaseBuffer);
- if (Result != 0) {
+ if (Result != nullptr) {
ErrorMessage = "Error while opening JSON database: " + Result.message();
- return NULL;
+ return nullptr;
}
std::unique_ptr<JSONCompilationDatabase> Database(
new JSONCompilationDatabase(DatabaseBuffer.release()));
if (!Database->parse(ErrorMessage))
- return NULL;
+ return nullptr;
return Database.release();
}
std::unique_ptr<JSONCompilationDatabase> Database(
new JSONCompilationDatabase(DatabaseBuffer.release()));
if (!Database->parse(ErrorMessage))
- return NULL;
+ return nullptr;
return Database.release();
}
return false;
}
llvm::yaml::Node *Root = I->getRoot();
- if (Root == NULL) {
+ if (!Root) {
ErrorMessage = "Error while parsing YAML.";
return false;
}
llvm::yaml::SequenceNode *Array = dyn_cast<llvm::yaml::SequenceNode>(Root);
- if (Array == NULL) {
+ if (!Array) {
ErrorMessage = "Expected array.";
return false;
}
AE = Array->end();
AI != AE; ++AI) {
llvm::yaml::MappingNode *Object = dyn_cast<llvm::yaml::MappingNode>(&*AI);
- if (Object == NULL) {
+ if (!Object) {
ErrorMessage = "Expected object.";
return false;
}
- llvm::yaml::ScalarNode *Directory = NULL;
- llvm::yaml::ScalarNode *Command = NULL;
- llvm::yaml::ScalarNode *File = NULL;
+ llvm::yaml::ScalarNode *Directory = nullptr;
+ llvm::yaml::ScalarNode *Command = nullptr;
+ llvm::yaml::ScalarNode *File = nullptr;
for (llvm::yaml::MappingNode::iterator KVI = Object->begin(),
KVE = Object->end();
KVI != KVE; ++KVI) {
llvm::yaml::Node *Value = (*KVI).getValue();
- if (Value == NULL) {
+ if (!Value) {
ErrorMessage = "Expected value.";
return false;
}
llvm::yaml::ScalarNode *ValueString =
dyn_cast<llvm::yaml::ScalarNode>(Value);
- if (ValueString == NULL) {
+ if (!ValueString) {
ErrorMessage = "Expected string as value.";
return false;
}
llvm::yaml::ScalarNode *KeyString =
dyn_cast<llvm::yaml::ScalarNode>((*KVI).getKey());
- if (KeyString == NULL) {
+ if (!KeyString) {
ErrorMessage = "Expected strings as key.";
return false;
}
bool Replacement::apply(Rewriter &Rewrite) const {
SourceManager &SM = Rewrite.getSourceMgr();
const FileEntry *Entry = SM.getFileManager().getFile(FilePath);
- if (Entry == NULL)
+ if (!Entry)
return false;
FileID ID;
// FIXME: Use SM.translateFile directly.
const std::pair<FileID, unsigned> DecomposedLocation =
Sources.getDecomposedLoc(Start);
const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
- if (Entry != NULL) {
+ if (Entry) {
// Make FilePath absolute so replacements can be applied correctly when
// relative paths for files are used.
llvm::SmallString<256> FilePath(Entry->getName());
Jobs.Print(error_stream, "; ", true);
Diagnostics->Report(clang::diag::err_fe_expected_compiler_job)
<< error_stream.str();
- return NULL;
+ return nullptr;
}
// The one job we find should be to invoke clang again.
cast<clang::driver::Command>(*Jobs.begin());
if (StringRef(Cmd->getCreator().getName()) != "clang") {
Diagnostics->Report(clang::diag::err_fe_expected_clang_command);
- return NULL;
+ return nullptr;
}
return &Cmd->getArguments();
Action(Action),
OwnsAction(false),
Files(Files),
- DiagConsumer(NULL) {}
+ DiagConsumer(nullptr) {}
ToolInvocation::ToolInvocation(std::vector<std::string> CommandLine,
FrontendAction *FAction, FileManager *Files)
Action(new SingleFrontendActionFactory(FAction)),
OwnsAction(true),
Files(Files),
- DiagConsumer(NULL) {}
+ DiagConsumer(nullptr) {}
ToolInvocation::~ToolInvocation() {
if (OwnsAction)
Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
&Diagnostics, Compilation.get());
- if (CC1Args == NULL) {
+ if (!CC1Args) {
return false;
}
std::unique_ptr<clang::CompilerInvocation> Invocation(
ClangTool::ClangTool(const CompilationDatabase &Compilations,
ArrayRef<std::string> SourcePaths)
- : Files(new FileManager(FileSystemOptions())), DiagConsumer(NULL) {
+ : Files(new FileManager(FileSystemOptions())), DiagConsumer(nullptr) {
ArgsAdjusters.push_back(new ClangStripOutputAdjuster());
ArgsAdjusters.push_back(new ClangSyntaxOnlyAdjuster());
for (const auto &SourcePath : SourcePaths) {
std::vector<std::unique_ptr<ASTUnit>> ASTs;
ASTBuilderAction Action(ASTs);
- ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef), &Action, 0);
+ ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef), &Action,
+ nullptr);
SmallString<1024> CodeStorage;
Invocation.mapVirtualFile(FileNameRef,
Code.toNullTerminatedStringRef(CodeStorage));
if (!Invocation.run())
- return 0;
+ return nullptr;
assert(ASTs.size() == 1);
return std::move(ASTs[0]);