r310444 - Attempt to appease msc buildbot

2017-08-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Aug  8 22:20:05 2017
New Revision: 310444

URL: http://llvm.org/viewvc/llvm-project?rev=310444=rev
Log:
Attempt to appease msc buildbot

It was timing out on this test, but for reasons unrelated to the
specific bug it was testing for. Randomly breaking in gdb with `clang
-target i686-windows -fmsc-version=1700` reveals *many* frames from
MicrosoftCXXNameMangler. So, it would seem that some caching is needed
there, as well...

Fingers crossed that specifying a triple is sufficient to work around
this.

Modified:
cfe/trunk/test/CodeGenCXX/pr29160.cpp

Modified: cfe/trunk/test/CodeGenCXX/pr29160.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr29160.cpp?rev=310444=310443=310444=diff
==
--- cfe/trunk/test/CodeGenCXX/pr29160.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pr29160.cpp Tue Aug  8 22:20:05 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 %s -o /dev/null -S
+// RUN: %clang_cc1 -std=c++11 -triple i686-linux %s -o /dev/null -S
 //
 // This test's failure mode is running ~forever. (For some value of "forever"
 // that's greater than 25 minutes on my machine)


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


[PATCH] D36491: clang-format: [JS] detect ASI after closing parens.

2017-08-08 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D36491



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/cmake/modules/ProtobufMutator.cmake:6
+
+ExternalProject_Add(${PBM_PREFIX}
+  PREFIX ${PBM_PREFIX}

Just noticed, for cmake projects shorter syntax can be used.
Example: 
https://github.com/google/libprotobuf-mutator/blob/master/cmake/external/googletest.cmake



Repository:
  rL LLVM

https://reviews.llvm.org/D36324



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


r310441 - [clang-fuzzer] Resolve proto dependencies

2017-08-08 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Aug  8 21:45:00 2017
New Revision: 310441

URL: http://llvm.org/viewvc/llvm-project?rev=310441=rev
Log:
[clang-fuzzer] Resolve proto dependencies

Modified:
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt?rev=310441=310440=310441=diff
==
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt Tue Aug  8 
21:45:00 2017
@@ -4,7 +4,10 @@ set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_
 # an executable built from this directory.
 set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)
 
-add_clang_library(clangProtoToCXX proto_to_cxx.cpp LINK_LIBS clangCXXProto)
+add_clang_library(clangProtoToCXX proto_to_cxx.cpp 
+  DEPENDS clangCXXProto
+  LINK_LIBS clangCXXProto
+  )
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)
 target_link_libraries(clang-proto-to-cxx clangProtoToCXX)


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


[PATCH] D36501: add flag to undo ABI change in r310401

2017-08-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, I think having an internal C++ ABI version makes a lot more sense than 
having a million different flags.  Is there a reason to expose this as a knob 
to users at all?


Repository:
  rL LLVM

https://reviews.llvm.org/D36501



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


r310437 - [AST] Cache intermediate visibility/linkage results

2017-08-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Aug  8 21:12:17 2017
New Revision: 310437

URL: http://llvm.org/viewvc/llvm-project?rev=310437=rev
Log:
[AST] Cache intermediate visibility/linkage results

This is a follow-up to r310436 with actual functional changes. Please
see that commit message for a description of why a cache is appearing
here.

Suggestions for less-bad ways of testing this are appreciated. :)

This fixes PR29160.

Added:
cfe/trunk/test/CodeGenCXX/pr29160.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/Linkage.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=310437=310436=310437=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 21:12:17 2017
@@ -192,7 +192,7 @@ LinkageInfo LinkageComputer::getLVForTyp
   LVComputationKind computation) {
   if (computation == LVForLinkageOnly)
 return LinkageInfo(T.getLinkage(), DefaultVisibility, true);
-  return T.getLinkageAndVisibility();
+  return getTypeLinkageAndVisibility();
 }
 
 /// \brief Get the most restrictive linkage for the types in the given
@@ -224,7 +224,7 @@ LinkageInfo LinkageComputer::getLVForTem
   for (unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
 QualType type = NTTP->getExpansionType(i);
 if (!type->isDependentType())
-  LV.merge(type->getLinkageAndVisibility());
+  LV.merge(getTypeLinkageAndVisibility(type));
   }
   continue;
 }
@@ -291,7 +291,7 @@ LinkageComputer::getLVForTemplateArgumen
   continue;
 
 case TemplateArgument::NullPtr:
-  LV.merge(Arg.getNullPtrType()->getLinkageAndVisibility());
+  LV.merge(getTypeLinkageAndVisibility(Arg.getNullPtrType()));
   continue;
 
 case TemplateArgument::Template:
@@ -610,7 +610,7 @@ LinkageComputer::getLVForNamespaceScopeD
  PrevVar = PrevVar->getPreviousDecl()) {
   if (PrevVar->getStorageClass() == SC_PrivateExtern &&
   Var->getStorageClass() == SC_None)
-return PrevVar->getLinkageAndVisibility();
+return getDeclLinkageAndVisibility(PrevVar);
   // Explicitly declared static.
   if (PrevVar->getStorageClass() == SC_Static)
 return getInternalLinkageFor(Var);
@@ -1358,11 +1358,15 @@ LinkageInfo LinkageComputer::getLVForDec
   if (computation == LVForLinkageOnly && D->hasCachedLinkage())
 return LinkageInfo(D->getCachedLinkage(), DefaultVisibility, false);
 
+  if (llvm::Optional LI = lookup(D, computation))
+return *LI;
+
   LinkageInfo LV = computeLVForDecl(D, computation);
   if (D->hasCachedLinkage())
 assert(D->getCachedLinkage() == LV.getLinkage());
 
   D->setCachedLinkage(LV.getLinkage());
+  cache(D, computation, LV);
 
 #ifndef NDEBUG
   // In C (because of gnu inline) and in c++ with microsoft extensions an

Modified: cfe/trunk/lib/AST/Linkage.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Linkage.h?rev=310437=310436=310437=diff
==
--- cfe/trunk/lib/AST/Linkage.h (original)
+++ cfe/trunk/lib/AST/Linkage.h Tue Aug  8 21:12:17 2017
@@ -19,6 +19,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
 
 namespace clang {
 enum : unsigned {
@@ -54,8 +55,50 @@ enum LVComputationKind {
   LVForLinkageOnly =
   LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
 };
+} // namespace clang
 
+namespace llvm {
+template <> struct DenseMapInfo {
+  static inline clang::LVComputationKind getEmptyKey() {
+return static_cast(-1);
+  }
+  static inline clang::LVComputationKind getTombstoneKey() {
+return static_cast(-2);
+  }
+  static unsigned getHashValue(const clang::LVComputationKind ) {
+return Val;
+  }
+  static bool isEqual(const clang::LVComputationKind ,
+  const clang::LVComputationKind ) {
+return LHS == RHS;
+  }
+};
+} // namespace llvm
+
+namespace clang {
 class LinkageComputer {
+  // We have a cache for repeated linkage/visibility computations. This saves 
us
+  // from exponential behavior in heavily templated code, such as:
+  //
+  // template  struct {};
+  // using A = int;
+  // using B = Foo;
+  // using C = Foo;
+  // using D = Foo;
+  using QueryType = std::pair;
+  llvm::SmallDenseMap CachedLinkageInfo;
+  llvm::Optional lookup(const NamedDecl *ND,
+ LVComputationKind Kind) const {
+auto Iter = CachedLinkageInfo.find(std::make_pair(ND, Kind));
+if (Iter == CachedLinkageInfo.end())
+  return None;
+return Iter->second;
+  }
+
+  void cache(const NamedDecl *ND, LVComputationKind Kind, LinkageInfo Info) {
+CachedLinkageInfo[std::make_pair(ND, 

[PATCH] D36503: [libcxx] [test] Update for C++17 feature removals.

2017-08-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

[libcxx] [test] Update for C++17 feature removals.

test/std/containers/Emplaceable.h
test/std/containers/NotConstructible.h
test/support/counting_predicates.hpp
Replace unary_function/binary_function inheritance with typedefs.

test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
test/std/utilities/function.objects/func.require/binary_function.pass.cpp
test/std/utilities/function.objects/func.require/unary_function.pass.cpp
Mark these tests as requiring 98/03/11/14 because 17 removed 
unary_function/binary_function.

test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp
Mark these tests as requiring 11/14 because 17 removed packaged_task allocator 
support.

test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
This test doesn't need to be skipped in C++17 mode. Only the construction of
std::function from an allocator needs to be skipped in C++17 mode.

test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
When testing these reference_wrapper features, unary_function inheritance is 
totally irrelevant.

test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
Define and use my_unary_function/my_binary_function to test the weak result 
type machinery
(which is still present in C++17, although deprecated).

test/support/msvc_stdlib_force_include.hpp
Now we can test C++17 strictly, without enabling removed features.


https://reviews.llvm.org/D36503

Files:
  test/std/containers/Emplaceable.h
  test/std/containers/NotConstructible.h
  test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
  test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp
  test/std/utilities/function.objects/func.require/binary_function.pass.cpp
  test/std/utilities/function.objects/func.require/unary_function.pass.cpp
  
test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
  test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
  test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
  test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
  test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
  test/support/counting_predicates.hpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -69,12 +69,6 @@
 // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
 #define _ENABLE_ATOMIC_ALIGNMENT_FIX
 
-// Enable features that /std:c++latest removes by default.
-#define _HAS_AUTO_PTR_ETC   1
-#define _HAS_FUNCTION_ALLOCATOR_SUPPORT 1
-#define _HAS_OLD_IOSTREAMS_MEMBERS  1
-#define _HAS_UNEXPECTED 1
-
 // Silence warnings about raw pointers and other unchecked iterators.
 #define _SCL_SECURE_NO_WARNINGS
 
Index: test/support/counting_predicates.hpp
===
--- test/support/counting_predicates.hpp
+++ test/support/counting_predicates.hpp
@@ -12,8 +12,11 @@
 
 
 template 
-struct unary_counting_predicate : public std::unary_function  {
+struct unary_counting_predicate {
 public:
+typedef Arg argument_type;
+typedef bool result_type;
+
 unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
 ~unary_counting_predicate() {}
 
@@ -28,8 +31,11 @@
 
 
 template 
-struct binary_counting_predicate : public std::binary_function {
+struct binary_counting_predicate {
 public:
+typedef Arg1 first_argument_type;
+typedef Arg2 second_argument_type;
+typedef bool result_type;
 
 binary_counting_predicate ( Predicate p ) : p_(p), count_(0) {}
 ~binary_counting_predicate() {}
Index: test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
+++ test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
@@ -16,27 +16,42 @@
 #include 
 #include 
 
+template 
+struct my_unary_function
+{ // 

r310436 - [AST] Move visibility computations into a class; NFC

2017-08-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Aug  8 21:02:49 2017
New Revision: 310436

URL: http://llvm.org/viewvc/llvm-project?rev=310436=rev
Log:
[AST] Move visibility computations into a class; NFC

This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
is to cache decl visibility/linkage for the duration of each
visibility+linkage query.

The simplest way I can see to do this is to put the visibility
calculation code that needs to (transitively) access this cache into a
class, which is what this patch does. Actual caching will come in patch
2. (Another way would be to keep the cache in ASTContext + manually
invalidate it or something, but that felt way too subtle to me.)

Caching visibility results across multiple queries seems a bit tricky,
since the user can add visibility attributes ~whenever they want, and
these attributes can apparently have far-reaching effects (e.g. class
visibility extends to its members, ...). Because a cache that's dropped
at the end of each top-level query seems to work nearly as well and
doesn't require any eviction logic, I opted for that design.

Added:
cfe/trunk/lib/AST/Linkage.h
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=310436=310435=310436=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 21:02:49 2017
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "clang/AST/Decl.h"
+#include "Linkage.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
@@ -99,38 +100,6 @@ TranslationUnitDecl::TranslationUnitDecl
 // and 'matcher' is a type only matters when looking for attributes
 // and settings from the immediate context.
 
-const static unsigned IgnoreExplicitVisibilityBit = 2;
-const static unsigned IgnoreAllVisibilityBit = 4;
-
-/// Kinds of LV computation.  The linkage side of the computation is
-/// always the same, but different things can change how visibility is
-/// computed.
-enum LVComputationKind {
-  /// Do an LV computation for, ultimately, a type.
-  /// Visibility may be restricted by type visibility settings and
-  /// the visibility of template arguments.
-  LVForType = NamedDecl::VisibilityForType,
-
-  /// Do an LV computation for, ultimately, a non-type declaration.
-  /// Visibility may be restricted by value visibility settings and
-  /// the visibility of template arguments.
-  LVForValue = NamedDecl::VisibilityForValue,
-
-  /// Do an LV computation for, ultimately, a type that already has
-  /// some sort of explicit visibility.  Visibility may only be
-  /// restricted by the visibility of template arguments.
-  LVForExplicitType = (LVForType | IgnoreExplicitVisibilityBit),
-
-  /// Do an LV computation for, ultimately, a non-type declaration
-  /// that already has some sort of explicit visibility.  Visibility
-  /// may only be restricted by the visibility of template arguments.
-  LVForExplicitValue = (LVForValue | IgnoreExplicitVisibilityBit),
-
-  /// Do an LV computation when we only care about the linkage.
-  LVForLinkageOnly =
-  LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
-};
-
 /// Does this computation kind permit us to consider additional
 /// visibility settings from attributes and the like?
 static bool hasExplicitVisibilityAlready(LVComputationKind computation) {
@@ -219,8 +188,8 @@ static Optional getVisibilit
   return None;
 }
 
-static LinkageInfo
-getLVForType(const Type , LVComputationKind computation) {
+LinkageInfo LinkageComputer::getLVForType(const Type ,
+  LVComputationKind computation) {
   if (computation == LVForLinkageOnly)
 return LinkageInfo(T.getLinkage(), DefaultVisibility, true);
   return T.getLinkageAndVisibility();
@@ -229,9 +198,8 @@ getLVForType(const Type , LVComputatio
 /// \brief Get the most restrictive linkage for the types in the given
 /// template parameter list.  For visibility purposes, template
 /// parameters are part of the signature of a template.
-static LinkageInfo
-getLVForTemplateParameterList(const TemplateParameterList *Params,
-  LVComputationKind computation) {
+LinkageInfo LinkageComputer::getLVForTemplateParameterList(
+const TemplateParameterList *Params, LVComputationKind computation) {
   LinkageInfo LV;
   for (const NamedDecl *P : *Params) {
 // Template type parameters are the most common and never
@@ -283,10 +251,6 @@ getLVForTemplateParameterList(const Temp
   return LV;
 }
 
-/// getLVForDecl - Get the linkage and visibility for the given declaration.
-static LinkageInfo getLVForDecl(const NamedDecl *D,
-LVComputationKind computation);
-
 static const Decl 

[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-08 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Nice work! This looks good, with some nits and testing comments inline. Have 
you run this on real code? What kind of false positives do you see?




Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:1853
+
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+void deriveAllocLocation(CheckerContext , SymbolRef sym);

Let's dispense with tradition and add some doxygen comments describing what 
these methods do.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2442
 
+  const DeclRegion *Region = dyn_cast(sym->getOriginRegion());
+  if (Region) {

LLVM style says to use `auto *` here rather than repeating the name of the type 
twice.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2479
+  AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
+  // assert(AllocStmt && "Cannot find allocation statement");
+

If you don't want this assertion, you should remove it rather than comment it 
out.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2524
+deriveParamLocation(Ctx, sym);
+
+  createDescription(Ctx, GCEnabled, IncludeAllocationLine);

I'm worried that in the future it would be possible to  reach createDescription 
without the Location, UniqueingLocation, and UniqueingDecl being filled in. Can 
you please add an assertion for this in createDescription().



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2683
 
+  DefaultBool PerformCalleeSideParameterChecking;
+

malhar1995 wrote:
> This might be used in the future in case callee side parameter checking is 
> added for Core Foundation and Objective-C objects.
Let's not add this if it is not used in the code.. You should either use this 
to control the checking for your generalized case or remove it.



Comment at: test/Analysis/retain-release-inline.m:305
 
+void 
callee_side_parameter_checking_leak(__attribute__((annotate("rc_ownership_consumed")))
 isl_basic_map *bmap) { // expected-warning {{Potential leak}}
+}

Please include the entire diagnostic text in the expected-warning{{}}. This 
will guarantee that future changes to the checker don't change it unexpectedly.



Comment at: test/Analysis/retain-release-inline.m:306
+void 
callee_side_parameter_checking_leak(__attribute__((annotate("rc_ownership_consumed")))
 isl_basic_map *bmap) { // expected-warning {{Potential leak}}
+}
+

I'd like to see some more tests. For example, you should get a warning if you 
set the parameter to something else; also if you return it.

Do you have a test checking for that you don't warn when a consumed parameter 
is correctly released?


Repository:
  rL LLVM

https://reviews.llvm.org/D36441



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


[PATCH] D36501: add flag to undo ABI change in r310401

2017-08-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
Herald added a subscriber: sanjoy.

This patch adds a flag `-fpass-indirect-ignore-move` that can be used to undo 
the ABI change in r310401, reverting Clang to its prior C++ ABI for pass/return 
by value of class types affected by that change.

This flag is enabled by default for PS4.

Perhaps we should consider adding a "clang ABI version" flag for this kind of 
thing, rather than flags for the individual settings? There are a collection of 
other ABI changes that a PS4 triple currently turns off in similar ad-hoc ways, 
and it would seem reasonable to have a more organized and disciplined way of 
handling them.


Repository:
  rL LLVM

https://reviews.llvm.org/D36501

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/uncopyable-args.cpp
  test/Driver/flags.c
  test/Driver/ps4-cpu-defaults.cpp

Index: test/Driver/ps4-cpu-defaults.cpp
===
--- test/Driver/ps4-cpu-defaults.cpp
+++ test/Driver/ps4-cpu-defaults.cpp
@@ -3,4 +3,5 @@
 
 // RUN: %clang -target x86_64-scei-ps4 -c %s -### 2>&1 | FileCheck %s
 // CHECK: "-target-cpu" "btver2"
+// CHECK: "-fpass-indirect-ignore-move"
 // CHECK-NOT: exceptions
Index: test/Driver/flags.c
===
--- test/Driver/flags.c
+++ test/Driver/flags.c
@@ -24,3 +24,12 @@
 
 // RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float -mimplicit-float %s 2>&1 | FileCheck -check-prefix=TEST8 %s
 // TEST8-NOT: "-no-implicit-float"
+
+// RUN: %clang -target x86_64-linux-gnu -### -c -fpass-indirect-ignore-move %s 2>&1 | FileCheck -check-prefix=TEST9 %s
+// RUN: %clang -target x86_64-scei-ps4 -### -c %s 2>&1 | FileCheck -check-prefix=TEST9 %s
+// TEST9: "-fpass-indirect-ignore-move"
+
+// RUN: %clang -target x86_64-linux-gnu -### -c -fno-pass-indirect-ignore-move %s 2>&1 | FileCheck -check-prefix=TEST10 %s
+// RUN: %clang -target x86_64-scei-ps4 -### -c -fno-pass-indirect-ignore-move %s 2>&1 | FileCheck -check-prefix=TEST10 %s
+// RUN: %clang -target x86_64-linux-gnu -### -c %s 2>&1 | FileCheck -check-prefix=TEST10 %s
+// TEST10-NOT: "-fpass-indirect-ignore-move"
Index: test/CodeGenCXX/uncopyable-args.cpp
===
--- test/CodeGenCXX/uncopyable-args.cpp
+++ test/CodeGenCXX/uncopyable-args.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=NEWABI
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -fpass-indirect-ignore-move -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=OLDABI
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=18 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-18
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=19 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-19
 
@@ -56,8 +57,10 @@
 // CHECK-LABEL: define void @_ZN9move_ctor3barEv()
 // CHECK: call void @_Z{{.*}}C1Ev(
 // CHECK-NOT: call
-// CHECK: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
-// CHECK-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
+// NEWABI: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
+// OLDABI: call void @_ZN9move_ctor3fooENS_1AE(i8* %{{.*}})
+// NEWABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
+// OLDABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(i8*)
 
 // WIN64-LABEL: declare void @"\01?foo@move_ctor@@YAXUA@1@@Z"(%"struct.move_ctor::A"*)
 }
@@ -76,8 +79,10 @@
 // CHECK-LABEL: define void @_ZN11all_deleted3barEv()
 // CHECK: call void @_Z{{.*}}C1Ev(
 // CHECK-NOT: call
-// CHECK: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
-// CHECK-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"*)
+// NEWABI: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
+// OLDABI: call void @_ZN11all_deleted3fooENS_1AE(i8* %{{.*}})
+// NEWABI-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"*)
+// OLDABI-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(i8*)
 
 // WIN64-LABEL: declare void @"\01?foo@all_deleted@@YAXUA@1@@Z"(%"struct.all_deleted::A"*)
 }
@@ -95,8 +100,10 @@
 // CHECK-LABEL: define void @_ZN18implicitly_deleted3barEv()
 // CHECK: call void @_Z{{.*}}C1Ev(
 // CHECK-NOT: call
-// CHECK: call void @_ZN18implicitly_deleted3fooENS_1AE(%"struct.implicitly_deleted::A"* %{{.*}})
-// CHECK-LABEL: declare void 

r310435 - Allow operator delete to be an invalid Decl.

2017-08-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Aug  8 19:03:59 2017
New Revision: 310435

URL: http://llvm.org/viewvc/llvm-project?rev=310435=rev
Log:
Allow operator delete to be an invalid Decl.

Do not discard invalid Decl when searching for the operator delete function.
The lookup for this function always expects to find a result, so sometimes the
invalid Decl is the only choice possible.  This fixes PR34109.

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=310435=310434=310435=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug  8 19:03:59 2017
@@ -1378,9 +1378,6 @@ Sema::BuildCXXTypeConstructExpr(TypeSour
 /// \brief Determine whether the given function is a non-placement
 /// deallocation function.
 static bool isNonPlacementDeallocationFunction(Sema , FunctionDecl *FD) {
-  if (FD->isInvalidDecl())
-return false;
-
   if (CXXMethodDecl *Method = dyn_cast(FD))
 return Method->isUsualDeallocationFunction();
 

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=310435=310434=310435=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Aug  8 19:03:59 2017
@@ -504,6 +504,20 @@ struct S {
 int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
 }
 
+class PR34109_class {
+  PR34109_class() {}
+  virtual ~PR34109_class() {}
+};
+
+void operator delete(void *) throw();
+// expected-note@-1 {{previous declaration is here}}
+__declspec(dllexport) void operator delete(void *) throw();
+// expected-error@-1  {{redeclaration of 'operator delete' cannot add 
'dllexport' attribute}}
+
+void PR34109(int* a) {
+  delete a;
+}
+
 #elif TEST2
 
 // Check that __unaligned is not recognized if MS extensions are not enabled


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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-08 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

I like this change in general.  Dinkumware has been using introsort for 10+ 
years, so I'm a bit surprised that libc++ wasn't already.




Comment at: include/algorithm:4208
+
+  // Threshold(or depth limit) for introsort is taken to be 2*log2(size)
+  typedef typename iterator_traits<_RandomAccessIterator>::difference_type 
difference_type;

This comment says basically the same thing as the code.  The comment would be 
more useful if it said why 2*log2(size) is used.


https://reviews.llvm.org/D36423



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-08 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

Those are interesting (and useful) results... but they don't look like they 
came from the same algorithms.bench.cpp that I'm looking at...
https://github.com/llvm-mirror/libcxx/blob/master/benchmarks/algorithms.bench.cpp

That being said, the benchmark there only does 1k elements at a time, and 
doesn't have the worst case for quick sort like yours does.  Adding to the 
upstream algorithms.bench.cpp seems valuable.


https://reviews.llvm.org/D36423



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

I have just pushed a fix, revision 310433.


https://reviews.llvm.org/D29654



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


[PATCH] D36349: [CMake] Build sanitized C++ runtimes for Fuchsia

2017-08-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 110311.

Repository:
  rL LLVM

https://reviews.llvm.org/D36349

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -33,24 +33,33 @@
 endforeach()
 
 if(NOT APPLE)
-  list(APPEND LLVM_BUILTIN_TARGETS "default")
+  set(LLVM_BUILTIN_TARGETS "default;${LLVM_BUILTIN_TARGETS}" CACHE STRING "" 
FORCE)
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 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_UNIX 1 CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
+
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX 
"${target}-fuchsia/" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_LIBDIR_SUFFIX "/asan" 
CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_LIBDIR_SUFFIX "/asan" CACHE 
STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_LIBDIR_SUFFIX "/asan" CACHE 
STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_LIBDIR_SUFFIX "/asan" CACHE 
STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -33,24 +33,33 @@
 endforeach()
 
 if(NOT APPLE)
-  list(APPEND LLVM_BUILTIN_TARGETS "default")
+  set(LLVM_BUILTIN_TARGETS "default;${LLVM_BUILTIN_TARGETS}" CACHE STRING "" FORCE)
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
 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_UNIX 1 CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
+
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX "${target}-fuchsia/" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_LIBDIR_SUFFIX "/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBUNWIND_LIBDIR_SUFFIX "/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_LIBDIR_SUFFIX "/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_LIBDIR_SUFFIX "/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.
___
cfe-commits mailing list

[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7571
+
+  // XXX: Should this be i64 instead, and should the limit increase?
+  llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());

b-sumner wrote:
> arsenm wrote:
> > b-sumner wrote:
> > > What we do here depends on NumRegsLeft when the block is entered and 
> > > NumRegs.  If NumRegsLeft >= NumRegs then we just need 2 adjacent 
> > > registers.  If NumRegsLeft == 1 and NumRegs == 2, then do we pass the low 
> > > half in a register and the upper half in memory, or all of it in memory?  
> > > Anyway, I think NumRegsLeft shouldn't be updated until we know it's OK, 
> > > and then we don't need the min().
> > It's all one or the other. Whether it's passed in memory or not is really 
> > determined in codegen based on the actual register limit (which is also 
> > higher than the 16 used here, at least for now). Here selects whether to 
> > use byval or not. The ABI is slightly different whether it's passed as 
> > byval or as too many registers. I'm not sure it ever really makes sense to 
> > use byval yet, so I wasn't trying to be very precise here.
> Thanks.  Just one more question.  If we use memory for an argument, are all 
> following arguments required to use memory?  In that case, the min() is 
> correct.  But if a following argument could use a register, then the amount 
> to subtract is NumRegs <= NumRegsLeft ? NumRegs : 0.
For what this does now, any large aggregates after NumRegsLeft == 0 will use 
byval. Simple types like int or small structs will still be directly passed 
arguments.


https://reviews.llvm.org/D36171



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


[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-08-08 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

In https://reviews.llvm.org/D36431#835165, @nemanjai wrote:

> This patch appears to be perfectly fine. However, it triggers a large number 
> of warnings. Namely, there's a large number of `warning: ISO C forbids an 
> empty translation unit [-Wpedantic]` warnings produced.


What config are the buildbots using? I don't see these warnings in default or 
RELEASE style builds. I'm happy to fix them though.

> The reason is that all the code in the file is wrapped with an `if 
> !_ARCH_PPC` macro. I assume that we do not want `compiler_rt` to expose 
> builtins that assume an 80-bit `long double` (which is the behaviour we get 
> now). So it seems to me that files that define such builtins should simply be 
> removed from the `powerpc64_SOURCES` and they should `#error` on PPC.

I think it is better to mark plain powerpc (32) as unsupported in the 
testsuite, for similar reasons to marking powerpc64 unsupported. Whoever 
originally #ifdefed these did it in a way that is misleading.  See the comments 
on https://reviews.llvm.org/D36249 for my reasoning.

> Also, I'm getting lots of warnings from `compiler-rt/lib/builtins/atomic.c` 
> such as `warning: implicit declaration of function '__c11_atomic_fetch_or' 
> [-Wimplicit-function-declaration]`. It would appear that the `__c11_atomic_*` 
> family of builtins isn't exposed by the build compiler (and should presumably 
> be declared in a header if file is being built with a compiler that doesn't 
> expose those).

What config do the buildbots use? I don't see these errors with DEBUG or 
RELEASE. I'm happy to fix them regardless, but I'd like to be able to 
anticipate these problems.


https://reviews.llvm.org/D36431



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


r310426 - Revert "Lexer: always allow imaginary constants in GNU mode."

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 16:17:51 2017
New Revision: 310426

URL: http://llvm.org/viewvc/llvm-project?rev=310426=rev
Log:
Revert "Lexer: always allow imaginary constants in GNU mode."

This reverts r310423. It was committed by mistake, I intended to commit the
improved diagnostics for implicit conversions instead.

Removed:
cfe/trunk/test/Lexer/imaginary-constants.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/SemaCXX/constexpr-printing.cpp
cfe/trunk/unittests/AST/DeclTest.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Aug  8 16:17:51 2017
@@ -659,7 +659,7 @@ NumericLiteralParser::NumericLiteralPars
 }
   }
   // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && !PP.getLangOpts().GNUMode)
+  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
 break;
   // fall through.
 case 'j':

Removed: cfe/trunk/test/Lexer/imaginary-constants.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/imaginary-constants.cpp?rev=310425=auto
==
--- cfe/trunk/test/Lexer/imaginary-constants.cpp (original)
+++ cfe/trunk/test/Lexer/imaginary-constants.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++98 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++11 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++14 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -DHAVE_IMAGINARY=0
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -DHAVE_IMAGINARY=0
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DHAVE_IMAGINARY=0 
-DCXX14=1
-
-// Imaginary constants are a GNU extension that became problematic when C++14
-// defined its own versions. Until then they're supported even in
-// standards-compliant mode.
-#if HAVE_IMAGINARY
-// expected-no-diagnostics
-#elif CXX14
-// expected-error@+9 {{no matching literal operator for call to 'operator""i' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
-// expected-error@+9 {{no matching literal operator for call to 'operator""il' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
-// expected-error@+9 {{invalid suffix 'ill' on integer constant}}
-#else
-// expected-error@+5 {{invalid suffix 'i' on integer constant}}
-// expected-error@+5 {{invalid suffix 'il' on integer constant}}
-// expected-error@+7 {{invalid suffix 'ill' on integer constant}}
-#endif
-
-_Complex int val1 = 2i;
-_Complex long val2 = 2il;
-_Complex long long val3 = 2ill;

Modified: cfe/trunk/test/SemaCXX/constexpr-printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-printing.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-printing.cpp Tue Aug  8 16:17:51 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple 
x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S );

Modified: cfe/trunk/unittests/AST/DeclTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclTest.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/unittests/AST/DeclTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclTest.cpp Tue Aug  8 16:17:51 2017
@@ -26,7 +26,7 @@ TEST(Decl, CleansUpAPValues) {
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector Args(1, "-std=gnu++11");
+  std::vector Args(1, "-std=c++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
   Factory->create(),


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


r310427 - Sema: disable implicit conversion from _Complex to real types in C++.

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 16:18:05 2017
New Revision: 310427

URL: http://llvm.org/viewvc/llvm-project?rev=310427=rev
Log:
Sema: disable implicit conversion from _Complex to real types in C++.

Converting a _Complex type to a real one simply discards the imaginary part.
This can easily lead to loss of information so for safety (and GCC
compatibility) this patch disallows that when the conversion would be implicit.

The one exception is bool, which actually compares both real and imaginary
parts and so is safe.

Added:
cfe/trunk/test/SemaCXX/complex-conversion.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
cfe/trunk/test/SemaCXX/complex-overload.cpp
cfe/trunk/test/SemaCXX/integer-overflow.cpp
cfe/trunk/test/SemaCXX/warn-absolute-value.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310427=310426=310427=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug  8 16:18:05 
2017
@@ -3087,6 +3087,8 @@ def warn_impcast_vector_scalar : Warning
 def warn_impcast_complex_scalar : Warning<
   "implicit conversion discards imaginary component: %0 to %1">,
   InGroup, DefaultIgnore;
+def err_impcast_complex_scalar : Error<
+  "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Aug  8 16:18:05 2017
@@ -9431,10 +9431,13 @@ void CheckImplicitConversion(Sema , Ex
   // Strip complex types.
   if (isa(Source)) {
 if (!isa(Target)) {
-  if (S.SourceMgr.isInSystemMacro(CC))
+  if (S.SourceMgr.isInSystemMacro(CC) || Target->isBooleanType())
 return;
 
-  return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_complex_scalar);
+  return DiagnoseImpCast(S, E, T, CC,
+ S.getLangOpts().CPlusPlus
+ ? diag::err_impcast_complex_scalar
+ : diag::warn_impcast_complex_scalar);
 }
 
 Source = cast(Source)->getElementType().getTypePtr();

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug  8 16:18:05 2017
@@ -7530,6 +7530,12 @@ Sema::CheckAssignmentConstraints(QualTyp
   if (unsupportedTypeConversion(*this, LHSType, RHSType))
 return Incompatible;
 
+  // Disallow assigning a _Complex to a real type in C++ mode since it simply
+  // discards the imaginary part.
+  if (getLangOpts().CPlusPlus && RHSType->getAs() &&
+  !LHSType->getAs())
+return Incompatible;
+
   // Arithmetic conversions.
   if (LHSType->isArithmeticType() && RHSType->isArithmeticType() &&
   !(getLangOpts().CPlusPlus && LHSType->isEnumeralType())) {

Modified: cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stmtexpr.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/test/CodeGenCXX/stmtexpr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stmtexpr.cpp Tue Aug  8 16:18:05 2017
@@ -173,7 +173,7 @@ extern "C" int cleanup_exit_lvalue_local
 _Complex float bar_complex(A, int);
 extern "C" int cleanup_exit_complex(bool b) {
   _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
-  return v;
+  return (float)v;
 }
 
 // CHECK-LABEL: define{{.*}} i32 @cleanup_exit_complex({{.*}})

Modified: cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp Tue Aug  8 16:18:05 2017
@@ -611,50 +611,6 @@ int main() {
 // CHECK: store i8 [[DESIRED_I8]], i8* @{{.+}},
 #pragma omp atomic capture
   {bx = civ - bx; bv = bx;}
-// CHECK: 

[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-08 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

In https://reviews.llvm.org/D34158#836026, @jyknight wrote:

> In https://reviews.llvm.org/D34158#827178, @joerg wrote:
>
> > I had a long discussion with James about this on IRC without reaching a 
> > clear consensus. I consider forcing this behavior on all targets to be a 
> > major bug. It should be opt-in and opt-in only:
> >
> > (1) The header name is not mandated by any standard. It is not in any 
> > namespace generally accepted as implementation-owned.
>
>
> This is a point. I didn't think it was a big deal, but if you want to argue a 
> different name should be used, that's a reasonable argument.
>  If we can get some agreement amongst other libc vendors to use some more 
> agreeable alternative name, and keep a fallback on linux-only for the 
> "stdc-predef.h" name, I'd consider that as a great success.


Perhaps not a big deal yet, but as I have recently described stdc-predef.h idea 
to Oracle Solaris libc/headers/compilers folks, they generally welcomed the 
idea..

>> (3) ...Most other platforms have a single canonical libc, libm and 
>> libpthread implementation and can as such directly define all the relevant 
>> macros directly in the driver.
> 
> I don't think this is accurate. There's many platforms out there, and for 
> almost none of them do we have exact knowledge of the features of the libc 
> encoded into the compiler.

Solaris is a direct example of that...


https://reviews.llvm.org/D34158



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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-08 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In https://reviews.llvm.org/D34158#827178, @joerg wrote:

> I had a long discussion with James about this on IRC without reaching a clear 
> consensus. I consider forcing this behavior on all targets to be a major bug. 
> It should be opt-in and opt-in only:
>
> (1) The header name is not mandated by any standard. It is not in any 
> namespace generally accepted as implementation-owned.


This is a point. I didn't think it was a big deal, but if you want to argue a 
different name should be used, that's a reasonable argument. If we can get some 
agreement amongst other libc vendors to use some more agreeable alternative 
name, and keep a fallback on linux-only for the "stdc-predef.h" name, I'd 
consider that as a great success.

> (2) It adds magic behavior that can make debugging more difficult. Partially 
> preprocessed sources for example could be compiled with plain -c before, now 
> they need a different command line.

If this is a problem, making it be Linux-only does _nothing_ to solve it. But I 
don't actually see how this is a substantively new problem? Compiling with 
plain -c before would get #defines for those predefined macros that the 
compiler sets, even though you may not have wanted those. Is this fundamentally 
different?

> (3) It seems to me that the GNU userland (and maybe Windows) is the exception 
> to a well integrated tool chain. Most other platforms have a single canonical 
> libc, libm and libpthread implementation and can as such directly define all 
> the relevant macros directly in the driver.

I don't think this is accurate. There's many platforms out there, and for 
almost none of them do we have exact knowledge of the features of the libc 
encoded into the compiler. I'd note that not only do you need this for every 
(OS, libc) combination, you'd need it for every (OS, libc-VERSION) combination.

> Given that many of the macros involved are already reflected by the compiler 
> behavior anyway, they can't be decoupled. I.e. the questionable concept of 
> locale-independent wchar_t is already hard-coded in the front end as soon as 
> any long character literals are used.

AFAICT, this example is not actually the case. The frontend only needs to know 
*a* valid encoding for wide-character literals in some implementation-defined 
locale (for example, it might always emit them as unicode codepoints, as clang 
does).  Standard says: "the array elements [...] are initialized with the 
sequence of wide characters corresponding to the multibyte character sequence, 
as defined by the mbstowcs function with an implementation defined current 
locale."

On the other hand, I believe the intent of this macro is to guarantee that _no 
matter what_ the locale is, that a U+0100 character (say, translated with 
mbrtowc from the locale encoding) gets represented as 0x100.

Thus, it's "fine" for the frontend to always emit wchar_t literals as unicode, 
yet, the libc may sometimes use an arbitrary different internal encoding, 
depending on the locale used at runtime. (Obviously using wide character 
literals with such a libc would be a poor user experience, and such a libc 
probably ought to reconsider its choices, but that's a different discussion.)

> As such, please move the command line additions back into the target-specific 
> files for targets that actually want to get this behavior.

Without even a suggestion of a better solution to use for other targets, I find 
it is to be a real shame to push for this to be linux-only, and leave everyone 
else hanging. I find that that _most_ of these defines are effectively library 
decisions. I further would claim that these are likely to vary over the 
lifetime of even a single libc, and that as such we would be better served by 
allowing the libc to set them directly, rather than encoding it into the 
compiler.

TTBOMK, no targets except linux/glibc/gcc actually comply with this part of the 
C99/C11 standard today, and so this feature would be useful to have available 
across all targets.

(I very much dislike that the C standard has started adding all these new 
predefined macros, instead of exposing them from a header, but there's not much 
to be done about that...)

Going through the various macros:
`__STDC_ISO_10646__`:
As discussed above, this is effectively entirely up to the libc. The compiler 
only need support one possible encoding for wchar_t, and clang always chooses 
unicode. But it can't define this because the libc might use others as well.

`__STDC_MB_MIGHT_NEQ_WC__`:
As with `__STDC_ISO_10646__`, this is up to the libc not the compiler. (At 
least, I think so... I note that clang currently sets this for freebsd, with a 
FIXME next to it saying it's only intended to apply to wide character literals. 
I don't see that the standard says that, however, so, IMO, having it set for 
freebsd was and is correct).

`__STDC_UTF16__`, `__STDC_UTF32__`:
Again, analogous to `__STDC_ISO_10646__`, except dealing with 

[PATCH] D36492: [RFC][time-report] Add preprocessor timer

2017-08-08 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

`gcc -ftime-report` provides a breakdown of how much time GCC spends
doing preprocessing, parsing, template instantiation, and more:

  g++ -ftime-report foo.cpp
  Execution times (seconds)
   phase setup :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.00 ( 0%) 
wall1414 kB ( 8%) ggc
   phase parsing   :   0.10 (100%) usr   0.08 (100%) sys   0.18 (95%) 
wall   15955 kB (88%) ggc
   phase opt and generate  :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 ( 5%) 
wall 489 kB ( 3%) ggc
   |name lookup:   0.00 ( 0%) usr   0.00 ( 0%) sys   0.04 (21%) 
wall1054 kB ( 6%) ggc
   preprocessing   :   0.02 (20%) usr   0.01 (13%) sys   0.03 (16%) 
wall 896 kB ( 5%) ggc
   parser (global) :   0.00 ( 0%) usr   0.03 (38%) sys   0.04 (21%) 
wall6603 kB (37%) ggc
   parser struct body  :   0.04 (40%) usr   0.00 ( 0%) sys   0.04 (21%) 
wall2791 kB (15%) ggc
   parser enumerator list  :   0.01 (10%) usr   0.00 ( 0%) sys   0.00 ( 0%) 
wall  44 kB ( 0%) ggc
   parser function body:   0.00 ( 0%) usr   0.02 (25%) sys   0.02 (11%) 
wall1047 kB ( 6%) ggc
   parser inl. meth. body  :   0.01 (10%) usr   0.01 (13%) sys   0.03 (16%) 
wall1093 kB ( 6%) ggc
   template instantiation  :   0.02 (20%) usr   0.01 (12%) sys   0.02 (11%) 
wall3280 kB (18%) ggc
   LRA non-specific:   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 ( 5%) 
wall   0 kB ( 0%) ggc
   TOTAL :   0.10 0.08 0.19 
 18028 kB

`clang -ftime-report` gives an incredibly detailed breakdown of how long
each LLVM pass takes, but when it comes to front-end times, only
provides the generic "Clang front-end timer", or "Code Generation Time".
Here's an example of its output:
https://gist.github.com/modocache/d74833818107ed50d11387a5a4e3fb72

As a result, when attempting to diagnose slow compile times with Clang,
users are forced to use external profiling tools in order to determine
whether the bottleneck is in parsing, template instantiation, or LLVM.

This diff adds the first of several timers that aim to match
`gcc -ftime-report`: a timer that outputs the amount of time spent in the Clang
preprocessor.

I'm curious whether Clang maintainers think this timer is useful, and whether
there's interest in adding more timers, especially around the Clang parser.


https://reviews.llvm.org/D36492

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/CompilerInstance.cpp
  lib/Lex/PPDirectives.cpp
  lib/Lex/Preprocessor.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -88,6 +88,7 @@
   CurDirLookup(nullptr), CurLexerKind(CLK_Lexer),
   CurLexerSubmodule(nullptr), Callbacks(nullptr),
   CurSubmoduleState(), MacroArgCache(nullptr),
+  PreprocessingTimer("preprocessor", "Preprocessing"),
   Record(nullptr), MIChainHead(nullptr) {
   OwnsHeaderSearch = OwnsHeaders;
   
@@ -656,6 +657,8 @@
 
   IdentifierInfo  = *Identifier.getIdentifierInfo();
 
+  llvm::TimeRegion(PPOpts->ShowTimers ?  : nullptr);
+
   // If the information about this identifier is out of date, update it from
   // the external source.
   // We have to treat __VA_ARGS__ in a special way, since it gets
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -871,6 +871,8 @@
 /// lexer/preprocessor state, and advances the lexer(s) so that the next token
 /// read is the correct one.
 void Preprocessor::HandleDirective(Token ) {
+  llvm::TimeRegion(PPOpts->ShowTimers ?  : nullptr);
+
   // FIXME: Traditional: # with whitespace before it not recognized by K?
 
   // We just parsed a # character at the start of a line, so we're in directive
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -367,7 +367,9 @@
 // Preprocessor
 
 void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
-  const PreprocessorOptions  = getPreprocessorOpts();
+  PreprocessorOptions  = getPreprocessorOpts();
+  if (getFrontendOpts().ShowTimers)
+PPOpts.ShowTimers = true;
 
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = nullptr;
Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -127,7 +127,11 @@
   /// manipulation of the compiler invocation object, in cases where the 
   /// compiler invocation and its buffers will be reused.
   bool RetainRemappedFileBuffers;
-  
+
+  /// \brief Whether to measure the amount of time spent in code related to
+  /// 

[PATCH] D36491: clang-format: [JS] detect ASI after closing parens.

2017-08-08 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

A closing parenthesis followed by a declaration or statement should always 
terminate the current statement.


https://reviews.llvm.org/D36491

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1059,6 +1059,10 @@
"  readonly ratherLongField = 1;\n"
"}",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("const x = (5 + 9)\n"
+   "const y = 3\n",
+   "const x = (   5 +9)\n"
+   "const y = 3\n");
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -853,7 +853,8 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+  if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
+  isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1059,6 +1059,10 @@
"  readonly ratherLongField = 1;\n"
"}",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("const x = (5 + 9)\n"
+   "const y = 3\n",
+   "const x = (   5 +9)\n"
+   "const y = 3\n");
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -853,7 +853,8 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+  if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
+  isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36450: [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/Sema/SemaStmtAsm.cpp:702-705
+  // MS InlineAsm often uses struct pointer aliases as a base
+  const QualType QT = TD->getUnderlyingType();
+  RT = isa(QT) ? QT->getPointeeType()->getAs() :
+  QT->getAs();

This would probably be simpler as:
  QualType Ty = TD->getUnderlyingType();
  if (const auto *PT = Ty->getAs())
Ty = PT->getPointeeType();
  RT = Ty->getAsRecordType();
... to avoid repeating getAs().


Repository:
  rL LLVM

https://reviews.llvm.org/D36450



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-08 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added a comment.

In https://reviews.llvm.org/D35955#835439, @klimek wrote:

> I think if we need this info, we can just make it count down to -1 again (or, 
> but that's isomorphic, let it run from 0 and make sure we never index into 
> the data structures at 0 :)


Should I do one of these things? Let me know how you'd like me to implement 
this.


https://reviews.llvm.org/D35955



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


r310423 - Lexer: always allow imaginary constants in GNU mode.

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 15:03:54 2017
New Revision: 310423

URL: http://llvm.org/viewvc/llvm-project?rev=310423=rev
Log:
Lexer: always allow imaginary constants in GNU mode.

Added:
cfe/trunk/test/Lexer/imaginary-constants.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/SemaCXX/constexpr-printing.cpp
cfe/trunk/unittests/AST/DeclTest.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Aug  8 15:03:54 2017
@@ -659,7 +659,7 @@ NumericLiteralParser::NumericLiteralPars
 }
   }
   // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
+  if (*s == 'i' && !PP.getLangOpts().GNUMode)
 break;
   // fall through.
 case 'j':

Added: cfe/trunk/test/Lexer/imaginary-constants.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/imaginary-constants.cpp?rev=310423=auto
==
--- cfe/trunk/test/Lexer/imaginary-constants.cpp (added)
+++ cfe/trunk/test/Lexer/imaginary-constants.cpp Tue Aug  8 15:03:54 2017
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++98 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++11 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++14 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DHAVE_IMAGINARY=0 
-DCXX14=1
+
+// Imaginary constants are a GNU extension that became problematic when C++14
+// defined its own versions. Until then they're supported even in
+// standards-compliant mode.
+#if HAVE_IMAGINARY
+// expected-no-diagnostics
+#elif CXX14
+// expected-error@+9 {{no matching literal operator for call to 'operator""i' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
+// expected-error@+9 {{no matching literal operator for call to 'operator""il' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
+// expected-error@+9 {{invalid suffix 'ill' on integer constant}}
+#else
+// expected-error@+5 {{invalid suffix 'i' on integer constant}}
+// expected-error@+5 {{invalid suffix 'il' on integer constant}}
+// expected-error@+7 {{invalid suffix 'ill' on integer constant}}
+#endif
+
+_Complex int val1 = 2i;
+_Complex long val2 = 2il;
+_Complex long long val3 = 2ill;

Modified: cfe/trunk/test/SemaCXX/constexpr-printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-printing.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-printing.cpp Tue Aug  8 15:03:54 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple 
x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S );

Modified: cfe/trunk/unittests/AST/DeclTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclTest.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/unittests/AST/DeclTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclTest.cpp Tue Aug  8 15:03:54 2017
@@ -26,7 +26,7 @@ TEST(Decl, CleansUpAPValues) {
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector Args(1, "-std=c++11");
+  std::vector Args(1, "-std=gnu++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
   Factory->create(),


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


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7571
+
+  // XXX: Should this be i64 instead, and should the limit increase?
+  llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());

arsenm wrote:
> b-sumner wrote:
> > What we do here depends on NumRegsLeft when the block is entered and 
> > NumRegs.  If NumRegsLeft >= NumRegs then we just need 2 adjacent registers. 
> >  If NumRegsLeft == 1 and NumRegs == 2, then do we pass the low half in a 
> > register and the upper half in memory, or all of it in memory?  Anyway, I 
> > think NumRegsLeft shouldn't be updated until we know it's OK, and then we 
> > don't need the min().
> It's all one or the other. Whether it's passed in memory or not is really 
> determined in codegen based on the actual register limit (which is also 
> higher than the 16 used here, at least for now). Here selects whether to use 
> byval or not. The ABI is slightly different whether it's passed as byval or 
> as too many registers. I'm not sure it ever really makes sense to use byval 
> yet, so I wasn't trying to be very precise here.
Thanks.  Just one more question.  If we use memory for an argument, are all 
following arguments required to use memory?  In that case, the min() is 
correct.  But if a following argument could use a register, then the amount to 
subtract is NumRegs <= NumRegsLeft ? NumRegs : 0.


https://reviews.llvm.org/D36171



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


[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-08 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: src/cxa_demangle.cpp:1575-1577
-sub_type names;
-template_param_type subs;
-Vector template_param;

dexonsmith wrote:
> - Why not rename `names` as well?
> - Please rename these in a separate prep commit to minimize noise on the 
> final patch.
Sure, r310415.



Comment at: src/cxa_demangle.cpp:1604
+assert(N < PackIndices.size());
+Node **Begin = Subs.begin() + PackIndices[N];
+Node **End = (N + 1 == PackIndices.size())

dexonsmith wrote:
> Should there be some assertion on `Subs.size()` here?  Perhaps, if so, this 
> should be `[PackIndices[N]]`, so that `Subs.operator[]()` handles it for 
> you.  Same below.
We can't use operator[] here because if all we have is an empty parameter pack 
then `[PackIndices[N]]` needs to point the the end() iterator, which is 
out of bounds. The new patch adds an assert though.



Comment at: src/cxa_demangle.cpp:1621-1631
+// Name stack, this is used by the parser to hold temporary names that were
+// parsed. The parser colapses multiple names into new nodes to construct
+// the AST. Once the parser is finished, names.size() == 1.
+PODSmallVector names;
+
+// Substitution table. Itanium supports name substitutions as a means of
+// compression. The string "S42_" refers to the 42nd entry in this table.

dexonsmith wrote:
> How much have you thought about these sizes (32, 32, and 4)?  Any evidence to 
> back up these specific choices?
Yep, 32 is enough for the Subs table/names to never overflow when demangling 
the symbols in LLVM, and 4 seldom overflows TemplateParams. TemplateParams is 
temporary held on the stack in parse_template_args(), so I wanted it to be 
smaller.


https://reviews.llvm.org/D36427



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


[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-08 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 110281.
erik.pilkington marked 14 inline comments as done.
erik.pilkington added a comment.

Address review comments.
Thanks!
Erik


https://reviews.llvm.org/D36427

Files:
  src/cxa_demangle.cpp
  test/unittest_demangle.pass.cpp

Index: test/unittest_demangle.pass.cpp
===
--- /dev/null
+++ test/unittest_demangle.pass.cpp
@@ -0,0 +1,123 @@
+//===--- unittest_demangle.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../src/cxa_demangle.cpp"
+
+using namespace __cxxabiv1;
+
+void testPODSmallVector() {
+  { // {push/pop}_back
+PODSmallVector PSV;
+PSV.push_back(0);
+PSV.push_back(1);
+PSV.push_back(2);
+PSV.push_back(3);
+for (int i = 0; i < 4; ++i)
+  assert(PSV[i] == i);
+PSV.pop_back();
+for (int i = 0; i < 3; ++i)
+  assert(PSV[i] == i);
+PSV.pop_back();
+PSV.pop_back();
+assert(!PSV.empty() && PSV.size() == 1);
+PSV.pop_back();
+assert(PSV.empty() && PSV.size() == 0);
+  }
+
+  {
+PODSmallVector PSV1;
+PSV1.push_back(1);
+PSV1.push_back(2);
+PSV1.push_back(3);
+
+PODSmallVector PSV2;
+std::swap(PSV1, PSV2);
+assert(PSV1.size() == 0);
+assert(PSV2.size() == 3);
+int i = 1;
+for (int x : PSV2) {
+  assert(x == i);
+  ++i;
+}
+assert(i == 4);
+std::swap(PSV1, PSV2);
+assert(PSV1.size() == 3);
+assert(PSV2.size() == 0);
+i = 1;
+for (int x : PSV1) {
+  assert(x == i);
+  ++i;
+}
+assert(i == 4);
+  }
+
+  {
+PODSmallVector PSV1;
+PODSmallVector PSV2;
+PSV1.push_back(0);
+PSV1.push_back(1);
+PSV1.push_back(2);
+assert(PSV1.size() == 3);
+assert(PSV2.size() == 0);
+std::swap(PSV1, PSV2);
+assert(PSV1.size() == 0);
+assert(PSV2.size() == 3);
+int i = 0;
+for (int x : PSV2) {
+  assert(x == i);
+  ++i;
+}
+for (int x : PSV1) {
+  assert(false);
+  (void)x;
+}
+  }
+}
+
+void testSubstitutionTable() {
+  {
+SubstitutionTable<2> Tab;
+
+NameType Names[] = { {"MERP"}, {"MARP"}, {"MAMP"} };
+Tab.pushPack();
+Tab.pushSubstitutionIntoPack([0]);
+Tab.pushSubstitutionIntoPack([1]);
+Tab.pushSubstitutionIntoPack([2]);
+
+int Index = 0;
+for (Node *N : Tab.nthSubstitution(0)) {
+  assert(static_cast(N)->getName() == Names[Index].getName());
+  ++Index;
+}
+assert(Index == 3);
+
+Tab.popPack();
+assert(Tab.empty() && Tab.size() == 0);
+Tab.pushSubstitution([0]);
+Tab.pushSubstitution([1]);
+assert(!Tab.empty() && Tab.size() == 2);
+
+int I = 0;
+for (Node *N : Tab.nthSubstitution(0)) {
+  assert(static_cast(N)->getName() == "MERP");
+  assert(I == 0);
+  ++I;
+}
+for (Node *N : Tab.nthSubstitution(1)) {
+  assert(static_cast(N)->getName() == "MARP");
+  assert(I == 1);
+  ++I;
+}
+  }
+}
+
+int main() {
+  testPODSmallVector();
+  testSubstitutionTable();
+}
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -1407,117 +1407,6 @@
   }
 };
 
-template 
-class arena
-{
-static const std::size_t alignment = 16;
-alignas(alignment) char buf_[N];
-char* ptr_;
-
-std::size_t 
-align_up(std::size_t n) noexcept
-{return (n + (alignment-1)) & ~(alignment-1);}
-
-bool
-pointer_in_buffer(char* p) noexcept
-{return buf_ <= p && p <= buf_ + N;}
-
-public:
-arena() noexcept : ptr_(buf_) {}
-~arena() {ptr_ = nullptr;}
-arena(const arena&) = delete;
-arena& operator=(const arena&) = delete;
-
-char* allocate(std::size_t n);
-void deallocate(char* p, std::size_t n) noexcept;
-
-static constexpr std::size_t size() {return N;}
-std::size_t used() const {return static_cast(ptr_ - buf_);}
-void reset() {ptr_ = buf_;}
-};
-
-template 
-char*
-arena::allocate(std::size_t n)
-{
-n = align_up(n);
-if (static_cast(buf_ + N - ptr_) >= n)
-{
-char* r = ptr_;
-ptr_ += n;
-return r;
-}
-return static_cast(std::malloc(n));
-}
-
-template 
-void
-arena::deallocate(char* p, std::size_t n) noexcept
-{
-if (pointer_in_buffer(p))
-{
-n = align_up(n);
-if (p + n == ptr_)
-ptr_ = p;
-}
-else
-std::free(p);
-}
-
-template 
-class short_alloc
-{
-arena& a_;
-public:
-typedef T value_type;
-
-public:
-template  struct rebind {typedef short_alloc<_Up, N> other;};
-
-

[PATCH] D36487: Emit section information for extern variables.

2017-08-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:2434
+// Emit section information for extern variables.
+if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+  if (const SectionAttr *SA = D->getAttr())

efriedma wrote:
> Why do you specifically check "D->hasExternalStorage() && 
> !D->isThisDeclarationADefinition()", instead of just setting the section 
> unconditionally?
I noticed that you enter GetOrCreateLLVMGlobal( ) whenever the extern variable 
is declared as well as when it is defined. The flow of the program is different 
in each case. When the variable is defined, it also enters 
EmitGlobalVarDefinition( ). There is existing code handling section information 
here. I added the check in GetOrCreateLLVMGlobal( ) so the block gets skipped 
for variable definition, since its already handled elsewhere.


https://reviews.llvm.org/D36487



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


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7386
+  bool isHomogeneousAggregateBaseType(QualType Ty) const override;
+  bool isHomogeneousAggregateSmallEnough(const Type *Base,
+ uint64_t Members) const override;

yaxunl wrote:
> arsenm wrote:
> > yaxunl wrote:
> > > Please add descriptions for the above newly added functions.
> > I prefer not to put descriptions on overrides since they will just be out 
> > of date with the declaration
> Please add descriptions for the non-override functions and data members above.
I've added them to the body



Comment at: lib/CodeGen/TargetInfo.cpp:7571
+
+  // XXX: Should this be i64 instead, and should the limit increase?
+  llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());

b-sumner wrote:
> What we do here depends on NumRegsLeft when the block is entered and NumRegs. 
>  If NumRegsLeft >= NumRegs then we just need 2 adjacent registers.  If 
> NumRegsLeft == 1 and NumRegs == 2, then do we pass the low half in a register 
> and the upper half in memory, or all of it in memory?  Anyway, I think 
> NumRegsLeft shouldn't be updated until we know it's OK, and then we don't 
> need the min().
It's all one or the other. Whether it's passed in memory or not is really 
determined in codegen based on the actual register limit (which is also higher 
than the 16 used here, at least for now). Here selects whether to use byval or 
not. The ABI is slightly different whether it's passed as byval or as too many 
registers. I'm not sure it ever really makes sense to use byval yet, so I 
wasn't trying to be very precise here.


https://reviews.llvm.org/D36171



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


[PATCH] D36487: Emit section information for extern variables.

2017-08-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:2434
+// Emit section information for extern variables.
+if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+  if (const SectionAttr *SA = D->getAttr())

Why do you specifically check "D->hasExternalStorage() && 
!D->isThisDeclarationADefinition()", instead of just setting the section 
unconditionally?


https://reviews.llvm.org/D36487



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


[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

Thanks for review.


Repository:
  rL LLVM

https://reviews.llvm.org/D36208



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


[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 Thread Simon Atanasyan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310418: [mips] Enable `long_call/short_call` attributes on 
MIPS64 (authored by atanasyan).

Changed prior to commit:
  https://reviews.llvm.org/D36208?vs=110252=110275#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36208

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/test/CodeGen/long-call-attr.c
  cfe/trunk/test/Sema/attr-long-call.c


Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -264,7 +264,8 @@
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
-def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetMips32 : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1160,13 +1161,13 @@
   let Documentation = [Undocumented];
 }
 
-def Mips16 : InheritableAttr, TargetSpecificAttr {
+def Mips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"mips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
+def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
   // NOTE: If you add any additional spellings, ARMInterrupt's,
   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
   let Spellings = [GNU<"interrupt">];
@@ -1182,19 +1183,19 @@
   let Documentation = [MipsInterruptDocs];
 }
 
-def MicroMips : InheritableAttr, TargetSpecificAttr {
+def MicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"micromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];
 }
 
-def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"long_call">, GCC<"far">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsLongCallStyleDocs];
 }
 
-def MipsShortCall : InheritableAttr, TargetSpecificAttr {
+def MipsShortCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];
@@ -1276,13 +1277,13 @@
   let Documentation = [Undocumented];
 }
 
-def NoMips16 : InheritableAttr, TargetSpecificAttr {
+def NoMips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def NoMicroMips : InheritableAttr, TargetSpecificAttr {
+def NoMicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomicromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];
Index: cfe/trunk/test/CodeGen/long-call-attr.c
===
--- cfe/trunk/test/CodeGen/long-call-attr.c
+++ cfe/trunk/test/CodeGen/long-call-attr.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);
Index: cfe/trunk/test/Sema/attr-long-call.c
===
--- cfe/trunk/test/Sema/attr-long-call.c
+++ cfe/trunk/test/Sema/attr-long-call.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' 
attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' 
attribute takes no arguments}}


Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -264,7 +264,8 @@
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
-def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetMips32 : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1160,13 +1161,13 @@
   let Documentation = [Undocumented];
 }
 
-def Mips16 : InheritableAttr, TargetSpecificAttr {
+def Mips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"mips16">];
   let Subjects = 

r310418 - [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Tue Aug  8 14:17:33 2017
New Revision: 310418

URL: http://llvm.org/viewvc/llvm-project?rev=310418=rev
Log:
[mips] Enable `long_call/short_call` attributes on MIPS64

This change enables `long_call/short_call/far/near` attributes on
MIPS64 targets.

Differential revision: https://reviews.llvm.org/D36208

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/CodeGen/long-call-attr.c
cfe/trunk/test/Sema/attr-long-call.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310418=310417=310418=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 14:17:33 2017
@@ -264,7 +264,8 @@ class TargetArch {
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
-def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetMips32 : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1160,13 +1161,13 @@ def MSP430Interrupt : InheritableAttr, T
   let Documentation = [Undocumented];
 }
 
-def Mips16 : InheritableAttr, TargetSpecificAttr {
+def Mips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"mips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
+def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
   // NOTE: If you add any additional spellings, ARMInterrupt's,
   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
   let Spellings = [GNU<"interrupt">];
@@ -1182,19 +1183,19 @@ def MipsInterrupt : InheritableAttr, Tar
   let Documentation = [MipsInterruptDocs];
 }
 
-def MicroMips : InheritableAttr, TargetSpecificAttr {
+def MicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"micromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];
 }
 
-def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"long_call">, GCC<"far">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsLongCallStyleDocs];
 }
 
-def MipsShortCall : InheritableAttr, TargetSpecificAttr {
+def MipsShortCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];
@@ -1276,13 +1277,13 @@ def NoInline : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def NoMips16 : InheritableAttr, TargetSpecificAttr {
+def NoMips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def NoMicroMips : InheritableAttr, TargetSpecificAttr {
+def NoMicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomicromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];

Modified: cfe/trunk/test/CodeGen/long-call-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/long-call-attr.c?rev=310418=310417=310418=diff
==
--- cfe/trunk/test/CodeGen/long-call-attr.c (original)
+++ cfe/trunk/test/CodeGen/long-call-attr.c Tue Aug  8 14:17:33 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);

Modified: cfe/trunk/test/Sema/attr-long-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-long-call.c?rev=310418=310417=310418=diff
==
--- cfe/trunk/test/Sema/attr-long-call.c (original)
+++ cfe/trunk/test/Sema/attr-long-call.c Tue Aug  8 14:17:33 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' 
attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' 
attribute takes no arguments}}


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


[PATCH] D36487: Emit section information for extern variables.

2017-08-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please propose a patch for LangRef clarifying what exactly it means to have a 
section attribute on a declaration.




Comment at: test/CodeGenCXX/extern-section-attribute.cpp:1
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=i386-pc-linux-gnu 
| FileCheck %s --check-prefix=CHECK-LIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=CHECK-LIN

Not sure it really adds anything to run this with four different RUN lines.


https://reviews.llvm.org/D36487



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


[PATCH] D36487: Emit section information for extern variables.

2017-08-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.

Currently, if  _attribute_((section())) is used for extern variables, section 
information is not emitted in generated IR when the variables are used. This is 
expected since sections are not generated for external linkage objects. However 
NiosII requires this information as it uses special GP-relative accesses for 
any objects that use attribute section (.sdata). GCC keeps this attribute in 
middle-end.

This change emits the section information for all targets.


https://reviews.llvm.org/D36487

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/extern-section-attribute.cpp


Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=i386-pc-linux-gnu 
| FileCheck %s --check-prefix=CHECK-LIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=CHECK-LIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=i386-pc-win32 | 
FileCheck %s --check-prefix=CHECK-WIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=x86_64-pc-win32 | 
FileCheck %s  --check-prefix=CHECK-WIN
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-LIN-DAG: @aa = external global i32, section ".sdata", align 4
+// CHECK-WIN-DAG: @"\01?aa@@3HA" = external global i32, section ".sdata", 
align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-LIN-DAG: @bb = global i32 1, section ".sdata", align 4
+// CHECK-WIN-DAG: @"\01?bb@@3HA" = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2430,6 +2430,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&


Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=i386-pc-linux-gnu | FileCheck %s --check-prefix=CHECK-LIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=CHECK-LIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=i386-pc-win32 | FileCheck %s --check-prefix=CHECK-WIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -triple=x86_64-pc-win32 | FileCheck %s  --check-prefix=CHECK-WIN
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-LIN-DAG: @aa = external global i32, section ".sdata", align 4
+// CHECK-WIN-DAG: @"\01?aa@@3HA" = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-LIN-DAG: @bb = global i32 1, section ".sdata", align 4
+// CHECK-WIN-DAG: @"\01?bb@@3HA" = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2430,6 +2430,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7571
+
+  // XXX: Should this be i64 instead, and should the limit increase?
+  llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());

What we do here depends on NumRegsLeft when the block is entered and NumRegs.  
If NumRegsLeft >= NumRegs then we just need 2 adjacent registers.  If 
NumRegsLeft == 1 and NumRegs == 2, then do we pass the low half in a register 
and the upper half in memory, or all of it in memory?  Anyway, I think 
NumRegsLeft shouldn't be updated until we know it's OK, and then we don't need 
the min().


https://reviews.llvm.org/D36171



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


r310410 - [codeview] Emit nested enums and typedefs from classes

2017-08-08 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug  8 13:30:14 2017
New Revision: 310410

URL: http://llvm.org/viewvc/llvm-project?rev=310410=rev
Log:
[codeview] Emit nested enums and typedefs from classes

Previously we limited ourselves to only emitting nested classes, but we
need other kinds of types as well.

This fixes the Visual Studio STL visualizers, so that users can
visualize std::string and other objects.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-codeview-nested-types.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=310410=310409=310410=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug  8 13:30:14 2017
@@ -1183,13 +1183,13 @@ void CGDebugInfo::CollectRecordNormalFie
   elements.push_back(FieldType);
 }
 
-void CGDebugInfo::CollectRecordNestedRecord(
-const RecordDecl *RD, SmallVectorImpl ) {
-  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+void CGDebugInfo::CollectRecordNestedType(
+const TypeDecl *TD, SmallVectorImpl ) {
+  QualType Ty = CGM.getContext().getTypeDeclType(TD);
   // Injected class names are not considered nested records.
   if (isa(Ty))
 return;
-  SourceLocation Loc = RD->getLocation();
+  SourceLocation Loc = TD->getLocation();
   llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateFile(Loc));
   elements.push_back(nestedType);
 }
@@ -1205,9 +1205,9 @@ void CGDebugInfo::CollectRecordFields(
   else {
 const ASTRecordLayout  = 
CGM.getContext().getASTRecordLayout(record);
 
-// Debug info for nested records is included in the member list only for
+// Debug info for nested types is included in the member list only for
 // CodeView.
-bool IncludeNestedRecords = CGM.getCodeGenOpts().EmitCodeView;
+bool IncludeNestedTypes = CGM.getCodeGenOpts().EmitCodeView;
 
 // Field number for non-static fields.
 unsigned fieldNo = 0;
@@ -1234,10 +1234,12 @@ void CGDebugInfo::CollectRecordFields(
 
 // Bump field number for next field.
 ++fieldNo;
-  } else if (const auto *nestedRec = dyn_cast(I))
-if (IncludeNestedRecords && !nestedRec->isImplicit() &&
-nestedRec->getDeclContext() == record)
-  CollectRecordNestedRecord(nestedRec, elements);
+  } else if (IncludeNestedTypes) {
+if (const auto *nestedType = dyn_cast(I))
+  if (!nestedType->isImplicit() &&
+  nestedType->getDeclContext() == record)
+CollectRecordNestedType(nestedType, elements);
+  }
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=310410=310409=310410=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Aug  8 13:30:14 2017
@@ -278,8 +278,8 @@ class CGDebugInfo {
 llvm::DIFile *F,
 SmallVectorImpl ,
 llvm::DIType *RecordTy, const RecordDecl *RD);
-  void CollectRecordNestedRecord(const RecordDecl *RD,
- SmallVectorImpl );
+  void CollectRecordNestedType(const TypeDecl *RD,
+   SmallVectorImpl );
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl ,
llvm::DICompositeType *RecordTy);

Added: cfe/trunk/test/CodeGenCXX/debug-info-codeview-nested-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-nested-types.cpp?rev=310410=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-codeview-nested-types.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-codeview-nested-types.cpp Tue Aug  8 
13:30:14 2017
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-pc-windows-msvc 
-debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
+
+struct HasNested {
+  enum InnerEnum { _BUF_SIZE = 1 };
+  typedef int InnerTypedef;
+  enum { InnerEnumerator = 2 };
+  struct InnerStruct { };
+};
+HasNested f;
+
+// CHECK: ![[INNERENUM:[0-9]+]] = !DICompositeType(tag: 
DW_TAG_enumeration_type, name: "InnerEnum", {{.*}})
+// CHECK: ![[HASNESTED:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "HasNested",
+// CHECK-SAME: elements: ![[MEMBERS:[0-9]+]],
+//
+// CHECK: ![[MEMBERS]] = !{![[INNERENUM]], ![[INNERTYPEDEF:[0-9]+]], 
![[UNNAMEDENUM:[0-9]+]], ![[INNERSTRUCT:[0-9]+]]}
+//
+// CHECK: ![[INNERTYPEDEF]] = !DIDerivedType(tag: DW_TAG_typedef, name: 
"InnerTypedef", scope: ![[HASNESTED]]{{.*}})
+//

[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 110272.
arsenm added a comment.

Fix assert when estimating array registers


https://reviews.llvm.org/D36171

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -511,9 +511,9 @@
 
 // CHECK-LABEL: test_memset_private
 // CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull {{.*}}, i8 0, i64 40, i32 8, i1 false)
-StructTy3 test_memset_private(void) {
+void test_memset_private(private StructTy3 *ptr) {
   StructTy3 S3 = {0, 0, 0, 0, 0};
-  return S3;
+  *ptr = S3;
 }
 
 // Test casting literal 0 to pointer.
Index: test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
===
--- test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
+++ test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
@@ -2,20 +2,52 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple r600-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
 
-// CHECK-NOT: %struct.single_element_struct_arg = type { i32 }
+typedef __attribute__(( ext_vector_type(2) )) char char2;
+typedef __attribute__(( ext_vector_type(3) )) char char3;
+typedef __attribute__(( ext_vector_type(4) )) char char4;
+
+typedef __attribute__(( ext_vector_type(2) )) short short2;
+typedef __attribute__(( ext_vector_type(3) )) short short3;
+typedef __attribute__(( ext_vector_type(4) )) short short4;
+
+typedef __attribute__(( ext_vector_type(2) )) int int2;
+typedef __attribute__(( ext_vector_type(3) )) int int3;
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+typedef __attribute__(( ext_vector_type(16) )) int int16;
+typedef __attribute__(( ext_vector_type(32) )) int int32;
+
+// CHECK: %struct.empty_struct = type {}
+typedef struct empty_struct
+{
+} empty_struct;
+
+// CHECK-NOT: %struct.single_element_struct_arg
 typedef struct single_element_struct_arg
 {
 int i;
 } single_element_struct_arg_t;
 
+// CHECK-NOT: %struct.nested_single_element_struct_arg
+typedef struct nested_single_element_struct_arg
+{
+  single_element_struct_arg_t i;
+} nested_single_element_struct_arg_t;
+
 // CHECK: %struct.struct_arg = type { i32, float, i32 }
 typedef struct struct_arg
 {
 int i1;
 float f;
 int i2;
 } struct_arg_t;
 
+// CHECK: %struct.struct_padding_arg = type { i8, i64 }
+typedef struct struct_padding_arg
+{
+  char i1;
+  long f;
+} struct_padding_arg;
+
 // CHECK: %struct.struct_of_arrays_arg = type { [2 x i32], float, [4 x i32], [3 x float], i32 }
 typedef struct struct_of_arrays_arg
 {
@@ -35,33 +67,457 @@
 int i2;
 } struct_of_structs_arg_t;
 
-// CHECK-LABEL: @test_single_element_struct_arg
-// CHECK: i32 %arg1.coerce
-__kernel void test_single_element_struct_arg(single_element_struct_arg_t arg1)
+// CHECK: %union.transparent_u = type { i32 }
+typedef union
 {
+  int b1;
+  float b2;
+} transparent_u __attribute__((__transparent_union__));
+
+// CHECK: %struct.single_array_element_struct_arg = type { [4 x i32] }
+typedef struct single_array_element_struct_arg
+{
+int i[4];
+} single_array_element_struct_arg_t;
+
+// CHECK: %struct.single_struct_element_struct_arg = type { %struct.inner }
+// CHECK: %struct.inner = type { i32, i64 }
+typedef struct single_struct_element_struct_arg
+{
+  struct inner {
+int a;
+long b;
+  } s;
+} single_struct_element_struct_arg_t;
+
+// CHECK: %struct.different_size_type_pair
+typedef struct different_size_type_pair {
+  long l;
+  int i;
+} different_size_type_pair;
+
+// CHECK: %struct.flexible_array = type { i32, [0 x i32] }
+typedef struct flexible_array
+{
+  int i;
+  int flexible[];
+} flexible_array;
+
+// CHECK: %struct.struct_arr16 = type { [16 x i32] }
+typedef struct struct_arr16
+{
+int arr[16];
+} struct_arr16;
+
+// CHECK: %struct.struct_arr32 = type { [32 x i32] }
+typedef struct struct_arr32
+{
+int arr[32];
+} struct_arr32;
+
+// CHECK: %struct.struct_arr33 = type { [33 x i32] }
+typedef struct struct_arr33
+{
+int arr[33];
+} struct_arr33;
+
+// CHECK: %struct.struct_char_arr32 = type { [32 x i8] }
+typedef struct struct_char_arr32
+{
+  char arr[32];
+} struct_char_arr32;
+
+// CHECK-NOT: %struct.struct_char_x8
+typedef struct struct_char_x8 {
+  char x, y, z, w;
+  char a, b, c, d;
+} struct_char_x8;
+
+// CHECK-NOT: %struct.struct_char_x4
+typedef struct struct_char_x4 {
+  char x, y, z, w;
+} struct_char_x4;
+
+// CHECK-NOT: %struct.struct_char_x3
+typedef struct struct_char_x3 {
+  char x, y, z;
+} struct_char_x3;
+
+// CHECK-NOT: %struct.struct_char_x2
+typedef struct struct_char_x2 {
+  char x, y;
+} struct_char_x2;
+
+// CHECK-NOT: %struct.struct_char_x1
+typedef struct struct_char_x1 {
+  char x;
+} 

[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-08 Thread Francis Ricci via Phabricator via cfe-commits
fjricci added a comment.

Please add a test for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482



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


r310409 - [sanitizer-coverage] -fsanitize-coverage=bb, inline-8bit-counters

2017-08-08 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Tue Aug  8 13:20:40 2017
New Revision: 310409

URL: http://llvm.org/viewvc/llvm-project?rev=310409=rev
Log:
[sanitizer-coverage] -fsanitize-coverage=bb,inline-8bit-counters

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=310409=310408=310409=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue Aug  8 13:20:40 2017
@@ -543,8 +543,10 @@ SanitizerArgs::SanitizerArgs(const ToolC
 << "-fsanitize-coverage=trace-pc-guard";
 
   int InsertionPointTypes = CoverageFunc | CoverageBB | CoverageEdge;
+  int InstrumentationTypes =
+  CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters;
   if ((CoverageFeatures & InsertionPointTypes) &&
-  !(CoverageFeatures &(CoverageTracePC | CoverageTracePCGuard))) {
+  !(CoverageFeatures & InstrumentationTypes)) {
 D.Diag(clang::diag::warn_drv_deprecated_arg)
 << "-fsanitize-coverage=[func|bb|edge]"
 << "-fsanitize-coverage=[func|bb|edge],[trace-pc-guard|trace-pc]";

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=310409=310408=310409=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Tue Aug  8 13:20:40 2017
@@ -86,6 +86,8 @@
 // CHECK_NOPRUNE: -fsanitize-coverage-no-prune
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=inline-8bit-counters %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK_INLINE8BIT
+// RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=bb,inline-8bit-counters %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK_INLINE8BIT
+// CHECK_INLINE8BIT-NOT: warning
 // CHECK_INLINE8BIT: -fsanitize-coverage-inline-8bit-counters
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=inline-8bit-counters,pc-table %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK_PC_TABLE


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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310408: Integrate Kostya's clang-proto-fuzzer with LLVM. 
(authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D36324?vs=110265=110269#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36324

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/cmake/modules/ProtobufMutator.cmake
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/README.txt
  cfe/trunk/tools/clang-fuzzer/cxx_proto.proto
  cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -377,6 +377,8 @@
 option(CLANG_ANALYZER_BUILD_Z3
   "Build the static analyzer with the Z3 constraint manager." OFF)
 
+option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3))
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
 endif()
Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,21 +1,60 @@
 if( LLVM_USE_SANITIZE_COVERAGE )
   set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
 
+  if(CLANG_ENABLE_PROTO_FUZZER)
+# Create protobuf .h and .cc files, and put them in a library for use by
+# clang-proto-fuzzer components.
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  ${PROTO_SRCS}
+  )
+add_clang_library(clangCXXProto
+  ${PROTO_SRCS}
+  ${PROTO_HDRS}
+
+  LINK_LIBS
+  ${PROTOBUF_LIBRARIES}
+  )
+
+# Build and include libprotobuf-mutator
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+# Build the protobuf->C++ translation library and driver.
+add_clang_subdirectory(proto-to-cxx)
+
+# Build the protobuf fuzzer
+add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
+target_link_libraries(clang-proto-fuzzer
+  ${ProtobufMutator_LIBRARIES}
+  clangCXXProto
+  clangHandleCXX
+  clangProtoToCXX
+  LLVMFuzzer
+  )
+  else()
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
+  endif()
+
+  add_clang_subdirectory(handle-cxx)
+
   add_clang_executable(clang-fuzzer
 EXCLUDE_FROM_ALL
 ClangFuzzer.cpp
 )
 
   target_link_libraries(clang-fuzzer
-${CLANG_FORMAT_LIB_DEPS}
-clangAST
-clangBasic
-clangCodeGen
-clangDriver
-clangFrontend
-clangRewriteFrontend
-clangStaticAnalyzerFrontend
-clangTooling
+clangHandleCXX
 LLVMFuzzer
 )
 endif()
Index: cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
===
--- cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
+++ cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
@@ -0,0 +1,58 @@
+//==-- handle_cxx.cpp - Helper function for Clang fuzzers --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements HandleCXX for use by the Clang fuzzers.
+//
+//===--===//
+
+#include "handle_cxx.h"
+
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/TargetSelect.h"
+
+using namespace clang;
+
+void clang_fuzzer::HandleCXX(const std::string ,
+ const 

r310408 - Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Aug  8 13:15:04 2017
New Revision: 310408

URL: http://llvm.org/viewvc/llvm-project?rev=310408=rev
Log:
Integrate Kostya's clang-proto-fuzzer with LLVM.

Summary:
The clang-proto-fuzzer models a subset of C++ as a protobuf and
uses libprotobuf-mutator to generate interesting mutations of C++
programs.  Clang-proto-fuzzer has already found several bugs in
Clang (e.g., https://bugs.llvm.org/show_bug.cgi?id=33747,
https://bugs.llvm.org/show_bug.cgi?id=33749).

As with clang-fuzzer, clang-proto-fuzzer requires the following
cmake flags:
- CMAKE_C_COMPILER=clang
- CMAKE_CXX_COMPILER=clang++
- LLVM_USE_SANITIZE_COVERAGE=YES  // needed for libFuzzer
- LLVM_USE_SANITIZER=Address  // needed for libFuzzer

In addition, clang-proto-fuzzer requires:
- CLANG_ENABLE_PROTO_FUZZER=ON

clang-proto-fuzzer also requires the following dependencies:
- binutils  // needed for libprotobuf-mutator
- liblzma-dev  // needed for libprotobuf-mutator
- libz-dev  // needed for libprotobuf-mutator
- docbook2x  // needed for libprotobuf-mutator
- Recent version of protobuf [3.3.0 is known to work]

A working version of libprotobuf-mutator will automatically be
downloaded and built as an external project.

Implementation of clang-proto-fuzzer provided by Kostya
Serebryany.

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

Reviewers: kcc, vitalybuka, bogner

Reviewed By: kcc, vitalybuka

Subscribers: thakis, mgorny, cfe-commits

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

Added:
cfe/trunk/cmake/modules/ProtobufMutator.cmake
cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
cfe/trunk/tools/clang-fuzzer/README.txt
cfe/trunk/tools/clang-fuzzer/cxx_proto.proto
cfe/trunk/tools/clang-fuzzer/handle-cxx/
cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.h
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=310408=310407=310408=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Aug  8 13:15:04 2017
@@ -377,6 +377,8 @@ option(CLANG_ENABLE_STATIC_ANALYZER "Bui
 option(CLANG_ANALYZER_BUILD_Z3
   "Build the static analyzer with the Z3 constraint manager." OFF)
 
+option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR 
CLANG_ANALYZER_BUILD_Z3))
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")
 endif()

Added: cfe/trunk/cmake/modules/ProtobufMutator.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=310408=auto
==
--- cfe/trunk/cmake/modules/ProtobufMutator.cmake (added)
+++ cfe/trunk/cmake/modules/ProtobufMutator.cmake Tue Aug  8 13:15:04 2017
@@ -0,0 +1,24 @@
+set(PBM_PREFIX protobuf_mutator)
+set(PBM_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PBM_PREFIX}/src/${PBM_PREFIX})
+set(PBM_LIB_PATH ${PBM_PATH}/src/libprotobuf-mutator.a)
+set(PBM_FUZZ_LIB_PATH 
${PBM_PATH}/src/libfuzzer/libprotobuf-mutator-libfuzzer.a)
+
+ExternalProject_Add(${PBM_PREFIX}
+  PREFIX ${PBM_PREFIX}
+  GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git
+  GIT_TAG 34287f8
+  CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
+-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+  BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
+  BUILD_BYPRODUCTS ${PBM_LIB_PATH} ${PBM_FUZZ_LIB_PATH}
+  BUILD_IN_SOURCE 1
+  INSTALL_COMMAND ""
+  LOG_DOWNLOAD 1
+  LOG_CONFIGURE 1
+  LOG_BUILD 1
+  )
+
+set(ProtobufMutator_INCLUDE_DIRS ${PBM_PATH})
+set(ProtobufMutator_LIBRARIES ${PBM_FUZZ_LIB_PATH} ${PBM_LIB_PATH})

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=310408=310407=310408=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Aug  8 13:15:04 2017
@@ -1,21 +1,60 @@
 if( LLVM_USE_SANITIZE_COVERAGE )
   set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
 
+  if(CLANG_ENABLE_PROTO_FUZZER)
+# Create protobuf .h and .cc files, and put them in a library for use by
+# 

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-08 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

Driver/openmp-offload.c still fails on 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7038, 
please fix.


https://reviews.llvm.org/D29654



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


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-08 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310406: [coverage] Special-case calls to noreturn functions. 
(authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D36250?vs=110249=110267#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36250

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/md.cpp
  cfe/trunk/test/CoverageMapping/switch.cpp


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,16 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+VisitStmt(E);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 
Index: cfe/trunk/test/CoverageMapping/switch.cpp
===
--- cfe/trunk/test/CoverageMapping/switch.cpp
+++ cfe/trunk/test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: cfe/trunk/test/CoverageMapping/md.cpp
===
--- cfe/trunk/test/CoverageMapping/md.cpp
+++ cfe/trunk/test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,16 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+VisitStmt(E);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 
Index: cfe/trunk/test/CoverageMapping/switch.cpp
===
--- cfe/trunk/test/CoverageMapping/switch.cpp
+++ cfe/trunk/test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: cfe/trunk/test/CoverageMapping/md.cpp
===
--- cfe/trunk/test/CoverageMapping/md.cpp
+++ cfe/trunk/test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310406 - [coverage] Special-case calls to noreturn functions.

2017-08-08 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Tue Aug  8 13:10:14 2017
New Revision: 310406

URL: http://llvm.org/viewvc/llvm-project?rev=310406=rev
Log:
[coverage] Special-case calls to noreturn functions.

The code after a noreturn call doesn't execute.

The pattern in the testcase is pretty common in LLVM (a switch with
a default case that calls llvm_unreachable).

The original version of this patch was reverted in r309995 due to a
crash. This version includes a fix for that crash (testcase in 
test/CoverageMapping/md.cpp).

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


Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/md.cpp
cfe/trunk/test/CoverageMapping/switch.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=310406=310405=310406=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Tue Aug  8 13:10:14 2017
@@ -716,6 +716,16 @@ struct CounterCoverageMappingBuilder
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+VisitStmt(E);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 

Modified: cfe/trunk/test/CoverageMapping/md.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/md.cpp?rev=310406=310405=310406=diff
==
--- cfe/trunk/test/CoverageMapping/md.cpp (original)
+++ cfe/trunk/test/CoverageMapping/md.cpp Tue Aug  8 13:10:14 2017
@@ -27,6 +27,17 @@ void foo(MD i) {
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;

Modified: cfe/trunk/test/CoverageMapping/switch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/switch.cpp?rev=310406=310405=310406=diff
==
--- cfe/trunk/test/CoverageMapping/switch.cpp (original)
+++ cfe/trunk/test/CoverageMapping/switch.cpp Tue Aug  8 13:10:14 2017
@@ -97,3 +97,16 @@ int fallthrough(int i) { // CHECK-NEXT:
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}


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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110265.
morehouse added a comment.

- README tweaks.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/README.txt
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+case BinaryOp::LE: os << "<="; break;
+case BinaryOp::GE: os << ">="; break;

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110264.
morehouse added a comment.

- Add run instructions to README.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/README.txt
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+case BinaryOp::LE: os << "<="; break;
+case BinaryOp::GE: os 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc accepted this revision.
kcc added a comment.

LGTM with a couple if nits in the README

Thanks!




Comment at: clang/tools/clang-fuzzer/README.txt:11
+class, producing valid C++ programs in the process.  As a result,
+clang-proto-fuzzer is better at stressing deeper layers of Clang.
+

.. of of Clang and LLVM



Comment at: clang/tools/clang-fuzzer/README.txt:36
+=
+Install the necessary dependencies:
+- binutils  // needed for libprotobuf-mutator

(linux-only instructions)



Comment at: clang/tools/clang-fuzzer/README.txt:51
+
+Then build the clang-proto-fuzzer target.
+

You may also build clang-fuzzer with this setup 


https://reviews.llvm.org/D36324



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110262.
morehouse added a comment.

- Add README.txt.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/README.txt
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+case BinaryOp::LE: os << "<="; break;
+case BinaryOp::GE: os << ">="; break;

[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 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, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D36208



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


[PATCH] D36237: Reland "Thread Safety Analysis: fix assert_capability.", add warnings

2017-08-08 Thread Josh Gao via Phabricator via cfe-commits
jmgao added a comment.

Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D36237



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


[PATCH] D36237: Reland "Thread Safety Analysis: fix assert_capability.", add warnings

2017-08-08 Thread Josh Gao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310402: Reland "Thread Safety Analysis: fix 
assert_capability." (authored by jmgao).

Changed prior to commit:
  https://reviews.llvm.org/D36237?vs=110054=110260#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36237

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/Analysis/ThreadSafety.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-capabilities.c
  cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -5700,8 +5700,12 @@
 
 static void handleAssertCapabilityAttr(Sema , Decl *D,
const AttributeList ) {
+  SmallVector Args;
+  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+return;
+
   D->addAttr(::new (S.Context) AssertCapabilityAttr(Attr.getRange(), S.Context,
-Attr.getArgAsExpr(0),
+Args.data(), Args.size(),
 Attr.getAttributeSpellingListIndex()));
 }
 
Index: cfe/trunk/lib/Analysis/ThreadSafety.cpp
===
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp
@@ -1735,8 +1735,23 @@
 CapExprSet AssertLocks;
 Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
 for (const auto  : AssertLocks)
-  Analyzer->addLock(FSet, llvm::make_unique(
-  AssertLock, LK_Shared, Loc, false, true),
+  Analyzer->addLock(FSet,
+llvm::make_unique(
+AssertLock, LK_Shared, Loc, false, true),
+ClassifyDiagnostic(A));
+break;
+  }
+
+  case attr::AssertCapability: {
+AssertCapabilityAttr *A = cast(At);
+CapExprSet AssertLocks;
+Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
+for (const auto  : AssertLocks)
+  Analyzer->addLock(FSet,
+llvm::make_unique(
+AssertLock,
+A->isShared() ? LK_Shared : LK_Exclusive, Loc,
+false, true),
 ClassifyDiagnostic(A));
 break;
   }
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -2138,7 +2138,7 @@
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
   let DuplicatesAllowedWhileMerging = 1;
-  let Args = [ExprArgument<"Expr">];
+  let Args = [VariadicExprArgument<"Args">];
   let Accessors = [Accessor<"isShared",
 [GNU<"assert_shared_capability">,
  CXX11<"clang", "assert_shared_capability">]>];
Index: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABILITY=0 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABILITY=1 %s
 
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
@@ -13,8 +14,15 @@
 #define ACQUIRED_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__)))
 #define EXCLUSIVE_LOCK_FUNCTION(...)__attribute__((exclusive_lock_function(__VA_ARGS__)))
 #define SHARED_LOCK_FUNCTION(...)   __attribute__((shared_lock_function(__VA_ARGS__)))
+
+#if USE_ASSERT_CAPABILITY
+#define ASSERT_EXCLUSIVE_LOCK(...)  __attribute__((assert_capability(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...) __attribute__((assert_shared_capability(__VA_ARGS__)))
+#else
 #define ASSERT_EXCLUSIVE_LOCK(...)  __attribute__((assert_exclusive_lock(__VA_ARGS__)))
 #define ASSERT_SHARED_LOCK(...) __attribute__((assert_shared_lock(__VA_ARGS__)))
+#endif
+
 #define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__((exclusive_trylock_function(__VA_ARGS__)))
 #define SHARED_TRYLOCK_FUNCTION(...)__attribute__((shared_trylock_function(__VA_ARGS__)))
 #define UNLOCK_FUNCTION(...)   

[PATCH] D36237: Reland "Thread Safety Analysis: fix assert_capability.", add warnings

2017-08-08 Thread Josh Gao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310403: Thread Safety Analysis: warn on nonsensical 
attributes. (authored by jmgao).

Changed prior to commit:
  https://reviews.llvm.org/D36237?vs=110054=110259#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36237

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-capabilities.c
  cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -480,7 +480,7 @@
   return nullptr;
 }
 
-static bool checkRecordTypeForCapability(Sema , QualType Ty) {
+template  static bool checkRecordTypeForAttr(Sema , QualType Ty) {
   const RecordType *RT = getRecordType(Ty);
 
   if (!RT)
@@ -497,43 +497,51 @@
 
   // Check if the record itself has a capability.
   RecordDecl *RD = RT->getDecl();
-  if (RD->hasAttr())
+  if (RD->hasAttr())
 return true;
 
   // Else check if any base classes have a capability.
   if (CXXRecordDecl *CRD = dyn_cast(RD)) {
 CXXBasePaths BPaths(false, false);
 if (CRD->lookupInBases([](const CXXBaseSpecifier *BS, CXXBasePath &) {
   const auto *Type = BS->getType()->getAs();
-  return Type->getDecl()->hasAttr();
+  return Type->getDecl()->hasAttr();
 }, BPaths))
   return true;
   }
   return false;
 }
 
-static bool checkTypedefTypeForCapability(QualType Ty) {
+template  static bool checkTypedefTypeForAttr(QualType Ty) {
   const auto *TD = Ty->getAs();
   if (!TD)
 return false;
 
   TypedefNameDecl *TN = TD->getDecl();
   if (!TN)
 return false;
 
-  return TN->hasAttr();
+  return TN->hasAttr();
 }
 
-static bool typeHasCapability(Sema , QualType Ty) {
-  if (checkTypedefTypeForCapability(Ty))
+template  static bool typeHasAttr(Sema , QualType Ty) {
+  if (checkTypedefTypeForAttr(Ty))
 return true;
 
-  if (checkRecordTypeForCapability(S, Ty))
+  if (checkRecordTypeForAttr(S, Ty))
 return true;
 
   return false;
 }
 
+static bool typeHasCapability(Sema , QualType Ty) {
+  return typeHasAttr(S, Ty);
+}
+
+static bool typeHasScopedLockable(Sema , QualType Ty) {
+  return typeHasAttr(S, Ty);
+}
+
 static bool isCapabilityExpr(Sema , const Expr *Ex) {
   // Capability expressions are simple expressions involving the boolean logic
   // operators &&, || or !, a simple DeclRefExpr, CastExpr or a ParenExpr. Once
@@ -570,6 +578,8 @@
SmallVectorImpl ,
int Sidx = 0,
bool ParamIdxOk = false) {
+  bool TriedParam = false;
+
   for (unsigned Idx = Sidx; Idx < Attr.getNumArgs(); ++Idx) {
 Expr *ArgExp = Attr.getArgAsExpr(Idx);
 
@@ -610,15 +620,18 @@
 const RecordType *RT = getRecordType(ArgTy);
 
 // Now check if we index into a record type function param.
-if(!RT && ParamIdxOk) {
+if (!RT && ParamIdxOk) {
   FunctionDecl *FD = dyn_cast(D);
   IntegerLiteral *IL = dyn_cast(ArgExp);
-  if(FD && IL) {
+  if (FD && IL) {
+// Don't emit free function warnings if an index was given.
+TriedParam = true;
+
 unsigned int NumParams = FD->getNumParams();
 llvm::APInt ArgValue = IL->getValue();
 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
-if(!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
+if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
   S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_range)
 << Attr.getName() << Idx + 1 << NumParams;
   continue;
@@ -637,6 +650,28 @@
 
 Args.push_back(ArgExp);
   }
+
+  // If we don't have any lockable arguments, verify that we're an instance
+  // method on a lockable type.
+  if (Args.empty() && !TriedParam) {
+if (auto *MD = dyn_cast(D)) {
+  if (MD->isStatic()) {
+S.Diag(Attr.getLoc(), diag::warn_thread_attribute_noargs_static_method)
+<< Attr.getName();
+return;
+  }
+
+  QualType ThisType = MD->getThisType(MD->getASTContext());
+  if (!typeHasCapability(S, ThisType) &&
+  !typeHasScopedLockable(S, ThisType)) {
+S.Diag(Attr.getLoc(), diag::warn_thread_attribute_noargs_not_lockable)
+<< Attr.getName() << ThisType;
+  }
+} else {
+  S.Diag(Attr.getLoc(), diag::warn_thread_attribute_noargs_not_method)
+  << Attr.getName();
+}
+  }
 }
 
 //===--===//
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- 

r310403 - Thread Safety Analysis: warn on nonsensical attributes.

2017-08-08 Thread Josh Gao via cfe-commits
Author: jmgao
Date: Tue Aug  8 12:44:35 2017
New Revision: 310403

URL: http://llvm.org/viewvc/llvm-project?rev=310403=rev
Log:
Thread Safety Analysis: warn on nonsensical attributes.

Add warnings in cases where an implicit `this` argument is expected to
attributes because either `this` doesn't exist because the attribute is
on a free function, or because `this` is on a type that doesn't have a
corresponding capability/lockable/scoped_lockable attribute.

Reviewers: delesley, aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-capabilities.c
cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310403=310402=310403=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug  8 12:44:35 
2017
@@ -2932,6 +2932,16 @@ def warn_thread_attribute_decl_not_locka
   "%0 attribute can only be applied in a context annotated "
   "with 'capability(\"mutex\")' attribute">,
   InGroup, DefaultIgnore;
+def warn_thread_attribute_noargs_not_lockable : Warning<
+  "%0 attribute requires type annotated with 'capability' attribute; "
+  "type here is %1">,
+  InGroup, DefaultIgnore;
+def warn_thread_attribute_noargs_not_method : Warning<
+  "%0 attribute without arguments can only be applied to a method of a class">,
+  InGroup, DefaultIgnore;
+def warn_thread_attribute_noargs_static_method : Warning<
+  "%0 attribute without arguments cannot be applied to a static method">,
+  InGroup, DefaultIgnore;
 def warn_thread_attribute_decl_not_pointer : Warning<
   "%0 only applies to pointer types; type here is %1">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=310403=310402=310403=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug  8 12:44:35 2017
@@ -480,7 +480,7 @@ static const RecordType *getRecordType(Q
   return nullptr;
 }
 
-static bool checkRecordTypeForCapability(Sema , QualType Ty) {
+template  static bool checkRecordTypeForAttr(Sema , QualType Ty) 
{
   const RecordType *RT = getRecordType(Ty);
 
   if (!RT)
@@ -497,7 +497,7 @@ static bool checkRecordTypeForCapability
 
   // Check if the record itself has a capability.
   RecordDecl *RD = RT->getDecl();
-  if (RD->hasAttr())
+  if (RD->hasAttr())
 return true;
 
   // Else check if any base classes have a capability.
@@ -505,14 +505,14 @@ static bool checkRecordTypeForCapability
 CXXBasePaths BPaths(false, false);
 if (CRD->lookupInBases([](const CXXBaseSpecifier *BS, CXXBasePath &) {
   const auto *Type = BS->getType()->getAs();
-  return Type->getDecl()->hasAttr();
+  return Type->getDecl()->hasAttr();
 }, BPaths))
   return true;
   }
   return false;
 }
 
-static bool checkTypedefTypeForCapability(QualType Ty) {
+template  static bool checkTypedefTypeForAttr(QualType Ty) {
   const auto *TD = Ty->getAs();
   if (!TD)
 return false;
@@ -521,19 +521,27 @@ static bool checkTypedefTypeForCapabilit
   if (!TN)
 return false;
 
-  return TN->hasAttr();
+  return TN->hasAttr();
 }
 
-static bool typeHasCapability(Sema , QualType Ty) {
-  if (checkTypedefTypeForCapability(Ty))
+template  static bool typeHasAttr(Sema , QualType Ty) {
+  if (checkTypedefTypeForAttr(Ty))
 return true;
 
-  if (checkRecordTypeForCapability(S, Ty))
+  if (checkRecordTypeForAttr(S, Ty))
 return true;
 
   return false;
 }
 
+static bool typeHasCapability(Sema , QualType Ty) {
+  return typeHasAttr(S, Ty);
+}
+
+static bool typeHasScopedLockable(Sema , QualType Ty) {
+  return typeHasAttr(S, Ty);
+}
+
 static bool isCapabilityExpr(Sema , const Expr *Ex) {
   // Capability expressions are simple expressions involving the boolean logic
   // operators &&, || or !, a simple DeclRefExpr, CastExpr or a ParenExpr. Once
@@ -570,6 +578,8 @@ static void checkAttrArgsAreCapabilityOb
SmallVectorImpl ,
int Sidx = 0,
bool ParamIdxOk = false) {
+  bool TriedParam = false;
+
   for (unsigned Idx = Sidx; Idx < Attr.getNumArgs(); ++Idx) {
 Expr *ArgExp = Attr.getArgAsExpr(Idx);
 
@@ -610,15 +620,18 @@ static void checkAttrArgsAreCapabilityOb
 const RecordType *RT = getRecordType(ArgTy);
 
 // Now check if we index into a record type function param.
-if(!RT && ParamIdxOk) {
+if (!RT && 

r310402 - Reland "Thread Safety Analysis: fix assert_capability."

2017-08-08 Thread Josh Gao via cfe-commits
Author: jmgao
Date: Tue Aug  8 12:44:34 2017
New Revision: 310402

URL: http://llvm.org/viewvc/llvm-project?rev=310402=rev
Log:
Reland "Thread Safety Analysis: fix assert_capability."

Delete the test that was broken by rL309725, and add it back in a
follow up commit. Also, improve the tests a bit.

Reviewers: delesley, aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-capabilities.c
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310402=310401=310402=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 12:44:34 2017
@@ -2138,7 +2138,7 @@ def AssertCapability : InheritableAttr {
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
   let DuplicatesAllowedWhileMerging = 1;
-  let Args = [ExprArgument<"Expr">];
+  let Args = [VariadicExprArgument<"Args">];
   let Accessors = [Accessor<"isShared",
 [GNU<"assert_shared_capability">,
  CXX11<"clang", "assert_shared_capability">]>];

Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=310402=310401=310402=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Tue Aug  8 12:44:34 2017
@@ -1735,8 +1735,23 @@ void BuildLockset::handleCall(Expr *Exp,
 CapExprSet AssertLocks;
 Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
 for (const auto  : AssertLocks)
-  Analyzer->addLock(FSet, llvm::make_unique(
-  AssertLock, LK_Shared, Loc, false, true),
+  Analyzer->addLock(FSet,
+llvm::make_unique(
+AssertLock, LK_Shared, Loc, false, true),
+ClassifyDiagnostic(A));
+break;
+  }
+
+  case attr::AssertCapability: {
+AssertCapabilityAttr *A = cast(At);
+CapExprSet AssertLocks;
+Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
+for (const auto  : AssertLocks)
+  Analyzer->addLock(FSet,
+llvm::make_unique(
+AssertLock,
+A->isShared() ? LK_Shared : LK_Exclusive, Loc,
+false, true),
 ClassifyDiagnostic(A));
 break;
   }

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=310402=310401=310402=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug  8 12:44:34 2017
@@ -5700,8 +5700,12 @@ static void handleCapabilityAttr(Sema 
 
 static void handleAssertCapabilityAttr(Sema , Decl *D,
const AttributeList ) {
+  SmallVector Args;
+  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+return;
+
   D->addAttr(::new (S.Context) AssertCapabilityAttr(Attr.getRange(), S.Context,
-Attr.getArgAsExpr(0),
+Args.data(), Args.size(),
 Attr.getAttributeSpellingListIndex()));
 }
 

Modified: cfe/trunk/test/Sema/attr-capabilities.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-capabilities.c?rev=310402=310401=310402=diff
==
--- cfe/trunk/test/Sema/attr-capabilities.c (original)
+++ cfe/trunk/test/Sema/attr-capabilities.c Tue Aug  8 12:44:34 2017
@@ -37,9 +37,6 @@ void Func6(void) __attribute__((requires
 void Func7(void) __attribute__((assert_capability(GUI))) {}
 void Func8(void) __attribute__((assert_shared_capability(GUI))) {}
 
-void Func9(void) __attribute__((assert_capability())) {} // expected-error 
{{'assert_capability' attribute takes one argument}}
-void Func10(void) __attribute__((assert_shared_capability())) {} // 
expected-error {{'assert_shared_capability' attribute takes one argument}}
-
 void Func11(void) __attribute__((acquire_capability(GUI))) {}
 void Func12(void) __attribute__((acquire_shared_capability(GUI))) {}
 

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 

[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7386
+  bool isHomogeneousAggregateBaseType(QualType Ty) const override;
+  bool isHomogeneousAggregateSmallEnough(const Type *Base,
+ uint64_t Members) const override;

arsenm wrote:
> yaxunl wrote:
> > Please add descriptions for the above newly added functions.
> I prefer not to put descriptions on overrides since they will just be out of 
> date with the declaration
Please add descriptions for the non-override functions and data members above.


https://reviews.llvm.org/D36171



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


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-08 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski created this revision.
krytarowski added a project: Sanitizers.

vptr is required for ubsan, which is reported to work on NetBSD.

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D36482

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
   }
   return Res;
 }


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7386
+  bool isHomogeneousAggregateBaseType(QualType Ty) const override;
+  bool isHomogeneousAggregateSmallEnough(const Type *Base,
+ uint64_t Members) const override;

yaxunl wrote:
> Please add descriptions for the above newly added functions.
I prefer not to put descriptions on overrides since they will just be out of 
date with the declaration



Comment at: lib/CodeGen/TargetInfo.cpp:7401
+bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
+  return true;
+}

yaxunl wrote:
> why do we need this function if it always return true
The default is return false


https://reviews.llvm.org/D36171



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


[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 110252.
atanasyan added a comment.

- Renamed `TargetMips` to `TargetMips32`


Repository:
  rL LLVM

https://reviews.llvm.org/D36208

Files:
  include/clang/Basic/Attr.td
  test/CodeGen/long-call-attr.c
  test/Sema/attr-long-call.c


Index: test/Sema/attr-long-call.c
===
--- test/Sema/attr-long-call.c
+++ test/Sema/attr-long-call.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' 
attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' 
attribute takes no arguments}}
Index: test/CodeGen/long-call-attr.c
===
--- test/CodeGen/long-call-attr.c
+++ test/CodeGen/long-call-attr.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -264,7 +264,8 @@
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
-def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetMips32 : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -1160,13 +1161,13 @@
   let Documentation = [Undocumented];
 }
 
-def Mips16 : InheritableAttr, TargetSpecificAttr {
+def Mips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"mips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
+def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
   // NOTE: If you add any additional spellings, ARMInterrupt's,
   // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
   let Spellings = [GNU<"interrupt">];
@@ -1182,19 +1183,19 @@
   let Documentation = [MipsInterruptDocs];
 }
 
-def MicroMips : InheritableAttr, TargetSpecificAttr {
+def MicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"micromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];
 }
 
-def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"long_call">, GCC<"far">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsLongCallStyleDocs];
 }
 
-def MipsShortCall : InheritableAttr, TargetSpecificAttr {
+def MipsShortCall : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];
@@ -1276,13 +1277,13 @@
   let Documentation = [Undocumented];
 }
 
-def NoMips16 : InheritableAttr, TargetSpecificAttr {
+def NoMips16 : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomips16">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
-def NoMicroMips : InheritableAttr, TargetSpecificAttr {
+def NoMicroMips : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"nomicromips">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [MicroMipsDocs];


Index: test/Sema/attr-long-call.c
===
--- test/Sema/attr-long-call.c
+++ test/Sema/attr-long-call.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
 __attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' attribute takes no arguments}}
Index: test/CodeGen/long-call-attr.c
===
--- test/CodeGen/long-call-attr.c
+++ test/CodeGen/long-call-attr.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
 void __attribute__((short_call)) foo4 (void);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ 

[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7386
+  bool isHomogeneousAggregateBaseType(QualType Ty) const override;
+  bool isHomogeneousAggregateSmallEnough(const Type *Base,
+ uint64_t Members) const override;

Please add descriptions for the above newly added functions.



Comment at: lib/CodeGen/TargetInfo.cpp:7401
+bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
+  return true;
+}

why do we need this function if it always return true


https://reviews.llvm.org/D36171



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


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.

Thanks, lgtm.


Repository:
  rL LLVM

https://reviews.llvm.org/D36250



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


[PATCH] D35817: Ban implicit _Complex to scalar conversions in C++

2017-08-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D35817#835740, @t.p.northover wrote:

> > What's going on with the OpenMP test changes?
>
> Compound assignment operators like "real /= complex" become illegal under the 
> new rules (in C++) because somewhere there has to be an implicit conversion. 
> I was pretty relieved to discover GCC also rejects the syntax because my 
> change actually messes up the AST quite comprehensively if we wanted it to be 
> legal (OpenMP does some weird stuff building its AST).


Okay. LGTM.


https://reviews.llvm.org/D35817



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-08 Thread Richard Smith via cfe-commits
I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Aug  8 12:12:28 2017
> New Revision: 310401
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310401=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>  * Previously, Clang ignored the move constructor when making this
>determination. It now takes the move constructor into account, per
>https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>seem recent, but the ABI change was agreed on the Itanium C++ ABI
>list a long time ago).
>
>  * Previously, Clang's behavior when the copy constructor was deleted
>was unstable -- depending on whether the lazy declaration of the
>copy constructor had been triggered, you might get different behavior.
>We now eagerly declare the copy constructor whenever its deletedness
>is unclear, and ignore deleted copy/move constructors when looking for
>a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>  * If the copy constructor would be implicitly deleted (but has not been
>lazily declared yet), for instance because the class has an rvalue
>reference member, we would pass it directly. We now pass such a class
>indirectly, matching MSVC.
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=310401=310400=310401=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
> @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if a defaulted corresponding
> special
>  /// member can't be fully analyzed without performing overload
> resolution.
>  /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>  unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if an implicit defaulted
> corresponding
>  /// special member would be defined as deleted.
>  /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>  unsigned DefaultedMoveConstructorIsDeleted : 1;
>  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>  unsigned DefaultedDestructorIsDeleted : 1;
> @@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
>  /// constructor.
>  unsigned HasDefaultedDefaultConstructor : 1;
>
> +/// \brief True if this class can be passed in a
> non-address-preserving
> +/// fashion (such as in registers) according to the C++ language
> rules.
> +/// This does not imply anything about how the ABI in use will
> actually
> +/// pass an object of this class.
> +unsigned CanPassInRegisters : 1;
> +
>  /// \brief True if a defaulted default constructor for this class
> would
>  /// be constexpr.
>  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
> @@ -811,18 +819,50 @@ public:
>  return data().FirstFriend.isValid();
>}
>
> +  /// \brief \c true if a defaulted copy constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedCopyConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForCopyConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
> +   "this property has not yet been computed by Sema");
> +return data().DefaultedCopyConstructorIsDeleted;
> +  }
> +
> +  /// \brief \c true if a defaulted move constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedMoveConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForMoveConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
> +   "this property has not yet been computed by Sema");
> +return data().DefaultedMoveConstructorIsDeleted;
> +  }
> +
> 

[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Committed as r310401.


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D35817: Ban implicit _Complex to scalar conversions in C++

2017-08-08 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

> What's going on with the OpenMP test changes?

Compound assignment operators like "real /= complex" become illegal under the 
new rules (in C++) because somewhere there has to be an implicit conversion. I 
was pretty relieved to discover GCC also rejects the syntax because my change 
actually messes up the AST quite comprehensively if we wanted it to be legal 
(OpenMP does some weird stuff building its AST).


https://reviews.llvm.org/D35817



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


r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

 * Previously, Clang ignored the move constructor when making this
   determination. It now takes the move constructor into account, per
   https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
   seem recent, but the ABI change was agreed on the Itanium C++ ABI
   list a long time ago).

 * Previously, Clang's behavior when the copy constructor was deleted
   was unstable -- depending on whether the lazy declaration of the
   copy constructor had been triggered, you might get different behavior.
   We now eagerly declare the copy constructor whenever its deletedness
   is unclear, and ignore deleted copy/move constructors when looking for
   a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

 * If the copy constructor would be implicitly deleted (but has not been
   lazily declared yet), for instance because the class has an rvalue
   reference member, we would pass it directly. We now pass such a class
   indirectly, matching MSVC.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401=310400=310401=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if a defaulted corresponding special
 /// member can't be fully analyzed without performing overload resolution.
 /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
 unsigned NeedOverloadResolutionForMoveConstructor : 1;
 unsigned NeedOverloadResolutionForMoveAssignment : 1;
 unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if an implicit defaulted corresponding
 /// special member would be defined as deleted.
 /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
 unsigned DefaultedMoveConstructorIsDeleted : 1;
 unsigned DefaultedMoveAssignmentIsDeleted : 1;
 unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
 /// constructor.
 unsigned HasDefaultedDefaultConstructor : 1;
 
+/// \brief True if this class can be passed in a non-address-preserving
+/// fashion (such as in registers) according to the C++ language rules.
+/// This does not imply anything about how the ABI in use will actually
+/// pass an object of this class.
+unsigned CanPassInRegisters : 1;
+
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -811,18 +819,50 @@ public:
 return data().FirstFriend.isValid();
   }
 
+  /// \brief \c true if a defaulted copy constructor for this class would be
+  /// deleted.
+  bool defaultedCopyConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForCopyConstructor() ||
+(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted move constructor for this class would be
+  /// deleted.
+  bool defaultedMoveConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForMoveConstructor() ||
+(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedMoveConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted destructor for this class would be deleted.
+  bool defaultedDestructorIsDeleted() const {
+return !data().DefaultedDestructorIsDeleted;
+  }
+
+  /// \brief \c true if we know for sure that this class has a single,
+  /// accessible, unambiguous copy constructor that is not deleted.
+  bool hasSimpleCopyConstructor() const {
+return !hasUserDeclaredCopyConstructor() &&
+   

[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 110249.
efriedma added a comment.

Update to call VisitStmt(E)


Repository:
  rL LLVM

https://reviews.llvm.org/D36250

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/md.cpp
  test/CoverageMapping/switch.cpp


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: test/CoverageMapping/md.cpp
===
--- test/CoverageMapping/md.cpp
+++ test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,16 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+VisitStmt(E);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: test/CoverageMapping/md.cpp
===
--- test/CoverageMapping/md.cpp
+++ test/CoverageMapping/md.cpp
@@ -27,6 +27,17 @@
   #include "Inputs/md.def"
 }
 
+// CHECK: bar
+// CHECK-NEXT: File 0, [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
+bool isVal1();
+bool isVal2();
+bool bar() {
+ #define HANDLE_MD(X) is##X() ||
+  return
+#include "Inputs/md.def"
+  0;
+}
+
 int main(int argc, const char *argv[]) {
   foo(MD::Val1);
   return 0;
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,16 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+VisitStmt(E);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35817: Ban implicit _Complex to scalar conversions in C++

2017-08-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

What's going on with the OpenMP test changes?


https://reviews.llvm.org/D35817



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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-08 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

@rsmith do you have an opinion on what would be the right place for the kind of 
proposed optimization?
It looks like it can be implemented as target independent optimization, acting 
only for target with specified properties - in this case target must provide 
required built-in functions.


https://reviews.llvm.org/D36327



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


Re: r308722 - Fixed failing assert in code completion.

2017-08-08 Thread Hans Wennborg via cfe-commits
Sorry for the slow reply; I missed this somehow.

Merged in r310395.

Thanks,
Hans

On Tue, Aug 8, 2017 at 5:20 AM, Alex L  wrote:
> Ping?
>
> On 21 July 2017 at 10:44, Alex L  wrote:
>>
>> Hans, can you please merge this to the LLVM 5.0 branch?
>>
>> AFAIK It's a recent regression that should get fixed in LLVM 5.0.
>>
>> Cheers,
>> Alex
>>
>>
>> On 21 July 2017 at 10:24, Ilya Biryukov via cfe-commits
>>  wrote:
>>>
>>> Author: ibiryukov
>>> Date: Fri Jul 21 02:24:00 2017
>>> New Revision: 308722
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=308722=rev
>>> Log:
>>> Fixed failing assert in code completion.
>>>
>>> Summary:
>>> The code was accessing uninstantiated default argument.
>>> This resulted in failing assertion at ParmVarDecl::getDefaultArg().
>>>
>>> Reviewers: erikjv, klimek, bkramer, krasimir
>>>
>>> Reviewed By: krasimir
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D35682
>>>
>>> Added:
>>> cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=308722=308721=308722=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jul 21 02:24:00 2017
>>> @@ -2401,10 +2401,7 @@ formatBlockPlaceholder(const PrintingPol
>>>  static std::string GetDefaultValueString(const ParmVarDecl *Param,
>>>   const SourceManager ,
>>>   const LangOptions ) {
>>> -  const Expr *defaultArg = Param->getDefaultArg();
>>> -  if (!defaultArg)
>>> -return "";
>>> -  const SourceRange SrcRange = defaultArg->getSourceRange();
>>> +  const SourceRange SrcRange = Param->getDefaultArgRange();
>>>CharSourceRange CharSrcRange =
>>> CharSourceRange::getTokenRange(SrcRange);
>>>bool Invalid = CharSrcRange.isInvalid();
>>>if (Invalid)
>>>
>>> Added: cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp?rev=308722=auto
>>>
>>> ==
>>> --- cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp (added)
>>> +++ cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp Fri Jul 21
>>> 02:24:00 2017
>>> @@ -0,0 +1,13 @@
>>> +template 
>>> +struct unique_ptr {
>>> +  typedef T* pointer;
>>> +
>>> +  void reset(pointer ptr = pointer());
>>> +};
>>> +
>>> +void test() {
>>> +  unique_ptr x;
>>> +  x.
>>> +  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - |
>>> FileCheck -check-prefix=CHECK-CC1 %s
>>> +  // CHECK-CC1: [#void#]reset({#<#unique_ptr::pointer ptr =
>>> pointer()#>#})
>>> +}
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309263 - [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-08-08 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r310393.

On Thu, Jul 27, 2017 at 3:43 AM, Peter Smith via cfe-commits
 wrote:
> Author: psmith
> Date: Thu Jul 27 03:43:53 2017
> New Revision: 309263
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309263=rev
> Log:
> [CodeGen][ARM] ARM runtime helper functions are not always soft-fp
>
> Re-commit r309257 with less precise register checks in arm-float-helpers.c
> test.
>
>
> Added:
> cfe/trunk/test/CodeGen/arm-float-helpers.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> cfe/trunk/test/CodeGen/complex-math.c
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=309263=309262=309263=diff
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Jul 27 03:43:53 2017
> @@ -5620,17 +5620,14 @@ void ARMABIInfo::setCCs() {
>// AAPCS apparently requires runtime support functions to be soft-float, 
> but
>// that's almost certainly for historic reasons (Thumb1 not supporting VFP
>// most likely). It's more convenient for AAPCS16_VFP to be hard-float.
> -  switch (getABIKind()) {
> -  case APCS:
> -  case AAPCS16_VFP:
> -if (abiCC != getLLVMDefaultCC())
> +
> +  // The Run-time ABI for the ARM Architecture section 4.1.2 requires
> +  // AEABI-complying FP helper functions to use the base AAPCS.
> +  // These AEABI functions are expanded in the ARM llvm backend, all the 
> builtin
> +  // support functions emitted by clang such as the _Complex helpers follow 
> the
> +  // abiCC.
> +  if (abiCC != getLLVMDefaultCC())
>BuiltinCC = abiCC;
> -break;
> -  case AAPCS:
> -  case AAPCS_VFP:
> -BuiltinCC = llvm::CallingConv::ARM_AAPCS;
> -break;
> -  }
>  }
>
>  ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty,
>
> Added: cfe/trunk/test/CodeGen/arm-float-helpers.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-float-helpers.c?rev=309263=auto
> ==
> --- cfe/trunk/test/CodeGen/arm-float-helpers.c (added)
> +++ cfe/trunk/test/CodeGen/arm-float-helpers.c Thu Jul 27 03:43:53 2017
> @@ -0,0 +1,233 @@
> +// REQUIRES: arm-registered-target
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | 
> FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | 
> FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi 
> -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | 
> FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi 
> -target-feature "+soft-float" %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | 
> FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature 
> "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature 
> "+soft-float" -meabi gnu %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s
> +// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | 
> FileCheck %s
> +
> +// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The
> +// floating-point helper functions to always use the base AAPCS (soft-float)
> +// calling convention.
> +//
> +// These helper functions such as __aeabi_fadd are not explicitly called by
> +// clang, instead they are generated by the ARMISelLowering when they are
> +// needed; clang relies on llvm to use the base AAPCS.
> +//
> +// In this test we check that clang is not directly calling the __aeabi_
> +// functions. We rely on llvm to test that the base AAPCS is used for any
> +// __aeabi_ function from 4.1.2 that is used.
> +//
> +// When compiled to an object file with -mfloat-abi=soft each function F
> +// below should result in a call to __aeabi_F. If clang is changed to call 
> any
> +// of these functions directly the test will need to be altered to check that
> +// arm_aapcscc is used.
> +//
> +// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
> +// other runtime functions such as the _Complex helper routines are not 
> covered.
> +
> +float fadd(float a, float b) { return a + b; }
> +// CHECK-LABEL: define float @fadd(float %a, float %b)
> +// CHECK-NOT: __aeabi_fadd
> +// CHECK: %add = fadd float  {{.*}}, {{.*}}
> +
> +float fdiv(float a, float b) { return a / b; }
> +// CHECK-LABEL: define float @fdiv(float %a, float %b)
> +// CHECK-NOT: __aeabi_fdiv
> +// CHECK: %div = fdiv float  {{.*}}, {{.*}}
> +
> +float fmul(float a, float 

[PATCH] D35817: Ban implicit _Complex to scalar conversions in C++

2017-08-08 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Pingy.


https://reviews.llvm.org/D35817



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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D36327#835634, @Anastasia wrote:

> In https://reviews.llvm.org/D36327#835153, @b-sumner wrote:
>
> > In https://reviews.llvm.org/D36327#834032, @Anastasia wrote:
> >
> > > In https://reviews.llvm.org/D36327#833891, @yaxunl wrote:
> > >
> > > > In https://reviews.llvm.org/D36327#833653, @bader wrote:
> > > >
> > > > > Hi Sam,
> > > > >
> > > > > What do you think about implementing this optimization in target 
> > > > > specific optimization pass? Since size/alignment is saved as function 
> > > > > parameter in LLVM IR, the optimization can be done in target specific 
> > > > > components w/o adding additional conditions to generic library.
> > > > >
> > > > > Thanks,
> > > > > Alexey
> > > >
> > > >
> > > > Hi Alexey,
> > > >
> > > > The optimization of the power-of-2 type size is implemented as a 
> > > > library function. Our backend lacks the capability to link in library 
> > > > code at ISA level, so linking of the optimized library function has to 
> > > > be done before any target-specific passes. It seems the only place to 
> > > > do this is Clang codegen since Clang/llvm does not support 
> > > > target-specific pre-linking passes.
> > >
> > >
> > > My general feeling is that it doesn't look like a generic enough change 
> > > for the frontend. Even though it is implemented in a generic way, not 
> > > every target might have a special support for the power of 2 size and 
> > > also if there is such a support not every implementation would handle it 
> > > as a library function. But I can see that perhaps LLVM is missing 
> > > flexibility in the flow to accommodate these needs. Any change we could 
> > > try to extend the compilation flow such that this target specific 
> > > optimization could happen before the IR linking?
> >
> >
> > It is trivial to implement the small number of specialized functions this 
> > patch adds in terms of the general one if desired, and the general one can 
> > continue to be handled as it had been.
> >
> > We had actually proposed a patch (sorry I don't have the reference handy) 
> > to add general mechanism for targets to introduce pre-link passes, but it 
> > was not accepted.  We can try again, but I don't really expect more 
> > progress.
>
>
> It would be nice to understand why it has not been accepted and whether we 
> could try to argument using this case as an example. It seems like a useful 
> feature for toolchains with the IR linking.


The original review is here:

https://reviews.llvm.org/D20682

To cite the reason why it was rejected:

"I fundamentally do not believe that the TargetMachine should be involved in 
fixing language semantics issues with a "pre linking" pass at the LLVM level. 
Why? Because there is nothing "target" about this.

There needs to be a fundamentally more principled way of handling this at the 
language and frontend level IMO."

However, until now, we could not find "a fundamentally more principled way of 
handling this at the language and frontend level".


https://reviews.llvm.org/D36327



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Looks good!
Now, please add a clang/tools/clang-fuzzer/README.txt describing how to build 
the fuzzers (both the old one and the new one) and how to run them.
For the new one explain how to install the deps


https://reviews.llvm.org/D36324



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


Re: r310359 - [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r310390 as suggested in the review.

Thanks,
Hans

On Tue, Aug 8, 2017 at 7:13 AM, Nikolai Bozhenov via cfe-commits
 wrote:
> Author: n.bozhenov
> Date: Tue Aug  8 07:13:50 2017
> New Revision: 310359
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310359=rev
> Log:
> [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)
>
> Fixes a regression introduced by r308218.
>
> Modified:
> cfe/trunk/include/clang-c/Index.h
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=310359=310358=310359=diff
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Tue Aug  8 07:13:50 2017
> @@ -3206,6 +3206,8 @@ enum CXCallingConv {
>CXCallingConv_X86RegCall = 8,
>CXCallingConv_IntelOclBicc = 9,
>CXCallingConv_Win64 = 10,
> +  /* Alias for compatibility with older versions of API. */
> +  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
>CXCallingConv_X86_64SysV = 11,
>CXCallingConv_X86VectorCall = 12,
>CXCallingConv_Swift = 13,
>
>
> ___
> 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] D36453: [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D36453#834949, @n.bozhenov wrote:

> If the patch is accepted, it should also be merged into 5.0, I believe.


Sounds like a good idea.
r310390


https://reviews.llvm.org/D36453



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: test/CodeGenCXX/uncopyable-args.cpp:101
+
+// In MSVC 2013, the copy ctor is not deleted by a move assignment. In MSVC 
2015, it is.
+// WIN64-18-LABEL: declare void @"\01?foo@implicitly_deleted@@YAXUA@1@@Z"(i64

rsmith wrote:
> rnk wrote:
> > Oh dear. :(
> Can you check that MSVC 2013 is compatible with the code we produce here? 
> (I've checked 2015 passes this indirectly on Compiler Explorer.)
Yes, 2013 passes this object directly as we do here.


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-08 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 110237.
twoh added a comment.

Addressing dblaikie's comments. Thanks!


https://reviews.llvm.org/D36474

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-preprocessed-file.i


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,11 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -483,6 +484,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,11 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -483,6 +484,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/DeclCXX.h:420
 
+/// \brief True if this class has at least one non-deleted copy or move
+/// constructor. That would allow passing it by registers.

rnk wrote:
> Isn't this "... at least one *trivial*, non-deleted copy or move 
> constructor..."?
Changed to:

```
/// \brief True if this class can be passed in a non-address-preserving
/// fashion (such as in registers) according to the C++ language rules.
/// This does not imply anything about how the ABI in use will actually
/// pass an object of this class.
```



Comment at: include/clang/AST/DeclCXX.h:827
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+  /// \brief \c true if a defaulted move constructor for this class would be

v.g.vassilev wrote:
> Is there a reason for not keeping the default (for the file) 1 empty line 
> between methods? Looks like if we add one new line before and after 
> `hasSimpleMoveAssignment` is will be all consistent.
Done. (I was following the local style, but you're right that we don't do this 
elsewhere in the class outside the `hasSimple` functions, excluding groups of 
methods that are much more closely tied together such as `*_begin`/`*_end`.)



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:836
 
-// If this is true, the implicit copy constructor that Sema would have
-// created would not be deleted. FIXME: We should provide a more direct way
-// for CodeGen to ask whether the constructor was deleted.
-if (!RD->hasUserDeclaredCopyConstructor() &&
-!RD->hasUserDeclaredMoveConstructor() &&
-!RD->needsOverloadResolutionForMoveConstructor() &&
-!RD->hasUserDeclaredMoveAssignment() &&
-!RD->needsOverloadResolutionForMoveAssignment())
-  return RAA_Default;
-
-// Otherwise, Sema should have created an implicit copy constructor if
-// needed.
-assert(!RD->needsImplicitCopyConstructor());
-
-// We have to make sure the trivial copy constructor isn't deleted.
-for (const CXXConstructorDecl *CD : RD->ctors()) {
-  if (CD->isCopyConstructor()) {
-assert(CD->isTrivial());
-// We had at least one undeleted trivial copy ctor.  Return directly.
-if (!CD->isDeleted())
-  return RAA_Default;
+// Win64 passes objects with non-deleted, non-trivial copy ctors 
indirectly.
+//

rnk wrote:
> This doesn't seem to match what we've computing, and it doesn't seem quite 
> right. MSVC will pass a class with deleted, trivial copy ctors indirectly. 
> Would it be correct to rephrase like this?
> "If RD has at least one trivial, non-deleted copy constructor, it is passed 
> directly. Otherwise, it is passed indirectly."
You're right. I think "it is passed directly" is overspecifying, though, so how 
about:

```
// If a class has at least one non-deleted, trivial copy constructor, it
// is passed according to the C ABI. Otherwise, it is passed indirectly.
```



Comment at: lib/Sema/SemaDeclCXX.cpp:5731
+/// registers, per C++ [class.temporary]p3.
+static bool computeCanPassInRegisters(Sema , CXXRecordDecl *D) {
+  if (D->isDependentType() || D->isInvalidDecl())

v.g.vassilev wrote:
> It would be very useful if we somehow assert if this function is called 
> before the class triviality is computed?
Many of the functions we unconditionally call below will assert if the class 
does not have a complete definition (eg, `needsImplicitCopyConstructor`).



Comment at: test/CodeGenCXX/uncopyable-args.cpp:101
+
+// In MSVC 2013, the copy ctor is not deleted by a move assignment. In MSVC 
2015, it is.
+// WIN64-18-LABEL: declare void @"\01?foo@implicitly_deleted@@YAXUA@1@@Z"(i64

rnk wrote:
> Oh dear. :(
Can you check that MSVC 2013 is compatible with the code we produce here? (I've 
checked 2015 passes this indirectly on Compiler Explorer.)


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit in r310388


https://reviews.llvm.org/D36411



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


r310388 - Restore previous structure ABI behavior for bit-fields with the packed attribute for PS4 targets.

2017-08-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Aug  8 11:07:17 2017
New Revision: 310388

URL: http://llvm.org/viewvc/llvm-project?rev=310388=rev
Log:
Restore previous structure ABI behavior for bit-fields with the packed 
attribute for PS4 targets.

An ABI change was introduced in r254596 that modified structure layouts when 
the 'packed' attribute was used on one-byte bitfields. Since the PS4 target 
needs to maintain backwards compatibility for all structure layouts, this 
change reintroduces the old behavior for PS4 targets only. It also introduces 
PS4 specific cases to the relevant test.

Patch by Matthew Voss.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/struct-packed-align.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310388=310387=310388=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug  8 11:07:17 
2017
@@ -3202,6 +3202,9 @@ def warn_int_to_void_pointer_cast : Warn
   "cast to %1 from smaller integer type %0">,
   InGroup;
 
+def warn_attribute_ignored_for_field_of_type : Warning<
+  "%0 attribute ignored for field of type %1">,
+  InGroup;
 def warn_no_underlying_type_specified_for_enum_bitfield : Warning<
   "enums in the Microsoft ABI are signed integers by default; consider giving "
   "the enum %0 an unsigned underlying type to make this code portable">,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=310388=310387=310388=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug  8 11:07:17 2017
@@ -1304,14 +1304,28 @@ static void handlePackedAttr(Sema , De
 TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
 Attr.getAttributeSpellingListIndex()));
   else if (FieldDecl *FD = dyn_cast(D)) {
-// Report warning about changed offset in the newer compiler versions.
-if (!FD->getType()->isDependentType() &&
-!FD->getType()->isIncompleteType() && FD->isBitField() &&
-S.Context.getTypeAlign(FD->getType()) <= 8)
-  S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
+bool BitfieldByteAligned = (!FD->getType()->isDependentType() &&
+!FD->getType()->isIncompleteType() &&
+FD->isBitField() &&
+S.Context.getTypeAlign(FD->getType()) <= 8);
+
+if (S.getASTContext().getTargetInfo().getTriple().isPS4()) {
+  if (BitfieldByteAligned)
+// The PS4 target needs to maintain ABI backwards compatibility.
+S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
+  << Attr.getName() << FD->getType();
+  else
+FD->addAttr(::new (S.Context) PackedAttr(
+Attr.getRange(), S.Context, 
Attr.getAttributeSpellingListIndex()));
+} else {
+  // Report warning about changed offset in the newer compiler versions.
+  if (BitfieldByteAligned)
+S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
+
+  FD->addAttr(::new (S.Context) PackedAttr(
+  Attr.getRange(), S.Context, 
Attr.getAttributeSpellingListIndex()));
+}
 
-FD->addAttr(::new (S.Context) PackedAttr(
-Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
   } else
 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
 }

Modified: cfe/trunk/test/Sema/struct-packed-align.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-packed-align.c?rev=310388=310387=310388=diff
==
--- cfe/trunk/test/Sema/struct-packed-align.c (original)
+++ cfe/trunk/test/Sema/struct-packed-align.c Tue Aug  8 11:07:17 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
 // RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-scei-ps4 -verify
 
 // Packed structs.
 struct s {
@@ -146,13 +147,24 @@ extern int n2[__alignof(struct nS) == 1
 // See the documentation of -Wpacked-bitfield-compat for more information.
 struct packed_chars {
   char a:4;
+#ifdef __ORBIS__
+  // Test for pre-r254596 clang behavior on the PS4 target. PS4 must maintain
+  // ABI backwards compatibility.
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{'packed' attribute ignored for field of type 
'char'}}
+  char c:4;
+#else
   char b:8 __attribute__ ((packed));
   // expected-warning@-1 {{'packed' attribute 

r310387 - [OPENMP][DEBUG] Set proper address space info if required by target.

2017-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  8 11:04:06 2017
New Revision: 310387

URL: http://llvm.org/viewvc/llvm-project?rev=310387=rev
Log:
[OPENMP][DEBUG] Set proper address space info if required by target.

Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.

Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.

Added:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310387=310386=310387=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 11:04:06 2017
@@ -2685,6 +2685,14 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPCaptureKind : Attr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let SemaHandler = 0;
+  let Args = [UnsignedArgument<"CaptureKind">];
+  let Documentation = [Undocumented];
+}
+
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310387=310386=310387=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  8 11:04:06 2017
@@ -8527,6 +8527,11 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
+  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
+  /// for \p FD based on DSA for the provided corresponding captured 
declaration
+  /// \p D.
+  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
+
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=310387=310386=310387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Aug  8 11:04:06 2017
@@ -7766,3 +7766,9 @@ void CGOpenMPRuntime::emitOutlinedFuncti
   }
   CGF.EmitRuntimeCall(OutlinedFn, Args);
 }
+
+Address CGOpenMPRuntime::getParameterAddress(CodeGenFunction ,
+ const VarDecl *NativeParam,
+ const VarDecl *TargetParam) const 
{
+  return CGF.GetAddrOfLocalVar(NativeParam);
+}

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310387=310386=310387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  8 11:04:06 2017
@@ -1325,6 +1325,23 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction ,
const OMPDependClause *C);
 
+  /// Translates the native parameter of outlined function if this is required
+  /// for target.
+  /// \param FD Field decl from captured record for the paramater.
+  /// \param NativeParam Parameter itself.
+  virtual const VarDecl *translateParameter(const FieldDecl *FD,
+const VarDecl *NativeParam) const {
+return NativeParam;
+  }
+
+  /// Gets the address of the native argument basing on the address of the
+  /// target-specific parameter.
+  /// \param NativeParam Parameter itself.
+  /// \param TargetParam Corresponding target-specific parameter.
+  virtual Address getParameterAddress(CodeGenFunction ,
+  const VarDecl *NativeParam,
+  const VarDecl *TargetParam) const;
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct 

[PATCH] D36407: [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-08 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.

Aside from a minor naming nit, LGTM!




Comment at: lib/Sema/SemaStmt.cpp:605-608
+static QualType GetTypeBeforeIntegralPromotion(const Expr *) {
+  if (const auto *cleanups = dyn_cast(expr))
 expr = cleanups->getSubExpr();
+  while (const auto *impcast = dyn_cast(expr)) {

Since you're touching the code -- can you change the names to `E` (or some 
other, more descriptive name), `Cleanups` and `Impcast` to meet the coding 
standards?


https://reviews.llvm.org/D36407



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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D36327#835153, @b-sumner wrote:

> In https://reviews.llvm.org/D36327#834032, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D36327#833891, @yaxunl wrote:
> >
> > > In https://reviews.llvm.org/D36327#833653, @bader wrote:
> > >
> > > > Hi Sam,
> > > >
> > > > What do you think about implementing this optimization in target 
> > > > specific optimization pass? Since size/alignment is saved as function 
> > > > parameter in LLVM IR, the optimization can be done in target specific 
> > > > components w/o adding additional conditions to generic library.
> > > >
> > > > Thanks,
> > > > Alexey
> > >
> > >
> > > Hi Alexey,
> > >
> > > The optimization of the power-of-2 type size is implemented as a library 
> > > function. Our backend lacks the capability to link in library code at ISA 
> > > level, so linking of the optimized library function has to be done before 
> > > any target-specific passes. It seems the only place to do this is Clang 
> > > codegen since Clang/llvm does not support target-specific pre-linking 
> > > passes.
> >
> >
> > My general feeling is that it doesn't look like a generic enough change for 
> > the frontend. Even though it is implemented in a generic way, not every 
> > target might have a special support for the power of 2 size and also if 
> > there is such a support not every implementation would handle it as a 
> > library function. But I can see that perhaps LLVM is missing flexibility in 
> > the flow to accommodate these needs. Any change we could try to extend the 
> > compilation flow such that this target specific optimization could happen 
> > before the IR linking?
>
>
> It is trivial to implement the small number of specialized functions this 
> patch adds in terms of the general one if desired, and the general one can 
> continue to be handled as it had been.
>
> We had actually proposed a patch (sorry I don't have the reference handy) to 
> add general mechanism for targets to introduce pre-link passes, but it was 
> not accepted.  We can try again, but I don't really expect more progress.


It would be nice to understand why it has not been accepted and whether we 
could try to argument using this case as an example. It seems like a useful 
feature for toolchains with the IR linking.


https://reviews.llvm.org/D36327



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-08-08 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D34331#831686, @arphaman wrote:

> Don't you need `// UNSUPPORTED: c++98, c++03` since `std::function` is 
> supported in C++11 only?


The tests in libcxx/test/std/utilities/function.objects/ don't have UNSUPPORTED 
lines, and I don't see a lit.local.cfg that sets config.unsupported.  What 
would be different here?


https://reviews.llvm.org/D34331



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


r310386 - [X86] Support 'avx5124vnniw' and 'avx5124fmaps' for __builtin_cpu_supports.

2017-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Aug  8 10:43:44 2017
New Revision: 310386

URL: http://llvm.org/viewvc/llvm-project?rev=310386=rev
Log:
[X86] Support 'avx5124vnniw' and 'avx5124fmaps' for __builtin_cpu_supports.

They still need to be implemented in the intrinsics, the command line, and the 
backend. But this change isn't dependent on any of that and resolves a TODO.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=310386=310385=310386=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Aug  8 10:43:44 2017
@@ -1301,6 +1301,8 @@ bool X86TargetInfo::validateCpuSupports(
   .Case("avx512pf", true)
   .Case("avx512vbmi", true)
   .Case("avx512ifma", true)
+  .Case("avx5124vnniw", true)
+  .Case("avx5124fmaps", true)
   .Case("avx512vpopcntdq", true)
   .Default(false);
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=310386=310385=310386=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug  8 10:43:44 2017
@@ -7375,8 +7375,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   AVX512PF,
   AVX512VBMI,
   AVX512IFMA,
-  AVX5124VNNIW, // TODO implement this fully
-  AVX5124FMAPS, // TODO implement this fully
+  AVX5124VNNIW,
+  AVX5124FMAPS,
   AVX512VPOPCNTDQ,
   MAX
 };
@@ -7411,6 +7411,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 .Case("avx512pf", X86Features::AVX512PF)
 .Case("avx512vbmi", X86Features::AVX512VBMI)
 .Case("avx512ifma", X86Features::AVX512IFMA)
+.Case("avx5124vnniw", X86Features::AVX5124VNNIW)
+.Case("avx5124fmaps", X86Features::AVX5124FMAPS)
 .Case("avx512vpopcntdq", X86Features::AVX512VPOPCNTDQ)
 .Default(X86Features::MAX);
 assert(Feature != X86Features::MAX && "Invalid feature!");

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=310386=310385=310386=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Aug  8 10:43:44 2017
@@ -72,4 +72,7 @@ void verifyfeaturestrings() {
   (void)__builtin_cpu_supports("avx512pf");
   (void)__builtin_cpu_supports("avx512vbmi");
   (void)__builtin_cpu_supports("avx512ifma");
+  (void)__builtin_cpu_supports("avx5124vnniw");
+  (void)__builtin_cpu_supports("avx5124fmaps");
+  (void)__builtin_cpu_supports("avx512vpopcntdq");
 }


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


[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks plausible (not sure how nice it is to use the llvm::Module itself to 
communicate the file name to this bit of logic - I'll leave that to Richard 
Smith to judge, I think)




Comment at: test/CodeGen/debug-info-preprocessed-file.i:10
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c"

Should probably be a bit more specific in the check - verifying that the 
DICompileUnit's DIFile is the one you're checking here. (not that there's any 
other DI* that would have a DIFile here, but still)


https://reviews.llvm.org/D36474



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


[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-08 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 110230.
twoh added a comment.

Relocate.


https://reviews.llvm.org/D36474

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-preprocessed-file.i


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,10 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -483,6 +484,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,10 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -483,6 +484,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29654#835548, @hfinkel wrote:

> In https://reviews.llvm.org/D29654#835392, @gtbercea wrote:
>
> > In https://reviews.llvm.org/D29654#835371, @arphaman wrote:
> >
> > > The last RUN line in the new commit triggers the same assertion failure:
> >
>
>
> ...
>
> > Hi Alex, I'm not sure why it's failing as I can't reproduce the error 
> > locally. Do you have access to a machine with the configuration the test 
> > uses?
>
> Can you reproduce if you specifically force the host target to 
> x86_64-apple-darwin17.0.0 (e.g., you pass -target x86_64-apple-darwin17.0.0)?


Yep, I can ! I didn't realize that would actually work thanks! :)


https://reviews.llvm.org/D29654



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


[PATCH] D36475: [analyzer] Add "create_sink" annotation support to MagentaHandleChecker

2017-08-08 Thread Haowei Wu via Phabricator via cfe-commits
haowei created this revision.
Herald added a subscriber: xazax.hun.

This patch adds "mx_create_sink" annotation support to MagentaHandleChecker to 
address the false positives found in Magenta unit tests. After this patch, when 
a call to a function contains this annotation, MagentaHandleChecker will create 
a sink node which will suppress the handle leaks warnings if the leak is 
post-dominated by this function (similar to a noreturn function).

The target problem it tries to solve can be illustrated in following example:

  static bool handle_info_test(void) {
  BEGIN_TEST;
  
  mx_handle_t event;
  ASSERT_EQ(mx_event_create(0u, ), 0, "");
  mx_handle_t duped;
  mx_status_t status = mx_handle_duplicate(event, MX_RIGHT_SAME_RIGHTS, 
);
  ASSERT_EQ(status, MX_OK, "");
  // 
  }

Unlike the "assert" keyword in C++, the ASSERT_EQ macro will not terminate the 
execution of the unit test program (in other words, it will not invoke a 
noreturn function), instead it will return false and the error will be recorded 
by the unit test runner. Therefore, before this patch, the MagentaHandleChecker 
will report handle leaks on these assertion failures as the function reaches 
return and symbol that contains the acquired handles are acquired. These 
reports are not helpful as assertion failures in unit tests mean test failures. 
With the help of this patch, we add a call to a function with "mx_create_sink" 
annotation in the failure branch in definition "ASSERT_EQ". In this case, the 
MagentaHandleChecker will create a sink node in each assertion failure and 
suppress the warnings if the leaks are post-dominated by assertion failures.


https://reviews.llvm.org/D36475

Files:
  lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
  test/Analysis/mxhandle.c

Index: test/Analysis/mxhandle.c
===
--- test/Analysis/mxhandle.c
+++ test/Analysis/mxhandle.c
@@ -60,6 +60,8 @@
 
 void noReturnFunc() __attribute__((__noreturn__));
 
+void sinkFunc() MX_SYSCALL_PARAM_ATTR(create_sink);
+
 int leakingFunc(int argc, char* argv[]) {
   mx_handle_t sa, sb;
   mx_channel_create(0, , );
@@ -228,6 +230,14 @@
   noReturnFunc(); // Should not report any bugs here
 }
 
+void checkNoLeak17() {
+  mx_handle_t sa, sb;
+  if (mx_channel_create(0, , ) < 0) {
+return;
+  }
+  sinkFunc(); // Should not report any bugs here
+}
+
 void checkLeak01() {
   mx_handle_t sa, sb;
   mx_channel_create(0, , );
Index: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
@@ -123,7 +123,9 @@
   UNPROCESSED_FUNC,
   // When a bug is found in function with this flag, do not report this bug
   // Used to suppress known false positives.
-  DONOTREPORT_FUNC
+  DONOTREPORT_FUNC,
+  // When a function has 'create_sink' annotation , create a sink node.
+  SINK_FUNC
 };
 
 enum AnnotationFlag {
@@ -144,7 +146,8 @@
   // This value is not describing the possible return value of a annotated
   // function. It basically tell the checker do not report any bugs found in
   // this function. Used to suppress false positive reports.
-  DONOTREPORT
+  DONOTREPORT,
+  CREATE_SINK
 };
 
 struct ArgSpec {
@@ -416,7 +419,8 @@
{"handle_escape", ESCAPE},
{"handle_use", NOESCAPE},
{"may_fail", BIFURCATE},
-   {"suppress_warning", DONOTREPORT}};
+   {"suppress_warning", DONOTREPORT},
+   {"create_sink", CREATE_SINK}};
 
   // Hard coded FuncSpec for mx_channel_read and mx_channel_write
   // We currently don't have a clean way to annotate handles passed through
@@ -455,6 +459,10 @@
 FuncKindMap[FuncDecl] == UNPROCESSED_FUNC ||
 FuncKindMap[FuncDecl] == DONOTREPORT_FUNC)
   return false;
+if (FuncKindMap[FuncDecl] == SINK_FUNC) {
+  C.generateSink(C.getState(), C.getPredecessor());
+  return true;
+}
   }
   // Check if the function has annotation and has already been processed before
   if (FuncDeclMap.count(FuncDecl))
@@ -545,6 +553,11 @@
 FuncKindMap[FD] = DONOTREPORT_FUNC;
 return false;
   }
+  if (FS.RetAction == CREATE_SINK) {
+FuncKindMap[FD] = SINK_FUNC;
+Ctx.generateSink(Ctx.getState(), Ctx.getPredecessor());
+return true;
+  }
   SmallVector invalidateSVal;
   ProgramStateRef State = Ctx.getState();
   ASTContext  = State->getStateManager().getContext();
@@ -1035,13 +1048,14 @@
 HasValidAnnotation = true;
   }
   // Return type is not mx_status_t but has annotation other than
-  // SYMBOLIC|DONOTREPORT Consider it as an error
+  // SYMBOLIC|DONOTREPORT|CREATE_SINK Consider it as an error
   if (RetType.getAsString().find(SYSCALL_RETURN_TYPE_NAME) &&
-  (FS.RetAction != SYMBOLIC && FS.RetAction != DONOTREPORT))
+  

[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-08 Thread Taewook Oh via Phabricator via cfe-commits
twoh created this revision.
Herald added a subscriber: aprantl.

Even in the case of the input file is a preprocessed source, clang uses the 
file name of the preprocesses source for debug info (DW_AT_name attribute for 
DW_TAG_compile_unit). However, gcc uses the file name specified in the first 
linemarker instead. This makes more sense because the one specified in the 
linemarker represents the "actual" source file name.

Clang already uses the file name specified in the first linemarker for Module 
name 
(https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendAction.cpp#L779)
 if the input is preprocessed. This patch makes clang to use the same value for 
debug info as well.


https://reviews.llvm.org/D36474

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-preprocessed-file.i


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,10 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -484,6 +485,16 @@
   MainFileName = MainFileDirSS.str();
 }
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
+
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
   }
 
   llvm::dwarf::SourceLanguage LangTag;


Index: test/CodeGen/debug-info-preprocessed-file.i
===
--- /dev/null
+++ test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,10 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -484,6 +485,16 @@
   MainFileName = MainFileDirSS.str();
 }
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
+
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
   }
 
   llvm::dwarf::SourceLanguage LangTag;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D29654#835392, @gtbercea wrote:

> In https://reviews.llvm.org/D29654#835371, @arphaman wrote:
>
> > The last RUN line in the new commit triggers the same assertion failure:
>


...

> Hi Alex, I'm not sure why it's failing as I can't reproduce the error 
> locally. Do you have access to a machine with the configuration the test uses?

Can you reproduce if you specifically force the host target to 
x86_64-apple-darwin17.0.0 (e.g., you pass -target x86_64-apple-darwin17.0.0)?


https://reviews.llvm.org/D29654



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

2017-08-08 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Great. Thanks for the review! I don't have commit access currently.


https://reviews.llvm.org/D36411



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

No, entry 1 has a different pointer (0x000111c01320 vs 0x000111c017d0).

Why is there a `DependentBoundArch` if it's always empty?


https://reviews.llvm.org/D29654



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D35056#834705, @rnk wrote:

> In https://reviews.llvm.org/D35056#834689, @rsmith wrote:
>
> > I also removed some incorrect assumptions from the Win64 ABI code; this 
> > changed the behavior of one testcase from uncopyable-args.cpp 
> > (`implicitly_deleted_copy_ctor::A` is now passed indirect).
>
>
> That's probably not correct, let me take a look... I remember breaking the 
> rules for small types here.


Nevermind, everything looks good there. Thanks for untangling the mess. I only 
have comments on comments.




Comment at: include/clang/AST/DeclCXX.h:420
 
+/// \brief True if this class has at least one non-deleted copy or move
+/// constructor. That would allow passing it by registers.

Isn't this "... at least one *trivial*, non-deleted copy or move 
constructor..."?



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:836
 
-// If this is true, the implicit copy constructor that Sema would have
-// created would not be deleted. FIXME: We should provide a more direct way
-// for CodeGen to ask whether the constructor was deleted.
-if (!RD->hasUserDeclaredCopyConstructor() &&
-!RD->hasUserDeclaredMoveConstructor() &&
-!RD->needsOverloadResolutionForMoveConstructor() &&
-!RD->hasUserDeclaredMoveAssignment() &&
-!RD->needsOverloadResolutionForMoveAssignment())
-  return RAA_Default;
-
-// Otherwise, Sema should have created an implicit copy constructor if
-// needed.
-assert(!RD->needsImplicitCopyConstructor());
-
-// We have to make sure the trivial copy constructor isn't deleted.
-for (const CXXConstructorDecl *CD : RD->ctors()) {
-  if (CD->isCopyConstructor()) {
-assert(CD->isTrivial());
-// We had at least one undeleted trivial copy ctor.  Return directly.
-if (!CD->isDeleted())
-  return RAA_Default;
+// Win64 passes objects with non-deleted, non-trivial copy ctors 
indirectly.
+//

This doesn't seem to match what we've computing, and it doesn't seem quite 
right. MSVC will pass a class with deleted, trivial copy ctors indirectly. 
Would it be correct to rephrase like this?
"If RD has at least one trivial, non-deleted copy constructor, it is passed 
directly. Otherwise, it is passed indirectly."



Comment at: test/CodeGenCXX/uncopyable-args.cpp:101
+
+// In MSVC 2013, the copy ctor is not deleted by a move assignment. In MSVC 
2015, it is.
+// WIN64-18-LABEL: declare void @"\01?foo@implicitly_deleted@@YAXUA@1@@Z"(i64

Oh dear. :(


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D36437: [clang] Get rid of "%T" expansions

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Thanks, most of these looks like potential races between tests waiting to 
happen.


Repository:
  rL LLVM

https://reviews.llvm.org/D36437



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


[PATCH] D36191: [CodeGen] Don't make availability attributes imply default visibility on macos

2017-08-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310382: [Availability] Don't make an availability attribute 
imply default visibility on… (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D36191?vs=109218=110223#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36191

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/test/CodeGen/attr-availability.c


Index: cfe/trunk/test/CodeGen/attr-availability.c
===
--- cfe/trunk/test/CodeGen/attr-availability.c
+++ cfe/trunk/test/CodeGen/attr-availability.c
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }
 
-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }
 
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -216,14 +216,6 @@
 return getVisibilityFromAttr(A);
   }
 
-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@
 Attribute Changes in Clang
 --
 
+- The presence of __attribute__((availability(...))) on a declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...
 
 Windows Support


Index: cfe/trunk/test/CodeGen/attr-availability.c
===
--- cfe/trunk/test/CodeGen/attr-availability.c
+++ cfe/trunk/test/CodeGen/attr-availability.c
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }
 
-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }
 
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -216,14 +216,6 @@
 return getVisibilityFromAttr(A);
   }
 
-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@
 Attribute Changes in Clang
 --
 
+- The presence of __attribute__((availability(...))) on a declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...
 
 Windows Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110222.
morehouse added a comment.

- Define GOOGLE_PROTOBUF_NO_RTTI to remove RTTI requirement.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+case BinaryOp::LE: os << "<="; break;
+case BinaryOp::GE: os << ">="; 

  1   2   >