Re: clang-format: Fix deref treated as binary op in throw

2017-07-17 Thread Manuel Klimek via cfe-commits
LG, thanks for the patch. For next time, it helps to use phabricator to
make people catch patches faster :)

Do you have commit access or do you need me to check it in?

On Thu, Jul 6, 2017 at 6:53 PM Erik Uhlmann via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> When dereferencing a pointer in a throw statement, clang-format assigns
> TT_BinaryOperator to the star token, so it gets formatted as:
>
> throw * x;
>
> With this change the above becomes
>
> throw *x;
>
> Bug tracker: https://bugs.llvm.org/show_bug.cgi?id=33665
>
> Attached is a patch containing the fix.
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308044 - Add documentation for @available

2017-07-17 Thread Aaron Ballman via cfe-commits
On Sun, Jul 16, 2017 at 7:49 PM, Nico Weber  wrote:
> Aaron, https://clang.llvm.org/docs/AttributeReference.html#availability
> still doesn't have the AttrDocs.td change I made in this change 2 days ago.
> Do I have to do anything to get it to update?

No, it's expected to update once a day, usually pretty early in the
morning EST (ridiculously early PST).

Tanya, I've not seen any failure emails for building from AttrDocs.td.
Did I get removed from that list when we updated? If so, I'm happy to
continue to receive it to help resolve problems, but in the interim,
do you happen to know more about what's going on?

Thanks!

~Aaron

>
> On Fri, Jul 14, 2017 at 2:40 PM, Nico Weber via cfe-commits
>  wrote:
>>
>> Author: nico
>> Date: Fri Jul 14 11:40:52 2017
>> New Revision: 308044
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308044=rev
>> Log:
>> Add documentation for @available
>>
>> https://reviews.llvm.org/D35379
>>
>> Modified:
>> cfe/trunk/docs/LanguageExtensions.rst
>> cfe/trunk/include/clang/Basic/AttrDocs.td
>>
>> Modified: cfe/trunk/docs/LanguageExtensions.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=308044=308043=308044=diff
>>
>> ==
>> --- cfe/trunk/docs/LanguageExtensions.rst (original)
>> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 14 11:40:52 2017
>> @@ -1271,6 +1271,87 @@ Further examples of these attributes are
>>  Query for these features with ``__has_attribute(ns_consumed)``,
>>  ``__has_attribute(ns_returns_retained)``, etc.
>>
>> +Objective-C @available
>> +--
>> +
>> +It is possible to use the newest SDK but still build a program that can
>> run on
>> +older versions of macOS and iOS by passing ``-mmacosx-version-info=`` /
>> +``--miphoneos-version-min=``.
>> +
>> +Before LLVM 5.0, when calling a function that exists only in the OS
>> that's
>> +newer than the target OS (as determined by the minimum deployment
>> version),
>> +programmers had to carefully check if the function exists at runtime,
>> using
>> +null checks for weakly-linked C functions, ``+class`` for Objective-C
>> classes,
>> +and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
>> +Objective-C methods.  If such a check was missed, the program would
>> compile
>> +fine, run fine on newer systems, but crash on older systems.
>> +
>> +As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability
>> attributes
>> +`_
>> together
>> +with the new ``@available()`` keyword to assist with this issue.
>> +When a method that's introduced in the OS newer than the target OS is
>> called, a
>> +-Wunguarded-availability warning is emitted if that call is not guarded:
>> +
>> +.. code-block:: objc
>> +
>> +  void my_fun(NSSomeClass* var) {
>> +// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
>> +// built with -mmacosx-version-min=10.11, then this unconditional
>> call
>> +// will emit a -Wunguarded-availability warning:
>> +[var fancyNewMethod];
>> +  }
>> +
>> +To fix the warning and to avoid the crash on macOS 10.11, wrap it in
>> +``if(@available())``:
>> +
>> +.. code-block:: objc
>> +
>> +  void my_fun(NSSomeClass* var) {
>> +if (@available(macOS 10.12, *)) {
>> +  [var fancyNewMethod];
>> +} else {
>> +  // Put fallback behavior for old macOS versions (and for non-mac
>> +  // platforms) here.
>> +}
>> +  }
>> +
>> +The ``*`` is required and means that platforms not explicitly listed will
>> take
>> +the true branch, and the compiler will emit ``-Wunguarded-availability``
>> +warnings for unlisted platforms based on those platform's deployment
>> target.
>> +More than one platform can be listed in ``@available()``:
>> +
>> +.. code-block:: objc
>> +
>> +  void my_fun(NSSomeClass* var) {
>> +if (@available(macOS 10.12, iOS 10, *)) {
>> +  [var fancyNewMethod];
>> +}
>> +  }
>> +
>> +If the caller of ``my_fun()`` already checks that ``my_fun()`` is only
>> called
>> +on 10.12, then add an `availability attribute
>> +`_ to
>> it,
>> +which will also suppress the warning and require that calls to my_fun()
>> are
>> +checked:
>> +
>> +.. code-block:: objc
>> +
>> +  API_AVAILABLE(macos(10.12)) void my_fun(NSSomeClass* var) {
>> +[var fancyNewMethod];  // Now ok.
>> +  }
>> +
>> +``@available()`` is only available in Objective-C code.  To use the
>> feature
>> +in C and C++ code, use the ``__builtin_available()`` spelling instead.
>> +
>> +If existing code uses null checks or ``-respondsToSelector:``, it should
>> +be changed to use ``@available()`` (or ``__builtin_available``) instead.
>> +
>> +``-Wunguarded-availability`` is disabled by default, but
>> +``-Wunguarded-availability-new``, which only 

r308174 - [OPENMP] Codegen for reduction clauses in 'taskloop' directives.

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 06:30:36 2017
New Revision: 308174

URL: http://llvm.org/viewvc/llvm-project?rev=308174=rev
Log:
[OPENMP] Codegen for reduction clauses in 'taskloop' directives.

Adds codegen for taskloop-based directives.

Added:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
cfe/trunk/test/OpenMP/taskloop_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_private_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_private_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=308174=308173=308174=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Jul 17 06:30:36 2017
@@ -643,6 +643,12 @@ enum OpenMPRTLFunction {
   // Call to void __kmpc_doacross_wait(ident_t *loc, kmp_int32 gtid, kmp_int64
   // *vec);
   OMPRTL__kmpc_doacross_wait,
+  // Call to void *__kmpc_task_reduction_init(int gtid, int num_data, void
+  // *data);
+  OMPRTL__kmpc_task_reduction_init,
+  // Call to void *__kmpc_task_reduction_get_th_data(int gtid, void *tg, void
+  // *d);
+  OMPRTL__kmpc_task_reduction_get_th_data,
 
   //
   // Offloading related calls
@@ -766,8 +772,8 @@ static void emitInitWithReductionInitial
 /// \param SrcAddr Address of the original array.
 static void EmitOMPAggregateInit(CodeGenFunction , Address DestAddr,
  QualType Type, const Expr *Init,
+ const OMPDeclareReductionDecl *DRD,
  Address SrcAddr = Address::invalid()) {
-  auto *DRD = getReductionInit(Init);
   // Perform element-by-element initialization.
   QualType ElementTy;
 
@@ -869,19 +875,17 @@ LValue ReductionCodeGen::emitSharedLValu
   return LValue();
 }
 
-void ReductionCodeGen::emitAggregateInitialization(CodeGenFunction ,
-   unsigned N,
-   Address PrivateAddr,
-   LValue SharedLVal) {
+void ReductionCodeGen::emitAggregateInitialization(
+CodeGenFunction , unsigned N, Address PrivateAddr, LValue SharedLVal,
+const OMPDeclareReductionDecl *DRD) {
   // Emit VarDecl with copy init for arrays.
   // Get the address of the original variable captured in current
   // captured region.
   auto *PrivateVD =
   cast(cast(ClausesData[N].Private)->getDecl());
-  auto *DRD = getReductionInit(ClausesData[N].ReductionOp);
   EmitOMPAggregateInit(CGF, PrivateAddr, PrivateVD->getType(),
DRD ? ClausesData[N].ReductionOp : PrivateVD->getInit(),
-   SharedLVal.getAddress());
+   DRD, SharedLVal.getAddress());
 }
 
 ReductionCodeGen::ReductionCodeGen(ArrayRef Shareds,
@@ -890,6 +894,7 @@ ReductionCodeGen::ReductionCodeGen(Array
   ClausesData.reserve(Shareds.size());
   SharedAddresses.reserve(Shareds.size());
   Sizes.reserve(Shareds.size());
+  BaseDecls.reserve(Shareds.size());
   auto IPriv = Privates.begin();
   auto IRed = ReductionOps.begin();
   for (const auto *Ref : Shareds) {
@@ -912,20 +917,30 @@ void ReductionCodeGen::emitAggregateType
   QualType PrivateType = PrivateVD->getType();
   bool AsArraySection = isa(ClausesData[N].Ref);
   if (!AsArraySection && !PrivateType->isVariablyModifiedType()) {
-Sizes.emplace_back(nullptr);
+Sizes.emplace_back(
+CGF.getTypeSize(
+SharedAddresses[N].first.getType().getNonReferenceType()),
+nullptr);
 return;
   }
   llvm::Value *Size;
+  llvm::Value *SizeInChars;
+  llvm::Type *ElemType =
+  cast(SharedAddresses[N].first.getPointer()->getType())
+  ->getElementType();
+  auto *ElemSizeOf = llvm::ConstantExpr::getSizeOf(ElemType);
   if (AsArraySection) {
 Size = CGF.Builder.CreatePtrDiff(SharedAddresses[N].second.getPointer(),
  SharedAddresses[N].first.getPointer());
 Size = CGF.Builder.CreateNUWAdd(
 Size, llvm::ConstantInt::get(Size->getType(), /*V=*/1));
+SizeInChars = CGF.Builder.CreateNUWMul(Size, ElemSizeOf);
   } else {
-Size = CGF.getTypeSize(
+SizeInChars = CGF.getTypeSize(
 

[PATCH] D35012: [refactor] Add the AST source selection component

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

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D35012



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-17 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added a project: clang.
Herald added subscribers: arichardson, javed.absar.

This patch adds support for the `long_call`, `far`, and `near` attributes for 
MIPS targets. The `long_call` and `far` attributes are synonyms. All these 
attributes override `-mlong-calls` / `-mno-long-calls` command line options for 
particular function.

  

The main non-trivial part is the change in 
`CodeGenModule::ConstructAttributeList` routine. It is not enough to configure 
attributes in `MIPSTargetCodeGenInfo::setTargetAttributes` because this method 
applied to the function definitions only while we need to configure the 
attributes for function declarations as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/long-call-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-long-call.c

Index: test/Sema/attr-long-call.c
===
--- /dev/null
+++ test/Sema/attr-long-call.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
+
+__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
+
+__attribute((long_call)) void foo4();
+__attribute((far)) void foo5();
+__attribute((near)) void foo6();
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 62 attributes:
+// CHECK: #pragma clang attribute supports 63 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
+// CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: test/CodeGen/long-call-attr.c
===
--- /dev/null
+++ test/CodeGen/long-call-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((long_call)) foo1 (void);
+
+void __attribute__((far)) foo2 (void) {}
+
+// CHECK: define void @foo2() [[FAR:#[0-9]+]]
+
+void __attribute__((near)) foo3 (void) { foo1(); }
+
+// CHECK: define void @foo3() [[NEAR:#[0-9]+]]
+// CHECK: call void @foo1() [[LONGCALL:#[0-9]+]]
+
+// CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+
+// CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[NEAR]] = { {{.*}} "near-call" {{.*}} }
+// CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[LONGCALL]] = { "long-call" }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5950,6 +5950,9 @@
   case AttributeList::AT_NoMicroMips:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_MipsLongCall:
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
 handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6619,6 +6619,13 @@
 else if (FD->hasAttr())
   Fn->addFnAttr("nomicromips");
 
+if (const auto *LongCallAttr = FD->getAttr()) {
+  if (LongCallAttr->longCall())
+Fn->addFnAttr("long-call");
+  else if (LongCallAttr->nearCall())
+Fn->addFnAttr("near-call");
+}
+
 const MipsInterruptAttr *Attr = FD->getAttr();
 

[PATCH] D35000: [OpenCL] Added extended tests on metadata generation for half data type and arrays.

2017-07-17 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 106851.

https://reviews.llvm.org/D35000

Files:
  test/CodeGenOpenCL/kernel-arg-info.cl


Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -1,10 +1,24 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
spir-unknown-unknown | FileCheck %s
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
 
-kernel void foo(__global int * restrict X, const int Y, 
-volatile int anotherArg, __constant float * restrict Z,
-__global volatile int * V, __global const int * C) {
-  *X = Y + anotherArg;
+kernel void foo(global int * globalintp, global int * restrict 
globalintrestrictp,
+global const int * globalconstintp,
+global const int * restrict globalconstintrestrictp,
+constant int * constantintp, constant int * restrict 
constantintrestrictp,
+global const volatile int * globalconstvolatileintp,
+global const volatile int * restrict 
globalconstvolatileintrestrictp,
+global volatile int * globalvolatileintp,
+global volatile int * restrict globalvolatileintrestrictp,
+local int * localintp, local int * restrict localintrestrictp,
+local const int * localconstintp,
+local const int * restrict localconstintrestrictp,
+local const volatile int * localconstvolatileintp,
+local const volatile int * restrict 
localconstvolatileintrestrictp,
+local volatile int * localvolatileintp,
+local volatile int * restrict localvolatileintrestrictp,
+int X, const int constint, const volatile int constvolatileint,
+volatile int volatileint) {
+  *globalintrestrictp = constint + volatileint;
 }
 // CHECK: define spir_kernel void @foo{{[^!]+}}
 // CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]]
@@ -61,11 +75,15 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[MD54:[0-9]+]]
 
-// CHECK: ![[MD11]] = !{i32 1, i32 0, i32 0, i32 2, i32 1, i32 1}
-// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none"}
-// CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*", !"int*", !"int*"}
-// CHECK: ![[MD14]] = !{!"restrict", !"", !"", !"restrict const", !"volatile", 
!"const"}
-// ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z", !"V", !"C"}
+typedef char char16 __attribute__((ext_vector_type(16)));
+__kernel void foo6(__global char16 arg[]) {}
+// CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+
+// CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 
1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, 
i32 0, i32 0, i32 0}
+// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", 
!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
+// CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", 
!"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
+// CHECK: ![[MD14]] = !{!"", !"restrict", !"const", !"restrict const", 
!"const", !"restrict const", !"const volatile", !"restrict const volatile", 
!"volatile", !"restrict volatile", !"", !"restrict", !"const", !"restrict 
const", !"const volatile", !"restrict const volatile", !"volatile", !"restrict 
volatile", !"", !"", !"", !""}
+// ARGINFO: ![[MD15]] = !{!"globalintp", !"globalintrestrictp", 
!"globalconstintp", !"globalconstintrestrictp", !"constantintp", 
!"constantintrestrictp", !"globalconstvolatileintp", 
!"globalconstvolatileintrestrictp", !"globalvolatileintp", 
!"globalvolatileintrestrictp", !"localintp", !"localintrestrictp", 
!"localconstintp", !"localconstintrestrictp", !"localconstvolatileintp", 
!"localconstvolatileintrestrictp", !"localvolatileintp", 
!"localvolatileintrestrictp", !"X", !"constint", !"constvolatileint", 
!"volatileint"}
 // CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1, i32 1}
 // CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only", 
!"read_write"}
 // CHECK: ![[MD23]] = !{!"image1d_t", !"image2d_t", !"image2d_array_t", 
!"image1d_t"}
@@ -86,4 +104,5 @@
 // CHECK: ![[MD52]] = !{!"myImage", !"image1d_t"}
 // CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
+// CHECK: ![[MD61]] = !{!"char16*"}
 


Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -1,10 +1,24 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 

[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-17 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: include/clang/Tooling/Refactoring/ASTSelection.h:30
+  /// inside of its source range.
+  ContainsSelectionPoint,
+

It's unclear what a selection point is. I'd have expected this to mean 
"overlaps" when first reading it.



Comment at: include/clang/Tooling/Refactoring/ASTSelection.h:68-74
+/// Traverses the given ASTContext and creates a tree of selected AST nodes.
+///
+/// \returns None if no nodes are selected in the AST, or a selected AST node
+/// that corresponds to the TranslationUnitDecl otherwise.
+Optional findSelectedASTNodes(const ASTContext ,
+   SourceLocation Location,
+   SourceRange SelectionRange);

Any reason not to do multiple ranges?

Also, it's not clear from reading the description here why we need the Location.



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:100
+  SelectionStack.back().Children.push_back(std::move(Node));
+return true;
+  }

Why do we always stop traversal?



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:103
+
+  void TraverseDeclInPrevious(Decl *D) {
+assert(!SelectionStack.back().Children.empty() &&

A short comment explaining when this happens would help understand this.



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:164
+  unsigned NumMatches = 0;
+  for (Decl *D : Context.getTranslationUnitDecl()->decls()) {
+if (ObjCImplEndLoc.isValid() &&

Why don't we do this as part of TraverseDecl() in the visitor?



Comment at: lib/Tooling/Refactoring/SourceLocationUtils.h:1
+//===--- SourceLocationUtils.h - Source location helper functions 
-===//
+//

I'm somewhat opposed to files having "utils" in the name, as they tend to 
accumulate too much stuff.
Can we implement those in SourceLocation and SourceManager respectively?


Repository:
  rL LLVM

https://reviews.llvm.org/D35012



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


[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

2017-07-17 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added a comment.

In https://reviews.llvm.org/D32411#799878, @mclow.lists wrote:

> @smeenai wrote:
>
> > This is kinda ugly, but I can't think of a better way to do it. I'm fine 
> > with this, but given that it's a pretty invasive change, I'm not 
> > comfortable accepting. You may wanna ping @EricWF and @mclow.lists directly.
>
> I'll be meeting with the MS compiler engineers next week; I'll see when/if 
> they plan on implemementing `include_next`.


How was a meeting in Toronto? Did they say anything about `#include_next`?


https://reviews.llvm.org/D32411



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


[PATCH] D35465: [clang] Remove redundant check-prefix=CHECK from tests. NFC.

2017-07-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Looks ok to me, at least for the one file that I wrote.


https://reviews.llvm.org/D35465



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


[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2017-07-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: include/type_traits:4740
 
+#if _LIBCPP_STD_VER > 14
+enum class endian

(Apologies for double commenting, did not notice that it was in phab until 
after replying)

I'm probably wrong, but if this is a C++2a proposal, shouldn't this
```#if _LIBCPP_STD_VER > 14```
be
```#if _LIBCPP_STD_VER > 17```
?


https://reviews.llvm.org/D35472



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


[PATCH] D35379: Add documentation for @available

2017-07-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: docs/LanguageExtensions.rst:1347
+
+In rare cases, the availability annotation on an API might be overly
+conservative.  For example, ``[NSProcessInfo processInfo]`` secretly responds 
to

thakis wrote:
> arphaman wrote:
> > We don't want to encourage usage of undocumented/private APIs before they 
> > are officially made public for a number of reasons. Can you please remove 
> > or rewrite this paragraph (ideally removing/replacing the specific example)?
> I removed it from this patch, but this is something that's necessary every 
> now and then. If there's no guidance on this, chances are people will come up 
> with worse hacks :-) So I think having some documentation on this is a good 
> thing. Once this is in, I'll send out a follow-up and we can iterate on this 
> paragraph there (or decide to omit it and let each project decide on what to 
> do here.)
Ok, sure.


https://reviews.llvm.org/D35379



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


[PATCH] D35483: clang-format: fix block OpeningLineIndex around preprocessor

2017-07-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Herald added a subscriber: klimek.

The current code would return an incorrect value when a preprocessor
directive is present immediately after the opening brace: this causes
the nanespace end comment fixer to break in some places, for exemple it
would not add the comment in this case:

  namespace a {
  #define FOO
  }

Fixing the computation is simple enough, but it was breaking a feature,
as it would cause comments to be added also when the namespace
declaration was dependant on conditional compilation.

To fix this, a hash of the current preprocessor stack/branches is
computed at the beginning of parseBlock(), so that we explicitely do not
store the OpeningLineIndex when the beginning and end of the block are
not in the same preprocessor conditions.

Tthe hash is computed based on the line, but this could propbably be
improved by using the actual condition, so that clang-format would be
able to match multiple identical #ifdef blocks.


https://reviews.llvm.org/D35483

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -509,6 +509,51 @@
 "}\n"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, AddEndCommentForNamespacesAroundMacros) {
+  EXPECT_EQ("namespace A {\n"
+"#if 0\n"
+"int i;\n"
+"#endif\n"
+"}// namespace A",
+fixNamespaceEndComments("namespace A {\n"
+"#if 0\n"
+"int i;\n"
+"#endif\n"
+"}"));
+  EXPECT_EQ("#if 0\n"
+"#endif\n"
+"namespace A {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A",
+fixNamespaceEndComments("#if 0\n"
+"#endif\n"
+"namespace A {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ("namespace A {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A\n"
+"#if 0\n"
+"#endif",
+fixNamespaceEndComments("namespace A {\n"
+"int i;\n"
+"int j;\n"
+"}\n"
+"#if 0\n"
+"#endif"));
+  EXPECT_EQ("namespace A {\n"
+"#define FOO\n"
+"int i;\n"
+"}// namespace A",
+fixNamespaceEndComments("namespace A {\n"
+"#define FOO\n"
+"int i;\n"
+"}"));
+}
+
 TEST_F(NamespaceEndCommentsFixerTest,
DoesNotAddEndCommentForNamespacesInMacroDeclarations) {
   EXPECT_EQ("#ifdef 1\n"
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -155,6 +155,7 @@
   void conditionalCompilationEnd();
 
   bool isOnNewLine(const FormatToken );
+  size_t computePPHash() const;
 
   // FIXME: We are constantly running into bugs where Line.Level is incorrectly
   // subtracted from beyond 0. Introduce a method to subtract from Line.Level
@@ -174,7 +175,7 @@
 
   // Preprocessor directives are parsed out-of-order from other unwrapped lines.
   // Thus, we need to keep a list of preprocessor directives to be reported
-  // after an unwarpped line that has been started was finished.
+  // after an unwrapped line that has been started was finished.
   SmallVector PreprocessorDirectives;
 
   // New unwrapped lines are added via CurrentLines.
@@ -207,8 +208,15 @@
 PP_Unreachable  // #if 0 or a conditional preprocessor block inside #if 0
   };
 
+  struct PPBranch {
+PPBranch(PPBranchKind Kind, size_t Line) : Kind(Kind), Line(Line) {}
+bool operator==(PPBranchKind Kind) const { return Kind == this->Kind; }
+PPBranchKind Kind;
+size_t Line;
+  };
+
   // Keeps a stack of currently active preprocessor branching directives.
-  SmallVector PPStack;
+  SmallVector PPStack;
 
   // The \c UnwrappedLineParser re-parses the code for each combination
   // of preprocessor branches that can be taken.
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -452,23 +452,43 @@
   FormatTok = 

Re: clang-format: Fix deref treated as binary op in throw

2017-07-17 Thread Erik Uhlmann via cfe-commits
I don’t have commit access, so I’d need you to check it in. Thanks for your 
help!

From: Manuel Klimek 
Date: Monday, July 17, 2017 at 03:31
To: Erik Uhlmann , "cfe-commits@lists.llvm.org" 

Subject: Re: clang-format: Fix deref treated as binary op in throw

LG, thanks for the patch. For next time, it helps to use phabricator to make 
people catch patches faster :)

Do you have commit access or do you need me to check it in?

On Thu, Jul 6, 2017 at 6:53 PM Erik Uhlmann via cfe-commits 
> wrote:
When dereferencing a pointer in a throw statement, clang-format assigns 
TT_BinaryOperator to the star token, so it gets formatted as:

throw * x;

With this change the above becomes

throw *x;

Bug tracker: 
https://bugs.llvm.org/show_bug.cgi?id=33665

Attached is a patch containing the fix.

___
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] r308181 - [clang-tidy] Add modernize-use-bool-literals.IgnoreMacros option

2017-07-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jul 17 07:43:06 2017
New Revision: 308181

URL: http://llvm.org/viewvc/llvm-project?rev=308181=rev
Log:
[clang-tidy] Add modernize-use-bool-literals.IgnoreMacros option

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp
  - copied, changed from r308085, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp?rev=308181=308180=308181=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp Mon 
Jul 17 07:43:06 2017
@@ -18,6 +18,11 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
+UseBoolLiteralsCheck::UseBoolLiteralsCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
+
 void UseBoolLiteralsCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -52,11 +57,16 @@ void UseBoolLiteralsCheck::check(const M
 
   const Expr *Expression = Cast ? Cast : Literal;
 
+  bool InMacro = Expression->getLocStart().isMacroID();
+
+  if (InMacro && IgnoreMacros)
+return;
+
   auto Diag =
   diag(Expression->getExprLoc(),
"converting integer literal to bool, use bool literal instead");
 
-  if (!Expression->getLocStart().isMacroID())
+  if (!InMacro)
 Diag << FixItHint::CreateReplacement(
 Expression->getSourceRange(), LiteralBooleanValue ? "true" : "false");
 }

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.h?rev=308181=308180=308181=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.h Mon Jul 
17 07:43:06 2017
@@ -22,10 +22,12 @@ namespace modernize {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
 class UseBoolLiteralsCheck : public ClangTidyCheck {
 public:
-  UseBoolLiteralsCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  UseBoolLiteralsCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize

Copied: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp
 (from r308085, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp=clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp=308085=308181=308181=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp
 Mon Jul 17 07:43:06 2017
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy %s modernize-use-bool-literals %t
+// RUN: %check_clang_tidy %s modernize-use-bool-literals %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-use-bool-literals.IgnoreMacros, \
+// RUN:   value: 1}]}" \
+// RUN:   -- -std=c++11
 
 bool IntToTrue = 1;
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: converting integer literal to 
bool, use bool literal instead [modernize-use-bool-literals]
@@ -28,7 +32,6 @@ bool ExplicitStaticIntToFalse = static_c
 // CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
 
 bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
 
 #define FALSE_MACRO bool(0)
@@ -37,7 +40,6 @@ bool MacroIntToTrue = TRUE_MACRO;
 bool TrueBool = true; // OK
 
 bool FalseBool = bool(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool FalseBool = 

[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2017-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It'd look good in clang-tidy, but if Daniel is interested in having this 
feature in the analyzer (and picked by clang-tidy from there), i wouldn't mind.

I wonder how noisy this check is - did you test it on large codebases? Because 
these functions are popular, and in many cases it'd be fine to use insecure 
functions, i wonder if it's worth it to have this check on by default. Like, if 
it's relatively quiet - it's fine, but if it'd constitute 90% of the analyzer's 
warnings on popular projects, that'd probably not be fine.




Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:597-598
+
+  if(!BR.getContext().getLangOpts().C11)
+return;
+

Note that you cannot easily figure out if the code is intended to get compiled 
only under C11 and above - maybe it's accidentally compiled under C11 for this 
user, but is otherwise intended to keep working under older standards.



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:632
+
+void WalkAST::checkUnsafeBufferHandling(const CallExpr *CE, const FunctionDecl 
*FD) { //TODO:TESTS
+  if (!filter.check_UnsafeBufferHandling)

Because it also checks deprecated buffer handling, i'd rename this function to 
`checkDeprecatedOrUnsafeBufferHandling`.



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:670-675
+  auto FormatString =
+dyn_cast(CE->getArg(ArgIndex)->IgnoreParenImpCasts());
+  if(FormatString &&
+ FormatString->getString().find("%s") == StringRef::npos &&
+ FormatString->getString().find("%[") == StringRef::npos)
+return;

You'd probably also want to quit early if the format string is not a literal.


Repository:
  rL LLVM

https://reviews.llvm.org/D35068



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


[PATCH] D35438: CodeGen: Ensure there is basic block when performing address space cast

2017-07-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 106879.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Insert addr space cast in the same basic block as alloca.


https://reviews.llvm.org/D35438

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/amdgcn-automatic-variable.cpp


Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -13,39 +13,39 @@
 // CHECK-LABEL: define void @_Z5func2v()
 void func2(void) {
   // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x 
i32]*
   // CHECK: %lp1 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: %lp2 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
 
-  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: store i32 1, i32* %[[r0]]
   int lv1;
   lv1 = 1;
-  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: store i32 2, i32* %[[r1]]
   int lv2 = 2;
 
-  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x 
i32]*
   // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x 
i32]* %[[r2]], i64 0, i64 0
   // CHECK: store i32 3, i32* %[[arrayidx]], align 4
   int la[100];
   la[0] = 3;
 
-  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: store i32* %[[r0]], i32** %[[r3]], align 8
   int *lp1 = 
 
-  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x 
i32]* %[[r2]], i32 0, i32 0
   // CHECK: store i32* %[[arraydecay]], i32** %[[r4]], align 8
   int *lp2 = la;
 
   // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
   func1();
 
-  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
   // CHECK: store i32 4, i32* %[[r5]]
   // CHECK: store i32 4, i32* %[[r0]]
   const int lvc = 4;
@@ -81,4 +81,25 @@
   func1();
 }
 
+// CHECK-LABEL: define void @_Z5func5v
+void func5() {
+  return;
+  int x = 0;
+}
+
+// CHECK-LABEL: define void @_Z5func6v
+void func6() {
+  return;
+  int x;
+}
+
+// CHECK-LABEL: define void @_Z5func7v
+extern void use(int *);
+void func7() {
+  goto later;
+  int x;
+later:
+  use();
+}
+
 // CHECK-NOT: !opencl.ocl.version
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -73,9 +73,14 @@
   // cast alloca to the default address space when necessary.
   if (CastToDefaultAddrSpace && getASTAllocaAddressSpace() != LangAS::Default) 
{
 auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
+EnsureInsertPoint();
+auto *CurBB = Builder.GetInsertBlock();
+auto CurPos = Builder.GetInsertPoint();
+Builder.SetInsertPoint(AllocaInsertPt);
 V = getTargetHooks().performAddrSpaceCast(
 *this, V, getASTAllocaAddressSpace(), LangAS::Default,
 Ty->getPointerTo(DestAddrSpace), /*non-null*/ true);
+Builder.SetInsertPoint(CurBB, CurPos);
   }
 
   return Address(V, Align);


Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -13,39 +13,39 @@
 // CHECK-LABEL: define void @_Z5func2v()
 void func2(void) {
   // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]*
   // CHECK: %lp1 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: %lp2 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
 
-  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: store i32 1, i32* %[[r0]]
   int lv1;
   lv1 = 1;
-  // CHECK: %[[r1:.*]] = addrspacecast i32 

[PATCH] D35000: [OpenCL] Added extended tests on metadata generation for half data type and arrays.

2017-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D35000



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


[PATCH] D35484: Add a warning for missing '#pragma pack (pop)' and suspicious '#pragma pack' uses when including files

2017-07-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds a new `-Wpragma-pack` warning. It warns in the following cases:

- When a translation unit is missing terminating `#pragma pack (pop)` 
directives.
- When entering an included file if the current alignment value as determined 
by '#pragma pack' directives is different from the default alignment value.
- When leaving an included file that changed the state of the current alignment 
value.

The change in the parser is required to avoid a missing diagnostic in the 
following scenario:

  #pragma pack (push, 1)
  #include “foo.h” // Without the change, the diagnostic for the 2nd case won’t 
be emitted since include will get processed by the Sema before the pragma


Repository:
  rL LLVM

https://reviews.llvm.org/D35484

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTReader.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/pragma-pack.c
  test/PCH/suspicious-pragma-pack.c
  test/Parser/pragma-options.c
  test/Parser/pragma-options.cpp
  test/Parser/pragma-pack.c
  test/Sema/Inputs/pragma-pack1.h
  test/Sema/Inputs/pragma-pack2.h
  test/Sema/pragma-pack.c
  test/Sema/suspicious-pragma-pack.c
  test/SemaObjC/Inputs/empty.h
  test/SemaObjC/suspicious-pragma-pack.m

Index: test/SemaObjC/suspicious-pragma-pack.m
===
--- /dev/null
+++ test/SemaObjC/suspicious-pragma-pack.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I%S/Inputs -verify %s
+
+#pragma pack (push, 1) // expected-note {{previous '#pragma pack' directive that modifies alignment is here}}
+#import "empty.h" // expected-warning {{non-default #pragma pack value might change the alignment of records in the included file}}
+
+#pragma pack (pop)
Index: test/SemaObjC/Inputs/empty.h
===
--- /dev/null
+++ test/SemaObjC/Inputs/empty.h
@@ -0,0 +1 @@
+// empty
Index: test/Sema/suspicious-pragma-pack.c
===
--- /dev/null
+++ test/Sema/suspicious-pragma-pack.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DSAFE -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DSAFE -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DPUSH_SET_HERE -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DRESET_HERE -DSAFE -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DSET_FIRST_HEADER -DWARN_MODIFIED_HEADER -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DRESET_HERE -DSET_FIRST_HEADER -DWARN_MODIFIED_HEADER -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DPUSH_SET_HERE -DSET_FIRST_HEADER -DWARN_MODIFIED_HEADER -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DPUSH_SET_HERE -DSET_SECOND_HEADER -DWARN_MODIFIED_HEADER -verify %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_HERE -DPUSH_SET_HERE -DSET_FIRST_HEADER -DSET_SECOND_HEADER -DWARN_MODIFIED_HEADER -verify %s
+
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -I %S/Inputs -DPUSH_POP_FIRST_HEADER -DSAFE -verify %s
+
+
+#ifdef SAFE
+// expected-no-diagnostics
+#endif
+
+#ifdef PUSH_HERE
+#pragma pack (push)
+#endif
+
+#ifdef PUSH_SET_HERE
+#pragma pack (push, 4) // expected-note {{previous '#pragma pack' directive that modifies alignment is here}}
+// expected-warning@+8 {{non-default #pragma pack value might change the alignment of records in the included file}}
+#endif
+
+#ifdef RESET_HERE
+#pragma pack (4)
+#pragma pack () // no warning after reset as the value is default.
+#endif
+
+#include "pragma-pack1.h"
+
+#ifdef WARN_MODIFIED_HEADER
+// expected-warning@-3 {{the current #pragma pack aligment value is modified in the included file}}
+#endif
+
+#ifdef PUSH_SET_HERE
+#pragma pack (pop)
+#endif
+
+#ifdef PUSH_HERE
+#pragma pack (pop)
+#endif
Index: test/Sema/pragma-pack.c
===
--- test/Sema/pragma-pack.c
+++ test/Sema/pragma-pack.c
@@ -25,3 +25,8 @@
 #pragma pack(pop, 16)
 /* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
 
+
+// Warn about unbalanced pushes.
+#pragma pack (push,4) // expected-warning {{unterminated '#pragma pack (push, ...)' at end of file}}
+#pragma pack (push)   // expected-warning {{unterminated '#pragma pack (push, ...)' at end of file}}
+#pragma pack ()
Index: test/Sema/Inputs/pragma-pack2.h

[PATCH] D35465: [clang] Remove redundant check-prefix=CHECK from tests. NFC.

2017-07-17 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier accepted this revision.
mcrosier added a comment.

LGTM.


https://reviews.llvm.org/D35465



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


r308182 - [OPENMP] Further fixes of the reduction codegen tests

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 07:47:59 2017
New Revision: 308182

URL: http://llvm.org/viewvc/llvm-project?rev=308182=rev
Log:
[OPENMP] Further fixes of the reduction codegen tests

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308182=308181=308182=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 07:47:59 
2017
@@ -62,76 +62,76 @@ sum = 0.0;
 // CHECK:[[VLA:%.+]] = alloca float, i64 %
 
 // CHECK:call void @__kmpc_taskgroup(%ident_t*
-// CHECK:[[DOTRD_INPUT_GEP_:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 0
-// CHECK:[[TMP20:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T:%.*]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 0
-// CHECK:[[TMP21:%.*]] = bitcast float* [[SUM]] to i8*
-// CHECK:store i8* [[TMP21]], i8** [[TMP20]],
-// CHECK:[[TMP22:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 1
-// CHECK:store i64 4, i64* [[TMP22]],
-// CHECK:[[TMP23:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 2
-// CHECK:store i8* bitcast (void (i8*)* [[RED_INIT1:@.+]] to i8*), i8** 
[[TMP23]],
-// CHECK:[[TMP24:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 3
-// CHECK:store i8* null, i8** [[TMP24]],
-// CHECK:[[TMP25:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 4
-// CHECK:store i8* bitcast (void (i8*, i8*)* [[RED_COMB1:@.+]] to i8*), 
i8** [[TMP25]],
-// CHECK:[[TMP26:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 5
-// CHECK:[[TMP27:%.*]] = bitcast i32* [[TMP26]] to i8*
-// CHECK:call void @llvm.memset.p0i8.i64(i8* [[TMP27]], i8 0, i64 4, i32 
8, i1 false)
-// CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 1
-// CHECK:[[TMP28:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 0
-// CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 0
-// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
-// CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
-// CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
-// CHECK:store i8* [[TMP31]], i8** [[TMP28]],
-// CHECK:[[TMP32:%.*]] = ptrtoint %struct.S* [[ARRAYIDX6]] to i64
-// CHECK:[[TMP33:%.*]] = ptrtoint %struct.S* [[ARRAYIDX5]] to i64
-// CHECK:[[TMP34:%.*]] = sub i64 [[TMP32]], [[TMP33]]
-// CHECK:[[TMP35:%.*]] = sdiv exact i64 [[TMP34]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
-// CHECK:[[TMP36:%.*]] = add nuw i64 [[TMP35]], 1
-// CHECK:[[TMP37:%.*]] = mul nuw i64 [[TMP36]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
-// CHECK:[[TMP38:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 1
-// CHECK:store i64 [[TMP37]], i64* [[TMP38]],
-// CHECK:[[TMP39:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 2
-// CHECK:store i8* bitcast (void (i8*)* [[RED_INIT2:@.+]] to i8*), i8** 
[[TMP39]],
-// CHECK:[[TMP40:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 3
-// CHECK:store i8* bitcast (void (i8*)* [[RED_FINI2:@.+]] to i8*), i8** 
[[TMP40]],
-// CHECK:[[TMP41:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 4
-// CHECK:store i8* bitcast (void (i8*, i8*)* [[RED_COMB2:@.+]] to i8*), 
i8** [[TMP41]],
-// CHECK:[[TMP42:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 5
-// CHECK:store i32 1, i32* [[TMP42]],
-// CHECK:[[DOTRD_INPUT_GEP_7:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x 

[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think we'd rather delay the unsigned difference feature (as far as i 
understand, you don't rely on it in the iterator checker), than introduce the 
artificial cast to signed which may have unexpected consequences, because 
that's not how unsigned difference normally behaves. I'd think a bit more on 
this as well.

In https://reviews.llvm.org/D35109#806466, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D35109#806156, @NoQ wrote:
>
> > I think you might also need to convert `APSInt`s to an appropriate type, as 
> > done above. Type of right-hand-side `APSInt`s do not necessarily coincide 
> > with the type of the left-hand-side symbol or of the whole expression. 
> > `APSInt` operations crash when signedness doesn't match (and in a few other 
> > cases).
>
>
> Could you please help me by constructing an example for this scenario? I 
> tried multiple options, but I always failed since I check the type of the two 
> sides, as you proposed. So I need an example where `typeof(A+n) == 
> typeof(B+m)` but `typeof(n) != typeof(m)`.


Hmm, you are right, there are only problems with casts of symbols, not of 
`APSInt`s; type of the latter is always equal to the type of the whole 
expression. So when two `SymIntExpr`s have the same type `T`, types of their 
right-hand sides are automatically equal to `T` as well. Please add this as a 
comment then :)

The rest looks good to me now.


https://reviews.llvm.org/D35109



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


[PATCH] D35438: CodeGen: Ensure there is basic block when performing address space cast

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

In https://reviews.llvm.org/D35438#810385, @rjmccall wrote:

> Oh, of course.  Sadly, in C/C++ the declaration point of a variable does not 
> necessarily dominate all uses of the variable, so you need to emit the cast 
> immediately after the alloca.  Just temporarily move CGF.Builder to that 
> point; hopefully we can assume that this function will never try to add 
> control flow.
>
> Test case:
>
>   extern void use(int*);
>   void foo() {
> goto later;
> int x;
> later:
> use();
>   }


Right. performAddressSpaceCast could be used in general cases. We only need to 
change insert position when emitting automatic or temporary variables. I will 
move this logic to CodeGenFunction::CreateTempAlloca.


https://reviews.llvm.org/D35438



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


r308178 - [OPENMP] Further test fixes.

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 07:22:34 2017
New Revision: 308178

URL: http://llvm.org/viewvc/llvm-project?rev=308178=rev
Log:
[OPENMP] Further test fixes.

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308178=308177=308178=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 07:22:34 
2017
@@ -37,26 +37,26 @@ sum = 0.0;
 }
 
 // CHECK-LABEL: @main(
-// CHECK:[[RETVAL:%.*]] = alloca i32, align 4
-// CHECK:[[ARGC_ADDR:%.*]] = alloca i32, align 4
-// CHECK:[[ARGV_ADDR:%.*]] = alloca i8**, align 8
-// CHECK:[[I:%.*]] = alloca i32, align 4
-// CHECK:[[N:%.*]] = alloca i32, align 4
-// CHECK:[[A:%.*]] = alloca [100 x float], align 4
-// CHECK:[[B:%.*]] = alloca [100 x float], align 4
-// CHECK:[[SUM:%.*]] = alloca float, align 4
-// CHECK:[[SAVED_STACK:%.*]] = alloca i8*, align 8
-// CHECK:[[C:%.*]] = alloca [100 x %struct.S], align 4
-// CHECK:[[D:%.*]] = alloca float*, align 8
-// CHECK:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 8
+// CHECK:[[RETVAL:%.*]] = alloca i32,
+// CHECK:[[ARGC_ADDR:%.*]] = alloca i32,
+// CHECK:[[ARGV_ADDR:%.*]] = alloca i8**,
+// CHECK:[[I:%.*]] = alloca i32,
+// CHECK:[[N:%.*]] = alloca i32,
+// CHECK:[[A:%.*]] = alloca [100 x float],
+// CHECK:[[B:%.*]] = alloca [100 x float],
+// CHECK:[[SUM:%.*]] = alloca float,
+// CHECK:[[SAVED_STACK:%.*]] = alloca i8*,
+// CHECK:[[C:%.*]] = alloca [100 x %struct.S],
+// CHECK:[[D:%.*]] = alloca float*,
+// CHECK:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]],
 // CHECK:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%ident_t*
-// CHECK:[[DOTRD_INPUT_:%.*]] = alloca [4 x %struct.kmp_task_red_input_t], 
align 8
-// CHECK:[[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
-// CHECK:[[DOTCAPTURE_EXPR_9:%.*]] = alloca i32, align 4
-// CHECK:store i32 0, i32* [[RETVAL]], align 4
-// CHECK:store i32 [[ARGC:%.*]], i32* [[ARGC_ADDR]], align 4
-// CHECK:store i8** [[ARGV:%.*]], i8*** [[ARGV_ADDR]], align 8
-// CHECK:[[TMP1:%.*]] = load i32, i32* [[ARGC_ADDR]], align 4
+// CHECK:[[DOTRD_INPUT_:%.*]] = alloca [4 x %struct.kmp_task_red_input_t],
+// CHECK:[[DOTCAPTURE_EXPR_:%.*]] = alloca i32,
+// CHECK:[[DOTCAPTURE_EXPR_9:%.*]] = alloca i32,
+// CHECK:store i32 0, i32* [[RETVAL]],
+// CHECK:store i32 [[ARGC:%.*]], i32* [[ARGC_ADDR]],
+// CHECK:store i8** [[ARGV:%.*]], i8*** [[ARGV_ADDR]],
+// CHECK:[[TMP1:%.*]] = load i32, i32* [[ARGC_ADDR]],
 // CHECK:[[ADD:%.*]] = add nsw i32 [[TMP1]], 100
 // CHECK:[[TMP2:%.*]] = zext i32 [[ADD]] to i64
 // CHECK:[[VLA:%.+]] = alloca float, i64 %
@@ -65,15 +65,15 @@ sum = 0.0;
 // CHECK:[[DOTRD_INPUT_GEP_:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 0
 // CHECK:[[TMP20:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T:%.*]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 0
 // CHECK:[[TMP21:%.*]] = bitcast float* [[SUM]] to i8*
-// CHECK:store i8* [[TMP21]], i8** [[TMP20]], align 8
+// CHECK:store i8* [[TMP21]], i8** [[TMP20]],
 // CHECK:[[TMP22:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 1
-// CHECK:store i64 4, i64* [[TMP22]], align 8
+// CHECK:store i64 4, i64* [[TMP22]],
 // CHECK:[[TMP23:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 2
-// CHECK:store i8* bitcast (void (i8*)* [[RED_INIT1:@.+]] to i8*), i8** 
[[TMP23]], align 8
+// CHECK:store i8* bitcast (void (i8*)* [[RED_INIT1:@.+]] to i8*), i8** 
[[TMP23]],
 // CHECK:[[TMP24:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 3
-// CHECK:store i8* null, i8** [[TMP24]], align 8
+// CHECK:store i8* null, i8** [[TMP24]],
 // CHECK:[[TMP25:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 4
-// CHECK:store i8* bitcast (void (i8*, i8*)* [[RED_COMB1:@.+]] to i8*), 
i8** [[TMP25]], align 8
+// CHECK:store i8* bitcast (void (i8*, i8*)* [[RED_COMB1:@.+]] to i8*), 
i8** [[TMP25]],
 // CHECK:[[TMP26:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_]], i32 0, i32 5
 // CHECK:[[TMP27:%.*]] = bitcast i32* [[TMP26]] 

[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2017-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:511
+   SSE->getLHS()->getType()->isSignedIntegerOrEnumerationType() ||
+   SSE->getLHS()->getType()->isPointerType()) {
+  return negV->Negate(BV, F);

baloghadamsoftware wrote:
> NoQ wrote:
> > Pointer types are currently treated as unsigned, so i'm not sure you want 
> > them here.
> For me it seems that pointer differences are still pointer types and they are 
> signed. (The range becomes negative upon negative assumption. From test 
> `ptr-arith.c`:
> 
> ```
> void use_symbols(int *lhs, int *rhs) {
>   clang_analyzer_eval(lhs < rhs); // expected-warning{{UNKNOWN}}
>   if (lhs < rhs)
> return;
>   clang_analyzer_eval(lhs < rhs); // expected-warning{{FALSE}}
> 
>   clang_analyzer_eval(lhs - rhs); // expected-warning{{UNKNOWN}}
>   if ((lhs - rhs) != 5)
> return;
>   clang_analyzer_eval((lhs - rhs) == 5); // expected-warning{{TRUE}}
> }
> ```
> 
> If I put `clang_analyzer_printState()` into the empty line in the middle, I 
> get the following range for the difference: `[-9223372036854775808, 0]`. If I 
> replace `int*` with `unsigned`, this range becomes `[0, 0]`, so `int*` is 
> handled as a signed type here.
Umm, yeah, i was wrong.

*looks closer*

`T` is the type of the difference, right? I don't think i'd expect pointer type 
as the type of the difference.

Could you add test cases for pointers if you intend to support them (and maybe 
for unsigned types)?


https://reviews.llvm.org/D35110



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'd have a look soon.

Is diff 1 the original diff from https://reviews.llvm.org/D28953? It was ok to 
reopen it, but the new revision is also fine.

Regarding 1-bit bools: did you notice https://reviews.llvm.org/D32328 and 
https://reviews.llvm.org/D35041, do they accidentally help?




Comment at: include/clang/AST/Expr.h:3096
+  static bool isCommutativeOp(Opcode Opc) {
+return Opc == BO_Mul || Opc == BO_Add || (Opc >= BO_EQ && Opc == BO_Or);
+  }

There seems to be a typo somewhere around the last comparison.


https://reviews.llvm.org/D35450



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


r308183 - [OPENMP] Fix reduction combiner test

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 07:53:02 2017
New Revision: 308183

URL: http://llvm.org/viewvc/llvm-project?rev=308183=rev
Log:
[OPENMP] Fix reduction combiner test

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308183=308182=308183=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 07:53:02 
2017
@@ -190,7 +190,7 @@ sum = 0.0;
 // CHECK: ret void
 
 // CHECK: define internal void [[RED_COMB1]](i8*, i8*)
-// CHECK: fadd float %6, %7
+// CHECK: fadd float %
 // CHECK: store float %{{.+}}, float* %
 // CHECK: ret void
 

Modified: cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp?rev=308183=308182=308183=diff
==
--- cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp Mon Jul 17 
07:53:02 2017
@@ -190,7 +190,7 @@ sum = 0.0;
 // CHECK: ret void
 
 // CHECK: define internal void [[RED_COMB1]](i8*, i8*)
-// CHECK: fadd float %6, %7
+// CHECK: fadd float %
 // CHECK: store float %{{.+}}, float* %
 // CHECK: ret void
 


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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I've figured out a test case for this:

  template  class A> class B { typedef A A_int; };

The real-world problem comes from ptr_traits.h 
.


https://reviews.llvm.org/D35212



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


r308185 - Fix dereference of pointers in throw statements.

2017-07-17 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Jul 17 08:27:53 2017
New Revision: 308185

URL: http://llvm.org/viewvc/llvm-project?rev=308185=rev
Log:
Fix dereference of pointers in throw statements.

Before:
  throw * x;

After:
  throw *x;

Patch by Erik Uhlmann.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=308185=308184=308185=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul 17 08:27:53 2017
@@ -1383,7 +1383,8 @@ private:
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
-   tok::equal, tok::kw_delete, tok::kw_sizeof) ||
+   tok::equal, tok::kw_delete, tok::kw_sizeof,
+   tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=308185=308184=308185=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul 17 08:27:53 2017
@@ -5350,6 +5350,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyFormat("x = *a(x) = *a(y);", Left);
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
+  verifyFormat("throw *x;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");


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


Re: clang-format: Fix deref treated as binary op in throw

2017-07-17 Thread Manuel Klimek via cfe-commits
Thx. Submitted as r308185.

On Mon, Jul 17, 2017 at 4:28 PM Erik Uhlmann  wrote:

> I don’t have commit access, so I’d need you to check it in. Thanks for
> your help!
>
>
>
> *From: *Manuel Klimek 
> *Date: *Monday, July 17, 2017 at 03:31
> *To: *Erik Uhlmann , "cfe-commits@lists.llvm.org" <
> cfe-commits@lists.llvm.org>
> *Subject: *Re: clang-format: Fix deref treated as binary op in throw
>
>
>
> LG, thanks for the patch. For next time, it helps to use phabricator to
> make people catch patches faster :)
>
>
>
> Do you have commit access or do you need me to check it in?
>
>
>
> On Thu, Jul 6, 2017 at 6:53 PM Erik Uhlmann via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> When dereferencing a pointer in a throw statement, clang-format assigns
> TT_BinaryOperator to the star token, so it gets formatted as:
>
> throw * x;
>
> With this change the above becomes
>
> throw *x;
>
> Bug tracker: https://bugs.llvm.org/show_bug.cgi?id=33665
> 
>
> Attached is a patch containing the fix.
>
> ___
> 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


r308176 - [OPENMP] Rework tests to pacify buildbots.

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 07:06:41 2017
New Revision: 308176

URL: http://llvm.org/viewvc/llvm-project?rev=308176=rev
Log:
[OPENMP] Rework tests to pacify buildbots.

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308176=308175=308176=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 07:06:41 
2017
@@ -80,9 +80,7 @@ sum = 0.0;
 // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 1
 // CHECK:[[TMP28:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 0
 // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 0
-// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
-// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
-// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
+// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
 // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
 // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
 // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8

Modified: cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp?rev=308176=308175=308176=diff
==
--- cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp Mon Jul 17 
07:06:41 2017
@@ -80,9 +80,7 @@ sum = 0.0;
 // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 1
 // CHECK:[[TMP28:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 0
 // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 0
-// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
-// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
-// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
+// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
 // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
 // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
 // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8


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


r308192 - [clang] Remove redundant check-prefix=CHECK from tests. NFC.

2017-07-17 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Mon Jul 17 10:31:44 2017
New Revision: 308192

URL: http://llvm.org/viewvc/llvm-project?rev=308192=rev
Log:
[clang] Remove redundant check-prefix=CHECK from tests. NFC.

Reviewers: t.p.northover, mstorsjo, rsmith, mcrosier

Reviewed By: mstorsjo, mcrosier

Subscribers: mcrosier, javed.absar, cfe-commits

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

Modified:
cfe/trunk/test/CodeGen/aarch64-type-sizes.c
cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp
cfe/trunk/test/Index/complete-available.m
cfe/trunk/test/Misc/ast-dump-decl.c
cfe/trunk/test/Misc/ast-dump-decl.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_if_codegen.cpp
cfe/trunk/test/OpenMP/parallel_if_codegen.cpp

Modified: cfe/trunk/test/CodeGen/aarch64-type-sizes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-type-sizes.c?rev=308192=308191=308192=diff
==
--- cfe/trunk/test/CodeGen/aarch64-type-sizes.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-type-sizes.c Mon Jul 17 10:31:44 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck --check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck %s
 // char by definition has size 1
 
 // CHECK: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"

Modified: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-varargs-ms.c?rev=308192=308191=308192=diff
==
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c Mon Jul 17 10:31:44 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck %s
 
 #include 
 

Modified: cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp?rev=308192=308191=308192=diff
==
--- cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp Mon Jul 17 10:31:44 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - 
-fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - 
-fcxx-exceptions -fexceptions | FileCheck %s
 
 struct A {
   A();

Modified: cfe/trunk/test/Index/complete-available.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-available.m?rev=308192=308191=308192=diff
==
--- cfe/trunk/test/Index/complete-available.m (original)
+++ cfe/trunk/test/Index/complete-available.m Mon Jul 17 10:31:44 2017
@@ -8,8 +8,8 @@ void atAvailable() {
   }
 }
 
-// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck 
-check-prefix=CHECK %s
-// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck 
-check-prefix=CHECK %s
+// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck %s
 // CHECK: {TypedText iOS} (40)
 // CHECK: {TypedText iOSApplicationExtension} (40)
 // CHECK: {TypedText macOS} (40)

Modified: cfe/trunk/test/Misc/ast-dump-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-decl.c?rev=308192=308191=308192=diff
==
--- cfe/trunk/test/Misc/ast-dump-decl.c (original)
+++ cfe/trunk/test/Misc/ast-dump-decl.c Mon Jul 17 10:31:44 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter 
Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter 
Test %s | FileCheck -strict-whitespace %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
-check-prefix CHECK-TU -strict-whitespace %s
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fmodule-name=X -triple x86_64-unknown-unknown 
-fmodule-map-file=%S/Inputs/module.modulemap -ast-dump -ast-dump-filter Test %s 
-DMODULES | FileCheck -check-prefix CHECK -check-prefix CHECK-MODULES 
-strict-whitespace %s
 

Modified: cfe/trunk/test/Misc/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-decl.cpp?rev=308192=308191=308192=diff
==
--- 

[PATCH] D35465: [clang] Remove redundant check-prefix=CHECK from tests. NFC.

2017-07-17 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308192: [clang] Remove redundant check-prefix=CHECK from 
tests. NFC. (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D35465?vs=106821=106901#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35465

Files:
  cfe/trunk/test/CodeGen/aarch64-type-sizes.c
  cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
  cfe/trunk/test/CodeGenCXX/implicit-exception-spec.cpp
  cfe/trunk/test/Index/complete-available.m
  cfe/trunk/test/Misc/ast-dump-decl.c
  cfe/trunk/test/Misc/ast-dump-decl.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  cfe/trunk/test/OpenMP/parallel_if_codegen.cpp


Index: cfe/trunk/test/CodeGen/aarch64-type-sizes.c
===
--- cfe/trunk/test/CodeGen/aarch64-type-sizes.c
+++ cfe/trunk/test/CodeGen/aarch64-type-sizes.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck --check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | 
FileCheck %s
 // char by definition has size 1
 
 // CHECK: target datalayout = 
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
Index: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
===
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck %s
 
 #include 
 
Index: cfe/trunk/test/Index/complete-available.m
===
--- cfe/trunk/test/Index/complete-available.m
+++ cfe/trunk/test/Index/complete-available.m
@@ -8,8 +8,8 @@
   }
 }
 
-// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck 
-check-prefix=CHECK %s
-// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck 
-check-prefix=CHECK %s
+// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck %s
 // CHECK: {TypedText iOS} (40)
 // CHECK: {TypedText iOSApplicationExtension} (40)
 // CHECK: {TypedText macOS} (40)
Index: cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
===
--- cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
+++ cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
%itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
%itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck --check-prefix=CHECK %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
%itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
Index: cfe/trunk/test/OpenMP/distribute_parallel_for_if_codegen.cpp
===
--- cfe/trunk/test/OpenMP/distribute_parallel_for_if_codegen.cpp
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_if_codegen.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix=CHECK %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
Index: cfe/trunk/test/Misc/ast-dump-decl.c
===
--- cfe/trunk/test/Misc/ast-dump-decl.c
+++ cfe/trunk/test/Misc/ast-dump-decl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter 
Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter 
Test %s | FileCheck -strict-whitespace %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
-check-prefix CHECK-TU -strict-whitespace %s
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 

[PATCH] D34955: [Basic] Detect Git submodule version in CMake

2017-07-17 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose accepted this revision.
jordan_rose added a comment.
This revision is now accepted and ready to land.

Whoops, yes, this new version looks good!


https://reviews.llvm.org/D34955



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 106883.
ddcc added a comment.

Fix typo


https://reviews.llvm.org/D35450

Files:
  include/clang/AST/Expr.h
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/analyzer_test.py
  test/Analysis/bitwise-ops.c
  test/Analysis/bool-assignment.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/plist-macros-z3.cpp
  test/Analysis/plist-macros.cpp
  test/Analysis/range_casts.c
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/range_casts.c
===
--- test/Analysis/range_casts.c
+++ test/Analysis/range_casts.c
@@ -67,8 +67,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1 == 0) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1 == 0)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -87,8 +87,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1L == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1L == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -117,8 +117,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1UL == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1UL == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
Index: test/Analysis/plist-macros.cpp
===
--- test/Analysis/plist-macros.cpp
+++ test/Analysis/plist-macros.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=true %s -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
-
+// REQUIRES: !z3
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
@@ -11,13 +11,13 @@
   y++;
   y--;
   mallocmemory
-  y++; 
+  y++;
   y++;
   delete x; // expected-warning {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
 }
 
 void macroIsFirstInFunction(int y) {
-  mallocmemory 
+  mallocmemory
   y++; // expected-warning {{Potential leak of memory pointed to by 'x'}}
 }
 
@@ -39,7 +39,7 @@
   return *p; // expected-warning {{Dereference of null pointer}}
 }
 
-#define macroWithArg(mp) mp==0 
+#define macroWithArg(mp) mp==0
 int macroWithArgInExpression(int *p, int y) {;
   y++;
   if (macroWithArg(p))
@@ -85,6 +85,7 @@
 void test2(int *p) {
   CALL_FN(p);
 }
+
 // CHECK:  diagnostics
 // CHECK-NEXT:  
 // CHECK-NEXT:   
@@ -636,6 +637,69 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line36
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 

[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

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

Looks good to me, other than a nit on indentation and a request for a little 
bit more info in a comment!




Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3394
+  // See if the function has 'rc_ownership_trusted_implementation'
+  // annotate attribute.
+  bool hasTrustedImplementationAnnotation = false;

Can you add a little bit more comment here to describe what the checker will do 
if the function has the attribute? Some like "... if so, we won't inline it."



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3412
+} else {
+if (FD->getDefinition()) {
+  canEval = isTrustedReferenceCountImplementation(FD->getDefinition());

Nit: indentation is off here. It should be two spaces.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@vsk: could you help me turning this into a test case?


https://reviews.llvm.org/D35212



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


[clang-tools-extra] r308191 - [NFC] Update function call names as changed in MacroInfo that should refer to Parameters (as opposed to Arguments).

2017-07-17 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Jul 17 10:20:57 2017
New Revision: 308191

URL: http://llvm.org/viewvc/llvm-project?rev=308191=rev
Log:
[NFC] Update function call names as changed in MacroInfo that should refer to 
Parameters (as opposed to Arguments).

This syncs them up with clang commit r308190

Thanks!

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp?rev=308191=308190=308191=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp Mon Jul 
17 10:20:57 2017
@@ -185,7 +185,7 @@ void MacroParenthesesPPCallbacks::argume
   continue;
 
 // Only interested in macro arguments.
-if (MI->getArgumentNum(Tok.getIdentifierInfo()) < 0)
+if (MI->getParameterNum(Tok.getIdentifierInfo()) < 0)
   continue;
 
 // Argument is surrounded with parentheses/squares/braces/commas.

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp?rev=308191=308190=308191=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp 
Mon Jul 17 10:20:57 2017
@@ -58,8 +58,8 @@ void MacroRepeatedPPCallbacks::MacroExpa
   }) != MI->tokens().end())
 return;
 
-  for (unsigned ArgNo = 0U; ArgNo < MI->getNumArgs(); ++ArgNo) {
-const IdentifierInfo *Arg = *(MI->arg_begin() + ArgNo);
+  for (unsigned ArgNo = 0U; ArgNo < MI->getNumParams(); ++ArgNo) {
+const IdentifierInfo *Arg = *(MI->param_begin() + ArgNo);
 const Token *ResultArgToks = Args->getUnexpArgument(ArgNo);
 
 if (hasSideEffects(ResultArgToks) &&

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=308191=308190=308191=diff
==
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Mon Jul 17 
10:20:57 2017
@@ -407,7 +407,7 @@ static std::string getMacroExpandedStrin
   // Walk over the macro Tokens.
   for (const auto  : MI->tokens()) {
 clang::IdentifierInfo *II = T.getIdentifierInfo();
-int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1);
+int ArgNo = (II && Args ? MI->getParameterNum(II) : -1);
 if (ArgNo == -1) {
   // This isn't an argument, just add it.
   if (II == nullptr)


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


[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2017-07-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/type_traits:4740
 
+#if _LIBCPP_STD_VER > 14
+enum class endian

lebedev.ri wrote:
> (Apologies for double commenting, did not notice that it was in phab until 
> after replying)
> 
> I'm probably wrong, but if this is a C++2a proposal, shouldn't this
> ```#if _LIBCPP_STD_VER > 14```
> be
> ```#if _LIBCPP_STD_VER > 17```
> ?
Yes it should. Thanks!


https://reviews.llvm.org/D35472



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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Some nits.




Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:23
+/// of the cursor or overlap with the selection range.
+class ASTSelectionFinder : public RecursiveASTVisitor {
+  const SourceLocation Location;

In LLVM, we use the following class layout:

```
class X {
public:
  void f();

private:
  void g();

  int member;
}
```



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:76
+
+  Optional getResult() {
+assert(SelectionStack.size() == 1 && "stack was not popped");

I think `getSelectedASTNode` would be clearer.



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:90
+  return RecursiveASTVisitor::TraverseDecl(D);
+// TODO (Alex): Add location adjustment for ObjCImplDecls.
+SourceSelectionKind SelectionKind =

Use FIXME() instead of TODO in LLVM. Here and elsewhere.



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:126-129
+SelectedASTNode Node = std::move(SelectionStack.back());
+SelectionStack.pop_back();
+if (SelectionKind != SourceSelectionKind::None || !Node.Children.empty())
+  SelectionStack.back().Children.push_back(std::move(Node));

This seems to be a recurring pattern. Maybe pull into a function?


Repository:
  rL LLVM

https://reviews.llvm.org/D35012



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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Tooling/Refactoring/ASTSelection.h:68-74
+/// Traverses the given ASTContext and creates a tree of selected AST nodes.
+///
+/// \returns None if no nodes are selected in the AST, or a selected AST node
+/// that corresponds to the TranslationUnitDecl otherwise.
+Optional findSelectedASTNodes(const ASTContext ,
+   SourceLocation Location,
+   SourceRange SelectionRange);

klimek wrote:
> Any reason not to do multiple ranges?
> 
> Also, it's not clear from reading the description here why we need the 
> Location.
I guess multiple ranges can be supported in follow-up patches to keep this one 
simpler.

I'll add it to the comment, but the idea is that the location corresponds to 
the cursor/right click position in the editor. That means that location doesn't 
have to be identical to the selection, since you can select something and then 
right click anywhere in the editor. 



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:100
+  SelectionStack.back().Children.push_back(std::move(Node));
+return true;
+  }

klimek wrote:
> Why do we always stop traversal?
False stops traversal, true is the default return value.


Repository:
  rL LLVM

https://reviews.llvm.org/D35012



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


r308190 - [NFC] Refactor the Preprocessor function that handles Macro definitions and rename Arguments to Parameters in Macro Definitions.

2017-07-17 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Jul 17 10:18:43 2017
New Revision: 308190

URL: http://llvm.org/viewvc/llvm-project?rev=308190=rev
Log:
[NFC] Refactor the Preprocessor function that handles Macro definitions and 
rename Arguments to Parameters in Macro Definitions. 
  - Extracted the reading of the tokens out into a separate function.
  - Replace 'Argument' with 'Parameter' when referring to the identifiers of 
the macro definition (as opposed to the supplied arguments - MacroArgs - during 
the macro invocation).

This is in preparation for submitting patches for review to implement 
__VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective 
function and making it less comprehensible.

I will also directly update some extra clang tooling that is broken by the 
change from Argument to Parameter.

Hopefully the bots will stay appeased.

Thanks!

Modified:
cfe/trunk/include/clang/Lex/MacroInfo.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/lib/Lex/MacroInfo.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=308190=308189=308190=diff
==
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Mon Jul 17 10:18:43 2017
@@ -42,14 +42,14 @@ class MacroInfo {
 
   /// \brief The list of arguments for a function-like macro.
   ///
-  /// ArgumentList points to the first of NumArguments pointers.
+  /// ParameterList points to the first of NumParameters pointers.
   ///
   /// This can be empty, for, e.g. "#define X()".  In a C99-style variadic
   /// macro, this includes the \c __VA_ARGS__ identifier on the list.
-  IdentifierInfo **ArgumentList;
+  IdentifierInfo **ParameterList;
 
-  /// \see ArgumentList
-  unsigned NumArguments;
+  /// \see ParameterList
+  unsigned NumParameters;
 
   /// \brief This is the list of tokens that the macro is defined to.
   SmallVector ReplacementTokens;
@@ -153,37 +153,37 @@ public:
   /// \brief Set the value of the IsWarnIfUnused flag.
   void setIsWarnIfUnused(bool val) { IsWarnIfUnused = val; }
 
-  /// \brief Set the specified list of identifiers as the argument list for
+  /// \brief Set the specified list of identifiers as the parameter list for
   /// this macro.
-  void setArgumentList(ArrayRef List,
+  void setParameterList(ArrayRef List,
llvm::BumpPtrAllocator ) {
-assert(ArgumentList == nullptr && NumArguments == 0 &&
-   "Argument list already set!");
+assert(ParameterList == nullptr && NumParameters == 0 &&
+   "Parameter list already set!");
 if (List.empty())
   return;
 
-NumArguments = List.size();
-ArgumentList = PPAllocator.Allocate(List.size());
-std::copy(List.begin(), List.end(), ArgumentList);
+NumParameters = List.size();
+ParameterList = PPAllocator.Allocate(List.size());
+std::copy(List.begin(), List.end(), ParameterList);
   }
 
-  /// Arguments - The list of arguments for a function-like macro.  This can be
-  /// empty, for, e.g. "#define X()".
-  typedef IdentifierInfo *const *arg_iterator;
-  bool arg_empty() const { return NumArguments == 0; }
-  arg_iterator arg_begin() const { return ArgumentList; }
-  arg_iterator arg_end() const { return ArgumentList + NumArguments; }
-  unsigned getNumArgs() const { return NumArguments; }
-  ArrayRef args() const {
-return ArrayRef(ArgumentList, NumArguments);
+  /// Parameters - The list of parameters for a function-like macro.  This can 
+  /// be empty, for, e.g. "#define X()".
+  typedef IdentifierInfo *const *param_iterator;
+  bool param_empty() const { return NumParameters == 0; }
+  param_iterator param_begin() const { return ParameterList; }
+  param_iterator param_end() const { return ParameterList + NumParameters; }
+  unsigned getNumParams() const { return NumParameters; }
+  ArrayRef params() const {
+return ArrayRef(ParameterList, NumParameters);
   }
 
-  /// \brief Return the argument number of the specified identifier,
-  /// or -1 if the identifier is not a formal argument identifier.
-  int getArgumentNum(const IdentifierInfo *Arg) const {
-for (arg_iterator I = arg_begin(), E = arg_end(); I != E; ++I)
+  /// \brief Return the parameter number of the specified identifier,
+  /// or -1 if the identifier is not a formal parameter identifier.
+  int getParameterNum(const IdentifierInfo 

[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

> Is diff 1 the original diff from https://reviews.llvm.org/D28953? It was ok 
> to reopen it, but the new revision is also fine.

No, diff 1 is already different; it contains most of the bugfixes. I couldn't 
find any way to reopen the previous review, and `arc diff` wouldn't let me 
update a closed review.

> Regarding 1-bit bools: did you notice https://reviews.llvm.org/D32328 and 
> https://reviews.llvm.org/D35041, do they accidentally help?

I did see those changes, but I think they're a little different. The test 
failures I ran into were cases where the input is a 1-bit APSInt, and 
attempting to retrieve the type for that gives a null QualType.


https://reviews.llvm.org/D35450



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 106896.
ddcc added a comment.

Fix tests after typo fix


https://reviews.llvm.org/D35450

Files:
  include/clang/AST/Expr.h
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/analyzer_test.py
  test/Analysis/bitwise-ops.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/plist-macros-z3.cpp
  test/Analysis/plist-macros.cpp
  test/Analysis/range_casts.c
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/range_casts.c
===
--- test/Analysis/range_casts.c
+++ test/Analysis/range_casts.c
@@ -67,7 +67,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1 == 0) // Was not reached prior fix.
+  if (index - 1 == 0)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
@@ -87,7 +87,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1L == 0L) // Was not reached prior fix.
+  if (index - 1L == 0L)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
@@ -117,7 +117,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1UL == 0L) // Was not reached prior fix.
+  if (index - 1UL == 0L)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
Index: test/Analysis/plist-macros.cpp
===
--- test/Analysis/plist-macros.cpp
+++ test/Analysis/plist-macros.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=true %s -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
-
+// REQUIRES: !z3
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
@@ -11,13 +11,13 @@
   y++;
   y--;
   mallocmemory
-  y++; 
+  y++;
   y++;
   delete x; // expected-warning {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
 }
 
 void macroIsFirstInFunction(int y) {
-  mallocmemory 
+  mallocmemory
   y++; // expected-warning {{Potential leak of memory pointed to by 'x'}}
 }
 
@@ -39,7 +39,7 @@
   return *p; // expected-warning {{Dereference of null pointer}}
 }
 
-#define macroWithArg(mp) mp==0 
+#define macroWithArg(mp) mp==0
 int macroWithArgInExpression(int *p, int y) {;
   y++;
   if (macroWithArg(p))
@@ -85,6 +85,7 @@
 void test2(int *p) {
   CALL_FN(p);
 }
+
 // CHECK:  diagnostics
 // CHECK-NEXT:  
 // CHECK-NEXT:   
@@ -636,6 +637,69 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line36
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// 

[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2017-07-17 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: test/std/utilities/meta/meta.type.synop/endian.pass.cpp:39-42
+union {
+uint32_t i;
+char c[4];
+} u = {0x01020304};

This is undefined behavior as-is because you are reading from a union member 
other than the active union member.

I'd recommend a sequence like:
  uint32_t i = 0x01020304;
  char c[4];
  memcpy(c, , 4);


https://reviews.llvm.org/D35472



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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Take a look at the tests in clang/test/Index/Core. You should be able to write 
a test which uses c-index-test to dump the symbols in this source.


https://reviews.llvm.org/D35212



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

As an update, after fixing the typo and updating the tests, the assertion in 
`range_casts.c` is no longer triggered and everything seems fine now.


https://reviews.llvm.org/D35450



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


[PATCH] D35438: CodeGen: Insert addr space cast for automatic/temp var at right position

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



Comment at: lib/CodeGen/CGExpr.cpp:76
 auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
+EnsureInsertPoint();
+auto *CurBB = Builder.GetInsertBlock();

rjmccall wrote:
> IRBuilder already has saveIP() and restoreIP() methods for this purpose that 
> deal correctly with the current insertion point being null.
Thanks. I will use those.


https://reviews.llvm.org/D35438



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


[PATCH] D35438: CodeGen: Insert addr space cast for automatic/temp var at right position

2017-07-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 106910.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Use saveIP/restoreIP.


https://reviews.llvm.org/D35438

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/amdgcn-automatic-variable.cpp


Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -13,39 +13,39 @@
 // CHECK-LABEL: define void @_Z5func2v()
 void func2(void) {
   // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x 
i32]*
   // CHECK: %lp1 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: %lp2 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
 
-  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: store i32 1, i32* %[[r0]]
   int lv1;
   lv1 = 1;
-  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: store i32 2, i32* %[[r1]]
   int lv2 = 2;
 
-  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x 
i32]*
   // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x 
i32]* %[[r2]], i64 0, i64 0
   // CHECK: store i32 3, i32* %[[arrayidx]], align 4
   int la[100];
   la[0] = 3;
 
-  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: store i32* %[[r0]], i32** %[[r3]], align 8
   int *lp1 = 
 
-  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x 
i32]* %[[r2]], i32 0, i32 0
   // CHECK: store i32* %[[arraydecay]], i32** %[[r4]], align 8
   int *lp2 = la;
 
   // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
   func1();
 
-  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
   // CHECK: store i32 4, i32* %[[r5]]
   // CHECK: store i32 4, i32* %[[r0]]
   const int lvc = 4;
@@ -81,4 +81,25 @@
   func1();
 }
 
+// CHECK-LABEL: define void @_Z5func5v
+void func5() {
+  return;
+  int x = 0;
+}
+
+// CHECK-LABEL: define void @_Z5func6v
+void func6() {
+  return;
+  int x;
+}
+
+// CHECK-LABEL: define void @_Z5func7v
+extern void use(int *);
+void func7() {
+  goto later;
+  int x;
+later:
+  use();
+}
+
 // CHECK-NOT: !opencl.ocl.version
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -73,9 +73,12 @@
   // cast alloca to the default address space when necessary.
   if (CastToDefaultAddrSpace && getASTAllocaAddressSpace() != LangAS::Default) 
{
 auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
+auto CurIP = Builder.saveIP();
+Builder.SetInsertPoint(AllocaInsertPt);
 V = getTargetHooks().performAddrSpaceCast(
 *this, V, getASTAllocaAddressSpace(), LangAS::Default,
 Ty->getPointerTo(DestAddrSpace), /*non-null*/ true);
+Builder.restoreIP(CurIP);
   }
 
   return Address(V, Align);


Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -13,39 +13,39 @@
 // CHECK-LABEL: define void @_Z5func2v()
 void func2(void) {
   // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]*
   // CHECK: %lp1 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r3:.*]] = addrspacecast i32* addrspace(5)* %lp1 to i32**
   // CHECK: %lp2 = alloca i32*, align 8, addrspace(5)
+  // CHECK: %[[r4:.*]] = addrspacecast i32* addrspace(5)* %lp2 to i32**
   // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r5:.*]] = addrspacecast i32 addrspace(5)* %lvc to i32*
 
-  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
   // CHECK: store i32 1, i32* %[[r0]]
   int lv1;
   lv1 = 1;
-  // CHECK: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %lv2 to i32*
   // CHECK: store i32 2, i32* %[[r1]]
   int lv2 = 2;
 
-  // CHECK: %[[r2:.*]] = addrspacecast [100 x 

[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-17 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

If most code can be shared in a common base class like CloexecCheck,
maybe all 8 "Add a close-on-exec check" CLs can be combined into 1 or 2 CLs
to consolidate all review efforts.
I also prefer a separate check name for each function,
so users can enable/disable each check.


https://reviews.llvm.org/D35372



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-17 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 added a comment.

In https://reviews.llvm.org/D34937#811500, @dcoughlin wrote:

> Looks good to me, other than a nit on indentation and a request for a little 
> bit more info in a comment!


Currently, I have added support for generic annotations for __isl_take and 
__isl_give and I have also added a generic diagnostic note when the function 
returns an object which is neither Core-Foundation nor Objective-C.
For emitting a generic diagnostic note, I have added an object kind to the enum 
ObjKind in ObjCRetainCount.h.

Now, for adding the aforementioned support, I have made some changes to the 
patch which I last submitted.

So, should I submit another patch on the same revision after modifying the 
title, summary, etc. or should I create another revision for that?


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-07-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

@rsmith: post-C++-commitee-meeting ping ;)


https://reviews.llvm.org/D34992



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


r308197 - [SystemZ] Add support for IBM z14 processor (1/3)

2017-07-17 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Jul 17 10:45:57 2017
New Revision: 308197

URL: http://llvm.org/viewvc/llvm-project?rev=308197=rev
Log:
[SystemZ] Add support for IBM z14 processor (1/3)

This patch series adds support for the IBM z14 processor.  This part includes:
- Basic support for the new processor and its features.
- Support for low-level builtins mapped to new LLVM intrinsics.

Support for the -fzvector extension to vector float and the new
high-level vector intrinsics is provided by separate patches.


Added:
cfe/trunk/test/CodeGen/builtins-systemz-vector2-error.c
cfe/trunk/test/CodeGen/builtins-systemz-vector2.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/systemz-abi-vector.c
cfe/trunk/test/CodeGen/systemz-abi.c
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/Driver/systemz-march.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def?rev=308197=308196=308197=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsSystemZ.def Mon Jul 17 10:45:57 2017
@@ -253,5 +253,29 @@ TARGET_BUILTIN(__builtin_s390_vfmsdb, "V
 TARGET_BUILTIN(__builtin_s390_vfsqdb, "V2dV2d", "nc", "vector")
 TARGET_BUILTIN(__builtin_s390_vftcidb, "V2SLLiV2dIii*", "nc", "vector")
 
+// Vector-enhancements facility 1 intrinsics.
+TARGET_BUILTIN(__builtin_s390_vlrl, "V16ScUivC*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vstrl, "vV16ScUiv*", "", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vbperm, "V2ULLiV16UcV16Uc", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vmslg, "V16UcV2ULLiV2ULLiV16UcIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmaxdb, "V2dV2dV2dIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmindb, "V2dV2dV2dIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmadb, "V2dV2dV2dV2d", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmsdb, "V2dV2dV2dV2d", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfcesbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfchsbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfchesbs, "V4SiV4fV4fi*", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfisb, "V4fV4fIiIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmaxsb, "V4fV4fV4fIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfminsb, "V4fV4fV4fIi", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vflnsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vflpsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmasb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfmssb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmasb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfnmssb, "V4fV4fV4fV4f", "nc", 
"vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vfsqsb, "V4fV4f", "nc", "vector-enhancements-1")
+TARGET_BUILTIN(__builtin_s390_vftcisb, "V4SiV4fIii*", "nc", 
"vector-enhancements-1")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308197=308196=308197=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 17 10:45:57 2017
@@ -7503,6 +7503,7 @@ public:
   .Cases("arch9", "z196", 9)
   .Cases("arch10", "zEC12", 10)
   .Cases("arch11", "z13", 11)
+  .Cases("arch12", "z14", 12)
   .Default(-1);
   }
   bool setCPU(const std::string ) override {
@@ -7519,6 +7520,8 @@ public:
   Features["transactional-execution"] = true;
 if (ISARevision >= 11)
   Features["vector"] = true;
+if (ISARevision >= 12)
+  Features["vector-enhancements-1"] = true;
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
@@ -7548,6 +7551,7 @@ public:
 .Case("arch9", ISARevision >= 9)
 .Case("arch10", ISARevision >= 10)
 .Case("arch11", ISARevision >= 11)
+.Case("arch12", ISARevision >= 12)
 .Case("htm", HasTransactionalExecution)
 .Case("vx", HasVector)
 .Default(false);

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=308197=308196=308197=diff

r308198 - [SystemZ] Add support for IBM z14 processor (2/3)

2017-07-17 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Jul 17 10:46:47 2017
New Revision: 308198

URL: http://llvm.org/viewvc/llvm-project?rev=308198=rev
Log:
[SystemZ] Add support for IBM z14 processor (2/3)

This patch extends the -fzvector language feature to enable the new
"vector float" data type when compiling at -march=z14.  This matches
the updated extension definition implemented by other compilers for
the platform, which is indicated to applications by pre-defining
__VEC__ to 10302 (instead of 10301).


Added:
cfe/trunk/test/CodeGen/zvector2.c
cfe/trunk/test/Sema/zvector2.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308198=308197=308198=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 17 10:46:47 2017
@@ -7476,7 +7476,7 @@ public:
 if (HasVector)
   Builder.defineMacro("__VX__");
 if (Opts.ZVector)
-  Builder.defineMacro("__VEC__", "10301");
+  Builder.defineMacro("__VEC__", "10302");
   }
   ArrayRef getTargetBuiltins() const override {
 return llvm::makeArrayRef(BuiltinInfo,

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=308198=308197=308198=diff
==
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Mon Jul 17 10:46:47 2017
@@ -1082,8 +1082,10 @@ void DeclSpec::Finish(Sema , const Pri
!S.getLangOpts().ZVector)
 S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
 } else if (TypeSpecType == TST_float) {
-  // vector float is unsupported for ZVector.
-  if (S.getLangOpts().ZVector)
+  // vector float is unsupported for ZVector unless we have the
+  // vector-enhancements facility 1 (ISA revision 12).
+  if (S.getLangOpts().ZVector &&
+  !S.Context.getTargetInfo().hasFeature("arch12"))
 S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
 } else if (TypeSpecWidth == TSW_long) {
   // vector long is unsupported for ZVector and deprecated for AltiVec.

Added: cfe/trunk/test/CodeGen/zvector2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/zvector2.c?rev=308198=auto
==
--- cfe/trunk/test/CodeGen/zvector2.c (added)
+++ cfe/trunk/test/CodeGen/zvector2.c Mon Jul 17 10:46:47 2017
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z14 -fzvector \
+// RUN:  -O -emit-llvm -o - -W -Wall -Werror %s | FileCheck %s
+
+volatile vector float ff, ff2;
+volatile vector bool int bi;
+
+void test_assign (void)
+{
+// CHECK-LABEL: test_assign
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: store volatile <4 x float> [[VAL]], <4 x float>* @ff
+  ff = ff2;
+}
+
+void test_pos (void)
+{
+// CHECK-LABEL: test_pos
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: store volatile <4 x float> [[VAL]], <4 x float>* @ff
+  ff = +ff2;
+}
+
+void test_neg (void)
+{
+// CHECK-LABEL: test_neg
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fsub <4 x float> , [[VAL]]
+  ff = -ff2;
+}
+
+void test_preinc (void)
+{
+// CHECK-LABEL: test_preinc
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ++ff2;
+}
+
+void test_postinc (void)
+{
+// CHECK-LABEL: test_postinc
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ff2++;
+}
+
+void test_predec (void)
+{
+// CHECK-LABEL: test_predec
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  --ff2;
+}
+
+void test_postdec (void)
+{
+// CHECK-LABEL: test_postdec
+// CHECK: [[VAL:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL]], 
+  ff2--;
+}
+
+void test_add (void)
+{
+// CHECK-LABEL: test_add
+// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff
+// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL1]], [[VAL2]]
+  ff = ff + ff2;
+}
+
+void test_add_assign (void)
+{
+// CHECK-LABEL: test_add_assign
+// CHECK: [[VAL2:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff2
+// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x float>, <4 x float>* @ff
+// CHECK: %{{.*}} = fadd <4 x float> [[VAL2]], [[VAL1]]
+  ff += ff2;
+}
+
+void test_sub (void)
+{
+// CHECK-LABEL: test_sub
+// CHECK: [[VAL1:%[^ ]+]] = load volatile <4 x 

[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-17 Thread Yan Wang via Phabricator via cfe-commits
yawanng added a comment.

In https://reviews.llvm.org/D35372#810525, @alexfh wrote:

> In https://reviews.llvm.org/D35372#810457, @alexfh wrote:
>
> > I have deja vu ;)
> >
> > Should we make a single check for all CLOEXEC and friends with a single 
> > configurable list of (function name, flag name) pairs?
>
>
> Okay, it may be a bit more complicated than just a list of function name -> 
> flag name mappings, since we have to take in account the argument position as 
> well. We also might want to check the signature to a certain degree to avoid 
> matching wrong function. There are multiple approaches possible to rule out 
> incorrect functions with the same name:
>
> 1. just look at the number of arguments - this might well be enough, since 
> for a certain codebase I wouldn't expect multiple `memfd_create`'s etc. It 
> would allow user configurability of the function -> flag mappings.
> 2. encode the types of arguments as strings and have a small dictionary of 
> matchers in the check (e.g. `"const char*" -> 
> pointerType(pointee(isAnyCharacter()))`) - that will be more precise and 
> still quite flexible and also allow user-configurable function -> flag 
> mappings. But this mechanism may be an overkill, if we don't anticipate 
> user-configurable functions. I don't know how complex the resulting code 
> turns out to be.
> 3. Add a matcher for each function statically. This would obviously allow for 
> arbitrarily complex matchers, but won't be extensible via configuration 
> options.


Great idea. But we may prefer separate checks, because each API can be 
controlled independently. Moreover, there are not that many such system 
functions and hopefully we have listed most of them already :-)  To reduce the 
code duplication, what about a base class for all of them and try to share as 
much code as possible?


https://reviews.llvm.org/D35372



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


[PATCH] D35438: CodeGen: Insert addr space cast for automatic/temp var at right position

2017-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:76
 auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
+EnsureInsertPoint();
+auto *CurBB = Builder.GetInsertBlock();

IRBuilder already has saveIP() and restoreIP() methods for this purpose that 
deal correctly with the current insertion point being null.


https://reviews.llvm.org/D35438



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-17 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 106911.
malhar1995 added a comment.

Addressed comments.
Changed the function from isTrustedReferenceCountImplementation() to 
hasRCAnnotation() (I'm unable to come up with a better name) as this will be 
useful when I add support to RetainCountChecker to check for generic 
annotations corresponding to __isl_give(cf_returns_retained) and 
__isl_take(cf_consumed).


Repository:
  rL LLVM

https://reviews.llvm.org/D34937

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m

Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -12,7 +12,7 @@
 //
 // It includes the basic definitions for the test cases below.
 //===--===//
-
+#define NULL 0
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -267,6 +267,10 @@
 
 extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
 
+typedef struct {
+  int ref;
+} isl_basic_map;
+
 //===--===//
 // Test cases.
 //===--===//
@@ -285,6 +289,7 @@
   foo(s);
   bar(s);
 }
+
 void test_neg() {
   NSString *s = [[NSString alloc] init]; // no-warning  
   foo(s);
@@ -294,6 +299,55 @@
   bar(s);
 }
 
+__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+void free(void *);
+
+// As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
+// implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
+// a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
+// count of 'bmap' along the path in 'isl_basic_map_free' assuming the predicate of the second 'if' branch to be
+// true or assuming both the predicates in the function to be false.
+__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  if (!bmap)
+return NULL;
+
+  if (--bmap->ref > 0)
+return NULL;
+
+  free(bmap);
+  return NULL;
+}
+
+// As 'isl_basic_map_copy' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
+// implementation and doesn't analyze its body. If that annotation is removed, a 'use-after-release' warning might
+// be raised by RetainCountChecker as the pointer which is passed as an argument to this function and the pointer
+// which is returned from the function point to the same memory location.
+__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
+  if (!bmap)
+return NULL;
+
+  bmap->ref++;
+  return bmap;
+}
+
+void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  // After this call, 'bmap' has a +1 reference count.
+  bmap = isl_basic_map_cow(bmap);
+  // After the call to 'isl_basic_map_copy', 'bmap' has a +1 reference count.
+  isl_basic_map *temp = isl_basic_map_cow(isl_basic_map_copy(bmap));
+  // After this call, 'bmap' has a +0 reference count.
+  isl_basic_map *temp2 = isl_basic_map_cow(bmap); // no-warning
+  isl_basic_map_free(temp2);
+  isl_basic_map_free(temp);
+}
+
+void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  // After this call, 'bmap' has a +1 reference count.
+  bmap = isl_basic_map_cow(bmap); // no-warning
+  // After this call, 'bmap' has a +0 reference count.
+  isl_basic_map_free(bmap);
+}
+
 //===--===//
 // Test returning retained and not-retained values.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1304,6 +1304,15 @@
   DoNothing, DoNothing);
 }
 
+/// Returns true if the declaration 'D' is annotated with 'rcAnnotation'.
+bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation) {
+  for (const auto *Ann : D->specific_attrs()) {
+if (Ann->getAnnotation() == rcAnnotation)
+  return true;
+  }
+  return false;
+}
+
 //===--===//
 // 

[PATCH] D34955: [Basic] Detect Git submodule version in CMake

2017-07-17 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Awesome, thanks @jordan_rose!


https://reviews.llvm.org/D34955



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

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

Thanks, looks great!


https://reviews.llvm.org/D34475



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


[PATCH] D35483: clang-format: fix block OpeningLineIndex around preprocessor

2017-07-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Nice!




Comment at: lib/Format/UnwrappedLineParser.cpp:461
+
+size_t UnwrappedLineParser::computePPHash() const {
+  size_t h = 0;

@djasper: do you aware of some baked-in hash-combine functionality in llvm 
which this can use directly? If there is no, I'm happy with this.



Comment at: unittests/Format/NamespaceEndCommentsFixerTest.cpp:556
+}
+
 TEST_F(NamespaceEndCommentsFixerTest,

Maybe also add some negative tests?


https://reviews.llvm.org/D35483



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


[PATCH] D34859: [COFF, ARM64] Set the data type widths and the data layout string

2017-07-17 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 106925.
mgrang retitled this revision from "[COFF, ARM64] Set the data type widths and 
the data layout string for COFF ARM64" to "[COFF, ARM64] Set the data type 
widths and the data layout string".
mgrang set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D34859

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/coff-aarch64-type-sizes.c

Index: test/CodeGen/coff-aarch64-type-sizes.c
===
--- /dev/null
+++ test/CodeGen/coff-aarch64-type-sizes.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s
+
+// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
+// CHECK: target triple = "aarch64--windows-msvc"
+
+int check_short() {
+  return sizeof(short);
+// CHECK: ret i32 2
+}
+
+int check_int() {
+  return sizeof(int);
+// CHECK: ret i32 4
+}
+
+int check_long() {
+  return sizeof(long);
+// CHECK: ret i32 4
+}
+
+int check_longlong() {
+  return sizeof(long long);
+// CHECK: ret i32 8
+}
+
+int check_int128() {
+  return sizeof(__int128);
+// CHECK: ret i32 16
+}
+
+int check_fp16() {
+  return sizeof(__fp16);
+// CHECK: ret i32 2
+}
+
+int check_float() {
+  return sizeof(float);
+// CHECK: ret i32 4
+}
+
+int check_double() {
+  return sizeof(double);
+// CHECK: ret i32 8
+}
+
+int check_longdouble() {
+  return sizeof(long double);
+// CHECK: ret i32 8
+}
+
+int check_floatComplex() {
+  return sizeof(float _Complex);
+// CHECK: ret i32 8
+}
+
+int check_doubleComplex() {
+  return sizeof(double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_longdoubleComplex() {
+  return sizeof(long double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_bool() {
+  return sizeof(_Bool);
+// CHECK: ret i32 1
+}
+
+int check_wchar() {
+  return sizeof(__WCHAR_TYPE__);
+// CHECK: ret i32 2
+}
+
+int check_wchar_unsigned() {
+  return (__WCHAR_TYPE__)-1 > (__WCHAR_TYPE__)0;
+// CHECK: ret i32 1
+}
+
+enum Small {
+  Item
+};
+
+int foo() {
+  return sizeof(enum Small);
+// CHECK: ret i32 4
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6652,13 +6652,26 @@
   MicrosoftARM64TargetInfo(const llvm::Triple ,
  const TargetOptions )
   : WindowsTargetInfo(Triple, Opts), Triple(Triple) {
+
+// This is an LLP64 platform.
+// int:4, long:4, long long:8, long double:8.
 WCharType = UnsignedShort;
+IntWidth = IntAlign = 32;
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = ::APFloat::IEEEdouble();
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
 SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+
 TheCXXABI.set(TargetCXXABI::Microsoft);
   }
 
   void setDataLayout() override {
-resetDataLayout("e-m:w-i64:64-i128:128-n32:64-S128");
+resetDataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128");
   }
 
   void getVisualStudioDefines(const LangOptions ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308209 - Update use of llvm::CallingConv:X86_64_Win64 after LLVM commit r308208

2017-07-17 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 17 13:05:56 2017
New Revision: 308209

URL: http://llvm.org/viewvc/llvm-project?rev=308209=rev
Log:
Update use of llvm::CallingConv:X86_64_Win64 after LLVM commit r308208

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/ms_abi.c
cfe/trunk/test/CodeGenObjC/attr-callconv.m

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=308209=308208=308209=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jul 17 13:05:56 2017
@@ -50,7 +50,7 @@ unsigned CodeGenTypes::ClangCallConvToLL
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
   case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
-  case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
+  case CC_X86_64Win64: return llvm::CallingConv::Win64;
   case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
   case CC_AAPCS: return llvm::CallingConv::ARM_AAPCS;
   case CC_AAPCS_VFP: return llvm::CallingConv::ARM_AAPCS_VFP;

Modified: cfe/trunk/test/CodeGen/ms_abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_abi.c?rev=308209=308208=308209=diff
==
--- cfe/trunk/test/CodeGen/ms_abi.c (original)
+++ cfe/trunk/test/CodeGen/ms_abi.c Mon Jul 17 13:05:56 2017
@@ -15,20 +15,20 @@ void f3(void) {
   // FREEBSD-LABEL: define void @f3()
   // WIN64-LABEL: define void @f3()
   f1();
-  // FREEBSD: call x86_64_win64cc void @f1()
+  // FREEBSD: call win64cc void @f1()
   // WIN64: call void @f1()
   f2();
   // FREEBSD: call void @f2()
   // WIN64: call x86_64_sysvcc void @f2()
 }
-// FREEBSD: declare x86_64_win64cc void @f1()
+// FREEBSD: declare win64cc void @f1()
 // FREEBSD: declare void @f2()
 // WIN64: declare void @f1()
 // WIN64: declare x86_64_sysvcc void @f2()
 
 // Win64 ABI varargs
 void __attribute__((ms_abi)) f4(int a, ...) {
-  // FREEBSD-LABEL: define x86_64_win64cc void @f4
+  // FREEBSD-LABEL: define win64cc void @f4
   // WIN64-LABEL: define void @f4
   __builtin_ms_va_list ap;
   __builtin_ms_va_start(ap, a);

Modified: cfe/trunk/test/CodeGenObjC/attr-callconv.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/attr-callconv.m?rev=308209=308208=308209=diff
==
--- cfe/trunk/test/CodeGenObjC/attr-callconv.m (original)
+++ cfe/trunk/test/CodeGenObjC/attr-callconv.m Mon Jul 17 13:05:56 2017
@@ -9,5 +9,5 @@
 // CHECK: define{{.*}}x86_stdcallcc{{.*}}Test test
 
 - (void)test2 __attribute__((ms_abi)) {}
-// CHECK: define{{.*}}x86_64_win64cc{{.*}}Test test2
+// CHECK: define{{.*}}win64cc{{.*}}Test test2
 @end


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


[PATCH] D21767: Fix instantiation of friend function templates

2017-07-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 106914.
sepavloff added a comment.

Aligned implementation with https://reviews.llvm.org/D21508.


https://reviews.llvm.org/D21767

Files:
  lib/AST/Decl.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  test/SemaTemplate/instantiate-friend-function.cpp

Index: test/SemaTemplate/instantiate-friend-function.cpp
===
--- /dev/null
+++ test/SemaTemplate/instantiate-friend-function.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -S -triple i686-pc-linux-gnu -std=c++11 %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+template void func_01(T *x);
+template
+struct C1 {
+  template friend void func_01(T *x) {}
+};
+
+C1 v1a;
+
+void use_01(int *x) {
+  func_01(x);
+}
+// CHECK: _Z7func_01IiEvPT_:
+
+
+template
+struct C2 {
+  template friend void func_02(T *x) {}
+};
+
+C2 v2a;
+template void func_02(T *x);
+
+void use_02(int *x) {
+  func_02(x);
+}
+// CHECK: _Z7func_02IiEvPT_:
+
+
+template
+struct C3a {
+  template friend void func_03(T *x) {}
+};
+template
+struct C3b {
+  template friend void func_03(T *x) {}
+};
+
+template void func_03(T *x) {}
+
+void use_03(int *x) {
+  func_03(x);
+}
+// CHECK: _Z7func_03IiEvPT_:
+
+
+template constexpr int func_04(const T x);
+template
+struct C4 {
+  template friend constexpr int func_04(const T x) { return sizeof(T); }
+};
+
+C4 v4;
+
+void use_04(int *x) {
+  static_assert(func_04(short(122)) == sizeof(short), "Invalid calculation");
+  static_assert(func_04(122) == sizeof(int), "Invalid calculation");
+  static_assert(func_04(122L) == sizeof(long), "Invalid calculation");
+  static_assert(func_04(122LL) == sizeof(long long), "Invalid calculation");
+}
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -165,6 +165,13 @@
 RelativeToPrimary = false;
 continue;
   }
+
+  if (Pattern && Pattern->getFriendObjectKind() != Decl::FOK_None &&
+  Function->getDeclContext()->isFileContext()) {
+Ctx = const_cast(Pattern->getLexicalDeclContext());
+RelativeToPrimary = false;
+continue;
+  }
 } else if (CXXRecordDecl *Rec = dyn_cast(Ctx)) {
   if (ClassTemplateDecl *ClassTemplate = Rec->getDescribedClassTemplate()) {
 QualType T = ClassTemplate->getInjectedClassNameSpecialization();
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -3249,7 +3249,23 @@
   }
   llvm_unreachable("All TSK values handled.");
 }
-   
+
+static FunctionTemplateDecl *getPatternFor(FunctionTemplateDecl *FTD) {
+  for (auto I : FTD->redecls()) {
+auto D = cast(I);
+// If we have hit a point where the user provided a specialization of
+// this template, we're done looking.
+if (D->isMemberSpecialization())
+  return D;
+if (D->isThisDeclarationADefinition())
+  return D;
+if (FunctionTemplateDecl *Orig = D->getInstantiatedFromMemberTemplate())
+  if (FunctionTemplateDecl *Def = getPatternFor(Orig))
+return Def;
+  }
+  return nullptr;
+}
+
 FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
   // Handle class scope explicit specialization special case.
   if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
@@ -3274,14 +3290,8 @@
   }
 
   if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) {
-while (Primary->getInstantiatedFromMemberTemplate()) {
-  // If we have hit a point where the user provided a specialization of
-  // this template, we're done looking.
-  if (Primary->isMemberSpecialization())
-break;
-  Primary = Primary->getInstantiatedFromMemberTemplate();
-}
-
+if (FunctionTemplateDecl *Def = getPatternFor(Primary))
+  Primary = Def;
 return getDefinitionOrSelf(Primary->getTemplatedDecl());
   } 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30170: Function definition may have uninstantiated body

2017-07-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Ping.


https://reviews.llvm.org/D30170



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Reid, with https://reviews.llvm.org/D34474 approved, does this look like what 
you had in mind?


https://reviews.llvm.org/D34475



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


[PATCH] D34859: [COFF, ARM64] Set the data type widths and the data layout string for COFF ARM64

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



Comment at: lib/Basic/Targets.cpp:6662
+DoubleAlign = LongLongAlign = 64;
+LongDoubleWidth = LongDoubleAlign = 64;
+IntMaxType = SignedLongLong;

If you're changing LongDoubleWidth and LongDoubleAlign, you also have to change 
LongDoubleFormat.


https://reviews.llvm.org/D34859



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


[PATCH] D21508: Diagnose friend function template redefinitions

2017-07-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 106912.
sepavloff edited the summary of this revision.
sepavloff added a comment.

Aligned implementation with https://reviews.llvm.org/D30170.


https://reviews.llvm.org/D21508

Files:
  include/clang/AST/DeclBase.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -129,6 +129,83 @@
 void func_22() {} // expected-error{{redefinition of 'func_22'}}
 
 
+// Case of template friend functions.
+
+template void func_31(T *x);
+template
+struct C31a {
+  template friend void func_31(T *x) {}
+};
+template
+struct C31b {
+  template friend void func_31(T *x) {}
+};
+
+
+template inline void func_32(T *x) {}
+template
+struct C32a {
+  template friend void func_32(T *x) {}
+};
+template
+struct C32b {
+  template friend void func_32(T *x) {}
+};
+
+
+template
+struct C33a {
+  template friend void func_33(T *x) {}
+};
+template
+struct C33b {
+  template friend void func_33(T *x) {}
+};
+
+
+template inline void func_34(T *x) {}  // expected-note{{previous definition is here}}
+template
+struct C34 {
+  template friend void func_34(T *x) {} // expected-error{{redefinition of 'func_34'}}
+};
+
+C34 v34;  // expected-note{{in instantiation of template class 'C34' requested here}}
+
+
+template inline void func_35(T *x);
+template
+struct C35a {
+  template friend void func_35(T *x) {} // expected-note{{previous definition is here}}
+};
+template
+struct C35b {
+  template friend void func_35(T *x) {} // expected-error{{redefinition of 'func_35'}}
+};
+
+C35a v35a;
+C35b v35b;  // expected-note{{in instantiation of template class 'C35b' requested here}}
+
+
+template void func_36(T *x);
+template
+struct C36 {
+  template friend void func_36(T *x) {}  // expected-error{{redefinition of 'func_36'}}
+ // expected-note@-1{{previous definition is here}}
+};
+
+C36 v36a;
+C36 v36b;  //expected-note{{in instantiation of template class 'C36' requested here}}
+
+
+template void func_37(T *x);
+template
+struct C37 {
+  template friend void func_37(T *x) {} // expected-note{{previous definition is here}}
+};
+
+C37 v37;
+template void func_37(T *x) {} // expected-error{{redefinition of 'func_37'}}
+
 
 namespace pr22307 {
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1795,7 +1795,9 @@
   // If the original function was part of a friend declaration,
   // inherit its namespace state and add it to the owner.
   if (isFriend) {
-PrincipalDecl->setObjectOfFriendDecl();
+Function->setObjectOfFriendDecl();
+if (FunctionTemplate)
+  FunctionTemplate->setObjectOfFriendDecl();
 DC->makeDeclVisibleInContext(PrincipalDecl);
 
 bool QueuedInstantiation = false;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11962,6 +11962,22 @@
   return MissingPrototype;
 }
 
+static FunctionTemplateDecl *findRedefinition(FunctionTemplateDecl *FTD) {
+  FunctionTemplateDecl *UninstantiatedDef = nullptr;
+  for (auto I : FTD->redecls()) {
+auto D = cast(I);
+if (D != FTD) {
+  if (D->isThisDeclarationADefinition())
+return D;
+  if (FunctionTemplateDecl *Orig = D->getInstantiatedFromMemberTemplate()) {
+if (Orig->isThisDeclarationADefinition() || findRedefinition(Orig))
+  UninstantiatedDef = D;
+  }
+}
+  }
+  return UninstantiatedDef;
+}
+
 void
 Sema::CheckForFunctionRedefinition(FunctionDecl *FD,
const FunctionDecl *EffectiveDefinition,
@@ -11990,6 +12006,31 @@
   }
 }
   }
+
+  if (!Definition)
+if (FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate()) {
+  if (FunctionTemplateDecl *DefTD = findRedefinition(FTD)) {
+const FunctionDecl *Def = DefTD->getTemplatedDecl();
+// If the found definition is a template with uninstantiated body, it
+// can be replaced in specialization:
+//
+//template struct X {
+//  template void f(T, U) { }
+//};
+//template<> template void X::f(int x, U y) { }
+//
+// In this example the specialization 'X' contains declaration of
+// 'f', which is considered a definition by 'isDefined' because it is
+// obtained by instantiation of 'X::f', which has a body.
+//
+if (isa(FTD->getDeclContext()) &&
+!Def->isThisDeclarationADefinition() &&
+Def->getFriendObjectKind() == Decl::FOK_None)
+  return;
+Definition = Def;
+  }
+}
+
   if 

r308205 - [Basic] Detect Git submodule version in CMake

2017-07-17 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Mon Jul 17 12:22:57 2017
New Revision: 308205

URL: http://llvm.org/viewvc/llvm-project?rev=308205=rev
Log:
[Basic] Detect Git submodule version in CMake

Summary:
When searching for Git version control information, libBasic's CMake
checks for the path '.git/logs/HEAD'. However, when LLVM is included as
a Git submodule, this path does not exist. Instead, it contains a '.git'
file with the following:

```
gitdir: ../../.git/modules/external/llvm
```

Where '../..' is the relative path to the root repository that contains
the LLVM Git submodule.

Because of this discrepancy, `clang --version` does not output source
control information if built from a Git submodule.

To fix, check whether '.git' is a directory or a file. If it's a
directory, simply use the '.git/logs/HEAD' path. If it's a file, read it
and check for the tell-tale sign of a Git submodule: the text "gitdir:".
If it exists, follow that path and use the 'logs/HEAD' at that location
instead. This allows not only the correct revision information to be
retrieved, but also uses a file that will change with each source
control revision.

Test Plan:
1. Before applying this change, build Clang as a Git submodule in a repository
   that places it in external/clang, and confirm no revision information
   is output when `clang --version` is invoked (just "clang 5.0.0" is
   output, no Git hashes).
2. Apply these changes and build Clang as a Git repository nested under
   llvm/tools/clang, and confirm that `clang --version` displays correct
   version information.
3. Apply these changes and build Clang as a Git submodule using the
   structure described in (1), and confirm version control information
   is output as in (2).

Reviewers: jordan_rose, beanz, probinson

Reviewed By: jordan_rose

Subscribers: chapuni, mgorny, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/CMakeLists.txt

Modified: cfe/trunk/lib/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=308205=308204=308205=diff
==
--- cfe/trunk/lib/Basic/CMakeLists.txt (original)
+++ cfe/trunk/lib/Basic/CMakeLists.txt Mon Jul 17 12:22:57 2017
@@ -15,8 +15,23 @@ function(find_first_existing_file out_va
 endfunction()
 
 macro(find_first_existing_vc_file out_var path)
+  set(git_path "${path}/.git")
+
+  # Normally '.git' is a directory that contains a 'logs/HEAD' file that
+  # is updated as modifications are made to the repository. In case the
+  # repository is a Git submodule, '.git' is a file that contains text that
+  # indicates where the repository's Git directory exists.
+  if (EXISTS "${git_path}" AND NOT IS_DIRECTORY "${git_path}")
+FILE(READ "${git_path}" file_contents)
+if("${file_contents}" MATCHES "^gitdir: ([^\n]+)")
+  # '.git' is indeed a link to the submodule's Git directory.
+  # Use the path to that Git directory.
+  set(git_path "${path}/${CMAKE_MATCH_1}")
+endif()
+  endif()
+
   find_first_existing_file(${out_var}
-"${path}/.git/logs/HEAD" # Git
+"${git_path}/logs/HEAD"  # Git or Git submodule
 "${path}/.svn/wc.db" # SVN 1.7
 "${path}/.svn/entries"   # SVN 1.6
 )


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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 106930.
krasimir added a comment.

- Add an Index test case


https://reviews.llvm.org/D35212

Files:
  lib/Index/IndexingContext.cpp
  test/Index/Core/no-templated-canonical-decl.cpp


Index: test/Index/Core/no-templated-canonical-decl.cpp
===
--- /dev/null
+++ test/Index/Core/no-templated-canonical-decl.cpp
@@ -0,0 +1,4 @@
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s | 
FileCheck %s
+
+template  class A> class B { typedef A A_int; };
+// CHECK: [[@LINE-1]]:46 | class(Gen)/C++ | B | c:@ST>1#t>1#T@B |  
| Def | rel: 0
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -260,8 +260,10 @@
 static const Decl *getCanonicalDecl(const Decl *D) {
   D = D->getCanonicalDecl();
   if (auto TD = dyn_cast(D)) {
-D = TD->getTemplatedDecl();
-assert(D->isCanonicalDecl());
+if (auto TTD = TD->getTemplatedDecl()) {
+  D = TTD;
+  assert(D->isCanonicalDecl());
+}
   }
 
   return D;


Index: test/Index/Core/no-templated-canonical-decl.cpp
===
--- /dev/null
+++ test/Index/Core/no-templated-canonical-decl.cpp
@@ -0,0 +1,4 @@
+// RUN: c-index-test core -print-source-symbols -include-locals -- %s | FileCheck %s
+
+template  class A> class B { typedef A A_int; };
+// CHECK: [[@LINE-1]]:46 | class(Gen)/C++ | B | c:@ST>1#t>1#T@B |  | Def | rel: 0
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -260,8 +260,10 @@
 static const Decl *getCanonicalDecl(const Decl *D) {
   D = D->getCanonicalDecl();
   if (auto TD = dyn_cast(D)) {
-D = TD->getTemplatedDecl();
-assert(D->isCanonicalDecl());
+if (auto TTD = TD->getTemplatedDecl()) {
+  D = TTD;
+  assert(D->isCanonicalDecl());
+}
   }
 
   return D;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

LGTM, thank you! (Let me know if you need someone to commit this for you.)


https://reviews.llvm.org/D35212



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


r308218 - [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-17 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Jul 17 13:49:45 2017
New Revision: 308218

URL: http://llvm.org/viewvc/llvm-project?rev=308218=rev
Log:
[AArch64] Add support for __builtin_ms_va_list on aarch64

Move builtins from the x86 specific scope into the global
scope. Their use is still limited to x86_64 and aarch64 though.

This allows wine on aarch64 to properly handle variadic functions.

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

Added:
cfe/trunk/test/CodeGen/ms_abi_aarch64.c
cfe/trunk/test/Sema/varargs-aarch64.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/varargs-x86-32.c
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=308218=308217=308218=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Jul 17 13:49:45 2017
@@ -3205,7 +3205,7 @@ enum CXCallingConv {
   CXCallingConv_AAPCS_VFP = 7,
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
-  CXCallingConv_X86_64Win64 = 10,
+  CXCallingConv_Win64 = 10,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=308218=308217=308218=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jul 17 13:49:45 2017
@@ -1413,6 +1413,11 @@ BUILTIN(__builtin_os_log_format, "v*v*cC
 // Builtins for XRay
 BUILTIN(__xray_customevent, "vcC*z", "")
 
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")
+BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=308218=308217=308218=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jul 17 13:49:45 2017
@@ -34,11 +34,6 @@
 // can use it?
 BUILTIN(__builtin_cpu_supports, "bcC*", "nc")
 
-// Win64-compatible va_list functions
-BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
-BUILTIN(__builtin_ms_va_end, "vc*&", "n")
-BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
-
 // Undefined Values
 //
 TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "")

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308218=308217=308218=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 17 13:49:45 
2017
@@ -8113,10 +8113,10 @@ def err_systemz_invalid_tabort_code : Er
   "invalid transaction abort code">;
 def err_64_bit_builtin_32_bit_tgt : Error<
   "this builtin is only available on 64-bit targets">;
+def err_builtin_x64_aarch64_only : Error<
+  "this builtin is only available on x86-64 and aarch64 targets">;
 def err_ppc_builtin_only_on_pwr7 : Error<
   "this builtin is only valid on POWER7 or later CPUs">;
-def err_x86_builtin_64_only : Error<
-  "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
 def err_x86_builtin_invalid_scale : Error<

Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=308218=308217=308218=diff
==
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Mon Jul 17 13:49:45 2017
@@ -236,7 +236,7 @@ namespace clang {
 CC_X86ThisCall, // __attribute__((thiscall))
 CC_X86VectorCall, // __attribute__((vectorcall))
 CC_X86Pascal,   // __attribute__((pascal))
-

[PATCH] D34859: [COFF, ARM64] Set the data type widths and the data layout string

2017-07-17 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D34859



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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@vsk: thank you!


https://reviews.llvm.org/D35212



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-17 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308218: [AArch64] Add support for __builtin_ms_va_list on 
aarch64 (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D34475?vs=106701=106941#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34475

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/ms_abi_aarch64.c
  cfe/trunk/test/Sema/varargs-aarch64.c
  cfe/trunk/test/Sema/varargs-x86-32.c
  cfe/trunk/tools/libclang/CXType.cpp

Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -611,7 +611,7 @@
   TCALLINGCONV(X86Pascal);
   TCALLINGCONV(X86RegCall);
   TCALLINGCONV(X86VectorCall);
-  TCALLINGCONV(X86_64Win64);
+  TCALLINGCONV(Win64);
   TCALLINGCONV(X86_64SysV);
   TCALLINGCONV(AAPCS);
   TCALLINGCONV(AAPCS_VFP);
Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -3205,7 +3205,7 @@
   CXCallingConv_AAPCS_VFP = 7,
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
-  CXCallingConv_X86_64Win64 = 10,
+  CXCallingConv_Win64 = 10,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -34,11 +34,6 @@
 // can use it?
 BUILTIN(__builtin_cpu_supports, "bcC*", "nc")
 
-// Win64-compatible va_list functions
-BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
-BUILTIN(__builtin_ms_va_end, "vc*&", "n")
-BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
-
 // Undefined Values
 //
 TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "")
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8113,10 +8113,10 @@
   "invalid transaction abort code">;
 def err_64_bit_builtin_32_bit_tgt : Error<
   "this builtin is only available on 64-bit targets">;
+def err_builtin_x64_aarch64_only : Error<
+  "this builtin is only available on x86-64 and aarch64 targets">;
 def err_ppc_builtin_only_on_pwr7 : Error<
   "this builtin is only valid on POWER7 or later CPUs">;
-def err_x86_builtin_64_only : Error<
-  "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
 def err_x86_builtin_invalid_scale : Error<
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1413,6 +1413,11 @@
 // Builtins for XRay
 BUILTIN(__xray_customevent, "vcC*z", "")
 
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")
+BUILTIN(__builtin_ms_va_copy, "vc**&", "n")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/include/clang/Basic/Specifiers.h
===
--- cfe/trunk/include/clang/Basic/Specifiers.h
+++ cfe/trunk/include/clang/Basic/Specifiers.h
@@ -236,7 +236,7 @@
 CC_X86ThisCall, // __attribute__((thiscall))
 CC_X86VectorCall, // __attribute__((vectorcall))
 CC_X86Pascal,   // __attribute__((pascal))
-CC_X86_64Win64, // __attribute__((ms_abi))
+CC_Win64,   // __attribute__((ms_abi))
 CC_X86_64SysV,  // __attribute__((sysv_abi))
 CC_X86RegCall, // __attribute__((regcall))
 CC_AAPCS,   // __attribute__((pcs("aapcs")))
Index: cfe/trunk/test/Sema/varargs-aarch64.c
===
--- cfe/trunk/test/Sema/varargs-aarch64.c
+++ cfe/trunk/test/Sema/varargs-aarch64.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple aarch64-linux-gnu
+
+void f1(int a, ...) {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a); // expected-error {{'__builtin_ms_va_start' 

[libcxx] r308225 - Check for _MSC_VER before defining _LIBCPP_MSVCRT

2017-07-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jul 17 14:52:31 2017
New Revision: 308225

URL: http://llvm.org/viewvc/llvm-project?rev=308225=rev
Log:
Check for _MSC_VER before defining _LIBCPP_MSVCRT

Some targets (e.g. Darwin) might have the Win32 API available, but they
do not use MSVC CRT. Assume _LIBCPP_MSVCRT only when _MSC_VER is available
and __MINGW32__ isn't defined.

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

rdar://problem/32628786

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=308225=308224=308225=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jul 17 14:52:31 2017
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))


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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308225: Check for _MSC_VER before defining _LIBCPP_MSVCRT 
(authored by bruno).

Changed prior to commit:
  https://reviews.llvm.org/D34588?vs=103975=106960#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34588

Files:
  libcxx/trunk/include/__config


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35527: [CMake] Move CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) into clang/Config/config.h.

2017-07-17 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni created this revision.
Herald added a subscriber: mgorny.

LLVM_ENABLE_MODULES is sensitive of -D. Move them into config.h.

FIXME: It'd be better that they are #cmakedefine01 rather than #cmakedefine.
(#if FOO rather than #if defined(FOO))
Then we can find missing #include "clang/Config/config.h" in the future.


Repository:
  rL LLVM

https://reviews.llvm.org/D35527

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/include/clang/Config/config.h.cmake
  cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/tools/libclang/ARCMigrate.cpp


Index: cfe/trunk/tools/libclang/ARCMigrate.cpp
===
--- cfe/trunk/tools/libclang/ARCMigrate.cpp
+++ cfe/trunk/tools/libclang/ARCMigrate.cpp
@@ -14,6 +14,7 @@
 #include "clang-c/Index.h"
 #include "CXString.h"
 #include "clang/ARCMigrate/ARCMT.h"
+#include "clang/Config/config.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Support/FileSystem.h"
 
Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -15,6 +15,7 @@
 #include "clang/FrontendTool/Utils.h"
 #include "clang/ARCMigrate/ARCMTActions.h"
 #include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
Index: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -20,6 +20,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Config/config.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/DenseSet.h"
Index: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -21,6 +21,7 @@
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Config/config.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/DenseSet.h"
Index: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
+++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -10,6 +10,7 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Config/config.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
Index: cfe/trunk/include/clang/Config/config.h.cmake
===
--- cfe/trunk/include/clang/Config/config.h.cmake
+++ cfe/trunk/include/clang/Config/config.h.cmake
@@ -56,4 +56,9 @@
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
+/* Enable each functionality of modules */
+#cmakedefine CLANG_ENABLE_ARCMT
+#cmakedefine CLANG_ENABLE_OBJC_REWRITER
+#cmakedefine CLANG_ENABLE_STATIC_ANALYZER
+
 #endif
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -389,11 +389,7 @@
 endif()
 
 if(CLANG_ENABLE_ARCMT)
-  add_definitions(-DCLANG_ENABLE_ARCMT)
-  add_definitions(-DCLANG_ENABLE_OBJC_REWRITER)
-endif()
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  add_definitions(-DCLANG_ENABLE_STATIC_ANALYZER)
+  set(CLANG_ENABLE_OBJC_REWRITER ON)
 endif()
 
 # Clang version information


Index: cfe/trunk/tools/libclang/ARCMigrate.cpp
===
--- cfe/trunk/tools/libclang/ARCMigrate.cpp
+++ cfe/trunk/tools/libclang/ARCMigrate.cpp
@@ -14,6 +14,7 @@
 #include "clang-c/Index.h"
 #include "CXString.h"
 #include "clang/ARCMigrate/ARCMT.h"
+#include "clang/Config/config.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Support/FileSystem.h"
 
Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -15,6 +15,7 @@
 #include 

[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-07-17 Thread Boris Kolpackov via Phabricator via cfe-commits
boris updated this revision to Diff 107017.
boris added a comment.

Rebase on latest HEAD.


https://reviews.llvm.org/D35020

Files:
  docs/ClangCommandLineReference.rst
  docs/Modules.rst
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ModuleManager.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  lib/Serialization/ModuleManager.cpp
  test/CXX/modules-ts/basic/basic.search/module-import.cpp

Index: test/CXX/modules-ts/basic/basic.search/module-import.cpp
===
--- /dev/null
+++ test/CXX/modules-ts/basic/basic.search/module-import.cpp
@@ -0,0 +1,39 @@
+// Tests for imported module search.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: echo 'export module x; int a, b;' > %t/x.cppm
+// RUN: echo 'export module y; import x; int c;' > %t/y.cppm
+// RUN: echo 'export module z; import y; int d;' > %t/z.cppm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/x.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: mv %t/x.pcm %t/a.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=x
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=y
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm
+//
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
+// RUN:-DMODULE_NAME=z
+//
+
+import MODULE_NAME;
+
+// expected-no-diagnostics
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -45,6 +45,14 @@
   return Known->second;
 }
 
+ModuleFile *ModuleManager::lookupPrebuilt(StringRef Name) const {
+  auto Known = PrebuiltModules.find(Name);
+  if (Known == PrebuiltModules.end())
+return nullptr;
+
+  return Known->second;
+}
+
 std::unique_ptr
 ModuleManager::lookupBuffer(StringRef Name) {
   const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
@@ -192,6 +200,11 @@
   return NewlyLoaded;
 }
 
+void ModuleManager::registerPrebuilt (ModuleFile ) {
+  assert (!M.ModuleName.empty());
+  PrebuiltModules[M.ModuleName] = 
+}
+
 void ModuleManager::removeModules(
 ModuleIterator First,
 llvm::SmallPtrSetImpl ,
@@ -232,6 +245,8 @@
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
 Modules.erase(victim->File);
+if (!victim->ModuleName.empty())
+  PrebuiltModules.erase(victim->ModuleName);
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
Index: lib/Serialization/GlobalModuleIndex.cpp
===
--- lib/Serialization/GlobalModuleIndex.cpp
+++ lib/Serialization/GlobalModuleIndex.cpp
@@ -619,6 +619,10 @@
   (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
   (uint32_t)Record[Idx++]}}};
 
+// Skip the module name (currently this is only used for prebuilt
+// modules while here we are only dealing with cached).
+Idx += Record[Idx] + 1;
+
 // Retrieve the imported file name.
 unsigned Length = Record[Idx++];
 SmallString<128> ImportedFile(Record.begin() + Idx,
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1505,6 +1505,7 @@
   for (auto I : M.Signature)
 Record.push_back(I);
 
+  AddString(M.ModuleName, Record);
   AddPath(M.FileName, Record);
 }
 

[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-07-17 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.

I am holding off on proposing the same functionality to GCC because I want to 
make sure the command line interface is the same for both compilers (GCC has 
less baggage in this area, option-name-wise). So confirming that at least the 
naming/semantics are acceptable would be very helpful.


https://reviews.llvm.org/D35020



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm considering making validateCpuIs return a std::pair with the appropriate 
value and a tag that indicates invalid/vendor/type/subtype. This way we can 
remove the target based string decoding from CodeGen by reusing the validate 
function(with a better name). Sema can look for the invalid tag for its error.

We could also make validateCpuSupports return the feature bit number for 
__builtin_cpu_supports and reuse it in CodeGen.


https://reviews.llvm.org/D35449



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


[PATCH] D34444: Teach codegen to work in incremental processing mode.

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

In https://reviews.llvm.org/D3#795175, @v.g.vassilev wrote:

> @rjmccall, thanks for the prompt and thorough reply.
>
> In https://reviews.llvm.org/D3#793311, @rjmccall wrote:
>
> > Okay.  In that case, I see two problems, one major and one potentially 
> > major.
>
>
>
>
>   This is a very accurate diagnosis which took us 5 years to discover on an 
> empirical basis ;)


You could've asked at any time. :)

>> The major problem is that, as Richard alludes to, you need to make sure you 
>> emit any on-demand definitions that Sema registered with CodeGen during the 
>> initial CGM's lifetime but used in later CGMs.
> 
> 
> 
>   We bring the CGM state to the subsequent CGMs. See 
> https://github.com/vgvassilev/clang/blob/cling-patches/lib/CodeGen/ModuleBuilder.cpp#L138-L160

That's quite brittle, because that code is only executed in a code path that 
only you are using, and you're not adding any tests.  I would greatly prefer a 
change to IRGen's core assumptions, as suggested.

>> The potentially major problem is that it is not possible in general to 
>> automatically break up a single translation unit into multiple translation 
>> units, for two reasons.  The big reason is that there is no way to correctly 
>> handle entities with non-external linkage that are referenced from two parts 
>> of the translation unit without implicitly finding some way to promote them 
>> to external linkage, which might open a huge can of worms if you have 
>> multiple "outer" translation units.
> 
> 
> 
>   We do not have an multiple 'outer' translation units. We have just one ever 
> growing TU (which probably invalidates my previous statement that we have a 
> distinct TUs) which we send to the RuntimeDyLD allowing only JIT to resolve 
> symbols from it.  We aid the JIT when resolving symbols with internal linkage 
> by changing all internal linkage to external (We haven't seen issues with 
> that approach).

Ah, okay.  Yes, that is a completely different translation model from having 
distinct TUs.

IRGen will generally happily emit references to undefined internal objects; 
instead of hacking the linkage, you could just clean that up as a post-pass.  
Although hacking the linkage as post-pass is reasonable, too.  In either case, 
you can recognize uses of internal-linkage objects that haven't been defined 
yet and report that back to the user.

>>   The lesser reason is that the prefix of a valid translation unit is not 
>> necessarily a valid translation unit: for example, a static or inline 
>> function can be defined at an arbitrary within the translation unit, i.e. 
>> not necessarily before its first use.  But if your use case somehow defines 
>> away these problems, this might be fine.
> 
> 
> 
>   If we end up with a module containing no definition of a symbol and such is 
> required, then we complain. So indeed we are defining away this issue.

Ok.

>> As a minor request, if you are going to make HandleTranslationUnit no longer 
>> the final call on CodeGenerator, please either add a new method that *is* a 
>> guaranteed final call or add a new method that does the whole "end a 
>> previous part of the translation unit and start a new one" step.
> 
> 
> 
>   We can have this but it would be a copy of `HandleTranslationUnit`.  The 
> `StartModule` interface is the antagonist routine to `ReleaseModule`. If you 
> prefer we could merge `StartModule` into `ReleaseModule` adding a flag (or 
> reading the value of `isIncrementalProcessingEnabled`).

I feel it is important that there be a way to inform an ASTConsumer that no 
further requests will be made of it, something other than calling its 
destructor.  I would like you to make sure that the ASTConsumer interface 
supports that and that that call is not made too soon in your alternate 
processing mode.


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


[PATCH] D35470: [libcxx] Implement pointer_traits::to_address as in P0653R0

2017-07-17 Thread Glen Fernandes via Phabricator via cfe-commits
glenjofe updated this revision to Diff 106965.
glenjofe removed rL LLVM as the repository for this revision.
glenjofe added a comment.

Include full context in the diff.


https://reviews.llvm.org/D35470

Files:
  include/memory
  
test/std/utilities/memory/pointer.traits/pointer.traits.functions/to_address.pass.cpp
  test/std/utilities/memory/pointer.traits/to_address.pass.cpp

Index: test/std/utilities/memory/pointer.traits/to_address.pass.cpp
===
--- test/std/utilities/memory/pointer.traits/to_address.pass.cpp
+++ test/std/utilities/memory/pointer.traits/to_address.pass.cpp
@@ -0,0 +1,23 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// element_type* pointer_traits::to_address(pointer p) noexcept;
+
+#include 
+#include 
+
+int main()
+{
+int i = 0;
+assert(std::pointer_traits::to_address() == );
+assert(std::pointer_traits::to_address() == );
+assert(std::pointer_traits::to_address() == );
+}
Index: test/std/utilities/memory/pointer.traits/pointer.traits.functions/to_address.pass.cpp
===
--- test/std/utilities/memory/pointer.traits/pointer.traits.functions/to_address.pass.cpp
+++ test/std/utilities/memory/pointer.traits/pointer.traits.functions/to_address.pass.cpp
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// element_type* pointer_traits::to_address(pointer p) noexcept;
+
+#include 
+#include 
+
+struct P1
+{
+  typedef int element_type;
+  int* value;
+  explicit P1(int* ptr) noexcept : value(ptr) { }
+  int* operator->() const noexcept { return value; }
+};
+
+struct P2
+{
+  typedef P1::element_type element_type;
+  P1 value;
+  explicit P2(P1 ptr) noexcept : value(ptr) { }
+  P1 operator->() const noexcept { return value; }
+};
+
+int main()
+{
+int i = 0;
+P1 p1();
+assert(std::pointer_traits::to_address(p1) == );
+P2 p2(p1);
+assert(std::pointer_traits::to_address(p2) == );
+}
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -32,6 +32,7 @@
 template  using rebind = ;
 
 static pointer pointer_to();
+static element_type* to_address(pointer p) noexcept;
 };
 
 template 
@@ -44,6 +45,7 @@
 template  using rebind = U*;
 
 static pointer pointer_to() noexcept;
+static element_type* to_address(pointer p) noexcept;
 };
 
 template 
@@ -950,11 +952,20 @@
 
 private:
 struct __nat {};
+
+template 
+_LIBCPP_INLINE_VISIBILITY
+static element_type* __to_address(_Tp __p) _NOEXCEPT
+{return pointer_traits<_Tp>::to_address(__p);}
 public:
 _LIBCPP_INLINE_VISIBILITY
 static pointer pointer_to(typename conditional::type& __r)
 {return pointer::pointer_to(__r);}
+
+_LIBCPP_INLINE_VISIBILITY
+static element_type* to_address(pointer __p) _NOEXCEPT
+{return __to_address(__p.operator->());}
 };
 
 template 
@@ -977,6 +988,9 @@
 static pointer pointer_to(typename conditional::type& __r) _NOEXCEPT
 {return _VSTD::addressof(__r);}
+
+_LIBCPP_INLINE_VISIBILITY
+static element_type* to_address(pointer __p) _NOEXCEPT {return __p;}
 };
 
 template 
@@ -1089,20 +1103,12 @@
 #endif
 };
 
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp*
-__to_raw_pointer(_Tp* __p) _NOEXCEPT
-{
-return __p;
-}
-
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename pointer_traits<_Pointer>::element_type*
 __to_raw_pointer(_Pointer __p) _NOEXCEPT
 {
-return _VSTD::__to_raw_pointer(__p.operator->());
+return pointer_traits<_Pointer>::to_address(__p);
 }
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308176 - [OPENMP] Rework tests to pacify buildbots.

2017-07-17 Thread Galina Kistanova via cfe-commits
Hello Alexey,

It looks like your resent commit broke couple of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

Failing Tests (2):
Clang :: OpenMP/taskloop_reduction_codegen.cpp
Clang :: OpenMP/taskloop_simd_reduction_codegen.cpp

Please have a look?

Thanks

Galina

On Mon, Jul 17, 2017 at 7:06 AM, Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Mon Jul 17 07:06:41 2017
> New Revision: 308176
>
> URL: http://llvm.org/viewvc/llvm-project?rev=308176=rev
> Log:
> [OPENMP] Rework tests to pacify buildbots.
>
> Modified:
> cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
> cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
>
> Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> taskloop_reduction_codegen.cpp?rev=308176=308175=308176=diff
> 
> ==
> --- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17
> 07:06:41 2017
> @@ -80,9 +80,7 @@ sum = 0.0;
>  // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x
> %struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]*
> [[DOTRD_INPUT_]], i64 0, i64 1
>  // CHECK:[[TMP28:%.*]] = getelementptr inbounds
> [[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t*
> [[DOTRD_INPUT_GEP_4]], i32 0, i32 0
>  // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x
> %struct.S], [100 x %struct.S]* [[C]], i64 0, i64 0
> -// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
> -// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
> -// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
> +// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
>  // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x
> %struct.S], [100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
>  // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
>  // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8
>
> Modified: cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> taskloop_simd_reduction_codegen.cpp?rev=308176=
> 308175=308176=diff
> 
> ==
> --- cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp Mon Jul 17
> 07:06:41 2017
> @@ -80,9 +80,7 @@ sum = 0.0;
>  // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x
> %struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]*
> [[DOTRD_INPUT_]], i64 0, i64 1
>  // CHECK:[[TMP28:%.*]] = getelementptr inbounds
> [[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t*
> [[DOTRD_INPUT_GEP_4]], i32 0, i32 0
>  // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x
> %struct.S], [100 x %struct.S]* [[C]], i64 0, i64 0
> -// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
> -// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
> -// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
> +// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
>  // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x
> %struct.S], [100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
>  // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
>  // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/Attr.td:1191
 
+def MipsLongCall : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [GCC<"long_call">, GCC<"far">, GCC<"near">];

Because this is used for all three attributes, I think you should call it 
something more general.  Perhaps MipsCallStyle?



Comment at: include/clang/Basic/Attr.td:1195
+  let Accessors = [Accessor<"longCall", [GCC<"long_call">, GCC<"far">]>,
+   Accessor<"nearCall", [GCC<"near">]>];
+  let Documentation = [MipsLongCallDocs];

This is not the standard naming convention for accessors.  I suggest 
isLongCall() and isNearCall().



Comment at: include/clang/Basic/AttrDocs.td:1336
+if code compiled using ``-mlong-calls`` switch, it forces compiler to use
+the ``jal`` instruction to call the function.
+  }];

I suggest the following wording:

Clang supports the ``__attribute__((long_call))``, ``__attribute__((far))``, and
``__attribute__((near))`` attributes on MIPS targets.  These attributes may 
only be
added to function declarations and change the code generated by the compiler 
when
directly calling the function.  The ``near`` attribute allows calls to the 
function to
be made using the ``jal`` instruction, which requires the function to be 
defined in the
same 256MB segment as the caller.  The ``long_call`` and ``far`` attributes are
synonyms and require the use of a different call sequence that works regardless 
of
the distance between the functions.

These attributes take priority over command line switches such as 
``-mlong-calls``.



Comment at: lib/CodeGen/CGCall.cpp:1810
+FuncAttrs.addAttribute("near-call");
+}
+

You should really put this in TargetCodeGenInfo::setTargetAttributes.  Please 
just add a ForDefinition_t argument to that function and SetFunctionAttributes, 
then call setTargetAttributes from SetFunctionAttributes.



Comment at: lib/Sema/SemaDeclAttr.cpp:5955
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:

You need to check for conflicts between the different attributes, and please 
add a test for that.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers

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

Committed in r308242. Thanks Dominik!


Repository:
  rL LLVM

https://reviews.llvm.org/D33645



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-17 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3412
+  if (FD->getDefinition()) {
+canEval = hasRCAnnotation(FD->getDefinition(),
+  "rc_ownership_trusted_implementation");

I'd like you to keep a call to "isTrustedReferenceCountImplementation()". The 
name of the function indicates what it means (rather than how it does it), 
which will be important when/if we change how annotations are implemented (for 
example, away from using the 'annotation' attribute to a custom attribute).

Using common code to check for annotations makes a lot sense though -- can you 
call hasRCAnnotation() from inside isTrustedReferenceCountImplementation()?


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


r308243 - [OPENMP] Pacify windows buildbots, NFC.

2017-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 17 17:42:35 2017
New Revision: 308243

URL: http://llvm.org/viewvc/llvm-project?rev=308243=rev
Log:
[OPENMP] Pacify windows buildbots, NFC.

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308243=308242=308243=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 17:42:35 
2017
@@ -144,43 +144,7 @@ sum = 0.0;
 // CHECK:[[SUB12:%.*]] = sub nsw i32 [[DIV]], 1
 // CHECK:store i32 [[SUB12]], i32* [[DOTCAPTURE_EXPR_9]],
 // CHECK:[[TMP65:%.*]] = call i8* @__kmpc_omp_task_alloc(%ident_t* 
%{{.+}}, i32 [[TMP0]], i32 1, i64 888, i64 72, i32 (i32, i8*)* bitcast (i32 
(i32, %struct.kmp_task_t_with_privates*)* @{{.+}} to i32 (i32, i8*)*))
-// CHECK:[[TMP66:%.*]] = bitcast i8* [[TMP65]] to 
%struct.kmp_task_t_with_privates*
-// CHECK:[[TMP67:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], %struct.kmp_task_t_with_privates* 
[[TMP66]], i32 0, i32 0
-// CHECK:[[TMP68:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T:%.*]], 
%struct.kmp_task_t* [[TMP67]], i32 0, i32 0
-// CHECK:[[TMP69:%.*]] = load i8*, i8** [[TMP68]],
-// CHECK:[[TMP70:%.*]] = bitcast %struct.anon* [[AGG_CAPTURED]] to i8*
-// CHECK:call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[TMP69]], i8* 
[[TMP70]], i64 72, i32 8, i1 false)
-// CHECK:[[TMP71:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], %struct.kmp_task_t_with_privates* 
[[TMP66]], i32 0, i32 1
-// CHECK:[[TMP72:%.*]] = bitcast i8* [[TMP69]] to %struct.anon*
-// CHECK:[[TMP73:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T:%.*]], %struct..kmp_privates.t* [[TMP71]], i32 0, i32 0
-// CHECK:[[TMP74:%.*]] = getelementptr inbounds [[STRUCT_ANON]], 
%struct.anon* [[TMP72]], i32 0, i32 1
-// CHECK:[[REF:%.*]] = load i32*, i32** [[TMP74]],
-// CHECK:[[TMP75:%.*]] = load i32, i32* [[REF]],
-// CHECK:store i32 [[TMP75]], i32* [[TMP73]],
-// CHECK:[[TMP76:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T]], %struct..kmp_privates.t* [[TMP71]], i32 0, i32 1
-// CHECK:[[TMP77:%.*]] = getelementptr inbounds [[STRUCT_ANON]], 
%struct.anon* [[TMP72]], i32 0, i32 3
-// CHECK:[[REF13:%.*]] = load [100 x float]*, [100 x float]** [[TMP77]],
-// CHECK:[[TMP78:%.*]] = bitcast [100 x float]* [[TMP76]] to i8*
-// CHECK:[[TMP79:%.*]] = bitcast [100 x float]* [[REF13]] to i8*
-// CHECK:call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[TMP78]], i8* 
[[TMP79]], i64 400, i32 4, i1 false)
-// CHECK:[[TMP80:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T]], %struct..kmp_privates.t* [[TMP71]], i32 0, i32 2
-// CHECK:[[TMP81:%.*]] = getelementptr inbounds [[STRUCT_ANON]], 
%struct.anon* [[TMP72]], i32 0, i32 4
-// CHECK:[[REF14:%.*]] = load [100 x float]*, [100 x float]** [[TMP81]],
-// CHECK:[[TMP82:%.*]] = bitcast [100 x float]* [[TMP80]] to i8*
-// CHECK:[[TMP83:%.*]] = bitcast [100 x float]* [[REF14]] to i8*
-// CHECK:call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[TMP82]], i8* 
[[TMP83]], i64 400, i32 4, i1 false)
-// CHECK:[[TMP84:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T]], 
%struct.kmp_task_t* [[TMP67]], i32 0, i32 5
-// CHECK:store i64 0, i64* [[TMP84]],
-// CHECK:[[TMP85:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T]], 
%struct.kmp_task_t* [[TMP67]], i32 0, i32 6
-// CHECK:[[TMP86:%.*]] = load i32, i32* [[DOTCAPTURE_EXPR_9]],
-// CHECK:[[CONV15:%.*]] = sext i32 [[TMP86]] to i64
-// CHECK:store i64 [[CONV15]], i64* [[TMP85]],
-// CHECK:[[TMP87:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T]], 
%struct.kmp_task_t* [[TMP67]], i32 0, i32 7
-// CHECK:store i64 1, i64* [[TMP87]],
-// CHECK:[[TMP88:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T]], 
%struct.kmp_task_t* [[TMP67]], i32 0, i32 9
-// CHECK:store i8* [[TMP62]], i8** [[TMP88]],
-// CHECK:[[TMP89:%.*]] = load i64, i64* [[TMP87]],
-// CHECK:call void @__kmpc_taskloop(%ident_t* %{{.+}}, i32 [[TMP0]], i8* 
[[TMP65]], i32 1, i64* [[TMP84]], i64* [[TMP85]], i64 [[TMP89]], i32 0, i32 0, 
i64 0, i8* null)
+// CHECK:call void @__kmpc_taskloop(%ident_t* %{{.+}}, i32 [[TMP0]], i8* 
[[TMP65]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0, 
i8* null)
 // CHECK:call void @__kmpc_end_taskgroup(%ident_t*
 
 // CHECK:ret i32

Modified: cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp?rev=308243=308242=308243=diff

[PATCH] D35529: [COFF, ARM64] Make +reserve-x18 the default

2017-07-17 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

https://reviews.llvm.org/D35529

Files:
  docs/ClangCommandLineReference.rst
  lib/Basic/Targets.cpp
  test/Driver/coff-aarch64-fixed-x18.c


Index: test/Driver/coff-aarch64-fixed-x18.c
===
--- /dev/null
+++ test/Driver/coff-aarch64-fixed-x18.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target aarch64-windows -emit-llvm -S %s -o - | FileCheck %s
+
+// CHECK: "target-features"{{.*}}+reserve-x18
+
+void foo() {}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6694,6 +6694,16 @@
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
+
+  bool handleTargetFeatures(std::vector ,
+DiagnosticsEngine ) override {
+// Register x18 is reserved for AArch64. We make this the default for
+// AArch64 Windows target.
+WindowsTargetInfo::handleTargetFeatures(Features,
+ Diags);
+Features.push_back("+reserve-x18");
+return true;
+  }
 };
 
 class AArch64beTargetInfo : public AArch64TargetInfo {
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2073,7 +2073,7 @@
 ---
 .. option:: -ffixed-x18
 
-Reserve the x18 register (AArch64 only)
+Reserve the x18 register (AArch64 only). It is on by default for AArch64 
Windows target.
 
 .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769
 


Index: test/Driver/coff-aarch64-fixed-x18.c
===
--- /dev/null
+++ test/Driver/coff-aarch64-fixed-x18.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target aarch64-windows -emit-llvm -S %s -o - | FileCheck %s
+
+// CHECK: "target-features"{{.*}}+reserve-x18
+
+void foo() {}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6694,6 +6694,16 @@
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
+
+  bool handleTargetFeatures(std::vector ,
+DiagnosticsEngine ) override {
+// Register x18 is reserved for AArch64. We make this the default for
+// AArch64 Windows target.
+WindowsTargetInfo::handleTargetFeatures(Features,
+ Diags);
+Features.push_back("+reserve-x18");
+return true;
+  }
 };
 
 class AArch64beTargetInfo : public AArch64TargetInfo {
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2073,7 +2073,7 @@
 ---
 .. option:: -ffixed-x18
 
-Reserve the x18 register (AArch64 only)
+Reserve the x18 register (AArch64 only). It is on by default for AArch64 Windows target.
 
 .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308176 - [OPENMP] Rework tests to pacify buildbots.

2017-07-17 Thread Alexey Bataev via cfe-commits
Hi Galina, thanks for the info. Will fix them ASAP.

Best regards,
Alexey Bataev

17 июля 2017 г., в 18:24, Galina Kistanova 
> написал(а):

Hello Alexey,

It looks like your resent commit broke couple of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

Failing Tests (2):
Clang :: OpenMP/taskloop_reduction_codegen.cpp
Clang :: OpenMP/taskloop_simd_reduction_codegen.cpp

Please have a look?

Thanks

Galina

On Mon, Jul 17, 2017 at 7:06 AM, Alexey Bataev via cfe-commits 
> wrote:
Author: abataev
Date: Mon Jul 17 07:06:41 2017
New Revision: 308176

URL: http://llvm.org/viewvc/llvm-project?rev=308176=rev
Log:
[OPENMP] Rework tests to pacify buildbots.

Modified:
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp?rev=308176=308175=308176=diff
==
--- cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp Mon Jul 17 07:06:41 
2017
@@ -80,9 +80,7 @@ sum = 0.0;
 // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 1
 // CHECK:[[TMP28:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 0
 // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 0
-// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
-// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
-// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
+// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
 // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
 // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
 // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8

Modified: cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp?rev=308176=308175=308176=diff
==
--- cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp Mon Jul 17 
07:06:41 2017
@@ -80,9 +80,7 @@ sum = 0.0;
 // CHECK:[[DOTRD_INPUT_GEP_4:%.*]] = getelementptr inbounds [4 x 
%struct.kmp_task_red_input_t], [4 x %struct.kmp_task_red_input_t]* 
[[DOTRD_INPUT_]], i64 0, i64 1
 // CHECK:[[TMP28:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_RED_INPUT_T]], %struct.kmp_task_red_input_t* 
[[DOTRD_INPUT_GEP_4]], i32 0, i32 0
 // CHECK:[[ARRAYIDX5:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 0
-// CHECK:[[TMP29:%.*]] = load i32, i32* [[N]], align 4
-// CHECK:[[TMP30:%.*]] = sext i32 [[TMP29]] to i64
-// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, [[TMP30]]
+// CHECK:[[LB_ADD_LEN:%.*]] = add nsw i64 -1, %
 // CHECK:[[ARRAYIDX6:%.*]] = getelementptr inbounds [100 x %struct.S], 
[100 x %struct.S]* [[C]], i64 0, i64 [[LB_ADD_LEN]]
 // CHECK:[[TMP31:%.*]] = bitcast %struct.S* [[ARRAYIDX5]] to i8*
 // CHECK:store i8* [[TMP31]], i8** [[TMP28]], align 8


___
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


r308242 - [analyzer] Add missing documentation for static analyzer checkers

2017-07-17 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jul 17 17:34:57 2017
New Revision: 308242

URL: http://llvm.org/viewvc/llvm-project?rev=308242=rev
Log:
[analyzer] Add missing documentation for static analyzer checkers

Some checks did not have documentation in the www/analyzer/ folder and also
some alpha checks became non-alpha.

Patch by Dominik Szabó!

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

Modified:
cfe/trunk/www/analyzer/alpha_checks.html
cfe/trunk/www/analyzer/available_checks.html
cfe/trunk/www/analyzer/implicit_checks.html

Modified: cfe/trunk/www/analyzer/alpha_checks.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/alpha_checks.html?rev=308242=308241=308242=diff
==
--- cfe/trunk/www/analyzer/alpha_checks.html (original)
+++ cfe/trunk/www/analyzer/alpha_checks.html Mon Jul 17 17:34:57 2017
@@ -24,6 +24,7 @@ keep them from being on by default. They
 Bug reports are welcome but will likely not be investigated for some time.
 Patches welcome!
 
+Clone Alpha Checkers
 Core Alpha Checkers
 C++ Alpha Checkers
 Variable Argument Alpha Checkers
@@ -33,6 +34,38 @@ Patches welcome!
 Unix Alpha Checkers
 
 
+
+
+Clone Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.clone.CloneChecker
+(C, C++, ObjC)
+Reports similar pieces of code.
+
+
+void log();
+
+int max(int a, int b) { // warn
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int x, int y) { // similar code here
+  log();
+  if (x > y)
+return x;
+  return y;
+}
+
+
+
 
 Core Alpha Checkers
 
@@ -53,6 +86,28 @@ void test() {
 
 
 
+alpha.core.CallAndMessageUnInitRefArg
+(C, C++)
+Check for uninitialized arguments in function calls and Objective-C 
+message expressions.
+
+
+void test(void) {
+  int t;
+  int  = t;
+  int  = p;
+  int  = s;
+  foo(q); // warn
+}
+
+
+void test(void) {
+  int x;
+  foo(); // warn
+}
+
+
+
 alpha.core.CastSize
 (C)
 Check when casting a malloc'ed type T, whether the size is a multiple of the 
@@ -91,6 +146,47 @@ void test(int *p) {
 
 
 
+alpha.core.Conversion
+(C, C++, ObjC)
+Loss of sign or precision in implicit conversions
+
+
+void test(unsigned U, signed S) {
+  if (S > 10) {
+if (U < S) {
+}
+  }
+  if (S < -10) {
+if (U < S) { // warn (loss of sign)
+}
+  }
+}
+
+
+void test() {
+  long long A = 1LL << 60;
+  short X = A; // warn (loss of precision)
+}
+
+
+
+
+alpha.core.DynamicTypeChecker
+(ObjC)
+Check for cases where the dynamic and the static type of an 
+object are unrelated.
+
+
+id date = [NSDate date];
+
+// Warning: Object has a dynamic type 'NSDate *' which is 
+// incompatible with static type 'NSNumber *'"
+NSNumber *number = date;
+[number doubleValue];
+
+
+
+
 alpha.core.FixedAddr
 (C)
 Check for assignment of a fixed address to a pointer.
@@ -178,6 +274,21 @@ int test(struct s *p) {
 }
 
 
+
+
+alpha.core.TestAfterDivZero
+(C, C++, ObjC)
+Check for division by variable that is later compared against 0. 
+Either the comparison is useless or there is division by zero.
+
+
+
+void test(int x) {
+  var = 77 / x;
+  if (x == 0) { } // warn 
+}
+
+
 
 
 
@@ -188,19 +299,6 @@ int test(struct s *p) {
 
 
 
-alpha.cplusplus.NewDeleteLeaks
-(C++)
-Check for memory leaks. Traces memory managed by new/
-delete.
-
-
-void test() {
-  int *p = new int;
-} // warn
-
-
-
-
 alpha.cplusplus.VirtualCall
 (C++)
 Check virtual member function calls during construction or 
@@ -345,66 +443,6 @@ void test(id x) {
 
 
 
-alpha.osx.cocoa.Dealloc
-(ObjC)
-Warn about Objective-C classes that lack a correct implementation 
-of -dealloc.
-
-
-
-@interface MyObject : NSObject {
-  id _myproperty;  
-}
-@end
-
-@implementation MyObject // warn: lacks 'dealloc'
-@end
-
-
-@interface MyObject : NSObject {}
-@property(assign) id myproperty;
-@end
-
-@implementation MyObject // warn: does not send 'dealloc' to super
-- (void)dealloc {
-  self.myproperty = 0;
-}
-@end
-
-
-@interface MyObject : NSObject {
-  id _myproperty;
-}
-@property(retain) id myproperty;
-@end
-
-@implementation MyObject
-@synthesize myproperty = _myproperty;
-  // warn: var was retained but wasn't released
-- (void)dealloc {
-  [super dealloc];
-}
-@end
-
-
-@interface MyObject : NSObject {
-  id _myproperty;
-}
-@property(assign) id myproperty;
-@end
-
-@implementation MyObject
-@synthesize myproperty = _myproperty;
-  // warn: var wasn't retained but was released
-- (void)dealloc {
-  [_myproperty release];
-  [super dealloc];
-}
-@end
-
-
-
-
 alpha.osx.cocoa.DirectIvarAssignment
 (ObjC)
 Check that Objective C properties follow the following rule: the property 
@@ -501,6 +539,32 @@ invalidatable instance variables.<
 @end
 
 
+
+
+alpha.osx.cocoa.localizability.PluralMisuseChecker
+(ObjC)
+Warns against using one vs. many plural pattern in code 
+when generating localized strings.
+
+
+
+NSString *reminderText = 
+  NSLocalizedString(@"None", @"Indicates no reminders");
+if (reminderCount == 1) {
+  // 

[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers

2017-07-17 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308242: [analyzer] Add missing documentation for static 
analyzer checkers (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D33645?vs=106184=106989#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33645

Files:
  cfe/trunk/www/analyzer/alpha_checks.html
  cfe/trunk/www/analyzer/available_checks.html
  cfe/trunk/www/analyzer/implicit_checks.html

Index: cfe/trunk/www/analyzer/alpha_checks.html
===
--- cfe/trunk/www/analyzer/alpha_checks.html
+++ cfe/trunk/www/analyzer/alpha_checks.html
@@ -24,6 +24,7 @@
 Bug reports are welcome but will likely not be investigated for some time.
 Patches welcome!
 
+Clone Alpha Checkers
 Core Alpha Checkers
 C++ Alpha Checkers
 Variable Argument Alpha Checkers
@@ -33,6 +34,38 @@
 Unix Alpha Checkers
 
 
+
+
+Clone Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.clone.CloneChecker
+(C, C++, ObjC)
+Reports similar pieces of code.
+
+
+void log();
+
+int max(int a, int b) { // warn
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int x, int y) { // similar code here
+  log();
+  if (x > y)
+return x;
+  return y;
+}
+
+
+
 
 Core Alpha Checkers
 
@@ -53,6 +86,28 @@
 
 
 
+alpha.core.CallAndMessageUnInitRefArg
+(C, C++)
+Check for uninitialized arguments in function calls and Objective-C 
+message expressions.
+
+
+void test(void) {
+  int t;
+  int  = t;
+  int  = p;
+  int  = s;
+  foo(q); // warn
+}
+
+
+void test(void) {
+  int x;
+  foo(); // warn
+}
+
+
+
 alpha.core.CastSize
 (C)
 Check when casting a malloc'ed type T, whether the size is a multiple of the 
@@ -91,6 +146,47 @@
 
 
 
+alpha.core.Conversion
+(C, C++, ObjC)
+Loss of sign or precision in implicit conversions
+
+
+void test(unsigned U, signed S) {
+  if (S > 10) {
+if (U < S) {
+}
+  }
+  if (S < -10) {
+if (U < S) { // warn (loss of sign)
+}
+  }
+}
+
+
+void test() {
+  long long A = 1LL << 60;
+  short X = A; // warn (loss of precision)
+}
+
+
+
+
+alpha.core.DynamicTypeChecker
+(ObjC)
+Check for cases where the dynamic and the static type of an 
+object are unrelated.
+
+
+id date = [NSDate date];
+
+// Warning: Object has a dynamic type 'NSDate *' which is 
+// incompatible with static type 'NSNumber *'"
+NSNumber *number = date;
+[number doubleValue];
+
+
+
+
 alpha.core.FixedAddr
 (C)
 Check for assignment of a fixed address to a pointer.
@@ -178,6 +274,21 @@
 }
 
 
+
+
+alpha.core.TestAfterDivZero
+(C, C++, ObjC)
+Check for division by variable that is later compared against 0. 
+Either the comparison is useless or there is division by zero.
+
+
+
+void test(int x) {
+  var = 77 / x;
+  if (x == 0) { } // warn 
+}
+
+
 
 
 
@@ -188,19 +299,6 @@
 
 
 
-alpha.cplusplus.NewDeleteLeaks
-(C++)
-Check for memory leaks. Traces memory managed by new/
-delete.
-
-
-void test() {
-  int *p = new int;
-} // warn
-
-
-
-
 alpha.cplusplus.VirtualCall
 (C++)
 Check virtual member function calls during construction or 
@@ -345,66 +443,6 @@
 
 
 
-alpha.osx.cocoa.Dealloc
-(ObjC)
-Warn about Objective-C classes that lack a correct implementation 
-of -dealloc.
-
-
-
-@interface MyObject : NSObject {
-  id _myproperty;  
-}
-@end
-
-@implementation MyObject // warn: lacks 'dealloc'
-@end
-
-
-@interface MyObject : NSObject {}
-@property(assign) id myproperty;
-@end
-
-@implementation MyObject // warn: does not send 'dealloc' to super
-- (void)dealloc {
-  self.myproperty = 0;
-}
-@end
-
-
-@interface MyObject : NSObject {
-  id _myproperty;
-}
-@property(retain) id myproperty;
-@end
-
-@implementation MyObject
-@synthesize myproperty = _myproperty;
-  // warn: var was retained but wasn't released
-- (void)dealloc {
-  [super dealloc];
-}
-@end
-
-
-@interface MyObject : NSObject {
-  id _myproperty;
-}
-@property(assign) id myproperty;
-@end
-
-@implementation MyObject
-@synthesize myproperty = _myproperty;
-  // warn: var wasn't retained but was released
-- (void)dealloc {
-  [_myproperty release];
-  [super dealloc];
-}
-@end
-
-
-
-
 alpha.osx.cocoa.DirectIvarAssignment
 (ObjC)
 Check that Objective C properties follow the following rule: the property 
@@ -501,6 +539,32 @@
 @end
 
 
+
+
+alpha.osx.cocoa.localizability.PluralMisuseChecker
+(ObjC)
+Warns against using one vs. many plural pattern in code 
+when generating localized strings.
+
+
+
+NSString *reminderText = 
+  NSLocalizedString(@"None", @"Indicates no reminders");
+if (reminderCount == 1) {
+  // Warning: Plural cases are not supported accross all languages. 
+  // Use a .stringsdict file instead
+  reminderText = 
+NSLocalizedString(@"1 Reminder", @"Indicates single reminder");
+} else if (reminderCount >= 2) {
+  // Warning: Plural cases are not supported accross all languages.
+  // Use a .stringsdict file instead
+  reminderText = 
+[NSString stringWithFormat:
+  NSLocalizedString(@"%@ Reminders", 

[PATCH] D34430: [Clang][TypoCorrection] Clang hangs in typo correction

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

Looks good, but I don't know this code well enough to stamp LGTM. Richard?


Repository:
  rL LLVM

https://reviews.llvm.org/D34430



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

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

> So, should I submit another patch on the same revision after modifying the 
> title, summary, etc. or should I create another revision for that?

You should create another revision. You can mark it as dependent on this one in 
Phabricator.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


[PATCH] D35438: CodeGen: Insert addr space cast for automatic/temp var at right position

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

LGTM.


https://reviews.llvm.org/D35438



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


[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Attribute 'target' can take either features or architectures.  This patch 
accomplishes this in a couple of ways:

1- It adds support to Targets.cpp for "isValidCPUName" and 
"isValidFeatureName".  HOWEVER, the latter is only implemented for X86.  I'm 
hoping to delay implementation of those until later (or get help on that).
2- Cleans up the 'target' entry in Attr.td to use a struct instead of a 'Pair', 
so that more data can be included.  
3- Validates the attribute sufficiently.

Note that we currently do not have multi-versioning support (that is to come in 
a future patch) and SemaDeclAttr.cpp lacks knowledge of whether this is a 
multi-version, so this validation doesn't cover the multi-versioning case.


https://reviews.llvm.org/D35519

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-target.c

Index: test/Sema/attr-target.c
===
--- test/Sema/attr-target.c
+++ test/Sema/attr-target.c
@@ -4,5 +4,8 @@
 int __attribute__((target())) bar() { return 4; } //expected-error {{'target' attribute takes one argument}}
 int __attribute__((target("tune=sandybridge"))) baz() { return 4; } //expected-warning {{Ignoring unsupported 'tune=' in the target attribute string}}
 int __attribute__((target("fpmath=387"))) walrus() { return 4; } //expected-warning {{Ignoring unsupported 'fpmath=' in the target attribute string}}
+int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() {  return 4; }//expected-warning {{Ignoring unsupported architecture 'hiss' in the target attribute string}}
+int __attribute__((target("woof"))) bark() {  return 4; }//expected-warning {{Ignoring unsupported 'woof' in the target attribute string}}
+
 
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2993,22 +2993,38 @@
 D->addAttr(NewAttr);
 }
 
-// Check for things we'd like to warn about, no errors or validation for now.
-// TODO: Validation should use a backend target library that specifies
-// the allowable subtarget features and cpus. We could use something like a
-// TargetCodeGenInfo hook here to do validation.
-void Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+// Check for things we'd like to warn about. Multiversioning issues are 
+// handled later in the process, once we know how many exist.
+bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
   for (auto Str : {"tune=", "fpmath="})
 if (AttrStr.find(Str) != StringRef::npos)
-  Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
+
+  TargetAttr::ParsedTargetAttr ParsedAttrs = TargetAttr::parse(AttrStr);
+  if(ParsedAttrs.DuplicateArchitecture)
+return Diag(LiteralLoc, diag::warn_duplicate_target_attribute) << "arch";
+
+  if (!ParsedAttrs.Architecture.empty() &&
+  !Context.getTargetInfo().isValidCPUName(ParsedAttrs.Architecture))
+return Diag(LiteralLoc, diag::warn_unsupported_target_architecture)
+   << ParsedAttrs.Architecture;
+
+  for (auto  : ParsedAttrs.Features) {
+auto CurFeature = StringRef(Feature).drop_front();// remove + or -.
+if (!Context.getTargetInfo().isValidFeatureName(CurFeature))
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << CurFeature;
+  }
+
+  return true;
 }
 
 static void handleTargetAttr(Sema , Decl *D, const AttributeList ) {
   StringRef Str;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ))
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ) ||
+  !S.checkTargetAttr(LiteralLoc, Str))
 return;
-  S.checkTargetAttr(LiteralLoc, Str);
   unsigned Index = Attr.getAttributeSpellingListIndex();
   TargetAttr *NewAttr =
   ::new (S.Context) TargetAttr(Attr.getRange(), S.Context, Str, Index);
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4499,18 +4499,19 @@
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
+if (ParsedAttr.Architecture != "")
+  TargetCPU = 

[PATCH] D35520: [Sema] Improve diagnostic message for unavailable c++17 aligned allocation functions

2017-07-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This changes the error message Sema prints when an unavailable c++17 aligned 
allocation function is selected.

Original message: "... possibly unavailable on x86_64-apple-macos10.12"
New message: "... only available on macosx 10.13 or newer"

This is a follow-up to r306722.


https://reviews.llvm.org/D35520

Files:
  include/clang/Basic/AlignedAllocation.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Driver/ToolChains/Darwin.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/unavailable_aligned_allocation.cpp

Index: test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- test/SemaCXX/unavailable_aligned_allocation.cpp
+++ test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -56,44 +62,68 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' possibly unavailable on}}
+// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' possibly unavailable on}}
+// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
 // expected-note@-29 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-29 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-29 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-30 {{if you supply your own aligned allocation functions}}
-// expected-error@-31 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-31 {{aligned deallocation 

[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> Could something like _WIN32 && _MSC_VER make this better?  That would allow 
> us to differentiate between the various environments.  It's kinda icky, but, 
> does make sense in a round about way.

The check in the patch was already under a `#if defined(_WIN32)`, having to 
repeat that again seemed not worth the effort!

> Another bad idea: -U_MSC_VER.  The undefine should come after the 
> preprocessor is initialized and should have the same effect as not having it 
> defined.

That's a bit non canonical :-)

In https://reviews.llvm.org/D34588#808076, @rnk wrote:

> > Some non-windows targets using MS extensions define _WIN32 for 
> > compatibility with Windows but do not have MSVC compatibility.
>
> So, these hypothetical targets have the Win32 API available, but they do not 
> use the MSVC CRT, correct?


Right.

Thanks for the review! Committed r308225.


Repository:
  rL LLVM

https://reviews.llvm.org/D34588



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


[PATCH] D35388: [libc++] Give extern templates default visibility on gcc

2017-07-17 Thread Tom Anderson via Phabricator via cfe-commits
thomasanderson added a comment.

Friendly ping for @EricWF


https://reviews.llvm.org/D35388



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


r308222 - [COFF, ARM64] Set the data type widths and the data layout string

2017-07-17 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Mon Jul 17 14:10:45 2017
New Revision: 308222

URL: http://llvm.org/viewvc/llvm-project?rev=308222=rev
Log:
[COFF, ARM64] Set the data type widths and the data layout string

Summary: COFF ARM64 is LLP64 platform. So int is 4 bytes, long is 4 bytes and 
long long is 8 bytes.

Reviewers: compnerd, ruiu, rnk, efriedma

Reviewed By: compnerd, efriedma

Subscribers: efriedma, javed.absar, cfe-commits, aemerson, llvm-commits, 
kristof.beyls

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

Added:
cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=308222=308221=308222=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 17 14:10:45 2017
@@ -6654,13 +6654,26 @@ public:
   MicrosoftARM64TargetInfo(const llvm::Triple ,
  const TargetOptions )
   : WindowsTargetInfo(Triple, Opts), Triple(Triple) {
+
+// This is an LLP64 platform.
+// int:4, long:4, long long:8, long double:8.
 WCharType = UnsignedShort;
+IntWidth = IntAlign = 32;
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = ::APFloat::IEEEdouble();
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
 SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+
 TheCXXABI.set(TargetCXXABI::Microsoft);
   }
 
   void setDataLayout() override {
-resetDataLayout("e-m:w-i64:64-i128:128-n32:64-S128");
+resetDataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128");
   }
 
   void getVisualStudioDefines(const LangOptions ,

Added: cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c?rev=308222=auto
==
--- cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c (added)
+++ cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c Mon Jul 17 14:10:45 2017
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s
+
+// CHECK: target datalayout = 
"e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
+// CHECK: target triple = "aarch64--windows-msvc"
+
+int check_short() {
+  return sizeof(short);
+// CHECK: ret i32 2
+}
+
+int check_int() {
+  return sizeof(int);
+// CHECK: ret i32 4
+}
+
+int check_long() {
+  return sizeof(long);
+// CHECK: ret i32 4
+}
+
+int check_longlong() {
+  return sizeof(long long);
+// CHECK: ret i32 8
+}
+
+int check_int128() {
+  return sizeof(__int128);
+// CHECK: ret i32 16
+}
+
+int check_fp16() {
+  return sizeof(__fp16);
+// CHECK: ret i32 2
+}
+
+int check_float() {
+  return sizeof(float);
+// CHECK: ret i32 4
+}
+
+int check_double() {
+  return sizeof(double);
+// CHECK: ret i32 8
+}
+
+int check_longdouble() {
+  return sizeof(long double);
+// CHECK: ret i32 8
+}
+
+int check_floatComplex() {
+  return sizeof(float _Complex);
+// CHECK: ret i32 8
+}
+
+int check_doubleComplex() {
+  return sizeof(double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_longdoubleComplex() {
+  return sizeof(long double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_bool() {
+  return sizeof(_Bool);
+// CHECK: ret i32 1
+}
+
+int check_wchar() {
+  return sizeof(__WCHAR_TYPE__);
+// CHECK: ret i32 2
+}
+
+int check_wchar_unsigned() {
+  return (__WCHAR_TYPE__)-1 > (__WCHAR_TYPE__)0;
+// CHECK: ret i32 1
+}
+
+enum Small {
+  Item
+};
+
+int foo() {
+  return sizeof(enum Small);
+// CHECK: ret i32 4
+}


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


[PATCH] D34859: [COFF, ARM64] Set the data type widths and the data layout string

2017-07-17 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308222: [COFF, ARM64] Set the data type widths and the data 
layout string (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D34859?vs=106925=106952#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34859

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6654,13 +6654,26 @@
   MicrosoftARM64TargetInfo(const llvm::Triple ,
  const TargetOptions )
   : WindowsTargetInfo(Triple, Opts), Triple(Triple) {
+
+// This is an LLP64 platform.
+// int:4, long:4, long long:8, long double:8.
 WCharType = UnsignedShort;
+IntWidth = IntAlign = 32;
+LongWidth = LongAlign = 32;
+DoubleAlign = LongLongAlign = 64;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongDoubleFormat = ::APFloat::IEEEdouble();
+IntMaxType = SignedLongLong;
+Int64Type = SignedLongLong;
 SizeType = UnsignedLongLong;
+PtrDiffType = SignedLongLong;
+IntPtrType = SignedLongLong;
+
 TheCXXABI.set(TargetCXXABI::Microsoft);
   }
 
   void setDataLayout() override {
-resetDataLayout("e-m:w-i64:64-i128:128-n32:64-S128");
+resetDataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128");
   }
 
   void getVisualStudioDefines(const LangOptions ,
Index: cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c
===
--- cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c
+++ cfe/trunk/test/CodeGen/coff-aarch64-type-sizes.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s
+
+// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
+// CHECK: target triple = "aarch64--windows-msvc"
+
+int check_short() {
+  return sizeof(short);
+// CHECK: ret i32 2
+}
+
+int check_int() {
+  return sizeof(int);
+// CHECK: ret i32 4
+}
+
+int check_long() {
+  return sizeof(long);
+// CHECK: ret i32 4
+}
+
+int check_longlong() {
+  return sizeof(long long);
+// CHECK: ret i32 8
+}
+
+int check_int128() {
+  return sizeof(__int128);
+// CHECK: ret i32 16
+}
+
+int check_fp16() {
+  return sizeof(__fp16);
+// CHECK: ret i32 2
+}
+
+int check_float() {
+  return sizeof(float);
+// CHECK: ret i32 4
+}
+
+int check_double() {
+  return sizeof(double);
+// CHECK: ret i32 8
+}
+
+int check_longdouble() {
+  return sizeof(long double);
+// CHECK: ret i32 8
+}
+
+int check_floatComplex() {
+  return sizeof(float _Complex);
+// CHECK: ret i32 8
+}
+
+int check_doubleComplex() {
+  return sizeof(double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_longdoubleComplex() {
+  return sizeof(long double _Complex);
+// CHECK: ret i32 16
+}
+
+int check_bool() {
+  return sizeof(_Bool);
+// CHECK: ret i32 1
+}
+
+int check_wchar() {
+  return sizeof(__WCHAR_TYPE__);
+// CHECK: ret i32 2
+}
+
+int check_wchar_unsigned() {
+  return (__WCHAR_TYPE__)-1 > (__WCHAR_TYPE__)0;
+// CHECK: ret i32 1
+}
+
+enum Small {
+  Item
+};
+
+int foo() {
+  return sizeof(enum Small);
+// CHECK: ret i32 4
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits