Skip to content

Commit 0a518db

Browse files
authored
[InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action (#82293)
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 cc13f3b commit 0a518db

30 files changed

+408
-271
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,4 @@ def warn_android_unversioned_fallback : Warning<
804804

805805
def err_drv_triple_version_invalid : Error<
806806
"version '%0' in target triple '%1' is invalid">;
807-
808-
def err_drv_installapi_unsupported : Error<
809-
"InstallAPI is not supported for '%0'">;
810807
}

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 & 10 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]>,
@@ -1559,9 +1556,6 @@ def static_libsan : Flag<["-"], "static-libsan">,
15591556
HelpText<"Statically link the sanitizer runtime (Not supported for ASan, TSan or UBSan on darwin)">;
15601557
def : Flag<["-"], "shared-libasan">, Alias<shared_libsan>;
15611558
def fasm : Flag<["-"], "fasm">, Group<f_Group>;
1562-
def installapi : Flag<["-"], "installapi">,
1563-
Visibility<[ClangOption, CC1Option]>, Group<Action_Group>,
1564-
HelpText<"Create a text-based stub file by scanning header files">;
15651559

15661560
defm assume_unique_vtables : BoolFOption<"assume-unique-vtables",
15671561
CodeGenOpts<"AssumeUniqueVTables">, DefaultTrue,
@@ -4320,9 +4314,7 @@ def verify_pch : Flag<["-"], "verify-pch">, Group<Action_Group>,
43204314
Visibility<[ClangOption, CC1Option]>,
43214315
HelpText<"Load and verify that a pre-compiled header file is not stale">;
43224316
def init : Separate<["-"], "init">;
4323-
def install__name : Separate<["-"], "install_name">,
4324-
Visibility<[ClangOption, CC1Option]>,
4325-
MarshallingInfoString<InstallAPIOpts<"InstallName">>;
4317+
def install__name : Separate<["-"], "install_name">;
43264318
def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>,
43274319
Visibility<[ClangOption, CC1Option]>,
43284320
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: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
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"
25-
#include "llvm/ADT/ArrayRef.h"
2624
#include "llvm/ADT/IntrusiveRefCntPtr.h"
25+
#include "llvm/ADT/ArrayRef.h"
2726
#include <memory>
2827
#include <string>
2928

@@ -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.
@@ -242,7 +237,6 @@ class CompilerInvocation : public CompilerInvocationBase {
242237
using CompilerInvocationBase::getFrontendOpts;
243238
using CompilerInvocationBase::getDependencyOutputOpts;
244239
using CompilerInvocationBase::getPreprocessorOutputOpts;
245-
using CompilerInvocationBase::getInstallAPIOpts;
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: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
9-
// Top level types for interacting with the generic clang driver and frontend
10-
// for InstallAPI operations.
11-
//
12-
//===----------------------------------------------------------------------===//
138

149
#ifndef LLVM_CLANG_INSTALLAPI_CONTEXT_H
1510
#define LLVM_CLANG_INSTALLAPI_CONTEXT_H
1611

17-
#include "clang/AST/ASTConsumer.h"
18-
#include "clang/Basic/Diagnostic.h"
19-
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2012
#include "llvm/TextAPI/InterfaceFile.h"
2113
#include "llvm/TextAPI/RecordVisitor.h"
2214
#include "llvm/TextAPI/RecordsSlice.h"
@@ -35,30 +27,13 @@ struct InstallAPIContext {
3527
/// Active target triple to parse.
3628
llvm::Triple TargetTriple{};
3729

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-
4430
/// File Path of output location.
4531
StringRef OutputLoc{};
4632

4733
/// What encoding to write output as.
4834
llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;
4935
};
5036

51-
class InstallAPIConsumer : public ASTConsumer {
52-
public:
53-
InstallAPIConsumer(InstallAPIContext InstallAPICtx)
54-
: Ctx(std::move(InstallAPICtx)) {}
55-
56-
void HandleTranslationUnit(ASTContext &ASTContext) override;
57-
58-
private:
59-
InstallAPIContext Ctx;
60-
};
61-
6237
} // namespace installapi
6338
} // namespace clang
6439

0 commit comments

Comments
 (0)