• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
11 #define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
12 
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/Support/WithColor.h"
15 #include <string>
16 
17 namespace llvm {
18 namespace dsymutil {
19 
20 enum class OutputFileType {
21   Object,
22   Assembly,
23 };
24 
25 /// The kind of accelerator tables we should emit.
26 enum class AccelTableKind {
27   Apple,   ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
28   Dwarf,   ///< DWARF v5 .debug_names.
29   Default, ///< Dwarf for DWARF5 or later, Apple otherwise.
30 };
31 
32 struct LinkOptions {
33   /// Verbosity
34   bool Verbose = false;
35 
36   /// Skip emitting output
37   bool NoOutput = false;
38 
39   /// Do not unique types according to ODR
40   bool NoODR = false;
41 
42   /// Update
43   bool Update = false;
44 
45   /// Minimize
46   bool Minimize = false;
47 
48   /// Do not check swiftmodule timestamp
49   bool NoTimestamp = false;
50 
51   /// Number of threads.
52   unsigned Threads = 1;
53 
54   // Output file type.
55   OutputFileType FileType = OutputFileType::Object;
56 
57   /// The accelerator table kind
58   AccelTableKind TheAccelTableKind;
59 
60   /// -oso-prepend-path
61   std::string PrependPath;
62 
63   LinkOptions() = default;
64 };
65 
66 inline void warn(Twine Warning, Twine Context = {}) {
67   WithColor::warning() << Warning + "\n";
68   if (!Context.isTriviallyEmpty())
69     WithColor::note() << Twine("while processing ") + Context + "\n";
70 }
71 
72 inline bool error(Twine Error, Twine Context = {}) {
73   WithColor::error() << Error + "\n";
74   if (!Context.isTriviallyEmpty())
75     WithColor::note() << Twine("while processing ") + Context + "\n";
76   return false;
77 }
78 
79 } // end namespace dsymutil
80 } // end namespace llvm
81 
82 #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
83