Skip to content

Commit 7f6b664

Browse files
committed
[InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action
Installapi has important distinctions when compared to the clang driver, so much that, it doesn't make much sense to try to integrate into it. This patch partially reverts the CC1 action & driver support to replace with its own driver as a clang tool. For distribution, we could use LLVM_TOOL_LLVM_DRIVER_BUILD mechanism for integrating the functionality into clang such that the toolchain size is less impacted.
1 parent 030d075 commit 7f6b664

29 files changed

+410
-234
lines changed

clang/include/clang/Driver/Action.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class Action {
5959
PreprocessJobClass,
6060
PrecompileJobClass,
6161
ExtractAPIJobClass,
62-
InstallAPIJobClass,
6362
AnalyzeJobClass,
6463
MigrateJobClass,
6564
CompileJobClass,
@@ -449,17 +448,6 @@ class ExtractAPIJobAction : public JobAction {
449448
void addHeaderInput(Action *Input) { getInputs().push_back(Input); }
450449
};
451450

452-
class InstallAPIJobAction : public JobAction {
453-
void anchor() override;
454-
455-
public:
456-
InstallAPIJobAction(Action *Input, types::ID OutputType);
457-
458-
static bool classof(const Action *A) {
459-
return A->getKind() == InstallAPIJobClass;
460-
}
461-
};
462-
463451
class AnalyzeJobAction : public JobAction {
464452
void anchor() override;
465453

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ class AnalyzerOpts<string base>
336336
: KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {}
337337
class MigratorOpts<string base>
338338
: KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
339-
class InstallAPIOpts<string base>
340-
: KeyPathAndMacro<"InstallAPIOpts.", base, "INSTALLAPI_"> {}
341339

342340
// A boolean option which is opt-in in CC1. The positive option exists in CC1 and
343341
// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
@@ -1143,8 +1141,7 @@ def config_user_dir_EQ : Joined<["--"], "config-user-dir=">,
11431141
def coverage : Flag<["-", "--"], "coverage">, Group<Link_Group>,
11441142
Visibility<[ClangOption, CLOption]>;
11451143
def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>;
1146-
def current__version : JoinedOrSeparate<["-"], "current_version">,
1147-
Visibility<[ClangOption, CC1Option]>;
1144+
def current__version : JoinedOrSeparate<["-"], "current_version">;
11481145
def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
11491146
HelpText<"Add directory to the C++ SYSTEM include search path">,
11501147
Visibility<[ClangOption, CC1Option]>,
@@ -4324,9 +4321,7 @@ def verify_pch : Flag<["-"], "verify-pch">, Group<Action_Group>,
43244321
Visibility<[ClangOption, CC1Option]>,
43254322
HelpText<"Load and verify that a pre-compiled header file is not stale">;
43264323
def init : Separate<["-"], "init">;
4327-
def install__name : Separate<["-"], "install_name">,
4328-
Visibility<[ClangOption, CC1Option]>,
4329-
MarshallingInfoString<InstallAPIOpts<"InstallName">>;
4324+
def install__name : Separate<["-"], "install_name">;
43304325
def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>,
43314326
Visibility<[ClangOption, CC1Option]>,
43324327
HelpText<"Set the -iwithprefix/-iwithprefixbefore prefix">, MetaVarName<"<dir>">;

clang/include/clang/Driver/Types.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ TYPE("lto-bc", LTO_BC, INVALID, "o", phases
9494
TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
9595
TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge)
9696
TYPE("ifs-cpp", IFS_CPP, INVALID, "ifs", phases::Compile, phases::IfsMerge)
97-
TYPE("tbd", TextAPI, INVALID, "tbd", phases::Precompile)
9897
TYPE("pcm", ModuleFile, INVALID, "pcm", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
9998
TYPE("header-unit", HeaderUnit, INVALID, "pcm", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
10099
TYPE("plist", Plist, INVALID, "plist", phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,6 @@ class CompilerInstance : public ModuleLoader {
294294
return Invocation->getFrontendOpts();
295295
}
296296

297-
InstallAPIOptions &getInstallAPIOpts() {
298-
return Invocation->getInstallAPIOpts();
299-
}
300-
const InstallAPIOptions &getInstallAPIOpts() const {
301-
return Invocation->getInstallAPIOpts();
302-
}
303-
304297
HeaderSearchOptions &getHeaderSearchOpts() {
305298
return Invocation->getHeaderSearchOpts();
306299
}

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "clang/Basic/LangStandard.h"
1919
#include "clang/Frontend/DependencyOutputOptions.h"
2020
#include "clang/Frontend/FrontendOptions.h"
21-
#include "clang/Frontend/InstallAPIOptions.h"
2221
#include "clang/Frontend/MigratorOptions.h"
2322
#include "clang/Frontend/PreprocessorOutputOptions.h"
2423
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
@@ -112,9 +111,6 @@ class CompilerInvocationBase {
112111
/// Options controlling preprocessed output.
113112
std::shared_ptr<PreprocessorOutputOptions> PreprocessorOutputOpts;
114113

115-
/// Options controlling InstallAPI operations and output.
116-
std::shared_ptr<InstallAPIOptions> InstallAPIOpts;
117-
118114
/// Dummy tag type whose instance can be passed into the constructor to
119115
/// prevent creation of the reference-counted option objects.
120116
struct EmptyConstructor {};
@@ -149,7 +145,6 @@ class CompilerInvocationBase {
149145
const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
150146
return *PreprocessorOutputOpts;
151147
}
152-
const InstallAPIOptions &getInstallAPIOpts() const { return *InstallAPIOpts; }
153148
/// @}
154149

155150
/// Command line generation.
@@ -229,20 +224,19 @@ class CompilerInvocation : public CompilerInvocationBase {
229224
/// @{
230225
// Note: These need to be pulled in manually. Otherwise, they get hidden by
231226
// the mutable getters with the same names.
232-
using CompilerInvocationBase::getLangOpts;
233-
using CompilerInvocationBase::getTargetOpts;
234-
using CompilerInvocationBase::getDiagnosticOpts;
235-
using CompilerInvocationBase::getHeaderSearchOpts;
236-
using CompilerInvocationBase::getPreprocessorOpts;
237227
using CompilerInvocationBase::getAnalyzerOpts;
238-
using CompilerInvocationBase::getMigratorOpts;
239228
using CompilerInvocationBase::getAPINotesOpts;
240229
using CompilerInvocationBase::getCodeGenOpts;
230+
using CompilerInvocationBase::getDependencyOutputOpts;
231+
using CompilerInvocationBase::getDiagnosticOpts;
241232
using CompilerInvocationBase::getFileSystemOpts;
242233
using CompilerInvocationBase::getFrontendOpts;
243-
using CompilerInvocationBase::getDependencyOutputOpts;
234+
using CompilerInvocationBase::getHeaderSearchOpts;
235+
using CompilerInvocationBase::getLangOpts;
236+
using CompilerInvocationBase::getMigratorOpts;
237+
using CompilerInvocationBase::getPreprocessorOpts;
244238
using CompilerInvocationBase::getPreprocessorOutputOpts;
245-
using CompilerInvocationBase::getInstallAPIOpts;
239+
using CompilerInvocationBase::getTargetOpts;
246240
/// @}
247241

248242
/// Mutable getters.
@@ -264,7 +258,6 @@ class CompilerInvocation : public CompilerInvocationBase {
264258
PreprocessorOutputOptions &getPreprocessorOutputOpts() {
265259
return *PreprocessorOutputOpts;
266260
}
267-
InstallAPIOptions &getInstallAPIOpts() { return *InstallAPIOpts; }
268261
/// @}
269262

270263
/// Base class internals.

clang/include/clang/Frontend/FrontendActions.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ class GenerateModuleAction : public ASTFrontendAction {
130130
bool shouldEraseOutputFiles() override;
131131
};
132132

133-
class InstallAPIAction : public ASTFrontendAction {
134-
protected:
135-
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
136-
StringRef InFile) override;
137-
138-
public:
139-
static std::unique_ptr<llvm::raw_pwrite_stream>
140-
CreateOutputFile(CompilerInstance &CI, StringRef InFile);
141-
};
142-
143133
class GenerateInterfaceStubsAction : public ASTFrontendAction {
144134
protected:
145135
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,

clang/include/clang/Frontend/FrontendOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ enum ActionKind {
100100
/// Only execute frontend initialization.
101101
InitOnly,
102102

103-
// Create TextAPI stub.
104-
InstallAPI,
105-
106103
/// Dump information about a module file.
107104
ModuleFileInfo,
108105

clang/include/clang/Frontend/InstallAPIOptions.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang/include/clang/InstallAPI/Context.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#define LLVM_CLANG_INSTALLAPI_CONTEXT_H
1616

1717
#include "clang/AST/ASTConsumer.h"
18-
#include "clang/Basic/Diagnostic.h"
18+
#include "clang/Frontend/CompilerInstance.h"
19+
#include "clang/Frontend/FrontendAction.h"
1920
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2021
#include "llvm/TextAPI/InterfaceFile.h"
2122
#include "llvm/TextAPI/RecordVisitor.h"
@@ -35,19 +36,19 @@ struct InstallAPIContext {
3536
/// Active target triple to parse.
3637
llvm::Triple TargetTriple{};
3738

38-
/// Output stream to write TextAPI file to.
39-
std::unique_ptr<llvm::raw_pwrite_stream> OS = nullptr;
40-
41-
/// DiagnosticsEngine to report errors.
42-
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags = nullptr;
43-
4439
/// File Path of output location.
4540
StringRef OutputLoc{};
4641

4742
/// What encoding to write output as.
4843
llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;
4944
};
5045

46+
class InstallAPIAction : public ASTFrontendAction {
47+
public:
48+
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
49+
StringRef InFile) override;
50+
};
51+
5152
class InstallAPIConsumer : public ASTConsumer {
5253
public:
5354
InstallAPIConsumer(InstallAPIContext InstallAPICtx)

clang/lib/Driver/Action.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ const char *Action::getClassName(ActionClass AC) {
3131
case MigrateJobClass: return "migrator";
3232
case CompileJobClass: return "compiler";
3333
case BackendJobClass: return "backend";
34-
case AssembleJobClass: return "assembler";
35-
case InstallAPIJobClass:
36-
return "installapi";
34+
case AssembleJobClass:
35+
return "assembler";
3736
case IfsMergeJobClass: return "interface-stub-merger";
3837
case LinkJobClass: return "linker";
3938
case LipoJobClass: return "lipo";
@@ -364,11 +363,6 @@ void ExtractAPIJobAction::anchor() {}
364363
ExtractAPIJobAction::ExtractAPIJobAction(Action *Inputs, types::ID OutputType)
365364
: JobAction(ExtractAPIJobClass, Inputs, OutputType) {}
366365

367-
void InstallAPIJobAction::anchor() {}
368-
369-
InstallAPIJobAction::InstallAPIJobAction(Action *Inputs, types::ID OutputType)
370-
: JobAction(InstallAPIJobClass, Inputs, OutputType) {}
371-
372366
void AnalyzeJobAction::anchor() {}
373367

374368
AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)

0 commit comments

Comments
 (0)