Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-08-21 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A few more comments.



Comment at: test/clang-tidy/move-const-arg.cpp:1
@@ +1,2 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s move-const-arg %t 
+// REQUIRES: shell

Please use check_clang_tidy.py instead:

  // RUN: %python %S/check_clang_tidy.py %s move-const-arg %t

and remove `// REQUIRES: shell`, as it's not needed any more.


Comment at: test/clang-tidy/move-const-arg.cpp:41
@@ +40,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: move of const variable 
[move-const-arg]
+  // CHECK-FIXES: return x;
+}

Please make the checked code lines unique to avoid matching in a wrong place. 
FileCheck (the utility that is called by the check_clang_tidy.py script to 
verify the `// CHECK-...` lines, 
http://llvm.org/docs/CommandGuide/FileCheck.html) doesn't take the location of 
the `// CHECK-FIXES:` line in the test file into consideration, it just 
verifies that the fixed file has a subsequence of lines that matches all `// 
CHECK-FIXES` lines in that order. Here, for example, `return x;` would equally 
match, if the check would fix line 34 instead of line 39. We could solve this 
by numbering lines so that CHECK-FIXES patterns could refer to the line 
numbers, but until we do that (if we decide so), making the checked lines 
unique is the way to go (e.g. by using different variable names in each test 
case instead of just `x`).


http://reviews.llvm.org/D12031



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


Re: r245459 - According to i686 ABI, long double size on x86 is 12 bytes not 16 bytes.

2015-08-21 Thread Yaron Keren via cfe-commits
The testcase from r245459 was not reverted and still in SVN.


2015-08-21 2:05 GMT+03:00 Martell Malone :

> I feel very silly now.
> After testing the testcase again on svn it still works.
> It appears the OP was looking for this patch to go onto the 3.6 branch and
> was applying my patch to that.
>
> I'll know in future to recheck the testcase afterwards myself in future.
>
> Apologies for the noise guys.
>
> Yaron I think the test case from r245459 would be useful to ensure it is
> never broken in the future?
> Would you be able to recommit the test case?
>
> Kind Regards
> Martell
>
>
On Thu, Aug 20, 2015 at 3:57 PM, Martell Malone 
wrote:

> There is no testcase for PR24398 nor the OP reporting the problem was
>> actually solved. Martell?
>
> I'm just re-looking through it now.
>
> X86TargetInfo sets LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> X86_64TargetInfo then sets LongDoubleWidth = LongDoubleAlign = 128;
> X86_32TargetInfo then sets LongDoubleWidth = 96; LongDoubleAlign = 32;
>
> From this I can see that the patch I committed actually doesn't change
> anything but only breaks mingw x86.
> I can only see these values changed in Microsoft*TargetInfo classes which
> is not a parent of MINGW
>
> When I submitted the patch I just wanted to explicitly set the values in 
> MinGWX86_64TargetInfo
> to ensure it was in fact that.
> It seemed as though it was not inheriting the value from the root parent
> class somehow.
>
> I was told on irc that it did fix the bug which is even stranger.
> I'm actually at a bit of a loss as to what the proper fix to this is then.
>
> Apologies for breaking mingw i686 long double.
>
> I will do up a test case and try to find the actual cause of the long
> double bug and reopen the issue.
>
> On Thu, Aug 20, 2015 at 3:09 PM, Yaron Keren 
> wrote:
>
>> Hi, I've just done this exactly this in r245618 (32 bit) and r245620 (64
>> bits).
>>
>> mingw i686 long double values were correct before r245084 and wrong after
>>  it.
>> mingw x86_64 long double values were not modified at all by r245084 for
>> the reason you stated, so I agree and do not see how this non-change can
>> solve anything. There is no testcase for PR24398 nor the OP reporting
>> the problem was actually solved. Martell?
>>
>> About PR24398,  long double support was in clang long ago and both code
>> examples compile and run correctly with current svn (without r245084)
>> and gcc version 5.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64
>> project).
>> It's not x86_64 but as said r245084 didn't actually modify x86_64
>> configuration.
>>
>>
>>
>>
>> 2015-08-21 0:52 GMT+03:00 Richard Smith :
>>
>>> OK, so here's the problem:
>>>
>>> The right way to fix this seems to be to delete the assignments to
>>> LongDouble* from the MinGWX86_32TargetInfo constructor; the
>>> X86_32TargetInfo and X86TargetInfo base classes already set them to the
>>> right values. Likewise we can delete the assignments to LongDouble* from
>>> the MinGWX86_64TargetInfo constructor for the same reason.
>>>
>>> But... that completely reverts Martell's r245084, which apparently fixed
>>> PR24398. So you two need to figure out what the actual problem is here, and
>>> what the right fix is. r245084 didn't provide any test cases, and had no
>>> apparent effect other than to break long double for mingw32; did it really
>>> fix PR24398 (and if so, how)?
>>>
>>>
>>> On Thu, Aug 20, 2015 at 2:27 PM, Yaron Keren 
>>> wrote:
>>>
 OK, based on testing, mingw i686 aligns long doubles to 4 bytes:

 sh-4.3$ cat < a.cpp
 #include 
 int main() {
   struct {
 char c[1];
 long double d;
   } s;
   std::cout<<&s.c<>>>   std::cout<<&s.d<>>> }
 sh-4.3$ g++ a.cpp&&./a.exe
 0x28fea0
 0x28fea4

 I'll fix that.


 2015-08-21 0:13 GMT+03:00 Richard Smith :

> On Wed, Aug 19, 2015 at 11:42 AM, Yaron Keren 
> wrote:
>
>> Yes, it looks like a legacy issue. Documentation says so:
>>
>> *https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/i386-and-x86-64-Options.html
>> *
>>
>> -m96bit-long-double-m128bit-long-doubleThese switches control the
>> size of long double type. The i386 application binary interface
>> specifies the size to be 96 bits, so -m96bit-long-double is the
>> default in 32-bit mode.
>>
>> Modern architectures (Pentium and newer) prefer long double to be
>> aligned to an 8- or 16-byte boundary. In arrays or structures conforming 
>> to
>> the ABI, this is not possible. So specifying -m128bit-long-double
>>  aligns long double to a 16-byte boundary by padding the long double with
>> an additional 32-bit zero.
>>
>> In the x86-64 compiler, -m128bit-long-double is the default choice
>> as its ABI specifies that long double is aligned on 16-byte boundary.
>>
>> Notice that neither of these options enable a

r245679 - Expand mingw-long-double.c to test for long double alignment.

2015-08-21 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Aug 21 03:26:31 2015
New Revision: 245679

URL: http://llvm.org/viewvc/llvm-project?rev=245679&view=rev
Log:
Expand mingw-long-double.c to test for long double alignment.


Added:
cfe/trunk/test/CodeGen/mingw-long-double.c
Removed:
cfe/trunk/test/CodeGen/mingw-long-double-size.c

Removed: cfe/trunk/test/CodeGen/mingw-long-double-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mingw-long-double-size.c?rev=245678&view=auto
==
--- cfe/trunk/test/CodeGen/mingw-long-double-size.c (original)
+++ cfe/trunk/test/CodeGen/mingw-long-double-size.c (removed)
@@ -1,6 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple i686-pc-windows-gnu -S %s  -o - | FileCheck %s 
-check-prefix=CHECK_I686
-// CHECK_I686: lda,12
-// RUN: %clang_cc1 -triple x86_64-pc-windows-gnu -S %s  -o - | FileCheck %s 
-check-prefix=CHECK_X86_64
-// CHECK_X86_64: lda,16
-long double lda;

Added: cfe/trunk/test/CodeGen/mingw-long-double.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mingw-long-double.c?rev=245679&view=auto
==
--- cfe/trunk/test/CodeGen/mingw-long-double.c (added)
+++ cfe/trunk/test/CodeGen/mingw-long-double.c Fri Aug 21 03:26:31 2015
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple i686-pc-windows-gnu -S %s  -o - | FileCheck %s 
-check-prefix=CHECK_I686
+// CHECK_I686: _lda,12
+// CHECK_I686: _lds,16
+// RUN: %clang_cc1 -triple x86_64-pc-windows-gnu -S %s  -o - | FileCheck %s 
-check-prefix=CHECK_X86_64
+// CHECK_X86_64: lda,16
+// CHECK_X86_64: lds,32
+long double lda;
+struct {
+  char c;
+  long double ldb;
+} lds;


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


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-21 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2887
@@ +2886,3 @@
+llvm::Value *
+CGOpenMPRuntime::emitTargetOutlinedFunction(CodeGenFunction &CGF,
+const OMPExecutableDirective &D,

I don't think you need this argument. You're emitting a new outlined function 
here and don't need info about your current function.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2906-2911
@@ +2905,8 @@
+
+  CodeGenFunction TargetAuxCGF(CGM, true);
+  CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen);
+  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(TargetAuxCGF, &CGInfo);
+  auto *TargetAuxFn = TargetAuxCGF.GenerateCapturedStmtFunction(CS);
+  TargetAuxFn->addFnAttr(llvm::Attribute::AlwaysInline);
+
+  // Collect the arguments of the main function.

You'd better to emit internal function separately in a new static function. 
Then you don't need to create TargetAuxCGF and TargetMainCGF. You should use 
just CGF everywhere. One CodeGenFunction instance per function.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2970-2972
@@ +2969,5 @@
+
+  auto ai = Args.begin();
+  for (RecordDecl::field_iterator ri = RD->field_begin(), re = RD->field_end();
+   ri != re; ++ri, ++ai) {
+

Variable names should start with an upper case letter (e.g. Leader or Boats).


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3070-3107
@@ +3069,40 @@
+} else {
+  // We expect all the sizes to be constant, so we collect them to create
+  // a constant array.
+  SmallVector ConstSizes;
+  for (auto *V : Sizes)
+ConstSizes.push_back(cast(V)->getZExtValue());
+
+  auto SizeTypeBytes =
+  CGF.getContext()
+  .getTypeSizeInChars(CGF.getContext().getSizeType())
+  .getQuantity();
+
+  llvm::Constant *SizesArrayInit;
+  switch (SizeTypeBytes) {
+  default:
+llvm_unreachable("Unexpected size-type type!");
+  case 1: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+ ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 2: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+  ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 4: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+  ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 8: {
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizes);
+  } break;
+  }
+  auto *SizesArrayGbl = new llvm::GlobalVariable(

Try instead:
  SizesArrayInit = 
llvm::ConstantArray::get(llvm::ArrayType::get(CGM.SizeTy, Sizes.size()), Sizes);



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3161-3164
@@ +3160,6 @@
+  } else {
+BasePointersArray = llvm::Constant::getNullValue(CGM.VoidPtrPtrTy);
+PointersArray = llvm::Constant::getNullValue(CGM.VoidPtrPtrTy);
+SizesArray = llvm::Constant::getNullValue(CGM.SizeTy->getPointerTo());
+MapTypesArray = llvm::Constant::getNullValue(CGM.Int32Ty->getPointerTo());
+  }

llvm::ConstantPointerNull::get();


Comment at: lib/CodeGen/CGOpenMPRuntime.h:190-204
@@ +189,17 @@
+public:
+  /// \brief Values for bit flags used to specify the mapping type for
+  /// offloading.
+  enum OpenMPOffloadMappingFlags {
+/// \brief Allocate memory on the device and move data from host to device.
+OMP_MAP_TO = 0x01,
+/// \brief Allocate memory on the device and move data from device to host.
+OMP_MAP_FROM = 0x02,
+  };
+
+private:
+  enum OpenMPOffloadingReservedDeviceIDs {
+/// \brief Device ID if the device was not defined, runtime should get it
+/// from environment variables in the spec.
+OMP_DEVICEID_UNDEF = -1,
+  };
+

These enums must not be exposed by CGOpenMPRuntime until they are used in 
arguments of runtime member functions.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:768
@@ -710,1 +767,3 @@
+  ArrayRef Sizes,
+  ArrayRef MapTypes, bool 
hasVLACaptures);
 };

I don't like the idea of using 'unsigned' as a map type. You should create some 
particular OpenMPMapClauseKind (just like OpenMPDefaultClauseKind, 
OpenMPDependClauseKind, OpenMPProcBindClauseKind etc.) and use it where 
required.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2139-2203
@@ +2138,67 @@
+
+  bool hasVLACaptures = false;
+  const CapturedStmt &CS = *cast(S

Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-21 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Another one thing I forget to mention. Current implementation of 
CGOpenMPRuntime is libomp-specific. You're trying to add functionality that is 
libtarget-specific. Maybe it is a good idea to separate support for libomp and 
libtarget runtime libraries?


http://reviews.llvm.org/D11361



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


[clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-08-21 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Aug 21 04:27:24 2015
New Revision: 245683

URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
Log:
Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.


Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Aug 21 
04:27:24 2015
@@ -67,7 +67,7 @@ def main():
   filename = None
   lines_by_file = {}
   for line in sys.stdin:
-match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
+match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
 if match:
   filename = match.group(2)
 if filename == None:


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


r245684 - Untabify.

2015-08-21 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Aug 21 04:37:53 2015
New Revision: 245684

URL: http://llvm.org/viewvc/llvm-project?rev=245684&view=rev
Log:
Untabify.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=245684&r1=245683&r2=245684&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Aug 21 04:37:53 2015
@@ -362,7 +362,7 @@ macro(add_clang_library name)
   set_source_files_properties(${tds}} PROPERTIES HEADER_FILE_ONLY ON)
 
   if(headers OR tds)
-   set(srcs ${headers} ${tds})
+set(srcs ${headers} ${tds})
   endif()
 endif()
   endif(MSVC_IDE OR XCODE)


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


r245685 - [CMake][Standalone] Detect Python. Python is used for Lit testing.

2015-08-21 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Aug 21 04:38:46 2015
New Revision: 245685

URL: http://llvm.org/viewvc/llvm-project?rev=245685&view=rev
Log:
[CMake][Standalone] Detect Python. Python is used for Lit testing.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=245685&r1=245684&r2=245685&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Aug 21 04:38:46 2015
@@ -116,6 +116,19 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
+set(Python_ADDITIONAL_VERSIONS 2.7)
+include(FindPythonInterp)
+if(NOT PYTHONINTERP_FOUND)
+  message(FATAL_ERROR
+"Unable to find Python interpreter, required for builds and testing.
+
+Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
+endif()
+
+if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 )
+  message(FATAL_ERROR "Python 2.7 or newer is required")
+endif()
+
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX}


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


[PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: cfe-commits, klimek.
angelgarcia changed the visibility of this Differential Revision from "Public 
(No Login Required)" to "All Users".

Migrate UseAuto from clang-modernize to clang-tidy.

http://reviews.llvm.org/D12231

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  test/clang-tidy/Inputs/modernize-use-auto/containers.h
  test/clang-tidy/modernize-use-auto-iterator.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -0,0 +1,96 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t
+
+class MyType {};
+
+class MyDerivedType : public MyType {};
+
+// FIXME: the replacement sometimes results in two consecutive spaces after
+// the word 'auto' (due to the presence of spaces at both sides of '*').
+void auto_new() {
+  MyType *a_new = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto a_new = new MyType();
+
+  static MyType *a_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: static auto a_static = new MyType();
+
+  MyType *derived = new MyDerivedType();
+
+  void *vd = new MyType();
+
+  // CV-qualifier tests.
+  //
+  // NOTE : the form "type const" is expected here because of a deficiency in
+  // TypeLoc where CV qualifiers are not considered part of the type location
+  // info. That is, all that is being replaced in each case is "MyType *" and
+  // not "MyType * const".
+  static MyType * const d_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: static auto  const d_static = new MyType();
+
+  MyType * const a_const = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto  const a_const = new MyType();
+
+  MyType * volatile vol = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto  volatile vol = new MyType();
+
+  int (**func)(int, int) = new (int(*[5])(int,int));
+
+  int *array = new int[5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto array = new int[5];
+
+  MyType *ptr(new MyType);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto ptr(new MyType);
+
+  MyType *ptr2{new MyType};
+
+  {
+// Test for declaration lists.
+MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+
+// Non-initialized declaration should not be transformed.
+MyType *d = new MyType(), *e;
+
+MyType **f = new MyType*(), **g = new MyType*();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+
+// Mismatching types in declaration lists should not be transformed.
+MyType *h = new MyType(), **i = new MyType*();
+
+// '*' shouldn't be removed in case of mismatching types with multiple
+// declarations.
+MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
+  }
+
+  {
+// Test for typedefs.
+typedef int * int_p;
+
+int_p a = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto  a = new int;
+int_p *b = new int*;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto b = new int*;
+
+// Test for typedefs in declarations lists.
+int_p c = new int, d = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto  c = new int, d = new int;
+
+// Different types should not be transformed.
+int_p e = new int, *f = new int_p;
+
+int_p *g = new int*, *h = new int_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto [modernize-use-auto]
+// CHECK-FIXES: auto g = new int*, h = new int_p;
+  }
+}
Index: test/clang-tidy/modernize-use-auto-iterator.cpp
===
--- test/clang-tidy/modernize-use-auto-iterator.cpp
+++ test/clang-tidy/modernize-use-auto-iterator.cpp
@@ -0,0 +1,320 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+#include "containers.h"
+
+void f_array() {
+  std::array C;
+  std::array::iterator I1 = 

Re: [clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-08-21 Thread Alexander Kornienko via cfe-commits
On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yrnkrn
> Date: Fri Aug 21 04:27:24 2015
> New Revision: 245683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
> Log:
> Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput


Out of curiosity, when does this happen? (I mean quotes around the file
name)


>
>

> Modified:
> clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>
> Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
> +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Aug 21
> 04:27:24 2015
> @@ -67,7 +67,7 @@ def main():
>filename = None
>lines_by_file = {}
>for line in sys.stdin:
> -match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
> +match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
>  if match:
>filename = match.group(2)
>  if filename == None:
>
>
> ___
> 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


[clang-tools-extra] r245688 - Make test EOL tolerant by moving the symbol ot the first line

2015-08-21 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Aug 21 05:46:46 2015
New Revision: 245688

URL: http://llvm.org/viewvc/llvm-project?rev=245688&view=rev
Log:
Make test EOL tolerant by moving the symbol ot the first line
before any EOL changes the byte offset count and enable it on Windows.


Modified:
clang-tools-extra/trunk/test/clang-rename/VarTest.cpp

Modified: clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/VarTest.cpp?rev=245688&r1=245687&r2=245688&view=diff
==
--- clang-tools-extra/trunk/test/clang-rename/VarTest.cpp (original)
+++ clang-tools-extra/trunk/test/clang-rename/VarTest.cpp Fri Aug 21 05:46:46 
2015
@@ -1,10 +1,8 @@
+namespace A { int foo;  // CHECK: int hector;
+}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=170 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-// REQUIRES: shell
-namespace A {
-int foo;  // CHECK: int hector;
-}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;


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


Re: [clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-08-21 Thread Yaron Keren via cfe-commits
Whenever is any special character in the filename, such as space or
backslash (Windows), some examples:

On Windows:
--- ".\\a.cpp"  2015-08-21 00:22:57.885370200 +0300
+++ b.cpp   2015-08-21 01:05:28.726269900 +0300

--- ./a.cpp 2015-08-21 00:22:57.885370200 +0300
+++ b.cpp   2015-08-21 01:05:28.726269900 +0300

--- "a a.cpp"   2015-08-21 00:22:57.885370200 +0300
+++ b.cpp   2015-08-21 01:05:28.726269900 +0300

On Linux:
~$ diff -U0 ./a.cpp b\ b.cpp
--- ./a.cpp 2015-08-14 00:27:03.569276652 +0300
+++ "b b.cpp"   2015-08-21 13:54:26.787896719 +0300

filename with space will break current clang-tidy-diff.py on all platforms,
the regular expression does not match quotes.
There is surely some Python package to process filenames correctly if this
ever become a problem.


2015-08-21 13:37 GMT+03:00 Alexander Kornienko :

> On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: yrnkrn
>> Date: Fri Aug 21 04:27:24 2015
>> New Revision: 245683
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
>> Log:
>> Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput
>
>
> Out of curiosity, when does this happen? (I mean quotes around the file
> name)
>
>
>>
>>
>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
>> +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Aug 21
>> 04:27:24 2015
>> @@ -67,7 +67,7 @@ def main():
>>filename = None
>>lines_by_file = {}
>>for line in sys.stdin:
>> -match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
>> +match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
>>  if match:
>>filename = match.group(2)
>>  if filename == None:
>>
>>
>> ___
>> 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


r245692 - [OPENMP 4.1] Initial support for 'simdlen' clause.

2015-08-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 21 06:14:16 2015
New Revision: 245692

URL: http://llvm.org/viewvc/llvm-project?rev=245692&view=rev
Log:
[OPENMP 4.1] Initial support for 'simdlen' clause.
Add parsing/sema analysis for 'simdlen' clause in simd directives. Also add 
check that if both 'safelen' and 'simdlen' clauses are specified, the value of 
'simdlen' parameter is less than the value of 'safelen' parameter.

Added:
cfe/trunk/test/OpenMP/for_simd_simdlen_messages.cpp   (with props)
cfe/trunk/test/OpenMP/parallel_for_simd_simdlen_messages.cpp   (with props)
cfe/trunk/test/OpenMP/simd_simdlen_messages.cpp   (with props)
Modified:
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/for_simd_misc_messages.c
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/simd_ast_print.cpp
cfe/trunk/test/OpenMP/simd_misc_messages.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=245692&r1=245691&r2=245692&view=diff
==
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Aug 21 06:14:16 
2015
@@ -2455,6 +2455,12 @@ bool RecursiveASTVisitor::Visit
 }
 
 template 
+bool RecursiveASTVisitor::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
+  TRY_TO(TraverseStmt(C->getSimdlen()));
+  return true;
+}
+
+template 
 bool
 RecursiveASTVisitor::VisitOMPCollapseClause(OMPCollapseClause *C) {
   TRY_TO(TraverseStmt(C->getNumForLoops()));

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=245692&r1=245691&r2=245692&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Aug 21 06:14:16 2015
@@ -365,6 +365,61 @@ public:
   child_range children() { return child_range(&Safelen, &Safelen + 1); }
 };
 
+/// \brief This represents 'simdlen' clause in the '#pragma omp ...'
+/// directive.
+///
+/// \code
+/// #pragma omp simd simdlen(4)
+/// \endcode
+/// In this example directive '#pragma omp simd' has clause 'simdlen'
+/// with single expression '4'.
+/// If the 'simdlen' clause is used then it specifies the preferred number of
+/// iterations to be executed concurrently. The parameter of the 'simdlen'
+/// clause must be a constant positive integer expression.
+///
+class OMPSimdlenClause : public OMPClause {
+  friend class OMPClauseReader;
+  /// \brief Location of '('.
+  SourceLocation LParenLoc;
+  /// \brief Safe iteration space distance.
+  Stmt *Simdlen;
+
+  /// \brief Set simdlen.
+  void setSimdlen(Expr *Len) { Simdlen = Len; }
+
+public:
+  /// \brief Build 'simdlen' clause.
+  ///
+  /// \param Len Expression associated with this clause.
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation 
LParenLoc,
+   SourceLocation EndLoc)
+  : OMPClause(OMPC_simdlen, StartLoc, EndLoc), LParenLoc(LParenLoc),
+Simdlen(Len) {}
+
+  /// \brief Build an empty clause.
+  ///
+  explicit OMPSimdlenClause()
+  : OMPClause(OMPC_simdlen, SourceLocation(), SourceLocation()),
+LParenLoc(SourceLocation()), Simdlen(nullptr) {}
+
+  /// \brief Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+  /// \brief Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// \brief Return safe iteration space distance.
+  Expr *getSimdlen() const { return cast_or_null(Simdlen); }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_simdlen;
+  }
+
+  child_range children() { return child_range(&Simdlen, &Simdlen + 1); }
+};
+
 /// \brief This represents 'collapse' clause in the '#pragma omp ...'
 /// directive.
 ///

Modified: cfe/trunk/include/clang/AST/Rec

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:45
@@ +44,3 @@
+
+  // The following test is based on DeclPrinter::VisitVarDecl() o find if an
+  // initializer is implicit o not.

s/o find/to find/?

s/o not/or not/?


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:51
@@ +50,3 @@
+  return false;
+ImplicitInit = Construct->getNumArgs() == 0 ||
+   Construct->getArg(0)->isDefaultArgument();

1. The logic is somewhat convoluted here. Instead of using a boolean flag 
that's assigned only here, I'd directly return the value.
2. Don't use else after return. 
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

  if (const auto *Construct = dyn_cast(Init)) {
​return Construct->isListInitialization() && Construct->getNumArgs() > 0 && 
!Construct->getArg(0)->isDefaultArgument();
  }
  return Node.getInitStyle() != VarDecl::ListInit;


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:81
@@ +80,3 @@
+if (NewQT == QT)
+  break;
+QT = NewQT;

Replace `break;` with `return false;` to make the control flow easier to 
understand.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:180
@@ +179,3 @@
+  return typedefType(
+  hasDeclaration(allOf(namedDecl(hasStdIteratorName()),
+   hasDeclContext(recordDecl(hasStdContainerName(),

The `hasDeclaration(...)` part is also used in the next function. Consider 
pulling this to a separate function.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:206
@@ +205,3 @@
+  namesType(
+  anyOf(typedefType(hasDeclaration(namedDecl(hasStdIteratorName(,
+
recordType(hasDeclaration(namedDecl(hasStdIteratorName(;

`hasDeclaration(namedDecl(hasStdIteratorName()))` is used at least twice. 
Please consider pulling this to a variable.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:348
@@ +347,3 @@
+  FirstDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange());
+  auto Diag = diag(Range.getBegin(), "use auto");
+

I'd make the message more user-friendly by specifying instead of what exactly 
`auto` should be used. This could be unclear from the context what exactly the 
check means.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:361
@@ +360,3 @@
+void UseAutoCheck::check(const MatchFinder::MatchResult &Result) {
+  const DeclStmt *Dec;
+  if ((Dec = Result.Nodes.getNodeAs(IteratorDeclStmtId))) {

I'd rewrite this to use the `if (T *x = ...)` style:

  if (const auto *Decl = Result.Nodes.getNodeAs(IteratorDeclStmtId)) {
ReplaceIterators(Decl, Result.Context);
  } else if (const auto *Decl = 
Result.Nodes.getNodeAs(DeclWithNewId)) {
ReplaceNew(Dec, Result.Context);
  } else {
llvm_unreachable("Bad Callback. No node provided.");
  }


Comment at: clang-tidy/modernize/UseAutoCheck.h:27
@@ +26,3 @@
+
+  void ReplaceIterators(const DeclStmt *D, ASTContext *Context);
+  void ReplaceNew(const DeclStmt *D, ASTContext *Context);

Why are these public?


Comment at: clang-tidy/modernize/UseAutoCheck.h:27
@@ +26,3 @@
+
+  void ReplaceIterators(const DeclStmt *D, ASTContext *Context);
+  void ReplaceNew(const DeclStmt *D, ASTContext *Context);

alexfh wrote:
> Why are these public?
Method names should start with a lower-case character.

http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Comment at: test/clang-tidy/modernize-use-auto-iterator.cpp:30
@@ +29,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto [modernize-use-auto]
+  // CHECK-FIXES: auto I1 = C.begin();
+

Make the variable names unique across all functions to avoid incorrect matches.


http://reviews.llvm.org/D12231



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


r245693 - [OPENMP 4.1] Add ast-print tests for 'val', 'uval' and 'ref' modifiers.

2015-08-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 21 06:32:42 2015
New Revision: 245693

URL: http://llvm.org/viewvc/llvm-project?rev=245693&view=rev
Log:
[OPENMP 4.1] Add ast-print tests for 'val', 'uval' and 'ref' modifiers.

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

Modified: cfe/trunk/test/OpenMP/simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_ast_print.cpp?rev=245693&r1=245692&r2=245693&view=diff
==
--- cfe/trunk/test/OpenMP/simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_ast_print.cpp Fri Aug 21 06:32:42 2015
@@ -12,10 +12,11 @@ template T reduct(T* a
   N i;
   N ind;
   N myind;
+  N &ref = i;
   T sum = (T)0;
 // CHECK: T sum = (T)0;
-#pragma omp simd private(myind, g_ind), linear(ind), aligned(arr)
-// CHECK-NEXT: #pragma omp simd private(myind,g_ind) linear(ind) aligned(arr)
+#pragma omp simd private(myind, g_ind), linear(ind), aligned(arr), 
linear(uval(ref))
+// CHECK-NEXT: #pragma omp simd private(myind,g_ind) linear(ind) aligned(arr) 
linear(uval(ref))
   for (i = 0; i < num; ++i) {
 myind = ind;
 T cur = arr[myind];
@@ -32,11 +33,13 @@ template struct S {
 T res;
 T val;
 T lin = 0;
+T &ref = res;
 // CHECK: T res;
 // CHECK: T val;
 // CHECK: T lin = 0;
-#pragma omp simd private(val)  safelen(7) linear(lin : -5) 
lastprivate(res) simdlen(5)
-// CHECK-NEXT: #pragma omp simd private(val) safelen(7) linear(lin: -5) 
lastprivate(res) simdlen(5)
+// CHECK: T &ref = res;
+#pragma omp simd private(val)  safelen(7) linear(lin : -5) 
lastprivate(res) simdlen(5) linear(ref(ref))
+// CHECK-NEXT: #pragma omp simd private(val) safelen(7) linear(lin: -5) 
lastprivate(res) simdlen(5) linear(ref(ref))
 for (T i = 7; i < m_a; ++i) {
   val = v[i-7] + m_a;
   res = val;
@@ -90,6 +93,7 @@ template struct S2 {
 int main (int argc, char **argv) {
   int b = argc, c, d, e, f, g;
   int k1=0,k2=0;
+  int &ref = b;
   static int *a;
 // CHECK: static int *a;
 #pragma omp simd
@@ -112,8 +116,8 @@ int main (int argc, char **argv) {
 // CHECK-NEXT: foo();
   const int CLEN = 4;
 // CHECK-NEXT: const int CLEN = 4;
-  #pragma omp simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) 
simdlen(CLEN)
-// CHECK-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: CLEN) safelen(CLEN) 
collapse(1) simdlen(CLEN)
+  #pragma omp simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) 
simdlen(CLEN) linear(val(ref): CLEN)
+// CHECK-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: CLEN) safelen(CLEN) 
collapse(1) simdlen(CLEN) linear(val(ref): CLEN)
   for (int i = 0; i < 10; ++i)foo();
 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
 // CHECK-NEXT: foo();


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


r245694 - clang-format: Be more conservative about specially indenting blocks in C++.

2015-08-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Aug 21 06:44:57 2015
New Revision: 245694

URL: http://llvm.org/viewvc/llvm-project?rev=245694&view=rev
Log:
clang-format: Be more conservative about specially indenting blocks in C++.

This is a bit of a step back of what we did in r222531, as there are
some corner cases in C++, where this kind of formatting is really bad.

Example:
Before:
  virtual (std::function IsKindWeWant = [&]() {
return true;
  }, a a);

After:
  virtual (std::function IsKindWeWant =
   [&]() { return true; },
   a a);

The block formatting logic in JavaScript will probably go some other changes,
too, and we'll potentially be able to make the rules more consistent again. For
now, this seems to be the best approach for C++.

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=245694&r1=245693&r2=245694&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Aug 21 06:44:57 2015
@@ -501,6 +501,7 @@ unsigned ContinuationIndenter::addTokenO
   // Any break on this level means that the parent level has been broken
   // and we need to avoid bin packing there.
   bool NestedBlockSpecialCase =
+  Style.Language != FormatStyle::LK_Cpp &&
   Current.is(tok::r_brace) && State.Stack.size() > 1 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined;
   if (!NestedBlockSpecialCase)

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=245694&r1=245693&r2=245694&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Aug 21 06:44:57 2015
@@ -2245,7 +2245,7 @@ bool TokenAnnotator::canBreakBefore(cons
   Left.is(tok::kw_operator))
 return false;
   if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) &&
-  Line.Type == LT_VirtualFunctionDecl)
+  Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0)
 return false;
   if (Left.is(tok::l_paren) && Left.is(TT_AttributeParen))
 return false;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245694&r1=245693&r2=245694&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 21 06:44:57 2015
@@ -3076,10 +3076,12 @@ TEST_F(FormatTest, LayoutBlockInsidePare
"  int i;\n"
"  int j;\n"
"});");
-  verifyFormat("functionCall({\n"
-   "  int i;\n"
-   "  int j;\n"
-   "}, , , );");
+  verifyFormat("functionCall(\n"
+   "{\n"
+   "  int i;\n"
+   "  int j;\n"
+   "},\n"
+   ", , );");
   verifyFormat("functionA(functionB({\n"
"int i;\n"
"int j;\n"
@@ -3186,9 +3188,11 @@ TEST_F(FormatTest, LayoutNestedBlocks) {
  "});");
   FormatStyle Style = getGoogleStyle();
   Style.ColumnLimit = 45;
-  verifyFormat("Debug(a, {\n"
-   "  if () return;\n"
-   "}, a);",
+  verifyFormat("Debug(a,\n"
+   "  {\n"
+   "if () return;\n"
+   "  },\n"
+   "  a);",
Style);
 
   verifyFormat("SomeFunction({MACRO({ return output; }), b});");
@@ -8100,11 +8104,13 @@ TEST_F(FormatTest, ConfigurableUseOfTab)
"};",
Tab);
   verifyFormat("{\n"
-   "\tQ({\n"
-   "\t\tint a;\n"
-   "\t\tsomeFunction(,\n"
-   "\t\t bbb);\n"
-   "\t}, p);\n"
+   "\tQ(\n"
+   "\t{\n"
+   "\t\tint a;\n"
+   "\t\tsomeFunction(,\n"
+   "\t\t bbb);\n"
+   "\t},\n"
+   "\tp);\n"
"}",
Tab);
   EXPECT_EQ("{\n"
@@ -9996,6 +10002,9 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("SomeFunction({[&] {\n"
"  // comment\n"
"}});");
+  verifyFormat("virtual (std::function  
=\n"

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32815.
angelgarcia marked 10 inline comments as done.
angelgarcia added a comment.

Fix comments.

I did not include the 'hasDeclaration()" call in the 'standardIterator' 
function because its return type is
internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, 
internal::Matcher, void(internal::HasDeclarationSupportedTypes)>


http://reviews.llvm.org/D12231

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  test/clang-tidy/Inputs/modernize-use-auto/containers.h
  test/clang-tidy/modernize-use-auto-iterator.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -0,0 +1,96 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t
+
+class MyType {};
+
+class MyDerivedType : public MyType {};
+
+// FIXME: the replacement sometimes results in two consecutive spaces after
+// the word 'auto' (due to the presence of spaces at both sides of '*').
+void auto_new() {
+  MyType *a_new = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new [modernize-use-auto]
+  // CHECK-FIXES: auto a_new = new MyType();
+
+  static MyType *a_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto a_static = new MyType();
+
+  MyType *derived = new MyDerivedType();
+
+  void *vd = new MyType();
+
+  // CV-qualifier tests.
+  //
+  // NOTE : the form "type const" is expected here because of a deficiency in
+  // TypeLoc where CV qualifiers are not considered part of the type location
+  // info. That is, all that is being replaced in each case is "MyType *" and
+  // not "MyType * const".
+  static MyType * const d_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto  const d_static = new MyType();
+
+  MyType * const a_const = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  const a_const = new MyType();
+
+  MyType * volatile vol = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  volatile vol = new MyType();
+
+  int (**func)(int, int) = new (int(*[5])(int,int));
+
+  int *array = new int[5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto array = new int[5];
+
+  MyType *ptr(new MyType);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto ptr(new MyType);
+
+  MyType *ptr2{new MyType};
+
+  {
+// Test for declaration lists.
+MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+
+// Non-initialized declaration should not be transformed.
+MyType *d = new MyType(), *e;
+
+MyType **f = new MyType*(), **g = new MyType*();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+
+// Mismatching types in declaration lists should not be transformed.
+MyType *h = new MyType(), **i = new MyType*();
+
+// '*' shouldn't be removed in case of mismatching types with multiple
+// declarations.
+MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
+  }
+
+  {
+// Test for typedefs.
+typedef int * int_p;
+
+int_p a = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  a = new int;
+int_p *b = new int*;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto b = new int*;
+
+// Test for typedefs in declarations lists.
+int_p c = new int, d = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  c = new int, d = new int;
+
+// Different types should not be transformed.
+int_p e = new int, *f = new int_p;
+
+int_p *g = new int*, *h = new int_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto g = new int*, h = new int_p;
+  }
+}
Index: test/clang-tidy/modernize-use-auto-iterator.cpp
===
--- test/clang-tidy/modernize-use-auto-iterator.cpp
+++ test/clang-tidy/modernize-use-auto-iterator.cpp
@@ -0,0 +1,320 @@
+// RUN: %python %S/ch

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32816.
angelgarcia added a comment.

Apply clang-format to the code.


http://reviews.llvm.org/D12231

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  test/clang-tidy/Inputs/modernize-use-auto/containers.h
  test/clang-tidy/modernize-use-auto-iterator.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -0,0 +1,96 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t
+
+class MyType {};
+
+class MyDerivedType : public MyType {};
+
+// FIXME: the replacement sometimes results in two consecutive spaces after
+// the word 'auto' (due to the presence of spaces at both sides of '*').
+void auto_new() {
+  MyType *a_new = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new [modernize-use-auto]
+  // CHECK-FIXES: auto a_new = new MyType();
+
+  static MyType *a_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto a_static = new MyType();
+
+  MyType *derived = new MyDerivedType();
+
+  void *vd = new MyType();
+
+  // CV-qualifier tests.
+  //
+  // NOTE : the form "type const" is expected here because of a deficiency in
+  // TypeLoc where CV qualifiers are not considered part of the type location
+  // info. That is, all that is being replaced in each case is "MyType *" and
+  // not "MyType * const".
+  static MyType * const d_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto  const d_static = new MyType();
+
+  MyType * const a_const = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  const a_const = new MyType();
+
+  MyType * volatile vol = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  volatile vol = new MyType();
+
+  int (**func)(int, int) = new (int(*[5])(int,int));
+
+  int *array = new int[5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto array = new int[5];
+
+  MyType *ptr(new MyType);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto ptr(new MyType);
+
+  MyType *ptr2{new MyType};
+
+  {
+// Test for declaration lists.
+MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+
+// Non-initialized declaration should not be transformed.
+MyType *d = new MyType(), *e;
+
+MyType **f = new MyType*(), **g = new MyType*();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+
+// Mismatching types in declaration lists should not be transformed.
+MyType *h = new MyType(), **i = new MyType*();
+
+// '*' shouldn't be removed in case of mismatching types with multiple
+// declarations.
+MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
+  }
+
+  {
+// Test for typedefs.
+typedef int * int_p;
+
+int_p a = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  a = new int;
+int_p *b = new int*;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto b = new int*;
+
+// Test for typedefs in declarations lists.
+int_p c = new int, d = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  c = new int, d = new int;
+
+// Different types should not be transformed.
+int_p e = new int, *f = new int_p;
+
+int_p *g = new int*, *h = new int_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto g = new int*, h = new int_p;
+  }
+}
Index: test/clang-tidy/modernize-use-auto-iterator.cpp
===
--- test/clang-tidy/modernize-use-auto-iterator.cpp
+++ test/clang-tidy/modernize-use-auto-iterator.cpp
@@ -0,0 +1,320 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+#include "containers.h"
+
+void f_array() {
+  std::array C;
+  std::array::iterator ArrayI1 = C.begin();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declar

r245697 - [OPENMP 4.1] Add codegen for 'simdlen' clause.

2015-08-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 21 07:19:04 2015
New Revision: 245697

URL: http://llvm.org/viewvc/llvm-project?rev=245697&view=rev
Log:
[OPENMP 4.1] Add codegen for 'simdlen' clause.
Add emission of metadata for simd loops in presence of 'simdlen' clause.
If 'simdlen' clause is provided without 'safelen' clause, the vectorizer width 
for the loop is set to value of 'simdlen' clause + all read/write ops in loop 
are marked with '!llvm.mem.parallel_loop_access' metadata.
If 'simdlen' clause is provided along with 'safelen' clause, the vectorizer 
width for the loop is set to value of 'simdlen' clause + all read/write ops in 
loop are not marked with '!llvm.mem.parallel_loop_access' metadata.
If 'safelen' clause is provided without 'simdlen' clause, the vectorizer width 
for the loop is set to value of 'safelen' clause + all read/write ops in loop 
are not marked with '!llvm.mem.parallel_loop_access' metadata.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/simd_metadata.c

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=245697&r1=245696&r2=245697&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Aug 21 07:19:04 2015
@@ -739,10 +739,20 @@ emitPrivateLinearVars(CodeGenFunction &C
   }
 }
 
-static void emitSafelenClause(CodeGenFunction &CGF,
-  const OMPExecutableDirective &D) {
+static void emitSimdlenSafelenClause(CodeGenFunction &CGF,
+ const OMPExecutableDirective &D) {
   if (auto *C =
-  cast_or_null(D.getSingleClause(OMPC_safelen))) {
+  cast_or_null(D.getSingleClause(OMPC_simdlen))) {
+RValue Len = CGF.EmitAnyExpr(C->getSimdlen(), AggValueSlot::ignored(),
+ /*ignoreResult=*/true);
+llvm::ConstantInt *Val = cast(Len.getScalarVal());
+CGF.LoopStack.setVectorizeWidth(Val->getZExtValue());
+// In presence of finite 'safelen', it may be unsafe to mark all
+// the memory instructions parallel, because loop-carried
+// dependences of 'safelen' iterations are possible.
+CGF.LoopStack.setParallel(!D.getSingleClause(OMPC_safelen));
+  } else if (auto *C = cast_or_null(
+ D.getSingleClause(OMPC_safelen))) {
 RValue Len = CGF.EmitAnyExpr(C->getSafelen(), AggValueSlot::ignored(),
  /*ignoreResult=*/true);
 llvm::ConstantInt *Val = cast(Len.getScalarVal());
@@ -758,7 +768,7 @@ void CodeGenFunction::EmitOMPSimdInit(co
   // Walk clauses and process safelen/lastprivate.
   LoopStack.setParallel();
   LoopStack.setVectorizeEnable(true);
-  emitSafelenClause(*this, D);
+  emitSimdlenSafelenClause(*this, D);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(const OMPLoopDirective &D) {

Modified: cfe/trunk/test/OpenMP/simd_metadata.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_metadata.c?rev=245697&r1=245696&r2=245697&view=diff
==
--- cfe/trunk/test/OpenMP/simd_metadata.c (original)
+++ cfe/trunk/test/OpenMP/simd_metadata.c Fri Aug 21 07:19:04 2015
@@ -36,8 +36,69 @@ void h1(float *c, float *a, double b[],
   for (int i = 0; i < size; ++i) {
 c[i] = a[i] * a[i] + b[i] * b[t];
 ++t;
+  }
+// do not emit parallel_loop_access metadata due to usage of safelen clause.
+// CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, 
!llvm.mem.parallel_loop_access {{![0-9]+}}
+#pragma omp simd safelen(16) linear(t) aligned(c:32) aligned(a,b) simdlen(8)
+// CHECK: [[C_PTRINT:%.+]] = ptrtoint
+// CHECK-NEXT:[[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
+// CHECK-NEXT:[[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[C_MASKCOND]])
+// CHECK: [[A_PTRINT:%.+]] = ptrtoint
+
+// X86-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
+// X86-AVX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 31
+// X86-AVX512-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 63
+// PPC-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
+// PPC-QPX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
+
+// CHECK-NEXT:[[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[A_MASKCOND]])
+// CHECK: [[B_PTRINT:%.+]] = ptrtoint
+
+// X86-NEXT:  [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
+// X86-AVX-NEXT:  [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
+// X86-AVX512-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 63
+// PPC-NEXT:  [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
+// PPC-QPX-NEXT:  [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
+
+// CHECK-

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:45
@@ +44,3 @@
+
+  // The following test is based on DeclPrinter::VisitVarDecl() or find if an
+  // initializer is implicit or not.

I can't parse it with 'or'. Did you mean something different?


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:77
@@ +76,3 @@
+  }
+  return false;
+}

This is a dead code now.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:293
@@ +292,3 @@
+  SourceRange Range(V->getTypeSourceInfo()->getTypeLoc().getSourceRange());
+  auto Diag = diag(Range.getBegin(), "use auto when declaring iterators")
+  << FixItHint::CreateReplacement(Range, "auto");

No need for a variable here. Just `diag(...) << ...;`


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:343
@@ +342,3 @@
+  FirstDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange());
+  auto Diag = diag(Range.getBegin(), "use auto when initializing with new");
+

I'd expand the message with an explanation _why_ `auto` is better here: "use 
auto when initializing with new to avoid duplicating the type name".

It might be useful to include the type name to the message, but we can leave 
this until we have specific examples of when it helps.


http://reviews.llvm.org/D12231



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


[PATCH] D12234: [mips][p5600] Add -mcpu=p5600 option.

2015-08-21 Thread Daniel Sanders via cfe-commits
dsanders created this revision.
dsanders added reviewers: vkalintiris, atanasyan.
dsanders added a subscriber: cfe-commits.
dsanders added a dependency: D12193: [mips][p5600] Added P5600 processor and 
initial scheduler..

Depends on D12193

http://reviews.llvm.org/D12234

Files:
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains.cpp
  test/Driver/mips-abi.c
  test/Driver/mips-as.c

Index: test/Driver/mips-as.c
===
--- test/Driver/mips-as.c
+++ test/Driver/mips-as.c
@@ -58,6 +58,11 @@
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
 // MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB"
 //
+// RUN: %clang -target mips-linux-gnu -march=p5600 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-P5600 %s
+// MIPS-P5600: as{{(.exe)?}}" "-march" "p5600" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB"
+//
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -99,6 +99,12 @@
 // MIPS-ARCH-32R2: "-target-abi" "o32"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:-march=p5600 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600 %s
+// MIPS-ARCH-P5600: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600: "-target-abi" "o32"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
 // MIPS-ARCH-3264: "-target-cpu" "mips64"
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1754,7 +1754,7 @@
   addMultilibFlag(isMips16(Args), "mips16", Flags);
   addMultilibFlag(CPUName == "mips32", "march=mips32", Flags);
   addMultilibFlag(CPUName == "mips32r2" || CPUName == "mips32r3" ||
-  CPUName == "mips32r5",
+  CPUName == "mips32r5" || CPUName == "p5600",
   "march=mips32r2", Flags);
   addMultilibFlag(CPUName == "mips32r6", "march=mips32r6", Flags);
   addMultilibFlag(CPUName == "mips64", "march=mips64", Flags);
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6263,6 +6263,7 @@
 .Case("mips64r5", true)
 .Case("mips64r6", true)
 .Case("octeon", true)
+.Case("p5600", true)
 .Default(false);
   }
   const std::string& getCPU() const { return CPU; }


Index: test/Driver/mips-as.c
===
--- test/Driver/mips-as.c
+++ test/Driver/mips-as.c
@@ -58,6 +58,11 @@
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
 // MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
+// RUN: %clang -target mips-linux-gnu -march=p5600 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-P5600 %s
+// MIPS-P5600: as{{(.exe)?}}" "-march" "p5600" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
+//
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -99,6 +99,12 @@
 // MIPS-ARCH-32R2: "-target-abi" "o32"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:-march=p5600 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600 %s
+// MIPS-ARCH-P5600: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600: "-target-abi" "o32"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
 // MIPS-ARCH-3264: "-target-cpu" "mips64"
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1754,7 +1754,7 @@
   addMultilibFlag(isMips16(Args), "mips16", Flags);
   addMultilibFlag(CPUName == "mips32", "march=mips32", Flags);
   addMultilibFlag(CPUName == "mips32r2" || CPUName == "mips32r3" ||
-  CPUName == "mips32r5",
+  CPUName == "mips32r5" || CPUName == "p5600",
   "march=mips32r2", Flags);
   addMultilibFlag(CPUName == "mips32r6", "march=mips32r6", Flags);
   addMultilibFlag(CPUName == "mips64", "march=mips64", Flags);
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6263,6 +6263,7 @@
 .Case(

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32818.
angelgarcia added a comment.

Fix comments: change warning message and minor fixes.


http://reviews.llvm.org/D12231

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  test/clang-tidy/Inputs/modernize-use-auto/containers.h
  test/clang-tidy/modernize-use-auto-iterator.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -0,0 +1,96 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t
+
+class MyType {};
+
+class MyDerivedType : public MyType {};
+
+// FIXME: the replacement sometimes results in two consecutive spaces after
+// the word 'auto' (due to the presence of spaces at both sides of '*').
+void auto_new() {
+  MyType *a_new = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto a_new = new MyType();
+
+  static MyType *a_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto a_static = new MyType();
+
+  MyType *derived = new MyDerivedType();
+
+  void *vd = new MyType();
+
+  // CV-qualifier tests.
+  //
+  // NOTE : the form "type const" is expected here because of a deficiency in
+  // TypeLoc where CV qualifiers are not considered part of the type location
+  // info. That is, all that is being replaced in each case is "MyType *" and
+  // not "MyType * const".
+  static MyType * const d_static = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
+  // CHECK-FIXES: static auto  const d_static = new MyType();
+
+  MyType * const a_const = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  const a_const = new MyType();
+
+  MyType * volatile vol = new MyType();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto  volatile vol = new MyType();
+
+  int (**func)(int, int) = new (int(*[5])(int,int));
+
+  int *array = new int[5];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto array = new int[5];
+
+  MyType *ptr(new MyType);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto ptr(new MyType);
+
+  MyType *ptr2{new MyType};
+
+  {
+// Test for declaration lists.
+MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+
+// Non-initialized declaration should not be transformed.
+MyType *d = new MyType(), *e;
+
+MyType **f = new MyType*(), **g = new MyType*();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+
+// Mismatching types in declaration lists should not be transformed.
+MyType *h = new MyType(), **i = new MyType*();
+
+// '*' shouldn't be removed in case of mismatching types with multiple
+// declarations.
+MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
+  }
+
+  {
+// Test for typedefs.
+typedef int * int_p;
+
+int_p a = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  a = new int;
+int_p *b = new int*;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto b = new int*;
+
+// Test for typedefs in declarations lists.
+int_p c = new int, d = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto  c = new int, d = new int;
+
+// Different types should not be transformed.
+int_p e = new int, *f = new int_p;
+
+int_p *g = new int*, *h = new int_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
+// CHECK-FIXES: auto g = new int*, h = new int_p;
+  }
+}
Index: test/clang-tidy/modernize-use-auto-iterator.cpp
===
--- test/clang-tidy/modernize-use-auto-iterator.cpp
+++ test/clang-tidy/modernize-use-auto-iterator.cpp
@@ -0,0 +1,320 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-auto %t -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+#include "containers.h"
+
+void f_array() {
+  std::array C;
+  std::array::iterator ArrayI1 = C.begin();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when decla

[clang-tools-extra] r245699 - [clang-tidy] Remove check_clang_tidy.sh that has been replaced with check_clang_tidy.py.

2015-08-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Aug 21 07:41:14 2015
New Revision: 245699

URL: http://llvm.org/viewvc/llvm-project?rev=245699&view=rev
Log:
[clang-tidy] Remove check_clang_tidy.sh that has been replaced with 
check_clang_tidy.py.

Removed:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.sh

Removed: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.sh
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.sh?rev=245698&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.sh (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.sh (removed)
@@ -1,54 +0,0 @@
-#!/bin/sh
-#
-# Run clang-tidy in fix mode and verify fixes, messages or both.
-# Usage:
-#   check_clang_tidy.sh\
-# [optional clang-tidy arguments]
-#
-# Example:
-#   // RUN: $(dirname %s)/check_clang_tidy.sh %s llvm-include-order %t -- 
-isystem $(dirname %s)/Inputs/Headers
-#   // REQUIRES: shell
-
-INPUT_FILE=$1
-CHECK_TO_RUN=$2
-TEMPORARY_FILE=$3.cpp
-# Feed the rest arguments to clang-tidy.
-shift 3
-if [ "$#" -eq 0 ] ; then
-  # Default to -- --std=c++11
-  set - -- --std=c++11
-fi
-
-set -o errexit
-
-if ! grep -q 'CHECK-FIXES\|CHECK-MESSAGES' "${INPUT_FILE}"; then
-  echo "FAIL: Neither CHECK-FIXES nor CHECK-MESSAGES found in the input"
-  exit 1
-fi
-
-# Remove the contents of the CHECK lines to avoid CHECKs matching on 
themselves.
-# We need to keep the comments to preserve line numbers while avoiding empty
-# lines which could potentially trigger formatting-related checks.
-sed 's#// *CHECK-[A-Z-]*:.*#//#' "${INPUT_FILE}" > "${TEMPORARY_FILE}"
-cp "${TEMPORARY_FILE}" "${TEMPORARY_FILE}.orig"
-
-clang-tidy "${TEMPORARY_FILE}" -fix --checks="-*,${CHECK_TO_RUN}" "$@" \
-  > "${TEMPORARY_FILE}.msg" 2>&1
-
-echo " clang-tidy output "
-cat "${TEMPORARY_FILE}.msg"
-echo "---"
-
-echo "-- Fixes --"
-diff -u "${TEMPORARY_FILE}.orig" "${TEMPORARY_FILE}" || true
-echo "---"
-
-if grep -q 'CHECK-FIXES' "${INPUT_FILE}"; then
-  FileCheck -input-file="${TEMPORARY_FILE}" "${INPUT_FILE}" \
--check-prefix=CHECK-FIXES -strict-whitespace
-fi
-
-if grep -q 'CHECK-MESSAGES' "${INPUT_FILE}"; then
-  FileCheck -input-file="${TEMPORARY_FILE}.msg" "${INPUT_FILE}" \
--check-prefix=CHECK-MESSAGES -implicit-check-not='{{warning|error}}:'
-fi


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


r245700 - [RecordLayoutBuilder] Remove duplicated diagnostic argument. NFC.

2015-08-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Aug 21 07:51:01 2015
New Revision: 245700

URL: http://llvm.org/viewvc/llvm-project?rev=245700&view=rev
Log:
[RecordLayoutBuilder] Remove duplicated diagnostic argument. NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=245700&r1=245699&r2=245700&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 21 07:51:01 
2015
@@ -4188,15 +4188,15 @@ def warn_array_new_too_large : Warning<"
 // -Wpadded, -Wpacked
 def warn_padded_struct_field : Warning<
   "padding %select{struct|interface|class}0 %1 with %2 "
-  "%select{byte|bit}3%select{|s}4 to align %5">,
+  "%select{byte|bit}3%s2 to align %4">,
   InGroup, DefaultIgnore;
 def warn_padded_struct_anon_field : Warning<
   "padding %select{struct|interface|class}0 %1 with %2 "
-  "%select{byte|bit}3%select{|s}4 to align anonymous bit-field">,
+  "%select{byte|bit}3%s2 to align anonymous bit-field">,
   InGroup, DefaultIgnore;
 def warn_padded_struct_size : Warning<
-  "padding size of %0 with %1 %select{byte|bit}2%select{|s}3 "
-  "to alignment boundary">, InGroup, DefaultIgnore;
+  "padding size of %0 with %1 %select{byte|bit}2%s1 to alignment boundary">,
+  InGroup, DefaultIgnore;
 def warn_unnecessary_packed : Warning<
   "packed attribute is unnecessary for %0">, InGroup, DefaultIgnore;
 

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=245700&r1=245699&r2=245700&view=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Aug 21 07:51:01 2015
@@ -1866,7 +1866,7 @@ void ItaniumRecordLayoutBuilder::FinishL
   Diag(RD->getLocation(), diag::warn_padded_struct_size)
   << Context.getTypeDeclType(RD)
   << PadSize
-  << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1); // plural or not
+  << (InBits ? 1 : 0); // (byte|bit)
 }
 
 // Warn if we packed it unnecessarily. If the alignment is 1 byte don't
@@ -1956,14 +1956,14 @@ void ItaniumRecordLayoutBuilder::CheckFi
   << getPaddingDiagFromTagKind(D->getParent()->getTagKind())
   << Context.getTypeDeclType(D->getParent())
   << PadSize
-  << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1) // plural or not
+  << (InBits ? 1 : 0) // (byte|bit)
   << D->getIdentifier();
 else
   Diag(D->getLocation(), diag::warn_padded_struct_anon_field)
   << getPaddingDiagFromTagKind(D->getParent()->getTagKind())
   << Context.getTypeDeclType(D->getParent())
   << PadSize
-  << (InBits ? 1 : 0) /*(byte|bit)*/ << (PadSize > 1); // plural or not
+  << (InBits ? 1 : 0); // (byte|bit)
   }
 
   // Warn if we packed it unnecessarily. If the alignment is 1 byte don't


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


r245698 - Remove unused diagnostic.

2015-08-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Aug 21 07:29:47 2015
New Revision: 245698

URL: http://llvm.org/viewvc/llvm-project?rev=245698&view=rev
Log:
Remove unused diagnostic.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=245698&r1=245697&r2=245698&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 21 07:29:47 
2015
@@ -7477,8 +7477,6 @@ def err_omp_expected_var_name_or_array_i
   "expected variable name, array element or array section">;
 def note_omp_task_predetermined_firstprivate_here : Note<
   "predetermined as a firstprivate in a task construct here">;
-def err_omp_task_predetermined_firstprivate_ref_type_arg : Error<
-  "predetermined as a firstprivate in a task construct variable cannot be of 
reference type %0">;
 def err_omp_threadprivate_incomplete_type : Error<
   "threadprivate variable with incomplete type %0">;
 def err_omp_no_dsa_for_variable : Error<


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


Re: [PATCH] D12234: [mips][p5600] Add -mcpu=p5600 option.

2015-08-21 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D12234



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


[clang-tools-extra] r245701 - Test commit!

2015-08-21 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Aug 21 08:55:16 2015
New Revision: 245701

URL: http://llvm.org/viewvc/llvm-project?rev=245701&view=rev
Log:
Test commit!

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=245701&r1=245700&r2=245701&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Aug 21 
08:55:16 2015
@@ -439,6 +439,7 @@ private:
   Expr *FirstSubExpr;
   bool PruneSubtree;
 };
+
 } // namespace
 
 UseNullptrCheck::UseNullptrCheck(StringRef Name, ClangTidyContext *Context)


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


Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


http://reviews.llvm.org/D12231



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


[clang-tools-extra] r245703 - [clang-tidy] Migrate UseAuto from clang-modernize to clang-tidy.

2015-08-21 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Aug 21 10:08:51 2015
New Revision: 245703

URL: http://llvm.org/viewvc/llvm-project?rev=245703&view=rev
Log:
[clang-tidy] Migrate UseAuto from clang-modernize to clang-tidy.

http://reviews.llvm.org/D12231

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-use-auto/

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-use-auto/containers.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=245703&r1=245702&r2=245703&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Fri Aug 21 
10:08:51 2015
@@ -5,6 +5,7 @@ add_clang_library(clangTidyModernizeModu
   LoopConvertUtils.cpp
   ModernizeTidyModule.cpp
   PassByValueCheck.cpp
+  UseAutoCheck.cpp
   UseNullptrCheck.cpp
 
   LINK_LIBS

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=245703&r1=245702&r2=245703&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Fri 
Aug 21 10:08:51 2015
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "LoopConvertCheck.h"
 #include "PassByValueCheck.h"
+#include "UseAutoCheck.h"
 #include "UseNullptrCheck.h"
 
 using namespace clang::ast_matchers;
@@ -25,6 +26,7 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck("modernize-loop-convert");
 CheckFactories.registerCheck("modernize-pass-by-value");
+CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck("modernize-use-nullptr");
   }
 

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=245703&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Fri Aug 21 
10:08:51 2015
@@ -0,0 +1,368 @@
+//===--- UseAutoCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseAutoCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+namespace {
+
+const char IteratorDeclStmtId[] = "iterator_decl";
+const char DeclWithNewId[] = "decl_new";
+
+/// \brief Matches variable declarations that have explicit initializers that
+/// are not initializer lists.
+///
+/// Given
+/// \code
+///   iterator I = Container.begin();
+///   MyType A(42);
+///   MyType B{2};
+///   MyType C;
+/// \endcode
+///
+/// varDecl(hasWrittenNonListInitializer()) maches \c I and \c A but not \c B
+/// or \c C.
+AST_MATCHER(VarDecl, hasWrittenNonListInitializer) {
+  const Expr *Init = Node.getAnyInitializer();
+  if (!Init)
+return false;
+
+  // The following test is based on DeclPrinter::VisitVarDecl() to find if an
+  // initializer is implicit or not.
+  if (const auto *Construct = dyn_cast(Init)) {
+return !Construct->isListInitialization() && Construct->getNumArgs() > 0 &&
+   !Construct->getArg(0)->isDefaultArgument();
+  }
+  return Node.getInitStyle() != VarDecl::ListInit;
+}
+
+/// \brief Matches QualTypes that are type sugar for QualTypes that match \c
+/// SugarMatcher.
+///
+/// Given
+/// \code
+///   class C {};
+///   typedef C my_type;
+///   typedef my_type my_other_type;
+/// \endcode
+///
+/// qualType(isSugarFor(recordType(hasDeclaration(namedDecl(hasName("C"))
+/// matches \c my_type and \c my_other_type.
+AST_MATCHER_P(Q

Re: [PATCH] D12231: Add use-auto check to modernize module.

2015-08-21 Thread Angel Garcia via cfe-commits
angelgarcia closed this revision.
angelgarcia added a comment.

Committed revision 245703.


http://reviews.llvm.org/D12231



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


Re: [PATCH] D12109: [WinEH] Update to new EH pad/ret signatures (with tokens required)

2015-08-21 Thread Joseph Tremoulet via cfe-commits
JosephTremoulet updated this revision to Diff 32831.
JosephTremoulet added a comment.

rebase


http://reviews.llvm.org/D12109

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp

Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -859,7 +859,7 @@
   void Emit(CodeGenFunction &CGF, Flags flags) override {
 if (CGF.CGM.getCodeGenOpts().NewMSEH) {
   llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
-  CGF.Builder.CreateCatchRet(BB, CPI);
+  CGF.Builder.CreateCatchRet(CPI, BB);
   CGF.EmitBlock(BB);
 } else {
   CGF.EmitNounwindRuntimeCall(
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -887,11 +887,10 @@
 
 if (EHPersonality::get(CGF).isMSVCXXPersonality()) {
   CGF.Builder.CreateCatchPad(
-  llvm::Type::getTokenTy(CGF.getLLVMContext()), Handler.Block,
-  NextBlock, {TypeValue, llvm::Constant::getNullValue(CGF.VoidPtrTy)});
+  Handler.Block, NextBlock,
+  {TypeValue, llvm::Constant::getNullValue(CGF.VoidPtrTy)});
 } else {
-  CGF.Builder.CreateCatchPad(llvm::Type::getTokenTy(CGF.getLLVMContext()),
- Handler.Block, NextBlock, {TypeValue});
+  CGF.Builder.CreateCatchPad(Handler.Block, NextBlock, {TypeValue});
 }
 
 // Otherwise we need to emit and continue at that block.
Index: lib/CodeGen/CGCleanup.cpp
===
--- lib/CodeGen/CGCleanup.cpp
+++ lib/CodeGen/CGCleanup.cpp
@@ -904,8 +904,7 @@
 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
 if (CGM.getCodeGenOpts().NewMSEH &&
 EHPersonality::get(*this).isMSVCPersonality())
-  CPI = Builder.CreateCleanupPad(llvm::Type::getTokenTy(getLLVMContext()),
- {});
+  CPI = Builder.CreateCleanupPad({});
 
 // We only actually emit the cleanup code if the cleanup is either
 // active or was used before it was deactivated.
@@ -916,7 +915,7 @@
 }
 
 if (CPI)
-  Builder.CreateCleanupRet(NextAction, CPI);
+  Builder.CreateCleanupRet(CPI, NextAction);
 else
   Builder.CreateBr(NextAction);
 


Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -859,7 +859,7 @@
   void Emit(CodeGenFunction &CGF, Flags flags) override {
 if (CGF.CGM.getCodeGenOpts().NewMSEH) {
   llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
-  CGF.Builder.CreateCatchRet(BB, CPI);
+  CGF.Builder.CreateCatchRet(CPI, BB);
   CGF.EmitBlock(BB);
 } else {
   CGF.EmitNounwindRuntimeCall(
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -887,11 +887,10 @@
 
 if (EHPersonality::get(CGF).isMSVCXXPersonality()) {
   CGF.Builder.CreateCatchPad(
-  llvm::Type::getTokenTy(CGF.getLLVMContext()), Handler.Block,
-  NextBlock, {TypeValue, llvm::Constant::getNullValue(CGF.VoidPtrTy)});
+  Handler.Block, NextBlock,
+  {TypeValue, llvm::Constant::getNullValue(CGF.VoidPtrTy)});
 } else {
-  CGF.Builder.CreateCatchPad(llvm::Type::getTokenTy(CGF.getLLVMContext()),
- Handler.Block, NextBlock, {TypeValue});
+  CGF.Builder.CreateCatchPad(Handler.Block, NextBlock, {TypeValue});
 }
 
 // Otherwise we need to emit and continue at that block.
Index: lib/CodeGen/CGCleanup.cpp
===
--- lib/CodeGen/CGCleanup.cpp
+++ lib/CodeGen/CGCleanup.cpp
@@ -904,8 +904,7 @@
 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
 if (CGM.getCodeGenOpts().NewMSEH &&
 EHPersonality::get(*this).isMSVCPersonality())
-  CPI = Builder.CreateCleanupPad(llvm::Type::getTokenTy(getLLVMContext()),
- {});
+  CPI = Builder.CreateCleanupPad({});
 
 // We only actually emit the cleanup code if the cleanup is either
 // active or was used before it was deactivated.
@@ -916,7 +915,7 @@
 }
 
 if (CPI)
-  Builder.CreateCleanupRet(NextAction, CPI);
+  Builder.CreateCleanupRet(CPI, NextAction);
 else
   Builder.CreateBr(NextAction);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12240: [AArch64] Define the macro __ARM_FP16_ARGS

2015-08-21 Thread Keith Walker via cfe-commits
keith.walker.arm created this revision.
keith.walker.arm added reviewers: olista01, rengolin, cfe-commits.
Herald added subscribers: rengolin, aemerson.

The ACLE (ARM C Language Extensions) 2.0 defines that the predefined macro
__ARM_FP16_ARGS should be defined if __fp16 can be used as an argument and
result.

The support for __fp16 to be used as an argument and result is already
implemented for AArch64 so this change is just adding the missing macro.

http://reviews.llvm.org/D12240

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/aarch64-target-features.c

Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -19,6 +19,7 @@
 // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK: __ARM_FEATURE_UNALIGNED 1
 // CHECK: __ARM_FP 0xe
+// CHECK: __ARM_FP16_ARGS 1
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
 // CHECK-NOT: __ARM_FP_FAST 1
 // CHECK: __ARM_FP_FENV_ROUNDING 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5264,6 +5264,7 @@
 // PCS specifies this for SysV variants, which is all we support. Other 
ABIs
 // may choose __ARM_FP16_FORMAT_ALTERNATIVE.
 Builder.defineMacro("__ARM_FP16_FORMAT_IEEE");
+Builder.defineMacro("__ARM_FP16_ARGS");
 
 if (Opts.FastMath || Opts.FiniteMathOnly)
   Builder.defineMacro("__ARM_FP_FAST");


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -19,6 +19,7 @@
 // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK: __ARM_FEATURE_UNALIGNED 1
 // CHECK: __ARM_FP 0xe
+// CHECK: __ARM_FP16_ARGS 1
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
 // CHECK-NOT: __ARM_FP_FAST 1
 // CHECK: __ARM_FP_FENV_ROUNDING 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5264,6 +5264,7 @@
 // PCS specifies this for SysV variants, which is all we support. Other ABIs
 // may choose __ARM_FP16_FORMAT_ALTERNATIVE.
 Builder.defineMacro("__ARM_FP16_FORMAT_IEEE");
+Builder.defineMacro("__ARM_FP16_ARGS");
 
 if (Opts.FastMath || Opts.FiniteMathOnly)
   Builder.defineMacro("__ARM_FP_FAST");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-08-21 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:20
@@ +19,3 @@
+  const auto* CallMove = result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1) return;
+  const Expr* Arg = CallMove->getArg(0);

You can move both checks to the matcher.
Something like:

callExpr(callee(functionDecl(hasName("::std::move"))),
 argumentCountIs(1),
 hasArgument(0, expr(hasType(isConstQualified()


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:32
@@ +31,3 @@
+diag(CallMove->getLocStart(), "move of const variable")
+<< FixItHint::CreateReplacement(MoveRange, ArgString);
+  }

It is better to remove/insert than to replace.
Replacement could strip comments inadvertently.
In this case it also removes the need to find the text for the replacement.
You could do:

Remove(CallMove->Start(), Arg->Start())
Remove(CallMove->End(), CallMove->End())


http://reviews.llvm.org/D12031



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


Re: [PATCH] D11976: [libclang] Return deduced type for auto type, not the one written in the source.

2015-08-21 Thread Oleksandr Senkovych via cfe-commits
blackjack added a subscriber: blackjack.
blackjack added a comment.

With this patch applied, class variables type is printed as :  
http://i.imgur.com/CXHnjwJ.png


http://reviews.llvm.org/D11976



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


r245706 - Fix typo - symetric -> symmetric.

2015-08-21 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Aug 21 11:24:01 2015
New Revision: 245706

URL: http://llvm.org/viewvc/llvm-project?rev=245706&view=rev
Log:
Fix typo - symetric -> symmetric.

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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=245706&r1=245705&r2=245706&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Aug 21 11:24:01 2015
@@ -7527,7 +7527,7 @@ public:
 llvm::SmallPtrSet AddedTypes;
 
 for (int Arg = 0; Arg < 2; ++Arg) {
-  QualType AsymetricParamTypes[2] = {
+  QualType AsymmetricParamTypes[2] = {
 S.Context.getPointerDiffType(),
 S.Context.getPointerDiffType(),
   };
@@ -7539,11 +7539,11 @@ public:
 if (!PointeeTy->isObjectType())
   continue;
 
-AsymetricParamTypes[Arg] = *Ptr;
+AsymmetricParamTypes[Arg] = *Ptr;
 if (Arg == 0 || Op == OO_Plus) {
   // operator+(T*, ptrdiff_t) or operator-(T*, ptrdiff_t)
   // T* operator+(ptrdiff_t, T*);
-  S.AddBuiltinCandidate(*Ptr, AsymetricParamTypes, Args, CandidateSet);
+  S.AddBuiltinCandidate(*Ptr, AsymmetricParamTypes, Args, 
CandidateSet);
 }
 if (Op == OO_Minus) {
   // ptrdiff_t operator-(T, T);


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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

This doesn't seem like a fundamental property of a type, to me. If I understand 
properly, this has more to do with specific instances of memory access. By 
making it part of the type, you run into sticky situations that become hard to 
resolve, such as with templates in C++.

~Aaron


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-21 Thread Josh Gao via cfe-commits
jmgao updated this revision to Diff 32833.
jmgao added a comment.

Remove more `\brief`s


http://reviews.llvm.org/D12181

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/sanitize-trap-function.c

Index: test/CodeGen/sanitize-trap-function.c
===
--- /dev/null
+++ test/CodeGen/sanitize-trap-function.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=integer-divide-by-zero -fsanitize-trap=integer-divide-by-zero | FileCheck %s -check-prefix=NONE -check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=integer-divide-by-zero -fsanitize-trap=integer-divide-by-zero -ftrap-function=foo | FileCheck %s -check-prefix=TRAP -check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=integer-divide-by-zero -fsanitize-trap=integer-divide-by-zero -fsanitize-trap-function=bar | FileCheck %s -check-prefix=SANITIZE -check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=integer-divide-by-zero -fsanitize-trap=integer-divide-by-zero -ftrap-function=foo -fsanitize-trap-function=bar | FileCheck %s -check-prefix=SANITIZE -check-prefix=CHECK
+
+int f(int x, int y) {
+  // CHECK: call void @llvm.trap() #[[N:[0-9]+]],
+  // CHECK-NEXT: unreachable
+
+  // NONE-NOT: trap-func-name
+  // TRAP: attributes #[[N]] {{.+}} "trap-func-name"="foo"
+  // SANITIZE: attributes #[[N]] {{.+}} "trap-func-name"="bar"
+  return x / y;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -681,6 +681,8 @@
   parseSanitizerKinds("-fsanitize-trap=",
   Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
   Opts.SanitizeTrap);
+  Opts.SanitizeTrapFuncName =
+  Args.getLastArgValue(OPT_fsanitize_trap_function_EQ);
 
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2884,14 +2884,29 @@
  StringRef CheckName, ArrayRef StaticArgs,
  ArrayRef DynamicArgs);
 
+  /// Create a basic block that will call the trap intrinsic and emit a
+  /// conditional branch to it, for the -fsanitize checks.
+  void EmitSanitizeTrapCheck(llvm::Value *Checked);
+
   /// \brief Create a basic block that will call the trap intrinsic, and emit a
   /// conditional branch to it, for the -ftrapv checks.
   void EmitTrapCheck(llvm::Value *Checked);
 
-  /// \brief Emit a call to trap or debugtrap and attach function attribute
-  /// "trap-func-name" if specified.
+  /// Emit a call to trap or debugtrap and attach function attribute
+  /// "trap-func-name" if -ftrap-function is specified.
   llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID);
 
+ private:
+  /// Create a basic block that will call the specified trap function, and emit
+  /// a conditional branch to it.
+  void EmitTrapCheck(llvm::Value *Checked, const std::string &TrapFuncName);
+
+  /// Emit a call to trap or debugtrap and attach function attribute
+  /// "trap-func-name" if nonempty.
+  llvm::CallInst *EmitTrapCall(llvm::Intrinsic::ID IntrID,
+   const std::string &TrapFuncName);
+
+ public:
   /// \brief Create a check for a function parameter that may potentially be
   /// declared as non-null.
   void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2300,8 +2300,7 @@
 Cond = Cond ? Builder.CreateAnd(Cond, Check) : Check;
   }
 
-  if (TrapCond)
-EmitTrapCheck(TrapCond);
+  if (TrapCond) EmitSanitizeTrapCheck(TrapCond);
   if (!FatalCond && !RecoverableCond)
 return;
 
@@ -2381,16 +2380,33 @@
   EmitBlock(Cont);
 }
 
+void CodeGenFunction::EmitSanitizeTrapCheck(llvm::Value *Checked) {
+  if (!CGM.getCodeGenOpts().SanitizeTrapFuncName.empty()) {
+return EmitTrapCheck(Checked, CGM.getCodeGenOpts().SanitizeTrapFuncName);
+  }
+  return EmitTrapCheck(Checked);
+}
+
 void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) {
+  return EmitTrapCheck(Checked, CGM.getCodeGenOpts().TrapFuncName);
+}
+
+llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
+  return EmitTrapCall(IntrID, CGM.getCodeGenOpts().TrapFuncName);
+}
+
+void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
+const std::string &TrapFuncName) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
   // If we're optimizing, collapse all calls to trap dow

Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-21 Thread Josh Gao via cfe-commits
jmgao marked an inline comment as done.


Comment at: lib/CodeGen/CGExpr.cpp:2303
@@ -2302,4 +2302,3 @@
 
-  if (TrapCond)
-EmitTrapCheck(TrapCond);
+  if (TrapCond) EmitSanitizeTrapCheck(TrapCond);
   if (!FatalCond && !RecoverableCond)

Yes


http://reviews.llvm.org/D12181



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


Re: [PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

2015-08-21 Thread Josh Gao via cfe-commits
jmgao marked 4 inline comments as done.
jmgao added a comment.

http://reviews.llvm.org/D12181



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


Re: [PATCH] D12109: [WinEH] Update to new EH pad/ret signatures (with tokens required)

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

lgtm


http://reviews.llvm.org/D12109



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


[PATCH] D12243: Properly provide alignment of 'byval' arguments down to llvm.

2015-08-21 Thread James Y Knight via cfe-commits
jyknight created this revision.
jyknight added a reviewer: majnemer.
jyknight added a subscriber: cfe-commits.

This is important in the case that the LLVM-inferred llvm-struct
alignment is not the same as the clang-known C-struct alignment.

http://reviews.llvm.org/D12243

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/le32-arguments.c
  test/CodeGen/nvptx-abi.c
  test/CodeGen/sparc-arguments.c

Index: test/CodeGen/sparc-arguments.c
===
--- /dev/null
+++ test/CodeGen/sparc-arguments.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// Ensure that we pass proper alignment to llvm in the call
+// instruction. The proper alignment for the type is sometimes known
+// only by clang, and is not manifest in the LLVM-type. So, it must be
+// explicitly passed through.  (Besides the case of the user specifying
+// alignment, as here, this situation also occurrs for non-POD C++
+// structs with tail-padding: clang emits those as packed llvm-structs
+// for some reason.)
+struct s1 {
+  long x;
+  char y;
+  int z;
+} __attribute__((packed, aligned(8)));
+
+struct s1 x1;
+
+void f1_helper(struct s1);
+// CHECK-LABEL: define void @f1()
+// CHECK: call void @f1_helper(%struct.s1* byval align 8 @x1)
+void f1() {
+  f1_helper(x1);
+}
Index: test/CodeGen/nvptx-abi.c
===
--- test/CodeGen/nvptx-abi.c
+++ test/CodeGen/nvptx-abi.c
@@ -21,14 +21,14 @@
 
 void foo(float4_t x) {
 // CHECK-LABEL: @foo
-// CHECK: %struct.float4_s* byval %x
+// CHECK: %struct.float4_s* byval align 4 %x
 }
 
 void fooN(float4_t x, float4_t y, float4_t z) {
 // CHECK-LABEL: @fooN
-// CHECK: %struct.float4_s* byval %x
-// CHECK: %struct.float4_s* byval %y
-// CHECK: %struct.float4_s* byval %z
+// CHECK: %struct.float4_s* byval align 4 %x
+// CHECK: %struct.float4_s* byval align 4 %y
+// CHECK: %struct.float4_s* byval align 4 %z
 }
 
 typedef struct nested_s {
@@ -39,5 +39,5 @@
 
 void baz(nested_t x) {
 // CHECK-LABEL: @baz
-// CHECK: %struct.nested_s* byval %x)
+// CHECK: %struct.nested_s* byval align 8 %x)
 }
Index: test/CodeGen/le32-arguments.c
===
--- test/CodeGen/le32-arguments.c
+++ test/CodeGen/le32-arguments.c
@@ -10,7 +10,7 @@
   int bb;
 } s1;
 // Structs should be passed byval and not split up
-// CHECK-LABEL: define void @f1(%struct.s1* byval %i)
+// CHECK-LABEL: define void @f1(%struct.s1* byval align 4 %i)
 void f1(s1 i) {}
 
 typedef struct {
@@ -48,14 +48,14 @@
   char b;
 };
 // Unions should be passed as byval structs
-// CHECK-LABEL: define void @f7(%union.simple_union* byval %s)
+// CHECK-LABEL: define void @f7(%union.simple_union* byval align 4 %s)
 void f7(union simple_union s) {}
 
 typedef struct {
   int b4 : 4;
   int b3 : 3;
   int b8 : 8;
 } bitfield1;
 // Bitfields should be passed as byval structs
-// CHECK-LABEL: define void @f8(%struct.bitfield1* byval %bf1)
+// CHECK-LABEL: define void @f8(%struct.bitfield1* byval align 4 %bf1)
 void f8(bitfield1 bf1) {}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1663,20 +1663,35 @@
 Attrs.addAttribute(llvm::Attribute::InReg);
   break;
 
-case ABIArgInfo::Indirect:
+case ABIArgInfo::Indirect: {
   if (AI.getInReg())
 Attrs.addAttribute(llvm::Attribute::InReg);
 
   if (AI.getIndirectByVal())
 Attrs.addAttribute(llvm::Attribute::ByVal);
 
-  Attrs.addAlignmentAttr(AI.getIndirectAlign());
+  unsigned Align = AI.getIndirectAlign();
+
+  // In a byval argument, it is important that the required
+  // alignment of the type is honored, as LLVM might be creating a
+  // *new* stack object, and needs to know what alignment to give
+  // it. (Sometimes it can deduce a sensible alignment on its own,
+  // but not if clang decides it must emit a packed struct, or the
+  // user specifies increased alignment requirements.)
+  //
+  // This is different from indirect *not* byval, where the object
+  // exists already, and the align attribute is purely
+  // informative.
+  if (Align == 0 && AI.getIndirectByVal())
+Align = getContext().getTypeAlignInChars(ParamType).getQuantity();
+
+  Attrs.addAlignmentAttr(Align);
 
   // byval disables readnone and readonly.
   FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
 .removeAttribute(llvm::Attribute::ReadNone);
   break;
-
+}
 case ABIArgInfo::Ignore:
 case ABIArgInfo::Expand:
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12244: Implement ACLE 2.0 macros of chapters 6.4 and 6.5 for [ARM] and [Aarch64] targets

2015-08-21 Thread Alexandros Lamprineas via cfe-commits
labrinea created this revision.
labrinea added subscribers: cfe-commits, llvm-commits.
Herald added subscribers: rengolin, aemerson.

Implementation and testing of ACLE 2.0 macros, for details see the above 
document:
[[ 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf 
| ACLE 2.0 ]]

http://reviews.llvm.org/D12244

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/aarch64-target-features.c
  test/Preprocessor/arm-acle-6.4.c
  test/Preprocessor/arm-acle-6.5.c

Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -1,22 +1,96 @@
-// RUN: %clang -target arm-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-eabi -mfpu=none -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv4-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv5-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv6m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
+// RUN: %clang -target armv7m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FP
 
-// CHECK-DEFAULT-NOT: __ARM_FP
+// CHECK-NO-FP-NOT: __ARM_FP 0x{{.*}}
+// CHECK-NO-FP-NOT: __ARM_FP16_FORMAT_IEEE
+
+// RUN: %clang -target arm-eabi -mfpu=vfpv3xd -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3xd-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=fpv4-sp-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+// RUN: %clang -target arm-eabi -mfpu=fpv5-sp-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP
+
+// CHECK-SP: __ARM_FP 0x4
+// CHECK-SP-NOT: __ARM_FP16_FORMAT_IEEE
 
 // RUN: %clang -target arm-eabi -mfpu=vfp -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfpv2 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 // RUN: %clang -target arm-eabi -mfpu=vfp3-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 // RUN: %clang -target arm-eabi -mfpu=neon -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
-// RUN: %clang -target armv7-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv6-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
 
-// CHECK-SP-DP: __ARM_FP 0xC
+// CHECK-SP-DP: __ARM_FP 0xC
+// CHECK-SP-DP-NOT: __ARM_FP16_FORMAT_IEEE
 
+// RUN: %clang -target arm-eabi -mfpu=vfpv3-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=vfpv3-d16-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=vfpv4-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=fpv5-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-fp16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target arm-eabi -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 // RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
 
 // CHECK-SP-DP-HP: __ARM_FP 0xE
+// CHECK-SP-DP-HP: __ARM_FP16_FORMAT_IEEE 1
+
+// RUN: %clang -target armv4-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv5-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv6-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv6m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7m-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+
+// CHECK-NO-FMA-NOT: __ARM_FEAT

Re: [PATCH] D12243: Properly provide alignment of 'byval' arguments down to llvm.

2015-08-21 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D12243



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


Re: [PATCH] D12240: [AArch64] Define the macro __ARM_FP16_ARGS

2015-08-21 Thread Ahmed Bougacha via cfe-commits
ab added a subscriber: ab.
ab accepted this revision.
ab added a reviewer: ab.
ab added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


http://reviews.llvm.org/D12240



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi all,

Thanks for the feedback, please find my answers below:

> What does it mean to have the attribute applied to non-pointer types like int 
> __attribute__((nontemporal)) i; ? The ACLE doesn't say but making it 
> erroneous might make sense. Perhaps it would be good to have a semantic test 
> which uses __attribute__((nontemporal)).


**David**,
That's a good idea. Actually, I don't know how we should behave in such cases, 
but probably just giving an error should be fine. And should we handle 
references in a similar manner (`int __attribute__((nontemporal)) &i)`? I'll 
update the patch correspondingly if we decide to go with type attributes.

> This seems like a property of an operation, rather than a property of a type. 
> Have you considered adding a __builtin_nontemporal_store builtin as an 
> alternative?


**Richard**,
Yes, I've considered a builitin as an alternative. In fact, I started with it 
as it was easier to implement, but then decided to switch to type attribute due 
to the following reasons:

1. ARM ACLE 2.0 mentions attribute. Though it's not a final version of the 
document, AFAIU, I still preferred to use it as an argument for type-attribute.
2. Once we introduce a builtin, we'll have to support it forever (otherwise we 
could break someone's code). With the attribute the burden is much smaller, as 
we can just start ignoring it at any point if we need to - all the code will 
remain correct and compilable.
3. We'll need to have an intrinsic for every type + separate intrinsics for 
loads and stores. If we use the type attribute, one fits all.
4. While it's true, that this is more type of operation, than a type, I think 
in real use-cases a user would rarely need to use it on a single operation. 
I.e. nontemporal operations are usually used for processing bulk volumes of 
data, and probably this data is almost always is processed as a whole. That's 
why I think it's fine to mark the entire 'data' as nontemporal. And, if a user 
then wants to work with a small subset of it, she can use a usual (not 
nontemporal) pointer to it.
5. Personally, I find the code using attributes more elegant than using 
builtins. Compare:

  void foo(float *__attribute__((nontemporal)) dst,
   float *__attribute__((nontemporal)) src1,
   float *__attribute__((nontemporal)) src2) {
*dst = *src1 + *src2;
  }

and

  void foo(float *dst, float *src1, float *src2) {
float s1 = __builtin_nontemporal_load(src1);
float s2 = __builtin_nontemporal_load(src2);
__builtin_nontemporal_store(s1 + s2, dst);
  }

But that said, in the end I'm open to other alternatives (including builtins), 
and this thread is just an attempt to find the best option.

> This doesn't seem like a fundamental property of a type, to me. If I 
> understand properly, this has more to do with specific instances of memory 
> access. By making it part of the type, you run into sticky situations that 
> become hard to resolve, such as with templates in C++.


**Aaron**,
As far as I understand, type attributes doesn't result in such complications 
(as opposed to type qualifiers, e.g. `__restrict__`). That is, it doesn't 
change the canonical type, it only adds some 'sugar' to it. I.e. ` float 
*__attribute__((nontemporal))` and `float *` would behave as the same type in 
templates and names mangling. Please correct me if I'm wrong here.

Thanks,
Michael


http://reviews.llvm.org/D12221



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


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-21 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 32843.
sfantao added a comment.

Address reviewer concerns.


http://reviews.llvm.org/D11361

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_codegen.cpp

Index: test/OpenMP/target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen.cpp
@@ -0,0 +1,754 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+// REQUIRES: powerpc-registered-target
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
+// CHECK-DAG: [[S1:%.+]] = type { double }
+
+// We have 8 target regions, but only 7 that actually will generate offloading
+// code, only 6 will have mapped arguments, and only 4 have all-constant map
+// sizes.
+
+// CHECK-DAG: [[SIZET2:@.+]] = private unnamed_addr constant [1 x i{{32|64}}] [i[[SZ:32|64]] 2]
+// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [1 x i32] [i32 3]
+// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2]
+// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i32] [i32 3, i32 3]
+// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [9 x i32] [i32 3, i32 3, i32 1, i32 3, i32 3, i32 1, i32 1, i32 3, i32 3]
+// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i32] [i32 3, i32 3, i32 3]
+// CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i32] [i32 3, i32 3, i32 3, i32 3]
+// CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [5 x i32] [i32 3, i32 3, i32 1, i32 1, i32 3]
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 0, i8** null, i8** null, i[[SZ]]* null, i32* null)
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT0:@.+]]()
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp target
+  {
+  }
+
+  // CHECK:   call void [[HVT1:@.+]](i32* {{[^,]+}})
+  #pragma omp target if(0)
+  {
+a += 1;
+  }
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
+  // CHECK-DAG:   [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
+  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
+  // CHECK-DAG:   store i8* [[BP0:%[^,]+]], i8** [[BPADDR0]]
+  // CHECK-DAG:   store i8* [[P0:%[^,]+]], i8** [[PADDR0]]
+  // CHECK-DAG:   [[BP0]] = bitcast i16* %{{.+}} to i8*
+  // CHECK-DAG:   [[P0]] = bitcast i16* %{{.+}} to i8*
+
+  // CHECK:   [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT2:@.+]](i16* {{[^,]+}})
+  // CHECK-NEXT:  br label %[[END]]
+  // CHEC

Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-21 Thread Samuel Antao via cfe-commits
sfantao added a comment.

In http://reviews.llvm.org/D11361#229744, @ABataev wrote:

> Another one thing I forget to mention. Current implementation of 
> CGOpenMPRuntime is libomp-specific. You're trying to add functionality that 
> is libtarget-specific. Maybe it is a good idea to separate support for libomp 
> and libtarget runtime libraries?


Not sure what do you mean by separation. Different files? Different codegen 
class? My perspective is that the two things should be together given that they 
both address the same specification, and I see that interaction is required 
between the two components. E.g. teams codegen will have to interact with the 
target codegen (communicate number of teams/threads ) and the teams codegen 
will require the libomp interface in its implementation. We could always 
separate the two things in the future if we see that is a better way to 
organize the code.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2887
@@ +2886,3 @@
+llvm::Value *
+CGOpenMPRuntime::emitTargetOutlinedFunction(CodeGenFunction &CGF,
+const OMPExecutableDirective &D,

ABataev wrote:
> I don't think you need this argument. You're emitting a new outlined function 
> here and don't need info about your current function.
Done!


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2906-2911
@@ +2905,8 @@
+
+  CodeGenFunction TargetAuxCGF(CGM, true);
+  CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen);
+  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(TargetAuxCGF, &CGInfo);
+  auto *TargetAuxFn = TargetAuxCGF.GenerateCapturedStmtFunction(CS);
+  TargetAuxFn->addFnAttr(llvm::Attribute::AlwaysInline);
+
+  // Collect the arguments of the main function.

ABataev wrote:
> You'd better to emit internal function separately in a new static function. 
> Then you don't need to create TargetAuxCGF and TargetMainCGF. You should use 
> just CGF everywhere. One CodeGenFunction instance per function.
Done!


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2970-2972
@@ +2969,5 @@
+
+  auto ai = Args.begin();
+  for (RecordDecl::field_iterator ri = RD->field_begin(), re = RD->field_end();
+   ri != re; ++ri, ++ai) {
+

ABataev wrote:
> Variable names should start with an upper case letter (e.g. Leader or Boats).
Ok, thought iterators were an exception to that rule. Fixed now!


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3070-3107
@@ +3069,40 @@
+} else {
+  // We expect all the sizes to be constant, so we collect them to create
+  // a constant array.
+  SmallVector ConstSizes;
+  for (auto *V : Sizes)
+ConstSizes.push_back(cast(V)->getZExtValue());
+
+  auto SizeTypeBytes =
+  CGF.getContext()
+  .getTypeSizeInChars(CGF.getContext().getSizeType())
+  .getQuantity();
+
+  llvm::Constant *SizesArrayInit;
+  switch (SizeTypeBytes) {
+  default:
+llvm_unreachable("Unexpected size-type type!");
+  case 1: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+ ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 2: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+  ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 4: {
+SmallVector ConstSizesL(ConstSizes.begin(),
+  ConstSizes.end());
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizesL);
+  } break;
+  case 8: {
+SizesArrayInit =
+llvm::ConstantDataArray::get(CGM.getLLVMContext(), ConstSizes);
+  } break;
+  }
+  auto *SizesArrayGbl = new llvm::GlobalVariable(

ABataev wrote:
> Try instead:
>   SizesArrayInit = 
> llvm::ConstantArray::get(llvm::ArrayType::get(CGM.SizeTy, Sizes.size()), 
> Sizes);
> 
Done!


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3161-3164
@@ +3160,6 @@
+  } else {
+BasePointersArray = llvm::Constant::getNullValue(CGM.VoidPtrPtrTy);
+PointersArray = llvm::Constant::getNullValue(CGM.VoidPtrPtrTy);
+SizesArray = llvm::Constant::getNullValue(CGM.SizeTy->getPointerTo());
+MapTypesArray = llvm::Constant::getNullValue(CGM.Int32Ty->getPointerTo());
+  }

ABataev wrote:
> llvm::ConstantPointerNull::get();
Done!


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2139-2203
@@ +2138,67 @@
+
+  bool hasVLACaptures = false;
+  const CapturedStmt &CS = *cast(S.getAssociatedStmt());
+  auto ri = CS.getCapturedRecordDecl()->field_begin();
+  auto ii = CS.capture_init_begin();
+  for (CapturedStmt::const_capture_iterator ci = CS.capture_be

Re: [PATCH] Fix out-of-bounds array access when setting arm float registers

2015-08-21 Thread Hans Wennborg via cfe-commits
On Thu, Aug 20, 2015 at 8:28 PM, Saleem Abdulrasool
 wrote:
> On Thu, Aug 20, 2015 at 2:13 PM, Hans Wennborg  wrote:
>>
>> +Saleem and Renato; maybe you can take a look?
>
>
> Thanks for pointing this out!
>
> The patch is correct and pretty safe to apply for 3.7 I think since its a
> simple bug fix, and can result in VFP state corruption (the invalid memory
> access in this case shouldn't access to arbitrary memory fortunately).  I've
> applied to trunk as SVN r245665.  Should I send a request on the thread for
> the actual commit?

It's too late to get this into 3.7.0, but it seems like a good
candidate for 3.7.1. I'll put it on my list and we can merge it when
Tom starts preparing the dot-release.

Thanks,
Hans


>> On Tue, Aug 18, 2015 at 11:24 AM, Leandro Graciá Gil
>>  wrote:
>> > Hi,
>> >
>> > Please find attached a patch fixing an out-of-bounds array access
>> > present in
>> > the current libunwind top of tree code.
>> >
>> > The problem is caused by subtracting the wrong base register in
>> > Registers_arm::SetFloatRegister and should become obvious after taking a
>> > quick look to the code.
>> >
>> > Could someone please commit this to trunk and merge it to the release 37
>> > branch?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D12221#230187, @mzolotukhin wrote:

> **Aaron**,
>  As far as I understand, type attributes doesn't result in such complications 
> (as opposed to type qualifiers, e.g. `__restrict__`). That is, it doesn't 
> change the canonical type, it only adds some 'sugar' to it. I.e. ` float 
> *__attribute__((nontemporal))` and `float *` would behave as the same type in 
> templates and names mangling. Please correct me if I'm wrong here.


You are correct in that type attributes do not change the canonical type, but I 
perhaps didn't explain the complications properly. For instance, if I wanted to 
store a std::vector of these nontemporal type objects, I could not do so 
because the type attribute information would be lost. By using a builtin, I 
could instead push the temporality decision to the operation on the vector 
objects.

~Aaron


http://reviews.llvm.org/D12221



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


[PATCH] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-08-21 Thread Yiran Wang via cfe-commits
yiranwang created this revision.
yiranwang added a subscriber: cfe-commits.

In libc++, there are some usage of aligned_storage which uses "sizeof" bytes of 
raw data. This is problematic a bit, as the trailing padding area will be 
counted by "sizeof", and it leads to out of bound access. For example, the 
member __buf_ of std::function can be used to store pointers to parameters, and 
the compiler could fail to figure out there is a pointer in the padding area 
points to some local variable.
The fix enlarges the buffer so that the size is exact multiple of "_Align". It 
is of no run time overhead.


http://reviews.llvm.org/D12247

Files:
  include/type_traits

Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -1143,7 +1143,7 @@
 union type
 {
 _Aligner __align;
-unsigned char __data[_Len];
+unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
 };
 };
 
@@ -1158,7 +1158,7 @@
 {\
 struct _ALIGNAS(n) type\
 {\
-unsigned char __lx[_Len];\
+unsigned char __lx[(_Len + n - 1)/n * n];\
 };\
 }
 


Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -1143,7 +1143,7 @@
 union type
 {
 _Aligner __align;
-unsigned char __data[_Len];
+unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
 };
 };
 
@@ -1158,7 +1158,7 @@
 {\
 struct _ALIGNAS(n) type\
 {\
-unsigned char __lx[_Len];\
+unsigned char __lx[(_Len + n - 1)/n * n];\
 };\
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245719 - Properly provide alignment of 'byval' arguments down to llvm.

2015-08-21 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Fri Aug 21 13:19:06 2015
New Revision: 245719

URL: http://llvm.org/viewvc/llvm-project?rev=245719&view=rev
Log:
Properly provide alignment of 'byval' arguments down to llvm.

This is important in the case that the LLVM-inferred llvm-struct
alignment is not the same as the clang-known C-struct alignment.

Differential Revision: http://reviews.llvm.org/D12243

Added:
cfe/trunk/test/CodeGen/sparc-arguments.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/le32-arguments.c
cfe/trunk/test/CodeGen/nvptx-abi.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245719&r1=245718&r2=245719&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Aug 21 13:19:06 2015
@@ -1663,20 +1663,35 @@ void CodeGenModule::ConstructAttributeLi
 Attrs.addAttribute(llvm::Attribute::InReg);
   break;
 
-case ABIArgInfo::Indirect:
+case ABIArgInfo::Indirect: {
   if (AI.getInReg())
 Attrs.addAttribute(llvm::Attribute::InReg);
 
   if (AI.getIndirectByVal())
 Attrs.addAttribute(llvm::Attribute::ByVal);
 
-  Attrs.addAlignmentAttr(AI.getIndirectAlign());
+  unsigned Align = AI.getIndirectAlign();
+
+  // In a byval argument, it is important that the required
+  // alignment of the type is honored, as LLVM might be creating a
+  // *new* stack object, and needs to know what alignment to give
+  // it. (Sometimes it can deduce a sensible alignment on its own,
+  // but not if clang decides it must emit a packed struct, or the
+  // user specifies increased alignment requirements.)
+  //
+  // This is different from indirect *not* byval, where the object
+  // exists already, and the align attribute is purely
+  // informative.
+  if (Align == 0 && AI.getIndirectByVal())
+Align = getContext().getTypeAlignInChars(ParamType).getQuantity();
+
+  Attrs.addAlignmentAttr(Align);
 
   // byval disables readnone and readonly.
   FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
 .removeAttribute(llvm::Attribute::ReadNone);
   break;
-
+}
 case ABIArgInfo::Ignore:
 case ABIArgInfo::Expand:
   continue;

Modified: cfe/trunk/test/CodeGen/le32-arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/le32-arguments.c?rev=245719&r1=245718&r2=245719&view=diff
==
--- cfe/trunk/test/CodeGen/le32-arguments.c (original)
+++ cfe/trunk/test/CodeGen/le32-arguments.c Fri Aug 21 13:19:06 2015
@@ -10,7 +10,7 @@ typedef struct {
   int bb;
 } s1;
 // Structs should be passed byval and not split up
-// CHECK-LABEL: define void @f1(%struct.s1* byval %i)
+// CHECK-LABEL: define void @f1(%struct.s1* byval align 4 %i)
 void f1(s1 i) {}
 
 typedef struct {
@@ -48,7 +48,7 @@ union simple_union {
   char b;
 };
 // Unions should be passed as byval structs
-// CHECK-LABEL: define void @f7(%union.simple_union* byval %s)
+// CHECK-LABEL: define void @f7(%union.simple_union* byval align 4 %s)
 void f7(union simple_union s) {}
 
 typedef struct {
@@ -57,5 +57,5 @@ typedef struct {
   int b8 : 8;
 } bitfield1;
 // Bitfields should be passed as byval structs
-// CHECK-LABEL: define void @f8(%struct.bitfield1* byval %bf1)
+// CHECK-LABEL: define void @f8(%struct.bitfield1* byval align 4 %bf1)
 void f8(bitfield1 bf1) {}

Modified: cfe/trunk/test/CodeGen/nvptx-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-abi.c?rev=245719&r1=245718&r2=245719&view=diff
==
--- cfe/trunk/test/CodeGen/nvptx-abi.c (original)
+++ cfe/trunk/test/CodeGen/nvptx-abi.c Fri Aug 21 13:19:06 2015
@@ -21,14 +21,14 @@ float bar(void) {
 
 void foo(float4_t x) {
 // CHECK-LABEL: @foo
-// CHECK: %struct.float4_s* byval %x
+// CHECK: %struct.float4_s* byval align 4 %x
 }
 
 void fooN(float4_t x, float4_t y, float4_t z) {
 // CHECK-LABEL: @fooN
-// CHECK: %struct.float4_s* byval %x
-// CHECK: %struct.float4_s* byval %y
-// CHECK: %struct.float4_s* byval %z
+// CHECK: %struct.float4_s* byval align 4 %x
+// CHECK: %struct.float4_s* byval align 4 %y
+// CHECK: %struct.float4_s* byval align 4 %z
 }
 
 typedef struct nested_s {
@@ -39,5 +39,5 @@ typedef struct nested_s {
 
 void baz(nested_t x) {
 // CHECK-LABEL: @baz
-// CHECK: %struct.nested_s* byval %x)
+// CHECK: %struct.nested_s* byval align 8 %x)
 }

Added: cfe/trunk/test/CodeGen/sparc-arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sparc-arguments.c?rev=245719&view=auto
==
--- cfe/trunk/test/CodeGen/sparc-arguments.c (added)
+++ cfe/trunk/test/CodeGen/sparc-arguments.c Fri 

Re: [PATCH] D12243: Properly provide alignment of 'byval' arguments down to llvm.

2015-08-21 Thread James Y Knight via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245719: Properly provide alignment of 'byval' arguments down 
to llvm. (authored by jyknight).

Changed prior to commit:
  http://reviews.llvm.org/D12243?vs=32839&id=32847#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12243

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGen/le32-arguments.c
  cfe/trunk/test/CodeGen/nvptx-abi.c
  cfe/trunk/test/CodeGen/sparc-arguments.c

Index: cfe/trunk/test/CodeGen/le32-arguments.c
===
--- cfe/trunk/test/CodeGen/le32-arguments.c
+++ cfe/trunk/test/CodeGen/le32-arguments.c
@@ -10,7 +10,7 @@
   int bb;
 } s1;
 // Structs should be passed byval and not split up
-// CHECK-LABEL: define void @f1(%struct.s1* byval %i)
+// CHECK-LABEL: define void @f1(%struct.s1* byval align 4 %i)
 void f1(s1 i) {}
 
 typedef struct {
@@ -48,14 +48,14 @@
   char b;
 };
 // Unions should be passed as byval structs
-// CHECK-LABEL: define void @f7(%union.simple_union* byval %s)
+// CHECK-LABEL: define void @f7(%union.simple_union* byval align 4 %s)
 void f7(union simple_union s) {}
 
 typedef struct {
   int b4 : 4;
   int b3 : 3;
   int b8 : 8;
 } bitfield1;
 // Bitfields should be passed as byval structs
-// CHECK-LABEL: define void @f8(%struct.bitfield1* byval %bf1)
+// CHECK-LABEL: define void @f8(%struct.bitfield1* byval align 4 %bf1)
 void f8(bitfield1 bf1) {}
Index: cfe/trunk/test/CodeGen/sparc-arguments.c
===
--- cfe/trunk/test/CodeGen/sparc-arguments.c
+++ cfe/trunk/test/CodeGen/sparc-arguments.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// Ensure that we pass proper alignment to llvm in the call
+// instruction. The proper alignment for the type is sometimes known
+// only by clang, and is not manifest in the LLVM-type. So, it must be
+// explicitly passed through. (Besides the case of the user specifying
+// alignment, as here, this situation also occurrs for non-POD C++
+// structs with tail-padding: clang emits these as packed llvm-structs
+// for ABI reasons.)
+
+struct s1 {
+  int x;
+} __attribute__((aligned(8)));
+
+struct s1 x1;
+
+
+// Ensure the align 8 is passed through:
+// CHECK-LABEL: define void @f1()
+// CHECK: call void @f1_helper(%struct.s1* byval align 8 @x1)
+// Also ensure the declaration of f1_helper includes it
+// CHECK: declare void @f1_helper(%struct.s1* byval align 8)
+
+void f1_helper(struct s1);
+void f1() {
+  f1_helper(x1);
+}
Index: cfe/trunk/test/CodeGen/nvptx-abi.c
===
--- cfe/trunk/test/CodeGen/nvptx-abi.c
+++ cfe/trunk/test/CodeGen/nvptx-abi.c
@@ -21,14 +21,14 @@
 
 void foo(float4_t x) {
 // CHECK-LABEL: @foo
-// CHECK: %struct.float4_s* byval %x
+// CHECK: %struct.float4_s* byval align 4 %x
 }
 
 void fooN(float4_t x, float4_t y, float4_t z) {
 // CHECK-LABEL: @fooN
-// CHECK: %struct.float4_s* byval %x
-// CHECK: %struct.float4_s* byval %y
-// CHECK: %struct.float4_s* byval %z
+// CHECK: %struct.float4_s* byval align 4 %x
+// CHECK: %struct.float4_s* byval align 4 %y
+// CHECK: %struct.float4_s* byval align 4 %z
 }
 
 typedef struct nested_s {
@@ -39,5 +39,5 @@
 
 void baz(nested_t x) {
 // CHECK-LABEL: @baz
-// CHECK: %struct.nested_s* byval %x)
+// CHECK: %struct.nested_s* byval align 8 %x)
 }
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1663,20 +1663,35 @@
 Attrs.addAttribute(llvm::Attribute::InReg);
   break;
 
-case ABIArgInfo::Indirect:
+case ABIArgInfo::Indirect: {
   if (AI.getInReg())
 Attrs.addAttribute(llvm::Attribute::InReg);
 
   if (AI.getIndirectByVal())
 Attrs.addAttribute(llvm::Attribute::ByVal);
 
-  Attrs.addAlignmentAttr(AI.getIndirectAlign());
+  unsigned Align = AI.getIndirectAlign();
+
+  // In a byval argument, it is important that the required
+  // alignment of the type is honored, as LLVM might be creating a
+  // *new* stack object, and needs to know what alignment to give
+  // it. (Sometimes it can deduce a sensible alignment on its own,
+  // but not if clang decides it must emit a packed struct, or the
+  // user specifies increased alignment requirements.)
+  //
+  // This is different from indirect *not* byval, where the object
+  // exists already, and the align attribute is purely
+  // informative.
+  if (Align == 0 && AI.getIndirectByVal())
+Align = getContext().getTypeAlignInChars(ParamType).getQuantity();
+
+  Attrs.addAlignmentAttr(Align);
 
   // byval disables readnone and readonly.
   FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
 .removeAttribute(llvm::Attribute::ReadNone);

Re: [PATCH] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-08-21 Thread Dan Albert via cfe-commits
danalbert added reviewers: mclow.lists, EricWF.
danalbert added a comment.

FYI this was found because it can cause issues when used with GCC.


http://reviews.llvm.org/D12247



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


r245721 - Generating assumption loads of vptr after ctor call (fixed)

2015-08-21 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Aug 21 13:28:00 2015
New Revision: 245721

URL: http://llvm.org/viewvc/llvm-project?rev=245721&view=rev
Log:
Generating assumption loads of vptr after ctor call (fixed)

Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

Added:
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGen/available-externally-hidden.cpp
cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
cfe/trunk/test/CodeGenCXX/virtual-base-ctor.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=245721&r1=245720&r2=245721&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Fri Aug 21 13:28:00 2015
@@ -346,13 +346,25 @@ public:
   virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
  const CXXRecordDecl *RD) = 0;
 
+  /// Checks if ABI requires extra virtual offset for vtable field.
+  virtual bool
+  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
+  CodeGenFunction::VPtr Vptr) = 0;
+
+  /// Checks if ABI requires to initilize vptrs for given dynamic class.
+  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 
0;
+
+  /// Get the address point of the vtable for the given base subobject.
+  virtual llvm::Constant *
+  getVTableAddressPoint(BaseSubobject Base,
+const CXXRecordDecl *VTableClass) = 0;
+
   /// Get the address point of the vtable for the given base subobject while
-  /// building a constructor or a destructor. On return, NeedsVirtualOffset
-  /// tells if a virtual base adjustment is needed in order to get the offset
-  /// of the base subobject.
-  virtual llvm::Value *getVTableAddressPointInStructor(
-  CodeGenFunction &CGF, const CXXRecordDecl *RD, BaseSubobject Base,
-  const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) = 0;
+  /// building a constructor or a destructor.
+  virtual llvm::Value *
+  getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl 
*RD,
+  BaseSubobject Base,
+  const CXXRecordDecl *NearestVBase) = 0;
 
   /// Get the address point of the vtable for the given base subobject while
   /// building a constexpr.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245721&r1=245720&r2=245721&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Aug 21 13:28:00 2015
@@ -1412,7 +1412,8 @@ void CodeGenModule::ConstructAttributeLi
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   const FunctionProtoType *FPT = Fn->getType()->getAs();
-  if (FPT && FPT->isNothrow(getContext()))
+  if (FPT && !isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
+  FPT->isNothrow(getContext()))
 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
   // These attributes are not inherited by overloads.

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=245721&r1=245720&r2=245721&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Aug 21 13:28:00 2015
@@ -1806,12 +1806,14 @@ void CodeGenFunction::EmitCXXConstructor
  bool ForVirtualBase,
  bool Delegating, llvm::Value 
*This,
  const CXXConstructExpr *E) {
+  const CXXRecordDecl *ClassDecl = D->getParent();
+
   // C++11 [class.mfct.non-static]p2:
   //   If a non-static member function of a class X is called for an object 
that
   //   is not of type X, or of a type derived from X, the behavior is 
undefined.
   // FIXME: Provide a source location here.
   EmitTypeCheck(CodeGenFunction::TCK_ConstructorCall, SourceLocation(), This,
-   

Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Oh, I see. So, you meant something like this?

  void foo(std::vector av, float * b, int 
N) {
for (auto a: av)  // << `a` doesn't have nontemporal attribute here
  for (int i = 0; i < N; i++)
a[i] = b[i]+1;
  }

One can easily work around it by using an explicit type here (`float * 
__attribute__((nontemporal))` instead of `auto`), but I agree that disappeared 
attribute might be a surprise for the user. Do you think it would be a frequent 
case?

BTW, there are other type attributes, which also suffer from the same issue, 
e.g. `vector_size`. What was the rationale of making them type attributes?


http://reviews.llvm.org/D12221



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


Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-21 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 32854.
xazax.hun added a comment.

Only send implicit dereference events, when the null pointer was bound to a 
reference.


http://reviews.llvm.org/D11433

Files:
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -28,7 +28,7 @@
 
 namespace {
 class NonNullParamChecker
-  : public Checker< check::PreCall > {
+  : public Checker< check::PreCall, EventDispatcher > {
   mutable std::unique_ptr BTAttrNonNull;
   mutable std::unique_ptr BTNullRefArg;
 
@@ -139,26 +139,33 @@
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull && !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+if (stateNull) {
+  if (!stateNotNull){
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
 
-std::unique_ptr R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+  std::unique_ptr R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
 
-// Highlight the range of the argument that was null.
-R->addRange(Call.getArgSourceRange(idx));
+  // Highlight the range of the argument that was null.
+  R->addRange(Call.getArgSourceRange(idx));
 
-// Emit the bug report.
-C.emitReport(std::move(R));
-  }
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-  // Always return.  Either we cached out or we just emitted an error.
-  return;
+// Always return.  Either we cached out or we just emitted an error.
+return;
+  }
+  ExplodedNode *N = C.generateSink(stateNull);
+  if (haveRefTypeParam && N) {
+ImplicitNullDerefEvent event = { V, false, N, &C.getBugReporter() };
+dispatchEvent(event);
+  }
 }
 
 // If a pointer value passed the check we should assume that it is


Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -28,7 +28,7 @@
 
 namespace {
 class NonNullParamChecker
-  : public Checker< check::PreCall > {
+  : public Checker< check::PreCall, EventDispatcher > {
   mutable std::unique_ptr BTAttrNonNull;
   mutable std::unique_ptr BTNullRefArg;
 
@@ -139,26 +139,33 @@
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull && !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+if (stateNull) {
+  if (!stateNotNull){
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
 
-std::unique_ptr R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+  std::unique_ptr R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
 
-// Highlight the range of the argument that was null.
-R->addRange(Call.getArgSourceRange(idx));
+  // Highlight the range of the argument that was null.
+  R->addRange(Call.getArgSourceRange(idx));
 
-// Emit the bug report.
-C.emitReport(std::move(R));
-  }
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-  // Always return.  Either we cached out or we just emitted an error.
-  return;
+// Always return.  Either we cached out or we just emitted an error.
+return;
+  }
+  ExplodedNode *N = C.generateSink(stateNull);
+  if (haveRefTypeParam && N) {
+ImplicitNullDerefEvent event = { V, false, N, &C.getBugReporter() };
+dispatchEvent(event);
+  }
 }
 
 // If a pointer value passed the check we should assume that it is

Re: [PATCH] D10732: [OPENMP 4.0] Initial support for array sections.

2015-08-21 Thread Richard Smith via cfe-commits
rsmith added a comment.

Thanks for the rework, the general approach here seems reasonable.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7680
@@ +7679,3 @@
+def err_omp_section_length_undefined : Error<
+  "section length is unspecified, but subscripted value is not an array">;
+

How about "section length is unspecified and cannot be inferred because 
subscripted value is not an array"?

Presumably there should also be an error for "section length is unspecified and 
cannot be inferred because subscripted value is an array of unknown bound"?


Comment at: lib/AST/ASTContext.cpp:1046-1047
@@ -1045,1 +1045,4 @@
 
+  // Placeholder type for OMP array sections.
+  InitBuiltinType(OMPArraySectionTy,  BuiltinType::OMPArraySection);
+

Condition this behind `if (LangOpts.OpenMP)`.


Comment at: lib/AST/Stmt.cpp:18
@@ -17,2 +17,3 @@
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/Stmt.h"

This appears to be unused?


Comment at: lib/Parse/ParseExpr.cpp:1400
@@ +1399,3 @@
+  ExprResult Idx, Length;
+  bool OMPArraySectionIsFound = false;
+  SourceLocation ColonLoc;

This appears to be unnecessary; you can use `ColonLoc.isValid()`.


Comment at: lib/Parse/ParseExpr.cpp:1406
@@ +1405,3 @@
+  } else {
+ColonProtectionRAIIObject RAII(*this);
+// Parse [: or [ expr or [ expr :

Please condition your new parsing, and in particular this colon protection, on 
`getLangOpts().OpenMP`, so we can still recover properly from typos like 
`A[X:foo()]` in C++.


Comment at: lib/Sema/SemaExpr.cpp:4001-4004
@@ +4000,6 @@
+  unsigned ArraySectionCount = 0;
+  while (auto *OASE = dyn_cast(Base)) {
+Base = OASE->getBase();
+++ArraySectionCount;
+  }
+  auto OriginalTy = Base->getType();

Should you `IgnoreParens()` here?


Comment at: lib/Sema/SemaExpr.cpp:4006
@@ +4005,3 @@
+  auto OriginalTy = Base->getType();
+  for (unsigned i = 0; i < ArraySectionCount; ++i) {
+if (OriginalTy->isAnyPointerType())

Please either consistently capitalize (per prevailing style in this file), or 
do not capitalize (per new LLVM coding style), your local variables; don't mix 
and match.


Comment at: lib/Sema/SemaExpr.cpp:4017
@@ +4016,3 @@
+
+ExprResult Sema::ActOnOMPArraySectionExpr(Scope *S, Expr *Base,
+  SourceLocation LBLoc,

I don't think you should need a `Scope` here; you shouldn't be performing any 
unqualified lookups while handling this expression.


Comment at: lib/Sema/SemaExpr.cpp:4022-4026
@@ +4021,7 @@
+  SourceLocation RBLoc) {
+  // Handle any non-overload placeholder types in the base and index
+  // expressions.  We can't handle overloads here because the other
+  // operand might be an overloadable type, in which case the overload
+  // resolution for the operator overload should get the first crack
+  // at the overload.
+  if (Base->getType()->isNonOverloadPlaceholderType() &&

This comment doesn't seem right -- array section expressions aren't 
overloadable.


Comment at: lib/Sema/SemaExpr.cpp:4027
@@ +4026,3 @@
+  // at the overload.
+  if (Base->getType()->isNonOverloadPlaceholderType() &&
+  !Base->getType()->isSpecificPlaceholderType(

Likewise, these `isNonOverloadablePlaceholderType()` calls don't seem right; I 
think you should be checking for /any/ placeholder type other than 
`OMPArraySection` here.


Comment at: lib/Sema/SemaExpr.cpp:4072
@@ +4071,3 @@
+  if (LowerBound) {
+if (!LowerBound->getType()->isIntegerType())
+  return ExprError(Diag(LowerBound->getExprLoc(),

This should presumably follow the rules for the underlying language. In 
particular, in C++, we should try to contextually implicitly convert to an 
integral type -- see `Sema::PerformContextualImplicitConversion`).


Comment at: lib/Sema/SemaExpr.cpp:4110
@@ +4109,3 @@
+llvm::APSInt LowerBoundValue;
+if (LowerBound->EvaluateAsInt(LowerBoundValue, Context)) {
+  // OpenMP 4.0, [2.4 Array Sections]

Same comment here as before: using constant folding to drive an error is not 
OK; you should only error here if the expression is an ICE.


Comment at: lib/Sema/SemaExpr.cpp:4112
@@ +4111,3 @@
+  // OpenMP 4.0, [2.4 Array Sections]
+  // The lower-bound and length must evaluate to non-negative integers.
+  if (LowerBoundValue.isNegative()) {

Is this a constraint or a semantic rule? (Are we required to reject it, are we 
permitted to reject it, or is a violation just UB?)


Comment at: lib/Sema/SemaExpr.cpp:4146-4154
@@ +4145

r245727 - Revert "Generating assumption loads of vptr after ctor call (fixed)"

2015-08-21 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Aug 21 14:49:41 2015
New Revision: 245727

URL: http://llvm.org/viewvc/llvm-project?rev=245727&view=rev
Log:
Revert "Generating assumption loads of vptr after ctor call (fixed)"
Reverting because of 245721

This reverts commit 552658e2b60543c928030b09cc9b5dfcb40c3f28.

Removed:
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGen/available-externally-hidden.cpp
cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
cfe/trunk/test/CodeGenCXX/virtual-base-ctor.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=245727&r1=245726&r2=245727&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Fri Aug 21 14:49:41 2015
@@ -346,25 +346,13 @@ public:
   virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
  const CXXRecordDecl *RD) = 0;
 
-  /// Checks if ABI requires extra virtual offset for vtable field.
-  virtual bool
-  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
-  CodeGenFunction::VPtr Vptr) = 0;
-
-  /// Checks if ABI requires to initilize vptrs for given dynamic class.
-  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 
0;
-
-  /// Get the address point of the vtable for the given base subobject.
-  virtual llvm::Constant *
-  getVTableAddressPoint(BaseSubobject Base,
-const CXXRecordDecl *VTableClass) = 0;
-
   /// Get the address point of the vtable for the given base subobject while
-  /// building a constructor or a destructor.
-  virtual llvm::Value *
-  getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl 
*RD,
-  BaseSubobject Base,
-  const CXXRecordDecl *NearestVBase) = 0;
+  /// building a constructor or a destructor. On return, NeedsVirtualOffset
+  /// tells if a virtual base adjustment is needed in order to get the offset
+  /// of the base subobject.
+  virtual llvm::Value *getVTableAddressPointInStructor(
+  CodeGenFunction &CGF, const CXXRecordDecl *RD, BaseSubobject Base,
+  const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) = 0;
 
   /// Get the address point of the vtable for the given base subobject while
   /// building a constexpr.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245727&r1=245726&r2=245727&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Aug 21 14:49:41 2015
@@ -1412,8 +1412,7 @@ void CodeGenModule::ConstructAttributeLi
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   const FunctionProtoType *FPT = Fn->getType()->getAs();
-  if (FPT && !isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
-  FPT->isNothrow(getContext()))
+  if (FPT && FPT->isNothrow(getContext()))
 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
   // These attributes are not inherited by overloads.

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=245727&r1=245726&r2=245727&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Aug 21 14:49:41 2015
@@ -1806,14 +1806,12 @@ void CodeGenFunction::EmitCXXConstructor
  bool ForVirtualBase,
  bool Delegating, llvm::Value 
*This,
  const CXXConstructExpr *E) {
-  const CXXRecordDecl *ClassDecl = D->getParent();
-
   // C++11 [class.mfct.non-static]p2:
   //   If a non-static member function of a class X is called for an object 
that
   //   is not of type X, or of a type derived from X, the behavior is 
undefined.
   // FIXME: Provide a source location here.
   EmitTypeCheck(CodeGenFunction::TCK_ConstructorCall, SourceLocation(), This,
-getContext().getRecordType(ClassDecl));
+getContext().getRecordType(D->getParent()));
 
   if (D->isTrivial() && D->isDefaultConstructor()) {

Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D12221#230263, @mzolotukhin wrote:

> Oh, I see. So, you meant something like this?
>
>   void foo(std::vector av, float * b, 
> int N) {
> for (auto a: av)  // << `a` doesn't have nontemporal attribute here
>   for (int i = 0; i < N; i++)
> a[i] = b[i]+1;
>   }
>
>
> One can easily work around it by using an explicit type here (`float * 
> __attribute__((nontemporal))` instead of `auto`), but I agree that 
> disappeared attribute might be a surprise for the user. Do you think it would 
> be a frequent case?


Yes, that's along the lines of what I was thinking. There are also other 
questions, as to whether a user would expect this code to work or not:

template 
void f(Ty *ptr);

template 
void f(Ty * __attribute__((nontemporal)) ptr);

I honestly don't know enough about nontemporal object usage patterns to really 
have a gut feeling for what patterns are likely to appear in the wild.

> BTW, there are other type attributes, which also suffer from the same issue, 
> e.g. `vector_size`. What was the rationale of making them type attributes?


The usual rationale is that these attributes are targeting C code more than 
C++, or that the C++ use cases that would be strange to a user are unlikely to 
happen with realistic code. The discussion that's come up in the past when we 
touch on these is that Clang could perhaps use a pluggable type system that 
allows for more fine-grained control on whether an attribute participates as 
part of a type or not. A production-quality pluggable type system is a pretty 
large undertaking, and it's a bit research-y at this point, so I'm not 
proposing anything like that.

Similar questions that help decide is whether you should be able to overload on 
the type attribute, specialize templates on it, type identity, etc.

~Aaron


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Richard Smith via cfe-commits
On Fri, Aug 21, 2015 at 12:14 PM, Michael Zolotukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> mzolotukhin added a comment.
>
> Oh, I see. So, you meant something like this?
>
>   void foo(std::vector av, float *
> b, int N) {
> for (auto a: av)  // << `a` doesn't have nontemporal attribute here
>   for (int i = 0; i < N; i++)
> a[i] = b[i]+1;
>   }
>
> One can easily work around it by using an explicit type here (`float *
> __attribute__((nontemporal))` instead of `auto`), but I agree that
> disappeared attribute might be a surprise for the user. Do you think it
> would be a frequent case?
>
> BTW, there are other type attributes, which also suffer from the same
> issue, e.g. `vector_size`. What was the rationale of making them type
> attributes?


vector_size produces a completely different type, with a different size,
alignment, different semantics and constraints for primitive operations,
and so on.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245731 - [SemaObjC] Remove unused code from test.

2015-08-21 Thread Alex Denisov via cfe-commits
Author: alexdenisov
Date: Fri Aug 21 15:28:16 2015
New Revision: 245731

URL: http://llvm.org/viewvc/llvm-project?rev=245731&view=rev
Log:
[SemaObjC] Remove unused code from test.
Patch by modocache (Brian Gesiak).


Modified:
cfe/trunk/test/SemaObjC/access-property-getter.m

Modified: cfe/trunk/test/SemaObjC/access-property-getter.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/access-property-getter.m?rev=245731&r1=245730&r2=245731&view=diff
==
--- cfe/trunk/test/SemaObjC/access-property-getter.m (original)
+++ cfe/trunk/test/SemaObjC/access-property-getter.m Fri Aug 21 15:28:16 2015
@@ -1,53 +1,17 @@
 // RUN: %clang_cc1 -verify %s
 
-@protocol NSObject
-- (oneway void)release;
+@protocol Protocol
+- (oneway void) method;
 @end
 
-@protocol XCOutputStreams 
-@end
-
-
-@interface XCWorkQueueCommandInvocation 
-{
-id  _outputStream;
-}
-@end
-
-@interface XCWorkQueueCommandSubprocessInvocation : 
XCWorkQueueCommandInvocation
-@end
-
-@interface XCWorkQueueCommandLocalSubprocessInvocation : 
XCWorkQueueCommandSubprocessInvocation
-@end
-
-@interface XCWorkQueueCommandDistributedSubprocessInvocation : 
XCWorkQueueCommandSubprocessInvocation
-@end
-
-@interface XCWorkQueueCommandCacheFetchInvocation : 
XCWorkQueueCommandSubprocessInvocation
-
-@end
-
-@implementation XCWorkQueueCommandCacheFetchInvocation
-- (id)harvestPredictivelyProcessedOutputFiles
-{
- _outputStream.release;// expected-warning {{property access result 
unused - getters should not be used for side effects}}
- return 0;
+void accessMethodViaPropertySyntaxAndTriggerWarning(id object) {
+object.method; // expected-warning {{property access result unused - 
getters should not be used for side effects}}
 }
-@end
 
 // rdar://19137815
 #pragma clang diagnostic ignored "-Wunused-getter-return-value"
 
-@interface NSObject @end
-
-@interface I : NSObject
-@property (copy) id window;
-@end
-
-@implementation I
-- (void) Meth {
-  [self window];
-  self.window;
+void 
accessMethodViaPropertySyntaxWhenWarningIsIgnoredDoesNotTriggerWarning(id
 object) {
+object.method;
 }
-@end
 


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


Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-21 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Please, commit this after committing the nullability checker so that this could 
have tests. Two tests need to be added:

1. the reference case
2. the attribute nonnull case

Also, I'd suggest adding a field to ImplicitNullDerefEvent instead of creating 
a new event.


http://reviews.llvm.org/D11433



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


Re: [PATCH] D12047: test/SemaObjC: Remove cruft in unused getter test

2015-08-21 Thread Alexey Denisov via cfe-commits
AlexDenisov accepted this revision.
AlexDenisov added a reviewer: AlexDenisov.
AlexDenisov added a comment.
This revision is now accepted and ready to land.

Committed, r245731.


http://reviews.llvm.org/D12047



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


Re: [PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-21 Thread Devin Coughlin via cfe-commits
dcoughlin updated this revision to Diff 32864.
dcoughlin added a comment.

Update comments to correct nil/non-nil mistakes.


http://reviews.llvm.org/D12123

Files:
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  test/Analysis/NSContainers.m
  test/Analysis/objc-message.m

Index: test/Analysis/objc-message.m
===
--- /dev/null
+++ test/Analysis/objc-message.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s
+
+extern void clang_analyzer_warnIfReached();
+void clang_analyzer_eval(int);
+
+@interface SomeClass
+-(id)someMethodWithReturn;
+-(void)someMethod;
+@end
+
+void consistencyOfReturnWithNilReceiver(SomeClass *o) {
+  id result = [o someMethodWithReturn];
+  if (result) {
+if (!o) {
+  // It is impossible for both o to be nil and result to be non-nil,
+  // so this should not be reached.
+  clang_analyzer_warnIfReached(); // no-warning
+}
+  }
+}
+
+void maybeNilReceiverIsNotNilAfterMessage(SomeClass *o) {
+  [o someMethod];
+
+  // We intentionally drop the nil flow (losing coverage) after a method
+  // call when the receiver may be nil in order to avoid inconsistencies of
+  // the kind tested for in consistencyOfReturnWithNilReceiver().
+  clang_analyzer_eval(o != 0); // expected-warning{{TRUE}}
+}
+
+void nilReceiverIsStillNilAfterMessage(SomeClass *o) {
+  if (o == 0) {
+id result = [o someMethodWithReturn];
+
+// Both the receiver and the result should be nil after a message
+// sent to a nil receiver returning a value of type id.
+clang_analyzer_eval(o == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(result == 0); // expected-warning{{TRUE}}
+  }
+}
Index: test/Analysis/NSContainers.m
===
--- test/Analysis/NSContainers.m
+++ test/Analysis/NSContainers.m
@@ -24,6 +24,8 @@
 @interface NSObject  {}
 - (id)init;
 + (id)alloc;
+
+- (id)mutableCopy;
 @end
 
 typedef struct {
@@ -292,3 +294,20 @@
   [arr addObject:0 safe:1]; // no-warning
 }
 
+@interface MyView : NSObject
+-(NSArray *)subviews;
+@end
+
+void testNoReportWhenReceiverNil(NSMutableArray *array, int b) {
+  // Don't warn about adding nil to a container when the receiver is also
+  // definitely nil.
+  if (array == 0) {
+[array addObject:0]; // no-warning
+  }
+
+  MyView *view = b ? [[MyView alloc] init] : 0;
+  NSMutableArray *subviews = [[view subviews] mutableCopy];
+  // When view is nil, subviews is also nil so there should be no warning
+  // here either.
+  [subviews addObject:view]; // no-warning
+}
Index: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -139,6 +139,69 @@
   CallEventRef Msg =
 CEMgr.getObjCMethodCall(ME, Pred->getState(), Pred->getLocationContext());
 
+  // There are three cases for the receiver:
+  //   (1) it is definitely nil,
+  //   (2) it is definitely non-nil, and
+  //   (3) we don't know.
+  //
+  // If the receiver is definitely nil, we skip the pre/post callbacks and
+  // instead call the ObjCMessageNil callbacks and return.
+  //
+  // If the receiver is definitely non-nil, we call the pre- callbacks,
+  // evaluate the call, and call the post- callbacks.
+  //
+  // If we don't know, we drop the potential nil flow and instead
+  // continue from the assumed non-nil state as in (2). This approach
+  // intentionally drops coverage in order to prevent false alarms
+  // in the following scenario:
+  //
+  // id result = [o someMethod]
+  // if (result) {
+  //   if (!o) {
+  // // <-- This program point should be unreachable because if o is nil
+  // // it must the case that result is nil as well.
+  //   }
+  // }
+  //
+  // We could avoid dropping coverage by performing an explicit case split
+  // on each method call -- but this would get very expensive. An alternative
+  // would be to introduce lazy constraints.
+  // FIXME: This ignores many potential bugs ().
+  // Revisit once we have lazier constraints.
+  if (Msg->isInstanceMessage()) {
+SVal recVal = Msg->getReceiverSVal();
+if (!recVal.isUndef()) {
+  // Bifurcate the state into nil and non-nil ones.
+  DefinedOrUnknownSVal receiverVal =
+  recVal.castAs();
+  ProgramStateRef State = Pred->getState();
+
+  ProgramStateRef notNilState, nilState;
+  std::tie(notNilState, nilState) = State->assume(receiverVal);
+
+  // Receiver is definitely nil, so run ObjCMessageNil callbacks and return.
+  if (nilState && !

Re: [PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-21 Thread Devin Coughlin via cfe-commits
dcoughlin marked an inline comment as done.
dcoughlin added a comment.

http://reviews.llvm.org/D12123



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Richard Smith via cfe-commits
On Fri, Aug 21, 2015 at 10:35 AM, Michael Zolotukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Yes, I've considered a builitin as an alternative. In fact, I started with
> it as it was easier to implement, but then decided to switch to type
> attribute due to the following reasons:
>
> 1. ARM ACLE 2.0 mentions attribute. Though it's not a final version of the
> document, AFAIU, I still preferred to use it as an argument for
> type-attribute.
>

I don't think this argument carries much weight by itself: I would imagine
that the reason this was listed as a possible future direction was to
solicit feedback from implementers and users; I think it's entirely
appropriate for our feedback to be "this is the wrong approach".

Another objection I have to the ACLE proposal is that it puts the attribute
on a pointer type but applies it to the pointee. This seems to make various
reasonable use cases awkward to support. For instance, suppose I want to
have a global variable to which I perform nontemporal loads and stores: I
would need to take the address of that global, cast it to a nontemporal
pointer, and dereference that in order to get a nontemporal operation. It
would seem more natural to have the attribute apply to any type, and to
apply to loads and stores of that type. So:

  int __attribute__((nontemporal)) *p; // a pointer to a nontemporal int
  int * __attribute__((nontemporal)) q; // a pointer (within nontemporal
storage) to an int

  int x = *p; // normal load of p, nontemporal load of *p
  int y = *q; // nontemporal load of q, normal load of *q

2. Once we introduce a builtin, we'll have to support it forever (otherwise
> we could break someone's code). With the attribute the burden is much
> smaller, as we can just start ignoring it at any point if we need to - all
> the code will remain correct and compilable.
>

Whatever we do here, we will in practice support it forever. We already
have target-specific versions of these nontemporal operations that we
intend to support forever. The support cost of the builtins is lower than
that of a type attribute.

3. We'll need to have an intrinsic for every type + separate intrinsics for
> loads and stores. If we use the type attribute, one fits all.
>

Builtins can have custom type checking, and if they do they can effectively
be overloaded for any type. (See the atomic builtins for an example.)


> 4. While it's true, that this is more type of operation, than a type, I
> think in real use-cases a user would rarely need to use it on a single
> operation. I.e. nontemporal operations are usually used for processing bulk
> volumes of data, and probably this data is almost always is processed as a
> whole. That's why I think it's fine to mark the entire 'data' as
> nontemporal. And, if a user then wants to work with a small subset of it,
> she can use a usual (not nontemporal) pointer to it.
>

OK, so you'd require a cast to/from a nontemporal type at the entry/exit of
such code? That's probably reasonable, but like Aaron, I'm not really sure
what usage patterns will appear in the wild here.

5. Personally, I find the code using attributes more elegant than using
> builtins. Compare:
>
>   void foo(float *__attribute__((nontemporal)) dst,
>float *__attribute__((nontemporal)) src1,
>float *__attribute__((nontemporal)) src2) {
> *dst = *src1 + *src2;
>   }
>
> and
>
>   void foo(float *dst, float *src1, float *src2) {
> float s1 = __builtin_nontemporal_load(src1);
> float s2 = __builtin_nontemporal_load(src2);
> __builtin_nontemporal_store(s1 + s2, dst);
>   }
>
> But that said, in the end I'm open to other alternatives (including
> builtins), and this thread is just an attempt to find the best option.


I think my personal preference here would depend on how important it is
that these operations are nontemporal -- the latter formulation makes this
a lot more obvious (the reader really can't miss that fact).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-08-21 Thread Sean Silva via cfe-commits
silvas added inline comments.


Comment at: test/Modules/auto-module-import.m:89
@@ +88,3 @@
+  expected-error {{import of module 'NoUmbrella.A' 
appears within function 'includeNotAtTopLevel'}} \
+  expected-note {{consider marking the module as 
textual}}
+}

I think what this means is marking the *header* as textual. So I would suggest 
the wording "consider marking the header as textual".


http://reviews.llvm.org/D11844



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


LLVM buildmaster will be restarted tonight

2015-08-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted after 6 PM Pacific time today.

Thanks

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


Re: [PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

2015-08-21 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 32869.
xazax.hun added a comment.

- Updated to the latest trunk.
- Relaxed an assert in ExprEngine which turned out to be unsound.
- The individual checks can be turned on or off.
- Added some framework specific heuristic to reduce the number of false 
positive results.
- Refactoring.


http://reviews.llvm.org/D11468

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- /dev/null
+++ test/Analysis/nullability.mm
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.nullability -verify %s
+
+#define nil 0
+#define BOOL int
+
+@protocol NSObject
++ (id)alloc;
+- (id)init;
+@end
+
+@protocol NSCopying
+@end
+
+__attribute__((objc_root_class))
+@interface
+NSObject
+@end
+
+@interface NSString : NSObject
+- (BOOL)isEqualToString : (NSString *_Nonnull)aString;
+- (NSString *)stringByAppendingString:(NSString *_Nonnull)aString;
+@end
+
+@interface TestObject : NSObject
+- (int *_Nonnull)returnsNonnull;
+- (int *_Nullable)returnsNullable;
+- (int *)returnsUnspecified;
+- (void)takesNonnull:(int *_Nonnull)p;
+- (void)takesNullable:(int *_Nullable)p;
+- (void)takesUnspecified:(int *)p;
+@property(readonly, strong) NSString *stuff;
+@end
+
+TestObject * getUnspecifiedTestObject();
+TestObject *_Nonnull getNonnullTestObject();
+TestObject *_Nullable getNullableTestObject();
+
+int getRandom();
+
+typedef struct Dummy { int val; } Dummy;
+
+void takesNullable(Dummy *_Nullable);
+void takesNonnull(Dummy *_Nonnull);
+void takesUnspecified(Dummy *);
+
+Dummy *_Nullable returnsNullable();
+Dummy *_Nonnull returnsNonnull();
+Dummy *returnsUnspecified();
+int *_Nullable returnsNullableInt();
+
+template  T *eraseNullab(T *p) { return p; }
+
+void testBasicRules() {
+  Dummy *p = returnsNullable();
+  int *ptr = returnsNullableInt();
+  // Make every dereference a different path to avoid sinks after errors.
+  switch (getRandom()) {
+  case 0: {
+Dummy &r = *p; // expected-warning {{}}
+  } break;
+  case 1: {
+int b = p->val; // expected-warning {{}}
+  } break;
+  case 2: {
+int stuff = *ptr; // expected-warning {{}}
+  } break;
+  case 3:
+takesNonnull(p); // expected-warning {{}}
+break;
+  case 4: {
+Dummy d;
+takesNullable(&d);
+Dummy dd(d);
+break;
+  }
+  // Here the copy constructor is called, so a reference is initialized with the
+  // value of p. No ImplicitNullDereference event will be dispatched for this
+  // case. A followup patch is expected to fix this in NonNullParamChecker.
+  default: { Dummy d = *p; } break; // No warning.
+  }
+  if (p) {
+takesNonnull(p);
+if (getRandom()) {
+  Dummy &r = *p;
+} else {
+  int b = p->val;
+}
+  }
+  Dummy *q = 0;
+  if (getRandom()) {
+takesNullable(q);
+takesNonnull(q); // expected-warning {{}}
+  }
+  Dummy a;
+  Dummy *_Nonnull nonnull = &a;
+  nonnull = q; // expected-warning {{}}
+  q = &a;
+  takesNullable(q);
+  takesNonnull(q);
+}
+
+void testArgumentTracking(Dummy *_Nonnull nonnull, Dummy *_Nullable nullable) {
+  Dummy *p = nullable;
+  nonnull = p; // expected-warning {{}}
+  p = 0;
+  Dummy *q = nonnull;
+  q = p;
+}
+
+Dummy *_Nonnull testNullableReturn(Dummy *_Nullable a) {
+  Dummy *p = a;
+  return p; // expected-warning {{}}
+}
+
+Dummy *_Nonnull testNullReturn() {
+  Dummy *p = 0;
+  return p; // expected-warning {{}}
+}
+
+void testObjCMessageResultNullability() {
+  // The expected result: the most nullable of self and method return type.
+  TestObject *o = getUnspecifiedTestObject();
+  int *shouldBeNullable = [eraseNullab(getNullableTestObject()) returnsNonnull];
+  switch (getRandom()) {
+  case 0:
+// The core analyzer assumes that the receiver is non-null after a message
+// send. This is to avoid some false positives, and increase performance
+// but it also reduces the coverage and makes this checker unable to reason
+// about the nullness of the receiver. 
+[o takesNonnull:shouldBeNullable]; // No warning expected.
+break;
+  case 1:
+shouldBeNullable =
+[eraseNullab(getNullableTestObject()) returnsUnspecified];
+[o takesNonnull:shouldBeNullable]; // No warning expected.
+break;
+  case 3:
+shouldBeNullable = [eraseNullab(getNullableTestObject()) returnsNullable];
+[o takesNonnull:shouldBeNullable]; // expected-warning {{}}
+break;
+  case 4:
+shouldBeNullable = [eraseNullab(getNonnullTestObject()) returnsNullable];
+[o takesNonnull:shouldBeNullable]; // expected-warning {{}}
+break;
+  case 5:
+shouldBeNullable =
+[eraseNullab(getUnspecifiedTestObject()) returnsNullable];
+[o takesNonnull:shouldBeNullable]; // expected-warning {{}}
+break;
+  case

[PATCH] D12251: Analyzer: Calculate field offset correctly

2015-08-21 Thread Ismail Pazarbasi via cfe-commits
ismailp created this revision.
ismailp added reviewers: krememek, zaks.anna.
ismailp added a subscriber: cfe-commits.

`StoreManager::getLValueFieldOrIvar` should return loc as
base + field-offset, instead of just base.

http://reviews.llvm.org/D12251

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/array-struct-region.cpp

Index: test/Analysis/array-struct-region.cpp
===
--- test/Analysis/array-struct-region.cpp
+++ test/Analysis/array-struct-region.cpp
@@ -106,6 +106,26 @@
 #endif
 }
 
+struct FieldOffset {
+  int firstField;
+  char secondField[63];
+  void *thirdField;
+};
+
+void testFieldOffsets() {
+  struct FieldOffset FO;
+  struct FieldOffset *PFONull = 0;
+#if __cplusplus
+  struct FieldOffset *PFONew = new struct FieldOffset;
+#endif
+  clang_analyzer_eval((void *)&FO.secondField != (void*)&FO); // 
expected-warning{{TRUE}}
+  clang_analyzer_eval((void *)&FO.secondField != (void*)&FO.thirdField); // 
expected-warning{{TRUE}}
+  clang_analyzer_eval((void *)&PFONull->secondField != (void 
*)&PFONull->thirdField); // expected-warning{{FALSE}}
+  clang_analyzer_eval((void *)&PFONull->secondField == (void *)0); // 
expected-warning{{TRUE}}
+#if __cplusplus
+  clang_analyzer_eval((void *)&PFONew->secondField != (void *)&PFONew); // 
expected-warning{{TRUE}}
+#endif
+}
 
 //
 // C++-only tests
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 
@@ -401,12 +402,21 @@
 // These are anormal cases. Flag an undefined value.
 return UndefinedVal();
 
-  case loc::ConcreteIntKind:
-// While these seem funny, this can happen through casts.
-// FIXME: What we should return is the field offset.  For example,
-//  add the field offset to the integer value.  That way funny things
-//  like this work properly:  &(((struct foo *) 0xa)->f)
+  case loc::ConcreteIntKind: {
+// Don't allow field offset calculations, if base is null.
+if (!Base.isZeroConstant()) {
+  if (const FieldDecl *FD = dyn_cast(D)) {
+ASTContext &Ctx = D->getASTContext();
+CharUnits CU = Ctx.toCharUnitsFromBits(Ctx.getFieldOffset(FD));
+loc::ConcreteInt BasePtr = BaseL.castAs();
+llvm::APSInt Offset(Ctx.getTypeSize(Ctx.VoidPtrTy));
+Offset = CU.getQuantity();
+Offset += BasePtr.getValue();
+return svalBuilder.makeIntLocVal(Offset);
+  }
+}
 return Base;
+  }
 
   default:
 llvm_unreachable("Unhandled Base.");


Index: test/Analysis/array-struct-region.cpp
===
--- test/Analysis/array-struct-region.cpp
+++ test/Analysis/array-struct-region.cpp
@@ -106,6 +106,26 @@
 #endif
 }
 
+struct FieldOffset {
+  int firstField;
+  char secondField[63];
+  void *thirdField;
+};
+
+void testFieldOffsets() {
+  struct FieldOffset FO;
+  struct FieldOffset *PFONull = 0;
+#if __cplusplus
+  struct FieldOffset *PFONew = new struct FieldOffset;
+#endif
+  clang_analyzer_eval((void *)&FO.secondField != (void*)&FO); // expected-warning{{TRUE}}
+  clang_analyzer_eval((void *)&FO.secondField != (void*)&FO.thirdField); // expected-warning{{TRUE}}
+  clang_analyzer_eval((void *)&PFONull->secondField != (void *)&PFONull->thirdField); // expected-warning{{FALSE}}
+  clang_analyzer_eval((void *)&PFONull->secondField == (void *)0); // expected-warning{{TRUE}}
+#if __cplusplus
+  clang_analyzer_eval((void *)&PFONew->secondField != (void *)&PFONew); // expected-warning{{TRUE}}
+#endif
+}
 
 //
 // C++-only tests
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 
@@ -401,12 +402,21 @@
 // These are anormal cases. Flag an undefined value.
 return UndefinedVal();
 
-  case loc::ConcreteIntKind:
-// While these seem funny, this can happen through casts.
-// FIXME: What we should return is the field offset.  For example,
-//  add the field offset to the integer value.  That way funny things
-//  like this work properly:  &(((struct foo *) 0xa)->f)
+  case loc::ConcreteIntKind: {
+// Don't a

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 32873.
nmusgrave marked 2 inline comments as done.
nmusgrave added a comment.

- Poisoning on field-by-field basis, with collective poisoning of trivial 
members when possible.
- Cleaned up implementation of calculating region to poison in dtor.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,14 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
 

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:41
@@ +40,3 @@
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor && Layout.getFieldCount() > 0
+  && HasTrivialDestructorBody(Context, D->getParent(), D->getParent())) {
+return true;

I'm not sure this is correct. It says not to use an alias if D has trivial 
body. Should not it be the other way around?


http://reviews.llvm.org/D12022



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


Improved Diagnostics and Extended vectorize(enable)

2015-08-21 Thread Tyler Nowicki via cfe-commits
Hi,

I’ve been working on the vectorization diagnostics a little more. The first 
patch makes sure the analysis diagnostics are printed unless a disabling hint 
is provided. And the two pairs of LLVM and Clang patches make the diagnostic 
messages easier to understand and extend the vectorize(enable) hint to override 
the mem-pointer check threshold.

The new diagnostics are:

remark: loop not vectorized: cannot prove it is safe to reorder floating-point 
operations; allow reordering by specifying '#pragma clang loop 
vectorize(enable)' before the loop or by providing the compiler option 
'-ffast-math’.

and

remark: loop not vectorized: cannot prove it is safe to reorder memory 
operations; allow reordering by specifying '#pragma clang loop 
vectorize(enable)' before the loop. If the arrays will always be independent 
specify '#pragma clang loop vectorize(assume_safety)' before the loop or 
provide the '__restrict__' qualifier with the independent array arguments. 
Erroneous results will occur if these options are incorrectly applied!

Using 'vectorize(enable)' to reorder memory operations is always safe (but not 
for fp ops), where as using 'vectorize(assume_safety)' might be dangerous. I 
removed the references to the mem-check threshold because I realized only 
compiler developers would know what it means.

Feedback is appreciated!

Tyler



LLVM-1-LoopVectorizeHints-produces-the-appropriate-pass-name.patch
Description: Binary data


LLVM-2-Modify-diagnostics-to-use-reordering-concept.patch
Description: Binary data


Clang-2-Modify-diagnostics-to-use-reordering-concept.patch
Description: Binary data


LLVM-3-Allow-hint-to-override-memcheck-threshold.patch
Description: Binary data


Clang-3-Allow-hint-to-override-memcheck-threshold.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245761 - [ARM NEON] Factor out FP-prototype checking. NFC.

2015-08-21 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Fri Aug 21 18:24:18 2015
New Revision: 245761

URL: http://llvm.org/viewvc/llvm-project?rev=245761&view=rev
Log:
[ARM NEON] Factor out FP-prototype checking. NFC.

Modified:
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=245761&r1=245760&r2=245761&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Fri Aug 21 18:24:18 2015
@@ -993,6 +993,10 @@ std::string Intrinsic::getInstTypeCode(T
   return S;
 }
 
+static bool isFloatingPointProtoModifier(char Mod) {
+  return Mod == 'F' || Mod == 'f';
+}
+
 std::string Intrinsic::getBuiltinTypeStr() {
   ClassKind LocalCK = getClassKind(true);
   std::string S;
@@ -1014,7 +1018,7 @@ std::string Intrinsic::getBuiltinTypeStr
 if (!RetT.isScalar() && !RetT.isSigned())
   RetT.makeSigned();
 
-bool ForcedVectorFloatingType = Proto[0] == 'F' || Proto[0] == 'f';
+bool ForcedVectorFloatingType = isFloatingPointProtoModifier(Proto[0]);
 if (LocalCK == ClassB && !RetT.isScalar() && !ForcedVectorFloatingType)
   // Cast to vector of 8-bit elements.
   RetT.makeInteger(8, true);
@@ -1027,7 +1031,7 @@ std::string Intrinsic::getBuiltinTypeStr
 if (T.isPoly())
   T.makeInteger(T.getElementSizeInBits(), false);
 
-bool ForcedFloatingType = Proto[I + 1] == 'F' || Proto[I + 1] == 'f';
+bool ForcedFloatingType = isFloatingPointProtoModifier(Proto[I + 1]);
 if (LocalCK == ClassB && !T.isScalar() && !ForcedFloatingType)
   T.makeInteger(8, true);
 // Halves always get converted to 8-bit elements.
@@ -1364,7 +1368,7 @@ void Intrinsic::emitBodyAsBuiltinCall()
   // Extra constant integer to hold type class enum for this function, e.g. s8
   if (getClassKind(true) == ClassB) {
 Type ThisTy = getReturnType();
-if (Proto[0] == 'v' || Proto[0] == 'f' || Proto[0] == 'F')
+if (Proto[0] == 'v' || isFloatingPointProtoModifier(Proto[0]))
   ThisTy = getParamType(0);
 if (ThisTy.isPointer())
   ThisTy = getParamType(1);
@@ -2022,8 +2026,8 @@ void NeonEmitter::genOverloadTypeCheckCo
 
 uint64_t Mask = 0ULL;
 Type Ty = Def->getReturnType();
-if (Def->getProto()[0] == 'v' || Def->getProto()[0] == 'f' ||
-Def->getProto()[0] == 'F')
+if (Def->getProto()[0] == 'v' ||
+isFloatingPointProtoModifier(Def->getProto()[0]))
   Ty = Def->getParamType(0);
 if (Ty.isPointer())
   Ty = Def->getParamType(1);


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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Naomi Musgrave via cfe-commits
nmusgrave added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:41
@@ +40,3 @@
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor && Layout.getFieldCount() > 0
+  && HasTrivialDestructorBody(Context, D->getParent(), D->getParent())) {
+return true;

eugenis wrote:
> I'm not sure this is correct. It says not to use an alias if D has trivial 
> body. Should not it be the other way around?
It's counter-intuitive:
TryEmitBaseDestructorAsAlias returns false when TryEmitDefinitionAsAlias 
returns false.
TryEmitDefinitionAsAlias returns false when an alias is successfully created 
(line 216 in this CL)


http://reviews.llvm.org/D12022



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


r245763 - [ARM NEON] Use the common naming scheme for vcvt f16 builtins. NFC.

2015-08-21 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Fri Aug 21 18:34:20 2015
New Revision: 245763

URL: http://llvm.org/viewvc/llvm-project?rev=245763&view=rev
Log:
[ARM NEON] Use the common naming scheme for vcvt f16 builtins. NFC.

We had "vcvt_f16" and "VCVT_HIGH_F16": for other FP types, this naming
is used for intrinsics with integer overloads. The FP->FP conversions,
on the other hand, use the full "vcvt_f32_f64" name instead.

Use the same naming convention for the f16<->f32 conversions.
While there, reorder the definitions a little bit.

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=245763&r1=245762&r2=245763&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Aug 21 18:34:20 2015
@@ -414,7 +414,7 @@ def OP_XTN  : Op<(call "vcombine", $
 def OP_SQXTUN   : Op<(call "vcombine", (cast $p0, "U", $p0),
(call "vqmovun", $p1))>;
 def OP_QXTN : Op<(call "vcombine", $p0, (call "vqmovn", $p1))>;
-def OP_VCVT_NA_HI_F16 : Op<(call "vcombine", $p0, (call "vcvt_f16", $p1))>;
+def OP_VCVT_NA_HI_F16 : Op<(call "vcombine", $p0, (call "vcvt_f16_f32", $p1))>;
 def OP_VCVT_NA_HI_F32 : Op<(call "vcombine", $p0, (call "vcvt_f32_f64", $p1))>;
 def OP_VCVT_EX_HI_F32 : Op<(call "vcvt_f32_f16", (call "vget_high", $p0))>;
 def OP_VCVT_EX_HI_F64 : Op<(call "vcvt_f64_f32", (call "vget_high", $p0))>;
@@ -687,16 +687,19 @@ def VGET_LOW  : NoTestOpInst<"vget_low",
 
 

 // E.3.22 Converting vectors
+
+def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "hk", "f">;
+def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "fd", "h">;
+
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
-def VCVT_F16 : SInst<"vcvt_f16", "hk",  "f">;
 def VCVT_F32 : SInst<"vcvt_f32", "fd",  "iUiQiQUi">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "fd",  "h">;
 let isVCVT_N = 1 in {
 def VCVT_N_S32   : SInst<"vcvt_n_s32", "xdi", "fQf">;
 def VCVT_N_U32   : SInst<"vcvt_n_u32", "udi", "fQf">;
 def VCVT_N_F32   : SInst<"vcvt_n_f32", "fdi", "iUiQiQUi">;
 }
+
 def VMOVN: IInst<"vmovn", "hk",  "silUsUiUl">;
 def VMOVL: SInst<"vmovl", "wd",  "csiUcUsUi">;
 def VQMOVN   : SInst<"vqmovn", "hk",  "silUsUiUl">;
@@ -923,6 +926,9 @@ def USQADD : SInst<"vsqadd", "ddd", "UcU
 // Reciprocal/Sqrt
 def FRECPS  : IInst<"vrecps", "ddd", "dQd">;
 def FRSQRTS : IInst<"vrsqrts", "ddd", "dQd">;
+def FRECPE  : SInst<"vrecpe", "dd", "dQd">;
+def FRSQRTE : SInst<"vrsqrte", "dd", "dQd">;
+def FSQRT   : SInst<"vsqrt", "dd", "fdQfQd">;
 
 

 // bitwise reverse
@@ -942,20 +948,21 @@ def QXTN2 : SOpInst<"vqmovn_high", "qhk"
 
 

 // Converting vectors
-def VCVT_HIGH_F16 : SOpInst<"vcvt_high_f16", "qhj", "f", OP_VCVT_NA_HI_F16>;
-def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
+
 def VCVT_F32_F64 : SInst<"vcvt_f32_f64", "md", "Qd">;
-def VCVT_HIGH_F32_F64 : SOpInst<"vcvt_high_f32", "qfj", "d", 
OP_VCVT_NA_HI_F32>;
 def VCVT_F64_F32 : SInst<"vcvt_f64_f32", "wd", "f">;
+
+def VCVT_S64 : SInst<"vcvt_s64", "xd",  "dQd">;
+def VCVT_U64 : SInst<"vcvt_u64", "ud",  "dQd">;
 def VCVT_F64 : SInst<"vcvt_f64", "Fd",  "lUlQlQUl">;
+
+def VCVT_HIGH_F16_f32 : SOpInst<"vcvt_high_f16", "qhj", "f", 
OP_VCVT_NA_HI_F16>;
+def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
+def VCVT_HIGH_F32_F64 : SOpInst<"vcvt_high_f32", "qfj", "d", 
OP_VCVT_NA_HI_F32>;
 def VCVT_HIGH_F64_F32 : SOpInst<"vcvt_high_f64", "wj", "f", OP_VCVT_EX_HI_F64>;
-def VCVTX_F32_F64 : SInst<"vcvtx_f32", "fj",  "d">;
+
+def VCVTX_F32_F64  : SInst<"vcvtx_f32", "fj",  "d">;
 def VCVTX_HIGH_F32_F64 : SOpInst<"vcvtx_high_f32", "qfj", "d", OP_VCVTX_HI>;
-def VCVT_S64 : SInst<"vcvt_s64", "xd",  "dQd">;
-def VCVT_U64 : SInst<"vcvt_u64", "ud",  "dQd">;
-def FRECPE  : SInst<"vrecpe", "dd", "dQd">;
-def FRSQRTE : SInst<"vrsqrte", "dd", "dQd">;
-def FSQRT   : SInst<"vsqrt", "dd", "fdQfQd">;
 
 

 // Comparison

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=245763&r1=245762&r2=245763&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 21 18:34:20 2015
@@ -2102,7 +2102,7 @@ static NeonIntrinsicInfo ARMSIMDIntrinsi
   

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Naomi Musgrave via cfe-commits
nmusgrave added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:41
@@ +40,3 @@
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor && Layout.getFieldCount() > 0
+  && HasTrivialDestructorBody(Context, D->getParent(), D->getParent())) {
+return true;

nmusgrave wrote:
> eugenis wrote:
> > I'm not sure this is correct. It says not to use an alias if D has trivial 
> > body. Should not it be the other way around?
> It's counter-intuitive:
> TryEmitBaseDestructorAsAlias returns false when TryEmitDefinitionAsAlias 
> returns false.
> TryEmitDefinitionAsAlias returns false when an alias is successfully created 
> (line 216 in this CL)
For example: line 3711 of clang/lib/CodeGen/MicrosoftCXXABI.cpp
 bool ProducedAlias = !CGM.TryEmitDefinitionAsAlias(
GlobalDecl(dtor, Dtor_Complete), GlobalDecl(dtor, Dtor_Base), true); 

^uses the negation of the function's return value


http://reviews.llvm.org/D12022



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Thanks for the feedback everyone!
I think at this point I'll try to return to builtins then. In my original patch 
I didn't have type overloading, so I'll need some time to add this. We can 
return back to type attributes later if we'd like to.

And do I understand it correctly, that we are talking about target-independent 
builtins?


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Richard Smith via cfe-commits
On Fri, Aug 21, 2015 at 4:59 PM, Michael Zolotukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> mzolotukhin added a comment.
>
> Thanks for the feedback everyone!
> I think at this point I'll try to return to builtins then. In my original
> patch I didn't have type overloading, so I'll need some time to add this.
> We can return back to type attributes later if we'd like to.
>

Sounds good.


> And do I understand it correctly, that we are talking about
> target-independent builtins?


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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CGClass.cpp:1578
@@ +1577,3 @@
+if (CGF.CGM.FieldHasTrivialDestructorBody(Context, Field) ||
+Field->getType()->isPointerType()) {
+  // Start sanitizing at this field

Why do you need to special-case pointers?


http://reviews.llvm.org/D12022



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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-21 Thread Naomi Musgrave via cfe-commits
nmusgrave added inline comments.


Comment at: lib/CodeGen/CGClass.cpp:1578
@@ +1577,3 @@
+if (CGF.CGM.FieldHasTrivialDestructorBody(Context, Field) ||
+Field->getType()->isPointerType()) {
+  // Start sanitizing at this field

eugenis wrote:
> Why do you need to special-case pointers?
FieldHasTrivialDestructorBody doesn't catch pointers- it identifies their base 
type as some class, and returns false


http://reviews.llvm.org/D12022



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


r245771 - When building a pseudo-object assignment, and the RHS is

2015-08-21 Thread John McCall via cfe-commits
Author: rjmccall
Date: Fri Aug 21 19:35:27 2015
New Revision: 245771

URL: http://llvm.org/viewvc/llvm-project?rev=245771&view=rev
Log:
When building a pseudo-object assignment, and the RHS is
a contextually-typed expression that semantic analysis will
probably need to invasively rewrite, don't include the
RHS OVE as a separate semantic expression, and check the
operation with the original RHS expression.

There are two contextually-typed expressions that can survive
to here: overloaded function references, which are at least
safe to double-emit, and C++11 initializer list expressions,
which are not at all safe to double-emit and which often
don't update the original syntactic InitListExpr with
implicit conversions to member types, etc.

This means that the original RHS may appear, undecorated by
an OVE, in the semantic expressions.  Fortunately, it will
only ever be used in a single place there, and I don't
believe there are clients that rely on being able to pick
out the original RHS from the semantic expressions.
But this could be problematic if there are clients that do
visit the entire tree and rely on not seeing the same
expression multiple times, once in the syntactic and once
in the semantic expressions.  This is a very fiddly part
of the compiler.

rdar://21801088

Modified:
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=245771&r1=245770&r2=245771&view=diff
==
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Fri Aug 21 19:35:27 2015
@@ -406,19 +406,27 @@ PseudoOpBuilder::buildAssignmentOperatio
   BinaryOperatorKind opcode,
   Expr *LHS, Expr *RHS) {
   assert(BinaryOperator::isAssignmentOp(opcode));
-  
-  // Recover from user error
-  if (isa(RHS))
-return ExprError();
 
   Expr *syntacticLHS = rebuildAndCaptureObject(LHS);
   OpaqueValueExpr *capturedRHS = capture(RHS);
 
+  // In some very specific cases, semantic analysis of the RHS as an
+  // expression may require it to be rewritten.  In these cases, we
+  // cannot safely keep the OVE around.  Fortunately, we don't really
+  // need to: we don't use this particular OVE in multiple places, and
+  // no clients rely that closely on matching up expressions in the
+  // semantic expression with expressions from the syntactic form.
+  Expr *semanticRHS = capturedRHS;
+  if (RHS->hasPlaceholderType() || isa(RHS)) {
+semanticRHS = RHS;
+Semantics.pop_back();
+  }
+
   Expr *syntactic;
 
   ExprResult result;
   if (opcode == BO_Assign) {
-result = capturedRHS;
+result = semanticRHS;
 syntactic = new (S.Context) BinaryOperator(syntacticLHS, capturedRHS,
opcode, capturedRHS->getType(),
capturedRHS->getValueKind(),
@@ -430,8 +438,7 @@ PseudoOpBuilder::buildAssignmentOperatio
 // Build an ordinary, non-compound operation.
 BinaryOperatorKind nonCompound =
   BinaryOperator::getOpForCompoundAssignment(opcode);
-result = S.BuildBinOp(Sc, opcLoc, nonCompound,
-  opLHS.get(), capturedRHS);
+result = S.BuildBinOp(Sc, opcLoc, nonCompound, opLHS.get(), semanticRHS);
 if (result.isInvalid()) return ExprError();
 
 syntactic =
@@ -745,16 +752,6 @@ ExprResult ObjCPropertyOpBuilder::buildS
   op = opResult.get();
   assert(op && "successful assignment left argument invalid?");
 }
-else if (OpaqueValueExpr *OVE = dyn_cast(op)) {
-  Expr *Initializer = OVE->getSourceExpr();
-  // passing C++11 style initialized temporaries to objc++ properties
-  // requires special treatment by removing OpaqueValueExpr so type
-  // conversion takes place and adding the OpaqueValueExpr later on.
-  if (isa(Initializer) &&
-  Initializer->getType()->isVoidType()) {
-op = Initializer;
-  }
-}
   }
 
   // Arguments.

Modified: cfe/trunk/test/CodeGenObjCXX/property-objects.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-objects.mm?rev=245771&r1=245770&r2=245771&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/property-objects.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/property-objects.mm Fri Aug 21 19:35:27 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -g -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -g 
-o - | FileCheck %s
 
 class S {
 public:
@@ -91,3 +91,133 @@ struct X {
 void f(A* a) {
   a.x = X();
 }
+
+// rdar://21801088
+//   Ensure that pseudo-objecet expressi

Re: [PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

2015-08-21 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Partial review...



Comment at: lib/StaticAnalyzer/Checkers/Checkers.td:137
@@ +136,3 @@
+def NullPassedToNonnullChecker : Checker<"NullPassedToNonnull">,
+  HelpText<"Warns when a null pointer is passed to a nonnull pointer.">,
+  DescFile<"NullabilityChecker.cpp">;

Should it be "pointer is used as a nonnull argument"?


Comment at: lib/StaticAnalyzer/Checkers/Checkers.td:149
@@ +148,3 @@
+def NullablePassedToNonnullChecker : Checker<"NullablePassedToNonnull">,
+  HelpText<"Warns when a nullable pointer is passed to a nonnull pointer.">,
+  DescFile<"NullabilityChecker.cpp">;

"nullable pointer is used as a nonnull argument"?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:12
@@ +11,3 @@
+// checker is that, the user is running this checker after all the nullability
+// warnings that is emitted by the compiler was fixed.
+//

"is" -> "are"

How are we relying on this assumption? What happens if they are not fixed?

Also we should describe what we mean by nullability warnings, maybe refer to 
the annotations themselves here? It would be great to give a high level 
overflow of the algorithm and maybe even talk about the difference between the 
checks?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:54
@@ +53,3 @@
+  return static_cast(
+  std::min(static_cast(Lhs), static_cast(Rhs)));
+}

??


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:70
@@ +69,3 @@
+const char *ErrorMessages[] = {
+"Null pointer is assigned to nonnull pointer",
+"Null pointer is passed to a nonnull parameter",

Same as above - there is no such thing as "nonnull pointer".


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:152
@@ +151,3 @@
+  R->addRange(ValueExpr->getSourceRange());
+  if (Error < ErrorKind::NullPointerEnd)
+bugreporter::trackNullOrUndefValue(N, ValueExpr, *R);

I don't like that we assume ordering here. Someone might sort the values in the 
enum and break this. Please, change this.



Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:179
@@ +178,3 @@
+  Nullability Nullab;
+  const Stmt *Source;
+};

Please, add comments.
What is Source?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:192
@@ +191,3 @@
+
+static bool shouldTrackRegion(const MemRegion *Region,
+  AnalysisDeclContext *DeclContext) {

Is this used for optimization purposes? Can you describe the rules we use here?

What's the benefit of not tracking self?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:259
@@ +258,3 @@
+
+static Nullability getNullability(QualType Type) {
+  const auto *AttrType = Type->getAs();

Maybe rename to "getNullabilityAnnotation" ?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:267
@@ +266,3 @@
+return Nullability::Nonnull;
+  return Nullability::Unspecified;
+}

shouldn't this be an llvm_unreachable?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:298
@@ +297,3 @@
+TrackedNullability = State->get(
+Region->getAs()->getSuperRegion());
+if (!TrackedNullability)

Are we sure that if "!TrackedNullability", the event complains about a 
dereference on the parent (like field access)?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:317
@@ +316,3 @@
+  QualType RetExprType = RetExpr->getType();
+  if (!RetExprType->isPointerType() && !RetExprType->isObjCObjectPointerType())
+return;

Let's use an existing helper here:
inline bool Type::isAnyPointerType() const {
  return isPointerType() || isObjCObjectPointerType();
}


http://reviews.llvm.org/D11468



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


r245778 - [ARM NEON] Remove special-case for f16 vcvt handling. NFCI.

2015-08-21 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Fri Aug 21 20:30:13 2015
New Revision: 245778

URL: http://llvm.org/viewvc/llvm-project?rev=245778&view=rev
Log:
[ARM NEON] Remove special-case for f16 vcvt handling. NFCI.

We can use the 'H' typespec modifier to use 128-bit vectors directly
in the only two users of this special-case: the vcvt f16 intrinsics.
This also lets us use more meaningful prototype modifiers.

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=245778&r1=245777&r2=245778&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Aug 21 20:30:13 2015
@@ -688,8 +688,8 @@ def VGET_LOW  : NoTestOpInst<"vget_low",
 

 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "hk", "f">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "fd", "h">;
+def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
@@ -956,7 +956,7 @@ def VCVT_S64 : SInst<"vcvt_s64", "xd",
 def VCVT_U64 : SInst<"vcvt_u64", "ud",  "dQd">;
 def VCVT_F64 : SInst<"vcvt_f64", "Fd",  "lUlQlQUl">;
 
-def VCVT_HIGH_F16_f32 : SOpInst<"vcvt_high_f16", "qhj", "f", 
OP_VCVT_NA_HI_F16>;
+def VCVT_HIGH_F16_F32 : SOpInst<"vcvt_high_f16", "hmj", "Hf", 
OP_VCVT_NA_HI_F16>;
 def VCVT_HIGH_F32_F16 : SOpInst<"vcvt_high_f32", "wk", "h", OP_VCVT_EX_HI_F32>;
 def VCVT_HIGH_F32_F64 : SOpInst<"vcvt_high_f32", "qfj", "d", 
OP_VCVT_NA_HI_F32>;
 def VCVT_HIGH_F64_F32 : SOpInst<"vcvt_high_f64", "wj", "f", OP_VCVT_EX_HI_F64>;

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=245778&r1=245777&r2=245778&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Fri Aug 21 20:30:13 2015
@@ -837,10 +837,6 @@ void Type::applyModifier(char Mod) {
 Float = true;
 break;
   case 'f':
-// Special case - if we're half-precision, a floating
-// point argument needs to be 128-bits (double size).
-if (isHalf())
-  Bitwidth = 128;
 Float = true;
 ElementBitwidth = 32;
 break;


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


Re: [PATCH] Fix out-of-bounds array access when setting arm float registers

2015-08-21 Thread Saleem Abdulrasool via cfe-commits
On Fri, Aug 21, 2015 at 11:02 AM, Hans Wennborg  wrote:

> On Thu, Aug 20, 2015 at 8:28 PM, Saleem Abdulrasool
>  wrote:
> > On Thu, Aug 20, 2015 at 2:13 PM, Hans Wennborg 
> wrote:
> >>
> >> +Saleem and Renato; maybe you can take a look?
> >
> >
> > Thanks for pointing this out!
> >
> > The patch is correct and pretty safe to apply for 3.7 I think since its a
> > simple bug fix, and can result in VFP state corruption (the invalid
> memory
> > access in this case shouldn't access to arbitrary memory fortunately).
> I've
> > applied to trunk as SVN r245665.  Should I send a request on the thread
> for
> > the actual commit?
>
> It's too late to get this into 3.7.0, but it seems like a good
> candidate for 3.7.1. I'll put it on my list and we can merge it when
> Tom starts preparing the dot-release.
>

Sounds good to me.  Thanks.  If you can keep it on your list for 3.7.1,
that would be greatly appreciated.


> Thanks,
> Hans
>
>
> >> On Tue, Aug 18, 2015 at 11:24 AM, Leandro Graciá Gil
> >>  wrote:
> >> > Hi,
> >> >
> >> > Please find attached a patch fixing an out-of-bounds array access
> >> > present in
> >> > the current libunwind top of tree code.
> >> >
> >> > The problem is caused by subtracting the wrong base register in
> >> > Registers_arm::SetFloatRegister and should become obvious after
> taking a
> >> > quick look to the code.
> >> >
> >> > Could someone please commit this to trunk and merge it to the release
> 37
> >> > branch?
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245779 - [modules] Rearrange how redeclaration chains are loaded, to remove a walk over

2015-08-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 21 20:47:18 2015
New Revision: 245779

URL: http://llvm.org/viewvc/llvm-project?rev=245779&view=rev
Log:
[modules] Rearrange how redeclaration chains are loaded, to remove a walk over
all modules and reduce the number of declarations we load when loading a
redeclaration chain.

The new approach is:
 * when loading the first declaration of an entity within a module file, we
   first load all declarations of the entity that were imported into that
   module file, and then load all the other declarations of that entity from
   that module file and build a suitable decl chain from them
 * when loading any other declaration of an entity, we first load the first
   declaration from the same module file

As before, we complete redecl chains through name lookup where necessary.

To make this work, I also had to change the way that template specializations
are stored -- it no longer suffices to track only canonical specializations; we
now emit all "first local" declarations when emitting a list of specializations
for a template.

On one testcase with several thousand imported module files, this reduces the
total runtime by 72%.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/cxx-templates.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=245779&r1=245778&r2=245779&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Aug 21 20:47:18 2015
@@ -405,6 +405,10 @@ private:
   /// \brief The set of declarations that may have redeclaration chains that
   /// need to be serialized.
   llvm::SmallVector Redeclarations;
+
+  /// \brief A cache of the first local declaration for "interesting"
+  /// redeclaration chains.
+  llvm::DenseMap FirstLocalDeclCache;
   
   /// \brief Statements that we've encountered while serializing a
   /// declaration or type.
@@ -676,6 +680,10 @@ public:
   const ASTTemplateArgumentListInfo *ASTTemplArgList,
   RecordDataImpl &Record);
 
+  /// \brief Find the first local declaration of a given local redeclarable
+  /// decl.
+  const Decl *getFirstLocalDecl(const Decl *D);
+
   /// \brief Emit a reference to a declaration.
   void AddDeclRef(const Decl *D, RecordDataImpl &Record);
 
@@ -857,12 +865,6 @@ public:
   void CompletedTagDefinition(const TagDecl *D) override;
   void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
   void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
-  void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
- const ClassTemplateSpecializationDecl *D) 
override;
-  void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD,
-   const VarTemplateSpecializationDecl *D) 
override;
-  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
-  const FunctionDecl *D) override;
   void ResolvedExceptionSpec(const FunctionDecl *FD) override;
   void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
   void ResolvedOperatorDelete(const CXXDestructorDecl *DD,

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245779&r1=245778&r2=245779&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 21 20:47:18 2015
@@ -8123,11 +8123,8 @@ void ASTReader::finishPendingActions() {
 PendingIncompleteDeclChains.clear();
 
 // Load pending declaration chains.
-for (unsigned I = 0; I != PendingDeclChains.size(); ++I) {
-  PendingDeclChainsKnown.erase(PendingDeclChains[I]);
+for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
   loadPendingDeclChain(PendingDeclChains[I]);
-}
-assert(PendingDeclChainsKnown.empty());
 PendingDeclChains.clear();
 
 assert(RedeclsDeserialized.empty() && "some redecls not wired up");

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=245779&r1=245778&r2=245779&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Aug 21 20:47:18 2015
@@ -147,12 +147,6 @@ namespac

r245780 - [modules] Remove some dead code after r245779.

2015-08-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 21 21:09:38 2015
New Revision: 245780

URL: http://llvm.org/viewvc/llvm-project?rev=245780&view=rev
Log:
[modules] Remove some dead code after r245779.

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=245780&r1=245779&r2=245780&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Aug 21 21:09:38 2015
@@ -932,10 +932,6 @@ private:
   /// Objective-C protocols.
   std::deque InterestingDecls;
 
-  /// \brief The set of redeclarable declarations that have been deserialized
-  /// since the last time the declaration chains were linked.
-  llvm::SmallPtrSet RedeclsDeserialized;
-  
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed.
   ///
@@ -944,9 +940,6 @@ private:
   /// PendingDeclChainsKnown to ensure uniqueness.
   SmallVector PendingDeclChains;
 
-  /// \brief Keeps track of the elements added to PendingDeclChains.
-  llvm::SmallSet PendingDeclChainsKnown;
-
   /// \brief The list of canonical declarations whose redeclaration chains
   /// need to be marked as incomplete once we're done deserializing things.
   SmallVector PendingIncompleteDeclChains;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=245780&r1=245779&r2=245780&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 21 21:09:38 2015
@@ -8127,8 +8127,6 @@ void ASTReader::finishPendingActions() {
   loadPendingDeclChain(PendingDeclChains[I]);
 PendingDeclChains.clear();
 
-assert(RedeclsDeserialized.empty() && "some redecls not wired up");
-
 // Make the most recent of the top-level declarations visible.
 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=245780&r1=245779&r2=245780&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Aug 21 21:09:38 2015
@@ -120,47 +120,21 @@ namespace clang {
 static void setAnonymousDeclForMerging(ASTReader &Reader, DeclContext *DC,
unsigned Index, NamedDecl *D);
 
-/// \brief RAII class used to capture the first ID within a redeclaration
-/// chain and to introduce it into the list of pending redeclaration chains
-/// on destruction.
+/// Results from loading a RedeclarableDecl.
 class RedeclarableResult {
-  ASTReader &Reader;
   GlobalDeclID FirstID;
-  Decl *LoadedDecl;
   Decl *MergeWith;
-  mutable bool Owning;
   bool IsKeyDecl;
 
-  void operator=(RedeclarableResult &) = delete;
-
 public:
-  RedeclarableResult(ASTReader &Reader, GlobalDeclID FirstID,
- Decl *LoadedDecl, Decl *MergeWith, bool IsKeyDecl)
-  : Reader(Reader), FirstID(FirstID), LoadedDecl(LoadedDecl),
-MergeWith(MergeWith), Owning(true), IsKeyDecl(IsKeyDecl) {}
-
-  RedeclarableResult(RedeclarableResult &&Other)
-  : Reader(Other.Reader), FirstID(Other.FirstID),
-LoadedDecl(Other.LoadedDecl), MergeWith(Other.MergeWith),
-Owning(Other.Owning), IsKeyDecl(Other.IsKeyDecl) {
-Other.Owning = false;
-  }
-
-  ~RedeclarableResult() {
-  }
-
-  /// \brief Note that a RedeclarableDecl is not actually redeclarable.
-  void setNotRedeclarable() {
-Owning = false;
-Reader.RedeclsDeserialized.erase(LoadedDecl);
-assert(FirstID == LoadedDecl->getGlobalID() && !MergeWith &&
-   "non-redeclarable declaration was redeclared?");
-  }
+  RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl)
+  : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {}
+  ~RedeclarableResult() {}
 
   /// \brief Retrieve the first ID.
   GlobalDeclID getFirstID() const { return FirstID; }
 
-  /// \brief Is this declaration the key declaration?
+  /// \brief Is this declaration a key declaration?
   bool isKeyDecl() const { return IsKeyDecl; }
 
   /// \brief Get a known declaration that this should be merged with, if
@@ -912,7 +886,6 @@ void ASTDecl

[PATCH] D12262: [OpenMP] Capture global variables in target regions.

2015-08-21 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, rjmccall, hfinkel.
sfantao added a subscriber: cfe-commits.

All global variables that are not enclosed in a declare target region must be 
captured in the target region as local variables do. Currently, there is no 
support for declare target, so this patch adds support for capturing all the 
global variables used in a the target region.

This patch requires http://reviews.llvm.org/D11361.


http://reviews.llvm.org/D12262

Files:
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/Basic/OpenMPKinds.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_codegen_global_capture.cpp

Index: test/OpenMP/target_codegen_global_capture.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_global_capture.cpp
@@ -0,0 +1,186 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+// CHECK-DAG: [[GA:@.+]] = global double 1.00e+00
+// CHECK-DAG: [[GB:@.+]] = global double 2.00e+00
+// CHECK-DAG: [[GC:@.+]] = global double 3.00e+00
+// CHECK-DAG: [[GD:@.+]] = global double 4.00e+00
+// CHECK-DAG: [[FA:@.+]] = internal global float 5.00e+00
+// CHECK-DAG: [[FB:@.+]] = internal global float 6.00e+00
+// CHECK-DAG: [[FC:@.+]] = internal global float 7.00e+00
+// CHECK-DAG: [[FD:@.+]] = internal global float 8.00e+00
+// CHECK-DAG: [[BA:@.+]] = internal global float 9.00e+00
+// CHECK-DAG: [[BB:@.+]] = internal global float 1.00e+01
+// CHECK-DAG: [[BC:@.+]] = internal global float 1.10e+01
+// CHECK-DAG: [[BD:@.+]] = internal global float 1.20e+01
+double Ga = 1.0;
+double Gb = 2.0;
+double Gc = 3.0;
+double Gd = 4.0;
+
+// CHECK: define {{.*}} @{{.*}}foo{{.*}}(
+// CHECK-SAME: i16 {{[^,]*}}[[A:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[B:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[C:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[D:%[^,]+]])
+// CHECK: [[LA:%.+]] = alloca i16
+// CHECK: [[LB:%.+]] = alloca i16
+// CHECK: [[LC:%.+]] = alloca i16
+// CHECK: [[LD:%.+]] = alloca i16
+int foo(short a, short b, short c, short d){
+  static float Sa = 5.0;
+  static float Sb = 6.0;
+  static float Sc = 7.0;
+  static float Sd = 8.0;
+
+  // CHECK-DAG: [[REFB:%.+]] = bitcast i16* [[LB]] to i8*
+  // CHECK-DAG: store i8* [[REFB]], i8** [[GEPB:%.+]]
+  // CHECK-DAG: [[REFC:%.+]] = bitcast i16* [[LC]] to i8*
+  // CHECK-DAG: store i8* [[REFC]], i8** [[GEPC:%.+]]
+  // CHECK-DAG: [[REFD:%.+]] = bitcast i16* [[LD]] to i8*
+  // CHECK-DAG: store i8* [[REFD]], i8** [[GEPD:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GB]] to i8*), i8** [[GEPGB:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GC]] to i8*), i8** [[GEPGC:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GD]] to i8*), i8** [[GEPGD:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FB]] to i8*), i8** [[GEPFB:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FC]] to i8*), i8** [[GEPFC:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FD]] to i8*), i8** [[GEPFD:%.+]]
+  // CHECK-DAG: [[GEPB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK: call i32 @__tgt_target
+  // CHECK: call void [[OFFLOADF:@.+]](
+  // Capture b, Gb, Sb, Gc, c, Sc, d, Gd, Sd
+  #pragma omp target if(Ga>0.0 && a>0 && Sa>0.0)
+  {
+b += 1;
+Gb += 1.0;
+Sb += 1.0;
+
+
+// CHECK: define internal void [[PARF:@.+]](i32* %{{.*}}, i32* %{{.*}},
+// CHECK: defin

Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-21 Thread Ted Kremenek via cfe-commits
krememek added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:778
@@ -780,3 +777,3 @@
 
-UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
-: Out(std::move(Out)), Filename(Filename), Cntr(0) {
+UbigraphViz::UbigraphViz(std::unique_ptr Stm, StringRef Filename)
+: Out(std::move(Stm)), Filename(Filename), Cntr(0) {

While succinct, I think 'Stm' is an actively harmful name as it conveys no 
meaning.  There's no need to hyper optimize here.

How about 'outStream', or something that clearly indicates what it is.

You're only going to use it twice.  No harm in spelling it out.  'Stm' could 
mean a bunch of things.


http://reviews.llvm.org/D12119



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


Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-21 Thread Ted Kremenek via cfe-commits
krememek added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:749
@@ -748,3 @@
-
-  assert (Src != Dst && "Self-edges are not allowed.");
-

Did you look at the test case that causes this assertion to fail?  I think it 
would be good to know if this assertion is actually safe to remove.  I'm a bit 
skeptical that it is safe to remove, and that (per my last review) that this 
may be detecting that an invariant is getting violated.  If you are not certain 
how to investigate that part, please report which test is triggering the 
problem and myself or someone else familiar with the engine core can take a 
look.  Thanks.


http://reviews.llvm.org/D12119



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


r245786 - [CUDA] Change initializer for CUDA device code based on CUDA documentation.

2015-08-21 Thread Jingyue Wu via cfe-commits
Author: jingyue
Date: Sat Aug 22 00:49:28 2015
New Revision: 245786

URL: http://llvm.org/viewvc/llvm-project?rev=245786&view=rev
Log:
[CUDA] Change initializer for CUDA device code based on CUDA documentation.

Summary:
According to CUDA documentation, global variables declared with __device__,
__constant__ can be initialized from host code, so mark them as
externally initialized. Because __shared__ variables cannot have an
initialization as part of their declaration and since the value maybe kept
across different kernel invocation, the value of __shared__ is effectively
undefined instead of zero initialized.

Wrongly using zero initializer may cause illegitimate optimization, e.g.
removing unused __constant__ variable because it's not updated in the device
code and the value is initialized with zero.

Test Plan: test/CodeGenCUDA/address-spaces.cu

Patch by Xuetian Weng

Reviewers: jholewinski, eliben, tra, jingyue

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12241

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCUDA/address-spaces.cu
cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=245786&r1=245785&r2=245786&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Aug 22 00:49:28 2015
@@ -1990,7 +1990,16 @@ void CodeGenModule::EmitGlobalVarDefinit
   const VarDecl *InitDecl;
   const Expr *InitExpr = D->getAnyInitializer(InitDecl);
 
-  if (!InitExpr) {
+  // CUDA E.2.4.1 "__shared__ variables cannot have an initialization as part
+  // of their declaration."
+  if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice
+  && D->hasAttr()) {
+if (InitExpr) {
+  Error(D->getLocation(),
+"__shared__ variable cannot have an initialization.");
+}
+Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
+  } else if (!InitExpr) {
 // This is a tentative definition; tentative definitions are
 // implicitly initialized with { 0 }.
 //
@@ -2076,6 +2085,17 @@ void CodeGenModule::EmitGlobalVarDefinit
   if (D->hasAttr())
 AddGlobalAnnotations(D, GV);
 
+  // CUDA B.2.1 "The __device__ qualifier declares a variable that resides on
+  // the device. [...]"
+  // CUDA B.2.2 "The __constant__ qualifier, optionally used together with
+  // __device__, declares a variable that: [...]
+  // Is accessible from all the threads within the grid and from the host
+  // through the runtime library (cudaGetSymbolAddress() / cudaGetSymbolSize()
+  // / cudaMemcpyToSymbol() / cudaMemcpyFromSymbol())."
+  if (GV && LangOpts.CUDA && LangOpts.CUDAIsDevice &&
+  (D->hasAttr() || D->hasAttr())) {
+GV->setExternallyInitialized(true);
+  }
   GV->setInitializer(Init);
 
   // If it is safe to mark the global 'constant', do so now.

Modified: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/address-spaces.cu?rev=245786&r1=245785&r2=245786&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu Sat Aug 22 00:49:28 2015
@@ -5,10 +5,10 @@
 
 #include "Inputs/cuda.h"
 
-// CHECK: @i = addrspace(1) global
+// CHECK: @i = addrspace(1) externally_initialized global
 __device__ int i;
 
-// CHECK: @j = addrspace(4) global
+// CHECK: @j = addrspace(4) externally_initialized global
 __constant__ int j;
 
 // CHECK: @k = addrspace(3) global
@@ -24,7 +24,7 @@ struct MyStruct {
 // CHECK: @_ZZ5func2vE1a = internal addrspace(3) global [256 x float] 
zeroinitializer
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
-// CHECK: @b = addrspace(3) global float 0.00e+00
+// CHECK: @b = addrspace(3) global float undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)

Modified: cfe/trunk/test/CodeGenCUDA/filter-decl.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/filter-decl.cu?rev=245786&r1=245785&r2=245786&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/filter-decl.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/filter-decl.cu Sat Aug 22 00:49:28 2015
@@ -9,12 +9,12 @@
 // CHECK-DEVICE-NOT: module asm "file scope asm is host only"
 __asm__("file scope asm is host only");
 
-// CHECK-HOST-NOT: constantdata = global
-// CHECK-DEVICE: constantdata = global
+// CHECK-HOST-NOT: constantdata = externally_initialized global
+// CHECK-DEVICE: constantdata = externally_initialized global
 __constant__ char constantdata[256];
 
-// C