diff --git a/README.en.md b/README.en.md index 2de3e41700ab35644f61f3afc812ac462c5e58ac..93c563820be353d39c95007fedc037a73ef8e2cd 100644 --- a/README.en.md +++ b/README.en.md @@ -1,7 +1,7 @@ -# clang +# clang-15 #### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} +C Language Family Front-end #### Software Architecture Software architecture description diff --git a/README.md b/README.md index f5b5b7f00208741f453e43e3d8888be0d7727a20..3df8a6281f217de2ae59bff64e850425465844c1 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -# clang +# clang-15 #### 介绍 -{**以下是码云平台说明,您可以替换此简介** -码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +C Language Family Front-end #### 软件架构 软件架构说明 @@ -29,11 +27,11 @@ 4. 新建 Pull Request -#### 码云特技 +#### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 -5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/clang-12.0.1.src.tar.xz b/clang-15.0.7.src.tar.xz similarity index 58% rename from clang-12.0.1.src.tar.xz rename to clang-15.0.7.src.tar.xz index 6eaa7e3aca193f2dd2d8afcb6ffc6282aacfc7c6..0062fa6d3e3a5fd0522d9d1d26aecd6708a5d051 100644 Binary files a/clang-12.0.1.src.tar.xz and b/clang-15.0.7.src.tar.xz differ diff --git a/clang-config.h b/clang-config.h deleted file mode 100644 index c369b4551f785da6e2c586417caa36591a9eaee2..0000000000000000000000000000000000000000 --- a/clang-config.h +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#if __WORDSIZE == 32 -#include "config-32.h" -#elif __WORDSIZE == 64 -#include "config-64.h" -#else -#error "Unknown word size" -#endif diff --git a/clang-tools-extra-12.0.1.src.tar.xz b/clang-tools-extra-12.0.1.src.tar.xz deleted file mode 100644 index 4fe27ad89b32eec9a0bf3a5abb90826388047e9b..0000000000000000000000000000000000000000 Binary files a/clang-tools-extra-12.0.1.src.tar.xz and /dev/null differ diff --git a/clang-tools-extra-15.0.7.src.tar.xz b/clang-tools-extra-15.0.7.src.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..113884182abe53e4a1e8bfa1b0d0a9d42d986d9a Binary files /dev/null and b/clang-tools-extra-15.0.7.src.tar.xz differ diff --git a/clang.spec b/clang.spec index 03956aeeda12201d596f4a3502a49045289ee277..7648ca2702c903d3bc4e363cfb72342bace294d9 100644 --- a/clang.spec +++ b/clang.spec @@ -1,51 +1,115 @@ -%global maj_ver 12 +%bcond_without check + +%global maj_ver 15 %global min_ver 0 -%global patch_ver 1 -%global clang_srcdir clang-%{version}.src -%global clang_tools_srcdir clang-tools-extra-%{version}.src - -Name: clang -Version: 12.0.1 -Release: 3 -License: GPL-2.0-only and Apache-2.0 and MIT -Summary: An "LLVM native" C/C++/Objective-C compiler +%global patch_ver 7 +%global clang_version %{maj_ver}.%{min_ver}.%{patch_ver} + +%global pkg_name clang%{maj_ver} +%global bin_suffix -%{maj_ver} +%global install_prefix %{_libdir}/llvm%{maj_ver} +%global install_bindir %{install_prefix}/bin +%global install_includedir %{install_prefix}/include +%global install_libdir %{install_prefix}/lib +%global install_libexecdir %{install_prefix}/libexec +%global install_sharedir %{install_prefix}/share +%global install_docdir %{install_sharedir}/doc + +%global pkg_bindir %{install_bindir} +%global pkg_includedir %{install_includedir} +%global pkg_libdir %{install_libdir} +%global pkg_libexecdir %{install_libexecdir} +%global pkg_sharedir %{install_sharedir} +%global pkg_docdir %{install_sharedir}/doc + +%global clang_srcdir clang-%{clang_version}.src +%global clang_tools_srcdir clang-tools-extra-%{clang_version}.src +%global max_link_jobs 2 + +Name: %pkg_name +Version: %{clang_version} +Release: 1 +Summary: A C language family front-end for LLVM + +License: NCSA URL: http://llvm.org -Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{clang_srcdir}.tar.xz -Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{clang_tools_srcdir}.tar.xz -Source2: clang-config.h - -BuildRequires: cmake gcc-c++ python-sphinx git -BuildRequires: llvm-devel = %{version} -BuildRequires: llvm-static = %{version} -BuildRequires: llvm-googletest = %{version} -BuildRequires: libxml2-devel perl-generators ncurses-devel emacs libatomic -BuildRequires: python3-lit python3-sphinx python3-devel - +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_srcdir}.tar.xz +Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_tools_srcdir}.tar.xz + +Patch0: fedora-PATCH-clang-Reorganize-gtest-integration.patch +Patch1: fedora-PATCH-clang-Don-t-install-static-libraries.patch + +Patch201: fedora-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch + +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: cmake +BuildRequires: emacs +BuildRequires: libatomic +BuildRequires: llvm%{maj_ver}-devel = %{version} +BuildRequires: llvm%{maj_ver}-static = %{version} +BuildRequires: llvm%{maj_ver}-test = %{version} +BuildRequires: llvm%{maj_ver}-googletest = %{version} + +BuildRequires: libxml2-devel +BuildRequires: multilib-rpm-config +BuildRequires: ninja-build +BuildRequires: ncurses-devel +BuildRequires: perl-generators +BuildRequires: python3-lit >= %{version} +BuildRequires: python3-sphinx +BuildRequires: python3-recommonmark +BuildRequires: python3-devel + +BuildRequires: perl(Digest::MD5) +BuildRequires: perl(File::Copy) +BuildRequires: perl(File::Find) +BuildRequires: perl(File::Path) +BuildRequires: perl(File::Temp) +BuildRequires: perl(FindBin) +BuildRequires: perl(Hash::Util) +BuildRequires: perl(lib) +BuildRequires: perl(Term::ANSIColor) +BuildRequires: perl(Text::ParseWords) +BuildRequires: perl(Sys::Hostname) + +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +Requires: libstdc++-devel +Requires: gcc-c++ -Requires: libstdc++-devel gcc-c++ emacs-filesystem -Requires: %{name}-resource-filesystem = %{version} Provides: clang(major) = %{maj_ver} -Provides: %{name}-libs = %{version}-%{release} -Obsoletes: %{name}-libs < %{version}-%{release} -Recommends: libomp = %{version} -Recommends: compiler-rt = %{version} -Conflicts: compiler-rt < %{version} -Conflicts: compiler-rt > %{version} - -Patch0: support-ignored_and_replaced_opts.patch -Patch1: support-print-c-function-prototype.patch +Conflicts: compiler-rt < 11.0.0 %description -The Clang project provides a language front-end and tooling infrastructure for\ -languages in the C language family (C, C++, Objective C/C++, OpenCL, CUDA, and\ -RenderScript) for the LLVM project. Both a GCC-compatible compiler driver (clang)\ -and an MSVC-compatible compiler driver (clang-cl.exe) are provided.\ +clang: noun + 1. A loud, resonant, metallic sound. + 2. The strident call of a crane or goose. + 3. C-language family front-end toolkit. + +The goal of the Clang project is to create a new C, C++, Objective C +and Objective C++ front-end for the LLVM compiler. Its tools are built +as libraries and designed to be loosely-coupled and extensible. + +Install compiler-rt if you want the Blocks C language extension or to +enable sanitization and profiling options when building, and +libomp-devel to enable -fopenmp. + +%package libs +Summary: Runtime library for clang +Requires: %{name}-resource-filesystem%{?_isa} = %{version} +Recommends: compiler-rt%{?_isa} = %{version} +Recommends: libatomic%{?_isa} +Recommends: libomp-devel%{_isa} = %{version} +Recommends: libomp%{_isa} = %{version} + +%description libs +Runtime library for clang. %package devel -Summary: Development header files for clang. -Requires: %{name} = %{version}-%{release} -Requires: %{name}-tools-extra = %{version}-%{release} +Summary: Development header files for clang +Requires: %{name}-libs = %{version}-%{release} %description devel Development header files for clang. @@ -57,18 +121,12 @@ Provides: %{name}-resource-filesystem(major) = %{maj_ver} %description resource-filesystem This package owns the clang resouce directory: $libdir/clang/$version/ -%package help -Summary: Help manual for %{name} - -%description help -The %{name}-help package conatins man manual etc %package analyzer Summary: A source code analysis framework License: NCSA and MIT BuildArch: noarch Requires: %{name} = %{version}-%{release} -Requires: python3 %description analyzer The Clang Static Analyzer consists of both a source code analysis @@ -78,58 +136,69 @@ intended to run in tandem with a build of a project or code base. %package tools-extra Summary: Extra tools for clang -Requires: %{name}-libs = %{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: emacs-filesystem %description tools-extra A set of extra tools built using Clang's tooling API. %package -n git-clang-format -Summary: clang-format integration for git -Requires: %{name} = %{version}-%{release} +Summary: Integration of clang-format for git +Requires: %{name}-tools-extra = %{version}-%{release} Requires: git +Requires: python3 %description -n git-clang-format clang-format integration for git. %prep %setup -T -q -b 1 -n %{clang_tools_srcdir} +%autopatch -m200 -p2 + +# failing test case +rm test/clang-tidy/checkers/altera/struct-pack-align.cpp + pathfix.py -i %{__python3} -pn \ - clang-tidy/tool/*.py + clang-tidy/tool/ \ + clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py + +%setup -q -n %{clang_srcdir} +%autopatch -M200 -p2 + +# failing test case +rm test/CodeGen/profile-filter.c -%autosetup -n %{clang_srcdir} -p1 pathfix.py -i %{__python3} -pn \ - tools/clang-format/*.py \ + tools/clang-format/ \ tools/clang-format/git-clang-format \ utils/hmaptool/hmaptool \ - tools/scan-view/bin/scan-view + tools/scan-view/bin/scan-view \ + tools/scan-view/share/Reporter.py \ + tools/scan-view/share/startfile.py \ + tools/scan-build-py/bin/* \ + tools/scan-build-py/libexec/* + mv ../%{clang_tools_srcdir} tools/extra %build - mkdir -p _build cd _build - - -%global optflags %(echo %{optflags} | sed 's/-g /-g1 /') - - -%cmake .. \ +%cmake .. -G Ninja \ + -DCLANG_DEFAULT_PIE_ON_LINUX=ON \ + -DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_RPATH:BOOL=";" \ - -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ - -DLLVM_CONFIG:FILEPATH=/usr/bin/llvm-config-%{__isa_bits} \ + -DCMAKE_BUILD_TYPE=Release \ + -DPYTHON_EXECUTABLE=%{__python3} \ + -DCMAKE_SKIP_RPATH:BOOL=ON \ + -DCLANG_BUILD_TOOLS:BOOL=ON \ + -DLLVM_CONFIG:FILEPATH=%{pkg_bindir}/llvm-config-%{maj_ver}-%{__isa_bits} \ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ -DCLANG_INCLUDE_TESTS:BOOL=ON \ -DLLVM_EXTERNAL_LIT=%{_bindir}/lit \ - -DLLVM_MAIN_SRC_DIR=%{_datadir}/llvm/src \ -%if 0%{?__isa_bits} == 64 - -DLLVM_LIBDIR_SUFFIX=64 \ -%else - -DLLVM_LIBDIR_SUFFIX= \ -%endif - \ + -DLLVM_LIT_ARGS="-vv" \ + -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver} \ + -DLLVM_MAIN_SRC_DIR=%{_libdir}/llvm%{maj_ver}/src \ + -DLLVM_BUILD_UTILS:BOOL=ON \ -DCLANG_ENABLE_ARCMT:BOOL=ON \ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ -DCLANG_INCLUDE_DOCS:BOOL=ON \ @@ -139,175 +208,186 @@ cd _build -DLLVM_ENABLE_RTTI=ON \ -DLLVM_BUILD_DOCS=ON \ -DLLVM_ENABLE_SPHINX=ON \ + -DCLANG_LINK_CLANG_DYLIB=ON \ -DSPHINX_WARNINGS_AS_ERRORS=OFF \ - \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ - -DCLANG_REPOSITORY_STRING="%{_vendor} %{version}-%{release}" \ - -DLIB_SUFFIX= + -DBUILD_SHARED_LIBS=OFF \ + -DCLANG_REPOSITORY_STRING="%{?distro} %{version}-%{release}" \ + -DCLANG_DEFAULT_UNWINDLIB=libgcc -%make_build +%ninja_build %install -%make_install -C _build - -mv -v %{buildroot}%{_includedir}/clang/Config/config{,-%{__isa_bits}}.h -install -m 0644 %{SOURCE2} %{buildroot}%{_includedir}/clang/Config/config.h -mkdir -p %{buildroot}%{_emacs_sitestartdir} -for f in clang-format.el clang-rename.el clang-include-fixer.el; do -mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/$f -done +%ninja_install -C _build +mkdir -p %{buildroot}/%{_bindir} rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript rm -vf %{buildroot}%{_datadir}/clang/clang-format-sublime.py* -rm -Rvf %{buildroot}%{_pkgdocdir} - -rm -vf %{buildroot}%{_datadir}/clang/bash-autocomplete.sh +rm -vf %{buildroot}%{install_sharedir}/clang/clang-format-bbedit.applescript +rm -vf %{buildroot}%{install_sharedir}/clang/clang-format-sublime.py* -# Create sub-directories in the clang resource directory that will be -# populated by other packages -mkdir -p %{buildroot}%{_libdir}/clang/%{version}/{include,lib,share}/ +rm -Rvf %{buildroot}%{install_docdir}/Clang/clang/html +rm -Rvf %{buildroot}%{install_sharedir}/clang/clang-doc-default-stylesheet.css +rm -Rvf %{buildroot}%{install_sharedir}/clang/index.js +rm -vf %{buildroot}%{install_sharedir}/clang/bash-autocomplete.sh -# Remove clang-tidy headers. -rm -Rvf %{buildroot}%{_includedir}/clang-tidy/ +rm -Rvf %{buildroot}%{_docdir}/Clang/clang/html +rm -Rvf %{buildroot}%{_datadir}/clang/clang-doc-default-stylesheet.css +rm -Rvf %{buildroot}%{_datadir}/clang/index.js -ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver} +for f in %{buildroot}/%{install_bindir}/*; do + filename=`basename $f` + if [ $filename != "clang%{bin_suffix}" ]; then + ln -s ../../%{install_bindir}/$filename %{buildroot}%{_bindir}/$filename%{bin_suffix} + fi +done -%check -# Checking is disabled because we don't pack libLLVMTestingSupport.a, which makes -# standalone build of clang impossible. +# Create Manpage symlinks +mkdir -p %{buildroot}/%{_mandir}/man1 +for f in %{buildroot}%{install_prefix}/share/man/man1/*; do + filename=`basename $f | cut -f 1 -d '.'` + mv $f %{buildroot}%{_mandir}/man1/$filename%{bin_suffix}.1 +done -#cd _build -#PATH=%{_libdir}/llvm:$PATH make %{?_smp_mflags} check-clang || \ -#%ifarch %{arm} -#: -#%else -#false -#%endif +mkdir -p %{buildroot}%{pkg_libdir}/clang/%{version}/{include,lib,share}/ -%post -/sbin/ldconfig +rm -Rvf %{buildroot}%{_includedir}/clang-tidy/ -%postun -/sbin/ldconfig +%check +%if %{with check} +LD_LIBRARY_PATH=%{buildroot}/%{pkg_libdir} %{__ninja} check-all -C ./_build/ +%endif %files -%{_bindir}/clang -%{_bindir}/clang++ +%license LICENSE.TXT %{_bindir}/clang-%{maj_ver} %{_bindir}/clang++-%{maj_ver} -%{_bindir}/clang-check -%{_bindir}/clang-cl -%{_bindir}/clang-cpp -%{_bindir}/clang-format -%{_bindir}/clang-doc -%{_bindir}/clang-extdef-mapping -%{_bindir}/clang-move -%{_bindir}/clang-offload-wrapper -%{_bindir}/clang-scan-deps -%{_bindir}/pp-trace -%{_bindir}/clang-offload-bundler -%{_bindir}/diagtool -%{_bindir}/hmaptool -%{_bindir}/c-index-test -%{_emacs_sitestartdir}/clang-format.el -%{_datadir}/clang/clang-format.py* -%{_datadir}/clang/clang-format-diff.py* -%{_libdir}/clang/ -%{_libdir}/*.so.* +%{_mandir}/man1/* +%{_bindir}/clang-cl-%{maj_ver} +%{_bindir}/clang-cpp-%{maj_ver} +%{pkg_bindir} + +%files libs +%{pkg_libdir}/*.so.* +%{pkg_libdir}/clang/%{version} %files devel -%{_libdir}/*.so -%{_includedir}/clang/ -%{_includedir}/clang-c/ -%{_libdir}/cmake/* -%dir %{_datadir}/clang/ +%{pkg_libdir}/*.so +%{pkg_includedir}/clang/ +%{pkg_includedir}/clang-c/ +%{pkg_includedir}/clang-tidy/ +%{pkg_libdir}/cmake/ %files resource-filesystem -%dir %{_libdir}/clang/%{version}/ -%dir %{_libdir}/clang/%{version}/include/ -%dir %{_libdir}/clang/%{version}/lib/ -%dir %{_libdir}/clang/%{version}/share/ - -%files help -%{_mandir}/man1/clang.1.gz -%{_mandir}/man1/diagtool.1.gz +%dir %{pkg_libdir}/clang/%{version}/ +%dir %{pkg_libdir}/clang/%{version}/include/ +%dir %{pkg_libdir}/clang/%{version}/lib/ +%dir %{pkg_libdir}/clang/%{version}/share/ %files analyzer -%{_bindir}/scan-view -%{_bindir}/scan-build -%{_libexecdir}/ccc-analyzer -%{_libexecdir}/c++-analyzer -%{_datadir}/scan-view/ -%{_datadir}/scan-build/ -%{_mandir}/man1/scan-build.1.* +%{_bindir}/scan-view%{bin_suffix} +%{_bindir}/scan-build%{bin_suffix} +%{_bindir}/analyze-build%{bin_suffix} +%{_bindir}/intercept-build%{bin_suffix} +%{_bindir}/scan-build-py%{bin_suffix} +%{pkg_libexecdir}/ccc-analyzer +%{pkg_libexecdir}/c++-analyzer +%{pkg_libexecdir}/analyze-c++ +%{pkg_libexecdir}/analyze-cc +%{pkg_libexecdir}/intercept-c++ +%{pkg_libexecdir}/intercept-cc +%{pkg_bindir}/scan-view +%{pkg_bindir}/scan-build +%{_mandir}/man1/* +%{pkg_libdir}/libear +%{pkg_libdir}/libscanbuild +%{pkg_sharedir}/scan-view +%{pkg_sharedir}/scan-build + %files tools-extra -%{_bindir}/clangd -%{_bindir}/clang-apply-replacements -%{_bindir}/clang-change-namespace -%{_bindir}/clang-include-fixer -%{_bindir}/clang-query -%{_bindir}/clang-refactor -%{_bindir}/clang-reorder-fields -%{_bindir}/clang-rename -%{_bindir}/clang-tidy -%{_bindir}/find-all-symbols -%{_bindir}/modularize -%{_emacs_sitestartdir}/clang-rename.el -%{_emacs_sitestartdir}/clang-include-fixer.el -%{_datadir}/clang/clang-include-fixer.py* -%{_datadir}/clang/clang-tidy-diff.py* -%{_datadir}/clang/run-clang-tidy.py* -%{_datadir}/clang/run-find-all-symbols.py* -%{_datadir}/clang/clang-rename.py* -%{_datadir}/clang/index.js -%{_datadir}/clang/clang-doc-default-stylesheet.css +%{_bindir}/c-index-test%{bin_suffix} +%{_bindir}/clang-apply-replacements%{bin_suffix} +%{_bindir}/clang-change-namespace%{bin_suffix} +%{_bindir}/clang-check%{bin_suffix} +%{_bindir}/clang-doc%{bin_suffix} +%{_bindir}/clang-extdef-mapping%{bin_suffix} +%{_bindir}/clang-format%{bin_suffix} +%{_bindir}/clang-include-fixer%{bin_suffix} +%{_bindir}/clang-move%{bin_suffix} +%{_bindir}/clang-offload-bundler%{bin_suffix} +%{_bindir}/clang-offload-packager%{bin_suffix} +%{_bindir}/clang-offload-wrapper%{bin_suffix} +%{_bindir}/clang-linker-wrapper%{bin_suffix} +%{_bindir}/clang-nvlink-wrapper%{bin_suffix} +%{_bindir}/clang-pseudo%{bin_suffix} +%{_bindir}/clang-query%{bin_suffix} +%{_bindir}/clang-refactor%{bin_suffix} +%{_bindir}/clang-rename%{bin_suffix} +%{_bindir}/clang-reorder-fields%{bin_suffix} +%{_bindir}/clang-repl%{bin_suffix} +%{_bindir}/clang-scan-deps%{bin_suffix} +%{_bindir}/clang-tidy%{bin_suffix} +%{_bindir}/clangd%{bin_suffix} +%{_bindir}/diagtool%{bin_suffix} +%{_bindir}/hmaptool%{bin_suffix} +%{_bindir}/pp-trace%{bin_suffix} +%{_bindir}/find-all-symbols%{bin_suffix} +%{_bindir}/modularize%{bin_suffix} +%{_bindir}/run-clang-tidy%{bin_suffix} +%{pkg_bindir}/c-index-test +%{pkg_bindir}/clang-apply-replacements +%{pkg_bindir}/clang-change-namespace +%{pkg_bindir}/clang-check +%{pkg_bindir}/clang-doc +%{pkg_bindir}/clang-extdef-mapping +%{pkg_bindir}/clang-format +%{pkg_bindir}/clang-include-fixer +%{pkg_bindir}/clang-move +%{pkg_bindir}/clang-offload-bundler +%{pkg_bindir}/clang-offload-packager +%{pkg_bindir}/clang-offload-wrapper +%{pkg_bindir}/clang-linker-wrapper +%{pkg_bindir}/clang-nvlink-wrapper +%{pkg_bindir}/clang-pseudo +%{pkg_bindir}/clang-query +%{pkg_bindir}/clang-refactor +%{pkg_bindir}/clang-rename +%{pkg_bindir}/clang-reorder-fields +%{pkg_bindir}/clang-repl +%{pkg_bindir}/clang-scan-deps +%{pkg_bindir}/clang-tidy +%{pkg_bindir}/clangd +%{pkg_bindir}/diagtool +%{pkg_bindir}/hmaptool +%{pkg_bindir}/pp-trace +%{pkg_bindir}/find-all-symbols +%{pkg_bindir}/modularize +%{pkg_bindir}/run-clang-tidy +%{_mandir}/man1/diagtool%{bin_suffix}.1.* +%{pkg_sharedir}/clang/clang-format.el +%{pkg_sharedir}/clang/clang-rename.el +%{pkg_sharedir}/clang/clang-include-fixer.el +%{pkg_sharedir}/clang/clang-format.py +%{pkg_sharedir}/clang/clang-format-diff.py +%{pkg_sharedir}/clang/clang-include-fixer.py +%{pkg_sharedir}/clang/clang-tidy-diff.py +%{pkg_sharedir}/clang/run-find-all-symbols.py +%{pkg_sharedir}/clang/clang-rename.py %files -n git-clang-format -%{_bindir}/git-clang-format +%{_bindir}/git-clang-format%{bin_suffix} %changelog -* Thu Sep 22 2022 linguoxiong - 12.0.1-3 -- Implement the "-aux-info" option to print function prototype - -* Tue Aug 23 2022 linguoxiong - 12.0.1-2 -- Implement some options to ignore and replace - -* Wed Dec 29 2021 panxiaohe - 12.0.1-1 -- update to 12.0.1 -- add clang-resource-filesystem sub-package - -* Tue Sep 07 2021 chenchen - 10.0.1-5 -- del rpath from some binaries and bin - -* Fri Apr 30 2021 licihua - 10.0.1-4 -- Reduce build time. - -* Thu Apr 29 2021 licihua - 10.0.1-3 -- Reduce debuginfo verbosity. - -* Thu Feb 18 2021 zhangjiapeng - 10.0.1-2 -- Modify the dependency to python3 - -* Fri Sep 25 2020 zhangjiapeng - 10.0.1-1 -- Delete low version dynamic library - -* Thu Jul 30 2020 Guoshuai Sun - 10.0.1-0 -- Upgrade to 10.0.1 - -* Thu May 28 2020 leiju - 7.0.0-7 -- Fix uninitialized value in ABIArgInfo - -* Fri Apr 03 2020 zhouyihang - 7.0.0-6 -- Remove useless scriptlet - -* Thu Feb 20 2020 openEuler Buildteam - 7.0.0-5 -- Add buildrequire compiler-rt +* Mon Feb 20 2023 Chenxi Mao - 15.0.7-1 +- Upgrade to 15.0.7. -* Tue Dec 17 2019 openEuler Buildteam - 7.0.0-4 -- Delete redundant info +* Thu Feb 9 2023 Chenxi Mao - 15.0.6-2 +- Enable clang unit tests. +- Leverage macro define instead of hardcode version number. +- Remove duplicated character. -* Mon Dec 9 2019 openEuler Buildteam - 7.0.0-3 +* Mon Jan 2 2023 Chenxi Mao - 15.0.6-1 - Package init diff --git a/clang.yaml b/clang.yaml deleted file mode 100644 index 7d98bd835f0acc97da741f20f900a6ebae1512c5..0000000000000000000000000000000000000000 --- a/clang.yaml +++ /dev/null @@ -1,4 +0,0 @@ -version_control: github -src_repo: llvm/llvm-project -tag_prefix: ^llvmorg- -seperator: . diff --git a/fedora-PATCH-clang-Don-t-install-static-libraries.patch b/fedora-PATCH-clang-Don-t-install-static-libraries.patch new file mode 100644 index 0000000000000000000000000000000000000000..8cab18078c70d5ff7f084cb0c5e4993a8a78dc42 --- /dev/null +++ b/fedora-PATCH-clang-Don-t-install-static-libraries.patch @@ -0,0 +1,26 @@ +From 88704fc2eabb9dd19a9c3eb81a9b3dc37d95651c Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 31 Jan 2020 11:04:57 -0800 +Subject: [PATCH][clang] Don't install static libraries + +Signed-off-by: Chenxi Mao +--- + clang/cmake/modules/AddClang.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake +index 5752f4277444..0f52822d91f0 100644 +--- a/clang/cmake/modules/AddClang.cmake ++++ b/clang/cmake/modules/AddClang.cmake +@@ -113,7 +113,7 @@ macro(add_clang_library name) + if(TARGET ${lib}) + target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS}) + +- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN) ++ if (ARG_SHARED AND (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)) + get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries) + install(TARGETS ${lib} + COMPONENT ${lib} +-- +2.30.2 + diff --git a/fedora-PATCH-clang-Reorganize-gtest-integration.patch b/fedora-PATCH-clang-Reorganize-gtest-integration.patch new file mode 100644 index 0000000000000000000000000000000000000000..79e6e549c654566ba052c73c149d2d631d16a12b --- /dev/null +++ b/fedora-PATCH-clang-Reorganize-gtest-integration.patch @@ -0,0 +1,43 @@ +From c6b921c8d833546946b70a8c2640032fd7c62461 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:04:52 +0100 +Subject: [PATCH 1/6] [PATCH][clang] Reorganize gtest integration + +Signed-off-by: Chenxi Mao +--- + clang/CMakeLists.txt | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 9e74014..0185276 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -153,12 +153,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + set(LLVM_UTILS_PROVIDED ON) + set(CLANG_TEST_DEPS FileCheck count not) + endif() +- set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) +- if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h +- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} +- AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) +- add_subdirectory(${UNITTEST_DIR} utils/unittest) +- endif() + else() + # Seek installed Lit. + find_program(LLVM_LIT +@@ -537,7 +531,11 @@ endif() + + + if( CLANG_INCLUDE_TESTS ) +- if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) ++ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) ++ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h ++ AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ++ AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) ++ add_subdirectory(${UNITTEST_DIR} utils/unittest) + add_subdirectory(unittests) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS +-- +1.8.3.1 + diff --git a/fedora-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch b/fedora-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch new file mode 100644 index 0000000000000000000000000000000000000000..8601e25041a5bd717193994a215813bdefb7315e --- /dev/null +++ b/fedora-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch @@ -0,0 +1,83 @@ +From 581300e447602b9b7a505b0f07e8461d58d041ca Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 1 Jul 2022 21:24:17 -0700 +Subject: [PATCH] clang-tools-extra: Make test dependency on LLVMHello optional + +This fixes clang + clang-tools-extra standalone build after +Signed-off-by: Chenxi Mao +36892727e4f19a60778e371d78f8fb09d8122c85. +--- + clang-tools-extra/test/CMakeLists.txt | 10 +++++++++- + clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp | 2 +- + clang-tools-extra/test/lit.cfg.py | 3 +++ + clang-tools-extra/test/lit.site.cfg.py.in | 1 + + 4 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt +index f4c529ee8af2..1cfb4dd529aa 100644 +--- a/clang-tools-extra/test/CMakeLists.txt ++++ b/clang-tools-extra/test/CMakeLists.txt +@@ -7,10 +7,15 @@ + set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") + set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") + ++if (TARGET LLVMHello) ++ set (LLVM_HAS_LLVM_HELLO 1) ++endif() ++ + llvm_canonicalize_cmake_booleans( + CLANG_TIDY_ENABLE_STATIC_ANALYZER + CLANG_PLUGIN_SUPPORT + LLVM_INSTALL_TOOLCHAIN_ONLY ++ LLVM_HAS_LLVM_HELLO + ) + + configure_lit_site_cfg( +@@ -86,7 +91,10 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + endif() + + if(TARGET CTTestTidyModule) +- list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) ++ list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule) ++ if (TARGET LLVMHello) ++ list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule) ++ endif() + target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") + if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) + set(LLVM_LINK_COMPONENTS +diff --git a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp b/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp +index c66a94f458cf..b4e7a5d691e5 100644 +--- a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp ++++ b/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp +@@ -1,4 +1,4 @@ +-// REQUIRES: plugins ++// REQUIRES: plugins, llvm-hello + // RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s + // CHECK-LIST: Enabled checks: + // CHECK-LIST-NEXT: mytest1 +diff --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py +index 9b99bfd93440..3fca9f25fb48 100644 +--- a/clang-tools-extra/test/lit.cfg.py ++++ b/clang-tools-extra/test/lit.cfg.py +@@ -59,3 +59,6 @@ config.substitutions.append( + # Plugins (loadable modules) + if config.has_plugins and config.llvm_plugin_ext: + config.available_features.add('plugins') ++ ++if config.has_llvm_hello: ++ config.available_features.add("llvm-hello") +diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in +index 4eb830a1baf1..6e5559348454 100644 +--- a/clang-tools-extra/test/lit.site.cfg.py.in ++++ b/clang-tools-extra/test/lit.site.cfg.py.in +@@ -11,6 +11,7 @@ config.target_triple = "@LLVM_TARGET_TRIPLE@" + config.host_triple = "@LLVM_HOST_TRIPLE@" + config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ + config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ ++config.has_llvm_hello = @LLVM_HAS_LLVM_HELLO@ + # Support substitution of the tools and libs dirs with user parameters. This is + # used when we can't determine the tool dir at configuration time. + config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") +-- +2.27.0 + diff --git a/support-ignored_and_replaced_opts.patch b/support-ignored_and_replaced_opts.patch deleted file mode 100644 index 2393489990c22763517e50414bc1025d52132f78..0000000000000000000000000000000000000000 --- a/support-ignored_and_replaced_opts.patch +++ /dev/null @@ -1,201 +0,0 @@ -From e6c1017c1bc412148662f64156a4d60315e59eb3 Mon Sep 17 00:00:00 2001 -From: cokeom -Date: Fri, 14 Oct 2022 18:20:15 +0800 -Subject: [PATCH] Implement ignored options and replaced options. - ---- - include/clang/Basic/DiagnosticDriverKinds.td | 6 +++ - include/clang/Driver/Options.td | 25 ++++++++++++ - lib/Driver/Driver.cpp | 41 ++++++++++++++++++++ - lib/Driver/ToolChains/Clang.cpp | 16 ++++++++ - test/Driver/ignored-and-replaced-options.c | 25 ++++++++++++ - test/Misc/warning-flags.c | 3 +- - 6 files changed, 115 insertions(+), 1 deletion(-) - create mode 100644 test/Driver/ignored-and-replaced-options.c - -diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td -index ad13f923..bd7225b5 100644 ---- a/include/clang/Basic/DiagnosticDriverKinds.td -+++ b/include/clang/Basic/DiagnosticDriverKinds.td -@@ -536,4 +536,10 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognize - - def err_aix_default_altivec_abi : Error< - "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI">; -+ -+def warn_drv_ignore_options : Warning<"unsupported option '%0', ignore it.">, -+ InGroup; -+ -+def warn_drv_replace_options -+ : Warning<"unsupported option '%0', use '%1' instead.">; - } -diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td -index 81779892..04521197 100644 ---- a/include/clang/Driver/Options.td -+++ b/include/clang/Driver/Options.td -@@ -466,6 +466,31 @@ defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPat - // C++ => CXX - // . => _ - -+// Options to ignore and replace -+def clang_ignored_options_Group : OptionGroup<"">, -+ Group, -+ Flags<[Ignored]>; -+def ip : Flag<["-"], "ip">, -+ Group, -+ HelpText<"Enables additional interprocedural optimizations for " -+ "single-file compilation">; -+def assume : Separate<["-"], "assume">, -+ Group, -+ HelpText<"Determines whether units for the OPEN statement RECL " -+ "specifier (record length) value in unformatted files " -+ "are in bytes or longwords (four-byte units)">; -+def fdec : Flag<["-"], "fdec">, -+ Group, -+ HelpText<"Enables extensions and other features that mimic the " -+ "default behavior of older compilers (such as DEC)">; -+ -+def clang_replaced_options_Group -+ : OptionGroup<"">, -+ Group; -+def convert : Separate<["-"], "convert">, -+ Group, -+ HelpText<"Generate big-endian/little-endian code">; -+ - // Developer Driver Options - - def internal_Group : OptionGroup<"">, Flags<[HelpHidden]>; -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 418e1d3e..95c0e256 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -996,6 +996,47 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { - CLOptions = std::make_unique( - ParseArgStrings(ArgList.slice(1), IsCLMode(), ContainsError)); - -+ // Compiler replacement option function. -+ for (auto *Opt : -+ CLOptions->filtered(options::OPT_clang_replaced_options_Group)) { -+ switch (Opt->getOption().getID()) { -+ default: -+ Diag(diag::err_drv_unsupported_opt) << Opt->getAsString(*CLOptions); -+ break; -+ case options::OPT_convert: -+ auto *OptLastArg = -+ CLOptions->getLastArg(options::OPT_mlittle_endian, -+ options::OPT_mbig_endian, options::OPT_convert); -+ if (OptLastArg->getOption().matches(options::OPT_convert)) { -+ StringRef OptionValue = OptLastArg->getValue(); -+ if (OptionValue.equals("big_endian")) { -+ Diag(diag::warn_drv_replace_options) -+ << OptLastArg->getAsString(*CLOptions) << "-mbig-endian"; -+ StringRef SpellingReplaced = StringRef("-mbig-endian"); -+ unsigned IndexReplaced = CLOptions->MakeIndex(SpellingReplaced); -+ Option OptReplaced = getOpts().getOption(options::OPT_mbig_endian); -+ Arg *ArgReplaced = -+ new Arg(OptReplaced, SpellingReplaced, IndexReplaced); -+ CLOptions->append(ArgReplaced); -+ } else if (OptionValue.equals("little_endian")) { -+ Diag(diag::warn_drv_replace_options) -+ << OptLastArg->getAsString(*CLOptions) << "-mlittle-endian"; -+ StringRef SpellingReplaced = StringRef("-mlittle-endian"); -+ unsigned IndexReplaced = CLOptions->MakeIndex(SpellingReplaced); -+ Option OptReplaced = getOpts().getOption(options::OPT_mlittle_endian); -+ Arg *ArgReplaced = -+ new Arg(OptReplaced, SpellingReplaced, IndexReplaced); -+ CLOptions->append(ArgReplaced); -+ } else { -+ Diag(diag::err_drv_unknown_argument) -+ << OptLastArg->getAsString(*CLOptions); -+ } -+ } -+ CLOptions->eraseArg(options::OPT_convert); -+ break; -+ } -+ } -+ - // Try parsing configuration file. - if (!ContainsError) - ContainsError = loadConfigFile(); -diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp -index 1976b48e..706d0431 100644 ---- a/lib/Driver/ToolChains/Clang.cpp -+++ b/lib/Driver/ToolChains/Clang.cpp -@@ -5178,6 +5178,22 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - A->claim(); - } - -+ // Warn about ignored options to clang -+ for (const Arg *A : Args.filtered(options::OPT_clang_ignored_options_Group)) { -+ if (A->getOption().matches(options::OPT_assume)) { -+ StringRef OptionValue = A->getValue(); -+ if (OptionValue.equals("byterecl")) { -+ D.Diag(diag::warn_drv_ignore_options) << A->getAsString(Args); -+ } else { -+ D.Diag(diag::err_drv_unknown_argument) << A->getAsString(Args); -+ } -+ A->claim(); -+ continue; -+ } -+ D.Diag(diag::warn_drv_ignore_options) << A->getAsString(Args); -+ A->claim(); -+ } -+ - claimNoWarnArgs(Args); - - Args.AddAllArgs(CmdArgs, options::OPT_R_Group); -diff --git a/test/Driver/ignored-and-replaced-options.c b/test/Driver/ignored-and-replaced-options.c -new file mode 100644 -index 00000000..a13944db ---- /dev/null -+++ b/test/Driver/ignored-and-replaced-options.c -@@ -0,0 +1,25 @@ -+// Test that Some options are ignored and replaced. -+// -+// REQUIRES: clang-driver -+ -+// RUN: %clang -### -ip -c %s 2>&1 \ -+// RUN: | FileCheck --check-prefix=WARN %s -+// WARN: warning: unsupported option '-ip', ignore it. -+ -+// RUN: %clang -### -fdec -c %s 2>&1 \ -+// RUN: | FileCheck --check-prefix=WARN1 %s -+// WARN1: warning: unsupported option '-fdec', ignore it. -+ -+// RUN: %clang -### -assume byterecl -c %s 2>&1 \ -+// RUN: | FileCheck --check-prefix=WARN2 %s -+// WARN2: warning: unsupported option '-assume byterecl', ignore it. -+ -+// RUN: %clang -convert little_endian -c %s 2>&1 \ -+// RUN: | FileCheck --check-prefix=WARN3 %s -+// WARN3: warning: unsupported option '-convert little_endian', use -+// '-mlittle-endian' instead. -+ -+// RUN: %clang -convert big_endian -c %s 2>&1 \ -+// RUN: | FileCheck --check-prefix=WARN4 %s -+// WARN4: warning: unsupported option '-convert big_endian', use '-mbig-endian' -+// instead. -\ No newline at end of file -diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c -index 54e36e1e..1b9b779e 100644 ---- a/test/Misc/warning-flags.c -+++ b/test/Misc/warning-flags.c -@@ -18,7 +18,7 @@ This test serves two purposes: - - The list of warnings below should NEVER grow. It should gradually shrink to 0. - --CHECK: Warnings without flags (68): -+CHECK: Warnings without flags (69): - - CHECK-NEXT: ext_expected_semi_decl_list - CHECK-NEXT: ext_explicit_specialization_storage_class -@@ -47,6 +47,7 @@ CHECK-NEXT: warn_double_const_requires_fp64 - CHECK-NEXT: warn_drv_assuming_mfloat_abi_is - CHECK-NEXT: warn_drv_clang_unsupported - CHECK-NEXT: warn_drv_pch_not_first_include -+CHECK-NEXT: warn_drv_replace_options - CHECK-NEXT: warn_dup_category_def - CHECK-NEXT: warn_enum_value_overflow - CHECK-NEXT: warn_expected_qualified_after_typename --- -2.25.1 - diff --git a/support-print-c-function-prototype.patch b/support-print-c-function-prototype.patch deleted file mode 100644 index cd94f1407ddc631b4c1d58370949fe8357f24350..0000000000000000000000000000000000000000 --- a/support-print-c-function-prototype.patch +++ /dev/null @@ -1,499 +0,0 @@ -From feb61342aaf3e5ef2bcc36b3d512eba600e03c9c Mon Sep 17 00:00:00 2001 -From: cokeom -Date: Fri, 14 Oct 2022 18:30:00 +0800 -Subject: [PATCH] Implement -aux-info option. - ---- - include/clang/AST/DeclBase.h | 2 + - include/clang/AST/PrettyPrinter.h | 6 +- - include/clang/Driver/Options.td | 7 ++ - include/clang/Frontend/ASTConsumers.h | 3 + - include/clang/Frontend/FrontendActions.h | 6 ++ - include/clang/Frontend/FrontendOptions.h | 3 + - lib/AST/DeclPrinter.cpp | 96 +++++++++++++++++++ - lib/AST/TypePrinter.cpp | 23 +++-- - lib/Driver/Driver.cpp | 6 +- - lib/Driver/ToolChains/Clang.cpp | 7 ++ - lib/Frontend/ASTConsumers.cpp | 34 +++++++ - lib/Frontend/CompilerInvocation.cpp | 7 ++ - lib/Frontend/FrontendActions.cpp | 13 +++ - .../ExecuteCompilerInvocation.cpp | 2 + - test/Frontend/print-function-prototype.c | 28 ++++++ - 15 files changed, 230 insertions(+), 13 deletions(-) - create mode 100644 test/Frontend/print-function-prototype.c - -diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h -index 15eb29f7..a46b13e4 100644 ---- a/include/clang/AST/DeclBase.h -+++ b/include/clang/AST/DeclBase.h -@@ -1164,6 +1164,8 @@ public: - bool PrintInstantiation = false) const; - void print(raw_ostream &Out, const PrintingPolicy &Policy, - unsigned Indentation = 0, bool PrintInstantiation = false) const; -+ void printDeclPrototype(raw_ostream &Out, unsigned Indentation = 0, -+ bool PrintInstantiation = false) const; - static void printGroup(Decl** Begin, unsigned NumDecls, - raw_ostream &Out, const PrintingPolicy &Policy, - unsigned Indentation = 0); -diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h -index 3baf2b2b..f147fd87 100644 ---- a/include/clang/AST/PrettyPrinter.h -+++ b/include/clang/AST/PrettyPrinter.h -@@ -74,7 +74,8 @@ struct PrintingPolicy { - MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true), - MSVCFormatting(false), ConstantsAsWritten(false), - SuppressImplicitBase(false), FullyQualifiedName(false), -- PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) {} -+ PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true), -+ PrintRestrict(true) {} - - /// Adjust this printing policy for cases where it's known that we're - /// printing C++ code (for instance, if AST dumping reaches a C++-only -@@ -273,6 +274,9 @@ struct PrintingPolicy { - /// invalid C++ code. - unsigned PrintInjectedClassNameWithArguments : 1; - -+ /// Whether to print the keyword "restrict" in the function prototype. -+ unsigned PrintRestrict : 1; -+ - /// Callbacks to use to allow the behavior of printing to be customized. - const PrintingCallbacks *Callbacks = nullptr; - }; -diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td -index 04521197..2126f0df 100644 ---- a/include/clang/Driver/Options.td -+++ b/include/clang/Driver/Options.td -@@ -491,6 +491,13 @@ def convert : Separate<["-"], "convert">, - Group, - HelpText<"Generate big-endian/little-endian code">; - -+def aux_info : Separate<["-"], "aux-info">, -+ Flags<[NoXarchOption, CoreOption, CC1Option]>, -+ Group, -+ HelpText<"Output to the given filename prototyped declarations " -+ "for all functions declared and/or defined in a " -+ "translation unit, including those in header files">; -+ - // Developer Driver Options - - def internal_Group : OptionGroup<"">, Flags<[HelpHidden]>; -diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h -index 98cfc7ca..ecd3c268 100644 ---- a/include/clang/Frontend/ASTConsumers.h -+++ b/include/clang/Frontend/ASTConsumers.h -@@ -50,6 +50,9 @@ std::unique_ptr CreateASTDeclNodeLister(); - // function declarations to stderr. - std::unique_ptr CreateASTViewer(); - -+std::unique_ptr -+CreateASTFunctionPrinter(std::unique_ptr Out); -+ - } // end clang namespace - - #endif -diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h -index 25ca9598..d2b294a5 100644 ---- a/include/clang/Frontend/FrontendActions.h -+++ b/include/clang/Frontend/FrontendActions.h -@@ -74,6 +74,12 @@ protected: - StringRef InFile) override; - }; - -+class ASTFunctionPrinterAction : public ASTFrontendAction { -+protected: -+ std::unique_ptr CreateASTConsumer(CompilerInstance &CI, -+ StringRef InFile) override; -+}; -+ - class GeneratePCHAction : public ASTFrontendAction { - protected: - std::unique_ptr CreateASTConsumer(CompilerInstance &CI, -diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h -index 223c1e05..3362a2fc 100644 ---- a/include/clang/Frontend/FrontendOptions.h -+++ b/include/clang/Frontend/FrontendOptions.h -@@ -44,6 +44,9 @@ enum ActionKind { - /// Parse ASTs and view them in Graphviz. - ASTView, - -+ /// Print function prototype. -+ ASTFunctionPrinter, -+ - /// Dump the compiler configuration. - DumpCompilerOptions, - -diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp -index ca64f8f6..a857466e 100644 ---- a/lib/AST/DeclPrinter.cpp -+++ b/lib/AST/DeclPrinter.cpp -@@ -115,6 +115,7 @@ namespace { - void prettyPrintAttributes(Decl *D); - void prettyPrintPragmas(Decl *D); - void printDeclType(QualType T, StringRef DeclName, bool Pack = false); -+ void printFunctionDeclPrototype(FunctionDecl *D); - }; - } - -@@ -135,6 +136,14 @@ void TemplateParameterList::print(raw_ostream &Out, const ASTContext &Context, - print(Out, Context, Context.getPrintingPolicy(), OmitTemplateKW); - } - -+void Decl::printDeclPrototype(raw_ostream &Out, unsigned Indentation, -+ bool PrintInstantiation) const { -+ DeclPrinter Printer(Out, getASTContext().getPrintingPolicy(), getASTContext(), -+ Indentation, PrintInstantiation); -+ auto *FD = const_cast(dyn_cast(this)); -+ Printer.printFunctionDeclPrototype(FD); -+} -+ - void TemplateParameterList::print(raw_ostream &Out, const ASTContext &Context, - const PrintingPolicy &Policy, - bool OmitTemplateKW) const { -@@ -784,6 +793,93 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { - } - } - -+void DeclPrinter::printFunctionDeclPrototype(FunctionDecl *D) { -+ if (!Policy.SuppressSpecifiers) { -+ switch (D->getStorageClass()) { -+ case SC_None: -+ case SC_Extern: -+ case SC_PrivateExtern: -+ Out << "extern "; -+ break; -+ case SC_Static: -+ Out << "static "; -+ break; -+ case SC_Auto: -+ case SC_Register: -+ llvm_unreachable("invalid for functions"); -+ } -+ } -+ -+ PrintingPolicy SubPolicy(Policy); -+ SubPolicy.SuppressSpecifiers = false; -+ SubPolicy.PrintRestrict = false; -+ std::string Proto; -+ -+ /// Print the function name. -+ if (Policy.FullyQualifiedName) { -+ Proto += D->getQualifiedNameAsString(); -+ } else { -+ llvm::raw_string_ostream OS(Proto); -+ if (!Policy.SuppressScope) { -+ if (const NestedNameSpecifier *NS = D->getQualifier()) { -+ NS->print(OS, Policy); -+ } -+ } -+ D->getNameInfo().printName(OS, Policy); -+ } -+ -+ QualType Ty = D->getType(); -+ while (const ParenType *PT = dyn_cast(Ty)) { -+ Proto = '(' + Proto + ')'; -+ Ty = PT->getInnerType(); -+ } -+ if (const FunctionType *AFT = Ty->getAs()) { -+ const FunctionProtoType *FT = nullptr; -+ if (D->hasWrittenPrototype()) -+ FT = dyn_cast(AFT); -+ -+ Proto += "("; -+ -+ /// Print function parameters. -+ if (FT) { -+ llvm::raw_string_ostream POut(Proto); -+ for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) { -+ if (i) -+ POut << ", "; -+ ParmVarDecl *PVD = D->getParamDecl(i); -+ QualType T = PVD->getTypeSourceInfo() -+ ? PVD->getTypeSourceInfo()->getType() -+ : PVD->getASTContext().getUnqualifiedObjCPointerType( -+ PVD->getType()); -+ T.print(POut, SubPolicy, "", Indentation); -+ } -+ -+ if (FT->isVariadic()) { -+ if (D->getNumParams()) -+ POut << ", "; -+ POut << "..."; -+ } else if (!D->getNumParams()) { -+ POut << "void"; -+ } -+ } else if (D->doesThisDeclarationHaveABody() && !D->hasPrototype()) { -+ for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) { -+ if (i) -+ Proto += ", "; -+ Proto += D->getParamDecl(i)->getNameAsString(); -+ } -+ if (!D->getNumParams()) { -+ Proto += "void"; -+ } -+ } -+ Proto += ")"; -+ -+ /// Print the function return type. -+ AFT->getReturnType().print(Out, Policy, Proto); -+ } else { -+ Ty.print(Out, Policy, Proto); -+ } -+} -+ - void DeclPrinter::VisitFriendDecl(FriendDecl *D) { - if (TypeSourceInfo *TSI = D->getFriendType()) { - unsigned NumTPLists = D->getFriendTypeNumTemplateParameterLists(); -diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp -index 25d7874b..37d116ca 100644 ---- a/lib/AST/TypePrinter.cpp -+++ b/lib/AST/TypePrinter.cpp -@@ -139,7 +139,7 @@ namespace { - } // namespace - - static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, -- bool HasRestrictKeyword) { -+ bool HasRestrictKeyword, bool PrintRestrict) { - bool appendSpace = false; - if (TypeQuals & Qualifiers::Const) { - OS << "const"; -@@ -151,11 +151,13 @@ static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, - appendSpace = true; - } - if (TypeQuals & Qualifiers::Restrict) { -- if (appendSpace) OS << ' '; -- if (HasRestrictKeyword) { -- OS << "restrict"; -- } else { -- OS << "__restrict"; -+ if (PrintRestrict) { -+ if (appendSpace) OS << ' '; -+ if (HasRestrictKeyword) { -+ OS << "restrict"; -+ } else { -+ OS << "__restrict"; -+ } - } - } - } -@@ -506,8 +508,8 @@ void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T, - raw_ostream &OS) { - OS << '['; - if (T->getIndexTypeQualifiers().hasQualifiers()) { -- AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers(), -- Policy.Restrict); -+ AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers(), Policy.Restrict, -+ Policy.PrintRestrict); - OS << ' '; - } - -@@ -542,7 +544,8 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T, - raw_ostream &OS) { - OS << '['; - if (T->getIndexTypeQualifiers().hasQualifiers()) { -- AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers(), Policy.Restrict); -+ AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers(), Policy.Restrict, -+ Policy.PrintRestrict); - OS << ' '; - } - -@@ -2149,7 +2152,7 @@ void Qualifiers::print(raw_ostream &OS, const PrintingPolicy& Policy, - - unsigned quals = getCVRQualifiers(); - if (quals) { -- AppendTypeQualList(OS, quals, Policy.Restrict); -+ AppendTypeQualList(OS, quals, Policy.Restrict, Policy.PrintRestrict); - addSpace = true; - } - if (hasUnaligned()) { -diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp -index 95c0e256..ce677965 100644 ---- a/lib/Driver/Driver.cpp -+++ b/lib/Driver/Driver.cpp -@@ -309,7 +309,8 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL, - (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) || - (PhaseArg = DAL.getLastArg(options::OPT__migrate)) || - (PhaseArg = DAL.getLastArg(options::OPT__analyze)) || -- (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) { -+ (PhaseArg = DAL.getLastArg(options::OPT_emit_ast)) || -+ (PhaseArg = DAL.getLastArg(options::OPT_aux_info))) { - FinalPhase = phases::Compile; - - // -S only runs up to the backend. -@@ -3851,7 +3852,8 @@ Action *Driver::ConstructPhaseAction( - return C.MakeAction(Input, OutputTy); - } - case phases::Compile: { -- if (Args.hasArg(options::OPT_fsyntax_only)) -+ if (Args.hasArg(options::OPT_fsyntax_only) || -+ Args.hasArg(options::OPT_aux_info)) - return C.MakeAction(Input, types::TY_Nothing); - if (Args.hasArg(options::OPT_rewrite_objc)) - return C.MakeAction(Input, types::TY_RewrittenObjC); -diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp -index 706d0431..e7946529 100644 ---- a/lib/Driver/ToolChains/Clang.cpp -+++ b/lib/Driver/ToolChains/Clang.cpp -@@ -6258,6 +6258,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - } - } - -+ if (Arg *A = Args.getLastArg(options::OPT_aux_info)) { -+ if (Input.getType() == types::TY_C) { -+ CmdArgs.push_back("-aux-info"); -+ CmdArgs.push_back(A->getValue()); -+ } -+ } -+ - // With -save-temps, we want to save the unoptimized bitcode output from the - // CompileJobAction, use -disable-llvm-passes to get pristine IR generated - // by the frontend. -diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp -index a73cc887..48f999ab 100644 ---- a/lib/Frontend/ASTConsumers.cpp -+++ b/lib/Frontend/ASTConsumers.cpp -@@ -212,3 +212,37 @@ void ASTViewer::HandleTopLevelSingleDecl(Decl *D) { - std::unique_ptr clang::CreateASTViewer() { - return std::make_unique(); - } -+ -+//===----------------------------------------------------------------------===// -+/// ASTFunctionPrototype - AST FunctionPrototype print -+namespace { -+ class ASTFunctionPrinter : public ASTConsumer { -+ private: -+ llvm::raw_fd_ostream &Out; -+ std::unique_ptr OwnedOut; -+ public: -+ ASTFunctionPrinter(std::unique_ptr Out) -+ : Out(Out ? *Out : llvm::outs()), OwnedOut(std::move(Out)) {} -+ -+ bool HandleTopLevelDecl(DeclGroupRef D) override { -+ for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) -+ HandleTopLevelSingleDecl(*I); -+ return true; -+ } -+ -+ void HandleTopLevelSingleDecl(Decl *D); -+ }; -+} // namespace -+ -+void ASTFunctionPrinter::HandleTopLevelSingleDecl(Decl *D) { -+ if (isa(D)) { -+ D->printDeclPrototype(Out); -+ Out << ";"; -+ Out << '\n'; -+ } -+} -+ -+std::unique_ptr -+clang::CreateASTFunctionPrinter(std::unique_ptr Out) { -+ return std::make_unique(std::move(Out)); -+} -\ No newline at end of file -diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp -index 5c5cf461..9665b4ed 100644 ---- a/lib/Frontend/CompilerInvocation.cpp -+++ b/lib/Frontend/CompilerInvocation.cpp -@@ -1574,6 +1574,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, - Opts.ProgramAction = frontend::ASTPrint; break; - case OPT_ast_view: - Opts.ProgramAction = frontend::ASTView; break; -+ case OPT_aux_info: -+ Opts.ProgramAction = frontend::ASTFunctionPrinter; break; - case OPT_compiler_options_dump: - Opts.ProgramAction = frontend::DumpCompilerOptions; break; - case OPT_dump_raw_tokens: -@@ -2711,6 +2713,7 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { - case frontend::ASTDump: - case frontend::ASTPrint: - case frontend::ASTView: -+ case frontend::ASTFunctionPrinter: - case frontend::EmitAssembly: - case frontend::EmitBC: - case frontend::EmitHTML: -@@ -2971,6 +2974,10 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, - - FixupInvocation(Res, Diags, Args, DashX); - -+ if (Arg *A = Args.getLastArg(OPT_aux_info)) { -+ Res.getFrontendOpts().OutputFile = A->getValue(); -+ } -+ - return Success; - } - -diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp -index 060cec23..1d0044c8 100644 ---- a/lib/Frontend/FrontendActions.cpp -+++ b/lib/Frontend/FrontendActions.cpp -@@ -93,6 +93,19 @@ ASTViewAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { - return CreateASTViewer(); - } - -+std::unique_ptr -+ASTFunctionPrinterAction::CreateASTConsumer(CompilerInstance &CI, -+ StringRef InFile) { -+ StringRef OutputFileName = CI.getFrontendOpts().OutputFile; -+ std::unique_ptr OutFile; -+ if (!OutputFileName.empty() && OutputFileName != "-") { -+ std::error_code EC; -+ OutFile.reset(new llvm::raw_fd_ostream(OutputFileName.str(), EC, -+ llvm::sys::fs::CD_CreateAlways)); -+ } -+ return CreateASTFunctionPrinter(std::move(OutFile)); -+} -+ - std::unique_ptr - GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { - std::string Sysroot; -diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp -index ac64e170..63a6b403 100644 ---- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp -+++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp -@@ -46,6 +46,8 @@ CreateFrontendBaseAction(CompilerInstance &CI) { - case ASTDump: return std::make_unique(); - case ASTPrint: return std::make_unique(); - case ASTView: return std::make_unique(); -+ case ASTFunctionPrinter: -+ return std::make_unique(); - case DumpCompilerOptions: - return std::make_unique(); - case DumpRawTokens: return std::make_unique(); -diff --git a/test/Frontend/print-function-prototype.c b/test/Frontend/print-function-prototype.c -new file mode 100644 -index 00000000..5abc7550 ---- /dev/null -+++ b/test/Frontend/print-function-prototype.c -@@ -0,0 +1,28 @@ -+// Test that -aux-info prints correct function prototypes. -+// RUN: %clang %s -aux-info %t 2>&1 \ -+// RUN: | FileCheck -input-file=%t %s -+// CHECK: extern void function1(int, const int, float); -+// CHECK: extern int function2(int, int); -+// CHECK: extern void function3(int, double, float); -+// CHECK: static void function4(void); -+// CHECK: extern int function5(volatile int *); -+// CHECK: extern int function6(int *); -+// CHECK: extern const int function7(void); -+// CHECK: extern volatile float function8(void); -+// CHECK: extern int main(void); -+// CHECK: extern void function1(int, const int, float); -+ -+void function1(int, const int, float); -+int function2(int a, int b) { return a + b; } -+void function3(int a, double b, float c) {} -+static void function4() {} -+inline int function5(volatile int *j); -+int function6(int *a) { return 0; } -+const int function7() { return 1; } -+volatile float function8() { return 0.; } -+int main() { -+ function1(1, 1, 0.0); -+ function2(1, 1); -+ return 0; -+} -+void function1(int a, const int b, float c) {} -\ No newline at end of file --- -2.25.1 -