[PATCH] D50755: [Driver] -print-target-triple and -print-effective-triple options

2018-08-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: beanz, rnk.
Herald added a subscriber: cfe-commits.

These can be used to print Clang target and effective triple.


Repository:
  rC Clang

https://reviews.llvm.org/D50755

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-effective-triple.c
  clang/test/Driver/print-target-triple.c


Index: clang/test/Driver/print-target-triple.c
===
--- /dev/null
+++ clang/test/Driver/print-target-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-target-triple 2>&1 \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck %s
+// CHECK: x86_64-unknown-linux-gnu
Index: clang/test/Driver/print-effective-triple.c
===
--- /dev/null
+++ clang/test/Driver/print-effective-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-effective-triple 2>&1 \
+// RUN: --target=thumb-linux-gnu \
+// RUN:   | FileCheck %s
+// CHECK: armv4t-unknown-linux-gnu
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1672,6 +1672,18 @@
 }
 return false;
   }
+
+  if (C.getArgs().hasArg(options::OPT_print_target_triple)) {
+llvm::outs() << TC.getTripleString() << "\n";
+return false;
+  }
+
+  if (C.getArgs().hasArg(options::OPT_print_effective_triple)) {
+const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
+llvm::outs() << Triple.getTriple() << "\n";
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2348,6 +2348,10 @@
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
   Flags<[Unsupported]>;
+def print_target_triple : Flag<["-", "--"], "print-target-triple">,
+  HelpText<"Print the normalized target triple">;
+def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
+  HelpText<"Print the effective target triple">;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of ">, MetaVarName<"">;
 def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,


Index: clang/test/Driver/print-target-triple.c
===
--- /dev/null
+++ clang/test/Driver/print-target-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-target-triple 2>&1 \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck %s
+// CHECK: x86_64-unknown-linux-gnu
Index: clang/test/Driver/print-effective-triple.c
===
--- /dev/null
+++ clang/test/Driver/print-effective-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-effective-triple 2>&1 \
+// RUN: --target=thumb-linux-gnu \
+// RUN:   | FileCheck %s
+// CHECK: armv4t-unknown-linux-gnu
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1672,6 +1672,18 @@
 }
 return false;
   }
+
+  if (C.getArgs().hasArg(options::OPT_print_target_triple)) {
+llvm::outs() << TC.getTripleString() << "\n";
+return false;
+  }
+
+  if (C.getArgs().hasArg(options::OPT_print_effective_triple)) {
+const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
+llvm::outs() << Triple.getTriple() << "\n";
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2348,6 +2348,10 @@
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
   Flags<[Unsupported]>;
+def print_target_triple : Flag<["-", "--"], "print-target-triple">,
+  HelpText<"Print the normalized target triple">;
+def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
+  HelpText<"Print the effective target triple">;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of ">, MetaVarName<"">;
 def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D50670: Implementation of multiple loops in cxx_loop_proto

2018-08-14 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 160740.
emmettneyman added a comment.

Changed the multiloop protos to nested loop protos. All the protos have an 
inner loop and an outer loop.


Repository:
  rC Clang

https://reviews.llvm.org/D50670

Files:
  clang/tools/clang-fuzzer/cxx_loop_proto.proto
  clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp

Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -30,17 +30,20 @@
 std::string StateSeqToString(std::ostream , const StatementSeq );
 
 // Counter variable to generate new LLVM IR variable names and wrapper function
-std::string get_var() {
+static std::string get_var() {
   static int ctr = 0;
   return "%var" + std::to_string(ctr++);
 }
 
+static bool inner_loop = false;
+
 // Proto to LLVM.
 
 std::string ConstToString(const Const ) {
   return std::to_string(x.val());
 }
 std::string VarRefToString(std::ostream , const VarRef ) {
+  std::string var = inner_loop ? "inner" : "outer";
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
@@ -54,7 +57,8 @@
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr
+ << ", i64 %" << var << "_ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream , const Rvalue ) {
@@ -120,27 +124,37 @@
   for (auto  : x.statements()) {
 os << st;
   }
+  inner_loop = true;
   return os;
 }
 std::ostream <<(std::ostream , const LoopFunction ) {
-  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
-<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
-<< "%1 = icmp sgt i64 %s, 0\n"
-<< "br i1 %1, label %start, label %end\n"
-<< "start:\n"
-<< "br label %loop\n"
-<< "end:\n"
-<< "ret void\n"
-<< "loop:\n"
-<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
-<< x.statements()
-<< "%ctnew = add i64 %ct, 1\n"
-<< "%j = icmp eq i64 %ctnew, %s\n"
-<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
-<< "!0 = distinct !{!0, !1, !2}\n"
-<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
-<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
-<< "}\n";
+  os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+ << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
+ << "%cmp = icmp sgt i64 %s, 0\n"
+ << "br i1 %cmp, label %outer_loop_start, label %end\n"
+ << "outer_loop_start:\n"
+ << "br label %inner_loop_start\n"
+ << "inner_loop_start:\n"
+ << "%outer_ct = phi i64 [%o_ct_new, %outer_loop], [0, %outer_loop_start]\n"
+ << "br label %inner_loop\n"
+ << "end:\n"
+ << "ret void\n"
+ << "outer_loop:\n"
+ << x.outer_statements()
+ << "%o_ct_new = add nuw nsw i64 %outer_ct, 1\n"
+ << "%jmp_outer = icmp eq i64 %o_ct_new, %s\n"
+ << "br i1 %jmp_outer, label %end, label %inner_loop_start\n"
+ << "inner_loop:\n"
+ << "%inner_ct = phi i64 [0, %inner_loop_start], [%i_ct_new, %inner_loop]\n"
+ << x.inner_statements()
+ << "%i_ct_new = add nuw nsw i64 %inner_ct, 1\n"
+ << "%jmp_inner = icmp eq i64 %i_ct_new, %s\n"
+ << "br i1 %jmp_inner, label %outer_loop, label %inner_loop, !llvm.loop !0\n"
+ << "}\n"
+ << "!0 = distinct !{!0, !1, !2}\n"
+ << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+ << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize << "}\n";
+  return os;
 }
 
 // -
Index: clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ clang/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -28,6 +28,8 @@
 
 namespace clang_fuzzer {
 
+static bool inner_loop;
+
 // Forward decls.
 std::ostream <<(std::ostream , const BinaryOp );
 std::ostream <<(std::ostream , const StatementSeq );
@@ -37,13 +39,14 @@
   return os << "(" << x.val() << ")";
 }
 std::ostream <<(std::ostream , const VarRef ) {
+  std::string var = inner_loop ? "i" : "j";
   switch (x.arr()) {
 case VarRef::ARR_A:
-  return os << "a[i]";
+  return os << "a[" << var << "]";
 case VarRef::ARR_B:
-  return os << "b[i]";
+  return os << "b[" << var << "]";
 case VarRef::ARR_C:
-  return os << "c[i]";
+  return os << "c[" << var << "]";
   }
 }
 std::ostream <<(std::ostream , const Rvalue ) {
@@ -109,9 +112,13 @@
   return os;
 }
 

r339747 - Silence "unused variable" warning.

2018-08-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 14 18:06:30 2018
New Revision: 339747

URL: http://llvm.org/viewvc/llvm-project?rev=339747=rev
Log:
Silence "unused variable" warning.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=339747=339746=339747=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Tue Aug 14 
18:06:30 2018
@@ -519,6 +519,7 @@ ProgramStateRef ExprEngine::finishArgume
 if (Optional V =
 getObjectUnderConstruction(State, {E, I}, LC)) {
   SVal VV = *V;
+  (void)VV;
   assert(cast(VV.castAs().getRegion())
  ->getStackFrame()->getParent()
  ->getStackFrame() == LC->getStackFrame());


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


r339745 - [analyzer] Add support for constructors of arguments.

2018-08-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 14 17:33:55 2018
New Revision: 339745

URL: http://llvm.org/viewvc/llvm-project?rev=339745=rev
Log:
[analyzer] Add support for constructors of arguments.

Once CFG-side support for argument construction contexts landed in r338436,
the analyzer could make use of them to evaluate argument constructors properly.

When evaluated as calls, constructors of arguments now use the variable region
of the parameter as their target. The corresponding stack frame does not yet
exist when the parameter is constructed, and this stack frame is created
eagerly.

Construction of functions whose body is unavailable and of virtual functions
is not yet supported. Part of the reason is the analyzer doesn't consistently
use canonical declarations o identify the function in these cases, and every
re-declaration or potential override comes with its own set of parameter
declarations. Also it is less important because if the function is not
inlined, there's usually no benefit in inlining the argument constructor.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
cfe/trunk/test/Analysis/copy-elision.cpp
cfe/trunk/test/Analysis/temporaries.cpp
cfe/trunk/test/Analysis/temporaries.mm

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=339745=339744=339745=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Tue 
Aug 14 17:33:55 2018
@@ -428,21 +428,23 @@ public:
   bool isArgumentConstructedDirectly(unsigned Index) const {
 // This assumes that the object was not yet removed from the state.
 return ExprEngine::getObjectUnderConstruction(
-getState(), {getOriginExpr(), Index}, 
getCalleeStackFrame()).hasValue();
+getState(), {getOriginExpr(), Index}, getLocationContext()).hasValue();
   }
 
   /// Some calls have parameter numbering mismatched from argument numbering.
   /// This function converts an argument index to the corresponding
   /// parameter index. Returns None is the argument doesn't correspond
   /// to any parameter variable.
-  Optional getAdjustedParameterIndex(unsigned ArgumentIndex) const {
-if (dyn_cast_or_null(getOriginExpr()) &&
-dyn_cast_or_null(getDecl())) {
-  // For member operator calls argument 0 on the expression corresponds
-  // to implicit this-parameter on the declaration.
-  return (ArgumentIndex > 0) ? Optional(ArgumentIndex - 1) : 
None;
-}
-return ArgumentIndex;
+  virtual Optional
+  getAdjustedParameterIndex(unsigned ASTArgumentIndex) const {
+return ASTArgumentIndex;
+  }
+
+  /// Some call event sub-classes conveniently adjust mismatching AST indices
+  /// to match parameter indices. This function converts an argument index
+  /// as understood by CallEvent to the argument index as understood by the 
AST.
+  virtual unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const {
+return CallArgumentIndex;
   }
 
   // Iterator access to formal parameters and their types.
@@ -769,6 +771,20 @@ public:
   static bool classof(const CallEvent *CA) {
 return CA->getKind() == CE_CXXMemberOperator;
   }
+
+  Optional
+  getAdjustedParameterIndex(unsigned ASTArgumentIndex) const override {
+// For member operator calls argument 0 on the expression corresponds
+// to implicit this-parameter on the declaration.
+return (ASTArgumentIndex > 0) ? Optional(ASTArgumentIndex - 1)
+  : None;
+  }
+
+  unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const override {
+// For member operator calls argument 0 on the expression corresponds
+// to implicit this-parameter on the declaration.
+return CallArgumentIndex + 1;
+  }
 };
 
 /// Represents an implicit call to a C++ destructor.

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=339745=339744=339745=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ 

[PATCH] D50341: [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339743: [libcxx] Fix XFAILs for aligned allocation tests on 
older OSX versions (authored by ldionne, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50341?vs=160465=160731#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50341

Files:
  libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.sh.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.sh.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_nothrow.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_nothrow.sh.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.sh.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.sh.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -9,12 +9,22 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// XFAIL: with_system_cxx_lib=macosx10.12
-// XFAIL: with_system_cxx_lib=macosx10.11
-// XFAIL: with_system_cxx_lib=macosx10.10
-// XFAIL: with_system_cxx_lib=macosx10.9
-// XFAIL: with_system_cxx_lib=macosx10.7
-// XFAIL: with_system_cxx_lib=macosx10.8
+// dylibs shipped before macosx10.13 do not provide aligned allocation, so that's a link error
+// UNSUPPORTED: with_system_cxx_lib=macosx10.12
+// UNSUPPORTED: with_system_cxx_lib=macosx10.11
+// UNSUPPORTED: with_system_cxx_lib=macosx10.10
+// UNSUPPORTED: with_system_cxx_lib=macosx10.9
+// UNSUPPORTED: with_system_cxx_lib=macosx10.8
+// UNSUPPORTED: with_system_cxx_lib=macosx10.7
+
+// Using aligned allocation functions is a compiler error when deploying to
+// platforms older than macosx10.13
+// UNSUPPORTED: macosx10.12
+// UNSUPPORTED: macosx10.11
+// UNSUPPORTED: macosx10.10
+// UNSUPPORTED: macosx10.9
+// UNSUPPORTED: macosx10.8
+// UNSUPPORTED: macosx10.7
 
 // asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -10,12 +10,24 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: sanitizer-new-delete
 
-// XFAIL: with_system_cxx_lib=macosx10.12
-// XFAIL: with_system_cxx_lib=macosx10.11
-// XFAIL: with_system_cxx_lib=macosx10.10
-// XFAIL: 

[libcxx] r339743 - [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

2018-08-14 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Aug 14 17:30:03 2018
New Revision: 339743

URL: http://llvm.org/viewvc/llvm-project?rev=339743=rev
Log:
[libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

Summary:
Since r338934, Clang emits an error when aligned allocation functions are
used in conjunction with a system libc++ dylib that does not support those
functions. This causes some tests to fail when testing against older libc++
dylibs. This commit marks those tests as UNSUPPORTED, and also documents the
various reasons for the tests being unsupported.

Reviewers: vsapsai, EricWF

Subscribers: christof, dexonsmith, cfe-commits, mclow.lists, EricWF

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

Added:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.sh.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.sh.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.sh.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_nothrow.sh.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.sh.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.sh.cpp
Removed:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_nothrow.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
Modified:
libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

Modified: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp?rev=339743=339742=339743=diff
==
--- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp Tue Aug 
14 17:30:03 2018
@@ -8,12 +8,14 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// XFAIL: with_system_cxx_lib=macosx10.12
-// XFAIL: with_system_cxx_lib=macosx10.11
-// XFAIL: with_system_cxx_lib=macosx10.10
-// XFAIL: with_system_cxx_lib=macosx10.9
-// XFAIL: with_system_cxx_lib=macosx10.8
-// XFAIL: with_system_cxx_lib=macosx10.7
+
+// aligned allocation functions are not provided prior to macosx10.13
+// XFAIL: macosx10.12
+// XFAIL: macosx10.11
+// XFAIL: macosx10.10
+// XFAIL: macosx10.9
+// XFAIL: macosx10.8
+// XFAIL: macosx10.7
 
 #include 
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=339743=339742=339743=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 Tue Aug 14 17:30:03 2018
@@ -12,17 +12,27 @@
 // UNSUPPORTED: sanitizer-new-delete, c++98, 

[libcxx] r339742 - [libc++] Disable failing C11 feature tests for and

2018-08-14 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Aug 14 17:18:01 2018
New Revision: 339742

URL: http://llvm.org/viewvc/llvm-project?rev=339742=rev
Log:
[libc++] Disable failing C11 feature tests for  and 

Summary:
Those tests are breaking the test bots. A Bugzilla has been filed to
make sure those tests are re-enabled: 
https://bugs.llvm.org/show_bug.cgi?id=38572

Reviewers: mclow.lists, EricWF

Subscribers: krytarowski, christof, dexonsmith, cfe-commits

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

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp

libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp?rev=339742=339741=339742=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp Tue Aug 14 
17:18:01 2018
@@ -25,7 +25,7 @@
 #error FLT_RADIX not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_HAS_SUBNORM
 #error FLT_HAS_SUBNORM not defined
 #endif
@@ -55,7 +55,7 @@
 #error DECIMAL_DIG not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_DECIMAL_DIG
 #error FLT_DECIMAL_DIG not defined
 #endif
@@ -165,7 +165,7 @@
 #error LDBL_MIN not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_TRUE_MIN
 #error FLT_TRUE_MIN not defined
 #endif

Modified: 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp?rev=339742=339741=339742=diff
==
--- 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp 
Tue Aug 14 17:18:01 2018
@@ -25,7 +25,7 @@
 #error FLT_RADIX not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_HAS_SUBNORM
 #error FLT_HAS_SUBNORM not defined
 #endif
@@ -55,7 +55,7 @@
 #error DECIMAL_DIG not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_DECIMAL_DIG
 #error FLT_DECIMAL_DIG not defined
 #endif
@@ -165,7 +165,7 @@
 #error LDBL_MIN not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_TRUE_MIN
 #error FLT_TRUE_MIN not defined
 #endif


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


[PATCH] D50748: [libc++] Detect C11 features on non-Clang compilers

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX339741: [libc++] Detect C11 features on non-Clang 
compilers (authored by ldionne, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50748?vs=160725=160727#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D50748

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -328,6 +328,28 @@
 #  define _LIBCPP_NO_CFI
 #endif
 
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#  if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#  endif
+#  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define _LIBCPP_HAS_C11_FEATURES
+#  endif
+#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_C11_FEATURES
+#endif
+#  endif // __linux__
+#endif
+
 #if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
@@ -430,28 +452,6 @@
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-#  if defined(__FreeBSD__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__Fuchsia__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#  endif
-#  if _LIBCPP_GLIBC_PREREQ(2, 17)
-#define _LIBCPP_HAS_C11_FEATURES
-#  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
-#  define _LIBCPP_HAS_QUICK_EXIT
-#  define _LIBCPP_HAS_C11_FEATURES
-#endif
-#  endif // __linux__
-#endif
-
 #if !(__has_feature(cxx_noexcept))
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -328,6 +328,28 @@
 #  define _LIBCPP_NO_CFI
 #endif
 
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#  if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#  endif
+#  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define _LIBCPP_HAS_C11_FEATURES
+#  endif
+#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_C11_FEATURES
+#endif
+#  endif // __linux__
+#endif
+
 #if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
@@ -430,28 +452,6 @@
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-#  if defined(__FreeBSD__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__Fuchsia__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#  endif
-#  if _LIBCPP_GLIBC_PREREQ(2, 17)
-#define _LIBCPP_HAS_C11_FEATURES
-#  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
-#  define _LIBCPP_HAS_QUICK_EXIT
-#  define _LIBCPP_HAS_C11_FEATURES
-#endif
-#  endif // __linux__
-#endif
-
 #if !(__has_feature(cxx_noexcept))
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r339741 - [libc++] Detect C11 features on non-Clang compilers

2018-08-14 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Aug 14 17:16:41 2018
New Revision: 339741

URL: http://llvm.org/viewvc/llvm-project?rev=339741=rev
Log:
[libc++] Detect C11 features on non-Clang compilers

Summary:
The macros were inside `#if defined(_LIBCPP_COMPILER_CLANG)`, which means
we would never detect C11 features on non-Clang compilers. According to
Marshall Clow, this is not the intended behavior.

Reviewers: mclow.lists, EricWF

Subscribers: krytarowski, christof, dexonsmith, cfe-commits

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=339741=339740=339741=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Aug 14 17:16:41 2018
@@ -328,6 +328,28 @@
 #  define _LIBCPP_NO_CFI
 #endif
 
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#  if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#  endif
+#  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define _LIBCPP_HAS_C11_FEATURES
+#  endif
+#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_C11_FEATURES
+#endif
+#  endif // __linux__
+#endif
+
 #if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
@@ -430,28 +452,6 @@ typedef __char32_t char32_t;
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-#  if defined(__FreeBSD__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__Fuchsia__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#  endif
-#  if _LIBCPP_GLIBC_PREREQ(2, 17)
-#define _LIBCPP_HAS_C11_FEATURES
-#  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
-#  define _LIBCPP_HAS_QUICK_EXIT
-#  define _LIBCPP_HAS_C11_FEATURES
-#endif
-#  endif // __linux__
-#endif
-
 #if !(__has_feature(cxx_noexcept))
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif


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


[PATCH] D50748: [libc++] Detect C11 features on non-Clang compilers

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50748



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


[PATCH] D50748: [libc++] Detect C11 features on non-Clang compilers

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: mclow.lists.
Herald added a reviewer: EricWF.
Herald added subscribers: cfe-commits, dexonsmith, christof, krytarowski.

The macros were inside `#if defined(_LIBCPP_COMPILER_CLANG)`, which means
we would never detect C11 features on non-Clang compilers. According to
Marshall Clow, this is not the intended behavior.

[libc++] Disable failing C11 feature tests for  and 

Those tests are breaking the test bots. A Bugzilla has been filed to
make sure those tests are re-enabled: 
https://bugs.llvm.org/show_bug.cgi?id=38572


Repository:
  rCXX libc++

https://reviews.llvm.org/D50748

Files:
  libcxx/include/__config
  libcxx/test/std/depr/depr.c.headers/float_h.pass.cpp
  libcxx/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp

Index: libcxx/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
===
--- libcxx/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
+++ libcxx/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
@@ -25,7 +25,7 @@
 #error FLT_RADIX not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_HAS_SUBNORM
 #error FLT_HAS_SUBNORM not defined
 #endif
@@ -55,7 +55,7 @@
 #error DECIMAL_DIG not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_DECIMAL_DIG
 #error FLT_DECIMAL_DIG not defined
 #endif
@@ -165,7 +165,7 @@
 #error LDBL_MIN not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_TRUE_MIN
 #error FLT_TRUE_MIN not defined
 #endif
Index: libcxx/test/std/depr/depr.c.headers/float_h.pass.cpp
===
--- libcxx/test/std/depr/depr.c.headers/float_h.pass.cpp
+++ libcxx/test/std/depr/depr.c.headers/float_h.pass.cpp
@@ -25,7 +25,7 @@
 #error FLT_RADIX not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_HAS_SUBNORM
 #error FLT_HAS_SUBNORM not defined
 #endif
@@ -55,7 +55,7 @@
 #error DECIMAL_DIG not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_DECIMAL_DIG
 #error FLT_DECIMAL_DIG not defined
 #endif
@@ -165,7 +165,7 @@
 #error LDBL_MIN not defined
 #endif
 
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES) && 0
 #ifndef FLT_TRUE_MIN
 #error FLT_TRUE_MIN not defined
 #endif
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -328,6 +328,28 @@
 #  define _LIBCPP_NO_CFI
 #endif
 
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#  if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#  endif
+#  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define _LIBCPP_HAS_C11_FEATURES
+#  endif
+#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_C11_FEATURES
+#endif
+#  endif // __linux__
+#endif
+
 #if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
@@ -430,28 +452,6 @@
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-#  if defined(__FreeBSD__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__Fuchsia__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#define _LIBCPP_HAS_C11_FEATURES
-#  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
-#define _LIBCPP_HAS_QUICK_EXIT
-#  endif
-#  if _LIBCPP_GLIBC_PREREQ(2, 17)
-#define _LIBCPP_HAS_C11_FEATURES
-#  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
-#  define _LIBCPP_HAS_QUICK_EXIT
-#  define _LIBCPP_HAS_C11_FEATURES
-#endif
-#  endif // __linux__
-#endif
-
 #if !(__has_feature(cxx_noexcept))
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49890: Clang-Tidy Export Problem

2018-08-14 Thread Ahmad Nouralizadeh via Phabricator via cfe-commits
TheAhmad added a comment.

In https://reviews.llvm.org/D49890#1182556, @alexfh wrote:

> Could you describe the specific problem you're solving and provide an 
> example? As mentioned by others, a test would be very welcome as well.


Sorry for so much delay,  @alexfh. I didn't see your comment. I will describe 
in detail:
I wanted to do a source to source transformation on `MPlayer-1.3.0` source 
code. The transformation may require modification of many files and possibly 
repeated modifications in the headers files included in multiple `.c` files. 
Therefore, the changes should be serialized for each translation unit and 
stored in a `YAML` file. At the end, `clang-apply-replacements` will be called 
and transform the entire source code.
The problem is that `clang-tidy` expects a limited format for the compilation 
database. This is the format typically used when the build system generating 
the compilation database is `CMAKE`.  But `MPlayer` uses `Makefile`. Therefore, 
I had to use an external database generator, `Bear`.  In this case, the 
contents of the `YAML` files are OK. But it is not what is expected by 
`clang-tidy`.  `clang-tidy` requires every file path to be absolute, even the 
header files.
The problem (i.e., using relative paths) only arises when the fixes are 
`exported`. Not when they are applied `in-place`. I reused some of the code for 
the in-place case and did some modifications to it. The code is OK, at least 
for my case with `MPlayer`. A small change is still needed to support `merge 
conflicts` which can be brought from the `in-place fix` stuff. It seems that at 
the end the commanlities of the two cases should be put in a function. Then 
this function can be called from both places (i.e., the `in-place fix` and the 
`export fix`).
I am new to `Clang` and do not know what is needed for tests. I am looking 
forward to your reply.
Regards.




Comment at: ClangTidy.cpp:614
+  vfs::FileSystem  = *Files->getVirtualFileSystem();
+  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
+  if (!InitialWorkingDir)

JonasToth wrote:
> TheAhmad wrote:
> > Eugene.Zelenko wrote:
> > > Type is not obvious, so please don't use auto.
> > Hi, Eugene. Why line 352 uses auto?
> He means line 615 (`InitialWorkingDir`). The type of the variable can not be 
> deduced from reading the code.
> 
> The rule is, to write the type once. E.g. `llvm::make_unique(args)` 
> makes it clear, that the type is `MyType`, so you can use `auto` for the 
> variable.
> This is not the case for `InitialWorkingDir`.
Right. I agree. So `line 352` should not use `auto` either.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49890



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


[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 4 inline comments as done.
aaronpuchert added a comment.

@aaron.ballman Maybe you can have a look again — this is much more elegant. I'm 
not sure why I didn't see this in the first place.




Comment at: test/SemaCXX/warn-thread-safety-analysis.cpp:2765-2768
+  // Debatable that there is no warning. Currently we don't track in the scoped
+  // object whether it is active, but just check if the contained locks can be
+  // reacquired. Here they can, because mu has been unlocked manually.
+  scope.Lock();

I have a local patch that addresses this, but I think it should be discussed 
separately as it introduces additional changes.


Repository:
  rC Clang

https://reviews.llvm.org/D49885



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


[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 160719.
aaronpuchert added a comment.

Found a much simpler solution. After introducing a new virtual function 
HandleLock() in FactEntry, I just needed to change two lines in 
ThreadSafetyAnalyzer::addLock. Changes in BuildLockset::handleCall are no 
longer necessary.


Repository:
  rC Clang

https://reviews.llvm.org/D49885

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2621,6 +2621,213 @@
 } // end namespace ReleasableScopedLock
 
 
+namespace RelockableScopedLock {
+
+class SCOPED_LOCKABLE RelockableExclusiveMutexLock {
+public:
+  RelockableExclusiveMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableExclusiveMutexLock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+};
+
+class SCOPED_LOCKABLE RelockableSharedMutexLock {
+public:
+  RelockableSharedMutexLock(Mutex *mu) SHARED_LOCK_FUNCTION(mu);
+  ~RelockableSharedMutexLock() UNLOCK_FUNCTION();
+
+  void Lock() SHARED_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+};
+
+class SharedTraits {};
+class ExclusiveTraits {};
+
+class SCOPED_LOCKABLE RelockableMutexLock {
+public:
+  RelockableMutexLock(Mutex *mu, SharedTraits) SHARED_LOCK_FUNCTION(mu);
+  RelockableMutexLock(Mutex *mu, ExclusiveTraits) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableMutexLock() UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+
+  void ReaderLock() SHARED_LOCK_FUNCTION();
+  void ReaderUnlock() UNLOCK_FUNCTION();
+
+  void PromoteShared() UNLOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION();
+  void DemoteExclusive() UNLOCK_FUNCTION() SHARED_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+
+void print(int);
+
+void write() {
+  RelockableExclusiveMutexLock scope();
+  x = 2;
+  scope.Unlock();
+
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.Lock();
+  x = 4;
+}
+
+void read() {
+  RelockableSharedMutexLock scope();
+  print(x);
+  scope.Unlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.Lock();
+  print(x);
+  x = 4; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void relockExclusive() {
+  RelockableMutexLock scope(, SharedTraits{});
+  print(x);
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.ReaderUnlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.Lock();
+  print(x);
+  x = 4;
+
+  scope.DemoteExclusive();
+  print(x);
+  x = 5; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void relockShared() {
+  RelockableMutexLock scope(, ExclusiveTraits{});
+  print(x);
+  x = 2;
+  scope.Unlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.ReaderLock();
+  print(x);
+  x = 4; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.PromoteShared();
+  print(x);
+  x = 5;
+}
+
+void doubleUnlock1() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+void doubleUnlock2() {
+  RelockableSharedMutexLock scope();
+  scope.Unlock();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+void doubleLock1() {
+  RelockableExclusiveMutexLock scope();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock2() {
+  RelockableSharedMutexLock scope();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock3() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock4() {
+  RelockableSharedMutexLock scope();
+  scope.Unlock();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void directUnlock() {
+  RelockableExclusiveMutexLock scope();
+  mu.Unlock();
+  // Debatable that there is no warning. Currently we don't track in the scoped
+  // object whether it is active, but just check if the contained locks can be
+  // reacquired. Here they can, because mu has been unlocked manually.
+  scope.Lock();
+}
+
+void directRelock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  mu.Lock();
+  // Similarly debatable that there is no warning.
+  

[PATCH] D50341: [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

2018-08-14 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai accepted this revision.
vsapsai added a comment.
This revision is now accepted and ready to land.

I don't have any other comments. Looks good to me.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50341



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


[clang-tools-extra] r339739 - [clangd] update the new test to check for diagnostic's category as well

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:27:03 2018
New Revision: 339739

URL: http://llvm.org/viewvc/llvm-project?rev=339739=rev
Log:
[clangd] update the new test to check for diagnostic's category as well

Modified:
clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test

Modified: clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test?rev=339739=339738=339739=diff
==
--- clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test Tue Aug 
14 15:27:03 2018
@@ -6,6 +6,7 @@
 # CHECK-NEXT:"params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"clangd_fixes": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {


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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2018-08-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ requested changes to this revision.
NoQ added a comment.
This revision now requires changes to proceed.
Herald added subscribers: Szelethus, mikhail.ramalho.

Let's see if this is still necessary after https://reviews.llvm.org/D49443. 
Iterators will be constructed directly into the argument region, so i suspect 
that the manual copy is no longer necessary.


https://reviews.llvm.org/D32906



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


[PATCH] D50571: [clangd] add an extension field to LSP to transfer the diagnostic's category

2018-08-14 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE339738: [clangd] add an extension field to LSP to transfer 
the diagnostics category (authored by arphaman, committed by ).

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50571

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/compile-commands-path.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/extra-flags.test
  test/clangd/fixits.test

Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -506,6 +506,8 @@
 }
 LSPDiag["clangd_fixes"] = std::move(ClangdFixes);
   }
+  if (!Diag.category.empty())
+LSPDiag["category"] = Diag.category;
   DiagnosticsJSON.push_back(std::move(LSPDiag));
 
   auto  = LocalFixIts[Diag];
Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -226,6 +226,7 @@
 clangd::Diagnostic Res;
 Res.range = D.Range;
 Res.severity = getSeverity(D.Severity);
+Res.category = D.Category;
 return Res;
   };
 
@@ -292,6 +293,9 @@
 D.InsideMainFile = InsideMainFile;
 D.File = Info.getSourceManager().getFilename(Info.getLocation());
 D.Severity = DiagLevel;
+D.Category = DiagnosticIDs::getCategoryNameFromID(
+ DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
+ .str();
 return D;
   };
 
Index: clangd/Diagnostics.h
===
--- clangd/Diagnostics.h
+++ clangd/Diagnostics.h
@@ -37,6 +37,7 @@
   std::string File;
   clangd::Range Range;
   DiagnosticsEngine::Level Severity = DiagnosticsEngine::Note;
+  std::string Category;
   // Since File is only descriptive, we store a separate flag to distinguish
   // diags from the main file.
   bool InsideMainFile = false;
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -544,6 +544,12 @@
 
   /// The diagnostic's message.
   std::string message;
+
+  /// The diagnostic's category. Can be omitted.
+  /// An LSP extension that's used to send the name of the category over to the
+  /// client. The category typically describes the compilation stage during
+  /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
+  std::string category;
 };
 
 /// A LSP-specific comparator used to find diagnostic in a container like
Index: test/clangd/did-change-configuration-params.test
===
--- test/clangd/did-change-configuration-params.test
+++ test/clangd/did-change-configuration-params.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits.test
===
--- test/clangd/fixits.test
+++ test/clangd/fixits.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/compile-commands-path-in-initialize.test
===
--- test/clangd/compile-commands-path-in-initialize.test
+++ test/clangd/compile-commands-path-in-initialize.test
@@ -23,13 +23,15 @@
 # CHECK-NEXT:   "params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:   {
+# CHECK-NEXT: "category": "#pragma message Directive",
 # CHECK-NEXT: "message": "MACRO is one",
 ---
 {"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"INPUT_DIR/build-2"}}}
 # CHECK:   "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:   "params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:   {
+# CHECK-NEXT: "category": "#pragma message Directive",
 # CHECK-NEXT: "message": "MACRO is two",
 ---
 {"jsonrpc":"2.0","id":1,"method":"shutdown"}
Index: test/clangd/compile-commands-path.test
===
--- test/clangd/compile-commands-path.test
+++ test/clangd/compile-commands-path.test
@@ -23,20 +23,23 @@
 # CHECK-NEXT:   

[PATCH] D32859: [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

2018-08-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Szelethus.

I think this patch is in good shape.

In https://reviews.llvm.org/D32859#1187551, @baloghadamsoftware wrote:

> I do not see which lines exactly you commented


This was about the `replaceSymbol()` sub. You can traverse history using the 
History tab, or if there's still a greyed out comment you can push the |<< 
button on it to jump to the respective historical diff.

In any case, i think in current form `replaceSymbol()` is much easier to 
understand, but still deserves a short comment, maybe a small example, maybe a 
better name (the word "rebase" comes to mind).


https://reviews.llvm.org/D32859



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


[clang-tools-extra] r339738 - [clangd] add an extension field to LSP to transfer the diagnostic's category

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:21:40 2018
New Revision: 339738

URL: http://llvm.org/viewvc/llvm-project?rev=339738=rev
Log:
[clangd] add an extension field to LSP to transfer the diagnostic's category

This patch adds a 'category' extension field to the LSP diagnostic that's sent
by Clangd. This extension is always on by default.

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test
clang-tools-extra/trunk/test/clangd/compile-commands-path.test
clang-tools-extra/trunk/test/clangd/diagnostics.test
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
clang-tools-extra/trunk/test/clangd/execute-command.test
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/fixits.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=339738=339737=339738=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Aug 14 15:21:40 2018
@@ -506,6 +506,8 @@ void ClangdLSPServer::onDiagnosticsReady
 }
 LSPDiag["clangd_fixes"] = std::move(ClangdFixes);
   }
+  if (!Diag.category.empty())
+LSPDiag["category"] = Diag.category;
   DiagnosticsJSON.push_back(std::move(LSPDiag));
 
   auto  = LocalFixIts[Diag];

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=339738=339737=339738=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Tue Aug 14 15:21:40 2018
@@ -226,6 +226,7 @@ void toLSPDiags(
 clangd::Diagnostic Res;
 Res.range = D.Range;
 Res.severity = getSeverity(D.Severity);
+Res.category = D.Category;
 return Res;
   };
 
@@ -292,6 +293,9 @@ void StoreDiags::HandleDiagnostic(Diagno
 D.InsideMainFile = InsideMainFile;
 D.File = Info.getSourceManager().getFilename(Info.getLocation());
 D.Severity = DiagLevel;
+D.Category = DiagnosticIDs::getCategoryNameFromID(
+ DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
+ .str();
 return D;
   };
 

Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=339738=339737=339738=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Tue Aug 14 15:21:40 2018
@@ -37,6 +37,7 @@ struct DiagBase {
   std::string File;
   clangd::Range Range;
   DiagnosticsEngine::Level Severity = DiagnosticsEngine::Note;
+  std::string Category;
   // Since File is only descriptive, we store a separate flag to distinguish
   // diags from the main file.
   bool InsideMainFile = false;

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=339738=339737=339738=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Tue Aug 14 15:21:40 2018
@@ -544,6 +544,12 @@ struct Diagnostic {
 
   /// The diagnostic's message.
   std::string message;
+
+  /// The diagnostic's category. Can be omitted.
+  /// An LSP extension that's used to send the name of the category over to the
+  /// client. The category typically describes the compilation stage during
+  /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
+  std::string category;
 };
 
 /// A LSP-specific comparator used to find diagnostic in a container like

Modified: 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test?rev=339738=339737=339738=diff
==
--- 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test 
(original)
+++ 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test 
Tue Aug 14 15:21:40 2018
@@ -23,6 +23,7 @@
 # CHECK-NEXT:   "params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:   {
+# CHECK-NEXT: "category": "#pragma message 

[clang-tools-extra] r339737 - [clangd] add missing test from r339454

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:20:35 2018
New Revision: 339737

URL: http://llvm.org/viewvc/llvm-project?rev=339737=rev
Log:
[clangd] add missing test from r339454

I forgot to checkin the test for the fixits into SVN.

Added:
clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test

Added: clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test?rev=339737=auto
==
--- clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test (added)
+++ clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test Tue Aug 
14 15:20:35 2018
@@ -0,0 +1,66 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"publishDiagnostics":{"clangdFixSupport":true}}},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"struct
 Point {}; union Point p;"}}}
+#  CHECK:"method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:"params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"clangd_fixes": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"edit": {
+# CHECK-NEXT:  "changes": {
+# CHECK-NEXT:"file://{{.*}}/foo.c": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"newText": "struct",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:]
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"title": "change 'union' to 'struct'"
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"message": "Use of 'Point' with tag type that does not 
match previous declaration\n\nfoo.c:1:8: note: previous use is here",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 1
+# CHECK-NEXT:  },
+# CHECK-NEXT:  {
+# CHECK-NEXT:"message": "Previous use is here\n\nfoo.c:1:18: error: 
use of 'Point' with tag type that does not match previous declaration",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 12,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 3
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}


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


[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: include/__config:433
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)

ldionne wrote:
> mclow.lists wrote:
> > Should we be using `__ISO_C_VISIBLE` here, or `__STDC_VERSION__`?
> > I didn't change this, but ...
> The weird part is that neither is defined when compiling C++ code..
This means that `TEST_HAS_C11_FEATURES` and `_LIBCPP_HAS_C11_FEATURES` will 
both be disabled all the time.


https://reviews.llvm.org/D50739



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

2018-08-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I guess one of the things the analyzer could find with path-sensitive analysis 
is direct comparison of non-aliasing pointers. Not only this is 
non-deterministic, but there's a related problem that comparison for equality 
would always yield false and is therefore useless. However, there will be many 
false negatives because most of the time it's hard to figure out if pointers 
alias by looking at a small part of the program (a call stack of at most 3-4 
functions in the middle of nowhere), as the analyzer does.


Repository:
  rC Clang

https://reviews.llvm.org/D50488



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


[PATCH] D32845: [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters

2018-08-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Szelethus.

Looks good. I guess we may have to tone down the heuristic about "all template 
functions" if we see it fail.

@a.sidorin and @whisperity have some valid minor comments.


https://reviews.llvm.org/D32845



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


[PATCH] D50740: [SourceManager] isPointWithin: avoid using isBeforeInTranslationUnit, compare buffer offsets directly for lexical correctness

2018-08-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: jkorous, klimek, ioeric, vsapsai, ilya-biryukov.
Herald added a subscriber: dexonsmith.

The current implementation of `isPointWithin` uses `isBeforeInTranslationUnit` 
to check if a location is within a range.
The problem is that `isPointWithin` is used to perform is lexical range check, 
i.e. we want to determine if a location in a particular source file is within a 
source range in the same source file.
The use of `isBeforeInTranslationUnit` is not correct for this use-case, as one 
source file can be included multiple times. Given a source range and a location 
that's lexically contained within that source range (e.g. file.h:1:2->1:10 and 
file:h:1:5),  `isBeforeInTranslationUnit` will fail to correctly determine if a 
source range from the first occurrence of the source file contains a location 
from the second occurrence of the same source file, as the start and end of the 
range are both included before the location.
This patch reimplements `isPointWithin` to ensure that buffer offsets are 
compared directly for lexical correctness.

This patch is a pre-requisuite to fix a bug in clang-rename where we are unable 
to rename a structure in a PCH that has a header that's included multiple times 
(follow-up patch will be posted to update clang-rename to use isPointWithin).

rdar://42746284


Repository:
  rC Clang

https://reviews.llvm.org/D50740

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  unittests/Basic/SourceManagerTest.cpp

Index: unittests/Basic/SourceManagerTest.cpp
===
--- unittests/Basic/SourceManagerTest.cpp
+++ unittests/Basic/SourceManagerTest.cpp
@@ -377,6 +377,68 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isPointWithin) {
+  const char *header = "int x;";
+
+  const char *main = "#include \n"
+ "#include \n";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr MainBuf =
+  llvm::MemoryBuffer::getMemBuffer(main);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(MainBuf)));
+
+  const FileEntry *headerFile =
+  FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
+
+  TrivialModuleLoader ModLoader;
+  MemoryBufferCache PCMCache;
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, &*Target);
+  Preprocessor PP(std::make_shared(), Diags, LangOpts,
+  SourceMgr, PCMCache, HeaderInfo, ModLoader,
+  /*IILookup =*/nullptr,
+  /*OwnsHeaderSearch =*/false);
+  PP.Initialize(*Target);
+
+  PP.EnterMainSourceFile();
+
+  std::vector Tokens;
+  while (1) {
+Token tok;
+PP.Lex(tok);
+if (tok.is(tok::eof))
+  break;
+Tokens.push_back(tok);
+  }
+
+  // Make sure we got the tokens that we expected.
+  ASSERT_EQ(6U, Tokens.size());
+
+  // Make sure the FileIDs are different.
+  SourceLocation L1 = Tokens[0].getLocation();
+  SourceLocation L2 = Tokens[3].getLocation();
+  ASSERT_NE(L1, L2);
+
+  // The location of the 'int' in the first inclusion is lexically within the
+  // range of the 'int' in the second inclusion.
+  ASSERT_TRUE(SourceMgr.isPointWithin(L1, L2, L2));
+  // The location of the 'int' in the second inclusion is lexically within the
+  // range of the 'int' in the first inclusion.
+  ASSERT_TRUE(SourceMgr.isPointWithin(L2, L1, L1));
+  // The location of the 'x' in the second inclusion is lexically within the
+  // range of the 'int' in the first inclusion and ';' in the second inclusion.
+  ASSERT_TRUE(SourceMgr.isPointWithin(Tokens[4].getLocation(), L1,
+  Tokens[5].getLocation()));
+  // The location of the 'int' in the second inclusion is lexically outside of
+  // the 'x' in the first inclusion and ';' in the second inclusion.
+  ASSERT_FALSE(SourceMgr.isPointWithin(Tokens[3].getLocation(),
+   Tokens[1].getLocation(),
+   Tokens[5].getLocation()));
+}
+
 #endif
 
 } // anonymous namespace
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -2028,6 +2028,35 @@
   return IBTUCacheOverflow;
 }
 
+bool SourceManager::isPointWithin(SourceLocation Loc, SourceLocation Start,
+  SourceLocation End) const {
+  assert(Start.isValid() && End.isValid() && Loc.isValid() &&
+ "Passed invalid source location!");
+  assert(Start.isFileID() && End.isFileID() && Loc.isFileID() &&
+ "Passed non-file source location!");
+
+  std::pair PointLoc = getDecomposedLoc(Loc);
+  std::pair StartLoc = getDecomposedLoc(Start);

[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: include/__config:433
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)

mclow.lists wrote:
> Should we be using `__ISO_C_VISIBLE` here, or `__STDC_VERSION__`?
> I didn't change this, but ...
The weird part is that neither is defined when compiling C++ code..


https://reviews.llvm.org/D50739



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


[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-08-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Szelethus.

Looks great, let's land this!


https://reviews.llvm.org/D32747



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


[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__config:433
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)

Should we be using `__ISO_C_VISIBLE` here, or `__STDC_VERSION__`?
I didn't change this, but ...


https://reviews.llvm.org/D50739



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


[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF, dexonsmith.

During the review of https://reviews.llvm.org/D50719, I said:

> The presence/absence of C11 features in the underlying C library does not 
> depend on what version of the C++ language we're compiling with.
>  The tests that use `TEXT_HAS_C11_XXX` should be updated to check 
> `TEST_STD_VER` instead.

This does that.
The detection of C11 features happens no matter what the language level is.
The enabling/disabling of the C++ features is done based on the language level.


https://reviews.llvm.org/D50739

Files:
  include/__config
  include/cstdlib
  test/std/language.support/support.start.term/quick_exit.pass.cpp
  test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
  test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
Index: test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
 // results in a compile error.
Index: test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
@@ -7,6 +7,7 @@
 //
 
//===--===//
 //
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing at_quick_exit when _LIBCPP_HAS_QUICK_EXIT is not 
defined
 // results in a compile error.
Index: test/std/language.support/support.start.term/quick_exit.pass.cpp
===
--- test/std/language.support/support.start.term/quick_exit.pass.cpp
+++ test/std/language.support/support.start.term/quick_exit.pass.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test quick_exit and at_quick_exit
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -430,7 +430,7 @@
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
 #define _LIBCPP_HAS_C11_FEATURES


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
Index: test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
 // results in 

r339731 - Remove obsolete comment

2018-08-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 14 14:34:29 2018
New Revision: 339731

URL: http://llvm.org/viewvc/llvm-project?rev=339731=rev
Log:
Remove obsolete comment

This related to the code as first checked in in r266292 ([ASTImporter]
Implement some expression-related AST node import., 2016-04-14).

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=339731=339730=339731=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Tue Aug 14 14:34:29 2018
@@ -653,7 +653,6 @@ TEST_P(ImportExpr, ImportSwitch) {
 
 TEST_P(ImportExpr, ImportStmtExpr) {
   MatchVerifier Verifier;
-  // NOTE: has() ignores implicit casts, using hasDescendant() to match it
   testImport(
 "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
 Lang_C, "", Lang_C, Verifier,


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


[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-14 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160694.
shuaiwang marked 2 inline comments as done.
shuaiwang added a comment.
Herald added a subscriber: Szelethus.

- Fix a few cases overlooked previously
- More test cases


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619

Files:
  clang-tidy/utils/ExprMutationAnalyzer.cpp
  unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
+++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -114,6 +114,20 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
+  auto AST = tooling::buildASTFromCode(
+  "struct X { template  void mf(); };"
+  "template  void f() { X x; x.mf(); }");
+  auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+
+  AST =
+  tooling::buildASTFromCode("template  void f() { T x; x.mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+}
+
 TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
@@ -292,6 +306,40 @@
   ElementsAre("std::forward(x)"));
 }
 
+TEST(ExprMutationAnalyzerTest, CallUnresolved) {
+  auto AST =
+  tooling::buildASTFromCode("template  void f() { T x; g(x); }");
+  auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
+
+  AST = tooling::buildASTFromCode(
+  "template  void f(T t) { int x; g(t, x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(t, x)"));
+
+  AST = tooling::buildASTFromCode(
+  "template  void g(T t) { int x; t.mf(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("t.mf(x)"));
+
+  AST = tooling::buildASTFromCode(
+  "struct S { template  void mf(); };"
+  "template  void f(S s) { int x; s.mf(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
+
+  AST = tooling::buildASTFromCode("template "
+  "void g(F f) { int x; f(x); } ");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f(x)"));
+
+  AST = tooling::buildASTFromCode(
+  "template  void f() { int x; (void)T(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("T(x)"));
+}
+
 TEST(ExprMutationAnalyzerTest, ReturnAsValue) {
   const auto AST = tooling::buildASTFromCode("int f() { int x; return x; }");
   const auto Results =
@@ -347,6 +395,21 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x"));
 }
 
+TEST(ExprMutationAnalyzerTest, TemplateWithArrayToPointerDecay) {
+  const auto AST = tooling::buildASTFromCode(
+  "template  struct S { static constexpr int v = 8; };"
+  "template <> struct S { static constexpr int v = 4; };"
+  "void g(char*);"
+  "template  void f() { char x[S::v]; g(x); }"
+  "template <> void f() { char y[S::v]; g(y); }");
+  const auto ResultsX =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(ResultsX, AST.get()), ElementsAre("g(x)"));
+  const auto ResultsY =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y"));
+}
+
 TEST(ExprMutationAnalyzerTest, FollowRefModified) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { int x; int& r0 = x; int& r1 = r0; int& r2 = r1; "
@@ -398,21 +461,31 @@
 }
 
 TEST(ExprMutationAnalyzerTest, NestedMemberModified) {
-  const auto AST = tooling::buildASTFromCode(
+  auto AST = tooling::buildASTFromCode(
   "void f() { struct A { int vi; }; struct B { A va; }; "
   "struct C { B vb; }; C x; x.vb.va.vi = 10; }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.vb.va.vi = 10"));
+
+  AST = tooling::buildASTFromCode(
+  "template  void f() { T x; x.y.z = 10; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.y.z = 10"));
 }
 

r339730 - Fix Stmt::ignoreImplicit

2018-08-14 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 14 14:33:28 2018
New Revision: 339730

URL: http://llvm.org/viewvc/llvm-project?rev=339730=rev
Log:
Fix Stmt::ignoreImplicit

Summary:
A CXXBindTemporaryExpr can appear inside an ImplicitCastExpr, and was
not ignored previously.

Fixes the case reported in PR37327.

Reviewers: rsmith, dblaikie, klimek

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=339730=339729=339730=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Tue Aug 14 14:33:28 2018
@@ -113,17 +113,23 @@ void Stmt::EnableStatistics() {
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=339730=339729=339730=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Tue Aug 14 
14:33:28 2018
@@ -1321,6 +1321,45 @@ TEST(IgnoringImplicit, MatchesImplicit)
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();


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


[PATCH] D50666: Fix Stmt::ignoreImplicit

2018-08-14 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339730: Fix Stmt::ignoreImplicit (authored by steveire, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50666

Files:
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1321,6 +1321,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1321,6 +1321,45 @@
   varDecl(has(ignoringImplicit(cxxConstructExpr());
 }
 
+TEST(IgnoringImplicit, MatchesNestedImplicit) {
+  EXPECT_TRUE(matches(R"(
+
+struct OtherType;
+
+struct SomeType
+{
+SomeType() {}
+SomeType(const OtherType&) {}
+SomeType& operator=(OtherType const&) { return *this; }
+};
+
+struct OtherType
+{
+OtherType() {}
+~OtherType() {}
+};
+
+OtherType something()
+{
+return {};
+}
+
+int main()
+{
+SomeType i = something();
+}
+)"
+  , varDecl(
+  hasName("i"),
+  hasInitializer(exprWithCleanups(has(
+cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(
+  has(expr(ignoringImplicit(callExpr(
+  )
+)))
+  )
+  ));
+}
+
 TEST(IgnoringImplicit, DoesNotMatchIncorrectly) {
   EXPECT_TRUE(
   notMatches("class C {}; C a = C();", varDecl(has(cxxConstructExpr();
Index: cfe/trunk/lib/AST/Stmt.cpp
===
--- cfe/trunk/lib/AST/Stmt.cpp
+++ cfe/trunk/lib/AST/Stmt.cpp
@@ -113,17 +113,23 @@
 Stmt *Stmt::IgnoreImplicit() {
   Stmt *s = this;
 
-  if (auto *ewc = dyn_cast(s))
-s = ewc->getSubExpr();
+  Stmt *lasts = nullptr;
 
-  if (auto *mte = dyn_cast(s))
-s = mte->GetTemporaryExpr();
+  while (s != lasts) {
+lasts = s;
 
-  if (auto *bte = dyn_cast(s))
-s = bte->getSubExpr();
+if (auto *ewc = dyn_cast(s))
+  s = ewc->getSubExpr();
 
-  while (auto *ice = dyn_cast(s))
-s = ice->getSubExpr();
+if (auto *mte = dyn_cast(s))
+  s = mte->GetTemporaryExpr();
+
+if (auto *bte = dyn_cast(s))
+  s = bte->getSubExpr();
+
+if (auto *ice = dyn_cast(s))
+  s = ice->getSubExpr();
+  }
 
   return s;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50737: [ASTImporter] Add test for CXXNoexceptExpr

2018-08-14 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50737

Files:
  test/Import/cxx-noexcept-expr/Inputs/F.cpp
  test/Import/cxx-noexcept-expr/test.cpp


Index: test/Import/cxx-noexcept-expr/test.cpp
===
--- /dev/null
+++ test/Import/cxx-noexcept-expr/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXNoexceptExpr
+// CHECK-NEXT: IntegerLiteral
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-noexcept-expr/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-noexcept-expr/Inputs/F.cpp
@@ -0,0 +1 @@
+bool f() { return noexcept(1); }


Index: test/Import/cxx-noexcept-expr/test.cpp
===
--- /dev/null
+++ test/Import/cxx-noexcept-expr/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXNoexceptExpr
+// CHECK-NEXT: IntegerLiteral
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-noexcept-expr/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-noexcept-expr/Inputs/F.cpp
@@ -0,0 +1 @@
+bool f() { return noexcept(1); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50738: Remove vestiges of configure buildsystem

2018-08-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, mgorny.

Remove also the condition to allow in-source builds when using MSVC_IDE.
This may be vestigial and date from a time when llvm CMakeLists.txt had
a similar condition.  The llvm file does not have such a condition, so
this brings them in sync.


Repository:
  rC Clang

https://reviews.llvm.org/D50738

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite 
"
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -285,26 +285,14 @@
 set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
-  message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
-"the makefiles distributed with LLVM. Please create a directory and run cmake "
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+  message(FATAL_ERROR "In-source builds are not allowed. "
+"Please create a directory and run cmake "
 "from there, passing the path to this source directory as the last argument. "
 "This process created the file `CMakeCache.txt' and the directory "
 "`CMakeFiles'. Please delete them.")
 endif()
 
-if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
-  file(GLOB_RECURSE
-tablegenned_files_on_include_dir
-"${CLANG_SOURCE_DIR}/include/clang/*.inc")
-  if( tablegenned_files_on_include_dir )
-message(FATAL_ERROR "Apparently there is a previous in-source build, "
-"probably as the result of running `configure' and `make' on "
-"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n"
-"${tablegenned_files_on_include_dir}\nPlease clean the source directory.")
-  endif()
-endif()
-
 # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
 if(NOT DEFINED CLANG_VERSION_MAJOR)
   set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.

2018-08-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/Cancellation.h:71
+
+class TaskHandle {
+public:

ilya-biryukov wrote:
> I wonder if we should make `TaskHandle` move-only?
> 
> The reasoning is that is can be easily used from multiple threads (since it's 
> used by code dealing with async tasks anyway) and copying it concurrently is 
> a data race.
> On the other hand, calling `cancel()` is perfectly thread-safe and shouldn't 
> cause any problems.
As similar to above mentioned case copying doesn't introduce any data races.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50502



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


Re: r339629 - [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread George Karpenkov via cfe-commits


> On Aug 14, 2018, at 2:17 PM, Reid Kleckner  wrote:
> 
> After this, check-clang no longer worked, it emitted a fatal error because 
> USE_Z3_SOLVER was not in lit_config.params. I worked around it in r339728, 
> but you might want to double check it.

Hm that’s strange, it works for me, and the buildbots are quiet this time.
Sorry for the trouble.
Your change seems safe in either case.

> 
> On Mon, Aug 13, 2018 at 4:13 PM George Karpenkov via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: george.karpenkov
> Date: Mon Aug 13 16:12:43 2018
> New Revision: 339629
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=339629=rev 
> 
> Log:
> [analyzer] [NFC] Introduce separate targets for testing the analyzer: 
> check-clang-analyzer and check-clang-analyzer-z3
> 
> Current testing setup for analyzer tests with Z3 is rather inconvenient:
> 
> There's no way to run the analyzer tests separately (I use
> LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer).
> 
> When Clang is built with Z3 support, there's no way to *not* run tests
> with Z3 solver, and this is often desired, as tests with Z3 solver take
> a very long time.
> 
> This patch introduces two extra targets:
> 
>  - check-clang-analyzer
>  - check-clang-analyzer-z3
> 
> which solve those problems.
> 
> Differential Revision: https://reviews.llvm.org/D50594 
> 
> 
> Modified:
> cfe/trunk/test/Analysis/analyzer_test.py
> cfe/trunk/test/Analysis/lit.local.cfg
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/test/lit.site.cfg.py.in 
> 
> Modified: cfe/trunk/test/Analysis/analyzer_test.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=339629=339628=339629=diff
>  
> 
> ==
> --- cfe/trunk/test/Analysis/analyzer_test.py (original)
> +++ cfe/trunk/test/Analysis/analyzer_test.py Mon Aug 13 16:12:43 2018
> @@ -4,6 +4,10 @@ import lit.TestRunner
>  # Custom format class for static analyzer tests
>  class AnalyzerTest(lit.formats.ShTest):
> 
> +def __init__(self, execute_external, use_z3_solver=False):
> +super(AnalyzerTest, self).__init__(execute_external)
> +self.use_z3_solver = use_z3_solver
> +
>  def execute(self, test, litConfig):
>  results = []
> 
> @@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest):
>  return results[-1]
> 
>  # If z3 backend available, add an additional run line for it
> -if test.config.clang_staticanalyzer_z3 == '1':
> +if self.use_z3_solver == '1':
> +assert(test.config.clang_staticanalyzer_z3 == '1')
>  results.append(self.executeWithAnalyzeSubstitution(
>  saved_test, litConfig, '-analyzer-constraints=z3 
> -DANALYZER_CM_Z3'))
> 
> 
> Modified: cfe/trunk/test/Analysis/lit.local.cfg
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=339629=339628=339629=diff
>  
> 
> ==
> --- cfe/trunk/test/Analysis/lit.local.cfg (original)
> +++ cfe/trunk/test/Analysis/lit.local.cfg Mon Aug 13 16:12:43 2018
> @@ -7,7 +7,7 @@ import site
>  site.addsitedir(os.path.dirname(__file__))
>  import analyzer_test
>  config.test_format = analyzer_test.AnalyzerTest(
> -config.test_format.execute_external)
> +config.test_format.execute_external, config.use_z3_solver)
> 
>  if not config.root.clang_staticanalyzer:
>  config.unsupported = True
> 
> Modified: cfe/trunk/test/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=339629=339628=339629=diff
>  
> 
> ==
> --- cfe/trunk/test/CMakeLists.txt (original)
> +++ cfe/trunk/test/CMakeLists.txt Mon Aug 13 16:12:43 2018
> @@ -88,8 +88,15 @@ endif ()
> 
>  set(CLANG_TEST_PARAMS
>clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
> +  USE_Z3_SOLVER=0
>)
> 
> +set(ANALYZER_TEST_PARAMS
> +  USE_Z3_SOLVER=0)
> +
> +set(ANALYZER_TEST_PARAMS_Z3
> +  USE_Z3_SOLVER=1)
> +
>  if( NOT CLANG_BUILT_STANDALONE )
>list(APPEND CLANG_TEST_DEPS
>  llvm-config
> @@ -126,6 +133,24 @@ add_lit_testsuite(check-clang "Running t
>)
>  set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
> 
> +if (CLANG_ENABLE_STATIC_ANALYZER)
> +  add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
> +${CMAKE_CURRENT_BINARY_DIR}/Analysis
> +

[PATCH] D21767: Fix instantiation of friend function templates

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

Oh, I see.  The code currently tries to work with just the specialization and 
the pattern.  To do the instantiation, we have to find template arguments for 
the context in which the pattern appears.  For function temploids that aren't 
defined in a friend declaration, we can just consider the semantic DC hierarchy 
of the specialization, which will be the same across all redeclarations.  For 
function temploids that *are* defined in a friend declaration, we have to look 
at the lexical DC of the declaration that was actually instantiated from the 
class temploid that defined the friend function, which isn't necessarily the 
specialization because it might have been redeclared after the friend function 
was instantiated.  So your patch is mostly just changing the find-the-pattern 
lookup to remember that lexical DC when we find a pattern this way, which seems 
sensible.  Richard should look over the actual lookup-algorithm changes.




Comment at: include/clang/AST/Decl.h:2443
+  /// defined in a friend declaration, this parameter is assigned pointer to 
the
+  /// class containing the friend declaration.
+  ///

"If this is non-null and the pattern is a friend function declaration, this is 
set to the class containing the friend declaration."



Comment at: lib/AST/Decl.cpp:3389
+  if (Orig->getFriendObjectKind() != Decl::FOK_None) {
+if (auto *RDC = dyn_cast(D->getLexicalDeclContext()))
+  Host = RDC;

I don't think this can fail; a friend should always be lexically nested in a 
class.



Comment at: lib/AST/Decl.cpp:3399
+return Def;
+  }
+}

It's unfortunate that this needs to walk the redeclaration chain itself looking 
for definitions.  Can't you just call `getDefinition` to find the definition 
and then run your extra checks on that?



Comment at: lib/AST/Decl.cpp:3444
+if (MFD->getFriendObjectKind() != Decl::FOK_None)
+  if (auto *DC = dyn_cast(getLexicalDeclContext()))
+if (HostForFriend)

Same observation.


Repository:
  rC Clang

https://reviews.llvm.org/D21767



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


Re: r339629 - [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread Reid Kleckner via cfe-commits
After this, check-clang no longer worked, it emitted a fatal error because
USE_Z3_SOLVER was not in lit_config.params. I worked around it in r339728,
but you might want to double check it.

On Mon, Aug 13, 2018 at 4:13 PM George Karpenkov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: george.karpenkov
> Date: Mon Aug 13 16:12:43 2018
> New Revision: 339629
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339629=rev
> Log:
> [analyzer] [NFC] Introduce separate targets for testing the analyzer:
> check-clang-analyzer and check-clang-analyzer-z3
>
> Current testing setup for analyzer tests with Z3 is rather inconvenient:
>
> There's no way to run the analyzer tests separately (I use
> LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer).
>
> When Clang is built with Z3 support, there's no way to *not* run tests
> with Z3 solver, and this is often desired, as tests with Z3 solver take
> a very long time.
>
> This patch introduces two extra targets:
>
>  - check-clang-analyzer
>  - check-clang-analyzer-z3
>
> which solve those problems.
>
> Differential Revision: https://reviews.llvm.org/D50594
>
> Modified:
> cfe/trunk/test/Analysis/analyzer_test.py
> cfe/trunk/test/Analysis/lit.local.cfg
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/test/lit.site.cfg.py.in
>
> Modified: cfe/trunk/test/Analysis/analyzer_test.py
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=339629=339628=339629=diff
>
> ==
> --- cfe/trunk/test/Analysis/analyzer_test.py (original)
> +++ cfe/trunk/test/Analysis/analyzer_test.py Mon Aug 13 16:12:43 2018
> @@ -4,6 +4,10 @@ import lit.TestRunner
>  # Custom format class for static analyzer tests
>  class AnalyzerTest(lit.formats.ShTest):
>
> +def __init__(self, execute_external, use_z3_solver=False):
> +super(AnalyzerTest, self).__init__(execute_external)
> +self.use_z3_solver = use_z3_solver
> +
>  def execute(self, test, litConfig):
>  results = []
>
> @@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest):
>  return results[-1]
>
>  # If z3 backend available, add an additional run line for it
> -if test.config.clang_staticanalyzer_z3 == '1':
> +if self.use_z3_solver == '1':
> +assert(test.config.clang_staticanalyzer_z3 == '1')
>  results.append(self.executeWithAnalyzeSubstitution(
>  saved_test, litConfig, '-analyzer-constraints=z3
> -DANALYZER_CM_Z3'))
>
>
> Modified: cfe/trunk/test/Analysis/lit.local.cfg
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=339629=339628=339629=diff
>
> ==
> --- cfe/trunk/test/Analysis/lit.local.cfg (original)
> +++ cfe/trunk/test/Analysis/lit.local.cfg Mon Aug 13 16:12:43 2018
> @@ -7,7 +7,7 @@ import site
>  site.addsitedir(os.path.dirname(__file__))
>  import analyzer_test
>  config.test_format = analyzer_test.AnalyzerTest(
> -config.test_format.execute_external)
> +config.test_format.execute_external, config.use_z3_solver)
>
>  if not config.root.clang_staticanalyzer:
>  config.unsupported = True
>
> Modified: cfe/trunk/test/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=339629=339628=339629=diff
>
> ==
> --- cfe/trunk/test/CMakeLists.txt (original)
> +++ cfe/trunk/test/CMakeLists.txt Mon Aug 13 16:12:43 2018
> @@ -88,8 +88,15 @@ endif ()
>
>  set(CLANG_TEST_PARAMS
>clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
> +  USE_Z3_SOLVER=0
>)
>
> +set(ANALYZER_TEST_PARAMS
> +  USE_Z3_SOLVER=0)
> +
> +set(ANALYZER_TEST_PARAMS_Z3
> +  USE_Z3_SOLVER=1)
> +
>  if( NOT CLANG_BUILT_STANDALONE )
>list(APPEND CLANG_TEST_DEPS
>  llvm-config
> @@ -126,6 +133,24 @@ add_lit_testsuite(check-clang "Running t
>)
>  set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
>
> +if (CLANG_ENABLE_STATIC_ANALYZER)
> +  add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer
> tests"
> +${CMAKE_CURRENT_BINARY_DIR}/Analysis
> +PARAMS ${ANALYZER_TEST_PARAMS}
> +DEPENDS ${CLANG_TEST_DEPS})
> +  set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang
> tests")
> +
> +
> +  if (CLANG_ANALYZER_WITH_Z3)
> +add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer
> tests, using Z3 as a solver"
> +  ${CMAKE_CURRENT_BINARY_DIR}/Analysis
> +  PARAMS ${ANALYZER_TEST_PARAMS_Z3}
> +  DEPENDS ${CLANG_TEST_DEPS})
> +set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER
> "Clang tests")
> +  endif()
> +
> +endif()
> +
>  add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
>PARAMS ${CLANG_TEST_PARAMS}
>DEPENDS ${CLANG_TEST_DEPS}
>
> Modified: 

r339728 - Fix lit fatal errors about requiring a USE_Z3_SOLVER param

2018-08-14 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug 14 14:15:57 2018
New Revision: 339728

URL: http://llvm.org/viewvc/llvm-project?rev=339728=rev
Log:
Fix lit fatal errors about requiring a USE_Z3_SOLVER param

Modified:
cfe/trunk/test/lit.site.cfg.py.in

Modified: cfe/trunk/test/lit.site.cfg.py.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.py.in?rev=339728=339727=339728=diff
==
--- cfe/trunk/test/lit.site.cfg.py.in (original)
+++ cfe/trunk/test/lit.site.cfg.py.in Tue Aug 14 14:15:57 2018
@@ -26,7 +26,7 @@ config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
-config.use_z3_solver = "@USE_Z3_SOLVER@"
+config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', 
"@USE_Z3_SOLVER@")
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
@@ -35,7 +35,6 @@ try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-config.use_z3_solver = lit_config.params['USE_Z3_SOLVER']
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args


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


[PATCH] D50487: [CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.

2018-08-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339727: [CFG] [analyzer] Find argument constructors in 
CXXTemporaryObjectExprs. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50487?vs=159844=160689#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50487

Files:
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/test/Analysis/cfg-rich-constructors.cpp


Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -820,6 +820,7 @@
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class 
argument_constructors::D)
+// CXX11-NEXT: 6: [B1.5] (BindTemporary)
+// CXX11-ELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], [B1.11], class argument_constructors::D)
+// CXX11-NOELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], class argument_constructors::D)
+// CXX11-NEXT: 8: [B1.7] (BindTemporary)
+// CXX11-NEXT: 9: [B1.8] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT:10: [B1.9]
+// CXX11-NEXT:11: [B1.10] (CXXConstructExpr, [B1.12], [B1.13]+1, class 
argument_constructors::D)
+// CXX11-NEXT:12: [B1.11] (BindTemporary)
+// CXX11-NEXT:13: argument_constructors::E([B1.6], [B1.12]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX11-NEXT:14: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:15: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:16: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:17: ~argument_constructors::D() (Temporary object destructor)
+// CXX17:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], 
[B1.5]+0, class argument_constructors::D)
+// CXX17-NEXT: 2: [B1.1] (BindTemporary)
+// CXX17-NEXT: 3: argument_constructors::D() (CXXConstructExpr, [B1.4], 
[B1.5]+1, class argument_constructors::D)
+// CXX17-NEXT: 4: [B1.3] (BindTemporary)
+// CXX17-NEXT: 5: argument_constructors::E([B1.2], [B1.4]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX17-NEXT: 6: ~argument_constructors::D() (Temporary object destructor)
+// CXX17-NEXT: 7: ~argument_constructors::D() (Temporary object destructor)
+void passTwoArgumentsIntoAnotherConstructor() {
+  E(D(), D());
+}
 } // end namespace argument_constructors
 
 namespace copy_elision_with_extra_arguments {
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -4352,6 +4352,11 @@
 
 CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
   AddStmtChoice asc) {
+  // If the constructor takes objects as arguments by value, we need to 
properly
+  // construct these objects. Construction contexts we find here aren't for the
+  // constructor C, they're for its arguments only.
+  findConstructionContextsForArguments(C);
+
   autoCreateBlock();
   appendConstructor(Block, C);
   return VisitChildren(C);


Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -820,6 +820,7 @@
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class 

[PATCH] D50487: [CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.

2018-08-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339727: [CFG] [analyzer] Find argument constructors in 
CXXTemporaryObjectExprs. (authored by dergachev, committed by ).
Herald added a subscriber: Szelethus.

Repository:
  rC Clang

https://reviews.llvm.org/D50487

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-rich-constructors.cpp


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -820,6 +820,7 @@
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class 
argument_constructors::D)
+// CXX11-NEXT: 6: [B1.5] (BindTemporary)
+// CXX11-ELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], [B1.11], class argument_constructors::D)
+// CXX11-NOELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], class argument_constructors::D)
+// CXX11-NEXT: 8: [B1.7] (BindTemporary)
+// CXX11-NEXT: 9: [B1.8] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT:10: [B1.9]
+// CXX11-NEXT:11: [B1.10] (CXXConstructExpr, [B1.12], [B1.13]+1, class 
argument_constructors::D)
+// CXX11-NEXT:12: [B1.11] (BindTemporary)
+// CXX11-NEXT:13: argument_constructors::E([B1.6], [B1.12]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX11-NEXT:14: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:15: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:16: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:17: ~argument_constructors::D() (Temporary object destructor)
+// CXX17:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], 
[B1.5]+0, class argument_constructors::D)
+// CXX17-NEXT: 2: [B1.1] (BindTemporary)
+// CXX17-NEXT: 3: argument_constructors::D() (CXXConstructExpr, [B1.4], 
[B1.5]+1, class argument_constructors::D)
+// CXX17-NEXT: 4: [B1.3] (BindTemporary)
+// CXX17-NEXT: 5: argument_constructors::E([B1.2], [B1.4]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX17-NEXT: 6: ~argument_constructors::D() (Temporary object destructor)
+// CXX17-NEXT: 7: ~argument_constructors::D() (Temporary object destructor)
+void passTwoArgumentsIntoAnotherConstructor() {
+  E(D(), D());
+}
 } // end namespace argument_constructors
 
 namespace copy_elision_with_extra_arguments {
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -4352,6 +4352,11 @@
 
 CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
   AddStmtChoice asc) {
+  // If the constructor takes objects as arguments by value, we need to 
properly
+  // construct these objects. Construction contexts we find here aren't for the
+  // constructor C, they're for its arguments only.
+  findConstructionContextsForArguments(C);
+
   autoCreateBlock();
   appendConstructor(Block, C);
   return VisitChildren(C);


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -820,6 +820,7 @@
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class argument_constructors::D)
+// CXX11-NEXT: 6: [B1.5] (BindTemporary)
+// CXX11-ELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, [B1.8], [B1.10], [B1.11], class 

r339727 - [CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.

2018-08-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 14 14:10:46 2018
New Revision: 339727

URL: http://llvm.org/viewvc/llvm-project?rev=339727=rev
Log:
[CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.

CXXTemporaryObjectExpr is a sub-class of CXXConstructExpr. If it has arguments
that are structures passed by value, their respective constructors need to be
handled by providing a ConstructionContext, like for regular function calls and
for regular constructors.

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

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=339727=339726=339727=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Aug 14 14:10:46 2018
@@ -4352,6 +4352,11 @@ CFGBlock *CFGBuilder::VisitCXXFunctional
 
 CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
   AddStmtChoice asc) {
+  // If the constructor takes objects as arguments by value, we need to 
properly
+  // construct these objects. Construction contexts we find here aren't for the
+  // constructor C, they're for its arguments only.
+  findConstructionContextsForArguments(C);
+
   autoCreateBlock();
   appendConstructor(Block, C);
   return VisitChildren(C);

Modified: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-rich-constructors.cpp?rev=339727=339726=339727=diff
==
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp Tue Aug 14 14:10:46 2018
@@ -820,6 +820,7 @@ public:
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@ void passArgumentWithDestructorByReferen
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class 
argument_constructors::D)
+// CXX11-NEXT: 6: [B1.5] (BindTemporary)
+// CXX11-ELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], [B1.11], class argument_constructors::D)
+// CXX11-NOELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], class argument_constructors::D)
+// CXX11-NEXT: 8: [B1.7] (BindTemporary)
+// CXX11-NEXT: 9: [B1.8] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT:10: [B1.9]
+// CXX11-NEXT:11: [B1.10] (CXXConstructExpr, [B1.12], [B1.13]+1, class 
argument_constructors::D)
+// CXX11-NEXT:12: [B1.11] (BindTemporary)
+// CXX11-NEXT:13: argument_constructors::E([B1.6], [B1.12]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX11-NEXT:14: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:15: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:16: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:17: ~argument_constructors::D() (Temporary object destructor)
+// CXX17:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], 
[B1.5]+0, class argument_constructors::D)
+// CXX17-NEXT: 2: [B1.1] (BindTemporary)
+// CXX17-NEXT: 3: argument_constructors::D() (CXXConstructExpr, [B1.4], 
[B1.5]+1, class argument_constructors::D)
+// CXX17-NEXT: 4: [B1.3] (BindTemporary)
+// CXX17-NEXT: 5: argument_constructors::E([B1.2], [B1.4]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX17-NEXT: 6: ~argument_constructors::D() (Temporary object destructor)
+// CXX17-NEXT: 7: ~argument_constructors::D() (Temporary object destructor)
+void passTwoArgumentsIntoAnotherConstructor() {
+  E(D(), D());
+}
 } // end namespace argument_constructors
 
 namespace copy_elision_with_extra_arguments {


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


r339726 - [analyzer] Add a test forgotten in r339088.

2018-08-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 14 14:06:30 2018
New Revision: 339726

URL: http://llvm.org/viewvc/llvm-project?rev=339726=rev
Log:
[analyzer] Add a test forgotten in r339088.

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

Added:
cfe/trunk/test/Analysis/std-c-library-functions-inlined.c

Added: cfe/trunk/test/Analysis/std-c-library-functions-inlined.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions-inlined.c?rev=339726=auto
==
--- cfe/trunk/test/Analysis/std-c-library-functions-inlined.c (added)
+++ cfe/trunk/test/Analysis/std-c-library-functions-inlined.c Tue Aug 14 
14:06:30 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=unix.StdCLibraryFunctions -verify 
%s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux 
-analyzer-checker=unix.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux 
-analyzer-checker=unix.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux 
-analyzer-checker=unix.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux 
-analyzer-checker=unix.StdCLibraryFunctions -verify %s
+
+// This test tests crashes that occur when standard functions are available
+// for inlining.
+
+// expected-no-diagnostics
+
+int isdigit(int _) { return !0; }
+void test_redefined_isdigit(int x) {
+  int (*func)(int) = isdigit;
+  for (; func(x);) // no-crash
+;
+}


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


[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: mclow.lists, EricWF, jasonliu.
Herald added subscribers: ldionne, christof.

When a seed sequence would lead to having no non-zero significant bits in the 
initial state of a `mersenne_twister_engine`, the fallback is to flip the most 
significant bit of the first value that appears in the textual representation 
of the initial state.

rand.eng.mers describes this as setting the value to be 2 to the power of one 
less than w; the previous value encoded in the implementation, namely one less 
than "2 to the power of w", is replaced by the correct value in this patch.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736

Files:
  include/random
  test/libcxx/numerics/rand/rand.eng.mers/
  test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp

Index: test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp
===
--- /dev/null
+++ test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp
@@ -0,0 +1,74 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// class mersenne_twister_engine;
+
+// template  explicit mersenne_twister_engine(Sseq );
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+struct all_zero_seed_seq {
+  typedef unsigned int result_type;
+
+  all_zero_seed_seq() {}
+
+  template 
+  all_zero_seed_seq(InputIterator, InputIterator) {}
+#if TEST_STD_VER >= 11
+  all_zero_seed_seq(std::initializer_list) {}
+#endif
+
+  template 
+  void generate(RandomAccessIterator rb, RandomAccessIterator re) {
+std::fill(rb, re, 0u);
+  }
+
+  std::size_t size() const { return 0u; }
+  template  void param(OutputIterator) const {}
+};
+
+template  void test(void) {
+  const std::size_t state_size = 1u;
+  const std::size_t shift_size = 1u;
+  const std::size_t tempering_l = word_size;
+
+  all_zero_seed_seq q;
+  std::mersenne_twister_engine
+  e(q);
+
+  const result_type Xneg1 = result_type(1) << (word_size - 1);
+  const result_type Y = Xneg1;
+  const result_type X0 = Xneg1 ^ (Y >> 1);
+  assert(e() == X0);
+}
+
+int main() {
+  // Test for k == 1: word_size <= 32.
+  test();
+
+  // Test for k == 2: (32 < word_size <= 64).
+  test();
+}
Index: include/random
===
--- include/random
+++ include/random
@@ -2337,7 +2337,7 @@
 for (size_t __i = 1; __i < __n; ++__i)
 if (__x_[__i] != 0)
 return;
-__x_[0] = _Max;
+__x_[0] = result_type(1) << (__w - 1);
 }
 }
 
@@ -2363,7 +2363,7 @@
 for (size_t __i = 1; __i < __n; ++__i)
 if (__x_[__i] != 0)
 return;
-__x_[0] = _Max;
+__x_[0] = result_type(1) << (__w - 1);
 }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50735: [ASTImporter] Add test for CXXScalarValueInit

2018-08-14 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50735

Files:
  test/Import/cxx-scalar-value-init/Inputs/S.cpp
  test/Import/cxx-scalar-value-init/test.cpp


Index: test/Import/cxx-scalar-value-init/test.cpp
===
--- /dev/null
+++ test/Import/cxx-scalar-value-init/test.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+// CHECK: CXXScalarValueInitExpr
+// CHECK-SAME: 'int'
+
+// CHECK: CXXScalarValueInitExpr
+// CHECK-SAME: 'float'
+
+void expr() {
+  int i = si();
+  float f = sf();
+}
Index: test/Import/cxx-scalar-value-init/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-scalar-value-init/Inputs/S.cpp
@@ -0,0 +1,2 @@
+int si() { return int(); }
+float sf() { return float(); }


Index: test/Import/cxx-scalar-value-init/test.cpp
===
--- /dev/null
+++ test/Import/cxx-scalar-value-init/test.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: CXXScalarValueInitExpr
+// CHECK-SAME: 'int'
+
+// CHECK: CXXScalarValueInitExpr
+// CHECK-SAME: 'float'
+
+void expr() {
+  int i = si();
+  float f = sf();
+}
Index: test/Import/cxx-scalar-value-init/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-scalar-value-init/Inputs/S.cpp
@@ -0,0 +1,2 @@
+int si() { return int(); }
+float sf() { return float(); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50733: [ASTImporter] Add test for ArrayInitLoopExpr

2018-08-14 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50733

Files:
  test/Import/array-init-loop-expr/Inputs/S.cpp
  test/Import/array-init-loop-expr/test.cpp


Index: test/Import/array-init-loop-expr/test.cpp
===
--- /dev/null
+++ test/Import/array-init-loop-expr/test.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+// CHECK: CXXCtorInitializer
+// CHECK-NEXT: ArrayInitLoopExpr
+// CHECK-SAME: 'int [10]'
+
+// CHECK: ArrayInitIndexExpr
+
+void expr() {
+  S s;
+  S copy = s;
+}
Index: test/Import/array-init-loop-expr/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/array-init-loop-expr/Inputs/S.cpp
@@ -0,0 +1,3 @@
+class S {
+  int a[10];
+};


Index: test/Import/array-init-loop-expr/test.cpp
===
--- /dev/null
+++ test/Import/array-init-loop-expr/test.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: CXXCtorInitializer
+// CHECK-NEXT: ArrayInitLoopExpr
+// CHECK-SAME: 'int [10]'
+
+// CHECK: ArrayInitIndexExpr
+
+void expr() {
+  S s;
+  S copy = s;
+}
Index: test/Import/array-init-loop-expr/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/array-init-loop-expr/Inputs/S.cpp
@@ -0,0 +1,3 @@
+class S {
+  int a[10];
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 160680.
ldionne added a comment.
Herald added a subscriber: mgorny.

Add a way to change the default behavior of _LIBCPP_HIDE_FROM_ABI at build 
time. Also, rename the macro to _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE to 
align with other ABI-related macros.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652

Files:
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/DesignDocs/VisibilityMacros.rst
  libcxx/include/__config
  libcxx/include/__config_site.in

Index: libcxx/include/__config_site.in
===
--- libcxx/include/__config_site.in
+++ libcxx/include/__config_site.in
@@ -14,6 +14,7 @@
 #cmakedefine _LIBCPP_ABI_UNSTABLE
 #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
 #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
+#cmakedefine _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
 #cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 #cmakedefine _LIBCPP_HAS_NO_STDIN
 #cmakedefine _LIBCPP_HAS_NO_STDOUT
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -796,7 +796,11 @@
 #endif
 
 #ifndef _LIBCPP_HIDE_FROM_ABI
-#  define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  ifdef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#  else
+#define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
+#  endif
 #endif
 
 #ifdef _LIBCPP_BUILDING_LIBRARY
Index: libcxx/docs/DesignDocs/VisibilityMacros.rst
===
--- libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -42,9 +42,7 @@
 
 **_LIBCPP_HIDE_FROM_ABI**
   Mark a function as not being part of the ABI of any final linked image that
-  uses it, and also as being internal to each TU that uses that function. In
-  other words, the address of a function marked with this attribute is not
-  guaranteed to be the same across translation units.
+  uses it.
 
 **_LIBCPP_HIDE_FROM_ABI_AFTER_V1**
   Mark a function as being hidden from the ABI (per `_LIBCPP_HIDE_FROM_ABI`)
@@ -61,6 +59,21 @@
   ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can
   use it to start removing symbols from the ABI after that stable version.
 
+**_LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE**
+  This macro controls whether symbols hidden from the ABI with `_LIBCPP_HIDE_FROM_ABI`
+  are local to each translation unit in addition to being local to each final
+  linked image. When enabled, this means that translation units compiled
+  with different versions of libc++ can be linked together, since all non
+  ABI-facing functions are local to each translation unit. This allows static
+  archives built with different versions of libc++ to be linked together. This
+  also means that functions marked with `_LIBCPP_HIDE_FROM_ABI` are not guaranteed
+  to have the same address across translation unit boundaries.
+
+  When the macro is not defined (the default), there is no guarantee that
+  translation units compiled with different versions of libc++ can interoperate.
+  However, this leads to code size improvements, since non ABI-facing functions
+  can be deduplicated across translation unit boundaries.
+
 **_LIBCPP_TYPE_VIS**
   Mark a type's typeinfo, vtable and members as having default visibility.
   This attribute cannot be used on class templates.
Index: libcxx/docs/BuildingLibcxx.rst
===
--- libcxx/docs/BuildingLibcxx.rst
+++ libcxx/docs/BuildingLibcxx.rst
@@ -351,6 +351,15 @@
   Build the "unstable" ABI version of libc++. Includes all ABI changing features
   on top of the current stable version.
 
+.. option:: LIBCXX_ABI_HIDDEN_USE_INTERNAL_LINKAGE:BOOL
+
+  **Default**: ``OFF``
+
+  Give internal linkage to all symbols that are not part of the ABI. This
+  allows linking translation units built with different versions of libc++
+  together, at the cost of code bloat (because non exported functions are
+  duplicated in each TU).
+
 .. option:: LIBCXX_ABI_DEFINES:STRING
 
   **Default**: ``""``
Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -120,6 +120,7 @@
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
+option(LIBCXX_ABI_HIDDEN_USE_INTERNAL_LINKAGE "Give internal linkage to symbols that are not part of the ABI" OFF)
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" 

[PATCH] D50732: [ASTImporter] Add test for CXXDefaultInitExpr

2018-08-14 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50732

Files:
  test/Import/cxx-default-init-expr/Inputs/S.cpp
  test/Import/cxx-default-init-expr/test.cpp


Index: test/Import/cxx-default-init-expr/test.cpp
===
--- /dev/null
+++ test/Import/cxx-default-init-expr/test.cpp
@@ -0,0 +1,22 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+// CHECK: CXXCtorInitializer
+// CHECK-SAME: 'int_member'
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'int'
+
+// CHECK-NEXT: CXXCtorInitializer
+// CHECK-SAME: 'float_member'
+// CHECK-SAME: 'float'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'float'
+
+// CHECK-NEXT: CXXCtorInitializer
+// CHECK-SAME: 'class_member'
+// CHECK-SAME: 'Foo'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'Foo'
+
+void expr() {
+  struct S s;
+}
Index: test/Import/cxx-default-init-expr/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-default-init-expr/Inputs/S.cpp
@@ -0,0 +1,9 @@
+struct Foo {
+  int i;
+};
+
+struct S {
+  int int_member = 3;
+  float float_member = 3.0f;
+  Foo class_member = Foo();
+};


Index: test/Import/cxx-default-init-expr/test.cpp
===
--- /dev/null
+++ test/Import/cxx-default-init-expr/test.cpp
@@ -0,0 +1,22 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: CXXCtorInitializer
+// CHECK-SAME: 'int_member'
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'int'
+
+// CHECK-NEXT: CXXCtorInitializer
+// CHECK-SAME: 'float_member'
+// CHECK-SAME: 'float'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'float'
+
+// CHECK-NEXT: CXXCtorInitializer
+// CHECK-SAME: 'class_member'
+// CHECK-SAME: 'Foo'
+// CHECK-NEXT: CXXDefaultInitExpr
+// CHECK-SAME: 'Foo'
+
+void expr() {
+  struct S s;
+}
Index: test/Import/cxx-default-init-expr/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/cxx-default-init-expr/Inputs/S.cpp
@@ -0,0 +1,9 @@
+struct Foo {
+  int i;
+};
+
+struct S {
+  int int_member = 3;
+  float float_member = 3.0f;
+  Foo class_member = Foo();
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50678: [InlineAsm] Update the min-legal-vector-width function attribute based on inputs and outputs to inline assembly

2018-08-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339721: [InlineAsm] Update the min-legal-vector-width 
function attribute based on… (authored by ctopper, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50678

Files:
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/x86-inline-asm-min-vector-width.c


Index: test/CodeGen/x86-inline-asm-min-vector-width.c
===
--- test/CodeGen/x86-inline-asm-min-vector-width.c
+++ test/CodeGen/x86-inline-asm-min-vector-width.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm 
-target-feature +avx512f -o - | FileCheck %s
+
+typedef long long __m128i __attribute__ ((vector_size (16)));
+typedef long long __m256i __attribute__ ((vector_size (32)));
+typedef long long __m512i __attribute__ ((vector_size (64)));
+
+// CHECK: define <2 x i64> @testXMMout(<2 x i64>* %p) #0
+__m128i testXMMout(__m128i *p) {
+  __m128i xmm0;
+  __asm__("vmovdqu %1, %0" :"=v"(xmm0) : "m"(*(__m128i*)p));
+  return xmm0;
+}
+
+// CHECK: define <4 x i64> @testYMMout(<4 x i64>* %p) #1
+__m256i testYMMout(__m256i *p) {
+  __m256i ymm0;
+  __asm__("vmovdqu %1, %0" :"=v"(ymm0) : "m"(*(__m256i*)p));
+  return ymm0;
+}
+
+// CHECK: define <8 x i64> @testZMMout(<8 x i64>* %p) #2
+__m512i testZMMout(__m512i *p) {
+  __m512i zmm0;
+  __asm__("vmovdqu64 %1, %0" :"=v"(zmm0) : "m"(*(__m512i*)p));
+  return zmm0;
+}
+
+// CHECK: define void @testXMMin(<2 x i64> %xmm0, <2 x i64>* %p) #0
+void testXMMin(__m128i xmm0, __m128i *p) {
+  __asm__("vmovdqu %0, %1" : : "v"(xmm0), "m"(*(__m128i*)p));
+}
+
+// CHECK: define void @testYMMin(<4 x i64> %ymm0, <4 x i64>* %p) #1
+void testYMMin(__m256i ymm0, __m256i *p) {
+  __asm__("vmovdqu %0, %1" : : "v"(ymm0), "m"(*(__m256i*)p));
+}
+
+// CHECK: define void @testZMMin(<8 x i64> %zmm0, <8 x i64>* %p) #2
+void testZMMin(__m512i zmm0, __m512i *p) {
+  __asm__("vmovdqu64 %0, %1" : : "v"(zmm0), "m"(*(__m512i*)p));
+}
+
+// CHECK: attributes #0 = {{.*}}"min-legal-vector-width"="128"
+// CHECK: attributes #1 = {{.*}}"min-legal-vector-width"="256"
+// CHECK: attributes #2 = {{.*}}"min-legal-vector-width"="512"
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1979,6 +1979,11 @@
   diag::err_asm_invalid_type_in_input)
 << OutExpr->getType() << OutputConstraint;
   }
+
+  // Update largest vector width for any vector types.
+  if (auto *VT = dyn_cast(ResultRegTypes.back()))
+LargestVectorWidth = std::max(LargestVectorWidth,
+  VT->getPrimitiveSizeInBits());
 } else {
   ArgTypes.push_back(Dest.getAddress().getType());
   Args.push_back(Dest.getPointer());
@@ -2000,6 +2005,10 @@
Arg->getType()))
 Arg = Builder.CreateBitCast(Arg, AdjTy);
 
+  // Update largest vector width for any vector types.
+  if (auto *VT = dyn_cast(Arg->getType()))
+LargestVectorWidth = std::max(LargestVectorWidth,
+  VT->getPrimitiveSizeInBits());
   if (Info.allowsRegister())
 InOutConstraints += llvm::utostr(i);
   else
@@ -2080,6 +2089,11 @@
   CGM.getDiags().Report(S.getAsmLoc(), diag::err_asm_invalid_type_in_input)
   << InputExpr->getType() << InputConstraint;
 
+// Update largest vector width for any vector types.
+if (auto *VT = dyn_cast(Arg->getType()))
+  LargestVectorWidth = std::max(LargestVectorWidth,
+VT->getPrimitiveSizeInBits());
+
 ArgTypes.push_back(Arg->getType());
 Args.push_back(Arg);
 Constraints += InputConstraint;


Index: test/CodeGen/x86-inline-asm-min-vector-width.c
===
--- test/CodeGen/x86-inline-asm-min-vector-width.c
+++ test/CodeGen/x86-inline-asm-min-vector-width.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-feature +avx512f -o - | FileCheck %s
+
+typedef long long __m128i __attribute__ ((vector_size (16)));
+typedef long long __m256i __attribute__ ((vector_size (32)));
+typedef long long __m512i __attribute__ ((vector_size (64)));
+
+// CHECK: define <2 x i64> @testXMMout(<2 x i64>* %p) #0
+__m128i testXMMout(__m128i *p) {
+  __m128i xmm0;
+  __asm__("vmovdqu %1, %0" :"=v"(xmm0) : "m"(*(__m128i*)p));
+  return xmm0;
+}
+
+// CHECK: define <4 x i64> @testYMMout(<4 x i64>* %p) #1
+__m256i testYMMout(__m256i *p) {
+  __m256i ymm0;
+  __asm__("vmovdqu %1, %0" :"=v"(ymm0) : "m"(*(__m256i*)p));
+  return ymm0;
+}
+
+// CHECK: define <8 x i64> @testZMMout(<8 x i64>* %p) #2
+__m512i testZMMout(__m512i *p) {
+  __m512i zmm0;
+  __asm__("vmovdqu64 %1, %0" :"=v"(zmm0) : "m"(*(__m512i*)p));
+  return zmm0;
+}
+
+// CHECK: define void 

r339721 - [InlineAsm] Update the min-legal-vector-width function attribute based on inputs and outputs to inline assembly

2018-08-14 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Aug 14 13:21:05 2018
New Revision: 339721

URL: http://llvm.org/viewvc/llvm-project?rev=339721=rev
Log:
[InlineAsm] Update the min-legal-vector-width function attribute based on 
inputs and outputs to inline assembly

Summary:
Another piece of my ongoing to work for prefer-vector-width.

min-legal-vector-width will eventually be used by the X86 backend to know 
whether it needs to make 512 bits type legal when prefer-vector-width=256. If 
the user used inline assembly that passed in/out a 512-bit register, we need to 
make sure 512 bits are considered legal. Otherwise we'll get an assert failure 
when we try to wire up the inline assembly to the rest of the code.

This patch just checks the LLVM IR types to see if they are vectors and then 
updates the attribute based on their total width. I'm not sure if this is the 
best way to do this or if there's any subtlety I might have missed. So if 
anyone has other opinions on how to do this I'm open to suggestions.

Reviewers: chandlerc, rsmith, rnk

Reviewed By: rnk

Subscribers: eraman, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/x86-inline-asm-min-vector-width.c
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=339721=339720=339721=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Aug 14 13:21:05 2018
@@ -1979,6 +1979,11 @@ void CodeGenFunction::EmitAsmStmt(const
   diag::err_asm_invalid_type_in_input)
 << OutExpr->getType() << OutputConstraint;
   }
+
+  // Update largest vector width for any vector types.
+  if (auto *VT = dyn_cast(ResultRegTypes.back()))
+LargestVectorWidth = std::max(LargestVectorWidth,
+  VT->getPrimitiveSizeInBits());
 } else {
   ArgTypes.push_back(Dest.getAddress().getType());
   Args.push_back(Dest.getPointer());
@@ -2000,6 +2005,10 @@ void CodeGenFunction::EmitAsmStmt(const
Arg->getType()))
 Arg = Builder.CreateBitCast(Arg, AdjTy);
 
+  // Update largest vector width for any vector types.
+  if (auto *VT = dyn_cast(Arg->getType()))
+LargestVectorWidth = std::max(LargestVectorWidth,
+  VT->getPrimitiveSizeInBits());
   if (Info.allowsRegister())
 InOutConstraints += llvm::utostr(i);
   else
@@ -2080,6 +2089,11 @@ void CodeGenFunction::EmitAsmStmt(const
   CGM.getDiags().Report(S.getAsmLoc(), diag::err_asm_invalid_type_in_input)
   << InputExpr->getType() << InputConstraint;
 
+// Update largest vector width for any vector types.
+if (auto *VT = dyn_cast(Arg->getType()))
+  LargestVectorWidth = std::max(LargestVectorWidth,
+VT->getPrimitiveSizeInBits());
+
 ArgTypes.push_back(Arg->getType());
 Args.push_back(Arg);
 Constraints += InputConstraint;

Added: cfe/trunk/test/CodeGen/x86-inline-asm-min-vector-width.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-inline-asm-min-vector-width.c?rev=339721=auto
==
--- cfe/trunk/test/CodeGen/x86-inline-asm-min-vector-width.c (added)
+++ cfe/trunk/test/CodeGen/x86-inline-asm-min-vector-width.c Tue Aug 14 
13:21:05 2018
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm 
-target-feature +avx512f -o - | FileCheck %s
+
+typedef long long __m128i __attribute__ ((vector_size (16)));
+typedef long long __m256i __attribute__ ((vector_size (32)));
+typedef long long __m512i __attribute__ ((vector_size (64)));
+
+// CHECK: define <2 x i64> @testXMMout(<2 x i64>* %p) #0
+__m128i testXMMout(__m128i *p) {
+  __m128i xmm0;
+  __asm__("vmovdqu %1, %0" :"=v"(xmm0) : "m"(*(__m128i*)p));
+  return xmm0;
+}
+
+// CHECK: define <4 x i64> @testYMMout(<4 x i64>* %p) #1
+__m256i testYMMout(__m256i *p) {
+  __m256i ymm0;
+  __asm__("vmovdqu %1, %0" :"=v"(ymm0) : "m"(*(__m256i*)p));
+  return ymm0;
+}
+
+// CHECK: define <8 x i64> @testZMMout(<8 x i64>* %p) #2
+__m512i testZMMout(__m512i *p) {
+  __m512i zmm0;
+  __asm__("vmovdqu64 %1, %0" :"=v"(zmm0) : "m"(*(__m512i*)p));
+  return zmm0;
+}
+
+// CHECK: define void @testXMMin(<2 x i64> %xmm0, <2 x i64>* %p) #0
+void testXMMin(__m128i xmm0, __m128i *p) {
+  __asm__("vmovdqu %0, %1" : : "v"(xmm0), "m"(*(__m128i*)p));
+}
+
+// CHECK: define void @testYMMin(<4 x i64> %ymm0, <4 x i64>* %p) #1
+void testYMMin(__m256i ymm0, __m256i *p) {
+  __asm__("vmovdqu %0, %1" : : "v"(ymm0), "m"(*(__m256i*)p));
+}
+
+// CHECK: define void @testZMMin(<8 x i64> %zmm0, <8 x i64>* %p) #2
+void testZMMin(__m512i zmm0, __m512i *p) {
+  

[PATCH] D50731: [ASTImporter] Add test for ExprWithCleanups

2018-08-14 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D50731

Files:
  test/Import/expr-with-cleanups/Inputs/S.cpp
  test/Import/expr-with-cleanups/test.cpp


Index: test/Import/expr-with-cleanups/test.cpp
===
--- /dev/null
+++ test/Import/expr-with-cleanups/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+// CHECK: ExprWithCleanups
+// CHECK-SAME: 'RAII'
+// CHECK-NEXT: CXXBindTemporaryExpr
+
+void expr() {
+  f();
+}
Index: test/Import/expr-with-cleanups/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/expr-with-cleanups/Inputs/S.cpp
@@ -0,0 +1,8 @@
+struct RAII {
+  int i = 0;
+  RAII() { i++; }
+  ~RAII() { i--; }
+};
+void f() {
+  RAII();
+}


Index: test/Import/expr-with-cleanups/test.cpp
===
--- /dev/null
+++ test/Import/expr-with-cleanups/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: ExprWithCleanups
+// CHECK-SAME: 'RAII'
+// CHECK-NEXT: CXXBindTemporaryExpr
+
+void expr() {
+  f();
+}
Index: test/Import/expr-with-cleanups/Inputs/S.cpp
===
--- /dev/null
+++ test/Import/expr-with-cleanups/Inputs/S.cpp
@@ -0,0 +1,8 @@
+struct RAII {
+  int i = 0;
+  RAII() { i++; }
+  ~RAII() { i--; }
+};
+void f() {
+  RAII();
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50724: SafeStack: Disable Darwin support

2018-08-14 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339720: SafeStack: Disable Darwin support (authored by 
vlad.tsyrklevich, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50724

Files:
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -509,15 +509,6 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
 
-  // SafeStack requires its own runtime libraries
-  // These libraries should be linked first, to make sure the
-  // __safestack_init constructor executes before everything else
-  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
-getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
-  "libclang_rt.safestack_osx.a",
-  toolchains::Darwin::RLO_AlwaysLink);
-  }
-
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -2297,7 +2288,6 @@
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
-Res |= SanitizerKind::SafeStack;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {


Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -509,15 +509,6 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
 
-  // SafeStack requires its own runtime libraries
-  // These libraries should be linked first, to make sure the
-  // __safestack_init constructor executes before everything else
-  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
-getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
-  "libclang_rt.safestack_osx.a",
-  toolchains::Darwin::RLO_AlwaysLink);
-  }
-
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -2297,7 +2288,6 @@
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
-Res |= SanitizerKind::SafeStack;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339720 - SafeStack: Disable Darwin support

2018-08-14 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Tue Aug 14 12:50:41 2018
New Revision: 339720

URL: http://llvm.org/viewvc/llvm-project?rev=339720=rev
Log:
SafeStack: Disable Darwin support

Summary:
Darwin support does not appear to be used as evidenced by the fact that
the runtime has never supported non-trivial programs.

Reviewers: pcc, kubamracek

Reviewed By: pcc

Subscribers: cfe-commits, kcc

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=339720=339719=339720=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Aug 14 12:50:41 2018
@@ -509,15 +509,6 @@ void darwin::Linker::ConstructJob(Compil
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
 
-  // SafeStack requires its own runtime libraries
-  // These libraries should be linked first, to make sure the
-  // __safestack_init constructor executes before everything else
-  if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
-getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
-  "libclang_rt.safestack_osx.a",
-  toolchains::Darwin::RLO_AlwaysLink);
-  }
-
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -2297,7 +2288,6 @@ SanitizerMask Darwin::getSupportedSaniti
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
-Res |= SanitizerKind::SafeStack;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {


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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-14 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.

A few more minor nits to be cleared up, but otherwise LGTM. You should wait for 
@rsmith to sign off before committing in case he has further comments, however.




Comment at: lib/Sema/SemaExpr.cpp:4165
+bool Sema::TypeHasNoDeref(QualType Ty) {
+  // Strip off everything but attributes
+  QualType OldTy;

Missing a full stop at the end of the comment.



Comment at: lib/Sema/SemaExpr.cpp:4167
+  QualType OldTy;
+  while (Ty != OldTy && Ty->getTypeClass() != Type::Attributed) {
+OldTy = Ty;

I'd prefer to use `!isa(Ty)`; I think that's more clear than 
looking at the enumeration.



Comment at: test/Frontend/noderef.c:153
+
+  // Parenthesis
+  (((*((p); // expected-warning{{dereferencing p; was declared with a 
'noderef' type}}

Typo: Parentheses


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D50670: Implementation of multiple loops in cxx_loop_proto

2018-08-14 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Another option would be to allow simple control flow within the loop itself.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50670: Implementation of multiple loops in cxx_loop_proto

2018-08-14 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

In https://reviews.llvm.org/D50670#1199556, @emmettneyman wrote:

> Should I switch my focus to nested loops instead? I think nested loops will 
> increase coverage.


Yes, I'd recommend doing that.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


Re: r339629 - [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread George Karpenkov via cfe-commits
Hi, this should have been fixed by https://reviews.llvm.org/rC339709 


> On Aug 14, 2018, at 12:16 PM, Galina Kistanova  wrote:
> 
> Hello George,
> 
> This commit broke few of our builders:
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/34845
>  
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/19056
>  
> 
> 
> http://lab.llvm.org:8011/builders/clang-lld-x86_64-2stage 
> 
> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu 
> 
> etc...
> 
> ...
> Failing Tests (11):
> Clang :: Analysis/auto-obj-dtors-cfg-output.cpp
> Clang :: Analysis/blocks.mm 
> Clang :: Analysis/cfg-rich-constructors.cpp
> Clang :: Analysis/cfg-rich-constructors.mm 
> 
> Clang :: Analysis/conditional-path-notes.c
> Clang :: Analysis/diagnostics/plist-multi-file.c
> Clang :: Analysis/html-diags.c
> Clang :: Analysis/plist-html-macros.c
> Clang :: Analysis/plist-html-macros.c
> Clang :: Analysis/retain-release-path-notes-gc.m
> Clang :: Analysis/temp-obj-dtors-cfg-output.cpp
> 
> Please have a look ASAP?
> 
> Thanks
> 
> Galina
> 
> 
> On Mon, Aug 13, 2018 at 4:12 PM, George Karpenkov via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: george.karpenkov
> Date: Mon Aug 13 16:12:43 2018
> New Revision: 339629
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=339629=rev 
> 
> Log:
> [analyzer] [NFC] Introduce separate targets for testing the analyzer: 
> check-clang-analyzer and check-clang-analyzer-z3
> 
> Current testing setup for analyzer tests with Z3 is rather inconvenient:
> 
> There's no way to run the analyzer tests separately (I use
> LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer).
> 
> When Clang is built with Z3 support, there's no way to *not* run tests
> with Z3 solver, and this is often desired, as tests with Z3 solver take
> a very long time.
> 
> This patch introduces two extra targets:
> 
>  - check-clang-analyzer
>  - check-clang-analyzer-z3
> 
> which solve those problems.
> 
> Differential Revision: https://reviews.llvm.org/D50594 
> 
> 
> Modified:
> cfe/trunk/test/Analysis/analyzer_test.py
> cfe/trunk/test/Analysis/lit.local.cfg
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/test/lit.site.cfg.py.in 
> 
> Modified: cfe/trunk/test/Analysis/analyzer_test.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=339629=339628=339629=diff
>  
> 
> ==
> --- cfe/trunk/test/Analysis/analyzer_test.py (original)
> +++ cfe/trunk/test/Analysis/analyzer_test.py Mon Aug 13 16:12:43 2018
> @@ -4,6 +4,10 @@ import lit.TestRunner
>  # Custom format class for static analyzer tests
>  class AnalyzerTest(lit.formats.ShTest):
> 
> +def __init__(self, execute_external, use_z3_solver=False):
> +super(AnalyzerTest, self).__init__(execute_external)
> +self.use_z3_solver = use_z3_solver
> +
>  def execute(self, test, litConfig):
>  results = []
> 
> @@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest):
>  return results[-1]
> 
>  # If z3 backend available, add an additional run line for it
> -if test.config.clang_staticanalyzer_z3 == '1':
> +if self.use_z3_solver == '1':
> +assert(test.config.clang_staticanalyzer_z3 == '1')
>  results.append(self.executeWithAnalyzeSubstitution(
>  saved_test, litConfig, '-analyzer-constraints=z3 
> -DANALYZER_CM_Z3'))
> 
> 
> Modified: cfe/trunk/test/Analysis/lit.local.cfg
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=339629=339628=339629=diff
>  
> 
> ==
> --- cfe/trunk/test/Analysis/lit.local.cfg (original)
> +++ cfe/trunk/test/Analysis/lit.local.cfg Mon Aug 13 16:12:43 2018
> @@ -7,7 +7,7 @@ import site
>  site.addsitedir(os.path.dirname(__file__))
>  import analyzer_test
>  config.test_format = analyzer_test.AnalyzerTest(
> -config.test_format.execute_external)
> +config.test_format.execute_external, config.use_z3_solver)
> 
>  if not 

[PATCH] D50214: Add inherited attributes before parsed attributes.

2018-08-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/DeclBase.cpp:854-859
+  auto I = Attrs.begin(), E = Attrs.end();
+  for (; I != E; ++I) {
+if (!(*I)->isInherited())
+  break;
+  }
+  Attrs.insert(I, A);

Meinersbur wrote:
> aaron.ballman wrote:
> > The unfortunate part about this is that inherited attributes are fairly 
> > common, so this extra searching may happen more often than we'd like. I 
> > wonder how bad it would be to keep track of the location within the list 
> > where the inherited attributes start. Then again, the list of attributes 
> > should be relatively short in most cases, so this search isn't likely to be 
> > too expensive.
> > 
> > Having some performance measurements might help decide this, too.
> Timed clang-compilation using perf (`perf stat bin/clang 
> llvm/unittests/IR/InstructionsTest.cpp ...`), before this patch (r339574):
> ```
>7647.415800  task-clock (msec) #0.983 CPUs utilized
>289  context-switches  #0.038 K/sec
> 26  cpu-migrations#0.003 K/sec
> 86,494  page-faults   #0.011 M/sec
> 19,068,741,863  cycles#2.493 GHz
> 26,581,355,844  instructions  #1.39  insn per cycle
>  6,242,394,037  branches  #  816.275 M/sec
>128,405,656  branch-misses #2.06% of all branches
> 
>7.779848330 seconds time elapsed
> ```
> 
> With this patch:
> ```
>7679.173467  task-clock (msec) #0.987 CPUs utilized
>321  context-switches  #0.042 K/sec
> 23  cpu-migrations#0.003 K/sec
> 86,071  page-faults   #0.011 M/sec
> 19,150,248,538  cycles#2.494 GHz
> 26,667,465,697  instructions  #1.39  insn per cycle
>  6,262,381,898  branches  #  815.502 M/sec
>128,527,669  branch-misses #2.05% of all branches
> 
>7.779477815 seconds time elapsed
> ```
> (Intel(R) Xeon(R) Platinum 8180M CPU @ 2.50GHz)
> 
> The vector insert operation is also be `O(n)`. If the number of non-inherited 
> is expected to be smaller, we can instead search for the first inherited 
> attribute starting at the end of the vector. If we want to avoid the `O(n)` 
> entirely, we need one list for inherited and another for non-inherited 
> attributes.
Thank you for gathering this data -- those perf numbers look reasonable to me. 
We can refactor for performance later if it ever turns up on the hot path.


Repository:
  rC Clang

https://reviews.llvm.org/D50214



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


[PATCH] D50724: SafeStack: Disable Darwin support

2018-08-14 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D50724



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


[PATCH] D50341: [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D50341#1198863, @ldionne wrote:

> In https://reviews.llvm.org/D50341#1198339, @vsapsai wrote:
>
> > What about defining a feature for unsupported configurations? I've tried
> >
> >   if '__cpp_aligned_new' not in macros or \
> >   intMacroValue(macros['__cpp_aligned_new']) < 201606:
> >   self.config.available_features.add('libcpp-no-aligned-new')
> >   
> >
> > and `// UNSUPPORTED: libcpp-no-aligned-new`. Seems to be working but it's 
> > not sufficient. For example, clang-6 for old macOS versions would define 
> > `__cpp_aligned_new` but a test would fail. Still, we can use another 
> > feature, not necessarily macro-based. Though probably something like 
> > `libcpp-no-aligned-new` can replace `// UNSUPPORTED: c++98, c++03, c++11, 
> > c++14`.
>
>
> I thought about something like this, but it would only be useful in a couple 
> of places, and I still don't understand why the tests are marked as 
> unsupported on some compilers at all. Also, there's already a feature called 
> `no-aligned-alloc`, which tests whether `-faligned-alloc` is supported, so we 
> should avoid confusing both.


After discussing with Volodymyr, it's not clear exactly how we might create a 
`libcpp-no-aligned-new` check that properly expresses when aligned allocations 
are available or not. It also seems like there are no other lit features based 
on such a combination of compiler/target platform/standard/system_cxx_lib. I 
think we're better off just keeping the duplication of `UNSUPPORTED` cases 
right now, and we can revisit this idea in the future if we find ourselves 
needing that feature again.

Is there any blocking comment on this patch? I'd like to get it through to see 
if it fixes our testers (and Marshall's local testing, too).


Repository:
  rCXX libc++

https://reviews.llvm.org/D50341



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


Re: r339629 - [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread Galina Kistanova via cfe-commits
Hello George,

This commit broke few of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/34845
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/19056

http://lab.llvm.org:8011/builders/clang-lld-x86_64-2stage
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu
etc...

...
Failing Tests (11):
Clang :: Analysis/auto-obj-dtors-cfg-output.cpp
Clang :: Analysis/blocks.mm
Clang :: Analysis/cfg-rich-constructors.cpp
Clang :: Analysis/cfg-rich-constructors.mm
Clang :: Analysis/conditional-path-notes.c
Clang :: Analysis/diagnostics/plist-multi-file.c
Clang :: Analysis/html-diags.c
Clang :: Analysis/plist-html-macros.c
Clang :: Analysis/plist-html-macros.c
Clang :: Analysis/retain-release-path-notes-gc.m
Clang :: Analysis/temp-obj-dtors-cfg-output.cpp

Please have a look ASAP?

Thanks

Galina


On Mon, Aug 13, 2018 at 4:12 PM, George Karpenkov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: george.karpenkov
> Date: Mon Aug 13 16:12:43 2018
> New Revision: 339629
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339629=rev
> Log:
> [analyzer] [NFC] Introduce separate targets for testing the analyzer:
> check-clang-analyzer and check-clang-analyzer-z3
>
> Current testing setup for analyzer tests with Z3 is rather inconvenient:
>
> There's no way to run the analyzer tests separately (I use
> LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer).
>
> When Clang is built with Z3 support, there's no way to *not* run tests
> with Z3 solver, and this is often desired, as tests with Z3 solver take
> a very long time.
>
> This patch introduces two extra targets:
>
>  - check-clang-analyzer
>  - check-clang-analyzer-z3
>
> which solve those problems.
>
> Differential Revision: https://reviews.llvm.org/D50594
>
> Modified:
> cfe/trunk/test/Analysis/analyzer_test.py
> cfe/trunk/test/Analysis/lit.local.cfg
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/test/lit.site.cfg.py.in
>
> Modified: cfe/trunk/test/Analysis/analyzer_test.py
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Analysis/analyzer_test.py?rev=339629=339628=339629=diff
> 
> ==
> --- cfe/trunk/test/Analysis/analyzer_test.py (original)
> +++ cfe/trunk/test/Analysis/analyzer_test.py Mon Aug 13 16:12:43 2018
> @@ -4,6 +4,10 @@ import lit.TestRunner
>  # Custom format class for static analyzer tests
>  class AnalyzerTest(lit.formats.ShTest):
>
> +def __init__(self, execute_external, use_z3_solver=False):
> +super(AnalyzerTest, self).__init__(execute_external)
> +self.use_z3_solver = use_z3_solver
> +
>  def execute(self, test, litConfig):
>  results = []
>
> @@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest):
>  return results[-1]
>
>  # If z3 backend available, add an additional run line for it
> -if test.config.clang_staticanalyzer_z3 == '1':
> +if self.use_z3_solver == '1':
> +assert(test.config.clang_staticanalyzer_z3 == '1')
>  results.append(self.executeWithAnalyzeSubstitution(
>  saved_test, litConfig, '-analyzer-constraints=z3
> -DANALYZER_CM_Z3'))
>
>
> Modified: cfe/trunk/test/Analysis/lit.local.cfg
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Analysis/lit.local.cfg?rev=339629=339628=339629=diff
> 
> ==
> --- cfe/trunk/test/Analysis/lit.local.cfg (original)
> +++ cfe/trunk/test/Analysis/lit.local.cfg Mon Aug 13 16:12:43 2018
> @@ -7,7 +7,7 @@ import site
>  site.addsitedir(os.path.dirname(__file__))
>  import analyzer_test
>  config.test_format = analyzer_test.AnalyzerTest(
> -config.test_format.execute_external)
> +config.test_format.execute_external, config.use_z3_solver)
>
>  if not config.root.clang_staticanalyzer:
>  config.unsupported = True
>
> Modified: cfe/trunk/test/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CMakeLists.txt?rev=339629=339628=339629=diff
> 
> ==
> --- cfe/trunk/test/CMakeLists.txt (original)
> +++ cfe/trunk/test/CMakeLists.txt Mon Aug 13 16:12:43 2018
> @@ -88,8 +88,15 @@ endif ()
>
>  set(CLANG_TEST_PARAMS
>clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
> +  USE_Z3_SOLVER=0
>)
>
> +set(ANALYZER_TEST_PARAMS
> +  USE_Z3_SOLVER=0)
> +
> +set(ANALYZER_TEST_PARAMS_Z3
> +  USE_Z3_SOLVER=1)
> +
>  if( NOT CLANG_BUILT_STANDALONE )
>list(APPEND CLANG_TEST_DEPS
>  llvm-config
> @@ -126,6 +133,24 @@ add_lit_testsuite(check-clang "Running t
>)
>  set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
>
> +if (CLANG_ENABLE_STATIC_ANALYZER)
> +  add_lit_testsuite(check-clang-analyzer "Running the Clang 

[PATCH] D50535: Fix selective formatting of ObjC scope

2018-08-14 Thread Arnaud Coomans via Phabricator via cfe-commits
acoomans added a comment.

@jolesiak let me know what you think


Repository:
  rC Clang

https://reviews.llvm.org/D50535



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


[PATCH] D49074: [Analyzer] [WIP] Basic support for multiplication and division in the constraint manager

2018-08-14 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@baloghadamsoftware @xazax.hun we've had very promising results with using Z3 
for refutation so far, almost at no cost, see Mikhail's recent email on cfe-dev 
(and sometimes at a negative cost!).
Do you still not want to try it first? False negatives could be addressed as 
well separately (e.g. by giving a checkers an option to cross-check the report 
with a more expensive solver before throwing), currently false positives are a 
far more pressing problem.


https://reviews.llvm.org/D49074



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-14 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x updated this revision to Diff 160660.
cdavis5x added a comment.

- Get rid of DISPATCHER_CONTEXT def for ARM. We only support ARM on Win8+ 
anyway.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564

Files:
  include/__libunwind_config.h
  src/AddressSpace.hpp
  src/CMakeLists.txt
  src/Unwind-seh.cpp
  src/UnwindCursor.hpp
  src/UnwindLevel1-gcc-ext.c
  src/UnwindLevel1.c
  src/config.h
  src/libunwind_ext.h

Index: src/libunwind_ext.h
===
--- src/libunwind_ext.h
+++ src/libunwind_ext.h
@@ -17,6 +17,12 @@
 #include 
 #include 
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+  #include 
+  #include 
+  #include 
+#endif
+
 #define UNW_STEP_SUCCESS 1
 #define UNW_STEP_END 0
 
@@ -33,6 +39,28 @@
 extern void _unw_add_dynamic_fde(unw_word_t fde);
 extern void _unw_remove_dynamic_fde(unw_word_t fde);
 
+// Provide a definition for the DISPATCHER_CONTEXT struct for old (Win7 and
+// earlier) SDKs.
+// MinGW-w64 has always provided this struct.
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && !defined(__MINGW32__) && VER_PRODUCTBUILD < 8000
+  #if defined(__x86_64__)
+typedef struct _DISPATCHER_CONTEXT {
+  ULONG64 ControlPc;
+  ULONG64 ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG64 EstablisherFrame;
+  ULONG64 TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG Fill0;
+} DISPATCHER_CONTEXT;
+  #endif
+typedef DISPATCHER_CONTEXT* PDISPATCHER_CONTEXT;
+#endif
+
 #if defined(_LIBUNWIND_ARM_EHABI)
 extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);
 extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -38,7 +38,11 @@
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
 #elif defined(_WIN32)
-  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #ifdef __SEH__
+#define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
+  #else
+#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #endif
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -32,6 +32,8 @@
 
 #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
+#ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND
+
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
   unw_init_local(cursor, uc);
@@ -449,6 +451,7 @@
   return result;
 }
 
+#endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND
 
 /// Called by personality handler during phase 2 if a foreign exception
 // is caught.
Index: src/UnwindLevel1-gcc-ext.c
===
--- src/UnwindLevel1-gcc-ext.c
+++ src/UnwindLevel1-gcc-ext.c
@@ -25,6 +25,10 @@
 
 #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#define private_1 private_[0]
+#endif
+
 ///  Called by __cxa_rethrow().
 _LIBUNWIND_EXPORT _Unwind_Reason_Code
 _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -18,18 +18,40 @@
 #include 
 #include 
 
+#ifdef _WIN32
+  #include 
+#endif
 #ifdef __APPLE__
   #include 
 #endif
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#  ifdef _LIBUNWIND_TARGET_X86_64
+struct UNWIND_INFO {
+  BYTE Version : 3;
+  BYTE Flags : 5;
+  BYTE SizeOfProlog;
+  BYTE CountOfCodes;
+  BYTE FrameRegister : 4;
+  BYTE FrameOffset : 4;
+  WORD UnwindCodes[2];
+};
+#  endif
+
+extern "C" _Unwind_Reason_Code __libunwind_seh_personality(
+int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception *,
+struct _Unwind_Context *);
+
+#endif
+
 #include "config.h"
 
 #include "AddressSpace.hpp"
 #include "CompactUnwinder.hpp"
 #include "config.h"
 #include "DwarfInstructions.hpp"
 #include "EHHeaderParser.hpp"
-#include "libunwind.h"
+#include "libunwind_ext.h"
 #include "Registers.hpp"
 #include "RWMutex.hpp"
 #include "Unwind-EHABI.h"
@@ -412,6 +434,525 @@
 #endif
 };
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+
+/// \c UnwindCursor contains all state (including all register values) during
+/// an unwind.  This is normally stack-allocated inside a unw_cursor_t.
+template 
+class UnwindCursor : public AbstractUnwindCursor {
+  typedef typename A::pint_t pint_t;
+public:
+  UnwindCursor(unw_context_t *context, A );
+  UnwindCursor(CONTEXT *context, A );
+  UnwindCursor(A , void *threadArg);
+  virtual ~UnwindCursor() {}
+  virtual boolvalidReg(int);
+  virtual unw_word_t  

[PATCH] D50594: [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Should be fixed now.


Repository:
  rC Clang

https://reviews.llvm.org/D50594



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


Re: [PATCH] D50594: [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread George Karpenkov via cfe-commits
Should be fixed now.

> On Aug 14, 2018, at 1:10 AM, Thomas Preud'homme via Phabricator 
>  wrote:
> 
> thopre added a comment.
> 
> Hi George,
> 
> This commit seems to be causing some testsuite regression on Armv8 (both 
> Aarch64 and ARM) architectures:
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-full/builds/5450
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/5625
> 
> Best regards,
> 
> Thomas
> 
> 
> Repository:
>  rC Clang
> 
> https://reviews.llvm.org/D50594
> 
> 
> 

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


Re: [PATCH] D50594: [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3

2018-08-14 Thread George Karpenkov via cfe-commits
Should be fixed.

> On Aug 14, 2018, at 10:32 AM, George Karpenkov via cfe-commits 
>  wrote:
> 
> Yes, investigating. Will rollback if not fixed in a few hours.
> 
>> On Aug 14, 2018, at 3:17 AM, Yvan Roux via Phabricator 
>>  wrote:
>> 
>> yroux added a comment.
>> 
>> Notice that the affected bots run two times the test cases where one 
>> execution passes and one fails, as you can see in (search 
>> Analysis/plist-macros.cpp for instance):
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv8-full/builds/5450/steps/ninja%20check%201/logs/stdio
>> 
>> and I think it is due to llvm-lit being invoked with "--param 
>> USE_Z3_SOLVER=0 --param USE_Z3_SOLVER=0"
>> 
>> 
>> Repository:
>> rC Clang
>> 
>> https://reviews.llvm.org/D50594
>> 
>> 
>> 
> 
> ___
> 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


r339709 - [analyzer] Fix bots by removing new check-clang-analyzer commands from CHECK-ALL

2018-08-14 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Aug 14 11:55:34 2018
New Revision: 339709

URL: http://llvm.org/viewvc/llvm-project?rev=339709=rev
Log:
[analyzer] Fix bots by removing new check-clang-analyzer commands from CHECK-ALL

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=339709=339708=339709=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Tue Aug 14 11:55:34 2018
@@ -134,6 +134,9 @@ add_lit_testsuite(check-clang "Running t
 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
 
 if (CLANG_ENABLE_STATIC_ANALYZER)
+  # check-all would launch those tests via check-clang.
+  set(EXCLUDE_FROM_ALL ON)
+
   add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
 ${CMAKE_CURRENT_BINARY_DIR}/Analysis
 PARAMS ${ANALYZER_TEST_PARAMS}
@@ -149,6 +152,7 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
 set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER "Clang 
tests")
   endif()
 
+  set(EXCLUDE_FROM_ALL OFF)
 endif()
 
 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}


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


[PATCH] D50618: Refactor Darwin driver to refer to runtimes by component

2018-08-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D50618



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


[PATCH] D50670: Implementation of multiple loops in cxx_loop_proto

2018-08-14 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added a comment.

No, it doesn't actually. I thought it would try to combine the separate loops 
into one block of vectorized instructions but after looking at the coverage of 
multiple loops vs single loop, they cover exactly the same parts of the Loop 
Vectorizer. Should I switch my focus to nested loops instead? I think nested 
loops will increase coverage.


Repository:
  rC Clang

https://reviews.llvm.org/D50670



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


[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.

2018-08-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 160652.
kadircet marked 8 inline comments as done.
kadircet added a comment.

- Resolve discussions.
- Get rid of CancellationHandler class.
- Change error class name.
- Improve documentation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50502

Files:
  clangd/CMakeLists.txt
  clangd/Cancellation.cpp
  clangd/Cancellation.h
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/CancellationTests.cpp

Index: unittests/clangd/CancellationTests.cpp
===
--- /dev/null
+++ unittests/clangd/CancellationTests.cpp
@@ -0,0 +1,67 @@
+#include "Cancellation.h"
+#include "Context.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(CancellationTest, CancellationTest) {
+  {
+TaskHandle TH = TaskHandle::create();
+WithContext ContextWithCancellation(setCurrentCancellationToken(TH));
+EXPECT_FALSE(isCancelled());
+TH.cancel();
+EXPECT_TRUE(isCancelled());
+  }
+  EXPECT_FALSE(isCancelled());
+}
+
+TEST(CancellationTest, TaskHandleTestHandleDiesContextLives) {
+  llvm::Optional ContextWithCancellation;
+  {
+auto CancellableTaskHandle = TaskHandle::create();
+ContextWithCancellation.emplace(
+setCurrentCancellationToken(CancellableTaskHandle));
+EXPECT_FALSE(isCancelled());
+CancellableTaskHandle.cancel();
+EXPECT_TRUE(isCancelled());
+  }
+  EXPECT_TRUE(isCancelled());
+  ContextWithCancellation.reset();
+  EXPECT_FALSE(isCancelled());
+}
+
+TEST(CancellationTest, TaskHandleContextDiesHandleLives) {
+  {
+auto CancellableTaskHandle = TaskHandle::create();
+{
+  WithContext ContextWithCancellation(
+  setCurrentCancellationToken(CancellableTaskHandle));
+  EXPECT_FALSE(isCancelled());
+  CancellableTaskHandle.cancel();
+  EXPECT_TRUE(isCancelled());
+}
+  }
+  EXPECT_FALSE(isCancelled());
+}
+
+TEST(CancellationTest, CancellationToken) {
+  auto CancellableTaskHandle = TaskHandle::create();
+  WithContext ContextWithCancellation(
+  setCurrentCancellationToken(CancellableTaskHandle));
+  auto CT = isCancelled();
+  EXPECT_FALSE(CT);
+  CancellableTaskHandle.cancel();
+  EXPECT_TRUE(CT);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -10,6 +10,7 @@
 
 add_extra_unittest(ClangdTests
   Annotations.cpp
+  CancellationTests.cpp
   ClangdTests.cpp
   ClangdUnitTests.cpp
   CodeCompleteTests.cpp
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,6 +55,7 @@
   virtual void onDocumentHighlight(TextDocumentPositionParams ) = 0;
   virtual void onHover(TextDocumentPositionParams ) = 0;
   virtual void onChangeConfiguration(DidChangeConfigurationParams ) = 0;
+  virtual void onCancelRequest(CancelParams ) = 0;
 };
 
 void registerCallbackHandlers(JSONRPCDispatcher ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -75,4 +75,5 @@
   Register("workspace/didChangeConfiguration",
::onChangeConfiguration);
   Register("workspace/symbol", ::onWorkspaceSymbol);
+  Register("$/cancelRequest", ::onCancelRequest);
 }
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -861,6 +861,13 @@
 llvm::json::Value toJSON(const DocumentHighlight );
 llvm::raw_ostream <<(llvm::raw_ostream &, const DocumentHighlight &);
 
+struct CancelParams {
+  std::string ID;
+};
+llvm::json::Value toJSON(const CancelParams &);
+llvm::raw_ostream <<(llvm::raw_ostream &, const CancelParams &);
+bool fromJSON(const llvm::json::Value &, CancelParams &);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -615,5 +615,30 @@
  O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges);
 }
 
+json::Value toJSON(const CancelParams ) {
+  return json::Object{{"id", CP.ID}};
+}
+
+llvm::raw_ostream <<(llvm::raw_ostream , const CancelParams ) {
+  O << toJSON(CP);
+  return O;
+}
+
+bool fromJSON(const json::Value , CancelParams ) {
+  json::ObjectMapper O(Params);
+  if (!O)
+return false;

[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I will clean this up as part of https://bugs.llvm.org/show_bug.cgi?id=38495


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

thinking about this more, I think this the wrong long-term direction.

The presence/absence of C11 features in the underlying C library does not 
depend on what version of the C++ language we're compiling with.
The tests that use `TEXT_HAS_C11_XXX` should be updated to check `TEST_STD_VER` 
instead.

However, I'm fine with this as a short-term fix.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


r339704 - [OPENMP] Fix processing of declare target construct.

2018-08-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 14 11:31:20 2018
New Revision: 339704

URL: http://llvm.org/viewvc/llvm-project?rev=339704=rev
Log:
[OPENMP] Fix processing of declare target construct.

The attribute marked as inheritable since OpenMP 5.0 supports it +
additional fixes to support new functionality.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=339704=339703=339704=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug 14 11:31:20 2018
@@ -2956,9 +2956,10 @@ def OMPDeclareSimdDecl : Attr {
   }];
 }
 
-def OMPDeclareTargetDecl : Attr {
+def OMPDeclareTargetDecl : InheritableAttr {
   let Spellings = [Pragma<"omp", "declare target">];
   let SemaHandler = 0;
+  let Subjects = SubjectList<[Function, SharedVar]>;
   let Documentation = [OMPDeclareTargetDocs];
   let Args = [
 EnumArgument<"MapType", "MapTypeTy",
@@ -2971,6 +2972,15 @@ def OMPDeclareTargetDecl : Attr {
   if (getMapType() != MT_To)
 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
 }
+static llvm::Optional
+isDeclareTargetDeclaration(const ValueDecl *VD) {
+  if (!VD->hasAttrs())
+return llvm::None;
+  if (const auto *Attr = VD->getAttr())
+return Attr->getMapType();
+
+  return llvm::None;
+}
   }];
 }
 

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=339704=339703=339704=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Aug 14 11:31:20 2018
@@ -9806,13 +9806,9 @@ bool ASTContext::DeclMustBeEmitted(const
   return true;
 
   // If the decl is marked as `declare target`, it should be emitted.
-  for (const auto *Decl : D->redecls()) {
-if (!Decl->hasAttrs())
-  continue;
-if (const auto *Attr = Decl->getAttr())
-  if (Attr->getMapType() != OMPDeclareTargetDeclAttr::MT_Link)
-return true;
-  }
+  if (const llvm::Optional Res =
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+return *Res != OMPDeclareTargetDeclAttr::MT_Link;
 
   return false;
 }

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=339704=339703=339704=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Aug 14 11:31:20 2018
@@ -1091,6 +1091,10 @@ void DeclPrinter::VisitFunctionTemplateD
   printTemplateParameters(FD->getTemplateParameterList(I));
   }
   VisitRedeclarableTemplateDecl(D);
+  // Declare target attribute is special one, natural spelling for the pragma
+  // assumes "ending" construct so print it here.
+  if (D->getTemplatedDecl()->hasAttr())
+Out << "#pragma omp end declare target\n";
 
   // Never print "instantiations" for deduction guides (they don't really
   // have them).

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=339704=339703=339704=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Aug 14 11:31:20 2018
@@ -897,25 +897,6 @@ static void EmitOMPAggregateInit(CodeGen
   CGF.EmitBlock(DoneBB, /*IsFinished=*/true);
 }
 
-static llvm::Optional
-isDeclareTargetDeclaration(const ValueDecl *VD) {
-  for (const Decl *D : VD->redecls()) {
-if (!D->hasAttrs())
-  continue;
-if (const auto *Attr = D->getAttr())
-  return Attr->getMapType();
-  }
-  if (const auto *V = dyn_cast(VD)) {
-if (const VarDecl *TD = V->getTemplateInstantiationPattern())
-  return isDeclareTargetDeclaration(TD);
-  } else if (const auto *FD = dyn_cast(VD)) {
-if (const auto *TD = FD->getTemplateInstantiationPattern())
-  return isDeclareTargetDeclaration(TD);
-  }
-
-  return llvm::None;
-}
-
 LValue ReductionCodeGen::emitSharedLValue(CodeGenFunction , const Expr *E) 
{
   return CGF.EmitOMPSharedLValue(E);
 }
@@ -2417,7 +2398,7 @@ Address CGOpenMPRuntime::getAddrOfDeclar
   if (CGM.getLangOpts().OpenMPSimd)
 return Address::invalid();
   llvm::Optional Res =
-  isDeclareTargetDeclaration(VD);
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (Res && *Res == 

[PATCH] D50727: [clangd] Fetch documentation from the Index during signature help

2018-08-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 160647.
ilya-biryukov added a comment.

- run clang-format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50727

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -826,11 +826,19 @@
   EXPECT_TRUE(Results.Completions.empty());
 }
 
-SignatureHelp signatures(StringRef Text) {
+SignatureHelp signatures(StringRef Text,
+ std::vector IndexSymbols = {}) {
+  std::unique_ptr Index;
+  if (!IndexSymbols.empty())
+Index = memIndex(IndexSymbols);
+
   MockFSProvider FS;
   MockCompilationDatabase CDB;
   IgnoreDiagnostics DiagConsumer;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.StaticIndex = Index.get();
+
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
   auto File = testPath("foo.cpp");
   Annotations Test(Text);
   runAddDocument(Server, File, Test.code());
@@ -845,6 +853,7 @@
   return false;
   return true;
 }
+MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
 
 Matcher Sig(std::string Label,
   std::vector Params) {
@@ -1590,6 +1599,51 @@
   ElementsAre(Sig("foo(T, U) -> void", {"T", "U"})));
 }
 
+TEST(SignatureHelpTest, IndexDocumentation) {
+  Symbol::Details DocDetails;
+  DocDetails.Documentation = "Doc from the index";
+
+  Symbol Foo0 = sym("foo", index::SymbolKind::Function, "@F@\\0#");
+  Foo0.Detail = 
+  Symbol Foo1 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#");
+  Foo1.Detail = 
+  Symbol Foo2 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#I#");
+
+  EXPECT_THAT(
+  signatures(R"cpp(
+int foo();
+int foo(double);
+
+void test() {
+  foo(^);
+}
+  )cpp",
+ {Foo0})
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Doc from the index")),
+  AllOf(Sig("foo(double) -> int", {"double"}), SigDoc("";
+
+  EXPECT_THAT(
+  signatures(R"cpp(
+int foo();
+// Overriden doc from sema
+int foo(int);
+// Doc from sema
+int foo(int, int);
+
+void test() {
+  foo(^);
+}
+  )cpp",
+ {Foo0, Foo1, Foo2})
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Doc from the index")),
+  AllOf(Sig("foo(int) -> int", {"int"}),
+SigDoc("Overriden doc from sema")),
+  AllOf(Sig("foo(int, int) -> int", {"int", "int"}),
+SigDoc("Doc from sema";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -21,6 +21,8 @@
 #include 
 
 namespace clang {
+class Decl;
+
 namespace clangd {
 
 struct SymbolLocation {
@@ -60,6 +62,8 @@
 // SymbolID can be used as key in the symbol indexes to lookup the symbol.
 class SymbolID {
 public:
+  static llvm::Optional forDecl(const Decl );
+
   SymbolID() = default;
   explicit SymbolID(llvm::StringRef USR);
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "Index.h"
+#include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
@@ -23,6 +24,13 @@
 << L.End.Line << ":" << L.End.Column << ")";
 }
 
+llvm::Optional SymbolID::forDecl(const Decl ) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(, USR))
+return llvm::None;
+  return SymbolID(USR);
+}
+
 SymbolID::SymbolID(StringRef USR)
 : HashValue(SHA1::hash(arrayRefFromStringRef(USR))) {}
 
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -171,12 +171,11 @@
 CodeCompleteOptions Opts);
 
 /// Get signature help at a specified \p Pos in \p FileName.
-SignatureHelp signatureHelp(PathRef FileName,
-const tooling::CompileCommand ,
-PrecompiledPreamble const *Preamble,
-StringRef Contents, Position Pos,
-IntrusiveRefCntPtr VFS,
-std::shared_ptr PCHs);
+SignatureHelp
+signatureHelp(PathRef FileName, const tooling::CompileCommand ,
+  

[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX339702: [libc++] Fix incorrect definition of 
TEST_HAS_C11_FEATURES (authored by ldionne, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50719?vs=160616=160648#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D50719

Files:
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011
+#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011
+#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r339702 - [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Aug 14 11:16:56 2018
New Revision: 339702

URL: http://llvm.org/viewvc/llvm-project?rev=339702=rev
Log:
[libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

Summary:
The macro was not defined in C++11 mode when it should have been, at least
according to how _LIBCPP_HAS_C11_FEATURES is defined.

Reviewers: mclow.lists, EricWF, jfb, dexonsmith

Subscribers: christof, dexonsmith, cfe-commits

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

Modified:
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=339702=339701=339702=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Tue Aug 14 11:16:56 2018
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011
+#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)


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


[PATCH] D48896: [libcxx][c++17] P0083R5: Splicing Maps and Sets Part 2: merge

2018-08-14 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D48896



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


[PATCH] D50726: [clangd] Show function documentation in sigHelp

2018-08-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

There's a test for the new behavior in https://reviews.llvm.org/D50726


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50726



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


[PATCH] D50727: [clangd] Fetch documentation from the Index during signature help

2018-08-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, ioeric, kadircet.
Herald added subscribers: arphaman, mgrang, jkorous, MaskRay.

Sema can only be used for documentation in the current file, other doc
comments should be fetched from the index.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50727

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -826,11 +826,19 @@
   EXPECT_TRUE(Results.Completions.empty());
 }
 
-SignatureHelp signatures(StringRef Text) {
+SignatureHelp signatures(StringRef Text,
+ std::vector IndexSymbols = {}) {
+  std::unique_ptr Index;
+  if (!IndexSymbols.empty())
+Index = memIndex(IndexSymbols);
+
   MockFSProvider FS;
   MockCompilationDatabase CDB;
   IgnoreDiagnostics DiagConsumer;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.StaticIndex = Index.get();
+
+  ClangdServer Server(CDB, FS, DiagConsumer, Opts);
   auto File = testPath("foo.cpp");
   Annotations Test(Text);
   runAddDocument(Server, File, Test.code());
@@ -845,6 +853,7 @@
   return false;
   return true;
 }
+MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
 
 Matcher Sig(std::string Label,
   std::vector Params) {
@@ -1590,6 +1599,51 @@
   ElementsAre(Sig("foo(T, U) -> void", {"T", "U"})));
 }
 
+TEST(SignatureHelpTest, IndexDocumentation) {
+  Symbol::Details DocDetails;
+  DocDetails.Documentation = "Doc from the index";
+
+  Symbol Foo0 = sym("foo", index::SymbolKind::Function, "@F@\\0#");
+  Foo0.Detail = 
+  Symbol Foo1 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#");
+  Foo1.Detail = 
+  Symbol Foo2 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#I#");
+
+  EXPECT_THAT(
+  signatures(R"cpp(
+int foo();
+int foo(double);
+
+void test() {
+  foo(^);
+}
+  )cpp",
+ {Foo0})
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Doc from the index")),
+  AllOf(Sig("foo(double) -> int", {"double"}), SigDoc("";
+
+  EXPECT_THAT(
+  signatures(R"cpp(
+int foo();
+// Overriden doc from sema
+int foo(int);
+// Doc from sema
+int foo(int, int);
+
+void test() {
+  foo(^);
+}
+  )cpp",
+ {Foo0, Foo1, Foo2})
+  .signatures,
+  ElementsAre(AllOf(Sig("foo() -> int", {}), SigDoc("Doc from the index")),
+  AllOf(Sig("foo(int) -> int", {"int"}),
+SigDoc("Overriden doc from sema")),
+  AllOf(Sig("foo(int, int) -> int", {"int", "int"}),
+SigDoc("Doc from sema";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -21,6 +21,8 @@
 #include 
 
 namespace clang {
+class Decl;
+
 namespace clangd {
 
 struct SymbolLocation {
@@ -60,6 +62,8 @@
 // SymbolID can be used as key in the symbol indexes to lookup the symbol.
 class SymbolID {
 public:
+  static llvm::Optional forDecl(const Decl& D);
+
   SymbolID() = default;
   explicit SymbolID(llvm::StringRef USR);
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "Index.h"
+#include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
@@ -23,8 +24,16 @@
 << L.End.Line << ":" << L.End.Column << ")";
 }
 
+llvm::Optional SymbolID::forDecl(const Decl ) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(, USR))
+return llvm::None;
+  return SymbolID(USR);
+}
+
 SymbolID::SymbolID(StringRef USR)
-: HashValue(SHA1::hash(arrayRefFromStringRef(USR))) {}
+: HashValue(SHA1::hash(arrayRefFromStringRef(USR))) {
+}
 
 raw_ostream <<(raw_ostream , const SymbolID ) {
   OS << toHex(toStringRef(ID.HashValue));
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -176,7 +176,8 @@
 PrecompiledPreamble const *Preamble,
 StringRef Contents, Position Pos,
 IntrusiveRefCntPtr VFS,
-std::shared_ptr PCHs);
+  

[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne marked an inline comment as done.
ldionne added a comment.

Ok, I'm pushing with JF's suggested change (use `TEST_STD_VER >= 11` instead of 
`__cplusplus >= 201103L`). Let's cross fingers that this is going to unbreak 
the testers -- like I said it fixed my Docker container.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/Basic/TargetInfo.cpp:72
+// For 64-bit Android, alignment is 8 bytes for allocations <= 8 bytes.
+NewAlign = (Triple.isArch64Bit() || Triple.isArch32Bit()) ? 64 : 0;
+  } else

Might as well just set `NewAlign = 64;` here.  But not a big deal either way.


Repository:
  rC Clang

https://reviews.llvm.org/D50683



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-08-14 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 160642.
Quuxplusone marked an inline comment as done.
Quuxplusone added a comment.

Rebased, and ping!


Repository:
  rC Clang

https://reviews.llvm.org/D50119

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Features.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/trivially-relocatable.cpp

Index: test/SemaCXX/trivially-relocatable.cpp
===
--- /dev/null
+++ test/SemaCXX/trivially-relocatable.cpp
@@ -0,0 +1,510 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-diagnostics
+
+static_assert(__has_extension(trivially_relocatable), "");
+
+// It shall appear at most once in each attribute-list
+// and no attribute-argument-clause shall be present.
+
+struct [[trivially_relocatable, trivially_relocatable]] B1 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot appear multiple times in an attribute specifier}}
+
+struct [[trivially_relocatable]] [[trivially_relocatable]] B2 {}; // should really be an error
+
+struct [[trivially_relocatable(42)]] B3 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot have an argument list}}
+
+
+//   The first declaration of a type shall specify the
+//   trivially_relocatable attribute if any declaration of that
+//   type specifies the trivially_relocatable attribute.
+
+struct [[trivially_relocatable]] A1 {};  // ok
+struct [[trivially_relocatable]] A1;
+
+struct [[trivially_relocatable]] A2;  // ok
+struct [[trivially_relocatable]] A2 {};
+
+struct [[trivially_relocatable]] A3 {};  // ok
+struct A3;
+
+struct [[trivially_relocatable]] A4;  // ok
+struct A4 {};
+
+struct A5 {};
+struct [[trivially_relocatable]] A5;
+// expected-error@-1{{type A5 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+// expected-warning@-3{{attribute declaration must precede definition}}
+// expected-note@-5{{previous definition is here}}
+
+struct A6;
+struct [[trivially_relocatable]] A6 {};
+// expected-error@-1{{type A6 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+
+
+// If a type T is declared with the trivially_relocatable attribute, and T is
+// either not move-constructible or not destructible, the program is ill-formed.
+
+struct NonDestructible {
+NonDestructible(const NonDestructible&) = default;
+NonDestructible(NonDestructible&&) = default;
+~NonDestructible() = delete;
+};
+struct NonCopyConstructible {
+NonCopyConstructible(const NonCopyConstructible&) = delete;
+};
+struct NonMoveConstructible {
+NonMoveConstructible(const NonMoveConstructible&) = default;
+NonMoveConstructible(NonMoveConstructible&&) = delete;
+};
+static_assert(!__is_trivially_relocatable(NonDestructible), "");
+static_assert(!__is_trivially_relocatable(NonCopyConstructible), "");
+static_assert(!__is_constructible(NonCopyConstructible, NonCopyConstructible&&), "");
+static_assert(!__is_trivially_relocatable(NonMoveConstructible), "");
+static_assert(!__is_constructible(NonMoveConstructible, NonMoveConstructible&&), "");
+
+struct [[trivially_relocatable]] D1 { ~D1() = delete; };
+// expected-error@-1{{cannot be applied to struct 'D1' because it is not destructible}}
+
+struct [[trivially_relocatable]] D2 : private NonDestructible { };
+// expected-error@-1{{cannot be applied to struct 'D2' because it is not destructible}}
+
+struct [[trivially_relocatable]] D3 { D3(const D3&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D3' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D4 { D4(const D4&) = default; D4(D4&&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D4' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D5 : private NonCopyConstructible { };
+// expected-error@-1{{cannot be applied to struct 'D5' because it is not move-constructible}}
+static_assert(!__is_constructible(D5, D5&&), "");
+
+struct [[trivially_relocatable]] D6 : private NonMoveConstructible { D6(D6&&) = default; };
+// expected-error@-1{{cannot be applied to struct 'D6' because it is not move-constructible}}
+
+template
+struct [[trivially_relocatable]] DT1 : private T { };  // ok
+
+struct D7 {
+  

[PATCH] D50715: [AST] Store the OwnedTagDecl as a trailing object in ElaboratedType.

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

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D50715



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D50719#1199427, @mclow.lists wrote:

> I have pissed in this area, too - See 
> https://bugs.llvm.org/show_bug.cgi?id=38495 and the proposed resolution here: 
> https://bugs.llvm.org/attachment.cgi?id=20692
>  How about I just make this change as part of that fix?


Yes, that would be great.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D50719#1199450, @dexonsmith wrote:

> If the bots are red from a previous commit I think it would be better for 
> Louis to commit this separately.


I'm ok with that.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50630: [AST] Update/correct the static_asserts for the bit-fields in Type

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

Sure, that seems like a reasonable optimization.


Repository:
  rC Clang

https://reviews.llvm.org/D50630



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.

In https://reviews.llvm.org/D50719#1199427, @mclow.lists wrote:

> I have pissed in this area, too - See 
> https://bugs.llvm.org/show_bug.cgi?id=38495 and the proposed resolution here: 
> https://bugs.llvm.org/attachment.cgi?id=20692
>  How about I just make this change as part of that fix?


If the bots are red from a previous commit I think it would be better for Louis 
to commit this separately.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50726: [clangd] Show function documentation in sigHelp

2018-08-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, ioeric, kadircet.
Herald added subscribers: arphaman, jkorous, MaskRay.

Previously, clangd was trying to show documentation for the active
parameter instead, which is wrong per LSP specification.

Moreover, the code path that attempts to get parameter comments never
succeds, because no attempt is made to parse function doc comment and
extract parameter-specific parts out of it. So we also remove the code
that claims to fetch parameter comments: it is not used anymore and is
incorrect.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50726

Files:
  clangd/CodeComplete.cpp
  clangd/CodeCompletionStrings.cpp
  clangd/CodeCompletionStrings.h

Index: clangd/CodeCompletionStrings.h
===
--- clangd/CodeCompletionStrings.h
+++ clangd/CodeCompletionStrings.h
@@ -32,18 +32,10 @@
   const CodeCompletionResult ,
   bool CommentsFromHeaders);
 
-/// Gets a minimally formatted documentation for parameter of \p Result,
-/// corresponding to argument number \p ArgIndex.
-/// This currently looks for comments attached to the parameter itself, and
-/// doesn't extract them from function documentation.
-/// Returns empty string when no comment is available.
-/// If \p CommentsFromHeaders parameter is set, only comments from the main
-/// file will be returned. It is used to workaround crashes when parsing
-/// comments in the stale headers, coming from completion preamble.
 std::string
-getParameterDocComment(const ASTContext ,
-   const CodeCompleteConsumer::OverloadCandidate ,
-   unsigned ArgIndex, bool CommentsFromHeaders);
+getDocComment(const ASTContext ,
+  const CodeCompleteConsumer::OverloadCandidate ,
+  bool CommentsFromHeaders);
 
 /// Formats the signature for an item, as a display string and snippet.
 /// e.g. for const_reference std::vector::at(size_type) const, this returns:
Index: clangd/CodeCompletionStrings.cpp
===
--- clangd/CodeCompletionStrings.cpp
+++ clangd/CodeCompletionStrings.cpp
@@ -41,28 +41,17 @@
   return CommentText.find_first_not_of("/*-= \t\r\n") != llvm::StringRef::npos;
 }
 
-} // namespace
-
-std::string getDocComment(const ASTContext ,
-  const CodeCompletionResult ,
-  bool CommentsFromHeaders) {
-  // FIXME: clang's completion also returns documentation for RK_Pattern if they
-  // contain a pattern for ObjC properties. Unfortunately, there is no API to
-  // get this declaration, so we don't show documentation in that case.
-  if (Result.Kind != CodeCompletionResult::RK_Declaration)
-return "";
-  auto *Decl = Result.getDeclaration();
-  if (!Decl || llvm::isa(Decl)) {
+std::string getDeclComment(const ASTContext , const NamedDecl ) {
+  if (llvm::isa(Decl)) {
 // Namespaces often have too many redecls for any particular redecl comment
 // to be useful. Moreover, we often confuse file headers or generated
 // comments with namespace comments. Therefore we choose to just ignore
 // the comments for namespaces.
 return "";
   }
-  const RawComment *RC = getCompletionComment(Ctx, Decl);
+  const RawComment *RC = getCompletionComment(Ctx, );
   if (!RC)
 return "";
-
   // Sanity check that the comment does not come from the PCH. We choose to not
   // write them into PCH, because they are racy and slow to load.
   assert(!Ctx.getSourceManager().isLoadedSourceLocation(RC->getBeginLoc()));
@@ -72,23 +61,30 @@
   return Doc;
 }
 
-std::string
-getParameterDocComment(const ASTContext ,
-   const CodeCompleteConsumer::OverloadCandidate ,
-   unsigned ArgIndex, bool CommentsFromHeaders) {
-  auto *Func = Result.getFunction();
-  if (!Func)
+} // namespace
+
+std::string getDocComment(const ASTContext ,
+  const CodeCompletionResult ,
+  bool CommentsFromHeaders) {
+  // FIXME: clang's completion also returns documentation for RK_Pattern if they
+  // contain a pattern for ObjC properties. Unfortunately, there is no API to
+  // get this declaration, so we don't show documentation in that case.
+  if (Result.Kind != CodeCompletionResult::RK_Declaration)
 return "";
-  const RawComment *RC = getParameterComment(Ctx, Result, ArgIndex);
-  if (!RC)
+  auto *Decl = Result.getDeclaration();
+  if (!Decl)
 return "";
-  // Sanity check that the comment does not come from the PCH. We choose to not
-  // write them into PCH, because they are racy and slow to load.
-  assert(!Ctx.getSourceManager().isLoadedSourceLocation(RC->getBeginLoc()));
-  std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
-  if (!looksLikeDocComment(Doc))
+  return getDeclComment(Ctx, *Decl);
+}
+

[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I have pissed in this area, too - See 
https://bugs.llvm.org/show_bug.cgi?id=38495 and the proposed resolution here: 
https://bugs.llvm.org/attachment.cgi?id=20692
How about I just make this change as part of that fix?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:1886
   case BuiltinType::ObjCId:
-mangleArtificalTagType(TTK_Struct, "objc_object");
+mangleArtificalTagType(TTK_Struct, ".objc_object");
 break;

DHowett-MSFT wrote:
> I'm interested in @smeenai's take on this, as well.
Hmm, doesn't this break ObjC/ObjC++ interoperability?  I don't think that we 
should be changing the decoration here for the MS ABI case.


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-14 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

...And it turns out Phab marked the comments as done when I uploaded the new 
change. I didn't know it would do that. That's useful to know.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-14 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

Marked some comments as done. (Phab won't let me post an empty comment, so...)


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-14 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x updated this revision to Diff 160638.
cdavis5x marked 3 inline comments as done.
cdavis5x edited the summary of this revision.
cdavis5x added a comment.

- Update checks for DISPATCHER_CONTEXT definition.
- Add link to KJK::Hyperion's articles on SEH.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564

Files:
  include/__libunwind_config.h
  src/AddressSpace.hpp
  src/CMakeLists.txt
  src/Unwind-seh.cpp
  src/UnwindCursor.hpp
  src/UnwindLevel1-gcc-ext.c
  src/UnwindLevel1.c
  src/config.h
  src/libunwind_ext.h

Index: src/libunwind_ext.h
===
--- src/libunwind_ext.h
+++ src/libunwind_ext.h
@@ -17,6 +17,12 @@
 #include 
 #include 
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+  #include 
+  #include 
+  #include 
+#endif
+
 #define UNW_STEP_SUCCESS 1
 #define UNW_STEP_END 0
 
@@ -33,6 +39,44 @@
 extern void _unw_add_dynamic_fde(unw_word_t fde);
 extern void _unw_remove_dynamic_fde(unw_word_t fde);
 
+// Provide a definition for the DISPATCHER_CONTEXT struct for old (Win7 and
+// earlier) SDKs.
+// MinGW-w64 has always provided this struct.
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && !defined(__MINGW32__) && VER_PRODUCTBUILD < 8000
+  #if defined(__x86_64__)
+typedef struct _DISPATCHER_CONTEXT {
+  ULONG64 ControlPc;
+  ULONG64 ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG64 EstablisherFrame;
+  ULONG64 TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG Fill0;
+} DISPATCHER_CONTEXT;
+  #elif defined(__arm__)
+typedef struct _DISPATCHER_CONTEXT {
+  ULONG ControlPc;
+  ULONG ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG EstablisherFrame;
+  ULONG TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG ControlPcIsUnwound;
+  PKNONVOLATILE_CONTEXT_POINTERS NonVolatileRegisters;
+  ULONG VirtualVfpHead;
+} DISPATCHER_CONTEXT;
+  #endif
+typedef DISPATCHER_CONTEXT* PDISPATCHER_CONTEXT;
+#endif
+
 #if defined(_LIBUNWIND_ARM_EHABI)
 extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);
 extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -38,7 +38,11 @@
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
 #elif defined(_WIN32)
-  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #ifdef __SEH__
+#define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
+  #else
+#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #endif
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -32,6 +32,8 @@
 
 #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
+#ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND
+
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
   unw_init_local(cursor, uc);
@@ -449,6 +451,7 @@
   return result;
 }
 
+#endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND
 
 /// Called by personality handler during phase 2 if a foreign exception
 // is caught.
Index: src/UnwindLevel1-gcc-ext.c
===
--- src/UnwindLevel1-gcc-ext.c
+++ src/UnwindLevel1-gcc-ext.c
@@ -25,6 +25,10 @@
 
 #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#define private_1 private_[0]
+#endif
+
 ///  Called by __cxa_rethrow().
 _LIBUNWIND_EXPORT _Unwind_Reason_Code
 _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -18,18 +18,40 @@
 #include 
 #include 
 
+#ifdef _WIN32
+  #include 
+#endif
 #ifdef __APPLE__
   #include 
 #endif
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#  ifdef _LIBUNWIND_TARGET_X86_64
+struct UNWIND_INFO {
+  BYTE Version : 3;
+  BYTE Flags : 5;
+  BYTE SizeOfProlog;
+  BYTE CountOfCodes;
+  BYTE FrameRegister : 4;
+  BYTE FrameOffset : 4;
+  WORD UnwindCodes[2];
+};
+#  endif
+
+extern "C" _Unwind_Reason_Code __libunwind_seh_personality(
+int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception *,
+struct _Unwind_Context *);
+
+#endif
+
 #include "config.h"
 
 #include "AddressSpace.hpp"
 #include "CompactUnwinder.hpp"
 #include "config.h"
 #include "DwarfInstructions.hpp"
 #include "EHHeaderParser.hpp"
-#include "libunwind.h"
+#include "libunwind_ext.h"
 #include "Registers.hpp"
 #include "RWMutex.hpp"
 #include "Unwind-EHABI.h"
@@ -412,6 +434,525 @@
 #endif
 };
 
+#if 

[PATCH] D50641: [clangd][test] Fix exit messages in tests

2018-08-14 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I can see the value of getting more information in case of unexpected test 
behaviour but I still don't really like to have separate codepath for testing 
purposes.

Anyway, it's not a big deal and it looks like you guys are all in agreement 
about this.

I created a patch that I will put for review (rebuilding and running tests 
overnight).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50641



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added a comment.
This revision is now accepted and ready to land.

From `__ISO_C_VISIBLE >= 2011` it looks like this tries to test C11 features 
regardless of the C++ version. That's probably fine, but we're walking this 
line where only C++17 really guarantees C11 support, so this entire thing is 
weird and brittle to me. You're not changing the brittle-ness, just removing 
one kink, so from that perspective this change LGTM.




Comment at: libcxx/test/support/test_macros.h:127
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
 #  if defined(__FreeBSD__)

Should this be `TEST_STD_VER >= 11`?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.

2018-08-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/Cancellation.cpp:17
+namespace {
+static Key>> CancellationTokenKey;
+} // namespace

ilya-biryukov wrote:
> Having a `shared_ptr` key in the Context can cause data races (e.g. if we 
> copy it concurrently from multiple threads).
> I suggest we make `CancellationToken` move-only (i.e. disallow copies) and 
> return `const CancellationToken&` when getting it from the context.
As talked offline, copying std::shared_ptr is thread safe.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50502



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


[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.

2018-08-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 160636.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Get rid of getCancellationError.
- Add replyError helper.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50502

Files:
  clangd/CMakeLists.txt
  clangd/Cancellation.cpp
  clangd/Cancellation.h
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/CancellationTests.cpp

Index: unittests/clangd/CancellationTests.cpp
===
--- /dev/null
+++ unittests/clangd/CancellationTests.cpp
@@ -0,0 +1,70 @@
+#include "Cancellation.h"
+#include "Context.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(CancellationTest, CancellationTest) {
+  {
+TaskHandle TH = TaskHandle::createCancellableTaskHandle();
+WithContext ContextWithCancellation(
+CancellationHandler::setCurrentCancellationToken(TH));
+EXPECT_FALSE(CancellationHandler::isCancelled());
+TH.cancel();
+EXPECT_TRUE(CancellationHandler::isCancelled());
+  }
+  EXPECT_FALSE(CancellationHandler::isCancelled());
+}
+
+TEST(CancellationTest, TaskHandleTestHandleDiesContextLives) {
+  llvm::Optional ContextWithCancellation;
+  {
+auto CancellableTaskHandle = TaskHandle::createCancellableTaskHandle();
+ContextWithCancellation.emplace(
+CancellationHandler::setCurrentCancellationToken(
+CancellableTaskHandle));
+EXPECT_FALSE(CancellationHandler::isCancelled());
+CancellableTaskHandle.cancel();
+EXPECT_TRUE(CancellationHandler::isCancelled());
+  }
+  EXPECT_TRUE(CancellationHandler::isCancelled());
+  ContextWithCancellation.reset();
+  EXPECT_FALSE(CancellationHandler::isCancelled());
+}
+
+TEST(CancellationTest, TaskHandleContextDiesHandleLives) {
+  {
+auto CancellableTaskHandle = TaskHandle::createCancellableTaskHandle();
+{
+  WithContext ContextWithCancellation(
+  CancellationHandler::setCurrentCancellationToken(
+  CancellableTaskHandle));
+  EXPECT_FALSE(CancellationHandler::isCancelled());
+  CancellableTaskHandle.cancel();
+  EXPECT_TRUE(CancellationHandler::isCancelled());
+}
+  }
+  EXPECT_FALSE(CancellationHandler::isCancelled());
+}
+
+TEST(CancellationTest, CancellationToken) {
+  auto CancellableTaskHandle = TaskHandle::createCancellableTaskHandle();
+  WithContext ContextWithCancellation(
+  CancellationHandler::setCurrentCancellationToken(CancellableTaskHandle));
+  auto CT = CancellationHandler::isCancelled();
+  EXPECT_FALSE(CT);
+  CancellableTaskHandle.cancel();
+  EXPECT_TRUE(CT);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -10,6 +10,7 @@
 
 add_extra_unittest(ClangdTests
   Annotations.cpp
+  CancellationTests.cpp
   ClangdTests.cpp
   ClangdUnitTests.cpp
   CodeCompleteTests.cpp
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -55,6 +55,7 @@
   virtual void onDocumentHighlight(TextDocumentPositionParams ) = 0;
   virtual void onHover(TextDocumentPositionParams ) = 0;
   virtual void onChangeConfiguration(DidChangeConfigurationParams ) = 0;
+  virtual void onCancelRequest(CancelParams ) = 0;
 };
 
 void registerCallbackHandlers(JSONRPCDispatcher ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -75,4 +75,5 @@
   Register("workspace/didChangeConfiguration",
::onChangeConfiguration);
   Register("workspace/symbol", ::onWorkspaceSymbol);
+  Register("$/cancelRequest", ::onCancelRequest);
 }
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -861,6 +861,13 @@
 llvm::json::Value toJSON(const DocumentHighlight );
 llvm::raw_ostream <<(llvm::raw_ostream &, const DocumentHighlight &);
 
+struct CancelParams {
+  std::string ID;
+};
+llvm::json::Value toJSON(const CancelParams &);
+llvm::raw_ostream <<(llvm::raw_ostream &, const CancelParams &);
+bool fromJSON(const llvm::json::Value &, CancelParams &);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -615,5 +615,30 @@
   

[libcxx] r339697 - [CMake] Fix the LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY option

2018-08-14 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Aug 14 10:33:10 2018
New Revision: 339697

URL: http://llvm.org/viewvc/llvm-project?rev=339697=rev
Log:
[CMake] Fix the LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY option

This option should be available if LIBCXX_ENABLE_SHARED is enabled,
not LIBCXX_ENABLE_STATIC.

This fixes a typo from SVN r337814.

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

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=339697=339696=339697=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Aug 14 10:33:10 2018
@@ -175,7 +175,7 @@ cmake_dependent_option(LIBCXX_STATICALLY
 
 cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
   "Statically link the ABI library to shared library" ON
-  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
+  "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF)
 
 # Generate and install a linker script inplace of libc++.so. The linker script
 # will link libc++ to the correct ABI library. This option is on by default


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


  1   2   3   >