@@ -73,16 +73,12 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
73
73
DiagnosticsEngine *Diags = nullptr ,
74
74
bool DefaultDiagColor = true );
75
75
76
- // / The base class of CompilerInvocation with reference semantics.
77
- // /
78
- // / This class stores option objects behind reference-counted pointers. This is
79
- // / useful for clients that want to keep some option object around even after
80
- // / CompilerInvocation gets destroyed, without making a copy.
81
- // /
82
- // / This is a separate class so that we can implement the copy constructor and
83
- // / assignment here and leave them defaulted in the rest of CompilerInvocation.
84
- class CompilerInvocationRefBase {
85
- public:
76
+ // / The base class of CompilerInvocation. It keeps individual option objects
77
+ // / behind reference-counted pointers, which is useful for clients that want to
78
+ // / keep select option objects alive (even after CompilerInvocation gets
79
+ // / destroyed) without making a copy.
80
+ class CompilerInvocationBase {
81
+ protected:
86
82
// / Options controlling the language variant.
87
83
std::shared_ptr<LangOptions> LangOpts;
88
84
@@ -93,115 +89,81 @@ class CompilerInvocationRefBase {
93
89
IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts;
94
90
95
91
// / Options controlling the \#include directive.
96
- std::shared_ptr<HeaderSearchOptions> HeaderSearchOpts ;
92
+ std::shared_ptr<HeaderSearchOptions> HSOpts ;
97
93
98
94
// / Options controlling the preprocessor (aside from \#include handling).
99
- std::shared_ptr<PreprocessorOptions> PreprocessorOpts ;
95
+ std::shared_ptr<PreprocessorOptions> PPOpts ;
100
96
101
97
// / Options controlling the static analyzer.
102
98
AnalyzerOptionsRef AnalyzerOpts;
103
99
104
- CompilerInvocationRefBase ();
105
- CompilerInvocationRefBase (const CompilerInvocationRefBase &X);
106
- CompilerInvocationRefBase (CompilerInvocationRefBase &&X);
107
- CompilerInvocationRefBase &operator =(CompilerInvocationRefBase X);
108
- CompilerInvocationRefBase &operator =(CompilerInvocationRefBase &&X);
109
- ~CompilerInvocationRefBase ();
110
-
111
- LangOptions &getLangOpts () { return *LangOpts; }
112
- const LangOptions &getLangOpts () const { return *LangOpts; }
113
-
114
- TargetOptions &getTargetOpts () { return *TargetOpts.get (); }
115
- const TargetOptions &getTargetOpts () const { return *TargetOpts.get (); }
116
-
117
- DiagnosticOptions &getDiagnosticOpts () const { return *DiagnosticOpts; }
118
-
119
- HeaderSearchOptions &getHeaderSearchOpts () { return *HeaderSearchOpts; }
120
-
121
- const HeaderSearchOptions &getHeaderSearchOpts () const {
122
- return *HeaderSearchOpts;
123
- }
124
-
125
- std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr () const {
126
- return HeaderSearchOpts;
127
- }
128
-
129
- std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr () {
130
- return PreprocessorOpts;
131
- }
132
-
133
- PreprocessorOptions &getPreprocessorOpts () { return *PreprocessorOpts; }
134
-
135
- const PreprocessorOptions &getPreprocessorOpts () const {
136
- return *PreprocessorOpts;
137
- }
138
-
139
- AnalyzerOptions &getAnalyzerOpts () { return *AnalyzerOpts; }
140
- const AnalyzerOptions &getAnalyzerOpts () const { return *AnalyzerOpts; }
141
- };
142
-
143
- // / The base class of CompilerInvocation with value semantics.
144
- class CompilerInvocationValueBase {
145
- protected:
146
- MigratorOptions MigratorOpts;
100
+ std::shared_ptr<MigratorOptions> MigratorOpts;
147
101
148
102
// / Options controlling API notes.
149
- APINotesOptions APINotesOpts;
103
+ std::shared_ptr< APINotesOptions> APINotesOpts;
150
104
151
105
// / Options configuring the CAS.
152
- CASOptions CASOpts;
106
+ std::shared_ptr< CASOptions> CASOpts;
153
107
154
108
// / Options controlling IRgen and the backend.
155
- CodeGenOptions CodeGenOpts;
156
-
157
- // / Options controlling dependency output.
158
- DependencyOutputOptions DependencyOutputOpts;
109
+ std::shared_ptr<CodeGenOptions> CodeGenOpts;
159
110
160
111
// / Options controlling file system operations.
161
- FileSystemOptions FileSystemOpts ;
112
+ std::shared_ptr< FileSystemOptions> FSOpts ;
162
113
163
114
// / Options controlling the frontend itself.
164
- FrontendOptions FrontendOpts;
115
+ std::shared_ptr<FrontendOptions> FrontendOpts;
116
+
117
+ // / Options controlling dependency output.
118
+ std::shared_ptr<DependencyOutputOptions> DependencyOutputOpts;
165
119
166
120
// / Options controlling preprocessed output.
167
- PreprocessorOutputOptions PreprocessorOutputOpts;
121
+ std::shared_ptr< PreprocessorOutputOptions> PreprocessorOutputOpts;
168
122
169
123
public:
170
- CASOptions &getCASOpts () { return CASOpts; }
171
- const CASOptions &getCASOpts () const { return CASOpts; }
172
-
173
- MigratorOptions &getMigratorOpts () { return MigratorOpts; }
174
- const MigratorOptions &getMigratorOpts () const { return MigratorOpts; }
175
-
176
- APINotesOptions &getAPINotesOpts () { return APINotesOpts; }
177
- const APINotesOptions &getAPINotesOpts () const { return APINotesOpts; }
178
-
179
- CodeGenOptions &getCodeGenOpts () { return CodeGenOpts; }
180
- const CodeGenOptions &getCodeGenOpts () const { return CodeGenOpts; }
181
-
182
- DependencyOutputOptions &getDependencyOutputOpts () {
183
- return DependencyOutputOpts;
184
- }
124
+ CompilerInvocationBase ();
125
+ CompilerInvocationBase (const CompilerInvocationBase &X) { operator =(X); }
126
+ CompilerInvocationBase (CompilerInvocationBase &&X) = default ;
127
+ CompilerInvocationBase &operator =(const CompilerInvocationBase &X);
128
+ CompilerInvocationBase &operator =(CompilerInvocationBase &&X) = default ;
129
+ ~CompilerInvocationBase () = default ;
185
130
131
+ const LangOptions &getLangOpts () const { return *LangOpts; }
132
+ const TargetOptions &getTargetOpts () const { return *TargetOpts; }
133
+ const DiagnosticOptions &getDiagnosticOpts () const { return *DiagnosticOpts; }
134
+ const HeaderSearchOptions &getHeaderSearchOpts () const { return *HSOpts; }
135
+ const PreprocessorOptions &getPreprocessorOpts () const { return *PPOpts; }
136
+ const AnalyzerOptions &getAnalyzerOpts () const { return *AnalyzerOpts; }
137
+ const MigratorOptions &getMigratorOpts () const { return *MigratorOpts; }
138
+ const APINotesOptions &getAPINotesOpts () const { return *APINotesOpts; }
139
+ const CASOptions &getCASOpts () const { return *CASOpts; }
140
+ const CodeGenOptions &getCodeGenOpts () const { return *CodeGenOpts; }
141
+ const FileSystemOptions &getFileSystemOpts () const { return *FSOpts; }
142
+ const FrontendOptions &getFrontendOpts () const { return *FrontendOpts; }
186
143
const DependencyOutputOptions &getDependencyOutputOpts () const {
187
- return DependencyOutputOpts;
144
+ return * DependencyOutputOpts;
188
145
}
189
-
190
- FileSystemOptions &getFileSystemOpts () { return FileSystemOpts; }
191
-
192
- const FileSystemOptions &getFileSystemOpts () const {
193
- return FileSystemOpts;
146
+ const PreprocessorOutputOptions &getPreprocessorOutputOpts () const {
147
+ return *PreprocessorOutputOpts;
194
148
}
195
149
196
- FrontendOptions &getFrontendOpts () { return FrontendOpts; }
197
- const FrontendOptions &getFrontendOpts () const { return FrontendOpts; }
198
-
199
- PreprocessorOutputOptions &getPreprocessorOutputOpts () {
200
- return PreprocessorOutputOpts;
150
+ LangOptions &getLangOpts () { return *LangOpts; }
151
+ TargetOptions &getTargetOpts () { return *TargetOpts; }
152
+ DiagnosticOptions &getDiagnosticOpts () { return *DiagnosticOpts; }
153
+ HeaderSearchOptions &getHeaderSearchOpts () { return *HSOpts; }
154
+ PreprocessorOptions &getPreprocessorOpts () { return *PPOpts; }
155
+ AnalyzerOptions &getAnalyzerOpts () { return *AnalyzerOpts; }
156
+ MigratorOptions &getMigratorOpts () { return *MigratorOpts; }
157
+ APINotesOptions &getAPINotesOpts () { return *APINotesOpts; }
158
+ CASOptions &getCASOpts () { return *CASOpts; }
159
+ CodeGenOptions &getCodeGenOpts () { return *CodeGenOpts; }
160
+ FileSystemOptions &getFileSystemOpts () { return *FSOpts; }
161
+ FrontendOptions &getFrontendOpts () { return *FrontendOpts; }
162
+ DependencyOutputOptions &getDependencyOutputOpts () {
163
+ return *DependencyOutputOpts;
201
164
}
202
-
203
- const PreprocessorOutputOptions &getPreprocessorOutputOpts () const {
204
- return PreprocessorOutputOpts;
165
+ PreprocessorOutputOptions &getPreprocessorOutputOpts () {
166
+ return *PreprocessorOutputOpts;
205
167
}
206
168
};
207
169
@@ -210,9 +172,21 @@ class CompilerInvocationValueBase {
210
172
// / This class is designed to represent an abstract "invocation" of the
211
173
// / compiler, including data such as the include paths, the code generation
212
174
// / options, the warning flags, and so on.
213
- class CompilerInvocation : public CompilerInvocationRefBase ,
214
- public CompilerInvocationValueBase {
175
+ class CompilerInvocation : public CompilerInvocationBase {
215
176
public:
177
+ // / Base class internals.
178
+ // / @{
179
+ using CompilerInvocationBase::LangOpts;
180
+ using CompilerInvocationBase::TargetOpts;
181
+ using CompilerInvocationBase::DiagnosticOpts;
182
+ std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr () {
183
+ return HSOpts;
184
+ }
185
+ std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr () {
186
+ return PPOpts;
187
+ }
188
+ // / @}
189
+
216
190
// / Create a compiler invocation from a list of input options.
217
191
// / \returns true on success.
218
192
// /
0 commit comments