Skip to content

[InstallAPI] Cleanup HeaderFile Interface & options handling, NFC #82544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

cyndyishida
Copy link
Member

No description provided.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 21, 2024

@llvm/pr-subscribers-clang

Author: Cyndy Ishida (cyndyishida)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/82544.diff

2 Files Affected:

  • (modified) clang/include/clang/InstallAPI/HeaderFile.h (+3)
  • (modified) clang/tools/clang-installapi/Options.cpp (+4-10)
diff --git a/clang/include/clang/InstallAPI/HeaderFile.h b/clang/include/clang/InstallAPI/HeaderFile.h
index 6ccd944f8b01be..fc64a43b3def5c 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -21,6 +21,8 @@
 
 namespace clang::installapi {
 enum class HeaderType {
+  /// Unset or unknown type.
+  Unknown,
   /// Represents declarations accessible to all clients.
   Public,
   /// Represents declarations accessible to a disclosed set of clients.
@@ -41,6 +43,7 @@ class HeaderFile {
   std::optional<clang::Language> Language;
 
 public:
+  HeaderFile() = delete;
   HeaderFile(StringRef FullPath, HeaderType Type,
              StringRef IncludeName = StringRef(),
              std::optional<clang::Language> Language = std::nullopt)
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
index 08d1c0e8e660fc..562a643edfcf40 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -22,14 +22,7 @@ namespace installapi {
 
 bool Options::processDriverOptions(InputArgList &Args) {
   // Handle inputs.
-  llvm::vfs::Status Stat;
-  for (const auto &Path : Args.getAllArgValues(OPT_INPUT)) {
-    if (FM->getNoncachedStatValue(Path, Stat) || !Stat.exists()) {
-      Diags->Report(clang::diag::err_drv_no_such_file) << Path;
-      return false;
-    }
-    DriverOpts.FileLists.push_back(std::move(Path));
-  }
+  llvm::append_range(DriverOpts.FileLists, Args.getAllArgValues(OPT_INPUT));
 
   // Handle output.
   SmallString<PATH_MAX> OutputPath;
@@ -61,8 +54,9 @@ bool Options::processDriverOptions(InputArgList &Args) {
 
   // Capture target triples first.
   if (ArgTarget) {
-    for (auto *Arg : Args.filtered(OPT_target)) {
-      llvm::Triple TargetTriple(Arg->getValue());
+    for (const Arg *A : Args.filtered(OPT_target)) {
+      A->claim();
+      llvm::Triple TargetTriple(A->getValue());
       Target TAPITarget = Target(TargetTriple);
       if ((TAPITarget.Arch == AK_unknown) ||
           (TAPITarget.Platform == PLATFORM_UNKNOWN)) {

@cyndyishida cyndyishida merged commit 828bf13 into llvm:main Feb 21, 2024
@cyndyishida cyndyishida deleted the eng/Pr-installapinits branch February 21, 2024 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants