Skip to content

Commit 2d7df31

Browse files
committed
Revert "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)"
This reverts commit b7d8c61. And This reverts commit 2d40f17. It caused a build failure i'll need to reproduce. ` error: could not convert ‘Rule’ from ‘llvm::Regex’ to ‘llvm::Expected<llvm::Regex>’`
1 parent 6ee39fb commit 2d7df31

File tree

23 files changed

+2
-3931
lines changed

23 files changed

+2
-3931
lines changed

clang/include/clang/Basic/DiagnosticInstallAPIKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ let CategoryName = "Command line" in {
1515
def err_cannot_write_file : Error<"cannot write file '%0': %1">;
1616
def err_no_install_name : Error<"no install name specified: add -install_name <path>">;
1717
def err_no_output_file: Error<"no output file specified">;
18-
def err_no_such_header_file : Error<"no such %select{public|private|project}1 header file: '%0'">;
19-
def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public|private}0 header file: '%1'">, InGroup<InstallAPIViolation>;
20-
def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup<InstallAPIViolation>;
2118
} // end of command line category.
2219

2320
let CategoryName = "Verification" in {

clang/include/clang/InstallAPI/HeaderFile.h

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#ifndef LLVM_CLANG_INSTALLAPI_HEADERFILE_H
1414
#define LLVM_CLANG_INSTALLAPI_HEADERFILE_H
1515

16-
#include "clang/Basic/FileManager.h"
1716
#include "clang/Basic/LangStandard.h"
18-
#include "clang/InstallAPI/MachO.h"
1917
#include "llvm/ADT/StringRef.h"
2018
#include "llvm/Support/ErrorHandling.h"
2119
#include "llvm/Support/Regex.h"
@@ -58,10 +56,6 @@ class HeaderFile {
5856
std::string IncludeName;
5957
/// Supported language mode for header.
6058
std::optional<clang::Language> Language;
61-
/// Exclude header file from processing.
62-
bool Excluded{false};
63-
/// Add header file to processing.
64-
bool Extra{false};
6559

6660
public:
6761
HeaderFile() = delete;
@@ -77,48 +71,17 @@ class HeaderFile {
7771
StringRef getIncludeName() const { return IncludeName; }
7872
StringRef getPath() const { return FullPath; }
7973

80-
void setExtra(bool V = true) { Extra = V; }
81-
void setExcluded(bool V = true) { Excluded = V; }
82-
bool isExtra() const { return Extra; }
83-
bool isExcluded() const { return Excluded; }
84-
8574
bool useIncludeName() const {
8675
return Type != HeaderType::Project && !IncludeName.empty();
8776
}
8877

8978
bool operator==(const HeaderFile &Other) const {
90-
return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
79+
return std::tie(Type, FullPath, IncludeName, Language) ==
9180
std::tie(Other.Type, Other.FullPath, Other.IncludeName,
92-
Other.Language, Other.Excluded, Other.Extra);
81+
Other.Language);
9382
}
9483
};
9584

96-
/// Glob that represents a pattern of header files to retreive.
97-
class HeaderGlob {
98-
private:
99-
std::string GlobString;
100-
llvm::Regex Rule;
101-
HeaderType Type;
102-
bool FoundMatch{false};
103-
104-
public:
105-
HeaderGlob(StringRef GlobString, llvm::Regex &&, HeaderType Type);
106-
107-
/// Create a header glob from string for the header access level.
108-
static llvm::Expected<std::unique_ptr<HeaderGlob>>
109-
create(StringRef GlobString, HeaderType Type);
110-
111-
/// Query if provided header matches glob.
112-
bool match(const HeaderFile &Header);
113-
114-
/// Query if a header was matched in the glob, used primarily for error
115-
/// reporting.
116-
bool didMatch() { return FoundMatch; }
117-
118-
/// Provide back input glob string.
119-
StringRef str() { return GlobString; }
120-
};
121-
12285
/// Assemble expected way header will be included by clients.
12386
/// As in what maps inside the brackets of `#include <IncludeName.h>`
12487
/// For example,
@@ -130,19 +93,6 @@ class HeaderGlob {
13093
std::optional<std::string> createIncludeHeaderName(const StringRef FullPath);
13194
using HeaderSeq = std::vector<HeaderFile>;
13295

133-
/// Determine if Path is a header file.
134-
/// It does not touch the file system.
135-
///
136-
/// \param Path File path to file.
137-
bool isHeaderFile(StringRef Path);
138-
139-
/// Given input directory, collect all header files.
140-
///
141-
/// \param FM FileManager for finding input files.
142-
/// \param Directory Path to directory file.
143-
llvm::Expected<PathSeq> enumerateFiles(clang::FileManager &FM,
144-
StringRef Directory);
145-
14696
} // namespace clang::installapi
14797

14898
#endif // LLVM_CLANG_INSTALLAPI_HEADERFILE_H

clang/include/clang/InstallAPI/MachO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ using SymbolSet = llvm::MachO::SymbolSet;
4040
using SimpleSymbol = llvm::MachO::SimpleSymbol;
4141
using FileType = llvm::MachO::FileType;
4242
using PackedVersion = llvm::MachO::PackedVersion;
43-
using PathSeq = llvm::MachO::PathSeq;
4443
using Target = llvm::MachO::Target;
4544
using TargetList = llvm::MachO::TargetList;
4645

clang/lib/InstallAPI/Frontend.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ std::unique_ptr<MemoryBuffer> createInputBuffer(InstallAPIContext &Ctx) {
138138
SmallString<4096> Contents;
139139
raw_svector_ostream OS(Contents);
140140
for (const HeaderFile &H : Ctx.InputHeaders) {
141-
if (H.isExcluded())
142-
continue;
143141
if (H.getType() != Ctx.Type)
144142
continue;
145143
if (Ctx.LangMode == Language::C || Ctx.LangMode == Language::CXX)

clang/lib/InstallAPI/HeaderFile.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "clang/InstallAPI/HeaderFile.h"
10-
#include "llvm/TextAPI/Utils.h"
1110

1211
using namespace llvm;
1312
namespace clang::installapi {
@@ -35,54 +34,4 @@ std::optional<std::string> createIncludeHeaderName(const StringRef FullPath) {
3534
return Matches[1].drop_front(Matches[1].rfind('/') + 1).str() + "/" +
3635
Matches[3].str();
3736
}
38-
39-
bool isHeaderFile(StringRef Path) {
40-
return StringSwitch<bool>(sys::path::extension(Path))
41-
.Cases(".h", ".H", ".hh", ".hpp", ".hxx", true)
42-
.Default(false);
43-
}
44-
45-
llvm::Expected<PathSeq> enumerateFiles(FileManager &FM, StringRef Directory) {
46-
PathSeq Files;
47-
std::error_code EC;
48-
auto &FS = FM.getVirtualFileSystem();
49-
for (llvm::vfs::recursive_directory_iterator i(FS, Directory, EC), ie;
50-
i != ie; i.increment(EC)) {
51-
if (EC)
52-
return errorCodeToError(EC);
53-
54-
// Skip files that do not exist. This usually happens for broken symlinks.
55-
if (FS.status(i->path()) == std::errc::no_such_file_or_directory)
56-
continue;
57-
58-
StringRef Path = i->path();
59-
if (isHeaderFile(Path))
60-
Files.emplace_back(Path);
61-
}
62-
63-
return Files;
64-
}
65-
66-
HeaderGlob::HeaderGlob(StringRef GlobString, Regex &&Rule, HeaderType Type)
67-
: GlobString(GlobString), Rule(std::move(Rule)), Type(Type) {}
68-
69-
bool HeaderGlob::match(const HeaderFile &Header) {
70-
if (Header.getType() != Type)
71-
return false;
72-
73-
bool Match = Rule.match(Header.getPath());
74-
if (Match)
75-
FoundMatch = true;
76-
return Match;
77-
}
78-
79-
Expected<std::unique_ptr<HeaderGlob>> HeaderGlob::create(StringRef GlobString,
80-
HeaderType Type) {
81-
auto Rule = MachO::createRegexFromGlob(GlobString);
82-
if (!Rule)
83-
return Rule.takeError();
84-
85-
return std::make_unique<HeaderGlob>(GlobString, std::move(*Rule), Type);
86-
}
87-
8837
} // namespace clang::installapi

clang/test/InstallAPI/Inputs/Simple/Extra/SimpleExtraAPI1.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/test/InstallAPI/Inputs/Simple/Extra/SimpleExtraAPI2.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/Basic.h

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

clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/External.h

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

clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/Simple.h

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

clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/SimpleAPI.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/test/InstallAPI/Inputs/Simple/Simple.framework/PrivateHeaders/SimplePrivate.h

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

clang/test/InstallAPI/Inputs/Simple/Simple.framework/PrivateHeaders/SimplePrivateSPI.h

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

0 commit comments

Comments
 (0)