[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-14 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/94508
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-13 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

ping 

https://github.com/llvm/llvm-project/pull/94508
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-11 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/94508

>From 95cc0c9a2b135706e80a5e73ef5e4257aa89984c Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 10 May 2024 09:19:22 -0700
Subject: [PATCH] [InstallAPI] Pick up input headers by directory traversal

Match TAPI behavior and allow input headers to be resolved via a passed
directory, which is expected to be a library sitting in a build
directory.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   2 +
 .../clang/InstallAPI/DirectoryScanner.h   |  81 +
 clang/include/clang/InstallAPI/HeaderFile.h   |  13 +
 clang/include/clang/InstallAPI/Library.h  |  65 
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   2 +
 clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++
 clang/lib/InstallAPI/Library.cpp  |  40 +++
 clang/test/InstallAPI/asm.test|   2 +-
 clang/test/InstallAPI/basic.test  |   4 +-
 clang/test/InstallAPI/binary-attributes.test  |   6 +-
 clang/test/InstallAPI/cpp.test|   4 +-
 clang/test/InstallAPI/diagnostics-dsym.test   |   4 +-
 .../InstallAPI/directory-scanning-dylib.test  |  57 
 .../directory-scanning-frameworks.test|  88 +
 clang/test/InstallAPI/functions.test  |   2 +-
 clang/test/InstallAPI/variables.test  |   2 +-
 clang/tools/clang-installapi/Options.cpp  |  51 ++-
 clang/tools/clang-installapi/Options.h|   3 +
 19 files changed, 703 insertions(+), 24 deletions(-)
 create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h
 create mode 100644 clang/include/clang/InstallAPI/Library.h
 create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp
 create mode 100644 clang/lib/InstallAPI/Library.cpp
 create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test
 create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index cdf27247602f2..e10fa71011f30 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is 
not supported: '%1'
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
+def err_directory_scanning: Error<"could not read directory '%0': %1">;
+def err_more_than_one_library: Error<"more than one framework/dynamic library 
found">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h 
b/clang/include/clang/InstallAPI/DirectoryScanner.h
new file mode 100644
index 0..803328982ec87
--- /dev/null
+++ b/clang/include/clang/InstallAPI/DirectoryScanner.h
@@ -0,0 +1,81 @@
+//===- InstallAPI/DirectoryScanner.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// The DirectoryScanner for collecting library files on the file system.
+///
+//===--===//
+#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+
+#include "clang/Basic/FileManager.h"
+#include "clang/InstallAPI/Library.h"
+
+namespace clang::installapi {
+
+enum ScanMode {
+  /// Scanning Framework directory.
+  ScanFrameworks,
+  /// Scanning Dylib directory.
+  ScanDylibs,
+};
+
+class DirectoryScanner {
+public:
+  DirectoryScanner(FileManager , ScanMode Mode = ScanMode::ScanFrameworks)
+  : FM(FM), Mode(Mode) {}
+
+  /// Scan for all input files throughout directory.
+  ///
+  /// \param Directory Path of input directory.
+  llvm::Error scan(StringRef Directory);
+
+  /// Take over ownership of stored libraries.
+  std::vector takeLibraries() { return std::move(Libraries); };
+
+  /// Get all the header files in libraries.
+  ///
+  /// \param Libraries Reference of collection of libraries.
+  static HeaderSeq getHeaders(ArrayRef Libraries);
+
+private:
+  /// Collect files for dylibs in usr/(local)/lib within directory.
+  llvm::Error scanForUnwrappedLibraries(StringRef Directory);
+
+  /// Collect files for any frameworks within directory.
+  llvm::Error scanForFrameworks(StringRef Directory);
+
+  /// Get a library from the libraries collection.
+  Library (StringRef Path, std::vector ) 
const;
+
+  /// Collect multiple frameworks from directory.

[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-06 Thread Cyndy Ishida via cfe-commits


@@ -97,6 +97,14 @@ class HeaderFile {
   Other.Excluded, Other.Extra,
   Other.Umbrella);
   }
+
+  bool operator<(const HeaderFile ) const {

cyndyishida wrote:

I could infer, but I don't actually know @ributzka do you remember?

https://github.com/llvm/llvm-project/pull/94508
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-06 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/94508

>From c547d990aca29ecfe6f51d37c5c3f8712dfc5e44 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 10 May 2024 09:19:22 -0700
Subject: [PATCH 1/2] [InstallAPI] Pick up input headers by directory traversal

Match TAPI behavior and allow input headers to be resolved via a passed
directory, which is expected to be a library sitting in a build
directory.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   2 +
 .../clang/InstallAPI/DirectoryScanner.h   |  81 +
 clang/include/clang/InstallAPI/HeaderFile.h   |   8 +
 clang/include/clang/InstallAPI/Library.h  |  65 
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   2 +
 clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++
 clang/lib/InstallAPI/Library.cpp  |  40 +++
 clang/test/InstallAPI/asm.test|   2 +-
 clang/test/InstallAPI/basic.test  |   4 +-
 clang/test/InstallAPI/binary-attributes.test  |   6 +-
 clang/test/InstallAPI/cpp.test|   4 +-
 clang/test/InstallAPI/diagnostics-dsym.test   |   4 +-
 .../InstallAPI/directory-scanning-dylib.test  |  57 
 .../directory-scanning-frameworks.test|  89 ++
 clang/test/InstallAPI/functions.test  |   2 +-
 clang/test/InstallAPI/variables.test  |   2 +-
 clang/tools/clang-installapi/Options.cpp  |  51 ++-
 clang/tools/clang-installapi/Options.h|   3 +
 19 files changed, 699 insertions(+), 24 deletions(-)
 create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h
 create mode 100644 clang/include/clang/InstallAPI/Library.h
 create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp
 create mode 100644 clang/lib/InstallAPI/Library.cpp
 create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test
 create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index cdf27247602f2..e10fa71011f30 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is 
not supported: '%1'
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
+def err_directory_scanning: Error<"could not read directory '%0': %1">;
+def err_more_than_one_library: Error<"more than one framework/dynamic library 
found">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h 
b/clang/include/clang/InstallAPI/DirectoryScanner.h
new file mode 100644
index 0..803328982ec87
--- /dev/null
+++ b/clang/include/clang/InstallAPI/DirectoryScanner.h
@@ -0,0 +1,81 @@
+//===- InstallAPI/DirectoryScanner.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// The DirectoryScanner for collecting library files on the file system.
+///
+//===--===//
+#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+
+#include "clang/Basic/FileManager.h"
+#include "clang/InstallAPI/Library.h"
+
+namespace clang::installapi {
+
+enum ScanMode {
+  /// Scanning Framework directory.
+  ScanFrameworks,
+  /// Scanning Dylib directory.
+  ScanDylibs,
+};
+
+class DirectoryScanner {
+public:
+  DirectoryScanner(FileManager , ScanMode Mode = ScanMode::ScanFrameworks)
+  : FM(FM), Mode(Mode) {}
+
+  /// Scan for all input files throughout directory.
+  ///
+  /// \param Directory Path of input directory.
+  llvm::Error scan(StringRef Directory);
+
+  /// Take over ownership of stored libraries.
+  std::vector takeLibraries() { return std::move(Libraries); };
+
+  /// Get all the header files in libraries.
+  ///
+  /// \param Libraries Reference of collection of libraries.
+  static HeaderSeq getHeaders(ArrayRef Libraries);
+
+private:
+  /// Collect files for dylibs in usr/(local)/lib within directory.
+  llvm::Error scanForUnwrappedLibraries(StringRef Directory);
+
+  /// Collect files for any frameworks within directory.
+  llvm::Error scanForFrameworks(StringRef Directory);
+
+  /// Get a library from the libraries collection.
+  Library (StringRef Path, std::vector ) 
const;
+
+  /// Collect multiple frameworks from 

[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/94508

Match TAPI behavior and allow input headers to be resolved via a passed 
directory, which is expected to be a library sitting in a build directory.

>From c547d990aca29ecfe6f51d37c5c3f8712dfc5e44 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 10 May 2024 09:19:22 -0700
Subject: [PATCH] [InstallAPI] Pick up input headers by directory traversal

Match TAPI behavior and allow input headers to be resolved via a passed
directory, which is expected to be a library sitting in a build
directory.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   2 +
 .../clang/InstallAPI/DirectoryScanner.h   |  81 +
 clang/include/clang/InstallAPI/HeaderFile.h   |   8 +
 clang/include/clang/InstallAPI/Library.h  |  65 
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   2 +
 clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++
 clang/lib/InstallAPI/Library.cpp  |  40 +++
 clang/test/InstallAPI/asm.test|   2 +-
 clang/test/InstallAPI/basic.test  |   4 +-
 clang/test/InstallAPI/binary-attributes.test  |   6 +-
 clang/test/InstallAPI/cpp.test|   4 +-
 clang/test/InstallAPI/diagnostics-dsym.test   |   4 +-
 .../InstallAPI/directory-scanning-dylib.test  |  57 
 .../directory-scanning-frameworks.test|  89 ++
 clang/test/InstallAPI/functions.test  |   2 +-
 clang/test/InstallAPI/variables.test  |   2 +-
 clang/tools/clang-installapi/Options.cpp  |  51 ++-
 clang/tools/clang-installapi/Options.h|   3 +
 19 files changed, 699 insertions(+), 24 deletions(-)
 create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h
 create mode 100644 clang/include/clang/InstallAPI/Library.h
 create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp
 create mode 100644 clang/lib/InstallAPI/Library.cpp
 create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test
 create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index cdf27247602f2..e10fa71011f30 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is 
not supported: '%1'
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
+def err_directory_scanning: Error<"could not read directory '%0': %1">;
+def err_more_than_one_library: Error<"more than one framework/dynamic library 
found">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h 
b/clang/include/clang/InstallAPI/DirectoryScanner.h
new file mode 100644
index 0..803328982ec87
--- /dev/null
+++ b/clang/include/clang/InstallAPI/DirectoryScanner.h
@@ -0,0 +1,81 @@
+//===- InstallAPI/DirectoryScanner.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// The DirectoryScanner for collecting library files on the file system.
+///
+//===--===//
+#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H
+
+#include "clang/Basic/FileManager.h"
+#include "clang/InstallAPI/Library.h"
+
+namespace clang::installapi {
+
+enum ScanMode {
+  /// Scanning Framework directory.
+  ScanFrameworks,
+  /// Scanning Dylib directory.
+  ScanDylibs,
+};
+
+class DirectoryScanner {
+public:
+  DirectoryScanner(FileManager , ScanMode Mode = ScanMode::ScanFrameworks)
+  : FM(FM), Mode(Mode) {}
+
+  /// Scan for all input files throughout directory.
+  ///
+  /// \param Directory Path of input directory.
+  llvm::Error scan(StringRef Directory);
+
+  /// Take over ownership of stored libraries.
+  std::vector takeLibraries() { return std::move(Libraries); };
+
+  /// Get all the header files in libraries.
+  ///
+  /// \param Libraries Reference of collection of libraries.
+  static HeaderSeq getHeaders(ArrayRef Libraries);
+
+private:
+  /// Collect files for dylibs in usr/(local)/lib within directory.
+  llvm::Error scanForUnwrappedLibraries(StringRef Directory);
+
+  /// Collect files for any frameworks within directory.
+  llvm::Error scanForFrameworks(StringRef Directory);
+
+  

[clang] [flang] Fix more diagnostic wording for style; NFC (PR #93190)

2024-05-23 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida approved this pull request.

the InstallAPI changes LGTM, thanks! 

https://github.com/llvm/llvm-project/pull/93190
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)

2024-05-20 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/91770
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)

2024-05-20 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/91770

>From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 2 May 2024 19:53:07 -0700
Subject: [PATCH 1/3] [InstallAPI] add JSON option to pass X arguments

---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  2 +-
 clang/test/InstallAPI/alias_list.test |  2 +-
 clang/test/InstallAPI/exclusive-passes-2.test |  9 ++
 clang/test/InstallAPI/exclusive-passes-3.test | 86 +++
 clang/test/InstallAPI/exclusive-passes.test   | 15 
 .../InstallAPI/invalid-exclusive-passes.test  | 33 +++
 .../tools/clang-installapi/InstallAPIOpts.td  |  3 +
 clang/tools/clang-installapi/Options.cpp  | 74 +++-
 clang/tools/clang-installapi/Options.h|  2 +
 9 files changed, 222 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 674742431dcb2..944b2a38b6e96 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
-def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
diff --git a/clang/test/InstallAPI/alias_list.test 
b/clang/test/InstallAPI/alias_list.test
index 3e12221e088c4..aba7e395cca95 100644
--- a/clang/test/InstallAPI/alias_list.test
+++ b/clang/test/InstallAPI/alias_list.test
@@ -23,7 +23,7 @@
 ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s  \
 ; RUN: --check-prefix=INVALID
 
-; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden
+; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': 
invalid input format: missing alias for: _hidden
 
 ;--- Frameworks/AliasList.framework/Headers/AliasList.h
 // simple alias from one symbol to another.
diff --git a/clang/test/InstallAPI/exclusive-passes-2.test 
b/clang/test/InstallAPI/exclusive-passes-2.test
index 3e7a6d777d5af..132b27df383c4 100644
--- a/clang/test/InstallAPI/exclusive-passes-2.test
+++ b/clang/test/InstallAPI/exclusive-passes-2.test
@@ -11,6 +11,15 @@
 ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck 
-allow-empty %s 
 ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib \
+; RUN: -current_version 1 -compatibility_version 1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \
+; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \
+; RUN: -o %t/output2.tbd \
+; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
 ; CHECK-NOT: error
 ; CHECK-NOT: warning
 
diff --git a/clang/test/InstallAPI/exclusive-passes-3.test 
b/clang/test/InstallAPI/exclusive-passes-3.test
new file mode 100644
index 0..3a9b64c9f7b86
--- /dev/null
+++ b/clang/test/InstallAPI/exclusive-passes-3.test
@@ -0,0 +1,86 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+
+// "Apple" label has split options between the optionlist & command line. 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+// Validate duplicated options give same result.
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -XApple -DDarwin -XElf -DNONDarwin \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: warning
+
+;--- 

[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)

2024-05-20 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/91770

>From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 2 May 2024 19:53:07 -0700
Subject: [PATCH 1/2] [InstallAPI] add JSON option to pass X arguments

---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  2 +-
 clang/test/InstallAPI/alias_list.test |  2 +-
 clang/test/InstallAPI/exclusive-passes-2.test |  9 ++
 clang/test/InstallAPI/exclusive-passes-3.test | 86 +++
 clang/test/InstallAPI/exclusive-passes.test   | 15 
 .../InstallAPI/invalid-exclusive-passes.test  | 33 +++
 .../tools/clang-installapi/InstallAPIOpts.td  |  3 +
 clang/tools/clang-installapi/Options.cpp  | 74 +++-
 clang/tools/clang-installapi/Options.h|  2 +
 9 files changed, 222 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 674742431dcb2..944b2a38b6e96 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
-def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
diff --git a/clang/test/InstallAPI/alias_list.test 
b/clang/test/InstallAPI/alias_list.test
index 3e12221e088c4..aba7e395cca95 100644
--- a/clang/test/InstallAPI/alias_list.test
+++ b/clang/test/InstallAPI/alias_list.test
@@ -23,7 +23,7 @@
 ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s  \
 ; RUN: --check-prefix=INVALID
 
-; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden
+; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': 
invalid input format: missing alias for: _hidden
 
 ;--- Frameworks/AliasList.framework/Headers/AliasList.h
 // simple alias from one symbol to another.
diff --git a/clang/test/InstallAPI/exclusive-passes-2.test 
b/clang/test/InstallAPI/exclusive-passes-2.test
index 3e7a6d777d5af..132b27df383c4 100644
--- a/clang/test/InstallAPI/exclusive-passes-2.test
+++ b/clang/test/InstallAPI/exclusive-passes-2.test
@@ -11,6 +11,15 @@
 ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck 
-allow-empty %s 
 ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib \
+; RUN: -current_version 1 -compatibility_version 1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \
+; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \
+; RUN: -o %t/output2.tbd \
+; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
 ; CHECK-NOT: error
 ; CHECK-NOT: warning
 
diff --git a/clang/test/InstallAPI/exclusive-passes-3.test 
b/clang/test/InstallAPI/exclusive-passes-3.test
new file mode 100644
index 0..3a9b64c9f7b86
--- /dev/null
+++ b/clang/test/InstallAPI/exclusive-passes-3.test
@@ -0,0 +1,86 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+
+// "Apple" label has split options between the optionlist & command line. 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+// Validate duplicated options give same result.
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -XApple -DDarwin -XElf -DNONDarwin \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: warning
+
+;--- 

[clang] 504cf55 - [InstallAPI] Pass explicit module cache to avoid permissions issues.

2024-05-10 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-05-10T17:17:38-07:00
New Revision: 504cf554639360525c3f746e7296a242350b2af9

URL: 
https://github.com/llvm/llvm-project/commit/504cf554639360525c3f746e7296a242350b2af9
DIFF: 
https://github.com/llvm/llvm-project/commit/504cf554639360525c3f746e7296a242350b2af9.diff

LOG: [InstallAPI] Pass explicit module cache to avoid permissions issues.

Fixes: https://lab.llvm.org/buildbot/#/builders/192/builds/9313

Added: 


Modified: 
clang/test/InstallAPI/project-header-only-args.test
clang/tools/clang-installapi/Options.cpp

Removed: 




diff  --git a/clang/test/InstallAPI/project-header-only-args.test 
b/clang/test/InstallAPI/project-header-only-args.test
index 7147c83b0f5d4..76fecce5b4a26 100644
--- a/clang/test/InstallAPI/project-header-only-args.test
+++ b/clang/test/InstallAPI/project-header-only-args.test
@@ -1,11 +1,13 @@
 ; RUN: rm -rf %t
 ; RUN: split-file %s %t
 ; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+; RUN: mkdir -p %t/modules.cache
 
 ; RUN: clang-installapi \
 ; RUN: -target arm64-apple-macos12 -install_name @rpath/libfoo.dylib \
 ; RUN: -current_version 1 -compatibility_version 1 \
 ; RUN: -Xproject -fmodules -I%t/usr/include \
+; RUN: -Xproject -fmodules-cache-path=%t/modules.cache \
 ; RUN: -F %S/Inputs/Foundation/ \
 ; RUN: -exclude-public-header %t/usr/include/public.h \
 ; RUN: -extra-project-header %t/project.h -I%t -dynamiclib \
@@ -17,6 +19,7 @@
 ; RUN: -target arm64-apple-macos12 -install_name @rpath/libfoo.dylib \
 ; RUN: -current_version 1 -compatibility_version 1 \
 ; RUN: -Xproject -fmodules -I%t/usr/include \
+; RUN: -Xproject -fmodules-cache-path=%t/modules.cache \
 ; RUN: -extra-project-header %t/project.h \
 ; RUN: -F %S/Inputs/Foundation/ \
 ; RUN: %t/inputs.json \

diff  --git a/clang/tools/clang-installapi/Options.cpp 
b/clang/tools/clang-installapi/Options.cpp
index 5396ad23620b9..53340da704fc0 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -299,8 +299,11 @@ bool Options::processXprojectOption(InputArgList , 
arg_iterator Curr) {
 return false;
   }
 
-  ProjectLevelArgs.push_back(NextA->getSpelling().str());
-  llvm::copy(NextA->getValues(), std::back_inserter(ProjectLevelArgs));
+  std::string ArgString = NextA->getSpelling().str();
+  for (const StringRef Val : NextA->getValues())
+ArgString += Val.str();
+
+  ProjectLevelArgs.push_back(ArgString);
   A->claim();
   NextA->claim();
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)

2024-05-10 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/91770

None

>From 480f1a6dd0c78c8018ac08259b4d3cba64c25165 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 2 May 2024 19:53:07 -0700
Subject: [PATCH] [InstallAPI] add JSON option to pass X arguments

---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  2 +-
 clang/test/InstallAPI/alias_list.test |  2 +-
 clang/test/InstallAPI/exclusive-passes-2.test |  9 ++
 clang/test/InstallAPI/exclusive-passes-3.test | 86 +++
 clang/test/InstallAPI/exclusive-passes.test   | 15 
 .../InstallAPI/invalid-exclusive-passes.test  | 33 +++
 .../tools/clang-installapi/InstallAPIOpts.td  |  3 +
 clang/tools/clang-installapi/Options.cpp  | 74 +++-
 clang/tools/clang-installapi/Options.h|  2 +
 9 files changed, 222 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 674742431dcb2..944b2a38b6e96 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
-def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_cannot_read_input_list : Error<"could not read %0 input list '%1': 
%2">;
 def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
diff --git a/clang/test/InstallAPI/alias_list.test 
b/clang/test/InstallAPI/alias_list.test
index 3e12221e088c4..aba7e395cca95 100644
--- a/clang/test/InstallAPI/alias_list.test
+++ b/clang/test/InstallAPI/alias_list.test
@@ -23,7 +23,7 @@
 ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s  \
 ; RUN: --check-prefix=INVALID
 
-; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden
+; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': 
invalid input format: missing alias for: _hidden
 
 ;--- Frameworks/AliasList.framework/Headers/AliasList.h
 // simple alias from one symbol to another.
diff --git a/clang/test/InstallAPI/exclusive-passes-2.test 
b/clang/test/InstallAPI/exclusive-passes-2.test
index 3e7a6d777d5af..132b27df383c4 100644
--- a/clang/test/InstallAPI/exclusive-passes-2.test
+++ b/clang/test/InstallAPI/exclusive-passes-2.test
@@ -11,6 +11,15 @@
 ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck 
-allow-empty %s 
 ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib \
+; RUN: -current_version 1 -compatibility_version 1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \
+; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \
+; RUN: -o %t/output2.tbd \
+; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
 ; CHECK-NOT: error
 ; CHECK-NOT: warning
 
diff --git a/clang/test/InstallAPI/exclusive-passes-3.test 
b/clang/test/InstallAPI/exclusive-passes-3.test
new file mode 100644
index 0..3a9b64c9f7b86
--- /dev/null
+++ b/clang/test/InstallAPI/exclusive-passes-3.test
@@ -0,0 +1,86 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+
+// "Apple" label has split options between the optionlist & command line. 
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+// Validate duplicated options give same result.
+; RUN: clang-installapi -target arm64-apple-macos12 \
+; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \
+; RUN: -compatibility_version 1 \
+; RUN: -extra-public-header %t/usr/include/opts.h \
+; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \
+; RUN: -I%S/Inputs/LibFoo/usr/include \
+; RUN: -XApple -DDarwin -XElf -DNONDarwin \
+; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s 
-allow-empty 
+; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck 
-allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: warning
+

[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)

2024-05-10 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/90686
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)

2024-05-03 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

ping

https://github.com/llvm/llvm-project/pull/90686
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)

2024-05-02 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/90686

>From faabe7752dbb596f13e0e676b5c8db9fb8ad9258 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 18 Apr 2024 07:28:44 -0700
Subject: [PATCH] [InstallAPI] Support mutually exclusive parse options

Projects like libc use mutually exclusive macros to compile files
multiple times then merge the result into the final library. For
installapi to accept these, we'd need to parse the same declarations in 
different
ways. This patch add the basic pipelining for installapi to create the
correct TBD file.

* -Xproject allows:
  -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers
* -Xlabel allows:
  -D and -U settings
* Error on 'private' and 'public' labels -X
* Xplatform allows:
  -iframework  This is to support the case where zippered
  frameworks want to pass in iOSSupport search path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/InstallAPI/MachO.h|   2 +
 .../Modules/module.modulemap  |   3 +
 .../Inputs/LibFoo/usr/include/foo.h   |  15 +
 .../Inputs/LibFoo/usr/include/macro_defs.h|  15 +
 .../Inputs/LibFoo/usr/include/public.h|   9 +
 .../Zippered.framework/Headers/Zippered.h |  20 +
 .../PrivateHeaders/Zippered_Private.h |   9 +
 .../InstallAPI/Inputs/Zippered/Zippered.tbd   |  47 +++
 .../InstallAPI/Inputs/Zippered/Zippered.yaml  | 383 ++
 clang/test/InstallAPI/exclusive-passes-2.test |  58 +++
 .../InstallAPI/exclusive-passes-platform.test | 286 +
 .../InstallAPI/exclusive-passes-zippered.test |  56 +++
 clang/test/InstallAPI/exclusive-passes.test   |  54 +++
 .../InstallAPI/invalid-exclusive-passes.test  |  37 ++
 .../InstallAPI/project-header-only-args.test  |  81 
 .../clang-installapi/ClangInstallAPI.cpp  |  22 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  30 ++
 clang/tools/clang-installapi/Options.cpp  | 187 +++--
 clang/tools/clang-installapi/Options.h|  13 +-
 llvm/include/llvm/TextAPI/Utils.h |   9 +
 llvm/lib/TextAPI/Utils.cpp|  10 +
 22 files changed, 1316 insertions(+), 31 deletions(-)
 create mode 100644 
clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/macro_defs.h
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml
 create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/project-header-only-args.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 6896e0f5aa593c..674742431dcb2d 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not 
supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 9da91a62e23311..1ea544412f4cd8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol;
 using FileType = llvm::MachO::FileType;
 using PackedVersion = llvm::MachO::PackedVersion;
 using PathSeq = llvm::MachO::PathSeq;
+using PlatformType = llvm::MachO::PlatformType;
+using PathToPlatformSeq = llvm::MachO::PathToPlatformSeq;
 using Target = llvm::MachO::Target;
 using TargetList = llvm::MachO::TargetList;
 
diff --git 
a/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
 
b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
new file mode 100644
index 00..2bb688da1fa4b0

[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)

2024-04-30 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/90686

>From c4fec501607059b1030b7c53794ad271194d Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 18 Apr 2024 07:28:44 -0700
Subject: [PATCH 1/2] [InstallAPI] Support mutually exclusive parse options

Projects like libc use mutually exclusive macros to compile files
multiple times then merge the result into the final library. For
installapi to accept these, we'd need to parse the same declarations in 
different
ways. This patch add the basic pipelining for installapi to create the
correct TBD file.

* -Xproject allows:
  -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers
* -Xlabel allows:
  -D and -U settings
* Error on 'private' and 'public' labels -X
* Xplatform allows:
  -iframework  This is to support the case where zippered
  frameworks want to pass in iOSSupport search path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/InstallAPI/MachO.h|   2 +
 .../Modules/module.modulemap  |   3 +
 .../Inputs/LibFoo/usr/include/foo.h   |  20 +
 .../Inputs/LibFoo/usr/include/public.h|  14 +
 .../Zippered.framework/Headers/Zippered.h |  20 +
 .../PrivateHeaders/Zippered_Private.h |   9 +
 .../InstallAPI/Inputs/Zippered/Zippered.tbd   |  47 +++
 .../InstallAPI/Inputs/Zippered/Zippered.yaml  | 383 ++
 clang/test/InstallAPI/exclusive-passes-2.test |  58 +++
 .../InstallAPI/exclusive-passes-platform.test | 277 +
 .../InstallAPI/exclusive-passes-zippered.test |  56 +++
 clang/test/InstallAPI/exclusive-passes.test   |  54 +++
 .../InstallAPI/invalid-exclusive-passes.test  |  37 ++
 .../InstallAPI/project-header-only-args.test  |  81 
 .../clang-installapi/ClangInstallAPI.cpp  |  20 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  30 ++
 clang/tools/clang-installapi/Options.cpp  | 187 +++--
 clang/tools/clang-installapi/Options.h|  13 +-
 llvm/include/llvm/TextAPI/Utils.h |   9 +
 llvm/lib/TextAPI/Utils.cpp|  10 +
 21 files changed, 1301 insertions(+), 30 deletions(-)
 create mode 100644 
clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml
 create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/project-header-only-args.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 6896e0f5aa593c..674742431dcb2d 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not 
supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 9da91a62e23311..1ea544412f4cd8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol;
 using FileType = llvm::MachO::FileType;
 using PackedVersion = llvm::MachO::PackedVersion;
 using PathSeq = llvm::MachO::PathSeq;
+using PlatformType = llvm::MachO::PlatformType;
+using PathToPlatformSeq = llvm::MachO::PathToPlatformSeq;
 using Target = llvm::MachO::Target;
 using TargetList = llvm::MachO::TargetList;
 
diff --git 
a/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
 
b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
new file mode 100644
index 00..2bb688da1fa4b0
--- /dev/null
+++ 
b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework 

[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)

2024-04-30 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/90686

Projects like libc use mutually exclusive macros to compile files multiple 
times and then merge the result into the final library. For installapi to 
accept these, we'd need to parse the same declarations in different ways. This 
patch adds the basic pipelining for installapi to create the correct TBD file.

* -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers
* -Xlabel allows: -D and -U settings
* Error on 'private' and 'public' labels -X
* Xplatform allows: -iframework  This is to support the case where 
zippered frameworks want to pass in iOSSupport search path.

>From c4fec501607059b1030b7c53794ad271194d Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 18 Apr 2024 07:28:44 -0700
Subject: [PATCH] [InstallAPI] Support mutually exclusive parse options

Projects like libc use mutually exclusive macros to compile files
multiple times then merge the result into the final library. For
installapi to accept these, we'd need to parse the same declarations in 
different
ways. This patch add the basic pipelining for installapi to create the
correct TBD file.

* -Xproject allows:
  -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers
* -Xlabel allows:
  -D and -U settings
* Error on 'private' and 'public' labels -X
* Xplatform allows:
  -iframework  This is to support the case where zippered
  frameworks want to pass in iOSSupport search path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/InstallAPI/MachO.h|   2 +
 .../Modules/module.modulemap  |   3 +
 .../Inputs/LibFoo/usr/include/foo.h   |  20 +
 .../Inputs/LibFoo/usr/include/public.h|  14 +
 .../Zippered.framework/Headers/Zippered.h |  20 +
 .../PrivateHeaders/Zippered_Private.h |   9 +
 .../InstallAPI/Inputs/Zippered/Zippered.tbd   |  47 +++
 .../InstallAPI/Inputs/Zippered/Zippered.yaml  | 383 ++
 clang/test/InstallAPI/exclusive-passes-2.test |  58 +++
 .../InstallAPI/exclusive-passes-platform.test | 277 +
 .../InstallAPI/exclusive-passes-zippered.test |  56 +++
 clang/test/InstallAPI/exclusive-passes.test   |  54 +++
 .../InstallAPI/invalid-exclusive-passes.test  |  37 ++
 .../InstallAPI/project-header-only-args.test  |  81 
 .../clang-installapi/ClangInstallAPI.cpp  |  20 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  30 ++
 clang/tools/clang-installapi/Options.cpp  | 187 +++--
 clang/tools/clang-installapi/Options.h|  13 +-
 llvm/include/llvm/TextAPI/Utils.h |   9 +
 llvm/lib/TextAPI/Utils.cpp|  10 +
 21 files changed, 1301 insertions(+), 30 deletions(-)
 create mode 100644 
clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h
 create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd
 create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml
 create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test
 create mode 100644 clang/test/InstallAPI/exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test
 create mode 100644 clang/test/InstallAPI/project-header-only-args.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 6896e0f5aa593c..674742431dcb2d 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not 
supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
+def err_invalid_label: Error<"label '%0' is reserved: use a different label 
name for -X">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 9da91a62e23311..1ea544412f4cd8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol;
 using FileType = llvm::MachO::FileType;
 using PackedVersion = llvm::MachO::PackedVersion;
 using PathSeq = 

[clang] [InstallAPI] Cleanup I/O error handling for input lists (PR #90664)

2024-04-30 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/90664
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Cleanup I/O error handling for input lists (PR #90664)

2024-04-30 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/90664

Add validation in the FileList reader to check that the headers exist and use 
similar diagnostics in Options.cpp

>From 42ad6921fdf179647f6529ddeb7d060e93e0f52f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Tue, 30 Apr 2024 11:24:42 -0700
Subject: [PATCH] [InstallAPI] Cleanup I/O error handling for input lists

Add validation in FileList reader to actually check that the files
exist and refactor common code in Options.cpp
---
 clang/include/clang/Basic/DiagnosticInstallAPIKinds.td |  2 +-
 clang/include/clang/InstallAPI/FileList.h  |  3 ++-
 clang/lib/InstallAPI/FileList.cpp  | 10 +-
 clang/tools/clang-installapi/Options.cpp   |  9 +
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 91a40cd589b385..6896e0f5aa593c 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
-def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
+def err_cannot_read_input_list : Error<"could not read %select{alias 
list|filelist}0 '%1': %2">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/FileList.h 
b/clang/include/clang/InstallAPI/FileList.h
index 460af003b6a0ac..913734b8dc7c88 100644
--- a/clang/include/clang/InstallAPI/FileList.h
+++ b/clang/include/clang/InstallAPI/FileList.h
@@ -29,9 +29,10 @@ class FileListReader {
   ///
   /// \param InputBuffer JSON input data.
   /// \param Destination Container to load headers into.
+  /// \param FM Optional File Manager to validate input files exist.
   static llvm::Error
   loadHeaders(std::unique_ptr InputBuffer,
-  HeaderSeq );
+  HeaderSeq , clang::FileManager *FM = nullptr);
 
   FileListReader() = delete;
 };
diff --git a/clang/lib/InstallAPI/FileList.cpp 
b/clang/lib/InstallAPI/FileList.cpp
index 8a01248659b7d7..65610903840af7 100644
--- a/clang/lib/InstallAPI/FileList.cpp
+++ b/clang/lib/InstallAPI/FileList.cpp
@@ -51,6 +51,7 @@ class Implementation {
 
 public:
   std::unique_ptr InputBuffer;
+  clang::FileManager *FM;
   unsigned Version;
   HeaderSeq HeaderList;
 
@@ -124,6 +125,12 @@ Error Implementation::parseHeaders(Array ) {
   HeaderFile{PathStr, *Type, /*IncludeName=*/"", Language});
   continue;
 }
+
+if (FM)
+  if (!FM->getOptionalFileRef(PathStr))
+return createFileError(
+PathStr, make_error_code(std::errc::no_such_file_or_directory));
+
 auto IncludeName = createIncludeHeaderName(PathStr);
 HeaderList.emplace_back(PathStr, *Type,
 IncludeName.has_value() ? IncludeName.value() : "",
@@ -170,9 +177,10 @@ Error Implementation::parse(StringRef Input) {
 
 llvm::Error
 FileListReader::loadHeaders(std::unique_ptr InputBuffer,
-HeaderSeq ) {
+HeaderSeq , clang::FileManager *FM) {
   Implementation Impl;
   Impl.InputBuffer = std::move(InputBuffer);
+  Impl.FM = FM;
 
   if (llvm::Error Err = Impl.parse(Impl.InputBuffer->getBuffer()))
 return Err;
diff --git a/clang/tools/clang-installapi/Options.cpp 
b/clang/tools/clang-installapi/Options.cpp
index ae5b697b8eb9e0..21f04a291b2f1f 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -697,8 +697,8 @@ InstallAPIContext Options::createContext() {
 }
 Expected Result = parseAliasList(Buffer.get());
 if (!Result) {
-  Diags->Report(diag::err_cannot_read_alias_list)
-  << ListPath << toString(Result.takeError());
+  Diags->Report(diag::err_cannot_read_input_list)
+  << /*IsFileList=*/false << ListPath << toString(Result.takeError());
   return Ctx;
 }
 Aliases.insert(Result.get().begin(), Result.get().end());
@@ -717,8 +717,9 @@ InstallAPIContext Options::createContext() {
   return Ctx;
 }
 if (auto Err = FileListReader::loadHeaders(std::move(Buffer.get()),
-   Ctx.InputHeaders)) {
-  Diags->Report(diag::err_cannot_open_file) << ListPath << std::move(Err);
+   Ctx.InputHeaders, FM)) {
+  Diags->Report(diag::err_cannot_read_input_list)
+  << /*IsFileList=*/true << ListPath << std::move(Err);
   return Ctx;
 }
   }

___

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-26 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> Overall I really like the direction of this. I'm curious if any of the 
> maintainers from Apple have thoughts since they're the primary users of 
> availability annotations.

While I like the approach of aligning availability parameters closer to 
`llvm::Triple`, I am concerned about how this will interact with existing 
precedent. There is a lot of code that passes in _platform_ values that aren't 
actually `OSType`. For example `__attribute__((availability(macCatalyst, ...))` 
aligns to `EnviornmentType::MacABI` and 
`__attribute__((availability(macOSApplicationExtension, ...)))` aligns to  cli 
args `-mtargetos=macos -fapplication-extension`. It may become difficult to 
maintain the distinction between what is accepted as a `platform` vs a 
`environment`. And we can't realistically re-write client code relying on this. 
This attribute behavior also aligns very closely with Swift's `@available`
Would it be possible to similarly treat the target shader stages & combinations 
as platform values as well? Or define a new attribute that does not conflict. 


https://github.com/llvm/llvm-project/pull/89809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [mlir] [lldb][Core] Remove pointless condition (PR #89480)

2024-04-19 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

It appears your PR branch is based on a stale version of the target `llvm/main` 
branch, resulting in more commits than what this PR intended for. Please merge 
in the target branch and resolve any conflicts. 

https://github.com/llvm/llvm-project/pull/89480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)

2024-04-19 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/89483
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)

2024-04-19 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida edited 
https://github.com/llvm/llvm-project/pull/89483
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)

2024-04-19 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/89483

Matches up with the clang tools

>From 76ece379c8a8325b0f866a89e1de523cbeaa0c25 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 19 Apr 2024 19:34:14 -0700
Subject: [PATCH] [clang][darwin][cmake] Disable plugin support at LLVM level

---
 clang/cmake/caches/Apple-stage2.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index ede256a2da6b8f..e919c56739679e 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -16,6 +16,7 @@ set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES OFF CACHE BOOL "")
+set(LLVM_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)

2024-04-18 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/89270
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)

2024-04-18 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> How hard would it be to make the output here have a consistent order? I mean, 
> emitting diagnostics in a consistent order isn't nearly as important as 
> emitting consistent binaries, but it's still nice to have if we can get it 
> easily.

I don't think it's too hard in general, but a little more effort to get it done 
in a performant fashion for the passing InstallAPI case. Something I'd want to 
profile before committing to.

https://github.com/llvm/llvm-project/pull/89270
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-18 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> It looks like this is causing failures on the reverse-iteration buildbot 
> (https://lab.llvm.org/buildbot/#/builders/54/builds/9683)

Thanks for the heads up, should be fixed by 
https://github.com/llvm/llvm-project/pull/89270

https://github.com/llvm/llvm-project/pull/87674
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)

2024-04-18 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/89270

None

>From efefd04b1545b62f3a22bc0ff53bfb0a2a512b1f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 18 Apr 2024 10:24:35 -0700
Subject: [PATCH] [InstallAPI][Tests] Update tests to be resilient to reversion
 iteration config

---
 clang/test/InstallAPI/binary-attributes.test | 2 +-
 clang/test/InstallAPI/rpath.test | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/InstallAPI/binary-attributes.test 
b/clang/test/InstallAPI/binary-attributes.test
index d97c7a14a98d78..b28e99f6445462 100644
--- a/clang/test/InstallAPI/binary-attributes.test
+++ b/clang/test/InstallAPI/binary-attributes.test
@@ -43,7 +43,7 @@
 ; RUN: -current_version 1.2.3  -compatibility_version 1 \
 ; RUN: -allowable_client Foo -allowable_client Bar \
 ; RUN: -o tmp.tbd --verify-against=%t/Simple 2>&1 | FileCheck 
-check-prefix=ALLOWABLE %s
-; ALLOWABLE: error: allowable client missing from binary file: 'Foo [ x86_64 ]'
+; ALLOWABLE: error: allowable client missing from binary file: '{{Foo|Bar}} [ 
x86_64 ]'
 
 ; RUN: not clang-installapi -target x86_64-apple-macos10.12 \
 ; RUN: -install_name 
/System/Library/Frameworks/Simple.framework/Versions/A/Simple \
diff --git a/clang/test/InstallAPI/rpath.test b/clang/test/InstallAPI/rpath.test
index 083a15419abaab..ace9c47b6e686a 100644
--- a/clang/test/InstallAPI/rpath.test
+++ b/clang/test/InstallAPI/rpath.test
@@ -12,8 +12,8 @@
 ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s --check-prefix=MISSING
 ; RUN: llvm-readtapi --compare %t/RPath_warnings.tbd %t/expected_no_rpaths.tbd
 
-; MISSING: warning: runpath search paths missing from installAPI option: 
'@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]'
-; MISSING: warning: runpath search paths missing from installAPI option: 
'@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]'
+; MISSING-DAG: warning: runpath search paths missing from installAPI option: 
'@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]'
+; MISSING-DAG: warning: runpath search paths missing from installAPI option: 
'@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]'
 
 ; RUN: clang-installapi --filetype=tbd-v5 \
 ; RUN: -target arm64-apple-macos13.0 -target x86_64-apple-macos13.0 \

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-18 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/88750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-17 Thread Cyndy Ishida via cfe-commits


@@ -259,7 +259,10 @@ bool Options::processLinkerOptions(InputArgList ) {
   if (auto *Arg = Args.getLastArg(drv::OPT_umbrella))
 LinkerOpts.ParentUmbrella = Arg->getValue();
 
-  LinkerOpts.IsDylib = Args.hasArg(drv::OPT_dynamiclib);

cyndyishida wrote:

nope, looks like I was missing some test coverage, added one implicitly here 
https://github.com/llvm/llvm-project/pull/88750/files#diff-0b1bbd3584706760de8a4030db1b04120c2c7c1f640681be80114f59278988bfR22

https://github.com/llvm/llvm-project/pull/88750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-17 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88750

>From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH 1/4] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  24 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  12 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 569 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations to report.
   VerificationMode Mode = VerificationMode::Invalid;
 
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 854399f54ba6c8..9da91a62e23311 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -23,6 +23,7 @@
 #include "llvm/TextAPI/TextAPIWriter.h"
 #include 

[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-17 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

ping, is there anything else needed to land this patch? 

https://github.com/llvm/llvm-project/pull/88750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88750

>From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH 1/3] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  24 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  12 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 569 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations to report.
   VerificationMode Mode = VerificationMode::Invalid;
 
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 854399f54ba6c8..9da91a62e23311 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -23,6 +23,7 @@
 #include "llvm/TextAPI/TextAPIWriter.h"
 #include 

[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88750

>From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH 1/2] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  24 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  12 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 569 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations to report.
   VerificationMode Mode = VerificationMode::Invalid;
 
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 854399f54ba6c8..9da91a62e23311 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -23,6 +23,7 @@
 #include "llvm/TextAPI/TextAPIWriter.h"
 #include 

[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits


@@ -973,5 +978,24 @@ bool DylibVerifier::verifyBinaryAttrs(const 
ArrayRef ProvidedTargets,
   return true;
 }
 
+std::unique_ptr DylibVerifier::getExports() {
+  for (const auto &[Alias, Base] : Aliases) {

cyndyishida wrote:

`getExports()` only gets called once for the whole lifetime of InstallAPI as it 
releases ownership over the exports to forward along to write out the final TBD 
file. 

https://github.com/llvm/llvm-project/pull/88750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88750

>From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  24 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  12 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 569 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations to report.
   VerificationMode Mode = VerificationMode::Invalid;
 
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 854399f54ba6c8..9da91a62e23311 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -23,6 +23,7 @@
 #include "llvm/TextAPI/TextAPIWriter.h"
 #include 

[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88750

>From d7a4e72f80a9dcd18770dec1e06fd54518b60233 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  24 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  12 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 569 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations to report.
   VerificationMode Mode = VerificationMode::Invalid;
 
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 854399f54ba6c8..9da91a62e23311 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -23,6 +23,7 @@
 #include "llvm/TextAPI/TextAPIWriter.h"
 #include 

[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)

2024-04-15 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/88750

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same input and 
account for it in verification.

>From 3170f89b36ccf3ad6003f24decb282e23951d943 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 13:13:45 -0700
Subject: [PATCH] [InstallAPI] Add support for aliased exports

Apple's ld supports alias_lists, described as
```
 -alias_list filename
 The specified filename contains a list of aliases. The symbol name 
and its alias are on one
 line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   1 +
 clang/include/clang/Driver/Options.td |   1 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  15 +-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  24 +
 clang/test/InstallAPI/alias_list.test | 461 ++
 clang/tools/clang-installapi/Options.cpp  |  26 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/Utils.h |  11 +
 llvm/lib/TextAPI/Utils.cpp|  34 ++
 10 files changed, 570 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/InstallAPI/alias_list.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 396bff0146a373..91a40cd589b385 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found 
for target variant
 def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
 def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
 def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
+def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24626913add76..8c38acb72362c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], 
"end-no-unused-arguments">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">,
   Visibility<[ClangOption, CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
+def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>;
 def extract_api : Flag<["-"], "extract-api">,
   Visibility<[ClangOption, CC1Option]>, Group,
   HelpText<"Extract API information">;
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 31de212fc423a5..f1a949d8f99394 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
-bool Demangle, StringRef DSYMPath)
-  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
+AliasMap Aliases, DiagnosticsEngine *Diag,
+VerificationMode Mode, bool Zippered, bool Demangle,
+StringRef DSYMPath)
+  : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)),
+Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered),
+Demangle(Demangle), DSYMPath(DSYMPath),
 Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
@@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   void setTarget(const Target );
 
   /// Release ownership over exports.
-  std::unique_ptr getExports() { return std::move(Exports); }
+  std::unique_ptr getExports();
 
   /// Get result of verification.
   Result getState() const { return Ctx.FrontendState; }
@@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Reexported interfaces apart of the library.
   ReexportedInterfaces Reexports;
 
+  // Symbol aliases.
+  AliasMap Aliases;
+
   // Controls what class of violations 

[clang] 79dca25 - [InstallAPI] Replace std::string -> StringRef

2024-04-12 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-04-12T22:05:12-07:00
New Revision: 79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb

URL: 
https://github.com/llvm/llvm-project/commit/79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb
DIFF: 
https://github.com/llvm/llvm-project/commit/79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb.diff

LOG: [InstallAPI] Replace std::string -> StringRef

Added: 


Modified: 
clang/tools/clang-installapi/Options.cpp

Removed: 




diff  --git a/clang/tools/clang-installapi/Options.cpp 
b/clang/tools/clang-installapi/Options.cpp
index 120ff3da899868..3dc61476ce09d9 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -372,7 +372,7 @@ bool Options::addFilePaths(InputArgList , PathSeq 
,
   }
   // Sort headers to ensure deterministic behavior.
   sort(*InputHeadersOrErr);
-  for (std::string  : *InputHeadersOrErr)
+  for (StringRef H : *InputHeadersOrErr)
 Headers.emplace_back(std::move(H));
 } else
   Headers.emplace_back(Path);
@@ -690,7 +690,7 @@ InstallAPIContext Options::createContext() {
 FrameworkName = getFrameworkNameFromInstallName(LinkerOpts.InstallName);
 
   // Process inputs.
-  for (const std::string  : DriverOpts.FileLists) {
+  for (const StringRef ListPath : DriverOpts.FileLists) {
 auto Buffer = FM->getBufferForFile(ListPath);
 if (auto Err = Buffer.getError()) {
   Diags->Report(diag::err_cannot_open_file) << ListPath << Err.message();



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Handle zippered frameworks (PR #88205)

2024-04-11 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/88205
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)

2024-04-11 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/88448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)

2024-04-11 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88448

>From 0039cbc0d53a4ff8530b78657f8365229162516b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 14:10:15 -0700
Subject: [PATCH 1/2] [clang][docs] Modernize attribute docs for darwin
 specifics

* Generally recommend target triples. But replace `m*version-min` with
  `mtargetos`.
* Also include test coverage for -mtargetos=visionos.
---
 clang/include/clang/Basic/AttrDocs.td | 30 +--
 clang/test/Driver/mtargetos-darwin.c  |  2 ++
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ca4ea377fc36a..a37e9f97a19ccd 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1604,23 +1604,31 @@ specifies availability for the current target platform, 
the availability
 attributes are ignored. Supported platforms are:
 
 ``ios``
-  Apple's iOS operating system. The minimum deployment target is specified by
-  the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*``
-  command-line arguments.
+  Apple's iOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  ``-mtargetos=ios*version*`` command-line argument.
 
 ``macos``
-  Apple's macOS operating system. The minimum deployment target is
-  specified by the ``-mmacosx-version-min=*version*`` command-line argument.
-  ``macosx`` is supported for backward-compatibility reasons, but it is
-  deprecated.
+  Apple's macOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  ``-mtargetos=macos*version*`` or ``-mtargetos=macosx*version*``
+  command-line arguments. ``macosx`` is supported for backward-compatibility 
+  reasons, but it is deprecated.
 
 ``tvos``
-  Apple's tvOS operating system. The minimum deployment target is specified by
-  the ``-mtvos-version-min=*version*`` command-line argument.
+  Apple's tvOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=tvos*version*`` command-line argument.
 
 ``watchos``
-  Apple's watchOS operating system. The minimum deployment target is specified 
by
-  the ``-mwatchos-version-min=*version*`` command-line argument.
+  Apple's watchOS operating system. The minimum deployment target is specified
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=watchos*version*`` command-line argument.
+
+``visionos``
+  Apple's visionOS operating system. The minimum deployment target is specified
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=visionos*version*`` command-line argument.
 
 ``driverkit``
   Apple's DriverKit userspace kernel extensions. The minimum deployment target
diff --git a/clang/test/Driver/mtargetos-darwin.c 
b/clang/test/Driver/mtargetos-darwin.c
index e706be37a371f4..7e86ab15279b9a 100644
--- a/clang/test/Driver/mtargetos-darwin.c
+++ b/clang/test/Driver/mtargetos-darwin.c
@@ -4,6 +4,7 @@
 // RUN: %clang -mtargetos=ios14-macabi -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=MACCATALYST %s
 // RUN: %clang -mtargetos=tvos14 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=TVOS %s
 // RUN: %clang -mtargetos=watchos7.1 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=WATCHOS %s
+// RUN: %clang -mtargetos=visionos1 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=VISIONOS %s
 
 // RUN: not %clang -target arm64-apple-ios14 -mtargetos=ios14 -arch arm64 -c 
%s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX1 %s
 // RUN: not %clang -mtargetos=ios14 -arch arm64 -miphoneos-version-min=14 -c 
%s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX2 %s
@@ -19,6 +20,7 @@
 // MACCATALYST: "-cc1" "-triple" "arm64-apple-ios14.0.0-macabi"
 // TVOS: "-cc1" "-triple" "arm64-apple-tvos14.0.0"
 // WATCHOS: "-cc1" "-triple" "arm64-apple-watchos7.1.0"
+// VISIONOS: "-cc1" "-triple" "arm64-apple-xros1.0.0"
 
 // NOMIX1: error: cannot specify '-mtargetos=ios14' along with '-target 
arm64-apple-ios14'
 // NOMIX2: error: cannot specify '-miphoneos-version-min=14' along with 
'-mtargetos=ios14'

>From 5577083efc7e642f23c961b80cb2aa33acb6f14d Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 15:49:13 -0700
Subject: [PATCH 2/2] Address review comments

---
 clang/include/clang/Basic/AttrDocs.td | 31 ---
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a37e9f97a19ccd..8687c4f57d3f83 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1605,34 +1605,39 @@ attributes are 

[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)

2024-04-11 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/88448

* Generally recommend target triples. But replace `m*version-min` with 
`mtargetos`.
* Also include test coverage for -mtargetos=visionos

>From 0039cbc0d53a4ff8530b78657f8365229162516b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 11 Apr 2024 14:10:15 -0700
Subject: [PATCH] [clang][docs] Modernize attribute docs for darwin specifics

* Generally recommend target triples. But replace `m*version-min` with
  `mtargetos`.
* Also include test coverage for -mtargetos=visionos.
---
 clang/include/clang/Basic/AttrDocs.td | 30 +--
 clang/test/Driver/mtargetos-darwin.c  |  2 ++
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ca4ea377fc36a..a37e9f97a19ccd 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1604,23 +1604,31 @@ specifies availability for the current target platform, 
the availability
 attributes are ignored. Supported platforms are:
 
 ``ios``
-  Apple's iOS operating system. The minimum deployment target is specified by
-  the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*``
-  command-line arguments.
+  Apple's iOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  ``-mtargetos=ios*version*`` command-line argument.
 
 ``macos``
-  Apple's macOS operating system. The minimum deployment target is
-  specified by the ``-mmacosx-version-min=*version*`` command-line argument.
-  ``macosx`` is supported for backward-compatibility reasons, but it is
-  deprecated.
+  Apple's macOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  ``-mtargetos=macos*version*`` or ``-mtargetos=macosx*version*``
+  command-line arguments. ``macosx`` is supported for backward-compatibility 
+  reasons, but it is deprecated.
 
 ``tvos``
-  Apple's tvOS operating system. The minimum deployment target is specified by
-  the ``-mtvos-version-min=*version*`` command-line argument.
+  Apple's tvOS operating system. The minimum deployment target is specified 
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=tvos*version*`` command-line argument.
 
 ``watchos``
-  Apple's watchOS operating system. The minimum deployment target is specified 
by
-  the ``-mwatchos-version-min=*version*`` command-line argument.
+  Apple's watchOS operating system. The minimum deployment target is specified
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=watchos*version*`` command-line argument.
+
+``visionos``
+  Apple's visionOS operating system. The minimum deployment target is specified
+  as part of the triple. Alternatively, it can be specified by the 
+  the ``-mtargetos=visionos*version*`` command-line argument.
 
 ``driverkit``
   Apple's DriverKit userspace kernel extensions. The minimum deployment target
diff --git a/clang/test/Driver/mtargetos-darwin.c 
b/clang/test/Driver/mtargetos-darwin.c
index e706be37a371f4..7e86ab15279b9a 100644
--- a/clang/test/Driver/mtargetos-darwin.c
+++ b/clang/test/Driver/mtargetos-darwin.c
@@ -4,6 +4,7 @@
 // RUN: %clang -mtargetos=ios14-macabi -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=MACCATALYST %s
 // RUN: %clang -mtargetos=tvos14 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=TVOS %s
 // RUN: %clang -mtargetos=watchos7.1 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=WATCHOS %s
+// RUN: %clang -mtargetos=visionos1 -arch arm64 -c %s -o %t.o -### 2>&1 | 
FileCheck --check-prefix=VISIONOS %s
 
 // RUN: not %clang -target arm64-apple-ios14 -mtargetos=ios14 -arch arm64 -c 
%s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX1 %s
 // RUN: not %clang -mtargetos=ios14 -arch arm64 -miphoneos-version-min=14 -c 
%s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX2 %s
@@ -19,6 +20,7 @@
 // MACCATALYST: "-cc1" "-triple" "arm64-apple-ios14.0.0-macabi"
 // TVOS: "-cc1" "-triple" "arm64-apple-tvos14.0.0"
 // WATCHOS: "-cc1" "-triple" "arm64-apple-watchos7.1.0"
+// VISIONOS: "-cc1" "-triple" "arm64-apple-xros1.0.0"
 
 // NOMIX1: error: cannot specify '-mtargetos=ios14' along with '-target 
arm64-apple-ios14'
 // NOMIX2: error: cannot specify '-miphoneos-version-min=14' along with 
'-mtargetos=ios14'

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Handle zippered frameworks (PR #88205)

2024-04-10 Thread Cyndy Ishida via cfe-commits


@@ -588,13 +622,58 @@ void DylibVerifier::visitSymbolInDylib(const Record , 
SymbolContext ) {
 }
   }
 
+  const bool IsLinkerSymbol = SymbolName.starts_with("$ld$");
+
+  if (R.isVerified()) {
+// Check for unavailable symbols.
+// This should only occur in the zippered case where we ignored
+// availability until all headers have been parsed.
+auto It = DeferredZipperedSymbols.find(SymCtx.SymbolName);
+if (It == DeferredZipperedSymbols.end()) {
+  updateState(Result::Valid);
+  return;
+}
+
+ZipperedDeclSources Locs;
+for (const ZipperedDeclSource  : It->second) {
+  if (ZSource.FA->Avail.isObsoleted()) {
+updateState(Result::Ignore);
+return;
+  }
+  if (ZSource.T.Arch != Ctx.Target.Arch)
+continue;
+  Locs.emplace_back(ZSource);
+}
+assert(Locs.size() == 2 && "Expected two decls for zippered symbol");

cyndyishida wrote:

Ah, so that errors out differently with 
```
error: no declaration found for exported symbol '_unavailableSymbol' in a 
dynamic library
```
in clang-installapi & tapi. That should be improved to also show the source 
location, can do in a separate patch. 

https://github.com/llvm/llvm-project/pull/88205
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Handle zippered frameworks (PR #88205)

2024-04-10 Thread Cyndy Ishida via cfe-commits


@@ -588,13 +622,58 @@ void DylibVerifier::visitSymbolInDylib(const Record , 
SymbolContext ) {
 }
   }
 
+  const bool IsLinkerSymbol = SymbolName.starts_with("$ld$");
+
+  if (R.isVerified()) {
+// Check for unavailable symbols.
+// This should only occur in the zippered case where we ignored
+// availability until all headers have been parsed.
+auto It = DeferredZipperedSymbols.find(SymCtx.SymbolName);
+if (It == DeferredZipperedSymbols.end()) {
+  updateState(Result::Valid);
+  return;
+}
+
+ZipperedDeclSources Locs;
+for (const ZipperedDeclSource  : It->second) {
+  if (ZSource.FA->Avail.isObsoleted()) {
+updateState(Result::Ignore);
+return;
+  }
+  if (ZSource.T.Arch != Ctx.Target.Arch)
+continue;
+  Locs.emplace_back(ZSource);
+}
+assert(Locs.size() == 2 && "Expected two decls for zippered symbol");

cyndyishida wrote:

My thinking at this point is that the only kind of error is when every version 
of the decl look unavailable (no decl at all/only one available decl are 
handled separately). Because this check is handled after all CC1 invocations 
have finished, any macro-guarded declarations should have been resolved and 
show 2. 
e.g. 
```
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
extern int unavailableSymbol API_UNAVAILABLE(macos) ;
#else
extern int unavailableSymbol API_UNAVAILABLE(macCatalyst);
#endif
```
results in 

```
warning: violations found for arm64-apple-macos13
/Users/cishida/Builds/llvm-build/tools/clang/test/InstallAPI/Output/diagnostics-zippered.test.tmp/System/Library/Frameworks/Mismatch.framework/Headers/Mismatch.h:16:5:
 error: declaration 'unavailableSymbol' is marked unavailable, but symbol is 
exported in dynamic library
   16 | int unavailableSymbol API_UNAVAILABLE(macos) ;
  | ^
warning: violations found for arm64-apple-ios16.0-macabi 
/Users/cishida/Builds/llvm-build/tools/clang/test/InstallAPI/Output/diagnostics-zippered.test.tmp/System/Library/Frameworks/Mismatch.framework/Headers/Mismatch.h:18:5:
 error: declaration 'unavailableSymbol' is marked unavailable, but symbol is 
exported in dynamic library
   18 | int unavailableSymbol API_UNAVAILABLE(macCatalyst);
  | ^
```

Were you thinking of a different example? 

https://github.com/llvm/llvm-project/pull/88205
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Handle zippered frameworks (PR #88205)

2024-04-09 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/88205

A zippered framework is a single framework that can be loaded in both macOS and 
macatalyst processes. Broadly to InstallAPI, it means the same interface can 
represent two separate platforms.

A dylib's symbol table does not distinguish between macOS/macCatalyst.
  `InstallAPI` provides the ability for the tbd file to distinct
symbols between them.
The verifier handles this special logic by tracking all unavailable and 
obsoleted APIs in this context and checking against those when determining 
dylib symbols with no matching declaration.

* If there exists an available decl for either platform, do not warn.
* If there is no available decl, emit a diagnostic and print the source 
location for both decls.

>From cf8e63e06d8ed8ee626aab4fdf5ec499ed476b51 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Tue, 9 Apr 2024 14:14:10 -0700
Subject: [PATCH] [InstallAPI] Handle zippered frameworks

A zippered framework is a single framework that can be loaded in both macOS and
macatalyst processes. Broadly to InstallAPI, it means the same interface can
represent two seperate platforms.

A dylib's symbol table does not distinct between macOS/macCatalyst.
  `InstallAPI` provides ability for the tbd file to distinct
symbols between them.
The verifier handles this special logic by tracking all unavailable and
obsoleted APIs in this context and check against those when determining
dylib symbols with no matching declaration.

* If there exists an available decl for either platform, do not warn.
* If there is no available decl, emit an diagnostic and print the source
  location for both decls.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |   4 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  32 +-
 clang/lib/InstallAPI/DylibVerifier.cpp|  98 ++-
 .../Inputs/MacOSX13.0.sdk/SDKSettings.json|  19 +
 .../test/InstallAPI/diagnostics-zippered.test | 765 ++
 .../InstallAPI/driver-invalid-options.test|   7 +
 clang/tools/clang-installapi/Options.cpp  |  52 +-
 clang/tools/clang-installapi/Options.h|   3 +
 8 files changed, 964 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/InstallAPI/Inputs/MacOSX13.0.sdk/SDKSettings.json
 create mode 100644 clang/test/InstallAPI/diagnostics-zippered.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 0a477da7186b09..396bff0146a373 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -20,6 +20,10 @@ def warn_no_such_excluded_header_file : Warning<"no such 
excluded %select{public
 def warn_glob_did_not_match: Warning<"glob '%0' did not match any header 
file">, InGroup;
 def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
 def err_cannot_find_reexport : Error<"cannot find re-exported 
%select{framework|library}0: '%1'">;
+def err_no_matching_target : Error<"no matching target found for target 
variant '%0'">;
+def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
+def err_unsupported_environment : Error<"environment '%0' is not supported: 
'%1'">;
+def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index a3df25f10de4b1..31de212fc423a5 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -28,6 +28,16 @@ enum class VerificationMode {
 using LibAttrs = llvm::StringMap;
 using ReexportedInterfaces = llvm::SmallVector;
 
+// Pointers to information about a zippered declaration used for
+// querying and reporting violations against different
+// declarations that all map to the same symbol.
+struct ZipperedDeclSource {
+  const FrontendAttrs *FA;
+  clang::SourceManager *SrcMgr;
+  Target T;
+};
+using ZipperedDeclSources = std::vector;
+
 /// Service responsible to tracking state of verification across the
 /// lifetime of InstallAPI.
 /// As declarations are collected during AST traversal, they are
@@ -68,10 +78,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, ReexportedInterfaces &,
-DiagnosticsEngine *Diag, VerificationMode Mode, bool Demangle,
-StringRef DSYMPath)
+DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered,
+bool Demangle, StringRef DSYMPath)
   : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode),
-Demangle(Demangle), DSYMPath(DSYMPath),
+Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath),
 

[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)

2024-04-09 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/88189
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)

2024-04-09 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/88189

>From a7894f987b80f1916195c3ab15da5c33ab69ab00 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Tue, 9 Apr 2024 13:04:18 -0700
Subject: [PATCH] [InstallAPI] Tie lifetime of FE objects to DylibVerifier

A few verification checks need to happen until all AST's have been
traversed, specifically for zippered framework checking.
To keep source location until that time valid, hold onto to
references of FrontendRecords + SourceManager.
---
 .../include/clang/InstallAPI/DylibVerifier.h  | 10 ++--
 clang/include/clang/InstallAPI/Frontend.h |  2 +-
 .../clang/InstallAPI/FrontendRecords.h|  1 +
 clang/lib/InstallAPI/DylibVerifier.cpp| 47 +--
 clang/lib/InstallAPI/Frontend.cpp | 15 +++---
 .../clang-installapi/ClangInstallAPI.cpp  |  2 +
 6 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 07dbd3bf5f2b10..a3df25f10de4b1 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_INSTALLAPI_DYLIBVERIFIER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/InstallAPI/MachO.h"
 
 namespace clang {
@@ -99,11 +100,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   Result getState() const { return Ctx.FrontendState; }
 
   /// Set different source managers to the same diagnostics engine.
-  void setSourceManager(SourceManager ) const {
-if (!Ctx.Diag)
-  return;
-Ctx.Diag->setSourceManager();
-  }
+  void setSourceManager(IntrusiveRefCntPtr SourceMgr);
 
 private:
   /// Determine whether to compare declaration to symbol in binary.
@@ -190,6 +187,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 
   // Track DWARF provided source location for dylibs.
   DWARFContext *DWARFCtx = nullptr;
+
+  // Source manager for each unique compiler instance.
+  llvm::SmallVector, 12> SourceManagers;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/Frontend.h 
b/clang/include/clang/InstallAPI/Frontend.h
index 5cccd891c58093..bc4e77de2b7256 100644
--- a/clang/include/clang/InstallAPI/Frontend.h
+++ b/clang/include/clang/InstallAPI/Frontend.h
@@ -36,7 +36,7 @@ class InstallAPIAction : public ASTFrontendAction {
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
  StringRef InFile) override {
 Ctx.Diags->getClient()->BeginSourceFile(CI.getLangOpts());
-Ctx.Verifier->setSourceManager(CI.getSourceManager());
+Ctx.Verifier->setSourceManager(CI.getSourceManagerPtr());
 return std::make_unique(
 CI.getASTContext(), Ctx, CI.getSourceManager(), CI.getPreprocessor());
   }
diff --git a/clang/include/clang/InstallAPI/FrontendRecords.h 
b/clang/include/clang/InstallAPI/FrontendRecords.h
index 59271e81e230c2..ef82398addd7ac 100644
--- a/clang/include/clang/InstallAPI/FrontendRecords.h
+++ b/clang/include/clang/InstallAPI/FrontendRecords.h
@@ -21,6 +21,7 @@ namespace installapi {
 struct FrontendAttrs {
   const AvailabilityInfo Avail;
   const Decl *D;
+  const SourceLocation Loc;
   const HeaderType Access;
 };
 
diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp 
b/clang/lib/InstallAPI/DylibVerifier.cpp
index 2387ee0e78ad56..4fa2d4e9292c72 100644
--- a/clang/lib/InstallAPI/DylibVerifier.cpp
+++ b/clang/lib/InstallAPI/DylibVerifier.cpp
@@ -214,16 +214,16 @@ bool DylibVerifier::compareObjCInterfaceSymbols(const 
Record *R,
  StringRef SymName, bool PrintAsWarning = false) {
 if (SymLinkage == RecordLinkage::Unknown)
   Ctx.emitDiag([&]() {
-Ctx.Diag->Report(SymCtx.FA->D->getLocation(),
- PrintAsWarning ? diag::warn_library_missing_symbol
-: diag::err_library_missing_symbol)
+Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning
+ ? 
diag::warn_library_missing_symbol
+ : 
diag::err_library_missing_symbol)
 << SymName;
   });
 else
   Ctx.emitDiag([&]() {
-Ctx.Diag->Report(SymCtx.FA->D->getLocation(),
- PrintAsWarning ? diag::warn_library_hidden_symbol
-: diag::err_library_hidden_symbol)
+Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning
+ ? diag::warn_library_hidden_symbol
+ : diag::err_library_hidden_symbol)
 << SymName;
   });
   };
@@ -270,16 +270,14 @@ DylibVerifier::Result 
DylibVerifier::compareVisibility(const Record *R,
   if (R->isExported()) {
 if (!DR) {
   Ctx.emitDiag([&]() {
-

[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)

2024-04-09 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/88189

A few verification checks need to happen until all AST's have been traversed, 
specifically for zippered framework checking. To keep source location until 
that time valid, hold onto to references of FrontendRecords + SourceManager.

>From d74c47dcadaa83422637de6ab6b1d0852b07817c Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Tue, 9 Apr 2024 13:04:18 -0700
Subject: [PATCH] [InstallAPI] Tie lifetime of FE objects to DylibVerifier

A few verification checks need to happen until all AST's have been
traversed, specifically for zippered framework checking.
To keep source location until that time valid, hold onto to
references of FrontendRecords + SourceManager.
---
 .../include/clang/InstallAPI/DylibVerifier.h  | 10 ++--
 clang/include/clang/InstallAPI/Frontend.h |  2 +-
 .../clang/InstallAPI/FrontendRecords.h|  1 +
 clang/lib/InstallAPI/DylibVerifier.cpp| 47 +--
 clang/lib/InstallAPI/Frontend.cpp | 15 +++---
 .../clang-installapi/ClangInstallAPI.cpp  |  2 +
 6 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 07dbd3bf5f2b10..a3df25f10de4b1 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_INSTALLAPI_DYLIBVERIFIER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/InstallAPI/MachO.h"
 
 namespace clang {
@@ -99,11 +100,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   Result getState() const { return Ctx.FrontendState; }
 
   /// Set different source managers to the same diagnostics engine.
-  void setSourceManager(SourceManager ) const {
-if (!Ctx.Diag)
-  return;
-Ctx.Diag->setSourceManager();
-  }
+  void setSourceManager(IntrusiveRefCntPtr SourceMgr);
 
 private:
   /// Determine whether to compare declaration to symbol in binary.
@@ -190,6 +187,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 
   // Track DWARF provided source location for dylibs.
   DWARFContext *DWARFCtx = nullptr;
+
+  // Source manager for each unique compiler instance.
+  llvm::SmallVector, 12> SourceManagers;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/Frontend.h 
b/clang/include/clang/InstallAPI/Frontend.h
index 5cccd891c58093..bc4e77de2b7256 100644
--- a/clang/include/clang/InstallAPI/Frontend.h
+++ b/clang/include/clang/InstallAPI/Frontend.h
@@ -36,7 +36,7 @@ class InstallAPIAction : public ASTFrontendAction {
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
  StringRef InFile) override {
 Ctx.Diags->getClient()->BeginSourceFile(CI.getLangOpts());
-Ctx.Verifier->setSourceManager(CI.getSourceManager());
+Ctx.Verifier->setSourceManager(CI.getSourceManagerPtr());
 return std::make_unique(
 CI.getASTContext(), Ctx, CI.getSourceManager(), CI.getPreprocessor());
   }
diff --git a/clang/include/clang/InstallAPI/FrontendRecords.h 
b/clang/include/clang/InstallAPI/FrontendRecords.h
index 59271e81e230c2..ef82398addd7ac 100644
--- a/clang/include/clang/InstallAPI/FrontendRecords.h
+++ b/clang/include/clang/InstallAPI/FrontendRecords.h
@@ -21,6 +21,7 @@ namespace installapi {
 struct FrontendAttrs {
   const AvailabilityInfo Avail;
   const Decl *D;
+  const SourceLocation Loc;
   const HeaderType Access;
 };
 
diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp 
b/clang/lib/InstallAPI/DylibVerifier.cpp
index 2387ee0e78ad56..4fa2d4e9292c72 100644
--- a/clang/lib/InstallAPI/DylibVerifier.cpp
+++ b/clang/lib/InstallAPI/DylibVerifier.cpp
@@ -214,16 +214,16 @@ bool DylibVerifier::compareObjCInterfaceSymbols(const 
Record *R,
  StringRef SymName, bool PrintAsWarning = false) {
 if (SymLinkage == RecordLinkage::Unknown)
   Ctx.emitDiag([&]() {
-Ctx.Diag->Report(SymCtx.FA->D->getLocation(),
- PrintAsWarning ? diag::warn_library_missing_symbol
-: diag::err_library_missing_symbol)
+Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning
+ ? 
diag::warn_library_missing_symbol
+ : 
diag::err_library_missing_symbol)
 << SymName;
   });
 else
   Ctx.emitDiag([&]() {
-Ctx.Diag->Report(SymCtx.FA->D->getLocation(),
- PrintAsWarning ? diag::warn_library_hidden_symbol
-: diag::err_library_hidden_symbol)
+Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning
+ ? diag::warn_library_hidden_symbol
+ : diag::err_library_hidden_symbol)
 

[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> FYI, it looks like this change broke `compiler-rt` build, e.g. in 
> https://lab.llvm.org/buildbot/#/builders/270/builds/12485

Should be resolved by: 
https://github.com/llvm/llvm-project/commit/fe45029dbdee6b3df2dbeaed17c9dd598ec511f2
 
I suspect compiler-rt may be relying on defaults set by Apple* cmake caches on 
unrelated environments.

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via cfe-commits


@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) 
+if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+  set_property(TARGET ${name} APPEND_STRING PROPERTY
+LINK_FLAGS " -Wl,-no_exported_symbols")
+else()
+  message(FATAL_ERROR 
+"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when 
linker does not support \"-no_exported_symbols\"")

cyndyishida wrote:

Yea, theres more platform-friendly and older ways to achieve the same thing. I 
opted not to because AFAIK, our toolchain only builds with linkers that support 
the straightforward flag, and wasn't sure how useful this would be for other 
platforms. 

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/87674
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-05 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

Thanks for reviewing @zixu-w !

https://github.com/llvm/llvm-project/pull/87674
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87684

>From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 12:08:28 -0700
Subject: [PATCH 1/4] [cmake] Build executables with -no_exported_symbols when
 building Apple toolchain

Building the Apple way turns off plugin support, meaning we don't need to be 
exporting unloadable symbols from all executables.
While deadstripping effects aren't expected to change, enabling this across all 
tools prevents the creation of export tries. This saves us ~3.5 MB's in just 
the universal build of `clang`.
---
 clang/cmake/caches/Apple-stage2.cmake   |  1 +
 lldb/cmake/caches/Apple-lldb-base.cmake |  1 +
 llvm/CMakeLists.txt |  3 +++
 llvm/cmake/modules/AddLLVM.cmake| 30 ++---
 llvm/docs/CMake.rst |  4 
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..faf61fd1fe9ecb 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")
diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..021538896b2346 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 6f5647d70d8bc1..7e393acacb80d8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS
+  "When building executables, disable any symbol exports (Darwin Only)" OFF)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..141a97c852e24f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+set_property(TARGET ${name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,-no_exported_symbols")
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
 set(USE_SHARED USE_SHARED)
   

[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87674

>From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 12:17:01 -0400
Subject: [PATCH 1/3] [InstallAPI] Capture and compare load commands that may
 differ per arch slice

* Capture reexported libraries, allowable clients, rpaths, shared cache
  eligiblity.
* Add support for select Xarch options.
* Add diagnostics related to capturing these options.
* Add support for verifying these attributes against what is encoded in
  the dylib.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |   1 +
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  21 +
 clang/include/clang/InstallAPI/Context.h  |  17 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  29 +-
 clang/include/clang/InstallAPI/MachO.h|   2 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 .../InstallAPI/DiagnosticBuilderWrappers.cpp  | 111 +++
 .../InstallAPI/DiagnosticBuilderWrappers.h|  49 ++
 clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++
 clang/lib/InstallAPI/Frontend.cpp |  54 ++
 clang/test/InstallAPI/binary-attributes.test  |  70 ++
 .../InstallAPI/driver-invalid-options.test|   6 +
 .../InstallAPI/reexported-frameworks.test | 638 +
 clang/test/InstallAPI/rpath.test  | 663 ++
 clang/tools/clang-installapi/CMakeLists.txt   |   1 +
 .../clang-installapi/ClangInstallAPI.cpp  |  27 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  40 +-
 clang/tools/clang-installapi/Options.cpp  | 277 +++-
 clang/tools/clang-installapi/Options.h|  43 +-
 19 files changed, 2230 insertions(+), 16 deletions(-)
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
 create mode 100644 clang/test/InstallAPI/binary-attributes.test
 create mode 100644 clang/test/InstallAPI/reexported-frameworks.test
 create mode 100644 clang/test/InstallAPI/rpath.test

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d86f7510bde20..fdce4f3f9d9a60 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; 
 def err_drv_darwin_sdk_missing_arclite : Error<
   "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
 
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index e3263fe9ccb9d4..0a477da7186b09 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such 
%select{public|private|project}1 he
 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;
 def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
+def err_cannot_find_reexport : Error<"cannot find re-exported 
%select{framework|library}0: '%1'">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
+// Diagnostics about symbols.
 def warn_target: Warning<"violations found for %0">, 
InGroup;
 def err_library_missing_symbol : Error<"declaration has external linkage, but 
dynamic library doesn't have symbol '%0'">;
 def warn_library_missing_symbol : Warning<"declaration has external linkage, 
but dynamic library doesn't have symbol '%0'">, InGroup;
@@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library 
symbol '%0' is "
   "%select{weak defined|thread local}1, but its declaration is not">;
 def err_header_symbol_flags_mismatch : Error<"declaration '%0' is "
   "%select{weak defined|thread local}1, but symbol is not in dynamic library">;
+
+// Diagnostics about load commands.
+def err_architecture_mismatch : Error<"architectures do not match: '%0' 
(provided) vs '%1' (found)">;
+def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) 
vs '%1' (found)">, InGroup;
+def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs 
'%1' (found)">;
+def err_install_name_mismatch : Error<"install_name does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_current_version_mismatch : Error<"current_version does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_compatibility_version_mismatch : Error<"compatibility_version does not 
match: '%0' (provided) vs 

[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87684

>From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 12:08:28 -0700
Subject: [PATCH 1/3] [cmake] Build executables with -no_exported_symbols when
 building Apple toolchain

Building the Apple way turns off plugin support, meaning we don't need to be 
exporting unloadable symbols from all executables.
While deadstripping effects aren't expected to change, enabling this across all 
tools prevents the creation of export tries. This saves us ~3.5 MB's in just 
the universal build of `clang`.
---
 clang/cmake/caches/Apple-stage2.cmake   |  1 +
 lldb/cmake/caches/Apple-lldb-base.cmake |  1 +
 llvm/CMakeLists.txt |  3 +++
 llvm/cmake/modules/AddLLVM.cmake| 30 ++---
 llvm/docs/CMake.rst |  4 
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..faf61fd1fe9ecb 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")
diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..021538896b2346 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 6f5647d70d8bc1..7e393acacb80d8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS
+  "When building executables, disable any symbol exports (Darwin Only)" OFF)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..141a97c852e24f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+set_property(TARGET ${name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,-no_exported_symbols")
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
 set(USE_SHARED USE_SHARED)
   

[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-05 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87674

>From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 12:17:01 -0400
Subject: [PATCH 1/2] [InstallAPI] Capture and compare load commands that may
 differ per arch slice

* Capture reexported libraries, allowable clients, rpaths, shared cache
  eligiblity.
* Add support for select Xarch options.
* Add diagnostics related to capturing these options.
* Add support for verifying these attributes against what is encoded in
  the dylib.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |   1 +
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  21 +
 clang/include/clang/InstallAPI/Context.h  |  17 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  29 +-
 clang/include/clang/InstallAPI/MachO.h|   2 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 .../InstallAPI/DiagnosticBuilderWrappers.cpp  | 111 +++
 .../InstallAPI/DiagnosticBuilderWrappers.h|  49 ++
 clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++
 clang/lib/InstallAPI/Frontend.cpp |  54 ++
 clang/test/InstallAPI/binary-attributes.test  |  70 ++
 .../InstallAPI/driver-invalid-options.test|   6 +
 .../InstallAPI/reexported-frameworks.test | 638 +
 clang/test/InstallAPI/rpath.test  | 663 ++
 clang/tools/clang-installapi/CMakeLists.txt   |   1 +
 .../clang-installapi/ClangInstallAPI.cpp  |  27 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  40 +-
 clang/tools/clang-installapi/Options.cpp  | 277 +++-
 clang/tools/clang-installapi/Options.h|  43 +-
 19 files changed, 2230 insertions(+), 16 deletions(-)
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
 create mode 100644 clang/test/InstallAPI/binary-attributes.test
 create mode 100644 clang/test/InstallAPI/reexported-frameworks.test
 create mode 100644 clang/test/InstallAPI/rpath.test

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d86f7510bde20..fdce4f3f9d9a60 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; 
 def err_drv_darwin_sdk_missing_arclite : Error<
   "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
 
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index e3263fe9ccb9d4..0a477da7186b09 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such 
%select{public|private|project}1 he
 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;
 def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
+def err_cannot_find_reexport : Error<"cannot find re-exported 
%select{framework|library}0: '%1'">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
+// Diagnostics about symbols.
 def warn_target: Warning<"violations found for %0">, 
InGroup;
 def err_library_missing_symbol : Error<"declaration has external linkage, but 
dynamic library doesn't have symbol '%0'">;
 def warn_library_missing_symbol : Warning<"declaration has external linkage, 
but dynamic library doesn't have symbol '%0'">, InGroup;
@@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library 
symbol '%0' is "
   "%select{weak defined|thread local}1, but its declaration is not">;
 def err_header_symbol_flags_mismatch : Error<"declaration '%0' is "
   "%select{weak defined|thread local}1, but symbol is not in dynamic library">;
+
+// Diagnostics about load commands.
+def err_architecture_mismatch : Error<"architectures do not match: '%0' 
(provided) vs '%1' (found)">;
+def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) 
vs '%1' (found)">, InGroup;
+def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs 
'%1' (found)">;
+def err_install_name_mismatch : Error<"install_name does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_current_version_mismatch : Error<"current_version does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_compatibility_version_mismatch : Error<"compatibility_version does not 
match: '%0' (provided) vs 

[clang] [InstallAPI] Add test to validate cc1 arg forwarding (PR #87666)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/87666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Add test to validate cc1 arg forwarding (PR #87666)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida edited 
https://github.com/llvm/llvm-project/pull/87666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87674

>From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 12:17:01 -0400
Subject: [PATCH] [InstallAPI] Capture and compare load commands that may
 differ per arch slice

* Capture reexported libraries, allowable clients, rpaths, shared cache
  eligiblity.
* Add support for select Xarch options.
* Add diagnostics related to capturing these options.
* Add support for verifying these attributes against what is encoded in
  the dylib.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |   1 +
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  21 +
 clang/include/clang/InstallAPI/Context.h  |  17 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  29 +-
 clang/include/clang/InstallAPI/MachO.h|   2 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 .../InstallAPI/DiagnosticBuilderWrappers.cpp  | 111 +++
 .../InstallAPI/DiagnosticBuilderWrappers.h|  49 ++
 clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++
 clang/lib/InstallAPI/Frontend.cpp |  54 ++
 clang/test/InstallAPI/binary-attributes.test  |  70 ++
 .../InstallAPI/driver-invalid-options.test|   6 +
 .../InstallAPI/reexported-frameworks.test | 638 +
 clang/test/InstallAPI/rpath.test  | 663 ++
 clang/tools/clang-installapi/CMakeLists.txt   |   1 +
 .../clang-installapi/ClangInstallAPI.cpp  |  27 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  40 +-
 clang/tools/clang-installapi/Options.cpp  | 277 +++-
 clang/tools/clang-installapi/Options.h|  43 +-
 19 files changed, 2230 insertions(+), 16 deletions(-)
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
 create mode 100644 clang/test/InstallAPI/binary-attributes.test
 create mode 100644 clang/test/InstallAPI/reexported-frameworks.test
 create mode 100644 clang/test/InstallAPI/rpath.test

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d86f7510bde20..fdce4f3f9d9a60 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; 
 def err_drv_darwin_sdk_missing_arclite : Error<
   "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
 
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index e3263fe9ccb9d4..0a477da7186b09 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such 
%select{public|private|project}1 he
 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;
 def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
+def err_cannot_find_reexport : Error<"cannot find re-exported 
%select{framework|library}0: '%1'">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
+// Diagnostics about symbols.
 def warn_target: Warning<"violations found for %0">, 
InGroup;
 def err_library_missing_symbol : Error<"declaration has external linkage, but 
dynamic library doesn't have symbol '%0'">;
 def warn_library_missing_symbol : Warning<"declaration has external linkage, 
but dynamic library doesn't have symbol '%0'">, InGroup;
@@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library 
symbol '%0' is "
   "%select{weak defined|thread local}1, but its declaration is not">;
 def err_header_symbol_flags_mismatch : Error<"declaration '%0' is "
   "%select{weak defined|thread local}1, but symbol is not in dynamic library">;
+
+// Diagnostics about load commands.
+def err_architecture_mismatch : Error<"architectures do not match: '%0' 
(provided) vs '%1' (found)">;
+def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) 
vs '%1' (found)">, InGroup;
+def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs 
'%1' (found)">;
+def err_install_name_mismatch : Error<"install_name does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_current_version_mismatch : Error<"current_version does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_compatibility_version_mismatch : Error<"compatibility_version does not 
match: '%0' (provided) vs 

[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87674

>From a7e67582e35fe6c33a1e391eaf6cc7d5b49087c6 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 12:17:01 -0400
Subject: [PATCH 1/2] [InstallAPI] Capture and compare load commands that may
 differ per arch slice

* Capture reexported libraries, allowable clients, rpaths, shared cache
  eligiblity.
* Add support for select Xarch options.
* Add diagnostics related to capturing these options.
* Add support for verifying these attributes against what is encoded in
  the dylib.
---
 .../clang/Basic/DiagnosticDriverKinds.td  |   1 +
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  21 +
 clang/include/clang/InstallAPI/Context.h  |  17 +
 .../include/clang/InstallAPI/DylibVerifier.h  |  25 +-
 clang/include/clang/InstallAPI/MachO.h|   2 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 .../InstallAPI/DiagnosticBuilderWrappers.cpp  | 111 +++
 .../InstallAPI/DiagnosticBuilderWrappers.h|  49 ++
 clang/lib/InstallAPI/DylibVerifier.cpp| 175 +
 clang/lib/InstallAPI/Frontend.cpp |  54 ++
 clang/test/InstallAPI/binary-attributes.test  |  70 ++
 .../InstallAPI/driver-invalid-options.test|   6 +
 .../InstallAPI/reexported-frameworks.test | 551 +++
 clang/test/InstallAPI/rpath.test  | 663 ++
 clang/tools/clang-installapi/CMakeLists.txt   |   1 +
 .../clang-installapi/ClangInstallAPI.cpp  |  27 +-
 .../tools/clang-installapi/InstallAPIOpts.td  |  40 +-
 clang/tools/clang-installapi/Options.cpp  | 269 ++-
 clang/tools/clang-installapi/Options.h|  43 +-
 19 files changed, 2110 insertions(+), 16 deletions(-)
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
 create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
 create mode 100644 clang/test/InstallAPI/binary-attributes.test
 create mode 100644 clang/test/InstallAPI/reexported-frameworks.test
 create mode 100644 clang/test/InstallAPI/rpath.test

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3d86f7510bde20..fdce4f3f9d9a60 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; 
 def err_drv_darwin_sdk_missing_arclite : Error<
   "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
 
diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index e3263fe9ccb9d4..0a477da7186b09 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such 
%select{public|private|project}1 he
 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;
 def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
+def err_cannot_find_reexport : Error<"cannot find re-exported 
%select{framework|library}0: '%1'">;
 } // end of command line category.
 
 let CategoryName = "Verification" in {
+// Diagnostics about symbols.
 def warn_target: Warning<"violations found for %0">, 
InGroup;
 def err_library_missing_symbol : Error<"declaration has external linkage, but 
dynamic library doesn't have symbol '%0'">;
 def warn_library_missing_symbol : Warning<"declaration has external linkage, 
but dynamic library doesn't have symbol '%0'">, InGroup;
@@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library 
symbol '%0' is "
   "%select{weak defined|thread local}1, but its declaration is not">;
 def err_header_symbol_flags_mismatch : Error<"declaration '%0' is "
   "%select{weak defined|thread local}1, but symbol is not in dynamic library">;
+
+// Diagnostics about load commands.
+def err_architecture_mismatch : Error<"architectures do not match: '%0' 
(provided) vs '%1' (found)">;
+def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) 
vs '%1' (found)">, InGroup;
+def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs 
'%1' (found)">;
+def err_install_name_mismatch : Error<"install_name does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_current_version_mismatch : Error<"current_version does not match: '%0' 
(provided) vs '%1' (found)">;
+def err_compatibility_version_mismatch : Error<"compatibility_version does not 
match: '%0' (provided) vs 

[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-04 Thread Cyndy Ishida via cfe-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

cyndyishida wrote:

Would `LLVM_ENABLE_EXECUTABLES_WITH_EXPORTED_SYMBOLS` be too long?

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-04 Thread Cyndy Ishida via cfe-commits


@@ -654,6 +654,11 @@ enabled sub-projects. Nearly all of these variable names 
begin with
   Generate dSYM files and strip executables and libraries (Darwin Only).
   Defaults to OFF.
 
+**LLVM_ENABLE_EXPORTED_SYMBOLS**:BOOL
+  When building executables, preserve symbol exports. Defaults to ON. 
+  You can use this option to disable exported symbols on all executable build

cyndyishida wrote:

That's what I initially thought as well but a lot of the LLVM_INCLUDE* 
variables on the lines below follow a "You can use this option..." And they 
also have similar behavior which defaults to ON. 

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-04 Thread Cyndy Ishida via cfe-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS

cyndyishida wrote:

No preference here. Whatever seems easier for others to understand.

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87684

>From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 12:08:28 -0700
Subject: [PATCH 1/2] [cmake] Build executables with -no_exported_symbols when
 building Apple toolchain

Building the Apple way turns off plugin support, meaning we don't need to be 
exporting unloadable symbols from all executables.
While deadstripping effects aren't expected to change, enabling this across all 
tools prevents the creation of export tries. This saves us ~3.5 MB's in just 
the universal build of `clang`.
---
 clang/cmake/caches/Apple-stage2.cmake   |  1 +
 lldb/cmake/caches/Apple-lldb-base.cmake |  1 +
 llvm/CMakeLists.txt |  3 +++
 llvm/cmake/modules/AddLLVM.cmake| 30 ++---
 llvm/docs/CMake.rst |  4 
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..faf61fd1fe9ecb 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")
diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..021538896b2346 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 6f5647d70d8bc1..7e393acacb80d8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS
+  "When building executables, disable any symbol exports (Darwin Only)" OFF)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..141a97c852e24f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+set_property(TARGET ${name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,-no_exported_symbols")
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
 set(USE_SHARED USE_SHARED)
   

[clang] [InstallAPI] Add test to validate cc1 arg forwading (PR #87666)

2024-04-04 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87666

>From 6b2f262d1e69724d4eb96f5ad75aa2c202f3eb2d Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 10:36:47 -0700
Subject: [PATCH] [InstallAPI] Add test to validate cc1 arg forwading

---
 .../Foundation.framework/Headers/Foundation.h | 19 +++
 .../InstallAPI/extra-exclude-headers.test | 22 +---
 .../InstallAPI/forwarded-search-paths.test| 34 +++
 3 files changed, 54 insertions(+), 21 deletions(-)
 create mode 100644 
clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Headers/Foundation.h
 create mode 100644 clang/test/InstallAPI/forwarded-search-paths.test

diff --git 
a/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Headers/Foundation.h
 
b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Headers/Foundation.h
new file mode 100644
index 00..e731b59ac5308b
--- /dev/null
+++ 
b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Headers/Foundation.h
@@ -0,0 +1,19 @@
+@interface NSObject 
+@end
+
+typedef unsigned char BOOL; 
+#ifndef NS_AVAILABLE
+#define NS_AVAILABLE(x,y) __attribute__((availability(macosx,introduced=x)))
+#endif 
+#ifndef NS_UNAVAILABLE
+#define NS_UNAVAILABLE  __attribute__((unavailable))
+#endif 
+#ifndef NS_DEPRECATED_MAC
+#define NS_DEPRECATED_MAC(x,y) 
__attribute__((availability(macosx,introduced=x,deprecated=y,message="" )));
+#endif 
+
+@interface NSManagedObject
+@end 
+
+@interface NSSet 
+@end 
diff --git a/clang/test/InstallAPI/extra-exclude-headers.test 
b/clang/test/InstallAPI/extra-exclude-headers.test
index 663ca1a5d5000d..addb81f5386f3e 100644
--- a/clang/test/InstallAPI/extra-exclude-headers.test
+++ b/clang/test/InstallAPI/extra-exclude-headers.test
@@ -2,6 +2,7 @@
 ; RUN: split-file %s %t
 ; RUN: mkdir -p %t/System/Library/Frameworks 
 ; RUN: cp -r %S/Inputs/Simple/Simple.framework %t/System/Library/Frameworks/
+; RUN: cp -r %S/Inputs/Foundation/Foundation.framework 
%t/System/Library/Frameworks/
 ; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
 ; RUN: yaml2obj %S/Inputs/Simple/Simple.yaml -o %t/Simple 
 
@@ -184,24 +185,3 @@
   ],
   "version": "3"
 }
-
-;--- System/Library/Frameworks/Foundation.framework/Headers/Foundation.h
-@interface NSObject 
-@end
-
-typedef unsigned char BOOL; 
-#ifndef NS_AVAILABLE
-#define NS_AVAILABLE(x,y) __attribute__((availability(macosx,introduced=x)))
-#endif 
-#ifndef NS_UNAVAILABLE
-#define NS_UNAVAILABLE  __attribute__((unavailable))
-#endif 
-#ifndef NS_DEPRECATED_MAC
-#define NS_DEPRECATED_MAC(x,y) 
__attribute__((availability(macosx,introduced=x,deprecated=y,message="" )));
-#endif 
-
-@interface NSManagedObject
-@end 
-
-@interface NSSet 
-@end 
diff --git a/clang/test/InstallAPI/forwarded-search-paths.test 
b/clang/test/InstallAPI/forwarded-search-paths.test
new file mode 100644
index 00..dc1e9006060f44
--- /dev/null
+++ b/clang/test/InstallAPI/forwarded-search-paths.test
@@ -0,0 +1,34 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/input.json.in > %t/input.json
+
+; RUN: mkdir -p %t/System/Library/Frameworks 
+; RUN: cp -r %S/Inputs/Foundation/Foundation.framework 
%t/System/Library/Frameworks/
+; RUN: cp -r %S/Inputs/Simple/Simple.framework %t/System/Library/Frameworks/
+; RUN: yaml2obj %S/Inputs/Simple/Simple.yaml -o %t/Simple 
+; RUN: mkdir -p %t/usr/include/after
+
+; RUN: clang-installapi -target x86_64-apple-macosx10.12 \
+; RUN: -install_name 
/System/Library/Frameworks/Simple.framework/Versions/A/Simple \
+; RUN: -current_version 1.2.3 -compatibility_version 1 -o %t/Simple.tbd \
+; RUN: -idirafter %t/usr/include/after \
+; RUN: -F %t/System/Library/Frameworks \
+; RUN: --verify-against=%t/Simple --verify-mode=ErrorsOnly \
+; RUN: %t/input.json  -v 2>&1 | FileCheck %s
+
+; CHECK: "-idirafter" {{.*}}/usr/include/after"
+; CHECK: #include "..." search starts here:
+; CHECK: #include <...> search starts here:
+; CHECK: usr/include/after 
+; CHECK-NEXT: End of search list.
+
+;--- input.json.in
+{
+  "version" : "3",
+  "headers" : [
+{
+  "type" : "public",
+  "path" : 
"DSTROOT/System/Library/Frameworks/Simple.framework/Headers/Basic.h"
+}
+  ]
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 207f153 - [InstallAPI] Condense std::pair unwrapping in CategoryRecord NFC

2024-04-02 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-04-02T09:17:06-07:00
New Revision: 207f1531d611b8add27b94e756e0bc7eb864babf

URL: 
https://github.com/llvm/llvm-project/commit/207f1531d611b8add27b94e756e0bc7eb864babf
DIFF: 
https://github.com/llvm/llvm-project/commit/207f1531d611b8add27b94e756e0bc7eb864babf.diff

LOG: [InstallAPI] Condense std::pair unwrapping in CategoryRecord NFC

Added: 


Modified: 
clang/lib/InstallAPI/Visitor.cpp

Removed: 




diff  --git a/clang/lib/InstallAPI/Visitor.cpp 
b/clang/lib/InstallAPI/Visitor.cpp
index 6476c5107cb5cc..cf3aaa4c6ec931 100644
--- a/clang/lib/InstallAPI/Visitor.cpp
+++ b/clang/lib/InstallAPI/Visitor.cpp
@@ -205,10 +205,10 @@ bool InstallAPIVisitor::VisitObjCCategoryDecl(const 
ObjCCategoryDecl *D) {
   const ObjCInterfaceDecl *InterfaceD = D->getClassInterface();
   const StringRef InterfaceName = InterfaceD->getName();
 
-  std::pair Category =
-  Ctx.Slice->addObjCCategory(InterfaceName, CategoryName, Avail, D,
- *Access);
-  recordObjCInstanceVariables(D->getASTContext(), Category.first, 
InterfaceName,
+  ObjCCategoryRecord *CategoryRecord =
+  Ctx.Slice->addObjCCategory(InterfaceName, CategoryName, Avail, D, 
*Access)
+  .first;
+  recordObjCInstanceVariables(D->getASTContext(), CategoryRecord, 
InterfaceName,
   D->ivars());
   return true;
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Fixup dsym test (PR #87299)

2024-04-01 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/87299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Fixup dsym test (PR #87299)

2024-04-01 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87299

>From fc2b73a261a0eddb19d49fcbbf301ec40a1d5ed2 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 1 Apr 2024 18:09:27 -0700
Subject: [PATCH] [InstallAPI] Fixup dsym test to actually run when compiler is
 built for arm64-darwin support

---
 clang/test/InstallAPI/diagnostics-dsym.test | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/clang/test/InstallAPI/diagnostics-dsym.test 
b/clang/test/InstallAPI/diagnostics-dsym.test
index 8a1b394f2f8683..c9cbeffef7bacc 100644
--- a/clang/test/InstallAPI/diagnostics-dsym.test
+++ b/clang/test/InstallAPI/diagnostics-dsym.test
@@ -1,23 +1,24 @@
-; REQUIRES: 86_64-darwin
+; REQUIRES: system-darwin
+; REQUIRES: target-aarch64 
 
 ; RUN: rm -rf %t
 ; RUN: split-file %s %t
 
 // Build a simple dylib with debug info.
-; RUN: %clang --target=x86_64-apple-macos10.15 -g -dynamiclib %t/foo.c \
+; RUN: %clang --target=arm64-apple-macos11 -g -dynamiclib %t/foo.c \
 ; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
 ; RUN: -save-temps \
 ; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
 ; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
 
-; RUN: not clang-installapi -x c++ --target=x86_64-apple-macos10.15 \
+; RUN: not clang-installapi -x c++ --target=arm64-apple-macos11 \
 ; RUN: -install_name %t/foo.dylib  \
 ; RUN: -current_version 1 -compatibility_version 1 \
 ; RUN: -o %t/output.tbd \
 ; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
 ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
 
-; CHECK: violations found for x86_64 
+; CHECK: violations found for arm64 
 ; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in 
dynamic library
 ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in 
dynamic library
 
@@ -31,9 +32,9 @@ char bar = 'a';
 ;--- usr/lib/libSystem.tbd
 --- !tapi-tbd
 tbd-version: 4
-targets: [ x86_64-macos ]
+targets: [ arm64-macos ]
 install-name:'/usr/lib/libSystem.B.dylib'
 exports: 
-  - targets: [ x86_64-macos ]
+  - targets: [ arm64-macos ]
 symbols: [ dyld_stub_binder ]
 ...

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Fixup dsym test (PR #87299)

2024-04-01 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/87299

Update the test to run when the compiler is built to support arm64-darwin 
targets.

>From fc2b73a261a0eddb19d49fcbbf301ec40a1d5ed2 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 1 Apr 2024 18:09:27 -0700
Subject: [PATCH] [InstallAPI] Fixup dsym test to actually run when compiler is
 built for arm64-darwin support

---
 clang/test/InstallAPI/diagnostics-dsym.test | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/clang/test/InstallAPI/diagnostics-dsym.test 
b/clang/test/InstallAPI/diagnostics-dsym.test
index 8a1b394f2f8683..c9cbeffef7bacc 100644
--- a/clang/test/InstallAPI/diagnostics-dsym.test
+++ b/clang/test/InstallAPI/diagnostics-dsym.test
@@ -1,23 +1,24 @@
-; REQUIRES: 86_64-darwin
+; REQUIRES: system-darwin
+; REQUIRES: target-aarch64 
 
 ; RUN: rm -rf %t
 ; RUN: split-file %s %t
 
 // Build a simple dylib with debug info.
-; RUN: %clang --target=x86_64-apple-macos10.15 -g -dynamiclib %t/foo.c \
+; RUN: %clang --target=arm64-apple-macos11 -g -dynamiclib %t/foo.c \
 ; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
 ; RUN: -save-temps \
 ; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
 ; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
 
-; RUN: not clang-installapi -x c++ --target=x86_64-apple-macos10.15 \
+; RUN: not clang-installapi -x c++ --target=arm64-apple-macos11 \
 ; RUN: -install_name %t/foo.dylib  \
 ; RUN: -current_version 1 -compatibility_version 1 \
 ; RUN: -o %t/output.tbd \
 ; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
 ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
 
-; CHECK: violations found for x86_64 
+; CHECK: violations found for arm64 
 ; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in 
dynamic library
 ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in 
dynamic library
 
@@ -31,9 +32,9 @@ char bar = 'a';
 ;--- usr/lib/libSystem.tbd
 --- !tapi-tbd
 tbd-version: 4
-targets: [ x86_64-macos ]
+targets: [ arm64-macos ]
 install-name:'/usr/lib/libSystem.B.dylib'
 exports: 
-  - targets: [ x86_64-macos ]
+  - targets: [ arm64-macos ]
 symbols: [ dyld_stub_binder ]
 ...

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Darwin] Handle reexported library arguments in driver (PR #86980)

2024-03-29 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/86980
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bdb60e6 - [InstallAPI][test] Add requires x86_64 for hardcoded target test

2024-03-29 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-03-29T10:34:35-07:00
New Revision: bdb60e6f0c8e89abf9bdf36411348db304ca65ba

URL: 
https://github.com/llvm/llvm-project/commit/bdb60e6f0c8e89abf9bdf36411348db304ca65ba
DIFF: 
https://github.com/llvm/llvm-project/commit/bdb60e6f0c8e89abf9bdf36411348db304ca65ba.diff

LOG: [InstallAPI][test] Add requires x86_64 for hardcoded target test

Added: 


Modified: 
clang/test/InstallAPI/diagnostics-dsym.test

Removed: 




diff  --git a/clang/test/InstallAPI/diagnostics-dsym.test 
b/clang/test/InstallAPI/diagnostics-dsym.test
index 45c69c09d2863f..8a1b394f2f8683 100644
--- a/clang/test/InstallAPI/diagnostics-dsym.test
+++ b/clang/test/InstallAPI/diagnostics-dsym.test
@@ -1,4 +1,4 @@
-; REQUIRES: system-darwin
+; REQUIRES: 86_64-darwin
 
 ; RUN: rm -rf %t
 ; RUN: split-file %s %t



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 60deb8b - [InstallAPI][test] Tweak test to run on older CI config

2024-03-29 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-03-29T10:00:51-07:00
New Revision: 60deb8b39afe9be90e30aa18d77ad129dacd4d55

URL: 
https://github.com/llvm/llvm-project/commit/60deb8b39afe9be90e30aa18d77ad129dacd4d55
DIFF: 
https://github.com/llvm/llvm-project/commit/60deb8b39afe9be90e30aa18d77ad129dacd4d55.diff

LOG: [InstallAPI][test] Tweak test to run on older CI config

Added: 


Modified: 
clang/test/InstallAPI/diagnostics-dsym.test

Removed: 




diff  --git a/clang/test/InstallAPI/diagnostics-dsym.test 
b/clang/test/InstallAPI/diagnostics-dsym.test
index ee2c8b32df29c3..45c69c09d2863f 100644
--- a/clang/test/InstallAPI/diagnostics-dsym.test
+++ b/clang/test/InstallAPI/diagnostics-dsym.test
@@ -4,20 +4,20 @@
 ; RUN: split-file %s %t
 
 // Build a simple dylib with debug info.
-; RUN: %clang --target=arm64-apple-macos13 -g -dynamiclib %t/foo.c \
+; RUN: %clang --target=x86_64-apple-macos10.15 -g -dynamiclib %t/foo.c \
 ; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
 ; RUN: -save-temps \
 ; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
 ; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
 
-; RUN: not clang-installapi -x c++ --target=arm64-apple-macos13 \
+; RUN: not clang-installapi -x c++ --target=x86_64-apple-macos10.15 \
 ; RUN: -install_name %t/foo.dylib  \
 ; RUN: -current_version 1 -compatibility_version 1 \
 ; RUN: -o %t/output.tbd \
 ; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
 ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
 
-; CHECK: violations found for arm64 
+; CHECK: violations found for x86_64 
 ; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in 
dynamic library
 ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in 
dynamic library
 
@@ -29,15 +29,11 @@ extern char bar;
 char bar = 'a';
 
 ;--- usr/lib/libSystem.tbd
-{
-  "main_library": {
-"install_names": [
-  {"name": "/usr/lib/libSystem.B.dylib"}
-],
-"target_info": [
-  {"target": "arm64-macos"}
-]
-  },
-  "tapi_tbd_version": 5
-}
-
+--- !tapi-tbd
+tbd-version: 4
+targets: [ x86_64-macos ]
+install-name:'/usr/lib/libSystem.B.dylib'
+exports: 
+  - targets: [ x86_64-macos ]
+symbols: [ dyld_stub_binder ]
+...



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-29 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/86852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Darwin] Handle reexported library arguments in driver (PR #86980)

2024-03-28 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

Thanks for the reviews!

https://github.com/llvm/llvm-project/pull/86980
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Darwin] Handle reexported library arguments in driver (PR #86980)

2024-03-28 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/86980

`-reexport*` is the newer spelling for `-sub-library` which is already 
supported by the clang driver when invoking ld.
Support the new spellings when passed by the user. This also helps simplify 
`clang-installapi` driver logic.

>From 8a0443608ece499d929ddda83d21872da117dd16 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 28 Mar 2024 12:57:46 -0400
Subject: [PATCH] [clang][Darwin] Handle reexported library arguments in driver

`-reexport*` is the newer spelling for `-sub-library` which is already
supported by the clang driver when invoking ld.
Support the new spellings when passed by the user. This also helps
simplify `clang-installapi` driver logic.
---
 clang/include/clang/Driver/Options.td   |  3 +++
 clang/test/Driver/darwin-ld-reexports.c | 21 +
 2 files changed, 24 insertions(+)
 create mode 100644 clang/test/Driver/darwin-ld-reexports.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 29066ea14280c2..8a3929eeb6692b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3635,6 +3635,9 @@ defm preserve_as_comments : 
BoolFOption<"preserve-as-comments",
   "Do not preserve comments in inline assembly">,
   PosFlag>;
 def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
+def reexport_framework : Separate<["-"], "reexport_framework">, 
Flags<[LinkerInput]>;
+def reexport_l : Joined<["-"], "reexport-l">, Flags<[LinkerInput]>;
+def reexport_library : JoinedOrSeparate<["-"], "reexport_library">, 
Flags<[LinkerInput]>;
 def frandom_seed_EQ : Joined<["-"], "frandom-seed=">, 
Group;
 def freg_struct_return : Flag<["-"], "freg-struct-return">, Group,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/test/Driver/darwin-ld-reexports.c 
b/clang/test/Driver/darwin-ld-reexports.c
new file mode 100644
index 00..2e96db49a8a387
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-reexports.c
@@ -0,0 +1,21 @@
+// RUN: touch %t.o
+// RUN: %clang -target arm64-apple-darwin13 -### \
+// RUN: -reexport_framework Foo -reexport-lBar -reexport_library Baz %t.o 2> 
%t.log
+
+// Check older spellings also work.
+// RUN: %clang -target arm64-apple-darwin13 -### \
+// RUN: -Xlinker -reexport_framework -Xlinker Forest \
+// RUN: -Xlinker -reexport-lBranch \
+// RUN: -Xlinker -reexport_library -Xlinker Flower %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_REEXPORT %s < %t.log
+
+// LINK_REEXPORT: {{ld(.exe)?"}}
+// LINK_REEXPORT: "-reexport_framework" "Foo"
+// LINK_REEXPORT: "-reexport-lBar"
+// LINK_REEXPORT: "-reexport_library" "Baz"
+// LINK_REEXPORT: "-reexport_framework" "Forest"
+// LINK_REEXPORT: "-reexport-lBranch"
+// LINK_REEXPORT: "-reexport_library" "Flower"
+
+// Make sure arguments are not repeated.
+// LINK_REEXPORT-NOT: "-reexport

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-28 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86852

>From 9ddf01a4f28df19914aa393b1ac518410693af5b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 14:33:15 -0400
Subject: [PATCH 1/4] [InstallAPI] Add support for parsing dSYMs

InstallAPI does not directly look at object files in the dylib. To help
diagnose violations where a declaration is undiscovered in headers,
parse the dSYM and lookup the source location for symbols.
Emitting out the source location with a diagnostic is enough for
some IDE's (e.g. Xcode) to have them map back to editable source files.
---
 .../include/clang/InstallAPI/DylibVerifier.h  |  20 +++-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  71 ---
 clang/test/CMakeLists.txt |   1 +
 clang/test/InstallAPI/diagnostics-dsym.test   |  40 +++
 clang/test/lit.cfg.py |   1 +
 .../tools/clang-installapi/InstallAPIOpts.td  |   2 +
 clang/tools/clang-installapi/Options.cpp  |   6 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/DylibReader.h   |   9 ++
 llvm/include/llvm/TextAPI/Record.h|  17 +++
 llvm/lib/TextAPI/BinaryReader/CMakeLists.txt  |   1 +
 llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 112 +-
 14 files changed, 263 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/InstallAPI/diagnostics-dsym.test

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 49de24763f1f93..22cdc234486cf3 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -31,6 +31,7 @@ enum class VerificationMode {
 class DylibVerifier : llvm::MachO::RecordVisitor {
 private:
   struct SymbolContext;
+  struct DWARFContext;
 
 public:
   enum class Result { NoVerify, Ignore, Valid, Invalid };
@@ -54,7 +55,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 DiagnosticsEngine *Diag = nullptr;
 
 // Handle diagnostics reporting for target level violations.
-void emitDiag(llvm::function_ref Report);
+void emitDiag(llvm::function_ref Report, RecordLoc *Loc = nullptr);
 
 VerifierContext() = default;
 VerifierContext(DiagnosticsEngine *Diag) : Diag(Diag) {}
@@ -63,9 +64,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, DiagnosticsEngine *Diag,
-VerificationMode Mode, bool Demangle)
+VerificationMode Mode, bool Demangle, StringRef DSYMPath)
   : Dylib(std::move(Dylib)), Mode(Mode), Demangle(Demangle),
-Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
+DSYMPath(DSYMPath), Exports(std::make_unique()),
+Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
   Result verify(ObjCInterfaceRecord *R, const FrontendAttrs *FA);
@@ -143,6 +145,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   std::string getAnnotatedName(const Record *R, SymbolContext ,
bool ValidSourceLoc = true);
 
+  /// Extract source location for symbol implementations.
+  /// As this is a relatively expensive operation, it is only used
+  /// when there is a violation to report and there is not a known declaration
+  /// in the interface.
+  void accumulateSrcLocForDylibSymbols();
+
   // Symbols in dylib.
   llvm::MachO::Records Dylib;
 
@@ -152,11 +160,17 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Attempt to demangle when reporting violations.
   bool Demangle = false;
 
+  // File path to DSYM file.
+  StringRef DSYMPath;
+
   // Valid symbols in final text file.
   std::unique_ptr Exports = std::make_unique();
 
   // Track current state of verification while traversing AST.
   VerifierContext Ctx;
+
+  // Track DWARF provided source location for dylibs.
+  DWARFContext *DWARFCtx = nullptr;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 4961c596fd68ae..827220dbf39fb8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -34,6 +34,7 @@ using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord;
 using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord;
 using ObjCIFSymbolKind = llvm::MachO::ObjCIFSymbolKind;
 using Records = llvm::MachO::Records;
+using RecordLoc = llvm::MachO::RecordLoc;
 using RecordsSlice = llvm::MachO::RecordsSlice;
 using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs;
 using SymbolSet = llvm::MachO::SymbolSet;
diff --git a/clang/lib/InstallAPI/CMakeLists.txt 
b/clang/lib/InstallAPI/CMakeLists.txt
index 894db699578f20..e0bc8d969ecb3a 100644
--- a/clang/lib/InstallAPI/CMakeLists.txt
+++ 

[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits


@@ -0,0 +1,40 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+
+// Build a simple dylib with debug info.
+; RUN: %clang --target=arm64-apple-macos13 -g -dynamiclib %t/foo.c \

cyndyishida wrote:

Looks like the linker on the linux bot doesn't support building Darwin anyway
```
/usr/bin/ld: unrecognised emulation mode: llvm
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om 
elf_k1om i386pep i386pe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
Perhaps I'll require Darwin env to run the test and then I won't need to 
introduce a `dsymutil` dependency at all since it can come from xcode.

https://github.com/llvm/llvm-project/pull/86852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits


@@ -511,14 +520,16 @@ DylibVerifier::Result DylibVerifier::verify(GlobalRecord 
*R,
   return verifyImpl(R, SymCtx);
 }
 
-void DylibVerifier::VerifierContext::emitDiag(
-llvm::function_ref Report) {
+void DylibVerifier::VerifierContext::emitDiag(llvm::function_ref 
Report,
+  RecordLoc *Loc) {
   if (!DiscoveredFirstError) {
 Diag->Report(diag::warn_target)
 << (PrintArch ? getArchitectureName(Target.Arch)
   : getTargetTripleName(Target));
 DiscoveredFirstError = true;
   }
+  if (Loc && Loc->isValid())
+llvm::errs() << Loc->File << ":" << Loc->Line << ":" << 0 << ": ";

cyndyishida wrote:

Yep https://llvm.org/doxygen/classllvm_1_1DWARFDie.html Doubt its too hard to 
add, but
for stuff like jump to definition, it doesn't impact usability.

https://github.com/llvm/llvm-project/pull/86852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86852

>From 9ddf01a4f28df19914aa393b1ac518410693af5b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 14:33:15 -0400
Subject: [PATCH 1/3] [InstallAPI] Add support for parsing dSYMs

InstallAPI does not directly look at object files in the dylib. To help
diagnose violations where a declaration is undiscovered in headers,
parse the dSYM and lookup the source location for symbols.
Emitting out the source location with a diagnostic is enough for
some IDE's (e.g. Xcode) to have them map back to editable source files.
---
 .../include/clang/InstallAPI/DylibVerifier.h  |  20 +++-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  71 ---
 clang/test/CMakeLists.txt |   1 +
 clang/test/InstallAPI/diagnostics-dsym.test   |  40 +++
 clang/test/lit.cfg.py |   1 +
 .../tools/clang-installapi/InstallAPIOpts.td  |   2 +
 clang/tools/clang-installapi/Options.cpp  |   6 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/DylibReader.h   |   9 ++
 llvm/include/llvm/TextAPI/Record.h|  17 +++
 llvm/lib/TextAPI/BinaryReader/CMakeLists.txt  |   1 +
 llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 112 +-
 14 files changed, 263 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/InstallAPI/diagnostics-dsym.test

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 49de24763f1f93..22cdc234486cf3 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -31,6 +31,7 @@ enum class VerificationMode {
 class DylibVerifier : llvm::MachO::RecordVisitor {
 private:
   struct SymbolContext;
+  struct DWARFContext;
 
 public:
   enum class Result { NoVerify, Ignore, Valid, Invalid };
@@ -54,7 +55,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 DiagnosticsEngine *Diag = nullptr;
 
 // Handle diagnostics reporting for target level violations.
-void emitDiag(llvm::function_ref Report);
+void emitDiag(llvm::function_ref Report, RecordLoc *Loc = nullptr);
 
 VerifierContext() = default;
 VerifierContext(DiagnosticsEngine *Diag) : Diag(Diag) {}
@@ -63,9 +64,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, DiagnosticsEngine *Diag,
-VerificationMode Mode, bool Demangle)
+VerificationMode Mode, bool Demangle, StringRef DSYMPath)
   : Dylib(std::move(Dylib)), Mode(Mode), Demangle(Demangle),
-Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
+DSYMPath(DSYMPath), Exports(std::make_unique()),
+Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
   Result verify(ObjCInterfaceRecord *R, const FrontendAttrs *FA);
@@ -143,6 +145,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   std::string getAnnotatedName(const Record *R, SymbolContext ,
bool ValidSourceLoc = true);
 
+  /// Extract source location for symbol implementations.
+  /// As this is a relatively expensive operation, it is only used
+  /// when there is a violation to report and there is not a known declaration
+  /// in the interface.
+  void accumulateSrcLocForDylibSymbols();
+
   // Symbols in dylib.
   llvm::MachO::Records Dylib;
 
@@ -152,11 +160,17 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Attempt to demangle when reporting violations.
   bool Demangle = false;
 
+  // File path to DSYM file.
+  StringRef DSYMPath;
+
   // Valid symbols in final text file.
   std::unique_ptr Exports = std::make_unique();
 
   // Track current state of verification while traversing AST.
   VerifierContext Ctx;
+
+  // Track DWARF provided source location for dylibs.
+  DWARFContext *DWARFCtx = nullptr;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 4961c596fd68ae..827220dbf39fb8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -34,6 +34,7 @@ using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord;
 using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord;
 using ObjCIFSymbolKind = llvm::MachO::ObjCIFSymbolKind;
 using Records = llvm::MachO::Records;
+using RecordLoc = llvm::MachO::RecordLoc;
 using RecordsSlice = llvm::MachO::RecordsSlice;
 using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs;
 using SymbolSet = llvm::MachO::SymbolSet;
diff --git a/clang/lib/InstallAPI/CMakeLists.txt 
b/clang/lib/InstallAPI/CMakeLists.txt
index 894db699578f20..e0bc8d969ecb3a 100644
--- a/clang/lib/InstallAPI/CMakeLists.txt
+++ 

[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86852

>From 9ddf01a4f28df19914aa393b1ac518410693af5b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 14:33:15 -0400
Subject: [PATCH 1/2] [InstallAPI] Add support for parsing dSYMs

InstallAPI does not directly look at object files in the dylib. To help
diagnose violations where a declaration is undiscovered in headers,
parse the dSYM and lookup the source location for symbols.
Emitting out the source location with a diagnostic is enough for
some IDE's (e.g. Xcode) to have them map back to editable source files.
---
 .../include/clang/InstallAPI/DylibVerifier.h  |  20 +++-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  71 ---
 clang/test/CMakeLists.txt |   1 +
 clang/test/InstallAPI/diagnostics-dsym.test   |  40 +++
 clang/test/lit.cfg.py |   1 +
 .../tools/clang-installapi/InstallAPIOpts.td  |   2 +
 clang/tools/clang-installapi/Options.cpp  |   6 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/DylibReader.h   |   9 ++
 llvm/include/llvm/TextAPI/Record.h|  17 +++
 llvm/lib/TextAPI/BinaryReader/CMakeLists.txt  |   1 +
 llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 112 +-
 14 files changed, 263 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/InstallAPI/diagnostics-dsym.test

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 49de24763f1f93..22cdc234486cf3 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -31,6 +31,7 @@ enum class VerificationMode {
 class DylibVerifier : llvm::MachO::RecordVisitor {
 private:
   struct SymbolContext;
+  struct DWARFContext;
 
 public:
   enum class Result { NoVerify, Ignore, Valid, Invalid };
@@ -54,7 +55,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 DiagnosticsEngine *Diag = nullptr;
 
 // Handle diagnostics reporting for target level violations.
-void emitDiag(llvm::function_ref Report);
+void emitDiag(llvm::function_ref Report, RecordLoc *Loc = nullptr);
 
 VerifierContext() = default;
 VerifierContext(DiagnosticsEngine *Diag) : Diag(Diag) {}
@@ -63,9 +64,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, DiagnosticsEngine *Diag,
-VerificationMode Mode, bool Demangle)
+VerificationMode Mode, bool Demangle, StringRef DSYMPath)
   : Dylib(std::move(Dylib)), Mode(Mode), Demangle(Demangle),
-Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
+DSYMPath(DSYMPath), Exports(std::make_unique()),
+Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
   Result verify(ObjCInterfaceRecord *R, const FrontendAttrs *FA);
@@ -143,6 +145,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   std::string getAnnotatedName(const Record *R, SymbolContext ,
bool ValidSourceLoc = true);
 
+  /// Extract source location for symbol implementations.
+  /// As this is a relatively expensive operation, it is only used
+  /// when there is a violation to report and there is not a known declaration
+  /// in the interface.
+  void accumulateSrcLocForDylibSymbols();
+
   // Symbols in dylib.
   llvm::MachO::Records Dylib;
 
@@ -152,11 +160,17 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Attempt to demangle when reporting violations.
   bool Demangle = false;
 
+  // File path to DSYM file.
+  StringRef DSYMPath;
+
   // Valid symbols in final text file.
   std::unique_ptr Exports = std::make_unique();
 
   // Track current state of verification while traversing AST.
   VerifierContext Ctx;
+
+  // Track DWARF provided source location for dylibs.
+  DWARFContext *DWARFCtx = nullptr;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 4961c596fd68ae..827220dbf39fb8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -34,6 +34,7 @@ using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord;
 using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord;
 using ObjCIFSymbolKind = llvm::MachO::ObjCIFSymbolKind;
 using Records = llvm::MachO::Records;
+using RecordLoc = llvm::MachO::RecordLoc;
 using RecordsSlice = llvm::MachO::RecordsSlice;
 using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs;
 using SymbolSet = llvm::MachO::SymbolSet;
diff --git a/clang/lib/InstallAPI/CMakeLists.txt 
b/clang/lib/InstallAPI/CMakeLists.txt
index 894db699578f20..e0bc8d969ecb3a 100644
--- a/clang/lib/InstallAPI/CMakeLists.txt
+++ 

[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits


@@ -0,0 +1,40 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+
+// Build a simple dylib with debug info.
+; RUN: %clang --target=arm64-apple-macos13 -g -dynamiclib %t/foo.c \

cyndyishida wrote:

@JDevlieghere Is there a better/known practice for generating full dylibs with 
debug info for tests? Hopefully, PR CI will let me know, but I'm a little 
worried about different linker semantics. 
e.g. Xcode's ld requires all userspace dylibs link against libSystem. 

https://github.com/llvm/llvm-project/pull/86852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add support for parsing dSYMs (PR #86852)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/86852

InstallAPI does not directly look at object files in the dylib for 
verification. To help diagnose violations where a declaration is undiscovered 
in headers, parse the dSYM and look up the source location for symbols. 
Emitting out the source location with a diagnostic is enough for some IDE's 
(e.g. Xcode) to have them map back to editable source files.

>From 9ddf01a4f28df19914aa393b1ac518410693af5b Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Wed, 27 Mar 2024 14:33:15 -0400
Subject: [PATCH] [InstallAPI] Add support for parsing dSYMs

InstallAPI does not directly look at object files in the dylib. To help
diagnose violations where a declaration is undiscovered in headers,
parse the dSYM and lookup the source location for symbols.
Emitting out the source location with a diagnostic is enough for
some IDE's (e.g. Xcode) to have them map back to editable source files.
---
 .../include/clang/InstallAPI/DylibVerifier.h  |  20 +++-
 clang/include/clang/InstallAPI/MachO.h|   1 +
 clang/lib/InstallAPI/CMakeLists.txt   |   1 +
 clang/lib/InstallAPI/DylibVerifier.cpp|  71 ---
 clang/test/CMakeLists.txt |   1 +
 clang/test/InstallAPI/diagnostics-dsym.test   |  40 +++
 clang/test/lit.cfg.py |   1 +
 .../tools/clang-installapi/InstallAPIOpts.td  |   2 +
 clang/tools/clang-installapi/Options.cpp  |   6 +-
 clang/tools/clang-installapi/Options.h|   3 +
 llvm/include/llvm/TextAPI/DylibReader.h   |   9 ++
 llvm/include/llvm/TextAPI/Record.h|  17 +++
 llvm/lib/TextAPI/BinaryReader/CMakeLists.txt  |   1 +
 llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 112 +-
 14 files changed, 263 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/InstallAPI/diagnostics-dsym.test

diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 49de24763f1f93..22cdc234486cf3 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -31,6 +31,7 @@ enum class VerificationMode {
 class DylibVerifier : llvm::MachO::RecordVisitor {
 private:
   struct SymbolContext;
+  struct DWARFContext;
 
 public:
   enum class Result { NoVerify, Ignore, Valid, Invalid };
@@ -54,7 +55,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
 DiagnosticsEngine *Diag = nullptr;
 
 // Handle diagnostics reporting for target level violations.
-void emitDiag(llvm::function_ref Report);
+void emitDiag(llvm::function_ref Report, RecordLoc *Loc = nullptr);
 
 VerifierContext() = default;
 VerifierContext(DiagnosticsEngine *Diag) : Diag(Diag) {}
@@ -63,9 +64,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   DylibVerifier() = default;
 
   DylibVerifier(llvm::MachO::Records &, DiagnosticsEngine *Diag,
-VerificationMode Mode, bool Demangle)
+VerificationMode Mode, bool Demangle, StringRef DSYMPath)
   : Dylib(std::move(Dylib)), Mode(Mode), Demangle(Demangle),
-Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {}
+DSYMPath(DSYMPath), Exports(std::make_unique()),
+Ctx(VerifierContext{Diag}) {}
 
   Result verify(GlobalRecord *R, const FrontendAttrs *FA);
   Result verify(ObjCInterfaceRecord *R, const FrontendAttrs *FA);
@@ -143,6 +145,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   std::string getAnnotatedName(const Record *R, SymbolContext ,
bool ValidSourceLoc = true);
 
+  /// Extract source location for symbol implementations.
+  /// As this is a relatively expensive operation, it is only used
+  /// when there is a violation to report and there is not a known declaration
+  /// in the interface.
+  void accumulateSrcLocForDylibSymbols();
+
   // Symbols in dylib.
   llvm::MachO::Records Dylib;
 
@@ -152,11 +160,17 @@ class DylibVerifier : llvm::MachO::RecordVisitor {
   // Attempt to demangle when reporting violations.
   bool Demangle = false;
 
+  // File path to DSYM file.
+  StringRef DSYMPath;
+
   // Valid symbols in final text file.
   std::unique_ptr Exports = std::make_unique();
 
   // Track current state of verification while traversing AST.
   VerifierContext Ctx;
+
+  // Track DWARF provided source location for dylibs.
+  DWARFContext *DWARFCtx = nullptr;
 };
 
 } // namespace installapi
diff --git a/clang/include/clang/InstallAPI/MachO.h 
b/clang/include/clang/InstallAPI/MachO.h
index 4961c596fd68ae..827220dbf39fb8 100644
--- a/clang/include/clang/InstallAPI/MachO.h
+++ b/clang/include/clang/InstallAPI/MachO.h
@@ -34,6 +34,7 @@ using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord;
 using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord;
 using ObjCIFSymbolKind = llvm::MachO::ObjCIFSymbolKind;
 using Records = llvm::MachO::Records;
+using RecordLoc = llvm::MachO::RecordLoc;
 

[clang] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/86587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86587

>From 5be17ceb3272253aa52d77fbf8426782e9c21f72 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 25 Mar 2024 17:12:14 -0400
Subject: [PATCH] [InstallAPI] Add *umbrella-header options

Umbrella headers are a concept for darwin based libraries. They allow
framework authors control the order of which their headers should be
parsed and allows clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  1 +
 clang/include/clang/InstallAPI/HeaderFile.h   | 16 ++--
 .../Umbrella/Umbrella.framework/Headers/AAA.h |  3 +
 .../Headers/SpecialUmbrella.h |  1 +
 .../PrivateHeaders/AAA_Private.h  |  3 +
 .../PrivateHeaders/SpecialPrivateUmbrella.h   |  1 +
 .../InstallAPI/umbrella-headers-unix.test | 40 ++
 clang/test/InstallAPI/umbrella-headers.test   | 48 +++
 .../tools/clang-installapi/InstallAPIOpts.td  | 12 +++
 clang/tools/clang-installapi/Options.cpp  | 79 ++-
 clang/tools/clang-installapi/Options.h|  9 +++
 11 files changed, 206 insertions(+), 7 deletions(-)
 create mode 100644 
clang/test/InstallAPI/Inputs/Umbrella/Umbrella.framework/Headers/AAA.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Umbrella/Umbrella.framework/Headers/SpecialUmbrella.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Umbrella/Umbrella.framework/PrivateHeaders/AAA_Private.h
 create mode 100644 
clang/test/InstallAPI/Inputs/Umbrella/Umbrella.framework/PrivateHeaders/SpecialPrivateUmbrella.h
 create mode 100644 clang/test/InstallAPI/umbrella-headers-unix.test
 create mode 100644 clang/test/InstallAPI/umbrella-headers.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 27df731fa28627..e3263fe9ccb9d4 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -18,6 +18,7 @@ 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;
+def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 
umbrella header file not found in input: '%0'">;
 } // 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 235b4da3add840..c67503d4ad49e9 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -24,8 +24,6 @@
 
 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.
@@ -33,6 +31,8 @@ enum class HeaderType {
   /// Represents declarations only accessible as implementation details to the
   /// input library.
   Project,
+  /// Unset or unknown type.
+  Unknown,
 };
 
 inline StringRef getName(const HeaderType T) {
@@ -62,6 +62,8 @@ class HeaderFile {
   bool Excluded{false};
   /// Add header file to processing.
   bool Extra{false};
+  /// Specify that header file is the umbrella header for library.
+  bool Umbrella{false};
 
 public:
   HeaderFile() = delete;
@@ -79,17 +81,21 @@ class HeaderFile {
 
   void setExtra(bool V = true) { Extra = V; }
   void setExcluded(bool V = true) { Excluded = V; }
+  void setUmbrellaHeader(bool V = true) { Umbrella = V; }
   bool isExtra() const { return Extra; }
   bool isExcluded() const { return Excluded; }
+  bool isUmbrellaHeader() const { return Umbrella; }
 
   bool useIncludeName() const {
 return Type != HeaderType::Project && !IncludeName.empty();
   }
 
   bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
-   std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language, Other.Excluded, Other.Extra);
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra,
+Umbrella) == std::tie(Other.Type, Other.FullPath,
+  Other.IncludeName, Other.Language,
+  Other.Excluded, Other.Extra,
+  Other.Umbrella);
   }
 };
 
diff --git 

[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (PR #86808)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida edited 
https://github.com/llvm/llvm-project/pull/86808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (PR #86808)

2024-03-27 Thread Cyndy Ishida via cfe-commits


@@ -255,7 +255,7 @@ bool InstallAPIVisitor::VisitFunctionDecl(const 
FunctionDecl *D) {
   return true;
 
 // Skip methods in CXX RecordDecls.
-for (auto P : D->getASTContext().getParents(*M)) {
+for (const auto  : D->getASTContext().getParents(*M)) {

cyndyishida wrote:

```suggestion
for (const DynTypedNode  : D->getASTContext().getParents(*M)) {
```
An improvement would be to be explicit about the type.

https://github.com/llvm/llvm-project/pull/86808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (PR #86808)

2024-03-27 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida approved this pull request.

Can you condense the title to something more like `[clang-installapi] Remove 
unnecessary copy`? 


A couple of nits but in general looks good. Thanks for fixing this! 

https://github.com/llvm/llvm-project/pull/86808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86587

>From 9b25b0486d8f3c8409ee199a9f4695da7780e6cb Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 25 Mar 2024 17:12:14 -0400
Subject: [PATCH 1/3] [InstallAPI] Add *umbrella-header options

Umbrella headers are a concept for darwin based libraries. They allow
framework authors control the order of which their headers should be
parsed and allows clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  1 +
 clang/include/clang/InstallAPI/HeaderFile.h   | 12 ++-
 clang/test/InstallAPI/umbrella-headers.test   | 59 +++
 .../tools/clang-installapi/InstallAPIOpts.td  | 12 +++
 clang/tools/clang-installapi/Options.cpp  | 74 +++
 clang/tools/clang-installapi/Options.h|  9 +++
 llvm/include/llvm/TextAPI/Utils.h |  3 +
 7 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/InstallAPI/umbrella-headers.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 27df731fa28627..d710688fc1fe20 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -18,6 +18,7 @@ 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;
+def err_no_such_umbrella_header_file : Error<"no such 
%select{public|private|project}1 umbrella header file: '%0'">;
 } // 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 235b4da3add840..332cd415b39ae4 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -62,6 +62,8 @@ class HeaderFile {
   bool Excluded{false};
   /// Add header file to processing.
   bool Extra{false};
+  /// Specify that header file is the umbrella header for library.
+  bool Umbrella{false};
 
 public:
   HeaderFile() = delete;
@@ -79,17 +81,21 @@ class HeaderFile {
 
   void setExtra(bool V = true) { Extra = V; }
   void setExcluded(bool V = true) { Excluded = V; }
+  void setUmbrellaHeader(bool V = true) { Umbrella = V; }
   bool isExtra() const { return Extra; }
   bool isExcluded() const { return Excluded; }
+  bool isUmbrellaHeader() const { return Umbrella; }
 
   bool useIncludeName() const {
 return Type != HeaderType::Project && !IncludeName.empty();
   }
 
   bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
-   std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language, Other.Excluded, Other.Extra);
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra,
+Umbrella) == std::tie(Other.Type, Other.FullPath,
+  Other.IncludeName, Other.Language,
+  Other.Excluded, Other.Extra,
+  Other.Umbrella);
   }
 };
 
diff --git a/clang/test/InstallAPI/umbrella-headers.test 
b/clang/test/InstallAPI/umbrella-headers.test
new file mode 100644
index 00..b91d3df25b38ec
--- /dev/null
+++ b/clang/test/InstallAPI/umbrella-headers.test
@@ -0,0 +1,59 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+// Try umbrella header flags with different spellings.
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN:  -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: 
--public-umbrella-header=%t/Frameworks/Umbrella2.framework/Headers/SpecialUmbrella.h
 \
+; RUN: -private-umbrella-header \
+; RUN: 
%t/Frameworks/Umbrella2.framework/PrivateHeaders/SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN: -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: --public-umbrella-header=SpecialUmbrella.h \
+; RUN: --private-umbrella-header=SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: 

[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida edited 
https://github.com/llvm/llvm-project/pull/86587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits


@@ -424,6 +448,56 @@ InstallAPIContext Options::createContext() {
 if (!Glob->didMatch())
   Diags->Report(diag::warn_glob_did_not_match) << Glob->str();
 
+  // Mark any explicit or inferred umbrella headers. If one exists, move
+  // that to the beginning of the input headers.
+  auto MarkandMoveUmbrellaInHeaders = [&](Regex ,
+  HeaderType Type) -> bool {
+auto It = find_if(Ctx.InputHeaders, [, Type](const HeaderFile ) {
+  return (H.getType() == Type) && Regex.match(H.getPath());
+});
+
+if (It == Ctx.InputHeaders.end())
+  return false;
+It->setUmbrellaHeader();
+
+// Because there can be an umbrella header per header type,
+// find the first non umbrella header to swap position with.
+auto BeginPos = find_if(Ctx.InputHeaders, [](const HeaderFile ) {
+  return !H.isUmbrellaHeader();
+});
+if (BeginPos != Ctx.InputHeaders.end() && BeginPos < It)
+  std::swap(*BeginPos, *It);
+return true;
+  };
+
+  auto FindUmbrellaHeader = [&](StringRef HeaderPath, HeaderType Type) -> bool 
{
+if (!HeaderPath.empty()) {
+  auto EscapedString = Regex::escape(HeaderPath);
+  Regex UmbrellaRegex(EscapedString);
+  if (!MarkandMoveUmbrellaInHeaders(UmbrellaRegex, Type)) {
+Diags->Report(diag::err_no_such_umbrella_header_file)
+<< HeaderPath << (unsigned)Type - 1;

cyndyishida wrote:

Oh sorry, I thought you meant for umbrella headers. In general, it's used as a 
default value. E.g. When non-input header files that are parsed through 
includes, cached then skipped over when picking up declarations during AST 
traversal. 
I think that's generally good to have a concept of null for enum values.

https://github.com/llvm/llvm-project/pull/86587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86587

>From 9b25b0486d8f3c8409ee199a9f4695da7780e6cb Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 25 Mar 2024 17:12:14 -0400
Subject: [PATCH 1/3] [InstallAPI] Add *umbrella-header options

Umbrella headers are a concept for darwin based libraries. They allow
framework authors control the order of which their headers should be
parsed and allows clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  1 +
 clang/include/clang/InstallAPI/HeaderFile.h   | 12 ++-
 clang/test/InstallAPI/umbrella-headers.test   | 59 +++
 .../tools/clang-installapi/InstallAPIOpts.td  | 12 +++
 clang/tools/clang-installapi/Options.cpp  | 74 +++
 clang/tools/clang-installapi/Options.h|  9 +++
 llvm/include/llvm/TextAPI/Utils.h |  3 +
 7 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/InstallAPI/umbrella-headers.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 27df731fa28627..d710688fc1fe20 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -18,6 +18,7 @@ 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;
+def err_no_such_umbrella_header_file : Error<"no such 
%select{public|private|project}1 umbrella header file: '%0'">;
 } // 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 235b4da3add840..332cd415b39ae4 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -62,6 +62,8 @@ class HeaderFile {
   bool Excluded{false};
   /// Add header file to processing.
   bool Extra{false};
+  /// Specify that header file is the umbrella header for library.
+  bool Umbrella{false};
 
 public:
   HeaderFile() = delete;
@@ -79,17 +81,21 @@ class HeaderFile {
 
   void setExtra(bool V = true) { Extra = V; }
   void setExcluded(bool V = true) { Excluded = V; }
+  void setUmbrellaHeader(bool V = true) { Umbrella = V; }
   bool isExtra() const { return Extra; }
   bool isExcluded() const { return Excluded; }
+  bool isUmbrellaHeader() const { return Umbrella; }
 
   bool useIncludeName() const {
 return Type != HeaderType::Project && !IncludeName.empty();
   }
 
   bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
-   std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language, Other.Excluded, Other.Extra);
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra,
+Umbrella) == std::tie(Other.Type, Other.FullPath,
+  Other.IncludeName, Other.Language,
+  Other.Excluded, Other.Extra,
+  Other.Umbrella);
   }
 };
 
diff --git a/clang/test/InstallAPI/umbrella-headers.test 
b/clang/test/InstallAPI/umbrella-headers.test
new file mode 100644
index 00..b91d3df25b38ec
--- /dev/null
+++ b/clang/test/InstallAPI/umbrella-headers.test
@@ -0,0 +1,59 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+// Try umbrella header flags with different spellings.
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN:  -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: 
--public-umbrella-header=%t/Frameworks/Umbrella2.framework/Headers/SpecialUmbrella.h
 \
+; RUN: -private-umbrella-header \
+; RUN: 
%t/Frameworks/Umbrella2.framework/PrivateHeaders/SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN: -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: --public-umbrella-header=SpecialUmbrella.h \
+; RUN: --private-umbrella-header=SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: 

[clang] 6d579cd - [InstallAPI] Add missing license header to file, NFC

2024-03-26 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-03-26T11:56:16-04:00
New Revision: 6d579cd1d91cdde5adfa455bda7903e737e9d5cf

URL: 
https://github.com/llvm/llvm-project/commit/6d579cd1d91cdde5adfa455bda7903e737e9d5cf
DIFF: 
https://github.com/llvm/llvm-project/commit/6d579cd1d91cdde5adfa455bda7903e737e9d5cf.diff

LOG: [InstallAPI] Add missing license header to file, NFC

Added: 


Modified: 
clang/lib/InstallAPI/DylibVerifier.cpp

Removed: 




diff  --git a/clang/lib/InstallAPI/DylibVerifier.cpp 
b/clang/lib/InstallAPI/DylibVerifier.cpp
index 94b8e9cd3233a9..ba25e4183a9b89 100644
--- a/clang/lib/InstallAPI/DylibVerifier.cpp
+++ b/clang/lib/InstallAPI/DylibVerifier.cpp
@@ -1,3 +1,11 @@
+//===- DylibVerifier.cpp *- 
C++--*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
 #include "clang/InstallAPI/DylibVerifier.h"
 #include "clang/InstallAPI/FrontendRecords.h"
 #include "clang/InstallAPI/InstallAPIDiagnostic.h"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits


@@ -424,6 +448,56 @@ InstallAPIContext Options::createContext() {
 if (!Glob->didMatch())
   Diags->Report(diag::warn_glob_did_not_match) << Glob->str();
 
+  // Mark any explicit or inferred umbrella headers. If one exists, move
+  // that to the beginning of the input headers.
+  auto MarkandMoveUmbrellaInHeaders = [&](Regex ,
+  HeaderType Type) -> bool {
+auto It = find_if(Ctx.InputHeaders, [, Type](const HeaderFile ) {
+  return (H.getType() == Type) && Regex.match(H.getPath());
+});
+
+if (It == Ctx.InputHeaders.end())
+  return false;
+It->setUmbrellaHeader();
+
+// Because there can be an umbrella header per header type,
+// find the first non umbrella header to swap position with.
+auto BeginPos = find_if(Ctx.InputHeaders, [](const HeaderFile ) {
+  return !H.isUmbrellaHeader();
+});
+if (BeginPos != Ctx.InputHeaders.end() && BeginPos < It)
+  std::swap(*BeginPos, *It);
+return true;
+  };
+
+  auto FindUmbrellaHeader = [&](StringRef HeaderPath, HeaderType Type) -> bool 
{
+if (!HeaderPath.empty()) {
+  auto EscapedString = Regex::escape(HeaderPath);
+  Regex UmbrellaRegex(EscapedString);
+  if (!MarkandMoveUmbrellaInHeaders(UmbrellaRegex, Type)) {
+Diags->Report(diag::err_no_such_umbrella_header_file)
+<< HeaderPath << (unsigned)Type - 1;

cyndyishida wrote:

No, added asserts.

https://github.com/llvm/llvm-project/pull/86587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-26 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/86587

>From 9b25b0486d8f3c8409ee199a9f4695da7780e6cb Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 25 Mar 2024 17:12:14 -0400
Subject: [PATCH 1/2] [InstallAPI] Add *umbrella-header options

Umbrella headers are a concept for darwin based libraries. They allow
framework authors control the order of which their headers should be
parsed and allows clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  1 +
 clang/include/clang/InstallAPI/HeaderFile.h   | 12 ++-
 clang/test/InstallAPI/umbrella-headers.test   | 59 +++
 .../tools/clang-installapi/InstallAPIOpts.td  | 12 +++
 clang/tools/clang-installapi/Options.cpp  | 74 +++
 clang/tools/clang-installapi/Options.h|  9 +++
 llvm/include/llvm/TextAPI/Utils.h |  3 +
 7 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/InstallAPI/umbrella-headers.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 27df731fa28627..d710688fc1fe20 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -18,6 +18,7 @@ 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;
+def err_no_such_umbrella_header_file : Error<"no such 
%select{public|private|project}1 umbrella header file: '%0'">;
 } // 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 235b4da3add840..332cd415b39ae4 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -62,6 +62,8 @@ class HeaderFile {
   bool Excluded{false};
   /// Add header file to processing.
   bool Extra{false};
+  /// Specify that header file is the umbrella header for library.
+  bool Umbrella{false};
 
 public:
   HeaderFile() = delete;
@@ -79,17 +81,21 @@ class HeaderFile {
 
   void setExtra(bool V = true) { Extra = V; }
   void setExcluded(bool V = true) { Excluded = V; }
+  void setUmbrellaHeader(bool V = true) { Umbrella = V; }
   bool isExtra() const { return Extra; }
   bool isExcluded() const { return Excluded; }
+  bool isUmbrellaHeader() const { return Umbrella; }
 
   bool useIncludeName() const {
 return Type != HeaderType::Project && !IncludeName.empty();
   }
 
   bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
-   std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language, Other.Excluded, Other.Extra);
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra,
+Umbrella) == std::tie(Other.Type, Other.FullPath,
+  Other.IncludeName, Other.Language,
+  Other.Excluded, Other.Extra,
+  Other.Umbrella);
   }
 };
 
diff --git a/clang/test/InstallAPI/umbrella-headers.test 
b/clang/test/InstallAPI/umbrella-headers.test
new file mode 100644
index 00..b91d3df25b38ec
--- /dev/null
+++ b/clang/test/InstallAPI/umbrella-headers.test
@@ -0,0 +1,59 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+// Try umbrella header flags with different spellings.
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN:  -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: 
--public-umbrella-header=%t/Frameworks/Umbrella2.framework/Headers/SpecialUmbrella.h
 \
+; RUN: -private-umbrella-header \
+; RUN: 
%t/Frameworks/Umbrella2.framework/PrivateHeaders/SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN: -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: --public-umbrella-header=SpecialUmbrella.h \
+; RUN: --private-umbrella-header=SpecialPrivateUmbrella.h \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck -allow-empty %s
+
+; CHECK-NOT: error
+; CHECK-NOT: 

[clang] [llvm] [InstallAPI] Add *umbrella-header options (PR #86587)

2024-03-25 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/86587

Umbrella headers are a concept for Darwin-based libraries. They allow framework 
authors to control the order in which their headers should be parsed and allow 
clients to access available headers by including a single header.

InstallAPI will attempt to find the umbrella based on the name of the 
framework. Users can also specify this explicitly by using command line options 
specifying the umbrella header by file path. There can be an umbrella header 
per access level. 

>From 9b25b0486d8f3c8409ee199a9f4695da7780e6cb Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Mon, 25 Mar 2024 17:12:14 -0400
Subject: [PATCH] [InstallAPI] Add *umbrella-header options

Umbrella headers are a concept for darwin based libraries. They allow
framework authors control the order of which their headers should be
parsed and allows clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path.
---
 .../clang/Basic/DiagnosticInstallAPIKinds.td  |  1 +
 clang/include/clang/InstallAPI/HeaderFile.h   | 12 ++-
 clang/test/InstallAPI/umbrella-headers.test   | 59 +++
 .../tools/clang-installapi/InstallAPIOpts.td  | 12 +++
 clang/tools/clang-installapi/Options.cpp  | 74 +++
 clang/tools/clang-installapi/Options.h|  9 +++
 llvm/include/llvm/TextAPI/Utils.h |  3 +
 7 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/InstallAPI/umbrella-headers.test

diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td 
b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
index 27df731fa28627..d710688fc1fe20 100644
--- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
+++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td
@@ -18,6 +18,7 @@ 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;
+def err_no_such_umbrella_header_file : Error<"no such 
%select{public|private|project}1 umbrella header file: '%0'">;
 } // 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 235b4da3add840..332cd415b39ae4 100644
--- a/clang/include/clang/InstallAPI/HeaderFile.h
+++ b/clang/include/clang/InstallAPI/HeaderFile.h
@@ -62,6 +62,8 @@ class HeaderFile {
   bool Excluded{false};
   /// Add header file to processing.
   bool Extra{false};
+  /// Specify that header file is the umbrella header for library.
+  bool Umbrella{false};
 
 public:
   HeaderFile() = delete;
@@ -79,17 +81,21 @@ class HeaderFile {
 
   void setExtra(bool V = true) { Extra = V; }
   void setExcluded(bool V = true) { Excluded = V; }
+  void setUmbrellaHeader(bool V = true) { Umbrella = V; }
   bool isExtra() const { return Extra; }
   bool isExcluded() const { return Excluded; }
+  bool isUmbrellaHeader() const { return Umbrella; }
 
   bool useIncludeName() const {
 return Type != HeaderType::Project && !IncludeName.empty();
   }
 
   bool operator==(const HeaderFile ) const {
-return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra) ==
-   std::tie(Other.Type, Other.FullPath, Other.IncludeName,
-Other.Language, Other.Excluded, Other.Extra);
+return std::tie(Type, FullPath, IncludeName, Language, Excluded, Extra,
+Umbrella) == std::tie(Other.Type, Other.FullPath,
+  Other.IncludeName, Other.Language,
+  Other.Excluded, Other.Extra,
+  Other.Umbrella);
   }
 };
 
diff --git a/clang/test/InstallAPI/umbrella-headers.test 
b/clang/test/InstallAPI/umbrella-headers.test
new file mode 100644
index 00..b91d3df25b38ec
--- /dev/null
+++ b/clang/test/InstallAPI/umbrella-headers.test
@@ -0,0 +1,59 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+// Try umbrella header flags with different spellings.
+; RUN: clang-installapi --target=arm64-apple-macosx13 \
+; RUN:  -install_name 
/System/Library/Frameworks/Umbrella2.framework/Versions/A/Umbrella2 \
+; RUN: -ObjC -F%t/Frameworks/ %t/inputs.json \
+; RUN: 
--public-umbrella-header=%t/Frameworks/Umbrella2.framework/Headers/SpecialUmbrella.h
 \
+; RUN: -private-umbrella-header \
+; RUN: 

[clang] [llvm] Reapply "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)" (PR #86574)

2024-03-25 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/86574
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a9d8bf4 - [InstallAPI] Silence unused variable warning, NFC

2024-03-25 Thread Cyndy Ishida via cfe-commits

Author: Cyndy Ishida
Date: 2024-03-25T17:20:24-04:00
New Revision: a9d8bf41bf9538154bcc3afcef55bdf309890c6f

URL: 
https://github.com/llvm/llvm-project/commit/a9d8bf41bf9538154bcc3afcef55bdf309890c6f
DIFF: 
https://github.com/llvm/llvm-project/commit/a9d8bf41bf9538154bcc3afcef55bdf309890c6f.diff

LOG: [InstallAPI] Silence unused variable warning, NFC

Added: 


Modified: 
clang/lib/InstallAPI/Visitor.cpp

Removed: 




diff  --git a/clang/lib/InstallAPI/Visitor.cpp 
b/clang/lib/InstallAPI/Visitor.cpp
index 452c8f2fb1e489..f8f5d8d53d5691 100644
--- a/clang/lib/InstallAPI/Visitor.cpp
+++ b/clang/lib/InstallAPI/Visitor.cpp
@@ -205,9 +205,10 @@ bool InstallAPIVisitor::VisitObjCCategoryDecl(const 
ObjCCategoryDecl *D) {
   const ObjCInterfaceDecl *InterfaceD = D->getClassInterface();
   const StringRef InterfaceName = InterfaceD->getName();
 
-  auto [Category, FA] = Ctx.Slice->addObjCCategory(InterfaceName, CategoryName,
-   Avail, D, *Access);
-  recordObjCInstanceVariables(D->getASTContext(), Category, InterfaceName,
+  std::pair Category =
+  Ctx.Slice->addObjCCategory(InterfaceName, CategoryName, Avail, D,
+ *Access);
+  recordObjCInstanceVariables(D->getASTContext(), Category.first, 
InterfaceName,
   D->ivars());
   return true;
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstallAPI] Add --extra* and --exclude* cli options for header input (PR #86522)

2024-03-25 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida closed 
https://github.com/llvm/llvm-project/pull/86522
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >