clang: include/clang/Driver/ToolChain.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H

10#define LLVM_CLANG_DRIVER_TOOLCHAIN_H

11

18#include "llvm/ADT/APFloat.h"

19#include "llvm/ADT/ArrayRef.h"

20#include "llvm/ADT/FloatingPointMode.h"

21#include "llvm/ADT/SmallVector.h"

22#include "llvm/ADT/StringRef.h"

23#include "llvm/Frontend/Debug/Options.h"

24#include "llvm/MC/MCTargetOptions.h"

25#include "llvm/Option/Option.h"

26#include "llvm/Support/VersionTuple.h"

27#include "llvm/Target/TargetOptions.h"

28#include "llvm/TargetParser/Triple.h"

29#include

30#include

31#include

32#include

33#include

34#include

35

36namespace llvm {

37namespace opt {

38

39class Arg;

40class ArgList;

41class DerivedArgList;

42

43}

44namespace vfs {

45

46class FileSystem;

47

48}

49}

50

52

53class ObjCRuntime;

54

55namespace driver {

56

58class InputInfo;

59class SanitizerArgs;

60class Tool;

61class XRayArgs;

62

63

64

66

68

69

71

72

74

75

77

82 bool IsRegistered)

85

88 }

89};

90

91

93public:

95

100

105

111

116 };

117

121 };

122

126 };

127

133 };

134

136

137private:

139

141 llvm::Triple Triple;

142 const llvm::opt::ArgList &Args;

143

144

145 const llvm::opt::Arg *const CachedRTTIArg;

146

147 const RTTIMode CachedRTTIMode;

148

150

151

153

154

156

157

159

160 mutable std::unique_ptr Clang;

161 mutable std::unique_ptr Flang;

162 mutable std::unique_ptr Assemble;

163 mutable std::unique_ptr Link;

164 mutable std::unique_ptr StaticLibTool;

165 mutable std::unique_ptr IfsMerge;

167 mutable std::unique_ptr OffloadPackager;

168 mutable std::unique_ptr LinkerWrapper;

169

170 Tool *getClang() const;

171 Tool *getFlang() const;

172 Tool *getAssemble() const;

173 Tool *getLink() const;

174 Tool *getStaticLibTool() const;

175 Tool *getIfsMerge() const;

176 Tool *getClangAs() const;

177 Tool *getOffloadBundler() const;

178 Tool *getOffloadPackager() const;

179 Tool *getLinkerWrapper() const;

180

181 mutable bool SanitizerArgsChecked = false;

182 mutable std::unique_ptr XRayArguments;

183

184

185 mutable llvm::Triple EffectiveTriple;

186

187

188 void setEffectiveTriple(llvm::Triple ET) const {

189 EffectiveTriple = std::move(ET);

190 }

191

192 std::optionalstd::string

193 getFallbackAndroidTargetPath(StringRef BaseDir) const;

194

195 mutable std::optional cxxStdlibType;

196 mutable std::optional runtimeLibType;

197 mutable std::optional unwindLibType;

198

199protected:

202

204 const llvm::opt::ArgList &Args);

205

206

209

211

216

218 StringRef Component,

220 bool AddArch) const;

221

222

223

224

226

227

228

229 static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,

230 llvm::opt::ArgStringList &CC1Args,

231 const Twine &Path);

233 llvm::opt::ArgStringList &CC1Args,

234 const Twine &Path);

235 static void

237 llvm::opt::ArgStringList &CC1Args,

238 const Twine &Path);

239 static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,

240 llvm::opt::ArgStringList &CC1Args,

242

243 static std::string concat(StringRef Path, const Twine &A, const Twine &B = "",

244 const Twine &C = "", const Twine &D = "");

245

246

247public:

249

250

251

253 llvm::vfs::FileSystem &getVFS() const;

254 const llvm::Triple &getTriple() const { return Triple; }

255

256

257

258

259

260

261 virtual const llvm::Triple *getAuxTriple() const { return nullptr; }

262

263

264

265

267

268 llvm::Triple::ArchType getArch() const { return Triple.getArch(); }

269 StringRef getArchName() const { return Triple.getArchName(); }

270 StringRef getPlatform() const { return Triple.getVendorName(); }

271 StringRef getOS() const { return Triple.getOSName(); }

272

273

274

276

278 return Triple.getTriple();

279 }

280

281

283 assert(!EffectiveTriple.getTriple().empty() && "No effective triple");

284 return EffectiveTriple;

285 }

286

288 return !EffectiveTriple.getTriple().empty();

289 }

290

293

296

299

301

304 }

305

306

307

308

309

310

311

312

313

314

315

317

319

321

322

323 const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; }

324

325

327

328

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

346

347

348

349

350

351

352

353

354

355

356

357 virtual llvm::opt::DerivedArgList *

358 TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,

360 return nullptr;

361 }

362

363

364

365

367 const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,

369

370

371

372

374 const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,

375 llvm::opt::DerivedArgList *DAL,

377

378

379

380

381 virtual llvm::opt::DerivedArgList *

382 TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,

385

386

387

388

389

391

392

393

394 std::string GetFilePath(const char *Name) const;

396

397

398

399

400

401

402

403 std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const;

404

405

407

408

409

410

411

412

414

415

416

417

418

420

421

422

424

425

426

428

429

431

432

433

435

436

437

439

440

441

443

444

445

447

448

450

451

453

454

455

457

458

460

461

462

464

465

466

468

469

470

472

473

475

476

478

479

480

484 }

485

486

490 }

491

492

494

495

498 }

499

502 }

503

506 }

507

509

510 virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,

511 StringRef Component,

513

514 const char *

517

519 StringRef Component,

521

522

524

525

526 std::optionalstd::string getStdlibPath() const;

527

528

530

531

532

534

535

537

538

539 static bool needsProfileRT(const llvm::opt::ArgList &Args);

540

541

543

544

547

548

549 virtual bool

551 return false;

552 }

553

554

556

557

558 virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const = 0;

559

560

561

562

563

565

566

568

569

571

572

574 return llvm::codegenoptions::DIF_DWARF;

575 }

576

577

578

580

581

583

584

585

587

588

589

590

592

593

594

595

596

598

599

601 return llvm::DebuggerKind::GDB;

602 }

603

604

606 return true;

607 }

608

609

610 virtual void

612 const llvm::opt::ArgList &Args) const {}

613

614

615 virtual llvm::ExceptionHandling

617

618

620

621

623

624

626

627

629

631 const llvm::Triple &TargetTriple,

632 StringRef SysRoot) const {

633 return TargetTriple.str();

634 }

635

636

637

638 virtual std::string

641

642

643

644

645

646

648 const llvm::opt::ArgList &Args,

650

651

652

653

654

656

657

658

659

660

661

663

664

665

667

668

669

670

671

672 virtual void

674 llvm::opt::ArgStringList &CC1Args) const;

675

676

678 llvm::opt::ArgStringList &CC1Args,

680

681

682 virtual void

684 llvm::opt::ArgStringList &CC1ASArgs) const;

685

686

688

689

690

693 return {};

694 };

695

696

697

700

701

702

704

705

706

708

709

711

712

713

714 virtual void

716 llvm::opt::ArgStringList &CC1Args) const;

717

718

719

721 llvm::opt::ArgStringList &CC1Args) const;

722

723

724

726

727

728

730 llvm::opt::ArgStringList &CmdArgs) const;

731

732

734 llvm::opt::ArgStringList &CmdArgs) const;

735

736

737

738 virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,

739 llvm::opt::ArgStringList &CmdArgs) const;

740

741

742

743

744

746 const llvm::opt::ArgList &Args, std::string &Path) const;

747

748

749

750

751

753 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;

754

755

758

759

760

761 virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,

762 llvm::opt::ArgStringList &CmdArgs) const;

763

764

765 virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,

766 llvm::opt::ArgStringList &CC1Args) const;

767

768

769 virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,

770 llvm::opt::ArgStringList &CC1Args) const;

771

772

773 virtual void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,

774 llvm::opt::ArgStringList &CC1Args) const;

775

776

778 llvm::opt::ArgStringList &CC1Args) const;

779

780

782 const llvm::opt::ArgList &Args) const;

783

784

786 getDeviceLibs(const llvm::opt::ArgList &Args) const;

787

788

789

791 llvm::opt::ArgStringList &CmdArgs) const {}

792

793

795

796

799 }

800

801

802

804

805

806

807

809 const llvm::opt::ArgList &DriverArgs, const JobAction &JA,

810 const llvm::fltSemantics *FPType = nullptr) const {

811 return llvm::DenormalMode::getIEEE();

812 }

813

814

815

817 llvm::Triple TT(TripleStr);

818 if (TT.getVendor() == llvm::Triple::UnknownVendor ||

819 TT.getOS() == llvm::Triple::UnknownOS) {

820 if (TT.getArch() == llvm::Triple::nvptx)

821 return llvm::Triple("nvptx-nvidia-cuda");

822 if (TT.getArch() == llvm::Triple::nvptx64)

823 return llvm::Triple("nvptx64-nvidia-cuda");

824 if (TT.getArch() == llvm::Triple::amdgcn)

825 return llvm::Triple("amdgcn-amd-amdhsa");

826 }

827 return TT;

828 }

829};

830

831

832

835

836public:

838 TC.setEffectiveTriple(std::move(T));

839 }

840

842};

843

844}

845

846}

847

848#endif

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::LangOptions interface.

llvm::MachO::FileType FileType

llvm::MachO::Target Target

Defines the clang::SanitizerKind enum.

The basic abstraction for the target Objective-C runtime.

The base class of the type hierarchy.

Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...

InputInfo - Wrapper for information about an input source.

See also MultilibSetBuilder for combining multilibs into a set.

std::vector< std::string > flags_list

Set a ToolChain's effective triple.

~RegisterEffectiveTriple()

RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)

The JSON file list parser is used to communicate input to InstallAPI.

const FunctionProtoType * T

bool(*)(llvm::ArrayRef< const char * >, llvm::raw_ostream &, llvm::raw_ostream &, bool, bool) Driver

Diagnostic wrappers for TextAPI types for error reporting.

Helper structure used to pass information extracted from clang executable name such as i686-linux-and...

ParsedClangName(std::string Suffix, const char *Mode)

ParsedClangName()=default

const char * DriverMode

Corresponding driver mode argument, as '–driver-mode=g++'.

std::string ModeSuffix

Driver mode part of the executable name, as g++.

std::string TargetPrefix

Target part of the executable name, as i686-linux-android.

bool TargetIsValid

True if TargetPrefix is recognized as a registered target name.

ParsedClangName(std::string Target, std::string Suffix, const char *Mode, bool IsRegistered)