Re: [PATCH] D16932: [CUDA] Bug 26497 : Remove wrappers for variants already provided by CUDA headers.

2016-02-05 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Is it worth having a test, if only for one or two functions?


http://reviews.llvm.org/D16932



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


r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Fri Feb  5 15:34:28 2016
New Revision: 259931

URL: http://llvm.org/viewvc/llvm-project?rev=259931=rev
Log:
[SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.

This fixes a miscompile of GCC C++11 standard library headers
due to use of those macros in an ABI-changing manner.

See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:

  // Compile time constant that indicates prefered locking policy in
  // the current configuration.
  static const _Lock_policy __default_lock_policy =
#ifdef __GTHREADS
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
 && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
  _S_atomic;
#else
  _S_mutex;
#endif
#else
  _S_single;
#endif

A different choice of __default_lock_policy causes different
sizes of several of the C++11 data structures, which are then
incompatible when inlined in clang-compiled code with what the
(GCC-compiled) external library expects.

This in turn leads to various crashes when using std::thread
in code compiled with clang, as see e.g. via the ThreadPool
unit tests.  See PR 26473 for an example.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259931=259930=259931=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb  5 15:34:28 2016
@@ -6166,6 +6166,12 @@ public:
 Builder.defineMacro("__s390x__");
 Builder.defineMacro("__zarch__");
 Builder.defineMacro("__LONG_DOUBLE_128__");
+
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
 if (HasTransactionalExecution)
   Builder.defineMacro("__HTM__");
 if (Opts.ZVector)

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=259931=259930=259931=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Fri Feb  5 15:34:28 
2016
@@ -1787,6 +1787,10 @@
 // RUN: -target s390x-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_Z10
 //
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
 // CHECK_SYSTEMZ_Z10: #define __s390__ 1
 // CHECK_SYSTEMZ_Z10: #define __s390x__ 1
@@ -1796,6 +1800,10 @@
 // RUN: -target s390x-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZEC12
 //
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK_SYSTEMZ_ZEC12: #define __HTM__ 1
 // CHECK_SYSTEMZ_ZEC12: #define __LONG_DOUBLE_128__ 1
 // CHECK_SYSTEMZ_ZEC12: #define __s390__ 1


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


r259935 - Move DebugInfoKind enum from Driver to Basic. NFC

2016-02-05 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb  5 15:54:42 2016
New Revision: 259935

URL: http://llvm.org/viewvc/llvm-project?rev=259935=rev
Log:
Move DebugInfoKind enum from Driver to Basic. NFC

Added:
cfe/trunk/include/clang/Basic/DebugInfoOptions.h
  - copied, changed from r259876, 
cfe/trunk/include/clang/Driver/DebugInfoKind.h
Removed:
cfe/trunk/include/clang/Driver/DebugInfoKind.h
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Driver/Tools.h

Copied: cfe/trunk/include/clang/Basic/DebugInfoOptions.h (from r259876, 
cfe/trunk/include/clang/Driver/DebugInfoKind.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DebugInfoOptions.h?p2=cfe/trunk/include/clang/Basic/DebugInfoOptions.h=cfe/trunk/include/clang/Driver/DebugInfoKind.h=259876=259935=259935=diff
==
--- cfe/trunk/include/clang/Driver/DebugInfoKind.h (original)
+++ cfe/trunk/include/clang/Basic/DebugInfoOptions.h Fri Feb  5 15:54:42 2016
@@ -1,4 +1,4 @@
-//===--- DebugInfoKind.h - Debug Info Emission Types *- C++ 
-*-===//
+//===--- DebugInfoOptions.h - Debug Info Emission Types -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_DRIVER_DEBUGINFOKIND_H
-#define LLVM_CLANG_DRIVER_DEBUGINFOKIND_H
+#ifndef LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
+#define LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
 
 namespace clang {
 namespace codegenoptions {

Removed: cfe/trunk/include/clang/Driver/DebugInfoKind.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/DebugInfoKind.h?rev=259934=auto
==
--- cfe/trunk/include/clang/Driver/DebugInfoKind.h (original)
+++ cfe/trunk/include/clang/Driver/DebugInfoKind.h (removed)
@@ -1,39 +0,0 @@
-//===--- DebugInfoKind.h - Debug Info Emission Types *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_DRIVER_DEBUGINFOKIND_H
-#define LLVM_CLANG_DRIVER_DEBUGINFOKIND_H
-
-namespace clang {
-namespace codegenoptions {
-
-enum DebugInfoKind {
-  NoDebugInfo, /// Don't generate debug info.
-  LocTrackingOnly, /// Emit location information but do not generate
-   /// debug info in the output. This is useful in
-   /// cases where the backend wants to track source
-   /// locations for instructions without actually
-   /// emitting debug info for them (e.g., when -Rpass
-   /// is used).
-  DebugLineTablesOnly, /// Emit only debug info necessary for generating
-   /// line number tables (-gline-tables-only).
-  LimitedDebugInfo,/// Limit generated debug info to reduce size
-   /// (-fno-standalone-debug). This emits
-   /// forward decls for types that could be
-   /// replaced with forward decls in the source
-   /// code. For dynamic C++ classes type info
-   /// is only emitted int the module that
-   /// contains the classe's vtable.
-  FullDebugInfo/// Generate complete debug info.
-};
-
-} // end namespace codegenoptions
-} // end namespace clang
-
-#endif

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=259935=259934=259935=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Fri Feb  5 15:54:42 2016
@@ -14,8 +14,8 @@
 #ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
 #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
 
+#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Sanitizers.h"
-#include "clang/Driver/DebugInfoKind.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=259935=259934=259935=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Fri Feb  5 15:54:42 2016
@@ -10,8 +10,8 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLS_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLS_H
 
+#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/VersionTuple.h"
-#include "clang/Driver/DebugInfoKind.h"
 #include "clang/Driver/Tool.h"
 #include 

Re: [PATCH] D16460: Bug 10002 - [opencl] Wrongfully assuming RHS is always unsigned

2016-02-05 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

Ping.


Repository:
  rL LLVM

http://reviews.llvm.org/D16460



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


Re: [PATCH] D16932: [CUDA] Bug 26497 : Remove wrappers for variants already provided by CUDA headers.

2016-02-05 Thread Artem Belevich via cfe-commits
tra added a comment.

I'm not sure what we could test here without CUDA headers.
I've tested out-of-tree by compiling thrust unit tests and the test case in PR.


http://reviews.llvm.org/D16932



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


Re: [PATCH] D16932: [CUDA] Bug 26497 : Remove wrappers for variants already provided by CUDA headers.

2016-02-05 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Oh right, CUDA headers.

We really need to get a buildbot and/or tests in test-suite set up.


http://reviews.llvm.org/D16932



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


[PATCH] D16934: [Coverage] Fix crash in VisitIfStmt

2016-02-05 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added a reviewer: bogner.
vsk added a subscriber: cfe-commits.

When handling 'if' statements, we crash if the condition and the consequent
branch are spanned by a single macro expansion.

The crash occurs because of a sanity 'reset' in `popRegions()`: if an expansion
exactly spans an entire region, we set `MostRecentLocation` to the start of the
expansion (its 'include location').  This ensures we don't `handleFileExit()`
ourselves out of the expansion before we're done processing all of the regions
within it. This is tested in test/CoverageMapping/macro-expressions.c.

This causes a problem when an expansion spans both the condition and the
consequent branch of an 'if' statement. `MostRecentLocation` is updated to the
start of the 'if' statement in `popRegions()`, so the file for the expansion
isn't exited by the time we're done handling the statement. We then crash with
'fatal: File exit not handled before popRegions'.

The fix for this is to detect these kinds of expansions, and conservatively
update `MostRecentLocation` to the end of expansion region containing the
conditional. I've added tests to make sure we don't have the same problem with
other kinds of statements.

rdar://problem/23630316

http://reviews.llvm.org/D16934

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/macro-expressions.cpp

Index: test/CoverageMapping/macro-expressions.cpp
===
--- test/CoverageMapping/macro-expressions.cpp
+++ test/CoverageMapping/macro-expressions.cpp
@@ -12,6 +12,38 @@
 #define PRIo64 PRI_64_LENGTH_MODIFIER "o"
 #define PRIu64 PRI_64_LENGTH_MODIFIER "u"
 
+#define STMT(s) s
+
+void fn1() {
+  STMT(if (1));
+  STMT(while (1));
+  STMT(for (;;));
+  if (1)
+STMT(if (1)) 0;
+  if (1)
+STMT(while (1)) 0;
+  if (1)
+STMT(for (;;)) 0;
+  while (1)
+STMT(if (1)) 0;
+  while (1)
+STMT(while (1)) 0;
+  while (1)
+STMT(for (;;)) 0;
+  for (;;)
+STMT(if (1)) 0;
+  for (;;)
+STMT(while (1)) 0;
+  for (;;)
+STMT(for (;;)) 0;
+}
+
+void STMT(fn2()) {
+}
+
+void STMT(fn3)() {
+}
+
 // CHECK: foo
 // CHECK-NEXT: File 0, [[@LINE+1]]:17 -> {{[0-9]+}}:2 = #0
 void foo(int i) {
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -807,6 +807,14 @@
 // counter for the body when looking at the coverage.
 propagateCounts(ParentCount, S->getCond());
 
+// The region containing the condition may be spanned by an expansion.
+// Make sure we handle a file exit out of this expansion before handling
+// the consequent branch.
+if (SM.isBeforeInTranslationUnit(getStart(S->getCond()),
+ S->getCond()->getLocStart())) {
+  MostRecentLocation = getEnd(S->getCond());
+}
+
 extendRegion(S->getThen());
 Counter OutCount = propagateCounts(ThenCount, S->getThen());
 


Index: test/CoverageMapping/macro-expressions.cpp
===
--- test/CoverageMapping/macro-expressions.cpp
+++ test/CoverageMapping/macro-expressions.cpp
@@ -12,6 +12,38 @@
 #define PRIo64 PRI_64_LENGTH_MODIFIER "o"
 #define PRIu64 PRI_64_LENGTH_MODIFIER "u"
 
+#define STMT(s) s
+
+void fn1() {
+  STMT(if (1));
+  STMT(while (1));
+  STMT(for (;;));
+  if (1)
+STMT(if (1)) 0;
+  if (1)
+STMT(while (1)) 0;
+  if (1)
+STMT(for (;;)) 0;
+  while (1)
+STMT(if (1)) 0;
+  while (1)
+STMT(while (1)) 0;
+  while (1)
+STMT(for (;;)) 0;
+  for (;;)
+STMT(if (1)) 0;
+  for (;;)
+STMT(while (1)) 0;
+  for (;;)
+STMT(for (;;)) 0;
+}
+
+void STMT(fn2()) {
+}
+
+void STMT(fn3)() {
+}
+
 // CHECK: foo
 // CHECK-NEXT: File 0, [[@LINE+1]]:17 -> {{[0-9]+}}:2 = #0
 void foo(int i) {
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -807,6 +807,14 @@
 // counter for the body when looking at the coverage.
 propagateCounts(ParentCount, S->getCond());
 
+// The region containing the condition may be spanned by an expansion.
+// Make sure we handle a file exit out of this expansion before handling
+// the consequent branch.
+if (SM.isBeforeInTranslationUnit(getStart(S->getCond()),
+ S->getCond()->getLocStart())) {
+  MostRecentLocation = getEnd(S->getCond());
+}
+
 extendRegion(S->getThen());
 Counter OutCount = propagateCounts(ThenCount, S->getThen());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16761: clang-cl: Support loading plugins on Windows

2016-02-05 Thread Ehsan Akhgari via cfe-commits
ehsan updated this revision to Diff 47056.
ehsan added a comment.

Updating based on the LLVM side changes.


http://reviews.llvm.org/D16761

Files:
  docs/ClangPlugins.rst
  examples/PrintFunctionNames/PrintFunctionNames.cpp
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/CodeGenCXX/static-init-msvc.cpp
  test/Frontend/plugins.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: test/CodeGenCXX/static-init-msvc.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-init-msvc.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+
+void fun_and() {
+// CHECK-LABEL: @"\01?fun_and@@YAXXZ"()
+// GNU-LABEL: @_Z7fun_andv()
+  static int k;
+  static const int foo = 0 && k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_and@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_or() {
+// CHECK-LABEL: @"\01?fun_or@@YAXXZ"()
+// GNU-LABEL: @_Z6fun_orv()
+  static int k;
+  static const int foo = 1 || k;
+// CHECK: init:
+// CHECK-NEXT: store i32 1, i32* @"\01?foo@?1??fun_or@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_comma() {
+// CHECK-LABEL: @"\01?fun_comma@@YAXXZ"()
+// GNU-LABEL: @_Z9fun_commav()
+  static int k;
+  static const int foo = (k, 0);
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_comma@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_cond() {
+// CHECK-LABEL: @"\01?fun_cond@@YAXXZ"()
+// GNU-LABEL: @_Z8fun_condv()
+  static int k;
+  static const int foo = true ? 0 : k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_cond@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), ))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -477,6 +477,19 @@
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief True if we need to obey the Microsoft ABI.  This affects whether
+/// some expressions can be evaluated as a constant if they refer to
+/// variables in some cases.  See PR26210 for the discussion.
+bool IsMicrosoftABI;
+
+/// \brief True if we are looking for a DeclRefExpr.
+bool LookingForDeclRefExpr;
+
+/// \brief True if we have observed a DeclRefExpr since the last time that
+/// awaitDeclRefExpr() was called.  This is used in order to handle Microsoft
+/// ABI requirements.
+bool HaveSeenDeclRefExpr;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the expression
   /// is not a constant expression.
@@ -541,7 +554,9 @@

Re: r259271 - Improve -Wconstant-conversion

2016-02-05 Thread Nico Weber via cfe-commits
Thanks!

Maybe it's interesting if I list the instances where this fired in Chromium.

* libwebp calls _mm_set1_epi16(33050) (but then is careful to only use
unsigned intrinsics with this). There's no version of this function that
takes unsigned short, so the only thing to change here was to add a cast.

* Some function taking int was passed 2651229008. I don't understand why;
it was some machine_id thing. The parameter probably wanted to be unsigned.

* In two cases, a char array contained a 255 (this no longer fires after
your change)

* some file had `volatile short lineno = (__LINE__ << 8) + __COUNTER__;
(void)lineno;` in a macro to prevent the compiler from combining functions
(in dynamic_annotations.c) and that number became larget than 32k (but not
larger than 64k, so we changed that to unsigned short).

* finally we had the line `const int16_t kReservedManufacturerID = 1 << 15;`

None of these were bugs, but it seems like a good change anyhow. I can see
how this could catch bugs.


On Fri, Feb 5, 2016 at 6:07 PM, Richard Trieu  wrote:

> r259947 will stop this warning on char arrays.
>
> On Mon, Feb 1, 2016 at 1:40 PM, Richard Trieu  wrote:
>
>> C++11 narrowing only happens during certain conversions while this
>> warning checks all conversions.
>>
>> We might be able to avoid char array initialization, but it would be a
>> little tricky.  These warning usually have little information about where
>> the conversion is coming from, so distinguishing array initialization
>> versus variable initialization could be hard.
>>
>> On Sat, Jan 30, 2016 at 6:41 AM, Nico Weber  wrote:
>>
>>> Shouldn't the new case be in -Wc++11-narrowing instead? This is warning
>>> in similar places where that warning used to warn.
>>>
>>> In practice, char arrays seem to be often used for storing binary blobs
>>> in header files, and those are usually initialized with numbers 0...255
>>> instead of -128...127 (why not make the array uint8_t then? Because maybe
>>> the function you want to pass the data from wants a char* array, and having
>>> to reinterpret_cast from uint8_t to char is annoying). Maybe this shouldn't
>>> fire for char arrays?
>>>
>>> On Fri, Jan 29, 2016 at 6:51 PM, Richard Trieu via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rtrieu
 Date: Fri Jan 29 17:51:16 2016
 New Revision: 259271

 URL: http://llvm.org/viewvc/llvm-project?rev=259271=rev
 Log:
 Improve -Wconstant-conversion

 Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt.
 EvaluateAsInt will evaluate more types of expressions than
 isIntegerConstantExpr.

 Move one case from -Wsign-conversion to -Wconstant-conversion.  The
 case is:
 1) Source and target types are signed
 2) Source type is wider than the target type
 3) The source constant value is positive
 4) The conversion will store the value as negative in the target.

 Modified:
 cfe/trunk/lib/Sema/SemaChecking.cpp
 cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
 cfe/trunk/test/Sema/constant-conversion.c

 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=259271=259270=259271=diff

 ==
 --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan 29 17:51:16 2016
 @@ -7578,7 +7578,7 @@ void CheckImplicitConversion(Sema , Ex
  // If the source is a constant, use a default-on diagnostic.
  // TODO: this should happen for bitfield stores, too.
  llvm::APSInt Value(32);
 -if (E->isIntegerConstantExpr(Value, S.Context)) {
 +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects))
 {
if (S.SourceMgr.isInSystemMacro(CC))
  return;

 @@ -7603,6 +7603,42 @@ void CheckImplicitConversion(Sema , Ex
  return DiagnoseImpCast(S, E, T, CC,
 diag::warn_impcast_integer_precision);
}

 +  if (TargetRange.Width == SourceRange.Width &&
 !TargetRange.NonNegative &&
 +  SourceRange.NonNegative && Source->isSignedIntegerType()) {
 +// Warn when doing a signed to signed conversion, warn if the
 positive
 +// source value is exactly the width of the target type, which will
 +// cause a negative value to be stored.
 +
 +llvm::APSInt Value;
 +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects))
 {
 +  if (!S.SourceMgr.isInSystemMacro(CC)) {
 +
 +IntegerLiteral *IntLit =
 +dyn_cast(E->IgnoreParenImpCasts());
 +
 +// If initializing from a constant, and the constant starts
 with '0',
 +// then it is a binary, octal, or hexadecimal.  Allow 

r259984 - Revert r259977 - [OpenMP] Reorganize code to allow specialized code generation for different devices.

2016-02-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Sat Feb  6 00:22:46 2016
New Revision: 259984

URL: http://llvm.org/viewvc/llvm-project?rev=259984=rev
Log:
Revert r259977 - [OpenMP] Reorganize code to allow specialized code generation 
for different devices.

It triggered some problem in the configuration related with zlib and exposed in 
the driver.


Removed:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/target_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=259984=259983=259984=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Sat Feb  6 00:22:46 
2016
@@ -132,9 +132,7 @@ def err_drv_no_neon_modifier : Error<"[n
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
-def err_drv_omp_host_target_not_supported : Error<
-  "The target '%0' is not a supported OpenMP host target.">;
-  
+
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
dir not found; using 'ld' default search path instead">,
   InGroup;

Removed: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=259983=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (removed)
@@ -1,21 +0,0 @@
-//=== CGOpenMPRuntimeNVPTX.cpp - Interface to OpenMP NVPTX Runtimes 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This provides a class for OpenMP runtime code generation specialized to 
NVPTX
-// targets.
-//
-//===--===//
-
-#include "CGOpenMPRuntimeNVPTX.h"
-
-using namespace clang;
-using namespace CodeGen;
-
-CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX(CodeGenModule )
-: CGOpenMPRuntime(CGM) {}

Removed: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=259983=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (removed)
@@ -1,31 +0,0 @@
-//===- CGOpenMPRuntimeNVPTX.h - Interface to OpenMP NVPTX Runtimes 
===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This provides a class for OpenMP runtime code generation specialized to 
NVPTX
-// targets.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
-#define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
-
-#include "CGOpenMPRuntime.h"
-
-namespace clang {
-namespace CodeGen {
-
-class CGOpenMPRuntimeNVPTX : public CGOpenMPRuntime {
-public:
-  explicit CGOpenMPRuntimeNVPTX(CodeGenModule );
-};
-
-} // CodeGen namespace.
-} // clang namespace.
-
-#endif // LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=259984=259983=259984=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Sat Feb  6 00:22:46 2016
@@ -57,7 +57,6 @@ add_clang_library(clangCodeGen
   CGObjCRuntime.cpp
   CGOpenCLRuntime.cpp
   CGOpenMPRuntime.cpp
-  CGOpenMPRuntimeNVPTX.cpp
   CGRecordLayoutBuilder.cpp
   CGStmt.cpp
   CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=259984=259983=259984=diff
==
--- 

r259985 - Re-apply r259977 - [OpenMP] Reorganize code to allow specialized code generation for different devices.

2016-02-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Sat Feb  6 00:52:48 2016
New Revision: 259985

URL: http://llvm.org/viewvc/llvm-project?rev=259985=rev
Log:
Re-apply r259977 - [OpenMP] Reorganize code to allow specialized code 
generation for different devices.

This was reverted due to a failure in a buildbot, but it turned out the failure 
was unrelated.


Added:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/target_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=259985=259984=259985=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Sat Feb  6 00:52:48 
2016
@@ -132,7 +132,9 @@ def err_drv_no_neon_modifier : Error<"[n
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
-
+def err_drv_omp_host_target_not_supported : Error<
+  "The target '%0' is not a supported OpenMP host target.">;
+  
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
dir not found; using 'ld' default search path instead">,
   InGroup;

Added: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=259985=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (added)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Sat Feb  6 00:52:48 2016
@@ -0,0 +1,21 @@
+//=== CGOpenMPRuntimeNVPTX.cpp - Interface to OpenMP NVPTX Runtimes 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This provides a class for OpenMP runtime code generation specialized to 
NVPTX
+// targets.
+//
+//===--===//
+
+#include "CGOpenMPRuntimeNVPTX.h"
+
+using namespace clang;
+using namespace CodeGen;
+
+CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX(CodeGenModule )
+: CGOpenMPRuntime(CGM) {}

Added: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=259985=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (added)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Sat Feb  6 00:52:48 2016
@@ -0,0 +1,31 @@
+//===- CGOpenMPRuntimeNVPTX.h - Interface to OpenMP NVPTX Runtimes 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This provides a class for OpenMP runtime code generation specialized to 
NVPTX
+// targets.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
+#define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
+
+#include "CGOpenMPRuntime.h"
+
+namespace clang {
+namespace CodeGen {
+
+class CGOpenMPRuntimeNVPTX : public CGOpenMPRuntime {
+public:
+  explicit CGOpenMPRuntimeNVPTX(CodeGenModule );
+};
+
+} // CodeGen namespace.
+} // clang namespace.
+
+#endif // LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=259985=259984=259985=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Sat Feb  6 00:52:48 2016
@@ -57,6 +57,7 @@ add_clang_library(clangCodeGen
   CGObjCRuntime.cpp
   CGOpenCLRuntime.cpp
   CGOpenMPRuntime.cpp
+  CGOpenMPRuntimeNVPTX.cpp
   CGRecordLayoutBuilder.cpp
   CGStmt.cpp
   CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=259985=259984=259985=diff

Re: r259976 - [modules] Compress files embedded into a .pcm file, to reduce the disk usage of -fembed-all-files mode.

2016-02-05 Thread Richard Smith via cfe-commits
On 5 Feb 2016 11:12 p.m., "Dmitri Gribenko"  wrote:
>
> On Fri, Feb 5, 2016 at 6:06 PM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Fri Feb  5 20:06:43 2016
> > New Revision: 259976
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=259976=rev
> > Log:
> > [modules] Compress files embedded into a .pcm file, to reduce the disk
usage of -fembed-all-files mode.
>
> Hi Richard,
>
> I think your commit might have caused a failure in the
> Driver/nozlibcompress.c test.  Could you take a look?

My commit made "REQUIRES: zlib" actually work. Previously that test had
been disabled on all configurations. Maybe disable it and contact whoever
added it?

>
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/34405/steps/test/logs/stdio
>
> I am not sure why the CI software didn't include you in the email, but
> from this page http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast
> we can see that the failure was caused by one of the commits between
> 259971 and 259978, and yours is the only commit that changes something
> about zlib.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j (j){printf("%d\n",i);}}} /*Dmitri Gribenko */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Parse/ParseStmt.cpp:2214
@@ +2213,3 @@
+
+bool Parser::ParseOpenCLUnrollHintAttribute(ParsedAttributes ) {
+  MaybeParseGNUAttributes(Attrs);

pxli168 wrote:
> I am wondering where should this function goes in, here or ParseDecl.cpp.
ParseGNUAttributes is in ParseDecl.cpp, but may be because it's generally 
applicable to Decls?

I am not aware of any rule here.


http://reviews.llvm.org/D16686



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


Re: [PATCH] D16926: [clang-tidy] Fix assertion failure on `at` function in modernize-loop-convert.

2016-02-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 47019.
hokein added a comment.

Fix a typo in doc.


http://reviews.llvm.org/D16926

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  docs/clang-tidy/checks/modernize-loop-convert.rst
  test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -251,8 +251,16 @@
   // CHECK-FIXES-NEXT: const int& Idx = Other[0];
   // CHECK-FIXES-NEXT: unsigned Othersize = Other.size();
 
+  for (int i = 0; i <  Other.size(); ++i) {
+Other.at(i);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int & i : Other)
+  // CHECK-FIXES: i;
+
   for (int I = 0, E = Dep.size(); I != E; ++I) {
 int Idx = Other.at(I);
+Other.at(I, I);  // Should not trigger assert failure.
   }
 }
 
Index: test/clang-tidy/Inputs/modernize-loop-convert/structures.h
===
--- test/clang-tidy/Inputs/modernize-loop-convert/structures.h
+++ test/clang-tidy/Inputs/modernize-loop-convert/structures.h
@@ -98,6 +98,7 @@
   ElemType & operator[](unsigned);
   const ElemType & operator[](unsigned) const;
   ElemType & at(unsigned);
+  ElemType & at(unsigned, unsigned);
   const ElemType & at(unsigned) const;
 
   // Intentionally evil.
Index: docs/clang-tidy/checks/modernize-loop-convert.rst
===
--- docs/clang-tidy/checks/modernize-loop-convert.rst
+++ docs/clang-tidy/checks/modernize-loop-convert.rst
@@ -89,7 +89,7 @@
 
   // reasonable conversion
   for (vector::iterator it = v.begin(); it != v.end(); ++it)
-cout << *it;*
+cout << *it;
 
   // reasonable conversion
   for (int i = 0; i < v.size(); ++i)
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -391,8 +391,8 @@
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
 const auto *MDecl = MemCall->getMethodDecl();
-if (MDecl && !isa(MDecl) && MDecl->getName() == "at") {
-  assert(MemCall->getNumArgs() == 1);
+if (MDecl && !isa(MDecl) && MDecl->getName() == "at" &&
+MemCall->getNumArgs() == 1) {
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }
 return false;


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -251,8 +251,16 @@
   // CHECK-FIXES-NEXT: const int& Idx = Other[0];
   // CHECK-FIXES-NEXT: unsigned Othersize = Other.size();
 
+  for (int i = 0; i <  Other.size(); ++i) {
+Other.at(i);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int & i : Other)
+  // CHECK-FIXES: i;
+
   for (int I = 0, E = Dep.size(); I != E; ++I) {
 int Idx = Other.at(I);
+Other.at(I, I);  // Should not trigger assert failure.
   }
 }
 
Index: test/clang-tidy/Inputs/modernize-loop-convert/structures.h
===
--- test/clang-tidy/Inputs/modernize-loop-convert/structures.h
+++ test/clang-tidy/Inputs/modernize-loop-convert/structures.h
@@ -98,6 +98,7 @@
   ElemType & operator[](unsigned);
   const ElemType & operator[](unsigned) const;
   ElemType & at(unsigned);
+  ElemType & at(unsigned, unsigned);
   const ElemType & at(unsigned) const;
 
   // Intentionally evil.
Index: docs/clang-tidy/checks/modernize-loop-convert.rst
===
--- docs/clang-tidy/checks/modernize-loop-convert.rst
+++ docs/clang-tidy/checks/modernize-loop-convert.rst
@@ -89,7 +89,7 @@
 
   // reasonable conversion
   for (vector::iterator it = v.begin(); it != v.end(); ++it)
-cout << *it;*
+cout << *it;
 
   // reasonable conversion
   for (int i = 0; i < v.size(); ++i)
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -391,8 +391,8 @@
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
 const auto *MDecl = MemCall->getMethodDecl();
-if (MDecl && !isa(MDecl) && MDecl->getName() == "at") {
-  assert(MemCall->getNumArgs() == 1);
+if (MDecl && !isa(MDecl) && MDecl->getName() == "at" &&
+MemCall->getNumArgs() == 1) {
   return 

Re: [PATCH] D16923: [AST] Implemented missing VisitAccessSpecDecl function in ASTImporter class.

2016-02-05 Thread Axel Naumann via cfe-commits
karies added reviewers: klimek, bkramer.
karies added a comment.

Because of previous review subscriptions...


http://reviews.llvm.org/D16923



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D15506



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


Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-05 Thread Vassil Vassilev via cfe-commits
Good point. Do you have in mind calling 'clang::Sema::MergeVarDeclTypes' 
or we to just "duplicate" the logic in 
clang::ASTDeclReader::mergeRedeclarable?

On 05/02/16 02:50, Richard Smith via cfe-commits wrote:
I suspect we'll need to do a little more than this: when we rebuild 
the redeclaration chain, we should probably propagate the complete 
type to later redeclarations in the same scope. Otherwise, if we 
import a module that has a complete type and one that has an 
incomplete type, the declaration found by name lookup might be the one 
with the incomplete type, possibly resulting in rejects-valid on code 
like this:


a.h:
extern int a[5];

b.h:
extern int a[];

x.cc:
#include "a.h"
#include "b.h"
int k = sizeof(a);

On Fri, Jan 22, 2016 at 11:03 AM, Yaron Keren via cfe-commits 
> wrote:


Author: yrnkrn
Date: Fri Jan 22 13:03:27 2016
New Revision: 258524

URL: http://llvm.org/viewvc/llvm-project?rev=258524=rev
Log:
Merge templated static member variables, fixes
http://llvm.org/pr26179.

Patch by Vassil Vassilev!
Reviewed by Richard Smith.


Added:
cfe/trunk/test/Modules/Inputs/PR26179/
cfe/trunk/test/Modules/Inputs/PR26179/A.h
cfe/trunk/test/Modules/Inputs/PR26179/B.h
cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
cfe/trunk/test/Modules/pr26179.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=258524=258523=258524=diff

==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jan 22
13:03:27 2016
@@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, N
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast(X)) {
 VarDecl *VarY = cast(Y);
-return (VarX->getLinkageInternal() ==
VarY->getLinkageInternal()) &&
- VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
+  ASTContext  = VarX->getASTContext();
+  if (C.hasSameType(VarX->getType(), VarY->getType()))
+return true;
+
+  // We can get decls with different types on the redecl
chain. Eg.
+  // template  struct S { static T Var[]; }; // #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Only? happens when completing an incomplete array type.
In this case
+  // when comparing #1 and #2 we should go through their
elements types.
+  const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
+  const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
+  if (!VarXTy || !VarYTy)
+return false;
+  if (VarXTy->isIncompleteArrayType() ||
VarYTy->isIncompleteArrayType())
+return C.hasSameType(VarXTy->getElementType(),
VarYTy->getElementType());
+}
+return false;
   }

   // Namespaces with the same name and inlinedness match.

Added: cfe/trunk/test/Modules/Inputs/PR26179/A.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/A.h?rev=258524=auto

==
--- cfe/trunk/test/Modules/Inputs/PR26179/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/A.h Fri Jan 22 13:03:27 2016
@@ -0,0 +1,4 @@
+#include "basic_string.h"
+#include "B.h"
+
+int *p = a;

Added: cfe/trunk/test/Modules/Inputs/PR26179/B.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/B.h?rev=258524=auto

==
--- cfe/trunk/test/Modules/Inputs/PR26179/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/B.h Fri Jan 22 13:03:27 2016
@@ -0,0 +1,2 @@
+#include "basic_string.h"
+extern int a[5];

Added: cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h?rev=258524=auto

==
--- cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h Fri Jan
22 13:03:27 2016
@@ -0,0 +1,14 @@
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING 1
+
+template
+struct basic_string {
+  static T _S_empty_rep_storage[];
+};
+
+template
+T 

Re: [PATCH] D16574: Bug 15685 - OpenCL 'char' is not signed

2016-02-05 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

No, just make test case more 'standard'.


http://reviews.llvm.org/D16574



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


Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator

2016-02-05 Thread Alexey Bader via cfe-commits
bader added a subscriber: bader.


Comment at: test/SemaOpenCL/ternary-implicit-casts.cl:10-11
@@ +9,4 @@
+kernel void implicit_cast_generic(global int* gint, local int* lint, int cond) 
{
+   // will compile, ptr is generic and can accept global and local
+   int* ptr = cond ? gint : lint; // expected-warning {{pointer type 
mismatch ('__global int *' and '__local int *')}}
+} 

Note that test doesn't specify OpenCL version. By default it's 1.0, so ptr 
points to private AS and it's illegal to cast pointers from different address 
spaces in OpenCL v1.x.


http://reviews.llvm.org/D16682



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


Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

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


Comment at: include/clang/Basic/TargetInfo.h:206
@@ +205,3 @@
+  /// \brief  Whether explicit bit field alignment attributes are honored.
+  unsigned int UseExplicitBitFieldAlignment : 1;
+

I'd use `unsigned` to match the style of the surrounding code.


http://reviews.llvm.org/D16788



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


Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

2016-02-05 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava updated this revision to Diff 47026.
Sunil_Srivastava added a comment.

Changed the patch based of feedback from John McCall.

There is new bit UseExplicitBitFieldAlignment, which is set for everything 
except for PS4. The r257462 change has been made conditional on this bit.


http://reviews.llvm.org/D16788

Files:
  include/clang/Basic/TargetInfo.h
  lib/AST/RecordLayoutBuilder.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  test/Sema/bitfield-layout.c

Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-scei-ps4
 // expected-no-diagnostics
 #include 
 
@@ -96,9 +97,15 @@
   char c;
 };
 
+#if defined(__PS4__)
+CHECK_SIZE(struct, g0, 16);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 2);
+#else
 CHECK_SIZE(struct, g0, 32);
 CHECK_ALIGN(struct, g0, 16);
 CHECK_OFFSET(struct, g0, c, 17);
+#endif
 
 // Bit-field with explicit align smaller than normal.
 struct g1 {
@@ -109,7 +116,11 @@
 
 CHECK_SIZE(struct, g1, 4);
 CHECK_ALIGN(struct, g1, 4);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g1, c, 2);
+#else
 CHECK_OFFSET(struct, g1, c, 3);
+#endif
 
 // Same as above but without explicit align.
 struct g2 {
@@ -130,9 +141,14 @@
   char c;
 };
 
-CHECK_SIZE(struct, g3, 32);
 CHECK_ALIGN(struct, g3, 16);
+#if defined(__PS4__)
+CHECK_SIZE(struct, g3, 16);
+CHECK_OFFSET(struct, g3, c, 2);
+#else
+CHECK_SIZE(struct, g3, 32);
 CHECK_OFFSET(struct, g3, c, 17);
+#endif
 
 struct __attribute__((packed)) g4 {
   char a;
@@ -142,7 +158,11 @@
 
 CHECK_SIZE(struct, g4, 4);
 CHECK_ALIGN(struct, g4, 2);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g4, c, 2);
+#else
 CHECK_OFFSET(struct, g4, c, 3);
+#endif
 
 struct g5 {
   char : 1;
@@ -162,28 +182,44 @@
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g7, 4);
+#else
 CHECK_SIZE(struct, g7, 8);
+#endif
 CHECK_ALIGN(struct, g7, 4);
 
 struct __attribute__((packed)) g8 {
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g8, 4);
+#else
 CHECK_SIZE(struct, g8, 5);
+#endif
 CHECK_ALIGN(struct, g8, 1);
 
 struct g9 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g9, 8);
+#else
 CHECK_SIZE(struct, g9, 12);
+#endif
 CHECK_ALIGN(struct, g9, 4);
 
 struct __attribute__((packed)) g10 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g10, 6);
+#else
 CHECK_SIZE(struct, g10, 9);
+#endif
 CHECK_ALIGN(struct, g10, 1);
 
 struct g11 {
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -606,6 +606,10 @@
 this->MaxTLSAlign = 256;
 this->UserLabelPrefix = "";
 
+// On PS4, do not honor explicit bit field alignment,
+// as in "__attribute__((aligned(2))) int b : 1;".
+this->UseExplicitBitFieldAlignment = false;
+
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86_64:
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -66,6 +66,7 @@
   UseSignedCharForObjCBool = true;
   UseBitFieldTypeAlignment = true;
   UseZeroLengthBitfieldAlignment = false;
+  UseExplicitBitFieldAlignment = true;
   ZeroLengthBitfieldBoundary = 0;
   HalfFormat = ::APFloat::IEEEhalf;
   FloatFormat = ::APFloat::IEEEsingle;
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1600,7 +1600,8 @@
 (AllowPadding &&
  (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
   FieldOffset = llvm::alignTo(FieldOffset, FieldAlign);
-} else if (ExplicitFieldAlign) {
+} else if (ExplicitFieldAlign &&
+   Context.getTargetInfo().useExplicitBitFieldAlignment()) {
   // TODO: figure it out what needs to be done on targets that don't honor
   // bit-field type alignment like ARM APCS ABI.
   FieldOffset = llvm::alignTo(FieldOffset, ExplicitFieldAlign);
@@ -1612,7 +1613,8 @@
  (UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize > TypeSize))
   UnpackedFieldOffset =
   llvm::alignTo(UnpackedFieldOffset, UnpackedFieldAlign);
-else if (ExplicitFieldAlign)
+else if (ExplicitFieldAlign &&
+ Context.getTargetInfo().useExplicitBitFieldAlignment())
   

Re: [PATCH] D16870: [CUDA] Tweak attribute-based overload resolution to match nvcc behavior.

2016-02-05 Thread Jingyue Wu via cfe-commits
jingyue added inline comments.


Comment at: test/SemaCUDA/function-overload.cu:138
@@ -149,3 +137,3 @@
   fp_t cdhp = cdh;
-  gp_t gp = g; // expected-error {{reference to __global__ function 'g' in 
__global__ function}}
-   // expected-note@67 {{'g' declared here}}
+  gp_t gp = g; 
+  // expected-error@-1 {{reference to __global__ function 'g' in __global__ 
function}}

This line seems to have a trailing space. 


http://reviews.llvm.org/D16870



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


Re: r259898 - [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Hans Wennborg via cfe-commits
Probably not (unless someone corrects me). In that case, it can wait
for the next release.

Thanks,
Hans

On Fri, Feb 5, 2016 at 11:02 AM, Aaron Ballman  wrote:
> Is PR25804 a regression?
>
> ~Aaron
>
> On Fri, Feb 5, 2016 at 1:59 PM, Hans Wennborg via cfe-commits
>  wrote:
>> It was requested that this be merged to 3.8 as it fixes PR25804.
>>
>> Manuel: does this look OK for the branch?
>>
>> Thanks,
>> Hans
>>
>> On Fri, Feb 5, 2016 at 10:29 AM, Samuel Benzaquen via cfe-commits
>>  wrote:
>>> Author: sbenza
>>> Date: Fri Feb  5 12:29:24 2016
>>> New Revision: 259898
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=259898=rev
>>> Log:
>>> [ASTMatchers] Allow hasName() to look through inline namespaces
>>>
>>> Summary:
>>> Allow hasName() to look through inline namespaces.
>>> This will fix the interaction between some clang-tidy checks and libc++.
>>>
>>> libc++ defines names in an inline namespace named std::.
>>> When we try to match a name using hasName("std::xxx") it fails to match and 
>>> the clang-tidy check does not work.
>>>
>>> Reviewers: klimek
>>>
>>> Subscribers: klimek, cfe-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D15506
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16930: Improve literal operator parameter diagnostics.

2016-02-05 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

Previously, invalid parameters in a literal operator function were diagnosed 
with an uninformative catch all. This commit breaks the catch all into a couple 
of more informative cases.

http://reviews.llvm.org/D16930

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/over/over.oper/over.literal/p5.cpp
  test/CXX/over/over.oper/over.literal/p8.cpp
  test/SemaCXX/literal-operators.cpp

Index: test/SemaCXX/literal-operators.cpp
===
--- test/SemaCXX/literal-operators.cpp
+++ test/SemaCXX/literal-operators.cpp
@@ -35,13 +35,14 @@
 void operator "" _good (c*);
 
 // Check extra cv-qualifiers
-void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator""_cv_good' is not valid}}
+void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{invalid literal operator parameter type 'const volatile char *', did you mean 'const char *'?}}
 
 // Template declaration
 template  void operator "" _good ();
 
-// FIXME: Test some invalid decls that might crop up.
-template  void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator""_invalid' is not valid}}
+template  void operator "" _invalid(); // expected-error {{invalid template parameters for literal operator}}
+template  void operator "" _invalid(); // expected-error {{invalid template parameters for literal operator}}
+template  void operator "" _invalid(); // expected-error {{invalid template parameters for literal operator}}
 
 _Complex float operator""if(long double); // expected-warning {{reserved}}
 _Complex float test_if_1() { return 2.0f + 1.5if; };
Index: test/CXX/over/over.oper/over.literal/p8.cpp
===
--- test/CXX/over/over.oper/over.literal/p8.cpp
+++ test/CXX/over/over.oper/over.literal/p8.cpp
@@ -12,6 +12,6 @@
 float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}}
 string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}}
 double operator "" _miles(double); // expected-error {{parameter}}
-template int operator "" j(const char*); // expected-error {{parameter}}
+template int operator "" j(const char*); // expected-error {{template}}
 
 float operator ""_E(const char *);
Index: test/CXX/over/over.oper/over.literal/p5.cpp
===
--- test/CXX/over/over.oper/over.literal/p5.cpp
+++ test/CXX/over/over.oper/over.literal/p5.cpp
@@ -12,11 +12,11 @@
   friend U operator "" _a(const T *, size_t); // expected-error {{parameter}}
 };
 template struct V {
-  friend void operator "" _b(); // expected-error {{parameter}}
+  friend void operator "" _b(); // expected-error {{template}}
 };
 
-template void operator "" _b(); // expected-error {{parameter}}
-template void operator "" _b(int N = 0); // expected-error {{parameter}}
-template void operator "" _b(); // expected-error {{parameter}}
-template T operator "" _b(const char *); // expected-error {{parameter}}
-template int operator "" _b(const T *, size_t); // expected-error {{parameter}}
+template void operator "" _b(); // expected-error {{template}}
+template void operator "" _b(int N = 0); // expected-error {{template}}
+template void operator "" _b(); // expected-error {{template}}
+template T operator "" _b(const char *); // expected-error {{template}}
+template int operator "" _b(const T *, size_t); // expected-error {{template}}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -11780,10 +11780,9 @@
 return true;
   }
 
-  bool Valid = false;
-
   // This might be the definition of a literal operator template.
   FunctionTemplateDecl *TpDecl = FnDecl->getDescribedFunctionTemplate();
+
   // This might be a specialization of a literal operator template.
   if (!TpDecl)
 TpDecl = FnDecl->getPrimaryTemplate();
@@ -11793,100 +11792,155 @@
   // template signatures, and the only valid signatures with no parameters.
   if (TpDecl) {
 if (FnDecl->param_size() == 0) {
-  // Must have one or two template parameters
   TemplateParameterList *Params = TpDecl->getTemplateParameters();
+
+  // Must have one or two template parameters
   if (Params->size() == 1) {
 NonTypeTemplateParmDecl *PmDecl =
   dyn_cast(Params->getParam(0));
 
 // The template parameter must be a char parameter pack.
 if (PmDecl && PmDecl->isTemplateParameterPack() &&
 Context.hasSameType(PmDecl->getType(), Context.CharTy))
-  Valid = true;
+  goto 

Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

2016-02-05 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, thank you, this looks great.  I agree with David's review, but otherwise 
this LGTM.


http://reviews.llvm.org/D16788



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


Re: r259898 - [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Aaron Ballman via cfe-commits
Is PR25804 a regression?

~Aaron

On Fri, Feb 5, 2016 at 1:59 PM, Hans Wennborg via cfe-commits
 wrote:
> It was requested that this be merged to 3.8 as it fixes PR25804.
>
> Manuel: does this look OK for the branch?
>
> Thanks,
> Hans
>
> On Fri, Feb 5, 2016 at 10:29 AM, Samuel Benzaquen via cfe-commits
>  wrote:
>> Author: sbenza
>> Date: Fri Feb  5 12:29:24 2016
>> New Revision: 259898
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259898=rev
>> Log:
>> [ASTMatchers] Allow hasName() to look through inline namespaces
>>
>> Summary:
>> Allow hasName() to look through inline namespaces.
>> This will fix the interaction between some clang-tidy checks and libc++.
>>
>> libc++ defines names in an inline namespace named std::.
>> When we try to match a name using hasName("std::xxx") it fails to match and 
>> the clang-tidy check does not work.
>>
>> Reviewers: klimek
>>
>> Subscribers: klimek, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D15506
> ___
> 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] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-05 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 47024.
congliu added a comment.

- Added test cases of macro and template.


http://reviews.llvm.org/D16922

Files:
  clang-tidy/misc/VirtualNearMissCheck.cpp
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -1,5 +1,25 @@
 // RUN: %check_clang_tidy %s misc-virtual-near-miss %t
 
+#define MACRO1 void funcM()
+#define MACRO2(m) void m()
+
+template 
+struct TBase {
+  virtual void tfunc(T t);
+};
+
+template 
+struct TDerived : TBase {
+  virtual void tfunk(T t);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'TDerived::tfunk' has a similar name and the same signature as virtual method 'TBase::tfunc'; did you mean to override it? [misc-virtual-near-miss]
+  // CHECK-MESSAGES: note: this fix will not be applied because it overlaps with another fix
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: method 'TDerived::tfunk' has {{.*}} 'TBase::tfunc'
+  // CHECK-MESSAGES: note: this fix will not be applied because it overlaps with another fix
+};
+
+TDerived T1;
+TDerived T2;
+
 class NoDefinedClass1;
 class NoDefinedClass2;
 
@@ -15,21 +35,31 @@
   // Should not warn "do you want to override 'gunk'?", because gunk is already
   // overriden by this class.
   virtual void funk();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has {{.*}} 'Base::func'
+  // CHECK-FIXES: virtual void func();
 
   void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   void func22(); // Should not warn.
 
   void gunk(); // Should not warn: gunk is override.
 
   void fun();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   Derived ==(const Base &); // Should not warn: operators are ignored.
 
   virtual NoDefinedClass2 *f1(); // Should not crash: non-defined class return type is ignored.
+
+  MACRO1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funcM' has {{.*}} 'Base::func'
+
+  MACRO2(func3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func3' has {{.*}} 'Base::func'
+  // CHECK-FIXES: MACRO2(func);
 };
 
 typedef Derived derived_type;
@@ -58,32 +88,40 @@
 
   virtual void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 'Father::func'
+  // CHECK-FIXES: virtual void func();
 
   int methoe(int x, char **strs); // Should not warn: parameter types don't match.
 
   int methoe(int x);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x);
 
   void methof(int x, const char **strs); // Should not warn: return types don't match.
 
   int methoh(int x, const char **strs);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x, const char **strs);
 
   virtual Child *creat(int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 'Father::create'
+  // CHECK-FIXES: virtual Child *create(int i);
 
   virtual Derived &();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate'
+  // CHECK-FIXES: virtual Derived &();
 
   int decaz(const char str[]);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay'
+  // CHECK-FIXES: int decay(const char str[]);
 
   operator bool();
 
   derived_type *canonica(derived_type D);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::canonica' has {{.*}} 'Father::canonical'
+  // CHECK-FIXES: derived_type *canonical(derived_type D);
 
 private:
   void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func'
+  // CHECK-FIXES: void func();
 };
Index: clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -249,11 +249,14 @@
 if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
   if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
 // A "virtual near miss" is found.
+auto Range = CharSourceRange::getTokenRange(
+SourceRange(DerivedMD->getLocation()));
 diag(DerivedMD->getLocStart(),
  "method '%0' has a similar name and the same signature as "
  "virtual method '%1'; did you mean to override it?")
 

Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator

2016-02-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/ternary-implicit-casts.cl:6
@@ +5,3 @@
+   // will not compile, ptr is not generic but local
+  local int *ptr = cond ? gint : lint; // expected-warning {{pointer type 
mismatch ('__global int *' and '__local int *')}} expected-error {{initializing 
'__local int *' with an expression of type 'void *' changes address space of 
pointer}}
+}

Again, I am not quite clear about the purpose of this change.

We have similar testing in test/SemaOpenCL/address-spaces-conversions-cl2.0.cl.

However, the diagnostics, that Clang currently gives, seem wrong to me. We 
might need to investigate that.


http://reviews.llvm.org/D16682



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


Re: r259898 - [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Hans Wennborg via cfe-commits
It was requested that this be merged to 3.8 as it fixes PR25804.

Manuel: does this look OK for the branch?

Thanks,
Hans

On Fri, Feb 5, 2016 at 10:29 AM, Samuel Benzaquen via cfe-commits
 wrote:
> Author: sbenza
> Date: Fri Feb  5 12:29:24 2016
> New Revision: 259898
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259898=rev
> Log:
> [ASTMatchers] Allow hasName() to look through inline namespaces
>
> Summary:
> Allow hasName() to look through inline namespaces.
> This will fix the interaction between some clang-tidy checks and libc++.
>
> libc++ defines names in an inline namespace named std::.
> When we try to match a name using hasName("std::xxx") it fails to match and 
> the clang-tidy check does not work.
>
> Reviewers: klimek
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15506
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259898 - [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Fri Feb  5 12:29:24 2016
New Revision: 259898

URL: http://llvm.org/viewvc/llvm-project?rev=259898=rev
Log:
[ASTMatchers] Allow hasName() to look through inline namespaces

Summary:
Allow hasName() to look through inline namespaces.
This will fix the interaction between some clang-tidy checks and libc++.

libc++ defines names in an inline namespace named std::.
When we try to match a name using hasName("std::xxx") it fails to match and the 
clang-tidy check does not work.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=259898=259897=259898=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Fri Feb  5 
12:29:24 2016
@@ -653,10 +653,18 @@ class HasNameMatcher : public SingleNode
 
   /// \brief Full match routine
   ///
+  /// Fast implementation for the simple case of a named declaration at
+  /// namespace or RecordDecl scope.
+  /// It is slower than matchesNodeUnqualified, but faster than
+  /// matchesNodeFullSlow.
+  bool matchesNodeFullFast(const NamedDecl ) const;
+
+  /// \brief Full match routine
+  ///
   /// It generates the fully qualified name of the declaration (which is
   /// expensive) before trying to match.
   /// It is slower but simple and works on all cases.
-  bool matchesNodeFull(const NamedDecl ) const;
+  bool matchesNodeFullSlow(const NamedDecl ) const;
 
   const bool UseUnqualifiedMatch;
   const std::string Name;

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=259898=259897=259898=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Fri Feb  5 12:29:24 2016
@@ -298,45 +298,149 @@ HasNameMatcher::HasNameMatcher(StringRef
   assert(!Name.empty());
 }
 
-bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl ) const {
-  assert(UseUnqualifiedMatch);
-  if (Node.getIdentifier()) {
-// Simple name.
-return Name == Node.getName();
+namespace {
+
+bool ConsumeNameSuffix(StringRef , StringRef Suffix) {
+  StringRef Name = FullName;
+  if (!Name.endswith(Suffix))
+return false;
+  Name = Name.drop_back(Suffix.size());
+  if (!Name.empty()) {
+if (!Name.endswith("::"))
+  return false;
+Name = Name.drop_back(2);
   }
+  FullName = Name;
+  return true;
+}
+
+bool ConsumeNodeName(StringRef , const NamedDecl ) {
+  // Simple name.
+  if (Node.getIdentifier())
+return ConsumeNameSuffix(Name, Node.getName());
+
   if (Node.getDeclName()) {
 // Name needs to be constructed.
 llvm::SmallString<128> NodeName;
 llvm::raw_svector_ostream OS(NodeName);
 Node.printName(OS);
-return Name == OS.str();
+return ConsumeNameSuffix(Name, OS.str());
   }
-  return false;
+
+  return ConsumeNameSuffix(Name, "(anonymous)");
+}
+
+}  // namespace
+
+bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl ) const {
+  assert(UseUnqualifiedMatch);
+  StringRef NodeName = Name;
+  return ConsumeNodeName(NodeName, Node) && NodeName.empty();
 }
 
-bool HasNameMatcher::matchesNodeFull(const NamedDecl ) const {
-  llvm::SmallString<128> NodeName = StringRef("::");
-  llvm::raw_svector_ostream OS(NodeName);
-  Node.printQualifiedName(OS);
-  const StringRef FullName = OS.str();
+bool HasNameMatcher::matchesNodeFullFast(const NamedDecl ) const {
+  // This function is copied and adapted from NamedDecl::printQualifiedName()
+  // By matching each part individually we optimize in a couple of ways:
+  //  - We can exit early on the first failure.
+  //  - We can skip inline/anonymous namespaces without another pass.
+  //  - We print one name at a time, reducing the chance of overflowing the
+  //inlined space of the SmallString.
+  StringRef Pattern = Name;
+  const bool IsFullyQualified = Pattern.startswith("::");
+
+  // First, match the name.
+  if (!ConsumeNodeName(Pattern, Node))
+return false;
+
+  // Try to match each declaration context.
+  // We are allowed to skip anonymous and inline namespaces if they don't 
match.
+  const DeclContext *Ctx = Node.getDeclContext();
+
+  if (Ctx->isFunctionOrMethod())
+return Pattern.empty() && !IsFullyQualified;
+
+  for (; !Pattern.empty() && Ctx && isa(Ctx);
+   Ctx = Ctx->getParent()) {
+if (const auto *ND = dyn_cast(Ctx)) {
+  

Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-05 Thread Richard Smith via cfe-commits
On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev 
wrote:

> Good point. Do you have in mind calling 'clang::Sema::MergeVarDeclTypes'
> or we to just "duplicate" the logic in
> clang::ASTDeclReader::mergeRedeclarable?
>

It's not safe to call into Sema while we're in a partially-deserialized
state. We know the only interesting case here is complete versus incomplete
array types, so we don't need anything like the complexity of
MergeVarDeclTypes -- something as easy as "if (new type is incomplete and
old type is not) set new type to old type" should work.


> On 05/02/16 02:50, Richard Smith via cfe-commits wrote:
>
> I suspect we'll need to do a little more than this: when we rebuild the
> redeclaration chain, we should probably propagate the complete type to
> later redeclarations in the same scope. Otherwise, if we import a module
> that has a complete type and one that has an incomplete type, the
> declaration found by name lookup might be the one with the incomplete type,
> possibly resulting in rejects-valid on code like this:
>
> a.h:
> extern int a[5];
>
> b.h:
> extern int a[];
>
> x.cc:
> #include "a.h"
> #include "b.h"
> int k = sizeof(a);
>
> On Fri, Jan 22, 2016 at 11:03 AM, Yaron Keren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: yrnkrn
>> Date: Fri Jan 22 13:03:27 2016
>> New Revision: 258524
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258524=rev
>> Log:
>> Merge templated static member variables, fixes 
>> http://llvm.org/pr26179.
>>
>> Patch by Vassil Vassilev!
>> Reviewed by Richard Smith.
>>
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/PR26179/
>> cfe/trunk/test/Modules/Inputs/PR26179/A.h
>> cfe/trunk/test/Modules/Inputs/PR26179/B.h
>> cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
>> cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
>> cfe/trunk/test/Modules/pr26179.cpp
>> Modified:
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>
>> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=258524=258523=258524=diff
>>
>> ==
>> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jan 22 13:03:27 2016
>> @@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, N
>>// Variables with the same type and linkage match.
>>if (VarDecl *VarX = dyn_cast(X)) {
>>  VarDecl *VarY = cast(Y);
>> -return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
>> -  VarX->getASTContext().hasSameType(VarX->getType(),
>> VarY->getType());
>> +if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
>> +  ASTContext  = VarX->getASTContext();
>> +  if (C.hasSameType(VarX->getType(), VarY->getType()))
>> +return true;
>> +
>> +  // We can get decls with different types on the redecl chain. Eg.
>> +  // template  struct S { static T Var[]; }; // #1
>> +  // template  T S::Var[sizeof(T)]; // #2
>> +  // Only? happens when completing an incomplete array type. In this
>> case
>> +  // when comparing #1 and #2 we should go through their elements
>> types.
>> +  const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
>> +  const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
>> +  if (!VarXTy || !VarYTy)
>> +return false;
>> +  if (VarXTy->isIncompleteArrayType() ||
>> VarYTy->isIncompleteArrayType())
>> +return C.hasSameType(VarXTy->getElementType(),
>> VarYTy->getElementType());
>> +}
>> +return false;
>>}
>>
>>// Namespaces with the same name and inlinedness match.
>>
>> Added: cfe/trunk/test/Modules/Inputs/PR26179/A.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/A.h?rev=258524=auto
>>
>> ==
>> --- cfe/trunk/test/Modules/Inputs/PR26179/A.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/PR26179/A.h Fri Jan 22 13:03:27 2016
>> @@ -0,0 +1,4 @@
>> +#include "basic_string.h"
>> +#include "B.h"
>> +
>> +int *p = a;
>>
>> Added: cfe/trunk/test/Modules/Inputs/PR26179/B.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/B.h?rev=258524=auto
>>
>> ==
>> --- cfe/trunk/test/Modules/Inputs/PR26179/B.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/PR26179/B.h Fri Jan 22 13:03:27 2016
>> @@ -0,0 +1,2 @@
>> +#include "basic_string.h"
>> +extern int a[5];
>>
>> Added: cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h?rev=258524=auto
>>
>> 

Re: [PATCH] D16574: Bug 15685 - OpenCL 'char' is not signed

2016-02-05 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I am missing to understand the intention of this change. Are you trying to 
improve the testing for OpenCL?


http://reviews.llvm.org/D16574



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2016-02-05 Thread Samuel Benzaquen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259898: [ASTMatchers] Allow hasName() to look through inline 
namespaces (authored by sbenza).

Changed prior to commit:
  http://reviews.llvm.org/D15506?vs=45438=47029#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15506

Files:
  cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -653,10 +653,18 @@
 
   /// \brief Full match routine
   ///
+  /// Fast implementation for the simple case of a named declaration at
+  /// namespace or RecordDecl scope.
+  /// It is slower than matchesNodeUnqualified, but faster than
+  /// matchesNodeFullSlow.
+  bool matchesNodeFullFast(const NamedDecl ) const;
+
+  /// \brief Full match routine
+  ///
   /// It generates the fully qualified name of the declaration (which is
   /// expensive) before trying to match.
   /// It is slower but simple and works on all cases.
-  bool matchesNodeFull(const NamedDecl ) const;
+  bool matchesNodeFullSlow(const NamedDecl ) const;
 
   const bool UseUnqualifiedMatch;
   const std::string Name;
Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -298,45 +298,149 @@
   assert(!Name.empty());
 }
 
-bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl ) const {
-  assert(UseUnqualifiedMatch);
-  if (Node.getIdentifier()) {
-// Simple name.
-return Name == Node.getName();
+namespace {
+
+bool ConsumeNameSuffix(StringRef , StringRef Suffix) {
+  StringRef Name = FullName;
+  if (!Name.endswith(Suffix))
+return false;
+  Name = Name.drop_back(Suffix.size());
+  if (!Name.empty()) {
+if (!Name.endswith("::"))
+  return false;
+Name = Name.drop_back(2);
   }
+  FullName = Name;
+  return true;
+}
+
+bool ConsumeNodeName(StringRef , const NamedDecl ) {
+  // Simple name.
+  if (Node.getIdentifier())
+return ConsumeNameSuffix(Name, Node.getName());
+
   if (Node.getDeclName()) {
 // Name needs to be constructed.
 llvm::SmallString<128> NodeName;
 llvm::raw_svector_ostream OS(NodeName);
 Node.printName(OS);
-return Name == OS.str();
+return ConsumeNameSuffix(Name, OS.str());
   }
-  return false;
+
+  return ConsumeNameSuffix(Name, "(anonymous)");
+}
+
+}  // namespace
+
+bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl ) const {
+  assert(UseUnqualifiedMatch);
+  StringRef NodeName = Name;
+  return ConsumeNodeName(NodeName, Node) && NodeName.empty();
+}
+
+bool HasNameMatcher::matchesNodeFullFast(const NamedDecl ) const {
+  // This function is copied and adapted from NamedDecl::printQualifiedName()
+  // By matching each part individually we optimize in a couple of ways:
+  //  - We can exit early on the first failure.
+  //  - We can skip inline/anonymous namespaces without another pass.
+  //  - We print one name at a time, reducing the chance of overflowing the
+  //inlined space of the SmallString.
+  StringRef Pattern = Name;
+  const bool IsFullyQualified = Pattern.startswith("::");
+
+  // First, match the name.
+  if (!ConsumeNodeName(Pattern, Node))
+return false;
+
+  // Try to match each declaration context.
+  // We are allowed to skip anonymous and inline namespaces if they don't match.
+  const DeclContext *Ctx = Node.getDeclContext();
+
+  if (Ctx->isFunctionOrMethod())
+return Pattern.empty() && !IsFullyQualified;
+
+  for (; !Pattern.empty() && Ctx && isa(Ctx);
+   Ctx = Ctx->getParent()) {
+if (const auto *ND = dyn_cast(Ctx)) {
+  StringRef NSName =
+  ND->isAnonymousNamespace() ? "(anonymous namespace)" : ND->getName();
+
+  // If it matches, continue.
+  if (ConsumeNameSuffix(Pattern, NSName))
+continue;
+  // If it didn't match but we can skip it, continue.
+  if (ND->isAnonymousNamespace() || ND->isInline())
+continue;
+
+  return false;
+}
+if (const auto *RD = dyn_cast(Ctx)) {
+  if (!isa(Ctx)) {
+if (RD->getIdentifier()) {
+  if (ConsumeNameSuffix(Pattern, RD->getName()))
+continue;
+} else {
+  llvm::SmallString<128> NodeName;
+  NodeName += StringRef("(anonymous ");
+  NodeName += RD->getKindName();
+  NodeName += ')';
+  if (ConsumeNameSuffix(Pattern, NodeName))
+continue;
+}
+
+return false;
+  }
+}
+
+// We don't know how to deal with this DeclContext.
+// Fallback to the slow version of the code.
+

Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-05 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

ping?


http://reviews.llvm.org/D16310



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


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:5067
@@ +5066,3 @@
+  if (DeclTy->isPipeType() ||
+  (S.getLangOpts().OpenCLVersion < 200 && DeclTy->isImageType())) {
+S.Diag(D->getLocation(), diag::err_opencl_invalid_read_write)

pxli168 wrote:
> I used arc to update the patch and it case some line error.
> I have check about OpenCL version here and will handle the read_write with 
> image before OpenCL 2.0. As spec mentioned that it is reversed before OpenCL 
> 2.0. 
Do you think we could just check:
  if (S.getLangOpts().OpenCLVersion < 200 || DeclTy->isPipeType())


http://reviews.llvm.org/D16040



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


[PATCH] D16932: [CUDA] Bug 26497 : Remove wrappers for variants already provided by CUDA headers.

2016-02-05 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jingyue, jlebar.
tra added a subscriber: cfe-commits.

... and pull them into std namespace with using-declaration instead.


http://reviews.llvm.org/D16932

Files:
  lib/Headers/__clang_cuda_cmath.h

Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -36,57 +36,44 @@
 namespace std {
 __DEVICE__ long long abs(long long n) { return ::llabs(n); }
 __DEVICE__ long abs(long n) { return ::labs(n); }
-__DEVICE__ int abs(int n) { return ::abs(n); }
+using ::abs;
 __DEVICE__ float abs(float x) { return ::fabsf(x); }
 __DEVICE__ double abs(double x) { return ::fabs(x); }
 __DEVICE__ float acos(float x) { return ::acosf(x); }
-__DEVICE__ double acos(double x) { return ::acos(x); }
-__DEVICE__ float acosh(float x) { return ::acoshf(x); }
-__DEVICE__ double acosh(double x) { return ::acosh(x); }
+using ::acos;
+using ::acosh;
 __DEVICE__ float asin(float x) { return ::asinf(x); }
-__DEVICE__ double asin(double x) { return ::asin(x); }
-__DEVICE__ float asinh(float x) { return ::asinhf(x); }
-__DEVICE__ double asinh(double x) { return ::asinh(x); }
+using ::asin;
+using ::asinh;
 __DEVICE__ float atan(float x) { return ::atanf(x); }
-__DEVICE__ double atan(double x) { return ::atan(x); }
+using ::atan;
 __DEVICE__ float atan2(float x, float y) { return ::atan2f(x, y); }
-__DEVICE__ double atan2(double x, double y) { return ::atan2(x, y); }
-__DEVICE__ float atanh(float x) { return ::atanhf(x); }
-__DEVICE__ double atanh(double x) { return ::atanh(x); }
-__DEVICE__ float cbrt(float x) { return ::cbrtf(x); }
-__DEVICE__ double cbrt(double x) { return ::cbrt(x); }
+using ::atan2;
+using ::atanh;
+using ::cbrt;
 __DEVICE__ float ceil(float x) { return ::ceilf(x); }
-__DEVICE__ double ceil(double x) { return ::ceil(x); }
-__DEVICE__ float copysign(float x, float y) { return ::copysignf(x, y); }
-__DEVICE__ double copysign(double x, double y) { return ::copysign(x, y); }
+using ::ceil;
+using ::copysign;
 __DEVICE__ float cos(float x) { return ::cosf(x); }
-__DEVICE__ double cos(double x) { return ::cos(x); }
+using ::cos;
 __DEVICE__ float cosh(float x) { return ::coshf(x); }
-__DEVICE__ double cosh(double x) { return ::cosh(x); }
-__DEVICE__ float erf(float x) { return ::erff(x); }
-__DEVICE__ double erf(double x) { return ::erf(x); }
-__DEVICE__ float erfc(float x) { return ::erfcf(x); }
-__DEVICE__ double erfc(double x) { return ::erfc(x); }
+using ::cosh;
+using ::erf;
+using ::erfc;
 __DEVICE__ float exp(float x) { return ::expf(x); }
-__DEVICE__ double exp(double x) { return ::exp(x); }
-__DEVICE__ float exp2(float x) { return ::exp2f(x); }
-__DEVICE__ double exp2(double x) { return ::exp2(x); }
-__DEVICE__ float expm1(float x) { return ::expm1f(x); }
-__DEVICE__ double expm1(double x) { return ::expm1(x); }
+using ::exp;
+using ::exp2;
+using ::expm1;
 __DEVICE__ float fabs(float x) { return ::fabsf(x); }
-__DEVICE__ double fabs(double x) { return ::fabs(x); }
-__DEVICE__ float fdim(float x, float y) { return ::fdimf(x, y); }
-__DEVICE__ double fdim(double x, double y) { return ::fdim(x, y); }
+using ::fabs;
+using ::fdim;
 __DEVICE__ float floor(float x) { return ::floorf(x); }
-__DEVICE__ double floor(double x) { return ::floor(x); }
-__DEVICE__ float fma(float x, float y, float z) { return ::fmaf(x, y, z); }
-__DEVICE__ double fma(double x, double y, double z) { return ::fma(x, y, z); }
-__DEVICE__ float fmax(float x, float y) { return ::fmaxf(x, y); }
-__DEVICE__ double fmax(double x, double y) { return ::fmax(x, y); }
-__DEVICE__ float fmin(float x, float y) { return ::fminf(x, y); }
-__DEVICE__ double fmin(double x, double y) { return ::fmin(x, y); }
+using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
 __DEVICE__ float fmod(float x, float y) { return ::fmodf(x, y); }
-__DEVICE__ double fmod(double x, double y) { return ::fmod(x, y); }
+using ::fmod;
 __DEVICE__ int fpclassify(float x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, x);
@@ -96,11 +83,9 @@
   FP_ZERO, x);
 }
 __DEVICE__ float frexp(float arg, int *exp) { return ::frexpf(arg, exp); }
-__DEVICE__ double frexp(double arg, int *exp) { return ::frexp(arg, exp); }
-__DEVICE__ float hypot(float x, float y) { return ::hypotf(x, y); }
-__DEVICE__ double hypot(double x, double y) { return ::hypot(x, y); }
-__DEVICE__ int ilogb(float arg) { return ::ilogbf(arg); }
-__DEVICE__ int ilogb(double arg) { return ::ilogb(arg); }
+using ::frexp;
+using ::hypot;
+using ::ilogb;
 __DEVICE__ bool isfinite(float x) { return ::__finitef(x); }
 __DEVICE__ bool isfinite(double x) { return ::__finite(x); }
 __DEVICE__ bool isgreater(float x, float y) {
@@ -141,82 +126,57 @@
 __DEVICE__ bool isunordered(double x, double y) {
   return __builtin_isunordered(x, y);
 }
-__DEVICE__ long 

Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Ulrich Weigand via cfe-commits


Hans,

this is one more patch that should go into 3.8  --  it fixes miscompiles of
code using GCC-provided C++11 system headers like .

With this patch, the test suite is now clean also with a bootstrapped
clang.

>Author: uweigand
>Date: Fri Feb  5 15:34:28 2016
>New Revision: 259931
>
>URL: http://llvm.org/viewvc/llvm-project?rev=259931=rev
>Log: [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
>
>Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.
>
>This fixes a miscompile of GCC C++11 standard library headers
>due to use of those macros in an ABI-changing manner.
>
>See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:
>
>  // Compile time constant that indicates prefered locking policy in
>  // the current configuration.
>  static const _Lock_policy __default_lock_policy =
>#ifdef __GTHREADS
>#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
> && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
>  _S_atomic;
>#else
>  _S_mutex;
>#endif
>#else
>  _S_single;
>#endif
>
>A different choice of __default_lock_policy causes different
>sizes of several of the C++11 data structures, which are then
>incompatible when inlined in clang-compiled code with what the
>(GCC-compiled) external library expects.
>
>This in turn leads to various crashes when using std::thread
>in code compiled with clang, as see e.g. via the ThreadPool
>unit tests.  See PR 26473 for an example.
>
>
>Modified:
>cfe/trunk/lib/Basic/Targets.cpp
>cfe/trunk/test/Preprocessor/predefined-arch-macros.c


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU/Linux compilers and toolchain
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Hal Finkel via cfe-commits
Just a general comment: I believe we've now fixed this bug for at least four 
different architectures (each time as a separate effort). Is there some kind of 
auditing we could do to make sure we don't run into this again?

 -Hal

- Original Message -
> From: "Ulrich Weigand via cfe-commits" 
> To: cfe-commits@lists.llvm.org
> Sent: Friday, February 5, 2016 3:34:29 PM
> Subject: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
> 
> Author: uweigand
> Date: Fri Feb  5 15:34:28 2016
> New Revision: 259931
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259931=rev
> Log:
> [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
> 
> Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.
> 
> This fixes a miscompile of GCC C++11 standard library headers
> due to use of those macros in an ABI-changing manner.
> 
> See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:
> 
>   // Compile time constant that indicates prefered locking policy in
>   // the current configuration.
>   static const _Lock_policy __default_lock_policy =
> #ifdef __GTHREADS
> #if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
>  && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
>   _S_atomic;
> #else
>   _S_mutex;
> #endif
> #else
>   _S_single;
> #endif
> 
> A different choice of __default_lock_policy causes different
> sizes of several of the C++11 data structures, which are then
> incompatible when inlined in clang-compiled code with what the
> (GCC-compiled) external library expects.
> 
> This in turn leads to various crashes when using std::thread
> in code compiled with clang, as see e.g. via the ThreadPool
> unit tests.  See PR 26473 for an example.
> 
> 
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/test/Preprocessor/predefined-arch-macros.c
> 
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259931=259930=259931=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb  5 15:34:28 2016
> @@ -6166,6 +6166,12 @@ public:
>  Builder.defineMacro("__s390x__");
>  Builder.defineMacro("__zarch__");
>  Builder.defineMacro("__LONG_DOUBLE_128__");
> +
> +Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
> +Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
> +Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
> +Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
> +
>  if (HasTransactionalExecution)
>Builder.defineMacro("__HTM__");
>  if (Opts.ZVector)
> 
> Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=259931=259930=259931=diff
> ==
> --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
> +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Fri Feb  5
> 15:34:28 2016
> @@ -1787,6 +1787,10 @@
>  // RUN: -target s390x-unknown-linux \
>  // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_Z10
>  //
> +// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
> +// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
> +// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
> +// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
>  // CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
>  // CHECK_SYSTEMZ_Z10: #define __s390__ 1
>  // CHECK_SYSTEMZ_Z10: #define __s390x__ 1
> @@ -1796,6 +1800,10 @@
>  // RUN: -target s390x-unknown-linux \
>  // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZEC12
>  //
> +// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
> +// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
> +// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
> +// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
>  // CHECK_SYSTEMZ_ZEC12: #define __HTM__ 1
>  // CHECK_SYSTEMZ_ZEC12: #define __LONG_DOUBLE_128__ 1
>  // CHECK_SYSTEMZ_ZEC12: #define __s390__ 1
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259950 - Eliminate an unnecessary enum, use the LLVM version. NFC

2016-02-05 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb  5 17:23:25 2016
New Revision: 259950

URL: http://llvm.org/viewvc/llvm-project?rev=259950=rev
Log:
Eliminate an unnecessary enum, use the LLVM version. NFC

Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=259950=259949=259950=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Feb  5 17:23:25 2016
@@ -188,7 +188,8 @@ VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
 ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, 
codegenoptions::NoDebugInfo)
 
 /// Tune the debug info for this debugger.
-ENUM_CODEGENOPT(DebuggerTuning, DebuggerKind, 2, DebuggerKindDefault)
+ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2,
+llvm::DebuggerKind::Default)
 
 /// Dwarf version. Version zero indicates to LLVM that no DWARF should be
 /// emitted.

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=259950=259949=259950=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Fri Feb  5 17:23:25 2016
@@ -17,6 +17,7 @@
 #include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Sanitizers.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Target/TargetOptions.h"
 #include 
 #include 
 #include 
@@ -59,13 +60,6 @@ public:
 Mixed = 2
   };
 
-  enum DebuggerKind {
-DebuggerKindDefault,
-DebuggerKindGDB,
-DebuggerKindLLDB,
-DebuggerKindSCE
-  };
-
   enum TLSModel {
 GeneralDynamicTLSModel,
 LocalDynamicTLSModel,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=259950=259949=259950=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Feb  5 17:23:25 2016
@@ -558,19 +558,7 @@ TargetMachine *EmitAssemblyHelper::Creat
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
-  switch (CodeGenOpts.getDebuggerTuning()) {
-  case CodeGenOptions::DebuggerKindGDB:
-Options.DebuggerTuning = llvm::DebuggerKind::GDB;
-break;
-  case CodeGenOptions::DebuggerKindLLDB:
-Options.DebuggerTuning = llvm::DebuggerKind::LLDB;
-break;
-  case CodeGenOptions::DebuggerKindSCE:
-Options.DebuggerTuning = llvm::DebuggerKind::SCE;
-break;
-  default:
-break;
-  }
+  Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
 
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=259950=259949=259950=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb  5 17:23:25 2016
@@ -428,15 +428,15 @@ static bool ParseCodeGenArgs(CodeGenOpti
   }
   if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
 unsigned Val = llvm::StringSwitch(A->getValue())
-   .Case("gdb", CodeGenOptions::DebuggerKindGDB)
-   .Case("lldb", CodeGenOptions::DebuggerKindLLDB)
-   .Case("sce", CodeGenOptions::DebuggerKindSCE)
+   .Case("gdb", unsigned(llvm::DebuggerKind::GDB))
+   .Case("lldb", unsigned(llvm::DebuggerKind::LLDB))
+   .Case("sce", unsigned(llvm::DebuggerKind::SCE))
.Default(~0U);
 if (Val == ~0U)
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
 << A->getValue();
 else
-  Opts.setDebuggerTuning(static_cast(Val));
+  Opts.setDebuggerTuning(static_cast(Val));
   }
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
   Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);


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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-02-05 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: include/clang/Frontend/CodeGenOptions.h:234
@@ +233,3 @@
+
+  /// \brief Check if IR profile instrumenation is on.
+  bool hasProfileIRInstr() const {

typo: instrumentation


http://reviews.llvm.org/D15829



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


Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType

2016-02-05 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

Ping.


http://reviews.llvm.org/D16539



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


Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType

2016-02-05 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

Ping.


http://reviews.llvm.org/D16539



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


r259944 - [CUDA] Bug 26497 : Remove wrappers for variants provided by CUDA headers.

2016-02-05 Thread Artem Belevich via cfe-commits
Author: tra
Date: Fri Feb  5 16:54:05 2016
New Revision: 259944

URL: http://llvm.org/viewvc/llvm-project?rev=259944=rev
Log:
[CUDA] Bug 26497 : Remove wrappers for variants provided by CUDA headers.

... and pull global-scope ones into std namespace with using-declaration.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=259944=259943=259944=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Fri Feb  5 16:54:05 2016
@@ -36,57 +36,44 @@
 namespace std {
 __DEVICE__ long long abs(long long n) { return ::llabs(n); }
 __DEVICE__ long abs(long n) { return ::labs(n); }
-__DEVICE__ int abs(int n) { return ::abs(n); }
+using ::abs;
 __DEVICE__ float abs(float x) { return ::fabsf(x); }
 __DEVICE__ double abs(double x) { return ::fabs(x); }
 __DEVICE__ float acos(float x) { return ::acosf(x); }
-__DEVICE__ double acos(double x) { return ::acos(x); }
-__DEVICE__ float acosh(float x) { return ::acoshf(x); }
-__DEVICE__ double acosh(double x) { return ::acosh(x); }
+using ::acos;
+using ::acosh;
 __DEVICE__ float asin(float x) { return ::asinf(x); }
-__DEVICE__ double asin(double x) { return ::asin(x); }
-__DEVICE__ float asinh(float x) { return ::asinhf(x); }
-__DEVICE__ double asinh(double x) { return ::asinh(x); }
+using ::asin;
+using ::asinh;
 __DEVICE__ float atan(float x) { return ::atanf(x); }
-__DEVICE__ double atan(double x) { return ::atan(x); }
+using ::atan;
 __DEVICE__ float atan2(float x, float y) { return ::atan2f(x, y); }
-__DEVICE__ double atan2(double x, double y) { return ::atan2(x, y); }
-__DEVICE__ float atanh(float x) { return ::atanhf(x); }
-__DEVICE__ double atanh(double x) { return ::atanh(x); }
-__DEVICE__ float cbrt(float x) { return ::cbrtf(x); }
-__DEVICE__ double cbrt(double x) { return ::cbrt(x); }
+using ::atan2;
+using ::atanh;
+using ::cbrt;
 __DEVICE__ float ceil(float x) { return ::ceilf(x); }
-__DEVICE__ double ceil(double x) { return ::ceil(x); }
-__DEVICE__ float copysign(float x, float y) { return ::copysignf(x, y); }
-__DEVICE__ double copysign(double x, double y) { return ::copysign(x, y); }
+using ::ceil;
+using ::copysign;
 __DEVICE__ float cos(float x) { return ::cosf(x); }
-__DEVICE__ double cos(double x) { return ::cos(x); }
+using ::cos;
 __DEVICE__ float cosh(float x) { return ::coshf(x); }
-__DEVICE__ double cosh(double x) { return ::cosh(x); }
-__DEVICE__ float erf(float x) { return ::erff(x); }
-__DEVICE__ double erf(double x) { return ::erf(x); }
-__DEVICE__ float erfc(float x) { return ::erfcf(x); }
-__DEVICE__ double erfc(double x) { return ::erfc(x); }
+using ::cosh;
+using ::erf;
+using ::erfc;
 __DEVICE__ float exp(float x) { return ::expf(x); }
-__DEVICE__ double exp(double x) { return ::exp(x); }
-__DEVICE__ float exp2(float x) { return ::exp2f(x); }
-__DEVICE__ double exp2(double x) { return ::exp2(x); }
-__DEVICE__ float expm1(float x) { return ::expm1f(x); }
-__DEVICE__ double expm1(double x) { return ::expm1(x); }
+using ::exp;
+using ::exp2;
+using ::expm1;
 __DEVICE__ float fabs(float x) { return ::fabsf(x); }
-__DEVICE__ double fabs(double x) { return ::fabs(x); }
-__DEVICE__ float fdim(float x, float y) { return ::fdimf(x, y); }
-__DEVICE__ double fdim(double x, double y) { return ::fdim(x, y); }
+using ::fabs;
+using ::fdim;
 __DEVICE__ float floor(float x) { return ::floorf(x); }
-__DEVICE__ double floor(double x) { return ::floor(x); }
-__DEVICE__ float fma(float x, float y, float z) { return ::fmaf(x, y, z); }
-__DEVICE__ double fma(double x, double y, double z) { return ::fma(x, y, z); }
-__DEVICE__ float fmax(float x, float y) { return ::fmaxf(x, y); }
-__DEVICE__ double fmax(double x, double y) { return ::fmax(x, y); }
-__DEVICE__ float fmin(float x, float y) { return ::fminf(x, y); }
-__DEVICE__ double fmin(double x, double y) { return ::fmin(x, y); }
+using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
 __DEVICE__ float fmod(float x, float y) { return ::fmodf(x, y); }
-__DEVICE__ double fmod(double x, double y) { return ::fmod(x, y); }
+using ::fmod;
 __DEVICE__ int fpclassify(float x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, x);
@@ -96,11 +83,9 @@ __DEVICE__ int fpclassify(double x) {
   FP_ZERO, x);
 }
 __DEVICE__ float frexp(float arg, int *exp) { return ::frexpf(arg, exp); }
-__DEVICE__ double frexp(double arg, int *exp) { return ::frexp(arg, exp); }
-__DEVICE__ float hypot(float x, float y) { return ::hypotf(x, y); }
-__DEVICE__ double hypot(double x, double y) { return ::hypot(x, y); }
-__DEVICE__ int ilogb(float arg) { return ::ilogbf(arg); }
-__DEVICE__ int ilogb(double arg) { return 

Re: [PATCH] D16932: [CUDA] Bug 26497 : Remove wrappers for variants already provided by CUDA headers.

2016-02-05 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259944: [CUDA] Bug 26497 : Remove wrappers for variants 
provided by CUDA headers. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D16932?vs=47040=47058#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16932

Files:
  cfe/trunk/lib/Headers/__clang_cuda_cmath.h

Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -36,57 +36,44 @@
 namespace std {
 __DEVICE__ long long abs(long long n) { return ::llabs(n); }
 __DEVICE__ long abs(long n) { return ::labs(n); }
-__DEVICE__ int abs(int n) { return ::abs(n); }
+using ::abs;
 __DEVICE__ float abs(float x) { return ::fabsf(x); }
 __DEVICE__ double abs(double x) { return ::fabs(x); }
 __DEVICE__ float acos(float x) { return ::acosf(x); }
-__DEVICE__ double acos(double x) { return ::acos(x); }
-__DEVICE__ float acosh(float x) { return ::acoshf(x); }
-__DEVICE__ double acosh(double x) { return ::acosh(x); }
+using ::acos;
+using ::acosh;
 __DEVICE__ float asin(float x) { return ::asinf(x); }
-__DEVICE__ double asin(double x) { return ::asin(x); }
-__DEVICE__ float asinh(float x) { return ::asinhf(x); }
-__DEVICE__ double asinh(double x) { return ::asinh(x); }
+using ::asin;
+using ::asinh;
 __DEVICE__ float atan(float x) { return ::atanf(x); }
-__DEVICE__ double atan(double x) { return ::atan(x); }
+using ::atan;
 __DEVICE__ float atan2(float x, float y) { return ::atan2f(x, y); }
-__DEVICE__ double atan2(double x, double y) { return ::atan2(x, y); }
-__DEVICE__ float atanh(float x) { return ::atanhf(x); }
-__DEVICE__ double atanh(double x) { return ::atanh(x); }
-__DEVICE__ float cbrt(float x) { return ::cbrtf(x); }
-__DEVICE__ double cbrt(double x) { return ::cbrt(x); }
+using ::atan2;
+using ::atanh;
+using ::cbrt;
 __DEVICE__ float ceil(float x) { return ::ceilf(x); }
-__DEVICE__ double ceil(double x) { return ::ceil(x); }
-__DEVICE__ float copysign(float x, float y) { return ::copysignf(x, y); }
-__DEVICE__ double copysign(double x, double y) { return ::copysign(x, y); }
+using ::ceil;
+using ::copysign;
 __DEVICE__ float cos(float x) { return ::cosf(x); }
-__DEVICE__ double cos(double x) { return ::cos(x); }
+using ::cos;
 __DEVICE__ float cosh(float x) { return ::coshf(x); }
-__DEVICE__ double cosh(double x) { return ::cosh(x); }
-__DEVICE__ float erf(float x) { return ::erff(x); }
-__DEVICE__ double erf(double x) { return ::erf(x); }
-__DEVICE__ float erfc(float x) { return ::erfcf(x); }
-__DEVICE__ double erfc(double x) { return ::erfc(x); }
+using ::cosh;
+using ::erf;
+using ::erfc;
 __DEVICE__ float exp(float x) { return ::expf(x); }
-__DEVICE__ double exp(double x) { return ::exp(x); }
-__DEVICE__ float exp2(float x) { return ::exp2f(x); }
-__DEVICE__ double exp2(double x) { return ::exp2(x); }
-__DEVICE__ float expm1(float x) { return ::expm1f(x); }
-__DEVICE__ double expm1(double x) { return ::expm1(x); }
+using ::exp;
+using ::exp2;
+using ::expm1;
 __DEVICE__ float fabs(float x) { return ::fabsf(x); }
-__DEVICE__ double fabs(double x) { return ::fabs(x); }
-__DEVICE__ float fdim(float x, float y) { return ::fdimf(x, y); }
-__DEVICE__ double fdim(double x, double y) { return ::fdim(x, y); }
+using ::fabs;
+using ::fdim;
 __DEVICE__ float floor(float x) { return ::floorf(x); }
-__DEVICE__ double floor(double x) { return ::floor(x); }
-__DEVICE__ float fma(float x, float y, float z) { return ::fmaf(x, y, z); }
-__DEVICE__ double fma(double x, double y, double z) { return ::fma(x, y, z); }
-__DEVICE__ float fmax(float x, float y) { return ::fmaxf(x, y); }
-__DEVICE__ double fmax(double x, double y) { return ::fmax(x, y); }
-__DEVICE__ float fmin(float x, float y) { return ::fminf(x, y); }
-__DEVICE__ double fmin(double x, double y) { return ::fmin(x, y); }
+using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
 __DEVICE__ float fmod(float x, float y) { return ::fmodf(x, y); }
-__DEVICE__ double fmod(double x, double y) { return ::fmod(x, y); }
+using ::fmod;
 __DEVICE__ int fpclassify(float x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, x);
@@ -96,11 +83,9 @@
   FP_ZERO, x);
 }
 __DEVICE__ float frexp(float arg, int *exp) { return ::frexpf(arg, exp); }
-__DEVICE__ double frexp(double arg, int *exp) { return ::frexp(arg, exp); }
-__DEVICE__ float hypot(float x, float y) { return ::hypotf(x, y); }
-__DEVICE__ double hypot(double x, double y) { return ::hypot(x, y); }
-__DEVICE__ int ilogb(float arg) { return ::ilogbf(arg); }
-__DEVICE__ int ilogb(double arg) { return ::ilogb(arg); }
+using ::frexp;
+using ::hypot;
+using ::ilogb;
 __DEVICE__ bool isfinite(float x) { return ::__finitef(x); }
 __DEVICE__ bool isfinite(double x) { return ::__finite(x); }
 __DEVICE__ bool 

Re: [PATCH] D3976: -Wcomma, a new warning for questionable uses of the comma operator

2016-02-05 Thread Richard Trieu via cfe-commits
So, this week got consumed by -Wconstant-conversion.  We'll see how next
week goes.

On Fri, Jan 29, 2016 at 7:16 PM, Richard Trieu  wrote:

> rtrieu added a comment.
>
> Not sure what happened.  Will check it out on Monday.
>
>
> http://reviews.llvm.org/D3976
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259932 - Add an ARC autoreleased-return-value caller marker on i386.

2016-02-05 Thread John McCall via cfe-commits
Author: rjmccall
Date: Fri Feb  5 15:37:38 2016
New Revision: 259932

URL: http://llvm.org/viewvc/llvm-project?rev=259932=rev
Log:
Add an ARC autoreleased-return-value caller marker on i386.

rdar://24531556

Added:
cfe/trunk/test/CodeGenObjC/arc-i386.m
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=259932=259931=259932=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Feb  5 15:37:38 2016
@@ -920,6 +920,11 @@ public:
('T' << 24);
 return llvm::ConstantInt::get(CGM.Int32Ty, Sig);
   }
+
+  StringRef getARCRetainAutoreleasedReturnValueMarker() const override {
+return "movl\t%ebp, %ebp"
+   "\t\t## marker for objc_retainAutoreleaseReturnValue";
+  }
 };
 
 }

Added: cfe/trunk/test/CodeGenObjC/arc-i386.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-i386.m?rev=259932=auto
==
--- cfe/trunk/test/CodeGenObjC/arc-i386.m (added)
+++ cfe/trunk/test/CodeGenObjC/arc-i386.m Fri Feb  5 15:37:38 2016
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm -fblocks -fobjc-arc 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-apple-iossimulator6.0 -emit-llvm -fblocks 
-fobjc-arc -o - %s | FileCheck %s
+
+// : implement objc_retainAutoreleasedReturnValue on i386
+
+// CHECK-LABEL: define i8* @test0()
+id test0(void) {
+  extern id test0_helper(void);
+  // CHECK:  [[T0:%.*]] = call i8* @test0_helper()
+  // CHECK-NEXT: ret i8* [[T0]]
+  return test0_helper();
+}
+
+// CHECK-LABEL: define void @test1()
+void test1(void) {
+  extern id test1_helper(void);
+  // CHECK:  [[T0:%.*]] = call i8* @test1_helper()
+  // CHECK-NEXT: call void asm sideeffect "mov
+  // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* 
[[T0]])
+  // CHECK-NEXT: store i8* [[T1]],
+  // CHECK-NEXT: call void @objc_storeStrong(
+  // CHECK-NEXT: ret void
+  id x = test1_helper();
+}
+
+// rdar://problem/12133032
+// CHECK-LABEL: define {{.*}} @test2()
+@class A;
+A *test2(void) {
+  extern A *test2_helper(void);
+  // CHECK:  [[T0:%.*]] = call [[A:%.*]]* @test2_helper()
+  // CHECK-NEXT: ret [[A]]* [[T0]]
+  return test2_helper();
+}
+
+// CHECK-LABEL: define i8* @test3()
+id test3(void) {
+  extern A *test3_helper(void);
+  // CHECK:  [[T0:%.*]] = call [[A]]* @test3_helper()
+  // CHECK-NEXT: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+  // CHECK-NEXT: ret i8* [[T1]]
+  return test3_helper();
+}


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


Re: r259931 - [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2016-02-05 Thread Hans Wennborg via cfe-commits
Merged in r259939.

Cheers,
Hans

On Fri, Feb 5, 2016 at 2:06 PM, Ulrich Weigand
 wrote:
> Hans,
>
> this is one more patch that should go into 3.8 -- it fixes miscompiles of
> code using GCC-provided C++11 system headers like .
>
> With this patch, the test suite is now clean also with a bootstrapped clang.
>
>
>
>>Author: uweigand
>>Date: Fri Feb  5 15:34:28 2016
>>New Revision: 259931
>>
>>URL: http://llvm.org/viewvc/llvm-project?rev=259931=rev
>>Log: [SystemZ] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
>>
>>Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248] macros on SystemZ.
>>
>>This fixes a miscompile of GCC C++11 standard library headers
>>due to use of those macros in an ABI-changing manner.
>>
>>See e.g. /usr/include/c++/4.8.5/ext/concurrence.h:
>>
>>  // Compile time constant that indicates prefered locking policy in
>>  // the current configuration.
>>  static const _Lock_policy __default_lock_policy =
>>#ifdef __GTHREADS
>>#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
>> && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
>>  _S_atomic;
>>#else
>>  _S_mutex;
>>#endif
>>#else
>>  _S_single;
>>#endif
>>
>>A different choice of __default_lock_policy causes different
>>sizes of several of the C++11 data structures, which are then
>>incompatible when inlined in clang-compiled code with what the
>>(GCC-compiled) external library expects.
>>
>>This in turn leads to various crashes when using std::thread
>>in code compiled with clang, as see e.g. via the ThreadPool
>>unit tests.  See PR 26473 for an example.
>>
>>
>>Modified:
>>cfe/trunk/lib/Basic/Targets.cpp
>>cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>
>
> Mit freundlichen Gruessen / Best Regards
>
> Ulrich Weigand
>
> --
> Dr. Ulrich Weigand | Phone: +49-7031/16-3727
> STSM, GNU/Linux compilers and toolchain
> IBM Deutschland Research & Development GmbH
> Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
> Wittkopp
> Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht Stuttgart,
> HRB 243294
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16761: clang-cl: Support loading plugins on Windows

2016-02-05 Thread Ehsan Akhgari via cfe-commits
ehsan updated this revision to Diff 47057.
ehsan added a comment.

Sorry for the noise, arconist fail...


http://reviews.llvm.org/D16761

Files:
  docs/ClangPlugins.rst
  examples/PrintFunctionNames/PrintFunctionNames.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/Frontend/plugins.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin 
print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang 
%llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 
2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), 
))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: examples/PrintFunctionNames/PrintFunctionNames.cpp
===
--- examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -121,3 +121,4 @@
 
 static FrontendPluginRegistry::Add
 X("print-fns", "print function names");
+LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
Index: docs/ClangPlugins.rst
===
--- docs/ClangPlugins.rst
+++ docs/ClangPlugins.rst
@@ -37,11 +37,14 @@
 
 
 A plugin is loaded from a dynamic library at runtime by the compiler. To
-register a plugin in a library, use ``FrontendPluginRegistry::Add<>``:
+register a plugin in a library, use ``FrontendPluginRegistry::Add<>``.
+On Windows, you also need to export your plugin registry using
+``LLVM_EXPORT_REGISTRY``.  Here is an example:
 
 .. code-block:: c++
 
   static FrontendPluginRegistry::Add X("my-plugin-name", "my plugin 
description");
+  LLVM_EXPORT_REGISTRY(FrontendPluginRegistry)
 
 Putting it all together
 ===


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -196,7 +196,7 @@
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform in ['cygwin']:
 has_plugins = (config.enable_shared == 1)
 else:
 has_plugins = True
Index: test/Frontend/plugins.c
===
--- test/Frontend/plugins.c
+++ test/Frontend/plugins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s
+// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s
 // REQUIRES: plugins, examples
 
 // CHECK: top-level-decl: "x"
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -184,9 +184,16 @@
  e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
 const std::string  = Clang->getFrontendOpts().Plugins[i];
 std::string Error;
-if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), ))
+llvm::sys::DynamicLibrary DL(
+llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), ));
+if (DL.isValid()) {
+  // On Windows, we need to import the plugin front-end action
+  // dynamically.
+  LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL);
+} else {
   Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
 << Path << Error;
+}
   }
 
   // Honor -mllvm.
Index: 

Re: r259271 - Improve -Wconstant-conversion

2016-02-05 Thread Richard Trieu via cfe-commits
r259947 will stop this warning on char arrays.

On Mon, Feb 1, 2016 at 1:40 PM, Richard Trieu  wrote:

> C++11 narrowing only happens during certain conversions while this warning
> checks all conversions.
>
> We might be able to avoid char array initialization, but it would be a
> little tricky.  These warning usually have little information about where
> the conversion is coming from, so distinguishing array initialization
> versus variable initialization could be hard.
>
> On Sat, Jan 30, 2016 at 6:41 AM, Nico Weber  wrote:
>
>> Shouldn't the new case be in -Wc++11-narrowing instead? This is warning
>> in similar places where that warning used to warn.
>>
>> In practice, char arrays seem to be often used for storing binary blobs
>> in header files, and those are usually initialized with numbers 0...255
>> instead of -128...127 (why not make the array uint8_t then? Because maybe
>> the function you want to pass the data from wants a char* array, and having
>> to reinterpret_cast from uint8_t to char is annoying). Maybe this shouldn't
>> fire for char arrays?
>>
>> On Fri, Jan 29, 2016 at 6:51 PM, Richard Trieu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rtrieu
>>> Date: Fri Jan 29 17:51:16 2016
>>> New Revision: 259271
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=259271=rev
>>> Log:
>>> Improve -Wconstant-conversion
>>>
>>> Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt.
>>> EvaluateAsInt will evaluate more types of expressions than
>>> isIntegerConstantExpr.
>>>
>>> Move one case from -Wsign-conversion to -Wconstant-conversion.  The case
>>> is:
>>> 1) Source and target types are signed
>>> 2) Source type is wider than the target type
>>> 3) The source constant value is positive
>>> 4) The conversion will store the value as negative in the target.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>>> cfe/trunk/test/Sema/constant-conversion.c
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=259271=259270=259271=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan 29 17:51:16 2016
>>> @@ -7578,7 +7578,7 @@ void CheckImplicitConversion(Sema , Ex
>>>  // If the source is a constant, use a default-on diagnostic.
>>>  // TODO: this should happen for bitfield stores, too.
>>>  llvm::APSInt Value(32);
>>> -if (E->isIntegerConstantExpr(Value, S.Context)) {
>>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>>>if (S.SourceMgr.isInSystemMacro(CC))
>>>  return;
>>>
>>> @@ -7603,6 +7603,42 @@ void CheckImplicitConversion(Sema , Ex
>>>  return DiagnoseImpCast(S, E, T, CC,
>>> diag::warn_impcast_integer_precision);
>>>}
>>>
>>> +  if (TargetRange.Width == SourceRange.Width &&
>>> !TargetRange.NonNegative &&
>>> +  SourceRange.NonNegative && Source->isSignedIntegerType()) {
>>> +// Warn when doing a signed to signed conversion, warn if the
>>> positive
>>> +// source value is exactly the width of the target type, which will
>>> +// cause a negative value to be stored.
>>> +
>>> +llvm::APSInt Value;
>>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>>> +  if (!S.SourceMgr.isInSystemMacro(CC)) {
>>> +
>>> +IntegerLiteral *IntLit =
>>> +dyn_cast(E->IgnoreParenImpCasts());
>>> +
>>> +// If initializing from a constant, and the constant starts
>>> with '0',
>>> +// then it is a binary, octal, or hexadecimal.  Allow these
>>> constants
>>> +// to fill all the bits, even if there is a sign change.
>>> +if (!IntLit ||
>>> +
>>> *(S.getSourceManager().getCharacterData(IntLit->getLocStart())) !=
>>> +'0') {
>>> +
>>> +  std::string PrettySourceValue = Value.toString(10);
>>> +  std::string PrettyTargetValue =
>>> +  PrettyPrintInRange(Value, TargetRange);
>>> +
>>> +  S.DiagRuntimeBehavior(
>>> +  E->getExprLoc(), E,
>>> +  S.PDiag(diag::warn_impcast_integer_precision_constant)
>>> +  << PrettySourceValue << PrettyTargetValue <<
>>> E->getType() << T
>>> +  << E->getSourceRange() << clang::SourceRange(CC));
>>> +  return;
>>> +}
>>> +  }
>>> +}
>>> +// Fall through for non-constants to give a sign conversion warning.
>>> +  }
>>> +
>>>if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
>>>(!TargetRange.NonNegative && SourceRange.NonNegative &&
>>> SourceRange.Width == TargetRange.Width)) {
>>>
>>> Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>>> URL:
>>> 

r259947 - Exempt char array initializers from -Wconstant-converion.

2016-02-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb  5 17:02:38 2016
New Revision: 259947

URL: http://llvm.org/viewvc/llvm-project?rev=259947=rev
Log:
Exempt char array initializers from -Wconstant-converion.

Sometimes, char arrays are used as bit storage, with no difference made between
signed and unsigned char.  Thus, it is reasonable to use 0 to 255 instead of
-128 to 127 and not trigger this warning.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/constant-conversion.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=259947=259946=259947=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Feb  5 17:02:38 2016
@@ -7400,6 +7400,32 @@ static void checkObjCDictionaryLiteral(
   }
 }
 
+// Helper function to filter out cases for constant width constant conversion.
+// Don't warn on char array initialization or for non-decimal values.
+static bool isSameWidthConstantConversion(Sema , Expr *E, QualType T,
+  SourceLocation CC) {
+  // If initializing from a constant, and the constant starts with '0',
+  // then it is a binary, octal, or hexadecimal.  Allow these constants
+  // to fill all the bits, even if there is a sign change.
+  if (auto *IntLit = dyn_cast(E->IgnoreParenImpCasts())) {
+const char FirstLiteralCharacter =
+S.getSourceManager().getCharacterData(IntLit->getLocStart())[0];
+if (FirstLiteralCharacter == '0')
+  return false;
+  }
+
+  // If the CC location points to a '{', and the type is char, then assume
+  // assume it is an array initialization.
+  if (CC.isValid() && T->isCharType()) {
+const char FirstContextCharacter =
+S.getSourceManager().getCharacterData(CC)[0];
+if (FirstContextCharacter == '{')
+  return false;
+  }
+
+  return true;
+}
+
 void CheckImplicitConversion(Sema , Expr *E, QualType T,
  SourceLocation CC, bool *ICContext = nullptr) {
   if (E->isTypeDependent() || E->isValueDependent()) return;
@@ -7610,32 +7636,21 @@ void CheckImplicitConversion(Sema , Ex
 // cause a negative value to be stored.
 
 llvm::APSInt Value;
-if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
-  if (!S.SourceMgr.isInSystemMacro(CC)) {
-
-IntegerLiteral *IntLit =
-dyn_cast(E->IgnoreParenImpCasts());
-
-// If initializing from a constant, and the constant starts with '0',
-// then it is a binary, octal, or hexadecimal.  Allow these constants
-// to fill all the bits, even if there is a sign change.
-if (!IntLit ||
-*(S.getSourceManager().getCharacterData(IntLit->getLocStart())) !=
-'0') {
-
-  std::string PrettySourceValue = Value.toString(10);
-  std::string PrettyTargetValue =
-  PrettyPrintInRange(Value, TargetRange);
-
-  S.DiagRuntimeBehavior(
-  E->getExprLoc(), E,
-  S.PDiag(diag::warn_impcast_integer_precision_constant)
-  << PrettySourceValue << PrettyTargetValue << E->getType() << 
T
-  << E->getSourceRange() << clang::SourceRange(CC));
-  return;
-}
+if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects) &&
+!S.SourceMgr.isInSystemMacro(CC)) {
+  if (isSameWidthConstantConversion(S, E, T, CC)) {
+std::string PrettySourceValue = Value.toString(10);
+std::string PrettyTargetValue = PrettyPrintInRange(Value, TargetRange);
+
+S.DiagRuntimeBehavior(
+E->getExprLoc(), E,
+S.PDiag(diag::warn_impcast_integer_precision_constant)
+<< PrettySourceValue << PrettyTargetValue << E->getType() << T
+<< E->getSourceRange() << clang::SourceRange(CC));
+return;
   }
 }
+
 // Fall through for non-constants to give a sign conversion warning.
   }
 

Modified: cfe/trunk/test/Sema/constant-conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-conversion.c?rev=259947=259946=259947=diff
==
--- cfe/trunk/test/Sema/constant-conversion.c (original)
+++ cfe/trunk/test/Sema/constant-conversion.c Fri Feb  5 17:02:38 2016
@@ -110,4 +110,6 @@ void test9() {
   char macro_char_hex = CHAR_MACRO_HEX;
 #define CHAR_MACRO_DEC 255
   char macro_char_dec = CHAR_MACRO_DEC;  // expected-warning {{implicit 
conversion from 'int' to 'char' changes value from 255 to -1}}
+
+  char array_init[] = { 255, 127, 128, 129, 0 };
 }


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


[clang-tools-extra] r259949 - Add qualifiers that are about to be necessary. NFC

2016-02-05 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb  5 17:20:02 2016
New Revision: 259949

URL: http://llvm.org/viewvc/llvm-project?rev=259949=rev
Log:
Add qualifiers that are about to be necessary. NFC

Modified:
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=259949=259948=259949=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Fri Feb  5 
17:20:02 2016
@@ -334,7 +334,7 @@ bool ModularizeUtilities::collectModuleM
 // Collect referenced headers from one module.
 // Collects the headers referenced in the given module into
 // HeaderFileNames.
-bool ModularizeUtilities::collectModuleHeaders(const Module ) {
+bool ModularizeUtilities::collectModuleHeaders(const clang::Module ) {
 
   // Ignore explicit modules because they often have dependencies
   // we can't know.
@@ -345,7 +345,7 @@ bool ModularizeUtilities::collectModuleH
   DependentsVector UmbrellaDependents;
 
   // Recursively do submodules.
-  for (Module::submodule_const_iterator MI = Mod.submodule_begin(),
+  for (clang::Module::submodule_const_iterator MI = Mod.submodule_begin(),
   MIEnd = Mod.submodule_end();
   MI != MIEnd; ++MI)
 collectModuleHeaders(**MI);


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


r259910 - [Parser] Perform CachedTokens update dependent on token consumption

2016-02-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Feb  5 13:36:39 2016
New Revision: 259910

URL: http://llvm.org/viewvc/llvm-project?rev=259910=rev
Log:
[Parser] Perform CachedTokens update dependent on token consumption

In the context where we break one tok::greatergreater into two
tok::greater in order to correctly update the cached tokens; update the
CachedTokens with two tok::greater only if ParseGreaterThanInTemplateList
clients asks to consume the last token. Otherwise we only need to add
one because the second is already added later on, as a not yet cached token.

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

rdar://problem/24488367

Added:
cfe/trunk/test/Parser/objcxx14-protocol-in-template.mm
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=259910=259909=259910=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri Feb  5 13:36:39 2016
@@ -855,8 +855,12 @@ bool Parser::ParseGreaterThanInTemplateL
   RemainingToken == tok::greater && PP.IsPreviousCachedToken(PrevTok)) {
 PrevTok.setKind(RemainingToken);
 PrevTok.setLength(1);
-Token NewToks[] = {PrevTok, Tok};
-PP.ReplacePreviousCachedToken(NewToks);
+// Break tok::greatergreater into two tok::greater but only add the second
+// one in case the client asks to consume the last token.
+if (ConsumeLastToken)
+  PP.ReplacePreviousCachedToken({PrevTok, Tok});
+else
+  PP.ReplacePreviousCachedToken({PrevTok});
   }
 
   if (!ConsumeLastToken) {

Added: cfe/trunk/test/Parser/objcxx14-protocol-in-template.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objcxx14-protocol-in-template.mm?rev=259910=auto
==
--- cfe/trunk/test/Parser/objcxx14-protocol-in-template.mm (added)
+++ cfe/trunk/test/Parser/objcxx14-protocol-in-template.mm Fri Feb  5 13:36:39 
2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+template class vector {};
+@protocol P @end
+
+// expected-no-diagnostics
+
+template  void F(Functor functor) {}
+
+// Test protocol in template within lambda capture initializer context.
+void z() {
+  id x = 0;
+  (void)x;
+  F( [ x = vector{} ] {} );
+}


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


Re: [PATCH] D16906: [Parser] Perform CachedTokens update dependent on token consume request

2016-02-05 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Committed r259910


http://reviews.llvm.org/D16906



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


Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-05 Thread Vassil Vassilev via cfe-commits
I am not sure where else to put this logic if not in isSameEntity... 
Could you point me to a better place?

--Vassil
On 05/02/16 19:56, Richard Smith wrote:
On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev 
> wrote:


Good point. Do you have in mind calling
'clang::Sema::MergeVarDeclTypes' or we to just "duplicate" the
logic in clang::ASTDeclReader::mergeRedeclarable?


It's not safe to call into Sema while we're in a 
partially-deserialized state. We know the only interesting case here 
is complete versus incomplete array types, so we don't need anything 
like the complexity of MergeVarDeclTypes -- something as easy as "if 
(new type is incomplete and old type is not) set new type to old type" 
should work.


On 05/02/16 02:50, Richard Smith via cfe-commits wrote:

I suspect we'll need to do a little more than this: when we
rebuild the redeclaration chain, we should probably propagate the
complete type to later redeclarations in the same scope.
Otherwise, if we import a module that has a complete type and one
that has an incomplete type, the declaration found by name lookup
might be the one with the incomplete type, possibly resulting in
rejects-valid on code like this:

a.h:
extern int a[5];

b.h:
extern int a[];

x.cc:
#include "a.h"
#include "b.h"
int k = sizeof(a);

On Fri, Jan 22, 2016 at 11:03 AM, Yaron Keren via cfe-commits
>
wrote:

Author: yrnkrn
Date: Fri Jan 22 13:03:27 2016
New Revision: 258524

URL: http://llvm.org/viewvc/llvm-project?rev=258524=rev
Log:
Merge templated static member variables, fixes
http://llvm.org/pr26179.

Patch by Vassil Vassilev!
Reviewed by Richard Smith.


Added:
cfe/trunk/test/Modules/Inputs/PR26179/
cfe/trunk/test/Modules/Inputs/PR26179/A.h
cfe/trunk/test/Modules/Inputs/PR26179/B.h
cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
cfe/trunk/test/Modules/pr26179.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=258524=258523=258524=diff

==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jan 22
13:03:27 2016
@@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, N
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast(X)) {
 VarDecl *VarY = cast(Y);
-return (VarX->getLinkageInternal() ==
VarY->getLinkageInternal()) &&
- VarX->getASTContext().hasSameType(VarX->getType(),
VarY->getType());
+if (VarX->getLinkageInternal() ==
VarY->getLinkageInternal()) {
+  ASTContext  = VarX->getASTContext();
+  if (C.hasSameType(VarX->getType(), VarY->getType()))
+return true;
+
+  // We can get decls with different types on the redecl
chain. Eg.
+  // template  struct S { static T Var[]; };
// #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Only? happens when completing an incomplete array
type. In this case
+  // when comparing #1 and #2 we should go through their
elements types.
+  const ArrayType *VarXTy =
C.getAsArrayType(VarX->getType());
+  const ArrayType *VarYTy =
C.getAsArrayType(VarY->getType());
+  if (!VarXTy || !VarYTy)
+return false;
+  if (VarXTy->isIncompleteArrayType() ||
VarYTy->isIncompleteArrayType())
+return C.hasSameType(VarXTy->getElementType(),
VarYTy->getElementType());
+}
+return false;
   }

   // Namespaces with the same name and inlinedness match.

Added: cfe/trunk/test/Modules/Inputs/PR26179/A.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/A.h?rev=258524=auto

==
--- cfe/trunk/test/Modules/Inputs/PR26179/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/A.h Fri Jan 22
13:03:27 2016
@@ -0,0 +1,4 @@
+#include "basic_string.h"
+#include "B.h"
+
+int *p = a;

Added: cfe/trunk/test/Modules/Inputs/PR26179/B.h
URL:


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-05 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 47037.
ahatanak added a comment.

Fixed a couple of bugs:

- Make sure Capacity is a multiple of 8-byte.
- "||=" isn't a valid operator. Use "||" instead.


http://reviews.llvm.org/D16843

Files:
  lib/Sema/TypeLocBuilder.cpp
  lib/Sema/TypeLocBuilder.h
  test/SemaObjCXX/typeloc-data-alignment.mm

Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.h
===
--- lib/Sema/TypeLocBuilder.h
+++ lib/Sema/TypeLocBuilder.h
@@ -41,12 +41,13 @@
   /// The inline buffer.
   enum { BufferMaxAlignment = llvm::AlignOf::Alignment };
   llvm::AlignedCharArray InlineBuffer;
-  unsigned NumBytesAtAlign4, NumBytesAtAlign8;
+  unsigned NumBytesAtAlign4;
+  bool SeenAlign8;
 
  public:
   TypeLocBuilder()
 : Buffer(InlineBuffer.buffer), Capacity(InlineCapacity),
-  Index(InlineCapacity), NumBytesAtAlign4(0), NumBytesAtAlign8(0)
+  Index(InlineCapacity), NumBytesAtAlign4(0), SeenAlign8(false)
   {
   }
 
@@ -80,7 +81,8 @@
 LastTy = QualType();
 #endif
 Index = Capacity;
-NumBytesAtAlign4 = NumBytesAtAlign8 = 0;
+NumBytesAtAlign4 = 0;
+SeenAlign8 = false;
   }  
 
   /// \brief Tell the TypeLocBuilder that the type it is storing has been
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -43,6 +43,9 @@
 }
 
 void TypeLocBuilder::grow(size_t NewCapacity) {
+  // Make sure NewCapacity is a multiple of 8.
+  NewCapacity = llvm::alignTo(NewCapacity, 8);
+
   assert(NewCapacity > Capacity);
 
   // Allocate the new buffer and copy the old data into it.
@@ -68,66 +71,49 @@
   LastTy = T;
 #endif
 
-  assert(LocalAlignment <= BufferMaxAlignment && "Unexpected alignment");
+  assert(Capacity % 8 == 0 && "Capacity must be a multiple of 8");
+  assert(LocalSize % 4 == 0 && "LocalSize must be a multiple of 4");
+  assert(LocalAlignment <= BufferMaxAlignment &&
+ (LocalAlignment == 8 || LocalAlignment == 4 || LocalSize == 0) &&
+ "Unexpected alignment");
+
+  // Check whether there is padding at the tail of the 4-byte elements.
+  bool HasPadding = (Index + NumBytesAtAlign4) % 8;
+  bool RemoveOrInsertPadding = false;
+  unsigned RequiredCapacity = Capacity - Index + LocalSize;
+
+  // The element being pushed has to be aligned at an 8-byte boundary if its
+  // alignment is 8-byte or an 8-byte aligned element has already been pushed.
+  // In that case, make sure RequiredCapacity is a multiple of 8.
+  if ((SeenAlign8 || LocalAlignment == 8) && RequiredCapacity % 8) {
+RequiredCapacity += (HasPadding ? -4 : 4);
+RemoveOrInsertPadding = NumBytesAtAlign4 != 0;
+  }
+
+  unsigned NewCapacity = Capacity;
 
   // If we need to grow, grow by a factor of 2.
-  if (LocalSize > Index) {
-size_t RequiredCapacity = Capacity + (LocalSize - Index);
-size_t NewCapacity = Capacity * 2;
-while (RequiredCapacity > NewCapacity)
-  NewCapacity *= 2;
+  while (RequiredCapacity > NewCapacity)
+NewCapacity *= 2;
+
+  if (NewCapacity != Capacity)
 grow(NewCapacity);
-  }
 
-  // Because we're adding elements to the TypeLoc backwards, we have to
-  // do some extra work to keep everything aligned appropriately.
-  // FIXME: This algorithm is a absolute mess because every TypeLoc returned
-  // needs to be valid.  Partial TypeLocs are a terrible idea.
-  // FIXME: 4 and 8 are sufficient at the moment, but it's pretty ugly to
-  // hardcode them.
-  if (LocalAlignment == 4) {
-if (NumBytesAtAlign8 == 0) {
-  NumBytesAtAlign4 += LocalSize;
-} else {
-  unsigned Padding = NumBytesAtAlign4 % 8;
-  if (Padding == 0) {
-if (LocalSize % 8 == 0) {
-  // Everything is set: there's no padding and we don't need to add
-  // any.
-} else {
-  assert(LocalSize % 8 == 4);
-  // No existing padding; add in 4 bytes padding
-  memmove([Index - 4], [Index], NumBytesAtAlign4);
-  Index -= 4;
-}
-  } else {
-assert(Padding == 4);
-if (LocalSize % 8 == 0) {
-  // Everything is set: there's 4 bytes padding and we don't need
-  // to add any.
-} else {
-  assert(LocalSize % 8 == 4);
-  // There are 4 bytes padding, but we don't need any; remove it.
-  memmove([Index + 4], [Index], NumBytesAtAlign4);
-  Index += 4;
-}
-  }
-  NumBytesAtAlign4 += LocalSize;
-}
-  } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 

Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-05 Thread Richard Smith via cfe-commits
This belongs in ASTDeclReader::attachPreviousDecl[Impl]. That's where we
propagate data that's supposed to be consistent across a redeclaration
chain from earlier declarations to later ones.

There's another wrinkle here: we should only be propagating the type from a
previous declaration that's declared in the same scope (in particular, we
should skip over declarations declared as local extern declarations within
a function). This may in some cases require walking backwards along the
redeclaration chain to find the previous declaration that was not a local
extern declaration. That'd be observable in a case like this:

modulemap:
module A { module A1 { header "a1.h" } module A2 { header "a2.h" } }
module B { header "b.h" }

a1.h:
int a[];

b.h:
void g(int(*)[], int);
void g(int(*)[1], int) = delete;
template void f(T t) {
  extern int a[];
  g(, t);
}

a2.h:
int a[1];

x.cc:
#include "a1.h"
#include "b.h"
void h() { f(0); } // should not produce an error; type of 'a' within 'f'
should not have been updated

That example actually reveals another problem: we really don't want the
completed type to be visible unless there is a visible declaration with the
completed type. That suggests that propagating the type across the
redeclaration chain may be the wrong approach, and we should instead handle
this by changing isPreferredLookupResult (in SemaLookup.cpp) to prefer a
VarDecl with a complete type over one with an incomplete type.

On Fri, Feb 5, 2016 at 12:27 PM, Vassil Vassilev 
wrote:

> I am not sure where else to put this logic if not in isSameEntity... Could
> you point me to a better place?
> --Vassil
>
> On 05/02/16 19:56, Richard Smith wrote:
>
> On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev < 
> v.g.vassi...@gmail.com> wrote:
>
>> Good point. Do you have in mind calling 'clang::Sema::MergeVarDeclTypes'
>> or we to just "duplicate" the logic in
>> clang::ASTDeclReader::mergeRedeclarable?
>>
>
> It's not safe to call into Sema while we're in a partially-deserialized
> state. We know the only interesting case here is complete versus incomplete
> array types, so we don't need anything like the complexity of
> MergeVarDeclTypes -- something as easy as "if (new type is incomplete and
> old type is not) set new type to old type" should work.
>
>
>> On 05/02/16 02:50, Richard Smith via cfe-commits wrote:
>>
>> I suspect we'll need to do a little more than this: when we rebuild the
>> redeclaration chain, we should probably propagate the complete type to
>> later redeclarations in the same scope. Otherwise, if we import a module
>> that has a complete type and one that has an incomplete type, the
>> declaration found by name lookup might be the one with the incomplete type,
>> possibly resulting in rejects-valid on code like this:
>>
>> a.h:
>> extern int a[5];
>>
>> b.h:
>> extern int a[];
>>
>> x.cc:
>> #include "a.h"
>> #include "b.h"
>> int k = sizeof(a);
>>
>> On Fri, Jan 22, 2016 at 11:03 AM, Yaron Keren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: yrnkrn
>>> Date: Fri Jan 22 13:03:27 2016
>>> New Revision: 258524
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258524=rev
>>> Log:
>>> Merge templated static member variables, fixes http://llvm.org/pr26179.
>>>
>>> Patch by Vassil Vassilev!
>>> Reviewed by Richard Smith.
>>>
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/PR26179/
>>> cfe/trunk/test/Modules/Inputs/PR26179/A.h
>>> cfe/trunk/test/Modules/Inputs/PR26179/B.h
>>> cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
>>> cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
>>> cfe/trunk/test/Modules/pr26179.cpp
>>> Modified:
>>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>>
>>> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=258524=258523=258524=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
>>> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jan 22 13:03:27
>>> 2016
>>> @@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, N
>>>// Variables with the same type and linkage match.
>>>if (VarDecl *VarX = dyn_cast(X)) {
>>>  VarDecl *VarY = cast(Y);
>>> -return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
>>> -  VarX->getASTContext().hasSameType(VarX->getType(),
>>> VarY->getType());
>>> +if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
>>> +  ASTContext  = VarX->getASTContext();
>>> +  if (C.hasSameType(VarX->getType(), VarY->getType()))
>>> +return true;
>>> +
>>> +  // We can get decls with different types on the redecl chain. Eg.
>>> +  // template  struct S { static T Var[]; }; // #1
>>> +  // template  T S::Var[sizeof(T)]; // #2
>>> +  // 

r259916 - Do not honor explicit alignment attribute on fields for PS4.

2016-02-05 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Fri Feb  5 14:50:02 2016
New Revision: 259916

URL: http://llvm.org/viewvc/llvm-project?rev=259916=rev
Log:
Do not honor explicit alignment attribute on fields for PS4.
This change reverts r257462 for PS4 triple.

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Sema/bitfield-layout.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=259916=259915=259916=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Feb  5 14:50:02 2016
@@ -202,6 +202,9 @@ protected:
   /// zero-length bitfield.
   unsigned UseZeroLengthBitfieldAlignment : 1;
 
+  /// \brief  Whether explicit bit field alignment attributes are honored.
+  unsigned UseExplicitBitFieldAlignment : 1;
+
   /// If non-zero, specifies a fixed alignment value for bitfields that follow
   /// zero length bitfield, regardless of the zero length bitfield type.
   unsigned ZeroLengthBitfieldBoundary;
@@ -466,6 +469,12 @@ public:
 return ZeroLengthBitfieldBoundary;
   }
 
+  /// \brief Check whether explicit bitfield alignment attributes should be
+  //  honored, as in "__attribute__((aligned(2))) int b : 1;".
+  bool useExplicitBitFieldAlignment() const {
+return UseExplicitBitFieldAlignment;
+  }
+
   /// \brief Check whether this target support '\#pragma options align=mac68k'.
   bool hasAlignMac68kSupport() const {
 return HasAlignMac68kSupport;

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=259916=259915=259916=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Feb  5 14:50:02 2016
@@ -1600,7 +1600,8 @@ void ItaniumRecordLayoutBuilder::LayoutB
 (AllowPadding &&
  (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
   FieldOffset = llvm::alignTo(FieldOffset, FieldAlign);
-} else if (ExplicitFieldAlign) {
+} else if (ExplicitFieldAlign &&
+   Context.getTargetInfo().useExplicitBitFieldAlignment()) {
   // TODO: figure it out what needs to be done on targets that don't honor
   // bit-field type alignment like ARM APCS ABI.
   FieldOffset = llvm::alignTo(FieldOffset, ExplicitFieldAlign);
@@ -1612,7 +1613,8 @@ void ItaniumRecordLayoutBuilder::LayoutB
  (UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize > 
TypeSize))
   UnpackedFieldOffset =
   llvm::alignTo(UnpackedFieldOffset, UnpackedFieldAlign);
-else if (ExplicitFieldAlign)
+else if (ExplicitFieldAlign &&
+ Context.getTargetInfo().useExplicitBitFieldAlignment())
   UnpackedFieldOffset =
   llvm::alignTo(UnpackedFieldOffset, ExplicitFieldAlign);
   }

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=259916=259915=259916=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Feb  5 14:50:02 2016
@@ -66,6 +66,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   UseSignedCharForObjCBool = true;
   UseBitFieldTypeAlignment = true;
   UseZeroLengthBitfieldAlignment = false;
+  UseExplicitBitFieldAlignment = true;
   ZeroLengthBitfieldBoundary = 0;
   HalfFormat = ::APFloat::IEEEhalf;
   FloatFormat = ::APFloat::IEEEsingle;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259916=259915=259916=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb  5 14:50:02 2016
@@ -606,6 +606,10 @@ public:
 this->MaxTLSAlign = 256;
 this->UserLabelPrefix = "";
 
+// On PS4, do not honor explicit bit field alignment,
+// as in "__attribute__((aligned(2))) int b : 1;".
+this->UseExplicitBitFieldAlignment = false;
+
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86_64:

Modified: cfe/trunk/test/Sema/bitfield-layout.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield-layout.c?rev=259916=259915=259916=diff
==
--- cfe/trunk/test/Sema/bitfield-layout.c (original)
+++ cfe/trunk/test/Sema/bitfield-layout.c Fri Feb  5 14:50:02 2016
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify 

Re: [PATCH] D16574: Bug 15685 - OpenCL 'char' is not signed

2016-02-05 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

Instead of checking by division by zero, I've used _StaticAssert. Functionally 
bo change, but more understandable.


http://reviews.llvm.org/D16574



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


Re: [PATCH] D16930: Improve literal operator parameter diagnostics.

2016-02-05 Thread Richard Smith via cfe-commits
rsmith added a comment.

Thanks for tackling this!



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6889
@@ +6888,3 @@
+def err_literal_operator_invalid_param : Error<
+  "invalid literal operator parameter type %0">;
+def err_literal_operator_param : Error<

Maybe "parameter of literal operator must have type 'unsigned long long', 'long 
double', 'char', 'wchar_t', 'char16_t', or 'char32_t'"?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6895
@@ +6894,3 @@
+def err_literal_operator_defined_type : Error<
+  "cannot define a literal operator on user-defined type %0">;
+def err_literal_operator_template : Error<

on -> for ?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6897
@@ -6889,1 +6896,3 @@
+def err_literal_operator_template : Error<
+  "invalid template parameters for literal operator">;
 def err_literal_operator_extern_c : Error<

It'd be nice to say what the valid ones are here. "template parameter list for 
literal operator must be either 'char...' or 'typename T, T...'" maybe?


Comment at: lib/Sema/SemaDeclCXX.cpp:11798-11825
@@ -11798,29 +11797,30 @@
+  // Must have one or two template parameters
   if (Params->size() == 1) {
 NonTypeTemplateParmDecl *PmDecl =
   dyn_cast(Params->getParam(0));
 
 // The template parameter must be a char parameter pack.
 if (PmDecl && PmDecl->isTemplateParameterPack() &&
 Context.hasSameType(PmDecl->getType(), Context.CharTy))
-  Valid = true;
+  goto FinishedParams;
+
   } else if (Params->size() == 2) {
 TemplateTypeParmDecl *PmType =
   dyn_cast(Params->getParam(0));
 NonTypeTemplateParmDecl *PmArgs =
   dyn_cast(Params->getParam(1));
 
 // The second template parameter must be a parameter pack with the
 // first template parameter as its type.
-if (PmType && PmArgs &&
-!PmType->isTemplateParameterPack() &&
-PmArgs->isTemplateParameterPack()) {
+if (PmType && PmArgs && !PmType->isTemplateParameterPack() &&
+  PmArgs->isTemplateParameterPack()) {
   const TemplateTypeParmType *TArgs =
 PmArgs->getType()->getAs();
   if (TArgs && TArgs->getDepth() == PmType->getDepth() &&
   TArgs->getIndex() == PmType->getIndex()) {
-Valid = true;
 if (ActiveTemplateInstantiations.empty())
   Diag(FnDecl->getLocation(),
diag::ext_string_literal_operator_template);
+goto FinishedParams;
   }
 }

Factor out an `isValidLiteralOperatorTemplateParameterList` function to avoid 
the somewhat-unclear control flow via `goto` here.


Comment at: lib/Sema/SemaDeclCXX.cpp:11827-11831
@@ -11826,3 +11826,7 @@
 }
+  } else {
+Diag(TpDecl->getLocation(),
+ diag::err_literal_operator_template_with_params);
+return true;
   }
 }

Please invert the sense of the `param_size() == 0` test and move this up to the 
top, so it's right next to the condition that the diagnostic is diagnosing.


Comment at: lib/Sema/SemaDeclCXX.cpp:11846-11847
@@ +11845,4 @@
+// allowed as the only parameters.
+if (Context.hasSameType(ParamType, Context.UnsignedLongLongTy) ||
+Context.hasSameType(ParamType, Context.LongDoubleTy) ||
+Context.hasSameType(ParamType, Context.CharTy) ||

Replace these two with 
`ParamType->isSpecificBuiltinType(BuiltinType::ULongLong)` and 
`ParamType->isSpecificBuiltinType(BuiltinType::LongDouble)`.


Comment at: lib/Sema/SemaDeclCXX.cpp:11871-11874
@@ +11870,6 @@
+
+} else if (!ParamType->isBuiltinType()) {
+  Diag(Param->getSourceRange().getBegin(),
+   diag::err_literal_operator_defined_type)
+  << ParamType << Param->getSourceRange();
+

I don't think this special case is worthwhile. Merge it with the 
`_invalid_param` case.


http://reviews.llvm.org/D16930



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


Re: [PATCH] D16788: Do not honor explicit alignment attribute on fields for PS4.

2016-02-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259916: Do not honor explicit alignment attribute on fields 
for PS4. (authored by ssrivastava).

Changed prior to commit:
  http://reviews.llvm.org/D16788?vs=47026=47039#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16788

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Sema/bitfield-layout.c

Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -202,6 +202,9 @@
   /// zero-length bitfield.
   unsigned UseZeroLengthBitfieldAlignment : 1;
 
+  /// \brief  Whether explicit bit field alignment attributes are honored.
+  unsigned UseExplicitBitFieldAlignment : 1;
+
   /// If non-zero, specifies a fixed alignment value for bitfields that follow
   /// zero length bitfield, regardless of the zero length bitfield type.
   unsigned ZeroLengthBitfieldBoundary;
@@ -466,6 +469,12 @@
 return ZeroLengthBitfieldBoundary;
   }
 
+  /// \brief Check whether explicit bitfield alignment attributes should be
+  //  honored, as in "__attribute__((aligned(2))) int b : 1;".
+  bool useExplicitBitFieldAlignment() const {
+return UseExplicitBitFieldAlignment;
+  }
+
   /// \brief Check whether this target support '\#pragma options align=mac68k'.
   bool hasAlignMac68kSupport() const {
 return HasAlignMac68kSupport;
Index: cfe/trunk/test/Sema/bitfield-layout.c
===
--- cfe/trunk/test/Sema/bitfield-layout.c
+++ cfe/trunk/test/Sema/bitfield-layout.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-scei-ps4
 // expected-no-diagnostics
 #include 
 
@@ -96,9 +97,15 @@
   char c;
 };
 
+#if defined(__PS4__)
+CHECK_SIZE(struct, g0, 16);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 2);
+#else
 CHECK_SIZE(struct, g0, 32);
 CHECK_ALIGN(struct, g0, 16);
 CHECK_OFFSET(struct, g0, c, 17);
+#endif
 
 // Bit-field with explicit align smaller than normal.
 struct g1 {
@@ -109,7 +116,11 @@
 
 CHECK_SIZE(struct, g1, 4);
 CHECK_ALIGN(struct, g1, 4);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g1, c, 2);
+#else
 CHECK_OFFSET(struct, g1, c, 3);
+#endif
 
 // Same as above but without explicit align.
 struct g2 {
@@ -130,9 +141,14 @@
   char c;
 };
 
-CHECK_SIZE(struct, g3, 32);
 CHECK_ALIGN(struct, g3, 16);
+#if defined(__PS4__)
+CHECK_SIZE(struct, g3, 16);
+CHECK_OFFSET(struct, g3, c, 2);
+#else
+CHECK_SIZE(struct, g3, 32);
 CHECK_OFFSET(struct, g3, c, 17);
+#endif
 
 struct __attribute__((packed)) g4 {
   char a;
@@ -142,7 +158,11 @@
 
 CHECK_SIZE(struct, g4, 4);
 CHECK_ALIGN(struct, g4, 2);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g4, c, 2);
+#else
 CHECK_OFFSET(struct, g4, c, 3);
+#endif
 
 struct g5 {
   char : 1;
@@ -162,28 +182,44 @@
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g7, 4);
+#else
 CHECK_SIZE(struct, g7, 8);
+#endif
 CHECK_ALIGN(struct, g7, 4);
 
 struct __attribute__((packed)) g8 {
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g8, 4);
+#else
 CHECK_SIZE(struct, g8, 5);
+#endif
 CHECK_ALIGN(struct, g8, 1);
 
 struct g9 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g9, 8);
+#else
 CHECK_SIZE(struct, g9, 12);
+#endif
 CHECK_ALIGN(struct, g9, 4);
 
 struct __attribute__((packed)) g10 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g10, 6);
+#else
 CHECK_SIZE(struct, g10, 9);
+#endif
 CHECK_ALIGN(struct, g10, 1);
 
 struct g11 {
Index: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
===
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
@@ -1600,7 +1600,8 @@
 (AllowPadding &&
  (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
   FieldOffset = llvm::alignTo(FieldOffset, FieldAlign);
-} else if (ExplicitFieldAlign) {
+} else if (ExplicitFieldAlign &&
+   Context.getTargetInfo().useExplicitBitFieldAlignment()) {
   // TODO: figure it out what needs to be done on targets that don't honor
   // bit-field type alignment like ARM APCS ABI.
   FieldOffset = llvm::alignTo(FieldOffset, ExplicitFieldAlign);
@@ -1612,7 +1613,8 @@
  (UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize 

Re: [PATCH] D16873: Refactor MemRegionManager::getVarRegion to call two new functions, improving readability

2016-02-05 Thread Aleksei Sidorin via cfe-commits
a.sidorin added inline comments.


Comment at: 
llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1186
@@ +1185,3 @@
+  ///  associated with a specified globally stored, non-static local, VarDecl.
+  const MemRegion *getMemRegionGloballyStored(const VarDecl *D);
+

ariccio wrote:
> a.sidorin wrote:
> > How about make these helper functions return `const MemSpaceRegion *` to 
> > make their signatures more meaningful?
> Would that change their behavior functionally?
No, it will not change it. You will need to change `static_cast` type to `const 
MemSpaceRegion *`, however (lines 809-810). There is `const MemSpaceRegion *` 
and its children classes everywhere in return statements already.


Comment at: llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:843
@@ +842,3 @@
+const LocationContext *LC) {
+  const MemRegion *sReg = nullptr;
+

ariccio wrote:
> a.sidorin wrote:
> > `const MemSpaceRegion *StorageSpace?`
> Same question as above: Would that change their behavior functionally?
> 
> 
> (if not, then I'll happily change it)
No, this will not.


http://reviews.llvm.org/D16873



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


Re: [PATCH] D16873: Refactor MemRegionManager::getVarRegion to call two new functions, improving readability

2016-02-05 Thread Aleksei Sidorin via cfe-commits
a.sidorin added inline comments.


Comment at: llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:800
@@ -803,1 +799,3 @@
+  if (V.is())
+return V.get();
 

Oops.
Lines above should stay in the caller function or be refactored. Otherwise, 
we'll get the subregion of `V.gethttp://reviews.llvm.org/D16873



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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-02-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Still looks good.


http://reviews.llvm.org/D16113



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


[clang-tools-extra] r259879 - [clang-tdiy] Add header file extension configuration support.

2016-02-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Feb  5 05:23:59 2016
New Revision: 259879

URL: http://llvm.org/viewvc/llvm-project?rev=259879=rev
Log:
[clang-tdiy] Add header file extension configuration support.

Summary: * Add a `HeaderFileExtensions` check option in 
misc-definitions-in-headers, google-build-namespaces and 
google-global-names-in-headers.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=259879=259878=259879=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb  5 05:23:59 2016
@@ -344,11 +344,23 @@ OptionsView::OptionsView(StringRef Check
  const ClangTidyOptions::OptionMap )
 : NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions) {}
 
-std::string OptionsView::get(StringRef LocalName, std::string Default) const {
+std::string OptionsView::get(StringRef LocalName, StringRef Default) const {
   const auto  = CheckOptions.find(NamePrefix + LocalName.str());
   if (Iter != CheckOptions.end())
 return Iter->second;
   return Default;
+}
+
+std::string OptionsView::getLocalOrGlobal(StringRef LocalName,
+  StringRef Default) const {
+  auto Iter = CheckOptions.find(NamePrefix + LocalName.str());
+  if (Iter != CheckOptions.end())
+return Iter->second;
+  // Fallback to global setting, if present.
+  Iter = CheckOptions.find(LocalName.str());
+  if (Iter != CheckOptions.end())
+return Iter->second;
+  return Default;
 }
 
 void OptionsView::store(ClangTidyOptions::OptionMap ,

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=259879=259878=259879=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Fri Feb  5 05:23:59 2016
@@ -47,7 +47,15 @@ public:
   /// Reads the option with the check-local name \p LocalName from the
   /// \c CheckOptions. If the corresponding key is not present, returns
   /// \p Default.
-  std::string get(StringRef LocalName, std::string Default) const;
+  std::string get(StringRef LocalName, StringRef Default) const;
+
+  /// \brief Read a named option from the \c Context.
+  ///
+  /// Reads the option with the check-local name \p LocalName from local or
+  /// global \c CheckOptions. Gets local option first. If local is not
+  /// present, falls back to get global option. If global option is not present
+  /// either, returns Default.
+  std::string getLocalOrGlobal(StringRef LocalName, StringRef Default) const;
 
   /// \brief Read a named option from the \c Context and parse it as an 
integral
   /// type \c T.

Modified: 
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp?rev=259879=259878=259879=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp Fri 
Feb  5 05:23:59 2016
@@ -20,6 +20,24 @@ namespace tidy {
 namespace google {
 namespace readability {
 
+GlobalNamesInHeadersCheck::GlobalNamesInHeadersCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  RawStringHeaderFileExtensions(
+  Options.getLocalOrGlobal("HeaderFileExtensions", "h")) {
+  if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
+HeaderFileExtensions,
+',')) {
+llvm::errs() << "Invalid header file extension: "
+ 

Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-02-05 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259879: [clang-tdiy] Add header file extension configuration 
support. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D16113?vs=46923=47007#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16113

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidy.h
  clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/trunk/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.cpp
  clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.h

Index: clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
+++ clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
@@ -11,20 +11,32 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GLOBALNAMESINHEADERSCHECK_H
 
 #include "../ClangTidy.h"
+#include "../utils/HeaderFileExtensionsUtils.h"
 
 namespace clang {
 namespace tidy {
 namespace google {
 namespace readability {
 
-// Flag global namespace pollution in header files.
-// Right now it only triggers on using declarations and directives.
+/// Flag global namespace pollution in header files.
+/// Right now it only triggers on using declarations and directives.
+///
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a comma-separated list of filename extensions
+/// of header files (The filename extensions should not contain "." prefix).
+/// "h" by default.
+/// For extension-less header files, using an empty string or leaving an
+/// empty string between "," if there are other filename extensions.
 class GlobalNamesInHeadersCheck : public ClangTidyCheck {
 public:
-  GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  const std::string RawStringHeaderFileExtensions;
+  utils::HeaderFileExtensionsSet HeaderFileExtensions;
 };
 
 } // namespace readability
Index: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
@@ -11,23 +11,35 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
 
 #include "../ClangTidy.h"
+#include "../utils/HeaderFileExtensionsUtils.h"
 
 namespace clang {
 namespace tidy {
 namespace google {
 namespace build {
 
 /// Finds anonymous namespaces in headers.
 ///
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
+/// header files (The filename extensions should not contain "." prefix).
+/// "h,hh,hpp,hxx" by default.
+/// For extension-less header files, using an empty string or leaving an
+/// empty string between "," if there are other filename extensions.
+///
 /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namespaces#Namespaces
 ///
 /// Corresponding cpplint.py check name: 'build/namespaces'.
 class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
 public:
-  UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  const std::string RawStringHeaderFileExtensions;
+  utils::HeaderFileExtensionsSet HeaderFileExtensions;
 };
 
 } // namespace build
Index: clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
@@ -20,6 +20,24 @@
 namespace google {
 

[clang-tools-extra] r259880 - Unbreak the cmake shared build.

2016-02-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Feb  5 05:38:50 2016
New Revision: 259880

URL: http://llvm.org/viewvc/llvm-project?rev=259880=rev
Log:
Unbreak the cmake shared build.

Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=259880=259879=259880=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Fri Feb  5 
05:38:50 2016
@@ -22,4 +22,5 @@ add_clang_library(clangTidyGoogleModule
   clangLex
   clangTidy
   clangTidyReadabilityModule
+  clangTidyUtils
   )


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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-02-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A couple of post-commit comments.



Comment at: 
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h:24
@@ +23,3 @@
+///
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a comma-separated list of filename extensions

BTW, this belongs to the user-facing doc, so please move this to the .rst file. 
Same for other checks.


Comment at: 
clang-tools-extra/trunk/clang-tidy/utils/HeaderFileExtensionsUtils.cpp:53
@@ +52,3 @@
+StringRef Extension = Suffix.trim();
+for (StringRef::const_iterator it = Extension.begin();
+ it != Extension.end(); ++it) {

BTW, you should be able to use a range-based for loop.


Repository:
  rL LLVM

http://reviews.llvm.org/D16113



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


[PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-05 Thread Cong Liu via cfe-commits
congliu created this revision.
congliu added a reviewer: alexfh.
congliu added a subscriber: cfe-commits.

Addes FixItHint and updated test.

http://reviews.llvm.org/D16922

Files:
  clang-tidy/misc/VirtualNearMissCheck.cpp
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -16,16 +16,19 @@
   // overriden by this class.
   virtual void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a 
similar name and the same signature as virtual method 'Base::func'; did you 
mean to override it? [misc-virtual-near-miss]
+  // CHECK-FIXES: virtual void func();
 
   void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has 
{{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   void func22(); // Should not warn.
 
   void gunk(); // Should not warn: gunk is override.
 
   void fun();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 
'Base::func'
+  // CHECK-FIXES: void func();
 
   Derived ==(const Base &); // Should not warn: operators are ignored.
 
@@ -58,32 +61,40 @@
 
   virtual void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 
'Father::func'
+  // CHECK-FIXES: virtual void func();
 
   int methoe(int x, char **strs); // Should not warn: parameter types don't 
match.
 
   int methoe(int x);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has 
{{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x);
 
   void methof(int x, const char **strs); // Should not warn: return types 
don't match.
 
   int methoh(int x, const char **strs);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has 
{{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x, const char **strs);
 
   virtual Child *creat(int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 
'Father::create'
+  // CHECK-FIXES: virtual Child *create(int i);
 
   virtual Derived &();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has 
{{.*}} 'Father::generate'
+  // CHECK-FIXES: virtual Derived &();
 
   int decaz(const char str[]);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 
'Mother::decay'
+  // CHECK-FIXES: int decay(const char str[]);
 
   operator bool();
 
   derived_type *canonica(derived_type D);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::canonica' has 
{{.*}} 'Father::canonical'
+  // CHECK-FIXES: derived_type *canonical(derived_type D);
 
 private:
   void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 
'Father::func'
+  // CHECK-FIXES: void func();
 };
Index: clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -249,11 +249,14 @@
 if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
   if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
 // A "virtual near miss" is found.
+auto Range = CharSourceRange::getTokenRange(SourceRange(
+DerivedMD->getLocation(), DerivedMD->getLocation()));
 diag(DerivedMD->getLocStart(),
  "method '%0' has a similar name and the same signature as "
  "virtual method '%1'; did you mean to override it?")
 << DerivedMD->getQualifiedNameAsString()
-<< BaseMD->getQualifiedNameAsString();
+<< BaseMD->getQualifiedNameAsString()
+<< FixItHint::CreateReplacement(Range, BaseMD->getName());
   }
 }
   }


Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -16,16 +16,19 @@
   // overriden by this class.
   virtual void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
+  // CHECK-FIXES: virtual void func();
 
   void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   void func22(); // Should not warn.
 
   void gunk(); // Should not warn: gunk is override.
 
   void fun();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   Derived ==(const Base &); // Should not warn: operators are ignored.
 
@@ -58,32 +61,40 @@
 
   virtual void func2();
   // CHECK-MESSAGES: 

Re: [PATCH] D16517: ClangTidy check to flag uninitialized builtin and pointer fields.

2016-02-05 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D16517#336157, @flx wrote:

> In http://reviews.llvm.org/D16517#336148, @alexfh wrote:
>
> > A high-level comment: I think, this comment 
> >  still applies. I'm also slightly 
> > concerned about having this check in misc-, since the check isn't 
> > universally applicable (e.g. based on a couple of discussions, I guess LLVM 
> > community would likely not welcome this rule), but I'd like to leave misc- 
> > enabled by default. So moving the check to cppcoreguidelines- makes sense 
> > to me.
> >
> > More substantial comments later.
>
>
> Sounds good to me. If I'm reading the original comment correctly what's 
> missing would be this part:
>
> "Issue a diagnostic when constructing an object of a trivially constructible 
> type without () or {} to initialize its members. To fix: Add () or {}. "


Yes. I think, we might want to either add a separate check for this or make 
this part configurable. Adding a FIXME for now would be enough.

> Please let me know if that changes the name of the check and whether the next 
> step should be moving the check or we'll do that after a detailed review of 
> the specifics.


I'd call the check `cppcoreguidelines-pro-type-memberinit` to be consistent 
with the anchor name of this rule used in the CppCoreGuidelines document 
(https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-memberinit).
 These anchor names are usually short enough, but still quite descriptive, so 
it makes sense to use them when there are no significantly better alternatives.



Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:29
@@ +28,3 @@
+const Stmt , ASTContext ,
+std::unordered_set ) {
+  auto Matches =

Once you switch to `SmallPtrSet`, this should be changed to `SmallPtrSetImpl&`.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:104
@@ +103,3 @@
+}
+Code = Stream.str();
+// The initializer list is created, replace leading comma with colon.

That's a self-assignment, basically. Just use `Stream.flush()` or put the 
`Stream` definition into a nested scope.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:106
@@ +105,3 @@
+// The initializer list is created, replace leading comma with colon.
+if (InitializerBefore == nullptr && InitializerAfter == nullptr) {
+  Code[1] = ':';

nit: No braces around single-line `if/for` bodies.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:123
@@ +122,3 @@
+  }
+  std::vector OrderedFields;
+  OrderedFields.push_back({LastWrittenNonMemberInit, nullptr, {}});

`SmallVector`?


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:124
@@ +123,3 @@
+  std::vector OrderedFields;
+  OrderedFields.push_back({LastWrittenNonMemberInit, nullptr, {}});
+

`.emplace_back(...)`?


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:163
@@ +162,3 @@
+  const auto *Ctor = Result.Nodes.getNodeAs("ctor");
+  if (!Ctor->isUserProvided())
+return;

I'd make a local matcher for this and push this check to the matcher.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:169
@@ +168,3 @@
+
+  std::unordered_set FieldsToInit;
+  std::copy_if(MemberFields.begin(), MemberFields.end(),

This should probably use SmallPtrSet.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:170
@@ +169,3 @@
+  std::unordered_set FieldsToInit;
+  std::copy_if(MemberFields.begin(), MemberFields.end(),
+   std::inserter(FieldsToInit, FieldsToInit.end()),

Consider this as a simpler alternative with fewer dependencies:

  for (const auto  : ParentClass->fields()) {
if (fieldRequiresInit(Field))
  FieldsToInit.insert(Field);
  }

Also, might be reasonable to expand the `fieldRequiresInit` function:

  for (const auto  : ParentClass->fields()) {
if (Field->getType()->isPointerType() || Field->getType()->isBuiltinType())
  FieldsToInit.insert(Field);
  }



Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:177
@@ +176,3 @@
+  for (CXXCtorInitializer *Init : Ctor->inits()) {
+if (Init->isDelegatingInitializer())
+  return;

I think, this is superfluous. `isMemberInitializer()` should be enough.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:181
@@ +180,3 @@
+  continue;
+const FieldDecl *MemberField = Init->getMember();
+FieldsToInit.erase(MemberField);

The variable does not make code cleaner, please remove it.


Comment at: clang-tidy/misc/UninitializedFieldCheck.cpp:199
@@ +198,3 @@
+
+for (const auto *Field : FieldsToInit)
+  Builder << FixItHint::CreateInsertion(

nit: We don't 

r259884 - clang-format: Fix corner case in template detection.

2016-02-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Feb  5 08:17:16 2016
New Revision: 259884

URL: http://llvm.org/viewvc/llvm-project?rev=259884=rev
Log:
clang-format: Fix corner case in template detection.

Before:
  f(a.operator() < A > ());

After:
  f(a.operator()());

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=259884=259883=259884=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Feb  5 08:17:16 2016
@@ -250,7 +250,7 @@ bool ContinuationIndenter::mustBreak(con
   // If the return type spans multiple lines, wrap before the function name.
   if ((Current.is(TT_FunctionDeclarationName) ||
(Current.is(tok::kw_operator) && !Previous.is(tok::coloncolon))) &&
-  State.Stack.back().BreakBeforeParameter)
+  !Previous.is(tok::kw_template) && 
State.Stack.back().BreakBeforeParameter)
 return true;
 
   if (startsSegmentOfBuilderTypeCall(Current) &&

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=259884=259883=259884=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Feb  5 08:17:16 2016
@@ -42,8 +42,21 @@ public:
 
 private:
   bool parseAngle() {
-if (!CurrentToken)
+if (!CurrentToken || !CurrentToken->Previous)
+  return false;
+if (NonTemplateLess.count(CurrentToken->Previous))
   return false;
+
+const FormatToken& Previous = *CurrentToken->Previous;
+if (Previous.Previous) {
+  if (Previous.Previous->Tok.isLiteral())
+return false;
+  if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
+  (!Previous.Previous->MatchingParen ||
+   !Previous.Previous->MatchingParen->is(TT_OverloadedOperatorLParen)))
+return false;
+}
+
 FormatToken *Left = CurrentToken->Previous;
 Left->ParentBracket = Contexts.back().ContextKind;
 ScopedContextCreator ContextCreator(*this, tok::less, 10);
@@ -550,11 +563,7 @@ private:
 return false;
   break;
 case tok::less:
-  if (!NonTemplateLess.count(Tok) &&
-  (!Tok->Previous ||
-   (!Tok->Previous->Tok.isLiteral() &&
-!(Tok->Previous->is(tok::r_paren) && Contexts.size() > 1))) &&
-  parseAngle()) {
+  if (parseAngle()) {
 Tok->Type = TT_TemplateOpener;
   } else {
 Tok->Type = TT_BinaryOperator;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259884=259883=259884=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb  5 08:17:16 2016
@@ -5394,6 +5394,10 @@ TEST_F(FormatTest, UnderstandsTemplatePa
   verifyFormat("struct A::type>;");
   verifyFormat("template  struct S {};");
+  verifyFormat("f(a.operator()());");
+  verifyFormat("f(aa\n"
+   "  .template operator()());",
+   getLLVMStyleWithColumns(35));
 
   // Not template parameters.
   verifyFormat("return a < b && c > d;");


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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

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


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:20
@@ +19,3 @@
+void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
+  auto Calc = stmt(anyOf(binaryOperator(anyOf(
+ hasOperatorName("+"), hasOperatorName("-"),

It makes sense to use the closest common parent, which is `expr` here, not 
`stmt`.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:27
@@ +26,3 @@
+  auto Cast =
+  stmt(anyOf(cStyleCastExpr(has(Calc)), cxxStaticCastExpr(has(Calc)),
+ cxxReinterpretCastExpr(has(Calc

You can use `explicitCastExpr` instead of `stmt` and restructure the matcher to 
reduce code duplication:

  explicitCastExpr(anyOf(cStyleCastExpr(), cxxStaticCastExpr(),
 cxxReinterpretCastExpr()),
   has(Calc))


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:31
@@ +30,3 @@
+
+  Finder->addMatcher(returnStmt(has(Cast)), this);
+  Finder->addMatcher(varDecl(has(Cast)), this);

FYI, these matchers can be combined using `anyOf`. Not sure whether this will 
be better (readability-wise and performance-wise) or not.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:78
@@ +77,3 @@
+  const auto *Cast = Result.Nodes.getNodeAs("cast");
+  if (!Cast || Cast->getLocStart().isMacroID())
+return;

IIUC, both "cast" and "calc" are bound in non-optional branches of the matcher, 
so `Cast` and `Calc` should never be `nullptr`. Please move the `!Cast` and 
`!Calc` checks from `if`s to asserts.


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:88
@@ +87,3 @@
+
+  if (!CastType->isIntegerType() || !CalcType->isIntegerType())
+return;

You should be able to check this in the matcher (using `hasType(isInteger())` 
for the `expr` matcher and a bit more specific 
`hasDestinationType(isInteger())` for `explicitCastExpr`).


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.h:16
@@ +15,3 @@
+namespace clang {
+namespace tidy {
+

Please add `namespace misc {`. BTW, do you know the `add_new_check.py` script 
that uses the currently recommended template?


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.h:21
@@ +20,3 @@
+/// of precision then the cast is misplaced, and there can be loss of
+/// precision. Otherwise such cast is ineffective.
+class MisplacedWideningCastCheck : public ClangTidyCheck {

Please add a link to the user docs:

  // For the user-facing documentation see:
  // 
http://clang.llvm.org/extra/clang-tidy/checks/misc-misplaced-widening-cast.html

(and next time use `add_new_check.py` ;)


Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:1
@@ +1,2 @@
+.. title:: clang-tidy - misc-misplaced-widening-cast
+

If you wonder how to test the RST you write:

  1. when running cmake, specify `-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON` (you can 
also turn on `LLVM_INCLUDE_DOCS` and `CLANG_INCLUDE_DOCS`, if you wish, but 
this shouldn't be necessary)
  2. `make/ninja docs-clang-tools-html`, the results should be generated in 
"/tools/clang/tools/extra/docs/html"


Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:4
@@ +3,3 @@
+misc-misplaced-widening-cast
+==
+

nit: Please make the underline the same length as the previous line.


Comment at: test/clang-tidy/misc-misplaced-widening-cast.cpp:31
@@ +30,3 @@
+  long l;
+  // the result is a 9 bit value, there is no truncation in the implicit cast
+  l = (long)(a + 15);

Please use proper punctuation and capitalization in the comments.


http://reviews.llvm.org/D16310



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


Re: [PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

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


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:252
@@ -251,1 +251,3 @@
 // A "virtual near miss" is found.
+auto Range = CharSourceRange::getTokenRange(SourceRange(
+DerivedMD->getLocation(), DerivedMD->getLocation()));

There are two ways to make it shorter:
  * use the `getTokenRange` overload for `SourceLocation`s: 
`CharSourceRange::getTokenRange(DerivedMD->getLocation(), 
DerivedMD->getLocation());`;
  * use the `SourceRange` constructor accepting a single location: 
`CharSourceRange::getTokenRange(SourceRange(DerivedMD->getLocation()));`.

Choose whatever you like more ;)


Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:1
@@ -1,2 +1,2 @@
 // RUN: %check_clang_tidy %s misc-virtual-near-miss %t
 

Please add a test ensuring replacements are applied correctly in templates with 
multiple instantiations and in macros.


http://reviews.llvm.org/D16922



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


Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-05 Thread Akira Hatanaka via cfe-commits
I agree with you, that was actually what John suggested too.

I'll update the patch shortly.

On Fri, Feb 5, 2016 at 3:38 PM, Duncan P. N. Exon Smith <
dexonsm...@apple.com> wrote:

>
> > On 2016-Feb-04, at 18:54, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > ahatanak created this revision.
> > ahatanak added a subscriber: cfe-commits.
> >
> > The assert near CGCall.cpp:2465 is triggered because
> QualType::isObjCRetainableType() is called on different types. In
> CodeGenFunction::StartFunction, it returns true because it is called on the
> typedef marked with __attribute__((NSObject)), whereas in
> CodeGenFunction::EmitFunctionEpilog it returns false because it's called on
> the canonical type.
> >
> > To fix the assert, this patch changes the code in
> CodeGenFunction::EmitFunctionEpilog to get the function's return type from
> CodeGenFunction::CurCodeDecl or BlockInfo instead of from CGFunctionInfo.
> >
> > http://reviews.llvm.org/D16914
>
> I have a nitpick below.  (I think you should find someone that knows
> this code better than I do to sign off on this though.)
>
> > Files:
> >  lib/CodeGen/CGCall.cpp
> >  test/CodeGenObjCXX/auto-release-result-assert.mm
> >
> > Index: test/CodeGenObjCXX/auto-release-result-assert.mm
> > ===
> > --- /dev/null
> > +++ test/CodeGenObjCXX/auto-release-result-assert.mm
> > @@ -0,0 +1,35 @@
> > +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks
> -fobjc-arc -o - %s | FileCheck %s
> > +
> > +// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
> > +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> > +// CHECK: ret %struct.S1* %[[CALL]]
> > +
> > +// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
> > +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> > +// CHECK: ret %struct.S1* %[[CALL]]
> > +
> > +// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
> > +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> > +// CHECK: ret %struct.S1* %[[CALL]]
> > +
> > +struct S1;
> > +
> > +typedef __attribute__((NSObject)) struct
> __attribute__((objc_bridge(id))) S1 * S1Ref;
> > +
> > +S1Ref foo0(int);
> > +
> > +struct S2 {
> > +  S1Ref m1();
> > +};
> > +
> > +S1Ref foo1(int a) {
> > +  return foo0(a);
> > +}
> > +
> > +S1Ref S2::m1() {
> > +  return foo0(0);
> > +}
> > +
> > +S1Ref (^Block1)(void) = ^{
> > +  return foo0(0);
> > +};
> > Index: lib/CodeGen/CGCall.cpp
> > ===
> > --- lib/CodeGen/CGCall.cpp
> > +++ lib/CodeGen/CGCall.cpp
> > @@ -14,6 +14,7 @@
> >
> > #include "CGCall.h"
> > #include "ABIInfo.h"
> > +#include "CGBlocks.h"
> > #include "CGCXXABI.h"
> > #include "CGCleanup.h"
> > #include "CodeGenFunction.h"
> > @@ -2462,9 +2463,21 @@
> > // In ARC, end functions that return a retainable type with a call
> > // to objc_autoreleaseReturnValue.
> > if (AutoreleaseResult) {
> > +  QualType RT;
> > +
> > +  if (auto *FD = dyn_cast(CurCodeDecl))
> > +RT = FD->getReturnType();
> > +  else if (auto *MD = dyn_cast(CurCodeDecl))
> > +RT = MD->getReturnType();
> > +  else if (isa(CurCodeDecl))
> > +RT =
> BlockInfo->BlockExpression->getFunctionType()->getReturnType();
> > +  else
> > +llvm_unreachable("Unexpected function/method type");
>
> There's no reason for this code to run when NDEBUG, is there?
>
> > +
> > +  (void)RT;
> >   assert(getLangOpts().ObjCAutoRefCount &&
> >  !FI.isReturnsRetained() &&
> > - RetTy->isObjCRetainableType());
> > + RT->isObjCRetainableType());
>
> I think you should change this to:
> ```
> #ifndef NDEBUG
> QualType RT;
> if (...)
>RT = ...
> else if (...)
>RT = ...
> else if (...)
>RT = ...
> else
>llvm_unreachable(...);
> assert(...);
> #endif
> ```
>
> >   RV = emitAutoreleaseOfResult(*this, RV);
> > }
> >
> >
> >
> > ___
> > 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] D16613: Introduce a cmake module to figure out whether we need to link with libatomic.

2016-02-05 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added a comment.

Sorry for the early pings. In case it's not clear from Daniel's comment, 
without this patch libc++ will be broken for 32-bit MIPS CPUs. The relevant bug 
report has been nominated as a release block but we'd like to have it committed 
before the next RC.


http://reviews.llvm.org/D16613



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


LLVM buildmaster will be restarted tonight

2016-02-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


r259976 - [modules] Compress files embedded into a .pcm file, to reduce the disk usage of -fembed-all-files mode.

2016-02-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb  5 20:06:43 2016
New Revision: 259976

URL: http://llvm.org/viewvc/llvm-project?rev=259976=rev
Log:
[modules] Compress files embedded into a .pcm file, to reduce the disk usage of 
-fembed-all-files mode.

Added:
cfe/trunk/test/Modules/embed-files-compressed.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=259976=259975=259976=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Fri Feb  5 20:06:43 2016
@@ -591,9 +591,12 @@ namespace clang {
   /// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an
   /// overridden buffer.
   SM_SLOC_BUFFER_BLOB = 3,
+  /// \brief Describes a zlib-compressed blob that contains the data for
+  /// a buffer entry.
+  SM_SLOC_BUFFER_BLOB_COMPRESSED = 4,
   /// \brief Describes a source location entry (SLocEntry) for a
   /// macro expansion.
-  SM_SLOC_EXPANSION_ENTRY = 4
+  SM_SLOC_EXPANSION_ENTRY = 5
 };
 
 /// \brief Record types used within a preprocessor block.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=259976=259975=259976=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb  5 20:06:43 2016
@@ -48,6 +48,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -1203,6 +1204,32 @@ bool ASTReader::ReadSLocEntry(int ID) {
 return true;
   }
 
+  // Local helper to read the (possibly-compressed) buffer data following the
+  // entry record.
+  auto ReadBuffer = [this](
+  BitstreamCursor ,
+  StringRef Name) -> std::unique_ptr {
+RecordData Record;
+StringRef Blob;
+unsigned Code = SLocEntryCursor.ReadCode();
+unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, );
+
+if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) {
+  SmallString<0> Uncompressed;
+  if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) !=
+  llvm::zlib::StatusOK) {
+Error("could not decompress embedded file contents");
+return nullptr;
+  }
+  return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
+} else if (RecCode == SM_SLOC_BUFFER_BLOB) {
+  return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name, true);
+} else {
+  Error("AST record has invalid code");
+  return nullptr;
+}
+  };
+
   ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
   F->SLocEntryCursor.JumpToBit(F->SLocEntryOffsets[ID - F->SLocEntryBaseID]);
   BitstreamCursor  = F->SLocEntryCursor;
@@ -1258,24 +1285,16 @@ bool ASTReader::ReadSLocEntry(int ID) {
   FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
  NumFileDecls));
 }
-
+
 const SrcMgr::ContentCache *ContentCache
   = SourceMgr.getOrCreateContentCache(File,
   /*isSystemFile=*/FileCharacter != 
SrcMgr::C_User);
 if (OverriddenBuffer && !ContentCache->BufferOverridden &&
 ContentCache->ContentsEntry == ContentCache->OrigEntry &&
 !ContentCache->getRawBuffer()) {
-  unsigned Code = SLocEntryCursor.ReadCode();
-  Record.clear();
-  unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, );
-  
-  if (RecCode != SM_SLOC_BUFFER_BLOB) {
-Error("AST record has invalid code");
+  auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
+  if (!Buffer)
 return true;
-  }
-  
-  std::unique_ptr Buffer
-= llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->getName());
   SourceMgr.overrideFileContents(File, std::move(Buffer));
 }
 
@@ -1292,18 +1311,10 @@ bool ASTReader::ReadSLocEntry(int ID) {
 (F->Kind == MK_ImplicitModule || F->Kind == MK_ExplicitModule)) {
   IncludeLoc = getImportLocation(F);
 }
-unsigned Code = SLocEntryCursor.ReadCode();
-Record.clear();
-unsigned RecCode
-  = SLocEntryCursor.readRecord(Code, Record, );
 
-if (RecCode != SM_SLOC_BUFFER_BLOB) {
-  Error("AST record has invalid code");
+auto Buffer = ReadBuffer(SLocEntryCursor, Name);
+if (!Buffer)
   

r259977 - [OpenMP] Reorganize code to allow specialized code generation for different devices.

2016-02-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Feb  5 20:12:34 2016
New Revision: 259977

URL: http://llvm.org/viewvc/llvm-project?rev=259977=rev
Log:
[OpenMP] Reorganize code to allow specialized code generation for different 
devices.

Summary:
Different devices may in some cases require different code generation schemes 
in order to implement OpenMP. This is required not only for performance 
reasons, but also because it may not be possible to have the current (default) 
implementation working for these devices. E.g. GPU's cannot implement the same 
scheme a target such as powerpc or x86b would use, in the sense that it does 
not have the ability to fork threads, instead all the threads are always 
executing and need to be managed by the implementation. 

This patch proposes a reorganization of the code in the OpenMP code generation 
to pave the way to have specialized implementation of OpenMP support. More than 
a "real" patch this is more a request for comments in order to understand if 
what is proposed is acceptable or if there are better/easier ways to do it.

In this patch part of the common OpenMP codegen infrastructure is moved to a 
new file under a new namespace (CGOpenMPCommon) so it can be shared between the 
default implementation and the specialized one. When CGOpenMPRuntime is 
created, an attempt to select a specialized implementation is done.

In the patch a specialization for nvptx targets is done which currently checks 
if the target is an OpenMP device and trap if it is not. 

Let me know comments suggestions you may have.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: Hahnfeld, cfe-commits, fraggamuffin, caomhin, jholewinski

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

Added:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/target_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=259977=259976=259977=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Feb  5 20:12:34 
2016
@@ -132,7 +132,9 @@ def err_drv_no_neon_modifier : Error<"[n
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
 def err_drv_omp_host_ir_file_not_found : Error<
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
-
+def err_drv_omp_host_target_not_supported : Error<
+  "The target '%0' is not a supported OpenMP host target.">;
+  
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
dir not found; using 'ld' default search path instead">,
   InGroup;

Added: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=259977=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (added)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Feb  5 20:12:34 2016
@@ -0,0 +1,21 @@
+//=== CGOpenMPRuntimeNVPTX.cpp - Interface to OpenMP NVPTX Runtimes 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This provides a class for OpenMP runtime code generation specialized to 
NVPTX
+// targets.
+//
+//===--===//
+
+#include "CGOpenMPRuntimeNVPTX.h"
+
+using namespace clang;
+using namespace CodeGen;
+
+CGOpenMPRuntimeNVPTX::CGOpenMPRuntimeNVPTX(CodeGenModule )
+: CGOpenMPRuntime(CGM) {}

Added: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=259977=auto
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (added)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Fri Feb  5 20:12:34 2016
@@ -0,0 +1,31 @@
+//===- CGOpenMPRuntimeNVPTX.h - Interface to OpenMP NVPTX Runtimes 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:13011
@@ -12978,5 +13010,3 @@
 
-  // OpenCL 1.2 spec, s6.9 r:
-  // The event type cannot be used to declare a structure or union field.
-  if (LangOpts.OpenCL && T->isEventT()) {
-Diag(Loc, diag::err_event_t_struct_field);
+  // OpenCL v1.2 s6.9b,r & OpenCL v2.0 s6.12.5 - The following types can be 
used
+  // as structure or union field: image, sampler, event or block types.

can -> cannot
I just find I could not understand this.


Comment at: lib/Sema/SemaType.cpp:3827
@@ +3826,3 @@
+  if (LangOpts.OpenCL) {
+// OpenCL v1.2 s6.9 doesn't support variadic functions, except for
+// printf

OpenCL v1.2 s6.9 doesn't support variadic functions, except for ->OpenCL v1.2 
s6.9 - Variadic functions are not supported, 


Repository:
  rL LLVM

http://reviews.llvm.org/D16928



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


Re: [PATCH] D16876: [OpenCL] Refine pipe builtin support

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 requested a review of this revision.
pxli168 added a reviewer: rsmith.
pxli168 added a comment.

Hi Richard/Anastasia,

I replied in the commit email, and here are some explains:

1. Without the space after comma the "//" will be aligned.
2. We want generic prototypes of the builtin functions, and we generate them in 
CodeGen. So there will be no use to perform conversion in sema for the function 
prototype.
3. We used generic prototypes and varadic function declration, the conversion 
in CodeGen use cast and won't change the original type for some arguments that 
maybe used elsewhere. (Also I do not understand very clear about how to convert 
in Sema)

Thanks
Xiuli



Comment at: lib/Sema/SemaChecking.cpp:294
@@ +293,3 @@
+ diag::err_opencl_builtin_pipe_invalid_access_modifier)
+  << "read_only" << Arg0->getSourceRange();
+  return true;

Anastasia wrote:
> Anastasia wrote:
> > Could we use getName() instead?
> > 
> > We could then also move this statement after the switch and just set an 
> > error flag here.
> Just to be clear getName() of the attr instead of passing the string (i.e. 
> "read_only").
Here we need a different access qualifier then we have. I seems to complicated 
to generated a useless attribute here just for a name. 


http://reviews.llvm.org/D16876



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


r259975 - Fix a crash when emitting dbeug info for forward-declared scoped enums.

2016-02-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb  5 19:59:09 2016
New Revision: 259975

URL: http://llvm.org/viewvc/llvm-project?rev=259975=rev
Log:
Fix a crash when emitting dbeug info for forward-declared scoped enums.
It is possible for enums to be created as part of their own
declcontext. We need to cache a placeholder to avoid the type being
created twice before hitting the cache.



Added:
cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=259975=259974=259975=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb  5 19:59:09 2016
@@ -2051,13 +2051,25 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
   // If this is just a forward declaration, construct an appropriately
   // marked node and just return it.
   if (isImportedFromModule || !ED->getDefinition()) {
-llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
+
+// It is possible for enums to be created as part of their own
+// declcontext. We need to cache a placeholder to avoid the type being
+// created twice before hitting the cache.
+llvm::DIScope *EDContext = DBuilder.createReplaceableCompositeType(
+  llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0);
+
 unsigned Line = getLineNumber(ED->getLocation());
 StringRef EDName = ED->getName();
 llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, Line,
 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
+
+// Cache the enum type so it is available when building the declcontext
+// and replace the declcontect with the real thing.
+TypeCache[Ty].reset(RetTy);
+EDContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
+
 ReplaceMap.emplace_back(
 std::piecewise_construct, std::make_tuple(Ty),
 std::make_tuple(static_cast(RetTy)));

Added: cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp?rev=259975=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp Fri Feb  5 19:59:09 
2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -std=c++11 \
+// RUN:   -triple thumbv7-apple-ios %s -o - | FileCheck %s
+
+// This forward-declared scoped enum will be created while building its own
+// declcontext. Make sure it is only emitted once.
+
+struct A {
+  enum class Return;
+  Return f1();
+};
+A::Return* f2() {}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Return",
+// CHECK-SAME: flags: DIFlagFwdDecl,
+// CHECK-NOT:  tag: DW_TAG_enumeration_type, name: "Return"


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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 added a reviewer: rsmith.
pxli168 added a comment.

Hi richard,

What is your opinion about where to put this ParseOpenCLUnrollHintAttribute?

Thanks
Xiuli



Comment at: lib/Parse/ParseStmt.cpp:2214
@@ +2213,3 @@
+
+bool Parser::ParseOpenCLUnrollHintAttribute(ParsedAttributes ) {
+  MaybeParseGNUAttributes(Attrs);

Anastasia wrote:
> pxli168 wrote:
> > I am wondering where should this function goes in, here or ParseDecl.cpp.
> ParseGNUAttributes is in ParseDecl.cpp, but may be because it's generally 
> applicable to Decls?
> 
> I am not aware of any rule here.
Maybe we could ask richard for help?


http://reviews.llvm.org/D16686



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


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 47073.
pxli168 added a comment.

Make some optimization


http://reviews.llvm.org/D16040

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/Parser/opencl-image-access.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-kernel-attrs.cl

Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -28,8 +28,8 @@
 
 void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
   int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only applies to parameters}}
 }
 
 kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 -DCL20 %s
+
+void test1(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}}
+
+void test2(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+#ifdef CL20
+void test4(read_write pipe int i){} // expected-error{{access qualifier read_write can not be used for 'pipe'}}
+#else
+void test4(read_write image1d_t i){} // expected-error{{access qualifier read_write can not be used for 'image1d_t' earlier than OpenCL2.0 version}}
+#endif
Index: test/Parser/opencl-image-access.cl
===
--- test/Parser/opencl-image-access.cl
+++ test/Parser/opencl-image-access.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -fsyntax-only
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0 -DCL20
 
 __kernel void f__ro(__read_only image2d_t a) { }
 
 __kernel void f__wo(__write_only image2d_t a) { }
 
+#if CL20
 __kernel void f__rw(__read_write image2d_t a) { }
-
+#endif
 
 __kernel void fro(read_only image2d_t a) { }
 
 __kernel void fwo(write_only image2d_t a) { }
 
+#if CL20
 __kernel void frw(read_write image2d_t a) { }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6218,6 +6218,17 @@
   CurType = S.Context.getVectorType(CurType, numElts, VecKind);
 }
 
+/// Handle OpenCL Access Qualifier Attribute
+static void HandleOpenCLAccessAttr(QualType , const AttributeList ,
+   Sema ) {
+  // OpenCL v2.0 s6.6: Access Qualifier can used only for image and pipe type
+  if (!(CurType->isImageType() || CurType->isPipeType())) {
+S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier);
+Attr.setInvalid();
+return;
+  }
+}
+
 static void processTypeAttrs(TypeProcessingState , QualType ,
  TypeAttrLocation TAL, AttributeList *attrs) {
   // Scan through and apply attributes to this type where it makes sense.  Some
@@ -6313,9 +6324,8 @@
VectorType::NeonPolyVector);
   attr.setUsedAsTypeAttr();
   break;
-case AttributeList::AT_OpenCLImageAccess:
-  // FIXME: there should be some type checking happening here, I would
-  // imagine, but the original handler's checking was entirely superfluous.
+case AttributeList::AT_OpenCLAccess:
+  HandleOpenCLAccessAttr(type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
   break;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5042,6 +5042,40 @@
   return false;
 }
 
+static void handleOpenCLAccessAttr(Sema , Decl *D,
+   const AttributeList ) {
+  if (D->isInvalidDecl())
+return;
+
+  // Check if there only one access qualifier
+  if (D->hasAttr()) {
+S.Diag(D->getLocation(), diag::err_opencl_multiple_access_qualifiers)
+<< D->getSourceRange();
+D->setInvalidDecl(true);
+return;
+  }
+
+  // OpenCL v2.0 s6.6: read_write can be used for image types to specify that an
+  // image 

Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:5067
@@ +5066,3 @@
+  if (DeclTy->isPipeType() ||
+  (S.getLangOpts().OpenCLVersion < 200 && DeclTy->isImageType())) {
+S.Diag(D->getLocation(), diag::err_opencl_invalid_read_write)

Anastasia wrote:
> pxli168 wrote:
> > I used arc to update the patch and it case some line error.
> > I have check about OpenCL version here and will handle the read_write with 
> > image before OpenCL 2.0. As spec mentioned that it is reversed before 
> > OpenCL 2.0. 
> Do you think we could just check:
>   if (S.getLangOpts().OpenCLVersion < 200 || DeclTy->isPipeType())
It seems can work, but maybe mislead to others.
But with the comment above it seems ok.


http://reviews.llvm.org/D16040



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


Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-05 Thread Pete Cooper via cfe-commits
pete added a comment.

Sorry I haven't got to this sooner.  I'll try review what I can over the next 
day or two.

Saying that, i'm not experienced enough in the clang codebase to give a LGTM.  
I can comment on style, but someone else will need to give the final ok.


http://reviews.llvm.org/D16821



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


r259955 - [PGO] Test case update

2016-02-05 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Fri Feb  5 17:36:08 2016
New Revision: 259955

URL: http://llvm.org/viewvc/llvm-project?rev=259955=rev
Log:
[PGO] Test case update
 
  Temporarily relax check in test to avoid 
  breakage for format change in LLVM side. Once that is
  done, the test case will be retightened.




Modified:
cfe/trunk/test/CoverageMapping/ir.c
cfe/trunk/test/CoverageMapping/unused_names.c

Modified: cfe/trunk/test/CoverageMapping/ir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/ir.c?rev=259955=259954=259955=diff
==
--- cfe/trunk/test/CoverageMapping/ir.c (original)
+++ cfe/trunk/test/CoverageMapping/ir.c Fri Feb  5 17:36:08 2016
@@ -9,4 +9,4 @@ int main(void) {
   return 0;
 }
 
-// CHECK: @__llvm_coverage_mapping = internal constant { { i32, i32, i32, i32 
}, [2 x <{ i8*, i32, i32, i64 }>], [{{[0-9]+}} x i8] } { { i32, i32, i32, i32 } 
{ i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0 }, [2 x <{ i8*, i32, i32, i64 
}>] [<{ i8*, i32, i32, i64 }> <{ i8* getelementptr inbounds ([3 x i8], [3 x 
i8]* @__profn_foo, i32 0, i32 0), i32 3, i32 9, i64 {{[0-9]+}} }>, <{ i8*, i32, 
i32, i64 }> <{ i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_main, 
i32 0, i32 0), i32 4, i32 9, i64 {{[0-9]+}} }>]
+// CHECK: @__llvm_coverage_mapping = internal constant { { i32, i32, i32, i32 
}, [2 x <{{.*}}>], [{{[0-9]+}} x i8] } { { i32, i32, i32, i32 } { i32 2, i32 
{{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}} }, [2 x <{{.*}}>] [<{{.*}}> 
<{{.*}}>, <{{.*}}> <{{.*}}>]

Modified: cfe/trunk/test/CoverageMapping/unused_names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/unused_names.c?rev=259955=259954=259955=diff
==
--- cfe/trunk/test/CoverageMapping/unused_names.c (original)
+++ cfe/trunk/test/CoverageMapping/unused_names.c Fri Feb  5 17:36:08 2016
@@ -4,9 +4,9 @@
 
 // Since foo is never emitted, there should not be a profile name for it.
 
-// CHECK-DAG: @__profn_bar = {{.*}} [3 x i8] c"bar", section 
"{{.*}}__llvm_prf_names"
-// CHECK-DAG: @__profn_baz = {{.*}} [3 x i8] c"baz", section 
"{{.*}}__llvm_prf_names"
-// CHECK-DAG: @__profn_unused_names.c_qux = {{.*}} [18 x i8] 
c"unused_names.c:qux", section "{{.*}}__llvm_prf_names"
+// CHECK-DAG: @__profn_bar = {{.*}} [3 x i8] c"bar"
+// CHECK-DAG: @__profn_baz = {{.*}} [3 x i8] c"baz"
+// CHECK-DAG: @__profn_unused_names.c_qux = {{.*}} [18 x i8] 
c"unused_names.c:qux"
 
 // SYSHEADER-NOT: @__profn_foo =
 


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


Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-05 Thread Akira Hatanaka via cfe-commits
ahatanak added a reviewer: rjmccall.
ahatanak updated this revision to Diff 47062.
ahatanak added a comment.

Enclose the code with "#ifndef NDEBUG".


http://reviews.llvm.org/D16914

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenObjCXX/auto-release-result-assert.mm

Index: test/CodeGenObjCXX/auto-release-result-assert.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/auto-release-result-assert.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks 
-fobjc-arc -o - %s | FileCheck %s
+
+// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+struct S1;
+
+typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 * 
S1Ref;
+
+S1Ref foo0(int);
+
+struct S2 {
+  S1Ref m1();
+};
+
+S1Ref foo1(int a) {
+  return foo0(a);
+}
+
+S1Ref S2::m1() {
+  return foo0(0);
+}
+
+S1Ref (^Block1)(void) = ^{
+  return foo0(0);
+};
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "ABIInfo.h"
+#include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CodeGenFunction.h"
@@ -2462,9 +2463,22 @@
 // In ARC, end functions that return a retainable type with a call
 // to objc_autoreleaseReturnValue.
 if (AutoreleaseResult) {
+#ifndef NDEBUG
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))
+RT = FD->getReturnType();
+  else if (auto *MD = dyn_cast(CurCodeDecl))
+RT = MD->getReturnType();
+  else if (isa(CurCodeDecl))
+RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
+  else
+llvm_unreachable("Unexpected function/method type");
+
   assert(getLangOpts().ObjCAutoRefCount &&
  !FI.isReturnsRetained() &&
- RetTy->isObjCRetainableType());
+ RT->isObjCRetainableType());
+#endif
   RV = emitAutoreleaseOfResult(*this, RV);
 }
 


Index: test/CodeGenObjCXX/auto-release-result-assert.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/auto-release-result-assert.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -o - %s | FileCheck %s
+
+// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
+// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
+// CHECK: ret %struct.S1* %[[CALL]]
+
+struct S1;
+
+typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 * S1Ref;
+
+S1Ref foo0(int);
+
+struct S2 {
+  S1Ref m1();
+};
+
+S1Ref foo1(int a) {
+  return foo0(a);
+}
+
+S1Ref S2::m1() {
+  return foo0(0);
+}
+
+S1Ref (^Block1)(void) = ^{
+  return foo0(0);
+};
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -14,6 +14,7 @@
 
 #include "CGCall.h"
 #include "ABIInfo.h"
+#include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CodeGenFunction.h"
@@ -2462,9 +2463,22 @@
 // In ARC, end functions that return a retainable type with a call
 // to objc_autoreleaseReturnValue.
 if (AutoreleaseResult) {
+#ifndef NDEBUG
+  QualType RT;
+
+  if (auto *FD = dyn_cast(CurCodeDecl))
+RT = FD->getReturnType();
+  else if (auto *MD = dyn_cast(CurCodeDecl))
+RT = MD->getReturnType();
+  else if (isa(CurCodeDecl))
+RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
+  else
+llvm_unreachable("Unexpected function/method type");
+
   assert(getLangOpts().ObjCAutoRefCount &&
  !FI.isReturnsRetained() &&
- RetTy->isObjCRetainableType());
+ RT->isObjCRetainableType());
+#endif
   RV = emitAutoreleaseOfResult(*this, RV);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259967 - [www] Update analyzer website for checker-278.

2016-02-05 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Feb  5 18:53:33 2016
New Revision: 259967

URL: http://llvm.org/viewvc/llvm-project?rev=259967=rev
Log:
[www] Update analyzer website for checker-278.

Modified:
cfe/trunk/www/analyzer/latest_checker.html.incl
cfe/trunk/www/analyzer/release_notes.html

Modified: cfe/trunk/www/analyzer/latest_checker.html.incl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/latest_checker.html.incl?rev=259967=259966=259967=diff
==
--- cfe/trunk/www/analyzer/latest_checker.html.incl (original)
+++ cfe/trunk/www/analyzer/latest_checker.html.incl Fri Feb  5 18:53:33 2016
@@ -1 +1 @@
-checker-277.tar.bz2 (built 
October 28, 2015)
+checker-278.tar.bz2 (built 
February 5, 2016)

Modified: cfe/trunk/www/analyzer/release_notes.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/release_notes.html?rev=259967=259966=259967=diff
==
--- cfe/trunk/www/analyzer/release_notes.html (original)
+++ cfe/trunk/www/analyzer/release_notes.html Fri Feb  5 18:53:33 2016
@@ -14,6 +14,21 @@
 
 
 Release notes for checker-XXX builds
+checker-278
+built: February 6, 2016
+   download: checker-278.tar.bz2
+   highlights:
+   
+Greatly improves analysis of C++ lambdas, including interprocedural 
analysis of lambda applications and reduced 'dead store'
+false positives for variables captured by reference.
+The analyzer now checks for misuse of 'vfork()'. This check is enabled 
by default.
+The analyzer can now detect excessively-padded structs. This check can 
be enabled by passing the following
+command to scan-build:
+  -enable-checker optin.performance.Padding 
+The checks to detect misuse of _Nonnull are now enabled by 
default.
+The checks to detect misuse of Objective-C generics are now enabled by 
default.
+Many miscellaneous improvements.
+   
 
 checker-277
 built: October 28, 2015


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


r259969 - [www] Update analyzer release notes to correct the checker-278 build date.

2016-02-05 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Feb  5 18:59:14 2016
New Revision: 259969

URL: http://llvm.org/viewvc/llvm-project?rev=259969=rev
Log:
[www] Update analyzer release notes to correct the checker-278 build date.

This is not the future.

Modified:
cfe/trunk/www/analyzer/release_notes.html

Modified: cfe/trunk/www/analyzer/release_notes.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/release_notes.html?rev=259969=259968=259969=diff
==
--- cfe/trunk/www/analyzer/release_notes.html (original)
+++ cfe/trunk/www/analyzer/release_notes.html Fri Feb  5 18:59:14 2016
@@ -15,7 +15,7 @@
 
 Release notes for checker-XXX builds
 checker-278
-built: February 6, 2016
+built: February 5, 2016
download: checker-278.tar.bz2
highlights:



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


Re: [PATCH] D16914: [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog

2016-02-05 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-04, at 18:54, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> ahatanak created this revision.
> ahatanak added a subscriber: cfe-commits.
> 
> The assert near CGCall.cpp:2465 is triggered because 
> QualType::isObjCRetainableType() is called on different types. In 
> CodeGenFunction::StartFunction, it returns true because it is called on the 
> typedef marked with __attribute__((NSObject)), whereas in 
> CodeGenFunction::EmitFunctionEpilog it returns false because it's called on 
> the canonical type.
> 
> To fix the assert, this patch changes the code in 
> CodeGenFunction::EmitFunctionEpilog to get the function's return type from 
> CodeGenFunction::CurCodeDecl or BlockInfo instead of from CGFunctionInfo.
> 
> http://reviews.llvm.org/D16914

I have a nitpick below.  (I think you should find someone that knows
this code better than I do to sign off on this though.)

> Files:
>  lib/CodeGen/CGCall.cpp
>  test/CodeGenObjCXX/auto-release-result-assert.mm
> 
> Index: test/CodeGenObjCXX/auto-release-result-assert.mm
> ===
> --- /dev/null
> +++ test/CodeGenObjCXX/auto-release-result-assert.mm
> @@ -0,0 +1,35 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks 
> -fobjc-arc -o - %s | FileCheck %s
> +
> +// CHECK-LABEL: define %struct.S1* @_Z4foo1i(
> +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> +// CHECK: ret %struct.S1* %[[CALL]]
> +
> +// CHECK-LABEL: define %struct.S1* @_ZN2S22m1Ev(
> +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> +// CHECK: ret %struct.S1* %[[CALL]]
> +
> +// CHECK-LABEL: define internal %struct.S1* @Block1_block_invoke(
> +// CHECK: %[[CALL:[a-z0-9]+]] = call %struct.S1* @_Z4foo0i
> +// CHECK: ret %struct.S1* %[[CALL]]
> +
> +struct S1;
> +
> +typedef __attribute__((NSObject)) struct __attribute__((objc_bridge(id))) S1 
> * S1Ref;
> +
> +S1Ref foo0(int);
> +
> +struct S2 {
> +  S1Ref m1();
> +};
> +
> +S1Ref foo1(int a) {
> +  return foo0(a);
> +}
> +
> +S1Ref S2::m1() {
> +  return foo0(0);
> +}
> +
> +S1Ref (^Block1)(void) = ^{
> +  return foo0(0);
> +};
> Index: lib/CodeGen/CGCall.cpp
> ===
> --- lib/CodeGen/CGCall.cpp
> +++ lib/CodeGen/CGCall.cpp
> @@ -14,6 +14,7 @@
> 
> #include "CGCall.h"
> #include "ABIInfo.h"
> +#include "CGBlocks.h"
> #include "CGCXXABI.h"
> #include "CGCleanup.h"
> #include "CodeGenFunction.h"
> @@ -2462,9 +2463,21 @@
> // In ARC, end functions that return a retainable type with a call
> // to objc_autoreleaseReturnValue.
> if (AutoreleaseResult) {
> +  QualType RT;
> +
> +  if (auto *FD = dyn_cast(CurCodeDecl))
> +RT = FD->getReturnType();
> +  else if (auto *MD = dyn_cast(CurCodeDecl))
> +RT = MD->getReturnType();
> +  else if (isa(CurCodeDecl))
> +RT = BlockInfo->BlockExpression->getFunctionType()->getReturnType();
> +  else
> +llvm_unreachable("Unexpected function/method type");

There's no reason for this code to run when NDEBUG, is there?

> +
> +  (void)RT;
>   assert(getLangOpts().ObjCAutoRefCount &&
>  !FI.isReturnsRetained() &&
> - RetTy->isObjCRetainableType());
> + RT->isObjCRetainableType());

I think you should change this to:
```
#ifndef NDEBUG
QualType RT;
if (...)
   RT = ...
else if (...)
   RT = ...
else if (...)
   RT = ...
else
   llvm_unreachable(...);
assert(...);
#endif
```

>   RV = emitAutoreleaseOfResult(*this, RV);
> }
> 
> 
> 
> ___
> 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] D16873: Refactor MemRegionManager::getVarRegion to call two new functions, improving readability

2016-02-05 Thread Alexander Riccio via cfe-commits
ariccio marked 9 inline comments as done.
ariccio added a comment.

Whoops, I didn't //submit// my comments.



Comment at: 
llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1185
@@ +1184,3 @@
+  /// getMemRegionGloballyStored - Retrieve or create the memory region
+  ///  associated with a specified globally stored, non-static local, VarDecl.
+  const MemRegion *getMemRegionGloballyStored(const VarDecl *D);

dcoughlin wrote:
> I think describing this as taking a "globally stored, non-static local, 
> VarDecl" is ambiguous. This method operates on global variables. It does not 
> act on local variables (static or otherwise). How about "Retrieve or create 
> the memory region associated with a VarDecl for a global variable."
> 
> Also, the recommended style these days is to not prefix the doc comment with 
> the name of the member, so I would remove "getMemRegionGloballyStored - " 
> even though getVarRegion() has the same thing. The doc comment style in this 
> file is sufficiently mismatched that I think it is better to do the 
> now-recommend thing rather than try to match its surrounding context.
I like that. Done.


Comment at: 
llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1186
@@ +1185,3 @@
+  ///  associated with a specified globally stored, non-static local, VarDecl.
+  const MemRegion *getMemRegionGloballyStored(const VarDecl *D);
+

a.sidorin wrote:
> ariccio wrote:
> > a.sidorin wrote:
> > > How about make these helper functions return `const MemSpaceRegion *` to 
> > > make their signatures more meaningful?
> > Would that change their behavior functionally?
> No, it will not change it. You will need to change `static_cast` type to 
> `const MemSpaceRegion *`, however (lines 809-810). There is `const 
> MemSpaceRegion *` and its children classes everywhere in return statements 
> already.
What're the `static_cast`s for anyways? Shouldn't the `const 
StackArgumentsSpaceRegion*`s convert to `const MemRegion*` automatically?

`StackArgumentsSpaceRegion` derives from `StackSpaceRegion`:

`class StackArgumentsSpaceRegion : public StackSpaceRegion`

...`StackSpaceRegion` derives from `MemSpaceRegion`:

`class StackSpaceRegion : public MemSpaceRegion`

...and `MemSpaceRegion` derives from `MemRegion`:

`class MemSpaceRegion : public MemRegion`

...which I think should work, because of the kooky rules of covariant return 
types (or something)?


Comment at: llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:769
@@ -768,4 +768,3 @@
 
-const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
-const LocationContext *LC) {
-  const MemRegion *sReg = nullptr;
+const MemRegion* MemRegionManager::getMemRegionGloballyStored(const VarDecl 
*D) {
+  assert(D->hasGlobalStorage());

ariccio wrote:
> ariccio wrote:
> > dcoughlin wrote:
> > > a.sidorin wrote:
> > > > `get[Global/StaticLocal]MemSpaceForVariable`?
> > > The rest of the method in class follow a pattern of getAdjectiveNoun, so 
> > > I would suggest something like getGlobalVarRegion() and 
> > > getLocalVarRegion()
> > Ahh, that might make more sense. I did this refactoring without any sense 
> > of context, as the unnecessary complexity was a hindrance thereto.
> > 
> How about `getGlobalMemSpaceForGlobalVariable`? I'm hesitant to drop the 
> second global, to be clear about the scope of the variable that's stored 
> globally. Is that a reasonable concern, or is that redundant?
Whatever. I've changed the global one to `getGlobalVarRegion`.


Comment at: llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:792
@@ -783,12 +791,3 @@
 
-// Treat other globals as GlobalInternal unless they are constants.
-} else {
-  QualType GQT = D->getType();
-  const Type *GT = GQT.getTypePtrOrNull();
-  // TODO: We could walk the complex types here and see if everything is
-  // constified.
-  if (GT && GQT.isConstQualified() && GT->isArithmeticType())
-sReg = getGlobalsRegion(MemRegion::GlobalImmutableSpaceRegionKind);
-  else
-sReg = getGlobalsRegion();
-}
+const MemRegion* MemRegionManager::getMemRegionStaticLocal(const VarDecl *D, 
const LocationContext *LC) {
+  // FIXME: Once we implement scope handling, we will need to properly lookup

dcoughlin wrote:
> It looks to me like this function operates on both locals *and* static 
> locals. I would change the name to reflect that.
So, `getMemRegionStaticLocalOrLocal`?


Comment at: llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:800
@@ -803,1 +799,3 @@
+  if (V.is())
+return V.get();
 

a.sidorin wrote:
> Oops.
> Lines above should stay in the caller function or be refactored. Otherwise, 
> we'll get the subregion of `V.get directly. This looks like a behaviour change. (And this 

Re: [PATCH] D16873: Refactor MemRegionManager::getVarRegion to call two new functions, improving readability

2016-02-05 Thread Alexander Riccio via cfe-commits
ariccio marked 11 inline comments as done.
ariccio added a comment.

Marked some inline comments as done.


http://reviews.llvm.org/D16873



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


Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-02-05 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 47074.
pxli168 updated the summary for this revision.
pxli168 added a comment.

Rebase for partition


http://reviews.llvm.org/D16047

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/Parser/opencl-atomics-cl20.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-decl.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -6,3 +6,6 @@
 }
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}}
 }
+void test4() {
+  pipe int p; // expected-error {{pipe can only be used as a function parameter}}
+}
Index: test/SemaOpenCL/invalid-image.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-image.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify %s
+
+void test1(image1d_t *i){} // expected-error {{pointer to image is invalid in OpenCL}}
+
+void test2() {
+  image1d_t i; // expected-error {{image can only be used as a function parameter}}
+}
Index: test/SemaOpenCL/invalid-decl.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-decl.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 %s 
+int; // expected-error {{declaration does not declare anything}}
+
+void test1(){
+  myfun(); // expected-error {{implicit declaration of function 'myfun' is invalid in OpenCL}}
+}
Index: test/SemaOpenCL/invalid-block.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-block.cl
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s
+
+int (^BlkVariadic)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed}}
+  return 0;
+};
+
+typedef int (^BlkInt)(int);
+void f1(int i) {
+  BlkInt B1 = ^int(int I) {return 1;};
+  BlkInt B2 = ^int(int I) {return 2;};
+  BlkInt Arr[] = {B1, B2}; // expected-error {{array of block is invalid in OpenCL}}
+  int tmp = i ? B1(i)  // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+  : B2(i); // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+}
+
+void f2(BlkInt *BlockPtr) {
+  BlkInt B = ^int(int I) {return 1;};
+  BlkInt *P =  // expected-error {{invalid argument type 'BlkInt' (aka 'int (^)(int)') to unary expression}}
+  B = *BlockPtr;  // expected-error {{dereferencing pointer of type '__generic BlkInt *' (aka 'int (^__generic *)(int)') is not allowed}}
+}
+
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -56,6 +56,7 @@
 #endif
 
 #ifdef CL20
+#define ATOMIC_VAR_INIT
 void foo(atomic_int * ptr) {}
 void atomic_ops_test() {
   atomic_int i;
@@ -66,4 +67,7 @@
   i += 1; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'int')}}
   i = i + i; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}}
 }
+void atomic_init_test() {
+atomic_int guide = ATOMIC_VAR_INIT(42); // expected-error {{initialization of atomic variables is restricted to variables in global address space in opencl}}
+}
 #endif
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -35,6 +35,3 @@
   fnc4smp(glb_smp);
 // CHECK: call {{.*}}void @fnc4smp(i32
 }
-
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {}
-// CHECK-LABEL: @{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2175,6 +2175,14 @@
 Diag(Loc, diag::warn_vla_used);
   }
 
+  // OpenCL v2.0 s6.12.5 - The following Blocks features are currently not
+  // supported in OpenCL C: Arrays of Blocks.
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 &&
+  Context.getBaseElementType(T)->isBlockPointerType()) {
+Diag(Loc, diag::err_opencl_invalid_block_array);
+return QualType();
+  }
+
   return T;
 }
 
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6135,6 +6135,32 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0