1 //===--- Driver.h - Clang GCC Compatible Driver -----------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_DRIVER_DRIVER_H 10 #define LLVM_CLANG_DRIVER_DRIVER_H 11 12 #include "clang/Basic/Diagnostic.h" 13 #include "clang/Basic/LLVM.h" 14 #include "clang/Driver/Action.h" 15 #include "clang/Driver/Options.h" 16 #include "clang/Driver/Phases.h" 17 #include "clang/Driver/ToolChain.h" 18 #include "clang/Driver/Types.h" 19 #include "clang/Driver/Util.h" 20 #include "llvm/ADT/StringMap.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "llvm/Option/Arg.h" 23 #include "llvm/Option/ArgList.h" 24 #include "llvm/Support/StringSaver.h" 25 26 #include <list> 27 #include <map> 28 #include <string> 29 30 namespace llvm { 31 class Triple; 32 namespace vfs { 33 class FileSystem; 34 } 35 } // namespace llvm 36 37 namespace clang { 38 39 namespace driver { 40 41 class Command; 42 class Compilation; 43 class InputInfo; 44 class JobList; 45 class JobAction; 46 class SanitizerArgs; 47 class ToolChain; 48 49 /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options. 50 enum LTOKind { 51 LTOK_None, 52 LTOK_Full, 53 LTOK_Thin, 54 LTOK_Unknown 55 }; 56 57 /// Driver - Encapsulate logic for constructing compilation processes 58 /// from a set of gcc-driver-like command line arguments. 59 class Driver { 60 DiagnosticsEngine &Diags; 61 62 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS; 63 64 enum DriverMode { 65 GCCMode, 66 GXXMode, 67 CPPMode, 68 CLMode, 69 FlangMode 70 } Mode; 71 72 enum SaveTempsMode { 73 SaveTempsNone, 74 SaveTempsCwd, 75 SaveTempsObj 76 } SaveTemps; 77 78 enum BitcodeEmbedMode { 79 EmbedNone, 80 EmbedMarker, 81 EmbedBitcode 82 } BitcodeEmbed; 83 84 /// LTO mode selected via -f(no-)?lto(=.*)? options. 85 LTOKind LTOMode; 86 87 public: 88 enum OpenMPRuntimeKind { 89 /// An unknown OpenMP runtime. We can't generate effective OpenMP code 90 /// without knowing what runtime to target. 91 OMPRT_Unknown, 92 93 /// The LLVM OpenMP runtime. When completed and integrated, this will become 94 /// the default for Clang. 95 OMPRT_OMP, 96 97 /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for 98 /// this runtime but can swallow the pragmas, and find and link against the 99 /// runtime library itself. 100 OMPRT_GOMP, 101 102 /// The legacy name for the LLVM OpenMP runtime from when it was the Intel 103 /// OpenMP runtime. We support this mode for users with existing 104 /// dependencies on this runtime library name. 105 OMPRT_IOMP5 106 }; 107 108 // Diag - Forwarding function for diagnostics. Diag(unsigned DiagID)109 DiagnosticBuilder Diag(unsigned DiagID) const { 110 return Diags.Report(DiagID); 111 } 112 113 // FIXME: Privatize once interface is stable. 114 public: 115 /// The name the driver was invoked as. 116 std::string Name; 117 118 /// The path the driver executable was in, as invoked from the 119 /// command line. 120 std::string Dir; 121 122 /// The original path to the clang executable. 123 std::string ClangExecutable; 124 125 /// Target and driver mode components extracted from clang executable name. 126 ParsedClangName ClangNameParts; 127 128 /// The path to the installed clang directory, if any. 129 std::string InstalledDir; 130 131 /// The path to the compiler resource directory. 132 std::string ResourceDir; 133 134 /// System directory for config files. 135 std::string SystemConfigDir; 136 137 /// User directory for config files. 138 std::string UserConfigDir; 139 140 /// A prefix directory used to emulate a limited subset of GCC's '-Bprefix' 141 /// functionality. 142 /// FIXME: This type of customization should be removed in favor of the 143 /// universal driver when it is ready. 144 typedef SmallVector<std::string, 4> prefix_list; 145 prefix_list PrefixDirs; 146 147 /// sysroot, if present 148 std::string SysRoot; 149 150 /// Dynamic loader prefix, if present 151 std::string DyldPrefix; 152 153 /// Driver title to use with help. 154 std::string DriverTitle; 155 156 /// Information about the host which can be overridden by the user. 157 std::string HostBits, HostMachine, HostSystem, HostRelease; 158 159 /// The file to log CC_PRINT_OPTIONS output to, if enabled. 160 const char *CCPrintOptionsFilename; 161 162 /// The file to log CC_PRINT_HEADERS output to, if enabled. 163 const char *CCPrintHeadersFilename; 164 165 /// The file to log CC_LOG_DIAGNOSTICS output to, if enabled. 166 const char *CCLogDiagnosticsFilename; 167 168 /// A list of inputs and their types for the given arguments. 169 typedef SmallVector<std::pair<types::ID, const llvm::opt::Arg *>, 16> 170 InputList; 171 172 /// Whether the driver should follow g++ like behavior. CCCIsCXX()173 bool CCCIsCXX() const { return Mode == GXXMode; } 174 175 /// Whether the driver is just the preprocessor. CCCIsCPP()176 bool CCCIsCPP() const { return Mode == CPPMode; } 177 178 /// Whether the driver should follow gcc like behavior. CCCIsCC()179 bool CCCIsCC() const { return Mode == GCCMode; } 180 181 /// Whether the driver should follow cl.exe like behavior. IsCLMode()182 bool IsCLMode() const { return Mode == CLMode; } 183 184 /// Whether the driver should invoke flang for fortran inputs. 185 /// Other modes fall back to calling gcc which in turn calls gfortran. IsFlangMode()186 bool IsFlangMode() const { return Mode == FlangMode; } 187 188 /// Only print tool bindings, don't build any jobs. 189 unsigned CCCPrintBindings : 1; 190 191 /// Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to 192 /// CCPrintOptionsFilename or to stderr. 193 unsigned CCPrintOptions : 1; 194 195 /// Set CC_PRINT_HEADERS mode, which causes the frontend to log header include 196 /// information to CCPrintHeadersFilename or to stderr. 197 unsigned CCPrintHeaders : 1; 198 199 /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics 200 /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable 201 /// format. 202 unsigned CCLogDiagnostics : 1; 203 204 /// Whether the driver is generating diagnostics for debugging purposes. 205 unsigned CCGenDiagnostics : 1; 206 207 /// Pointer to the ExecuteCC1Tool function, if available. 208 /// When the clangDriver lib is used through clang.exe, this provides a 209 /// shortcut for executing the -cc1 command-line directly, in the same 210 /// process. 211 typedef int (*CC1ToolFunc)(SmallVectorImpl<const char *> &ArgV); 212 CC1ToolFunc CC1Main = nullptr; 213 214 private: 215 /// Raw target triple. 216 std::string TargetTriple; 217 218 /// Name to use when invoking gcc/g++. 219 std::string CCCGenericGCCName; 220 221 /// Name of configuration file if used. 222 std::string ConfigFile; 223 224 /// Allocator for string saver. 225 llvm::BumpPtrAllocator Alloc; 226 227 /// Object that stores strings read from configuration file. 228 llvm::StringSaver Saver; 229 230 /// Arguments originated from configuration file. 231 std::unique_ptr<llvm::opt::InputArgList> CfgOptions; 232 233 /// Arguments originated from command line. 234 std::unique_ptr<llvm::opt::InputArgList> CLOptions; 235 236 /// Whether to check that input files exist when constructing compilation 237 /// jobs. 238 unsigned CheckInputsExist : 1; 239 240 public: 241 /// Force clang to emit reproducer for driver invocation. This is enabled 242 /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable 243 /// or when using the -gen-reproducer driver flag. 244 unsigned GenReproducer : 1; 245 246 private: 247 /// Certain options suppress the 'no input files' warning. 248 unsigned SuppressMissingInputWarning : 1; 249 250 /// Cache of all the ToolChains in use by the driver. 251 /// 252 /// This maps from the string representation of a triple to a ToolChain 253 /// created targeting that triple. The driver owns all the ToolChain objects 254 /// stored in it, and will clean them up when torn down. 255 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains; 256 257 private: 258 /// TranslateInputArgs - Create a new derived argument list from the input 259 /// arguments, after applying the standard argument translations. 260 llvm::opt::DerivedArgList * 261 TranslateInputArgs(const llvm::opt::InputArgList &Args) const; 262 263 // getFinalPhase - Determine which compilation mode we are in and record 264 // which option we used to determine the final phase. 265 // TODO: Much of what getFinalPhase returns are not actually true compiler 266 // modes. Fold this functionality into Types::getCompilationPhases and 267 // handleArguments. 268 phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, 269 llvm::opt::Arg **FinalPhaseArg = nullptr) const; 270 271 // handleArguments - All code related to claiming and printing diagnostics 272 // related to arguments to the driver are done here. 273 void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args, 274 const InputList &Inputs, ActionList &Actions) const; 275 276 // Before executing jobs, sets up response files for commands that need them. 277 void setUpResponseFiles(Compilation &C, Command &Cmd); 278 279 void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC, 280 SmallVectorImpl<std::string> &Names) const; 281 282 /// Find the appropriate .crash diagonostic file for the child crash 283 /// under this driver and copy it out to a temporary destination with the 284 /// other reproducer related files (.sh, .cache, etc). If not found, suggest a 285 /// directory for the user to look at. 286 /// 287 /// \param ReproCrashFilename The file path to copy the .crash to. 288 /// \param CrashDiagDir The suggested directory for the user to look at 289 /// in case the search or copy fails. 290 /// 291 /// \returns If the .crash is found and successfully copied return true, 292 /// otherwise false and return the suggested directory in \p CrashDiagDir. 293 bool getCrashDiagnosticFile(StringRef ReproCrashFilename, 294 SmallString<128> &CrashDiagDir); 295 296 public: 297 298 /// Takes the path to a binary that's either in bin/ or lib/ and returns 299 /// the path to clang's resource directory. 300 static std::string GetResourcesPath(StringRef BinaryPath, 301 StringRef CustomResourceDir = ""); 302 303 Driver(StringRef ClangExecutable, StringRef TargetTriple, 304 DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler", 305 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr); 306 307 /// @name Accessors 308 /// @{ 309 310 /// Name to use when invoking gcc/g++. getCCCGenericGCCName()311 const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; } 312 getConfigFile()313 const std::string &getConfigFile() const { return ConfigFile; } 314 getOpts()315 const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); } 316 getDiags()317 DiagnosticsEngine &getDiags() const { return Diags; } 318 getVFS()319 llvm::vfs::FileSystem &getVFS() const { return *VFS; } 320 getCheckInputsExist()321 bool getCheckInputsExist() const { return CheckInputsExist; } 322 setCheckInputsExist(bool Value)323 void setCheckInputsExist(bool Value) { CheckInputsExist = Value; } 324 setTargetAndMode(const ParsedClangName & TM)325 void setTargetAndMode(const ParsedClangName &TM) { ClangNameParts = TM; } 326 getTitle()327 const std::string &getTitle() { return DriverTitle; } setTitle(std::string Value)328 void setTitle(std::string Value) { DriverTitle = std::move(Value); } 329 getTargetTriple()330 std::string getTargetTriple() const { return TargetTriple; } 331 332 /// Get the path to the main clang executable. getClangProgramPath()333 const char *getClangProgramPath() const { 334 return ClangExecutable.c_str(); 335 } 336 337 /// Get the path to where the clang executable was installed. getInstalledDir()338 const char *getInstalledDir() const { 339 if (!InstalledDir.empty()) 340 return InstalledDir.c_str(); 341 return Dir.c_str(); 342 } setInstalledDir(StringRef Value)343 void setInstalledDir(StringRef Value) { InstalledDir = std::string(Value); } 344 isSaveTempsEnabled()345 bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; } isSaveTempsObj()346 bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; } 347 embedBitcodeEnabled()348 bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; } embedBitcodeInObject()349 bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); } embedBitcodeMarkerOnly()350 bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); } 351 352 /// Compute the desired OpenMP runtime from the flags provided. 353 OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; 354 355 /// @} 356 /// @name Primary Functionality 357 /// @{ 358 359 /// CreateOffloadingDeviceToolChains - create all the toolchains required to 360 /// support offloading devices given the programming models specified in the 361 /// current compilation. Also, update the host tool chain kind accordingly. 362 void CreateOffloadingDeviceToolChains(Compilation &C, InputList &Inputs); 363 364 /// BuildCompilation - Construct a compilation object for a command 365 /// line argument vector. 366 /// 367 /// \return A compilation, or 0 if none was built for the given 368 /// argument vector. A null return value does not necessarily 369 /// indicate an error condition, the diagnostics should be queried 370 /// to determine if an error occurred. 371 Compilation *BuildCompilation(ArrayRef<const char *> Args); 372 373 /// @name Driver Steps 374 /// @{ 375 376 /// ParseDriverMode - Look for and handle the driver mode option in Args. 377 void ParseDriverMode(StringRef ProgramName, ArrayRef<const char *> Args); 378 379 /// ParseArgStrings - Parse the given list of strings into an 380 /// ArgList. 381 llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args, 382 bool IsClCompatMode, 383 bool &ContainsError); 384 385 /// BuildInputs - Construct the list of inputs and their types from 386 /// the given arguments. 387 /// 388 /// \param TC - The default host tool chain. 389 /// \param Args - The input arguments. 390 /// \param Inputs - The list to store the resulting compilation 391 /// inputs onto. 392 void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args, 393 InputList &Inputs) const; 394 395 /// BuildActions - Construct the list of actions to perform for the 396 /// given arguments, which are only done for a single architecture. 397 /// 398 /// \param C - The compilation that is being built. 399 /// \param Args - The input arguments. 400 /// \param Actions - The list to store the resulting actions onto. 401 void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args, 402 const InputList &Inputs, ActionList &Actions) const; 403 404 /// BuildUniversalActions - Construct the list of actions to perform 405 /// for the given arguments, which may require a universal build. 406 /// 407 /// \param C - The compilation that is being built. 408 /// \param TC - The default host tool chain. 409 void BuildUniversalActions(Compilation &C, const ToolChain &TC, 410 const InputList &BAInputs) const; 411 412 /// Check that the file referenced by Value exists. If it doesn't, 413 /// issue a diagnostic and return false. 414 /// If TypoCorrect is true and the file does not exist, see if it looks 415 /// like a likely typo for a flag and if so print a "did you mean" blurb. 416 bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args, 417 StringRef Value, types::ID Ty, 418 bool TypoCorrect) const; 419 420 /// BuildJobs - Bind actions to concrete tools and translate 421 /// arguments to form the list of jobs to run. 422 /// 423 /// \param C - The compilation that is being built. 424 void BuildJobs(Compilation &C) const; 425 426 /// ExecuteCompilation - Execute the compilation according to the command line 427 /// arguments and return an appropriate exit code. 428 /// 429 /// This routine handles additional processing that must be done in addition 430 /// to just running the subprocesses, for example reporting errors, setting 431 /// up response files, removing temporary files, etc. 432 int ExecuteCompilation(Compilation &C, 433 SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands); 434 435 /// Contains the files in the compilation diagnostic report generated by 436 /// generateCompilationDiagnostics. 437 struct CompilationDiagnosticReport { 438 llvm::SmallVector<std::string, 4> TemporaryFiles; 439 }; 440 441 /// generateCompilationDiagnostics - Generate diagnostics information 442 /// including preprocessed source file(s). 443 /// 444 void generateCompilationDiagnostics( 445 Compilation &C, const Command &FailingCommand, 446 StringRef AdditionalInformation = "", 447 CompilationDiagnosticReport *GeneratedReport = nullptr); 448 449 /// @} 450 /// @name Helper Methods 451 /// @{ 452 453 /// PrintActions - Print the list of actions. 454 void PrintActions(const Compilation &C) const; 455 456 /// PrintHelp - Print the help text. 457 /// 458 /// \param ShowHidden - Show hidden options. 459 void PrintHelp(bool ShowHidden) const; 460 461 /// PrintVersion - Print the driver version. 462 void PrintVersion(const Compilation &C, raw_ostream &OS) const; 463 464 /// GetFilePath - Lookup \p Name in the list of file search paths. 465 /// 466 /// \param TC - The tool chain for additional information on 467 /// directories to search. 468 // 469 // FIXME: This should be in CompilationInfo. 470 std::string GetFilePath(StringRef Name, const ToolChain &TC) const; 471 472 /// GetProgramPath - Lookup \p Name in the list of program search paths. 473 /// 474 /// \param TC - The provided tool chain for additional information on 475 /// directories to search. 476 // 477 // FIXME: This should be in CompilationInfo. 478 std::string GetProgramPath(StringRef Name, const ToolChain &TC) const; 479 480 /// HandleAutocompletions - Handle --autocomplete by searching and printing 481 /// possible flags, descriptions, and its arguments. 482 void HandleAutocompletions(StringRef PassedFlags) const; 483 484 /// HandleImmediateArgs - Handle any arguments which should be 485 /// treated before building actions or binding tools. 486 /// 487 /// \return Whether any compilation should be built for this 488 /// invocation. 489 bool HandleImmediateArgs(const Compilation &C); 490 491 /// ConstructAction - Construct the appropriate action to do for 492 /// \p Phase on the \p Input, taking in to account arguments 493 /// like -fsyntax-only or --analyze. 494 Action *ConstructPhaseAction( 495 Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase, 496 Action *Input, 497 Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const; 498 499 /// BuildJobsForAction - Construct the jobs to perform for the action \p A and 500 /// return an InputInfo for the result of running \p A. Will only construct 501 /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once. 502 InputInfo 503 BuildJobsForAction(Compilation &C, const Action *A, const ToolChain *TC, 504 StringRef BoundArch, bool AtTopLevel, bool MultipleArchs, 505 const char *LinkingOutput, 506 std::map<std::pair<const Action *, std::string>, InputInfo> 507 &CachedResults, 508 Action::OffloadKind TargetDeviceOffloadKind) const; 509 510 /// Returns the default name for linked images (e.g., "a.out"). 511 const char *getDefaultImageName() const; 512 513 /// GetNamedOutputPath - Return the name to use for the output of 514 /// the action \p JA. The result is appended to the compilation's 515 /// list of temporary or result files, as appropriate. 516 /// 517 /// \param C - The compilation. 518 /// \param JA - The action of interest. 519 /// \param BaseInput - The original input file that this action was 520 /// triggered by. 521 /// \param BoundArch - The bound architecture. 522 /// \param AtTopLevel - Whether this is a "top-level" action. 523 /// \param MultipleArchs - Whether multiple -arch options were supplied. 524 /// \param NormalizedTriple - The normalized triple of the relevant target. 525 const char *GetNamedOutputPath(Compilation &C, const JobAction &JA, 526 const char *BaseInput, StringRef BoundArch, 527 bool AtTopLevel, bool MultipleArchs, 528 StringRef NormalizedTriple) const; 529 530 /// GetTemporaryPath - Return the pathname of a temporary file to use 531 /// as part of compilation; the file will have the given prefix and suffix. 532 /// 533 /// GCC goes to extra lengths here to be a bit more robust. 534 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const; 535 536 /// GetTemporaryDirectory - Return the pathname of a temporary directory to 537 /// use as part of compilation; the directory will have the given prefix. 538 std::string GetTemporaryDirectory(StringRef Prefix) const; 539 540 /// Return the pathname of the pch file in clang-cl mode. 541 std::string GetClPchPath(Compilation &C, StringRef BaseName) const; 542 543 /// ShouldUseClangCompiler - Should the clang compiler be used to 544 /// handle this action. 545 bool ShouldUseClangCompiler(const JobAction &JA) const; 546 547 /// ShouldUseFlangCompiler - Should the flang compiler be used to 548 /// handle this action. 549 bool ShouldUseFlangCompiler(const JobAction &JA) const; 550 551 /// ShouldEmitStaticLibrary - Should the linker emit a static library. 552 bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const; 553 554 /// Returns true if we are performing any kind of LTO. isUsingLTO()555 bool isUsingLTO() const { return LTOMode != LTOK_None; } 556 557 /// Get the specific kind of LTO being performed. getLTOMode()558 LTOKind getLTOMode() const { return LTOMode; } 559 560 private: 561 562 /// Tries to load options from configuration file. 563 /// 564 /// \returns true if error occurred. 565 bool loadConfigFile(); 566 567 /// Read options from the specified file. 568 /// 569 /// \param [in] FileName File to read. 570 /// \returns true, if error occurred while reading. 571 bool readConfigFile(StringRef FileName); 572 573 /// Set the driver mode (cl, gcc, etc) from an option string of the form 574 /// --driver-mode=<mode>. 575 void setDriverModeFromOption(StringRef Opt); 576 577 /// Parse the \p Args list for LTO options and record the type of LTO 578 /// compilation based on which -f(no-)?lto(=.*)? option occurs last. 579 void setLTOMode(const llvm::opt::ArgList &Args); 580 581 /// Retrieves a ToolChain for a particular \p Target triple. 582 /// 583 /// Will cache ToolChains for the life of the driver object, and create them 584 /// on-demand. 585 const ToolChain &getToolChain(const llvm::opt::ArgList &Args, 586 const llvm::Triple &Target) const; 587 588 /// @} 589 590 /// Get bitmasks for which option flags to include and exclude based on 591 /// the driver mode. 592 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const; 593 594 /// Helper used in BuildJobsForAction. Doesn't use the cache when building 595 /// jobs specifically for the given action, but will use the cache when 596 /// building jobs for the Action's inputs. 597 InputInfo BuildJobsForActionNoCache( 598 Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch, 599 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput, 600 std::map<std::pair<const Action *, std::string>, InputInfo> 601 &CachedResults, 602 Action::OffloadKind TargetDeviceOffloadKind) const; 603 604 public: 605 /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and 606 /// return the grouped values as integers. Numbers which are not 607 /// provided are set to 0. 608 /// 609 /// \return True if the entire string was parsed (9.2), or all 610 /// groups were parsed (10.3.5extrastuff). HadExtra is true if all 611 /// groups were parsed but extra characters remain at the end. 612 static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, 613 unsigned &Micro, bool &HadExtra); 614 615 /// Parse digits from a string \p Str and fulfill \p Digits with 616 /// the parsed numbers. This method assumes that the max number of 617 /// digits to look for is equal to Digits.size(). 618 /// 619 /// \return True if the entire string was parsed and there are 620 /// no extra characters remaining at the end. 621 static bool GetReleaseVersion(StringRef Str, 622 MutableArrayRef<unsigned> Digits); 623 /// Compute the default -fmodule-cache-path. 624 /// \return True if the system provides a default cache directory. 625 static bool getDefaultModuleCachePath(SmallVectorImpl<char> &Result); 626 }; 627 628 /// \return True if the last defined optimization level is -Ofast. 629 /// And False otherwise. 630 bool isOptimizationLevelFast(const llvm::opt::ArgList &Args); 631 632 /// \return True if the argument combination will end up generating remarks. 633 bool willEmitRemarks(const llvm::opt::ArgList &Args); 634 635 } // end namespace driver 636 } // end namespace clang 637 638 #endif 639