#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
#include <fstream>
#include <string>
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
- CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+ llvm::Expected<CommonOptionsParser> OptionsParser =
+ CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+ llvm::cl::OneOrMore);
+
+ if (!OptionsParser) {
+ llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+ return 1;
+ }
if (!Commands.empty() && !CommandFiles.empty()) {
llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
return 1;
}
- ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+ ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
std::vector<std::unique_ptr<ASTUnit>> ASTs;
int Status = Tool.buildASTs(ASTs);
int ASTStatus = 0;
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
using namespace clang::ast_matchers;
using namespace clang::driver;
int clangTidyMain(int argc, const char **argv) {
llvm::InitLLVM X(argc, argv);
- CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
- cl::ZeroOrMore);
+ llvm::Expected<CommonOptionsParser> OptionsParser =
+ CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+ cl::ZeroOrMore);
+ if (!OptionsParser) {
+ llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+ return 1;
+ }
+
llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> BaseFS(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
StringRef FileName("dummy");
- auto PathList = OptionsParser.getSourcePathList();
+ auto PathList = OptionsParser->getSourcePathList();
if (!PathList.empty()) {
FileName = PathList.front();
}
ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
std::vector<ClangTidyError> Errors =
- runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+ runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;