[PATCH] D22711: Diagnose invalid failure memory orderings.

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb requested changes to this revision.
jfb added a comment.
This revision now requires changes to proceed.

Given http://wg21.link/p0418 I think this requires an update. I don't think the 
old behavior is worth supporting in older `-std=` versions, unless we're 
worried that it would make code less portable.


https://reviews.llvm.org/D22711



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


[PATCH] D23041: Un-XFAIL GCC atomics.align

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.
Herald added subscribers: christof, aheejin.

In https://reviews.llvm.org/D23041#632708, @EricWF wrote:

> Have you filed a bug against GCC regarding its current behavior?
>
> Also it seems like a bad idea to add `-fabi-version=6`, since it selects an 
> older ABI version and not a newer one. Testing the old behavior is not what 
> we want.
>
> I think the best plan is to simply split the `vector_size` tests into another 
> file and XFAIL that for GCC. At least then we get some coverage.


Reviving this old thread... Do you think this is still the right approach? I 
can file the GCC bug and split off the test.


https://reviews.llvm.org/D23041



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


[PATCH] D45997: [CMake] Pass additional CMake flags in Fuchsia cache files

2018-05-07 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331717: [CMake] Pass additional CMake flags in Fuchsia cache 
files (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45997?vs=144824=145626#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45997

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
  cfe/trunk/cmake/caches/Fuchsia.cmake


Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -40,9 +40,11 @@
   install-distribution
   clang CACHE STRING "")
 
-foreach(target x86_64;aarch64)
-  if(FUCHSIA_${target}_SYSROOT)
-list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+get_cmake_property(variableNames VARIABLES)
+foreach(variableName ${variableNames})
+  if(variableName MATCHES "^STAGE2_")
+string(REPLACE "STAGE2_" "" new_name ${variableName})
+list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
   endif()
 endforeach()
 
Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -27,12 +27,23 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
+set(FUCHSIA_BUILTINS_BUILD_TYPE Release CACHE STRING "")
+set(FUCHSIA_RUNTIMES_BUILD_TYPE Release CACHE STRING "")
+set(FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS ON CACHE BOOL "")
+
 set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
 
 # Set the per-target builtins options.
 foreach(target x86_64;aarch64)
-  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_BUILD_TYPE 
${FUCHSIA_BUILTINS_BUILD_TYPE} CACHE STRING "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
@@ -54,9 +65,16 @@
 
 # Set the per-target runtimes options.
 foreach(target x86_64;aarch64)
-  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
-  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_TYPE 
${FUCHSIA_RUNTIMES_BUILD_TYPE} CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  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 "")


Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -40,9 +40,11 @@
   install-distribution
   clang CACHE STRING "")
 
-foreach(target x86_64;aarch64)
-  if(FUCHSIA_${target}_SYSROOT)
-list(APPEND EXTRA_ARGS -DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})

r331717 - [CMake] Pass additional CMake flags in Fuchsia cache files

2018-05-07 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon May  7 19:47:13 2018
New Revision: 331717

URL: http://llvm.org/viewvc/llvm-project?rev=331717=rev
Log:
[CMake] Pass additional CMake flags in Fuchsia cache files

This allows passing additional CMake flags to builtins and runtimes
build through Fuchsia cache files.

Differential Revision: https://reviews.llvm.org/D45997

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=331717=331716=331717=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Mon May  7 19:47:13 2018
@@ -27,12 +27,23 @@ set(CMAKE_BUILD_TYPE RelWithDebInfo CACH
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
+set(FUCHSIA_BUILTINS_BUILD_TYPE Release CACHE STRING "")
+set(FUCHSIA_RUNTIMES_BUILD_TYPE Release CACHE STRING "")
+set(FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS ON CACHE BOOL "")
+
 set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
 
 # Set the per-target builtins options.
 foreach(target x86_64;aarch64)
-  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_BUILD_TYPE 
${FUCHSIA_BUILTINS_BUILD_TYPE} CACHE STRING "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
@@ -54,9 +65,16 @@ endif()
 
 # Set the per-target runtimes options.
 foreach(target x86_64;aarch64)
-  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
-  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_TYPE 
${FUCHSIA_RUNTIMES_BUILD_TYPE} CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+  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 "")

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=331717=331716=331717=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Mon May  7 19:47:13 2018
@@ -40,9 +40,11 @@ set(CLANG_BOOTSTRAP_TARGETS
   install-distribution
   clang CACHE STRING "")
 
-foreach(target x86_64;aarch64)
-  if(FUCHSIA_${target}_SYSROOT)
-list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+get_cmake_property(variableNames VARIABLES)
+foreach(variableName ${variableNames})
+  if(variableName MATCHES "^STAGE2_")
+string(REPLACE "STAGE2_" "" new_name ${variableName})
+list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
   endif()
 endforeach()
 


___
cfe-commits 

r331713 - [C++2a] operator<=>: Fix incorrect use of Twine.

2018-05-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  7 19:28:47 2018
New Revision: 331713

URL: http://llvm.org/viewvc/llvm-project?rev=331713=rev
Log:
[C++2a] operator<=>: Fix incorrect use of Twine.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=331713=331712=331713=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon May  7 19:28:47 2018
@@ -8938,10 +8938,10 @@ QualType Sema::CheckComparisonCategoryTy
 
   // If lookup failed
   if (!Info) {
-auto NameForDiags =
-llvm::Twine("std::") + ComparisonCategories::getCategoryString(Kind);
+std::string NameForDiags = "std::";
+NameForDiags += ComparisonCategories::getCategoryString(Kind);
 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
-<< NameForDiags.str();
+<< NameForDiags;
 return QualType();
   }
 


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


r331707 - [C++2a] Implement operator<=>: Address bugs and post-commit review comments after r331677.

2018-05-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  7 17:52:19 2018
New Revision: 331707

URL: http://llvm.org/viewvc/llvm-project?rev=331707=rev
Log:
[C++2a] Implement operator<=>: Address bugs and post-commit review comments 
after r331677.

This patch addresses some mostly trivial post-commit review comments received
on r331677.

Additionally, this patch fixes an assertion in `getNarrowingKind` caused by
the use of an uninitialized value from `checkThreeWayNarrowingConversion`.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ComparisonCategories.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ComparisonCategories.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/compare-cxx2a.cpp
cfe/trunk/test/SemaCXX/std-compare-cxx2a.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=331707=331706=331707=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  7 17:52:19 2018
@@ -1979,8 +1979,8 @@ public:
   QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError ,
   unsigned *IntegerConstantArgs = nullptr) const;
 
-  /// \brief Types and expressions required to build C++2a three-way 
comparisons
-  ///   using operator<=>, including the values return by builtin <=> 
operators.
+  /// Types and expressions required to build C++2a three-way comparisons
+  /// using operator<=>, including the values return by builtin <=> operators.
   ComparisonCategories CompCategories;
 
 private:

Modified: cfe/trunk/include/clang/AST/ComparisonCategories.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ComparisonCategories.h?rev=331707=331706=331707=diff
==
--- cfe/trunk/include/clang/AST/ComparisonCategories.h (original)
+++ cfe/trunk/include/clang/AST/ComparisonCategories.h Mon May  7 17:52:19 2018
@@ -35,7 +35,7 @@ class Sema;
 class QualType;
 class NamespaceDecl;
 
-/// \brief An enumeration representing the different comparison categories
+/// An enumeration representing the different comparison categories
 /// types.
 ///
 /// C++2a [cmp.categories.pre] The types weak_equality, strong_equality,
@@ -51,9 +51,9 @@ enum class ComparisonCategoryType : unsi
   Last = StrongOrdering
 };
 
-/// \brief An enumeration representing the possible results of a three-way
-///   comparison. These values map onto instances of comparison category types
-///   defined in the standard library. i.e. 'std::strong_ordering::less'.
+/// An enumeration representing the possible results of a three-way
+/// comparison. These values map onto instances of comparison category types
+/// defined in the standard library. e.g. 'std::strong_ordering::less'.
 enum class ComparisonCategoryResult : unsigned char {
   Equal,
   Equivalent,
@@ -79,39 +79,26 @@ public:
 VarDecl *VD;
 
 ValueInfo(ComparisonCategoryResult Kind, VarDecl *VD)
-: Kind(Kind), VD(VD), HasValue(false) {}
+: Kind(Kind), VD(VD) {}
 
-/// \brief True iff we've successfully evaluated the variable as a constant
+/// True iff we've successfully evaluated the variable as a constant
 /// expression and extracted its integer value.
-bool hasValidIntValue() const { return HasValue; }
+bool hasValidIntValue() const;
 
-/// \brief Get the constant integer value used by this variable to 
represent
+/// Get the constant integer value used by this variable to represent
 /// the comparison category result type.
-llvm::APSInt getIntValue() const {
-  assert(hasValidIntValue());
-  return IntValue;
-}
-
-void setIntValue(llvm::APSInt Val) {
-  IntValue = Val;
-  HasValue = true;
-}
-
-  private:
-friend class ComparisonCategoryInfo;
-llvm::APSInt IntValue;
-bool HasValue : 1;
+llvm::APSInt getIntValue() const;
   };
 private:
   const ASTContext 
 
-  /// \brief A map containing the comparison category result decls from the
+  /// A map containing the comparison category result decls from the
   /// standard library. The key is a value of ComparisonCategoryResult.
   mutable llvm::SmallVector<
   ValueInfo, static_cast(ComparisonCategoryResult::Last) + 1>
   Objects;
 
-  /// \brief Lookup the ValueInfo struct for the specified ValueKind. If the
+  /// Lookup the ValueInfo struct for the specified ValueKind. If the
   /// VarDecl for the value cannot be found, nullptr is returned.
   ///
   /// If the ValueInfo does not have a valid integer value the variable
@@ -119,12 +106,12 @@ private:
   ValueInfo *lookupValueInfo(ComparisonCategoryResult ValueKind) const;
 
 public:
-  /// \brief The 

r331706 - Move test input file into same directory as test. NFC

2018-05-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon May  7 17:29:21 2018
New Revision: 331706

URL: http://llvm.org/viewvc/llvm-project?rev=331706=rev
Log:
Move test input file into same directory as test.  NFC

Added:
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/

cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
Removed:
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/
Modified:
cfe/trunk/test/Frontend/dependency-gen.c

Added: 
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt?rev=331706=auto
==
(empty)

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=331706=331705=331706=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Mon May  7 17:29:21 2018
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


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


Buildbot numbers for the week of 4/22/2018 - 4/28/2018

2018-05-07 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 4/22/2018 - 4/28/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 clang-x64-ninja-win7 | 132:35:41
 clang-x86-windows-msvc2015   | 88:37:04
 llvm-clang-x86_64-expensive-checks-win   | 63:58:55
 clang-cmake-aarch64-full | 39:44:41
 clang-with-thin-lto-windows  | 12:19:51
 clang-cmake-armv8-selfhost-neon  | 12:00:59
 clang-ppc64le-linux-multistage   | 10:19:48
 clang-cmake-armv7-global-isel| 10:19:13
 clang-cmake-armv8-quick  | 10:07:55
 clang-s390x-linux-multistage | 09:51:31
 clang-cmake-armv8-full   | 09:51:27
 clang-cmake-armv7-quick  | 09:50:22
 clang-cmake-aarch64-global-isel  | 09:31:54
 clang-cmake-aarch64-quick| 09:15:30
 sanitizer-x86_64-linux-bootstrap | 08:24:01
 clang-with-lto-ubuntu| 08:20:56
 clang-cmake-thumbv7-full-sh  | 08:17:14
 clang-cmake-armv7-full   | 08:04:53
 clang-with-thin-lto-ubuntu   | 07:20:17
 clang-s390x-linux| 07:17:34
 clang-cmake-armv7-selfhost   | 07:15:49
 clang-cmake-armv7-selfhost-neon  | 07:13:07
 clang-s390x-linux-lnt| 07:07:14
 clang-cmake-aarch64-lld  | 07:04:48
 lldb-x86_64-ubuntu-14.04-buildserver | 06:59:41
 polly-amd64-linux| 06:58:51
 clang-lld-x86_64-2stage  | 06:54:07
 reverse-iteration| 06:40:28
 lldb-x86_64-ubuntu-14.04-cmake   | 06:37:49
 clang-hexagon-elf| 06:34:17
 clang-x86_64-linux-abi-test  | 06:26:39
 lldb-x86_64-darwin-13.4  | 06:12:00
 polly-arm-linux  | 06:07:32
 sanitizer-ppc64be-linux  | 05:07:53
 lldb-windows7-android| 04:19:20
 clang-ppc64be-linux-multistage   | 03:49:28
 clang-cmake-x86_64-avx2-linux| 03:46:03
 llvm-hexagon-elf | 03:45:11
 clang-ppc64le-linux  | 03:43:19
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 03:39:57
 sanitizer-x86_64-linux-bootstrap-ubsan   | 03:37:58
 clang-ppc64be-linux-lnt  | 03:30:07
 clang-cmake-x86_64-sde-avx512-linux  | 03:29:55
 clang-bpf-build  | 03:21:44
 lldb-amd64-ninja-netbsd8 | 03:21:15
 sanitizer-x86_64-linux-fast  | 03:19:41
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 03:19:21
 sanitizer-ppc64le-linux  | 03:18:46
 sanitizer-x86_64-linux-bootstrap-msan| 03:15:11
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan| 03:13:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 03:10:57
 clang-ppc64le-linux-lnt  | 03:08:19
 clang-ppc64be-linux  | 03:03:42
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11 | 02:56:50
 clang-cmake-x86_64-avx2-linux-perf   | 02:54:22
 clang-cmake-armv7-lnt| 02:41:39
 sanitizer-x86_64-linux   | 02:16:55
 sanitizer-x86_64-linux-autoconf  | 01:51:57
 lld-perf-testsuite   | 01:30:03
 lld-x86_64-darwin13  | 01:25:51
 sanitizer-x86_64-linux-fuzzer| 01:16:27
 lld-x86_64-freebsd   | 01:14:24
 clang-cmake-armv8-lnt| 01:08:27
 lldb-x86_64-ubuntu-14.04-android | 00:58:38
 sanitizer-windows| 00:56:56
 lldb-amd64-ninja-freebsd11   | 00:53:19
 lld-x86_64-win7  | 00:43:16
 lldb-x86-windows-msvc2015| 00:39:51
(68 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder 

Buildbot numbers for the week of 4/29/2018 - 5/5/2018

2018-05-07 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 4/29/2018 - 5/5/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   | was_red
-+-
 libcxx-libcxxabi-libunwind-armv8-linux  | 87:08:24
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 87:08:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17  | 85:42:47
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 85:42:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 85:42:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit  | 85:41:45
 libcxx-libcxxabi-libunwind-aarch64-linux| 85:41:42
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 85:41:38
 libcxx-libcxxabi-libunwind-armv7-linux  | 85:41:29
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 85:41:23
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 85:41:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 85:40:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 85:40:28
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 85:39:58
 clang-cmake-aarch64-quick   | 37:06:23
 clang-lld-x86_64-2stage | 31:37:53
 clang-cmake-aarch64-lld | 30:24:42
 lld-x86_64-darwin13 | 28:39:51
 clang-cmake-aarch64-global-isel | 19:48:09
 clang-s390x-linux-multistage| 19:12:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14  | 18:48:27
 lldb-x86_64-darwin-13.4 | 12:35:39
 clang-cmake-aarch64-full| 10:41:34
 llvm-clang-x86_64-expensive-checks-win  | 09:20:43
 lldb-x86_64-ubuntu-14.04-cmake  | 05:58:00
 clang-with-thin-lto-ubuntu  | 05:51:28
 clang-s390x-linux   | 04:52:48
 clang-with-thin-lto-windows | 04:38:26
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 04:34:13
 clang-x86-windows-msvc2015  | 04:28:08
 clang-cmake-armv7-global-isel   | 03:30:35
 sanitizer-x86_64-linux-fuzzer   | 03:28:18
 clang-x64-ninja-win7| 03:27:07
 polly-amd64-linux   | 03:07:31
 clang-cmake-armv7-full  | 03:00:41
 clang-ppc64be-linux-lnt | 02:53:58
 sanitizer-ppc64le-linux | 02:52:10
 clang-with-lto-ubuntu   | 02:44:54
 reverse-iteration   | 02:24:45
 lldb-x86_64-ubuntu-14.04-buildserver| 02:23:09
 clang-ppc64le-linux-multistage  | 02:17:59
 sanitizer-x86_64-linux-bootstrap-ubsan  | 02:15:51
 clang-cmake-armv8-selfhost-neon | 02:15:40
 clang-hexagon-elf   | 02:14:13
 clang-cmake-x86_64-avx2-linux   | 02:01:42
 polly-arm-linux | 02:00:01
 clang-cmake-armv7-quick | 01:57:53
 clang-x86_64-linux-abi-test | 01:52:24
 clang-cmake-armv8-full  | 01:52:21
 clang-bpf-build | 01:51:12
 sanitizer-ppc64be-linux | 01:48:25
 llvm-hexagon-elf| 01:47:34
 lld-x86_64-freebsd  | 01:45:37
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 01:44:03
 sanitizer-x86_64-linux-fast | 01:41:42
 sanitizer-x86_64-linux-bootstrap| 01:40:06
 clang-cmake-armv8-quick | 01:35:13
 sanitizer-x86_64-linux-bootstrap-msan   | 01:32:56
 clang-ppc64be-linux | 01:29:46
 clang-ppc64be-linux-multistage  | 01:22:16
 clang-ppc64le-linux | 01:17:45
 clang-ppc64le-linux-lnt | 01:17:32
 

r331697 - Fix failing codegen test on non-x86_64 platforms

2018-05-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  7 16:15:34 2018
New Revision: 331697

URL: http://llvm.org/viewvc/llvm-project?rev=331697=rev
Log:
Fix failing codegen test on non-x86_64 platforms

Modified:
cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp

Modified: cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp?rev=331697=331696=331697=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp Mon May  7 16:15:34 2018
@@ -17,54 +17,54 @@
 
 // CHECK-LABEL: @_Z11test_signedii
 auto test_signed(int x, int y) {
-  // CHECK: %retval = alloca %[[SO]]
+  // CHECK: %[[DEST:retval|agg.result]]
   // CHECK: %cmp.lt = icmp slt i32 %0, %1
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
   // CHECK: %cmp.eq = icmp eq i32 %0, %1
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
-  // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %retval, i32 
0, i32 0
+  // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_, align 1
-  // CHECK: %[[FINAL:.*]] = getelementptr inbounds %[[SO]], %[[SO]]* %retval
-  // CHECK: %[[RET:.*]] = load i8, i8* %[[FINAL]]
-  // CHECK: ret i8 %[[RET]]
+  // CHECK: ret
   return x <=> y;
 }
 
 // CHECK-LABEL: @_Z13test_unsignedjj
 auto test_unsigned(unsigned x, unsigned y) {
+  // CHECK: %[[DEST:retval|agg.result]]
   // CHECK: %cmp.lt = icmp ult i32 %0, %1
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
   // CHECK: %cmp.eq = icmp eq i32 %0, %1
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
-  // CHECK: %retval
-  // CHECK: %sel.eq
+  // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
+  // CHECK: store i8 %sel.eq, i8* %__value_
   // CHECK: ret
   return x <=> y;
 }
 
 // CHECK-LABEL: @_Z10float_testdd
 auto float_test(double x, double y) {
-  // CHECK: %retval = alloca %[[PO]]
+  // CHECK: %[[DEST:retval|agg.result]]
   // CHECK: %cmp.eq = fcmp oeq double %0, %1
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 [[UNORD]]
   // CHECK: %cmp.gt = fcmp ogt double %0, %1
   // CHECK: %sel.gt = select i1 %cmp.gt, i8 [[GT]], i8 %sel.eq
   // CHECK: %cmp.lt = fcmp olt double %0, %1
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 %sel.gt
-  // CHECK: %retval
-  // CHECK: %sel.lt
+  // CHECK: %__value_ = getelementptr inbounds %[[PO]], %[[PO]]* %[[DEST]]
+  // CHECK: store i8 %sel.lt, i8* %__value_
   // CHECK: ret
   return x <=> y;
 }
 
 // CHECK-LABEL: @_Z8ptr_testPiS_
 auto ptr_test(int *x, int *y) {
+  // CHECK: %[[DEST:retval|agg.result]]
   // CHECK: %cmp.lt = icmp ult i32* %0, %1
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
   // CHECK: %cmp.eq = icmp eq i32* %0, %1
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
-  // CHECK: %retval
-  // CHECK: %sel.eq
+  // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
+  // CHECK: store i8 %sel.eq, i8* %__value_, align 1
   // CHECK: ret
   return x <=> y;
 }
@@ -75,38 +75,36 @@ using MemDataT = int(MemPtr::*);
 
 // CHECK-LABEL: @_Z12mem_ptr_testM6MemPtrFvvES1_
 auto mem_ptr_test(MemPtrT x, MemPtrT y) {
-  // CHECK: %retval = alloca %[[SE]]
-  // CHECK: %cmp.ptr = icmp eq i64 %lhs.memptr.ptr, %rhs.memptr.ptr
-  // CHECK: %cmp.ptr.null = icmp eq i64 %lhs.memptr.ptr, 0
-  // CHECK: %cmp.adj = icmp eq i64 %lhs.memptr.adj, %rhs.memptr.adj
-  // CHECK: %6 = or i1 %cmp.ptr.null, %cmp.adj
-  // CHECK: %memptr.eq = and i1 %cmp.ptr, %6
+  // CHECK: %[[DEST:retval|agg.result]]
+  // CHECK: %cmp.ptr = icmp eq [[TY:i[0-9]+]] %lhs.memptr.ptr, %rhs.memptr.ptr
+  // CHECK: %cmp.ptr.null = icmp eq [[TY]] %lhs.memptr.ptr, 0
+  // CHECK: %cmp.adj = icmp eq [[TY]] %lhs.memptr.adj, %rhs.memptr.adj
+  // CHECK: %[[OR:.*]] = or i1 %cmp.ptr.null, %cmp.adj
+  // CHECK: %memptr.eq = and i1 %cmp.ptr, %[[OR]]
   // CHECK: %sel.eq = select i1 %memptr.eq, i8 [[EQ]], i8 [[NE]]
-  // CHECK: %retval
-  // CHECK: %sel.eq
+  // CHECK: %__value_ = getelementptr inbounds %[[SE]], %[[SE]]* %[[DEST]]
+  // CHECK: store i8 %sel.eq, i8* %__value_, align 1
   // CHECK: ret
   return x <=> y;
 }
 
 // CHECK-LABEL: @_Z13mem_data_testM6MemPtriS0_
 auto mem_data_test(MemDataT x, MemDataT y) {
-  // CHECK: %retval = alloca %[[SE]]
-  // CHECK: %[[CMP:.*]] = icmp eq i64 %0, %1
+  // CHECK: %[[DEST:retval|agg.result]]
+  // CHECK: %[[CMP:.*]] = icmp eq i{{[0-9]+}} %0, %1
   // CHECK: %sel.eq = select i1 %[[CMP]], i8 [[EQ]], i8 [[NE]]
-  // CHECK: %retval
-  // CHECK: %sel.eq
+  // CHECK: %__value_ = getelementptr inbounds %[[SE]], %[[SE]]* %[[DEST]]
+  // CHECK: store i8 %sel.eq, i8* %__value_, align 1
   return x <=> y;
 }
 
 // CHECK-LABEL: @_Z13test_constantv
 auto test_constant() {
-  // CHECK: entry:
+  // CHECK: %[[DEST:retval|agg.result]]
   // CHECK-NOT: icmp
-  // CHECK: 

r331692 - PR37352: mangle numbering for decomposition declarations.

2018-05-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May  7 15:23:38 2018
New Revision: 331692

URL: http://llvm.org/viewvc/llvm-project?rev=331692=rev
Log:
PR37352: mangle numbering for decomposition declarations.

In order to match our mangling scheme, use a different set of numbers for
decomposition declarations, and consider all binding names when forming the
numbering. This does not yet affect any mangled names we produce, because
local decomposition declarations can't yet have linkage, but a C++ standard
proposal to change that is currently being processed.

Modified:
cfe/trunk/lib/AST/ItaniumCXXABI.cpp
cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp

Modified: cfe/trunk/lib/AST/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumCXXABI.cpp?rev=331692=331691=331692=diff
==
--- cfe/trunk/lib/AST/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumCXXABI.cpp Mon May  7 15:23:38 2018
@@ -24,6 +24,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/iterator.h"
 
 using namespace clang;
 
@@ -50,12 +51,64 @@ static const IdentifierInfo *findAnonymo
   return nullptr;
 }
 
+/// The name of a decomposition declaration.
+struct DecompositionDeclName {
+  using BindingArray = ArrayRef;
+
+  /// Representative example of a set of bindings with these names.
+  BindingArray Bindings;
+
+  /// Iterators over the sequence of identifiers in the name.
+  struct Iterator
+  : llvm::iterator_adaptor_base {
+Iterator(BindingArray::const_iterator It) : iterator_adaptor_base(It) {}
+const IdentifierInfo *operator*() const {
+  return (*this->I)->getIdentifier();
+}
+  };
+  Iterator begin() const { return Iterator(Bindings.begin()); }
+  Iterator end() const { return Iterator(Bindings.end()); }
+};
+}
+
+namespace llvm {
+template<>
+struct DenseMapInfo {
+  using ArrayInfo = llvm::DenseMapInfo;
+  using IdentInfo = llvm::DenseMapInfo;
+  static DecompositionDeclName getEmptyKey() {
+return {ArrayInfo::getEmptyKey()};
+  }
+  static DecompositionDeclName getTombstoneKey() {
+return {ArrayInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(DecompositionDeclName Key) {
+assert(!isEqual(Key, getEmptyKey()) && !isEqual(Key, getTombstoneKey()));
+return llvm::hash_combine_range(Key.begin(), Key.end());
+  }
+  static bool isEqual(DecompositionDeclName LHS, DecompositionDeclName RHS) {
+if (ArrayInfo::isEqual(LHS.Bindings, ArrayInfo::getEmptyKey()))
+  return ArrayInfo::isEqual(RHS.Bindings, ArrayInfo::getEmptyKey());
+if (ArrayInfo::isEqual(LHS.Bindings, ArrayInfo::getTombstoneKey()))
+  return ArrayInfo::isEqual(RHS.Bindings, ArrayInfo::getTombstoneKey());
+return LHS.Bindings.size() == RHS.Bindings.size() &&
+   std::equal(LHS.begin(), LHS.end(), RHS.begin());
+  }
+};
+}
+
+namespace {
+
 /// \brief Keeps track of the mangled names of lambda expressions and block
 /// literals within a particular context.
 class ItaniumNumberingContext : public MangleNumberingContext {
   llvm::DenseMap ManglingNumbers;
   llvm::DenseMap VarManglingNumbers;
   llvm::DenseMap TagManglingNumbers;
+  llvm::DenseMap
+  DecompsitionDeclManglingNumbers;
 
 public:
   unsigned getManglingNumber(const CXXMethodDecl *CallOperator) override {
@@ -82,9 +135,14 @@ public:
 
   /// Variable decls are numbered by identifier.
   unsigned getManglingNumber(const VarDecl *VD, unsigned) override {
+if (auto *DD = dyn_cast(VD))
+  return ++DecompsitionDeclManglingNumbers[
+  DecompositionDeclName{DD->bindings()}];
+
 const IdentifierInfo *Identifier = VD->getIdentifier();
 if (!Identifier) {
-  // VarDecl without an identifier represents an anonymous union 
declaration.
+  // VarDecl without an identifier represents an anonymous union
+  // declaration.
   Identifier = findAnonymousUnionVarDeclName(*VD);
 }
 return ++VarManglingNumbers[Identifier];

Modified: cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp?rev=331692=331691=331692=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp Mon May  7 15:23:38 2018
@@ -76,4 +76,9 @@ template  void dependent_foreac
 a,b,c;
 }
 
+struct PR37352 {
+  int n;
+  void f() { static auto [a] = *this; } // expected-error {{cannot be declared 
'static'}}
+};
+
 // FIXME: by-value array copies


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r331688 - [NFC] Move 2 variable initialization from Ctor to member initializers.

2018-05-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon May  7 15:01:06 2018
New Revision: 331688

URL: http://llvm.org/viewvc/llvm-project?rev=331688=rev
Log:
[NFC] Move 2 variable initialization from Ctor to member initializers.

In response to dblaikie's suggestion on r331536, replace the two enum
typed variable initializers in the constructor with member initializers.

Modified:
cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h

Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331688=331687=331688=diff
==
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Mon May  7 
15:01:06 2018
@@ -34,10 +34,10 @@ public:
   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
 
   /// Destination of cl.exe style /showIncludes info.
-  ShowIncludesDestination ShowIncludesDest;
+  ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
 
   /// The format for the dependency file.
-  DependencyOutputFormat OutputFormat;
+  DependencyOutputFormat OutputFormat = DependencyOutputFormat::Make;
 
   /// The file to write dependency output to.
   std::string OutputFile;
@@ -67,9 +67,7 @@ public:
 public:
   DependencyOutputOptions()
   : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0),
-ShowIncludesDest(ShowIncludesDestination::None),
-OutputFormat(DependencyOutputFormat::Make) {}
+AddMissingHeaderDeps(0), IncludeModuleFiles(0) {}
 };
 
 }  // end namespace clang


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


[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

2018-05-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2271
+static bool hasRequiredFeature(StringRef Feature,
+   llvm::StringMap& CallerFeatureMap,
+   std::string ) {

'&' should be in front of the variable name not after the type.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2305
+ return Feature == ExplicitFeature.substr(1);
+}))
+if (!hasRequiredFeature(Feature, CallerFeatureMap, FirstMissing))

Please run clang-format on this. There's some weird indentation happening.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2345
 StringRef(FeatureList).split(ReqFeatures, ',');
-if (!hasRequiredFeatures(ReqFeatures, CGM, FD, MissingFeature))
+if (!hasRequiredFeatures(ReqFeatures, CGM, FD, TargetDecl, MissingFeature))
   CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)

Can we call getAttr here and pass the result of that instead of the TargetDecl? 
We know the attribute exists. Then rename getFunctionTargetAttrs and make it 
only responsible for removing unknown features. Push its other call site back 
into the 'if' there. This removes the need to return an empty ParsedTargetAttr.



Comment at: lib/CodeGen/CodeGenModule.cpp:4998
 
-// Fills in the supplied string map with the set of target features for the
-// passed in function.
-void CodeGenModule::getFunctionFeatureMap(llvm::StringMap ,
-  const FunctionDecl *FD) {
-  StringRef TargetCPU = Target.getTargetOpts().CPU;
+TargetAttr::ParsedTargetAttr CodeGenModule::getFunctionTargetAttrs(const 
FunctionDecl *FD)
+{

Open curly brace should be on previous line.



Comment at: lib/CodeGen/CodeGenModule.cpp:5024
+  TargetAttr::ParsedTargetAttr ParsedAttr = getFunctionTargetAttrs(FD);
+  if (ParsedAttr.Features.size() != 0) {
 // Make a copy of the features as passed on the command line into the

!ParsedAttr.Features.empty()


Repository:
  rC Clang

https://reviews.llvm.org/D46541



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


[PATCH] D24867: Request init/fini array on FreeBSD 12 and later

2018-05-07 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson accepted this revision.
arichardson added a comment.

I recently made this change for the CHERI clang fork and as far as I can tell 
everything works fine.


https://reviews.llvm.org/D24867



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


Re: r331536 - [NFC]Convert Class to use member initialization instead of inline.

2018-05-07 Thread David Blaikie via cfe-commits
On Mon, May 7, 2018 at 12:57 PM Keane, Erich  wrote:

> I don’t believe the member initialization for bitfields (of which all the
> ‘0’ values are) happened until C++17, right?
>

Ah, fair point - I hadn't looked at the types, just what was visible in the
patch. (& I don't especially know/recall which standard/etc supported
member initialization of bitfields, but I could certainly believe it didn't
happen until '17)


>   I could definitely member initialize the two enum fields though.
>

*nod*


>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Monday, May 7, 2018 12:03 PM
> *To:* Keane, Erich 
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: r331536 - [NFC]Convert Class to use member initialization
> instead of inline.
>
>
>
> Perhaps this should use non-static data member initializers instead?
>
>
>
> On Fri, May 4, 2018 at 9:23 AM Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: erichkeane
> Date: Fri May  4 09:19:53 2018
> New Revision: 331536
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331536=rev
> Log:
> [NFC]Convert Class to use member initialization instead of inline.
>
> Modified:
> cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
>
> Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331536=331535=331536=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Fri May  4
> 09:19:53 2018
> @@ -65,15 +65,11 @@ public:
>std::string ModuleDependencyOutputDir;
>
>  public:
> -  DependencyOutputOptions() {
> -IncludeSystemHeaders = 0;
> -ShowHeaderIncludes = 0;
> -UsePhonyTargets = 0;
> -AddMissingHeaderDeps = 0;
> -IncludeModuleFiles = 0;
> -ShowIncludesDest = ShowIncludesDestination::None;
> -OutputFormat = DependencyOutputFormat::Make;
> -  }
> +  DependencyOutputOptions()
> +  : IncludeSystemHeaders(0), ShowHeaderIncludes(0),
> UsePhonyTargets(0),
> +AddMissingHeaderDeps(0), IncludeModuleFiles(0),
> +ShowIncludesDest(ShowIncludesDestination::None),
> +OutputFormat(DependencyOutputFormat::Make) {}
>  };
>
>  }  // end namespace clang
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331683 - [X86] Use target feature defines in tests instead of defining our own flag on the command line. NFCI

2018-05-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May  7 14:47:13 2018
New Revision: 331683

URL: http://llvm.org/viewvc/llvm-project?rev=331683=rev
Log:
[X86] Use target feature defines in tests instead of defining our own flag on 
the command line. NFCI

Modified:
cfe/trunk/test/CodeGen/gfni-builtins.c
cfe/trunk/test/CodeGen/vaes-builtins.c
cfe/trunk/test/CodeGen/vpclmulqdq-builtins.c

Modified: cfe/trunk/test/CodeGen/gfni-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/gfni-builtins.c?rev=331683=331682=331683=diff
==
--- cfe/trunk/test/CodeGen/gfni-builtins.c (original)
+++ cfe/trunk/test/CodeGen/gfni-builtins.c Mon May  7 14:47:13 2018
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -emit-llvm -o - | FileCheck %s --check-prefix SSE
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -DAVX 
-target-feature +gfni -target-feature +avx -emit-llvm -o - | FileCheck %s 
--check-prefixes SSE,AVX
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -DAVX512 
-target-feature +gfni -target-feature +avx512bw -target-feature +avx512vl 
-emit-llvm -o - | FileCheck %s --check-prefixes SSE,AVX,AVX512
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -target-feature +avx -emit-llvm -o - | FileCheck %s 
--check-prefixes SSE,AVX
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -target-feature +avx512bw -target-feature +avx512vl 
-emit-llvm -o - | FileCheck %s --check-prefixes SSE,AVX,AVX512
 
 #include 
 
@@ -22,7 +22,7 @@ __m128i test_mm_gf2p8mul_epi8(__m128i A,
   return _mm_gf2p8mul_epi8(A, B);
 }
 
-#if defined(AVX) || defined(AVX512)
+#ifdef __AVX__
 __m256i test_mm256_gf2p8affineinv_epi64_epi8(__m256i A, __m256i B) {
   // AVX-LABEL: @test_mm256_gf2p8affineinv_epi64_epi8
   // AVX: @llvm.x86.vgf2p8affineinvqb.256
@@ -40,9 +40,9 @@ __m256i test_mm256_gf2p8mul_epi8(__m256i
   // AVX: @llvm.x86.vgf2p8mulb.256
   return _mm256_gf2p8mul_epi8(A, B);
 }
-#endif // AVX
+#endif // __AVX__
 
-#ifdef AVX512
+#ifdef __AVX512BW__
 __m512i test_mm512_gf2p8affineinv_epi64_epi8(__m512i A, __m512i B) {
   // AVX512-LABEL: @test_mm512_gf2p8affineinv_epi64_epi8
   // AVX512: @llvm.x86.vgf2p8affineinvqb.512
@@ -179,4 +179,4 @@ __m128i test_mm_mask_gf2p8mul_epi8(__m12
   // AVX512: select <16 x i1> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i8> 
{{.*}}
   return _mm_mask_gf2p8mul_epi8(S, U, A, B);
 }
-#endif // AVX512
+#endif // __AVX512BW__

Modified: cfe/trunk/test/CodeGen/vaes-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vaes-builtins.c?rev=331683=331682=331683=diff
==
--- cfe/trunk/test/CodeGen/vaes-builtins.c (original)
+++ cfe/trunk/test/CodeGen/vaes-builtins.c Mon May  7 14:47:13 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +vaes -emit-llvm -o - | FileCheck %s --check-prefix AVX
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -DAVX512 
-target-feature +vaes -target-feature +avx512f -emit-llvm -o - | FileCheck %s 
--check-prefixes AVX,AVX512
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +vaes -target-feature +avx512f -emit-llvm -o - | FileCheck %s 
--check-prefixes AVX,AVX512
 
 #include 
 
@@ -27,7 +27,7 @@ __m256i test_mm256_aesdeclast_epi128(__m
   return _mm256_aesdeclast_epi128(__A, __B);
 }
 
-#ifdef AVX512
+#ifdef __AVX512F__
 __m512i test_mm512_aesenc_epi128(__m512i __A, __m512i __B) {
   // AVX512-LABEL: @test_mm512_aesenc_epi128
   // AVX512: @llvm.x86.aesni.aesenc.512

Modified: cfe/trunk/test/CodeGen/vpclmulqdq-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vpclmulqdq-builtins.c?rev=331683=331682=331683=diff
==
--- cfe/trunk/test/CodeGen/vpclmulqdq-builtins.c (original)
+++ cfe/trunk/test/CodeGen/vpclmulqdq-builtins.c Mon May  7 14:47:13 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +vpclmulqdq -emit-llvm -o - | FileCheck %s --check-prefix AVX
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -DAVX512 
-target-feature +vpclmulqdq -target-feature +avx512f -emit-llvm -o - | 
FileCheck %s --check-prefixes AVX,AVX512
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +vpclmulqdq -target-feature +avx512f -emit-llvm -o - | 
FileCheck %s --check-prefixes AVX,AVX512
 
 #include 
 
@@ -8,7 +8,7 @@ __m256i test_mm256_clmulepi64_epi128(__m
   return _mm256_clmulepi64_epi128(A, B, 0);
 }
 
-#ifdef AVX512
+#ifdef __AVX512F__
 __m512i test_mm512_clmulepi64_epi128(__m512i A, __m512i B) {
   // AVX512: @llvm.x86.pclmulqdq.512
   return 

r331682 - [X86] Make _mm256_gf2p8mul_epi8 require avx features since its 256 bits.

2018-05-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May  7 14:47:11 2018
New Revision: 331682

URL: http://llvm.org/viewvc/llvm-project?rev=331682=rev
Log:
[X86] Make _mm256_gf2p8mul_epi8 require avx features since its 256 bits.

Without this we throw an error on the header file instead of the user code when 
the right features aren't enabled in clang.

Rename the other DEFAULT_FN_ATTRS defines to _Z for 512-bit since I used _Y for 
this case.

Modified:
cfe/trunk/lib/Headers/gfniintrin.h

Modified: cfe/trunk/lib/Headers/gfniintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/gfniintrin.h?rev=331682=331681=331682=diff
==
--- cfe/trunk/lib/Headers/gfniintrin.h (original)
+++ cfe/trunk/lib/Headers/gfniintrin.h Mon May  7 14:47:11 2018
@@ -122,8 +122,11 @@
 /* Default attributes for simple form (no masking). */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("gfni")))
 
+/* Default attributes for YMM unmasked form. */
+#define __DEFAULT_FN_ATTRS_Y __attribute__((__always_inline__, __nodebug__, 
__target__("avx,gfni")))
+
 /* Default attributes for ZMM forms. */
-#define __DEFAULT_FN_ATTRS_F __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,gfni")))
+#define __DEFAULT_FN_ATTRS_Z __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,gfni")))
 
 /* Default attributes for VLX forms. */
 #define __DEFAULT_FN_ATTRS_VL __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,avx512vl,gfni")))
@@ -150,7 +153,7 @@ _mm_maskz_gf2p8mul_epi8(__mmask16 __U, _
   __U, __A, __B);
 }
 
-static __inline__ __m256i __DEFAULT_FN_ATTRS
+static __inline__ __m256i __DEFAULT_FN_ATTRS_Y
 _mm256_gf2p8mul_epi8(__m256i __A, __m256i __B)
 {
   return (__m256i) __builtin_ia32_vgf2p8mulb_v32qi((__v32qi) __A,
@@ -172,14 +175,14 @@ _mm256_maskz_gf2p8mul_epi8(__mmask32 __U
   __U, __A, __B);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_gf2p8mul_epi8(__m512i __A, __m512i __B)
 {
   return (__m512i) __builtin_ia32_vgf2p8mulb_v64qi((__v64qi) __A,
   (__v64qi) __B);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_mask_gf2p8mul_epi8(__m512i __S, __mmask64 __U, __m512i __A, __m512i __B)
 {
   return (__m512i) __builtin_ia32_selectb_512(__U,
@@ -187,7 +190,7 @@ _mm512_mask_gf2p8mul_epi8(__m512i __S, _
   (__v64qi) __S);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_maskz_gf2p8mul_epi8(__mmask64 __U, __m512i __A, __m512i __B)
 {
   return _mm512_mask_gf2p8mul_epi8((__m512i)_mm512_setzero_qi(),
@@ -195,7 +198,8 @@ _mm512_maskz_gf2p8mul_epi8(__mmask64 __U
 }
 
 #undef __DEFAULT_FN_ATTRS
-#undef __DEFAULT_FN_ATTRS_F
+#undef __DEFAULT_FN_ATTRS_Y
+#undef __DEFAULT_FN_ATTRS_Z
 #undef __DEFAULT_FN_ATTRS_VL
 
 #endif // __GFNIINTRIN_H


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


r331681 - Relax a FileCheck pattern to make it pass on Windows.

2018-05-07 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May  7 14:40:53 2018
New Revision: 331681

URL: http://llvm.org/viewvc/llvm-project?rev=331681=rev
Log:
Relax a FileCheck pattern to make it pass on Windows.

Should fix Windows bot failure:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16956

Modified:
cfe/trunk/test/Driver/fsanitize-blacklist.c

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=331681=331680=331681=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Mon May  7 14:40:53 2018
@@ -64,6 +64,6 @@
 
 // If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
-// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}cfi_blacklist.txt'
 
 // DELIMITERS: {{^ *"}}


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


[PATCH] D46550: Support Swift calling convention for PPC64 targets

2018-05-07 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added a comment.

Previous review (for the swift-llvm GitHub repo): 
https://github.com/apple/swift-clang/pull/167


Repository:
  rC Clang

https://reviews.llvm.org/D46550



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


[PATCH] D46052: GNUstep Objective-C ABI version 2

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, the comments help a lot.




Comment at: lib/CodeGen/CGObjCGNU.cpp:439
+ ArrayRef IvarOffsets,
+ ArrayRef IvarAlign,
+ ArrayRef IvarOwnership);

theraven wrote:
> DHowett-MSFT wrote:
> > While we're here, is there value in storing the ivar size in layout as 
> > well, so that the runtime doesn't need to calculate it from the distance to 
> > the next ivar/end of the instance?
> Normally the runtime calculates it from the type encoding, if it's required.  
> I agree that it might be nice to have though.  Do you have strong feelings 
> about needing it in the 2.0 ABI?  The looser coupling means that it would be 
> easy to add in the 2.1 ABI if we want it later.  Are you seeing cases where 
> the runtime is calculating it incorrectly because of insufficient information 
> in the type encoding, or where calculating it is causing performance problems?
The distance between ivar offsets wouldn't be correct anyway because of 
alignment padding.  A set-ivar function might be able to get away with copying 
too many bytes from an input buffer (although I wouldn't recommend it!), but a 
get-ivar function definitely should not copy too many bytes into an output 
buffer.

And all that's assuming that the runtime promises not to reorder ivars 
dynamically.  I don't know what the GNU runtime says about that.  (Static 
reordering is fine, since the runtime can reasonably demand that the compiler 
emit ivars in layout order.)



Comment at: lib/CodeGen/CGObjCGNU.cpp:1065
+  }
+}
+auto *ObjCStrGV =

Seems much more reasonable, thanks.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1067
+auto *ObjCStrGV =
+  Fields.finishAndCreateGlobal(isNamed ? StringName : ".objc_string",
+  Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage :

Micro-optimization: I'm pretty sure the type of this ternary is an r-value 
`std::string`, which means copying the string in either case; if you explicitly 
build a StringRef from StringName, the ternary will instead construct a 
StringRef and you'll avoid those unnecessary copies.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1069
+  Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage :
+  llvm::GlobalValue::PrivateLinkage);
+ObjCStrGV->setSection(ConstantStringSection);

The indentation here is a little misleading; I'd suggest aligning the two cases 
of the ternary operator.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1172
+if (isWeak) {
+  // Placeholder for the real symbol.
+  ClassSymbol->setInitializer(new llvm::GlobalVariable(TheModule,

I would suggest clarifying in what sense this is a placeholder.  Does the 
runtime recognize it specially?  If so, how?  Is it replaced statically by a 
later pass in IRGen?


Repository:
  rC Clang

https://reviews.llvm.org/D46052



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


[PATCH] D46550: Support Swift calling convention for PPC64 targets

2018-05-07 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson created this revision.
bob.wilson added a reviewer: aschwaighofer.
Herald added subscribers: kbarton, nemanjai, mcrosier.

This adds basic support for the Swift calling convention with PPC64 targets.
Patch provided by Atul Sowani in bug report #37223


Repository:
  rC Clang

https://reviews.llvm.org/D46550

Files:
  lib/Basic/Targets/PPC.h
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4287,7 +4287,7 @@
 
 namespace {
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
-class PPC64_SVR4_ABIInfo : public ABIInfo {
+class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
 public:
   enum ABIKind {
 ELFv1 = 0,
@@ -4331,7 +4331,7 @@
 public:
   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind, bool HasQPX,
  bool SoftFloatABI)
-  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
+  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
 IsSoftFloatABI(SoftFloatABI) {}
 
   bool isPromotableTypeForABI(QualType Ty) const;
@@ -4374,6 +4374,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -335,6 +335,15 @@
 }
 return false;
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinPPC32TargetInfo


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4287,7 +4287,7 @@
 
 namespace {
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
-class PPC64_SVR4_ABIInfo : public ABIInfo {
+class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
 public:
   enum ABIKind {
 ELFv1 = 0,
@@ -4331,7 +4331,7 @@
 public:
   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind, bool HasQPX,
  bool SoftFloatABI)
-  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
+  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
 IsSoftFloatABI(SoftFloatABI) {}
 
   bool isPromotableTypeForABI(QualType Ty) const;
@@ -4374,6 +4374,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -335,6 +335,15 @@
 }
 return false;
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinPPC32TargetInfo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 145547.
juliehockett marked 9 inline comments as done.
juliehockett edited the summary of this revision.
juliehockett added a comment.

Sorry for the delay in updating this -- check now restricts includes to a 
whitelist, rather than a blacklist, and only applies to system headers, to more 
strictly control which are allowed.

Also updated warning text and addressed comments.


https://reviews.llvm.org/D43778

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/RestrictIncludesCheck.cpp
  clang-tidy/fuchsia/RestrictIncludesCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-restrict-includes.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/fuchsia-restrict-includes/a.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/b.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/j.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/s.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/t.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
  test/clang-tidy/fuchsia-restrict-includes.cpp

Index: test/clang-tidy/fuchsia-restrict-includes.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-includes.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s fuchsia-restrict-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-includes.Includes, value: 's.h;transitive.h'}]}" \
+// RUN:   -system-headers -header-filter=.* \
+// RUN:   -- -std=c++11 -I %S/Inputs/fuchsia-restrict-includes -isystem %S/Inputs/fuchsia-restrict-includes/system
+
+#include "a.h"
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed
+// CHECK-FIXES-NOT: #include 
+#include 
+
+#define foo 
+
+#include foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: #include foo
+
+#/* comment */ include /* comment */ foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: # /* comment */ include /* comment */ foo
+
+// transitive.h includes 
+#include 
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively included from {{(.*\/)}}Inputs/fuchsia-restrict-includes/system/transitive.h
+
+int main() {
+  // f() is declared in r.h
+  f();
+}
\ No newline at end of file
Index: test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
@@ -0,0 +1 @@
+#include 
\ No newline at end of file
Index: test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
@@ -0,0 +1 @@
+void f() {}
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -95,6 +95,7 @@
fuchsia-default-arguments
fuchsia-multiple-inheritance
fuchsia-overloaded-operator
+   fuchsia-restrict-includes
fuchsia-statically-constructed-objects
fuchsia-trailing-return
fuchsia-virtual-inheritance
Index: docs/clang-tidy/checks/fuchsia-restrict-includes.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-restrict-includes.rst
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - fuchsia-restrict-includes
+
+fuchsia-restrict-includes
+=
+
+Checks for allowed includes and suggests removal of any others. If no includes
+are specified, the check will exit without issuing any warnings. 
+
+It is important to note that running this check with fixes may break code, as
+the fix removes headers.
+
+Note that the separator for identifying allowed includes is a semi-colon, and
+therefore this check is unable to allow an include with a semi-colon in the
+filename (e.g. 'foo;bar.h' will be parsed as allowing 'foo' and 'bar.h', and not
+as allowing a file called 'foo;bar.h').
+
+For example, given the allowed system includes 'a.h; b.h':
+
+.. code-block:: c++
+
+  #include 
+  #include 
+  #include // Warning, as c.h is not explicitly allowed
+  
+Options
+---
+
+.. option:: Includes
+
+   A string containing a semi-colon separated list of allowed include filenames.
+   The default is an empty string, which allows all includes.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -110,8 +110,14 @@
   Checks whether a ``std::string::find()`` result is compared with 0, and
   suggests replacing with 

[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/RestrictIncludesCheck.cpp:75
+for (const auto  : FileDirectives) {
+  auto D = Check.diag(Include.Loc, "restricted include found");
+

aaron.ballman wrote:
> I believe this check will be finding transitive includes, correct? If so, 
> maybe this should be two diagnostics: one to say `"'%0' is prohibited from 
> being included"` and a note for the transitive case to say `"file included 
> transitively from here"`?
> 
> Regardless of the behavior you'd like for it, we should have a test case:
> ```
> // a.h
> // Assumed that a.h is prohibited
> void f();
> 
> // b.h
> #include "a.h"
> 
> // c.c
> #include "b.h"
> 
> int main() {
>   f();
> }
> ```
It will flag, but not fix, if a disallowed file is transitively included *and* 
the relevant flag is passed (e.g. -system-headers for system, or 
-header-filter=.* for other. I changed the warning text for header warnings to 
clarify that.



Comment at: clang-tidy/fuchsia/RestrictIncludesCheck.cpp:83
+
+  D << FixItHint::CreateRemoval(ToRange);
+}

aaron.ballman wrote:
> Are you okay with breaking user's code from this removal? If you remove the 
> header file, but not the parts of the code that require that header file to 
> be included, this FixIt will break code.
Yes, but I did add a note to the documentation to call that out.



Comment at: docs/clang-tidy/checks/fuchsia-restrict-includes.rst:27
+
+   A string containing a comma-separated list of header filenames to restrict. 
Default is an empty string.

hokein wrote:
> The check seems do nothing with the default option.
> 
> Do we have a corresponding guideline of fuchsia? 
The idea is to maintain a list of disallowed headers in the local .clang-tidy 
file, so it will be dependent on that. If no headers are restricted, the check 
won't do anything. I'll add documentation to that effect.


https://reviews.llvm.org/D43778



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ASTContext.h:1983
+  /// \brief Types and expressions required to build C++2a three-way 
comparisons
+  ///   using operator<=>, including the values return by builtin <=> 
operators.
+  ComparisonCategories CompCategories;

We don't generally indent comments after a `\brief` like this. Also, we enable 
autobrief, so these `\brief`s are redundant.



Comment at: include/clang/AST/ComparisonCategories.h:56
+///   comparison. These values map onto instances of comparison category types
+///   defined in the standard library. i.e. 'std::strong_ordering::less'.
+enum class ComparisonCategoryResult : unsigned char {

You mean "eg", not "ie" here.



Comment at: include/clang/AST/ComparisonCategories.h:84-103
+/// \brief True iff we've successfully evaluated the variable as a constant
+/// expression and extracted its integer value.
+bool hasValidIntValue() const { return HasValue; }
+
+/// \brief Get the constant integer value used by this variable to 
represent
+/// the comparison category result type.
+llvm::APSInt getIntValue() const {

This seems unnecessary; we can get this information from the `VarDecl` instead. 
(You're caching a result here that is already cached there.)



Comment at: lib/AST/ComparisonCategories.cpp:25
+/// category result by evaluating the initializer for the specified VarDecl as
+/// a constant expression and retreiving the value of the classes first
+/// (and only) field.

classes -> class's



Comment at: lib/AST/ComparisonCategories.cpp:43-46
+  Expr::EvalResult Result;
+  if (!Info->VD->hasInit() ||
+  !Info->VD->getInit()->EvaluateAsRValue(Result, Ctx))
+return true;

Use `VD->evaluateValue()` to get the cached value already stored by the 
`VarDecl`.



Comment at: lib/CodeGen/CGExprAgg.cpp:959
+  !ArgTy->isMemberPointerType() && !ArgTy->isAnyComplexType()) {
+return CGF.ErrorUnsupported(E, "aggregate three-way comparisoaoeun");
+  }

Typo. I'm almost tempted to say we should keep this for entertainment value, 
but on balance let's fix it :)



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:2899-2937
   assert(!location.getAs() && "location cannot be a NonLoc.");
+
+  // Are we loading from a region?  This actually results in two loads; one
+  // to fetch the address of the referenced value and one to fetch the
+  // referenced value.
+  if (const auto *TR =
+dyn_cast_or_null(location.getAsRegion())) {

This does not look related to your three-way comparison changes.



Comment at: test/SemaCXX/compare-cxx2a.cpp:40
 
-#if 0
+  (void)(A < 42);
   // (A,b)

Did you intend to add this here? It doesn't look related to the code under test.



Comment at: test/SemaCXX/std-compare-cxx2a.cpp:6
+void compare_not_found_test() {
+  // expected-error@+1 {{cannot deduce return type of 'operator<=>' because 
type partial_ordering was not found; include }}
+  (void)(0.0 <=> 42.123);

This diagnostic says just `partial_ordering` whereas the one below says 
`'std::partial_ordering'`. I prefer the latter more-explicit form, but in any 
case it would seem good to be consistent.


Repository:
  rL LLVM

https://reviews.llvm.org/D45476



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


[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45093#1090292, @rsmith wrote:

> If you want to force a particular printing policy to be used for 
> `-ast-print`, I think it would be better to change the `print` call in 
> `lib/Frontend/ASTConsumers.cpp` to pass your desired printing policy, rather 
> than changing other components to prevent them from changing the 
> `ASTContext`'s default printing policy.


Thanks.  I'll look into that.

> (For what it's worth, I think we should also try to change the way we print 
> diagnostics so that `Sema` is asked for a printing policy when it's needed 
> rather than it setting global `ASTContext` state each time we consider 
> printing a diagnostic. That way we could also take the `SourceLocation` 
> information into account to figure out whether `bool` is suitably `#define`d 
> at the point of the diagnostic rather than checking whether it's defined at 
> the current end-of-preprocessing state. But that's not really relevant for 
> this patch, except that generally I think we should be moving away from 
> stashing a global `PrintingPolicy` on the `ASTContext`.)

I'll keep that in mind in case I have more work in that area.

>>> I'd like @rsmith's opinion on whether we should be trying to make 
>>> -ast-print have good source fidelity or not. I was under the impression we 
>>> wanted -ast-print to faithfully reproduce code at least as a low priority 
>>> desire, but it sounds like it may only be intended as an approximation of 
>>> the user's source code, so adding extra machinery to support better 
>>> fidelity may be more maintenance burden than it's worth.
>> 
>> Given the discussion in https://reviews.llvm.org/D45463, it seems I need a 
>> more precise understanding of the purpose of -ast-print before I write any 
>> more fixes like these.
> 
> As things stand, I'd generally consider `-ast-print` to be a "best-effort" 
> feature: we don't guarantee that it produces valid code, but we would prefer 
> that it does. I do not think we yet have a clear argument that it's worth 
> accepting costs elsewhere in order to solely improve `-ast-print`, but 
> fortunately most improvements to `-ast-print` also improve our diagnostic 
> quality, the usability of our AST in tooling scenarios, or some other 
> property that we do care about, so this issue seldom arises. (For example, in 
> the context of https://reviews.llvm.org/D45463, information on whether a 
> declaration owns a `TagDecl` is directly useful to tooling (for instance, 
> refactoring tools care how a multi-declarator declaration was written so that 
> they can properly rewrite it), as well as being useful for `-ast-print` 
> fidelity. So it would make sense to consider how to better represent this 
> information in the AST so that all the interested users have access to it.)

Thanks.  That helps.

> However... Clang is an open-source meritocracy. As such, the goals of the 
> Clang project are a synthesized amalgam of the goals of the Clang 
> contributors. If you want to take ownership of the AST printer and, for 
> instance, make it always generate valid code, we can discuss the technical 
> merits of that (use cases, benefit to you and to other users, maintenance 
> costs, etc) even if the original purpose of the flag did not extend that far.

For the moment, I'll just fix issues as I encounter them.  If I decide 
-ast-print fidelity is vital to my work in the long term, or if my fixes 
introduce problematic costs so that our goals for -ast-print then conflict, 
then we can have that larger discussion.

I'm not sure I'm experienced enough to take ownership of -ast-print just yet.  
However, if there are as many fidelity issues as you've suggested, I'll 
probably get there eventually.


https://reviews.llvm.org/D45093



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


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D42933#1090286, @smeenai wrote:

> Note that the alignment matters in addition to the size.


Sure, but AFAICT from `./lib/Basic/Targets/*` the alignment is also specified 
properly, is it not?

> The pattern I've seen internally is people using `%zd` for NSInteger and 
> `%tu` for NSUInteger, since until clang 6 neither of those were 
> format-checked at all.
> 
> I'd be fine with adding an option to relax the printf checking if the size 
> and alignment of the specifier and the actual type match, even if the types 
> themselves differ (`-Wformat-relaxed` or something similar), so that you'd 
> still get warnings on cases where the specifier mismatch could cause runtime 
> issues.

What are the cases that you're worried about? The only ones I'm trying to 
capture here are `NSInteger` with `%zd` and `NSUInteger` with `%zu`, are there 
others?

> I think that would be preferable to special-casing the Apple types.

If there are more that should be captured and a similar point solution doesn't 
apply, agreed. However I'd like to understand if we agree on the guarantees 
that the platform offers for the two specific cases I'm targeting.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331674: [CFI] Force LLVM to die if the implicit blacklist 
files cannot be found. (authored by pcc, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331674 - [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May  7 13:54:05 2018
New Revision: 331674

URL: http://llvm.org/viewvc/llvm-project?rev=331674=rev
Log:
[CFI] Force LLVM to die if the implicit blacklist files cannot be found.

Currently LLVM CFI tries to use an implicit blacklist file, currently
in /usr/lib64/clang//share. If the file is not there, LLVM
happily continues, which causes CFI to add checks to files/functions
that are known to fail, generating binaries that fail. This CL causes
LLVM to die (I hope) if it can't find these implicit blacklist files.

Patch by Caroline Tice!

Differential Revision: https://reviews.llvm.org/D46403

Added:
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/

cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-blacklist.c
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=331674=331673=331674=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon May  7 13:54:05 2018
@@ -115,6 +115,10 @@ static void addDefaultBlacklists(const D
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt?rev=331674=auto
==
(empty)

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=331674=331673=331674=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Mon May  7 13:54:05 2018
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=331674=331673=331674=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Mon May  7 13:54:05 2018
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331673: Correct warning on Float-Integer conversions. 
(authored by erichkeane, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46535?vs=145536=145542#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,16 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -81,9 +81,9 @@
   char b = -500.0;  // caught by -Wliteral-conversion
 
   const float LargeNumber = 1024;
-  char c = LargeNumber;  // expected-warning{{implicit conversion of out of range value from 'const float' to 'char' changes value from 1024 to 127}}
-  char d = 400.0 + 400.0;  // expected-warning{{implicit conversion of out of 

r331673 - Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon May  7 13:52:56 2018
New Revision: 331673

URL: http://llvm.org/viewvc/llvm-project?rev=331673=rev
Log:
Correct warning on Float->Integer conversions.

As identified and briefly discussed here:
https://bugs.llvm.org/show_bug.cgi?id=37305

Converting a floating point number to an integer type when
the integral part is out of the range of the integer type is
undefined behavior in C. Additionally, CodeGen emits an undef
in this situation.

HOWEVER, we've been giving a warning that says that the value is
changed. This patch corrects the warning to list that it is actually
undefined behavior.

Differential Revision: https://reviews.llvm.org/D46535

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331673=331672=331673=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  7 13:52:56 
2018
@@ -3140,6 +3140,9 @@ def warn_impcast_bitfield_precision_cons
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3148,6 +3151,9 @@ def warn_impcast_float_to_integer : Warn
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=331673=331672=331673=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon May  7 13:52:56 2018
@@ -9429,6 +9429,16 @@ static void DiagnoseFloatingImpCast(Sema
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@ static void DiagnoseFloatingImpCast(Sema
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   
diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=331673=331672=331673=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Mon May  7 13:52:56 2018
@@ -157,7 +157,7 @@ struct coroutine_handle {
 

[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM


https://reviews.llvm.org/D46403



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145540.
cmtice added a comment.

Make cfi_blacklist.txt be an empty file.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D46535



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145537.
cmtice added a comment.

Make -resource-dir point to correct directory, in test case; move 
cfi_blacklist.txt file to 'share' subdirectory in test resource dir.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: 
test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
===
--- test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
+++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
@@ -0,0 +1,19 @@
+[cfi-unrelated-cast]
+# The specification of std::get_temporary_buffer mandates a cast to
+# uninitialized T* (libstdc++, libc++, MSVC stdlib).
+fun:_ZSt20get_temporary_buffer*
+fun:_ZNSt3__120get_temporary_buffer*
+fun:*get_temporary_buffer@.*@std@@*
+
+# STL address-of magic (libstdc++, libc++).
+fun:*__addressof*
+fun:_ZNSt3__19addressof*
+
+# Windows C++ stdlib headers that contain bad unrelated casts.
+src:*xmemory0
+src:*xstddef
+
+# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
+# This ctor is used by std::make_shared and needs to cast to uninitialized T*
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: 

[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 145536.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Aaron's comments :)


https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,16 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ IntegerValue.isUnsigned() &&
+ (IntegerValue.isMaxValue() || IntegerValue.isMinValue(
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- test/SemaCXX/warn-literal-conversion.cpp
+++ test/SemaCXX/warn-literal-conversion.cpp
@@ -48,4 +48,11 @@
   // values.
   bool b3 = 0.0f;
   bool b4 = 0.0;
+
+  // These all warn because they overflow the target type.
+  short s = 32768.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'short' is undefined}}
+  unsigned short us = 65536.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'unsigned short' is undefined}}
+
+  short s2 = -32769.0; // expected-warning{{implicit conversion of out of 

[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman edited reviewers, added: probinson; removed: void.
aaron.ballman added a subscriber: probinson.
aaron.ballman added a comment.

Adding in @probinson as he originally added the `optnone` attribute. Paul, do 
you recall why you opted (haha, pun totally intended) to implement `optnone` 
rather than `optimize("O0")` from GCC?




Comment at: include/clang/Basic/Attr.td:1494
+def NoStackProtector : InheritableAttr {
+  let Spellings = [GCC<"no_stack_protector">];
+  let Subjects = SubjectList<[Function]>;

manojgupta wrote:
> aaron.ballman wrote:
> > This is not a GCC attribute, so this should use the Clang spelling.
> > 
> > However, why spell the attribute this way rather than use the GCC spelling 
> > (`optimize("no-stack-protector")`?
> Thanks, I have changed it to use Clang spelling.
> 
> Regarding __attribute__((optimize("..."))), it is a generic facility in GCC 
> that works for many optimizer flags.
> Clang currently does not support this syntax currently instead preferring its 
> own version for some options e.g. -O0. 
> e.g.  
> ```
> __attribute__((optimize("O0")))  // clang version is __attribute__((optnone)) 
> ```
> If we want to support the GCC syntax, future expectation would be support 
> more flags under this syntax. Is that the path we want to take (I do not know 
> the history related to previous syntax decisions but better GCC compatibility 
> will be a nice thing to have) 
The history of `optnone` predates my involvement with Clang and I've not been 
able to find the original review thread (I did find the one where I gave my 
LGTM on the original patch, but that was a resubmission after the original 
design was signed off).

I'm not keen on attributes that have the same semantics but differ in spelling 
from attributes supported by GCC unless there's a good reason to deviate. Given 
that we've already deviated, I'd like to understand why better -- I don't want 
to push you to implement something we've already decided was a poor design, but 
I also don't want to accept code if we can instead use syntax that is 
compatible with GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D46300



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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:9440-9441
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(

aaron.ballman wrote:
> I think you can combine all of the predicates into:
> ```
> if (!IsBool && ((IntegerValue.isSigned() && (...) || 
> (IntegerValue.isUnsigned() && (...
>   return DiagnoseImpCast(S, E, T, CContext, 
> diag::warn_impcast_literal_float_to_integer_out_of_range);
> ```
I'd waffled on whether to combine those ore not, since I was 50/50 and you have 
an opinion, combining it :)


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331666: [Driver] Use -fuse-line-directives by default in 
MSVC mode (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46520?vs=145446=145529#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46520

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331666: [Driver] Use -fuse-line-directives by default in 
MSVC mode (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46520?vs=145446=145528#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46520

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331666 - [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon May  7 13:26:09 2018
New Revision: 331666

URL: http://llvm.org/viewvc/llvm-project?rev=331666=rev
Log:
[Driver] Use -fuse-line-directives by default in MSVC mode

Don't use the GNU extension form of line markers in MSVC mode.

Differential Revision: https://reviews.llvm.org/D46520

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331666=331665=331666=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon May  7 13:26:09 2018
@@ -4215,9 +4215,9 @@ void Clang::ConstructJob(Compilation ,
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=331666=331665=331666=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon May  7 13:26:09 2018
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s


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


[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

If you want to force a particular printing policy to be used for `-ast-print`, 
I think it would be better to change the `print` call in 
`lib/Frontend/ASTConsumers.cpp` to pass your desired printing policy, rather 
than changing other components to prevent them from changing the `ASTContext`'s 
default printing policy.

(For what it's worth, I think we should also try to change the way we print 
diagnostics so that `Sema` is asked for a printing policy when it's needed 
rather than it setting global `ASTContext` state each time we consider printing 
a diagnostic. That way we could also take the `SourceLocation` information into 
account to figure out whether `bool` is suitably `#define`d at the point of the 
diagnostic rather than checking whether it's defined at the current 
end-of-preprocessing state. But that's not really relevant for this patch, 
except that generally I think we should be moving away from stashing a global 
`PrintingPolicy` on the `ASTContext`.)

>> I'd like @rsmith's opinion on whether we should be trying to make -ast-print 
>> have good source fidelity or not. I was under the impression we wanted 
>> -ast-print to faithfully reproduce code at least as a low priority desire, 
>> but it sounds like it may only be intended as an approximation of the user's 
>> source code, so adding extra machinery to support better fidelity may be 
>> more maintenance burden than it's worth.
> 
> Given the discussion in https://reviews.llvm.org/D45463, it seems I need a 
> more precise understanding of the purpose of -ast-print before I write any 
> more fixes like these.

As things stand, I'd generally consider `-ast-print` to be a "best-effort" 
feature: we don't guarantee that it produces valid code, but we would prefer 
that it does. I do not think we yet have a clear argument that it's worth 
accepting costs elsewhere in order to solely improve `-ast-print`, but 
fortunately most improvements to `-ast-print` also improve our diagnostic 
quality, the usability of our AST in tooling scenarios, or some other property 
that we do care about, so this issue seldom arises. (For example, in the 
context of https://reviews.llvm.org/D45463, information on whether a 
declaration owns a `TagDecl` is directly useful to tooling (for instance, 
refactoring tools care how a multi-declarator declaration was written so that 
they can properly rewrite it), as well as being useful for `-ast-print` 
fidelity. So it would make sense to consider how to better represent this 
information in the AST so that all the interested users have access to it.)

However... Clang is an open-source meritocracy. As such, the goals of the Clang 
project are a synthesized amalgam of the goals of the Clang contributors. If 
you want to take ownership of the AST printer and, for instance, make it always 
generate valid code, we can discuss the technical merits of that (use cases, 
benefit to you and to other users, maintenance costs, etc) even if the original 
purpose of the flag did not extend that far.


https://reviews.llvm.org/D45093



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: test/Frontend/dependency-gen.c:24
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist

Shouldn't this be `%S/../Driver/Inputs/resource_dir_with_cfi_blacklist`?


https://reviews.llvm.org/D46403



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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:9432
   if (IsLiteral) {
+// Conversion of a floating point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.

floating point -> floating-point



Comment at: lib/Sema/SemaChecking.cpp:9440-9441
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(

I think you can combine all of the predicates into:
```
if (!IsBool && ((IntegerValue.isSigned() && (...) || (IntegerValue.isUnsigned() 
&& (...
  return DiagnoseImpCast(S, E, T, CContext, 
diag::warn_impcast_literal_float_to_integer_out_of_range);
```


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice added a comment.

I'm not sure if I have commit access or not; Peter was working with me on 
trying to commit the change.


https://reviews.llvm.org/D46403



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


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Note that the alignment matters in addition to the size.

The pattern I've seen internally is people using `%zd` for NSInteger and `%tu` 
for NSUInteger, since until clang 6 neither of those were format-checked at all.

I'd be fine with adding an option to relax the printf checking if the size and 
alignment of the specifier and the actual type match, even if the types 
themselves differ (`-Wformat-relaxed` or something similar), so that you'd 
still get warnings on cases where the specifier mismatch could cause runtime 
issues. I think that would be preferable to special-casing the Apple types.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45
+  anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)),
+  callee(namedDecl(hasName("data"
+  .bind("call",

shuaiwang wrote:
> aaron.ballman wrote:
> > shuaiwang wrote:
> > > aaron.ballman wrote:
> > > > Eugene.Zelenko wrote:
> > > > > aaron.ballman wrote:
> > > > > > Should this check apply equally to `std::string::c_str()` as well 
> > > > > > as `std::string::data()`?
> > > > > readability-redundant-string-cstr do both.
> > > > Yup! But that makes me wonder if the name "redundant-data-call" is an 
> > > > issue. Perhaps the check name should focus more on the array subscript 
> > > > in the presence of an operator[]()?
> > > How about "readability-circumlocutionary-subscript"?
> > > "readability-circumlocutionary-element-access"?
> > > "circumlocutionary" -> "verbose"?
> > hah, I think circumlocutionary might be a bit too much. ;-) I think 
> > `readability-simplify-array-subscript-expr` might be reasonable, however. 
> > Right now, the simplification is just for `foo.data()[0]` but it seems 
> > plausible that there are other array subscript simplifications that could 
> > be added in the future, like `a[1 + 1]` being converted to `a[2]` or `x ? 
> > a[200] : a[400]` going to `a[x ? 200 : 400]` (etc).
> Just `readability-simplify-subscript-expr`?
> Since after simplification the subscript operation is done by calling 
> overloaded `operator[]` on an object instead of built-in subscript operator 
> on an array.
> 
> Let me know if this name looks good to you and I'll do the actual renaming 
> (together with addressing other comments) after your confirmation.
I think `readability-simplify-subscript-expr` is a reasonable name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Do you have commit access? If not I'd be happy to land this for you.




Comment at: 
test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt:19
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*

Would the test work if this were an empty file? If so, I'd suggest doing that 
for simplicity's sake.


https://reviews.llvm.org/D46403



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145524.
cmtice added a comment.

Fix test failure that my previous changes caused.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
===
--- test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
+++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
@@ -0,0 +1,19 @@
+[cfi-unrelated-cast]
+# The specification of std::get_temporary_buffer mandates a cast to
+# uninitialized T* (libstdc++, libc++, MSVC stdlib).
+fun:_ZSt20get_temporary_buffer*
+fun:_ZNSt3__120get_temporary_buffer*
+fun:*get_temporary_buffer@.*@std@@*
+
+# STL address-of magic (libstdc++, libc++).
+fun:*__addressof*
+fun:_ZNSt3__19addressof*
+
+# Windows C++ stdlib headers that contain bad unrelated casts.
+src:*xmemory0
+src:*xstddef
+
+# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
+# This ctor is used by std::make_shared and needs to cast to uninitialized T*
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
===
--- 

[PATCH] D24867: Request init/fini array on FreeBSD 12 and later

2018-05-07 Thread Brooks Davis via Phabricator via cfe-commits
brooks accepted this revision.
brooks added a comment.

I do think we should make this change, but don't have a strong opinion on the 
timing.  If we do it for 12 and not 13 then we should probably try to get it 
into a 6.0.2.


https://reviews.llvm.org/D24867



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


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.
Herald added a reviewer: javed.absar.

I was just looking at this, and I think @arphaman's patch is pretty much the 
right approach (with 2 suggested fixes below).

I don't think the code we're currently warning on is broken: a user code has 
`NSInteger` with `%zd` or `NSUInteger` with `%zu`, and on all platforms which 
support those types the implementor has guaranteed that `(sizeof(size_t) == 
sizeof(NSInteger)) && (sizeof(ssize_t) == sizeof(NSUInteger))`. I agree that, 
if we're playing C++ pedant and look at the typedefs, then it's undefined 
behavior and the code is broken. However the implementation provided more 
guarantees than C++ does through its platform typedefs so pendantry need not 
apply (or rather: clang should look no further than the typedef, and trust the 
platform in this particular case).

We of course should still warn on sign mismatch.

I don't think this should even be a warning with pedantic on: there's no 
portability issue at all because all OSes and architectures where this could 
ever fire are guaranteed to do the right thing.

Suggested fixes:

1. Don't compare `CastTyName` directly, instead recurse as 
`shouldNotPrintDirectly` does so `typedef` nesting is also handled.
2. Add a test that sign mismatched is still diagnosed.

If you all agree I'll post an updated patch.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


RE: r331536 - [NFC]Convert Class to use member initialization instead of inline.

2018-05-07 Thread Keane, Erich via cfe-commits
I don’t believe the member initialization for bitfields (of which all the ‘0’ 
values are) happened until C++17, right?  I could definitely member initialize 
the two enum fields though.

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Monday, May 7, 2018 12:03 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r331536 - [NFC]Convert Class to use member initialization instead 
of inline.

Perhaps this should use non-static data member initializers instead?

On Fri, May 4, 2018 at 9:23 AM Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Fri May  4 09:19:53 2018
New Revision: 331536

URL: http://llvm.org/viewvc/llvm-project?rev=331536=rev
Log:
[NFC]Convert Class to use member initialization instead of inline.

Modified:
cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h

Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331536=331535=331536=diff
==
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Fri May  4 
09:19:53 2018
@@ -65,15 +65,11 @@ public:
   std::string ModuleDependencyOutputDir;

 public:
-  DependencyOutputOptions() {
-IncludeSystemHeaders = 0;
-ShowHeaderIncludes = 0;
-UsePhonyTargets = 0;
-AddMissingHeaderDeps = 0;
-IncludeModuleFiles = 0;
-ShowIncludesDest = ShowIncludesDestination::None;
-OutputFormat = DependencyOutputFormat::Make;
-  }
+  DependencyOutputOptions()
+  : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowIncludesDest(ShowIncludesDestination::None),
+OutputFormat(DependencyOutputFormat::Make) {}
 };

 }  // end namespace clang


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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Fine, that works.


https://reviews.llvm.org/D45476



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


[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: include/clang/Basic/Attr.td:1494
+def NoStackProtector : InheritableAttr {
+  let Spellings = [GCC<"no_stack_protector">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> This is not a GCC attribute, so this should use the Clang spelling.
> 
> However, why spell the attribute this way rather than use the GCC spelling 
> (`optimize("no-stack-protector")`?
Thanks, I have changed it to use Clang spelling.

Regarding __attribute__((optimize("..."))), it is a generic facility in GCC 
that works for many optimizer flags.
Clang currently does not support this syntax currently instead preferring its 
own version for some options e.g. -O0. 
e.g.  
```
__attribute__((optimize("O0")))  // clang version is __attribute__((optnone)) 
```
If we want to support the GCC syntax, future expectation would be support more 
flags under this syntax. Is that the path we want to take (I do not know the 
history related to previous syntax decisions but better GCC compatibility will 
be a nice thing to have) 


Repository:
  rC Clang

https://reviews.llvm.org/D46300



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


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-05-07 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling added a comment.

Any further commentary? :)


Repository:
  rC Clang

https://reviews.llvm.org/D46024



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


[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45093#1087652, @aaron.ballman wrote:

> This approach generally looks good to me, but I'd like @rsmith's opinion on 
> whether we should be trying to make -ast-print have good source fidelity or 
> not. I was under the impression we wanted -ast-print to faithfully reproduce 
> code at least as a low priority desire, but it sounds like it may only be 
> intended as an approximation of the user's source code, so adding extra 
> machinery to support better fidelity may be more maintenance burden than it's 
> worth.


Thanks for your comment.  Give the discussion in 
https://reviews.llvm.org/D45463, it seems I need a more precise understanding 
of the purpose of -ast-print before I write any more fixes like these.


https://reviews.llvm.org/D45093



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


[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 145514.
manojgupta added a comment.

Added docs, Sema test case for the attribute.


Repository:
  rC Clang

https://reviews.llvm.org/D46300

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/stack-protector.c
  test/Sema/no_stack_protector.c

Index: test/Sema/no_stack_protector.c
===
--- /dev/null
+++ test/Sema/no_stack_protector.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __attribute__((no_stack_protector)) foo() {}
+int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}
Index: test/CodeGen/stack-protector.c
===
--- test/CodeGen/stack-protector.c
+++ test/CodeGen/stack-protector.c
@@ -22,6 +22,14 @@
   printf("%s\n", a);
 }
 
+// DEF: define {{.*}}void @test2(i8* %msg) #[[B:.*]] {
+__attribute__((no_stack_protector))
+void test2(const char *msg) {
+  char a[strlen(msg) + 1];
+  strcpy(a, msg);
+  printf("%s\n", a);
+}
+
 // NOSSP-NOT: attributes #[[A]] = {{.*}} ssp
 // SSP: attributes #[[A]] = {{.*}} ssp{{ }}
 // SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong
@@ -33,3 +41,15 @@
 // SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}
 // SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong
 // SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq
+
+// NOSSP-NOT: attributes #[[B]] = {{.*}} ssp
+// SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }}
+// SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong
+// SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq
+
+// SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }}
+// SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong
+// SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6230,6 +6230,10 @@
   case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg.
 handleSimpleAttribute(S, D, AL);
 break;
+  case AttributeList::AT_NoStackProtector:
+// Interacts with -fstack-protector options.
+handleSimpleAttribute(S, D, AL);
+break;
   case AttributeList::AT_StdCall:
   case AttributeList::AT_CDecl:
   case AttributeList::AT_FastCall:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1142,12 +1142,14 @@
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
-  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-B.addAttribute(llvm::Attribute::StackProtect);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-B.addAttribute(llvm::Attribute::StackProtectStrong);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-B.addAttribute(llvm::Attribute::StackProtectReq);
+  if (!D || !D->hasAttr()) {
+if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+  B.addAttribute(llvm::Attribute::StackProtect);
+else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+  B.addAttribute(llvm::Attribute::StackProtectStrong);
+else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
+  B.addAttribute(llvm::Attribute::StackProtectReq);
+  }
 
   if (!D) {
 // If we don't have a declaration to control inlining, the function isn't
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2740,6 +2740,27 @@
   }];
 }
 
+def NoStackProtectorDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((no_stack_protector))`` attribute to disable
+stack protector on the specified functions. This attribute is useful for
+selectively disabling stack protector on some functions when building with
+-fstack-protector compiler options.
+
+For example, it disables stack protector for the function foo but function bar
+will still be built with stack protector with -fstack-protector option.
+
+.. code-block:: c
+
+int __attribute__((no_stack_protector))
+foo (int); // stack protection will be disabled for foo.
+
+int bar(int a); // bar can be built with stack protector.
+
+}];
+}
+
 def NotTailCalledDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: include/clang/Basic/Attr.td
===

Re: r331536 - [NFC]Convert Class to use member initialization instead of inline.

2018-05-07 Thread David Blaikie via cfe-commits
Perhaps this should use non-static data member initializers instead?

On Fri, May 4, 2018 at 9:23 AM Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Fri May  4 09:19:53 2018
> New Revision: 331536
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331536=rev
> Log:
> [NFC]Convert Class to use member initialization instead of inline.
>
> Modified:
> cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
>
> Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331536=331535=331536=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Fri May  4
> 09:19:53 2018
> @@ -65,15 +65,11 @@ public:
>std::string ModuleDependencyOutputDir;
>
>  public:
> -  DependencyOutputOptions() {
> -IncludeSystemHeaders = 0;
> -ShowHeaderIncludes = 0;
> -UsePhonyTargets = 0;
> -AddMissingHeaderDeps = 0;
> -IncludeModuleFiles = 0;
> -ShowIncludesDest = ShowIncludesDestination::None;
> -OutputFormat = DependencyOutputFormat::Make;
> -  }
> +  DependencyOutputOptions()
> +  : IncludeSystemHeaders(0), ShowHeaderIncludes(0),
> UsePhonyTargets(0),
> +AddMissingHeaderDeps(0), IncludeModuleFiles(0),
> +ShowIncludesDest(ShowIncludesDestination::None),
> +OutputFormat(DependencyOutputFormat::Make) {}
>  };
>
>  }  // end namespace clang
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r331661 - Status updates for Rapperswil

2018-05-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May  7 11:59:04 2018
New Revision: 331661

URL: http://llvm.org/viewvc/llvm-project?rev=331661=rev
Log:
Status updates for Rapperswil

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=331661=331660=331661=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon May  7 11:59:04 2018
@@ -64,7 +64,7 @@
 https://wg21.link/LWG2970;>2970Return type of 
std::visit misspecifiedRapperswil
 https://wg21.link/LWG3058;>3058Parallel 
adjacent_difference shouldn't require creating 
temporariesRapperswil
 https://wg21.link/LWG3062;>3062Unnecessary 
decay_t in is_execution_policy_v should be 
remove_cvref_tRapperswil
-https://wg21.link/LWG3067;>3067recursive_directory_iterator::pop
 must invalidateRapperswil
+https://wg21.link/LWG3067;>3067recursive_directory_iterator::pop
 must invalidateRapperswilNothing to do
 https://wg21.link/LWG3071;>3071[networking.ts] 
read_until still refers to "input 
sequence"RapperswilNothing to do
 https://wg21.link/LWG3074;>3074Non-member 
functions for valarray should only deduce from the 
valarrayRapperswil
 https://wg21.link/LWG3076;>3076basic_string CTAD 
ambiguityRapperswil
@@ -74,7 +74,7 @@
 https://wg21.link/LWG3094;>3094[time.duration.io]p4 makes 
surprising claims about encodingRapperswil
 https://wg21.link/LWG3100;>3100Unnecessary and 
confusing "empty span" wordingRapperswilNothing to 
do
 https://wg21.link/LWG3102;>3102Clarify span 
iterator and const_iterator behaviorRapperswil
-https://wg21.link/LWG3104;>3104Fixing duration 
divisionRapperswil
+https://wg21.link/LWG3104;>3104Fixing duration 
divisionRapperswilComplete
 
 
 
@@ -95,7 +95,7 @@
 2970 - 
 3058 - 
 3062 - This should be very easy.
-3067 - 
+3067 - Adding restrictions; no code changes needed.
 3071 - This is just wording cleanup.
 3074 - 
 3076 - 
@@ -105,7 +105,7 @@
 3094 - 
 3100 - This is just wording cleanup.
 3102 - This should be just adding tests.
-3104 - 
+3104 - We already do this.
 
 
 Comments about the "Review" issues


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


[PATCH] D24867: Request init/fini array on FreeBSD 12 and later

2018-05-07 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Brooks, I can commit this if you prefer.  Maybe it can go into 6.0.2 still...


https://reviews.llvm.org/D24867



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


[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

2018-05-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added reviewers: craig.topper, echristo, dblaikie.
Herald added a subscriber: cfe-commits.

When requirement imposed by __target__ attributes on functions
are not satisfied, prefer printing those requirements, which
are explicitly mentioned in the attributes.

This makes such messages more useful, e.g. printing avx512f instead of avx2
in the following scenario:

  $ cat foo.c
  static inline void __attribute__((__always_inline__, __target__("avx512f")))
  x(void)
  {
  }
  
  int main(void)
  {
x();
  }
  $ clang foo.c
  foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', 
but would be inlined into function 'main' that is compiled without support for 
'avx2'
  x();
^
  1 error generated.

bugzilla: https://bugs.llvm.org/show_bug.cgi?id=37338


Repository:
  rC Clang

https://reviews.llvm.org/D46541

Files:
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/target-features-error-2.c
  test/CodeGen/target-features-error.c

Index: test/CodeGen/target-features-error.c
===
--- test/CodeGen/target-features-error.c
+++ test/CodeGen/target-features-error.c
@@ -3,6 +3,5 @@
   return a + 4;
 }
 int bar() {
-  return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'sse4.2', but would be inlined into function 'bar' that is compiled without support for 'sse4.2'}}
+  return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'avx', but would be inlined into function 'bar' that is compiled without support for 'avx'}}
 }
-
Index: test/CodeGen/target-features-error-2.c
===
--- test/CodeGen/target-features-error-2.c
+++ test/CodeGen/target-features-error-2.c
@@ -3,13 +3,14 @@
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX512f
 
 #define __MM_MALLOC_H
 #include 
 
 #if NEED_SSE42
 int baz(__m256i a) {
-  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be inlined into function 'baz' that is compiled without support for 'sse4.2'}}
+  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'avx', but would be inlined into function 'baz' that is compiled without support for 'avx'}}
 }
 #endif
 
@@ -36,3 +37,9 @@
   return _mm_cmp_sd(a, b, 0); // expected-error {{'__builtin_ia32_cmpsd' needs target feature avx}}
 }
 #endif
+
+#if NEED_AVX512f
+unsigned short need_avx512f(unsigned short a, unsigned short b) {
+  return __builtin_ia32_korhi(a, b); // expected-error {{'__builtin_ia32_korhi' needs target feature avx512f}}
+}
+#endif
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1082,6 +1082,8 @@
   /// It's up to you to ensure that this is safe.
   void AddDefaultFnAttrs(llvm::Function );
 
+  TargetAttr::ParsedTargetAttr getFunctionTargetAttrs(const FunctionDecl *FD);
+
   // Fills in the supplied string map with the set of target features for the
   // passed in function.
   void getFunctionFeatureMap(llvm::StringMap ,
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4995,11 +4995,8 @@
   }
 }
 
-// Fills in the supplied string map with the set of target features for the
-// passed in function.
-void CodeGenModule::getFunctionFeatureMap(llvm::StringMap ,
-  const FunctionDecl *FD) {
-  StringRef TargetCPU = Target.getTargetOpts().CPU;
+TargetAttr::ParsedTargetAttr CodeGenModule::getFunctionTargetAttrs(const FunctionDecl *FD)
+{
   if (const auto *TD = FD->getAttr()) {
 // If we have a TargetAttr build up the feature map based on that.
 TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
@@ -5011,7 +5008,20 @@
   StringRef{Feat}.substr(1));
 }),
 ParsedAttr.Features.end());
+return ParsedAttr;
+  } else {
+return TargetAttr::ParsedTargetAttr();
+  }
+}
+
 
+// Fills in the supplied string map with the set of target features for the
+// passed in function.
+void CodeGenModule::getFunctionFeatureMap(llvm::StringMap ,
+  const FunctionDecl *FD) {
+  StringRef TargetCPU = Target.getTargetOpts().CPU;
+  TargetAttr::ParsedTargetAttr ParsedAttr = getFunctionTargetAttrs(FD);

Re: r331556 - [analyzer] Treat more const variables and fields as known contants.

2018-05-07 Thread Alexander Kornienko via cfe-commits
It looks like this commit has introduced an assertion failure. See
https://bugs.llvm.org/show_bug.cgi?id=37357.

On Fri, May 4, 2018 at 10:56 PM Artem Dergachev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dergachev
> Date: Fri May  4 13:52:39 2018
> New Revision: 331556
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331556=rev
> Log:
> [analyzer] Treat more const variables and fields as known contants.
>
> When loading from a variable or a field that is declared as constant,
> the analyzer will try to inspect its initializer and constant-fold it.
> Upon success, the analyzer would skip normal load and return the respective
> constant.
>
> The new behavior also applies to fields/elements of brace-initialized
> structures
> and arrays.
>
> Patch by Rafael Stahl!
>
> Differential Revision: https://reviews.llvm.org/D45774
>
> Added:
> cfe/trunk/test/Analysis/globals.cpp
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=331556=331555=331556=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri May  4 13:52:39
> 2018
> @@ -1606,7 +1606,7 @@ SVal RegionStoreManager::getBindingForEl
>const MemRegion* superR = R->getSuperRegion();
>
>// Check if the region is an element region of a string literal.
> -  if (const StringRegion *StrR=dyn_cast(superR)) {
> +  if (const StringRegion *StrR = dyn_cast(superR)) {
>  // FIXME: Handle loads from strings where the literal is treated as
>  // an integer, e.g., *((unsigned int*)"hello")
>  QualType T =
> Ctx.getAsArrayType(StrR->getValueType())->getElementType();
> @@ -1629,6 +1629,27 @@ SVal RegionStoreManager::getBindingForEl
>char c = (i >= length) ? '\0' : Str->getCodeUnit(i);
>return svalBuilder.makeIntVal(c, T);
>  }
> +  } else if (const VarRegion *VR = dyn_cast(superR)) {
> +// Check if the containing array is const and has an initialized
> value.
> +const VarDecl *VD = VR->getDecl();
> +// Either the array or the array element has to be const.
> +if (VD->getType().isConstQualified() ||
> R->getElementType().isConstQualified()) {
> +  if (const Expr *Init = VD->getInit()) {
> +if (const auto *InitList = dyn_cast(Init)) {
> +  // The array index has to be known.
> +  if (auto CI = R->getIndex().getAs()) {
> +int64_t i = CI->getValue().getSExtValue();
> +// Return unknown value if index is out of bounds.
> +if (i < 0 || i >= InitList->getNumInits())
> +  return UnknownVal();
> +
> +if (const Expr *ElemInit = InitList->getInit(i))
> +  if (Optional V = svalBuilder.getConstantVal(ElemInit))
> +return *V;
> +  }
> +}
> +  }
> +}
>}
>
>// Check for loads from a code text region.  For such loads, just give
> up.
> @@ -1678,7 +1699,28 @@ SVal RegionStoreManager::getBindingForFi
>if (const Optional  = B.getDirectBinding(R))
>  return *V;
>
> -  QualType Ty = R->getValueType();
> +  // Is the field declared constant and has an in-class initializer?
> +  const FieldDecl *FD = R->getDecl();
> +  QualType Ty = FD->getType();
> +  if (Ty.isConstQualified())
> +if (const Expr *Init = FD->getInClassInitializer())
> +  if (Optional V = svalBuilder.getConstantVal(Init))
> +return *V;
> +
> +  // If the containing record was initialized, try to get its constant
> value.
> +  const MemRegion* superR = R->getSuperRegion();
> +  if (const auto *VR = dyn_cast(superR)) {
> +const VarDecl *VD = VR->getDecl();
> +QualType RecordVarTy = VD->getType();
> +// Either the record variable or the field has to be const qualified.
> +if (RecordVarTy.isConstQualified() || Ty.isConstQualified())
> +  if (const Expr *Init = VD->getInit())
> +if (const auto *InitList = dyn_cast(Init))
> +  if (const Expr *FieldInit =
> InitList->getInit(FD->getFieldIndex()))
> +if (Optional V = svalBuilder.getConstantVal(FieldInit))
> +  return *V;
> +  }
> +
>return getBindingForFieldOrElementCommon(B, R, Ty);
>  }
>
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=331556=331555=331556=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Fri May  4 13:52:39
> 2018
> @@ -119,7 +119,7 @@ SValBuilder::getRegionValueSymbolVal(con
>
>if 

[PATCH] D46540: [X86] ptwrite intrinsic

2018-05-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added a reviewer: craig.topper.
Herald added subscribers: cfe-commits, mgorny.

Repository:
  rC Clang

https://reviews.llvm.org/D46540

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/module.modulemap
  lib/Headers/ptwriteintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/ptwrite.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1400,6 +1400,7 @@
 // CHECK_GLMP_M32: #define __PCLMUL__ 1
 // CHECK_GLMP_M32: #define __POPCNT__ 1
 // CHECK_GLMP_M32: #define __PRFCHW__ 1
+// CHECK_GLMP_M32: #define __PTWRITE__ 1
 // CHECK_GLMP_M32: #define __RDPID__ 1
 // CHECK_GLMP_M32: #define __RDRND__ 1
 // CHECK_GLMP_M32: #define __RDSEED__ 1
@@ -1435,6 +1436,7 @@
 // CHECK_GLMP_M64: #define __PCLMUL__ 1
 // CHECK_GLMP_M64: #define __POPCNT__ 1
 // CHECK_GLMP_M64: #define __PRFCHW__ 1
+// CHECK_GLMP_M64: #define __PTWRITE__ 1
 // CHECK_GLMP_M64: #define __RDPID__ 1
 // CHECK_GLMP_M64: #define __RDRND__ 1
 // CHECK_GLMP_M64: #define __RDSEED__ 1
@@ -1472,6 +1474,7 @@
 // CHECK_TRM_M32: #define __PCLMUL__ 1
 // CHECK_TRM_M32: #define __POPCNT__ 1
 // CHECK_TRM_M32: #define __PRFCHW__ 1
+// CHECK_TRM_M32: #define __PTWRITE__ 1
 // CHECK_TRM_M32: #define __RDPID__ 1
 // CHECK_TRM_M32: #define __RDRND__ 1
 // CHECK_TRM_M32: #define __RDSEED__ 1
@@ -1512,6 +1515,7 @@
 // CHECK_TRM_M64: #define __PCLMUL__ 1
 // CHECK_TRM_M64: #define __POPCNT__ 1
 // CHECK_TRM_M64: #define __PRFCHW__ 1
+// CHECK_TRM_M64: #define __PTWRITE__ 1
 // CHECK_TRM_M64: #define __RDPID__ 1
 // CHECK_TRM_M64: #define __RDRND__ 1
 // CHECK_TRM_M64: #define __RDSEED__ 1
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -159,3 +159,8 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s
 // MOVDIR64B: "-target-feature" "+movdir64b"
 // NO-MOVDIR64B: "-target-feature" "-movdir64b"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mptwrite %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PTWRITE %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-ptwrite %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-PTWRITE %s
+// PTWRITE: "-target-feature" "+ptwrite"
+// NO-PTWRITE: "-target-feature" "-ptwrite"
Index: test/CodeGen/ptwrite.c
===
--- /dev/null
+++ test/CodeGen/ptwrite.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +ptwrite -emit-llvm -o - -Wall -Werror -pedantic | FileCheck %s --check-prefix=X86 --check-prefix=X86_64
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +ptwrite -emit-llvm -o - -Wall -Werror -pedantic | FileCheck %s --check-prefix=X86
+
+#include 
+
+#include 
+
+void test_ptwrite32(uint32_t value) {
+  //X86-LABEL: @test_ptwrite32
+  //X86: call void @llvm.x86.ptwrite32(i32 %{{.*}})
+  _ptwrite32(value);
+}
+
+#ifdef __x86_64__
+
+void test_ptwrite64(uint64_t value) {
+  //X86_64-LABEL: @test_ptwrite64
+  //X86_64: call void @llvm.x86.ptwrite64(i64 %{{.*}})
+  _ptwrite64(value);
+}
+
+#endif /* __x86_64__ */
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -105,4 +105,8 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PTWRITE__)
+#include 
+#endif
+
 #endif /* __X86INTRIN_H */
Index: lib/Headers/ptwriteintrin.h
===
--- /dev/null
+++ lib/Headers/ptwriteintrin.h
@@ -0,0 +1,51 @@
+/*=== ptwriteintrin.h - PTWRITE intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE 

[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/AST/ExprConstant.cpp:8829
+  return EvaluateComparisonBinaryOperator(Info, E, OnSuccess, [&]() {
+return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+  });

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > It'd be clearer to call `VisitBinCmp` rather than `VisitBinaryOperator`.
> > @rsmith: OK, so I'm confused about this. Originally I had an 
> > `llvm_unreachable` that the continuation was never reached, but you 
> > suggested it was. I'm not sure how. Could you provide an example?
> > 
> > The precondition of calling `VisitBinCmp` is that we have a call to a 
> > builtin operator. For `<=>`,  where the composite type is either an 
> > arithmetic type, pointer type, or member pointer type (which includes enum 
> > types after conversions),  *All* of these cases should be handled before 
> > reaching the function.
> > 
> > Is there a control flow path I'm missing? 
> What about comparisons of `_Complex` types, vector types, and any other 
> builtin type that gets added after you commit this patch? The right thing to 
> do (at least for now) in all of those cases is to call the base class 
> implementation, which will deal with emitting the "sorry, I don't know how to 
> constant-evaluate this" diagnostic.
> 
> My comment here was simply that when doing so, you should call the base-class 
> version of the *same* function, which you now do, so that concern is 
> addressed.
Ah, I didn't think about how errors were handled. Thank you.




Comment at: lib/CodeGen/CGExprAgg.cpp:964
+RHS = CGF.EmitAnyExpr(E->getRHS()).getAggregatePointer();
+break;
+  case TEK_Complex:

rjmccall wrote:
> EricWF wrote:
> > EricWF wrote:
> > > rjmccall wrote:
> > > > It looks like we don't actually support any aggregate types here, which 
> > > > I think is fine because comparing those types is only sensible for 
> > > > things like calls.  If you do want to pave the way for that, or 
> > > > (probably more usefully) for supporting complex types, you should make 
> > > > EmitCompare take the operands as RValues and just use EmitAnyExpr here 
> > > > without paying any attention to the evaluation kind.
> > > Initially I thought the same thing, but apparently member pointers are 
> > > Aggregates under the Microsoft ABI.
> > > 
> > > I'll give  trafficking in `RValue`s, but all the functions `EmitCompare` 
> > > calls use `Value*`, so it'll take some work.
> > *I'll give trafficking in `RValue`s a shot, but ...*
> Okay, this would be a *lot* cleaner with RValue.  You can break it down in 
> your EmitCmp helper function instead of EmitCompare if you want, but you've 
> basically just inlined EmitAnyExpr here.
OK, I think I've cleaned it up. Let me know what you think.



Comment at: lib/CodeGen/CGExprAgg.cpp:924
+  }();
+  ArgTy->isAnyComplexType();
+  if (ArgTy->hasFloatingRepresentation())

rjmccall wrote:
> Dead code?
Woops. Removed.


https://reviews.llvm.org/D45476



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


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-07 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments.



Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45
+  anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)),
+  callee(namedDecl(hasName("data"
+  .bind("call",

aaron.ballman wrote:
> shuaiwang wrote:
> > aaron.ballman wrote:
> > > Eugene.Zelenko wrote:
> > > > aaron.ballman wrote:
> > > > > Should this check apply equally to `std::string::c_str()` as well as 
> > > > > `std::string::data()`?
> > > > readability-redundant-string-cstr do both.
> > > Yup! But that makes me wonder if the name "redundant-data-call" is an 
> > > issue. Perhaps the check name should focus more on the array subscript in 
> > > the presence of an operator[]()?
> > How about "readability-circumlocutionary-subscript"?
> > "readability-circumlocutionary-element-access"?
> > "circumlocutionary" -> "verbose"?
> hah, I think circumlocutionary might be a bit too much. ;-) I think 
> `readability-simplify-array-subscript-expr` might be reasonable, however. 
> Right now, the simplification is just for `foo.data()[0]` but it seems 
> plausible that there are other array subscript simplifications that could be 
> added in the future, like `a[1 + 1]` being converted to `a[2]` or `x ? a[200] 
> : a[400]` going to `a[x ? 200 : 400]` (etc).
Just `readability-simplify-subscript-expr`?
Since after simplification the subscript operation is done by calling 
overloaded `operator[]` on an object instead of built-in subscript operator on 
an array.

Let me know if this name looks good to you and I'll do the actual renaming 
(together with addressing other comments) after your confirmation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprAgg.cpp:964
+RHS = CGF.EmitAnyExpr(E->getRHS()).getAggregatePointer();
+break;
+  case TEK_Complex:

EricWF wrote:
> EricWF wrote:
> > rjmccall wrote:
> > > It looks like we don't actually support any aggregate types here, which I 
> > > think is fine because comparing those types is only sensible for things 
> > > like calls.  If you do want to pave the way for that, or (probably more 
> > > usefully) for supporting complex types, you should make EmitCompare take 
> > > the operands as RValues and just use EmitAnyExpr here without paying any 
> > > attention to the evaluation kind.
> > Initially I thought the same thing, but apparently member pointers are 
> > Aggregates under the Microsoft ABI.
> > 
> > I'll give  trafficking in `RValue`s, but all the functions `EmitCompare` 
> > calls use `Value*`, so it'll take some work.
> *I'll give trafficking in `RValue`s a shot, but ...*
Okay, this would be a *lot* cleaner with RValue.  You can break it down in your 
EmitCmp helper function instead of EmitCompare if you want, but you've 
basically just inlined EmitAnyExpr here.



Comment at: lib/CodeGen/CGExprAgg.cpp:924
+  }();
+  ArgTy->isAnyComplexType();
+  if (ArgTy->hasFloatingRepresentation())

Dead code?


https://reviews.llvm.org/D45476



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


r331654 - [OPENMP, NVPTX] Small test fix, NFC.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 10:38:13 2018
New Revision: 331654

URL: http://llvm.org/viewvc/llvm-project?rev=331654=rev
Log:
[OPENMP, NVPTX] Small test fix, NFC.

Modified:
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp?rev=331654=331653=331654=diff
==
--- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Mon May  7 10:38:13 2018
@@ -317,8 +317,8 @@ int bar(int n){
 
 // CHECK-LABEL: define internal void @{{.+}}(i32* noalias %{{.+}}, i32* 
noalias %{{.+}}, i32* dereferenceable{{.*}})
 // CHECK:  [[CC:%.+]] = alloca i32,
-// CHECK:  [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x(),
-// CHECK:  [[NUM_THREADS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x(),
+// CHECK:  [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK:  [[NUM_THREADS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK:  store i32 0, i32* [[CC]],
 // CHECK:  br label
 


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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/Representation.cpp:53
+  move(Namespace, std::move(Other.Namespace));
+  extend(Description, std::move(Other.Description));
+  return true;

sammccall wrote:
> is plain concatenation of comments what you want?
Yes, in this case, as they aren't comment strings but vectors of comment infos. 


https://reviews.llvm.org/D43341



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


[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+  if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+  for (auto I : IL->inits())

sepavloff wrote:
> rjmccall wrote:
> > Do you actually care if it's an array initialization instead of a 
> > struct/enum initialization?
> If this code is enabled for for records too, some tests start to fail. For 
> instance, the code:
> ```
> union { int i; double f; } u2 = { };
> ```
> produces output:
> ```
> %union.anon = type { double }
> @u2 = global %union.anon zeroinitializer, align 4
> ```
> while previously it produced:
> ```
> @u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef }, align 4
> ```
> The latter looks more correct.
Hmm.  In C++, a static object which isn't constant-initialized is 
zero-initialized, which is required to set any padding bits to zero (N4640 
[dcl.init]p6) in both structs and unions.  In C, a static object which doesn't 
have an initializer also has all any padding bits set to zero (N1548 6.7.9p10). 
 Now, this object has an initializer (that acts as a constant-initializer in 
C++), so those rules don't directly apply; but I would argue that the intent of 
the standards is not that padding bits become undefined when you happen to have 
an initializer.  So I actually think the `zeroinitializer` emission is more 
correct.


Repository:
  rC Clang

https://reviews.llvm.org/D46241



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


[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D46471



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


r331652 - [OPENMP, NVPTX] Codegen for critical construct.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 10:23:05 2018
New Revision: 331652

URL: http://llvm.org/viewvc/llvm-project?rev=331652=rev
Log:
[OPENMP, NVPTX] Codegen for critical construct.

Added correct codegen for the critical construct on NVPTX devices.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=331652=331651=331652=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon May  7 10:23:05 2018
@@ -1837,6 +1837,66 @@ void CGOpenMPRuntimeNVPTX::emitSpmdParal
   emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 }
 
+void CGOpenMPRuntimeNVPTX::emitCriticalRegion(
+CodeGenFunction , StringRef CriticalName,
+const RegionCodeGenTy , SourceLocation Loc,
+const Expr *Hint) {
+  llvm::BasicBlock *LoopBB = CGF.createBasicBlock("omp.critical.loop");
+  llvm::BasicBlock *TestBB = CGF.createBasicBlock("omp.critical.test");
+  llvm::BasicBlock *SyncBB = CGF.createBasicBlock("omp.critical.sync");
+  llvm::BasicBlock *BodyBB = CGF.createBasicBlock("omp.critical.body");
+  llvm::BasicBlock *ExitBB = CGF.createBasicBlock("omp.critical.exit");
+
+  // Fetch team-local id of the thread.
+  llvm::Value *ThreadID = getNVPTXThreadID(CGF);
+
+  // Get the width of the team.
+  llvm::Value *TeamWidth = getNVPTXNumThreads(CGF);
+
+  // Initialize the counter variable for the loop.
+  QualType Int32Ty =
+  CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/0);
+  Address Counter = CGF.CreateMemTemp(Int32Ty, "critical_counter");
+  LValue CounterLVal = CGF.MakeAddrLValue(Counter, Int32Ty);
+  CGF.EmitStoreOfScalar(llvm::Constant::getNullValue(CGM.Int32Ty), CounterLVal,
+/*isInit=*/true);
+
+  // Block checks if loop counter exceeds upper bound.
+  CGF.EmitBlock(LoopBB);
+  llvm::Value *CounterVal = CGF.EmitLoadOfScalar(CounterLVal, Loc);
+  llvm::Value *CmpLoopBound = CGF.Builder.CreateICmpSLT(CounterVal, TeamWidth);
+  CGF.Builder.CreateCondBr(CmpLoopBound, TestBB, ExitBB);
+
+  // Block tests which single thread should execute region, and which threads
+  // should go straight to synchronisation point.
+  CGF.EmitBlock(TestBB);
+  CounterVal = CGF.EmitLoadOfScalar(CounterLVal, Loc);
+  llvm::Value *CmpThreadToCounter =
+  CGF.Builder.CreateICmpEQ(ThreadID, CounterVal);
+  CGF.Builder.CreateCondBr(CmpThreadToCounter, BodyBB, SyncBB);
+
+  // Block emits the body of the critical region.
+  CGF.EmitBlock(BodyBB);
+
+  // Output the critical statement.
+  CriticalOpGen(CGF);
+
+  // After the body surrounded by the critical region, the single executing
+  // thread will jump to the synchronisation point.
+  // Block waits for all threads in current team to finish then increments the
+  // counter variable and returns to the loop.
+  CGF.EmitBlock(SyncBB);
+  getNVPTXCTABarrier(CGF);
+
+  llvm::Value *IncCounterVal =
+  CGF.Builder.CreateNSWAdd(CounterVal, CGF.Builder.getInt32(1));
+  CGF.EmitStoreOfScalar(IncCounterVal, CounterLVal);
+  CGF.EmitBranch(LoopBB);
+
+  // Block that is reached when  all threads in the team complete the region.
+  CGF.EmitBlock(ExitBB, /*IsFinished=*/true);
+}
+
 /// Cast value to the specified type.
 static llvm::Value *castValueToType(CodeGenFunction , llvm::Value *Val,
 QualType ValTy, QualType CastTy,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=331652=331651=331652=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Mon May  7 10:23:05 2018
@@ -250,6 +250,16 @@ public:
 ArrayRef CapturedVars,
 const Expr *IfCond) override;
 
+  /// Emits a critical region.
+  /// \param CriticalName Name of the critical region.
+  /// \param CriticalOpGen Generator for the statement associated with the 
given
+  /// critical region.
+  /// \param Hint Value of the 'hint' clause (optional).
+  void emitCriticalRegion(CodeGenFunction , StringRef CriticalName,
+  const RegionCodeGenTy ,
+  SourceLocation Loc,
+  const Expr *Hint = nullptr) override;
+
   /// Emit a code for reduction clause.
   ///
   /// \param Privates List of private copies for original reduction arguments.

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 

[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Sorry, two more nits.




Comment at: include/clang/AST/ASTImporter.h:137
+///
+/// \returns the equivalent attribute in the "to" context, or NULL if an
+/// error occurred.

nullptr



Comment at: lib/AST/ASTImporter.cpp:4724
   SmallVector ToAttrs(FromAttrs.size());
-  ASTContext &_ToContext = Importer.getToContext();
   std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
+[this](const Attr *A) -> const Attr * {

Could we use ImportArrayChecked instead?


https://reviews.llvm.org/D46115



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


[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Rafael! Please find my comments inline.




Comment at: lib/AST/ASTImporter.cpp:2650
+  for (const auto *A : D->attrs())
+ToIndirectField->addAttr(Importer.Import(const_cast(A)));
 

Could we just remove 'const' qualifier from `A` to avoid `const_cast`? (Same 
below)



Comment at: lib/AST/ASTImporter.cpp:6547
+Attr *ASTImporter::Import(Attr *FromAttr) {
+  if (!FromAttr)
+return nullptr;

Is it possible to get into a situation where a nullptr attribute is imported?



Comment at: lib/AST/ASTImporter.cpp:7211
 for (auto *FromAttr : From->getAttrs())
-  To->addAttr(FromAttr->clone(To->getASTContext()));
+  To->addAttr(Import(FromAttr));
   }

As I can see, `Import(Attr *)` can return nullptr. And I'm not sure that 
`addAttr(nullptr)` has well-defined behaviour.



Comment at: test/Import/attr/Inputs/S.cpp:4
+struct S
+{
+struct {

Could you please clang-format the file?


https://reviews.llvm.org/D46115



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


[PATCH] D42664: Fix explicit template parameter reporting for narrowing conversions

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

Did Review-after-commit, in retrospect this is a pretty tiny change.


https://reviews.llvm.org/D42664



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


r331651 - Fix explicit template parameter reporting for narrowing conversions

2018-05-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon May  7 10:05:20 2018
New Revision: 331651

URL: http://llvm.org/viewvc/llvm-project?rev=331651=rev
Log:
Fix explicit template parameter reporting for narrowing conversions

I found that explicit template parameters that caused a
narrowing integer conversion resulted in the incorrect parameter
being mentioned in the note (see test attached). This is because
the argument checking code doesn't check to see if it caused
SFINAE errors when checking the arguments, so instead of giving
up on the first error, it continues through the list. This
makes the error reporting pick up the last template param every time.

This patch checks these parameters on each argument and gives up
if there is an error. The result is that only the required amount
of arguments are checked, and that the 'Converted' array contains
only the successful arguments before the first failure, as the
calls seem to all expect.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=331651=331650=331651=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon May  7 10:05:20 2018
@@ -4668,11 +4668,15 @@ bool Sema::CheckTemplateArgument(NamedDe
 
 case TemplateArgument::Expression: {
   TemplateArgument Result;
+  unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
 CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
   Result, CTAK);
   if (Res.isInvalid())
 return true;
+  // If the current template argument causes an error, give up now.
+  if (CurSFINAEErrors < NumSFINAEErrors)
+return true;
 
   // If the resulting expression is new, then use it in place of the
   // old expression in the template argument.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp?rev=331651=331650=331651=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Mon May  7 10:05:20 
2018
@@ -36,3 +36,15 @@ namespace check_conversion_early {
   struct Y { constexpr operator int() const { return 0; } };
   template struct A {}; // expected-error {{cannot be deduced}} 
expected-note {{'y'}}
 }
+
+namespace ReportCorrectParam {
+template 
+void TempFunc() {}
+
+void Useage() {
+  //expected-error@+2 {{no matching function}}
+  //expected-note@-4 {{candidate template ignored: invalid 
explicitly-specified argument for template parameter 'b'}}
+  TempFunc<1, -1, 1>();
+}
+}
+


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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, spatel, RKSimon.

As identified and briefly discussed here:
https://bugs.llvm.org/show_bug.cgi?id=37305

Converting a floating point number to an integer type when
the integral part is out of the range of the integer type is
undefined behavior in C.  Additionally, CodeGen emits an undef
in this situation.

HOWEVER, we've been giving a warning that says that the value is
changed.  This patch corrects the warning to list that it is actually
undefined behavior.


Repository:
  rC Clang

https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,20 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool) {
+  if (IntegerValue.isSigned() &&
+  (IntegerValue.isMaxSignedValue() || IntegerValue.isMinSignedValue()))
+return DiagnoseImpCast(
+S, E, T, CContext,
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(
+S, E, T, CContext,
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+}
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9458,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- 

[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl updated this revision to Diff 145486.
r.stahl edited the summary of this revision.
r.stahl added a comment.

full patch with test


https://reviews.llvm.org/D46115

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  test/Import/attr/Inputs/S.cpp
  test/Import/attr/test.cpp

Index: test/Import/attr/Inputs/S.cpp
===
--- test/Import/attr/Inputs/S.cpp
+++ test/Import/attr/Inputs/S.cpp
@@ -0,0 +1,14 @@
+extern void f() __attribute__((const));
+
+struct S
+{
+struct {
+int a __attribute__((packed));
+};
+};
+
+void stmt()
+{
+#pragma unroll
+for (;;);
+}
Index: test/Import/attr/test.cpp
===
--- test/Import/attr/test.cpp
+++ test/Import/attr/test.cpp
@@ -0,0 +1,26 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: FunctionDecl
+// CHECK-SAME: S.cpp:1:1, col:13
+// CHECK-NEXT: ConstAttr
+// CHECK-SAME: col:32
+
+// CHECK: IndirectFieldDecl
+// CHECK-NEXT: Field
+// CHECK-NEXT: Field
+// CHECK-NEXT: PackedAttr
+// CHECK-SAME: col:30
+
+// CHECK: AttributedStmt
+// CHECK-NEXT: LoopHintAttr
+// CHECK-SAME: line:12:13
+
+extern void f() __attribute__((const));
+
+struct S;
+
+void stmt();
+
+void expr() {
+  f();
+  struct S s;
+}
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2646,8 +2646,8 @@
   Importer.getToContext(), DC, Loc, Name.getAsIdentifierInfo(), T,
   {NamedChain, D->getChainingSize()});
 
-  for (const auto *Attr : D->attrs())
-ToIndirectField->addAttr(Attr->clone(Importer.getToContext()));
+  for (const auto *A : D->attrs())
+ToIndirectField->addAttr(Importer.Import(const_cast(A)));
 
   ToIndirectField->setAccess(D->getAccess());
   ToIndirectField->setLexicalDeclContext(LexicalDC);
@@ -4721,10 +4721,9 @@
   SourceLocation ToAttrLoc = Importer.Import(S->getAttrLoc());
   ArrayRef FromAttrs(S->getAttrs());
   SmallVector ToAttrs(FromAttrs.size());
-  ASTContext &_ToContext = Importer.getToContext();
   std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
-[&_ToContext](const Attr *A) -> const Attr * {
-  return A->clone(_ToContext);
+[this](const Attr *A) -> const Attr * {
+  return Importer.Import(const_cast(A));
 });
   for (const auto *ToA : ToAttrs) {
 if (!ToA)
@@ -6544,6 +6543,15 @@
Import(FromTSI->getTypeLoc().getLocStart()));
 }
 
+Attr *ASTImporter::Import(Attr *FromAttr) {
+  if (!FromAttr)
+return nullptr;
+
+  Attr *ToAttr = FromAttr->clone(ToContext);
+  ToAttr->setRange(Import(FromAttr->getRange()));
+  return ToAttr;
+}
+
 Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
   llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
   if (Pos != ImportedDecls.end()) {
@@ -7200,7 +7208,7 @@
 Decl *ASTImporter::Imported(Decl *From, Decl *To) {
   if (From->hasAttrs()) {
 for (auto *FromAttr : From->getAttrs())
-  To->addAttr(FromAttr->clone(To->getASTContext()));
+  To->addAttr(Import(FromAttr));
   }
   if (From->isUsed()) {
 To->setIsUsed();
Index: include/clang/AST/ASTImporter.h
===
--- include/clang/AST/ASTImporter.h
+++ include/clang/AST/ASTImporter.h
@@ -41,6 +41,7 @@
 class Stmt;
 class TagDecl;
 class TypeSourceInfo;
+class Attr;
 
   /// \brief Imports selected nodes from one AST context into another context,
   /// merging AST nodes where appropriate.
@@ -130,6 +131,13 @@
 /// context, or NULL if an error occurred.
 TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
 
+/// \brief Import the given attribute from the "from" context into the
+/// "to" context.
+///
+/// \returns the equivalent attribute in the "to" context, or NULL if an
+/// error occurred.
+Attr *Import(Attr *FromAttr);
+
 /// \brief Import the given declaration from the "from" context into the 
 /// "to" context.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331644 - [docs] Fix typos in the Clang User's Manual.

2018-05-07 Thread Joel Galenson via cfe-commits
Author: jgalenson
Date: Mon May  7 09:23:46 2018
New Revision: 331644

URL: http://llvm.org/viewvc/llvm-project?rev=331644=rev
Log:
[docs] Fix typos in the Clang User's Manual.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=331644=331643=331644=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon May  7 09:23:46 2018
@@ -1735,11 +1735,11 @@ profile creation and use.
 .. option:: -fprofile-generate[=]
 
   The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
-  an alterantive instrumentation method for profile generation. When
+  an alternative instrumentation method for profile generation. When
   given a directory name, it generates the profile file
   ``default_%m.profraw`` in the directory named ``dirname`` if specified.
   If ``dirname`` does not exist, it will be created at runtime. ``%m`` 
specifier
-  will be substibuted with a unique id documented in step 2 above. In other 
words,
+  will be substituted with a unique id documented in step 2 above. In other 
words,
   with ``-fprofile-generate[=]`` option, the "raw" profile data 
automatic
   merging is turned on by default, so there will no longer any risk of profile
   clobbering from different running processes.  For example,


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


[PATCH] D46472: [HIP] Support offloading by linkscript

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 145480.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Rename variables used for CUDA only.


https://reviews.llvm.org/D46472

Files:
  include/clang/Driver/Options.td
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Gnu.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,22 +1,22 @@
 // RUN: echo "GPU binary would be here" > %t
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA,CUDANORDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,CUDANOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA,CUDARDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
 // RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,HIP
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS -x hip \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - -x hip \
 // RUN:   | FileCheck %s --check-prefixes=ALL,RDC,HIP
@@ -64,15 +64,17 @@
 // * constant unnamed string with the kernel name
 // ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// NORDC-SAME: section ".nv_fatbin", align 8
-// RDC-SAME: section "__nv_relfatbin", align 8
+// HIP: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
+// CUDA: @[[FATBIN:.*]] = private unnamed_addr constant{{.*GPU binary would be here.*}}\00",
+// CUDANORDC-SAME: section ".nv_fatbin", align 8
+// CUDARDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
-// CUDA: @__[[PREFIX:cuda]]_fatbin_wrapper = internal constant
-// CUDA-SAME: { i32, i32, i8*, i8* }
-// HIP: @__[[PREFIX:hip]]_fatbin_wrapper = internal constant
-// HIP-SAME:  { i32, i32, i8*, i8* }
-// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// ALL: @__[[PREFIX:cuda|hip]]_fatbin_wrapper = internal constant
+// ALL-SAME: { i32, i32, i8*, i8* }
+// ALL-SAME: { i32 1180844977, i32 1,
+// CUDA-SAME: i8* getelementptr inbounds ({{.*}}@[[FATBIN]], i64 0, i64 0),
+// HIP-SAME:  i8* @[[FATBIN]],
+// ALL-SAME: i8* null }
 // ALL-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
 // NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
@@ -136,9 +138,10 @@
 // There should be no __[[PREFIX]]_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
 // Skip GPU binary string first.
-// NOGLOBALS: @0 = private unnamed_addr constant{{.*}}
+// CUDANOGLOBALS: @{{.*}} = private unnamed_addr constant{{.*}}
+// HIPNOGLOBALS: @{{.*}} = external constant{{.*}}
 // NOGLOBALS-NOT: define internal void @__{{.*}}_register_globals
-// NOGLOBALS: define internal void @__[[PREFIX:.*]]_module_ctor
+// NOGLOBALS: define internal void @__[[PREFIX:cuda|hip]]_module_ctor
 // NOGLOBALS: call{{.*}}[[PREFIX]]RegisterFatBinary{{.*}}__[[PREFIX]]_fatbin_wrapper
 // NOGLOBALS-NOT: call void @__[[PREFIX]]_register_globals
 // NOGLOBALS: define internal void @__[[PREFIX]]_module_dtor
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -535,6 +535,10 @@
   // Add OpenMP offloading linker script args if required.
   AddOpenMPLinkerScript(getToolChain(), C, Output, Inputs, Args, CmdArgs, JA);
 
+  // Add HIP offloading linker script args if required.
+  AddHIPLinkerScript(getToolChain(), C, Output, Inputs, Args, CmdArgs, JA,
+ *this);
+
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
Index: lib/Driver/ToolChains/CommonArgs.h
===
--- lib/Driver/ToolChains/CommonArgs.h
+++ lib/Driver/ToolChains/CommonArgs.h
@@ -52,6 +52,12 @@

[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:909
+
+auto QualScore = Quality.evaluate(), RelScore = Relevance.evaluate();
+CompletionItemScores Scores;

ilya-biryukov wrote:
> NIT: Maybe use `float` here instead of auto? Would remove the need to look at 
> `evaluate` for anyone reading the code for the first time.
Done. I was worried we might switch to double one day, seems unlikely.



Comment at: clangd/Quality.h:66
+  float NameMatch = 1;
+  bool Unavailable = false;
+

ilya-biryukov wrote:
> Maybe rename to `Inaccessible`? It seems to be closer to what this bool means 
> in C++, if I'm reading the code correctly.
> Or add a comment explaining what "unavailable" means?
So it's `Unavailable || Inaccessible`, where neither is all that well-defined 
:-)
I renamed to `Forbidden` to avoid conflation with either, and added examples as 
a comment.



Comment at: clangd/Quality.h:80
+// TopN is a lossy container that preserves only the "best" N elements.
+template > class TopN {
+public:

ilya-biryukov wrote:
> As you mentioned  in the change description, moving `TopN` and `sortText` to 
> a separate file might be a good idea since they don't depend on various 
> clangd-specific bits.
> But I'm perfectly happy to leave it as is and do this later if needed.
Yeah, I'd rather punt on this for now to avoid creating too many tiny files and 
a random standard library supplement. If TopN is pulled out, llvm/Support might 
be a better place for it.



Comment at: clangd/Quality.h:119
+
+// Returns a string that sorts like (-Score, Tiebreak).
+std::string sortText(float Score, llvm::StringRef Tiebreak = "");

ilya-biryukov wrote:
> Maybe mention that it's used for LSP sortText? To give a bit more context on 
> why we need this function.
Oops, I wrote the comment but put it in the cpp file by mistake...



Comment at: unittests/clangd/TestTU.cpp:62
+  << S;
+llvm_unreachable("QName is not unique");
+  }

ilya-biryukov wrote:
> Maybe use `FAIL()` instead of `ADD_FAILURE()` followed by 
> `llvm_unreachable()`?
> `llvm_unreachable` may produce surprising behaviors, i.e. miscompiles in opt 
> mode etc, IIUC.
> Both failing or returning a first matching symbol while also signalling an 
> error seem like good alternatives here.
`FAIL()` is the same as `ADD_FAILURE()` but it causes the enclosing function to 
immediately return - it can only be used from void functions.

> llvm_unreachable may produce surprising behaviors, i.e. miscompiles in opt 
> mode etc, IIUC
Right. After offline discussion, we don't care about asserts-disabled test 
behavior if the asserts-enabled failure is sensible, so just replaced with an 
assert.



Comment at: unittests/clangd/TestTU.h:28
+  TestTU() = default;
+  TestTU(llvm::StringRef Code, llvm::StringRef HeaderCode = "")
+  : Code(Code), HeaderCode(HeaderCode) {}

ilya-biryukov wrote:
> I really like this helper, now that we can reuse the code between different 
> tests!
> It took me some time to get the semantics of this constructor, though.
> I suggest to have a few constructor functions with more descriptive name (my 
> names are not great, but should give the idea):
> ```
> static TestTU FromSourceFile(StringRef Code);
> static TestTU FromHeaderFile(StringRef Code);
> static TestTU WithImplicitInclude(StringRef Source, StringRef IncludedHeader);
> ```
> 
> 
> 
Done, Just added `withCode` and `withHeaderCode` for now, and anyone who wants 
something more complicated can set the fields directly.
(The names mirror the struct fields)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524



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


[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 145478.
sammccall marked 9 inline comments as done.
sammccall added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524

Files:
  clang-move/ClangMove.cpp
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
  clang-tidy/google/IntegerTypesCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
  clang-tidy/tool/ClangTidyMain.cpp
  clangd/AST.cpp
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Protocol.h
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/XRefs.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/SymbolCollector.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/google-runtime-int.cpp
  test/clang-tidy/modernize-raw-string-literal.cpp
  test/clang-tidy/objc-property-declaration.m
  test/clang-tidy/temporaries.cpp
  test/clangd/rename.test
  unittests/clang-tidy/ClangTidyOptionsTest.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DraftStoreTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/SourceCodeTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -12,10 +12,11 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "XRefs.h"
-#include "clang/Frontend/CompilerInvocation.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Frontend/Utils.h"
+#include "index/FileIndex.h"
+#include "index/SymbolCollector.h"
+#include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -36,18 +37,6 @@
   std::vector Diagnostics) override {}
 };
 
-// FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef Code) {
-  auto CI = createInvocationFromCommandLine(
-  {"clang", "-xc++", testPath("Foo.cpp").c_str()});
-  auto Buf = MemoryBuffer::getMemBuffer(Code);
-  auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
-  std::make_shared(),
-  vfs::getRealFileSystem());
-  assert(AST.hasValue());
-  return std::move(*AST);
-}
-
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -98,14 +87,75 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU::withCode(T.code()).build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
 }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
 
+TEST(GoToDefinition, WithIndex) {
+  Annotations SymbolHeader(R"cpp(
+class $forward[[Forward]];
+class $foo[[Foo]] {};
+
+void $f1[[f1]]();
+
+inline void $f2[[f2]]() {}
+  )cpp");
+  Annotations SymbolCpp(R"cpp(
+  class $forward[[forward]] {};
+  void  $f1[[f1]]() {}
+)cpp");
+
+  TestTU TU;
+  TU.Code = SymbolCpp.code();
+  TU.HeaderCode = SymbolHeader.code();
+  auto Index = TU.index();
+  auto runFindDefinitionsWithIndex = [](const Annotations ) {
+auto AST = TestTU::withCode(Main.code()).build();
+return clangd::findDefinitions(AST, Main.point(), Index.get());
+  };
+
+  Annotations Test(R"cpp(// only declaration in AST.
+void [[f1]]();
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(SymbolCpp.range("f1")), RangeIs(Test.range())}));
+
+  Test = Annotations(R"cpp(// definition in AST.
+void [[f1]]() {}
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(Test.range()), 

[PATCH] D46472: [HIP] Support offloading by linkscript

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:317
+  if (GpuBinaryFileName.empty() && !IsHIP)
 return nullptr;
 

rjmccall wrote:
> Is this filename string only used for CUDA?  If so, please rename it to make 
> that clear, or at least add a comment.
Yes. Will do.


https://reviews.llvm.org/D46472



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


[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 145472.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Updated comments.


https://reviews.llvm.org/D46471

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/ToolChains/Clang.cpp

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -132,6 +132,11 @@
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
 Work(*C.getSingleOffloadToolChain());
 
+  if (JA.isHostOffloading(Action::OFK_HIP))
+Work(*C.getSingleOffloadToolChain());
+  else if (JA.isDeviceOffloading(Action::OFK_HIP))
+Work(*C.getSingleOffloadToolChain());
+
   if (JA.isHostOffloading(Action::OFK_OpenMP)) {
 auto TCs = C.getOffloadToolChains();
 for (auto II = TCs.first, IE = TCs.second; II != IE; ++II)
@@ -3104,13 +3109,14 @@
   // Check number of inputs for sanity. We need at least one input.
   assert(Inputs.size() >= 1 && "Must have at least one input.");
   const InputInfo  = Inputs[0];
-  // CUDA compilation may have multiple inputs (source file + results of
+  // CUDA/HIP compilation may have multiple inputs (source file + results of
   // device-side compilations). OpenMP device jobs also take the host IR as a
   // second input. All other jobs are expected to have exactly one
   // input.
   bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
+  bool IsHIP = JA.isOffloading(Action::OFK_HIP);
   bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
-  assert((IsCuda || (IsOpenMPDevice && Inputs.size() == 2) ||
+  assert((IsCuda || IsHIP || (IsOpenMPDevice && Inputs.size() == 2) ||
   Inputs.size() == 1) &&
  "Unable to handle multiple inputs.");
 
@@ -3122,10 +3128,10 @@
   bool IsWindowsMSVC = RawTriple.isWindowsMSVCEnvironment();
   bool IsIAMCU = RawTriple.isOSIAMCU();
 
-  // Adjust IsWindowsXYZ for CUDA compilations.  Even when compiling in device
-  // mode (i.e., getToolchain().getTriple() is NVPTX, not Windows), we need to
-  // pass Windows-specific flags to cc1.
-  if (IsCuda) {
+  // Adjust IsWindowsXYZ for CUDA/HIP compilations.  Even when compiling in
+  // device mode (i.e., getToolchain().getTriple() is NVPTX/AMDGCN, not
+  // Windows), we need to pass Windows-specific flags to cc1.
+  if (IsCuda || IsHIP) {
 IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment();
 IsWindowsGNU |= AuxTriple && AuxTriple->isWindowsGNUEnvironment();
 IsWindowsCygnus |= AuxTriple && AuxTriple->isWindowsCygwinEnvironment();
@@ -3149,18 +3155,21 @@
 Args.ClaimAllArgs(options::OPT_MJ);
   }
 
-  if (IsCuda) {
-// We have to pass the triple of the host if compiling for a CUDA device and
-// vice-versa.
+  if (IsCuda || IsHIP) {
+// We have to pass the triple of the host if compiling for a CUDA/HIP device
+// and vice-versa.
 std::string NormalizedTriple;
-if (JA.isDeviceOffloading(Action::OFK_Cuda))
+if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+JA.isDeviceOffloading(Action::OFK_HIP))
   NormalizedTriple = C.getSingleOffloadToolChain()
  ->getTriple()
  .normalize();
 else
-  NormalizedTriple = C.getSingleOffloadToolChain()
- ->getTriple()
- .normalize();
+  NormalizedTriple =
+  (IsCuda ? C.getSingleOffloadToolChain()
+  : C.getSingleOffloadToolChain())
+  ->getTriple()
+  .normalize();
 
 CmdArgs.push_back("-aux-triple");
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -196,10 +196,10 @@
   if (FailingCommands.empty())
 return false;
 
-  // CUDA can have the same input source code compiled multiple times so do not
-  // compiled again if there are already failures. It is OK to abort the CUDA
+  // CUDA/HIP can have the same input source code compiled multiple times so do
+  // not compiled again if there are already failures. It is OK to abort the
   // pipeline on errors.
-  if (A->isOffloading(Action::OFK_Cuda))
+  if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP))
 return true;
 
   for (const auto  : FailingCommands)
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -96,16 +96,23 @@
 return "device-cuda";
   case OFK_OpenMP:
 return "device-openmp";
+  case OFK_HIP:
+return "device-hip";
 
 // TODO: Add other programming models here.
   }
 
   if (!ActiveOffloadKindMask)
 return {};
 
   std::string Res("host");
+  assert(!((ActiveOffloadKindMask & OFK_Cuda) &&
+   

[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/Driver/Compilation.cpp:201
+  // not compiled again if there are already failures. It is OK to abort the
+  // CUDA pipeline on errors.
+  if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP))

rjmccall wrote:
> Mentioning only CUDA in the second clause makes me wonder whether it's *only* 
> okay to abort a CUDA pipeline, not a HIP one.  That is presumably not your 
> intent.  You could just drop "CUDA" there.
The second sentence is OK for both CUDA and HIP. Will drop CUDA in the second 
sentence.


https://reviews.llvm.org/D46471



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


[PATCH] D46501: [OpenCL] Guard all half float usage based on cl_khr_fp16 extension

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Only halfn type requires cl_khr_fp16. These functions do not use halfn type, 
therefore cl_khr_fp16 is not required.


Repository:
  rC Clang

https://reviews.llvm.org/D46501



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


[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm concerned about the scope of this patch - it does too many things and 
touches too many files for me to feel comfortable that I understand it well 
enough to review.
Is it possible to split it up? (You mention 6 distinct things in the 
description).

Have tried to focus comments on what seems to be the core parts.




Comment at: clangd/CodeComplete.cpp:247
+// Calculates include path and insertion edit for a new header.
+class IncludeInsertion {
+public:

I can't parse this name as it relates to this class. This inserts includes, it 
isn't itself an insertion.
Maybe `IncludeInserter`?



Comment at: clangd/CodeComplete.h:72
+PathRef FileName, const tooling::CompileCommand ,
+PrecompiledPreamble const *Preamble, const InclusionLocations 
,
+StringRef Contents, Position Pos, IntrusiveRefCntPtr VFS,

IncLocations isn't an appropriate name for the variable - it's coupled to the 
preamble



Comment at: clangd/Headers.h:1
 //===--- Headers.h - Include headers -*- 
C++-*-===//
 //

The interface to this header looks a bit complex and entangled after this 
change.
- The construction/lifecycle of IncludePaths is confusing (comments below)
- here we provide all the information needed to compute the edits (style, 
code...) but don't actually do so

it would be nice to achieve a simpler interface with the restricted set of 
functionality, or expand the functionality...



Comment at: clangd/Headers.h:29
 
+// A header inclusion in the main file.
+struct InclusionLocation {

I had some trouble working out the role of this struct (e.g. that it might have 
been a *proposed* inclusion).
Strictly it's not just the location, but also identifies the header being 
included.

So this could maybe be
```
// An #include directive that we found in the main file.
struct Inclusion
```

but it does also seem a little strange that this is part of the public 
interface at all (other than for testing)



Comment at: clangd/Headers.h:40
+
+using InclusionLocations = std::vector;
+

This doesn't seem to add any semantics over the vector, so it just seems to 
obscure a bit.
In fact it does have semantics: it's the stored list of inclusion locations for 
the preamble. But those semantics don't belong in this layer. I'd suggest 
moving it back to the preamble code, or avoiding the typedef altogether.



Comment at: clangd/Headers.h:55
 
-/// Determines the preferred way to #include a file, taking into account the
-/// search path. Usually this will prefer a shorter representation like
-/// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
-///
-/// \param File is an absolute file path.
-/// \param DeclaringHeader is the original header corresponding to \p
-/// InsertedHeader e.g. the header that declares a symbol.
-/// \param InsertedHeader The preferred header to be inserted. This could be 
the
-/// same as DeclaringHeader but must be provided.
-//  \return A quoted "path" or . This returns an empty string if:
-///   - Either \p DeclaringHeader or \p InsertedHeader is already (directly)
-///   included in the file (including those included via different paths).
-///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
-llvm::Expected
-calculateIncludePath(PathRef File, llvm::StringRef Code,
- const HeaderFile ,
- const HeaderFile ,
- const tooling::CompileCommand ,
- IntrusiveRefCntPtr FS);
+/// Calculates #include paths for inserting new headers into a file, based on
+/// preprocessor and build configs.

the main value-add of this class over HeaderSearch is that it determines 
whether to insert, so that should probably be mentioned.



Comment at: clangd/Headers.h:56
+/// Calculates #include paths for inserting new headers into a file, based on
+/// preprocessor and build configs.
+class IncludePaths {

can you describe the design a little bit here?
e.g. "We simply keep track of which files were already inserted, and delegate 
to clang's HeaderSearch if a header is new"



Comment at: clangd/Headers.h:57
+/// preprocessor and build configs.
+class IncludePaths {
+public:

This name suggests a set or sequence of include path entries (`-I` flags).
Can we merge this with `IncludeInsertion` and call it `IncludeInserter` or 
similar?



Comment at: clangd/Headers.h:60
+  /// This must be called before preprocessor is run (this registers a
+  /// PPCallback on \p PP).
+  /// \p SM is used in the PPCallbacks to filter source locations in main file.

hmm, if we require the InclusionLocations to be prebuilt for the preamble, why 
can't we do the same for non-preamble includes? i.e. can't 

r331640 - [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:30:49 2018
New Revision: 331640

URL: http://llvm.org/viewvc/llvm-project?rev=331640=rev
Log:
[mips] Improve handling of -fno-[pic/PIC] option

In order to disable PIC and to match GCC behaviour, -mno-abicalls
option is neccessary. When -fno-[pic/PIC] is used witout -mno-abicalls,
warning is reported. An error is reported when -fno-pic or -fno-PIC is
used in combination with -mabicalls.

In this commit, test case is added.

Depends on D44381.

Differential Revision: https://reviews.llvm.org/D44684


Added:
cfe/trunk/test/Driver/mips-abicalls-error.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331640=331639=331640=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:30:49 
2018
@@ -339,10 +339,12 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331640=331639=331640=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:30:49 2018
@@ -214,6 +214,7 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
+  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -225,6 +226,9 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
+IsPIC =
+(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
+ O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -234,9 +238,14 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (UseAbiCalls && IsN64 && NonPIC) {
-D.Diag(diag::warn_drv_unsupported_abicalls);
-UseAbiCalls = false;
+  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
+D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
+<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
+NonPIC = false;
+  }
+
+  if (ABICallsArg && !UseAbiCalls && IsPIC) {
+D.Diag(diag::err_drv_unsupported_noabicalls_pic);
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331640=331639=331640=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:30:49 2018
@@ -1018,6 +1018,14 @@ tools::ParsePICArgs(const ToolChain 
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
+StringRef CPUName;
+StringRef ABIName;
+mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+// When targeting the N64 ABI, PIC is the default, except in the case
+// when the -mno-abicalls option is used. In that case we exit
+// at next check regardless of PIC being set below.
+if (ABIName == "n64")
+  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))
   return 

r331642 - [OPENMP, NVPTX] Added support for L2 parallelism.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 07:50:05 2018
New Revision: 331642

URL: http://llvm.org/viewvc/llvm-project?rev=331642=rev
Log:
[OPENMP, NVPTX] Added support for L2 parallelism.

Added initial codegen for level 2, 3 etc. parallelism. Currently, all
the second, the third etc. parallel regions will run sequentially.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=331642=331641=331642=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon May  7 07:50:05 2018
@@ -2764,13 +2764,6 @@ Address CGOpenMPRuntime::getAddrOfArtifi
   CGM.getPointerAlign());
 }
 
-/// \brief Emits code for OpenMP 'if' clause using specified \a CodeGen
-/// function. Here is the logic:
-/// if (Cond) {
-///   ThenGen();
-/// } else {
-///   ElseGen();
-/// }
 void CGOpenMPRuntime::emitOMPIfClause(CodeGenFunction , const Expr *Cond,
   const RegionCodeGenTy ,
   const RegionCodeGenTy ) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=331642=331641=331642=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon May  7 07:50:05 2018
@@ -93,6 +93,9 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_end_sharing_variables,
   /// \brief Call to void __kmpc_get_shared_variables(void ***GlobalArgs)
   OMPRTL_NVPTX__kmpc_get_shared_variables,
+  /// Call to uint16_t __kmpc_parallel_level(ident_t *loc, kmp_int32
+  /// global_tid);
+  OMPRTL_NVPTX__kmpc_parallel_level,
 };
 
 /// Pre(post)-action for different OpenMP constructs specialized for NVPTX.
@@ -131,19 +134,17 @@ public:
   }
 };
 
-// A class to track the execution mode when codegening directives within
-// a target region. The appropriate mode (generic/spmd) is set on entry
-// to the target region and used by containing directives such as 'parallel'
-// to emit optimized code.
+/// A class to track the execution mode when codegening directives within
+/// a target region. The appropriate mode (SPMD|NON-SPMD) is set on entry
+/// to the target region and used by containing directives such as 'parallel'
+/// to emit optimized code.
 class ExecutionModeRAII {
 private:
-  CGOpenMPRuntimeNVPTX::ExecutionMode SavedMode;
-  CGOpenMPRuntimeNVPTX::ExecutionMode 
+  bool SavedMode;
+  bool 
 
 public:
-  ExecutionModeRAII(CGOpenMPRuntimeNVPTX::ExecutionMode ,
-CGOpenMPRuntimeNVPTX::ExecutionMode NewMode)
-  : Mode(Mode) {
+  ExecutionModeRAII(bool , bool NewMode) : Mode(Mode) {
 SavedMode = Mode;
 Mode = NewMode;
   }
@@ -579,24 +580,171 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
 }
 
 bool CGOpenMPRuntimeNVPTX::isInSpmdExecutionMode() const {
-  return CurrentExecutionMode == CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+  return IsInSPMDExecutionMode;
 }
 
-static CGOpenMPRuntimeNVPTX::ExecutionMode
-getExecutionMode(CodeGenModule ) {
-  return CGM.getLangOpts().OpenMPCUDAMode
- ? CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd
- : CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
+static CGOpenMPRuntimeNVPTX::DataSharingMode
+getDataSharingMode(CodeGenModule ) {
+  return CGM.getLangOpts().OpenMPCUDAMode ? CGOpenMPRuntimeNVPTX::CUDA
+  : CGOpenMPRuntimeNVPTX::Generic;
+}
+
+/// Check for inner (nested) SPMD construct, if any
+static bool hasNestedSPMDDirective(const OMPExecutableDirective ) {
+  const auto *CS = D.getCapturedStmt(OMPD_target);
+  const auto *Body = CS->getCapturedStmt()->IgnoreContainers();
+  const Stmt *ChildStmt = nullptr;
+  if (const auto *C = dyn_cast(Body))
+if (C->size() == 1)
+  ChildStmt = C->body_front();
+  if (!ChildStmt)
+return false;
+
+  if (const auto *NestedDir = dyn_cast(ChildStmt)) {
+OpenMPDirectiveKind DKind = NestedDir->getDirectiveKind();
+// TODO: add further analysis for inner teams|distribute directives, if 
any.
+switch (D.getDirectiveKind()) {
+case OMPD_target:
+  return (isOpenMPParallelDirective(DKind) &&
+  !isOpenMPTeamsDirective(DKind) &&
+  !isOpenMPDistributeDirective(DKind)) ||
+ isOpenMPSimdDirective(DKind) ||
+ DKind == OMPD_teams_distribute_parallel_for;
+case 

[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The change makes both testing and scoring code better.
Even though those are largely independent changes, perfectly happy to review 
them together.

I mostly have NITs here, overall the changes LG.




Comment at: clangd/CodeComplete.cpp:36
 
+#define DEBUG_TYPE "codecomplete"
+

Is this used by `DEBUG()` macro?
It would be nice to have a short comment saying why we need this define.



Comment at: clangd/CodeComplete.cpp:909
+
+auto QualScore = Quality.evaluate(), RelScore = Relevance.evaluate();
+CompletionItemScores Scores;

NIT: Maybe use `float` here instead of auto? Would remove the need to look at 
`evaluate` for anyone reading the code for the first time.



Comment at: clangd/Quality.cpp:83
+// That is: a < b <==> encodeFloat(a) < encodeFloat(b).
+uint32_t encodeFloat(float F) {
+  static_assert(std::numeric_limits::is_iec559, "");

This function does not seem to be exposed outside this C++ file. Maybe add 
`static`?



Comment at: clangd/Quality.h:45
+
+// Attributes of a symbol that affect how much we like it.
+struct SymbolQualitySignals {

Maybe use doxygen-style comments to be consistent with the rest of LLVM?



Comment at: clangd/Quality.h:66
+  float NameMatch = 1;
+  bool Unavailable = false;
+

Maybe rename to `Inaccessible`? It seems to be closer to what this bool means 
in C++, if I'm reading the code correctly.
Or add a comment explaining what "unavailable" means?



Comment at: clangd/Quality.h:80
+// TopN is a lossy container that preserves only the "best" N elements.
+template > class TopN {
+public:

As you mentioned  in the change description, moving `TopN` and `sortText` to a 
separate file might be a good idea since they don't depend on various 
clangd-specific bits.
But I'm perfectly happy to leave it as is and do this later if needed.



Comment at: clangd/Quality.h:119
+
+// Returns a string that sorts like (-Score, Tiebreak).
+std::string sortText(float Score, llvm::StringRef Tiebreak = "");

Maybe mention that it's used for LSP sortText? To give a bit more context on 
why we need this function.



Comment at: unittests/clangd/TestTU.cpp:56
+  const Symbol *Result = nullptr;
+  for (const Symbol  : Slab)
+if (QName == (S.Scope + S.Name).str()) {

Maybe add braces for the loop body here? It seems to be long enough that it 
could actually, arguably, improve readability.
We could some nesting by inverting the condition too:
`if (QName != ...) continue;`



Comment at: unittests/clangd/TestTU.cpp:62
+  << S;
+llvm_unreachable("QName is not unique");
+  }

Maybe use `FAIL()` instead of `ADD_FAILURE()` followed by `llvm_unreachable()`?
`llvm_unreachable` may produce surprising behaviors, i.e. miscompiles in opt 
mode etc, IIUC.
Both failing or returning a first matching symbol while also signalling an 
error seem like good alternatives here.



Comment at: unittests/clangd/TestTU.h:28
+  TestTU() = default;
+  TestTU(llvm::StringRef Code, llvm::StringRef HeaderCode = "")
+  : Code(Code), HeaderCode(HeaderCode) {}

I really like this helper, now that we can reuse the code between different 
tests!
It took me some time to get the semantics of this constructor, though.
I suggest to have a few constructor functions with more descriptive name (my 
names are not great, but should give the idea):
```
static TestTU FromSourceFile(StringRef Code);
static TestTU FromHeaderFile(StringRef Code);
static TestTU WithImplicitInclude(StringRef Source, StringRef IncludedHeader);
```





Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524



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


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:4218
 
   // -fno-use-line-directives is default.
   if (Args.hasFlag(options::OPT_fuse_line_directives,

hans wrote:
> The comment needs an update I think.
Thanks, will change into "-fno-use-line-directives is default, except for MSVC 
targets." before pushing.


Repository:
  rC Clang

https://reviews.llvm.org/D46520



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


r331636 - [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:19:54 2018
New Revision: 331636

URL: http://llvm.org/viewvc/llvm-project?rev=331636=rev
Log:
[mips] Improve handling of -fno-[pic/PIC] option

In order to disable PIC and to match GCC behaviour, -mno-abicalls
option is neccessary. When -fno-[pic/PIC] is used witout -mno-abicalls,
warning is reported. An error is reported when -fno-pic or -fno-PIC is
used in combination with -mabicalls.

Depends on D44381.

Differential Revision: https://reviews.llvm.org/D44684

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331636=331635=331636=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:19:54 
2018
@@ -339,10 +339,12 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331636=331635=331636=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:19:54 2018
@@ -214,6 +214,7 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
+  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -225,6 +226,9 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
+IsPIC =
+(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
+ O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -234,9 +238,14 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (UseAbiCalls && IsN64 && NonPIC) {
-D.Diag(diag::warn_drv_unsupported_abicalls);
-UseAbiCalls = false;
+  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
+D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
+<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
+NonPIC = false;
+  }
+
+  if (ABICallsArg && !UseAbiCalls && IsPIC) {
+D.Diag(diag::err_drv_unsupported_noabicalls_pic);
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331636=331635=331636=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:19:54 2018
@@ -1018,6 +1018,14 @@ tools::ParsePICArgs(const ToolChain 
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
+StringRef CPUName;
+StringRef ABIName;
+mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+// When targeting the N64 ABI, PIC is the default, except in the case
+// when the -mno-abicalls option is used. In that case we exit
+// at next check regardless of PIC being set below.
+if (ABIName == "n64")
+  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))
   return std::make_tuple(llvm::Reloc::Static, 0U, false);

Modified: cfe/trunk/test/Driver/mips-abicalls-warning.c
URL: 

r331639 - Revert "[mips] Improve handling of -fno-[pic/PIC] option"

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:28:42 2018
New Revision: 331639

URL: http://llvm.org/viewvc/llvm-project?rev=331639=rev
Log:
Revert "[mips] Improve handling of -fno-[pic/PIC] option"

This reverts commit r331636. Forgot to add the test case.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331639=331638=331639=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:28:42 
2018
@@ -339,12 +339,10 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_pic_with_mabicalls : Warning<
-  "ignoring '%0' option as it cannot be used with "
-  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
   InGroup;
-def err_drv_unsupported_noabicalls_pic : Error<
-  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331639=331638=331639=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:28:42 2018
@@ -214,7 +214,6 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
-  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -226,9 +225,6 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
-IsPIC =
-(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
- O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -238,14 +234,9 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
-D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
-<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
-NonPIC = false;
-  }
-
-  if (ABICallsArg && !UseAbiCalls && IsPIC) {
-D.Diag(diag::err_drv_unsupported_noabicalls_pic);
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331639=331638=331639=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:28:42 2018
@@ -1018,14 +1018,6 @@ tools::ParsePICArgs(const ToolChain 
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
-StringRef CPUName;
-StringRef ABIName;
-mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
-// When targeting the N64 ABI, PIC is the default, except in the case
-// when the -mno-abicalls option is used. In that case we exit
-// at next check regardless of PIC being set below.
-if (ABIName == "n64")
-  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))
   return std::make_tuple(llvm::Reloc::Static, 0U, false);

Modified: cfe/trunk/test/Driver/mips-abicalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abicalls-warning.c?rev=331639=331638=331639=diff
==
--- cfe/trunk/test/Driver/mips-abicalls-warning.c (original)
+++ 

[libcxx] r331638 - Update for Rapperswil

2018-05-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May  7 07:21:52 2018
New Revision: 331638

URL: http://llvm.org/viewvc/llvm-project?rev=331638=rev
Log:
Update for Rapperswil

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=331638=331637=331638=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon May  7 07:21:52 2018
@@ -60,86 +60,52 @@
   
Issue #Issue 
NameMeetingStatus
 
-https://wg21.link/LWG2164;>2164What are the 
semantics of vector.emplace(vector.begin(), 
vector.back())?Jacksonville
-https://wg21.link/LWG2243;>2243istream::putback 
problemJacksonvilleComplete
-https://wg21.link/LWG2816;>2816resize_file has 
impossible postconditionJacksonvilleNothing to 
do
-https://wg21.link/LWG2843;>2843Unclear behavior 
of 
std::pmr::memory_resource::do_allocate()Jacksonville
-https://wg21.link/LWG2849;>2849Why does 
!is_regular_file(from) cause copy_file to report a "file 
already exists" error?JacksonvilleNothing to 
do
-https://wg21.link/LWG2851;>2851std::filesystem enum 
classes are now underspecifiedJacksonvilleNothing to 
do
-https://wg21.link/LWG2969;>2969polymorphic_allocator::construct()
 shouldn't pass resource()Jacksonville
-https://wg21.link/LWG2975;>2975Missing case for 
pair construction in scoped and polymorphic 
allocatorsJacksonville
-https://wg21.link/LWG2989;>2989path's 
stream insertion operator lets you insert everything under the 
sunJacksonvilleCompleted
-https://wg21.link/LWG3000;>3000monotonic_memory_resource::do_is_equal
 uses dynamic_cast 
unnecessarilyJacksonville
-https://wg21.link/LWG3002;>3002[networking.ts] 
basic_socket_acceptor::is_open() isn't 
noexceptJacksonville
-https://wg21.link/LWG3004;>3004[string.capacity] and 
[vector.capacity] should specify time complexity for 
capacity()JacksonvilleNothing to do
-https://wg21.link/LWG3005;>3005Destruction order 
of arrays by make_shared/allocate_shared only 
recommended?Jacksonville
-https://wg21.link/LWG3007;>3007allocate_shared 
should rebind allocator to cv-unqualified value_type for 
constructionJacksonville
-https://wg21.link/LWG3009;>3009Including 
string_view doesn't provide 
std::size/empty/dataJacksonvilleComplete
-https://wg21.link/LWG3010;>3010[networking.ts] 
uses_executor says "if a type T::executor_type 
exists"Jacksonville
-https://wg21.link/LWG3013;>3013(recursive_)directory_iterator
 construction and traversal should not be 
noexceptJacksonvilleComplete
-https://wg21.link/LWG3014;>3014More 
noexcept issues with filesystem 
operationsJacksonvilleComplete
-https://wg21.link/LWG3015;>3015copy_options::unspecified
 underspecifiedJacksonvilleNothing to do
-https://wg21.link/LWG3017;>3017list 
splice functions should use 
addressofJacksonville
-https://wg21.link/LWG3020;>3020[networking.ts] 
Remove spurious nested value_type buffer sequence 
requirementJacksonville
-https://wg21.link/LWG3026;>3026filesystem::weakly_canonical
 still defined in terms of canonical(p, 
base)Jacksonville
-https://wg21.link/LWG3030;>3030Who shall meet 
the requirements of try_lock?JacksonvilleNothing 
to do
-https://wg21.link/LWG3034;>3034P0767R1 breaks 
previously-standard-layout typesJacksonvillePatch 
Ready
-https://wg21.link/LWG3035;>3035std::allocator's 
constructors should be constexprJacksonvillePatch 
Ready
-https://wg21.link/LWG3039;>3039Unnecessary 
decay in thread and 
packaged_taskJacksonvillePatch Ready
-https://wg21.link/LWG3041;>3041Unnecessary 
decay in 
reference_wrapperJacksonvillePatch 
Ready
-https://wg21.link/LWG3042;>3042is_literal_type_v 
should be inlineJacksonvilleComplete
-https://wg21.link/LWG3043;>3043Bogus 
postcondition for filesystem_error 
constructorJacksonville
-https://wg21.link/LWG3045;>3045atomicfloating-point
 doesn't have value_type or 
difference_typeJacksonville
-https://wg21.link/LWG3048;>3048transform_reduce(exec, 
first1, last1, first2, init) discards execution 
policyJacksonville
-https://wg21.link/LWG3051;>3051Floating 
point classifications were inadvertently changed in 
P0175JacksonvilleNothing to do
+https://wg21.link/LWG2139;>2139What is a 
user-defined type?Rapperswil
+https://wg21.link/LWG2970;>2970Return type of 
std::visit misspecifiedRapperswil
+https://wg21.link/LWG3058;>3058Parallel 
adjacent_difference shouldn't require creating 
temporariesRapperswil
+https://wg21.link/LWG3062;>3062Unnecessary 
decay_t in is_execution_policy_v should be 
remove_cvref_tRapperswil
+https://wg21.link/LWG3067;>3067recursive_directory_iterator::pop
 must invalidateRapperswil
+https://wg21.link/LWG3071;>3071[networking.ts] 
read_until still refers to "input 
sequence"RapperswilNothing to do
+https://wg21.link/LWG3074;>3074Non-member 
functions for valarray should only deduce from the 
valarrayRapperswil
+https://wg21.link/LWG3076;>3076basic_string CTAD 

[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331636: [mips] Improve handling of -fno-[pic/PIC] option 
(authored by abeserminji, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44684?vs=145460=145462#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44684

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/mips-abicalls-warning.c
  cfe/trunk/test/Driver/mips-as.c
  cfe/trunk/test/Driver/mips-features.c

Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -339,10 +339,12 @@
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -11,7 +11,7 @@
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
 // -mno-abicalls non-PIC N64
-// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
 // CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
 //
@@ -86,13 +86,13 @@
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
 // MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
 // CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
 //
 // MIPS64 + N64: -fno-pic -mno-gpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls -mno-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
 // CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
Index: cfe/trunk/test/Driver/mips-abicalls-warning.c
===
--- cfe/trunk/test/Driver/mips-abicalls-warning.c
+++ cfe/trunk/test/Driver/mips-abicalls-warning.c
@@ -1,6 +1,27 @@
 // REQUIRES: mips-registered-target
-// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s
-// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and the N64 ABI
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pic %s 2>&1 | FileCheck -check-prefix=CHECK-PIC1-IMPLICIT %s
+// CHECK-PIC1-IMPLICIT: warning: ignoring '-fno-pic' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pic -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIC1-EXPLICIT %s
+// CHECK-PIC1-EXPLICIT: warning: ignoring '-fno-pic' option as it cannot be used with -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC %s 2>&1 | FileCheck -check-prefix=CHECK-PIC2-IMPLICIT %s
+// CHECK-PIC2-IMPLICIT: warning: ignoring '-fno-PIC' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIC2-EXPLICIT %s
+// CHECK-PIC2-EXPLICIT: warning: ignoring '-fno-PIC' option as it cannot be used with -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pie %s 2>&1 | FileCheck -check-prefix=CHECK-PIE1-IMPLICIT %s
+// CHECK-PIE1-IMPLICIT: warning: ignoring '-fno-pie' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pie -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIE1-EXPLICIT %s
+// CHECK-PIE1-EXPLICIT: warning: ignoring '-fno-pie' option as it cannot be used with 

[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 145460.
abeserminji marked 4 inline comments as done.
abeserminji added a comment.

Comments resolved.


https://reviews.llvm.org/D44684

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/mips-abicalls-error.c
  test/Driver/mips-abicalls-warning.c
  test/Driver/mips-as.c
  test/Driver/mips-features.c

Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -11,7 +11,7 @@
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
 // -mno-abicalls non-PIC N64
-// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
 // CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
 //
@@ -86,13 +86,13 @@
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
 // MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
 // CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
 //
 // MIPS64 + N64: -fno-pic -mno-gpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls -mno-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
 // CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
Index: test/Driver/mips-as.c
===
--- test/Driver/mips-as.c
+++ test/Driver/mips-as.c
@@ -21,7 +21,7 @@
 // MIPS32R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EL"
 //
 // RUN: %clang -target mips64-linux-gnu -### \
-// RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
+// RUN:   -no-integrated-as -fno-pic -mno-abicalls -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EB-AS %s
 // MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -31,7 +31,7 @@
 // MIPS64R2-EB-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64el-linux-gnu -### \
-// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
+// RUN:   -no-integrated-as -c -fno-pic -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-DEF-EL-AS %s
 // MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"  "-mno-shared" "-EL"
 //
@@ -64,7 +64,7 @@
 // MIPS64R2-EL-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC"
 //
 // RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EL-AS %s
 // MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EL"
 //
@@ -84,7 +84,7 @@
 // MIPS-OCTEON-PIC: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
 // MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -144,7 +144,7 @@
 // MIPS-ALIAS-64-PIC: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64 -### \
-// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
+// RUN:   -no-integrated-as -c -fno-pic -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
 // MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -159,7 +159,7 @@
 // MIPS-ALIAS-64R3-PIC: as{{(.exe)?}}" "-march" "mips64r3" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r3 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R3 %s
 // MIPS-ALIAS-64R3: as{{(.exe)?}}" "-march" "mips64r3" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -169,7 +169,7 @@
 // MIPS-ALIAS-64R5-PIC: as{{(.exe)?}}" "-march" "mips64r5" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r5 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R5 %s
 // MIPS-ALIAS-64R5: as{{(.exe)?}}" "-march" "mips64r5" "-mabi" "64" "-mno-shared" "-EB"
 

[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgrang, jkorous, MaskRay, ioeric, 
mgorny, klimek.

Code completion scoring was embedded in CodeComplete.cpp, which is bad:

- awkward to test. The mechanisms (extracting info from index/sema) can be 
unit-tested well, the policy (scoring) should be quantitatively measured. 
Neither was easily possible, and debugging was hard. The intermediate signal 
struct makes this easier.
- hard to reuse. This is a bug in workspaceSymbols: it just presents the 
results in the index order, which is not sorted in practice, it needs to rank 
them! Also, index implementations care about scoring (both query-dependent and 
independent) in order to truncate result lists appropriately.

The main yak shaved here is the build() function that had 3 variants across
unit tests is unified in TestTU.h (rather than adding a 4th variant).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524

Files:
  clangd/CMakeLists.txt
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -12,15 +12,13 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "XRefs.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "index/SymbolCollector.h"
-#include "clang/Frontend/CompilerInvocation.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -39,34 +37,6 @@
   std::vector Diagnostics) override {}
 };
 
-// FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef MainCode, StringRef HeaderCode = "") {
-  auto HeaderPath = testPath("foo.h");
-  auto MainPath = testPath("foo.cpp");
-  llvm::IntrusiveRefCntPtr VFS(
-  new vfs::InMemoryFileSystem());
-  VFS->addFile(MainPath, 0, llvm::MemoryBuffer::getMemBuffer(MainCode));
-  VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer(HeaderCode));
-  std::vector Cmd = {"clang", "-xc++", MainPath.c_str()};
-  if (!HeaderCode.empty()) {
-std::vector args = {"-include", HeaderPath.c_str()};
-Cmd.insert(Cmd.begin() + 1, args.begin(), args.end());
-  }
-  auto CI = createInvocationFromCommandLine(Cmd);
-
-  auto Buf = MemoryBuffer::getMemBuffer(MainCode);
-  auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
-  std::make_shared(), VFS);
-  assert(AST.hasValue());
-  return std::move(*AST);
-}
-
-std::unique_ptr buildIndex(StringRef MainCode,
-StringRef HeaderCode) {
-  auto AST = build(MainCode, HeaderCode);
-  return MemIndex::build(indexAST());
-}
-
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -117,7 +87,7 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
@@ -139,10 +109,9 @@
   void  $f1[[f1]]() {}
 )cpp");
 
-  auto Index = buildIndex(SymbolCpp.code(), SymbolHeader.code());
+  auto Index = TestTU(SymbolCpp.code(), SymbolHeader.code()).index();
   auto runFindDefinitionsWithIndex = [](const Annotations ) {
-auto AST = build(/*MainCode=*/Main.code(),
- /*HeaderCode=*/"");
+auto AST = TestTU(Main.code()).build();
 return clangd::findDefinitions(AST, Main.point(), Index.get());
   };
 
@@ -329,7 +298,7 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 std::vector ExpectedLocations;
 for (const auto  : T.ranges())
   ExpectedLocations.push_back(RangeIs(R));
@@ -661,7 +630,7 @@
 
   for (const OneTest  : Tests) {
 Annotations T(Test.Input);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 Hover H = getHover(AST, T.point());
 
 EXPECT_EQ(H.contents.value, Test.ExpectedHover) << Test.Input;
Index: unittests/clangd/TestTU.h
===
--- /dev/null
+++ unittests/clangd/TestTU.h
@@ -0,0 +1,51 @@
+//===--- TestTU.h - Scratch source files for testing *- C++-*-===//
+//
+//

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/clang-tidy/bugprone-exception-escape.cpp:178
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' 
throws
+  implicit_int_thrower();

baloghadamsoftware wrote:
> dberris wrote:
> > How deep does this go? Say we have a call to a function that's extern which 
> > doesn't have 'noexcept' nor a dynamic exception specifier -- do we assume 
> > that the call to an extern function may throw? Does that warn? What does 
> > the warning look like? Should it warn? How about when you call a function 
> > through a function pointer?
> > 
> > The documentation should cover these cases and/or more explicitly say in 
> > the warning that an exception may throw in a noexcept function (rather than 
> > just "function <...> throws").
> We take the most conservative way here. We assume that a function throws if 
> and only if its body has a throw statement or its header has the (old) 
> throw() exception specification. We do not follow function pointers.
While i realize it may have more noise, it may be nice to have a more pedantic 
mode (guarded by an option?).
E.g. `noexcept` propagation, much like `const` on methods propagation.
Or at least a test that shows that it does not happen, unless i simply did not 
notice it :)


https://reviews.llvm.org/D33537



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

@aaron.ballman Ping


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 10 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: test/clang-tidy/bugprone-exception-escape.cpp:178
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' 
throws
+  implicit_int_thrower();

dberris wrote:
> How deep does this go? Say we have a call to a function that's extern which 
> doesn't have 'noexcept' nor a dynamic exception specifier -- do we assume 
> that the call to an extern function may throw? Does that warn? What does the 
> warning look like? Should it warn? How about when you call a function through 
> a function pointer?
> 
> The documentation should cover these cases and/or more explicitly say in the 
> warning that an exception may throw in a noexcept function (rather than just 
> "function <...> throws").
We take the most conservative way here. We assume that a function throws if and 
only if its body has a throw statement or its header has the (old) throw() 
exception specification. We do not follow function pointers.


https://reviews.llvm.org/D33537



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 145452.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/bugprone/ExceptionEscapeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-exception-escape.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-exception-escape.cpp

Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -0,0 +1,265 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: bugprone-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: bugprone-exception-escape.FunctionsThatShouldNotThrow, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  if (n) throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+if (n) throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1;
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 

[PATCH] D46522: [clang] cmake: resolve symlinks in ClangConfig.cmake

2018-05-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn created this revision.
Lekensteyn added a reviewer: sylvestre.ledru.
Herald added subscribers: cfe-commits, mgorny.

Ensure that symlinks such as /usr/lib/cmake/clang-X.Y (pointing to
/usr/lib/llvm-X.Y/lib/cmake/llvm) are resolved. This ensures that
CLANG_INSTALL_PREFIX ends up to be /usr/lib/llvm-X.Y instead of /usr.

Partially addresses PR37128


Repository:
  rC Clang

https://reviews.llvm.org/D46522

Files:
  cmake/modules/CMakeLists.txt


Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -30,10 +30,10 @@
 # Generate ClangConfig.cmake for the install tree.
 set(CLANG_CONFIG_CODE "
 # Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" 
PATH)")
+get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" 
REALPATH)")
 # Construct the proper number of get_filename_component(... PATH)
 # calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
+string(REGEX REPLACE "/" ";" _count "prefix/${CLANG_INSTALL_PACKAGE_DIR}")
 foreach(p ${_count})
   set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" 
PATH)")


Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -30,10 +30,10 @@
 # Generate ClangConfig.cmake for the install tree.
 set(CLANG_CONFIG_CODE "
 # Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
+get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" REALPATH)")
 # Construct the proper number of get_filename_component(... PATH)
 # calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
+string(REGEX REPLACE "/" ";" _count "prefix/${CLANG_INSTALL_PACKAGE_DIR}")
 foreach(p ${_count})
   set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >