r335410 - [Fuchsia] Enable static libc++, libc++abi, libunwind
Author: phosek Date: Fri Jun 22 20:15:07 2018 New Revision: 335410 URL: http://llvm.org/viewvc/llvm-project?rev=335410=rev Log: [Fuchsia] Enable static libc++, libc++abi, libunwind This is needed for building Fuchsia drivers. Differential Revision: https://reviews.llvm.org/D48208 Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp cfe/trunk/test/Driver/fuchsia.cpp Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=335410=335409=335410=diff == --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original) +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Fri Jun 22 20:15:07 2018 @@ -77,12 +77,9 @@ foreach(target x86_64;aarch64) set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "") Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=335410=335409=335410=diff == --- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Fri Jun 22 20:15:07 2018 @@ -115,8 +115,15 @@ void fuchsia::Linker::ConstructJob(Compi CmdArgs.push_back("-Bdynamic"); if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) + if (ToolChain.ShouldLinkCXXStdlib(Args)) { +bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && + !Args.hasArg(options::OPT_static); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); + } CmdArgs.push_back("-lm"); } Modified: cfe/trunk/test/Driver/fuchsia.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.cpp?rev=335410=335409=335410=diff == --- cfe/trunk/test/Driver/fuchsia.cpp (original) +++ cfe/trunk/test/Driver/fuchsia.cpp Fri Jun 22 20:15:07 2018 @@ -27,8 +27,8 @@ // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC -// CHECK-STATIC-NOT: "-Bstatic" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" -// CHECK-STATIC-NOT: "-Bdynamic" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "-lc" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48208: [Fuchsia] Enable static libc++, libc++abi, libunwind
This revision was automatically updated to reflect the committed changes. Closed by commit rL335410: [Fuchsia] Enable static libc++, libc++abi, libunwind (authored by phosek, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48208?vs=152578=152581#toc Repository: rL LLVM https://reviews.llvm.org/D48208 Files: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp cfe/trunk/test/Driver/fuchsia.cpp Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake === --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake @@ -77,12 +77,9 @@ set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "") Index: cfe/trunk/test/Driver/fuchsia.cpp === --- cfe/trunk/test/Driver/fuchsia.cpp +++ cfe/trunk/test/Driver/fuchsia.cpp @@ -27,8 +27,8 @@ // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC -// CHECK-STATIC-NOT: "-Bstatic" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" -// CHECK-STATIC-NOT: "-Bdynamic" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "-lc" Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp === --- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp +++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp @@ -115,8 +115,15 @@ CmdArgs.push_back("-Bdynamic"); if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) + if (ToolChain.ShouldLinkCXXStdlib(Args)) { +bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && + !Args.hasArg(options::OPT_static); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); + } CmdArgs.push_back("-lm"); } Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake === --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake @@ -77,12 +77,9 @@ set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "") Index: cfe/trunk/test/Driver/fuchsia.cpp === --- cfe/trunk/test/Driver/fuchsia.cpp +++ cfe/trunk/test/Driver/fuchsia.cpp @@ -27,8 +27,8 @@ // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC -// CHECK-STATIC-NOT: "-Bstatic" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" -// CHECK-STATIC-NOT: "-Bdynamic" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "-lc" Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp === --- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp +++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp @@ -115,8 +115,15 @@ CmdArgs.push_back("-Bdynamic"); if (D.CCCIsCXX()) { -
[PATCH] D48515: [mips][ias] Enable IAS by default for OpenBSD / FreeBSD mips64/mips64el.
brad updated this revision to Diff 152580. brad added a comment. Sorry wrong revision of the diff. https://reviews.llvm.org/D48515 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/openbsd.c Index: test/Driver/openbsd.c === --- test/Driver/openbsd.c +++ test/Driver/openbsd.c @@ -74,6 +74,13 @@ // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" +// Check that the integrated assembler is enabled for MIPS64 +// RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// CHECK-MIPS64-AS-NOT: "-no-integrated-as" + // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2421,11 +2421,13 @@ return true; case llvm::Triple::mips64: case llvm::Triple::mips64el: -// Enabled for Debian and Android mips64/mipsel, as they can precisely -// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android). -// Other targets are unable to distinguish N32 from N64. +// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they +// can precisely identify the ABI in use (Debian) or only use N64 for MIPS64 +// (Android). Other targets are unable to distinguish N32 from N64. if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 || -getTriple().isAndroid()) +getTriple().isAndroid() || +getTriple().isOSOpenBSD() || +getTriple().isOSFreeBSD()) return true; return false; default: Index: test/Driver/openbsd.c === --- test/Driver/openbsd.c +++ test/Driver/openbsd.c @@ -74,6 +74,13 @@ // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" +// Check that the integrated assembler is enabled for MIPS64 +// RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// CHECK-MIPS64-AS-NOT: "-no-integrated-as" + // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2421,11 +2421,13 @@ return true; case llvm::Triple::mips64: case llvm::Triple::mips64el: -// Enabled for Debian and Android mips64/mipsel, as they can precisely -// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android). -// Other targets are unable to distinguish N32 from N64. +// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they +// can precisely identify the ABI in use (Debian) or only use N64 for MIPS64 +// (Android). Other targets are unable to distinguish N32 from N64. if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 || -getTriple().isAndroid()) +getTriple().isAndroid() || +getTriple().isOSOpenBSD() || +getTriple().isOSFreeBSD()) return true; return false; default: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48208: [Fuchsia] Enable static libc++, libc++abi, libunwind
phosek updated this revision to Diff 152578. Repository: rC Clang https://reviews.llvm.org/D48208 Files: clang/cmake/caches/Fuchsia-stage2.cmake clang/lib/Driver/ToolChains/Fuchsia.cpp clang/test/Driver/fuchsia.cpp Index: clang/test/Driver/fuchsia.cpp === --- clang/test/Driver/fuchsia.cpp +++ clang/test/Driver/fuchsia.cpp @@ -27,8 +27,8 @@ // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC -// CHECK-STATIC-NOT: "-Bstatic" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" -// CHECK-STATIC-NOT: "-Bdynamic" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "-lc" Index: clang/lib/Driver/ToolChains/Fuchsia.cpp === --- clang/lib/Driver/ToolChains/Fuchsia.cpp +++ clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -115,8 +115,15 @@ CmdArgs.push_back("-Bdynamic"); if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) + if (ToolChain.ShouldLinkCXXStdlib(Args)) { +bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && + !Args.hasArg(options::OPT_static); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); + } CmdArgs.push_back("-lm"); } Index: clang/cmake/caches/Fuchsia-stage2.cmake === --- clang/cmake/caches/Fuchsia-stage2.cmake +++ clang/cmake/caches/Fuchsia-stage2.cmake @@ -77,12 +77,9 @@ set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "") Index: clang/test/Driver/fuchsia.cpp === --- clang/test/Driver/fuchsia.cpp +++ clang/test/Driver/fuchsia.cpp @@ -27,8 +27,8 @@ // RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-STATIC -// CHECK-STATIC-NOT: "-Bstatic" +// CHECK-STATIC: "-Bstatic" // CHECK-STATIC: "-lc++" -// CHECK-STATIC-NOT: "-Bdynamic" +// CHECK-STATIC: "-Bdynamic" // CHECK-STATIC: "-lm" // CHECK-STATIC: "-lc" Index: clang/lib/Driver/ToolChains/Fuchsia.cpp === --- clang/lib/Driver/ToolChains/Fuchsia.cpp +++ clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -115,8 +115,15 @@ CmdArgs.push_back("-Bdynamic"); if (D.CCCIsCXX()) { - if (ToolChain.ShouldLinkCXXStdlib(Args)) + if (ToolChain.ShouldLinkCXXStdlib(Args)) { +bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && + !Args.hasArg(options::OPT_static); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); +if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); + } CmdArgs.push_back("-lm"); } Index: clang/cmake/caches/Fuchsia-stage2.cmake === --- clang/cmake/caches/Fuchsia-stage2.cmake +++ clang/cmake/caches/Fuchsia-stage2.cmake @@ -77,12 +77,9 @@ set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
[PATCH] D48515: [mips][ias] Enable IAS by default for OpenBSD / FreeBSD mips64/mips64el.
brad created this revision. brad added reviewers: sdardis, atanasyan. Herald added a subscriber: srhines. Enable IAS by default for OpenBSD / FreeBSD mips64/mips64el. Repository: rC Clang https://reviews.llvm.org/D48515 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/openbsd.c Index: test/Driver/openbsd.c === --- test/Driver/openbsd.c +++ test/Driver/openbsd.c @@ -74,6 +74,13 @@ // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" +// Check that the integrated assembler is enabled for MIPS64 +// RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// CHECK-MIPS64-AS-NOT: "-no-integrated-as" + // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2421,11 +2421,12 @@ return true; case llvm::Triple::mips64: case llvm::Triple::mips64el: -// Enabled for Debian and Android mips64/mipsel, as they can precisely -// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android). -// Other targets are unable to distinguish N32 from N64. +// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they +// can precisely identify the ABI in use (Debian) or only use N64 for MIPS64 +// (Android). Other targets are unable to distinguish N32 from N64. if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 || -getTriple().isAndroid()) +getTriple().isAndroid() || +getTriple().isOSOpenBSD()) return true; return false; default: Index: test/Driver/openbsd.c === --- test/Driver/openbsd.c +++ test/Driver/openbsd.c @@ -74,6 +74,13 @@ // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" +// Check that the integrated assembler is enabled for MIPS64 +// RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-AS %s +// CHECK-MIPS64-AS-NOT: "-no-integrated-as" + // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2421,11 +2421,12 @@ return true; case llvm::Triple::mips64: case llvm::Triple::mips64el: -// Enabled for Debian and Android mips64/mipsel, as they can precisely -// identify the ABI in use (Debian) or only use N64 for MIPS64 (Android). -// Other targets are unable to distinguish N32 from N64. +// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they +// can precisely identify the ABI in use (Debian) or only use N64 for MIPS64 +// (Android). Other targets are unable to distinguish N32 from N64. if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 || -getTriple().isAndroid()) +getTriple().isAndroid() || +getTriple().isOSOpenBSD()) return true; return false; default: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference
NoQ added a comment. Ok, code makes sense to me now! I think we still need a few new tests to cover the corner cases. In https://reviews.llvm.org/D35110#1135306, @baloghadamsoftware wrote: > I added extra assertion into the test for the difference. Interestingly, it > also works if I assert `n-m` is in the range instead of `m-n`. However, I > wonder how can I apply such constraint to the difference of iterator > positions without decomposing them to symbols and constants. I don't see how iterator checker is different from the tests. The code of the program in your tests doesn't decompose `m - n` into symbols and constants, it simply subtracts an opaque value `n` (whatever it is) from an opaque value `m` (whatever it is) and makes assumptions on the opaque result of the subtraction (whatever it is). The checker should do the same, i guess? Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:177-178 +// Turn all [A, B] ranges to [-B, -A]. Turn minimal signed value to maximal +// signed value. +RangeSet RangeSet::Negate(BasicValueFactory , Factory ) const { I guess the comment needs to be updated. Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:189 +newRanges.begin()->From().isMinSignedValue()) { + const llvm::APSInt = newRanges.begin()->From(); + newRanges = I suggest a few sanity checks here (untested): `assert(newRanges.begin()->To().isMinSignedValue());` because we shouldn't ever get an overlap. `assert(!from.isMinSignedValue())` for the same reason; it's good to know because it tells us what `newTo` is equal to on this path. https://reviews.llvm.org/D35110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48412: [RISCV] Add support for interrupt attribute
apazos updated this revision to Diff 152560. apazos added a comment. Addressed review comments. https://reviews.llvm.org/D48412 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/TargetInfo.cpp lib/Sema/SemaDeclAttr.cpp test/Sema/riscv-interrupt-attr.c Index: test/Sema/riscv-interrupt-attr.c === --- /dev/null +++ test/Sema/riscv-interrupt-attr.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only +// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only + +struct a { int b; }; + +struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} + +__attribute__((interrupt("USER"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: USER}} + +__attribute__((interrupt("user", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}} + +__attribute__((interrupt)) int foo3() {return 0;} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}} + +__attribute__((interrupt())) int foo4(void) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have a 'void' return type}} + +__attribute__((interrupt())) void foo5(int a) {} // expected-warning {{RISC-V 'interrupt' attribute only applies to functions that have no parameters}} + +__attribute__((interrupt("user"), interrupt("supervisor"))) void foo6() {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ +// expected-note {{repeated RISC-V 'interrupt' attribute is here}} + +__attribute__((interrupt, interrupt)) void foo7() {} // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ + // expected-note {{repeated RISC-V 'interrupt' attribute is here}} +__attribute__((interrupt(""))) void foo11() {} // expected-warning {{'interrupt' attribute argument not supported}} + +__attribute__((interrupt("user"))) void foo8() {} +__attribute__((interrupt("supervisor"))) void foo9() {} +__attribute__((interrupt("machine"))) void foo10() {} +__attribute__((interrupt())) void foo12() {} +__attribute__((interrupt)) void foo13() {} + Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -5266,6 +5266,63 @@ handleSimpleAttribute(S, D, AL); } +static void handleRISCVInterruptAttr(Sema , Decl *D, + const AttributeList ) { + // Warn about repeated attributes. + if (const auto *A = D->getAttr()) { +S.Diag(AL.getRange().getBegin(), + diag::warn_riscv_repeated_interrupt_attribute); +S.Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute); +return; + } + + // Check the attribute argument. Argument is optional. + if (!checkAttributeAtMostNumArgs(S, AL, 1)) +return; + + StringRef Str; + SourceLocation ArgLoc; + + // 'machine'is the default interrupt mode. + if (AL.getNumArgs() == 0) +Str = "machine"; + else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, )) +return; + + // Semantic checks for a function with the 'interrupt' attribute: + // - Must be a function. + // - Must have no parameters. + // - Must have the 'void' return type. + // - The attribute itself must either have no argument or one of the + // valid interrupt types, see [RISCVInterruptDocs]. + + if (!isFunctionOrMethod(D)) { +S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) + << "'interrupt'" << ExpectedFunction; +return; + } + + if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { +S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 0; +return; + } + + if (!getFunctionOrMethodResultType(D)->isVoidType()) { +S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 1; +return; + } + + RISCVInterruptAttr::InterruptType Kind; + if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) { +S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) + << AL.getName() << Str << ArgLoc; +return; + } + + D->addAttr(::new (S.Context) RISCVInterruptAttr( +AL.getLoc(), S.Context, Kind, AL.getAttributeSpellingListIndex())); +} + static void handleInterruptAttr(Sema , Decl *D, const AttributeList ) { // Dispatch the interrupt attribute based on the current target. switch (S.Context.getTargetInfo().getTriple().getArch()) { @@ -5283,6 +5340,10 @@ case llvm::Triple::avr: handleAVRInterruptAttr(S, D, AL); break; + case llvm::Triple::riscv32: + case llvm::Triple::riscv64: +handleRISCVInterruptAttr(S, D, AL); +break; default:
[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types
rjmccall added inline comments. Comment at: lib/CodeGen/CGObjCMac.cpp:7457-7460 CGObjCNonFragileABIMac::GetEHType(QualType T) { // There's a particular fixed type info for 'id'. if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { +if (CGM.getTriple().isWindowsMSVCEnvironment()) smeenai wrote: > rjmccall wrote: > > rnk wrote: > > > @rjmccall how should this be organized in the long run? At this point, > > > the naming seems totally wrong. Is the non-fragile ABI sort of the > > > canonical way forward for Obj-C, i.e. it's what a new platform would want > > > to use to best stay in sync with the future of obj-c? > > For Darwin, yes, absolutely. > > > > I think this method should probably just completely delegate to the > > `CGCXXABI` using a new `getAddrOfObjCRTTIDescriptor` method. > To be clear, you'd want the entirety of the EHType emission logic to be > shifted to CGCXXABI? I think that would make sense, and I can look into it. Right. Repository: rC Clang https://reviews.llvm.org/D47233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47301: Warning for framework include violation from Headers to PrivateHeaders
vsapsai accepted this revision. vsapsai added a comment. This revision is now accepted and ready to land. Looks good to me. The only problem is I'm not entirely sure this warning will interact with real code the way I expect it to. We'll need to keep an eye on it and tweak if necessary. https://reviews.llvm.org/D47301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48443: [WebAssembly] Add no-prototype attribute to prototype-less C functions
sbc100 added a comment. Without the check for `doesThisDeclarationHaveABody()` the attribute will also be added to `baz` which is IIRC is not what we want since the C notions of "prototypeless" only applies to forward declarations I think. Repository: rC Clang https://reviews.llvm.org/D48443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin
This revision was automatically updated to reflect the committed changes. Closed by commit rL335393: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin (authored by jfb, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D47290 Files: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/FixIt/fixit-format-ios-nopedantic.m cfe/trunk/test/FixIt/fixit-format-ios.m cfe/trunk/test/SemaObjC/format-size-spec-nsinteger.m Index: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h === --- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h +++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h @@ -256,26 +256,34 @@ private: const Kind K; QualType T; - const char *Name; - bool Ptr; + const char *Name = nullptr; + bool Ptr = false, IsSizeT = false; + public: - ArgType(Kind k = UnknownTy, const char *n = nullptr) - : K(k), Name(n), Ptr(false) {} - ArgType(QualType t, const char *n = nullptr) - : K(SpecificTy), T(t), Name(n), Ptr(false) {} - ArgType(CanQualType t) : K(SpecificTy), T(t), Name(nullptr), Ptr(false) {} + ArgType(Kind K = UnknownTy, const char *N = nullptr) : K(K), Name(N) {} + ArgType(QualType T, const char *N = nullptr) : K(SpecificTy), T(T), Name(N) {} + ArgType(CanQualType T) : K(SpecificTy), T(T) {} static ArgType Invalid() { return ArgType(InvalidTy); } bool isValid() const { return K != InvalidTy; } + bool isSizeT() const { return IsSizeT; } + /// Create an ArgType which corresponds to the type pointer to A. static ArgType PtrTo(const ArgType& A) { assert(A.K >= InvalidTy && "ArgType cannot be pointer to invalid/unknown"); ArgType Res = A; Res.Ptr = true; return Res; } + /// Create an ArgType which corresponds to the size_t/ssize_t type. + static ArgType makeSizeT(const ArgType ) { +ArgType Res = A; +Res.IsSizeT = true; +return Res; + } + MatchKind matchesType(ASTContext , QualType argTy) const; QualType getRepresentativeType(ASTContext ) const; Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -7719,6 +7719,10 @@ "%select{values of type|enum values with underlying type}2 '%0' should not " "be used as format arguments; add an explicit cast to %1 instead">, InGroup; +def warn_format_argument_needs_cast_pedantic : Warning< + "%select{values of type|enum values with underlying type}2 '%0' should not " + "be used as format arguments; add an explicit cast to %1 instead">, + InGroup, DefaultIgnore; def warn_printf_positional_arg_exceeds_data_args : Warning < "data argument position '%0' exceeds the number of data arguments (%1)">, InGroup; Index: cfe/trunk/test/FixIt/fixit-format-ios.m === --- cfe/trunk/test/FixIt/fixit-format-ios.m +++ cfe/trunk/test/FixIt/fixit-format-ios.m @@ -1,5 +1,5 @@ // RUN: cp %s %t -// RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -fsyntax-only -Wformat -fixit %t +// RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -fsyntax-only -Wformat-pedantic -fixit %t // RUN: grep -v CHECK %t | FileCheck %s int printf(const char * restrict, ...); Index: cfe/trunk/test/FixIt/fixit-format-ios-nopedantic.m === --- cfe/trunk/test/FixIt/fixit-format-ios-nopedantic.m +++ cfe/trunk/test/FixIt/fixit-format-ios-nopedantic.m @@ -0,0 +1,21 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -fsyntax-only -Wformat -Werror -fixit %t + +int printf(const char *restrict, ...); +typedef unsigned int NSUInteger; +typedef int NSInteger; +NSUInteger getNSUInteger(); +NSInteger getNSInteger(); + +void test() { + // For thumbv7-apple-ios8.0.0 the underlying type of ssize_t is long + // and the underlying type of size_t is unsigned long. + + printf("test 1: %zu", getNSUInteger()); + + printf("test 2: %zu %zu", getNSUInteger(), getNSUInteger()); + + printf("test 3: %zd", getNSInteger()); + + printf("test 4: %zd %zd", getNSInteger(), getNSInteger()); +} Index: cfe/trunk/test/SemaObjC/format-size-spec-nsinteger.m === --- cfe/trunk/test/SemaObjC/format-size-spec-nsinteger.m +++ cfe/trunk/test/SemaObjC/format-size-spec-nsinteger.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat %s +// RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat-pedantic -DPEDANTIC %s + +#if
r335393 - [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin
Author: jfb Date: Fri Jun 22 14:54:40 2018 New Revision: 335393 URL: http://llvm.org/viewvc/llvm-project?rev=335393=rev Log: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin Summary: Pick D42933 back up, and make NSInteger/NSUInteger with %zu/%zi specifiers on Darwin warn only in pedantic mode. The default -Wformat recently started warning for the following code because of the added support for analysis for the '%zi' specifier. NSInteger i = NSIntegerMax; NSLog(@"max NSInteger = %zi", i); The problem is that on armv7 %zi is 'long', and NSInteger is typedefed to 'int' in Foundation. We should avoid this warning as it's inconvenient to our users: it's target specific (happens only on armv7 and not arm64), and breaks their existing code. We should also silence the warning for the '%zu' specifier to ensure consistency. This is acceptable because Darwin guarantees that, despite the unfortunate choice of typedef, sizeof(size_t) == sizeof(NS[U]Integer), the warning is therefore noisy for pedantic reasons. Once this is in I'll update public documentation. Related discussion on cfe-dev: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058050.html Reviewers: ahatanak, vsapsai, alexshap, aaron.ballman, javed.absar, jfb, rjmccall Subscribers: kristof.beyls, aheejin, cfe-commits Differential Revision: https://reviews.llvm.org/D47290 Added: cfe/trunk/test/FixIt/fixit-format-ios-nopedantic.m cfe/trunk/test/SemaObjC/format-size-spec-nsinteger.m Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/FixIt/fixit-format-ios.m Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=335393=335392=335393=diff == --- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Fri Jun 22 14:54:40 2018 @@ -256,18 +256,19 @@ public: private: const Kind K; QualType T; - const char *Name; - bool Ptr; + const char *Name = nullptr; + bool Ptr = false, IsSizeT = false; + public: - ArgType(Kind k = UnknownTy, const char *n = nullptr) - : K(k), Name(n), Ptr(false) {} - ArgType(QualType t, const char *n = nullptr) - : K(SpecificTy), T(t), Name(n), Ptr(false) {} - ArgType(CanQualType t) : K(SpecificTy), T(t), Name(nullptr), Ptr(false) {} + ArgType(Kind K = UnknownTy, const char *N = nullptr) : K(K), Name(N) {} + ArgType(QualType T, const char *N = nullptr) : K(SpecificTy), T(T), Name(N) {} + ArgType(CanQualType T) : K(SpecificTy), T(T) {} static ArgType Invalid() { return ArgType(InvalidTy); } bool isValid() const { return K != InvalidTy; } + bool isSizeT() const { return IsSizeT; } + /// Create an ArgType which corresponds to the type pointer to A. static ArgType PtrTo(const ArgType& A) { assert(A.K >= InvalidTy && "ArgType cannot be pointer to invalid/unknown"); @@ -276,6 +277,13 @@ public: return Res; } + /// Create an ArgType which corresponds to the size_t/ssize_t type. + static ArgType makeSizeT(const ArgType ) { +ArgType Res = A; +Res.IsSizeT = true; +return Res; + } + MatchKind matchesType(ASTContext , QualType argTy) const; QualType getRepresentativeType(ASTContext ) const; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=335393=335392=335393=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 22 14:54:40 2018 @@ -7719,6 +7719,10 @@ def warn_format_argument_needs_cast : Wa "%select{values of type|enum values with underlying type}2 '%0' should not " "be used as format arguments; add an explicit cast to %1 instead">, InGroup; +def warn_format_argument_needs_cast_pedantic : Warning< + "%select{values of type|enum values with underlying type}2 '%0' should not " + "be used as format arguments; add an explicit cast to %1 instead">, + InGroup, DefaultIgnore; def warn_printf_positional_arg_exceeds_data_args : Warning < "data argument position '%0' exceeds the number of data arguments (%1)">, InGroup; Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=335393=335392=335393=diff == --- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original) +++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Fri Jun
[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.
bsdjhb created this revision. bsdjhb added a reviewer: dim. Herald added subscribers: atanasyan, krytarowski, arichardson, sdardis. FreeBSD's mips64 builds O32 binaries for /usr/lib32 by default and thus needs to be able to link O32 binaries which requires an explicit linker emulation. Go ahead and list all the linker emulation variants for MIPS so that any supported MIPS ABI binary can be linked by any linker support MIPS. Repository: rC Clang https://reviews.llvm.org/D48507 Files: lib/Driver/ToolChains/FreeBSD.cpp test/Driver/freebsd.c Index: test/Driver/freebsd.c === --- test/Driver/freebsd.c +++ test/Driver/freebsd.c @@ -42,6 +42,24 @@ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // +// Check that MIPS passes the correct linker emulation. +// +// RUN: %clang -target mips-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-LD %s +// CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd" +// RUN: %clang -target mipsel-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSEL-LD %s +// CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd" +// RUN: %clang -target mips64-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s +// CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd" +// RUN: %clang -target mips64el-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s +// CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd" +// RUN: %clang -target mips64-freebsd -mabi=n32 %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSN32-LD %s +// CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd" +// // Check that the new linker flags are passed to FreeBSD // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ Index: lib/Driver/ToolChains/FreeBSD.cpp === --- lib/Driver/ToolChains/FreeBSD.cpp +++ lib/Driver/ToolChains/FreeBSD.cpp @@ -166,16 +166,36 @@ CmdArgs.push_back("--enable-new-dtags"); } - // When building 32-bit code on FreeBSD/amd64, we have to explicitly - // instruct ld in the base system to link 32-bit code. - if (Arch == llvm::Triple::x86) { + // Explicitly set the linker emulation for platforms that might not + // be the default emulation for the linker. + switch (Arch) { + case llvm::Triple::x86: CmdArgs.push_back("-m"); CmdArgs.push_back("elf_i386_fbsd"); - } - - if (Arch == llvm::Triple::ppc) { +break; + case llvm::Triple::ppc: CmdArgs.push_back("-m"); CmdArgs.push_back("elf32ppc_fbsd"); +break; + case llvm::Triple::mips: +CmdArgs.push_back("-m"); +CmdArgs.push_back("elf32btsmip_fbsd"); +break; + case llvm::Triple::mipsel: +CmdArgs.push_back("-m"); +CmdArgs.push_back("elf32ltsmip_fbsd"); +break; + case llvm::Triple::mips64: +CmdArgs.push_back("-m"); +if (tools::mips::hasMipsAbiArg(Args, "n32")) + CmdArgs.push_back("elf32btsmipn32_fbsd"); +else + CmdArgs.push_back("elf64btsmip_fbsd"); +break; + case llvm::Triple::mips64el: +CmdArgs.push_back("-m"); +CmdArgs.push_back("elf64ltsmip_fbsd"); +break; } if (Arg *A = Args.getLastArg(options::OPT_G)) { Index: test/Driver/freebsd.c === --- test/Driver/freebsd.c +++ test/Driver/freebsd.c @@ -42,6 +42,24 @@ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // +// Check that MIPS passes the correct linker emulation. +// +// RUN: %clang -target mips-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-LD %s +// CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd" +// RUN: %clang -target mipsel-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSEL-LD %s +// CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd" +// RUN: %clang -target mips64-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s +// CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd" +// RUN: %clang -target mips64el-freebsd %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s +// CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd" +// RUN: %clang -target mips64-freebsd -mabi=n32 %s -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSN32-LD %s +// CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd" +// // Check that the new linker flags are passed to FreeBSD // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ Index:
[PATCH] D48506: Fix for Crash in nested name specifier decltype
bviyer created this revision. bviyer added reviewers: rsmith, arphaman. There was a crash when qualtype is null in the function Sema::ActOnCXXNestedNameSpecifierDecltype. If it is null then just return without processing it further. Repository: rC Clang https://reviews.llvm.org/D48506 Files: lib/Sema/SemaCXXScopeSpec.cpp test/SemaCXX/qualtype-null-check.cpp Index: test/SemaCXX/qualtype-null-check.cpp === --- /dev/null +++ test/SemaCXX/qualtype-null-check.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s +struct A +{ +bool x{(foo)::foo}; // expected-error {{reference to non-static member function must be called}} +void foo(int); +}; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -846,6 +846,8 @@ assert(DS.getTypeSpecType() == DeclSpec::TST_decltype); QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc()); + if (T.getTypePtrOrNull() == nullptr) + return true; if (!T->isDependentType() && !T->getAs()) { Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) << T << getLangOpts().CPlusPlus; Index: test/SemaCXX/qualtype-null-check.cpp === --- /dev/null +++ test/SemaCXX/qualtype-null-check.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s +struct A +{ +bool x{(foo)::foo}; // expected-error {{reference to non-static member function must be called}} +void foo(int); +}; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -846,6 +846,8 @@ assert(DS.getTypeSpecType() == DeclSpec::TST_decltype); QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc()); + if (T.getTypePtrOrNull() == nullptr) + return true; if (!T->isDependentType() && !T->getAs()) { Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) << T << getLangOpts().CPlusPlus; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types
smeenai added inline comments. Comment at: lib/CodeGen/CGObjCMac.cpp:7457-7460 CGObjCNonFragileABIMac::GetEHType(QualType T) { // There's a particular fixed type info for 'id'. if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { +if (CGM.getTriple().isWindowsMSVCEnvironment()) rjmccall wrote: > rnk wrote: > > @rjmccall how should this be organized in the long run? At this point, the > > naming seems totally wrong. Is the non-fragile ABI sort of the canonical > > way forward for Obj-C, i.e. it's what a new platform would want to use to > > best stay in sync with the future of obj-c? > For Darwin, yes, absolutely. > > I think this method should probably just completely delegate to the > `CGCXXABI` using a new `getAddrOfObjCRTTIDescriptor` method. To be clear, you'd want the entirety of the EHType emission logic to be shifted to CGCXXABI? I think that would make sense, and I can look into it. Repository: rC Clang https://reviews.llvm.org/D47233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47988: [CodeGen] Emit MSVC funclet IR for Obj-C exceptions
smeenai added inline comments. Comment at: lib/CodeGen/CGCXXABI.h:248 +llvm_unreachable("Only needed for the Microsoft ABI"); + } rjmccall wrote: > Should you just generalize the existing method to only take a VarDecl* so it > can be used for either kind of catch? The Itanium version of emitBeginCatch actually uses the statement for location info (it calls `getLocStart` on it). I suppose I could generalize the existing method to take both a VarDecl* and a SourceLocation though. Repository: rC Clang https://reviews.llvm.org/D47988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin
arphaman accepted this revision. arphaman added a comment. This revision is now accepted and ready to land. LGTM. Thanks for working on this! Repository: rC Clang https://reviews.llvm.org/D47290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48443: [WebAssembly] Add no-prototype attribute to prototype-less C functions
sunfish accepted this revision. sunfish added a comment. This revision is now accepted and ready to land. I haven't thought through all the possibilities related to `!FD->doesThisDeclarationHaveABody()`, but overall this looks good. Repository: rC Clang https://reviews.llvm.org/D48443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335374 - Implemented proto to LLVM conversion and LLVM fuzz target
Author: emmettneyman Date: Fri Jun 22 11:05:00 2018 New Revision: 335374 URL: http://llvm.org/viewvc/llvm-project?rev=335374=rev Log: Implemented proto to LLVM conversion and LLVM fuzz target Differential Revision: https://reviews.llvm.org/D48106 Added: cfe/trunk/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp cfe/trunk/tools/clang-fuzzer/handle-llvm/ cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.h cfe/trunk/tools/clang-fuzzer/proto-to-llvm/ cfe/trunk/tools/clang-fuzzer/proto-to-llvm/CMakeLists.txt cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h cfe/trunk/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm_main.cpp Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto cfe/trunk/tools/clang-fuzzer/fuzzer-initialize/fuzzer_initialize.cpp cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=335374=335373=335374=diff == --- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original) +++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Fri Jun 22 11:05:00 2018 @@ -15,6 +15,7 @@ set(LLVM_OPTIONAL_SOURCES DummyClangFuzzer.cpp ExampleClangProtoFuzzer.cpp ExampleClangLoopProtoFuzzer.cpp + ExampleClangLLVMProtoFuzzer.cpp ) if(CLANG_ENABLE_PROTO_FUZZER) @@ -49,6 +50,9 @@ if(CLANG_ENABLE_PROTO_FUZZER) # Build the protobuf->C++ translation library and driver. add_clang_subdirectory(proto-to-cxx) + + # Build the protobuf->LLVM IR translation library and driver. + add_clang_subdirectory(proto-to-llvm) # Build the fuzzer initialization library. add_clang_subdirectory(fuzzer-initialize) @@ -65,29 +69,45 @@ if(CLANG_ENABLE_PROTO_FUZZER) ExampleClangLoopProtoFuzzer.cpp ) + # Build the llvm protobuf fuzzer + add_clang_executable(clang-llvm-proto-fuzzer +${DUMMY_MAIN} +ExampleClangLLVMProtoFuzzer.cpp +) + set(COMMON_PROTO_FUZZ_LIBRARIES ${ProtobufMutator_LIBRARIES} ${PROTOBUF_LIBRARIES} ${LLVM_LIB_FUZZING_ENGINE} clangFuzzerInitialize -clangHandleCXX ) target_link_libraries(clang-proto-fuzzer PRIVATE ${COMMON_PROTO_FUZZ_LIBRARIES} +clangHandleCXX clangCXXProto clangProtoToCXX ) target_link_libraries(clang-loop-proto-fuzzer PRIVATE ${COMMON_PROTO_FUZZ_LIBRARIES} +clangHandleCXX clangCXXLoopProto clangLoopProtoToCXX ) + target_link_libraries(clang-llvm-proto-fuzzer +PRIVATE +${COMMON_PROTO_FUZZ_LIBRARIES} +clangHandleLLVM +clangCXXLoopProto +clangLoopProtoToLLVM +) + endif() add_clang_subdirectory(handle-cxx) +add_clang_subdirectory(handle-llvm) add_clang_executable(clang-fuzzer EXCLUDE_FROM_ALL Added: cfe/trunk/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp?rev=335374=auto == --- cfe/trunk/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp (added) +++ cfe/trunk/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp Fri Jun 22 11:05:00 2018 @@ -0,0 +1,28 @@ +//===-- ExampleClangLLVMProtoFuzzer.cpp - Fuzz Clang --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// This file implements a function that compiles a single LLVM IR string as +/// input and uses libprotobuf-mutator to find new inputs. This function is +/// then linked into the Fuzzer library. +/// +//===--===// + +#include "cxx_loop_proto.pb.h" +#include "fuzzer-initialize/fuzzer_initialize.h" +#include "handle-llvm/handle_llvm.h" +#include "proto-to-llvm/loop_proto_to_llvm.h" +#include "src/libfuzzer/libfuzzer_macro.h" + +using namespace clang_fuzzer; + +DEFINE_BINARY_PROTO_FUZZER(const LoopFunction ) { + auto S = LoopFunctionToLLVMString(input); + HandleLLVM(S, GetCLArgs()); +} Modified: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto?rev=335374=335373=335374=diff
[PATCH] D47301: Warning for framework include violation from Headers to PrivateHeaders
bruno added a comment. Ping! https://reviews.llvm.org/D47301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335385 - Re-land "[LTO] Enable module summary emission by default for regular LTO"
Author: tobiasvk Date: Fri Jun 22 13:23:21 2018 New Revision: 335385 URL: http://llvm.org/viewvc/llvm-project?rev=335385=rev Log: Re-land "[LTO] Enable module summary emission by default for regular LTO" Since we are now producing a summary also for regular LTO builds, we need to run the NameAnonGlobals pass in those cases as well (the summary cannot handle anonymous globals). See https://reviews.llvm.org/D34156 for details on the original change. This reverts commit 6c9ee4a4a438a8059aacc809b2dd57128fccd6b3. Added: cfe/trunk/test/CodeGen/emit-summary-index.c Removed: cfe/trunk/test/Misc/thinlto.c Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/lto-newpm-pipeline.c Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=335385=335384=335385=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Jun 22 13:23:21 2018 @@ -110,7 +110,7 @@ CODEGENOPT(LessPreciseFPMAD , 1, 0) /// ///< be generated. CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the ///< compile step. -CODEGENOPT(EmitSummaryIndex, 1, 0) ///< Set when -flto=thin is enabled on the +CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the ///< compile step. CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole ///< program vtable opt). Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=335385=335384=335385=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jun 22 13:23:21 2018 @@ -524,7 +524,7 @@ void EmitAssemblyHelper::CreatePasses(le PMBuilder.Inliner = createFunctionInliningPass( CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize, (!CodeGenOpts.SampleProfileFile.empty() && - CodeGenOpts.EmitSummaryIndex)); + CodeGenOpts.PrepareForThinLTO)); } PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel; @@ -534,7 +534,7 @@ void EmitAssemblyHelper::CreatePasses(le PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions; - PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex; + PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO; PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO; PMBuilder.RerollLoops = CodeGenOpts.RerollLoops; @@ -776,7 +776,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba break; case Backend_EmitBC: -if (CodeGenOpts.EmitSummaryIndex) { +if (CodeGenOpts.PrepareForThinLTO) { if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) { ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile); if (!ThinLinkOS) @@ -784,10 +784,20 @@ void EmitAssemblyHelper::EmitAssembly(Ba } PerModulePasses.add(createWriteThinLTOBitcodePass( *OS, ThinLinkOS ? >os() : nullptr)); -} -else +} else { + // Emit a module summary by default for Regular LTO except for ld64 + // targets + bool EmitLTOSummary = + (CodeGenOpts.PrepareForLTO && + llvm::Triple(TheModule->getTargetTriple()).getVendor() != + llvm::Triple::Apple); + if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO")) +TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); + PerModulePasses.add( - createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists)); + createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, + EmitLTOSummary)); +} break; case Backend_EmitLL: @@ -935,7 +945,7 @@ void EmitAssemblyHelper::EmitAssemblyWit ModulePassManager MPM(CodeGenOpts.DebugPassManager); if (!CodeGenOpts.DisableLLVMPasses) { -bool IsThinLTO = CodeGenOpts.EmitSummaryIndex; +bool IsThinLTO = CodeGenOpts.PrepareForThinLTO; bool IsLTO = CodeGenOpts.PrepareForLTO; if (CodeGenOpts.OptimizationLevel == 0) { @@ -950,8 +960,8 @@ void EmitAssemblyHelper::EmitAssemblyWit if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass())); - // Lastly, add a semantically necessary pass for ThinLTO. - if (IsThinLTO) + // Lastly, add a semantically necessary pass for LTO. + if (IsLTO ||
r335382 - Reinstate quotes around the path to python that I accidentaly removed in r335330
Author: d0k Date: Fri Jun 22 13:03:32 2018 New Revision: 335382 URL: http://llvm.org/viewvc/llvm-project?rev=335382=rev Log: Reinstate quotes around the path to python that I accidentaly removed in r335330 This broke users with spaces in the path, like C:\Program Files\Python Modified: cfe/trunk/test/lit.cfg.py Modified: cfe/trunk/test/lit.cfg.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335382=335381=335382=diff == --- cfe/trunk/test/lit.cfg.py (original) +++ cfe/trunk/test/lit.cfg.py Fri Jun 22 13:03:32 2018 @@ -70,7 +70,7 @@ if config.clang_examples: llvm_config.add_tool_substitutions(tools, tool_dirs) config.substitutions.append( -('%hmaptool', '%s %s' % (config.python_executable, +('%hmaptool', "'%s' %s" % (config.python_executable, os.path.join(config.llvm_tools_dir, 'hmaptool' # Plugins (loadable modules) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r335375 - Re-apply: Warning for framework headers using double quote includes
Hi Nico, > Why not enable it by default, or put it in -Wall at least? We don't like > off-by-default warnings :-) Thanks for double checking. There's an explanation/discussion in the review: https://reviews.llvm.org/D47157, let me know if you have additional questions. Cheers, -- Bruno Cardoso Lopes http://www.brunocardoso.cc ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47847: [clangd] Simplify matches in FindSymbols tests
malaperle updated this revision to Diff 152536. malaperle added a comment. Rebased. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D47847 Files: unittests/clangd/FindSymbolsTests.cpp Index: unittests/clangd/FindSymbolsTests.cpp === --- unittests/clangd/FindSymbolsTests.cpp +++ unittests/clangd/FindSymbolsTests.cpp @@ -31,9 +31,10 @@ }; // GMock helpers for matching SymbolInfos items. -MATCHER_P(Named, Name, "") { return arg.name == Name; } -MATCHER_P(InContainer, ContainerName, "") { - return arg.containerName == ContainerName; +MATCHER_P(QName, Name, "") { + if (arg.containerName.empty()) +return arg.name == Name; + return (arg.containerName + "::" + arg.name) == Name; } MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; } @@ -106,12 +107,10 @@ #include "foo.h" )cpp"); EXPECT_THAT(getSymbols("global"), - UnorderedElementsAre(AllOf(Named("GlobalStruct"), InContainer(""), - WithKind(SymbolKind::Struct)), - AllOf(Named("global_func"), InContainer(""), - WithKind(SymbolKind::Function)), - AllOf(Named("global_var"), InContainer(""), - WithKind(SymbolKind::Variable; + UnorderedElementsAre( + AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)), + AllOf(QName("global_func"), WithKind(SymbolKind::Function)), + AllOf(QName("global_var"), WithKind(SymbolKind::Variable; } TEST_F(WorkspaceSymbolsTest, Unnamed) { @@ -123,12 +122,11 @@ #include "foo.h" )cpp"); EXPECT_THAT(getSymbols("UnnamedStruct"), - ElementsAre(AllOf(Named("UnnamedStruct"), + ElementsAre(AllOf(QName("UnnamedStruct"), WithKind(SymbolKind::Variable; - EXPECT_THAT( - getSymbols("InUnnamed"), - ElementsAre(AllOf(Named("InUnnamed"), InContainer("(anonymous struct)"), -WithKind(SymbolKind::Field; + EXPECT_THAT(getSymbols("InUnnamed"), + ElementsAre(AllOf(QName("(anonymous struct)::InUnnamed"), +WithKind(SymbolKind::Field; } TEST_F(WorkspaceSymbolsTest, InMainFile) { @@ -151,28 +149,20 @@ addFile("foo.cpp", R"cpp( #include "foo.h" )cpp"); - EXPECT_THAT( - getSymbols("a"), - UnorderedElementsAre(AllOf(Named("ans1"), InContainer("")), - AllOf(Named("ai1"), InContainer("ans1")), - AllOf(Named("ans2"), InContainer("ans1")), - AllOf(Named("ai2"), InContainer("ans1::ans2"; - EXPECT_THAT(getSymbols("::"), - ElementsAre(AllOf(Named("ans1"), InContainer(""; - EXPECT_THAT(getSymbols("::a"), - ElementsAre(AllOf(Named("ans1"), InContainer(""; + EXPECT_THAT(getSymbols("a"), + UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"), + QName("ans1::ans2"), + QName("ans1::ans2::ai2"))); + EXPECT_THAT(getSymbols("::"), ElementsAre(QName("ans1"))); + EXPECT_THAT(getSymbols("::a"), ElementsAre(QName("ans1"))); EXPECT_THAT(getSymbols("ans1::"), - UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")), - AllOf(Named("ans2"), InContainer("ans1"; - EXPECT_THAT(getSymbols("::ans1"), - ElementsAre(AllOf(Named("ans1"), InContainer(""; + UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2"))); + EXPECT_THAT(getSymbols("::ans1"), ElementsAre(QName("ans1"))); EXPECT_THAT(getSymbols("::ans1::"), - UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")), - AllOf(Named("ans2"), InContainer("ans1"; - EXPECT_THAT(getSymbols("::ans1::ans2"), - ElementsAre(AllOf(Named("ans2"), InContainer("ans1"; + UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2"))); + EXPECT_THAT(getSymbols("::ans1::ans2"), ElementsAre(QName("ans1::ans2"))); EXPECT_THAT(getSymbols("::ans1::ans2::"), - ElementsAre(AllOf(Named("ai2"), InContainer("ans1::ans2"; + ElementsAre(QName("ans1::ans2::ai2"))); } TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) { @@ -201,8 +191,7 @@ #include "foo2.h" )cpp"); EXPECT_THAT(getSymbols("foo"), - UnorderedElementsAre(AllOf(Named("foo"), InContainer("")), - AllOf(Named("foo2"), InContainer(""; + UnorderedElementsAre(QName("foo"), QName("foo2"))); } TEST_F(WorkspaceSymbolsTest, GlobalNamespaceQueries) { @@ -220,13 +209,11 @@ addFile("foo.cpp", R"cpp( #include "foo.h"
[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.
NoQ added a comment. Aha, yeah, i see. It only invalidates the current stack frame, and additionally it's impossible to bring the reference into the current stack frame by reference, because, well, it's already a reference and you can't mutate a reference. Ok then! Repository: rC Clang https://reviews.llvm.org/D47044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335381 - Restore pre-r335182 behavior for naming inherited constructors as
Author: rsmith Date: Fri Jun 22 12:50:19 2018 New Revision: 335381 URL: http://llvm.org/viewvc/llvm-project?rev=335381=rev Log: Restore pre-r335182 behavior for naming inherited constructors as members of dependent contexts. This permits cases where the names before and after the '::' in a dependent inherited constructor using-declaration do not match, but where we can nonetheless tell when parsing the template that a constructor is being named. Under (open) core language DR 2070, such cases will probably be ill-formed, but r335182 does not quite give that result and didn't intend to change this, so restore the old behavior for now. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=335381=335380=335381=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Fri Jun 22 12:50:19 2018 @@ -4985,7 +4985,8 @@ public: IdentifierInfo ); ParsedType getConstructorName(IdentifierInfo , SourceLocation NameLoc, -Scope *S, CXXScopeSpec ); +Scope *S, CXXScopeSpec , +bool EnteringContext); ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo , SourceLocation NameLoc, Scope *S, CXXScopeSpec , Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=335381=335380=335381=diff == --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Jun 22 12:50:19 2018 @@ -2505,7 +2505,8 @@ bool Parser::ParseUnqualifiedId(CXXScope if (AllowConstructorName && Actions.isCurrentClassName(*Id, getCurScope(), )) { // We have parsed a constructor name. - ParsedType Ty = Actions.getConstructorName(*Id, IdLoc, getCurScope(), SS); + ParsedType Ty = Actions.getConstructorName(*Id, IdLoc, getCurScope(), SS, + EnteringContext); if (!Ty) return true; Result.setConstructorName(Ty, IdLoc, IdLoc); @@ -2555,7 +2556,8 @@ bool Parser::ParseUnqualifiedId(CXXScope << FixItHint::CreateRemoval( SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)); ParsedType Ty = Actions.getConstructorName( -*TemplateId->Name, TemplateId->TemplateNameLoc, getCurScope(), SS); +*TemplateId->Name, TemplateId->TemplateNameLoc, getCurScope(), SS, +EnteringContext); if (!Ty) return true; Result.setConstructorName(Ty, TemplateId->TemplateNameLoc, Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=335381=335380=335381=diff == --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 22 12:50:19 2018 @@ -82,11 +82,20 @@ ParsedType Sema::getInheritingConstructo ParsedType Sema::getConstructorName(IdentifierInfo , SourceLocation NameLoc, -Scope *S, CXXScopeSpec ) { +Scope *S, CXXScopeSpec , +bool EnteringContext) { CXXRecordDecl *CurClass = getCurrentClass(S, ); assert(CurClass && == CurClass->getIdentifier() && "not a constructor name"); + // When naming a constructor as a member of a dependent context (eg, in a + // friend declaration or an inherited constructor declaration), form an + // unresolved "typename" type. + if (CurClass->isDependentContext() && !EnteringContext) { +QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), ); +return ParsedType::make(T); + } + if (SS.isNotEmpty() && RequireCompleteDeclContext(SS, CurClass)) return ParsedType(); Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp?rev=335381=335380=335381=diff == --- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp (original) +++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Fri Jun 22 12:50:19 2018 @@ -199,5 +199,20 @@
[PATCH] D48503: Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM
This revision was automatically updated to reflect the committed changes. Closed by commit rC335380: Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM (authored by sbc, committed by ). Changed prior to commit: https://reviews.llvm.org/D48503?vs=152531=152535#toc Repository: rC Clang https://reviews.llvm.org/D48503 Files: tools/clang-fuzzer/handle-llvm/CMakeLists.txt Index: tools/clang-fuzzer/handle-llvm/CMakeLists.txt === --- tools/clang-fuzzer/handle-llvm/CMakeLists.txt +++ tools/clang-fuzzer/handle-llvm/CMakeLists.txt @@ -1,4 +1,10 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support) +set(LLVM_LINK_COMPONENTS + Core + IRReader + MC + Support + Analysis +) add_clang_library(clangHandleLLVM handle_llvm.cpp Index: tools/clang-fuzzer/handle-llvm/CMakeLists.txt === --- tools/clang-fuzzer/handle-llvm/CMakeLists.txt +++ tools/clang-fuzzer/handle-llvm/CMakeLists.txt @@ -1,4 +1,10 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support) +set(LLVM_LINK_COMPONENTS + Core + IRReader + MC + Support + Analysis +) add_clang_library(clangHandleLLVM handle_llvm.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335380 - Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM
Author: sbc Date: Fri Jun 22 12:44:48 2018 New Revision: 335380 URL: http://llvm.org/viewvc/llvm-project?rev=335380=rev Log: Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM Differential Revision: https://reviews.llvm.org/D48503 Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt?rev=335380=335379=335380=diff == --- cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt (original) +++ cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt Fri Jun 22 12:44:48 2018 @@ -1,4 +1,10 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support) +set(LLVM_LINK_COMPONENTS + Core + IRReader + MC + Support + Analysis +) add_clang_library(clangHandleLLVM handle_llvm.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48492: [clang-format] Add a default format style that can be used by users of `getStyle`
sammccall accepted this revision. sammccall added a comment. This revision is now accepted and ready to land. I think this should work great for us, and hopefully helps other downstream users too. (@djasper: the plan is to introduce a new style name for our tweaked version of `"file"`, and make it the default) Comment at: tools/clang-format/ClangFormat.cpp:67 static cl::opt FallbackStyle("fallback-style", cl::desc("The name of the predefined style used as a\n" My only question is if we want to do the same with DefaultFallbackStyle. Not because we have a use case for changing it right now, but because it's another string that callers of getStyle() have to hard-code. In our internal codebase, some pass "LLVM", some pass "Google", and some make it an option. Repository: rC Clang https://reviews.llvm.org/D48492 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48106: implemented proto to llvm
sbc100 added a comment. I think this broke the BUILD_SHARED_LIBS=1 build: https://reviews.llvm.org/D48503 Repository: rC Clang https://reviews.llvm.org/D48106 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48503: Fix BUILD_SHARED_LIBS=1 build of libclangHandleLLVM
sbc100 created this revision. Herald added subscribers: cfe-commits, aheejin, mgorny. Repository: rC Clang https://reviews.llvm.org/D48503 Files: tools/clang-fuzzer/handle-llvm/CMakeLists.txt Index: tools/clang-fuzzer/handle-llvm/CMakeLists.txt === --- tools/clang-fuzzer/handle-llvm/CMakeLists.txt +++ tools/clang-fuzzer/handle-llvm/CMakeLists.txt @@ -1,4 +1,10 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support) +set(LLVM_LINK_COMPONENTS + Core + IRReader + MC + Support + Analysis +) add_clang_library(clangHandleLLVM handle_llvm.cpp Index: tools/clang-fuzzer/handle-llvm/CMakeLists.txt === --- tools/clang-fuzzer/handle-llvm/CMakeLists.txt +++ tools/clang-fuzzer/handle-llvm/CMakeLists.txt @@ -1,4 +1,10 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support) +set(LLVM_LINK_COMPONENTS + Core + IRReader + MC + Support + Analysis +) add_clang_library(clangHandleLLVM handle_llvm.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335377 - [OPENMP, NVPTX] Fix reduction of the big data types/structures.
Author: abataev Date: Fri Jun 22 12:10:38 2018 New Revision: 335377 URL: http://llvm.org/viewvc/llvm-project?rev=335377=rev Log: [OPENMP, NVPTX] Fix reduction of the big data types/structures. If the shuffle is required for the reduced structures/big data type, current code may cause compiler crash because of the loading of the aggregate values. Patch fixes this problem. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=335377=335376=335377=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Jun 22 12:10:38 2018 @@ -2086,6 +2086,80 @@ static llvm::Value *createRuntimeShuffle return castValueToType(CGF, ShuffledVal, CastTy, ElemType, Loc); } +static void shuffleAndStore(CodeGenFunction , Address SrcAddr, +Address DestAddr, QualType ElemType, +llvm::Value *Offset, SourceLocation Loc) { + CGBuilderTy = CGF.Builder; + + CharUnits Size = CGF.getContext().getTypeSizeInChars(ElemType); + // Create the loop over the big sized data. + // ptr = (void*)Elem; + // ptrEnd = (void*) Elem + 1; + // Step = 8; + // while (ptr + Step < ptrEnd) + // shuffle((int64_t)*ptr); + // Step = 4; + // while (ptr + Step < ptrEnd) + // shuffle((int32_t)*ptr); + // ... + Address ElemPtr = DestAddr; + Address Ptr = SrcAddr; + Address PtrEnd = Bld.CreatePointerBitCastOrAddrSpaceCast( + Bld.CreateConstGEP(SrcAddr, 1, Size), CGF.VoidPtrTy); + for (int IntSize = 8; IntSize >= 1; IntSize /= 2) { +if (Size < CharUnits::fromQuantity(IntSize)) + continue; +QualType IntType = CGF.getContext().getIntTypeForBitwidth( +CGF.getContext().toBits(CharUnits::fromQuantity(IntSize)), +/*Signed=*/1); +llvm::Type *IntTy = CGF.ConvertTypeForMem(IntType); +Ptr = Bld.CreatePointerBitCastOrAddrSpaceCast(Ptr, IntTy->getPointerTo()); +ElemPtr = +Bld.CreatePointerBitCastOrAddrSpaceCast(ElemPtr, IntTy->getPointerTo()); +if (Size.getQuantity() / IntSize > 1) { + llvm::BasicBlock *PreCondBB = CGF.createBasicBlock(".shuffle.pre_cond"); + llvm::BasicBlock *ThenBB = CGF.createBasicBlock(".shuffle.then"); + llvm::BasicBlock *ExitBB = CGF.createBasicBlock(".shuffle.exit"); + llvm::BasicBlock *CurrentBB = Bld.GetInsertBlock(); + CGF.EmitBlock(PreCondBB); + llvm::PHINode *PhiSrc = + Bld.CreatePHI(Ptr.getType(), /*NumReservedValues=*/2); + PhiSrc->addIncoming(Ptr.getPointer(), CurrentBB); + llvm::PHINode *PhiDest = + Bld.CreatePHI(ElemPtr.getType(), /*NumReservedValues=*/2); + PhiDest->addIncoming(ElemPtr.getPointer(), CurrentBB); + Ptr = Address(PhiSrc, Ptr.getAlignment()); + ElemPtr = Address(PhiDest, ElemPtr.getAlignment()); + llvm::Value *PtrDiff = Bld.CreatePtrDiff( + PtrEnd.getPointer(), Bld.CreatePointerBitCastOrAddrSpaceCast( + Ptr.getPointer(), CGF.VoidPtrTy)); + Bld.CreateCondBr(Bld.CreateICmpSGT(PtrDiff, Bld.getInt64(IntSize - 1)), + ThenBB, ExitBB); + CGF.EmitBlock(ThenBB); + llvm::Value *Res = createRuntimeShuffleFunction( + CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc), + IntType, Offset, Loc); + CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType); + Ptr = Bld.CreateConstGEP(Ptr, 1, CharUnits::fromQuantity(IntSize)); + ElemPtr = + Bld.CreateConstGEP(ElemPtr, 1, CharUnits::fromQuantity(IntSize)); + PhiSrc->addIncoming(Ptr.getPointer(), ThenBB); + PhiDest->addIncoming(ElemPtr.getPointer(), ThenBB); + CGF.EmitBranch(PreCondBB); + CGF.EmitBlock(ExitBB); +} else { + llvm::Value *Res = createRuntimeShuffleFunction( + CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc), + IntType, Offset, Loc); + CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType); + Ptr = Bld.CreateConstGEP(Ptr, 1, CharUnits::fromQuantity(IntSize)); + ElemPtr = + Bld.CreateConstGEP(ElemPtr, 1, CharUnits::fromQuantity(IntSize)); +} +Size = Size % IntSize; + } +} + namespace { enum CopyAction : unsigned { // RemoteLaneToThread: Copy over a Reduce list from a remote lane in @@ -2227,25 +2301,30 @@ static void emitReductionListCopy( // element as this is required in all directions SrcElementAddr = Bld.CreateElementBitCast( SrcElementAddr, CGF.ConvertTypeForMem(Private->getType())); -llvm::Value *Elem = -CGF.EmitLoadOfScalar(SrcElementAddr, /*Volatile=*/false, -
Re: r335375 - Re-apply: Warning for framework headers using double quote includes
Why not enable it by default, or put it in -Wall at least? We don't like off-by-default warnings :-) On Fri, Jun 22, 2018 at 2:09 PM Bruno Cardoso Lopes via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: bruno > Date: Fri Jun 22 11:05:17 2018 > New Revision: 335375 > > URL: http://llvm.org/viewvc/llvm-project?rev=335375=rev > Log: > Re-apply: Warning for framework headers using double quote includes > > Introduce -Wquoted-include-in-framework-header, which should fire a warning > whenever a quote include appears in a framework header and suggest a > fix-it. > For instance, for header A.h added in the tests, this is how the warning > looks > like: > > ./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in > framework header, expected angle-bracketed instead > [-Wquoted-include-in-framework-header] > #include "A0.h" > ^~ > > ./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in > framework header, expected angle-bracketed instead > [-Wquoted-include-in-framework-header] > #include "B.h" > ^ > > > This helps users to prevent frameworks from using local headers when in > fact > they should be targetting system level ones. > > The warning is off by default. > > Differential Revision: https://reviews.llvm.org/D47157 > > rdar://problem/37077034 > > Added: > cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h > cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h > > cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap > cfe/trunk/test/Modules/Inputs/double-quotes/B.h > cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h > > cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap > cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json > cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h > > cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap > cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json > cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml > cfe/trunk/test/Modules/double-quotes.m > Modified: > cfe/trunk/include/clang/Basic/DiagnosticGroups.td > cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td > cfe/trunk/lib/Lex/HeaderSearch.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335375=335374=335375=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun 22 11:05:17 > 2018 > @@ -31,6 +31,7 @@ def AutoDisableVptrSanitizer : DiagGroup > def Availability : DiagGroup<"availability">; > def Section : DiagGroup<"section">; > def AutoImport : DiagGroup<"auto-import">; > +def FrameworkHdrQuotedInclude : > DiagGroup<"quoted-include-in-framework-header">; > def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">; > def CXXPre14CompatBinaryLiteral : > DiagGroup<"c++98-c++11-compat-binary-literal">; > def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335375=335374=335375=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun 22 > 11:05:17 2018 > @@ -714,6 +714,11 @@ def warn_mmap_redundant_export_as : Warn > def err_mmap_submodule_export_as : Error< >"only top-level modules can be re-exported as public">; > > +def warn_quoted_include_in_framework_header : Warning< > + "double-quoted include \"%0\" in framework header, " > + "expected angle-bracketed instead" > + >, InGroup, DefaultIgnore; > + > def warn_auto_module_import : Warning< >"treating #%select{include|import|include_next|__include_macros}0 as an > " >"import of module '%1'">, InGroup, DefaultIgnore; > > Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335375=335374=335375=diff > > == > --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) > +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Jun 22 11:05:17 2018 > @@ -621,6 +621,59 @@ static const char *copyString(StringRef >return CopyStr; > } > > +static bool isFrameworkStylePath(StringRef Path, > + SmallVectorImpl ) { > + using namespace llvm::sys; > + path::const_iterator I = path::begin(Path); > + path::const_iterator E = path::end(Path); > + > + // Detect different types of framework style paths: > + // > +
[PATCH] D48456: [Fixed Point Arithmetic] Casting between fixed point types and other arithmetic types
leonardchan updated this revision to Diff 152525. leonardchan added a comment. - Add test case for fix where 0.0r would resolve as -1 when creating a fixed point literal. Repository: rC Clang https://reviews.llvm.org/D48456 Files: include/clang/AST/ASTContext.h include/clang/AST/OperationKinds.def include/clang/AST/Type.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TargetInfo.h include/clang/Lex/LiteralSupport.h include/clang/Sema/Sema.h lib/AST/ASTContext.cpp lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/AST/Type.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGExprScalar.cpp lib/Edit/RewriteObjCFoundationAPI.cpp lib/Lex/LiteralSupport.cpp lib/Sema/Sema.cpp lib/Sema/SemaCast.cpp lib/Sema/SemaExpr.cpp lib/StaticAnalyzer/Core/ExprEngineC.cpp test/Frontend/fixed_point_bit_widths.c test/Frontend/fixed_point_conversions.c test/Frontend/fixed_point_declarations.c test/Frontend/fixed_point_errors.c test/Frontend/fixed_point_same_fbits.c Index: test/Frontend/fixed_point_same_fbits.c === --- test/Frontend/fixed_point_same_fbits.c +++ test/Frontend/fixed_point_same_fbits.c @@ -1,5 +1,5 @@ -// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -check-prefix=DEFAULT -// RUN: %clang -ffixed-point -fsame-fbits -S -emit-llvm -o - %s | FileCheck %s -check-prefix=SAME +// RUN: %clang --target=x86_64-linux -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -check-prefix=DEFAULT +// RUN: %clang --target=x86_64-linux -ffixed-point -fsame-fbits -S -emit-llvm -o - %s | FileCheck %s -check-prefix=SAME /* The scale for unsigned fixed point types should be the same as that of signed * fixed point types when -fsame-fbits is enabled. */ Index: test/Frontend/fixed_point_errors.c === --- test/Frontend/fixed_point_errors.c +++ test/Frontend/fixed_point_errors.c @@ -142,6 +142,8 @@ _Accum rk = 1.0rk;// expected-error{{invalid suffix 'rk' on integer constant}} _Accum rk = 1.0rr;// expected-error{{invalid suffix 'rr' on integer constant}} _Accum qk = 1.0qr;// expected-error{{invalid suffix 'qr' on integer constant}} +_Accum no_dec = 0k; // expected-error{{invalid suffix 'k' on integer constant}} +_Fract no_dec2 = 0r; // expected-error{{invalid suffix 'r' on integer constant}} /* Using wrong exponent notation */ _Accum dec_with_hex_exp1 = 0.1p10k;// expected-error{{invalid suffix 'p10k' on integer constant}} Index: test/Frontend/fixed_point_declarations.c === --- test/Frontend/fixed_point_declarations.c +++ test/Frontend/fixed_point_declarations.c @@ -1,5 +1,4 @@ // RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-linux | FileCheck %s -// RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-scei-ps4-ubuntu-fast | FileCheck %s // Primary fixed point types signed short _Accum s_short_accum; // CHECK-DAG: @s_short_accum = {{.*}}global i16 0, align 2 @@ -111,3 +110,18 @@ unsigned short _Fract u_short_fract_eps = 0x1p-8uhr;// CHECK-DAG: @u_short_fract_eps = {{.*}}global i8 1, align 1 unsigned _Fract u_fract_eps = 0x1p-16ur;// CHECK-DAG: @u_fract_eps = {{.*}}global i16 1, align 2 unsigned long _Fract u_long_fract_eps = 0x1p-32ulr; // CHECK-DAG: @u_long_fract_eps = {{.*}}global i32 1, align 4 + +// Zero +short _Accum short_accum_zero= 0.0hk;// CHECK-DAG: @short_accum_zero = {{.*}}global i16 0, align 2 + _Accum accum_zero = 0.0k; // CHECK-DAG: @accum_zero = {{.*}}global i32 0, align 4 +long _Accum long_accum_zero = 0.0lk;// CHECK-DAG: @long_accum_zero = {{.*}}global i64 0, align 8 +unsigned short _Accum u_short_accum_zero = 0.0uhk; // CHECK-DAG: @u_short_accum_zero = {{.*}}global i16 0, align 2 +unsigned _Accum u_accum_zero= 0.0uk;// CHECK-DAG: @u_accum_zero = {{.*}}global i32 0, align 4 +unsigned long _Accum u_long_accum_zero = 0.0ulk; // CHECK-DAG: @u_long_accum_zero= {{.*}}global i64 0, align 8 + +short _Fract short_fract_zero= 0.0hr;// CHECK-DAG: @short_fract_zero = {{.*}}global i8 0, align 1 + _Fract fract_zero = 0.0r; // CHECK-DAG: @fract_zero = {{.*}}global i16 0, align 2 +long _Fract long_fract_zero = 0.0lr;// CHECK-DAG: @long_fract_zero = {{.*}}global i32 0, align 4 +unsigned short _Fract u_short_fract_zero = 0.0uhr; // CHECK-DAG: @u_short_fract_zero = {{.*}}global i8 0, align 1 +unsigned _Fract u_fract_zero= 0.0ur;// CHECK-DAG: @u_fract_zero = {{.*}}global i16 0, align 2 +unsigned long _Fract u_long_fract_zero = 0.0ulr; //
[PATCH] D48499: [mips] Use more conservative default CPUs for MIPS on FreeBSD.
bsdjhb created this revision. bsdjhb added a reviewer: dim. Herald added subscribers: atanasyan, krytarowski, arichardson. FreeBSD defaults to mips3 for all MIPS ABIs with GCC as that is the minimum MIPS architecture FreeBSD supports. Use mips3 for MIPS64 and mips2 for MIPS32 to match. Repository: rC Clang https://reviews.llvm.org/D48499 Files: lib/Driver/ToolChains/Arch/Mips.cpp test/Driver/freebsd-mips-as.c test/Driver/freebsd.c Index: test/Driver/freebsd.c === --- test/Driver/freebsd.c +++ test/Driver/freebsd.c @@ -148,3 +148,17 @@ // RUN: %clang -target mips-unknown-freebsd %s -### -G0 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS-G %s // CHECK-MIPS-G: ld{{.*}}" "-G0" + +// Check CPU type for MIPS +// RUN: %clang -target mips-unknown-freebsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS-CPU %s +// RUN: %clang -target mipsel-unknown-freebsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS-CPU %s +// CHECK-MIPS-CPU: "-target-cpu" "mips2" + +// Check CPU type for MIPS64 +// RUN: %clang -target mips64-unknown-freebsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-CPU %s +// RUN: %clang -target mips64el-unknown-freebsd -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-MIPS64-CPU %s +// CHECK-MIPS64-CPU: "-target-cpu" "mips3" Index: test/Driver/freebsd-mips-as.c === --- test/Driver/freebsd-mips-as.c +++ test/Driver/freebsd-mips-as.c @@ -3,62 +3,62 @@ // RUN: %clang -target mips-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s -// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" +// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB" // MIPS32-EB-AS-NOT: "-KPIC" // // RUN: %clang -target mips-unknown-freebsd -### \ // RUN: -no-integrated-as -fPIC -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-PIC %s -// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" +// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB" // MIPS32-EB-PIC: "-KPIC" // // RUN: %clang -target mips-unknown-freebsd -### \ // RUN: -no-integrated-as -fpic -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-PIC-SMALL %s -// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" +// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB" // MIPS32-EB-PIC-SMALL: "-KPIC" // // RUN: %clang -target mips-unknown-freebsd -### \ // RUN: -no-integrated-as -fPIE -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-PIE %s -// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" +// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB" // MIPS32-EB-PIE: "-KPIC" // // RUN: %clang -target mips-unknown-freebsd -### \ // RUN: -no-integrated-as -fpie -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-PIE-SMALL %s -// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" +// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB" // MIPS32-EB-PIE-SMALL: "-KPIC" // // RUN: %clang -target mipsel-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s -// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL" +// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EL" // // RUN: %clang -target mips64-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s -// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB" +// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EB" // // RUN: %clang -target mips64el-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s -// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" +// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EL" // // RUN: %clang -target mips64-unknown-freebsd -mabi=n32 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-N32 %s -// MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-EB" +// MIPS-N32: as{{(.exe)?}}" "-march" "mips3" "-mabi" "n32" "-EB" // // RUN: %clang -target mipsel-unknown-freebsd -mabi=32 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s -// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL" +// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EL" // // RUN: %clang -target mips64el-unknown-freebsd -mabi=64 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s -// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64r2"
r335375 - Re-apply: Warning for framework headers using double quote includes
Author: bruno Date: Fri Jun 22 11:05:17 2018 New Revision: 335375 URL: http://llvm.org/viewvc/llvm-project?rev=335375=rev Log: Re-apply: Warning for framework headers using double quote includes Introduce -Wquoted-include-in-framework-header, which should fire a warning whenever a quote include appears in a framework header and suggest a fix-it. For instance, for header A.h added in the tests, this is how the warning looks like: ./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header] #include "A0.h" ^~ ./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header] #include "B.h" ^ This helps users to prevent frameworks from using local headers when in fact they should be targetting system level ones. The warning is off by default. Differential Revision: https://reviews.llvm.org/D47157 rdar://problem/37077034 Added: cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/double-quotes/B.h cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml cfe/trunk/test/Modules/double-quotes.m Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/lib/Lex/HeaderSearch.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335375=335374=335375=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun 22 11:05:17 2018 @@ -31,6 +31,7 @@ def AutoDisableVptrSanitizer : DiagGroup def Availability : DiagGroup<"availability">; def Section : DiagGroup<"section">; def AutoImport : DiagGroup<"auto-import">; +def FrameworkHdrQuotedInclude : DiagGroup<"quoted-include-in-framework-header">; def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">; def CXXPre14CompatBinaryLiteral : DiagGroup<"c++98-c++11-compat-binary-literal">; def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">; Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335375=335374=335375=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun 22 11:05:17 2018 @@ -714,6 +714,11 @@ def warn_mmap_redundant_export_as : Warn def err_mmap_submodule_export_as : Error< "only top-level modules can be re-exported as public">; +def warn_quoted_include_in_framework_header : Warning< + "double-quoted include \"%0\" in framework header, " + "expected angle-bracketed instead" + >, InGroup, DefaultIgnore; + def warn_auto_module_import : Warning< "treating #%select{include|import|include_next|__include_macros}0 as an " "import of module '%1'">, InGroup, DefaultIgnore; Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335375=335374=335375=diff == --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Jun 22 11:05:17 2018 @@ -621,6 +621,59 @@ static const char *copyString(StringRef return CopyStr; } +static bool isFrameworkStylePath(StringRef Path, + SmallVectorImpl ) { + using namespace llvm::sys; + path::const_iterator I = path::begin(Path); + path::const_iterator E = path::end(Path); + + // Detect different types of framework style paths: + // + // ...Foo.framework/{Headers,PrivateHeaders} + // ...Foo.framework/Versions/{A,Current}/{Headers,PrivateHeaders} + // ...Foo.framework/Frameworks/Nested.framework/{Headers,PrivateHeaders} + // ... + // + // and some other variations among these lines. + int FoundComp = 0; + while (I != E) { +if (I->endswith(".framework")) { + FrameworkName.append(I->begin(), I->end()); +
[PATCH] D48493: [HIP] Support flush denorms bitcode
yaxunl added a comment. I think we should have a lit test for linked bitcode files. Comment at: lib/Driver/ToolChains/HIP.cpp:78 +std::string OCLC_daz_opt; +if (Args.hasArg(options::OPT_fcuda_flush_denormals_to_zero)) + OCLC_daz_opt = "oclc_daz_opt_on.amdgcn.bc"; you can use StringRef here. Please use a more meaningful name, e.g. FlushDenormalControlBC. Repository: rC Clang https://reviews.llvm.org/D48493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48412: [RISCV] Add support for interrupt attribute
apazos added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:8966 + +const RISCVInterruptAttr *Attr = FD->getAttr(); +if (!Attr) aaron.ballman wrote: > You can use `const auto *` here instead of repeating the type. Thanks Aaron, will do the cleanup. Comment at: lib/Sema/SemaDeclAttr.cpp:5280 + // Check the attribute arguments. + if (AL.getNumArgs() > 1) { +S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) aaron.ballman wrote: > Please call `checkAttributeNumArgs()` instead; the error you're using is > incorrect (it's used for variadic parameters where you receive more arguments > than you expect). The argument is optional and at most one argument , I will use checkAttributeAtMostNumArgs instead Comment at: lib/Sema/SemaDeclAttr.cpp:5301 + + if (!isFunctionOrMethod(D)) { +S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) aaron.ballman wrote: > I don't think you need to perform this check -- I believe it's handled > automatically (because you don't have custom parsing enabled). I think need it. Will double check in the test. Comment at: test/Sema/riscv-interrupt-attr.c:18 + +__attribute__((interrupt("user"), interrupt("supervisor"))) void foo6() { } // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ +// expected-note {{repeated RISC-V 'interrupt' attribute is here}} aaron.ballman wrote: > You should also add tests for: > ``` > __attribute__((interrupt("user"))) void f(void); > __attribute__((interrupt("machine"))) void f(void); > > void f(void) { } > > [[gnu::interrupt("user") gnu::interrupt("machine")]] void g() {} > > [[gnu::interrupt("user")]] [[gnu::interrupt("machine")]] void h() {} > ``` For this test case tt seems LLVM honors the last setting, "machine". But gcc is honoring the first. I think the last setting should prevail. Will check with GCC folks. Comment at: test/Sema/riscv-interrupt-attr.c:26 +__attribute__((interrupt("machine"))) void foo10() {} +__attribute__((interrupt(""))) void foo11() {} +__attribute__((interrupt())) void foo12() {} aaron.ballman wrote: > I'm a bit surprised that this is not an error -- the argument is provided, so > I don't know why this should be treated as acceptable. Good catch, In include/clang/Basic/Attr.td I mapped "" to the default machine mode. I will change it to align with GCC behavior. https://reviews.llvm.org/D48412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48493: [HIP] Support flush denorms bitcode
scchan added a comment. LGTM Repository: rC Clang https://reviews.llvm.org/D48493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48493: [HIP] Support flush denorms bitcode
b-sumner added a comment. LGTM Repository: rC Clang https://reviews.llvm.org/D48493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335372 - [NFC] Fix AttributeList allocated_size for ParsedType.
Author: erichkeane Date: Fri Jun 22 10:34:44 2018 New Revision: 335372 URL: http://llvm.org/viewvc/llvm-project?rev=335372=rev Log: [NFC] Fix AttributeList allocated_size for ParsedType. This if/elseif structure seems to be missing this case. Previously, this would report a size of 1 pointer too small. This didn't really change anything besides failing to reclaim a very small amount of memory. Modified: cfe/trunk/lib/Sema/AttributeList.cpp Modified: cfe/trunk/lib/Sema/AttributeList.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=335372=335371=335372=diff == --- cfe/trunk/lib/Sema/AttributeList.cpp (original) +++ cfe/trunk/lib/Sema/AttributeList.cpp Fri Jun 22 10:34:44 2018 @@ -40,6 +40,8 @@ size_t AttributeList::allocated_size() c return AttributeFactory::TypeTagForDatatypeAllocSize; else if (IsProperty) return AttributeFactory::PropertyAllocSize; + else if (HasParsedType) +return sizeof(AttributeList) + sizeof(void *); return (sizeof(AttributeList) + NumArgs * sizeof(ArgsUnion)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48493: [HIP] Support flush denorms bitcode
ashi1 created this revision. ashi1 added a reviewer: yaxunl. ashi1 added projects: clang, AMDGPU. Herald added a subscriber: cfe-commits. We need to use oclc_daz_opt_on.amdgcn.bc bitcode when option fcuda-flush-denormal-to-zero is enabled for HIP. Repository: rC Clang https://reviews.llvm.org/D48493 Files: lib/Driver/ToolChains/HIP.cpp Index: lib/Driver/ToolChains/HIP.cpp === --- lib/Driver/ToolChains/HIP.cpp +++ lib/Driver/ToolChains/HIP.cpp @@ -75,10 +75,16 @@ std::string ISAVerBC = "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc"; +std::string OCLC_daz_opt; +if (Args.hasArg(options::OPT_fcuda_flush_denormals_to_zero)) + OCLC_daz_opt = "oclc_daz_opt_on.amdgcn.bc"; +else + OCLC_daz_opt = "oclc_daz_opt_off.amdgcn.bc"; + BCLibs.append({"opencl.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc", "oclc_finite_only_off.amdgcn.bc", - "oclc_daz_opt_off.amdgcn.bc", + OCLC_daz_opt, "oclc_correctly_rounded_sqrt_on.amdgcn.bc", "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC}); } Index: lib/Driver/ToolChains/HIP.cpp === --- lib/Driver/ToolChains/HIP.cpp +++ lib/Driver/ToolChains/HIP.cpp @@ -75,10 +75,16 @@ std::string ISAVerBC = "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc"; +std::string OCLC_daz_opt; +if (Args.hasArg(options::OPT_fcuda_flush_denormals_to_zero)) + OCLC_daz_opt = "oclc_daz_opt_on.amdgcn.bc"; +else + OCLC_daz_opt = "oclc_daz_opt_off.amdgcn.bc"; + BCLibs.append({"opencl.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc", "oclc_finite_only_off.amdgcn.bc", - "oclc_daz_opt_off.amdgcn.bc", + OCLC_daz_opt, "oclc_correctly_rounded_sqrt_on.amdgcn.bc", "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC}); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48492: [clang-format] Add a default format style that can be used by users of `getStyle`
ioeric created this revision. ioeric added reviewers: sammccall, djasper. Herald added a subscriber: cfe-commits. Tools that reformat code often call `getStyle` to decide the format style to use on a certain source file. In practice, "file" style is widely used. As a result, many tools hardcode "file" when calling `getStyle`, which makes it hard to control the default style in tools across a codebase when needed. This change introduces a `DefaultFormatStyle` constant (default to "file" in upstream), which can be modified downstream if wanted, so that all users/tools built from the same source tree can have a consistent default format style. Repository: rC Clang https://reviews.llvm.org/D48492 Files: include/clang/Format/Format.h lib/Format/Format.cpp tools/clang-format/ClangFormat.cpp Index: tools/clang-format/ClangFormat.cpp === --- tools/clang-format/ClangFormat.cpp +++ tools/clang-format/ClangFormat.cpp @@ -60,9 +60,9 @@ "Can only be used with one input file."), cl::cat(ClangFormatCategory)); static cl::opt -Style("style", - cl::desc(clang::format::StyleOptionHelpDescription), - cl::init("file"), cl::cat(ClangFormatCategory)); +Style("style", cl::desc(clang::format::StyleOptionHelpDescription), + cl::init(clang::format::DefaultFormatStyle), + cl::cat(ClangFormatCategory)); static cl::opt FallbackStyle("fallback-style", cl::desc("The name of the predefined style used as a\n" Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -2144,6 +2144,8 @@ return GuessedLanguage; } +const char *DefaultFormatStyle = "file"; + llvm::Expected getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyleName, StringRef Code, vfs::FileSystem *FS) { Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -1963,6 +1963,11 @@ /// of ``getStyle()``. extern const char *StyleOptionHelpDescription; +/// The suggested format style to use by default. This allows tools using +/// `getStyle` to have a consistent default style. +/// Different builds can modify the value to the preferred styles. +extern const char *DefaultFormatStyle; + /// Construct a FormatStyle based on ``StyleName``. /// /// ``StyleName`` can take several forms: Index: tools/clang-format/ClangFormat.cpp === --- tools/clang-format/ClangFormat.cpp +++ tools/clang-format/ClangFormat.cpp @@ -60,9 +60,9 @@ "Can only be used with one input file."), cl::cat(ClangFormatCategory)); static cl::opt -Style("style", - cl::desc(clang::format::StyleOptionHelpDescription), - cl::init("file"), cl::cat(ClangFormatCategory)); +Style("style", cl::desc(clang::format::StyleOptionHelpDescription), + cl::init(clang::format::DefaultFormatStyle), + cl::cat(ClangFormatCategory)); static cl::opt FallbackStyle("fallback-style", cl::desc("The name of the predefined style used as a\n" Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -2144,6 +2144,8 @@ return GuessedLanguage; } +const char *DefaultFormatStyle = "file"; + llvm::Expected getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyleName, StringRef Code, vfs::FileSystem *FS) { Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -1963,6 +1963,11 @@ /// of ``getStyle()``. extern const char *StyleOptionHelpDescription; +/// The suggested format style to use by default. This allows tools using +/// `getStyle` to have a consistent default style. +/// Different builds can modify the value to the preferred styles. +extern const char *DefaultFormatStyle; + /// Construct a FormatStyle based on ``StyleName``. /// /// ``StyleName`` can take several forms: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48487: [X86][AVX512] Lowering _mm512_[max|min]_p[s|d] to native IR
greened added a comment. In https://reviews.llvm.org/D48487#1140703, @RKSimon wrote: > I haven't used the AVX512 versions, but I do know plenty of cases that rely > on the 'use the second op if there is a NAN or both zeros' special cases in > the SSE version of these FMIN/FMAX intrinsics. Yes, this behavior is important for AVX512 as well. Any lowering must preserve the full semantics of the intrinsics. Repository: rC Clang https://reviews.llvm.org/D48487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions
sbc100 added a comment. OK, I made this target specific. I think this is cleaner now. Repository: rC Clang https://reviews.llvm.org/D48443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions
sbc100 updated this revision to Diff 152505. sbc100 added a comment. - feedback Repository: rC Clang https://reviews.llvm.org/D48443 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/no-prototype.c Index: test/CodeGen/no-prototype.c === --- /dev/null +++ test/CodeGen/no-prototype.c @@ -0,0 +1,20 @@ +// REQUIRES: webassembly-registered-target +// RUN: %clang_cc1 -triple wasm32 -emit-llvm %s -o - | FileCheck %s + +int foo(); + +int bar(int a) { + return foo(); +} + +int baz() { + return foo(); +} + +// CHECK: define i32 @bar(i32 %a) [[BAR_ATTR:#[0-9]+]] { +// CHECK: declare i32 @foo(...) [[FOO_ATTR:#[0-9]+]] +// CHECK: define i32 @baz() [[BAZ_ATTR:#[0-9]+]] { + +// CHECK: attributes [[FOO_ATTR]] = { {{.*}}"no-prototype"{{.*}} } +// CHECK-NOT: attributes [[BAR_ATTR]] = { {{.*}}"no-prototype"{{.*}} } +// CHECK-NOT: attributes [[BAZ_ATTR]] = { {{.*}}"no-prototype"{{.*}} } Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -747,6 +747,15 @@ public: explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes ) : TargetCodeGenInfo(new WebAssemblyABIInfo(CGT)) {} + + void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule ) const override { +if (auto *FD = dyn_cast_or_null(D)) { + llvm::Function *Fn = cast(GV); + if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype()) +Fn->addFnAttr("no-prototype"); +} + } }; /// Classify argument of given type \p Ty. Index: test/CodeGen/no-prototype.c === --- /dev/null +++ test/CodeGen/no-prototype.c @@ -0,0 +1,20 @@ +// REQUIRES: webassembly-registered-target +// RUN: %clang_cc1 -triple wasm32 -emit-llvm %s -o - | FileCheck %s + +int foo(); + +int bar(int a) { + return foo(); +} + +int baz() { + return foo(); +} + +// CHECK: define i32 @bar(i32 %a) [[BAR_ATTR:#[0-9]+]] { +// CHECK: declare i32 @foo(...) [[FOO_ATTR:#[0-9]+]] +// CHECK: define i32 @baz() [[BAZ_ATTR:#[0-9]+]] { + +// CHECK: attributes [[FOO_ATTR]] = { {{.*}}"no-prototype"{{.*}} } +// CHECK-NOT: attributes [[BAR_ATTR]] = { {{.*}}"no-prototype"{{.*}} } +// CHECK-NOT: attributes [[BAZ_ATTR]] = { {{.*}}"no-prototype"{{.*}} } Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -747,6 +747,15 @@ public: explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes ) : TargetCodeGenInfo(new WebAssemblyABIInfo(CGT)) {} + + void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule ) const override { +if (auto *FD = dyn_cast_or_null(D)) { + llvm::Function *Fn = cast(GV); + if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype()) +Fn->addFnAttr("no-prototype"); +} + } }; /// Classify argument of given type \p Ty. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335366 - Add const qualifier on FieldChainInfoComparator::operator()
Author: steven_wu Date: Fri Jun 22 09:51:17 2018 New Revision: 335366 URL: http://llvm.org/viewvc/llvm-project?rev=335366=rev Log: Add const qualifier on FieldChainInfoComparator::operator() libcxx has user defined warning to check for non const call operator. Silence the warning by adding the const on operator(). Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp?rev=335366=335365=335366=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Fri Jun 22 09:51:17 2018 @@ -85,7 +85,7 @@ private: }; struct FieldChainInfoComparator { - bool operator()(const FieldChainInfo , const FieldChainInfo ) { + bool operator()(const FieldChainInfo , const FieldChainInfo ) const { assert(!lhs.Chain.isEmpty() && !rhs.Chain.isEmpty() && "Attempted to store an empty fieldchain!"); return *lhs.Chain.begin() < *rhs.Chain.begin(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r335330 - [hmaptool] Turn %hmaptool into a proper substitution
Thanks Ben! On Fri, Jun 22, 2018 at 2:51 AM Benjamin Kramer via cfe-commits wrote: > > Author: d0k > Date: Fri Jun 22 02:46:40 2018 > New Revision: 335330 > > URL: http://llvm.org/viewvc/llvm-project?rev=335330=rev > Log: > [hmaptool] Turn %hmaptool into a proper substitution > > This is still super ugly, but at least it doesn't require working > directories to just line up perfectly for python to find the tool. > > Modified: > cfe/trunk/test/Modules/crash-vfs-headermaps.m > cfe/trunk/test/Preprocessor/headermap-rel.c > cfe/trunk/test/Preprocessor/headermap-rel2.c > cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c > cfe/trunk/test/lit.cfg.py > > Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335330=335329=335330=diff > == > --- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original) > +++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Fri Jun 22 02:46:40 2018 > @@ -3,7 +3,7 @@ > // RUN: rm -rf %t > // RUN: mkdir -p %t/m %t/i/Foo.framework/Headers > // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h > -// RUN: '%python' hmaptool write > %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap > +// RUN: %hmaptool write > %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap > > // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ > // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \ > > Modified: cfe/trunk/test/Preprocessor/headermap-rel.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel.c?rev=335330=335329=335330=diff > == > --- cfe/trunk/test/Preprocessor/headermap-rel.c (original) > +++ cfe/trunk/test/Preprocessor/headermap-rel.c Fri Jun 22 02:46:40 2018 > @@ -1,5 +1,5 @@ > // RUN: rm -f %t.hmap > -// RUN: '%python' hmaptool write %S/Inputs/headermap-rel/foo.hmap.json > %t.hmap > +// RUN: %hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap > // RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel > // RUN: FileCheck %s -input-file %t.i > > > Modified: cfe/trunk/test/Preprocessor/headermap-rel2.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel2.c?rev=335330=335329=335330=diff > == > --- cfe/trunk/test/Preprocessor/headermap-rel2.c (original) > +++ cfe/trunk/test/Preprocessor/headermap-rel2.c Fri Jun 22 02:46:40 2018 > @@ -1,5 +1,5 @@ > // RUN: rm -f %t.hmap > -// RUN: '%python' hmaptool write > %S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap > +// RUN: %hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json > %t.hmap > // RUN: %clang_cc1 -v -fsyntax-only %s -iquote %t.hmap -isystem > %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H > // RUN: %clang_cc1 -fsyntax-only %s -iquote %t.hmap -isystem > %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> > %t.out > // RUN: FileCheck %s -input-file %t.out > > Modified: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c?rev=335330=335329=335330=diff > == > --- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c (original) > +++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Fri Jun 22 > 02:46:40 2018 > @@ -1,5 +1,5 @@ > // RUN: rm -f %t.hmap > -// RUN: '%python' hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json > %t.hmap > +// RUN: %hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap > // RUN: %clang_cc1 -Eonly\ > // RUN: -I%t.hmap \ > // RUN: -I%S/Inputs/nonportable-hmaps \ > > Modified: cfe/trunk/test/lit.cfg.py > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335330=335329=335330=diff > == > --- cfe/trunk/test/lit.cfg.py (original) > +++ cfe/trunk/test/lit.cfg.py Fri Jun 22 02:46:40 2018 > @@ -58,7 +58,7 @@ tool_dirs = [config.clang_tools_dir, con > > tools = [ > 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', > 'clang-tblgen', > -'opt', 'hmaptool', > +'opt', > ToolSubst('%clang_func_map', command=FindTool( > 'clang-func-mapping'), unresolved='ignore'), > ] > @@ -69,6 +69,10 @@ if config.clang_examples: > > llvm_config.add_tool_substitutions(tools, tool_dirs) > > +config.substitutions.append( > +('%hmaptool', '%s %s' % (config.python_executable, > + os.path.join(config.llvm_tools_dir, >
r335362 - [OpenCL] Fixed parsing of address spaces for C++.
Author: stulova Date: Fri Jun 22 09:20:21 2018 New Revision: 335362 URL: http://llvm.org/viewvc/llvm-project?rev=335362=rev Log: [OpenCL] Fixed parsing of address spaces for C++. Added address space tokens to C++ parsing code to be able to parse declarations that start from an address space keyword. Modified: cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/test/SemaOpenCL/address-spaces.cl Modified: cfe/trunk/lib/Parse/ParseTentative.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=335362=335361=335362=diff == --- cfe/trunk/lib/Parse/ParseTentative.cpp (original) +++ cfe/trunk/lib/Parse/ParseTentative.cpp Fri Jun 22 09:20:21 2018 @@ -1357,6 +1357,11 @@ Parser::isCXXDeclarationSpecifier(Parser // cv-qualifier case tok::kw_const: case tok::kw_volatile: + case tok::kw___private: + case tok::kw___local: + case tok::kw___global: + case tok::kw___constant: + case tok::kw___generic: // GNU case tok::kw_restrict: Modified: cfe/trunk/test/SemaOpenCL/address-spaces.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/address-spaces.cl?rev=335362=335361=335362=diff == --- cfe/trunk/test/SemaOpenCL/address-spaces.cl (original) +++ cfe/trunk/test/SemaOpenCL/address-spaces.cl Fri Jun 22 09:20:21 2018 @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -cl-std=c++ -verify -pedantic -fsyntax-only __constant int ci = 1; @@ -8,6 +9,8 @@ __kernel void foo(__global int *gip) { __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}} int *ip; +// FIXME: Temporarily disable part of the test that doesn't work for C++ yet. +#if !__OPENCL_CPP_VERSION__ #if __OPENCL_C_VERSION__ < 200 ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}} ip = // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}} @@ -64,4 +67,5 @@ void func_multiple_addr(void) { __local private_int_t *var4; // expected-error {{multiple address spaces specified for type}} __private private_int_t var5; // expected-warning {{multiple identical address spaces specified for type}} __private private_int_t *var6;// expected-warning {{multiple identical address spaces specified for type}} +#endif // !__OPENCL_CXX_VERSION__ } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48475: [clangd] More precise representation of symbol names/labels in the index.
This revision was automatically updated to reflect the committed changes. sammccall marked an inline comment as done. Closed by commit rCTE335360: [clangd] More precise representation of symbol names/labels in the index. (authored by sammccall, committed by ). Changed prior to commit: https://reviews.llvm.org/D48475?vs=152442=152488#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48475 Files: clangd/CodeComplete.cpp clangd/CodeCompletionStrings.cpp clangd/CodeCompletionStrings.h clangd/index/Index.cpp clangd/index/Index.h clangd/index/Merge.cpp clangd/index/SymbolCollector.cpp clangd/index/SymbolYAML.cpp unittests/clangd/CodeCompleteTests.cpp unittests/clangd/CodeCompletionStringsTests.cpp unittests/clangd/FileIndexTests.cpp unittests/clangd/IndexTests.cpp unittests/clangd/SymbolCollectorTests.cpp Index: unittests/clangd/CodeCompletionStringsTests.cpp === --- unittests/clangd/CodeCompletionStringsTests.cpp +++ unittests/clangd/CodeCompletionStringsTests.cpp @@ -23,24 +23,23 @@ CCTUInfo(Allocator), Builder(*Allocator, CCTUInfo) {} protected: - void labelAndInsertText(const CodeCompletionString , - bool EnableSnippets = false) { -Label.clear(); -InsertText.clear(); -getLabelAndInsertText(CCS, , , EnableSnippets); + void computeSignature(const CodeCompletionString ) { +Signature.clear(); +Snippet.clear(); +getSignature(CCS, , ); } std::shared_ptr Allocator; CodeCompletionTUInfo CCTUInfo; CodeCompletionBuilder Builder; - std::string Label; - std::string InsertText; + std::string Signature; + std::string Snippet; }; -TEST_F(CompletionStringTest, Detail) { +TEST_F(CompletionStringTest, ReturnType) { Builder.AddResultTypeChunk("result"); Builder.AddResultTypeChunk("redundant result no no"); - EXPECT_EQ(getDetail(*Builder.TakeString()), "result"); + EXPECT_EQ(getReturnType(*Builder.TakeString()), "result"); } TEST_F(CompletionStringTest, Documentation) { @@ -65,31 +64,15 @@ "Annotations: Ano1 Ano2 Ano3\n"); } -TEST_F(CompletionStringTest, SimpleLabelAndInsert) { +TEST_F(CompletionStringTest, EmptySignature) { Builder.AddTypedTextChunk("X"); Builder.AddResultTypeChunk("result no no"); - labelAndInsertText(*Builder.TakeString()); - EXPECT_EQ(Label, "X"); - EXPECT_EQ(InsertText, "X"); + computeSignature(*Builder.TakeString()); + EXPECT_EQ(Signature, ""); + EXPECT_EQ(Snippet, ""); } -TEST_F(CompletionStringTest, FunctionPlainText) { - Builder.AddResultTypeChunk("result no no"); - Builder.AddTypedTextChunk("Foo"); - Builder.AddChunk(CodeCompletionString::CK_LeftParen); - Builder.AddPlaceholderChunk("p1"); - Builder.AddChunk(CodeCompletionString::CK_Comma); - Builder.AddPlaceholderChunk("p2"); - Builder.AddChunk(CodeCompletionString::CK_RightParen); - Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); - Builder.AddInformativeChunk("const"); - - labelAndInsertText(*Builder.TakeString()); - EXPECT_EQ(Label, "Foo(p1, p2) const"); - EXPECT_EQ(InsertText, "Foo"); -} - -TEST_F(CompletionStringTest, FunctionSnippet) { +TEST_F(CompletionStringTest, Function) { Builder.AddResultTypeChunk("result no no"); Builder.addBriefComment("This comment is ignored"); Builder.AddTypedTextChunk("Foo"); @@ -100,13 +83,9 @@ Builder.AddChunk(CodeCompletionString::CK_RightParen); auto *CCS = Builder.TakeString(); - labelAndInsertText(*CCS); - EXPECT_EQ(Label, "Foo(p1, p2)"); - EXPECT_EQ(InsertText, "Foo"); - - labelAndInsertText(*CCS, /*EnableSnippets=*/true); - EXPECT_EQ(Label, "Foo(p1, p2)"); - EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})"); + computeSignature(*CCS); + EXPECT_EQ(Signature, "(p1, p2)"); + EXPECT_EQ(Snippet, "(${1:p1}, ${2:p2})"); EXPECT_EQ(formatDocumentation(*CCS, "Foo's comment"), "Foo's comment"); } @@ -116,18 +95,18 @@ Builder.AddPlaceholderChunk("$p}1\\"); Builder.AddChunk(CodeCompletionString::CK_RightParen); - labelAndInsertText(*Builder.TakeString(), /*EnableSnippets=*/true); - EXPECT_EQ(Label, "Foo($p}1\\)"); - EXPECT_EQ(InsertText, "Foo(${1:\\$p\\}1})"); + computeSignature(*Builder.TakeString()); + EXPECT_EQ(Signature, "($p}1\\)"); + EXPECT_EQ(Snippet, "(${1:\\$p\\}1})"); } TEST_F(CompletionStringTest, IgnoreInformativeQualifier) { Builder.AddTypedTextChunk("X"); Builder.AddInformativeChunk("info ok"); Builder.AddInformativeChunk("info no no::"); - labelAndInsertText(*Builder.TakeString()); - EXPECT_EQ(Label, "Xinfo ok"); - EXPECT_EQ(InsertText, "X"); + computeSignature(*Builder.TakeString()); + EXPECT_EQ(Signature, "info ok"); + EXPECT_EQ(Snippet, ""); } } // namespace Index: unittests/clangd/SymbolCollectorTests.cpp === --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@
[clang-tools-extra] r335360 - [clangd] More precise representation of symbol names/labels in the index.
Author: sammccall Date: Fri Jun 22 09:11:35 2018 New Revision: 335360 URL: http://llvm.org/viewvc/llvm-project?rev=335360=rev Log: [clangd] More precise representation of symbol names/labels in the index. Summary: Previously, the strings matched LSP completion pretty closely. The completion label was a single string, for instance. This made implementing completion itself easy but makes it hard to use the names in other way, e.g. pretty-printed name in synthesized documentation/hover. It also limits our introspection into completion items, which can only be as precise as the indexed symbols. This change is a prerequisite to improvements to overload bundling which need to inspect e.g. signature structure. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48475 Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.h clang-tools-extra/trunk/clangd/index/Index.cpp clang-tools-extra/trunk/clangd/index/Index.h clang-tools-extra/trunk/clangd/index/Merge.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=335360=335359=335360=diff == --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Jun 22 09:11:35 2018 @@ -249,17 +249,21 @@ struct CompletionCandidate { CompletionItem I; bool InsertingInclude = false; // Whether a new #include will be added. if (SemaResult) { - I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->Declaration); - getLabelAndInsertText(*SemaCCS, , , -Opts.EnableSnippets); - if (const char* Text = SemaCCS->getTypedText()) -I.filterText = Text; + llvm::StringRef Name(SemaCCS->getTypedText()); + std::string Signature, SnippetSuffix, Qualifiers; + getSignature(*SemaCCS, , , ); + I.label = (Qualifiers + Name + Signature).str(); + I.filterText = Name; + I.insertText = (Qualifiers + Name).str(); + if (Opts.EnableSnippets) +I.insertText += SnippetSuffix; I.documentation = formatDocumentation(*SemaCCS, SemaDocComment); - I.detail = getDetail(*SemaCCS); + I.detail = getReturnType(*SemaCCS); if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) if (const auto *D = SemaResult->getDeclaration()) if (const auto *ND = llvm::dyn_cast(D)) I.SymbolScope = splitQualifiedName(printQualifiedName(*ND)).first; + I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->Declaration); } if (IndexResult) { if (I.SymbolScope.empty()) @@ -268,21 +272,22 @@ struct CompletionCandidate { I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind); // FIXME: reintroduce a way to show the index source for debugging. if (I.label.empty()) -I.label = IndexResult->CompletionLabel; +I.label = (IndexResult->Name + IndexResult->Signature).str(); if (I.filterText.empty()) I.filterText = IndexResult->Name; // FIXME(ioeric): support inserting/replacing scope qualifiers. - if (I.insertText.empty()) -I.insertText = Opts.EnableSnippets - ? IndexResult->CompletionSnippetInsertText - : IndexResult->CompletionPlainInsertText; + if (I.insertText.empty()) { +I.insertText = IndexResult->Name; +if (Opts.EnableSnippets) + I.insertText += IndexResult->CompletionSnippetSuffix; + } if (auto *D = IndexResult->Detail) { if (I.documentation.empty()) I.documentation = D->Documentation; if (I.detail.empty()) - I.detail = D->CompletionDetail; + I.detail = D->ReturnType; if (auto Inserted = headerToInsertIfNotPresent()) { auto IncludePath = [&]() -> Expected { auto ResolvedDeclaring = toHeaderFile( Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=335360=335359=335360=diff == ---
[PATCH] D48475: [clangd] More precise representation of symbol names/labels in the index.
sammccall marked an inline comment as done. sammccall added inline comments. Comment at: clangd/CodeCompletionStrings.cpp:122 + // Typed-text chunk is the actual name. Text before it is qualifiers. + if (Qualifiers) +*Qualifiers = std::move(*Signature); ioeric wrote: > Qualifier seems a bit ambiguous for this. The documentation for > `CK_TypedText` says: > ``` > /// The piece of text that the user is expected to type to > /// match the code-completion string, typically a keyword or the name of a > /// declarator or macro. > CK_TypedText, > ``` > > For example, it could also be the keyword in "typedef ^". Maybe just > `TypedText` would be more straightforward? Changed to "RequiredQualifiers" and specified it more clearly in the method comment. Also added an implementation comment here as it's a little subtle. We're not outputting the current chunk to Qualifiers, but rather moving all the text we recorded so far. Comment at: unittests/clangd/CodeCompletionStringsTests.cpp:70 Builder.AddResultTypeChunk("result no no"); - labelAndInsertText(*Builder.TakeString()); - EXPECT_EQ(Label, "X"); - EXPECT_EQ(InsertText, "X"); + getSignature(*Builder.TakeString()); + EXPECT_EQ(Signature, ""); ioeric wrote: > nit: I find `getSignature` a bit awkward here because we are not getting > anything back. Maybe `setSignature`? Agreed. Changed to `computeSignature`. (I'm not sure the current test structure with the inputs and outputs being fixture members is great, but I don't really want to shave that yak now) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47698: [ASTImporter] import macro source locations
a.sidorin added a comment. Hi Rafael, I think the patch is great. But, honestly, I have never dealt with SourceLocation machinery closely, so some things are a bit unclear to me. Comment at: lib/AST/ASTImporter.cpp:7058 +const SrcMgr::ExpansionInfo = FromSLoc.getExpansion(); +SourceLocation ToSpLoc = Import(FromEx.getSpellingLoc()); +SourceLocation ToExLocS = Import(FromEx.getExpansionLocStart()); r.stahl wrote: > martong wrote: > > Let's say we import a `SourceLocation` with > > `ASTImporter::Import(SourceLocation FromLoc)`. > > That calls into `ASTImporter::Import(FileID FromID)` where we again import > > other source locations. > > Could the initial `FromLoc` be equal with any of these locations > > (`FromEx.getSpellingLoc()`, `FromEx.getExpansionLocStart()`) ? > > My understanding is that this is not possible because we cannot have > > recursive macros, but please confirm. > Yes, that was my understanding as well. If some compiler error is a macro > expansion it eventually stops at some point while walking this chain. If we have a macro referring another macro in the same file, will we import their FileID twice? First, during `Import(getSpellingLoc())` and then in this caller? Comment at: lib/AST/ASTImporter.cpp:7060 +SourceLocation ToExLocS = Import(FromEx.getExpansionLocStart()); +SourceLocation ToExLocE = Import(FromEx.getExpansionLocEnd()); +unsigned TokenLen = FromSM.getFileIDSize(FromID); `ToExLocE` seems to be unused in the true branch below. Could we move it into 'else' branch? Comment at: unittests/AST/ASTImporterTest.cpp:1537 + R"( + #define MFOO(arg) arg = arg + 1 + Could you please add a test with nested macros? I.e. ``` #define FUNC_INT void declToImport #define FUNC FUNC_INT FUNC(int a); ``` Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47698: [ASTImporter] import macro source locations
a.sidorin added a comment. Hi Rafael, I apologize for the delay in review and hope to get ASTImporter patches reviewed on this weekend. Comment at: lib/AST/ASTImporter.cpp:7054 + // Map the FileID for to the "to" source manager. FileID ToID; 'for to' => 'for the "from" source manager to'? Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335358 - [Sema] Updated note for address spaces to print the type.
Author: stulova Date: Fri Jun 22 08:45:08 2018 New Revision: 335358 URL: http://llvm.org/viewvc/llvm-project?rev=335358=rev Log: [Sema] Updated note for address spaces to print the type. This allows to reuse the same diagnostic for OpenCL or CUDA. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCXX/address-space-references.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=335358=335357=335358=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 22 08:45:08 2018 @@ -3683,8 +3683,8 @@ def note_ovl_candidate_bad_lvalue : Note "%select{%ordinal4 argument|object argument}3">; def note_ovl_candidate_bad_addrspace : Note< "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: " -"%select{%ordinal7|'this'}6 argument (%3) is in " -"address space %4, but parameter must be in address space %5">; +"address space mismatch in %select{%ordinal6|'this'}5 argument (%3), " +"parameter type must be %4">; def note_ovl_candidate_bad_gc : Note< "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: " "%select{%ordinal7|'this'}6 argument (%3) has %select{no|__weak|__strong}4 " Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=335358=335357=335358=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jun 22 08:45:08 2018 @@ -9591,9 +9591,7 @@ static void DiagnoseBadConversion(Sema & S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace) << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy - << FromQs.getAddressSpaceAttributePrintValue() - << ToQs.getAddressSpaceAttributePrintValue() - << (unsigned)isObjectArgument << I + 1; + << ToTy << (unsigned)isObjectArgument << I + 1; MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); return; } Modified: cfe/trunk/test/SemaCXX/address-space-references.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/address-space-references.cpp?rev=335358=335357=335358=diff == --- cfe/trunk/test/SemaCXX/address-space-references.cpp (original) +++ cfe/trunk/test/SemaCXX/address-space-references.cpp Fri Jun 22 08:45:08 2018 @@ -3,10 +3,10 @@ typedef int __attribute__((address_space(1))) int_1; typedef int __attribute__((address_space(2))) int_2; -void f0(int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \ -// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}} -void f0(const int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \ -// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}} +void f0(int_1 &); // expected-note{{candidate function not viable: address space mismatch in 1st argument ('int'), parameter type must be 'int_1 &' (aka '__attribute__((address_space(1))) int &')}} \ +// expected-note{{candidate function not viable: address space mismatch in 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')), parameter type must be 'int_1 &' (aka '__attribute__((address_space(1))) int &')}} +void f0(const int_1 &); // expected-note{{candidate function not viable: address space mismatch in 1st argument ('int'), parameter type must be 'const int_1 &' (aka 'const __attribute__((address_space(1))) int &')}} \ +// expected-note{{candidate function not viable: address space mismatch in 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')), parameter type must be 'const int_1 &' (aka 'const __attribute__((address_space(1))) int &')}} void test_f0() { int i; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48487: [X86][AVX512] Lowering _mm512_[max|min]_p[s|d] to native IR
RKSimon added a comment. I haven't used the AVX512 versions, but I do know plenty of cases that rely on the 'use the second op if there is a NAN or both zeros' special cases in the SSE version of these FMIN/FMAX intrinsics. The Intel docs state: > If the values being compared are both 0.0s (of either sign), the value in the > second operand (source operand) is returned. If a value in the second operand > is an SNaN, then SNaN is forwarded unchanged to the destination (that is, a > QNaN version of the SNaN is not returned). > If only one value is a NaN (SNaN or QNaN) for this instruction, the second > operand (source operand), either a NaN or a valid floating-point value, is > written to the result. If instead of this behavior, it is required that the > NaN source operand (from either the first or second operand) be returned, the > action of MAXPS can be emulated using a sequence of instructions, such as, a > comparison followed by AND, ANDN and OR. Repository: rC Clang https://reviews.llvm.org/D48487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48487: [X86][AVX512] Lowering _mm512_[max|min]_p[s|d] to native IR
GBuella created this revision. GBuella added reviewers: craig.topper, uriel.k, RKSimon, andrew.w.kaylor, spatel, scanon, efriedma. Herald added a subscriber: cfe-commits. Repository: rC Clang https://reviews.llvm.org/D48487 Files: lib/Headers/avx512fintrin.h test/CodeGen/avx512f-builtins.c Index: test/CodeGen/avx512f-builtins.c === --- test/CodeGen/avx512f-builtins.c +++ test/CodeGen/avx512f-builtins.c @@ -8426,23 +8426,28 @@ __m512d test_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { // CHECK-LABEL: @test_mm512_mask_max_pd - // CHECK: @llvm.x86.avx512.max.pd.512 + // CHECK: fcmp uge <8 x double> %{{.*}}, %{{.*}} + // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} return _mm512_mask_max_pd (__W,__U,__A,__B); } __m512d test_mm512_maskz_max_pd (__mmask8 __U, __m512d __A, __m512d __B) { // CHECK-LABEL: @test_mm512_maskz_max_pd - // CHECK: @llvm.x86.avx512.max.pd.512 + // CHECK: fcmp uge <8 x double> %{{.*}}, %{{.*}} + // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} + // CHECK: store <8 x double> zeroinitializer, <8 x double>* %.compoundliteral.i.i, align 64 + // CHECK: load <8 x double>, <8 x double>* %.compoundliteral.i.i, align 64 // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} return _mm512_maskz_max_pd (__U,__A,__B); } __m512 test_mm512_mask_max_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { // CHECK-LABEL: @test_mm512_mask_max_ps - // CHECK: @llvm.x86.avx512.max.ps.512 + // CHECK: fcmp uge <16 x float> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} return _mm512_mask_max_ps (__W,__U,__A,__B); } @@ -8473,7 +8478,10 @@ __m512 test_mm512_maskz_max_ps (__mmask16 __U, __m512 __A, __m512 __B) { // CHECK-LABEL: @test_mm512_maskz_max_ps - // CHECK: @llvm.x86.avx512.max.ps.512 + // CHECK: fcmp uge <16 x float> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} + // CHECK: store <16 x float> zeroinitializer, <16 x float>* %.compoundliteral.i.i, align 64 + // CHECK: load <16 x float>, <16 x float>* %.compoundliteral.i.i, align 64 // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} return _mm512_maskz_max_ps (__U,__A,__B); } @@ -8504,15 +8512,20 @@ __m512d test_mm512_mask_min_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { // CHECK-LABEL: @test_mm512_mask_min_pd - // CHECK: @llvm.x86.avx512.min.pd.512 + // CHECK: fcmp olt <8 x double> %{{.*}}, %{{.*}} + // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} return _mm512_mask_min_pd (__W,__U,__A,__B); } __m512d test_mm512_maskz_min_pd (__mmask8 __U, __m512d __A, __m512d __B) { // CHECK-LABEL: @test_mm512_maskz_min_pd - // CHECK: @llvm.x86.avx512.min.pd.512 + // CHECK: fcmp olt <8 x double> %{{.*}}, %{{.*}} + // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} + // CHECK: store <8 x double> zeroinitializer, <8 x double>* %.compoundliteral.i.i, align 64 + // CHECK: load <8 x double>, <8 x double>* %.compoundliteral.i.i, align 64 + // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}} return _mm512_maskz_min_pd (__U,__A,__B); } @@ -8542,15 +8555,19 @@ __m512 test_mm512_mask_min_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { // CHECK-LABEL: @test_mm512_mask_min_ps - // CHECK: @llvm.x86.avx512.min.ps.512 + // CHECK: fcmp olt <16 x float> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} return _mm512_mask_min_ps (__W,__U,__A,__B); } __m512 test_mm512_maskz_min_ps (__mmask16 __U, __m512 __A, __m512 __B) { // CHECK-LABEL: @test_mm512_maskz_min_ps - // CHECK: @llvm.x86.avx512.min.ps.512 + // CHECK: fcmp olt <16 x float> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} + // CHECK: store <16 x float> zeroinitializer, <16 x float>* %.compoundliteral.i.i, align 64 + // CHECK: load <16 x float>, <16 x float>* %.compoundliteral.i.i, align 64 // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} return _mm512_maskz_min_ps (__U,__A,__B); } Index: lib/Headers/avx512fintrin.h === --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -818,6 +818,118 @@ return (__m512i)((__v8du)__a ^ (__v8du)__b); } +/* Compare */ +
[PATCH] D47698: [ASTImporter] import macro source locations
martong added a comment. In https://reviews.llvm.org/D47698#1140629, @thakis wrote: > This code is live when reading pchs, correct? Does this have any measurable > perf impact on deserializing pchs for, say, Cocoa.h or Windows.h? No. The deserialization of a PCH is handled in a completely independent source code. ASTImporter is responsible to merge two ASTs. These ASTs may come from a PCH - deserialized - , or they may be provided by the parser; from the ASTImporer's point of view this is irrelevant. Thus, there is no performance impact on deserialization of PCHs. Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48441: [clangd] Incorporate transitive #includes into code complete proximity scoring.
sammccall updated this revision to Diff 152479. sammccall marked 9 inline comments as done. sammccall added a comment. Address review comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48441 Files: clangd/CMakeLists.txt clangd/ClangdServer.cpp clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/CodeComplete.cpp clangd/CodeComplete.h clangd/FileDistance.cpp clangd/FileDistance.h clangd/Headers.cpp clangd/Headers.h clangd/Quality.cpp clangd/Quality.h clangd/XRefs.cpp unittests/clangd/CMakeLists.txt unittests/clangd/FileDistanceTests.cpp unittests/clangd/HeadersTests.cpp unittests/clangd/QualityTests.cpp Index: unittests/clangd/QualityTests.cpp === --- unittests/clangd/QualityTests.cpp +++ unittests/clangd/QualityTests.cpp @@ -17,6 +17,7 @@ // //===--===// +#include "FileDistance.h" #include "Quality.h" #include "TestFS.h" #include "TestTU.h" @@ -157,9 +158,22 @@ PoorNameMatch.NameMatch = 0.2f; EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate()); - SymbolRelevanceSignals WithProximity; - WithProximity.SemaProximityScore = 0.2f; - EXPECT_GT(WithProximity.evaluate(), Default.evaluate()); + SymbolRelevanceSignals WithSemaProximity; + WithSemaProximity.SemaProximityScore = 0.2f; + EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals IndexProximate; + IndexProximate.SymbolURI = "unittest:/foo/bar.h"; + llvm::StringMap ProxRoots; + ProxRoots[testPath("foo/baz.h")] = 0; + URIDistance Distance(ProxRoots); + IndexProximate.FileProximityMatch = + EXPECT_GT(IndexProximate.evaluate(), Default.evaluate()); + SymbolRelevanceSignals IndexDistant = IndexProximate; + IndexDistant.SymbolURI = "unittest:/elsewhere/path.h"; + EXPECT_GT(IndexProximate.evaluate(), IndexDistant.evaluate()) + << IndexProximate << IndexDistant; + EXPECT_GT(IndexDistant.evaluate(), Default.evaluate()); SymbolRelevanceSignals Scoped; Scoped.Scope = SymbolRelevanceSignals::FileScope; @@ -180,59 +194,6 @@ EXPECT_LT(sortText(0, "a"), sortText(0, "z")); } -// {a,b,c} becomes /clangd-test/a/b/c -std::string joinPaths(llvm::ArrayRef Parts) { - return testPath( - llvm::join(Parts.begin(), Parts.end(), llvm::sys::path::get_separator())); -} - -static constexpr float ProximityBase = 0.7; - -// Calculates a proximity score for an index symbol with declaration file -// SymPath with the given URI scheme. -float URIProximity(const FileProximityMatcher , StringRef SymPath, - StringRef Scheme = "file") { - auto U = URI::create(SymPath, Scheme); - EXPECT_TRUE(static_cast(U)) << llvm::toString(U.takeError()); - return Matcher.uriProximity(U->toString()); -} - -TEST(QualityTests, URIProximityScores) { - FileProximityMatcher Matcher( - /*ProximityPaths=*/{joinPaths({"a", "b", "c", "d", "x"})}); - - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "x"})), - 1); - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "y"})), - ProximityBase); - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "y", "z"})), - std::pow(ProximityBase, 5)); - EXPECT_FLOAT_EQ( - URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "e", "y"})), - std::pow(ProximityBase, 2)); - EXPECT_FLOAT_EQ( - URIProximity(Matcher, joinPaths({"a", "b", "m", "n", "o", "y"})), - std::pow(ProximityBase, 5)); - EXPECT_FLOAT_EQ( - URIProximity(Matcher, joinPaths({"a", "t", "m", "n", "o", "y"})), - std::pow(ProximityBase, 6)); - // Note the common directory is /clang-test/ - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"m", "n", "o", "p", "y"})), - std::pow(ProximityBase, 7)); -} - -TEST(QualityTests, URIProximityScoresWithTestURI) { - FileProximityMatcher Matcher( - /*ProximityPaths=*/{joinPaths({"b", "c", "x"})}); - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "c", "x"}), "unittest"), - 1); - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "y"}), "unittest"), - std::pow(ProximityBase, 2)); - // unittest:///b/c/x vs unittest:///m/n/y. No common directory. - EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"m", "n", "y"}), "unittest"), - std::pow(ProximityBase, 4)); -} - } // namespace } // namespace clangd } // namespace clang Index: unittests/clangd/HeadersTests.cpp === --- unittests/clangd/HeadersTests.cpp +++ unittests/clangd/HeadersTests.cpp @@ -64,18 +64,17 @@ } protected: - std::vector collectIncludes() { + IncludeStructure collectIncludes() { auto Clang = setupClang(); PreprocessOnlyAction Action; EXPECT_TRUE( Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++
yaxunl accepted this revision. yaxunl added a comment. This revision is now accepted and ready to land. LGTM. Thank! https://reviews.llvm.org/D48419 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47698: [ASTImporter] import macro source locations
r.stahl added a comment. In https://reviews.llvm.org/D47698#1140629, @thakis wrote: > This code is live when reading pchs, correct? Does this have any measurable > perf impact on deserializing pchs for, say, Cocoa.h or Windows.h? I don't know for sure, but it should be used - yes. I have not measured a possible performance impact. Do you have a suggestion how I could do this on a Linux setup? Note that I did not implement this as nice-to-have feature, but for fixing a concrete issue: https://reviews.llvm.org/D26054#1085413 Comment at: unittests/AST/ASTImporterTest.cpp:1534 +} +TEST_P(ASTImporterTestBase, ImportSourceLocs) { + Decl *FromTU = getTuDecl( balazske wrote: > This test causes every case for expansion (macro, macro arg) to be executed > at import? Yes, the last DeclRef will be "arg" on the RHS which is a macro argument expansion and the last IntegerLiteral will be the "1" which is a non-argument macro expansion. Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48455: Remove hip.amdgcn.bc hc.amdgcn.bc from HIP Toolchains
yaxunl accepted this revision. yaxunl added a comment. This revision is now accepted and ready to land. LGTM. Thanks! Repository: rC Clang https://reviews.llvm.org/D48455 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48373: [Driver] Make scudo compatible with -fsanitize-minimal-runtime
This revision was automatically updated to reflect the committed changes. Closed by commit rC335352: [Driver] Make scudo compatible with -fsanitize-minimal-runtime (authored by cryptoad, committed by ). Changed prior to commit: https://reviews.llvm.org/D48373?vs=152171=152476#toc Repository: rC Clang https://reviews.llvm.org/D48373 Files: lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChains/CommonArgs.cpp test/Driver/fsanitize.c test/Driver/sanitizer-ld.c Index: test/Driver/sanitizer-ld.c === --- test/Driver/sanitizer-ld.c +++ test/Driver/sanitizer-ld.c @@ -689,6 +689,15 @@ // CHECK-SCUDO-LINUX: "-lpthread" // CHECK-SCUDO-LINUX: "-ldl" +// RUN: %clang -fsanitize=scudo -fsanitize-minimal-runtime %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SCUDO-MINIMAL-LINUX %s +// CHECK-SCUDO-MINIMAL-LINUX: "{{.*}}ld{{(.exe)?}}" +// CHECK-SCUDO-MINIMAL-LINUX: "-pie" +// CHECK-SCUDO-MINIMAL-LINUX: "--whole-archive" "{{.*}}libclang_rt.scudo_minimal-i386.a" "--no-whole-archive" +// CHECK-SCUDO-MINIMAL-LINUX: "-lpthread" + // RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=scudo -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -674,6 +674,14 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-UBSAN // CHECK-SCUDO-UBSAN: "-fsanitize={{.*}}scudo" +// RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-MINIMAL +// CHECK-SCUDO-MINIMAL: "-fsanitize=scudo" +// CHECK-SCUDO-MINIMAL: "-fsanitize-minimal-runtime" + +// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined,scudo -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-UBSAN-MINIMAL +// CHECK-SCUDO-UBSAN-MINIMAL: "-fsanitize={{.*}}scudo" +// CHECK-SCUDO-UBSAN-MINIMAL: "-fsanitize-minimal-runtime" + // RUN: %clang -target powerpc-unknown-linux -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SCUDO // CHECK-NO-SCUDO: unsupported option Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -45,7 +45,7 @@ Nullability | LocalBounds | CFI, TrappingDefault = CFI, CFIClasses = CFIVCall | CFINVCall | CFIDerivedCast | CFIUnrelatedCast, - CompatibleWithMinimalRuntime = TrappingSupported, + CompatibleWithMinimalRuntime = TrappingSupported | Scudo, }; enum CoverageFeature { @@ -179,7 +179,8 @@ bool SanitizerArgs::needsUbsanRt() const { // All of these include ubsan. if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() || - needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || needsScudoRt()) + needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || + (needsScudoRt() && !requiresMinimalRuntime())) return false; return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -593,14 +593,17 @@ HelperStaticRuntimes.push_back("asan-preinit"); } if (SanArgs.needsUbsanRt()) { - if (SanArgs.requiresMinimalRuntime()) { + if (SanArgs.requiresMinimalRuntime()) SharedRuntimes.push_back("ubsan_minimal"); - } else { + else SharedRuntimes.push_back("ubsan_standalone"); - } } -if (SanArgs.needsScudoRt()) - SharedRuntimes.push_back("scudo"); +if (SanArgs.needsScudoRt()) { + if (SanArgs.requiresMinimalRuntime()) +SharedRuntimes.push_back("scudo_minimal"); + else +SharedRuntimes.push_back("scudo"); +} if (SanArgs.needsHwasanRt()) SharedRuntimes.push_back("hwasan"); } @@ -666,9 +669,15 @@ if (SanArgs.needsEsanRt()) StaticRuntimes.push_back("esan"); if (SanArgs.needsScudoRt()) { -StaticRuntimes.push_back("scudo"); -if (SanArgs.linkCXXRuntimes()) - StaticRuntimes.push_back("scudo_cxx"); +if (SanArgs.requiresMinimalRuntime()) { + StaticRuntimes.push_back("scudo_minimal"); + if (SanArgs.linkCXXRuntimes()) +StaticRuntimes.push_back("scudo_cxx_minimal"); +} else { + StaticRuntimes.push_back("scudo"); + if (SanArgs.linkCXXRuntimes()) +StaticRuntimes.push_back("scudo_cxx"); +} } } ___ cfe-commits
r335352 - [Driver] Make scudo compatible with -fsanitize-minimal-runtime
Author: cryptoad Date: Fri Jun 22 07:31:30 2018 New Revision: 335352 URL: http://llvm.org/viewvc/llvm-project?rev=335352=rev Log: [Driver] Make scudo compatible with -fsanitize-minimal-runtime Summary: This is the clang side of the change, there is a compiler-rt counterpart. Scudo works with UBSan using `-fsanitize=scudo,integer` for example, and to do so it embeds UBSan runtime. This makes it not compatible with the UBSan minimal runtime, but this is something we want for production purposes. The idea is to have a Scudo minimal runtime on the compiler-rt side that will not embed UBSan. This is basically the runtime that is currently in use for Fuchsia, without coverage, stacktraces or symbolization. With this, Scudo becomes compatible with `-fsanitize-minimal-runtime`. If this approach is suitable, I'll add the tests as well, otherwise I am open to other options. Reviewers: eugenis Reviewed By: eugenis Subscribers: llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D48373 Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/test/Driver/fsanitize.c cfe/trunk/test/Driver/sanitizer-ld.c Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=335352=335351=335352=diff == --- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original) +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Jun 22 07:31:30 2018 @@ -45,7 +45,7 @@ enum : SanitizerMask { Nullability | LocalBounds | CFI, TrappingDefault = CFI, CFIClasses = CFIVCall | CFINVCall | CFIDerivedCast | CFIUnrelatedCast, - CompatibleWithMinimalRuntime = TrappingSupported, + CompatibleWithMinimalRuntime = TrappingSupported | Scudo, }; enum CoverageFeature { @@ -179,7 +179,8 @@ static SanitizerMask parseSanitizeTrapAr bool SanitizerArgs::needsUbsanRt() const { // All of these include ubsan. if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() || - needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || needsScudoRt()) + needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() || + (needsScudoRt() && !requiresMinimalRuntime())) return false; return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=335352=335351=335352=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Fri Jun 22 07:31:30 2018 @@ -593,14 +593,17 @@ collectSanitizerRuntimes(const ToolChain HelperStaticRuntimes.push_back("asan-preinit"); } if (SanArgs.needsUbsanRt()) { - if (SanArgs.requiresMinimalRuntime()) { + if (SanArgs.requiresMinimalRuntime()) SharedRuntimes.push_back("ubsan_minimal"); - } else { + else SharedRuntimes.push_back("ubsan_standalone"); - } } -if (SanArgs.needsScudoRt()) - SharedRuntimes.push_back("scudo"); +if (SanArgs.needsScudoRt()) { + if (SanArgs.requiresMinimalRuntime()) +SharedRuntimes.push_back("scudo_minimal"); + else +SharedRuntimes.push_back("scudo"); +} if (SanArgs.needsHwasanRt()) SharedRuntimes.push_back("hwasan"); } @@ -666,9 +669,15 @@ collectSanitizerRuntimes(const ToolChain if (SanArgs.needsEsanRt()) StaticRuntimes.push_back("esan"); if (SanArgs.needsScudoRt()) { -StaticRuntimes.push_back("scudo"); -if (SanArgs.linkCXXRuntimes()) - StaticRuntimes.push_back("scudo_cxx"); +if (SanArgs.requiresMinimalRuntime()) { + StaticRuntimes.push_back("scudo_minimal"); + if (SanArgs.linkCXXRuntimes()) +StaticRuntimes.push_back("scudo_cxx_minimal"); +} else { + StaticRuntimes.push_back("scudo"); + if (SanArgs.linkCXXRuntimes()) +StaticRuntimes.push_back("scudo_cxx"); +} } } Modified: cfe/trunk/test/Driver/fsanitize.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=335352=335351=335352=diff == --- cfe/trunk/test/Driver/fsanitize.c (original) +++ cfe/trunk/test/Driver/fsanitize.c Fri Jun 22 07:31:30 2018 @@ -674,6 +674,14 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-UBSAN // CHECK-SCUDO-UBSAN: "-fsanitize={{.*}}scudo" +// RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-MINIMAL +// CHECK-SCUDO-MINIMAL: "-fsanitize=scudo" +// CHECK-SCUDO-MINIMAL: "-fsanitize-minimal-runtime" + +// RUN:
[PATCH] D48475: [clangd] More precise representation of symbol names/labels in the index.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. lgtm Comment at: clangd/CodeCompletionStrings.cpp:122 + // Typed-text chunk is the actual name. Text before it is qualifiers. + if (Qualifiers) +*Qualifiers = std::move(*Signature); Qualifier seems a bit ambiguous for this. The documentation for `CK_TypedText` says: ``` /// The piece of text that the user is expected to type to /// match the code-completion string, typically a keyword or the name of a /// declarator or macro. CK_TypedText, ``` For example, it could also be the keyword in "typedef ^". Maybe just `TypedText` would be more straightforward? Comment at: unittests/clangd/CodeCompletionStringsTests.cpp:70 Builder.AddResultTypeChunk("result no no"); - labelAndInsertText(*Builder.TakeString()); - EXPECT_EQ(Label, "X"); - EXPECT_EQ(InsertText, "X"); + getSignature(*Builder.TakeString()); + EXPECT_EQ(Signature, ""); nit: I find `getSignature` a bit awkward here because we are not getting anything back. Maybe `setSignature`? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
hans added a comment. I hit a snag while building some more Chromium targets. For class templates with explicit instantiation decls in the PCH file and explicit instantiation definitions in a .cc file, the function definition will be marked as coming from the PCH, even though it wasn't defined there. For example: #ifndef IN_HEADER #define IN_HEADER template struct Template { Template() {} }; extern template class Template; #else template class __declspec(dllexport) Template; #endif This isn't a problem for regular functions where we build a decl chain: the first declaration may come from a PCH, but the definition would be a separate Decl object which does not. I'm trying to figure out how to handle this. https://reviews.llvm.org/D48426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47953: [builtin] Add bitfield support for __builtin_dump_struct
paulsemel added a comment. First thanks all for reviewing ! Basically, what's happening is that it works good with non-packed structures. Here is an example for packed structure (with unsigned signed short): c struct lol { unsigned short a:3; unsigned short b:2; unsigned short c:6; unsigned short d:2; unsigned short e:6; } __attribute__((packed)); int main(void) { struct lol lolo = { .a = 2, .b = 1, .c = 13, .d = 2, .e = 9 }; __builtin_dump_struct(, ); return 0; } Here is the output I get : sh unsigned short a : 2 unsigned short b : 1 unsigned short c : 13 unsigned short d : 2 unsigned short e : 1 The last `unsigned short` is incorrect. If I switch this to signed integers, I get : sh unsigned short a : 0 unsigned short b : 0 unsigned short c : 0 unsigned short d : 0 unsigned short e : 0 All the fields are zeroed. I absolutely do not understand what is happening... Thanks for trying to help guys ! Repository: rC Clang https://reviews.llvm.org/D47953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47698: [ASTImporter] import macro source locations
thakis added a comment. This code is live when reading pchs, correct? Does this have any measurable perf impact on deserializing pchs for, say, Cocoa.h or Windows.h? Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47698: [ASTImporter] import macro source locations
balazske added inline comments. Comment at: unittests/AST/ASTImporterTest.cpp:1534 +} +TEST_P(ASTImporterTestBase, ImportSourceLocs) { + Decl *FromTU = getTuDecl( This test causes every case for expansion (macro, macro arg) to be executed at import? Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++
Anastasia added a comment. In https://reviews.llvm.org/D48419#1139799, @yaxunl wrote: > In https://reviews.llvm.org/D48419#1139749, @Anastasia wrote: > > > In https://reviews.llvm.org/D48419#1139601, @yaxunl wrote: > > > > > Did you notice the bug that C++ silently allows implicit casting of a > > > pointer to a pointer type with different address space? > > > > > > Do you have a fix for that? > > > > > > I didn't think it did because if I run > > `test/SemaOpenCL/address-spaces-conversions-cl2.0.cl` in `-cl-std=c++` it > > gives me errors when I initialize a pointer with different AS pointer: > > > > error: cannot initialize a variable of type '__global int *' with an > > lvalue of type '__local int *' > > error: assigning to '__global int *' from incompatible type '__local int > > *' > > error: comparison of distinct pointer types ('__global int *' and > > '__local int *') > > > > > > Do you have an example code somewhere? > > > Actually this only happens when there is an explicit cast: > > $ cat address-space-cast.cpp > // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck > %s > > #define __private__ __attribute__((address_space(5))) > > void f(char* q) { > // CHECK: addrspacecast > __private__ char* p = (__private__ char*)q; > //__private__ char* p = q; > } > $clang -cc1 -triple=amdgcn-amd-amdhsa address-space-cast.cpp -ast-dump > TranslationUnitDecl 0x699f418 <> > |-TypedefDecl 0x699fab0 <> implicit __int128_t > '__int128' > | `-BuiltinType 0x699f770 '__int128' > |-TypedefDecl 0x699fb18 <> implicit > __uint128_t 'unsigned __int128' > | `-BuiltinType 0x699f790 'unsigned __int128' > |-TypedefDecl 0x699fe58 <> implicit > __NSConstantString '__NSConstantString_tag' > | `-RecordType 0x699fc00 '__NSConstantString_tag' > | `-CXXRecord 0x699fb68 '__NSConstantString_tag' > |-TypedefDecl 0x699fef0 <> implicit > __builtin_va_list 'char *' > | `-PointerType 0x699feb0 'char *' > | `-BuiltinType 0x699f4b0 'char' > `-FunctionDecl 0x69a0020 line:5:6 f > 'void (char *)' > |-ParmVarDecl 0x699ff58 col:14 used q 'char *' > `-CompoundStmt 0x69e4130 > `-DeclStmt 0x69e4118 > `-VarDecl 0x69e4000 col:21 p > '__attribute__((address_space(5))) char *' cinit > `-CStyleCastExpr 0x69e40f0 > '__attribute__((address_space(5))) char *' > `-ImplicitCastExpr 0x69e40d8 > '__attribute__((address_space(5))) char *' > `-ImplicitCastExpr 0x69e40c0 'char *' > `-DeclRefExpr 0x69e4080 'char *' lvalue ParmVar > 0x699ff58 'q' 'char *' > > > > In the AST there is a CStyleCast and an ImplicitCast, both are NoOp, which > will becomes bitcast in codegen and causes invalid bitcast instruction. Yes this extra `ImplicitCastExpr` doesn't appear in OpenCL C and also `CStyleCastExpr` is correctly attributed as `AddressSpaceConversion` CStyleCastExpr 0xc490810 'char *' Since C++ uses conversion ranking rules the Sema code for it largely goes through the different path than in C. I think fixing address spaces in C++ or OpenCL C++ will need quite a bit of more work. I am planning to look at further issues in the next weeks, but not sure when... I hope it doesn't prevent us to go ahead with this parsing fix. https://reviews.llvm.org/D48419 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48412: [RISCV] Add support for interrupt attribute
aaron.ballman added a reviewer: aaron.ballman. aaron.ballman added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:8966 + +const RISCVInterruptAttr *Attr = FD->getAttr(); +if (!Attr) You can use `const auto *` here instead of repeating the type. Comment at: lib/Sema/SemaDeclAttr.cpp:5280 + // Check the attribute arguments. + if (AL.getNumArgs() > 1) { +S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) Please call `checkAttributeNumArgs()` instead; the error you're using is incorrect (it's used for variadic parameters where you receive more arguments than you expect). Comment at: lib/Sema/SemaDeclAttr.cpp:5301 + + if (!isFunctionOrMethod(D)) { +S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) I don't think you need to perform this check -- I believe it's handled automatically (because you don't have custom parsing enabled). Comment at: test/Sema/riscv-interrupt-attr.c:18 + +__attribute__((interrupt("user"), interrupt("supervisor"))) void foo6() { } // expected-warning {{repeated RISC-V 'interrupt' attribute}} \ +// expected-note {{repeated RISC-V 'interrupt' attribute is here}} You should also add tests for: ``` __attribute__((interrupt("user"))) void f(void); __attribute__((interrupt("machine"))) void f(void); void f(void) { } [[gnu::interrupt("user") gnu::interrupt("machine")]] void g() {} [[gnu::interrupt("user")]] [[gnu::interrupt("machine")]] void h() {} ``` Comment at: test/Sema/riscv-interrupt-attr.c:23 + // expected-note {{repeated RISC-V 'interrupt' attribute is here}} +__attribute__((interrupt("user"))) void foo8() {} +__attribute__((interrupt("supervisor"))) void foo9() {} Do you intend for functions without a prototype to be accepted? foo8() can be passed an arbitrary number of arguments, which is a bit different than what I thought you wanted the semantic check to be. Comment at: test/Sema/riscv-interrupt-attr.c:26 +__attribute__((interrupt("machine"))) void foo10() {} +__attribute__((interrupt(""))) void foo11() {} +__attribute__((interrupt())) void foo12() {} I'm a bit surprised that this is not an error -- the argument is provided, so I don't know why this should be treated as acceptable. https://reviews.llvm.org/D48412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
thakis added inline comments. Comment at: test/CodeGen/pch-dllexport.cpp:41 + +void use() { baz(); } + There still isn't a non-dllexported-but-referenced inline function in here as far as I can see. Am I just missing it? https://reviews.llvm.org/D48426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
This revision was automatically updated to reflect the committed changes. Closed by commit rC335339: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR (authored by GBuella, committed by ). Changed prior to commit: https://reviews.llvm.org/D45616?vs=152060=152456#toc Repository: rC Clang https://reviews.llvm.org/D45616 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c test/CodeGen/avx-cmp-builtins.c test/CodeGen/avx2-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -10120,44 +10120,7 @@ return Builder.CreateExtractValue(Call, 1); } - case X86::BI__builtin_ia32_cmpps128_mask: - case X86::BI__builtin_ia32_cmpps256_mask: - case X86::BI__builtin_ia32_cmpps512_mask: - case X86::BI__builtin_ia32_cmppd128_mask: - case X86::BI__builtin_ia32_cmppd256_mask: - case X86::BI__builtin_ia32_cmppd512_mask: { -unsigned NumElts = Ops[0]->getType()->getVectorNumElements(); -Value *MaskIn = Ops[3]; -Ops.erase([3]); - -Intrinsic::ID ID; -switch (BuiltinID) { -default: llvm_unreachable("Unsupported intrinsic!"); -case X86::BI__builtin_ia32_cmpps128_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_128; - break; -case X86::BI__builtin_ia32_cmpps256_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_256; - break; -case X86::BI__builtin_ia32_cmpps512_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_512; - break; -case X86::BI__builtin_ia32_cmppd128_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_128; - break; -case X86::BI__builtin_ia32_cmppd256_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_256; - break; -case X86::BI__builtin_ia32_cmppd512_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_512; - break; -} - -Value *Cmp = Builder.CreateCall(CGM.getIntrinsic(ID), Ops); -return EmitX86MaskedCompareResult(*this, Cmp, NumElts, MaskIn); - } - - // SSE packed comparison intrinsics + // packed comparison intrinsics case X86::BI__builtin_ia32_cmpeqps: case X86::BI__builtin_ia32_cmpeqpd: return getVectorFCmpIR(CmpInst::FCMP_OEQ); @@ -10185,64 +10148,84 @@ case X86::BI__builtin_ia32_cmpps: case X86::BI__builtin_ia32_cmpps256: case X86::BI__builtin_ia32_cmppd: - case X86::BI__builtin_ia32_cmppd256: { + case X86::BI__builtin_ia32_cmppd256: + case X86::BI__builtin_ia32_cmpps128_mask: + case X86::BI__builtin_ia32_cmpps256_mask: + case X86::BI__builtin_ia32_cmpps512_mask: + case X86::BI__builtin_ia32_cmppd128_mask: + case X86::BI__builtin_ia32_cmppd256_mask: + case X86::BI__builtin_ia32_cmppd512_mask: { +// Lowering vector comparisons to fcmp instructions, while +// ignoring signalling behaviour requested +// ignoring rounding mode requested +// This is is only possible as long as FENV_ACCESS is not implemented. +// See also: https://reviews.llvm.org/D45616 + +// The third argument is the comparison condition, and integer in the +// range [0, 31] unsigned CC = cast(Ops[2])->getZExtValue() & 0x1f; -// If this one of the SSE immediates, we can use native IR. -if (CC < 8) { - FCmpInst::Predicate Pred; - switch (CC) { - case 0: Pred = FCmpInst::FCMP_OEQ; break; - case 1: Pred = FCmpInst::FCMP_OLT; break; - case 2: Pred = FCmpInst::FCMP_OLE; break; - case 3: Pred = FCmpInst::FCMP_UNO; break; - case 4: Pred = FCmpInst::FCMP_UNE; break; - case 5: Pred = FCmpInst::FCMP_UGE; break; - case 6: Pred = FCmpInst::FCMP_UGT; break; - case 7: Pred = FCmpInst::FCMP_ORD; break; - } - return getVectorFCmpIR(Pred); + +// Lowering to IR fcmp instruction. +// Ignoring requested signaling behaviour, +// e.g. both _CMP_GT_OS & _CMP_GT_OQ are translated to FCMP_OGT. +FCmpInst::Predicate Pred; +switch (CC) { +case 0x00: Pred = FCmpInst::FCMP_OEQ; break; +case 0x01: Pred = FCmpInst::FCMP_OLT; break; +case 0x02: Pred = FCmpInst::FCMP_OLE; break; +case 0x03: Pred = FCmpInst::FCMP_UNO; break; +case 0x04: Pred = FCmpInst::FCMP_UNE; break; +case 0x05: Pred = FCmpInst::FCMP_UGE; break; +case 0x06: Pred = FCmpInst::FCMP_UGT; break; +case 0x07: Pred = FCmpInst::FCMP_ORD; break; +case 0x08: Pred = FCmpInst::FCMP_UEQ; break; +case 0x09: Pred = FCmpInst::FCMP_ULT; break; +case 0x0a: Pred = FCmpInst::FCMP_ULE; break; +case 0x0c: Pred = FCmpInst::FCMP_ONE; break; +case 0x0d: Pred = FCmpInst::FCMP_OGE; break; +case 0x0e: Pred = FCmpInst::FCMP_OGT; break; +case 0x10: Pred = FCmpInst::FCMP_OEQ; break; +case 0x11: Pred = FCmpInst::FCMP_OLT; break; +case 0x12: Pred = FCmpInst::FCMP_OLE; break; +case 0x13: Pred = FCmpInst::FCMP_UNO; break; +case 0x14: Pred = FCmpInst::FCMP_UNE; break; +case 0x15: Pred =
r335339 - [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
Author: gbuella Date: Fri Jun 22 04:59:16 2018 New Revision: 335339 URL: http://llvm.org/viewvc/llvm-project?rev=335339=rev Log: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR Summary: Lowering some vector comparision builtins to fcmp IR instructions. This ignores the signaling behaviour specified in the predicate argument of said builtins. Affected AVX512 builtins: __builtin_ia32_cmpps128_mask __builtin_ia32_cmpps256_mask __builtin_ia32_cmpps512_mask __builtin_ia32_cmppd128_mask __builtin_ia32_cmppd256_mask __builtin_ia32_cmppd512_mask Reviewers: craig.topper, uriel.k, RKSimon, andrew.w.kaylor, spatel, scanon, efriedma Reviewed By: craig.topper, spatel, efriedma Differential Revision: https://reviews.llvm.org/D45616 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/avx-builtins.c cfe/trunk/test/CodeGen/avx-cmp-builtins.c cfe/trunk/test/CodeGen/avx2-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=335339=335338=335339=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jun 22 04:59:16 2018 @@ -10120,44 +10120,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx return Builder.CreateExtractValue(Call, 1); } - case X86::BI__builtin_ia32_cmpps128_mask: - case X86::BI__builtin_ia32_cmpps256_mask: - case X86::BI__builtin_ia32_cmpps512_mask: - case X86::BI__builtin_ia32_cmppd128_mask: - case X86::BI__builtin_ia32_cmppd256_mask: - case X86::BI__builtin_ia32_cmppd512_mask: { -unsigned NumElts = Ops[0]->getType()->getVectorNumElements(); -Value *MaskIn = Ops[3]; -Ops.erase([3]); - -Intrinsic::ID ID; -switch (BuiltinID) { -default: llvm_unreachable("Unsupported intrinsic!"); -case X86::BI__builtin_ia32_cmpps128_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_128; - break; -case X86::BI__builtin_ia32_cmpps256_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_256; - break; -case X86::BI__builtin_ia32_cmpps512_mask: - ID = Intrinsic::x86_avx512_mask_cmp_ps_512; - break; -case X86::BI__builtin_ia32_cmppd128_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_128; - break; -case X86::BI__builtin_ia32_cmppd256_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_256; - break; -case X86::BI__builtin_ia32_cmppd512_mask: - ID = Intrinsic::x86_avx512_mask_cmp_pd_512; - break; -} - -Value *Cmp = Builder.CreateCall(CGM.getIntrinsic(ID), Ops); -return EmitX86MaskedCompareResult(*this, Cmp, NumElts, MaskIn); - } - - // SSE packed comparison intrinsics + // packed comparison intrinsics case X86::BI__builtin_ia32_cmpeqps: case X86::BI__builtin_ia32_cmpeqpd: return getVectorFCmpIR(CmpInst::FCMP_OEQ); @@ -10185,64 +10148,84 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__builtin_ia32_cmpps: case X86::BI__builtin_ia32_cmpps256: case X86::BI__builtin_ia32_cmppd: - case X86::BI__builtin_ia32_cmppd256: { + case X86::BI__builtin_ia32_cmppd256: + case X86::BI__builtin_ia32_cmpps128_mask: + case X86::BI__builtin_ia32_cmpps256_mask: + case X86::BI__builtin_ia32_cmpps512_mask: + case X86::BI__builtin_ia32_cmppd128_mask: + case X86::BI__builtin_ia32_cmppd256_mask: + case X86::BI__builtin_ia32_cmppd512_mask: { +// Lowering vector comparisons to fcmp instructions, while +// ignoring signalling behaviour requested +// ignoring rounding mode requested +// This is is only possible as long as FENV_ACCESS is not implemented. +// See also: https://reviews.llvm.org/D45616 + +// The third argument is the comparison condition, and integer in the +// range [0, 31] unsigned CC = cast(Ops[2])->getZExtValue() & 0x1f; -// If this one of the SSE immediates, we can use native IR. -if (CC < 8) { - FCmpInst::Predicate Pred; - switch (CC) { - case 0: Pred = FCmpInst::FCMP_OEQ; break; - case 1: Pred = FCmpInst::FCMP_OLT; break; - case 2: Pred = FCmpInst::FCMP_OLE; break; - case 3: Pred = FCmpInst::FCMP_UNO; break; - case 4: Pred = FCmpInst::FCMP_UNE; break; - case 5: Pred = FCmpInst::FCMP_UGE; break; - case 6: Pred = FCmpInst::FCMP_UGT; break; - case 7: Pred = FCmpInst::FCMP_ORD; break; - } - return getVectorFCmpIR(Pred); + +// Lowering to IR fcmp instruction. +// Ignoring requested signaling behaviour, +// e.g. both _CMP_GT_OS & _CMP_GT_OQ are translated to FCMP_OGT. +FCmpInst::Predicate Pred; +switch (CC) { +case 0x00: Pred = FCmpInst::FCMP_OEQ; break; +case 0x01: Pred = FCmpInst::FCMP_OLT; break; +case 0x02: Pred = FCmpInst::FCMP_OLE; break; +case 0x03: Pred = FCmpInst::FCMP_UNO; break; +case 0x04: Pred
[PATCH] D48432: [clang-format] Add AlwaysBreakBeforeMultilineString tests
This revision was automatically updated to reflect the committed changes. Closed by commit rC335338: [clang-format] Add AlwaysBreakBeforeMultilineString tests (authored by jolesiak, committed by ). Changed prior to commit: https://reviews.llvm.org/D48432?vs=152298=152455#toc Repository: rC Clang https://reviews.llvm.org/D48432 Files: unittests/Format/FormatTestObjC.cpp Index: unittests/Format/FormatTestObjC.cpp === --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -1227,6 +1227,15 @@ " @\"\");"); verifyFormat("(qqq, @\"\"\n" " @\"\");"); + verifyFormat("[ :@\"\"\n" + " @\"\"];"); + verifyFormat(" = [ :@\"\"\n" + " @\"\"];"); + verifyFormat("[ :@\"\"\n" + " @\"\"\n" + "rr:42\n" + "ss:@\"ee\"\n" + " @\"f\"];"); } } // end namespace Index: unittests/Format/FormatTestObjC.cpp === --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -1227,6 +1227,15 @@ " @\"\");"); verifyFormat("(qqq, @\"\"\n" " @\"\");"); + verifyFormat("[ :@\"\"\n" + " @\"\"];"); + verifyFormat(" = [ :@\"\"\n" + " @\"\"];"); + verifyFormat("[ :@\"\"\n" + " @\"\"\n" + "rr:42\n" + "ss:@\"ee\"\n" + " @\"f\"];"); } } // end namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335338 - [clang-format] Add AlwaysBreakBeforeMultilineString tests
Author: jolesiak Date: Fri Jun 22 04:57:55 2018 New Revision: 335338 URL: http://llvm.org/viewvc/llvm-project?rev=335338=rev Log: [clang-format] Add AlwaysBreakBeforeMultilineString tests Summary: Followup to D47393. Reviewers: stephanemoore Reviewed By: stephanemoore Subscribers: benhamilton, cfe-commits Differential Revision: https://reviews.llvm.org/D48432 Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=335338=335337=335338=diff == --- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Fri Jun 22 04:57:55 2018 @@ -1227,6 +1227,15 @@ TEST_F(FormatTestObjC, AlwaysBreakBefore " @\"\");"); verifyFormat("(qqq, @\"\"\n" " @\"\");"); + verifyFormat("[ :@\"\"\n" + " @\"\"];"); + verifyFormat(" = [ :@\"\"\n" + " @\"\"];"); + verifyFormat("[ :@\"\"\n" + " @\"\"\n" + "rr:42\n" + "ss:@\"ee\"\n" + " @\"f\"];"); } } // end namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE335334: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only… (authored by ioeric, committed by ). Changed prior to commit: https://reviews.llvm.org/D48425?vs=152447=152448#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48425 Files: clangd/AST.cpp clangd/AST.h clangd/CodeComplete.cpp clangd/Protocol.h clangd/index/SymbolCollector.cpp unittests/clangd/CodeCompleteTests.cpp Index: unittests/clangd/CodeCompleteTests.cpp === --- unittests/clangd/CodeCompleteTests.cpp +++ unittests/clangd/CodeCompleteTests.cpp @@ -44,6 +44,7 @@ // GMock helpers for matching completion items. MATCHER_P(Named, Name, "") { return arg.insertText == Name; } +MATCHER_P(Scope, Name, "") { return arg.SymbolScope == Name; } MATCHER_P(Labeled, Label, "") { std::string Indented; if (!StringRef(Label).startswith( @@ -1251,6 +1252,17 @@ Failed()); } +TEST(CompletionTest, QualifiedNames) { + auto Results = completions( + R"cpp( + namespace ns { int local; void both(); } + void f() { ::ns::^ } + )cpp", + {func("ns::both"), cls("ns::Index")}); + // We get results from both index and sema, with no duplicates. + EXPECT_THAT(Results.items, UnorderedElementsAre(Scope("ns::"), Scope("ns::"), + Scope("ns::"))); +} } // namespace } // namespace clangd Index: clangd/AST.cpp === --- clangd/AST.cpp +++ clangd/AST.cpp @@ -38,5 +38,20 @@ return SpellingLoc; } +std::string printQualifiedName(const NamedDecl ) { + std::string QName; + llvm::raw_string_ostream OS(QName); + PrintingPolicy Policy(ND.getASTContext().getLangOpts()); + // Note that inline namespaces are treated as transparent scopes. This + // reflects the way they're most commonly used for lookup. Ideally we'd + // include them, but at query time it's hard to find all the inline + // namespaces to query: the preamble doesn't have a dedicated list. + Policy.SuppressUnwrittenScope = true; + ND.printQualifiedName(OS, Policy); + OS.flush(); + assert(!StringRef(QName).startswith("::")); + return QName; +} + } // namespace clangd } // namespace clang Index: clangd/index/SymbolCollector.cpp === --- clangd/index/SymbolCollector.cpp +++ clangd/index/SymbolCollector.cpp @@ -363,20 +363,9 @@ auto = ND.getASTContext(); auto = Ctx.getSourceManager(); - std::string QName; - llvm::raw_string_ostream OS(QName); - PrintingPolicy Policy(ASTCtx->getLangOpts()); - // Note that inline namespaces are treated as transparent scopes. This - // reflects the way they're most commonly used for lookup. Ideally we'd - // include them, but at query time it's hard to find all the inline - // namespaces to query: the preamble doesn't have a dedicated list. - Policy.SuppressUnwrittenScope = true; - ND.printQualifiedName(OS, Policy); - OS.flush(); - assert(!StringRef(QName).startswith("::")); - Symbol S; S.ID = std::move(ID); + std::string QName = printQualifiedName(ND); std::tie(S.Scope, S.Name) = splitQualifiedName(QName); // FIXME: this returns foo:bar: for objective-C methods, we prefer only foo: // for consistency with CodeCompletionString and a clean name/signature split. Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -734,6 +734,12 @@ // // data?: any - A data entry field that is preserved on a completion item // between a completion and a completion resolve request. + + // C++ extension that is only expected to be used by users of ClangdServer's + // C++ API. Not serialized from/to json. + /// The containing scope (e.g. namespace) of the symbol this item corresponds + /// to, e.g. "" (global scope), "ns::" (top-level namespace). + std::string SymbolScope; }; json::Expr toJSON(const CompletionItem &); llvm::raw_ostream <<(llvm::raw_ostream &, const CompletionItem &); Index: clangd/CodeComplete.cpp === --- clangd/CodeComplete.cpp +++ clangd/CodeComplete.cpp @@ -19,6 +19,7 @@ //===-===// #include "CodeComplete.h" +#include "AST.h" #include "CodeCompletionStrings.h" #include "Compiler.h" #include "FuzzyMatch.h" @@ -243,6 +244,8 @@ const IncludeInserter , llvm::StringRef SemaDocComment) const { assert(bool(SemaResult) == bool(SemaCCS)); +assert(SemaResult || IndexResult); + CompletionItem I; bool InsertingInclude = false; // Whether a new #include will be added. if (SemaResult) { @@ -253,8
[clang-tools-extra] r335334 - [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
Author: ioeric Date: Fri Jun 22 03:46:59 2018 New Revision: 335334 URL: http://llvm.org/viewvc/llvm-project?rev=335334=rev Log: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json). Summary: The qualified name can be used to match a completion item to its corresponding symbol. This can be useful for tools that measure code completion quality. Qualified names are not precise for identifying symbols; we need to figure out a better way to identify completion items. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48425 Modified: clang-tools-extra/trunk/clangd/AST.cpp clang-tools-extra/trunk/clangd/AST.h clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Modified: clang-tools-extra/trunk/clangd/AST.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=335334=335333=335334=diff == --- clang-tools-extra/trunk/clangd/AST.cpp (original) +++ clang-tools-extra/trunk/clangd/AST.cpp Fri Jun 22 03:46:59 2018 @@ -38,5 +38,20 @@ SourceLocation findNameLoc(const clang:: return SpellingLoc; } +std::string printQualifiedName(const NamedDecl ) { + std::string QName; + llvm::raw_string_ostream OS(QName); + PrintingPolicy Policy(ND.getASTContext().getLangOpts()); + // Note that inline namespaces are treated as transparent scopes. This + // reflects the way they're most commonly used for lookup. Ideally we'd + // include them, but at query time it's hard to find all the inline + // namespaces to query: the preamble doesn't have a dedicated list. + Policy.SuppressUnwrittenScope = true; + ND.printQualifiedName(OS, Policy); + OS.flush(); + assert(!StringRef(QName).startswith("::")); + return QName; +} + } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/clangd/AST.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=335334=335333=335334=diff == --- clang-tools-extra/trunk/clangd/AST.h (original) +++ clang-tools-extra/trunk/clangd/AST.h Fri Jun 22 03:46:59 2018 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ +#include "clang/AST/Decl.h" #include "clang/Basic/SourceLocation.h" namespace clang { @@ -28,6 +29,10 @@ namespace clangd { /// decl occurs in the code. SourceLocation findNameLoc(const clang::Decl *D); +/// Returns the qualified name of ND. The scope doesn't contain unwritten scopes +/// like inline namespaces. +std::string printQualifiedName(const NamedDecl ); + } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=335334=335333=335334=diff == --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Jun 22 03:46:59 2018 @@ -19,6 +19,7 @@ //===-===// #include "CodeComplete.h" +#include "AST.h" #include "CodeCompletionStrings.h" #include "Compiler.h" #include "FuzzyMatch.h" @@ -243,6 +244,8 @@ struct CompletionCandidate { const IncludeInserter , llvm::StringRef SemaDocComment) const { assert(bool(SemaResult) == bool(SemaCCS)); +assert(SemaResult || IndexResult); + CompletionItem I; bool InsertingInclude = false; // Whether a new #include will be added. if (SemaResult) { @@ -253,8 +256,14 @@ struct CompletionCandidate { I.filterText = Text; I.documentation = formatDocumentation(*SemaCCS, SemaDocComment); I.detail = getDetail(*SemaCCS); + if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) +if (const auto *D = SemaResult->getDeclaration()) + if (const auto *ND = llvm::dyn_cast(D)) +I.SymbolScope = splitQualifiedName(printQualifiedName(*ND)).first; } if (IndexResult) { + if (I.SymbolScope.empty()) +I.SymbolScope = IndexResult->Scope; if (I.kind == CompletionItemKind::Missing) I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind); // FIXME: reintroduce a way to show the index source for debugging. Modified: clang-tools-extra/trunk/clangd/Protocol.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=335334=335333=335334=diff ==
[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
ioeric updated this revision to Diff 152447. ioeric marked 2 inline comments as done. ioeric added a comment. - Add printQualifiedName in AST.h Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48425 Files: clangd/AST.cpp clangd/AST.h clangd/CodeComplete.cpp clangd/Protocol.h clangd/index/SymbolCollector.cpp unittests/clangd/CodeCompleteTests.cpp Index: unittests/clangd/CodeCompleteTests.cpp === --- unittests/clangd/CodeCompleteTests.cpp +++ unittests/clangd/CodeCompleteTests.cpp @@ -44,6 +44,7 @@ // GMock helpers for matching completion items. MATCHER_P(Named, Name, "") { return arg.insertText == Name; } +MATCHER_P(Scope, Name, "") { return arg.SymbolScope == Name; } MATCHER_P(Labeled, Label, "") { std::string Indented; if (!StringRef(Label).startswith( @@ -1251,6 +1252,17 @@ Failed()); } +TEST(CompletionTest, QualifiedNames) { + auto Results = completions( + R"cpp( + namespace ns { int local; void both(); } + void f() { ::ns::^ } + )cpp", + {func("ns::both"), cls("ns::Index")}); + // We get results from both index and sema, with no duplicates. + EXPECT_THAT(Results.items, UnorderedElementsAre(Scope("ns::"), Scope("ns::"), + Scope("ns::"))); +} } // namespace } // namespace clangd Index: clangd/index/SymbolCollector.cpp === --- clangd/index/SymbolCollector.cpp +++ clangd/index/SymbolCollector.cpp @@ -363,20 +363,9 @@ auto = ND.getASTContext(); auto = Ctx.getSourceManager(); - std::string QName; - llvm::raw_string_ostream OS(QName); - PrintingPolicy Policy(ASTCtx->getLangOpts()); - // Note that inline namespaces are treated as transparent scopes. This - // reflects the way they're most commonly used for lookup. Ideally we'd - // include them, but at query time it's hard to find all the inline - // namespaces to query: the preamble doesn't have a dedicated list. - Policy.SuppressUnwrittenScope = true; - ND.printQualifiedName(OS, Policy); - OS.flush(); - assert(!StringRef(QName).startswith("::")); - Symbol S; S.ID = std::move(ID); + std::string QName = printQualifiedName(ND); std::tie(S.Scope, S.Name) = splitQualifiedName(QName); S.IsIndexedForCodeCompletion = isIndexedForCodeCompletion(ND, Ctx); Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -734,6 +734,12 @@ // // data?: any - A data entry field that is preserved on a completion item // between a completion and a completion resolve request. + + // C++ extension that is only expected to be used by users of ClangdServer's + // C++ API. Not serialized from/to json. + /// The containing scope (e.g. namespace) of the symbol this item corresponds + /// to, e.g. "" (global scope), "ns::" (top-level namespace). + std::string SymbolScope; }; json::Expr toJSON(const CompletionItem &); llvm::raw_ostream <<(llvm::raw_ostream &, const CompletionItem &); Index: clangd/CodeComplete.cpp === --- clangd/CodeComplete.cpp +++ clangd/CodeComplete.cpp @@ -19,6 +19,7 @@ //===-===// #include "CodeComplete.h" +#include "AST.h" #include "CodeCompletionStrings.h" #include "Compiler.h" #include "FuzzyMatch.h" @@ -243,6 +244,8 @@ const IncludeInserter , llvm::StringRef SemaDocComment) const { assert(bool(SemaResult) == bool(SemaCCS)); +assert(SemaResult || IndexResult); + CompletionItem I; bool InsertingInclude = false; // Whether a new #include will be added. if (SemaResult) { @@ -252,8 +255,14 @@ I.filterText = getFilterText(*SemaCCS); I.documentation = formatDocumentation(*SemaCCS, SemaDocComment); I.detail = getDetail(*SemaCCS); + if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) +if (const auto *D = SemaResult->getDeclaration()) + if (const auto *ND = llvm::dyn_cast(D)) +I.SymbolScope = splitQualifiedName(printQualifiedName(*ND)).first; } if (IndexResult) { + if (I.SymbolScope.empty()) +I.SymbolScope = IndexResult->Scope; if (I.kind == CompletionItemKind::Missing) I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind); // FIXME: reintroduce a way to show the index source for debugging. Index: clangd/AST.h === --- clangd/AST.h +++ clangd/AST.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ +#include "clang/AST/Decl.h" #include "clang/Basic/SourceLocation.h" namespace clang { @@ -28,6 +29,10 @@ /// decl occurs
[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. Comment at: clangd/SourceCode.h:60 +/// Splits the qualified name of ND. The scope doesn't contain unwritten scopes +/// like inline namespaces. This is a bit non-orthogonal: the printing of the qname doesn't have much to do with splitting it. Also, the printing doesn't really belong in SourceCode.h as it's basically AST manipulation. What about adding e.g. `printQualifiedName` to AST.h, and calling `splitQualifiedName(printQualifiedName(ND))`?( Comment at: unittests/clangd/CodeCompleteTests.cpp:47 MATCHER_P(Named, Name, "") { return arg.insertText == Name; } +MATCHER_P(QName, Name, "") { + return (arg.SymbolScope + arg.filterText) == Name; maybe test scope explicitly/directly? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48441: [clangd] Incorporate transitive #includes into code complete proximity scoring.
ioeric added a comment. Looks great! Thanks for doing this! The algorithm looks pretty efficient. It might still make sense to collect some performance numbers for real files with potentially large #include tree (we have plenty of those in our internal codebase :) Comment at: clangd/CodeComplete.cpp:908 + llvm::Optional Inserter; // Available during runWithSema. + llvm::Optional FileProximity; // Initialized once Sema runs. It might make sense to briefly explain somewhere how computational cost is distributed across the workflow. Comment at: clangd/CodeComplete.cpp:938 + SemaCCInput.FileName, SemaCCInput.Contents, + format::getLLVMStyle(), // XXX + SemaCCInput.Command.Directory, nit: `Style`? Comment at: clangd/FileDistance.cpp:72 + // Fill in all ancestors between the query and the known. + for (unsigned I = 0; I < Ancestors.size(); ++I) { +if (Cost != kUnreachable) nit: this loop would probably be easier to understand if iterated reversely. Comment at: clangd/FileDistance.cpp:86 +return R.first->getSecond(); + if (auto U = clangd::URI::parse(URI)) { +LLVM_DEBUG(dbgs() << "distance(" << URI << ") = distance(" << U->body() This is done for every index symbol, so I wonder if we could avoid parsing URIs by assuming some URI structures. Comment at: clangd/FileDistance.h:56 + + FileDistance(llvm::StringMap Roots, + const FileDistanceOptions = {}); nit: It's unclear what the values of Roots are (it can be confused with tree roots or directory roots). Comment at: clangd/Headers.cpp:28 + : SM(SM), Out(Out) { +SM.getMainFileID(); + } What does this do? Comment at: clangd/Headers.h:62 + std::vector MainFileIncludes; + llvm::StringMap includeDepth(llvm::StringRef MainFileName) const; + Does this return all transitive includes in the entire TU or just those from `MainFileName`? And what's `MainFileName` here? Is it the same as the main file in a TU? Comment at: clangd/Headers.h:67 + llvm::StringRef IncludedName, + llvm::StringRef IncludedRealName); + The real name can be empty. How do we handle empty path? Comment at: clangd/Headers.h:75 + // The paths we want to expose are the RealPathName, so store those too. + unsigned fileNumber(llvm::StringRef Name); + llvm::StringMap NameToIndex; // Values are file numbers. Maybe `fileIndex`? Comment at: clangd/Quality.cpp:233 +std::pair proximityScore(llvm::StringRef SymbolURI, + URIDistance *D) { nit: `static` Comment at: unittests/clangd/FileDistanceTests.cpp:36 + // Ancestor (up+up+up+up) + EXPECT_EQ(D.distance("/"), 22u); + // Sibling (up+down) I think this is an interesting case. IIUC, 22u is contributed by 4 ups (4*5) and 1 include (1*2, via `llvm/ADT/StringRef.h`). Suppose `a/b/c/d/e/f.cc` includes `base/x.h`, then the shortest path into directory `other/` is likely to go via `base/x.h`. This might become a problem if `base/x.h` is very commonly used. One solution is probably to penalize edits that hit the root. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48441 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
hans updated this revision to Diff 152444. hans marked 2 inline comments as done. hans added a comment. Addressing review comments. https://reviews.llvm.org/D48426 Files: include/clang/AST/ExternalASTSource.h include/clang/Basic/LangOptions.def include/clang/Driver/CC1Options.td include/clang/Sema/MultiplexExternalSemaSource.h include/clang/Serialization/ASTBitCodes.h include/clang/Serialization/ASTReader.h include/clang/Serialization/Module.h lib/AST/ASTContext.cpp lib/Driver/Driver.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/Sema/MultiplexExternalSemaSource.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/CodeGen/pch-dllexport.cpp test/Driver/cl-pch.cpp Index: test/Driver/cl-pch.cpp === --- test/Driver/cl-pch.cpp +++ test/Driver/cl-pch.cpp @@ -7,13 +7,15 @@ // 1. Build .pch file. // CHECK-YC: cc1 // CHECK-YC: -emit-pch +// CHECK-YC: -building-pch-with-obj // CHECK-YC: -o // CHECK-YC: pchfile.pch // CHECK-YC: -x // CHECK-YC: "c++-header" // 2. Use .pch file. // CHECK-YC: cc1 // CHECK-YC: -emit-obj +// CHECK-YC: -building-pch-with-obj // CHECK-YC: -include-pch // CHECK-YC: pchfile.pch @@ -24,11 +26,13 @@ // 1. Build .pch file. // CHECK-YCO: cc1 // CHECK-YCO: -emit-pch +// CHECK-YCO: -building-pch-with-obj // CHECK-YCO: -o // CHECK-YCO: pchfile.pch // 2. Use .pch file. // CHECK-YCO: cc1 // CHECK-YCO: -emit-obj +// CHECK-YCO: -building-pch-with-obj // CHECK-YCO: -include-pch // CHECK-YCO: pchfile.pch // CHECK-YCO: -o @@ -46,6 +50,7 @@ // RUN: | FileCheck -check-prefix=CHECK-YU %s // Use .pch file, but don't build it. // CHECK-YU-NOT: -emit-pch +// CHECK-YU-NOT: -building-pch-with-obj // CHECK-YU: cc1 // CHECK-YU: -emit-obj // CHECK-YU: -include-pch @@ -63,6 +68,7 @@ // 1. Build .pch file. // CHECK-YC-YU: cc1 // CHECK-YC-YU: -emit-pch +// CHECK-YC-YU: -building-pch-with-obj // CHECK-YC-YU: -o // CHECK-YC-YU: pchfile.pch // 2. Use .pch file. Index: test/CodeGen/pch-dllexport.cpp === --- /dev/null +++ test/CodeGen/pch-dllexport.cpp @@ -0,0 +1,43 @@ +// Build PCH without object file, then use it. +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -o %t %s +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCH %s + +// Build PCH with object file, then use it. +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -building-pch-with-obj -o %t %s +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -building-pch-with-obj -o - %s | FileCheck -check-prefix=OBJ %s +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJ %s + +#ifndef IN_HEADER +#define IN_HEADER + +inline void __declspec(dllexport) foo() {} +// OBJ: define weak_odr dso_local dllexport void @"?foo@@YAXXZ" +// PCH: define weak_odr dso_local dllexport void @"?foo@@YAXXZ" +// PCHWITHOBJ-NOT: define {{.*}}foo + + +// This function is referenced, so gets emitted as usual. +inline void __declspec(dllexport) baz() {} +// OBJ: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" +// PCH: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" +// PCHWITHOBJ: define weak_odr dso_local dllexport void @"?baz@@YAXXZ" + + +struct __declspec(dllexport) S { + void bar() {} +// OBJ: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ" +// PCH: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ" +// PCHWITHOBJ-NOT: define {{.*}}bar +}; + +// This isn't dllexported, attribute((used)) or referenced, so not emitted. +inline void quux() {} +// OBJ-NOT: define {{.*}}quux +// PCH-NOT: define {{.*}}quux +// PCHWITHOBJ-NOT: define {{.*}}quux + +#else + +void use() { baz(); } + +#endif Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -1458,16 +1458,23 @@ MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min. MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Timestamps + MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // PCHHasObjectFile MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Errors MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag unsigned MetadataAbbrevCode = Stream.EmitAbbrev(std::move(MetadataAbbrev)); assert((!WritingModule || isysroot.empty()) && "writing module as a relocatable PCH?"); { -RecordData::value_type Record[] = {METADATA,
[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
hans marked 4 inline comments as done. hans added a comment. In https://reviews.llvm.org/D48426#1140057, @dblaikie wrote: > In https://reviews.llvm.org/D48426#1139823, @rnk wrote: > > > `LangOpts.ModulesCodegen` is very related in spirit to this, but I think we > > need a distinct option because that was designed to handle all inline > > functions (too much), not just dllexport inline functions. + @dblaikie > > > Does it have to be only the dllexported inline functions - or could this be > used to home all inline functions? (I guess not - presumably it's not > acceptable for the compiler to implicitly promote something to dllexport (& > if it doesn't do that promotion, then the function wouldn't be visible from > the use)) Right, I don't think we could do that. But regular inline functions isn't as large a problem as the dllexport ones, which we have to emit even if they're not referenced, causing a huge amount of redundant codegen. > Is it valid to provide a definition for optimization purposes (LLVM's > available_externally linkage) for these inline functions? Or is it required > that, after a change to the header (modifying the implementation of one of > these dllexported inline functions), the DLL they're exported could be > rebuilt without rebuilding the clients & the change in behavior would be > correctly applied? Yes, we will provide such definitions (not just available_externally, but weak_odr) if the inline function is referenced, as usual. This is only homing unreferenced but "force emitted", i.e. DeclMustBeEmitted, functions. Comment at: include/clang/AST/ASTContext.h:2886-2887 + + // XXX: I don't like adding this to ASTContext, but I ran out of ideas for how ASTContext::DeclMustBeEmitted() would know about it otherwise. + bool BuildingPCHWithObjectFile = false; }; rnk wrote: > Does `LangOpts.CompilingPCH` do the right thing, or is that also true when we > make a PCH with no object file? In any case, I'd probably make this a > langopt. Even if it's functionally different from ModulesCodegen and > ModulesDebugInfo, it's the same basic idea. Yes, CompilingPCH is always set when building PCHs, also when there's no object file so we can't use that. Moving BuildingPCHWithObjectFile to LangOpts sounds good to me. Actually that's interesting, because it means the flag will get written into the PCH will all the other LangOpts, and we could in theory look for that in ASTReader. But it seems the code isn't really set up to store the LangOpts coming out of an AST file, we only verify that they're compatible. Comment at: test/CodeGen/pch-dllexport.cpp:22 +// PCH: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ" +// PCHWITHOBJ-NOT: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ" +}; dblaikie wrote: > This is a pretty specific "NOT" - maybe: > > define {{.*}}@"?bar@... > > would be better to ensure no definition is provided? (similarly above) > > Also, should this file have some non-exported inline functions to check those > do the right thing? Updated the -NOT checks and added test. https://reviews.llvm.org/D48426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335330 - [hmaptool] Turn %hmaptool into a proper substitution
Author: d0k Date: Fri Jun 22 02:46:40 2018 New Revision: 335330 URL: http://llvm.org/viewvc/llvm-project?rev=335330=rev Log: [hmaptool] Turn %hmaptool into a proper substitution This is still super ugly, but at least it doesn't require working directories to just line up perfectly for python to find the tool. Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m cfe/trunk/test/Preprocessor/headermap-rel.c cfe/trunk/test/Preprocessor/headermap-rel2.c cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c cfe/trunk/test/lit.cfg.py Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335330=335329=335330=diff == --- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original) +++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Fri Jun 22 02:46:40 2018 @@ -3,7 +3,7 @@ // RUN: rm -rf %t // RUN: mkdir -p %t/m %t/i/Foo.framework/Headers // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h -// RUN: '%python' hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap +// RUN: %hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \ Modified: cfe/trunk/test/Preprocessor/headermap-rel.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel.c?rev=335330=335329=335330=diff == --- cfe/trunk/test/Preprocessor/headermap-rel.c (original) +++ cfe/trunk/test/Preprocessor/headermap-rel.c Fri Jun 22 02:46:40 2018 @@ -1,5 +1,5 @@ // RUN: rm -f %t.hmap -// RUN: '%python' hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap +// RUN: %hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap // RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel // RUN: FileCheck %s -input-file %t.i Modified: cfe/trunk/test/Preprocessor/headermap-rel2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel2.c?rev=335330=335329=335330=diff == --- cfe/trunk/test/Preprocessor/headermap-rel2.c (original) +++ cfe/trunk/test/Preprocessor/headermap-rel2.c Fri Jun 22 02:46:40 2018 @@ -1,5 +1,5 @@ // RUN: rm -f %t.hmap -// RUN: '%python' hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap +// RUN: %hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap // RUN: %clang_cc1 -v -fsyntax-only %s -iquote %t.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H // RUN: %clang_cc1 -fsyntax-only %s -iquote %t.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out // RUN: FileCheck %s -input-file %t.out Modified: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c?rev=335330=335329=335330=diff == --- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c (original) +++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Fri Jun 22 02:46:40 2018 @@ -1,5 +1,5 @@ // RUN: rm -f %t.hmap -// RUN: '%python' hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap +// RUN: %hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap // RUN: %clang_cc1 -Eonly\ // RUN: -I%t.hmap \ // RUN: -I%S/Inputs/nonportable-hmaps \ Modified: cfe/trunk/test/lit.cfg.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335330=335329=335330=diff == --- cfe/trunk/test/lit.cfg.py (original) +++ cfe/trunk/test/lit.cfg.py Fri Jun 22 02:46:40 2018 @@ -58,7 +58,7 @@ tool_dirs = [config.clang_tools_dir, con tools = [ 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'clang-tblgen', -'opt', 'hmaptool', +'opt', ToolSubst('%clang_func_map', command=FindTool( 'clang-func-mapping'), unresolved='ignore'), ] @@ -69,6 +69,10 @@ if config.clang_examples: llvm_config.add_tool_substitutions(tools, tool_dirs) +config.substitutions.append( +('%hmaptool', '%s %s' % (config.python_executable, + os.path.join(config.llvm_tools_dir, 'hmaptool' + # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']: ___ cfe-commits mailing list cfe-commits@lists.llvm.org
[PATCH] D48475: [clangd] More precise representation of symbol names/labels in the index.
sammccall created this revision. sammccall added a reviewer: ioeric. Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov. Previously, the strings matched LSP completion pretty closely. The completion label was a single string, for instance. This made implementing completion itself easy but makes it hard to use the names in other way, e.g. pretty-printed name in synthesized documentation/hover. It also limits our introspection into completion items, which can only be as precise as the indexed symbols. This change is a prerequisite to improvements to overload bundling which need to inspect e.g. signature structure. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48475 Files: clangd/CodeComplete.cpp clangd/CodeCompletionStrings.cpp clangd/CodeCompletionStrings.h clangd/index/Index.cpp clangd/index/Index.h clangd/index/Merge.cpp clangd/index/SymbolCollector.cpp clangd/index/SymbolYAML.cpp unittests/clangd/CodeCompleteTests.cpp unittests/clangd/CodeCompletionStringsTests.cpp unittests/clangd/FileIndexTests.cpp unittests/clangd/IndexTests.cpp unittests/clangd/SymbolCollectorTests.cpp Index: unittests/clangd/SymbolCollectorTests.cpp === --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@ -36,15 +36,18 @@ using testing::UnorderedElementsAreArray; // GMock helpers for matching Symbol. -MATCHER_P(Labeled, Label, "") { return arg.CompletionLabel == Label; } -MATCHER(HasDetail, "") { return arg.Detail; } -MATCHER_P(Detail, D, "") { - return arg.Detail && arg.Detail->CompletionDetail == D; +MATCHER_P(Labeled, Label, "") { + return (arg.Name + arg.Signature).str() == Label; +} +MATCHER(HasReturnType, "") { + return arg.Detail && !arg.Detail->ReturnType.empty(); +} +MATCHER_P(ReturnType, D, "") { + return arg.Detail && arg.Detail->ReturnType == D; } MATCHER_P(Doc, D, "") { return arg.Detail && arg.Detail->Documentation == D; } -MATCHER_P(Plain, Text, "") { return arg.CompletionPlainInsertText == Text; } MATCHER_P(Snippet, S, "") { - return arg.CompletionSnippetInsertText == S; + return (arg.Name + arg.CompletionSnippetSuffix).str() == S; } MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; } MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; } @@ -656,24 +659,23 @@ Symbols, UnorderedElementsAre( QName("nx"), AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"), - Detail("int"), Doc("Foo comment."; + ReturnType("int"), Doc("Foo comment."; } -TEST_F(SymbolCollectorTest, PlainAndSnippet) { +TEST_F(SymbolCollectorTest, Snippet) { const std::string Header = R"( namespace nx { void f() {} int ff(int x, double y) { return 0; } } )"; runSymbolCollector(Header, /*Main=*/""); - EXPECT_THAT( - Symbols, - UnorderedElementsAre( - QName("nx"), - AllOf(QName("nx::f"), Labeled("f()"), Plain("f"), Snippet("f()")), - AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"), Plain("ff"), -Snippet("ff(${1:int x}, ${2:double y})"; + EXPECT_THAT(Symbols, + UnorderedElementsAre( + QName("nx"), + AllOf(QName("nx::f"), Labeled("f()"), Snippet("f()")), + AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"), +Snippet("ff(${1:int x}, ${2:double y})"; } TEST_F(SymbolCollectorTest, YAMLConversions) { @@ -694,12 +696,9 @@ Line: 1 Column: 1 IsIndexedForCodeCompletion:true -CompletionLabel:'Foo1-label' -CompletionFilterText:'filter' -CompletionPlainInsertText:'plain' Detail: Documentation:'Foo doc' - CompletionDetail:'int' + ReturnType:'int' ... )"; const std::string YAML2 = R"( @@ -719,25 +718,23 @@ Line: 1 Column: 1 IsIndexedForCodeCompletion:false -CompletionLabel:'Foo2-label' -CompletionFilterText:'filter' -CompletionPlainInsertText:'plain' -CompletionSnippetInsertText:'snippet' +Signature:'-sig' +CompletionSnippetSuffix:'-snippet' ... )"; auto Symbols1 = SymbolsFromYAML(YAML1); EXPECT_THAT(Symbols1, - UnorderedElementsAre(AllOf( - QName("clang::Foo1"), Labeled("Foo1-label"), Doc("Foo doc"), - Detail("int"), DeclURI("file:///path/foo.h"), - ForCodeCompletion(true; + UnorderedElementsAre(AllOf(QName("clang::Foo1"), Labeled("Foo1"), + Doc("Foo doc"), ReturnType("int"), + DeclURI("file:///path/foo.h"), + ForCodeCompletion(true; auto Symbols2 = SymbolsFromYAML(YAML2); - EXPECT_THAT(Symbols2, - UnorderedElementsAre(AllOf( -
[PATCH] D47698: [ASTImporter] import macro source locations
martong added reviewers: balazske, xazax.hun. martong added subscribers: balazske, xazax.hun. martong added a comment. Adding @balazske and @xazax.hun as reviewers. I think if it gets one more approve then we could merge. I'd like to speed up the things here ... we can't expect Aleksei to review all those many patches we sent lately. Repository: rC Clang https://reviews.llvm.org/D47698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39679: [C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list
Rakete updated this revision to Diff 152441. Rakete added a comment. done :) Could you commit it please, @rsmith ? https://reviews.llvm.org/D39679 Files: lib/Sema/SemaInit.cpp test/SemaCXX/references.cpp Index: test/SemaCXX/references.cpp === --- test/SemaCXX/references.cpp +++ test/SemaCXX/references.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s int g(int); void f() { @@ -55,6 +56,24 @@ // const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0 const volatile int cvi = 1; const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}} + +#if __cplusplus >= 201103L + const int& r2{cvi}; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}} + + const int a = 2; + int& r3{a}; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const'}} + + const int&& r4{a}; // expected-error{{rvalue reference to type 'const int' cannot bind to lvalue of type 'const int'}} + + void func(); + void func(int); + int = {func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}} + int &{func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}} + // expected-note@-4{{candidate function}} + // expected-note@-4{{candidate function}} + // expected-note@-6{{candidate function}} + // expected-note@-6{{candidate function}} +#endif } // C++ [dcl.init.ref]p3 Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -7565,6 +7565,19 @@ if (!Failed()) return false; + // When we want to diagnose only one element of a braced-init-list, + // we need to factor it out. + Expr *OnlyArg; + if (Args.size() == 1) { +auto *List = dyn_cast(Args[0]); +if (List && List->getNumInits() == 1) + OnlyArg = List->getInit(0); +else + OnlyArg = Args[0]; + } + else +OnlyArg = nullptr; + QualType DestType = Entity.getType(); switch (Failure) { case FK_TooManyInitsForReference: @@ -7625,7 +7638,7 @@ ? diag::err_array_init_different_type : diag::err_array_init_non_constant_array)) << DestType.getNonReferenceType() - << Args[0]->getType() + << OnlyArg->getType() << Args[0]->getSourceRange(); break; @@ -7636,7 +7649,7 @@ case FK_AddressOfOverloadFailed: { DeclAccessPair Found; -S.ResolveAddressOfOverloadedFunction(Args[0], +S.ResolveAddressOfOverloadedFunction(OnlyArg, DestType.getNonReferenceType(), true, Found); @@ -7644,9 +7657,9 @@ } case FK_AddressOfUnaddressableFunction: { -auto *FD = cast(cast(Args[0])->getDecl()); +auto *FD = cast(cast(OnlyArg)->getDecl()); S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true, -Args[0]->getLocStart()); +OnlyArg->getLocStart()); break; } @@ -7656,11 +7669,11 @@ case OR_Ambiguous: if (Failure == FK_UserConversionOverloadFailed) S.Diag(Kind.getLocation(), diag::err_typecheck_ambiguous_condition) - << Args[0]->getType() << DestType + << OnlyArg->getType() << DestType << Args[0]->getSourceRange(); else S.Diag(Kind.getLocation(), diag::err_ref_init_ambiguous) - << DestType << Args[0]->getType() + << DestType << OnlyArg->getType() << Args[0]->getSourceRange(); FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args); @@ -7670,10 +7683,10 @@ if (!S.RequireCompleteType(Kind.getLocation(), DestType.getNonReferenceType(), diag::err_typecheck_nonviable_condition_incomplete, - Args[0]->getType(), Args[0]->getSourceRange())) + OnlyArg->getType(), Args[0]->getSourceRange())) S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition) << (Entity.getKind() == InitializedEntity::EK_Result) - << Args[0]->getType() << Args[0]->getSourceRange() + << OnlyArg->getType() << Args[0]->getSourceRange() << DestType.getNonReferenceType(); FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args); @@ -7681,7 +7694,7 @@ case OR_Deleted: { S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function) -<< Args[0]->getType() << DestType.getNonReferenceType() +<< OnlyArg->getType() <<
[PATCH] D47698: [ASTImporter] import macro source locations
r.stahl updated this revision to Diff 152436. r.stahl marked 5 inline comments as done. r.stahl added a comment. addressed review comment, but there is nothing like FullSourceRange to improve everything Repository: rC Clang https://reviews.llvm.org/D47698 Files: lib/AST/ASTImporter.cpp unittests/AST/ASTImporterTest.cpp Index: unittests/AST/ASTImporterTest.cpp === --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -1518,6 +1518,49 @@ ToTU, cxxRecordDecl(unless(isImplicit(); } +static void CompareSourceLocs(FullSourceLoc Loc1, FullSourceLoc Loc2) { + EXPECT_EQ(Loc1.getExpansionLineNumber(), Loc2.getExpansionLineNumber()); + EXPECT_EQ(Loc1.getExpansionColumnNumber(), Loc2.getExpansionColumnNumber()); + EXPECT_EQ(Loc1.getSpellingLineNumber(), Loc2.getSpellingLineNumber()); + EXPECT_EQ(Loc1.getSpellingColumnNumber(), Loc2.getSpellingColumnNumber()); +} +static void CompareSourceRanges(SourceRange Range1, SourceRange Range2, +SourceManager , SourceManager ) { + CompareSourceLocs(FullSourceLoc{ Range1.getBegin(), SM1 }, +FullSourceLoc{ Range2.getBegin(), SM2 }); + CompareSourceLocs(FullSourceLoc{ Range1.getEnd(), SM1 }, +FullSourceLoc{ Range2.getEnd(), SM2 }); +} +TEST_P(ASTImporterTestBase, ImportSourceLocs) { + Decl *FromTU = getTuDecl( + R"( + #define MFOO(arg) arg = arg + 1 + + void foo() { +int a = 5; +MFOO(a); + } + )", + Lang_CXX); + auto FromD = FirstDeclMatcher().match(FromTU, functionDecl()); + auto ToD = Import(FromD, Lang_CXX); + + auto ToLHS = LastDeclMatcher().match(ToD, declRefExpr()); + auto FromLHS = LastDeclMatcher().match(FromTU, declRefExpr()); + auto ToRHS = LastDeclMatcher().match(ToD, integerLiteral()); + auto FromRHS = + LastDeclMatcher().match(FromTU, integerLiteral()); + + SourceManager = ToAST->getASTContext().getSourceManager(); + SourceManager = FromD->getASTContext().getSourceManager(); + CompareSourceRanges(ToD->getSourceRange(), FromD->getSourceRange(), ToSM, + FromSM); + CompareSourceRanges(ToLHS->getSourceRange(), FromLHS->getSourceRange(), ToSM, + FromSM); + CompareSourceRanges(ToRHS->getSourceRange(), FromRHS->getSourceRange(), ToSM, + FromSM); +} + TEST_P( ASTImporterTestBase, ImportDefinitionOfClassTemplateSpecIfThereIsAnExistingFwdDeclAndDefinition) Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -7029,61 +7029,70 @@ return {}; SourceManager = FromContext.getSourceManager(); - - // For now, map everything down to its file location, so that we - // don't have to import macro expansions. - // FIXME: Import macro expansions! - FromLoc = FromSM.getFileLoc(FromLoc); + std::pair Decomposed = FromSM.getDecomposedLoc(FromLoc); - SourceManager = ToContext.getSourceManager(); FileID ToFileID = Import(Decomposed.first); if (ToFileID.isInvalid()) return {}; - SourceLocation ret = ToSM.getLocForStartOfFile(ToFileID) - .getLocWithOffset(Decomposed.second); - return ret; + SourceManager = ToContext.getSourceManager(); + return ToSM.getComposedLoc(ToFileID, Decomposed.second); } SourceRange ASTImporter::Import(SourceRange FromRange) { return SourceRange(Import(FromRange.getBegin()), Import(FromRange.getEnd())); } FileID ASTImporter::Import(FileID FromID) { - llvm::DenseMap::iterator Pos -= ImportedFileIDs.find(FromID); + llvm::DenseMap::iterator Pos = ImportedFileIDs.find(FromID); if (Pos != ImportedFileIDs.end()) return Pos->second; - + SourceManager = FromContext.getSourceManager(); SourceManager = ToContext.getSourceManager(); const SrcMgr::SLocEntry = FromSM.getSLocEntry(FromID); - assert(FromSLoc.isFile() && "Cannot handle macro expansions yet"); - - // Include location of this file. - SourceLocation ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc()); - + // Map the FileID for to the "to" source manager. FileID ToID; - const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache(); - if (Cache->OrigEntry && Cache->OrigEntry->getDir()) { -// FIXME: We probably want to use getVirtualFile(), so we don't hit the -// disk again -// FIXME: We definitely want to re-use the existing MemoryBuffer, rather -// than mmap the files several times. -const FileEntry *Entry = ToFileManager.getFile(Cache->OrigEntry->getName()); -if (!Entry) - return {}; -ToID = ToSM.createFileID(Entry, ToIncludeLoc, - FromSLoc.getFile().getFileCharacteristic()); + if (FromSLoc.isExpansion()) { +const SrcMgr::ExpansionInfo = FromSLoc.getExpansion(); +SourceLocation
[PATCH] D48474: [analyzer][ctu] fix unsortable diagnostics
r.stahl added a comment. In https://reviews.llvm.org/D30691#879838, @xazax.hun wrote: > In https://reviews.llvm.org/D30691#878830, @r.stahl wrote: > > > For my purposes I replaced the return statement of the > > compareCrossTUSourceLocs function with: > > > > return XL.getFileID() < YL.getFileID(); > > > > > > A more correct fix would create only one unique diagnostic for both cases. > > > Thank you for the report, I could reproduce this after modifying the null > dereference checker. My fear of using file IDs is that I don't know whether > they are stable. So in subsequent runs, different paths might be chosen by > the analyzer and this could be confusing to the user. I will think about a > workaround that both stable and solves this assertion. > > I see two possible ways to do the proper fix. One is to check explicitly for > this case when the same function appears in multiple translation units. A > better approach would be to have the ASTImporter handle this case. I think > the proper fix is better addressed in a separate patch. Here is my improper fix with test case. Since CTU is still an experimental feature and this is a rare case to encounter I believe it's okay to risk confusing the user, rather than keep it broken. Unfortunately I will not have the time to work on a proper fix. Repository: rC Clang https://reviews.llvm.org/D48474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros
tiena2cva added a comment. I am waiting for this feature. Any update? Repository: rL LLVM https://reviews.llvm.org/D28462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48474: [analyzer][ctu] fix unsortable diagnostics
r.stahl created this revision. r.stahl added reviewers: xazax.hun, NoQ, dcoughlin. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, rnkovacs, szepet. Herald added a reviewer: george.karpenkov. In the provided test case the PathDiagnostic compare function was not able to find a difference. Repository: rC Clang https://reviews.llvm.org/D48474 Files: lib/StaticAnalyzer/Core/PathDiagnostic.cpp test/Analysis/Inputs/ctu-other.cpp test/Analysis/Inputs/externalFnMap.txt test/Analysis/ctu-hdr.h test/Analysis/ctu-main.cpp Index: test/Analysis/ctu-main.cpp === --- test/Analysis/ctu-main.cpp +++ test/Analysis/ctu-main.cpp @@ -4,6 +4,8 @@ // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/ // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s +#include "ctu-hdr.h" + void clang_analyzer_eval(int); int f(int); @@ -41,6 +43,7 @@ } int fun_using_anon_struct(int); +int other_macro_diag(int); int main() { clang_analyzer_eval(f(3) == 2); // expected-warning{{TRUE}} @@ -58,4 +61,8 @@ clang_analyzer_eval(chns::chf1(4) == 12); // expected-warning{{TRUE}} clang_analyzer_eval(fun_using_anon_struct(8) == 8); // expected-warning{{TRUE}} + + clang_analyzer_eval(other_macro_diag(1) == 1); // expected-warning{{TRUE}} + // expected-warning@Inputs/ctu-other.cpp:75{{REACHABLE}} + MACRODIAG(); // expected-warning{{REACHABLE}} } Index: test/Analysis/ctu-hdr.h === --- /dev/null +++ test/Analysis/ctu-hdr.h @@ -0,0 +1,3 @@ +#define MACRODIAG() clang_analyzer_warnIfReached() + +void clang_analyzer_warnIfReached(); Index: test/Analysis/Inputs/externalFnMap.txt === --- test/Analysis/Inputs/externalFnMap.txt +++ test/Analysis/Inputs/externalFnMap.txt @@ -12,3 +12,4 @@ c:@N@chns@S@chcls@F@chf4#I# ctu-chain.cpp.ast c:@N@chns@F@chf2#I# ctu-chain.cpp.ast c:@F@fun_using_anon_struct#I# ctu-other.cpp.ast +c:@F@other_macro_diag#I# ctu-other.cpp.ast Index: test/Analysis/Inputs/ctu-other.cpp === --- test/Analysis/Inputs/ctu-other.cpp +++ test/Analysis/Inputs/ctu-other.cpp @@ -1,3 +1,5 @@ +#include "../ctu-hdr.h" + int callback_to_main(int x); int f(int x) { return x - 1; @@ -68,3 +70,8 @@ typedef struct { int n; } Anonymous; int fun_using_anon_struct(int n) { Anonymous anon; anon.n = n; return anon.n; } + +int other_macro_diag(int x) { + MACRODIAG(); + return x; +} Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp === --- lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -406,11 +406,15 @@ std::pair InSameTU = SM.isInTheSameTranslationUnit(XOffs, YOffs); if (InSameTU.first) return XL.isBeforeInTranslationUnitThan(YL); - const FileEntry *XFE = SM.getFileEntryForID(XL.getFileID()); - const FileEntry *YFE = SM.getFileEntryForID(YL.getFileID()); + const FileEntry *XFE = SM.getFileEntryForID(XL.getSpellingLoc().getFileID()); + const FileEntry *YFE = SM.getFileEntryForID(YL.getSpellingLoc().getFileID()); if (!XFE || !YFE) return XFE && !YFE; - return XFE->getName() < YFE->getName(); + int NameCmp = XFE->getName().compare(YFE->getName()); + if (NameCmp != 0) +return NameCmp == -1; + // Last resort: Compare raw file IDs that are possibly expansions. + return XL.getFileID() < YL.getFileID(); } static bool compare(const PathDiagnostic , const PathDiagnostic ) { Index: test/Analysis/ctu-main.cpp === --- test/Analysis/ctu-main.cpp +++ test/Analysis/ctu-main.cpp @@ -4,6 +4,8 @@ // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/ // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s +#include "ctu-hdr.h" + void clang_analyzer_eval(int); int f(int); @@ -41,6 +43,7 @@ } int fun_using_anon_struct(int); +int other_macro_diag(int); int main() { clang_analyzer_eval(f(3) == 2); // expected-warning{{TRUE}} @@ -58,4 +61,8 @@ clang_analyzer_eval(chns::chf1(4) == 12); // expected-warning{{TRUE}} clang_analyzer_eval(fun_using_anon_struct(8) == 8); // expected-warning{{TRUE}} + + clang_analyzer_eval(other_macro_diag(1) == 1); // expected-warning{{TRUE}} + // expected-warning@Inputs/ctu-other.cpp:75{{REACHABLE}} + MACRODIAG(); // expected-warning{{REACHABLE}} } Index: test/Analysis/ctu-hdr.h === --- /dev/null +++
[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments
t.p.northover added a comment. I'm fine with the ABI changes, but I'm not very convinced by the "NaturalAlignment" name. Far from being a privileged alignment kind, it seems to take account of a pretty arbitrary set of modifiers. In fact, I can't help wondering if what's really happened is that ARM has decided to document existing GCC practice as the path of least resistance and scrambled for a name. This would be fine in ARM-specific code but could be quite misleading in the generic ASTContext. Personally I'd go for `ARMNaturalAlignment` and stop pretending it's something anyone else needs to care about (at least until some other ABI comes along that does). Comment at: lib/CodeGen/TargetInfo.cpp:5055 + Alignment = getContext().getTypeNaturalAlign(Ty); + Alignment = std::min(std::max(Alignment, 64u), 128u); +} else { I think the max/min logic is more confusing here than the alternative: Alignment = Alignment < 128 ? 64 : 128; https://reviews.llvm.org/D46013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48375: [clangd] Remove FilterText from the index.
This revision was automatically updated to reflect the committed changes. Closed by commit rL335321: [clangd] Remove FilterText from the index. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D48375 Files: clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.h clang-tools-extra/trunk/clangd/index/Index.cpp clang-tools-extra/trunk/clangd/index/Index.h clang-tools-extra/trunk/clangd/index/Merge.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp Index: clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp @@ -43,13 +43,6 @@ EXPECT_EQ(getDetail(*Builder.TakeString()), "result"); } -TEST_F(CompletionStringTest, FilterText) { - Builder.AddTypedTextChunk("typed"); - Builder.AddTypedTextChunk("redundant typed no no"); - auto *S = Builder.TakeString(); - EXPECT_EQ(getFilterText(*S), "typed"); -} - TEST_F(CompletionStringTest, Documentation) { Builder.addBriefComment("This is ignored"); EXPECT_EQ(formatDocumentation(*Builder.TakeString(), "Is this brief?"), @@ -115,7 +108,6 @@ EXPECT_EQ(Label, "Foo(p1, p2)"); EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})"); EXPECT_EQ(formatDocumentation(*CCS, "Foo's comment"), "Foo's comment"); - EXPECT_EQ(getFilterText(*CCS), "Foo"); } TEST_F(CompletionStringTest, EscapeSnippet) { Index: clang-tools-extra/trunk/clangd/index/Merge.cpp === --- clang-tools-extra/trunk/clangd/index/Merge.cpp +++ clang-tools-extra/trunk/clangd/index/Merge.cpp @@ -98,8 +98,6 @@ S.References += O.References; if (S.CompletionLabel == "") S.CompletionLabel = O.CompletionLabel; - if (S.CompletionFilterText == "") -S.CompletionFilterText = O.CompletionFilterText; if (S.CompletionPlainInsertText == "") S.CompletionPlainInsertText = O.CompletionPlainInsertText; if (S.CompletionSnippetInsertText == "") Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp === --- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp @@ -378,6 +378,8 @@ Symbol S; S.ID = std::move(ID); std::tie(S.Scope, S.Name) = splitQualifiedName(QName); + // FIXME: this returns foo:bar: for objective-C methods, we prefer only foo: + // for consistency with CodeCompletionString and a clean name/signature split. S.IsIndexedForCodeCompletion = isIndexedForCodeCompletion(ND, Ctx); S.SymInfo = index::getSymbolInfo(); @@ -403,7 +405,6 @@ /*EnableSnippets=*/true); getLabelAndInsertText(*CCS, , , /*EnableSnippets=*/false); - std::string FilterText = getFilterText(*CCS); std::string Documentation = formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion, /*CommentsFromHeaders=*/true)); @@ -417,7 +418,6 @@ QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts)) Include = std::move(*Header); } - S.CompletionFilterText = FilterText; S.CompletionLabel = Label; S.CompletionPlainInsertText = PlainInsertText; S.CompletionSnippetInsertText = SnippetInsertText; Index: clang-tools-extra/trunk/clangd/index/Index.h === --- clang-tools-extra/trunk/clangd/index/Index.h +++ clang-tools-extra/trunk/clangd/index/Index.h @@ -156,10 +156,6 @@ /// candidate list. For example, "Foo(X x, Y y) const" is a label for a /// function. llvm::StringRef CompletionLabel; - /// The piece of text that the user is expected to type to match the - /// code-completion string, typically a keyword or the name of a declarator or - /// macro. - llvm::StringRef CompletionFilterText; /// What to insert when completing this symbol (plain text version). llvm::StringRef CompletionPlainInsertText; /// What to insert when completing this symbol (snippet version). This is Index: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp === --- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp +++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp @@ -111,7 +111,6 @@ IO.mapOptional("IsIndexedForCodeCompletion", Sym.IsIndexedForCodeCompletion, false); IO.mapRequired("CompletionLabel", Sym.CompletionLabel); -
[clang-tools-extra] r335321 - [clangd] Remove FilterText from the index.
Author: sammccall Date: Thu Jun 21 23:41:43 2018 New Revision: 335321 URL: http://llvm.org/viewvc/llvm-project?rev=335321=rev Log: [clangd] Remove FilterText from the index. Summary: It's almost always identical to Name, and in fact we never used it (we used name instead). The only case where they differ is objc method selectors (foo: vs foo:bar:). We can live with the latter for both name and filterText, so I've made that change too. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48375 Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.h clang-tools-extra/trunk/clangd/index/Index.cpp clang-tools-extra/trunk/clangd/index/Index.h clang-tools-extra/trunk/clangd/index/Merge.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompletionStringsTests.cpp Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=335321=335320=335321=diff == --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jun 21 23:41:43 2018 @@ -249,7 +249,8 @@ struct CompletionCandidate { I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->Declaration); getLabelAndInsertText(*SemaCCS, , , Opts.EnableSnippets); - I.filterText = getFilterText(*SemaCCS); + if (const char* Text = SemaCCS->getTypedText()) +I.filterText = Text; I.documentation = formatDocumentation(*SemaCCS, SemaDocComment); I.detail = getDetail(*SemaCCS); } Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=335321=335320=335321=diff == --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp Thu Jun 21 23:41:43 2018 @@ -249,18 +249,5 @@ std::string getDetail(const CodeCompleti return ""; } -std::string getFilterText(const CodeCompletionString ) { - for (const auto : CCS) { -switch (Chunk.Kind) { -case CodeCompletionString::CK_TypedText: - // There's always exactly one CK_TypedText chunk. - return Chunk.Text; -default: - break; -} - } - return ""; -} - } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.h?rev=335321=335320=335321=diff == --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.h (original) +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.h Thu Jun 21 23:41:43 2018 @@ -65,11 +65,6 @@ std::string formatDocumentation(const Co /// is usually the return type of a function. std::string getDetail(const CodeCompletionString ); -/// Gets the piece of text that the user is expected to type to match the -/// code-completion string, typically a keyword or the name of a declarator or -/// macro. -std::string getFilterText(const CodeCompletionString ); - } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/clangd/index/Index.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=335321=335320=335321=diff == --- clang-tools-extra/trunk/clangd/index/Index.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Jun 21 23:41:43 2018 @@ -85,7 +85,6 @@ static void own(Symbol , DenseSethttp://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=335321=335320=335321=diff == --- clang-tools-extra/trunk/clangd/index/Index.h (original) +++ clang-tools-extra/trunk/clangd/index/Index.h Thu Jun 21 23:41:43 2018 @@ -156,10 +156,6 @@ struct Symbol { /// candidate list. For example, "Foo(X x, Y y) const" is a label for a /// function. llvm::StringRef CompletionLabel; - /// The piece of text that the user is expected to type to match the - /// code-completion string, typically a keyword or the name of a declarator or - /// macro. - llvm::StringRef CompletionFilterText; /// What to insert when completing this symbol (plain text version). llvm::StringRef CompletionPlainInsertText; /// What to insert when completing
[PATCH] D48460: [analyzer] Fix invalidation on C++ const methods.
baloghadamsoftware added a comment. I find it a strange behavior that this-expression is sometimes a pointer, sometimes a record declaration. If references are resolved, why are pointers not? This is an important fix, but I wonder how many other places are in the code where we do not handle this-expressions by pointers. Repository: rC Clang https://reviews.llvm.org/D48460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits