From 7376d9eb38914ff7b6b5f5901d32743f0ee76b5a Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Fri, 6 Dec 2019 12:29:31 -0500 Subject: [NFC] Separate getLastArgIntValue to Basic getLastArgIntValue is a useful utility function to get command line argument as an integer. Currently it is in Frontend so that it can only be used by clang -cc1. Move it to basic so that it can also be used by clang driver. Differential Revision: https://reviews.llvm.org/D71080 --- clang/lib/Frontend/CompilerInvocation.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 93193ed..289c58e 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3716,35 +3716,8 @@ std::string CompilerInvocation::getModuleHash() const { return llvm::APInt(64, code).toString(36, /*Signed=*/false); } -template -static IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id, - IntTy Default, - DiagnosticsEngine *Diags) { - IntTy Res = Default; - if (Arg *A = Args.getLastArg(Id)) { - if (StringRef(A->getValue()).getAsInteger(10, Res)) { - if (Diags) - Diags->Report(diag::err_drv_invalid_int_value) << A->getAsString(Args) - << A->getValue(); - } - } - return Res; -} - namespace clang { -// Declared in clang/Frontend/Utils.h. -int getLastArgIntValue(const ArgList &Args, OptSpecifier Id, int Default, - DiagnosticsEngine *Diags) { - return getLastArgIntValueImpl(Args, Id, Default, Diags); -} - -uint64_t getLastArgUInt64Value(const ArgList &Args, OptSpecifier Id, - uint64_t Default, - DiagnosticsEngine *Diags) { - return getLastArgIntValueImpl(Args, Id, Default, Diags); -} - IntrusiveRefCntPtr createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags) { -- cgit v1.1