r341083 - Test the cross-product of how libgcc-related arguments are passed to the linker.
Author: saugustine Date: Thu Aug 30 09:37:06 2018 New Revision: 341083 URL: http://llvm.org/viewvc/llvm-project?rev=341083&view=rev Log: Test the cross-product of how libgcc-related arguments are passed to the linker. Modified: cfe/trunk/test/Driver/linux-ld.c Modified: cfe/trunk/test/Driver/linux-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=341083&r1=341082&r2=341083&view=diff == --- cfe/trunk/test/Driver/linux-ld.c (original) +++ cfe/trunk/test/Driver/linux-ld.c Thu Aug 30 09:37:06 2018 @@ -150,6 +150,88 @@ // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC %s +// CHECK-CLANG-NO-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-NO-LIBGCC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// CHECK-CLANG-NO-LIBGCC: "-lc" +// CHECK-CLANG-NO-LIBGCC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// +// RUN: %clang++ -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANGXX-NO-LIBGCC %s +// CHECK-CLANGXX-NO-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANGXX-NO-LIBGCC: "-lgcc_s" "-lgcc" +// CHECK-CLANGXX-NO-LIBGCC: "-lc" +// CHECK-CLANGXX-NO-LIBGCC: "-lgcc_s" "-lgcc" +// +// RUN: %clang -static -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC-STATIC %s +// CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group" +// +// RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC-DYNAMIC %s +// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lc" +// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// +// RUN: %clang -static-libgcc -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-STATIC-LIBGCC %s +// CHECK-CLANG-STATIC-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-STATIC-LIBGCC: "-lgcc" "-lgcc_eh" +// CHECK-CLANG-STATIC-LIBGCC: "-lc" +// CHECK-CLANG-STATIC-LIBGCC: "-lgcc" "-lgcc_eh" +// +// RUN: %clang -static-libgcc -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-STATIC-LIBGCC-DYNAMIC %s +// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lgcc" "-lgcc_eh" +// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lc" +// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lgcc" "-lgcc_eh" +// +// RUN: %clang -shared-libgcc -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC %s +// CHECK-CLANG-SHARED-LIBGCC: warning: argument unused during compilation: '-shared-libgcc' +// This will be the correct check once the driver supports -shared-libgcc +// SKIP-CHECK-CLANG-SHARED-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" +// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lc" +// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" +// +// RUN: %clang -shared-libgcc -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-unknown-linux -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC-DYNAMIC %s +// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: warning: argument unused during compilation: '-shared-libgcc' +// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" "--sysroo
r341107 - Refactor Addlibgcc to make the when and what logic more straightfoward.
Author: saugustine Date: Thu Aug 30 13:07:23 2018 New Revision: 341107 URL: http://llvm.org/viewvc/llvm-project?rev=341107&view=rev Log: Refactor Addlibgcc to make the when and what logic more straightfoward. No functional change. A forthcoming change will add support for -shared-libgcc. Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=341107&r1=341106&r2=341107&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Aug 30 13:07:23 2018 @@ -1126,23 +1126,41 @@ static void AddLibgcc(const llvm::Triple bool IsIAMCU = Triple.isOSIAMCU(); bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || Args.hasArg(options::OPT_static); - if (!D.CCCIsCXX()) + // The driver ignores -shared-libgcc and therefore treats such cases as + // unspecified. Breaking out the two variables as below makes the current + // behavior explicit. + bool UnspecifiedLibgcc = !StaticLibgcc; + bool SharedLibgcc = !StaticLibgcc; + + // Gcc adds libgcc arguments in various ways: + // + // gcc : -lgcc --as-needed -lgcc_s --no-as-needed + // g++ : -lgcc_s -lgcc + // gcc shared: -lgcc_s -lgcc + // g++ shared: -lgcc_s -lgcc + // gcc static: -lgcc -lgcc_eh + // g++ static: -lgcc -lgcc_eh + // + // Also, certain targets need additional adjustments. + + bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc; + if (LibGccFirst) CmdArgs.push_back("-lgcc"); - if (StaticLibgcc || isAndroid) { -if (D.CCCIsCXX()) - CmdArgs.push_back("-lgcc"); - } else { -if (!D.CCCIsCXX() && !isCygMing) - CmdArgs.push_back("--as-needed"); + bool AsNeeded = D.CCCIsCC() && !StaticLibgcc && !isCygMing; + if (AsNeeded) +CmdArgs.push_back("--as-needed"); + + if (UnspecifiedLibgcc || SharedLibgcc) CmdArgs.push_back("-lgcc_s"); -if (!D.CCCIsCXX() && !isCygMing) - CmdArgs.push_back("--no-as-needed"); - } - if (StaticLibgcc && !isAndroid && !IsIAMCU) + else if (StaticLibgcc && !isAndroid && !IsIAMCU) CmdArgs.push_back("-lgcc_eh"); - else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX()) + + if (AsNeeded) +CmdArgs.push_back("--no-as-needed"); + + if (!LibGccFirst) CmdArgs.push_back("-lgcc"); // According to Android ABI, we have to link with libdl if we are ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341114 - Revert r341107. That change breaks lto-android in a way is untested.
Author: saugustine Date: Thu Aug 30 13:42:49 2018 New Revision: 341114 URL: http://llvm.org/viewvc/llvm-project?rev=341114&view=rev Log: Revert r341107. That change breaks lto-android in a way is untested. Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=341114&r1=341113&r2=341114&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Aug 30 13:42:49 2018 @@ -1126,41 +1126,23 @@ static void AddLibgcc(const llvm::Triple bool IsIAMCU = Triple.isOSIAMCU(); bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || Args.hasArg(options::OPT_static); - // The driver ignores -shared-libgcc and therefore treats such cases as - // unspecified. Breaking out the two variables as below makes the current - // behavior explicit. - bool UnspecifiedLibgcc = !StaticLibgcc; - bool SharedLibgcc = !StaticLibgcc; - - // Gcc adds libgcc arguments in various ways: - // - // gcc : -lgcc --as-needed -lgcc_s --no-as-needed - // g++ : -lgcc_s -lgcc - // gcc shared: -lgcc_s -lgcc - // g++ shared: -lgcc_s -lgcc - // gcc static: -lgcc -lgcc_eh - // g++ static: -lgcc -lgcc_eh - // - // Also, certain targets need additional adjustments. - - bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc; - if (LibGccFirst) + if (!D.CCCIsCXX()) CmdArgs.push_back("-lgcc"); - bool AsNeeded = D.CCCIsCC() && !StaticLibgcc && !isCygMing; - if (AsNeeded) -CmdArgs.push_back("--as-needed"); - - if (UnspecifiedLibgcc || SharedLibgcc) + if (StaticLibgcc || isAndroid) { +if (D.CCCIsCXX()) + CmdArgs.push_back("-lgcc"); + } else { +if (!D.CCCIsCXX() && !isCygMing) + CmdArgs.push_back("--as-needed"); CmdArgs.push_back("-lgcc_s"); +if (!D.CCCIsCXX() && !isCygMing) + CmdArgs.push_back("--no-as-needed"); + } - else if (StaticLibgcc && !isAndroid && !IsIAMCU) + if (StaticLibgcc && !isAndroid && !IsIAMCU) CmdArgs.push_back("-lgcc_eh"); - - if (AsNeeded) -CmdArgs.push_back("--no-as-needed"); - - if (!LibGccFirst) + else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX()) CmdArgs.push_back("-lgcc"); // According to Android ABI, we have to link with libdl if we are ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341231 - Refactor Addlibgcc to make the when and what logic more straightfoward.
Author: saugustine Date: Fri Aug 31 10:59:03 2018 New Revision: 341231 URL: http://llvm.org/viewvc/llvm-project?rev=341231&view=rev Log: Refactor Addlibgcc to make the when and what logic more straightfoward. Add Android tests. Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/test/Driver/linux-ld.c Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=341231&r1=341230&r2=341231&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Fri Aug 31 10:59:03 2018 @@ -1126,23 +1126,42 @@ static void AddLibgcc(const llvm::Triple bool IsIAMCU = Triple.isOSIAMCU(); bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || Args.hasArg(options::OPT_static); - if (!D.CCCIsCXX()) + + // The driver ignores -shared-libgcc and therefore treats such cases as + // unspecified. Breaking out the two variables as below makes the current + // behavior explicit. + bool UnspecifiedLibgcc = !StaticLibgcc; + bool SharedLibgcc = !StaticLibgcc; + + // Gcc adds libgcc arguments in various ways: + // + // gcc : -lgcc --as-needed -lgcc_s --no-as-needed + // g++ : -lgcc_s -lgcc + // gcc shared: -lgcc_s -lgcc + // g++ shared: -lgcc_s -lgcc + // gcc static: -lgcc -lgcc_eh + // g++ static: -lgcc -lgcc_eh + // + // Also, certain targets need additional adjustments. + + bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc; + if (LibGccFirst) CmdArgs.push_back("-lgcc"); - if (StaticLibgcc || isAndroid) { -if (D.CCCIsCXX()) - CmdArgs.push_back("-lgcc"); - } else { -if (!D.CCCIsCXX() && !isCygMing) - CmdArgs.push_back("--as-needed"); + bool AsNeeded = D.CCCIsCC() && !StaticLibgcc && !isAndroid && !isCygMing; + if (AsNeeded) +CmdArgs.push_back("--as-needed"); + + if ((UnspecifiedLibgcc || SharedLibgcc) && !isAndroid) CmdArgs.push_back("-lgcc_s"); -if (!D.CCCIsCXX() && !isCygMing) - CmdArgs.push_back("--no-as-needed"); - } - if (StaticLibgcc && !isAndroid && !IsIAMCU) + else if (StaticLibgcc && !isAndroid && !IsIAMCU) CmdArgs.push_back("-lgcc_eh"); - else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX()) + + if (AsNeeded) +CmdArgs.push_back("--no-as-needed"); + + if (!LibGccFirst) CmdArgs.push_back("-lgcc"); // According to Android ABI, we have to link with libdl if we are Modified: cfe/trunk/test/Driver/linux-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=341231&r1=341230&r2=341231&view=diff == --- cfe/trunk/test/Driver/linux-ld.c (original) +++ cfe/trunk/test/Driver/linux-ld.c Fri Aug 31 10:59:03 2018 @@ -230,6 +230,30 @@ // SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lc" // SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc" // +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=aarch64-linux-android -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-ANDROID-NONE %s +// CHECK-CLANG-ANDROID-NONE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-ANDROID-NONE: "-lgcc" "-ldl" "-lc" +// +// RUN: %clang -shared -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=aarch64-linux-android -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-ANDROID-SHARED %s +// CHECK-CLANG-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-ANDROID-SHARED: "-lgcc" "-ldl" "-lc" +// +// RUN: %clang -static -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=aarch64-linux-android -rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CLANG-ANDROID-STATIC %s +// CHECK-CLANG-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-ANDROID-STATIC: "--start-group" "-lgcc" "-lc" "--end-group" +// // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=platform \ // RUN: -static \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r352404 - Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib=
Author: saugustine Date: Mon Jan 28 10:56:43 2019 New Revision: 352404 URL: http://llvm.org/viewvc/llvm-project?rev=352404&view=rev Log: Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= Summary: "clang++ hello.cc --rtlib=compiler-rt" now works without specifying additional unwind or exception handling libraries. Reviewers: rsmith Subscribers: srhines, dberris, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D57128 Added: cfe/trunk/test/Driver/compiler-rt-unwind.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Driver/ToolChain.h cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=352404&r1=352403&r2=352404&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jan 28 10:56:43 2019 @@ -51,6 +51,10 @@ def err_drv_invalid_rtlib_name : Error< "invalid runtime library name in argument '%0'">; def err_drv_unsupported_rtlib_for_platform : Error< "unsupported runtime library '%0' for platform '%1'">; +def err_drv_invalid_unwindlib_name : Error< + "invalid unwind library name in argument '%0'">; +def err_drv_incompatible_unwindlib : Error< + "--rtlib=libgcc requires --unwindlib=libgcc">; def err_drv_invalid_stdlib_name : Error< "invalid library name in argument '%0'">; def err_drv_invalid_output_with_multiple_archs : Error< Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352404&r1=352403&r2=352404&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Jan 28 10:56:43 2019 @@ -2568,6 +2568,8 @@ def std_EQ : Joined<["-", "--"], "std="> }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; +def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>, + HelpText<"Unwind library to use">, Values<"libgcc_eh,compiler-rt-unwind,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">; def system_header_prefix : Joined<["--"], "system-header-prefix=">, Modified: cfe/trunk/include/clang/Driver/ToolChain.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=352404&r1=352403&r2=352404&view=diff == --- cfe/trunk/include/clang/Driver/ToolChain.h (original) +++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Jan 28 10:56:43 2019 @@ -367,6 +367,10 @@ public: return ToolChain::CST_Libstdcxx; } + virtual RuntimeLibType GetDefaultUnwindLibType() const { +return ToolChain::RLT_Libgcc; + } + virtual std::string getCompilerRTPath() const; virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, @@ -511,6 +515,10 @@ public: // given compilation arguments. virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; + // GetUnwindLibType - Determine the unwind library type to use with the + // given compilation arguments. + virtual RuntimeLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const; + /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set /// the include paths to use for the given C++ standard library type. virtual void Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=352404&r1=352403&r2=352404&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Jan 28 10:56:43 2019 @@ -679,6 +679,33 @@ ToolChain::RuntimeLibType ToolChain::Get return GetDefaultRuntimeLibType(); } +ToolChain::RuntimeLibType ToolChain +::GetUnwindLibType( +const ArgList &Args) const { + const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); + // If nothing has been specified, follow the runtime lib type. + if (!A) +return GetRuntimeLibType(Args); + + StringRef LibName = A->getValue(); + if (LibName == "compiler-rt") { +if (GetRuntimeLibType(Args) == RLT_Libgcc) + getDriver().Diag(diag::err_drv_incompatible_unwindlib); +return ToolChain::RLT_CompilerRT; + } + else if (LibName == "libgcc") +return ToolChain::RLT_Libgcc; + else if (LibName == "platform") { +return GetRun
r352405 - Correct help text for --unwindlib options.
Author: saugustine Date: Mon Jan 28 10:56:44 2019 New Revision: 352405 URL: http://llvm.org/viewvc/llvm-project?rev=352405&view=rev Log: Correct help text for --unwindlib options. Modified: cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352405&r1=352404&r2=352405&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Jan 28 10:56:44 2019 @@ -2569,7 +2569,7 @@ def std_EQ : Joined<["-", "--"], "std="> def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>, - HelpText<"Unwind library to use">, Values<"libgcc_eh,compiler-rt-unwind,platform">; + HelpText<"Unwind library to use">, Values<"libgcc,compiler-rt,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">; def system_header_prefix : Joined<["--"], "system-header-prefix=">, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r352524 - Rollback unwindlib patch.
Author: saugustine Date: Tue Jan 29 10:27:51 2019 New Revision: 352524 URL: http://llvm.org/viewvc/llvm-project?rev=352524&view=rev Log: Rollback unwindlib patch. Removed: cfe/trunk/test/Driver/compiler-rt-unwind.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Driver/ToolChain.h cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=352524&r1=352523&r2=352524&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jan 29 10:27:51 2019 @@ -51,10 +51,6 @@ def err_drv_invalid_rtlib_name : Error< "invalid runtime library name in argument '%0'">; def err_drv_unsupported_rtlib_for_platform : Error< "unsupported runtime library '%0' for platform '%1'">; -def err_drv_invalid_unwindlib_name : Error< - "invalid unwind library name in argument '%0'">; -def err_drv_incompatible_unwindlib : Error< - "--rtlib=libgcc requires --unwindlib=libgcc">; def err_drv_invalid_stdlib_name : Error< "invalid library name in argument '%0'">; def err_drv_invalid_output_with_multiple_archs : Error< Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352524&r1=352523&r2=352524&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Jan 29 10:27:51 2019 @@ -2568,8 +2568,6 @@ def std_EQ : Joined<["-", "--"], "std="> }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; -def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>, - HelpText<"Unwind library to use">, Values<"libgcc,compiler-rt,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">; def system_header_prefix : Joined<["--"], "system-header-prefix=">, Modified: cfe/trunk/include/clang/Driver/ToolChain.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=352524&r1=352523&r2=352524&view=diff == --- cfe/trunk/include/clang/Driver/ToolChain.h (original) +++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Jan 29 10:27:51 2019 @@ -367,10 +367,6 @@ public: return ToolChain::CST_Libstdcxx; } - virtual RuntimeLibType GetDefaultUnwindLibType() const { -return ToolChain::RLT_Libgcc; - } - virtual std::string getCompilerRTPath() const; virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, @@ -515,10 +511,6 @@ public: // given compilation arguments. virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; - // GetUnwindLibType - Determine the unwind library type to use with the - // given compilation arguments. - virtual RuntimeLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const; - /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set /// the include paths to use for the given C++ standard library type. virtual void Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=352524&r1=352523&r2=352524&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Jan 29 10:27:51 2019 @@ -679,33 +679,6 @@ ToolChain::RuntimeLibType ToolChain::Get return GetDefaultRuntimeLibType(); } -ToolChain::RuntimeLibType ToolChain -::GetUnwindLibType( -const ArgList &Args) const { - const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); - // If nothing has been specified, follow the runtime lib type. - if (!A) -return GetRuntimeLibType(Args); - - StringRef LibName = A->getValue(); - if (LibName == "compiler-rt") { -if (GetRuntimeLibType(Args) == RLT_Libgcc) - getDriver().Diag(diag::err_drv_incompatible_unwindlib); -return ToolChain::RLT_CompilerRT; - } - else if (LibName == "libgcc") -return ToolChain::RLT_Libgcc; - else if (LibName == "platform") { -return GetRuntimeLibType(Args); - } - - if (A) -getDriver().Diag(diag::err_drv_invalid_unwindlib_name) -<< A->getAsString(Args); - - return GetDefaultUnwindLibType(); -} - ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ const Arg *A = Args.getLastArg(options::
r356508 - Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
Author: saugustine Date: Tue Mar 19 13:01:59 2019 New Revision: 356508 URL: http://llvm.org/viewvc/llvm-project?rev=356508&view=rev Log: Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2] "clang++ hello.cc --rtlib=compiler-rt" now can works without specifying additional unwind or exception handling libraries. This reworked version of the feature no longer modifies today's default unwind library for compiler-rt: which is nothing. Rather, a user can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring the compiler. This should address the issues from the previous version. Update tests for new --unwindlib semantics. Differential Revision: https://reviews.llvm.org/D59109 Added: cfe/trunk/test/Driver/compiler-rt-unwind.c Modified: cfe/trunk/CMakeLists.txt cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Config/config.h.cmake cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Driver/ToolChain.h cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=356508&r1=356507&r2=356508&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Tue Mar 19 13:01:59 2019 @@ -266,6 +266,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE) endif() +set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING + "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)") +if (CLANG_DEFAULT_UNWINDLIB STREQUAL "") + if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc") +set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE) + elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind") +set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE) + endif() +endif() + +if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR +CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR +CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind")) + message(WARNING "Resetting default unwindlib to use platform default") + set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING +"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE) +endif() + set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING "Default objcopy executable to use.") Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=356508&r1=356507&r2=356508&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 19 13:01:59 2019 @@ -51,6 +51,10 @@ def err_drv_invalid_rtlib_name : Error< "invalid runtime library name in argument '%0'">; def err_drv_unsupported_rtlib_for_platform : Error< "unsupported runtime library '%0' for platform '%1'">; +def err_drv_invalid_unwindlib_name : Error< + "invalid unwind library name in argument '%0'">; +def err_drv_incompatible_unwindlib : Error< + "--rtlib=libgcc requires --unwindlib=libgcc">; def err_drv_invalid_stdlib_name : Error< "invalid library name in argument '%0'">; def err_drv_invalid_output_with_multiple_archs : Error< Modified: cfe/trunk/include/clang/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=356508&r1=356507&r2=356508&view=diff == --- cfe/trunk/include/clang/Config/config.h.cmake (original) +++ cfe/trunk/include/clang/Config/config.h.cmake Tue Mar 19 13:01:59 2019 @@ -23,6 +23,9 @@ /* Default runtime library to use. */ #define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}" +/* Default unwind library to use. */ +#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}" + /* Default objcopy to use */ #define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}" Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=356508&r1=356507&r2=356508&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 19 13:01:59 2019 @@ -2591,6 +2591,8 @@ def std_EQ : Joined<["-", "--"], "std="> }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; +def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>, + HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">; def sub__library
r356724 - This test assumes that -rtlib defaults to libgcc. But that isn't true in the face of -DCLANG_DEFAULT_RTLIB=compiler-rt.
Author: saugustine Date: Thu Mar 21 16:30:50 2019 New Revision: 356724 URL: http://llvm.org/viewvc/llvm-project?rev=356724&view=rev Log: This test assumes that -rtlib defaults to libgcc. But that isn't true in the face of -DCLANG_DEFAULT_RTLIB=compiler-rt. Subscribers: dberris, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59674 Modified: cfe/trunk/test/Driver/compiler-rt-unwind.c Modified: cfe/trunk/test/Driver/compiler-rt-unwind.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compiler-rt-unwind.c?rev=356724&r1=356723&r2=356724&view=diff == --- cfe/trunk/test/Driver/compiler-rt-unwind.c (original) +++ cfe/trunk/test/Driver/compiler-rt-unwind.c Thu Mar 21 16:30:50 2019 @@ -2,13 +2,6 @@ // --unwindlib=XXX properly. // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: --target=x86_64-unknown-linux \ -// RUN: --gcc-toolchain="" \ -// RUN: | FileCheck --check-prefix=RTLIB-EMPTY %s -// RTLIB-EMPTY: "{{.*}}lgcc" -// RTLIB-EMPTY: "{{.*}}-lgcc_s" -// -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=libgcc \ // RUN: --gcc-toolchain="" \ // RUN: | FileCheck --check-prefix=RTLIB-GCC %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r365713 - rL365634 adds a unique_ptr in GobalCompilationDatabase.h:108 but CompilationDatabase is only forward declared. This makes the header not compile stan
Author: saugustine Date: Wed Jul 10 16:38:00 2019 New Revision: 365713 URL: http://llvm.org/viewvc/llvm-project?rev=365713&view=rev Log: rL365634 adds a unique_ptr in GobalCompilationDatabase.h:108 but CompilationDatabase is only forward declared. This makes the header not compile standalone, because unique_ptrs expect to have the full-definition of the... Summary: ...template argument. Remove the forward declaration and include the appropriate header instead. Remove CompileCommand too, which is also in the header. Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=365713&r1=365712&r2=365713&view=diff == --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h (original) +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Wed Jul 10 16:38:00 2019 @@ -11,6 +11,7 @@ #include "Function.h" #include "Path.h" +#include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include @@ -19,11 +20,6 @@ namespace clang { -namespace tooling { -class CompilationDatabase; -struct CompileCommand; -} // namespace tooling - namespace clangd { class Logger; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r360610 - Add a new LIBUNWIND_WEAK_PTHREAD Cmake option to force
Author: saugustine Date: Mon May 13 11:45:03 2019 New Revision: 360610 URL: http://llvm.org/viewvc/llvm-project?rev=360610&view=rev Log: Add a new LIBUNWIND_WEAK_PTHREAD Cmake option to force calls into the pthread library use weak symbols. This option allows libpthread to be a weak dependency rather than a hard one. Differential Revision: https://reviews.llvm.org/D60285 Modified: libunwind/trunk/CMakeLists.txt libunwind/trunk/src/CMakeLists.txt libunwind/trunk/src/RWMutex.hpp Modified: libunwind/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=360610&r1=360609&r2=360610&view=diff == --- libunwind/trunk/CMakeLists.txt (original) +++ libunwind/trunk/CMakeLists.txt Mon May 13 11:45:03 2019 @@ -134,6 +134,7 @@ option(LIBUNWIND_ENABLE_STATIC "Build li option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF) option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF) option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON) +option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread functions." OFF) option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS}) Modified: libunwind/trunk/src/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=360610&r1=360609&r2=360610&view=diff == --- libunwind/trunk/src/CMakeLists.txt (original) +++ libunwind/trunk/src/CMakeLists.txt Mon May 13 11:45:03 2019 @@ -67,6 +67,7 @@ endif() unwind_append_if(libraries LIBUNWIND_HAS_DL_LIB dl) if (LIBUNWIND_ENABLE_THREADS) unwind_append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread) + unwind_append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_WEAK_PTHREAD_LIB -DLIBUNWIND_USE_WEAK_PTHREAD=1) endif() # Setup flags. Modified: libunwind/trunk/src/RWMutex.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=360610&r1=360609&r2=360610&view=diff == --- libunwind/trunk/src/RWMutex.hpp (original) +++ libunwind/trunk/src/RWMutex.hpp Mon May 13 11:45:03 2019 @@ -56,17 +56,52 @@ private: SRWLOCK _lock = SRWLOCK_INIT; }; -#else +#elif !defined(LIBUNWIND_USE_WEAK_PTHREAD) class _LIBUNWIND_HIDDEN RWMutex { public: - bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; } + bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; } bool unlock_shared() { return pthread_rwlock_unlock(&_lock) == 0; } bool lock() { return pthread_rwlock_wrlock(&_lock) == 0; } bool unlock() { return pthread_rwlock_unlock(&_lock) == 0; } private: pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER; +}; + +#else + +extern "C" int __attribute__((weak)) +pthread_create(pthread_t *thread, const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg); +extern "C" int __attribute__((weak)) +pthread_rwlock_rdlock(pthread_rwlock_t *lock); +extern "C" int __attribute__((weak)) +pthread_rwlock_wrlock(pthread_rwlock_t *lock); +extern "C" int __attribute__((weak)) +pthread_rwlock_unlock(pthread_rwlock_t *lock); + +// Calls to the locking functions are gated on pthread_create, and not the +// functions themselves, because the data structure should only be locked if +// another thread has been created. This is what similar libraries do. + +class _LIBUNWIND_HIDDEN RWMutex { +public: + bool lock_shared() { +return !pthread_create || (pthread_rwlock_rdlock(&_lock) == 0); + } + bool unlock_shared() { +return !pthread_create || (pthread_rwlock_unlock(&_lock) == 0); + } + bool lock() { +return !pthread_create || (pthread_rwlock_wrlock(&_lock) == 0); + } + bool unlock() { +return !pthread_create || (pthread_rwlock_unlock(&_lock) == 0); + } + +private: + pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER; }; #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r350900 - Properly support -shared-libgcc.
Author: saugustine Date: Thu Jan 10 14:25:58 2019 New Revision: 350900 URL: http://llvm.org/viewvc/llvm-project?rev=350900&view=rev Log: Properly support -shared-libgcc. This revision was revied in D55016. Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/test/Driver/linux-ld.c Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=350900&r1=350899&r2=350900&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Jan 10 14:25:58 2019 @@ -1159,11 +1159,8 @@ static void AddLibgcc(const llvm::Triple bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || Args.hasArg(options::OPT_static); - // The driver ignores -shared-libgcc and therefore treats such cases as - // unspecified. Breaking out the two variables as below makes the current - // behavior explicit. - bool UnspecifiedLibgcc = !StaticLibgcc; - bool SharedLibgcc = !StaticLibgcc; + bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc); + bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc; // Gcc adds libgcc arguments in various ways: // @@ -1180,7 +1177,7 @@ static void AddLibgcc(const llvm::Triple if (LibGccFirst) CmdArgs.push_back("-lgcc"); - bool AsNeeded = D.CCCIsCC() && !StaticLibgcc && !isAndroid && !isCygMing; + bool AsNeeded = D.CCCIsCC() && UnspecifiedLibgcc && !isAndroid && !isCygMing; if (AsNeeded) CmdArgs.push_back("--as-needed"); Modified: cfe/trunk/test/Driver/linux-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=350900&r1=350899&r2=350900&view=diff == --- cfe/trunk/test/Driver/linux-ld.c (original) +++ cfe/trunk/test/Driver/linux-ld.c Thu Jan 10 14:25:58 2019 @@ -211,24 +211,19 @@ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC %s -// CHECK-CLANG-SHARED-LIBGCC: warning: argument unused during compilation: '-shared-libgcc' -// This will be the correct check once the driver supports -shared-libgcc -// SKIP-CHECK-CLANG-SHARED-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" -// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" -// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lc" -// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" +// CHECK-CLANG-SHARED-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" +// CHECK-CLANG-SHARED-LIBGCC: "-lc" +// CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc" // // RUN: %clang -shared-libgcc -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=x86_64-unknown-linux -rtlib=platform \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC-DYNAMIC %s -// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: warning: argument unused during compilation: '-shared-libgcc' -// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" -// This will be the correct check once the driver supports -shared-libgcc -// SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc" -// SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lc" -// SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc" +// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc" +// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lc" +// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=aarch64-linux-android -rtlib=platform \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy
I applied this to a clean local copy, which has no other changes, and have the following test error, which may be pilot error on my part, but nevertheless, this test needs to be robust to changes in the line number. llvm-svn/llvm/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp:39: Failure Value of: false Actual: false Expected: true Typename::getFullyQualifiedName failed for (anonymous struct)::un_in_st_1 Actual: union (anonymous struct at input.cc:1:1)::(anonymous union at input.cc:2:27) Exepcted: union (anonymous struct at input.cc:1:1)::(anonymous union at input.cc:2:31) On Fri, May 4, 2018 at 9:22 AM, Mikhail Ramalho via Phabricator < revi...@reviews.llvm.org> wrote: > mikhail.ramalho added a comment. > > Thanks. > > I just need someone to push it, as I don't have write access to the repo. > > > https://reviews.llvm.org/D36610 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331552 - Allow modifying the PrintingPolicy for fully qualified names.
Author: saugustine Date: Fri May 4 13:12:39 2018 New Revision: 331552 URL: http://llvm.org/viewvc/llvm-project?rev=331552&view=rev Log: Allow modifying the PrintingPolicy for fully qualified names. Author: mikhail.rama...@gmail.com Modified: cfe/trunk/include/clang/AST/QualTypeNames.h cfe/trunk/lib/AST/QualTypeNames.cpp cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Modified: cfe/trunk/include/clang/AST/QualTypeNames.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/QualTypeNames.h?rev=331552&r1=331551&r2=331552&view=diff == --- cfe/trunk/include/clang/AST/QualTypeNames.h (original) +++ cfe/trunk/include/clang/AST/QualTypeNames.h Fri May 4 13:12:39 2018 @@ -72,6 +72,7 @@ namespace TypeName { /// \param[in] WithGlobalNsPrefix - If true, then the global namespace /// specifier "::" will be prepended to the fully qualified name. std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, + const PrintingPolicy &Policy, bool WithGlobalNsPrefix = false); /// \brief Generates a QualType that can be used to name the same type Modified: cfe/trunk/lib/AST/QualTypeNames.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/QualTypeNames.cpp?rev=331552&r1=331551&r2=331552&view=diff == --- cfe/trunk/lib/AST/QualTypeNames.cpp (original) +++ cfe/trunk/lib/AST/QualTypeNames.cpp Fri May 4 13:12:39 2018 @@ -452,12 +452,8 @@ QualType getFullyQualifiedType(QualType std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, + const PrintingPolicy &Policy, bool WithGlobalNsPrefix) { - PrintingPolicy Policy(Ctx.getPrintingPolicy()); - Policy.SuppressScope = false; - Policy.AnonymousTagLocations = false; - Policy.PolishForDeclaration = true; - Policy.SuppressUnwrittenScope = true; QualType FQQT = getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix); return FQQT.getAsString(Policy); } Modified: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp?rev=331552&r1=331551&r2=331552&view=diff == --- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp (original) +++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Fri May 4 13:12:39 2018 @@ -26,9 +26,13 @@ struct TypeNameVisitor : TestVisitorgetNameAsString()); if (ExpectedName != "") { - std::string ActualName = - TypeName::getFullyQualifiedName(VD->getType(), *Context, - WithGlobalNsPrefix); + PrintingPolicy Policy(Context->getPrintingPolicy()); + Policy.SuppressScope = false; + Policy.AnonymousTagLocations = true; + Policy.PolishForDeclaration = true; + Policy.SuppressUnwrittenScope = true; + std::string ActualName = TypeName::getFullyQualifiedName( + VD->getType(), *Context, Policy, WithGlobalNsPrefix); if (ExpectedName != ActualName) { // A custom message makes it much easier to see what declaration // failed compared to EXPECT_EQ. @@ -217,6 +221,26 @@ TEST(QualTypeNameTest, getFullyQualified " }\n" "}\n" ); + + TypeNameVisitor AnonStrucs; + AnonStrucs.ExpectedQualTypeNames["a"] = "short"; + AnonStrucs.ExpectedQualTypeNames["un_in_st_1"] = + "union (anonymous struct at input.cc:1:1)::(anonymous union at " + "input.cc:2:27)"; + AnonStrucs.ExpectedQualTypeNames["b"] = "short"; + AnonStrucs.ExpectedQualTypeNames["un_in_st_2"] = + "union (anonymous struct at input.cc:1:1)::(anonymous union at " + "input.cc:5:27)"; + AnonStrucs.ExpectedQualTypeNames["anon_st"] = + "struct (anonymous struct at input.cc:1:1)"; + AnonStrucs.runOver(R"(struct { + union { +short a; + } un_in_st_1; + union { +short b; + } un_in_st_2; +} anon_st;)"); } } // end anonymous namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy
Committed as r331552. On Fri, May 4, 2018 at 12:43 PM, Mikhail Ramalho via Phabricator < revi...@reviews.llvm.org> wrote: > mikhail.ramalho updated this revision to Diff 145255. > mikhail.ramalho added a comment. > > Fixed the test case. > > > https://reviews.llvm.org/D36610 > > Files: > include/clang/AST/QualTypeNames.h > lib/AST/QualTypeNames.cpp > unittests/Tooling/QualTypeNamesTest.cpp > > > Index: unittests/Tooling/QualTypeNamesTest.cpp > === > --- unittests/Tooling/QualTypeNamesTest.cpp > +++ unittests/Tooling/QualTypeNamesTest.cpp > @@ -26,9 +26,13 @@ > std::string ExpectedName = > ExpectedQualTypeNames.lookup(VD->getNameAsString()); > if (ExpectedName != "") { > - std::string ActualName = > - TypeName::getFullyQualifiedName(VD->getType(), *Context, > - WithGlobalNsPrefix); > + PrintingPolicy Policy(Context->getPrintingPolicy()); > + Policy.SuppressScope = false; > + Policy.AnonymousTagLocations = true; > + Policy.PolishForDeclaration = true; > + Policy.SuppressUnwrittenScope = true; > + std::string ActualName = TypeName::getFullyQualifiedName( > + VD->getType(), *Context, Policy, WithGlobalNsPrefix); >if (ExpectedName != ActualName) { > // A custom message makes it much easier to see what declaration > // failed compared to EXPECT_EQ. > @@ -217,6 +221,26 @@ >" }\n" >"}\n" >); > + > + TypeNameVisitor AnonStrucs; > + AnonStrucs.ExpectedQualTypeNames["a"] = "short"; > + AnonStrucs.ExpectedQualTypeNames["un_in_st_1"] = > + "union (anonymous struct at input.cc:1:1)::(anonymous union at " > + "input.cc:2:27)"; > + AnonStrucs.ExpectedQualTypeNames["b"] = "short"; > + AnonStrucs.ExpectedQualTypeNames["un_in_st_2"] = > + "union (anonymous struct at input.cc:1:1)::(anonymous union at " > + "input.cc:5:27)"; > + AnonStrucs.ExpectedQualTypeNames["anon_st"] = > + "struct (anonymous struct at input.cc:1:1)"; > + AnonStrucs.runOver(R"(struct { > + union { > +short a; > + } un_in_st_1; > + union { > +short b; > + } un_in_st_2; > +} anon_st;)"); > } > > } // end anonymous namespace > Index: lib/AST/QualTypeNames.cpp > === > --- lib/AST/QualTypeNames.cpp > +++ lib/AST/QualTypeNames.cpp > @@ -452,12 +452,8 @@ > > std::string getFullyQualifiedName(QualType QT, >const ASTContext &Ctx, > + const PrintingPolicy &Policy, >bool WithGlobalNsPrefix) { > - PrintingPolicy Policy(Ctx.getPrintingPolicy()); > - Policy.SuppressScope = false; > - Policy.AnonymousTagLocations = false; > - Policy.PolishForDeclaration = true; > - Policy.SuppressUnwrittenScope = true; >QualType FQQT = getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix); >return FQQT.getAsString(Policy); > } > Index: include/clang/AST/QualTypeNames.h > === > --- include/clang/AST/QualTypeNames.h > +++ include/clang/AST/QualTypeNames.h > @@ -72,6 +72,7 @@ > /// \param[in] WithGlobalNsPrefix - If true, then the global namespace > /// specifier "::" will be prepended to the fully qualified name. > std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, > + const PrintingPolicy &Policy, >bool WithGlobalNsPrefix = false); > > /// \brief Generates a QualType that can be used to name the same type > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f07b3d4 - Add #includes so that ROCm.h is compilable stand-alone.
Author: Sterling Augustine Date: 2020-06-08T14:16:30-07:00 New Revision: f07b3d41e73979e46f468dbaa27866bbb53c1ab6 URL: https://github.com/llvm/llvm-project/commit/f07b3d41e73979e46f468dbaa27866bbb53c1ab6 DIFF: https://github.com/llvm/llvm-project/commit/f07b3d41e73979e46f468dbaa27866bbb53c1ab6.diff LOG: Add #includes so that ROCm.h is compilable stand-alone. Summary: ROCm.h had been getting the declarations for various data structures by being #included next to them, rather than #includeing them itself. This change fixes that by explicitly including the appropriate headers. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81432 Added: Modified: clang/lib/Driver/ToolChains/ROCm.h Removed: diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index 9f5fa451472b..779e2e133bec 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -10,9 +10,14 @@ #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H #include "clang/Basic/Cuda.h" +#include "clang/Basic/LLVM.h" +#include "clang/Driver/Driver.h" #include "clang/Driver/Options.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Option/ArgList.h" namespace clang { namespace driver { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ccd1922 - Fix variables used only in asserts.
Author: Sterling Augustine Date: 2020-06-09T17:19:38-07:00 New Revision: ccd192204da45cc3f4b42f585f04c4f934b21bef URL: https://github.com/llvm/llvm-project/commit/ccd192204da45cc3f4b42f585f04c4f934b21bef DIFF: https://github.com/llvm/llvm-project/commit/ccd192204da45cc3f4b42f585f04c4f934b21bef.diff LOG: Fix variables used only in asserts. Summary: Fix variables used only in asserts. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81522 Added: Modified: clang/unittests/StaticAnalyzer/ParamRegionTest.cpp Removed: diff --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp index c58af3f851c4..4edbeb30df1c 100644 --- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp +++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp @@ -20,8 +20,8 @@ class ParamRegionTestConsumer : public ExprEngineConsumer { const StackFrameContext *SFC, const ParmVarDecl *PVD) { for (const auto *D2: PVD->redecls()) { - const auto *PVD2 = cast(D2); - assert(MRMgr.getVarRegion(PVD, SFC) == MRMgr.getVarRegion(PVD2, SFC)); + assert(MRMgr.getVarRegion(PVD, SFC) == + MRMgr.getVarRegion(cast(D2), SFC)); } } @@ -33,29 +33,26 @@ class ParamRegionTestConsumer : public ExprEngineConsumer { if (const auto *FD = dyn_cast(D)) { for (const auto *P : FD->parameters()) { -const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC); if (SFC->inTopFrame()) - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); else - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); checkForSameParamRegions(MRMgr, SFC, P); } } else if (const auto *CD = dyn_cast(D)) { for (const auto *P : CD->parameters()) { -const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC); if (SFC->inTopFrame()) - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); else - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); checkForSameParamRegions(MRMgr, SFC, P); } } else if (const auto *MD = dyn_cast(D)) { for (const auto *P : MD->parameters()) { -const TypedValueRegion *Reg = MRMgr.getVarRegion(P, SFC); if (SFC->inTopFrame()) - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); else - assert(isa(Reg)); + assert(isa(MRMgr.getVarRegion(P, SFC))); checkForSameParamRegions(MRMgr, SFC, P); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e640598 - Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics"
Author: Sterling Augustine Date: 2020-06-12T12:10:13-07:00 New Revision: e64059828f19f629081220bffeb3ef7582870111 URL: https://github.com/llvm/llvm-project/commit/e64059828f19f629081220bffeb3ef7582870111 DIFF: https://github.com/llvm/llvm-project/commit/e64059828f19f629081220bffeb3ef7582870111.diff LOG: Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics" Summary: This reverts commit 33fb9cbe211d1b43d4b84edf34e11001f04cddf0. That commit violates layering by adding a dependency from StaticAnalyzer/Core back to StaticAnalyzer/FrontEnd, creating a circular dependency. I can't see a clean way to fix it except refactoring. Reviewers: echristo, Szelethus, martong Subscribers: xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Charusso, ASDenysPetrov, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81752 Added: Modified: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp Removed: diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 27bc0dda1f1c..51565524db1e 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -19,7 +19,6 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h" -#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" @@ -136,7 +135,7 @@ class BugReport { SmallVector Fixits; BugReport(Kind kind, const BugType &bt, StringRef desc) - : BugReport(kind, bt, "", desc) {} + : K(kind), BT(bt), Description(desc) {} BugReport(Kind K, const BugType &BT, StringRef ShortDescription, StringRef Description) @@ -370,13 +369,16 @@ class PathSensitiveBugReport : public BugReport { public: PathSensitiveBugReport(const BugType &bt, StringRef desc, const ExplodedNode *errorNode) - : PathSensitiveBugReport(bt, desc, desc, errorNode) {} + : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode), +ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() + : SourceRange()) {} PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errorNode) - : PathSensitiveBugReport(bt, shortDesc, desc, errorNode, - /*LocationToUnique*/ {}, - /*DeclToUnique*/ nullptr) {} + : BugReport(Kind::PathSensitive, bt, shortDesc, desc), +ErrorNode(errorNode), +ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() + : SourceRange()) {} /// Create a PathSensitiveBugReport with a custom uniqueing location. /// @@ -389,13 +391,11 @@ class PathSensitiveBugReport : public BugReport { const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique) - : PathSensitiveBugReport(bt, desc, desc, errorNode, LocationToUnique, - DeclToUnique) {} - - PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef desc, - const ExplodedNode *errorNode, - PathDiagnosticLocation LocationToUnique, - const Decl *DeclToUnique); + : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode), +ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()), +UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) { +assert(errorNode); + } static bool classof(const BugReport *R) { return R->getKind() == Kind::PathSensitive; diff --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h index 795067cba582..7b72fae0fefe 100644 --- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h +++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h @@ -135,7 +135,7 @@ class CheckerRegistry { "Invalid development status!"); } -LLVM_DUMP_METHOD void dump() const; +LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } LLVM_DUMP_METHOD void dumpToStream(llvm::raw_o
Re: [PATCH] D73967: Implement _ExtInt as an extended int type specifier.
Sorry for the trouble. I think many buildbots don't build lldb--not enough of them anyway. I found this myself. As I understand it, the switch-cover warning is supposed to be enabled everywhere when built in release mode, so it looks like the lldb builders (what few there are) aren't building in release mode. I can look into fixing that. On Fri, Apr 17, 2020 at 11:20 AM Erich Keane via Phabricator < revi...@reviews.llvm.org> wrote: > erichkeane added a comment. > > Already relanded here: 5f0903e9bec9 < > https://reviews.llvm.org/rG5f0903e9bec97e67bf34d887bcbe9d05790de934> > > @saugustine I checked the buildbots, every one with LLDB in its name > stayed green, and I cannot see the warning in any of their STDIO. Can you > point out how I can proactively keep an eye on this? The lldb build is > broken out-of-the-box anyway for me due to the LLDB Python Wrapper having a > syntax error in the SWIG bindings. > > bash-4.2$ swig -copyright > > SWIG Version 2.0.10 > /workspaces/llvm-project/lldb/bindings/./python/python-typemaps.swig:496: > Error: Syntax error in input(3). > > > Repository: > rG LLVM Github Monorepo > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D73967/new/ > > https://reviews.llvm.org/D73967 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] a20f5fe - Default to disabling the libunwind frameheader cache.
Author: Sterling Augustine Date: 2020-08-18T14:37:36-07:00 New Revision: a20f5fe70810e0a768c1814d69d10862965c21e4 URL: https://github.com/llvm/llvm-project/commit/a20f5fe70810e0a768c1814d69d10862965c21e4 DIFF: https://github.com/llvm/llvm-project/commit/a20f5fe70810e0a768c1814d69d10862965c21e4.diff LOG: Default to disabling the libunwind frameheader cache. Although it works fine with glibc, as currently implemented the frameheader cache is incompatible with certain platforms with slightly different locking semantics inside dl_iterate_phdr. Therefore only enable it when it is turned on explicitly with a configure-time option. Differential Revision: https://reviews.llvm.org/D86163 Added: Modified: libunwind/CMakeLists.txt libunwind/src/AddressSpace.hpp libunwind/test/frameheadercache_test.pass.cpp Removed: diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 8419d851ab7f..f4243f3d2791 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -138,6 +138,7 @@ option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread funct option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS}) option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF) +option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. Requires locking dl_iterate_phdr." OFF) set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") @@ -368,6 +369,10 @@ if(LIBUNWIND_IS_BAREMETAL) add_compile_definitions(_LIBUNWIND_IS_BAREMETAL) endif() +if(LIBUNWIND_USE_FRAME_HEADER_CACHE) + add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE) +endif() + # This is the _ONLY_ place where add_definitions is called. if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 78d2dd110865..2443bd761cc4 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -411,10 +411,12 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) #include "FrameHeaderCache.hpp" // There should be just one of these per process. static FrameHeaderCache ProcessFrameHeaderCache; +#endif static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, dl_iterate_cb_data *cbdata) { @@ -435,8 +437,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size, auto cbdata = static_cast(data); if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr) return 0; +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data)) return 1; +#endif Elf_Addr image_base = calculateImageBase(pinfo); bool found_obj = false; @@ -464,7 +468,9 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size, found_obj = checkAddrInSegment(phdr, image_base, cbdata); } if (found_obj && found_hdr) { +#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) ProcessFrameHeaderCache.add(cbdata->sects); +#endif return 1; } } diff --git a/libunwind/test/frameheadercache_test.pass.cpp b/libunwind/test/frameheadercache_test.pass.cpp index 9397e70d66cb..ebbc00464e07 100644 --- a/libunwind/test/frameheadercache_test.pass.cpp +++ b/libunwind/test/frameheadercache_test.pass.cpp @@ -6,7 +6,7 @@ // The frame header cache should work fine for other architectures, // but the #ifdefs end up being even more complicated than this. -#ifdef __x86_64__ +#if defined(__x86_64__) && defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE) // This #if chain is ugly, but see the comments in AddressSpace.hpp for // the reasoning. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4544a63 - Move variable only used in an assert into the assert.
Author: Sterling Augustine Date: 2021-02-18T13:04:58-08:00 New Revision: 4544a63b77056212af341722b2e04471a8ec0be6 URL: https://github.com/llvm/llvm-project/commit/4544a63b77056212af341722b2e04471a8ec0be6 DIFF: https://github.com/llvm/llvm-project/commit/4544a63b77056212af341722b2e04471a8ec0be6.diff LOG: Move variable only used in an assert into the assert. This prevents unused variable warnings when building without asserts. Added: Modified: clang/lib/CodeGen/CoverageMappingGen.cpp Removed: diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index ce2cb380e0c1..519b9ad4bdbd 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -981,8 +981,8 @@ struct CounterCoverageMappingBuilder bool UnnestStart = StartDepth >= EndDepth; bool UnnestEnd = EndDepth >= StartDepth; if (UnnestEnd) { -SourceLocation NestedLoc = getStartOfFileOrMacro(BeforeLoc); -assert(SM.isWrittenInSameFile(NestedLoc, BeforeLoc)); +assert(SM.isWrittenInSameFile(getStartOfFileOrMacro(BeforeLoc), + BeforeLoc)); BeforeLoc = getIncludeOrExpansionLoc(BeforeLoc); assert(BeforeLoc.isValid()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fc97a63 - Move a second variable only used in an assert into the assert.
Author: Sterling Augustine Date: 2021-02-18T13:26:07-08:00 New Revision: fc97a63db0d3488ce6c422a9545f8b0268760918 URL: https://github.com/llvm/llvm-project/commit/fc97a63db0d3488ce6c422a9545f8b0268760918 DIFF: https://github.com/llvm/llvm-project/commit/fc97a63db0d3488ce6c422a9545f8b0268760918.diff LOG: Move a second variable only used in an assert into the assert. This prevents unused variable warnings when building without asserts. Added: Modified: clang/lib/CodeGen/CoverageMappingGen.cpp Removed: diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 519b9ad4bdbd..72ed10d5c360 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -989,8 +989,8 @@ struct CounterCoverageMappingBuilder EndDepth--; } if (UnnestStart) { -SourceLocation NestedLoc = getEndOfFileOrMacro(AfterLoc); -assert(SM.isWrittenInSameFile(AfterLoc, NestedLoc)); +assert(SM.isWrittenInSameFile(AfterLoc, + getEndOfFileOrMacro(AfterLoc))); AfterLoc = getIncludeOrExpansionLoc(AfterLoc); assert(AfterLoc.isValid()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3e55f55 - Fully-qualify template args of outer types in getFullyQualifiedType
Author: Victor Kuznetsov Date: 2021-06-03T10:50:00-07:00 New Revision: 3e55f55048387a8efef01e445d46fc5cf100285d URL: https://github.com/llvm/llvm-project/commit/3e55f55048387a8efef01e445d46fc5cf100285d DIFF: https://github.com/llvm/llvm-project/commit/3e55f55048387a8efef01e445d46fc5cf100285d.diff LOG: Fully-qualify template args of outer types in getFullyQualifiedType Template args of outer types were not fully-qualified when calling getFullyQualifiedType() for inner types. For simplicity the patch is a copy-paste of the same call from getFullyQualifiedType(). Reviewed at: https://reviews.llvm.org/D103039 Added: Modified: clang/lib/AST/QualTypeNames.cpp clang/unittests/Tooling/QualTypeNamesTest.cpp Removed: diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index 73a33a208233b..9a1b418f5ac1b 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -356,11 +356,19 @@ NestedNameSpecifier *createNestedNameSpecifier(const ASTContext &Ctx, const TypeDecl *TD, bool FullyQualify, bool WithGlobalNsPrefix) { + const Type *TypePtr = TD->getTypeForDecl(); + if (isa(TypePtr) || + isa(TypePtr)) { +// We are asked to fully qualify and we have a Record Type (which +// may point to a template specialization) or Template +// Specialization Type. We need to fully qualify their arguments. + +TypePtr = getFullyQualifiedTemplateType(Ctx, TypePtr, WithGlobalNsPrefix); + } + return NestedNameSpecifier::Create( - Ctx, - createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix), - false /*No TemplateKeyword*/, - TD->getTypeForDecl()); + Ctx, createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix), + false /*No TemplateKeyword*/, TypePtr); } /// Return the fully qualified type, including fully-qualified diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index c820b61622856..8272edb28c219 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -93,12 +93,14 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["AliasInnerTypeVal"] = + "OuterTemplateClass::Inner"; Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; Visitor.runOver( "int CheckInt;\n" "template \n" - "class OuterTemplateClass { };\n" + "class OuterTemplateClass { public: struct Inner {}; };\n" "namespace A {\n" " namespace B {\n" " class Class0 { };\n" @@ -107,6 +109,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { " template \n" " using InnerAlias = OuterTemplateClass;\n" " InnerAlias AliasTypeVal;\n" + " InnerAlias::Inner AliasInnerTypeVal;\n" " }\n" " template class Template0;" " template class Template1;" @@ -165,8 +168,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { " enum AnEnum { ZERO, ONE };\n" "};\n" "EnumScopeClass::AnEnum AnEnumVar;\n", - TypeNameVisitor::Lang_CXX11 -); + TypeNameVisitor::Lang_CXX11); TypeNameVisitor Complex; Complex.ExpectedQualTypeNames["CheckTX"] = "B::TX"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1d3873d - Move variable only used inside an assert into the assert.
Author: Sterling Augustine Date: 2021-06-10T13:14:45-07:00 New Revision: 1d3873d41eca67e974bafbaa91866581bcc0d973 URL: https://github.com/llvm/llvm-project/commit/1d3873d41eca67e974bafbaa91866581bcc0d973 DIFF: https://github.com/llvm/llvm-project/commit/1d3873d41eca67e974bafbaa91866581bcc0d973.diff LOG: Move variable only used inside an assert into the assert. This prevents build failures with -Wunused. Added: Modified: clang/lib/Serialization/ASTReaderStmt.cpp Removed: diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 62d7a99b52c7..b100f946f558 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -3206,8 +3206,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { } case STMT_OMP_UNROLL_DIRECTIVE: { - unsigned NumLoops = Record[ASTStmtReader::NumStmtFields]; - assert(NumLoops == 1 && "Unroll directive accepts only a single loop"); + assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop"); unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1]; S = OMPUnrollDirective::CreateEmpty(Context, NumClauses); break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5eab94f - Eliminate unused-variable warning.
Author: Sterling Augustine Date: 2022-08-26T12:40:55-07:00 New Revision: 5eab94f7eb20c2f5d3123e7401892a1a6a133e38 URL: https://github.com/llvm/llvm-project/commit/5eab94f7eb20c2f5d3123e7401892a1a6a133e38 DIFF: https://github.com/llvm/llvm-project/commit/5eab94f7eb20c2f5d3123e7401892a1a6a133e38.diff LOG: Eliminate unused-variable warning. Added: Modified: clang/lib/Frontend/SARIFDiagnostic.cpp Removed: diff --git a/clang/lib/Frontend/SARIFDiagnostic.cpp b/clang/lib/Frontend/SARIFDiagnostic.cpp index d19426c91a3d..2bcbd5cf34f2 100644 --- a/clang/lib/Frontend/SARIFDiagnostic.cpp +++ b/clang/lib/Frontend/SARIFDiagnostic.cpp @@ -71,8 +71,7 @@ SarifResult SARIFDiagnostic::addLocationToResult( FileID FID = Loc.getFileID(); if (FID.isValid()) { if (const FileEntry *FE = Loc.getFileEntry()) { -llvm::StringRef Filename = -emitFilename(FE->getName(), Loc.getManager()); +emitFilename(FE->getName(), Loc.getManager()); // FIXME(llvm-project/issues/57366): File-only locations } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f886f7e - Remove unused private variable.
Author: Sterling Augustine Date: 2022-08-26T12:43:05-07:00 New Revision: f886f7e8ef7aa4f54298db792a656373af90440c URL: https://github.com/llvm/llvm-project/commit/f886f7e8ef7aa4f54298db792a656373af90440c DIFF: https://github.com/llvm/llvm-project/commit/f886f7e8ef7aa4f54298db792a656373af90440c.diff LOG: Remove unused private variable. Added: Modified: clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Driver/ToolChains/Cuda.h Removed: diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 16c82de54aa3..4d9a473419d3 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -599,7 +599,7 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const ArgList &Args, const Action::OffloadKind OK) : ToolChain(D, Triple, Args), HostTC(HostTC), - CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) { + CudaInstallation(D, HostTC.getTriple(), Args) { if (CudaInstallation.isValid()) { CudaInstallation.WarnIfUnsupportedVersion(); getProgramPaths().push_back(std::string(CudaInstallation.getBinPath())); diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h index 997fdfbc44df..a51dcc2d5a20 100644 --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -188,9 +188,6 @@ class LLVM_LIBRARY_VISIBILITY CudaToolChain : public ToolChain { protected: Tool *buildAssembler() const override; // ptxas Tool *buildLinker() const override; // fatbinary (ok, not really a linker) - -private: - const Action::OffloadKind OK; }; } // end namespace toolchains ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b9543f7 - Revert "[clang][Interp][NFC] Trim Source.h includes"
Author: Sterling Augustine Date: 2023-07-14T13:34:26-07:00 New Revision: b9543f7de69770a97e983452c5158acc3b4783c7 URL: https://github.com/llvm/llvm-project/commit/b9543f7de69770a97e983452c5158acc3b4783c7 DIFF: https://github.com/llvm/llvm-project/commit/b9543f7de69770a97e983452c5158acc3b4783c7.diff LOG: Revert "[clang][Interp][NFC] Trim Source.h includes" This reverts commit 245d10b7a2c12ec25e7b5860a38c61991543a739 which causes errors like the ones below on slightly older versions of clang: ``` In file included from .../clang/lib/AST/Interp/Source.h:17: In file included from .../llvm/include/llvm/ADT/PointerUnion.h:19: In file included from .../llvm/include/llvm/ADT/PointerIntPair.h:18: .../llvm/include/llvm/Support/PointerLikeTypeTraits.h:61:28: error: invalid application of 'alignof' to an incomplete type 'clang::Decl' 61 | detail::ConstantLog2::value; |^~ .../llvm/include/llvm/Support/PointerLikeTypeTraits.h:101:56: note: in instantiation of static data member 'llvm::PointerLikeTypeTraits::NumLowBitsAvailable' requested here 101 | static constexpr int NumLowBitsAvailable = NonConst::NumLowBitsAvailable; |^ .../llvm/include/llvm/ADT/PointerUnion.h:38:54: note: in instantiation of static data member 'llvm::PointerLikeTypeTraits::NumLowBitsAvailable' requested here 38 | return std::min({PointerLikeTypeTraits::NumLowBitsAvailable...}); | ^ .../llvm/include/llvm/ADT/PointerUnion.h:52:48: note: in instantiation of function template specialization 'llvm::pointer_union_detail::lowBitsAvailable' requested here 52 | static constexpr int NumLowBitsAvailable = lowBitsAvailable(); |^ .../llvm/include/llvm/ADT/PointerIntPair.h:169:28: note: in instantiation of static data member 'llvm::pointer_union_detail::PointerUnionUIntTraits::NumLowBitsAvailable' requested here 169 | static_assert(PtrTraits::NumLowBitsAvailable < |^ .../llvm/include/llvm/ADT/PointerIntPair.h:111:13: note: in instantiation of template class 'llvm::PointerIntPairInfo>' requested here 111 | Value = Info::updateInt(Info::updatePointer(0, PtrVal), | ^ .../llvm/include/llvm/ADT/PointerIntPair.h:89:5: note: in instantiation of member function 'llvm::PointerIntPair>::setPointerAndInt' requested here 89 | setPointerAndInt(PtrVal, IntVal); | ^ .../llvm/include/llvm/ADT/PointerUnion.h:77:16: note: in instantiation of member function 'llvm::PointerIntPair>::PointerIntPair' requested here 77 | : Base(ValTy(const_cast( |^ .../clang/lib/AST/Interp/Source.h:76:31: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers, llvm::PointerIntPair>, 1, const clang::Stmt *>::PointerUnionMembers' requested here 76 | SourceInfo(const Stmt *E) : Source(E) {} | ^ .../clang/lib/AST/Interp/Source.h:22:7: note: forward declaration of 'clang::Decl' 22 | class Decl; | ^ ``` Added: Modified: clang/lib/AST/Interp/Source.h Removed: diff --git a/clang/lib/AST/Interp/Source.h b/clang/lib/AST/Interp/Source.h index f448081362b58d..89fca9ac80f289 100644 --- a/clang/lib/AST/Interp/Source.h +++ b/clang/lib/AST/Interp/Source.h @@ -14,17 +14,11 @@ #define LLVM_CLANG_AST_INTERP_SOURCE_H #include "PrimType.h" -#include "llvm/ADT/PointerUnion.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Stmt.h" #include "llvm/Support/Endian.h" namespace clang { - -class Decl; -class Stmt; -class SourceLocation; -class Expr; -class SourceRange; - namespace interp { class Function; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 5eb44df - Make _LIBUNWIND_SUPPORT_FRAME_APIS a build-time option
Author: Sterling Augustine Date: 2023-08-23T14:34:40-07:00 New Revision: 5eb44df1b64dbd1a86b099128092a7fd2001c0ba URL: https://github.com/llvm/llvm-project/commit/5eb44df1b64dbd1a86b099128092a7fd2001c0ba DIFF: https://github.com/llvm/llvm-project/commit/5eb44df1b64dbd1a86b099128092a7fd2001c0ba.diff LOG: Make _LIBUNWIND_SUPPORT_FRAME_APIS a build-time option Previously this was based on target architecture, but that makes very little sense--frame API availability is generally for libgcc compatibility and that is dependent on runtime needs rather than target architecture. Default this to on, so as not to remove the apis from environments that already have them. The functions this macro protects are stubs for libgcc-compatibility. Today, libunwind as a drop-in replacement for libgcc_eh links on x86, x86_64, and powerpc, but not aarch64, which doesn't really make sense. As there is nothing architecture specific about these, they should be provided everywhere or nowhere. The target-specific protection goes all the way back to the original code contribution in 312fcd0e1cf14482b2ae8eee8234541dcc3bc2c4 from 2013, so the original reason is lost to history, and probably not relevant today. Differential Revision: https://reviews.llvm.org/D158011 Added: Modified: libunwind/CMakeLists.txt libunwind/src/config.h Removed: diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index bc2a820fe98ebb..84f8ce296a7410 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -51,6 +51,7 @@ option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF) option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. Requires locking dl_iterate_phdr." OFF) option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for .cfi_remember_state." OFF) option(LIBUNWIND_INSTALL_HEADERS "Install the libunwind headers." ON) +option(LIBUNWIND_ENABLE_FRAME_APIS "Include libgcc-compatible frame apis." OFF) set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") @@ -250,6 +251,11 @@ if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING) add_compile_flags(-D_LIBUNWIND_IS_NATIVE_ONLY) endif() +# Include stubs for __register_frame_info_bases and related +if (LIBUNWIND_ENABLE_FRAME_APIS) + add_compile_flags(-D_LIBUNWIND_SUPPORT_FRAME_APIS) +endif() + # Threading-support if (NOT LIBUNWIND_ENABLE_THREADS) add_compile_flags(-D_LIBUNWIND_HAS_NO_THREADS) diff --git a/libunwind/src/config.h b/libunwind/src/config.h index 6707d591361dfc..ef6b8d67181b4e 100644 --- a/libunwind/src/config.h +++ b/libunwind/src/config.h @@ -108,10 +108,6 @@ #define _LIBUNWIND_BUILD_SJLJ_APIS #endif -#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) -#define _LIBUNWIND_SUPPORT_FRAME_APIS -#endif - #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \ (!defined(__APPLE__) && defined(__arm__)) || defined(__aarch64__) || \ defined(__mips__) || defined(__riscv) || defined(__hexagon__) || \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 71fbd6e - Exit unwinding early when at the top of the stack and additional info won't be found.
Author: Sterling Augustine Date: 2020-04-02T10:52:25-07:00 New Revision: 71fbd6e40632f437049215904c28ad9d63cff4bc URL: https://github.com/llvm/llvm-project/commit/71fbd6e40632f437049215904c28ad9d63cff4bc DIFF: https://github.com/llvm/llvm-project/commit/71fbd6e40632f437049215904c28ad9d63cff4bc.diff LOG: Exit unwinding early when at the top of the stack and additional info won't be found. Summary: This patch follows libgcc's lead: When the return-address register is zero, there won't be additional stack frames to examine, or gather information about. Exit before spending time looking for something known not to be found. Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77099 Added: Modified: libunwind/src/UnwindCursor.hpp Removed: diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index e7fb70cc5718..32d71c2c1ed3 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -1848,6 +1848,12 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { pc &= (pint_t)~0x1; #endif + // Exit early if at the top of the stack. + if (pc == 0) { +_unwindInfoMissing = true; +return; + } + // If the last line of a function is a "throw" the compiler sometimes // emits no instructions after the call to __cxa_throw. This means // the return address is actually the start of the next function. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] d933712 - Promote nameless lambda used by dl_iterate_phdr to named function to clean up control flow inside findUnwindSections. Also, expose the data structure
Author: Sterling Augustine Date: 2020-03-03T09:13:01-08:00 New Revision: d93371238e7f5d5f9c506a88cf4f05f8dea9d008 URL: https://github.com/llvm/llvm-project/commit/d93371238e7f5d5f9c506a88cf4f05f8dea9d008 DIFF: https://github.com/llvm/llvm-project/commit/d93371238e7f5d5f9c506a88cf4f05f8dea9d008.diff LOG: Promote nameless lambda used by dl_iterate_phdr to named function to clean up control flow inside findUnwindSections. Also, expose the data structure to allow use by a future replacment function. Summary: [Refactor] Promote nameless lambda to fully named function, allowing easy replacement in following patch. Subscribers: krytarowski, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75480 Added: Modified: libunwind/src/AddressSpace.hpp Removed: diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 7433476f9117..63c20412ef54 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -392,6 +392,111 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, return result; } +#if defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) +struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { + LocalAddressSpace *addressSpace; + UnwindInfoSections *sects; + uintptr_t targetAddr; +}; + +static int findUnwindSectionByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { + auto cbdata = static_cast(data); + bool found_obj = false; + bool found_hdr = false; + + assert(cbdata); + assert(cbdata->sects); + + if (cbdata->targetAddr < pinfo->dlpi_addr) { +return false; + } + +#if !defined(Elf_Half) + typedef ElfW(Half) Elf_Half; +#endif +#if !defined(Elf_Phdr) + typedef ElfW(Phdr) Elf_Phdr; +#endif +#if !defined(Elf_Addr) + typedef ElfW(Addr) Elf_Addr; +#endif + + Elf_Addr image_base = pinfo->dlpi_addr; + +#if defined(__ANDROID__) && __ANDROID_API__ < 18 + if (image_base == 0) { +// Normally, an image base of 0 indicates a non-PIE executable. On +// versions of Android prior to API 18, the dynamic linker reported a +// dlpi_addr of 0 for PIE executables. Compute the true image base +// using the PT_PHDR segment. +// See https://github.com/android/ndk/issues/505. +for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { + const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; + if (phdr->p_type == PT_PHDR) { +image_base = reinterpret_cast(pinfo->dlpi_phdr) - + phdr->p_vaddr; +break; + } +} + } +#endif + + #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) +#if !defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) + #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." + #endif + size_t object_length; + + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { +const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; +if (phdr->p_type == PT_LOAD) { + uintptr_t begin = image_base + phdr->p_vaddr; + uintptr_t end = begin + phdr->p_memsz; + if (cbdata->targetAddr >= begin && cbdata->targetAddr < end) { +cbdata->sects->dso_base = begin; +object_length = phdr->p_memsz; +found_obj = true; + } +} else if (phdr->p_type == PT_GNU_EH_FRAME) { + EHHeaderParser::EHHeaderInfo hdrInfo; + uintptr_t eh_frame_hdr_start = image_base + phdr->p_vaddr; + cbdata->sects->dwarf_index_section = eh_frame_hdr_start; + cbdata->sects->dwarf_index_section_length = phdr->p_memsz; + found_hdr = EHHeaderParser::decodeEHHdr( + *cbdata->addressSpace, eh_frame_hdr_start, phdr->p_memsz, + hdrInfo); + if (found_hdr) +cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; +} + } + + if (found_obj && found_hdr) { +cbdata->sects->dwarf_section_length = object_length; +return true; + } else { +return false; + } + #else // defined(_LIBUNWIND_ARM_EHABI) + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { +const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; +if (phdr->p_type == PT_LOAD) { + uintptr_t begin = image_base + phdr->p_vaddr; + uintptr_t end = begin + phdr->p_memsz; + if (cbdata->targetAddr >= begin && cbdata->targetAddr < end) +found_obj = true; +} else if (phdr->p_type == PT_ARM_EXIDX) { + uintptr_t exidx_start = image_base + phdr->p_vaddr; + cbdata->sects->arm_section = exidx_start; + cbdata->sects->arm_section_length = phdr->p_memsz; + found_hdr = true; +} + } + return found_obj && found_hdr; + #endif +} + +#endif // defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) + inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, UnwindInfoSections &info) { #ifdef __APPLE__ @@ -483,110 +588,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
[libunwind] d3c7443 - Correctly update isSignalFrame when unwinding the stack via dwarf.
Author: Sterling Augustine Date: 2019-11-07T14:48:35-08:00 New Revision: d3c744313c3cca0c076f031ec71e66ca74b12f2a URL: https://github.com/llvm/llvm-project/commit/d3c744313c3cca0c076f031ec71e66ca74b12f2a DIFF: https://github.com/llvm/llvm-project/commit/d3c744313c3cca0c076f031ec71e66ca74b12f2a.diff LOG: Correctly update isSignalFrame when unwinding the stack via dwarf. A "signal frame" is a function or block of code where execution arrives via a signal or interrupt, rather than via a normal call instruction. In fact, a particular instruction is interrupted by the signal and needs to be restarted. Therefore, when the signal handler is complete, execution needs to return to the interrupted instruction, rather than the instruction immediately following the call instruction, as in a normal call. Stack unwinders need to know this to correctly unwind signal frames. Dwarf handily provides an "S" in the CIE augmentation string to describe this case, and the libunwind API provides various functions to for unwinders to determine it,. The llvm libunwind implementation correctly sets it's internal variable "isSignalFrame" when initializing an unwind context. However, upon stepping up the stack, the current implementation correctly reads the augmentation string and sets it in the CIE info (which it then discards), libunwind doesn't update it's internal unwind context data structure. This change fixes that, and provides compatibility with both the canonical libunwind and the libgcc implementation. Reviewers: jfb Subscribers: christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D69677 Added: libunwind/test/signal_frame.pass.cpp Modified: libunwind/src/DwarfInstructions.hpp libunwind/src/UnwindCursor.hpp libunwind/src/UnwindLevel1-gcc-ext.c Removed: diff --git a/libunwind/src/DwarfInstructions.hpp b/libunwind/src/DwarfInstructions.hpp index 29a070fa3e04..48ef1866d6e1 100644 --- a/libunwind/src/DwarfInstructions.hpp +++ b/libunwind/src/DwarfInstructions.hpp @@ -34,7 +34,7 @@ class DwarfInstructions { typedef typename A::sint_t sint_t; static int stepWithDwarf(A &addressSpace, pint_t pc, pint_t fdeStart, - R ®isters); + R ®isters, bool &isSignalFrame); private: @@ -150,7 +150,8 @@ v128 DwarfInstructions::getSavedVectorRegister( template int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc, - pint_t fdeStart, R ®isters) { + pint_t fdeStart, R ®isters, + bool &isSignalFrame) { FDE_Info fdeInfo; CIE_Info cieInfo; if (CFI_Parser::decodeFDE(addressSpace, fdeStart, &fdeInfo, @@ -196,6 +197,8 @@ int DwarfInstructions::stepWithDwarf(A &addressSpace, pint_t pc, // restoring SP means setting it to CFA. newRegisters.setSP(cfa); + isSignalFrame = cieInfo.isSignalFrame; + #if defined(_LIBUNWIND_TARGET_AARCH64) // If the target is aarch64 then the return address may have been signed // using the v8.3 pointer authentication extensions. The original diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index b4d44e111a65..4c18614b33d2 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -929,7 +929,7 @@ class UnwindCursor : public AbstractUnwindCursor{ return DwarfInstructions::stepWithDwarf(_addressSpace, (pint_t)this->getReg(UNW_REG_IP), (pint_t)_info.unwind_info, - _registers); + _registers, _isSignalFrame); } #endif diff --git a/libunwind/src/UnwindLevel1-gcc-ext.c b/libunwind/src/UnwindLevel1-gcc-ext.c index 63e4083a4579..008df815665e 100644 --- a/libunwind/src/UnwindLevel1-gcc-ext.c +++ b/libunwind/src/UnwindLevel1-gcc-ext.c @@ -221,7 +221,14 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) { _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, int *ipBefore) { _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p)", (void *)context); - *ipBefore = 0; + int isSignalFrame = __unw_is_signal_frame((unw_cursor_t *)context); + // Negative means some kind of error (probably UNW_ENOINFO), but we have no + // good way to report that, and this maintains backward compatibility with the + // implementation that hard-coded zero in every case, even signal frames. + if (isSignalFrame <= 0) +*ipBefore = 0; + else +*ipBefore = 1; return _Unwind_GetIP(context); } diff --git a/libunwind/test/signal_frame.pass.cpp b/libunwind/test/signal_frame.pass.cpp new file
[clang] 6470497 - Revert "[AST] Traverse the class type loc inside the member type loc."
Author: Sterling Augustine Date: 2019-12-05T16:48:18-08:00 New Revision: 6470497817eafe3fe2d15e11ade78fd99753d7ca URL: https://github.com/llvm/llvm-project/commit/6470497817eafe3fe2d15e11ade78fd99753d7ca DIFF: https://github.com/llvm/llvm-project/commit/6470497817eafe3fe2d15e11ade78fd99753d7ca.diff LOG: Revert "[AST] Traverse the class type loc inside the member type loc." This reverts commit 7f93cb62280a73e3e899d49c45be8bfbac634b7d. The assertion at RecursiveASTVisitor.h:1169 fails when passed a TypeLocNode. Not sure if the correct fix is to use getTypeLocClass or something else. Added: Modified: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp clang/include/clang/AST/RecursiveASTVisitor.h clang/unittests/Tooling/CMakeLists.txt Removed: clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp index b353c0bdb4ec..7b880faa554c 100644 --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -407,8 +407,8 @@ TEST(SemanticHighlighting, GetsCorrectTokens) { } )cpp", R"cpp( - template + template struct $Class[[G]] { void $Method[[foo]]( $TemplateParameter[[T]] *$Parameter[[O]]) { diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index d2144efb58e4..312f8bdf6bc8 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1162,12 +1162,11 @@ DEF_TRAVERSE_TYPELOC(LValueReferenceType, DEF_TRAVERSE_TYPELOC(RValueReferenceType, { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); }) +// FIXME: location of base class? // We traverse this in the type case as well, but how is it not reached through // the pointee type? DEF_TRAVERSE_TYPELOC(MemberPointerType, { - auto *TSI = TL.getClassTInfo(); - assert(TSI); - TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); + TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0))); TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); }) diff --git a/clang/unittests/Tooling/CMakeLists.txt b/clang/unittests/Tooling/CMakeLists.txt index be641845558b..5cef154926ae 100644 --- a/clang/unittests/Tooling/CMakeLists.txt +++ b/clang/unittests/Tooling/CMakeLists.txt @@ -42,7 +42,6 @@ add_clang_unittest(ToolingTests RecursiveASTVisitorTests/LambdaDefaultCapture.cpp RecursiveASTVisitorTests/LambdaExpr.cpp RecursiveASTVisitorTests/LambdaTemplateParams.cpp - RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp RecursiveASTVisitorTests/NestedNameSpecifiers.cpp RecursiveASTVisitorTests/ParenExpr.cpp RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp deleted file mode 100644 index 851c33dcf5a3.. --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===- unittest/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp -===// -// -// 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 "TestVisitor.h" - -using namespace clang; - -namespace { - -class MemberPointerTypeLocVisitor -: public ExpectedLocationVisitor { -public: - bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { -if (!TL) - return true; -Match(TL.getDecl()->getName(), TL.getNameLoc()); -return true; - } - bool VisitRecordTypeLoc(RecordTypeLoc RTL) { -if (!RTL) - return true; -Match(RTL.getDecl()->getName(), RTL.getNameLoc()); -return true; - } -}; - -TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) { - MemberPointerTypeLocVisitor Visitor; - Visitor.ExpectMatch("Bar", 4, 36); - Visitor.ExpectMatch("T", 7, 23); - EXPECT_TRUE(Visitor.runOver(R"cpp( - class Bar { void func(int); }; - class Foo { - void bind(const char*, void(Bar::*Foo)(int)) {} - - template - void test(void(T::*Foo)()); - }; - )cpp")); -} - -} // end anonymous namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 470f995 - Promote nameless lambda used by dl_iterate_phdr to named function.
Author: Sterling Augustine Date: 2020-03-05T08:55:22-08:00 New Revision: 470f995a517f5dbb53b1f5cd87ca3c9be0b32d79 URL: https://github.com/llvm/llvm-project/commit/470f995a517f5dbb53b1f5cd87ca3c9be0b32d79 DIFF: https://github.com/llvm/llvm-project/commit/470f995a517f5dbb53b1f5cd87ca3c9be0b32d79.diff LOG: Promote nameless lambda used by dl_iterate_phdr to named function. Summary: This cleans up control flow inside findUnwindSections, and will make it easier to replace this code in a following patch. Also, expose the data structure to allow use by a future replacment function. Reviewers: mstorsjo, miyuki Subscribers: krytarowski, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75637 Added: Modified: libunwind/src/AddressSpace.hpp Removed: diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 7433476f9117..2f68d6525a0f 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -392,6 +392,127 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, return result; } +#ifdef __APPLE__ +#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) +#elif defined(_LIBUNWIND_ARM_EHABI) && defined(_LIBUNWIND_IS_BAREMETAL) +#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32) +#elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32) +#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) +// Code inside findUnwindSections handles all these cases. +// +// Although the above ifdef chain is ugly, there doesn't seem to be a cleaner +// way to handle it. The generalized boolean expression is: +// +// A OR (B AND C) OR (D AND C) OR (B AND E) OR (F AND E) OR (D AND G) +// +// Running it through various boolean expression simplifiers gives expressions +// that don't help at all. +#elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) + +struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { + LocalAddressSpace *addressSpace; + UnwindInfoSections *sects; + uintptr_t targetAddr; +}; + +int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { + auto cbdata = static_cast(data); + bool found_obj = false; + bool found_hdr = false; + + assert(cbdata); + assert(cbdata->sects); + + if (cbdata->targetAddr < pinfo->dlpi_addr) { +return false; + } + +#if !defined(Elf_Half) + typedef ElfW(Half) Elf_Half; +#endif +#if !defined(Elf_Phdr) + typedef ElfW(Phdr) Elf_Phdr; +#endif +#if !defined(Elf_Addr) + typedef ElfW(Addr) Elf_Addr; +#endif + + Elf_Addr image_base = pinfo->dlpi_addr; + +#if defined(__ANDROID__) && __ANDROID_API__ < 18 + if (image_base == 0) { +// Normally, an image base of 0 indicates a non-PIE executable. On +// versions of Android prior to API 18, the dynamic linker reported a +// dlpi_addr of 0 for PIE executables. Compute the true image base +// using the PT_PHDR segment. +// See https://github.com/android/ndk/issues/505. +for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { + const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; + if (phdr->p_type == PT_PHDR) { +image_base = reinterpret_cast(pinfo->dlpi_phdr) - + phdr->p_vaddr; +break; + } +} + } +#endif + + #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) + #if !defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) + #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." + #endif + size_t object_length; + + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { +const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; +if (phdr->p_type == PT_LOAD) { + uintptr_t begin = image_base + phdr->p_vaddr; + uintptr_t end = begin + phdr->p_memsz; + if (cbdata->targetAddr >= begin && cbdata->targetAddr < end) { +cbdata->sects->dso_base = begin; +object_length = phdr->p_memsz; +found_obj = true; + } +} else if (phdr->p_type == PT_GNU_EH_FRAME) { + EHHeaderParser::EHHeaderInfo hdrInfo; + uintptr_t eh_frame_hdr_start = image_base + phdr->p_vaddr; + cbdata->sects->dwarf_index_section = eh_frame_hdr_start; + cbdata->sects->dwarf_index_section_length = phdr->p_memsz; + found_hdr = EHHeaderParser::decodeEHHdr( + *cbdata->addressSpace, eh_frame_hdr_start, phdr->p_memsz, + hdrInfo); + if (found_hdr) +cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; +} + } + + if (found_obj && found_hdr) { +cbdata->sects->dwarf_section_length = object_length; +return true; + } else { +return false; + } + #else // defined(_LIBUNWIND_ARM_EHABI) + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { +const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; +if (phdr->p_type == PT_LOAD) { + uintptr_t begin = image_base + phdr->p_vaddr; + uintptr_t end = begin + phdr->p_memsz; +
[libunwind] eb755df - Split findUnwindSectionsByPhdr into target-specific functions.
Author: Sterling Augustine Date: 2020-03-06T13:28:09-08:00 New Revision: eb755df5c27f5687a4f43a62e7eb0713c3f8f030 URL: https://github.com/llvm/llvm-project/commit/eb755df5c27f5687a4f43a62e7eb0713c3f8f030 DIFF: https://github.com/llvm/llvm-project/commit/eb755df5c27f5687a4f43a62e7eb0713c3f8f030.diff LOG: Split findUnwindSectionsByPhdr into target-specific functions. Summary: This further cleans up the control flow and makes it easier to optimize and replace portions in a subsequent patch. This should be NFC, but given the amount of #ifdeffing here, it may not be. So will watch the buildbots closely. Also, as this is purely moving existing code around, I plan to ignore the lint errors. Reviewers: compnerd, miyuki, mstorsjo Subscribers: libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75705 Added: Modified: libunwind/src/AddressSpace.hpp Removed: diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 2f68d6525a0f..d4d66ad74ff6 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -409,24 +409,6 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, // that don't help at all. #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) -struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { - LocalAddressSpace *addressSpace; - UnwindInfoSections *sects; - uintptr_t targetAddr; -}; - -int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { - auto cbdata = static_cast(data); - bool found_obj = false; - bool found_hdr = false; - - assert(cbdata); - assert(cbdata->sects); - - if (cbdata->targetAddr < pinfo->dlpi_addr) { -return false; - } - #if !defined(Elf_Half) typedef ElfW(Half) Elf_Half; #endif @@ -437,8 +419,8 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { typedef ElfW(Addr) Elf_Addr; #endif +static Elf_Addr calculateImageBase(struct dl_phdr_info *pinfo) { Elf_Addr image_base = pinfo->dlpi_addr; - #if defined(__ANDROID__) && __ANDROID_API__ < 18 if (image_base == 0) { // Normally, an image base of 0 indicates a non-PIE executable. On @@ -456,11 +438,32 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { } } #endif + return image_base; +} - #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) +struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { + LocalAddressSpace *addressSpace; + UnwindInfoSections *sects; + uintptr_t targetAddr; +}; + +#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if !defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) - #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." +#error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif + +int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { + auto *cbdata = static_cast(data); + bool found_obj = false; + bool found_hdr = false; + + assert(cbdata); + assert(cbdata->sects); + + if (cbdata->targetAddr < pinfo->dlpi_addr) +return 0; + + Elf_Addr image_base = calculateImageBase(pinfo); size_t object_length; for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { @@ -492,7 +495,25 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { } else { return false; } - #else // defined(_LIBUNWIND_ARM_EHABI) +} + +#else // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND) +// Given all the #ifdef's above, the code here is for +// defined(LIBUNWIND_ARM_EHABI) + +int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { + auto *cbdata = static_cast(data); + bool found_obj = false; + bool found_hdr = false; + + assert(cbdata); + assert(cbdata->sects); + + if (cbdata->targetAddr < pinfo->dlpi_addr) +return 0; + + Elf_Addr image_base = calculateImageBase(pinfo); + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; if (phdr->p_type == PT_LOAD) { @@ -508,8 +529,8 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { } } return found_obj && found_hdr; - #endif } +#endif // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND) #endif // defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] d67cf7a - Rework findUnwindSectionsByPhdr to be more optimal.
Author: Sterling Augustine Date: 2020-03-10T10:35:15-07:00 New Revision: d67cf7a0a970df6e69db437514bf61a2ab283e67 URL: https://github.com/llvm/llvm-project/commit/d67cf7a0a970df6e69db437514bf61a2ab283e67 DIFF: https://github.com/llvm/llvm-project/commit/d67cf7a0a970df6e69db437514bf61a2ab283e67.diff LOG: Rework findUnwindSectionsByPhdr to be more optimal. Summary: - Executable segment is usually segment 3. Look there for the address first. - GNU_EH_FRAME_HEADER segment is usually near the end. Iterate from the end. - Exit early if both phdrs have been found. This is the last cl before a patch to cache the information this function finds. Subscribers: libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75781 Added: Modified: libunwind/src/AddressSpace.hpp Removed: diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index d4d66ad74ff6..83af9aeaef77 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -452,31 +452,38 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif -int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { - auto *cbdata = static_cast(data); - bool found_obj = false; - bool found_hdr = false; - - assert(cbdata); - assert(cbdata->sects); +static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, + dl_iterate_cb_data *cbdata) { + if (phdr->p_type == PT_LOAD) { +uintptr_t begin = image_base + phdr->p_vaddr; +uintptr_t end = begin + phdr->p_memsz; +if (cbdata->targetAddr >= begin && cbdata->targetAddr < end) { + cbdata->sects->dso_base = begin; + cbdata->sects->dwarf_section_length = phdr->p_memsz; + return true; +} + } + return false; +} - if (cbdata->targetAddr < pinfo->dlpi_addr) +int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { + auto cbdata = static_cast(data); + if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr) return 0; Elf_Addr image_base = calculateImageBase(pinfo); - size_t object_length; + bool found_obj = false; + bool found_hdr = false; - for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { -const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; -if (phdr->p_type == PT_LOAD) { - uintptr_t begin = image_base + phdr->p_vaddr; - uintptr_t end = begin + phdr->p_memsz; - if (cbdata->targetAddr >= begin && cbdata->targetAddr < end) { -cbdata->sects->dso_base = begin; -object_length = phdr->p_memsz; -found_obj = true; - } -} else if (phdr->p_type == PT_GNU_EH_FRAME) { + // Third phdr is usually the executable phdr. + if (pinfo->dlpi_phnum > 2) +found_obj = checkAddrInSegment(&pinfo->dlpi_phdr[2], image_base, cbdata); + + // PT_GNU_EH_FRAME is usually near the end. Iterate backward. We already know + // that there is one or more phdrs. + for (Elf_Half i = pinfo->dlpi_phnum; i > 0; i--) { +const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i - 1]; +if (!found_hdr && phdr->p_type == PT_GNU_EH_FRAME) { EHHeaderParser::EHHeaderInfo hdrInfo; uintptr_t eh_frame_hdr_start = image_base + phdr->p_vaddr; cbdata->sects->dwarf_index_section = eh_frame_hdr_start; @@ -486,15 +493,14 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { hdrInfo); if (found_hdr) cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; +} else if (!found_obj) { + found_obj = checkAddrInSegment(phdr, image_base, cbdata); } +if (found_obj && found_hdr) + return 1; } - - if (found_obj && found_hdr) { -cbdata->sects->dwarf_section_length = object_length; -return true; - } else { -return false; - } + cbdata->sects->dwarf_section_length = 0; + return 0; } #else // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 8ffdabd - Lazily save initialState of registers during unwind.
Author: Sterling Augustine Date: 2020-03-11T10:13:33-07:00 New Revision: 8ffdabdb61e1e2251b07ee93a4806cde1890f47d URL: https://github.com/llvm/llvm-project/commit/8ffdabdb61e1e2251b07ee93a4806cde1890f47d DIFF: https://github.com/llvm/llvm-project/commit/8ffdabdb61e1e2251b07ee93a4806cde1890f47d.diff LOG: Lazily save initialState of registers during unwind. Summary: Copying all of the saved register state on every entry to parseInstruction is a severe performance contraint, especially because most of this saved state is never used. On x86 linux this is about 560 bytes, and will be more on other platforms. When performance testing libunwind, this memcpy appears at the top of nearly all our tests. By only saving this state as needed, we see increasing in performance of around 2.5% for the ctak test here. https://github.com/clasp-developers/ctak Certain internal extremely exception-heavy tasks run in about 2/3 the time. Note that by stashing the new boolean inside what had been padding in the original structure, this uses no additional memory. Subscribers: fedor.sergeev, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75692 Added: Modified: libunwind/src/DwarfParser.hpp Removed: diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp index 2994bd7bb41f..4a64c219255c 100644 --- a/libunwind/src/DwarfParser.hpp +++ b/libunwind/src/DwarfParser.hpp @@ -77,6 +77,7 @@ class CFI_Parser { }; struct RegisterLocation { RegisterSavedWhere location; +bool initialStateSaved; int64_t value; }; /// Information about a frame layout and registers saved determined @@ -90,6 +91,40 @@ class CFI_Parser { bool registersInOtherRegisters; bool sameValueUsed; RegisterLocation savedRegisters[kMaxRegisterNumber + 1]; +enum class InitializeTime { kLazy, kNormal }; + +// When saving registers, this data structure is lazily initialized. +PrologInfo(InitializeTime IT = InitializeTime::kNormal) { + if (IT == InitializeTime::kNormal) +memset(this, 0, sizeof(*this)); +} +void checkSaveRegister(uint64_t reg, PrologInfo &initialState) { + if (!savedRegisters[reg].initialStateSaved) { +initialState.savedRegisters[reg] = savedRegisters[reg]; +savedRegisters[reg].initialStateSaved = true; + } +} +void setRegister(uint64_t reg, RegisterSavedWhere newLocation, + int64_t newValue, PrologInfo &initialState) { + checkSaveRegister(reg, initialState); + savedRegisters[reg].location = newLocation; + savedRegisters[reg].value = newValue; +} +void setRegisterLocation(uint64_t reg, RegisterSavedWhere newLocation, + PrologInfo &initialState) { + checkSaveRegister(reg, initialState); + savedRegisters[reg].location = newLocation; +} +void setRegisterValue(uint64_t reg, int64_t newValue, + PrologInfo &initialState) { + checkSaveRegister(reg, initialState); + savedRegisters[reg].value = newValue; +} +void restoreRegisterToInitialState(uint64_t reg, PrologInfo &initialState) { + if (savedRegisters[reg].initialStateSaved) +savedRegisters[reg] = initialState.savedRegisters[reg]; + // else the register still holds its initial state +} }; struct PrologInfoStackEntry { @@ -355,8 +390,6 @@ bool CFI_Parser::parseFDEInstructions(A &addressSpace, const FDE_Info &fdeInfo, const CIE_Info &cieInfo, pint_t upToPC, int arch, PrologInfo *results) { - // clear results - memset(results, '\0', sizeof(PrologInfo)); PrologInfoStackEntry *rememberStack = NULL; // parse CIE then FDE instructions @@ -390,7 +423,9 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions, int arch, PrologInfo *results) { pint_t p = instructions; pint_t codeOffset = 0; - PrologInfo initialState = *results; + // initialState initialized as registers in results are modified. Use + // PrologInfo accessor functions to avoid reading uninitialized data. + PrologInfo initialState(PrologInfo::InitializeTime::kLazy); _LIBUNWIND_TRACE_DWARF("parseInstructions(instructions=0x%0" PRIx64 ")\n", static_cast(instructionsEnd)); @@ -443,8 +478,7 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions, "malformed DW_CFA_offset_extended DWARF unwind, reg too big"); return false; } - results->savedRegisters[reg].location = kRegisterInCFA; - results->savedRegisters[reg].value = offset; + results->setRegister(reg, kRegisterInCFA, offset, initialState); _LIBUNWIND_TRACE_DW
[libunwind] c53c205 - Cache uwnind frame headers as they are found.
Author: Sterling Augustine Date: 2020-03-12T10:53:33-07:00 New Revision: c53c2058ffb8ff877702bb2dded31c85c1dfe66d URL: https://github.com/llvm/llvm-project/commit/c53c2058ffb8ff877702bb2dded31c85c1dfe66d DIFF: https://github.com/llvm/llvm-project/commit/c53c2058ffb8ff877702bb2dded31c85c1dfe66d.diff LOG: Cache uwnind frame headers as they are found. Summary: This improves unwind performance quite substantially, and follows a somewhat similar approach used in libgcc_s as described in the thread here: https://gcc.gnu.org/ml/gcc/2005-02/msg00625.html On certain extremely exception heavy internal tests, the time drops from about 80 minutes to about five minutes. Subscribers: libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D75954 Added: libunwind/src/FrameHeaderCache.hpp libunwind/test/frameheadercache_test.pass.cpp Modified: libunwind/src/AddressSpace.hpp Removed: diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 83af9aeaef77..a4564cb67328 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -452,6 +452,11 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data { #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." #endif +#include "FrameHeaderCache.hpp" + +// There should be just one of these per process. +static FrameHeaderCache ProcessFrameHeaderCache; + static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, dl_iterate_cb_data *cbdata) { if (phdr->p_type == PT_LOAD) { @@ -466,10 +471,13 @@ static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base, return false; } -int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { +int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size, + void *data) { auto cbdata = static_cast(data); if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr) return 0; + if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data)) +return 1; Elf_Addr image_base = calculateImageBase(pinfo); bool found_obj = false; @@ -496,8 +504,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) { } else if (!found_obj) { found_obj = checkAddrInSegment(phdr, image_base, cbdata); } -if (found_obj && found_hdr) +if (found_obj && found_hdr) { + ProcessFrameHeaderCache.add(cbdata->sects); return 1; +} } cbdata->sects->dwarf_section_length = 0; return 0; diff --git a/libunwind/src/FrameHeaderCache.hpp b/libunwind/src/FrameHeaderCache.hpp new file mode 100644 index ..813fcd408b26 --- /dev/null +++ b/libunwind/src/FrameHeaderCache.hpp @@ -0,0 +1,149 @@ +//===-FrameHeaderCache.hpp ===// +// +// 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 +// +// Cache the elf program headers necessary to unwind the stack more efficiently +// in the presence of many dsos. +// +//===--===// + +#ifndef __FRAMEHEADER_CACHE_HPP__ +#define __FRAMEHEADER_CACHE_HPP__ + +#include "config.h" +#include + +#ifdef _LIBUNWIND_DEBUG_FRAMEHEADER_CACHE +#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE0(x) _LIBUNWIND_LOG0(x) +#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE(msg, ...) \ + _LIBUNWIND_LOG(msg, __VA_ARGS__) +#else +#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE0(x) +#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE(msg, ...) +#endif + +// This cache should only be be used from within a dl_iterate_phdr callback. +// dl_iterate_phdr does the necessary synchronization to prevent problems +// with concurrent access via the libc load lock. Adding synchronization +// for other uses is possible, but not currently done. + +class _LIBUNWIND_HIDDEN FrameHeaderCache { + struct CacheEntry { +uintptr_t LowPC() { return Info.dso_base; }; +uintptr_t HighPC() { return Info.dso_base + Info.dwarf_section_length; }; +UnwindInfoSections Info; +CacheEntry *Next; + }; + + static const size_t kCacheEntryCount = 8; + + // Can't depend on the C++ standard library in libunwind, so use an array to + // allocate the entries, and two linked lists for ordering unused and recently + // used entries. FIXME: Would the the extra memory for a doubly-linked list + // be better than the runtime cost of traversing a very short singly-linked + // list on a cache miss? The entries themselves are all small and consecutive, + // so unlikely to cause page faults when following the pointers. The memory + // spent on additional pointers could also be spent
[libunwind] 3eef589 - Add a catch-all else case so any unanticipated configs pass this test.
Author: Sterling Augustine Date: 2020-03-12T11:55:10-07:00 New Revision: 3eef58991b26feb37aaae92d5b568b27fab84584 URL: https://github.com/llvm/llvm-project/commit/3eef58991b26feb37aaae92d5b568b27fab84584 DIFF: https://github.com/llvm/llvm-project/commit/3eef58991b26feb37aaae92d5b568b27fab84584.diff LOG: Add a catch-all else case so any unanticipated configs pass this test. Added: Modified: libunwind/test/frameheadercache_test.pass.cpp Removed: diff --git a/libunwind/test/frameheadercache_test.pass.cpp b/libunwind/test/frameheadercache_test.pass.cpp index ac75f7d0cb29..df0f926985d7 100644 --- a/libunwind/test/frameheadercache_test.pass.cpp +++ b/libunwind/test/frameheadercache_test.pass.cpp @@ -79,4 +79,6 @@ int main() { abort(); return 0; } +#else +int main() { return 0; } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 3758b85 - Only run frameheader_cache_test.pass.cpp on x86_64.
Author: Sterling Augustine Date: 2020-03-12T18:14:22-07:00 New Revision: 3758b858ef3b39b3081bf9a567ead8bc69c9a208 URL: https://github.com/llvm/llvm-project/commit/3758b858ef3b39b3081bf9a567ead8bc69c9a208 DIFF: https://github.com/llvm/llvm-project/commit/3758b858ef3b39b3081bf9a567ead8bc69c9a208.diff LOG: Only run frameheader_cache_test.pass.cpp on x86_64. Although there is nothing architecturally specific, the ifdef chains are too complicated otherwise. Added: Modified: libunwind/test/frameheadercache_test.pass.cpp Removed: diff --git a/libunwind/test/frameheadercache_test.pass.cpp b/libunwind/test/frameheadercache_test.pass.cpp index df0f926985d7..9397e70d66cb 100644 --- a/libunwind/test/frameheadercache_test.pass.cpp +++ b/libunwind/test/frameheadercache_test.pass.cpp @@ -3,6 +3,11 @@ #include "../src/config.h" // Only run this test under supported configurations. +// The frame header cache should work fine for other architectures, +// but the #ifdefs end up being even more complicated than this. + +#ifdef __x86_64__ + // This #if chain is ugly, but see the comments in AddressSpace.hpp for // the reasoning. @@ -82,3 +87,6 @@ int main() { #else int main() { return 0; } #endif +#else +int main() { return 0;} +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307315 - Allow CompilerInvocations to generate .d files.
Author: saugustine Date: Thu Jul 6 14:02:52 2017 New Revision: 307315 URL: http://llvm.org/viewvc/llvm-project?rev=307315&view=rev Log: Allow CompilerInvocations to generate .d files. Summary: Most clang tools should ignore the -M family of options because one wouldn't want them to generate a new dependency (.d) file. However, some tools may want this dependency file. This patch creates a mechanism for them to do this. This implementation just plumbs a boolean down several layers of calls. Each of the modified calls has several call sites, and so a single member variable or new API entry point won't work. An alternative would be to write a function to filter the -M family of arguments out of CC1Args, and have each caller call that function by hand before calling newInvocation, Invocation::run, or buildAstFromCodeWithArgs. This is a more complicated and error-prone solution. Why burden all the callers to remember to use this function? But I could rewrite this patch to use that method if that is deemed more appropriate. Reviewers: klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34304 Modified: cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h cfe/trunk/include/clang/Tooling/Tooling.h cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h?rev=307315&r1=307314&r2=307315&view=diff == --- cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h (original) +++ cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h Thu Jul 6 14:02:52 2017 @@ -44,6 +44,10 @@ ArgumentsAdjuster getClangSyntaxOnlyAdju /// arguments. ArgumentsAdjuster getClangStripOutputAdjuster(); +/// \brief Gets an argument adjuster which removes dependency-file +/// related command line arguments. +ArgumentsAdjuster getClangStripDependencyFileAdjuster(); + enum class ArgumentInsertPosition { BEGIN, END }; /// \brief Gets an argument adjuster which inserts \p Extra arguments in the Modified: cfe/trunk/include/clang/Tooling/Tooling.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=307315&r1=307314&r2=307315&view=diff == --- cfe/trunk/include/clang/Tooling/Tooling.h (original) +++ cfe/trunk/include/clang/Tooling/Tooling.h Thu Jul 6 14:02:52 2017 @@ -202,12 +202,15 @@ buildASTFromCode(const Twine &Code, cons /// \param PCHContainerOps The PCHContainerOperations for loading and creating /// clang modules. /// +/// \param Adjuster A function to filter the command line arguments as specified. +/// /// \return The resulting AST or null if an error occurred. std::unique_ptr buildASTFromCodeWithArgs( const Twine &Code, const std::vector &Args, const Twine &FileName = "input.cc", const Twine &ToolName = "clang-tool", std::shared_ptr PCHContainerOps = -std::make_shared()); + std::make_shared(), +ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster()); /// \brief Utility to run a FrontendAction in a single clang invocation. class ToolInvocation { Modified: cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp?rev=307315&r1=307314&r2=307315&view=diff == --- cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp (original) +++ cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp Thu Jul 6 14:02:52 2017 @@ -42,7 +42,7 @@ ArgumentsAdjuster getClangStripOutputAdj AdjustedArgs.push_back(Args[i]); if (Arg == "-o") { -// Output is specified as -o foo. Skip the next argument also. +// Output is specified as -o foo. Skip the next argument too. ++i; } // Else, the output is specified as -ofoo. Just do nothing. @@ -51,6 +51,26 @@ ArgumentsAdjuster getClangStripOutputAdj }; } +ArgumentsAdjuster getClangStripDependencyFileAdjuster() { + return [](const CommandLineArguments &Args, StringRef /*unused*/) { +CommandLineArguments AdjustedArgs; +for (size_t i = 0, e = Args.size(); i < e; ++i) { + StringRef Arg = Args[i]; + // All dependency-file options begin with -M. These include -MM, + // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD. + if (!Arg.startswith("-M")) +AdjustedArgs.push_back(Args[i]); + + if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") || + (Arg == "-MD") || (Arg == "-MMD")) { +// Output is specified as -MX foo. Skip the next argument also. +++i; + } +} +return AdjustedArgs; + }; +} + ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
r307329 - This call-site should have been updated as part of D34304.
Author: saugustine Date: Thu Jul 6 15:47:19 2017 New Revision: 307329 URL: http://llvm.org/viewvc/llvm-project?rev=307329&view=rev Log: This call-site should have been updated as part of D34304. Summary: Use an argument adjuster to preserve behavior inadvertantly changed by D34304. Reviewers: klimek Differential Revision: https://reviews.llvm.org/D35095 Modified: cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=307329&r1=307328&r2=307329&view=diff == --- cfe/trunk/lib/Tooling/Tooling.cpp (original) +++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Jul 6 15:47:19 2017 @@ -139,9 +139,11 @@ bool runToolOnCodeWithArgs( OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); - ToolInvocation Invocation(getSyntaxOnlyToolArgs(ToolName, Args, FileNameRef), -ToolAction, Files.get(), -std::move(PCHContainerOps)); + ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(); + ToolInvocation Invocation( + getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileNameRef), FileNameRef), + ToolAction, Files.get(), + std::move(PCHContainerOps)); SmallString<1024> CodeStorage; InMemoryFileSystem->addFile(FileNameRef, 0, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308043 - Prevent ClangTools from generating dependency files.
Author: saugustine Date: Fri Jul 14 11:33:30 2017 New Revision: 308043 URL: http://llvm.org/viewvc/llvm-project?rev=308043&view=rev Log: Prevent ClangTools from generating dependency files. D34304 created a way for ToolInvocations to conditionally generate dependency files, and updated call sites to preserve the old behavior of not generating them by default. CompilerInvocations... Summary: ...are yet another call-path that needs updating to preserve the old behavior. Reviewers: klimek, echristo Reviewed By: echristo Subscribers: echristo, cfe-commits Differential Revision: https://reviews.llvm.org/D35131 Modified: cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=308043&r1=308042&r2=308043&view=diff == --- cfe/trunk/lib/Tooling/Tooling.cpp (original) +++ cfe/trunk/lib/Tooling/Tooling.cpp Fri Jul 14 11:33:30 2017 @@ -336,6 +336,7 @@ ClangTool::ClangTool(const CompilationDa OverlayFileSystem->pushOverlay(InMemoryFileSystem); appendArgumentsAdjuster(getClangStripOutputAdjuster()); appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); + appendArgumentsAdjuster(getClangStripDependencyFileAdjuster()); } ClangTool::~ClangTool() {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Getting fully qualified names of random qualtypes
As requested on cfe-dev, enclosed is a patch (that needs some style-related work) to calculate the complete fully qualified name of arbitrary Qualtypes, including recursively expanding template parameters and subtypes. Seems to me like it follows most of the conventions described here: http://llvm.org/docs/CodingStandards.html but I'm told it needs more work. Happy to oblige. Index: include/clang/Tooling/Core/QualTypeNames.h === --- include/clang/Tooling/Core/QualTypeNames.h (revision 0) +++ include/clang/Tooling/Core/QualTypeNames.h (working copy) @@ -0,0 +1,152 @@ +//===--- QualTypeNames.h - Generate Complete QualType Names *- C++ -*-===// +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +// ===--===// +// +// \file +// Functionality to generate the fully-qualified names of QualTypes, +// including recursively expanding any subtypes and template +// parameters. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPE_NAMES_H +#define LLVM_CLANG_TOOLING_CORE_QUALTYPE_NAMES_H + +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" + +namespace clang { +class ASTContext; +class Expr; +class Decl; +class DeclContext; +class DeclarationName; +class GlobalDecl; +class FunctionDecl; +class IntegerLiteral; +class NamedDecl; +class NamespaceDecl; +class NestedNameSpecifier; +class QualType; +class Sema; +class TagDecl; +class TemplateDecl; +class Type; +class TypedefNameDecl; + +///\brief Class containing static utility functions analizing ASTNodes or +/// types. +namespace Analyze { + +///\brief Return true if the class or template is declared directly in the +/// std namespace (modulo inline namespace). +/// +///\param[in] decl - The declaration being analyzed. +bool IsStdClass(const clang::NamedDecl &decl); +} + +///\brief Class containing static utility functions transforming AST nodes or +/// types. +/// +namespace Transform { + +///\brief Class containing the information on how to configure the +/// transformation +/// +struct Config { + typedef llvm::SmallSet SkipCollection; + typedef const clang::Type cType; + typedef llvm::DenseMap ReplaceCollection; + + SkipCollection m_toSkip; + ReplaceCollection m_toReplace; + + ///\brief Returns the number of default argument that should be dropped. + /// from the name of the template instances. + /// + ///\param[in] templateDecl - The declaration being analyzed. + unsigned int DropDefaultArg(clang::TemplateDecl &templateDecl) const; + + bool empty() const { return m_toSkip.size() == 0 && m_toReplace.empty(); } +}; + +///\brief Remove one layer of sugar, but only some kinds. +bool SingleStepPartiallyDesugarType(clang::QualType &QT, +const clang::ASTContext &C); + +///\brief "Desugars" a type while skipping the ones in the set. +/// +/// Desugars a given type recursively until strips all sugar or until gets a +/// sugared type, which is to be skipped. +///\param[in] Ctx - The ASTContext. +///\param[in] QT - The type to be partially desugared. +///\param[in] TypeConfig - The set of sugared types which shouldn't be +///desugared and those that should be replaced. +///\param[in] fullyQualify - if true insert Elaborated where needed. +///\returns Partially desugared QualType +/// +clang::QualType GetPartiallyDesugaredType(const clang::ASTContext &Ctx, + clang::QualType QT, + const Config &TypeConfig, + bool fullyQualify = true); +} + +namespace TypeName { +///\brief Convert the type into one with fully qualified template +/// arguments. +///\param[in] QT - the type for which the fully qualified type will be +/// returned. +///\param[in] Ctx - the ASTContext to be used. +clang::QualType GetFullyQualifiedType(clang::QualType QT, + const clang::ASTContext &Ctx); + +///\brief Get the fully qualified name for a type. This includes full +/// qualification of all template parameters etc. +/// +///\param[in] QT - the type for which the fully qualified name will be +/// returned. +///\param[in] Ctx - the ASTContext to be used. +std::string GetFullyQualifiedName(clang::QualType QT, + const clang::ASTContext &Ctx); + +///\brief Create a NestedNameSpecifier for Namesp and its enclosing +/// scopes. +/// +///\param[in] Ctx - the AST Context to be used. +///\param[in] Namesp - the NamespaceDecl for which a NestedNameSpecifier +/// is requested. +clang::NestedNameSpecifier * +CreateNestedNameSpecifier(const clang::ASTContext &Ctx, + const clang::NamespaceDecl *Namesp);
Re: [PATCH] D14459: Adjust printQualifiedName to handle unscoped enums in a way similar to anonymous namespaces.
saugustine updated this revision to Diff 39605. saugustine added a comment. Handle unscoped enum with name. Also add test cases. http://reviews.llvm.org/D14459 Files: lib/AST/Decl.cpp unittests/AST/NamedDeclPrinterTest.cpp Index: unittests/AST/NamedDeclPrinterTest.cpp === --- unittests/AST/NamedDeclPrinterTest.cpp +++ unittests/AST/NamedDeclPrinterTest.cpp @@ -131,3 +131,45 @@ "A", "A")); } + +TEST(NamedDeclPrinter, TestUnscopedUnnamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum { A };", +"A", +"A")); +} + +TEST(NamedDeclPrinter, TestNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum X { A };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestScopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum class X { A };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestClassWithUnscopedUnnamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum { A }; };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestClassWithUnscopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum Y { A }; };", +"A", +"X::Y::A")); +} + +TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum class Y { A }; };", +"A", +"X::Y::A")); +} Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -1430,6 +1430,15 @@ } } OS << ')'; +} else if (const EnumDecl *ED = dyn_cast(*I)) { + // C++ [dcl.enum]p10: Each enum-name and each unscoped + // enumerator is declared in the scope that immediately contains + // the enum-specifier. Each scoped enumerator is declared in the + // scope of the enumeration. + if (ED->isScoped() || ED->getIdentifier()) +OS << *ED; + else +continue; } else { OS << *cast(*I); } Index: unittests/AST/NamedDeclPrinterTest.cpp === --- unittests/AST/NamedDeclPrinterTest.cpp +++ unittests/AST/NamedDeclPrinterTest.cpp @@ -131,3 +131,45 @@ "A", "A")); } + +TEST(NamedDeclPrinter, TestUnscopedUnnamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum { A };", +"A", +"A")); +} + +TEST(NamedDeclPrinter, TestNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum X { A };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestScopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"enum class X { A };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestClassWithUnscopedUnnamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum { A }; };", +"A", +"X::A")); +} + +TEST(NamedDeclPrinter, TestClassWithUnscopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum Y { A }; };", +"A", +"X::Y::A")); +} + +TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) { + ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches( +"class X { enum class Y { A }; };", +"A", +"X::Y::A")); +} Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -1430,6 +1430,15 @@ } } OS << ')'; +} else if (const EnumDecl *ED = dyn_cast(*I)) { + // C++ [dcl.enum]p10: Each enum-name and each unscoped + // enumerator is declared in the scope that immediately contains + // the enum-specifier. Each scoped enumerator is declared in the + // scope of the enumeration. + if (ED->isScoped() || ED->getIdentifier()) +OS << *ED; + else +continue; } else { OS << *cast(*I); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine updated this revision to Diff 46680. saugustine marked 19 inline comments as done. saugustine added a comment. - Update docs. Handle keywords and anonymous namespaces. - Address code review issues. Cleanup many http://reviews.llvm.org/D15861 Files: include/clang/Tooling/Core/QualTypeNames.h lib/Tooling/Core/CMakeLists.txt lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/CMakeLists.txt unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- /dev/null +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -0,0 +1,166 @@ +//===- unittest/Tooling/QualTypeNameTest.cpp --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/Core/QualTypeNames.h" +#include "TestVisitor.h" +using namespace clang; + +namespace { +struct TypeNameVisitor : TestVisitor { + llvm::StringMap ExpectedQualTypeNames; + + // ValueDecls are the least-derived decl with both a qualtype and a + // name. + bool traverseDecl(Decl *D) { +return true; // Always continue + } + + bool VisitValueDecl(const ValueDecl *VD) { +std::string ExpectedName = +ExpectedQualTypeNames.lookup(VD->getNameAsString()); +if (ExpectedName != "") { + std::string ActualName = + TypeName::getFullyQualifiedName(VD->getType(), *Context); + if (ExpectedName != ActualName) { +// A custom message makes it much easier to see what declaration +// failed compared to EXPECT_EQ. +EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for " + << VD->getQualifiedNameAsString() << std::endl + << " Actual: " << ActualName << std::endl + << " Exepcted: " << ExpectedName; + } +} +return true; + } +}; + +// named namespaces inside anonymous namespaces + +TEST(QualTypeNameTest, getFullyQualifiedName) { + TypeNameVisitor Visitor; + // Simple case to test the test framework itself. + Visitor.ExpectedQualTypeNames["CheckInt"] = "int"; + + // Keeping the names of the variables whose types we check unique + // within the entire test--regardless of their own scope--makes it + // easier to diagnose test failures. + + // Simple namespace qualifier + Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0"; + // Lookup up the enclosing scopes, then down another one. (These + // appear as elaborated type in the AST. In that case--even if + // policy.SuppressScope = 0--qual_type.getAsString(policy) only + // gives the name as it appears in the source, not the full name. + Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1"; + // Template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckC"] = + "A::B::Template0"; + // Recursive template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckD"] = + "A::B::Template0, " + "A::B::Template0 >"; + // Variadic Template expansion. + Visitor.ExpectedQualTypeNames["CheckE"] = + "A::Variadic, " + "A::B::Template1, A::B::C::MyInt>"; + // Using declarations should be fully expanded. + Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0"; + // Elements found within "using namespace foo;" should be fully + // expanded. + Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt"; + // Type inside function + Visitor.ExpectedQualTypeNames["CheckH"] = "struct X"; + // Anonymous Namespaces + Visitor.ExpectedQualTypeNames["CheckI"] = "aClass"; + // Keyword inclusion with namespaces + Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct"; + // Anonymous Namespaces nested in named namespaces and vice-versa. + Visitor.ExpectedQualTypeNames["CheckK"] = "D::aStruct"; + // Namespace alias + Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; + Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = + "template Foo::non_dependent_type"; + Visitor.runOver( + "int CheckInt;\n" + "namespace A {\n" + " namespace B {\n" + " class Class0 { };\n" + " namespace C {\n" + " typedef int MyInt;" + " }\n" + " template class Template0;" + " template class Template1;" + " typedef B::Class0 AnotherClass;\n" + " void Function1(Template0 CheckC);\n" + " void Function2(Template0,\n" + "Template0 > CheckD);\n" + " }\n" + "template class Variadic {};\n" + "Variadic, " + " B::Template1, " + " B::C::MyInt > CheckE;\n" + " namespace BC = B::C;\n" + " BC::MyInt CheckL;\n" + "}\n" + "using A::B::Class0;\n" + "void Function(Class0 CheckF);\n" + "using name
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
Richard, Please take another look when you get a chance. Thanks. On Tue, Feb 2, 2016 at 11:14 AM, Sterling Augustine wrote: > saugustine updated this revision to Diff 46680. > saugustine marked 19 inline comments as done. > saugustine added a comment. > > - Update docs. Handle keywords and anonymous namespaces. > - Address code review issues. Cleanup many > > > http://reviews.llvm.org/D15861 > > Files: > include/clang/Tooling/Core/QualTypeNames.h > lib/Tooling/Core/CMakeLists.txt > lib/Tooling/Core/QualTypeNames.cpp > unittests/Tooling/CMakeLists.txt > unittests/Tooling/QualTypeNamesTest.cpp > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine updated this revision to Diff 47267. saugustine added a comment. - Privatize all functions but getFullyQualifiedName. http://reviews.llvm.org/D15861 Files: include/clang/Tooling/Core/QualTypeNames.h lib/Tooling/Core/CMakeLists.txt lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/CMakeLists.txt unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- /dev/null +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -0,0 +1,166 @@ +//===- unittest/Tooling/QualTypeNameTest.cpp --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/Core/QualTypeNames.h" +#include "TestVisitor.h" +using namespace clang; + +namespace { +struct TypeNameVisitor : TestVisitor { + llvm::StringMap ExpectedQualTypeNames; + + // ValueDecls are the least-derived decl with both a qualtype and a + // name. + bool traverseDecl(Decl *D) { +return true; // Always continue + } + + bool VisitValueDecl(const ValueDecl *VD) { +std::string ExpectedName = +ExpectedQualTypeNames.lookup(VD->getNameAsString()); +if (ExpectedName != "") { + std::string ActualName = + TypeName::getFullyQualifiedName(VD->getType(), *Context); + if (ExpectedName != ActualName) { +// A custom message makes it much easier to see what declaration +// failed compared to EXPECT_EQ. +EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for " + << VD->getQualifiedNameAsString() << std::endl + << " Actual: " << ActualName << std::endl + << " Exepcted: " << ExpectedName; + } +} +return true; + } +}; + +// named namespaces inside anonymous namespaces + +TEST(QualTypeNameTest, getFullyQualifiedName) { + TypeNameVisitor Visitor; + // Simple case to test the test framework itself. + Visitor.ExpectedQualTypeNames["CheckInt"] = "int"; + + // Keeping the names of the variables whose types we check unique + // within the entire test--regardless of their own scope--makes it + // easier to diagnose test failures. + + // Simple namespace qualifier + Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0"; + // Lookup up the enclosing scopes, then down another one. (These + // appear as elaborated type in the AST. In that case--even if + // policy.SuppressScope = 0--qual_type.getAsString(policy) only + // gives the name as it appears in the source, not the full name. + Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1"; + // Template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckC"] = + "A::B::Template0"; + // Recursive template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckD"] = + "A::B::Template0, " + "A::B::Template0 >"; + // Variadic Template expansion. + Visitor.ExpectedQualTypeNames["CheckE"] = + "A::Variadic, " + "A::B::Template1, A::B::C::MyInt>"; + // Using declarations should be fully expanded. + Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0"; + // Elements found within "using namespace foo;" should be fully + // expanded. + Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt"; + // Type inside function + Visitor.ExpectedQualTypeNames["CheckH"] = "struct X"; + // Anonymous Namespaces + Visitor.ExpectedQualTypeNames["CheckI"] = "aClass"; + // Keyword inclusion with namespaces + Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct"; + // Anonymous Namespaces nested in named namespaces and vice-versa. + Visitor.ExpectedQualTypeNames["CheckK"] = "D::aStruct"; + // Namespace alias + Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; + Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = + "template Foo::non_dependent_type"; + Visitor.runOver( + "int CheckInt;\n" + "namespace A {\n" + " namespace B {\n" + " class Class0 { };\n" + " namespace C {\n" + " typedef int MyInt;" + " }\n" + " template class Template0;" + " template class Template1;" + " typedef B::Class0 AnotherClass;\n" + " void Function1(Template0 CheckC);\n" + " void Function2(Template0,\n" + "Template0 > CheckD);\n" + " }\n" + "template class Variadic {};\n" + "Variadic, " + " B::Template1, " + " B::C::MyInt > CheckE;\n" + " namespace BC = B::C;\n" + " BC::MyInt CheckL;\n" + "}\n" + "using A::B::Class0;\n" + "void Function(Class0 CheckF);\n" + "using namespace A::B::C;\n" + "void Function(MyInt CheckG);\n" + "void f() {\n" + " str
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine updated this revision to Diff 47343. saugustine added a comment. - Cleanup dyn_cast usage inside QualTypeNames. http://reviews.llvm.org/D15861 Files: include/clang/Tooling/Core/QualTypeNames.h lib/Tooling/Core/CMakeLists.txt lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/CMakeLists.txt unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- /dev/null +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -0,0 +1,166 @@ +//===- unittest/Tooling/QualTypeNameTest.cpp --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/Core/QualTypeNames.h" +#include "TestVisitor.h" +using namespace clang; + +namespace { +struct TypeNameVisitor : TestVisitor { + llvm::StringMap ExpectedQualTypeNames; + + // ValueDecls are the least-derived decl with both a qualtype and a + // name. + bool traverseDecl(Decl *D) { +return true; // Always continue + } + + bool VisitValueDecl(const ValueDecl *VD) { +std::string ExpectedName = +ExpectedQualTypeNames.lookup(VD->getNameAsString()); +if (ExpectedName != "") { + std::string ActualName = + TypeName::getFullyQualifiedName(VD->getType(), *Context); + if (ExpectedName != ActualName) { +// A custom message makes it much easier to see what declaration +// failed compared to EXPECT_EQ. +EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for " + << VD->getQualifiedNameAsString() << std::endl + << " Actual: " << ActualName << std::endl + << " Exepcted: " << ExpectedName; + } +} +return true; + } +}; + +// named namespaces inside anonymous namespaces + +TEST(QualTypeNameTest, getFullyQualifiedName) { + TypeNameVisitor Visitor; + // Simple case to test the test framework itself. + Visitor.ExpectedQualTypeNames["CheckInt"] = "int"; + + // Keeping the names of the variables whose types we check unique + // within the entire test--regardless of their own scope--makes it + // easier to diagnose test failures. + + // Simple namespace qualifier + Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0"; + // Lookup up the enclosing scopes, then down another one. (These + // appear as elaborated type in the AST. In that case--even if + // policy.SuppressScope = 0--qual_type.getAsString(policy) only + // gives the name as it appears in the source, not the full name. + Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1"; + // Template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckC"] = + "A::B::Template0"; + // Recursive template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckD"] = + "A::B::Template0, " + "A::B::Template0 >"; + // Variadic Template expansion. + Visitor.ExpectedQualTypeNames["CheckE"] = + "A::Variadic, " + "A::B::Template1, A::B::C::MyInt>"; + // Using declarations should be fully expanded. + Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0"; + // Elements found within "using namespace foo;" should be fully + // expanded. + Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt"; + // Type inside function + Visitor.ExpectedQualTypeNames["CheckH"] = "struct X"; + // Anonymous Namespaces + Visitor.ExpectedQualTypeNames["CheckI"] = "aClass"; + // Keyword inclusion with namespaces + Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct"; + // Anonymous Namespaces nested in named namespaces and vice-versa. + Visitor.ExpectedQualTypeNames["CheckK"] = "D::aStruct"; + // Namespace alias + Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; + Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = + "template Foo::non_dependent_type"; + Visitor.runOver( + "int CheckInt;\n" + "namespace A {\n" + " namespace B {\n" + " class Class0 { };\n" + " namespace C {\n" + " typedef int MyInt;" + " }\n" + " template class Template0;" + " template class Template1;" + " typedef B::Class0 AnotherClass;\n" + " void Function1(Template0 CheckC);\n" + " void Function2(Template0,\n" + "Template0 > CheckD);\n" + " }\n" + "template class Variadic {};\n" + "Variadic, " + " B::Template1, " + " B::C::MyInt > CheckE;\n" + " namespace BC = B::C;\n" + " BC::MyInt CheckL;\n" + "}\n" + "using A::B::Class0;\n" + "void Function(Class0 CheckF);\n" + "using namespace A::B::C;\n" + "void Function(MyInt CheckG);\n" + "void f() {\n" + " struct X
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
I've updated the change. Would you mind checking it in? I'll look into switching the implementations shortly. On Tue, Feb 9, 2016 at 11:02 AM, Sterling Augustine wrote: > saugustine updated this revision to Diff 47343. > saugustine added a comment. > > - Cleanup dyn_cast usage inside QualTypeNames. > > > http://reviews.llvm.org/D15861 > > Files: > include/clang/Tooling/Core/QualTypeNames.h > lib/Tooling/Core/CMakeLists.txt > lib/Tooling/Core/QualTypeNames.cpp > unittests/Tooling/CMakeLists.txt > unittests/Tooling/QualTypeNamesTest.cpp > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17214: Stop using "template" when printing qualtype names
saugustine created this revision. saugustine added a reviewer: rsmith. saugustine added subscribers: cfe-commits, klimek. The keyword "template" isn't necessary when printing a fully-qualified qualtype name, and, in fact, results in a syntax error if one tries to use it. So stop printing it. http://reviews.llvm.org/D17214 Files: lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -85,7 +85,8 @@ // Namespace alias Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = - "template Foo::non_dependent_type"; + "Foo::non_dependent_type"; + Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.runOver( "int CheckInt;\n" "namespace A {\n" @@ -143,6 +144,11 @@ " var.dependent_type_var = 0;\n" "var.non_dependent_type_var = 0;\n" "}\n" + "class EnumScopeClass {\n" + "public:\n" + " enum AnEnum { ZERO, ONE };\n" + "};\n" + "EnumScopeClass::AnEnum AnEnumVar;\n" ); TypeNameVisitor Complex; Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -329,7 +329,8 @@ NestedNameSpecifier *createNestedNameSpecifier( const ASTContext &Ctx, const TypeDecl *TD, bool FullyQualify) { return NestedNameSpecifier::Create(Ctx, createOuterNNS(Ctx, TD, FullyQualify), - true /*Template*/, TD->getTypeForDecl()); + false /*No TemplateKeyword*/, + TD->getTypeForDecl()); } /// \brief Return the fully qualified type, including fully-qualified Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -85,7 +85,8 @@ // Namespace alias Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = - "template Foo::non_dependent_type"; + "Foo::non_dependent_type"; + Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.runOver( "int CheckInt;\n" "namespace A {\n" @@ -143,6 +144,11 @@ " var.dependent_type_var = 0;\n" "var.non_dependent_type_var = 0;\n" "}\n" + "class EnumScopeClass {\n" + "public:\n" + " enum AnEnum { ZERO, ONE };\n" + "};\n" + "EnumScopeClass::AnEnum AnEnumVar;\n" ); TypeNameVisitor Complex; Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -329,7 +329,8 @@ NestedNameSpecifier *createNestedNameSpecifier( const ASTContext &Ctx, const TypeDecl *TD, bool FullyQualify) { return NestedNameSpecifier::Create(Ctx, createOuterNNS(Ctx, TD, FullyQualify), - true /*Template*/, TD->getTypeForDecl()); + false /*No TemplateKeyword*/, + TD->getTypeForDecl()); } /// \brief Return the fully qualified type, including fully-qualified ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17214: Stop using "template" when printing qualtype names
saugustine added a comment. Thanks for the quick review. Assuming my response to your comment on line 138 is adequate, would you mind checking it in? Comment at: unittests/Tooling/QualTypeNamesTest.cpp:138 @@ -136,3 +137,3 @@ " typedef int non_dependent_type;\n" " dependent_type dependent_type_var;\n" " non_dependent_type non_dependent_type_var;\n" rnk wrote: > What's supposed to be printed for dependent_type_var? I'm not clever enough to generate one that compiles when it is at the end of the TU. When not at the end of the TU, this prints: FOO::dependent_type, omitting the keyword. I don't think this is worth adding as a test-case. http://reviews.llvm.org/D17214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17214: Stop using "template" when printing qualtype names
saugustine requested a review of this revision. saugustine added a comment. Would you mind reviewing this, and checking it in if you find it acceptable? http://reviews.llvm.org/D17214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
saugustine created this revision. saugustine added a reviewer: rnk. saugustine added a subscriber: cfe-commits. Herald added a subscriber: klimek. Treat qualifiers on elaborated types for qualtypenames appropriately. http://reviews.llvm.org/D20040 Files: lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,7 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +109,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,7 +383,10 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the Qualtype outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); @@ -395,8 +398,7 @@ true /*FullyQualified*/); // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { -PrefixQualifiers = QT.getLocalQualifiers(); + if (Prefix || Keyword != ETK_None) { QT = QualType(QT.getTypePtr(), 0); } Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,7 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +109,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,7 +383,10 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the Qualtype outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); @@ -395,8 +398,7 @@ true /*FullyQualified*/); // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { -PrefixQualifiers = QT.getLocalQualifiers(); + if (Prefix || Keyword != ETK_None) { QT = QualType(QT.getTypePtr(), 0); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
saugustine updated this revision to Diff 56634. saugustine marked an inline comment as done. saugustine added a comment. - Handle elaborated types even more cleanly. http://reviews.llvm.org/D20040 Files: lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,8 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; + Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +110,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " @@ -123,6 +126,8 @@ "void f() {\n" " struct X {} CheckH;\n" "}\n" + "struct X;\n" + "void f(const ::X* CheckN) {}\n" "namespace {\n" " class aClass {};\n" " aClass CheckI;\n" Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,22 +383,22 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the QualType outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); +assert(!QT.hasLocalQualifiers()); Keyword = ETypeInput->getKeyword(); } // Create a nested name specifier if needed (i.e. if the decl context // is not the global scope. Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(), true /*FullyQualified*/); - // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { -PrefixQualifiers = QT.getLocalQualifiers(); -QT = QualType(QT.getTypePtr(), 0); - } + QT = QualType(QT.getTypePtr(), 0); // In case of template specializations iterate over the arguments and // fully qualify them as well. @@ -408,14 +408,13 @@ // may pont to a template specialization) or Template // Specialization Type. We need to fully qualify their arguments. -Qualifiers Quals = QT.getLocalQualifiers(); const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr()); -QT = Ctx.getQualifiedType(TypePtr, Quals); +QT = Ctx.getQualifiedType(TypePtr, Qualifiers()); } if (Prefix || Keyword != ETK_None) { QT = Ctx.getElaboratedType(Keyword, Prefix, QT); -QT = Ctx.getQualifiedType(QT, PrefixQualifiers); } + QT = Ctx.getQualifiedType(QT, PrefixQualifiers); return QT; } Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,8 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; + Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +110,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " @@ -123,6 +126,8 @@ "void f() {\n" " struct X {} CheckH;\n" "}\n" + "struct X;\n" + "void f(const ::X* CheckN) {}\n" "namespace {\n" " class aClass {};\n" " aClass CheckI;\n" Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,22 +383,22 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the QualType outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKey
Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
saugustine added a comment. Thanks for the reviews. I believe I have addressed all issues. Take another look when you get the chance. Comment at: lib/Tooling/Core/QualTypeNames.cpp:401-403 @@ -397,6 +400,5 @@ // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { -PrefixQualifiers = QT.getLocalQualifiers(); + if (Prefix || Keyword != ETK_None) { QT = QualType(QT.getTypePtr(), 0); } rsmith wrote: > I find the way this code ensures that we preserve the qualifiers to be a > little subtle. It's not obvious to me that this does the right thing for a > case like > > struct X; > void f(const ::X x) {} > > ... where we have an `ElaboratedType` with no keyword, and for which we will > generate an empty `Prefix` -- it looks like we would lose the `const` on line > 392 and never add it back. > > Can you remove and re-add the qualifiers unconditionally? (That is, move this > removal of qualifiers from `QT` to after line 389, and move line 419 outside > the `if`.) I think that'll make the logic clearer. We can remove and put them back unconditionally, but we still need to condition getting a new elaborated type, because an assertion prevents creating an elaborated type without a prefix of an empty keyword. I'm not sure what you expect on the new example, but I have added it as a test case (as a pointer because the struct is incomplete). The result we produce in this case is "const X *", which I think is correct. Comment at: unittests/Tooling/QualTypeNamesTest.cpp:91 @@ -90,2 +90,3 @@ Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.runOver( dblaikie wrote: > What does this produce without your change? (what's the change causing to > happen?) Without the change, we get "A::B::Class0 *" with no "const". http://reviews.llvm.org/D20040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
saugustine added a comment. Thanks again. I've addressed the last little bits. Mind checking this in for me? http://reviews.llvm.org/D20040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
saugustine updated this revision to Diff 56643. saugustine marked 4 inline comments as done. saugustine added a comment. - Address remaining nits from review. http://reviews.llvm.org/D20040 Files: lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,8 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; + Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +110,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " @@ -123,6 +126,8 @@ "void f() {\n" " struct X {} CheckH;\n" "}\n" + "struct X;\n" + "void f(const ::X* CheckN) {}\n" "namespace {\n" " class aClass {};\n" " aClass CheckI;\n" Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,39 +383,37 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the QualType outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); + QT = QualType(QT.getTypePtr(), 0); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); +assert(!QT.hasLocalQualifiers()); Keyword = ETypeInput->getKeyword(); } // Create a nested name specifier if needed (i.e. if the decl context // is not the global scope. Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(), true /*FullyQualified*/); - // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { -PrefixQualifiers = QT.getLocalQualifiers(); -QT = QualType(QT.getTypePtr(), 0); - } - // In case of template specializations iterate over the arguments and // fully qualify them as well. if (isa(QT.getTypePtr()) || isa(QT.getTypePtr())) { // We are asked to fully qualify and we have a Record Type (which -// may pont to a template specialization) or Template +// may point to a template specialization) or Template // Specialization Type. We need to fully qualify their arguments. -Qualifiers Quals = QT.getLocalQualifiers(); const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr()); -QT = Ctx.getQualifiedType(TypePtr, Quals); +QT = QualType(TypePtr, 0); } if (Prefix || Keyword != ETK_None) { QT = Ctx.getElaboratedType(Keyword, Prefix, QT); -QT = Ctx.getQualifiedType(QT, PrefixQualifiers); } + QT = Ctx.getQualifiedType(QT, PrefixQualifiers); return QT; } Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,8 @@ "Foo::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; + Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -108,6 +110,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0,\n" "Template0 > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template class Variadic {};\n" "Variadic, " @@ -123,6 +126,8 @@ "void f() {\n" " struct X {} CheckH;\n" "}\n" + "struct X;\n" + "void f(const ::X* CheckN) {}\n" "namespace {\n" " class aClass {};\n" " aClass CheckI;\n" Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,39 +383,37 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the QualType outside of the + // elaborated type. R
Re: [PATCH] D21666: [Tooling] Add optional argument to getFullyQualifiedName to prepend "::".
saugustine accepted this revision. saugustine added a comment. This revision is now accepted and ready to land. This looks good and useful to me on the Tooling/Core side, but someone more familiar with the internals of NestedNamesSpecifiers should sign off on that portion. Also, I would probably add a test case for _Bool, which is a case that has confused other logic like this. I think it will work, but may as well include the proof. http://reviews.llvm.org/D21666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Getting fully qualified names of random qualtypes
I've finally had time to circle back to this, and just sent a version of this through reviews.llvm.org. It is highly edited, and we may as well start from scratch. In particular, my usecase has no need for all the desugaring, so I have removed it all. So no std::vector special casing, and no desugaring code even exists to simplify. Take a look if you get a chance. http://reviews.llvm.org/D15861 On Mon, Oct 26, 2015 at 6:03 AM, Benjamin Kramer wrote: > Some high level style comments: > > 1. Please convert the file to LLVM style for the things that > clang-format doesn't change. In particular PascalCase for all > variables and cameCase for all function names. > 2. We don't do author attribution in file comments, sorry. > 3. Try to avoid commented out/#if 0'd code. > 4. I'd really prefer to review this on reviews.llvm.org, makes things > easier. > > On the functional side: > 1. Why is std::vector and friends handled in a special case, don't we > want this for all default arguments? > 2. Can the desugaring code be simplified somehow? it feels extremely > repetitive and the corresponding code in Type.cpp looks much simpler? > Where is the additional complexity coming from? > > - Ben > > > On Sat, Oct 24, 2015 at 12:29 AM, Sterling Augustine via cfe-commits > wrote: > > As requested on cfe-dev, enclosed is a patch (that needs some > > style-related work) to calculate the complete fully qualified name of > > arbitrary Qualtypes, including recursively expanding template > > parameters and subtypes. > > > > Seems to me like it follows most of the conventions described here: > > > > http://llvm.org/docs/CodingStandards.html > > > > but I'm told it needs more work. Happy to oblige. > > > > ___ > > cfe-commits mailing list > > cfe-commits@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine updated this revision to Diff 44245. saugustine marked 4 inline comments as done. saugustine added a comment. - Update docs. Handle keywords and anonymous namespaces. http://reviews.llvm.org/D15861 Files: include/clang/Tooling/Core/QualTypeNames.h lib/Tooling/Core/CMakeLists.txt lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/CMakeLists.txt unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- /dev/null +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -0,0 +1,135 @@ +//===- unittest/Tooling/QualTypeNameTest.cpp --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/Core/QualTypeNames.h" +#include "TestVisitor.h" +using namespace clang; + +namespace { +struct TypeNameVisitor : TestVisitor { + llvm::StringMap ExpectedQualTypeNames; + + // ValueDecls are the least-derived decl with both a qualtype and a + // name. + bool traverseDecl(Decl *D) { +return true; // Always continue + } + + bool VisitValueDecl(const ValueDecl *VD) { +std::string ExpectedName = +ExpectedQualTypeNames.lookup(VD->getNameAsString()); +if (ExpectedName != "") { + std::string ActualName = + TypeName::getFullyQualifiedName(VD->getType(), *Context); + if (ExpectedName != ActualName) { +// A custom message makes it much easier to see what declaration +// failed compared to EXPECT_EQ. +EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for " + << VD->getQualifiedNameAsString() << std::endl + << " Actual: " << ActualName << std::endl + << " Exepcted: " << ExpectedName; + } +} +return true; + } +}; + +TEST(QualTypeNameTest, getFullyQualifiedName) { + TypeNameVisitor Visitor; + // Simple case to test the test framework itself. + Visitor.ExpectedQualTypeNames["CheckInt"] = "int"; + + // Keeping the names of the variables whose types we check unique + // within the entire test--regardless of their own scope--makes it + // easier to diagnose test failures. + + // Simple namespace qualifier + Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0"; + // Lookup up the enclosing scopes, then down another one. (These + // appear as elaborated type in the AST. In that case--even if + // policy.SuppressScope = 0--qual_type.getAsString(policy) only + // gives the name as it appears in the source, not the full name. + Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1"; + // Template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckC"] = + "A::B::Template0"; + // Recursive template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckD"] = + "A::B::Template0, " + "A::B::Template0 >"; + // Variadic Template expansion. + Visitor.ExpectedQualTypeNames["CheckE"] = + "A::Variadic, " + "A::B::Template1, A::B::C::MyInt>"; + // Using declarations should be fully expanded. + Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0"; + // Elements found within "using namespace foo;" should be fully + // expanded. + Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt"; + // Type inside function + Visitor.ExpectedQualTypeNames["CheckH"] = "struct X"; + // Anonymous Namespaces + Visitor.ExpectedQualTypeNames["CheckI"] = "aClass"; + // Keyword inclusion with namespaces + Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct"; + Visitor.runOver( + "int CheckInt;\n" + "namespace A {\n" + " namespace B {\n" + " class Class0 { };\n" + " namespace C {\n" + " typedef int MyInt;" + " }\n" + " template class Template0;" + " template class Template1;" + " typedef B::Class0 AnotherClass;\n" + " void Function1(Template0 CheckC);\n" + " void Function2(Template0,\n" + "Template0 > CheckD);\n" + " }\n" + "template class Variadic {};\n" + "Variadic, " + " B::Template1, " + " B::C::MyInt > CheckE;\n" + "}\n" + "using A::B::Class0;\n" + "void Function(Class0 CheckF);\n" + "using namespace A::B::C;\n" + "void Function(MyInt CheckG);\n" + "void f() {\n" + " struct X {} CheckH;\n" + "}\n" + "namespace {\n" + " class aClass {};\n" + " aClass CheckI;\n" + "}\n" + "namespace A {\n" + " struct aStruct {} CheckJ;\n" + "}\n"); + + TypeNameVisitor Complex; + Complex.ExpectedQualTypeNames["CheckTX"] = "B::TX"; + Complex.runOver( + "namespace A {" + " struct X {};" + "}" + "using
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine added a comment. Thanks for the reviews. Please take another look when you get a chance. Comment at: include/clang/Tooling/Core/QualTypeNames.h:32-33 @@ +31,4 @@ +namespace TypeName { +///\brief Convert the type into one with fully qualified template +/// arguments. +///\param[in] QT - the type for which the fully qualified type will be rsmith wrote: > rsmith wrote: > > Please ensure there's a space between each `/// ` and the content. > What do you mean by "fully qualified template arguments" here? Let me give > you some examples: > > namespace A { > struct X {}; > } > using A::X; > namespace B { > using std::tuple; > typedef typle TX; > TX t; > struct A { typedef int X; }; > } > > What is the fully-qualified name of `B::t`'s type? Is it `B::TX` or > `std::tuple` or `std::tuple<::A::X>`? Note that if you want to > redeclare `t` from within namespace `B`, `std::tuple` will name the > wrong type. > > > Why does this only affect template arguments? Its name suggests it should > affect the type as a whole (for instance, in the above case it should produce > `std::tuple<...>`, not `tuple<...>`). > > > Generally, I think this interface needs to specify where the produced names > can be used as a name for the specified type, otherwise I don't see how it > can ever be reliable. For instance: > > > "Generates a name for a type that can be used to name the same type if used > > at the end of the current translation unit." (eg, `B::TX` or > > `std::tuple`) > > or: > > > "Generates a maximally-explicit name for a type that can be used in any > > context where all the relevant components have been declared. In such a > > context, this name will either name the intended type or produce an > > ambiguity error." (eg, `::std::tuple<::A::X>`) > > You should also specify what happens when it's not possible to generate such > a name. For instance, given: > > void f() { > struct X {} x; > } > > ... there's no way to name the type of `x` from outside `f` (which makes > certain refactoring operations impossible unless you also move the definition > of `struct X`). > > > I think the ideal interface here would allow you to specify a location where > you wish to insert the name, and would produce a "best possible" name for > that type for that location, avoiding adding explicit qualification / > desugaring wherever possible, but the interface should at least take the > context-sensitivity of names into account. My use case is to take a function signature, and communicate to a developer one way to declare the variables they need to call the function. It does expand entire qualtypes, not just template parameters. (I've updated that description.) Given the use case, "at the end of the translation unit" is the closest description of where these names would be valid, with the exception that this code avoids relying on any "using" declaration. "using foo::bar; void bat(bar b);", this code would describe foo's parameter as type foo::bar, rather than plain "bar", even though plain "bar" would work at the end of the translation unit. I have updated the file header's comment to reflect all this, and added a couple of test cases to prove to myself that it does what I have documented. Along the way I have found a couple of places to explicitly mark where one would do things differently if one wanted to change this behavior. The "ideal interface" idea is a good--and very cool--one, but my use case doesn't call for it. Comment at: include/clang/Tooling/Core/QualTypeNames.h:49-79 @@ +48,33 @@ + +///\brief Create a NestedNameSpecifier for Namesp and its enclosing +/// scopes. +/// +///\param[in] Ctx - the AST Context to be used. +///\param[in] Namesp - the NamespaceDecl for which a NestedNameSpecifier +/// is requested. +clang::NestedNameSpecifier *createNestedNameSpecifier( +const clang::ASTContext &Ctx, const clang::NamespaceDecl *Namesp); + +///\brief Create a NestedNameSpecifier for TagDecl and its enclosing +/// scopes. +/// +///\param[in] Ctx - the AST Context to be used. +///\param[in] TD - the TagDecl for which a NestedNameSpecifier is +/// requested. +///\param[in] FullyQualify - Convert all template arguments into fully +/// qualified names. +clang::NestedNameSpecifier *createNestedNameSpecifier( +const clang::ASTContext &Ctx, const clang::TagDecl *TD, bool FullyQualify); + +///\brief Create a NestedNameSpecifier for TypedefDecl and its enclosing +/// scopes. +/// +///\param[in] Ctx - the AST Context to be used. +///\param[in] TD - the TypedefDecl for which a NestedNameSpecifier is +/// requested. +///\param[in] FullyQualify - Convert all template arguments (of possible +/// parent scopes) into fully qualified names. +clang::NestedNameSpecifier *createNestedNameSpecifier( +const clang::ASTContext &Ctx, const clang::TypedefNameDecl *TD, +bool Ful
[clang-tools-extra] c2ad7c2 - Revert "[clangd] Provide a way to disable external index"
Author: Sterling Augustine Date: 2021-04-12T14:39:13-07:00 New Revision: c2ad7c23707cece995ee9070283a72c4afc8c0fe URL: https://github.com/llvm/llvm-project/commit/c2ad7c23707cece995ee9070283a72c4afc8c0fe DIFF: https://github.com/llvm/llvm-project/commit/c2ad7c23707cece995ee9070283a72c4afc8c0fe.diff LOG: Revert "[clangd] Provide a way to disable external index" This reverts commit 63bc9e443502ab6def2dec0b5ffe64a522f801cc. This breaks llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:570:11: with error: enumeration value 'None' not handled in switch [-Werror,-Wswitch] Added: Modified: clang-tools-extra/clangd/Config.h clang-tools-extra/clangd/ConfigCompile.cpp clang-tools-extra/clangd/ConfigFragment.h clang-tools-extra/clangd/ConfigYAML.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp Removed: diff --git a/clang-tools-extra/clangd/Config.h b/clang-tools-extra/clangd/Config.h index fe6f4d7fa6e8e..7064edd76b8f4 100644 --- a/clang-tools-extra/clangd/Config.h +++ b/clang-tools-extra/clangd/Config.h @@ -70,7 +70,7 @@ struct Config { enum class BackgroundPolicy { Build, Skip }; /// Describes an external index configuration. struct ExternalIndexSpec { -enum { None, File, Server } Kind; +enum { File, Server } Kind; /// This is one of: /// - Address of a clangd-index-server, in the form of "ip:port". /// - Absolute path to an index produced by clangd-indexer. diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp index a5745727dca78..1185eb7255b4c 100644 --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -329,11 +329,10 @@ struct FragmentCompiler { } #endif // Make sure exactly one of the Sources is set. -unsigned SourceCount = External.File.hasValue() + - External.Server.hasValue() + *External.IsNone; +unsigned SourceCount = +External.File.hasValue() + External.Server.hasValue(); if (SourceCount != 1) { - diag(Error, "Exactly one of File, Server or None must be set.", - BlockRange); + diag(Error, "Exactly one of File or Server must be set.", BlockRange); return; } Config::ExternalIndexSpec Spec; @@ -347,29 +346,20 @@ struct FragmentCompiler { if (!AbsPath) return; Spec.Location = std::move(*AbsPath); -} else { - assert(*External.IsNone); - Spec.Kind = Config::ExternalIndexSpec::None; } -if (Spec.Kind != Config::ExternalIndexSpec::None) { - // Make sure MountPoint is an absolute path with forward slashes. - if (!External.MountPoint) -External.MountPoint.emplace(FragmentDirectory); - if ((**External.MountPoint).empty()) { -diag(Error, "A mountpoint is required.", BlockRange); -return; - } - auto AbsPath = makeAbsolute(std::move(*External.MountPoint), "MountPoint", - llvm::sys::path::Style::posix); - if (!AbsPath) -return; - Spec.MountPoint = std::move(*AbsPath); +// Make sure MountPoint is an absolute path with forward slashes. +if (!External.MountPoint) + External.MountPoint.emplace(FragmentDirectory); +if ((**External.MountPoint).empty()) { + diag(Error, "A mountpoint is required.", BlockRange); + return; } +auto AbsPath = makeAbsolute(std::move(*External.MountPoint), "MountPoint", +llvm::sys::path::Style::posix); +if (!AbsPath) + return; +Spec.MountPoint = std::move(*AbsPath); Out.Apply.push_back([Spec(std::move(Spec))](const Params &P, Config &C) { - if (Spec.Kind == Config::ExternalIndexSpec::None) { -C.Index.External.reset(); -return; - } if (P.Path.empty() || !pathStartsWith(Spec.MountPoint, P.Path, llvm::sys::path::Style::posix)) return; diff --git a/clang-tools-extra/clangd/ConfigFragment.h b/clang-tools-extra/clangd/ConfigFragment.h index 6b58b88dfd490..1365ed4c1037c 100644 --- a/clang-tools-extra/clangd/ConfigFragment.h +++ b/clang-tools-extra/clangd/ConfigFragment.h @@ -173,9 +173,6 @@ struct Fragment { /// usually prepared using clangd-indexer. /// Exactly one source (File/Server) should be configured. struct ExternalBlock { - /// Whether the block is explicitly set to `None`. Can be used to clear - /// any external index specified before. - Located IsNone = false; /// Path to an index file generated by clangd-indexer. Relative paths may /// be used, if config fragment is associated with a directory. llvm::Optional> File; diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYA
[clang] d2bb3cb - Make test runnable on read-only file systems.
Author: Sterling Augustine Date: 2021-04-14T13:29:51-07:00 New Revision: d2bb3cbbf8bc3a1b3d27c5a89e7cdd56bdca924f URL: https://github.com/llvm/llvm-project/commit/d2bb3cbbf8bc3a1b3d27c5a89e7cdd56bdca924f DIFF: https://github.com/llvm/llvm-project/commit/d2bb3cbbf8bc3a1b3d27c5a89e7cdd56bdca924f.diff LOG: Make test runnable on read-only file systems. Added: Modified: clang/test/Misc/serialized-diags-empty-filename.c Removed: diff --git a/clang/test/Misc/serialized-diags-empty-filename.c b/clang/test/Misc/serialized-diags-empty-filename.c index e86108414273e..32a9156e02151 100644 --- a/clang/test/Misc/serialized-diags-empty-filename.c +++ b/clang/test/Misc/serialized-diags-empty-filename.c @@ -1,5 +1,5 @@ // RUN: rm -f %t.diag -// RUN: not %clang -c %s --serialize-diagnostics %t.diag +// RUN: not %clang -c %s --serialize-diagnostics %t.diag -o /dev/null // RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s # 1 "" 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits