llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Cyndy Ishida (cyndyishida)
Changes
InstallAPI takes a json list of headers that is typically generated from a
build system like Xcode based on a project's attributes. Sometimes, maintainers
may want to alter this for tapi input. Using e.g. `--extra-public-headers`,
users can manipulate what headers will be used for TBD file generation.
---
Patch is 167.20 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/86522.diff
23 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticInstallAPIKinds.td (+3)
- (modified) clang/include/clang/InstallAPI/HeaderFile.h (+52-2)
- (modified) clang/include/clang/InstallAPI/MachO.h (+1)
- (modified) clang/lib/InstallAPI/Frontend.cpp (+2)
- (modified) clang/lib/InstallAPI/HeaderFile.cpp (+51)
- (added) clang/test/InstallAPI/Inputs/Simple/Extra/SimpleExtraAPI1.h (+1)
- (added) clang/test/InstallAPI/Inputs/Simple/Extra/SimpleExtraAPI2.h (+1)
- (added) clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/Basic.h
(+103)
- (added)
clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/External.h (+19)
- (added) clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/Simple.h
(+45)
- (added)
clang/test/InstallAPI/Inputs/Simple/Simple.framework/Headers/SimpleAPI.h (+1)
- (added)
clang/test/InstallAPI/Inputs/Simple/Simple.framework/PrivateHeaders/SimplePrivate.h
(+5)
- (added)
clang/test/InstallAPI/Inputs/Simple/Simple.framework/PrivateHeaders/SimplePrivateSPI.h
(+2)
- (added) clang/test/InstallAPI/Inputs/Simple/Simple.yaml (+3196)
- (added) clang/test/InstallAPI/Inputs/Simple/SimpleInternalAPI.h (+3)
- (added) clang/test/InstallAPI/Inputs/Simple/SimpleInternalAPI2.h (+7)
- (added) clang/test/InstallAPI/Inputs/Simple/SimpleInternalSPI.h (+5)
- (added) clang/test/InstallAPI/extra-exclude-headers.test (+207)
- (modified) clang/tools/clang-installapi/InstallAPIOpts.td (+32)
- (modified) clang/tools/clang-installapi/Options.cpp (+121)
- (modified) clang/tools/clang-installapi/Options.h (+21)
- (modified) llvm/include/llvm/TextAPI/Utils.h (+6)
- (modified) llvm/lib/TextAPI/Utils.cpp (+46)
``diff
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index a4c6e630ac5fd8..27df731fa28627 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -15,6 +15,9 @@ let CategoryName = "Command line" in {
def err_cannot_write_file : Error<"cannot write file '%0': %1">;
def err_no_install_name : Error<"no install name specified: add -install_name
">;
def err_no_output_file: Error<"no output file specified">;
+def err_no_such_header_file : Error<"no such %select{public|private|project}1
header file: '%0'">;
+def warn_no_such_excluded_header_file : Warning<"no such excluded
%select{public|private}0 header file: '%1'">, InGroup;
+def warn_glob_did_not_match: Warning<"glob '%0' did not match any header
file">, InGroup;
} // end of command line category.
let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/HeaderFile.h
b/clang/include/clang/InstallAPI/HeaderFile.h
index 70e83bbb3e76f6..235b4da3add840 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -13,7 +13,9 @@
#ifndef LLVM_CLANG_INSTALLAPI_HEADERFILE_H
#define LLVM_CLANG_INSTALLAPI_HEADERFILE_H
+#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangStandard.h"
+#include "clang/InstallAPI/MachO.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Regex.h"
@@ -56,6 +58,10 @@ class HeaderFile {
std::string IncludeName;
/// Supported language mode for header.
std::optional Language;
+ /// Exclude header file from processing.
+ bool Excluded{false};
+ /// Add header file to processing.
+ bool Extra{false};
public:
HeaderFile() = delete;
@@ -71,17 +77,48 @@ class HeaderFile {
StringRef getIncludeName() const { return IncludeName; }
StringRef getPath() const { return FullPath; }
+ void setExtra(bool V = true) { Extra = V; }
+ void setExcluded(bool V = true) { Excluded = V; }
+ bool isExtra() const { return Extra; }
+ bool isExcluded() const { return Excluded; }
+
bool useIncludeName() const {
return Type != HeaderType::Project && !IncludeName.empty();
}
bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language) ==
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language);
+Other.Language, Other.Excluded, Other.Extra);
}
};
+/// Glob that represents a pattern of header files to retreive.
+class HeaderGlob {
+private:
+ std::string