[libcxx] r268709 - Fix errors in documentation

2016-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  5 23:49:30 2016
New Revision: 268709

URL: http://llvm.org/viewvc/llvm-project?rev=268709=rev
Log:
Fix errors in documentation

Modified:
libcxx/trunk/docs/UsingLibcxx.rst

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=268709=268708=268709=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Thu May  5 23:49:30 2016
@@ -54,7 +54,7 @@ Using libc++experimental and 
-headers may requiring linking with ``-lc++experimental``.
+headers may be required to link ``-lc++experimental``.
 
 .. code-block:: bash
 


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


[libclc] r268708 - math: Add fdim implementation

2016-05-05 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Thu May  5 22:34:45 2016
New Revision: 268708

URL: http://llvm.org/viewvc/llvm-project?rev=268708=rev
Log:
math: Add fdim implementation

Based on the amd-builtin, but explicitly vectorized for all sizes (not just
float4), and includes a vectorized double implementation.

Passes piglit (float) tests on pitcairn.

Signed-off-by: Aaron Watry 
Reviewed-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/fdim.h
libclc/trunk/generic/include/clc/math/fdim.inc
libclc/trunk/generic/lib/math/fdim.cl
libclc/trunk/generic/lib/math/fdim.inc
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=268708=268707=268708=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu May  5 22:34:45 2016
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/fdim.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fdim.h?rev=268708=auto
==
--- libclc/trunk/generic/include/clc/math/fdim.h (added)
+++ libclc/trunk/generic/include/clc/math/fdim.h Thu May  5 22:34:45 2016
@@ -0,0 +1,2 @@
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/include/clc/math/fdim.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fdim.inc?rev=268708=auto
==
--- libclc/trunk/generic/include/clc/math/fdim.inc (added)
+++ libclc/trunk/generic/include/clc/math/fdim.inc Thu May  5 22:34:45 2016
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fdim(__CLC_GENTYPE a, __CLC_GENTYPE b);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=268708=268707=268708=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu May  5 22:34:45 2016
@@ -82,6 +82,7 @@ math/exp.cl
 math/exp_helper.cl
 math/exp2.cl
 math/exp10.cl
+math/fdim.cl
 math/fmax.cl
 math/fmin.cl
 math/fmod.cl

Added: libclc/trunk/generic/lib/math/fdim.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fdim.cl?rev=268708=auto
==
--- libclc/trunk/generic/lib/math/fdim.cl (added)
+++ libclc/trunk/generic/lib/math/fdim.cl Thu May  5 22:34:45 2016
@@ -0,0 +1,10 @@
+#include 
+
+#include "math.h"
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/lib/math/fdim.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/fdim.inc?rev=268708=auto
==
--- libclc/trunk/generic/lib/math/fdim.inc (added)
+++ libclc/trunk/generic/lib/math/fdim.inc Thu May  5 22:34:45 2016
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ * Copyright (c) 2016 Aaron Watry
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#if __CLC_FPSIZE == 32
+#ifdef __CLC_SCALAR
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE fdim(__CLC_GENTYPE x, __CLC_GENTYPE y) {
+if (__builtin_isnan(x) || __builtin_isnan(y))
+return as_float(QNANBITPATT_SP32);
+return __builtin_fmax(x - y, 0);
+}
+#define __CLC_FDIM_VEC(width) \
+_CLC_OVERLOAD _CLC_DEF float##width fdim(float##width x, float##width y) { \
+/* Determine if x or y is NaN. */ \
+/* 

Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-05 Thread Felix Berger via cfe-commits
flx added a comment.

In http://reviews.llvm.org/D19865#419905, @flx wrote:

> In http://reviews.llvm.org/D19865#419830, @alexfh wrote:
>
> > Is it a workaround to avoid breaking the code by incorrect fixes?
>
>
> Yes. We can't simply change the type of DeclStmt when we only look one of the 
> VarDecls and how it is initialized.


Also, all tests still pass. Alex, do you have any particular concern with this 
approach?


Repository:
  rL LLVM

http://reviews.llvm.org/D19865



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-05 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM after the minor fixes. Thank you for the patch.



Comment at: include/__threading_support:38
@@ +37,3 @@
+{
+pthread_mutexattr_t attr;
+int ec = pthread_mutexattr_init();

`ec` -> `__ec`.


Comment at: include/__threading_support:125
@@ +124,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{

Let's make the return type bool so it's clear.


Comment at: include/__threading_support:127
@@ +126,3 @@
+{
+return pthread_equal(t1, t2) != 0 ? 1 : 0;
+}

`return pthread_equal(t1, t2) != 0;`


Comment at: include/__threading_support:132
@@ +131,3 @@
+inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
+{

Make the return type `bool`.


Comment at: include/__threading_support:134
@@ +133,3 @@
+{
+return t1 < t2 ? 1 : 0;
+}

`return t1 < t2; `


Comment at: include/thread:200
@@ -198,3 +199,3 @@
 pointer __p = get();
-pthread_setspecific(__key_, 0);
+__libcpp_tl_set(__key_, 0);
 return __p;

Nit: Use `nullptr`.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Steven Wu via cfe-commits
steven_wu added a comment.

Attach a new patch with the comments



Comment at: lib/CodeGen/BackendUtil.cpp:799-831
@@ +798,35 @@
+  // Embed the bitcode for the llvm module.
+  std::string Data;
+  ArrayRef ModuleData;
+  Triple T(M->getTargetTriple());
+  if (CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Marker) {
+if (!isBitcode((const unsigned char *)Buf.getBufferStart(),
+   (const unsigned char *)Buf.getBufferEnd())) {
+  // If the input is LLVM Assembly, bitcode is produced by serializing
+  // the module. Use-lists order need to be perserved in this case.
+  llvm::raw_string_ostream OS(Data);
+  llvm::WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
+  ModuleData =
+  ArrayRef((const uint8_t *)OS.str().data(), OS.str().size());
+} else
+  // If the input is LLVM bitcode, write the input byte stream directly.
+  ModuleData = ArrayRef((const uint8_t *)Buf.getBufferStart(),
+ Buf.getBufferSize());
+  }
+  llvm::Constant *ModuleConstant =
+  llvm::ConstantDataArray::get(M->getContext(), ModuleData);
+  // Use Appending linkage so it doesn't get optimized out.
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  *M, ModuleConstant->getType(), true, llvm::GlobalValue::AppendingLinkage,
+  ModuleConstant);
+  GV->setSection(getSectionNameForBitcode(T));
+  if (llvm::GlobalVariable *Old =
+  M->getGlobalVariable("llvm.embedded.module")) {
+assert(Old->use_empty() && "llvm.embedded.module must have no uses");
+GV->takeName(Old);
+Old->eraseFromParent();
+  } else {
+GV->setName("llvm.embedded.module");
+  }
+
+  // Return if only bitcode needs to be embedded.

rsmith wrote:
> I see, the "marker" is an empty `llvm.embedded.module` constant. Please add a 
> comment to that effect; that's not obvious.
Sure. 


Comment at: lib/Driver/Tools.cpp:5710-5714
@@ -5709,4 +5709,7 @@
   // by the frontend.
-  if (C.getDriver().isSaveTempsEnabled() && isa(JA))
+  // When -fembed-bitcode is enabled, optimized bitcode is emitted because it
+  // has slightly different breakdown between stages.
+  if (C.getDriver().isSaveTempsEnabled() &&
+  !C.getDriver().embedBitcodeEnabled() && isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");
 

rsmith wrote:
> This means that `-fembed-bitcode -save-temps` will save different 
> intermediate IR than `-save-temps` alone; that seems wrong. I would expect 
> that process to save the unoptimized IR but embed the optimized IR. Getting 
> that right will probably require adding another action to the pipeline for 
> that combination of flags.
That is exactly the case. I will add a FIXME here.


http://reviews.llvm.org/D17392



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Steven Wu via cfe-commits
steven_wu updated this revision to Diff 56371.
steven_wu marked 2 inline comments as done.
steven_wu added a comment.

Add comments to address the feedback fromt the review.


http://reviews.llvm.org/D17392

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/embed-bitcode.c
  test/Frontend/embed-bitcode.ll

Index: test/Frontend/embed-bitcode.ll
===
--- /dev/null
+++ test/Frontend/embed-bitcode.ll
@@ -0,0 +1,59 @@
+; REQUIRES: arm-registered-target
+; REQUIRES: aarch64-registered-target
+; check .ll input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+; RUN: %clang_cc1 -triple aarch64-unknown-linux-gnueabi -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ELF
+
+; check .bc input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-x ir %s -o %t.bc
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %t.bc -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=bitcode -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ONLY-BITCODE
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+
+; run through -fembed-bitcode twice and make sure it doesn't crash
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir - -o /dev/null
+
+; check the magic number of bitcode at the beginning of the string
+; CHECK: @llvm.embedded.module
+; CHECK: c"\DE\C0\17\0B
+; CHECK: section "__LLVM,__bitcode"
+; CHECK: @llvm.cmdline
+; CHECK: section "__LLVM,__cmdline"
+
+; CHECK-ELF: @llvm.embedded.module
+; CHECK-ELF: section ".llvmbc"
+; CHECK-ELF: @llvm.cmdline
+; CHECK-ELF: section ".llvmcmd"
+
+; CHECK-ONLY-BITCODE: @llvm.embedded.module
+; CHECK-ONLY-BITCODE: c"\DE\C0\17\0B
+; CHECK-ONLY-BITCODE: section "__LLVM,__bitcode"
+; CHECK-ONLY-BITCODE-NOT: @llvm.cmdline
+; CHECK-ONLY-BITCODE-NOT: section "__LLVM,__cmdline"
+
+; CHECK-MARKER: @llvm.embedded.module
+; CHECK-MARKER: constant [0 x i8] zeroinitializer
+; CHECK-MARKER: section "__LLVM,__bitcode"
+; CHECK-MARKER: @llvm.cmdline
+; CHECK-MARKER: section "__LLVM,__cmdline"
+
+define i32 @f0() {
+  ret i32 0
+}
Index: test/Driver/embed-bitcode.c
===
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -7,28 +7,35 @@
 // CHECK-CC: -emit-llvm-bc
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-obj
-// CHECK-CC: -fembed-bitcode
+// CHECK-CC: -fembed-bitcode=all
 
+// RUN: %clang %s -c -fembed-bitcode=bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-BITCODE
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-llvm-bc
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-obj
+// CHECK-BITCODE: -fembed-bitcode=bitcode
+//
 // RUN: %clang %s -c -save-temps -fembed-bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-SAVE-TEMP
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -E
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -emit-llvm-bc
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -S
-// CHECK-SAVE-TEMP: -fembed-bitcode
+// CHECK-SAVE-TEMP: -fembed-bitcode=all
 // CHECK-SAVE-TEMP: -cc1as
 
 // RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
 // CHECK-LTO: -cc1
 // CHECK-LTO: -emit-llvm-bc
 // CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
 // CHECK-LTO-NOT: -cc1
-// CHECK-LTO-NOT: -fembed-bitcode
+// CHECK-LTO-NOT: -fembed-bitcode=all
 
 // RUN: %clang -c %s -fembed-bitcode-marker -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-MARKER
 // CHECK-MARKER: -cc1
 // CHECK-MARKER: -emit-obj
-// CHECK-MARKER: -fembed-bitcode-marker
+// CHECK-MARKER: -fembed-bitcode=marker
 // CHECK-MARKER-NOT: -cc1
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -634,6 +634,45 @@
   }
 }
   }
+	// Handle -fembed-bitcode option.
+  if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
+StringRef Name = 

Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-05 Thread Richard Smith via cfe-commits
On Thu, May 5, 2016 at 4:44 PM, Michael Miller via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> michael_miller added inline comments.
>
> 
> Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:31
> @@ +30,3 @@
> +// Convenience utility to get a RecordDecl from a QualType.
> +const RecordDecl *getCanonicalRecordDecl(const QualType ) {
> +  if (const auto *RT = Type.getCanonicalType()->getAs())
> 
> alexfh wrote:
> > Is `getCanonicalType()` important here? Did you try using
> `QualType::getAsCXXRecordDecl()`?
> Probably not but I didn't try it. I just moved the previous function up to
> the top so I didn't have to forward declare it.
>
> One thing I'm simply unsure of is whether it's possible to get a
> RecordDecl that's not a CXXRecordDecl in C++ code. It seems like the answer
> is no but that might be another reason to keep it as is if I'm wrong about
> that...


It's fine to assume that all RecordDecls will be CXXRecordDecls in C++
code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:799-831
@@ +798,35 @@
+  // Embed the bitcode for the llvm module.
+  std::string Data;
+  ArrayRef ModuleData;
+  Triple T(M->getTargetTriple());
+  if (CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Marker) {
+if (!isBitcode((const unsigned char *)Buf.getBufferStart(),
+   (const unsigned char *)Buf.getBufferEnd())) {
+  // If the input is LLVM Assembly, bitcode is produced by serializing
+  // the module. Use-lists order need to be perserved in this case.
+  llvm::raw_string_ostream OS(Data);
+  llvm::WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
+  ModuleData =
+  ArrayRef((const uint8_t *)OS.str().data(), OS.str().size());
+} else
+  // If the input is LLVM bitcode, write the input byte stream directly.
+  ModuleData = ArrayRef((const uint8_t *)Buf.getBufferStart(),
+ Buf.getBufferSize());
+  }
+  llvm::Constant *ModuleConstant =
+  llvm::ConstantDataArray::get(M->getContext(), ModuleData);
+  // Use Appending linkage so it doesn't get optimized out.
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  *M, ModuleConstant->getType(), true, llvm::GlobalValue::AppendingLinkage,
+  ModuleConstant);
+  GV->setSection(getSectionNameForBitcode(T));
+  if (llvm::GlobalVariable *Old =
+  M->getGlobalVariable("llvm.embedded.module")) {
+assert(Old->use_empty() && "llvm.embedded.module must have no uses");
+GV->takeName(Old);
+Old->eraseFromParent();
+  } else {
+GV->setName("llvm.embedded.module");
+  }
+
+  // Return if only bitcode needs to be embedded.

I see, the "marker" is an empty `llvm.embedded.module` constant. Please add a 
comment to that effect; that's not obvious.


Comment at: lib/Driver/Tools.cpp:5710-5714
@@ -5709,4 +5709,7 @@
   // by the frontend.
-  if (C.getDriver().isSaveTempsEnabled() && isa(JA))
+  // When -fembed-bitcode is enabled, optimized bitcode is emitted because it
+  // has slightly different breakdown between stages.
+  if (C.getDriver().isSaveTempsEnabled() &&
+  !C.getDriver().embedBitcodeEnabled() && isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");
 

This means that `-fembed-bitcode -save-temps` will save different intermediate 
IR than `-save-temps` alone; that seems wrong. I would expect that process to 
save the unoptimized IR but embed the optimized IR. Getting that right will 
probably require adding another action to the pipeline for that combination of 
flags.


http://reviews.llvm.org/D17392



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


Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-05 Thread Michael Miller via cfe-commits
michael_miller added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:31
@@ +30,3 @@
+// Convenience utility to get a RecordDecl from a QualType.
+const RecordDecl *getCanonicalRecordDecl(const QualType ) {
+  if (const auto *RT = Type.getCanonicalType()->getAs())

alexfh wrote:
> Is `getCanonicalType()` important here? Did you try using 
> `QualType::getAsCXXRecordDecl()`?
Probably not but I didn't try it. I just moved the previous function up to the 
top so I didn't have to forward declare it.

One thing I'm simply unsure of is whether it's possible to get a RecordDecl 
that's not a CXXRecordDecl in C++ code. It seems like the answer is no but that 
might be another reason to keep it as is if I'm wrong about that...


http://reviews.llvm.org/D19993



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


Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-05 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:31
@@ +30,3 @@
+// Convenience utility to get a RecordDecl from a QualType.
+const RecordDecl *getCanonicalRecordDecl(const QualType ) {
+  if (const auto *RT = Type.getCanonicalType()->getAs())

Is `getCanonicalType()` important here? Did you try using 
`QualType::getAsCXXRecordDecl()`?


http://reviews.llvm.org/D19993



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Steven Wu via cfe-commits
steven_wu updated this revision to Diff 56367.
steven_wu added a comment.

Format update according to review.


http://reviews.llvm.org/D17392

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/embed-bitcode.c
  test/Frontend/embed-bitcode.ll

Index: test/Frontend/embed-bitcode.ll
===
--- /dev/null
+++ test/Frontend/embed-bitcode.ll
@@ -0,0 +1,59 @@
+; REQUIRES: arm-registered-target
+; REQUIRES: aarch64-registered-target
+; check .ll input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+; RUN: %clang_cc1 -triple aarch64-unknown-linux-gnueabi -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ELF
+
+; check .bc input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-x ir %s -o %t.bc
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir %t.bc -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=bitcode -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ONLY-BITCODE
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=marker -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+
+; run through -fembed-bitcode twice and make sure it doesn't crash
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-fembed-bitcode=all -x ir %s -o - \
+; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode=all -x ir - -o /dev/null
+
+; check the magic number of bitcode at the beginning of the string
+; CHECK: @llvm.embedded.module
+; CHECK: c"\DE\C0\17\0B
+; CHECK: section "__LLVM,__bitcode"
+; CHECK: @llvm.cmdline
+; CHECK: section "__LLVM,__cmdline"
+
+; CHECK-ELF: @llvm.embedded.module
+; CHECK-ELF: section ".llvmbc"
+; CHECK-ELF: @llvm.cmdline
+; CHECK-ELF: section ".llvmcmd"
+
+; CHECK-ONLY-BITCODE: @llvm.embedded.module
+; CHECK-ONLY-BITCODE: c"\DE\C0\17\0B
+; CHECK-ONLY-BITCODE: section "__LLVM,__bitcode"
+; CHECK-ONLY-BITCODE-NOT: @llvm.cmdline
+; CHECK-ONLY-BITCODE-NOT: section "__LLVM,__cmdline"
+
+; CHECK-MARKER: @llvm.embedded.module
+; CHECK-MARKER: constant [0 x i8] zeroinitializer
+; CHECK-MARKER: section "__LLVM,__bitcode"
+; CHECK-MARKER: @llvm.cmdline
+; CHECK-MARKER: section "__LLVM,__cmdline"
+
+define i32 @f0() {
+  ret i32 0
+}
Index: test/Driver/embed-bitcode.c
===
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -7,28 +7,35 @@
 // CHECK-CC: -emit-llvm-bc
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-obj
-// CHECK-CC: -fembed-bitcode
+// CHECK-CC: -fembed-bitcode=all
 
+// RUN: %clang %s -c -fembed-bitcode=bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-BITCODE
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-llvm-bc
+// CHECK-BITCODE: -cc1
+// CHECK-BITCODE: -emit-obj
+// CHECK-BITCODE: -fembed-bitcode=bitcode
+//
 // RUN: %clang %s -c -save-temps -fembed-bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-SAVE-TEMP
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -E
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -emit-llvm-bc
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -S
-// CHECK-SAVE-TEMP: -fembed-bitcode
+// CHECK-SAVE-TEMP: -fembed-bitcode=all
 // CHECK-SAVE-TEMP: -cc1as
 
 // RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
 // CHECK-LTO: -cc1
 // CHECK-LTO: -emit-llvm-bc
 // CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
 // CHECK-LTO-NOT: -cc1
-// CHECK-LTO-NOT: -fembed-bitcode
+// CHECK-LTO-NOT: -fembed-bitcode=all
 
 // RUN: %clang -c %s -fembed-bitcode-marker -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-MARKER
 // CHECK-MARKER: -cc1
 // CHECK-MARKER: -emit-obj
-// CHECK-MARKER: -fembed-bitcode-marker
+// CHECK-MARKER: -fembed-bitcode=marker
 // CHECK-MARKER-NOT: -cc1
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -634,6 +634,45 @@
   }
 }
   }
+	// Handle -fembed-bitcode option.
+  if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
+StringRef Name = A->getValue();
+unsigned Model = llvm::StringSwitch(Name)
+

Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Steven Wu via cfe-commits
steven_wu added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:769-770
@@ +768,4 @@
+void clang::EmbedBitcode(llvm::Module *M, const CodeGenOptions ,
+ llvm::MemoryBufferRef Buf)
+{
+  if (CGOpts.getEmbedBitcode() == CodeGenOptions::Embed_Off)

rsmith wrote:
> Ping.
Sorry, I missed this. Will fix.


Comment at: lib/CodeGen/BackendUtil.cpp:774-806
@@ +773,35 @@
+
+  // Embed the bitcode for the llvm module.
+  std::string Data;
+  ArrayRef ModuleData;
+  Triple T(M->getTargetTriple());
+  if (CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Marker) {
+if (!isBitcode((const unsigned char *)Buf.getBufferStart(),
+   (const unsigned char *)Buf.getBufferEnd())) {
+  // If the input is LLVM Assembly, bitcode is produced by serializing
+  // the module. Use-lists order need to be perserved in this case.
+  llvm::raw_string_ostream OS(Data);
+  llvm::WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
+  ModuleData =
+  ArrayRef((const uint8_t *)OS.str().data(), OS.str().size());
+} else
+  // If the input is LLVM bitcode, write the input byte stream directly.
+  ModuleData = ArrayRef((const uint8_t *)Buf.getBufferStart(),
+ Buf.getBufferSize());
+  }
+  llvm::Constant *ModuleConstant =
+  llvm::ConstantDataArray::get(M->getContext(), ModuleData);
+  // Use Appending linkage so it doesn't get optimized out.
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  *M, ModuleConstant->getType(), true, llvm::GlobalValue::AppendingLinkage,
+  ModuleConstant);
+  GV->setSection(getSectionNameForBitcode(T));
+  if (llvm::GlobalVariable *Old =
+  M->getGlobalVariable("llvm.embedded.module")) {
+assert(Old->use_empty() && "llvm.embedded.module must have no uses");
+GV->takeName(Old);
+Old->eraseFromParent();
+  } else {
+GV->setName("llvm.embedded.module");
+  }
+

rsmith wrote:
> Can you skip all this if `Buf` is empty (in the common case where the input 
> is not an IR file)?
-fembed-bitcode-marker will actually take this path. -fembed-bitcode-marker 
will not split the compilation into two stages thus the input is not IR and Buf 
is empty but clang needs to generate a marker.


Comment at: lib/Driver/Tools.cpp:3766-3771
@@ -3765,8 +3765,8 @@
 // Add flags implied by -fembed-bitcode.
-CmdArgs.push_back("-fembed-bitcode");
+Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ);
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-optzns");
   }
   if (C.getDriver().embedBitcodeMarkerOnly())
-CmdArgs.push_back("-fembed-bitcode-marker");
+CmdArgs.push_back("-fembed-bitcode=marker");
 

rsmith wrote:
> This changes the semantics of `clang -fembed-bitcode -fembed-bitcode-marker` 
> to embed only a marker and no bitcode. Is that OK?
It wasn't clearly defined so I am ok with changing the semantics. It makes even 
more sense that we have different embed options.


Comment at: lib/Driver/Tools.cpp:5724-5728
@@ -5723,4 +5723,7 @@
   // by the frontend.
-  if (C.getDriver().isSaveTempsEnabled() && isa(JA))
+  // When -fembed-bitcode is enabled, optimized bitcode is emitted because it
+  // has slightly different breakdown between stages.
+  if (C.getDriver().isSaveTempsEnabled() &&
+  !C.getDriver().embedBitcodeEnabled() && isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");
 

rsmith wrote:
> Why is this necessary? `-fembed-bitcode` implies `-disable-llvm-optzns` 
> anyway.
-disable-llvm-passes is for -save-temps option. -fembed-bitcode and -save-temps 
disable optzns differently.
-save-temps has following outputs: preprocess source, IR emitted from front 
end, assembly file, object file
-fembed-bitcode has following outputs: optimized IR, object file
They don't share the same intermediate output at all so they need to use 
-disable-llvm-optzns at different stages.



http://reviews.llvm.org/D17392



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


Re: [PATCH] D19829: [scan-build] fix dead store warnings emitted on clang code base

2016-05-05 Thread Richard Trieu via cfe-commits
rtrieu added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:9629
@@ -9628,3 +9628,3 @@
   // Track if the current expression is the result of a derefence, and if the
   // next checked expression is the result of a derefence.
   bool IsDereference = false;

Add comment that these variables are only updated when processing MemberExpr's 
in the while loop.


Comment at: lib/Sema/SemaExpr.cpp:9635-9637
@@ -9634,4 +9634,5 @@
   while (true) {
 IsDereference = NextIsDereference;
 NextIsDereference = false;
+(void) NextIsDereference;
 

Remove these lines.


Comment at: lib/Sema/SemaExpr.cpp:9641
@@ -9639,3 +9640,3 @@
 if (const MemberExpr *ME = dyn_cast(E)) {
   NextIsDereference = ME->isArrow();
   const ValueDecl *VD = ME->getMemberDecl();

Add "IsDereference = NextIsDereference;" before this line.


http://reviews.llvm.org/D19829



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-05-05 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:769-770
@@ +768,4 @@
+void clang::EmbedBitcode(llvm::Module *M, const CodeGenOptions ,
+ llvm::MemoryBufferRef Buf)
+{
+  if (CGOpts.getEmbedBitcode() == CodeGenOptions::Embed_Off)

Ping.


Comment at: lib/CodeGen/BackendUtil.cpp:774-806
@@ +773,35 @@
+
+  // Embed the bitcode for the llvm module.
+  std::string Data;
+  ArrayRef ModuleData;
+  Triple T(M->getTargetTriple());
+  if (CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Marker) {
+if (!isBitcode((const unsigned char *)Buf.getBufferStart(),
+   (const unsigned char *)Buf.getBufferEnd())) {
+  // If the input is LLVM Assembly, bitcode is produced by serializing
+  // the module. Use-lists order need to be perserved in this case.
+  llvm::raw_string_ostream OS(Data);
+  llvm::WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ true);
+  ModuleData =
+  ArrayRef((const uint8_t *)OS.str().data(), OS.str().size());
+} else
+  // If the input is LLVM bitcode, write the input byte stream directly.
+  ModuleData = ArrayRef((const uint8_t *)Buf.getBufferStart(),
+ Buf.getBufferSize());
+  }
+  llvm::Constant *ModuleConstant =
+  llvm::ConstantDataArray::get(M->getContext(), ModuleData);
+  // Use Appending linkage so it doesn't get optimized out.
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  *M, ModuleConstant->getType(), true, llvm::GlobalValue::AppendingLinkage,
+  ModuleConstant);
+  GV->setSection(getSectionNameForBitcode(T));
+  if (llvm::GlobalVariable *Old =
+  M->getGlobalVariable("llvm.embedded.module")) {
+assert(Old->use_empty() && "llvm.embedded.module must have no uses");
+GV->takeName(Old);
+Old->eraseFromParent();
+  } else {
+GV->setName("llvm.embedded.module");
+  }
+

Can you skip all this if `Buf` is empty (in the common case where the input is 
not an IR file)?


Comment at: lib/Driver/Tools.cpp:3766-3771
@@ -3765,8 +3765,8 @@
 // Add flags implied by -fembed-bitcode.
-CmdArgs.push_back("-fembed-bitcode");
+Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ);
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-optzns");
   }
   if (C.getDriver().embedBitcodeMarkerOnly())
-CmdArgs.push_back("-fembed-bitcode-marker");
+CmdArgs.push_back("-fembed-bitcode=marker");
 

This changes the semantics of `clang -fembed-bitcode -fembed-bitcode-marker` to 
embed only a marker and no bitcode. Is that OK?


Comment at: lib/Driver/Tools.cpp:5724-5728
@@ -5723,4 +5723,7 @@
   // by the frontend.
-  if (C.getDriver().isSaveTempsEnabled() && isa(JA))
+  // When -fembed-bitcode is enabled, optimized bitcode is emitted because it
+  // has slightly different breakdown between stages.
+  if (C.getDriver().isSaveTempsEnabled() &&
+  !C.getDriver().embedBitcodeEnabled() && isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");
 

Why is this necessary? `-fembed-bitcode` implies `-disable-llvm-optzns` anyway.


http://reviews.llvm.org/D17392



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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: docs/UndefinedBehaviorSanitizer.rst:235
@@ +234,3 @@
+UndefinedBehaviorSanitizer adds static check data for each check unless it is
+in trap mode. This check data includes the full file name. option
+``-fsanitize-undefined-strip-path-components=N`` can be used to trim this

"option" -> "Option" or "The option"


Comment at: lib/CodeGen/CGExpr.cpp:2385-2386
@@ +2384,4 @@
+FilenameString = FilenameString.substr(I - E);
+  else
+FilenameString = llvm::sys::path::filename(FilenameString);
+} else if (PathComponentsToStrip > 0) {

This doesn't look right: if `I == E`, we were asked to keep at least as many 
components as there were, so we should keep the entire string. I think the 
`substr(I - E)` codepath is appropriate in either case here.


Comment at: test/CodeGen/ubsan-strip-path-components.cpp:6
@@ +5,3 @@
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=-9 | FileCheck %s 
-check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=9 | FileCheck %s 
-check-prefix=LAST-ONLY

I think this test is incorrect too.


http://reviews.llvm.org/D19666



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


Re: [PATCH] D19996: New clang option -mpiecopyrelocs to indicate support for linker copy relocations when linking as PIE

2016-05-05 Thread Sriraman Tallam via cfe-commits
On Thu, May 5, 2016 at 2:31 PM, Rafael Espíndola
 wrote:
> Is there a gcc option or they just assume they are targeting the
> linker that was around when gcc was built?

It is done at configure time, the linker is checked for copy
relocations support.  I recently saw a request to replace this with a
flag like -mpiecopyrelocs.  I chatted off-line with Reid about this
and a flag was suggested.

>
>
>> +  if (Args.hasFlag(options::OPT_mpiecopyrelocs, 
>> options::OPT_mno_piecopyrelocs,
>> +   false)) {
>> +CmdArgs.push_back("-piecopyrelocs");
>> +  }
>
> you don't need the {}
>
>> +def piecopyrelocs : Flag<["-"], "piecopyrelocs">,
>> +  HelpText<"Linker copy relocations support when linking as PIE">;
>
> I think you are missing a verb: Linker copy relocations *are* supported.
>
> But how about just "Position independent executables can have copy 
> relocations"?
>
> Cheers,
> Rafael
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19996: New clang option -mpiecopyrelocs to indicate support for linker copy relocations when linking as PIE

2016-05-05 Thread Rafael Espíndola via cfe-commits
Is there a gcc option or they just assume they are targeting the
linker that was around when gcc was built?


> +  if (Args.hasFlag(options::OPT_mpiecopyrelocs, 
> options::OPT_mno_piecopyrelocs,
> +   false)) {
> +CmdArgs.push_back("-piecopyrelocs");
> +  }

you don't need the {}

> +def piecopyrelocs : Flag<["-"], "piecopyrelocs">,
> +  HelpText<"Linker copy relocations support when linking as PIE">;

I think you are missing a verb: Linker copy relocations *are* supported.

But how about just "Position independent executables can have copy relocations"?

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


[PATCH] D19996: New clang option -mpiecopyrelocs to indicate support for linker copy relocations when linking as PIE

2016-05-05 Thread Sriraman Tallam via cfe-commits
tmsriram created this revision.
tmsriram added a reviewer: rnk.
tmsriram added subscribers: cfe-commits, davidxl, rafael.

With linker copy relocations, PIE can generate better code for external global 
variable accesses.  This patch adds a new option to clang to specify this.  
Please see  http://reviews.llvm.org/D19995  for the patch to LLVM to optimize 
global accesses when this is available. With this option, the module flag "PIE 
Copy Relocations" is set.

http://reviews.llvm.org/D19996

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -570,6 +570,7 @@
   Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
   Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
   Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
+  Opts.PIECopyRelocs = Args.hasArg(OPT_piecopyrelocs);
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4161,6 +4161,11 @@
 CmdArgs.push_back("-mms-bitfields");
   }
 
+  if (Args.hasFlag(options::OPT_mpiecopyrelocs, options::OPT_mno_piecopyrelocs,
+   false)) {
+CmdArgs.push_back("-piecopyrelocs");
+  }
+
   // This is a coarse approximation of what llvm-gcc actually does, both
   // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
   // complicated ways.
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -484,6 +484,8 @@
   if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
 assert(PLevel < 3 && "Invalid PIE Level");
 getModule().setPIELevel(static_cast(PLevel));
+if (CodeGenOpts.PIECopyRelocs)
+  getModule().setPIECopyRelocs();
   }
 
   SimplifyPersonality();
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -222,6 +222,8 @@
 /// The default TLS model to use.
 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
 
+CODEGENOPT(PIECopyRelocs, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1544,6 +1544,8 @@
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>;
+def mpiecopyrelocs : Flag<["-"], "mpiecopyrelocs">, Group;
+def mno_piecopyrelocs : Flag<["-"], "mno-piecopyrelocs">, Group;
 def msse2 : Flag<["-"], "msse2">, Group;
 def msse3 : Flag<["-"], "msse3">, Group;
 def msse4a : Flag<["-"], "msse4a">, Group;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -175,6 +175,8 @@
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
+def piecopyrelocs : Flag<["-"], "piecopyrelocs">,
+  HelpText<"Linker copy relocations support when linking as PIE">;
 def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">,
   HelpText<"Emit an error if a C++ static local initializer would need a guard 
variable">;
 def no_implicit_float : Flag<["-"], "no-implicit-float">,


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -570,6 +570,7 @@
   Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
   Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
   Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
+  Opts.PIECopyRelocs = Args.hasArg(OPT_piecopyrelocs);
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4161,6 +4161,11 @@
 

Re: [PATCH] D19084: [scan-build] fix warnings emitted on Clang AST code base

2016-05-05 Thread Richard Trieu via cfe-commits
rtrieu added inline comments.


Comment at: lib/AST/ASTDiagnostic.cpp:1686
@@ -1685,3 +1685,3 @@
 
-if (Same) {
+if (Same && FromTD) {
   OS << "template " << FromTD->getNameAsString();

dblaikie wrote:
> Should this be a condition, or just an assertion?
This should be an assertion.  Same == true implies FromTD and ToTD are not null.


http://reviews.llvm.org/D19084



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


r268685 - [CMake] Removing LLVM_ENABLE_TIMESTAMPS from the cache files

2016-05-05 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu May  5 16:08:41 2016
New Revision: 268685

URL: http://llvm.org/viewvc/llvm-project?rev=268685=rev
Log:
[CMake] Removing LLVM_ENABLE_TIMESTAMPS from the cache files

Since the option was removed in r268670, the cache scripts should stop 
referring to it.

Modified:
cfe/trunk/cmake/caches/3-stage-base.cmake
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/3-stage-base.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/3-stage-base.cmake?rev=268685=268684=268685=diff
==
--- cfe/trunk/cmake/caches/3-stage-base.cmake (original)
+++ cfe/trunk/cmake/caches/3-stage-base.cmake Thu May  5 16:08:41 2016
@@ -2,7 +2,6 @@ set(CMAKE_BUILD_TYPE RELEASE CACHE STRIN
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-set(LLVM_ENABLE_TIMESTAMPS OFF CACHE BOOL "")
 
 set(CLANG_BOOTSTRAP_TARGETS
   clang

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268685=268684=268685=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Thu May  5 16:08:41 2016
@@ -15,7 +15,6 @@ set(LLVM_ENABLE_BACKTRACES OFF CACHE BOO
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")
-set(LLVM_ENABLE_TIMESTAMPS OFF CACHE BOOL "Don't time-stamp shipping builds - 
this makes builds reproducible")
 
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT with 
just-built clang")
 set(COMPILER_RT_ENABLE_IOS ON CACHE BOOL "Build iOS Compiler-RT libraries")


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


Re: [PATCH] D19902: [ProfileData] (clang) Use Error in InstrProf and Coverage

2016-05-05 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 56346.
vsk added a comment.

- Handle an ECError we can see come out of opening a memory buffer.


http://reviews.llvm.org/D19902

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -403,7 +403,8 @@
   const std::string ProfileName) {
   auto ReaderOrErr = llvm::IndexedInstrProfReader::create(ProfileName);
   // In error, return silently and let Clang PGOUse report the error message.
-  if (ReaderOrErr.getError()) {
+  if (auto E = ReaderOrErr.takeError()) {
+llvm::consumeError(std::move(E));
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 return;
   }
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -800,20 +800,21 @@
   bool IsInMainFile) {
   CGM.getPGOStats().addVisited(IsInMainFile);
   RegionCounts.clear();
-  llvm::ErrorOr RecordErrorOr =
+  llvm::Expected RecordExpected =
   PGOReader->getInstrProfRecord(FuncName, FunctionHash);
-  if (std::error_code EC = RecordErrorOr.getError()) {
-if (EC == llvm::instrprof_error::unknown_function)
+  if (auto E = RecordExpected.takeError()) {
+auto IPE = llvm::InstrProfError::take(std::move(E));
+if (IPE == llvm::instrprof_error::unknown_function)
   CGM.getPGOStats().addMissing(IsInMainFile);
-else if (EC == llvm::instrprof_error::hash_mismatch)
+else if (IPE == llvm::instrprof_error::hash_mismatch)
   CGM.getPGOStats().addMismatched(IsInMainFile);
-else if (EC == llvm::instrprof_error::malformed)
+else if (IPE == llvm::instrprof_error::malformed)
   // TODO: Consider a more specific warning for this case.
   CGM.getPGOStats().addMismatched(IsInMainFile);
 return;
   }
   ProfRecord =
-  llvm::make_unique(std::move(RecordErrorOr.get()));
+  
llvm::make_unique(std::move(RecordExpected.get()));
   RegionCounts = ProfRecord->Counts;
 }
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -141,11 +141,13 @@
   if (CodeGenOpts.hasProfileClangUse()) {
 auto ReaderOrErr = llvm::IndexedInstrProfReader::create(
 CodeGenOpts.ProfileInstrumentUsePath);
-if (std::error_code EC = ReaderOrErr.getError()) {
+if (auto E = ReaderOrErr.takeError()) {
   unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
   "Could not read profile %0: %1");
-  getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath
-<< EC.message();
+  llvm::handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase ) {
+getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath
+  << EI.message();
+  });
 } else
   PGOReader = std::move(ReaderOrErr.get());
   }


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -403,7 +403,8 @@
   const std::string ProfileName) {
   auto ReaderOrErr = llvm::IndexedInstrProfReader::create(ProfileName);
   // In error, return silently and let Clang PGOUse report the error message.
-  if (ReaderOrErr.getError()) {
+  if (auto E = ReaderOrErr.takeError()) {
+llvm::consumeError(std::move(E));
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 return;
   }
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -800,20 +800,21 @@
   bool IsInMainFile) {
   CGM.getPGOStats().addVisited(IsInMainFile);
   RegionCounts.clear();
-  llvm::ErrorOr RecordErrorOr =
+  llvm::Expected RecordExpected =
   PGOReader->getInstrProfRecord(FuncName, FunctionHash);
-  if (std::error_code EC = RecordErrorOr.getError()) {
-if (EC == llvm::instrprof_error::unknown_function)
+  if (auto E = RecordExpected.takeError()) {
+auto IPE = llvm::InstrProfError::take(std::move(E));
+if (IPE == llvm::instrprof_error::unknown_function)
   CGM.getPGOStats().addMissing(IsInMainFile);
-else if (EC == llvm::instrprof_error::hash_mismatch)
+else if (IPE == llvm::instrprof_error::hash_mismatch)
   CGM.getPGOStats().addMismatched(IsInMainFile);
-else if (EC == llvm::instrprof_error::malformed)
+else if (IPE == llvm::instrprof_error::malformed)
   // TODO: Consider a more specific warning for this 

Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-05-05 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Sema/SemaCast.cpp:2317
@@ +2316,3 @@
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt intValue;

yaxunl wrote:
> tstellarAMD wrote:
> > A similar patch has been submitted and rejected several times:
> > 
> > https://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg91067.html
> > 
> > http://marc.info/?l=cfe-commits=141198505414824=2
> > 
> > These were all before OpenCL 2.0.  The 1.2 spec does not allow this, so I 
> > think this should be guarded by an OpenCL version check.
> I opened a bug at khronos bugzilla requesting clarification of the issue:
> 
> https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15609
> 
> I will keep you updated.
OpenCL WG has clarified that explicit or implicit cast of 0 to event_t is 
allowed. It does not make sense to only allow implicit cast but not allow 
explicit cast. So I think we should move on with this patch.


http://reviews.llvm.org/D17578



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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-05 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Basic/BuiltinsNVPTX.def:569-603
@@ -568,1 +568,37 @@
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+

jlebar wrote:
> majnemer wrote:
> > Would it be crazy to instead provide a generic builtin? Would cut down on 
> > the number of variants...
> > 
> > `__builtin_add_overflow` is an example of such a builtin.
> Art is going to send you flowers.  :)  He and I just had an argument about 
> this.
> 
> I think this isn't an unreasonable thing to want, but I think it's beneficial 
> to be consistent with our existing API.  So if we offer a generic thing for 
> ldg, it would be nice to have one for atomics above, which are basically the 
> same.
> 
> So I told Art I'd prefer to add it to our list.
Oh, another thing is that, you really see the benefit of having a generic 
builtin when you start hitting the combinatorial explosion of all the different 
kinds of loads.  Like, as-is it's not so bad, but if you want to support all 
forms of ld.global.nc, there are four different caching behaviors.  Supporting 
all forms of ld is way worse.

Which is to say, if we're going to do the generic thing, it seems like we 
benefit the most by making it generic on more than the types.  But we're not 
ready to do that; I don't think most of these loads even exist in llvm atm.

http://docs.nvidia.com/cuda/parallel-thread-execution/#data-movement-and-conversion-instructions-ld


http://reviews.llvm.org/D19990



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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-05 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Basic/BuiltinsNVPTX.def:569-603
@@ -568,1 +568,37 @@
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+

majnemer wrote:
> Would it be crazy to instead provide a generic builtin? Would cut down on the 
> number of variants...
> 
> `__builtin_add_overflow` is an example of such a builtin.
Art is going to send you flowers.  :)  He and I just had an argument about this.

I think this isn't an unreasonable thing to want, but I think it's beneficial 
to be consistent with our existing API.  So if we offer a generic thing for 
ldg, it would be nice to have one for atomics above, which are basically the 
same.

So I told Art I'd prefer to add it to our list.


http://reviews.llvm.org/D19990



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


[PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-05 Thread Michael Miller via cfe-commits
michael_miller created this revision.
michael_miller added reviewers: hokein, aaron.ballman, alexfh.
michael_miller added a subscriber: cfe-commits.

Fixed a crash in cppcoreguidelines-pro-type-member-init when checking record 
types with indirect fields pre-C++11.
Fixed handling of indirect fields so they are properly checked and suggested 
fixes are proposed.

http://reviews.llvm.org/D19993

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -357,3 +357,13 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
   // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
 };
+
+class PositiveIndirectMember {
+  struct {
+int *A;
+// CHECK-FIXES: int *A{};
+  };
+
+  PositiveIndirectMember() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
+};
Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
@@ -103,3 +103,14 @@
 
   int X;
 };
+
+class PositiveIndirectMember {
+  struct {
+int *A;
+  };
+
+  PositiveIndirectMember() : A() {}
+  PositiveIndirectMember(int) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
+  // CHECK-FIXES: PositiveIndirectMember(int) : A() {}
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,16 +27,30 @@
 
 namespace {
 
-void fieldsRequiringInit(const RecordDecl::field_range ,
- ASTContext ,
- SmallPtrSetImpl ) {
+// Convenience utility to get a RecordDecl from a QualType.
+const RecordDecl *getCanonicalRecordDecl(const QualType ) {
+  if (const auto *RT = Type.getCanonicalType()->getAs())
+return RT->getDecl();
+  return nullptr;
+}
+
+// Iterate over all the fields in a record type, both direct and indirect (e.g.
+// if the record contains an anonmyous struct). If OneFieldPerUnion is true and
+// the record type (or indirect field) is a union, forEachField will stop after
+// the first field.
+template 
+void forEachField(const RecordDecl *Record, const T ,
+  bool OneFieldPerUnion, Func &) {
   for (const FieldDecl *F : Fields) {
-if (F->hasInClassInitializer())
-  continue;
-QualType Type = F->getType();
-if (!F->hasInClassInitializer() &&
-utils::type_traits::isTriviallyDefaultConstructible(Type, Context))
-  FieldsToInit.insert(F);
+if (F->isAnonymousStructOrUnion()) {
+  if (const RecordDecl *R = getCanonicalRecordDecl(F->getType()))
+forEachField(R, R->fields(), OneFieldPerUnion, Fn);
+} else {
+  Fn(F);
+}
+
+if (OneFieldPerUnion && Record->isUnion())
+  break;
   }
 }
 
@@ -155,13 +169,6 @@
   SmallVector Initializers;
 };
 
-// Convenience utility to get a RecordDecl from a QualType.
-const RecordDecl *getCanonicalRecordDecl(const QualType ) {
-  if (const auto *RT = Type.getCanonicalType()->getAs())
-return RT->getDecl();
-  return nullptr;
-}
-
 template 
 SmallVector
 computeInsertions(const CXXConstructorDecl::init_const_range ,
@@ -179,8 +186,8 @@
   // Gets either the field or base class being initialized by the provided
   // initializer.
   const auto *InitDecl =
-  Init->isMemberInitializer()
-  ? static_cast(Init->getMember())
+  Init->isAnyMemberInitializer()
+  ? static_cast(Init->getAnyMember())
   : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
@@ -216,7 +223,8 @@
   Decls.emplace_back(Decl);
 }
   }
-  Decls.append(ClassDecl->fields().begin(), ClassDecl->fields().end());
+  forEachField(ClassDecl, ClassDecl->fields(), false,
+   [&](const FieldDecl *F) { Decls.push_back(F); });
 }
 
 template 
@@ -238,22 +246,6 @@
   }
 }
 
-template 
-void forEachField(const RecordDecl *Record, const T ,
-  bool OneFieldPerUnion, Func &) {
-  for (const FieldDecl *F : Fields) {
-if (F->isAnonymousStructOrUnion()) {
-  if (const RecordDecl *R = 

Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-05 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: include/clang/Basic/BuiltinsNVPTX.def:569-603
@@ -568,1 +568,37 @@
 
+// __ldg.  This is not implemented as a builtin by nvcc.
+BUILTIN(__nvvm_ldg_c, "ccC*", "")
+BUILTIN(__nvvm_ldg_s, "ssC*", "")
+BUILTIN(__nvvm_ldg_i, "iiC*", "")
+BUILTIN(__nvvm_ldg_l, "LiLiC*", "")
+BUILTIN(__nvvm_ldg_ll, "LLiLLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc, "UcUcC*", "")
+BUILTIN(__nvvm_ldg_us, "UsUsC*", "")
+BUILTIN(__nvvm_ldg_ui, "UiUiC*", "")
+BUILTIN(__nvvm_ldg_ul, "ULiULiC*", "")
+BUILTIN(__nvvm_ldg_ull, "ULLiULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f, "ffC*", "")
+BUILTIN(__nvvm_ldg_d, "ddC*", "")
+
+BUILTIN(__nvvm_ldg_c2, "E2cE2cC*", "")
+BUILTIN(__nvvm_ldg_c4, "E4cE4cC*", "")
+BUILTIN(__nvvm_ldg_s2, "E2sE2sC*", "")
+BUILTIN(__nvvm_ldg_s4, "E4sE4sC*", "")
+BUILTIN(__nvvm_ldg_i2, "E2iE2iC*", "")
+BUILTIN(__nvvm_ldg_i4, "E4iE4iC*", "")
+BUILTIN(__nvvm_ldg_ll2, "E2LLiE2LLiC*", "")
+
+BUILTIN(__nvvm_ldg_uc2, "E2UcE2UcC*", "")
+BUILTIN(__nvvm_ldg_uc4, "E4UcE4UcC*", "")
+BUILTIN(__nvvm_ldg_us2, "E2UsE2UsC*", "")
+BUILTIN(__nvvm_ldg_us4, "E4UsE4UsC*", "")
+BUILTIN(__nvvm_ldg_ui2, "E2UiE2UiC*", "")
+BUILTIN(__nvvm_ldg_ui4, "E4UiE4UiC*", "")
+BUILTIN(__nvvm_ldg_ull2, "E2ULLiE2ULLiC*", "")
+
+BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "")
+BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
+BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
+

Would it be crazy to instead provide a generic builtin? Would cut down on the 
number of variants...

`__builtin_add_overflow` is an example of such a builtin.


http://reviews.llvm.org/D19990



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


Re: [PATCH] D19947: [Clang] Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings

2016-05-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268674: Fix some Clang-tidy 
readability-simplify-boolean-expr and Include What You… (authored by 
eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D19947?vs=56226=56337#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19947

Files:
  cfe/trunk/include/clang/Lex/Token.h
  cfe/trunk/include/clang/Sema/ParsedTemplate.h

Index: cfe/trunk/include/clang/Lex/Token.h
===
--- cfe/trunk/include/clang/Lex/Token.h
+++ cfe/trunk/include/clang/Lex/Token.h
@@ -14,12 +14,10 @@
 #ifndef LLVM_CLANG_LEX_TOKEN_H
 #define LLVM_CLANG_LEX_TOKEN_H
 
-#include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/TemplateKinds.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/StringRef.h"
-#include 
+#include 
 
 namespace clang {
 
@@ -69,8 +67,8 @@
 
   /// Flags - Bits we track about this token, members of the TokenFlags enum.
   unsigned short Flags;
-public:
 
+public:
   // Various flags set per token:
   enum TokenFlags {
 StartOfLine   = 0x01,  // At start of line or only after whitespace
@@ -236,6 +234,11 @@
 Flags |= Flag;
   }
 
+  /// \brief Get the specified flag.
+  bool getFlag(TokenFlags Flag) const {
+return (Flags & Flag) != 0;
+  }
+
   /// \brief Unset the specified flag.
   void clearFlag(TokenFlags Flag) {
 Flags &= ~Flag;
@@ -259,50 +262,42 @@
 
   /// isAtStartOfLine - Return true if this token is at the start of a line.
   ///
-  bool isAtStartOfLine() const { return (Flags & StartOfLine) ? true : false; }
+  bool isAtStartOfLine() const { return getFlag(StartOfLine); }
 
   /// \brief Return true if this token has whitespace before it.
   ///
-  bool hasLeadingSpace() const { return (Flags & LeadingSpace) ? true : false; }
+  bool hasLeadingSpace() const { return getFlag(LeadingSpace); }
 
   /// \brief Return true if this identifier token should never
   /// be expanded in the future, due to C99 6.10.3.4p2.
-  bool isExpandDisabled() const {
-return (Flags & DisableExpand) ? true : false;
-  }
+  bool isExpandDisabled() const { return getFlag(DisableExpand); }
 
   /// \brief Return true if we have an ObjC keyword identifier.
   bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;
 
   /// \brief Return the ObjC keyword kind.
   tok::ObjCKeywordKind getObjCKeywordID() const;
 
   /// \brief Return true if this token has trigraphs or escaped newlines in it.
-  bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
+  bool needsCleaning() const { return getFlag(NeedsCleaning); }
 
   /// \brief Return true if this token has an empty macro before it.
   ///
-  bool hasLeadingEmptyMacro() const {
-return (Flags & LeadingEmptyMacro) ? true : false;
-  }
+  bool hasLeadingEmptyMacro() const { return getFlag(LeadingEmptyMacro); }
 
   /// \brief Return true if this token is a string or character literal which
   /// has a ud-suffix.
-  bool hasUDSuffix() const { return (Flags & HasUDSuffix) ? true : false; }
+  bool hasUDSuffix() const { return getFlag(HasUDSuffix); }
 
   /// Returns true if this token contains a universal character name.
-  bool hasUCN() const { return (Flags & HasUCN) ? true : false; }
+  bool hasUCN() const { return getFlag(HasUCN); }
 
   /// Returns true if this token is formed by macro by stringizing or charizing
   /// operator.
-  bool stringifiedInMacro() const {
-return (Flags & StringifiedInMacro) ? true : false;
-  }
+  bool stringifiedInMacro() const { return getFlag(StringifiedInMacro); }
 
   /// Returns true if the comma after this token was elided.
-  bool commaAfterElided() const {
-return (Flags & CommaAfterElided) ? true : false;
-  }
+  bool commaAfterElided() const { return getFlag(CommaAfterElided); }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
@@ -324,11 +319,11 @@
   bool FoundElse;
 };
 
-}  // end namespace clang
+} // end namespace clang
 
 namespace llvm {
   template <>
   struct isPodLike { static const bool value = true; };
-}  // end namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_CLANG_LEX_TOKEN_H
Index: cfe/trunk/include/clang/Sema/ParsedTemplate.h
===
--- cfe/trunk/include/clang/Sema/ParsedTemplate.h
+++ cfe/trunk/include/clang/Sema/ParsedTemplate.h
@@ -1,4 +1,4 @@
-//===--- ParsedTemplate.h - Template Parsing Data Types ---===//
+//===--- ParsedTemplate.h - Template Parsing Data Types -*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -11,12 +11,19 @@
 //  templates.
 //
 //===--===//
+
 #ifndef LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 #define LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 
+#include "clang/Basic/OperatorKinds.h"
+#include 

Re: [PATCH] D19959: [scan-build] fix warning emitted on Clang Driver code baseFix a "logic error" warning of the type Called c++ object pointer isnull" reported by Clang Static Analyzer on the file:-

2016-05-05 Thread Justin Bogner via cfe-commits
Apelete Seketeli via cfe-commits  writes:
> apelete created this revision.
> apelete added reviewers: kevin.qin, rsmith.
> apelete added a subscriber: cfe-commits.
>
> Signed-off-by: Apelete Seketeli 
>
> http://reviews.llvm.org/D19959
>
> Files:
>   lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -2346,7 +2346,7 @@
>  success = getAArch64MicroArchFeaturesFromMcpu(D, 
> getAArch64TargetCPU(Args),
>Args, Features);
>  
> -  if (!success)
> +  if (!success && A)
>  D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
>  
>if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {

This doesn't look right. The case where (!Success && !A) needs *some*
kind of diagnosic, doesn't it? I guess the value of OPT_arch was invalid
in that case.

I think this change just papers over a real diagnostic bug.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-05 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added reviewers: tra, rsmith.
jlebar added subscribers: cfe-commits, jhen.
Herald added a subscriber: jholewinski.

Previously it was implemented as inline asm in the CUDA headers.

This change allows us to use the [addr+imm] addressing mode when
executing ld.global.nc instructions.  This translates into a 1.3x
speedup on some benchmarks that call this instruction from within an
unrolled loop.

http://reviews.llvm.org/D19990

Files:
  include/clang/Basic/BuiltinsNVPTX.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_intrinsics.h
  lib/Headers/__clang_cuda_runtime_wrapper.h
  test/CodeGen/builtins-nvptx.c

Index: test/CodeGen/builtins-nvptx.c
===
--- test/CodeGen/builtins-nvptx.c
+++ test/CodeGen/builtins-nvptx.c
@@ -1,6 +1,8 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP32 %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
@@ -280,3 +282,103 @@
 
   // CHECK: ret
 }
+
+// CHECK-LABEL: nvvm_ldg
+__device__ void nvvm_ldg(const void *p) {
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  __nvvm_ldg_c((const char *)p);
+  __nvvm_ldg_uc((const unsigned char *)p);
+
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  __nvvm_ldg_s((const short *)p);
+  __nvvm_ldg_us((const unsigned short *)p);
+
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_i((const int *)p);
+  __nvvm_ldg_ui((const unsigned int *)p);
+
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_l((const long *)p);
+  __nvvm_ldg_ul((const unsigned long *)p);
+
+  // CHECK: call float @llvm.nvvm.ldg.global.f.f32.p0f32(float* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_f((const float *)p);
+  // CHECK: call double @llvm.nvvm.ldg.global.f.f64.p0f64(double* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_d((const double *)p);
+
+  // In practice, the pointers we pass to __ldg will be aligned as appropriate
+  // for the CUDA N vector types (e.g. short4), which are not the same as
+  // the LLVM vector types.  However, each LLVM vector type has an alignment
+  // less than or equal to its corresponding CUDA type, so we're OK.
+  //
+  // PTX Interoperability section 2.2: "For a vector with an even number of
+  // elements, its alignment is set to number of elements times the alignment of
+  // its member: n*alignof(t)."
+
+  // CHECK: call <2 x i8> @llvm.nvvm.ldg.global.i.v2i8.p0v2i8(<2 x i8>* {{%[0-9]+}}, i32 2)
+  // CHECK: call <2 x i8> @llvm.nvvm.ldg.global.i.v2i8.p0v2i8(<2 x i8>* {{%[0-9]+}}, i32 2)
+  typedef char char2 __attribute__((ext_vector_type(2)));
+  typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
+  __nvvm_ldg_c2((const char2 *)p);
+  __nvvm_ldg_uc2((const uchar2 *)p);
+
+  // CHECK: call <4 x i8> @llvm.nvvm.ldg.global.i.v4i8.p0v4i8(<4 x i8>* {{%[0-9]+}}, i32 4)
+  // CHECK: call <4 x i8> @llvm.nvvm.ldg.global.i.v4i8.p0v4i8(<4 x i8>* {{%[0-9]+}}, i32 4)
+  typedef char char4 __attribute__((ext_vector_type(4)));
+  typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
+  __nvvm_ldg_c4((const char4 *)p);
+  __nvvm_ldg_uc4((const uchar4 *)p);
+
+  // CHECK: call <2 x i16> @llvm.nvvm.ldg.global.i.v2i16.p0v2i16(<2 x i16>* {{%[0-9]+}}, i32 4)
+  // CHECK: call <2 x i16> @llvm.nvvm.ldg.global.i.v2i16.p0v2i16(<2 x i16>* {{%[0-9]+}}, i32 4)
+  typedef short short2 __attribute__((ext_vector_type(2)));
+  typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
+  __nvvm_ldg_s2((const short2 *)p);
+  __nvvm_ldg_us2((const ushort2 *)p);
+
+  // CHECK: call <4 x i16> @llvm.nvvm.ldg.global.i.v4i16.p0v4i16(<4 x i16>* {{%[0-9]+}}, i32 8)
+  // CHECK: call <4 x i16> @llvm.nvvm.ldg.global.i.v4i16.p0v4i16(<4 x i16>* {{%[0-9]+}}, i32 8)
+  typedef short short4 __attribute__((ext_vector_type(4)));
+  typedef 

Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-05 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: lib/Transforms/IPO/MergeFunctions.cpp:147
@@ -146,3 +146,3 @@
   struct Config : ValueMapConfig {
-enum { FollowRAUW = false };
+enum { FollowRAUW = 0 };
   };

This change should go to ValueMap, I think it should be moved to an enum class, 
and all uses of ValueMap should be changed accordingly. This is meant to act as 
a bool IMO, it's odd to make it otherwise.


http://reviews.llvm.org/D19105



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


r268665 - Add forgotten test from r268594.

2016-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  5 14:16:58 2016
New Revision: 268665

URL: http://llvm.org/viewvc/llvm-project?rev=268665=rev
Log:
Add forgotten test from r268594.

Added:
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp

Added: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp?rev=268665=auto
==
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp Thu May  
5 14:16:58 2016
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+enum class EC { ec };
+using EC::ec; // expected-error {{using declaration cannot refer to a scoped 
enumerator}}


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


r268664 - Add a FixItHint for the new diagnostic for a non-class-scope using-declaration that names a class-scope enumerator.

2016-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  5 14:16:15 2016
New Revision: 268664

URL: http://llvm.org/viewvc/llvm-project?rev=268664=rev
Log:
Add a FixItHint for the new diagnostic for a non-class-scope using-declaration 
that names a class-scope enumerator.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268664=268663=268664=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  5 14:16:15 
2016
@@ -393,8 +393,8 @@ def note_using_decl_constructor_ellipsis
 def err_using_decl_can_not_refer_to_class_member : Error<
   "using declaration cannot refer to class member">;
 def note_using_decl_class_member_workaround : Note<
-  "use %select{an alias declaration|a typedef declaration|a reference}0 "
-  "instead">;
+  "use %select{an alias declaration|a typedef declaration|a reference|"
+  "a const variable|a constexpr variable}0 instead">;
 def err_using_decl_can_not_refer_to_namespace : Error<
   "using declaration cannot refer to a namespace">;
 def err_using_decl_can_not_refer_to_scoped_enum : Error<

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=268664=268663=268664=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu May  5 14:16:15 2016
@@ -8421,6 +8421,20 @@ bool Sema::CheckUsingDeclQualifier(Sourc
 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
   << 2 // reference declaration
   << FixIt;
+  } else if (R.getAsSingle()) {
+// Don't provide a fixit outside C++11 mode; we don't want to suggest
+// repeating the type of the enumeration here, and we can't do so if
+// the type is anonymous.
+FixItHint FixIt;
+if (getLangOpts().CPlusPlus11) {
+  // Convert 'using X::Y;' to 'auto  = X::Y;'.
+  FixIt = FixItHint::CreateReplacement(
+  UsingLoc, "constexpr auto " + NameInfo.getName().getAsString() + 
" = ");
+}
+
+Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
+  << (getLangOpts().CPlusPlus11 ? 4 : 3) // const[expr] variable
+  << FixIt;
   }
   return true;
 }

Modified: 
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp?rev=268664=268663=268664=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp 
(original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp Thu 
May  5 14:16:15 2016
@@ -7,14 +7,41 @@
 struct X {
   int i;
   static int a;
+  enum E { e };
 };
 
 using X::i; // expected-error{{using declaration cannot refer to class member}}
 using X::s; // expected-error{{using declaration cannot refer to class member}}
+using X::e; // expected-error{{using declaration cannot refer to class member}}
+using X::E::e; // expected-error{{using declaration cannot refer to class 
member}} expected-warning 0-1{{C++11}}
+#if __cplusplus < 201103L
+// expected-note@-3 {{use a const variable}}
+// expected-note@-3 {{use a const variable}}
+// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]:
+// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]:
+#else
+// expected-note@-8 {{use a constexpr variable}}
+// expected-note@-8 {{use a constexpr variable}}
+// CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:1-[[@LINE-10]]:6}:"constexpr auto e = "
+// CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:1-[[@LINE-10]]:6}:"constexpr auto e = "
+#endif
 
 void f() {
   using X::i; // expected-error{{using declaration cannot refer to class 
member}}
   using X::s; // expected-error{{using declaration cannot refer to class 
member}}
+  using X::e; // expected-error{{using declaration cannot refer to class 
member}}
+  using X::E::e; // expected-error{{using declaration cannot refer to class 
member}} expected-warning 0-1{{C++11}}
+#if __cplusplus < 201103L
+  // expected-note@-3 {{use a const variable}}
+  // expected-note@-3 {{use a const variable}}
+  // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]:
+  // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]:
+#else
+  // expected-note@-8 {{use a constexpr variable}}
+  // expected-note@-8 {{use a constexpr variable}}
+  // CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:3-[[@LINE-10]]:8}:"constexpr auto e 
= "
+  // CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:3-[[@LINE-10]]:8}:"constexpr 

Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-05 Thread Arthur O'Dwyer via cfe-commits
Quuxplusone added a subscriber: Quuxplusone.
Quuxplusone added a comment.

It seems like this proposed diagnostic and fixit, statistically speaking, is 
*never* correct.
In the cases where there is a code issue to be corrected, the diagnosable issue 
really seems to involve dataflow analysis:

"Here is a variable of integral type (not bool), which over its lifetime 
assumes only the values `0` and `1`. This variable should be declared as type 
`bool`."
"Here is a function returning integral type (not bool), which returns only the 
values `0` and `1`. This function should be declared as returning type `bool`."
"Here is a parameter of integral type (not bool), which (via whole-program 
analysis) assumes only the values `0` and `1`. This parameter should be 
declared as type `bool`."



Comment at: lib/AST/DeclPrinter.cpp:1016
@@ -1015,3 +1015,3 @@
   Out << "<";
-  unsigned First = true;
+  unsigned First = 1;
   for (auto *Param : *Params) {

This is clearly the wrong correction, don't you think? Should be 
s/unsigned/bool/, not s/true/1/.


Comment at: lib/AST/DeclarationName.cpp:104
@@ -105,1 +103,3 @@
+  case -1: return 1;
+  case 1: return 0;
   default: break;

This seems like it might be a real bug: somebody in the past cut-and-pasting 
the implementation of operator<() into this compare() function. I suspect (but 
please don't trust me) that the proper fix is s/true/-1/ s/false/1/.


Comment at: lib/Bitcode/Writer/BitWriter.cpp:40
@@ -39,3 +39,3 @@
 int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle) {
-  return LLVMWriteBitcodeToFD(M, FileHandle, true, false);
+  return LLVMWriteBitcodeToFD(M, FileHandle, 1, 0);
 }

This also seems like the wrong correction.


Comment at: lib/Bitcode/Writer/BitcodeWriter.cpp:1332
@@ -1331,3 +1331,3 @@
   assert(N->isDistinct() && "Expected distinct compile units");
-  Record.push_back(/* IsDistinct */ true);
+  Record.push_back(/* IsDistinct */ 1);
   Record.push_back(N->getSourceLanguage());

This seems like a "correct" but unwanted adjustment. *Maybe* there's a case for 
`static_cast(true)`... but personally I'd leave the `true` alone.


Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:593
@@ -592,3 +592,3 @@
   switch (Op.getOpcode()) {
-  default: return false;
+  default: return 0;
   case ISD::ConstantFP:

Here is the first clearly beneficial correction I've noticed.


Comment at: lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp:1562
@@ -1563,1 +1561,3 @@
+IsBottomUp = 1,
+HasReadyFilter = 0
   };

If I understand correctly, the idiomatic C++11 way to write this code would be

static constexpr bool IsBottomUp = true;
static constexpr bool HasReadyFilter = false;

I think the proposed correction is worse than the original, because it makes 
this look like an integer enumeration.


Comment at: lib/Driver/Tools.cpp:2022
@@ -2021,3 +2021,3 @@
 
-if (OptionIter->second == true) {
+if (OptionIter->second == 1) {
   // Duplicate option specified.

Shouldn't the original code already have triggered some warning about explicit 
comparison with a boolean value?

if (OptionIter->second) {

doesn't have literally the same semantics, but it's clearly IMHO what was 
intended.
Also, if `decltype(llvm::StringMap::iterator{}->second)` is not `bool`, 
something weird is going on.


Comment at: lib/IR/Core.cpp:227
@@ -226,3 +226,3 @@
 *ErrorMessage = strdup(EC.message().c_str());
-return true;
+return 1;
   }

This correction is wrong; either `true` should be accepted as a valid value for 
`LLVMBool`, or `LLVMBool` should be replaced with `bool`.


http://reviews.llvm.org/D19105



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


r268663 - Some release note updates for C++ language acceptance changes since Clang 3.8.

2016-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  5 13:40:37 2016
New Revision: 268663

URL: http://llvm.org/viewvc/llvm-project?rev=268663=rev
Log:
Some release note updates for C++ language acceptance changes since Clang 3.8.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=268663=268662=268663=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu May  5 13:40:37 2016
@@ -91,11 +91,61 @@ C11 Feature Support
 C++ Language Changes in Clang
 -
 
-- ...
+- Clang now enforces the rule that a *using-declaration* cannot name an 
enumerator of a
+  scoped enumeration.
 
-C++11 Feature Support
+  .. codeblock:: c++
+
+namespace Foo { enum class E { e }; }
+namespace Bar {
+  using Foo::E::e; // error
+  constexpr auto e = Foo::E::e; // ok
+}
+
+- Clang now enforces the rule that an enumerator of an unscoped enumeration 
declared at
+  class scope can only be named by a *using-declaration* in a derived class.
+
+  .. codeblock:: c++
+
+class Foo { enum E { e }; }
+using Foo::e; // error
+static constexpr auto e = Foo::e; // ok
+
+...
+
+C++1z Feature Support
 ^
 
+Clang's experimental support for the upcoming C++1z standard can be enabled 
with ``-std=c++1z``.
+Changes to C++1z features since Clang 3.8:
+
+- The ``[[fallthrough]]``, ``[[nodiscard]]``, and ``[[maybe_unused]]`` 
attributes are
+  supported in C++11 onwards, and are largely synonymous with Clang's existing 
attributes
+  ``[[clang::fallthrough]]``, ``[[gnu::warn_unused_result]]``, and 
``[[gnu::unused]]``.
+  Use ``-Wimplicit-fallthrough`` to warn on unannotated fallthrough within 
``switch``
+  statements.
+
+- In C++1z mode, aggregate initialization can be performed for classes with 
base classes:
+
+  .. codeblock:: c++
+
+  struct A { int n; };
+  struct B : A { int x, y; };
+  B b = { 1, 2, 3 }; // b.n == 1, b.x == 2, b.y == 3
+
+- The range in a range-based ``for`` statement can have different types for 
its ``begin``
+  and ``end`` iterators. This is permitted as an extension in C++11 onwards.
+
+- Lambda-expressions can explicitly capture ``*this`` (to capture the 
surrounding object
+  by copy). This is permitted as an extension in C++11 onwards.
+
+- Objects of enumeration type can be direct-list-initialized from a value of 
the underlying
+  type. ``E{n}`` is equivalent to ``E(n)``, except that it implies a check for 
a narrowing
+  conversion.
+
+- Unary *fold-expression*\s over an empty pack are now rejected for all 
operators
+  other than ``&&``, ``||``, and ``,``.
+
 ...
 
 Objective-C Language Changes in Clang


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


Re: r268594 - Fix implementation of C++'s restrictions on using-declarations referring to enumerators:

2016-05-05 Thread Richard Smith via cfe-commits
On Thu, May 5, 2016 at 11:21 AM, Reid Kleckner  wrote:

> On Thu, May 5, 2016 at 11:15 AM, Richard Smith 
> wrote:
>
>> Given that GCC rejects this code (and has done for as long as it's
>> accepted the Enum::Member syntax), I don't expect the problems to be too
>> widespread. If they are, we could trivially accept this as an extension; it
>> seems like a pointless restriction.
>>
>
> I think there will be widespread issues on Mac, where many projects
> haven't built with GCC in years.
>

I've added some release notes in r268663. If people complain that this is
breaking a significant amount of code, we can think about allowing this as
an extension.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-05 Thread David Blaikie via cfe-commits
On Thu, May 5, 2016 at 8:50 AM, Robinson, Paul 
wrote:

> This would be a great conversation to have at the social, sadly I will
> have to miss it this month.
>

Yeah, I don't often make it along to them, unfortunately.


>
> >> dblaikie wrote:
> >>> Doesn't look like the const case is any different from the non-const
> >>> case, is it?
> >> Given a white-box analysis of the compiler internals, you are correct;
> >> this is in contrast to the static const/non-const handling, which *does*
> >> use different paths.
> >> I am unwilling to trust that the const/non-const paths for locals will
> >> forever use the same path.  You could also look at it as "the test is
> >> the spec."
> >
> > But even then - what about any other property of a variable? What if it's
> > in a nested scope instead of a top level scope? What if it's declared in
> > a condition (if (int x = ...)). What if it's volatile? We could pick
> > arbitrary properties that /could/ have an effect on debug info but we
> > generally believe to be orthogonal to the feature at hand
>
> What you are describing is what testing literature refers to as criteria
> for equivalence classes.  There is some level of judgment to that, yes.
>

Yep yep, to be sure. I'm just generally trying to encourage the community
behavior towards being both selective & thorough about testing.


> > & I'd say 'const' is in the same group of things.
>
> I would have thought exactly that for the static-storage case, but it is
> demonstrably not true.


Could you provide the example you had in mind there? I suspect there's a
bit of a false equivalence there - that, once we understand the language
rules/constructs better, we'll see it doesn't apply here to the local
variable case & wouldn't be used to inform our equivalence classification.
(I'll skip other parts where you refer to that issue in this email until we
discuss it further here)


> Therefore, const/not is a valid distinction for
> the equivalence classes in the static case.  Needing a separate const
> test for the static case, it seems completely appropriate to have the
> same for the auto case.  In other words, in my judgment the storage-class
> doesn't seem relevant to the equivalence class criteria for the test.
>
> > (a const local variable still needs storage, etc, - the address can be
> > escaped and accessed from elsewhere and determined to be unique
>
> All of those objections apply equally to the static case, and yet the
> static case must have separate tests.
>
> > - and both variables in this example could be optimized away entirely
> > by the compiler because they're unused, so the const is no worse off
> > there in that theoretical concern)
>
> Again not different for the (file-)static case.  If a file-static
> variable is not used in the CU there's no reason for it to be emitted.
> As it happens I *did* need uses to get the static cases to work, and
> (currently) don't need uses to get the local cases to work, so in the
> interest of not including elements in the test case that are irrelevant
> to the feature-under-test, I didn't add uses of the locals.
>

But I think that points out that the parallel doesn't apply here - uses are
critical to the static variable case (well, as you saw - uses of the type,
at least, and separately, definitions of the static members are also
necessary to test that codepath too). I don't think there's an equivalence
between this and the local variable case until we see the variable
disappear due to lack of use. Then we'll get into the territory of "what
kind of use is enough" to preserve the variable to demonstrate the debug
info is present/not present - but even then, the const isn't so relevant.
The const would just allow the variable to be optimized away more
frequently & thus not be present to demonstrate the attribute's
functionality.

Sorry, I'm perhaps having a hard time explaining this well.


>
> This is an argument for doing the test exactly as I did: first run it
> to prove debug info IS emitted in the absence of the attribute, then
> again to prove debug info is suppressed in the presence of the attribute.
> That way if optimization or lack-of-use means the variable is not emitted,
> the test can be adjusted to make sure that condition does not apply,
> proving that the lack of debug info is properly because of the attribute
> and not because of some other irrelevant circumstance.
>

Yeah, I think that's a separate and interesting part of testing too -
making the test case resilient to other changes (in this case - the
possibility of frontend optimizations that might remove the variable
entirely before we have a chance to test the attribute).

Another way I would suggest to approach this would be to make it impossible
for the compiler to mess this up - but that also "complicates" the test a
bit too:

void f1(int&);
void f2() {
  ...attribute... int x;
  f1(x);
}

That way the compiler can't optimize away x, has to put it somewhere in

Re: r268594 - Fix implementation of C++'s restrictions on using-declarations referring to enumerators:

2016-05-05 Thread Reid Kleckner via cfe-commits
On Thu, May 5, 2016 at 11:15 AM, Richard Smith 
wrote:

> Given that GCC rejects this code (and has done for as long as it's
> accepted the Enum::Member syntax), I don't expect the problems to be too
> widespread. If they are, we could trivially accept this as an extension; it
> seems like a pointless restriction.
>

I think there will be widespread issues on Mac, where many projects haven't
built with GCC in years.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r268594 - Fix implementation of C++'s restrictions on using-declarations referring to enumerators:

2016-05-05 Thread Richard Smith via cfe-commits
On Thu, May 5, 2016 at 10:40 AM, Reid Kleckner  wrote:

> FYI, this change broke bionic, which has this exact pattern:
>
> https://android.googlesource.com/platform/bionic/+/master/tools/relocation_packer/src/debug.h#84
>
> struct A {
>   enum E {
> X = 3
>   };
> };
> typedef A::E T;
> using T::X;
>
> I expect users are going to have lots of issues with this, and it probably
> warrants a release note.
>

Given that GCC rejects this code (and has done for as long as it's accepted
the Enum::Member syntax), I don't expect the problems to be too widespread.
If they are, we could trivially accept this as an extension; it seems like
a pointless restriction.


> On Wed, May 4, 2016 at 7:13 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed May  4 21:13:49 2016
>> New Revision: 268594
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=268594=rev
>> Log:
>> Fix implementation of C++'s restrictions on using-declarations referring
>> to enumerators:
>>
>>  * an unscoped enumerator whose enumeration is a class member is itself a
>> class
>>member, so can only be the subject of a class-scope using-declaration.
>>
>>  * a scoped enumerator cannot be the subject of a class-scope
>> using-declaration.
>>
>> Added:
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
>>   - copied, changed from r268583,
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
>>
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp
>>   - copied, changed from r268583,
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
>> Removed:
>>
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
>>
>> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/test/CXX/drs/dr4xx.cpp
>> cfe/trunk/test/SemaCXX/enum-scoped.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268594=268593=268594=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May  4
>> 21:13:49 2016
>> @@ -396,7 +396,9 @@ def note_using_decl_class_member_workaro
>>"use %select{an alias declaration|a typedef declaration|a reference}0 "
>>"instead">;
>>  def err_using_decl_can_not_refer_to_namespace : Error<
>> -  "using declaration cannot refer to namespace">;
>> +  "using declaration cannot refer to a namespace">;
>> +def err_using_decl_can_not_refer_to_scoped_enum : Error<
>> +  "using declaration cannot refer to a scoped enumerator">;
>>  def err_using_decl_constructor : Error<
>>"using declaration cannot refer to a constructor">;
>>  def warn_cxx98_compat_using_decl_constructor : Warning<
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=268594=268593=268594=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed May  4 21:13:49 2016
>> @@ -7738,7 +7738,7 @@ bool Sema::CheckUsingShadowDecl(UsingDec
>>// function will silently decide not to build a shadow decl, which
>>// will pre-empt further diagnostics.
>>//
>> -  // We don't need to do this in C++0x because we do the check once on
>> +  // We don't need to do this in C++11 because we do the check once on
>>// the qualifier.
>>//
>>// FIXME: diagnose the following if we care enough:
>> @@ -8227,7 +8227,7 @@ NamedDecl *Sema::BuildUsingDeclaration(S
>>  }
>>}
>>
>> -  // C++0x N2914 [namespace.udecl]p6:
>> +  // C++14 [namespace.udecl]p6:
>>// A using-declaration shall not name a namespace.
>>if (R.getAsSingle()) {
>>  Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
>> @@ -8235,6 +8235,16 @@ NamedDecl *Sema::BuildUsingDeclaration(S
>>  return BuildInvalid();
>>}
>>
>> +  // C++14 [namespace.udecl]p7:
>> +  // A using-declaration shall not name a scoped enumerator.
>> +  if (auto *ED = R.getAsSingle()) {
>> +if (cast(ED->getDeclContext())->isScoped()) {
>> +  Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
>> +<< SS.getRange();
>> +  return BuildInvalid();
>> +}
>> +  }
>> +
>>UsingDecl *UD = BuildValid();
>>
>>// The normal rules do not apply to inheriting constructor
>> declarations.
>> @@ -8359,8 +8369,10 @@ bool Sema::CheckUsingDeclQualifier(Sourc
>>
>>  // If we weren't able to compute a valid scope, it must be a
>>  // dependent class scope.
>> - 

Re: [PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

2016-05-05 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.


Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:300
@@ -299,2 +299,3 @@
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the 
diagnostics");
 

This assertion seems to be equivalent to replacing the prior 'if' with an 
assertion of the same condition, no? Is that correct? (& if it is, we should 
just do that)


http://reviews.llvm.org/D19962



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


Re: [PATCH] D19959: [scan-build] fix warning emitted on Clang Driver code baseFix a "logic error" warning of the type Called c++ object pointer isnull" reported by Clang Static Analyzer on the file:-

2016-05-05 Thread David Blaikie via cfe-commits
Should this be a test, or just an assertion?

On Thu, May 5, 2016 at 2:34 AM, Apelete Seketeli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> apelete created this revision.
> apelete added reviewers: kevin.qin, rsmith.
> apelete added a subscriber: cfe-commits.
>
> Signed-off-by: Apelete Seketeli 
>
> http://reviews.llvm.org/D19959
>
> Files:
>   lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -2346,7 +2346,7 @@
>  success = getAArch64MicroArchFeaturesFromMcpu(D,
> getAArch64TargetCPU(Args),
>Args, Features);
>
> -  if (!success)
> +  if (!success && A)
>  D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
>
>if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
>
>
>
> ___
> 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: [PATCH] D19960: [scan-build] fix warnings emitted on Clang CodeGen code base

2016-05-05 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1317
@@ -1316,2 +1316,3 @@
   }
+  assert(V && "constant must be not NULL at this point");
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(

It looks like this assertion could actually be a different assertion a little 
higher up.

For 'V' to be non-null, one of the if/else if chain above must fire.

So change the last else if to an else, and the dyn_cast to a cast, and the cast 
will fail an internal assertion if it's not valid (& the analyzer can easily 
then see that at least one of the assignments to V happens - whether or not the 
analyzer assumes that all the initializers of V are non-null, that's a separate 
issue...)


Comment at: lib/CodeGen/CodeGenModule.cpp:2302
@@ -2301,2 +2301,3 @@
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {

Again, a bit confused about whether you're proposing fixing nearly every 
pointer parameter in Clang and LLVM to assert non-null... I think we'd need a 
discussion about what that looks like.


http://reviews.llvm.org/D19960



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


Re: [PATCH] D19084: [scan-build] fix warnings emitted on Clang AST code base

2016-05-05 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.


Comment at: lib/AST/ASTDiagnostic.cpp:1686
@@ -1685,3 +1685,3 @@
 
-if (Same) {
+if (Same && FromTD) {
   OS << "template " << FromTD->getNameAsString();

Should this be a condition, or just an assertion?


Comment at: lib/AST/ExprConstant.cpp:1992
@@ -1991,2 +1991,3 @@
 int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;

Does the static analyzer assume any pointer parameter may be null? (I didn't 
think it did that - I thought it only assumed it could be null if there was a 
null test somewhere in the function?) That seems a bit too pessimistic in most 
codebases, especially LLVM - we pass a lot of non-null pointers around.


Comment at: lib/AST/NestedNameSpecifier.cpp:460
@@ +459,3 @@
+
+assert(Buffer && "Buffer cannot be NULL");
+

Again, is this assuming that the Buffer parameter may be null? That seems 
unlikely to be useful in the LLVM codebase where we have lots of guaranteed 
non-null pointers floating around (I'm surprised this wouldn't cause tons of 
analyzer warnings, so presumably it's something more subtle?)


http://reviews.llvm.org/D19084



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


Re: r268594 - Fix implementation of C++'s restrictions on using-declarations referring to enumerators:

2016-05-05 Thread Reid Kleckner via cfe-commits
FYI, this change broke bionic, which has this exact pattern:
https://android.googlesource.com/platform/bionic/+/master/tools/relocation_packer/src/debug.h#84

struct A {
  enum E {
X = 3
  };
};
typedef A::E T;
using T::X;

I expect users are going to have lots of issues with this, and it probably
warrants a release note.

On Wed, May 4, 2016 at 7:13 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed May  4 21:13:49 2016
> New Revision: 268594
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268594=rev
> Log:
> Fix implementation of C++'s restrictions on using-declarations referring
> to enumerators:
>
>  * an unscoped enumerator whose enumeration is a class member is itself a
> class
>member, so can only be the subject of a class-scope using-declaration.
>
>  * a scoped enumerator cannot be the subject of a class-scope
> using-declaration.
>
> Added:
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
>   - copied, changed from r268583,
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp
>   - copied, changed from r268583,
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
> Removed:
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CXX/drs/dr4xx.cpp
> cfe/trunk/test/SemaCXX/enum-scoped.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268594=268593=268594=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May  4
> 21:13:49 2016
> @@ -396,7 +396,9 @@ def note_using_decl_class_member_workaro
>"use %select{an alias declaration|a typedef declaration|a reference}0 "
>"instead">;
>  def err_using_decl_can_not_refer_to_namespace : Error<
> -  "using declaration cannot refer to namespace">;
> +  "using declaration cannot refer to a namespace">;
> +def err_using_decl_can_not_refer_to_scoped_enum : Error<
> +  "using declaration cannot refer to a scoped enumerator">;
>  def err_using_decl_constructor : Error<
>"using declaration cannot refer to a constructor">;
>  def warn_cxx98_compat_using_decl_constructor : Warning<
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=268594=268593=268594=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed May  4 21:13:49 2016
> @@ -7738,7 +7738,7 @@ bool Sema::CheckUsingShadowDecl(UsingDec
>// function will silently decide not to build a shadow decl, which
>// will pre-empt further diagnostics.
>//
> -  // We don't need to do this in C++0x because we do the check once on
> +  // We don't need to do this in C++11 because we do the check once on
>// the qualifier.
>//
>// FIXME: diagnose the following if we care enough:
> @@ -8227,7 +8227,7 @@ NamedDecl *Sema::BuildUsingDeclaration(S
>  }
>}
>
> -  // C++0x N2914 [namespace.udecl]p6:
> +  // C++14 [namespace.udecl]p6:
>// A using-declaration shall not name a namespace.
>if (R.getAsSingle()) {
>  Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
> @@ -8235,6 +8235,16 @@ NamedDecl *Sema::BuildUsingDeclaration(S
>  return BuildInvalid();
>}
>
> +  // C++14 [namespace.udecl]p7:
> +  // A using-declaration shall not name a scoped enumerator.
> +  if (auto *ED = R.getAsSingle()) {
> +if (cast(ED->getDeclContext())->isScoped()) {
> +  Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
> +<< SS.getRange();
> +  return BuildInvalid();
> +}
> +  }
> +
>UsingDecl *UD = BuildValid();
>
>// The normal rules do not apply to inheriting constructor declarations.
> @@ -8359,8 +8369,10 @@ bool Sema::CheckUsingDeclQualifier(Sourc
>
>  // If we weren't able to compute a valid scope, it must be a
>  // dependent class scope.
> -if (!NamedContext || NamedContext->isRecord()) {
> -  auto *RD = dyn_cast_or_null(NamedContext);
> +if (!NamedContext || NamedContext->getRedeclContext()->isRecord()) {
> +  auto *RD = NamedContext
> + ?
> cast(NamedContext->getRedeclContext())
> + : nullptr;
>if (RD && RequireCompleteDeclContext(const_cast(SS),
> RD))
>  RD = nullptr;
>
> @@ -8444,7 +8456,7 @@ bool 

Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-05-05 Thread Eric Niebler via cfe-commits
eric_niebler added a comment.

"pi"
clangclang 

"ng"


http://reviews.llvm.org/D19843



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


Re: [PATCH] D19918: AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

2016-05-05 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D19918



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


Re: [PATCH] D19769: [clang-tidy] Add explicitly given array size heuristic to misc-suspicious-missing-comma check.

2016-05-05 Thread Dominik Szabó via cfe-commits
szdominik added a comment.

I think the main success is that we don't warn here:

  const char* A[2] = {"a", "b" "c");

The problem is, as you said, not remove already supported cases (such as when 
the parent is not a vardecl (but also an initListExpr)).
But I'll implement, and we'll see it.


http://reviews.llvm.org/D19769



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


Re: [PATCH] D19952: AMDGPU: Use lld as the linker again

2016-05-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268648: AMDGPU: Use lld as the linker again (authored by 
tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D19952?vs=56231=56307#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19952

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/amdgpu-toolchain.c

Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -242,7 +242,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6786,6 +6786,8 @@
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  CmdArgs.push_back("-shared");
+  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
   CmdArgs, Inputs));
Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: amdphdrs{{.*}}
+// AS_LINK: ld.lld{{.*}} "-shared"


Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -242,7 +242,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6786,6 +6786,8 @@
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  CmdArgs.push_back("-shared");
+  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
   CmdArgs, Inputs));
Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: amdphdrs{{.*}}
+// AS_LINK: ld.lld{{.*}} "-shared"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268648 - AMDGPU: Use lld as the linker again

2016-05-05 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu May  5 12:03:41 2016
New Revision: 268648

URL: http://llvm.org/viewvc/llvm-project?rev=268648=rev
Log:
AMDGPU: Use lld as the linker again

Summary:
Now that LLVM is emitting version 2 of the AMD code object, we can
start using lld again for linking instead of our custom tool.

Reviewers: arsenm, kzhuravl

Subscribers: rafael, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=268648=268647=268648=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu May  5 12:03:41 2016
@@ -6786,6 +6786,8 @@ void amdgpu::Linker::ConstructJob(Compil
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  CmdArgs.push_back("-shared");
+  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
   CmdArgs, Inputs));

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=268648=268647=268648=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu May  5 12:03:41 2016
@@ -242,7 +242,7 @@ namespace amdgpu {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=268648=268647=268648=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Thu May  5 12:03:41 2016
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: amdphdrs{{.*}}
+// AS_LINK: ld.lld{{.*}} "-shared"


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


LLVM buildmaster will be updated and restarted tonight

2016-05-05 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


r268642 - [CMake][Apple-stage2] Don't link with -fno-pie

2016-05-05 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Thu May  5 11:31:28 2016
New Revision: 268642

URL: http://llvm.org/viewvc/llvm-project?rev=268642=rev
Log:
[CMake][Apple-stage2] Don't link with -fno-pie

On Darwin the default is to build PIC and link PIE. We shouldn't need to 
override that in the Apple Clang distributions.

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

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268642=268641=268642=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Thu May  5 11:31:28 2016
@@ -28,7 +28,6 @@ set(COMPILER_RT_INCLUDE_TESTS OFF CACHE
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
 set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common 
-Wno-profile-instr-unprofiled" CACHE STRING "")
-set(CMAKE_EXE_LINKER_FLAGS "-fno-pie" CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")


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


Re: [PATCH] D19952: AMDGPU: Use lld as the linker again

2016-05-05 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D19952



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


Re: [PATCH] D19947: [Clang] Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings

2016-05-05 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

nice improvement with getFlag()!


Repository:
  rL LLVM

http://reviews.llvm.org/D19947



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


[PATCH] D19979: [analyzer] ScopeContext - initial implementation

2016-05-05 Thread Aleksei Sidorin via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: zaks.anna, dcoughlin, bshastry.
a.sidorin added a subscriber: cfe-commits.

This patch enables ScopeContext to track variable lifetime. It is RFC mostly 
since the work on its dependencies is still not finished and it lacks some 
tests.
Pre-discussion took place in cfe-dev:
* http://lists.llvm.org/pipermail/cfe-dev/2015-December/046653.html
* 
http://clang-developers.42468.n3.nabble.com/Analyzer-ScopeContext-implementation-td4050861.html

StackLocalsSpaceRegion is still present to preserve current behaviour because 
'cfg-scope-info' is false by default.

http://reviews.llvm.org/D19979

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/ProgramPoint.h
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Core/MemRegion.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/scope-context.cpp

Index: test/Analysis/scope-context.cpp
===
--- /dev/null
+++ test/Analysis/scope-context.cpp
@@ -0,0 +1,24 @@
+// RUN: clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify -analyzer-config cfg-scope-info=true %s
+
+void clang_analyzer_eval(bool);
+
+void testEq() {
+  void *a[2];
+  for (int i = 0; i < 2; ++i) {
+int x[1];
+a[i] = [0];
+  }
+  clang_analyzer_eval(a[0] == a[1]); // expected-warning{{FALSE}}
+}
+
+void testBreak() {
+  for (int i = 0; i < 3; ++i) {
+{
+  int unused;
+  break;
+}
+  }
+  {
+int unused;
+  }
+}
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -106,6 +106,7 @@
 case MemRegion::HeapSpaceRegionKind:
 case MemRegion::UnknownSpaceRegionKind:
 case MemRegion::StaticGlobalSpaceRegionKind:
+case MemRegion::ScopeLocalSpaceRegionKind:
 case MemRegion::GlobalInternalSpaceRegionKind:
 case MemRegion::GlobalSystemSpaceRegionKind:
 case MemRegion::GlobalImmutableSpaceRegionKind: {
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -554,6 +554,14 @@
 return PathDiagnosticLocation(Init.getInitializer()->getInit(),
   SM, CallerCtx);
   }
+  case CFGElement::ScopeBegin: {
+const Stmt *TriggerStmt = Source.castAs().getTriggerStmt();
+return PathDiagnosticLocation(TriggerStmt, SM, CallerCtx);
+  }
+  case CFGElement::ScopeEnd: {
+const Stmt *TriggerStmt = Source.castAs().getTriggerStmt();
+return PathDiagnosticLocation::createEnd(TriggerStmt, SM, CallerCtx);
+  }
   case CFGElement::AutomaticObjectDtor: {
 const CFGAutomaticObjDtor  = Source.castAs();
 return PathDiagnosticLocation::createEnd(Dtor.getTriggerStmt(),
@@ -694,6 +702,10 @@
 return CEE->getCalleeContext()->getCallSite();
   if (Optional PIPP = P.getAs())
 return PIPP->getInitializer()->getInit();
+  if (Optional SE = P.getAs())
+return SE->getTriggerStmt();
+  if (Optional SEnt = P.getAs())
+return SEnt->getTriggerStmt();
 
   return 0;
 }
@@ -746,7 +758,7 @@
 if (const BinaryOperator *B = dyn_cast(S))
   return PathDiagnosticLocation::createOperatorLoc(B, SM);
 
-if (P.getAs())
+if (P.getAs() || P.getAs())
   return PathDiagnosticLocation::createEnd(S, SM, LC);
 
 if (S->getLocStart().isValid())
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -172,8 +172,15 @@
 }
 
 const StackFrameContext *VarRegion::getStackFrame() const {
-  const StackSpaceRegion *SSR = dyn_cast(getMemorySpace());
-  return SSR ? SSR->getStackFrame() : NULL;
+  const MemSpaceRegion *Space = getMemorySpace();
+  if (const StackSpaceRegion *StackSpace = 

r268637 - [Hexagon] Add a testcase for __builtin_HEXAGON_A2_tfrpi

2016-05-05 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu May  5 10:55:54 2016
New Revision: 268637

URL: http://llvm.org/viewvc/llvm-project?rev=268637=rev
Log:
[Hexagon] Add a testcase for __builtin_HEXAGON_A2_tfrpi

Modified:
cfe/trunk/test/CodeGen/builtins-hexagon.c

Modified: cfe/trunk/test/CodeGen/builtins-hexagon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hexagon.c?rev=268637=268636=268637=diff
==
--- cfe/trunk/test/CodeGen/builtins-hexagon.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hexagon.c Thu May  5 10:55:54 2016
@@ -226,6 +226,8 @@ void foo() {
   // CHECK: @llvm.hexagon.A2.tfril
   __builtin_HEXAGON_A2_tfrp(0);
   // CHECK: @llvm.hexagon.A2.tfrp
+  __builtin_HEXAGON_A2_tfrpi(0);
+  // CHECK: @llvm.hexagon.A2.tfrpi
   __builtin_HEXAGON_A2_tfrsi(0);
   // CHECK: @llvm.hexagon.A2.tfrsi
   __builtin_HEXAGON_A2_vabsh(0);


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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-05-05 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

LGTM with one comment about the doxygen comments, but you should probably wait 
to hear from @akyrtzi too.



Comment at: include/clang/Sema/CodeCompleteConsumer.h:916
@@ +915,3 @@
+  /// \name Code-completion filtering
+  //@{
+  /// \brief Check if the result should be filtered out.

Do we really need a group here for just one method?  If we do need the group, 
there should be a matching `@}`.  And it's missing one of the slashes (should 
be  `/// @{`).


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

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

LGTM

FYI, we will also want to update `getAddrOfCXXCatchHandler` and `getThrowInfo` 
to correctly handle `__unaligned`.


http://reviews.llvm.org/D19654



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


RE: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-05 Thread Robinson, Paul via cfe-commits
This would be a great conversation to have at the social, sadly I will
have to miss it this month.

>> dblaikie wrote:
>>> Doesn't look like the const case is any different from the non-const
>>> case, is it?
>> Given a white-box analysis of the compiler internals, you are correct;
>> this is in contrast to the static const/non-const handling, which *does*
>> use different paths.
>> I am unwilling to trust that the const/non-const paths for locals will
>> forever use the same path.  You could also look at it as "the test is
>> the spec."
>
> But even then - what about any other property of a variable? What if it's
> in a nested scope instead of a top level scope? What if it's declared in
> a condition (if (int x = ...)). What if it's volatile? We could pick
> arbitrary properties that /could/ have an effect on debug info but we
> generally believe to be orthogonal to the feature at hand

What you are describing is what testing literature refers to as criteria
for equivalence classes.  There is some level of judgment to that, yes.

> & I'd say 'const' is in the same group of things.

I would have thought exactly that for the static-storage case, but it is
demonstrably not true.  Therefore, const/not is a valid distinction for
the equivalence classes in the static case.  Needing a separate const
test for the static case, it seems completely appropriate to have the 
same for the auto case.  In other words, in my judgment the storage-class
doesn't seem relevant to the equivalence class criteria for the test.

> (a const local variable still needs storage, etc, - the address can be
> escaped and accessed from elsewhere and determined to be unique

All of those objections apply equally to the static case, and yet the
static case must have separate tests.

> - and both variables in this example could be optimized away entirely
> by the compiler because they're unused, so the const is no worse off
> there in that theoretical concern)

Again not different for the (file-)static case.  If a file-static
variable is not used in the CU there's no reason for it to be emitted.
As it happens I *did* need uses to get the static cases to work, and
(currently) don't need uses to get the local cases to work, so in the
interest of not including elements in the test case that are irrelevant
to the feature-under-test, I didn't add uses of the locals.

This is an argument for doing the test exactly as I did: first run it
to prove debug info IS emitted in the absence of the attribute, then
again to prove debug info is suppressed in the presence of the attribute.
That way if optimization or lack-of-use means the variable is not emitted,
the test can be adjusted to make sure that condition does not apply,
proving that the lack of debug info is properly because of the attribute
and not because of some other irrelevant circumstance.

--paulr

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


Re: [PATCH] D19769: [clang-tidy] Add explicitly given array size heuristic to misc-suspicious-missing-comma check.

2016-05-05 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D19769#422317, @szdominik wrote:

> The original size is available - but from the decleration, not from the 
> initListExpr.


Let do the copy paste (correctly):

  clang-query> match namedDecl(hasName("listA"))
  
  Match #1:
  
  Binding for "root":
  VarDecl 0x1a06370  col:13 listA 'const char *[2]' cinit
  `-InitListExpr 0x1a06538  'const char *[2]'
|-ImplicitCastExpr 0x1a06578  'const char *' 
| `-StringLiteral 0x1a06488  'const char [2]' lvalue "a"
`-ImplicitCastExpr 0x1a06598  'const char *' 
  `-StringLiteral 0x1a064b8  'const char [2]' lvalue "b"
  
  1 match.
  clang-query> match namedDecl(hasName("listB"))
  
  Match #1:
  
  Binding for "root":
  VarDecl 0x1a06678  col:13 listB 'const char *[5]' cinit
  `-InitListExpr 0x1a06788  'const char *[5]'
|-array filler
| `-ImplicitValueInitExpr 0x1a06810 <> 'const char *'
|-ImplicitCastExpr 0x1a067c8  'const char *' 
| `-StringLiteral 0x1a066d8  'const char [2]' lvalue "a"
`-ImplicitCastExpr 0x1a067e8  'const char *' 
  `-StringLiteral 0x1a06708  'const char [2]' lvalue "b"

Now, if you are telling me there is a way to handle correctly this example:

const char* A[2] = {"a" "b");

Even using "hasParent" and going to the declaration to get the original 
size this worth implementing it.
Just be sure your matcher won't remove actually supported cases. You first 
proposal was breaking initialization list in initialization list.

So, the plan is:
If the parent is a declaration, and has a size, and the size match skip the 
heuristic even if there is concatenated string literals.

wdyt?


http://reviews.llvm.org/D19769



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-05 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: lib/ASTMatchers/Dynamic/Marshallers.h:102
@@ +101,3 @@
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+return llvm::StringSwitch(AttrKind)
+  .Case("CK_Dependent", CK_Dependent)

etienneb wrote:
> aaron.ballman wrote:
> > This might be an awful idea, but let's explore it.
> > 
> > What if we moved the CastKind enumerator names into a .def (or .inc) file 
> > and use macros to generate the enumeration as well as this monster switch 
> > statement? We do this in other places where it makes sense to do so, such 
> > as in Expr.h:
> > ```
> >   enum AtomicOp {
> > #define BUILTIN(ID, TYPE, ATTRS)
> > #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
> > #include "clang/Basic/Builtins.def"
> > // Avoid trailing comma
> > BI_First = 0
> >   };
> > ```
> Does the dynamic matching is used somewhere else than clang-query?
> I wonder the impact of refactoring to support them if it's barely used.
> It can't be worse than before as it wasn't supported at all (the matcher 
> didn't exists).
> 
> I believe there is a larger cleanup to do to support correctly dynamic 
> matcher like "equals".
> And, this case is one among others.
> 
> I'm not a fan of this huge switch that may just get out-of-sync with the 
> original enum.
> 
> I'm still in favor of adding this matcher to the unsupported list until we 
> push the more complicated fix.
> [which may fall in my plate anyway]
> 
> Any toughs?
I'm not a fan of this either.
If the enum has to be used in this way, it should be refactored to be generated 
with an .inc/.def file.


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56289.
filcab added a comment.

Improve Windows support


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test(.|\\5C)CodeGen(.|\\5C)ubsan-strip-path-components\.cpp}}\00", align 1
+
+// First path component: "/" or "$drive_letter:", then a name, or '\5C' on Windows
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{(.:|/)([^\\/]*(/|\\5C))}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{/|\\5C}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,36 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = 

Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-05 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In http://reviews.llvm.org/D19932#421961, @pxli168 wrote:

> Could we output a generic function in CodeGen?
>  This seems to have no big difference to have a lot of declaration in an 
> opencl c header file.


What return type and argument type to use would you suggest for this generic 
function? If it is something like

  i8 addrspace(1)* to_global(i8 addrspace(4)*)

then bitcasts will be needed, which is what we want to avoid.

These functions accept pointers to arbitrary user types, so they cannot be 
declared in a header file.


http://reviews.llvm.org/D19932



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-05 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In http://reviews.llvm.org/D18369#421963, @pxli168 wrote:

> If we want to save some space, could we use some macro to expand the gentype 
> or some script to expand the gentype into each types when the clang is build?


We need to balance between space and readability. When I absorbed 
__attribute__((overloadable)) into __const_func to save space, it did not 
sacrifice readability. However using macro with gentype will cause the header 
file more difficult to read.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19769: [clang-tidy] Add explicitly given array size heuristic to misc-suspicious-missing-comma check.

2016-05-05 Thread Dominik Szabó via cfe-commits
szdominik added a comment.

The original size is available - but from the decleration, not from the 
initListExpr.



Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:106
@@ +105,3 @@
+  if (InitializerList->hasArrayFiller()) {
+  diag(InitializerList->getExprLoc(),
+   "wrong string array initialization: "

etienneb wrote:
> szdominik wrote:
> > etienneb wrote:
> > > The error should still be reported to the missing comma (concatenated 
> > > token):
> > >   ConcatenatedLiteral->getLocStart(),
> > > 
> > > We could add a NOTE to point to the array, stating that the size mismatch.
> > > 
> > > What do you think?
> > Interesting question (the first idea was that we can't decide that the 
> > comma is missing or the size is wrong, so report to the array, that's a 
> > more secure solution), but I agree that the note could be more effective.
> > And... it's still a suspicious-missing-comma checker, not a 
> > wrong-string-array-size checker :)
> How can you be sure the size was provided by the user? And not inferred by 
> the type system?
> 
> For the following examples:
> ```
> const char* listA[] = {"a", "b" };
> const char* listB[5] = {"a", "b" };
> ```
> 
> We've got this:
> ```
> VarDecl 0x5e9d840  col:13 
> listA 'const char *[2]' cinit
> `-InitListExpr 0x5e9d950  'const char *[2]'
>   |-ImplicitCastExpr 0x5e9d978  'const char *' 
>   | `-StringLiteral 0x5e9d8d8  'const char [2]' lvalue "a"
>   `-ImplicitCastExpr 0x5e9d988  'const char *' 
> `-StringLiteral 0x5e9d8fc  'const char [2]' lvalue "b"
> ```
> 
> ```
> VarDecl 0x5e9d840  col:13 
> listA 'const char *[2]' cinit
> `-InitListExpr 0x5e9d950  'const char *[2]'
>   |-ImplicitCastExpr 0x5e9d978  'const char *' 
>   | `-StringLiteral 0x5e9d8d8  'const char [2]' lvalue "a"
>   `-ImplicitCastExpr 0x5e9d988  'const char *' 
> `-StringLiteral 0x5e9d8fc  'const char [2]' lvalue "b"
> ```
> 
> How can I tell the "size" was written by the user?
> How can you get the "5" and not the "2".
> 
(You copied twice the AST-tree part of listA :))

The array, which was declared with explicit given size, has different type than 
the usual one. And I can filter the proper cases because of the different 
(incomplete / constant) array type. 
e.g.

```
VariableDeclaration->getTypeSourceInfo()->getType()->dump()

```
```
const char *string_array_init[3] = {
"first elem",
"second elem"
"third elem"
};
```
```
ConstantArrayType 0x1efae70 'const char *[3]' 3 
`-PointerType 0x1efae40 'const char *'
  `-QualType 0x1efa511 'const char' const
`-BuiltinType 0x1efa510 'char'
```
But
```
const char *string_array_init2[] = {
"first elem",
"second elem"
"third elem"
};
```
```
IncompleteArrayType 0x1f49ba0 'const char *[]' 
`-PointerType 0x1efae40 'const char *'
  `-QualType 0x1efa511 'const char' const
`-BuiltinType 0x1efa510 'char'
```
However, the type of InitListExpr is always ConstantArrayType (I tried to find 
a way to be sure the size is explicit given or inferred, but... I don't find 
anything).
So (unless you haven't better idea) I have two options, as I see:
a) use the array filler solution, but I can't reduce the false-positive cases.
b) use the decleration's type, but I have to use some kind of heuristic, what 
you told me at your first comment.
Probably we should decide which one is less used.


http://reviews.llvm.org/D19769



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


[PATCH] D19957: clang-rename: when renaming a field, rename initializers of that field as well

2016-05-05 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

The second check failed, the initializer wasn't renamed.

http://reviews.llvm.org/D19957

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/FieldTest.cpp

Index: test/clang-rename/FieldTest.cpp
===
--- /dev/null
+++ test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
 return true;
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (clang::CXXConstructorDecl::init_const_iterator it = 
ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
+  const clang::CXXCtorInitializer* Initializer = *it;
+  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+if (getUSRForDecl(FieldDecl) == USR) {
+  // The initializer refers to a field that is to be renamed.
+  LocationsFound.push_back(Initializer->getSourceLocation());
+}
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {


Index: test/clang-rename/FieldTest.cpp
===
--- /dev/null
+++ test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
 return true;
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
+  const clang::CXXCtorInitializer* Initializer = *it;
+  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+if (getUSRForDecl(FieldDecl) == USR) {
+  // The initializer refers to a field that is to be renamed.
+  LocationsFound.push_back(Initializer->getSourceLocation());
+}
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-05 Thread Jonathan Coe via cfe-commits
Modernize it is then.

The check currently only catches std::bind but further work can address that.

Jon

> On 4 May 2016, at 22:40, Arthur O'Dwyer  wrote:
> 
>> On Wed, May 4, 2016 at 1:43 PM, Aaron Ballman via cfe-commits 
>>  wrote:
>> jbcoe wrote:
>> > aaron.ballman wrote:
>> > > I believe we use "modernize" to really mean "migrate from the old way to 
>> > > the new way", which this definitely fits into since I think the point to 
>> > > this check is to replace bind with better alternatives.
>> > Would you prefer it to be in `modernize`? I can be easily convinced either 
>> > way and am happy to move it. If I do move it I might add a script to 
>> > facilitate doing so.
>> My preference is for modernize, your preference is for readability, so I 
>> say: make @alexfh the tie-breaker! ;-) Alex, what are your thoughts? This 
>> seems like a heuristic we may want to state in our documentation to help 
>> others decide where to put new checks in the future as well.
> 
> FWIW, I'd prefer "modernize", and I'll point out that these waters are 
> muddied by the fact that three of the old ways (boost::bind, std::bind1st, 
> std::bind2nd) all existed prior to C++11, so the fact that one of the old 
> ways (std::bind) was introduced in C++11 doesn't matter so much.
> (I haven't looked, but I'd assume that this clang-tidy check catches all four 
> cases, right?)
> 
> –Arthur
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19952: AMDGPU: Use lld as the linker again

2016-05-05 Thread Rafael Ávila de Espíndola via cfe-commits
rafael added a subscriber: rafael.
rafael added a comment.

lgtm


http://reviews.llvm.org/D19952



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-05 Thread Jonathan B Coe via cfe-commits
jbcoe removed a reviewer: djasper.
jbcoe updated this revision to Diff 56273.
jbcoe added a comment.

Move to modernize. Rename to `avoid-bind` as a later patch will add support for 
`boost::bind`, `std::bind1st` etc.


http://reviews.llvm.org/D16962

Files:
  clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tidy/modernize/AvoidBindCheck.h
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-avoid-bind.rst
  test/clang-tidy/modernize-avoid-bind.cpp

Index: test/clang-tidy/modernize-avoid-bind.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-avoid-bind.cpp
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s modernize-avoid-bind %t -- -- -std=c++14
+
+namespace std {
+inline namespace impl {
+template 
+class bind_rt {};
+
+template 
+bind_rt bind(Fp &&, Arguments &&...);
+}
+}
+
+int add(int x, int y) { return x + y; }
+
+void f() {
+  auto clj = std::bind(add, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // CHECK-FIXES: auto clj = [] { return add(2, 2); };
+}
+
+void g() {
+  int x = 2;
+  int y = 2;
+  auto clj = std::bind(add, x, y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // CHECK-FIXES: auto clj = [=] { return add(x, y); };
+}
+
+struct placeholder {};
+placeholder _1;
+placeholder _2;
+
+void h() {
+  int x = 2;
+  auto clj = std::bind(add, x, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
+}
+
+struct A;
+struct B;
+bool ABTest(const A &, const B &);
+
+void i() {
+  auto BATest = std::bind(ABTest, _2, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
+}
+
+void j() {
+  auto clj = std::bind(add, 2, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // No fix is applied for argument mismatches.
+  // CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
+}
+
+void k() {
+  auto clj = std::bind(add, _1, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // No fix is applied for reused placeholders.
+  // CHECK-FIXES: auto clj = std::bind(add, _1, _1);
+}
+
+void m() {
+  auto clj = std::bind(add, 1, add(2, 5));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
+  // No fix is applied for nested calls.
+  // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
+}
+
Index: docs/clang-tidy/checks/modernize-avoid-bind.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-avoid-bind.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - modernize-avoid-std-bind
+
+modernize-avoid-bind
+==
+
+The check finds uses of ``std::bind`` and replaces simple uses with lambdas.
+Lambdas will use value-capture where required.
+
+Right now it only handles free functions, not member functions.
+
+Given:
+
+.. code:: C++
+  int add(int x, int y) { return x + y; }
+
+Then:
+
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = std::bind(add, x, _1);
+  }
+
+is replaced by:
+  
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = [=](auto && arg1) { return add(x, arg1); };
+  }
+
+We created this check because ``std::bind`` can be hard to read and can result
+in larger object files and binaries due to type information that will not be
+produced by equivalent lambdas.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -87,6 +87,7 @@
misc-unused-raii
misc-unused-using-decls
misc-virtual-near-miss
+   modernize-avoid-bind
modernize-deprecated-headers
modernize-loop-convert
modernize-make-unique
Index: clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidBindCheck.h"
 #include "DeprecatedHeadersCheck.h"
 #include "LoopConvertCheck.h"
 #include "MakeUniqueCheck.h"
@@ -32,6 +33,8 @@
 class ModernizeModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"modernize-avoid-bind");
 CheckFactories.registerCheck(
 "modernize-deprecated-headers");
 

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In http://reviews.llvm.org/D19666#422150, @ygribov wrote:

> Can we have generic option for other sanitizers?


Do other sanitizers emit paths this way?
For ASan, for example, we end up emitting them only when there are global 
constructors involved, where we'd emit an __asan_global.
I don't know much about msan and tsan, but I'd think it wouldn't make as much a 
difference as this does in ubsan, since ubsan basically emits checks in every 
(non-trivial) file you compile.

I'm not opposed to doing it for other sanitizers, but the better option would 
be to measure first to see if it's useful. If it is, then deprecate this flag 
and do a more generic one.
BTW, how would we pass this information along to llvm-land so the other 
sanitizers could use it? Is there a mechanism already in place?


http://reviews.llvm.org/D19666



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


r268625 - Add a test for PR26076.

2016-05-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu May  5 06:51:22 2016
New Revision: 268625

URL: http://llvm.org/viewvc/llvm-project?rev=268625=rev
Log:
Add a test for PR26076.

r262056 accidentally fixed this.  Add a test to ensure it
doesn't regress.

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

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=268625=268624=268625=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Thu May  5 06:51:22 2016
@@ -933,3 +933,17 @@ template struct __declspec(dllimport) Ex
 USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv
+
+// PR26076
+struct LayerSelectionBound;
+template  struct Selection {};
+typedef Selection LayerSelection;
+struct LayerImpl;
+struct __declspec(dllexport) LayerTreeImpl {
+  struct __declspec(dllexport) ElementLayers {
+LayerImpl *main = nullptr;
+  };
+  LayerSelection foo;
+};
+// M32-DAG: define weak_odr dllexport x86_thiscallcc 
%"struct.LayerTreeImpl::ElementLayers"* 
@"\01??0ElementLayers@LayerTreeImpl@@QAE@XZ"
+// M64-DAG: define weak_odr dllexport %"struct.LayerTreeImpl::ElementLayers"* 
@"\01??0ElementLayers@LayerTreeImpl@@QEAA@XZ"


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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Yury Gribov via cfe-commits
ygribov added a subscriber: ygribov.
ygribov added a comment.

Can we have generic option for other sanitizers?


http://reviews.llvm.org/D19666



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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56262.
filcab added a comment.

Remove .data() call


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,36 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddrOfConstantCString(PLoc.getFilename(), ".src");
+StringRef FilenameString = PLoc.getFilename();
+
+

Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch

2016-05-05 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56261.
filcab added a comment.

Update catch-undef-behavior.c


http://reviews.llvm.org/D19667

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/catch-undef-behavior.c

Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 
100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, 
{{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 
4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 
4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 
2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 
2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, 
[11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} 
@[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -575,12 +575,12 @@
   }
 
   if (Checks.size() > 0) {
+// Make sure we're not losing information. Alignment needs to be a power 
of 2
+assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
 llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(Loc),
-  EmitCheckTypeDescriptor(Ty),
-  llvm::ConstantInt::get(SizeTy, AlignVal),
-  llvm::ConstantInt::get(Int8Ty, TCK)
-};
+EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty),
+llvm::ConstantInt::get(Int8Ty, llvm::Log2_64(AlignVal)),
+llvm::ConstantInt::get(Int8Ty, TCK)};
 EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
   }
 


Index: test/CodeGen/catch-undef-behavior.c
===
--- test/CodeGen/catch-undef-behavior.c
+++ test/CodeGen/catch-undef-behavior.c
@@ -6,16 +6,16 @@
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i8 2, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i8 2, i8 0
 // CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
 // CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
-// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i8 2, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i8 2, i8 1 }
 
 // CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i8 2, i8 3 }
 // CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 // CHECK-UBSAN: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 10 {{.*}} @{{.*}} }
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ 

[PATCH] D19963: [scan-build] fix warnings emitted on Clang Frontend code baseFix "Logic error" warnings of the type "Called C++ object pointer isnull" reported by Clang Static Analyzer on the followin

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added reviewers: akyrtzi, rsmith.
apelete added a subscriber: cfe-commits.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19963

Files:
  lib/Frontend/CompilerInstance.cpp

Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [Diffusion] rL268585: [modules] Enforce the rules that an explicit or partial specialization must be

2016-05-05 Thread NAKAMURA Takumi via cfe-commits
chapuni added subscribers: cfe-commits, chapuni.

/cfe/trunk/include/clang/Sema/Sema.h:1898 This method doesn't return anything. 
Tweaked in r268621. [-Wdocumentation]

Users:
  rsmith (Author)

http://reviews.llvm.org/rL268585



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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 56259.
apelete added a comment.

[scan-build] fix warnings emitted on Clang Format code base

Changes since last revision:

- split patch into Format unit to ease review process.


http://reviews.llvm.org/D19385

Files:
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h

Index: lib/Format/AffectedRangeManager.h
===
--- lib/Format/AffectedRangeManager.h
+++ lib/Format/AffectedRangeManager.h
@@ -54,7 +54,7 @@
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
-  bool nonPPLineAffected(AnnotatedLine *Line,
+  bool nonPPLineAffected(AnnotatedLine ,
  const AnnotatedLine *PreviousLine);
 
   const SourceManager 
Index: lib/Format/AffectedRangeManager.cpp
===
--- lib/Format/AffectedRangeManager.cpp
+++ lib/Format/AffectedRangeManager.cpp
@@ -48,7 +48,7 @@
   continue;
 }
 
-if (nonPPLineAffected(Line, PreviousLine))
+if (nonPPLineAffected(*Line, PreviousLine))
   SomeLineAffected = true;
 
 PreviousLine = Line;
@@ -99,24 +99,27 @@
 }
 
 bool AffectedRangeManager::nonPPLineAffected(
-AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+AnnotatedLine , const AnnotatedLine *PreviousLine) {
   bool SomeLineAffected = false;
-  Line->ChildrenAffected =
-  computeAffectedLines(Line->Children.begin(), Line->Children.end());
-  if (Line->ChildrenAffected)
+  Line.ChildrenAffected =
+  computeAffectedLines(Line.Children.begin(), Line.Children.end());
+  if (Line.ChildrenAffected)
 SomeLineAffected = true;
 
-  // Stores whether one of the line's tokens is directly affected.
-  bool SomeTokenAffected = false;
   // Stores whether we need to look at the leading newlines of the next token
   // in order to determine whether it was affected.
   bool IncludeLeadingNewlines = false;
 
   // Stores whether the first child line of any of this line's tokens is
   // affected.
   bool SomeFirstChildAffected = false;
 
-  for (FormatToken *Tok = Line->First; Tok; Tok = Tok->Next) {
+  // Stores whether one of the line's tokens is directly affected.
+  bool SomeTokenAffected = false;
+  if (Line.First == nullptr)
+return SomeTokenAffected;
+
+  for (FormatToken *Tok = Line.First; Tok; Tok = Tok->Next) {
 // Determine whether 'Tok' was affected.
 if (affectsTokenRange(*Tok, *Tok, IncludeLeadingNewlines))
   SomeTokenAffected = true;
@@ -131,16 +134,16 @@
   // Was this line moved, i.e. has it previously been on the same line as an
   // affected line?
   bool LineMoved = PreviousLine && PreviousLine->Affected &&
-   Line->First->NewlinesBefore == 0;
+   Line.First->NewlinesBefore == 0;
 
   bool IsContinuedComment =
-  Line->First->is(tok::comment) && Line->First->Next == nullptr &&
-  Line->First->NewlinesBefore < 2 && PreviousLine &&
+  Line.First->is(tok::comment) && Line.First->Next == nullptr &&
+  Line.First->NewlinesBefore < 2 && PreviousLine &&
   PreviousLine->Affected && PreviousLine->Last->is(tok::comment);
 
   if (SomeTokenAffected || SomeFirstChildAffected || LineMoved ||
   IsContinuedComment) {
-Line->Affected = true;
+Line.Affected = true;
 SomeLineAffected = true;
   }
   return SomeLineAffected;


Index: lib/Format/AffectedRangeManager.h
===
--- lib/Format/AffectedRangeManager.h
+++ lib/Format/AffectedRangeManager.h
@@ -54,7 +54,7 @@
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
-  bool nonPPLineAffected(AnnotatedLine *Line,
+  bool nonPPLineAffected(AnnotatedLine ,
  const AnnotatedLine *PreviousLine);
 
   const SourceManager 
Index: lib/Format/AffectedRangeManager.cpp
===
--- lib/Format/AffectedRangeManager.cpp
+++ lib/Format/AffectedRangeManager.cpp
@@ -48,7 +48,7 @@
   continue;
 }
 
-if (nonPPLineAffected(Line, PreviousLine))
+if (nonPPLineAffected(*Line, PreviousLine))
   SomeLineAffected = true;
 
 PreviousLine = Line;
@@ -99,24 +99,27 @@
 }
 
 bool AffectedRangeManager::nonPPLineAffected(
-AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+AnnotatedLine , const AnnotatedLine *PreviousLine) {
   bool SomeLineAffected = false;
-  Line->ChildrenAffected =
-  computeAffectedLines(Line->Children.begin(), Line->Children.end());
-  if (Line->ChildrenAffected)
+  Line.ChildrenAffected =
+  computeAffectedLines(Line.Children.begin(), Line.Children.end());
+  if (Line.ChildrenAffected)
 SomeLineAffected = true;
 
-  // Stores whether one of the line's tokens is directly affected.

r268621 - Sema.h: Prune a redundant \return. [-Wdocumentation]

2016-05-05 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu May  5 05:29:11 2016
New Revision: 268621

URL: http://llvm.org/viewvc/llvm-project?rev=268621=rev
Log:
Sema.h: Prune a redundant \return. [-Wdocumentation]

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268621=268620=268621=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu May  5 05:29:11 2016
@@ -1895,7 +1895,6 @@ public:
   /// \brief We've found a use of a templated declaration that would trigger an
   /// implicit instantiation. Check that any relevant explicit specializations
   /// and partial specializations are visible, and diagnose if not.
-  /// \return Whether a problem was diagnosed.
   void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec);
 
   /// \brief We've found a use of a template specialization that would select a


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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

David, just noticed that your first question doesn't have a redefinition. For 
this program:

__unaligned int unaligned_foo3() { return 0; }
auto z = unaligned_foo3();

Both MS and us mangle z the same:

?z@@3HA

Yours,
Andrey


http://reviews.llvm.org/D19654



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


[PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added a reviewer: zaks.anna.
apelete added a subscriber: cfe-commits.

This patch fixes a few "Logic error" warnings of the type "Called c++
object pointer is null" reported by Clang Static Analyzer on the
following files:

- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp,
- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19962

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the 
diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =


Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked an inline comment as done.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> majnemer wrote:
> > rnk wrote:
> > > majnemer wrote:
> > > > andreybokhanko wrote:
> > > > > majnemer wrote:
> > > > > > andreybokhanko wrote:
> > > > > > > Done. Test added.
> > > > > > Hmm, can you give a concrete example why we need this line?
> > > > > Sure. An example is:
> > > > > 
> > > > > __unaligned int unaligned_foo3() { return 0; }
> > > > > 
> > > > > MS mangles it as
> > > > > 
> > > > > ?unaligned_foo3@@YAHXZ
> > > > > 
> > > > > However, if __unaligned is taken into account, "if ((!IsPointer && 
> > > > > Quals) || isa(T))" computes to true and clang adds "?A", 
> > > > > resulting to
> > > > > 
> > > > > ?unaligned_foo3@@YA?AHXZ
> > > > > 
> > > > > Yours,
> > > > > Andrey
> > > > > 
> > > > Wait, I thought __unaligned can only apply to pointer types.  Is this 
> > > > not so?!
> > > > Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
> > > Yeah it does:
> > >   $ cat t.cpp
> > >   __unaligned int x;
> > >   $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
> > >   t.cpp
> > >   008  SECT3  notype   External | ?x@@3HFA (int 
> > > __unaligned x)
> > Woah.  So if you do:
> > 
> > > __unaligned int unaligned_foo3() { return 0; }
> > > auto z = foo3();
> > 
> > How is `z` mangled?
> `z` is mangled without the qualifiers.  In fact:
> 
> ```
> __unaligned int unaligned_foo3() { return 0; }
> __unaligned int z;
> auto z = unaligned_foo3();
> ```
> 
> Is an error:
> 
> 
> > x.cpp(3): error C2373: 'z': redefinition; different type modifiers
> > x.cpp(2): note: see declaration of 'z'
> 
> Do we have comparable behavior?
Not exactly the same, but comparable, indeed:

```
$ clang -cc1 ~/test.cpp -std=c++11 -triple i686-pc-win32 -fms-extensions
/nfs/ims/home/asbokhan/test.cpp:3:6: error: redefinition of 'z'
auto z = unaligned_foo3();
 ^
/nfs/ims/home/asbokhan/test.cpp:2:17: note: previous definition is here
__unaligned int z;
^
1 error generated.
```

This has nothing to do with __unaligned, though, as both MS compiler and us 
don't allow redefinitions. If a redefinition has a different __unaligned 
modifier, MS also notes this (with "; different type modifiers" suffix in the 
message), but it doesn't serve any practical purpose, as changing modifier 
won't make the code compilable.

Yours,
Andrey


http://reviews.llvm.org/D19654



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


[PATCH] D19960: [scan-build] fix warnings emitted on Clang CodeGen code base

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added reviewers: dblaikie, pcc.
apelete added a subscriber: cfe-commits.

Fix "Logic error" warnings of the type "Called c++ object pointer is
null" reported by Clang Static Analyzer on the following files:

- lib/CodeGen/CGDebugInfo.cpp,
- lib/CodeGen/CodeGenModule.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19960

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2299,6 +2299,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1314,6 +1314,7 @@
 CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset);
 V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars);
   }
+  assert(V && "constant must be not NULL at this point");
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(
   TheCU, Name, TTy,
   cast_or_null(V->stripPointerCasts(;


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2299,6 +2299,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1314,6 +1314,7 @@
 CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset);
 V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars);
   }
+  assert(V && "constant must be not NULL at this point");
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(
   TheCU, Name, TTy,
   cast_or_null(V->stripPointerCasts(;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 56253.
apelete added a comment.

[scan-build] fix warnings emitted on Clang Sema code base

Changes since last revision:

- split patch into Sema changes unit to ease review process,
- cherry-pick Sema changes from http://reviews.llvm.org/D19084,
- cherry-pick Sema changes from http://reviews.llvm.org/D19385.


http://reviews.llvm.org/D19278

Files:
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp

Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -8705,6 +8705,7 @@
 
 void Sema::diagnoseEquivalentInternalLinkageDeclarations(
 SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) {
+  assert(D && "named declaration must be not NULL");
   Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
 
   Module *M = getOwningModule(const_cast(D));
@@ -9185,7 +9186,9 @@
 !ToRefTy->getPointeeType()->isIncompleteType() &&
 S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) {
   BaseToDerivedConversion = 3;
-} else if (ToTy->isLValueReferenceType() && !FromExpr->isLValue() &&
+} else if (FromExpr &&
+   !FromExpr->isLValue() &&
+   ToTy->isLValueReferenceType() &&
ToTy.getNonReferenceType().getCanonicalType() ==
FromTy.getNonReferenceType().getCanonicalType()) {
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -985,6 +985,7 @@
 (VD && DSAStack->isForceVarCapturing()))
   return VD ? VD : Info.second;
 auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
+assert(DVarPrivate.PrivateCopy && "DSAStackTy object must be not NULL");
 if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(),
@@ -3994,6 +3995,7 @@
 static ExprResult
 tryBuildCapture(Sema , Expr *Capture,
 llvm::MapVector ) {
+  assert(Capture && "cannot build capture if expression is NULL");
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
 return SemaRef.PerformImplicitConversion(
 Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,
@@ -4251,7 +4253,7 @@
 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 0 << CollapseLoopCountExpr->getSourceRange();
-  else
+  else if (OrderedLoopCountExpr)
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 1 << OrderedLoopCountExpr->getSourceRange();
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool AnyVisibleDecls = !NewDecls.empty();
 
   for (/**/; DI != DE; ++DI) {
+assert(*DI && "TypoCorrection iterator cannot be NULL");
 NamedDecl *VisibleDecl = *DI;
 if (!LookupResult::isVisible(SemaRef, *DI))
   VisibleDecl = findAcceptableDecl(SemaRef, *DI);
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -4862,6 +4862,8 @@
InitializationSequence ,
const InitializedEntity ,
Expr *Initializer) {
+  assert(Initializer && "Initializer needs to be not NULL");
+
   bool ArrayDecay = false;
   QualType ArgType = Initializer->getType();
   QualType ArgPointee;
@@ -5237,11 +5239,11 @@
 DeclAccessPair dap;
 if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer)) {
   AddZeroInitializationStep(Entity.getType());
-} else if (Initializer->getType() == Context.OverloadTy &&
+} else if (Initializer && Initializer->getType() == Context.OverloadTy &&
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
  false, dap))
   SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
-else if (Initializer->getType()->isFunctionType() &&
+else if (Initializer && Initializer->getType()->isFunctionType() &&
  isExprAnUnaddressableFunction(S, Initializer))
   SetFailed(InitializationSequence::FK_AddressOfUnaddressableFunction);
 else
Index: lib/Sema/SemaExprCXX.cpp
===
--- 

Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-05-05 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Updated the diff with changes
http://reviews.llvm.org/D19105


http://reviews.llvm.org/D18821



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


Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-05 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 56250.
Prazek added a comment.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: jfb, mzolotukhin, dsanders, arsenm, MatzeB.

It seems that is doing it's work right now.

I will have to change some places to post it to llvm like:

- changing functions return type to bool
- removng comparasion with bool for bools


http://reviews.llvm.org/D19105

Files:
  clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclarationName.cpp
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Writer/BitWriter.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/MachineScheduler.cpp
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SplitKit.cpp
  lib/DebugInfo/Symbolize/DIPrinter.cpp
  lib/Driver/Tools.cpp
  lib/ExecutionEngine/Interpreter/Execution.cpp
  lib/IR/Core.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/MC/MCContext.cpp
  lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Support/APInt.cpp
  lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  lib/Target/AArch64/Disassembler/AArch64ExternalSymbolizer.cpp
  lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
  lib/Target/AMDGPU/R600InstrInfo.cpp
  lib/Target/AMDGPU/SIMachineScheduler.cpp
  lib/Target/ARM/ARMConstantIslandPass.cpp
  lib/Target/ARM/ARMFastISel.cpp
  lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
  lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
  lib/Target/Hexagon/HexagonOptAddrMode.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonMCChecker.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonMCShuffler.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp
  lib/Target/Mips/MipsConstantIslandPass.cpp
  lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
  lib/Target/TargetMachineC.cpp
  lib/Target/X86/X86FrameLowering.cpp
  lib/Transforms/IPO/GlobalOpt.cpp
  lib/Transforms/IPO/MergeFunctions.cpp
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  lib/Transforms/Scalar/GVN.cpp
  lib/Transforms/Scalar/LoopInstSimplify.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXComment.cpp
  tools/libclang/CXCursor.cpp
  tools/libclang/CXIndexDataConsumer.cpp
  tools/libclang/CXType.cpp
  tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
  tools/llvm-c-test/echo.cpp
  tools/llvm-nm/llvm-nm.cpp
  tools/llvm-pdbdump/llvm-pdbdump.cpp
  tools/llvm-symbolizer/llvm-symbolizer.cpp
  unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
  unittests/IR/ValueMapTest.cpp
  unittests/Support/CommandLineTest.cpp
  unittests/libclang/LibclangTest.cpp

Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -250,20 +250,20 @@
   if (!Context.getLangOpts().CPlusPlus11 &&
   (DestinationType->isPointerType() ||
DestinationType->isMemberPointerType()) &&
-  BoolLiteralExpression->getValue() == false) {
+  BoolLiteralExpression->getValue() == 0) {
 return "0";
   }
 
   if (DestinationType->isFloatingType()) {
-if (BoolLiteralExpression->getValue() == true) {
+if (BoolLiteralExpression->getValue() == 1) {
   return Context.hasSameType(DestinationType, Context.FloatTy) ? "1.0f"
: "1.0";
 }
 return Context.hasSameType(DestinationType, Context.FloatTy) ? "0.0f"
  : "0.0";
   }
 
-  if (BoolLiteralExpression->getValue() == true) {
+  if (BoolLiteralExpression->getValue() == 1) {
 return DestinationType->isUnsignedIntegerType() ? "1u" : "1";
   }
   return DestinationType->isUnsignedIntegerType() ? "0u" : "0";
Index: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -33,7 +33,7 @@
 
 void ThrowByValueCatchByReferenceCheck::storeOptions(
 ClangTidyOptions::OptionMap ) {
-  Options.store(Opts, "CheckThrowTemporaries", true);
+  Options.store(Opts, "CheckThrowTemporaries", 1);
 }
 
 void ThrowByValueCatchByReferenceCheck::check(
Index: unittests/libclang/LibclangTest.cpp
===
--- 

[PATCH] D19959: [scan-build] fix warning emitted on Clang Driver code baseFix a "logic error" warning of the type Called c++ object pointer isnull" reported by Clang Static Analyzer on the file:- lib/

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added reviewers: kevin.qin, rsmith.
apelete added a subscriber: cfe-commits.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19959

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2346,7 +2346,7 @@
 success = getAArch64MicroArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args),
   Args, Features);
 
-  if (!success)
+  if (!success && A)
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2346,7 +2346,7 @@
 success = getAArch64MicroArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args),
   Args, Features);
 
-  if (!success)
+  if (!success && A)
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19084: [clang-analyzer] fix warnings emitted on clang code base

2016-05-05 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 56248.
apelete added a comment.

[scan-build] fix warnings emitted on Clang AST code base

Changes since last revision:

- split patch into AST changes unit to ease review process.


http://reviews.llvm.org/D19084

Files:
  lib/AST/ASTDiagnostic.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/NestedNameSpecifier.cpp

Index: lib/AST/NestedNameSpecifier.cpp
===
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
   Buffer = NewBuffer;
   BufferCapacity = NewCapacity;
 }
-
+
+assert(Buffer && "Buffer cannot be NULL");
+
 memcpy(Buffer + BufferSize, Start, End - Start);
 BufferSize += End-Start;
   }
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1989,6 +1989,7 @@
 static bool HandleLValueArrayAdjustment(EvalInfo , const Expr *E,
 LValue , QualType EltTy,
 int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
   if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
 return false;
Index: lib/AST/DeclObjC.cpp
===
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
   data().IvarList = layout[0].Ivar; Ix++;
   curIvar = data().IvarList;
 }
-for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+  assert(curIvar && "instance variable is NULL, stop iterating through 
layout");
   curIvar->setNextIvar(layout[Ix].Ivar);
+}
   }
 }
   }
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1683,7 +1683,7 @@
   ToName = ToTD->getQualifiedNameAsString();
 }
 
-if (Same) {
+if (Same && FromTD) {
   OS << "template " << FromTD->getNameAsString();
 } else if (!PrintTree) {
   OS << (FromDefault ? "(default) template " : "template ");


Index: lib/AST/NestedNameSpecifier.cpp
===
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
   Buffer = NewBuffer;
   BufferCapacity = NewCapacity;
 }
-
+
+assert(Buffer && "Buffer cannot be NULL");
+
 memcpy(Buffer + BufferSize, Start, End - Start);
 BufferSize += End-Start;
   }
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1989,6 +1989,7 @@
 static bool HandleLValueArrayAdjustment(EvalInfo , const Expr *E,
 LValue , QualType EltTy,
 int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
   if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
 return false;
Index: lib/AST/DeclObjC.cpp
===
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
   data().IvarList = layout[0].Ivar; Ix++;
   curIvar = data().IvarList;
 }
-for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+  assert(curIvar && "instance variable is NULL, stop iterating through layout");
   curIvar->setNextIvar(layout[Ix].Ivar);
+}
   }
 }
   }
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1683,7 +1683,7 @@
   ToName = ToTD->getQualifiedNameAsString();
 }
 
-if (Same) {
+if (Same && FromTD) {
   OS << "template " << FromTD->getNameAsString();
 } else if (!PrintTree) {
   OS << (FromDefault ? "(default) template " : "template ");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268618 - [OPENMP 4.5] Codegen for 'lastprivate' clauses in 'taskloop' directives.

2016-05-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu May  5 03:46:22 2016
New Revision: 268618

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

OpenMP 4.5 adds taskloop/taskloop simd directives. These directives
allow to use lastprivate clause. Patch adds codegen for this clause.

Added:
cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=268618=268617=268618=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu May  5 03:46:22 2016
@@ -3292,6 +3292,7 @@ static llvm::Value *
 emitTaskPrivateMappingFunction(CodeGenModule , SourceLocation Loc,
ArrayRef PrivateVars,
ArrayRef FirstprivateVars,
+   ArrayRef LastprivateVars,
QualType PrivatesQTy,
ArrayRef Privates) {
   auto  = CGM.getContext();
@@ -3322,6 +3323,16 @@ emitTaskPrivateMappingFunction(CodeGenMo
 PrivateVarsPos[VD] = Counter;
 ++Counter;
   }
+  for (auto *E: LastprivateVars) {
+Args.push_back(ImplicitParamDecl::Create(
+C, /*DC=*/nullptr, Loc,
+/*Id=*/nullptr, C.getPointerType(C.getPointerType(E->getType()))
+.withConst()
+.withRestrict()));
+auto *VD = cast(cast(E)->getDecl());
+PrivateVarsPos[VD] = Counter;
+++Counter;
+  }
   auto  =
   CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, Args);
   auto *TaskPrivatesMapTy =
@@ -3361,6 +3372,179 @@ static int array_pod_sort_comparator(con
   return P1->first < P2->first ? 1 : (P2->first < P1->first ? -1 : 0);
 }
 
+/// Emit initialization for private variables in task-based directives.
+/// \return true if cleanups are required, false otherwise.
+static bool emitPrivatesInit(CodeGenFunction ,
+ const OMPExecutableDirective ,
+ Address KmpTaskSharedsPtr, LValue TDBase,
+ const RecordDecl *KmpTaskTWithPrivatesQTyRD,
+ QualType SharedsTy, QualType SharedsPtrTy,
+ const OMPTaskDataTy ,
+ ArrayRef Privates, bool ForDup) {
+  auto  = CGF.getContext();
+  bool NeedsCleanup = false;
+  auto FI = std::next(KmpTaskTWithPrivatesQTyRD->field_begin());
+  LValue PrivatesBase = CGF.EmitLValueForField(TDBase, *FI);
+  LValue SrcBase;
+  if (!Data.FirstprivateVars.empty()) {
+SrcBase = CGF.MakeAddrLValue(
+CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+KmpTaskSharedsPtr, CGF.ConvertTypeForMem(SharedsPtrTy)),
+SharedsTy);
+  }
+  CodeGenFunction::CGCapturedStmtInfo CapturesInfo(
+  cast(*D.getAssociatedStmt()));
+  FI = cast(FI->getType()->getAsTagDecl())->field_begin();
+  for (auto & : Privates) {
+auto *VD = Pair.second.PrivateCopy;
+auto *Init = VD->getAnyInitializer();
+LValue PrivateLValue = CGF.EmitLValueForField(PrivatesBase, *FI);
+if (Init && (!ForDup || (isa(Init) &&
+ !CGF.isTrivialInitializer(Init {
+  if (auto *Elem = Pair.second.PrivateElemInit) {
+auto *OriginalVD = Pair.second.Original;
+auto *SharedField = CapturesInfo.lookup(OriginalVD);
+auto SharedRefLValue = CGF.EmitLValueForField(SrcBase, SharedField);
+SharedRefLValue = CGF.MakeAddrLValue(
+Address(SharedRefLValue.getPointer(), C.getDeclAlign(OriginalVD)),
+SharedRefLValue.getType(), AlignmentSource::Decl);
+QualType Type = OriginalVD->getType();
+if (Type->isArrayType()) {
+  // Initialize firstprivate array.
+  if (!isa(Init) || CGF.isTrivialInitializer(Init)) {
+// Perform simple memcpy.
+CGF.EmitAggregateAssign(PrivateLValue.getAddress(),
+SharedRefLValue.getAddress(), Type);
+  } else {
+// Initialize firstprivate array using element-by-element
+// intialization.
+CGF.EmitOMPAggregateAssign(
+PrivateLValue.getAddress(), SharedRefLValue.getAddress(), Type,
+[, Elem, Init, ](Address DestElement,
+  Address SrcElement) {
+  // Clean up any temporaries needed by the initialization.
+  CodeGenFunction::OMPPrivateScope InitScope(CGF);
+  InitScope.addPrivate(
+  

[libcxx] r268614 - Fix sphinx build. This is a temporary solution.

2016-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  5 03:12:25 2016
New Revision: 268614

URL: http://llvm.org/viewvc/llvm-project?rev=268614=rev
Log:
Fix sphinx build. This is a temporary solution.

Modified:
libcxx/trunk/docs/TestingLibcxx.rst

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=268614=268613=268614=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Thu May  5 03:12:25 2016
@@ -98,7 +98,7 @@ configuration. Passing the option on the
 
 .. program:: lit
 
-.. option:: cxx_under_test=path/to/compiler
+.. option:: --cxx_under_test=
 
   Specify the compiler used to build the tests.
 
@@ -108,24 +108,24 @@ configuration. Passing the option on the
 
   Change the standard version used when building the tests.
 
-.. option:: libcxx_site_config=path/to/lit.site.cfg
+.. option:: --libcxx_site_config=
 
   Specify the site configuration to use when running the tests.  This option
   overrides the enviroment variable LIBCXX_SITE_CONFIG.
 
-.. option:: libcxx_headers=path/to/headers
+.. option:: --libcxx_headers=
 
   Specify the libc++ headers that are tested. By default the headers in the
   source tree are used.
 
-.. option:: cxx_library_root=path/to/lib/
+.. option:: --cxx_library_root=
 
   Specify the directory of the libc++ library to be tested. By default the
   library folder of the build directory is used. This option cannot be used
   when use_system_lib is provided.
 
 
-.. option:: cxx_runtime_root=path/to/lib/
+.. option:: --cxx_runtime_root=
 
   Specify the directory of the libc++ library to use at runtime. This directory
   is not added to the linkers search path. This can be used to compile tests
@@ -133,21 +133,21 @@ configuration. Passing the option on the
   for this option is `cxx_library_root`. This option cannot be used
   when use_system_lib is provided.
 
-.. option:: use_system_lib=
+.. option:: --use_system_lib=
 
   **Default**: False
 
   Enable or disable testing against the installed version of libc++ library.
   Note: This does not use the installed headers.
 
-.. option:: use_lit_shell=
+.. option:: --use_lit_shell=
 
   Enable or disable the use of LIT's internal shell in ShTests. If the
   environment variable LIT_USE_INTERNAL_SHELL is present then that is used as
   the default value. Otherwise the default value is True on Windows and False
   on every other platform.
 
-.. option:: no_default_flags=
+.. option:: --no_default_flags=
 
   **Default**: False
 
@@ -155,16 +155,16 @@ configuration. Passing the option on the
   option is used only flags specified using the compile_flags and link_flags
   will be used.
 
-.. option:: compile_flags="list-of-args"
+.. option:: --compile_flags=""
 
   Specify additional compile flags as a space delimited string.
   Note: This options should not be used to change the standard version used.
 
-.. option:: link_flags="list-of-args"
+.. option:: --link_flags=""
 
   Specify additional link flags as a space delimited string.
 
-.. option:: debug_level=
+.. option:: --debug_level=
 
   **Values**: 0, 1
 
@@ -188,7 +188,7 @@ configuration. Passing the option on the
 Environment Variables
 -
 
-.. envvar:: LIBCXX_SITE_CONFIG=path/to/lit.site.cfg
+.. envvar:: LIBCXX_SITE_CONFIG=
 
   Specify the site configuration to use when running the tests.
   Also see :option:`libcxx_site_config`.


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


[libcxx] r268613 - Try and fix sphinx build

2016-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  5 01:30:05 2016
New Revision: 268613

URL: http://llvm.org/viewvc/llvm-project?rev=268613=rev
Log:
Try and fix sphinx build

Modified:
libcxx/trunk/docs/TestingLibcxx.rst

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=268613=268612=268613=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Thu May  5 01:30:05 2016
@@ -98,7 +98,7 @@ configuration. Passing the option on the
 
 .. program:: lit
 
-.. option:: cxx_under_test=
+.. option:: cxx_under_test=path/to/compiler
 
   Specify the compiler used to build the tests.
 
@@ -108,24 +108,24 @@ configuration. Passing the option on the
 
   Change the standard version used when building the tests.
 
-.. option:: libcxx_site_config=
+.. option:: libcxx_site_config=path/to/lit.site.cfg
 
   Specify the site configuration to use when running the tests.  This option
   overrides the enviroment variable LIBCXX_SITE_CONFIG.
 
-.. option:: libcxx_headers=
+.. option:: libcxx_headers=path/to/headers
 
   Specify the libc++ headers that are tested. By default the headers in the
   source tree are used.
 
-.. option:: cxx_library_root=
+.. option:: cxx_library_root=path/to/lib/
 
   Specify the directory of the libc++ library to be tested. By default the
   library folder of the build directory is used. This option cannot be used
   when use_system_lib is provided.
 
 
-.. option:: cxx_runtime_root=
+.. option:: cxx_runtime_root=path/to/lib/
 
   Specify the directory of the libc++ library to use at runtime. This directory
   is not added to the linkers search path. This can be used to compile tests
@@ -155,12 +155,12 @@ configuration. Passing the option on the
   option is used only flags specified using the compile_flags and link_flags
   will be used.
 
-.. option:: compile_flags=""
+.. option:: compile_flags="list-of-args"
 
   Specify additional compile flags as a space delimited string.
   Note: This options should not be used to change the standard version used.
 
-.. option:: link_flags=""
+.. option:: link_flags="list-of-args"
 
   Specify additional link flags as a space delimited string.
 
@@ -188,7 +188,7 @@ configuration. Passing the option on the
 Environment Variables
 -
 
-.. envvar:: LIBCXX_SITE_CONFIG=
+.. envvar:: LIBCXX_SITE_CONFIG=path/to/lit.site.cfg
 
   Specify the site configuration to use when running the tests.
   Also see :option:`libcxx_site_config`.


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