[PATCH] D28451: [AVR] Add support for the 'interrupt' and 'naked' attributes

2017-02-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 87365.
dylanmckay marked 4 inline comments as done.
dylanmckay added a comment.

Remove 'Attr.setInvalid()'


https://reviews.llvm.org/D28451

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/avr/attributes/interrupt.c
  test/CodeGen/avr/attributes/signal.c
  test/Sema/avr-interrupt-attr.c
  test/Sema/avr-signal-attr.c

Index: test/Sema/avr-signal-attr.c
===
--- /dev/null
+++ test/Sema/avr-signal-attr.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only
+struct a { int b; };
+
+struct a test __attribute__((signal)); // expected-warning {{'signal' attribute only applies to functions}}
+
+__attribute__((signal(12))) void foo(void) { } // expected-error {{'signal' attribute takes no arguments}}
+
+__attribute__((signal)) void food() {}
Index: test/Sema/avr-interrupt-attr.c
===
--- /dev/null
+++ test/Sema/avr-interrupt-attr.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only
+struct a { int b; };
+
+struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}}
+
+__attribute__((interrupt(12))) void foo(void) { } // expected-error {{'interrupt' attribute takes no arguments}}
+
+__attribute__((interrupt)) void food() {}
Index: test/CodeGen/avr/attributes/signal.c
===
--- /dev/null
+++ test/CodeGen/avr/attributes/signal.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define void @foo() #0
+__attribute__((signal)) void foo(void) { }
+
+// CHECK: attributes #0 = {{{.*signal.*}}}
Index: test/CodeGen/avr/attributes/interrupt.c
===
--- /dev/null
+++ test/CodeGen/avr/attributes/interrupt.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define void @foo() #0
+__attribute__((interrupt)) void foo(void) { }
+
+// CHECK: attributes #0 = {{{.*interrupt.*}}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5126,6 +5126,32 @@
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
+static void handleAVRInterruptAttr(Sema , Decl *D, const AttributeList ) {
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "'interrupt'" << ExpectedFunction;
+return;
+  }
+
+  if (!checkAttributeNumArgs(S, Attr, 0))
+return;
+
+  handleSimpleAttribute(S, D, Attr);
+}
+
+static void handleAVRSignalAttr(Sema , Decl *D, const AttributeList ) {
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "'signal'" << ExpectedFunction;
+return;
+  }
+
+  if (!checkAttributeNumArgs(S, Attr, 0))
+return;
+
+  handleSimpleAttribute(S, D, Attr);
+}
+
 static void handleInterruptAttr(Sema , Decl *D, const AttributeList ) {
   // Dispatch the interrupt attribute based on the current target.
   switch (S.Context.getTargetInfo().getTriple().getArch()) {
@@ -5140,6 +5166,9 @@
   case llvm::Triple::x86_64:
 handleAnyX86InterruptAttr(S, D, Attr);
 break;
+  case llvm::Triple::avr:
+handleAVRInterruptAttr(S, D, Attr);
+break;
   default:
 handleARMInterruptAttr(S, D, Attr);
 break;
@@ -5700,6 +5729,9 @@
   case AttributeList::AT_AMDGPUNumVGPR:
 handleAMDGPUNumVGPRAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AVRSignal:
+handleAVRSignalAttr(S, D, Attr);
+break;
   case AttributeList::AT_IBAction:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6900,6 +6900,31 @@
 }
 
 //===--===//
+// AVR ABI Implementation.
+//===--===//
+
+namespace {
+class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  AVRTargetCodeGenInfo(CodeGenTypes )
+: TargetCodeGenInfo(new DefaultABIInfo(CGT)) { }
+
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule ) const override {
+const auto *FD = dyn_cast_or_null(D);
+if (!FD) return;
+auto *Fn = cast(GV);
+
+if (FD->getAttr())
+  Fn->addFnAttr("interrupt");
+
+if (FD->getAttr())
+  Fn->addFnAttr("signal");
+  }
+};
+}
+
+//===--===//
 // TCE 

[PATCH] D28451: [AVR] Add support for the 'interrupt' and 'naked' attributes

2017-02-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added inline comments.



Comment at: test/CodeGen/avr/attributes/interrupt.c:3
+
+// CHECK: define void @foo() #0
+__attribute__((interrupt)) void foo(void) { }

aaron.ballman wrote:
> dylanmckay wrote:
> > aaron.ballman wrote:
> > > As should this.
> > It seems like this sort of test _does_ sit in `CodeGen` - see 
> > `test/CodeGen/{arm-interrupt-attr.c|mips-interrupt-attr.c}`.
> > 
> You're correct, this test does belong here. I think I attached my comment to 
> the wrong thing (sorry about that).
No problems, thanks for the review!


https://reviews.llvm.org/D28451



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked an inline comment as done.
jbcoe added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+

Eugene.Zelenko wrote:
> aaron.ballman wrote:
> > Is this include needed?
> Will be good idea to run Include What You Use.
Fixed unnecessary include.



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:36
+void NoAssemblerCheck::check(const MatchFinder::MatchResult ) {
+  Optional ASMLocation;
+  if (const auto *ASM = Result.Nodes.getNodeAs("asm-stmt"))

aaron.ballman wrote:
> No need for this to be an `Optional`, is there?
I think optional makes intent clearer but am used to dealing with immutable 
objects.
I've changed the code to just use SourceLocation.


Repository:
  rL LLVM

https://reviews.llvm.org/D29267



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


[clang-tools-extra] r294283 - [clang-tidy] Cleanup of no-assembler check

2017-02-06 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Tue Feb  7 00:19:38 2017
New Revision: 294283

URL: http://llvm.org/viewvc/llvm-project?rev=294283=rev
Log:
[clang-tidy] Cleanup of no-assembler check

Address outstanding comments from https://reviews.llvm.org/D29267

Modified:
clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp?rev=294283=294282=294283=diff
==
--- clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp Tue Feb  7 
00:19:38 2017
@@ -10,7 +10,6 @@
 #include "NoAssemblerCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
@@ -33,7 +32,7 @@ void NoAssemblerCheck::registerMatchers(
 }
 
 void NoAssemblerCheck::check(const MatchFinder::MatchResult ) {
-  Optional ASMLocation;
+  SourceLocation ASMLocation;
   if (const auto *ASM = Result.Nodes.getNodeAs("asm-stmt"))
 ASMLocation = ASM->getAsmLoc();
   else if (const auto *ASM =
@@ -44,7 +43,7 @@ void NoAssemblerCheck::check(const Match
   else
 llvm_unreachable("Unhandled case in matcher.");
 
-  diag(*ASMLocation, "do not use inline assembler in safety-critical code");
+  diag(ASMLocation, "do not use inline assembler in safety-critical code");
 }
 
 } // namespace safety


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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

@aaron.ballman I will address post-approval comments post-commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D29267



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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: src/abort_message.cpp:25
 
-#pragma GCC visibility push(hidden)
-

EricWF wrote:
> Is this really redundant? There is an `#include ` 
> after it. Is this not going to affect those symbols?
That's a fair point. I think it's kinda unusual to wrap a header file this way 
(we don't do it for any other system headers, for example), and the header file 
in question appears to be Apple-internal, so I don't know if it's necessary. I 
can leave it in place for just the header file inclusion if you prefer, however.


https://reviews.llvm.org/D26949



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


[PATCH] D26949: [libc++abi] Clean up visibility

2017-02-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 87362.
smeenai edited the summary of this revision.
smeenai added a comment.

Addressing comments


https://reviews.llvm.org/D26949

Files:
  include/__cxxabi_config.h
  src/abort_message.cpp
  src/abort_message.h
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_handlers.cpp
  src/cxa_handlers.hpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  src/cxa_thread_atexit.cpp
  src/cxa_unexpected.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  src/private_typeinfo.cpp
  src/private_typeinfo.h
  src/stdlib_exception.cpp

Index: src/stdlib_exception.cpp
===
--- src/stdlib_exception.cpp
+++ src/stdlib_exception.cpp
@@ -9,8 +9,6 @@
 
 #include 
 
-#pragma GCC visibility push(default)
-
 namespace std
 {
 
@@ -37,5 +35,3 @@
 }
 
 }  // std
-
-#pragma GCC visibility pop
Index: src/private_typeinfo.h
===
--- src/private_typeinfo.h
+++ src/private_typeinfo.h
@@ -16,7 +16,6 @@
 #include 
 
 namespace __cxxabiv1 {
-#pragma GCC visibility push(hidden)
 
 class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {
 public:
@@ -67,7 +66,7 @@
 
 class _LIBCXXABI_TYPE_VIS __class_type_info;
 
-struct __dynamic_cast_info
+struct _LIBCXXABI_HIDDEN __dynamic_cast_info
 {
 // const data supplied to the search:
 
@@ -153,7 +152,7 @@
   has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;
 };
 
-struct __base_class_type_info
+struct _LIBCXXABI_HIDDEN __base_class_type_info
 {
 public:
 const __class_type_info* __base_type;
@@ -248,8 +247,6 @@
   _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;
 };
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
 
 #endif  // __PRIVATE_TYPEINFO_H_
Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -55,12 +55,7 @@
 #include 
 #endif
 
-namespace __cxxabiv1
-{
-
-#pragma GCC visibility push(hidden)
-
-inline
+static inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
@@ -73,6 +68,8 @@
 #endif
 }
 
+namespace __cxxabiv1
+{
 
 // __shim_type_info
 
@@ -538,9 +535,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(default)
-
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
@@ -715,9 +709,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(hidden)
-
 // Call this function when you hit a static_type which is a base (above) a dst_type.
 // Let caller know you hit a static_type.  But only start recording details if
 // this is (static_ptr, static_type) -- the node we are casting from.
@@ -1300,6 +1291,4 @@
   use_strcmp);
 }
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
Index: src/fallback_malloc.h
===
--- src/fallback_malloc.h
+++ src/fallback_malloc.h
@@ -10,21 +10,18 @@
 #ifndef _FALLBACK_MALLOC_H
 #define _FALLBACK_MALLOC_H
 
+#include "__cxxabi_config.h"
 #include  // for size_t
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 // Allocate some memory from _somewhere_
-void * __malloc_with_fallback(size_t size);
+_LIBCXXABI_HIDDEN void * __malloc_with_fallback(size_t size);
 
 // Allocate and zero-initialize memory from _somewhere_
-void * __calloc_with_fallback(size_t count, size_t size);
-
-void __free_with_fallback(void *ptr);
+_LIBCXXABI_HIDDEN void * __calloc_with_fallback(size_t count, size_t size);
 
-#pragma GCC visibility pop
+_LIBCXXABI_HIDDEN void __free_with_fallback(void *ptr);
 
 } // namespace __cxxabiv1
 
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -194,8 +194,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 void * __malloc_with_fallback(size_t size) {
 void *ptr = std::malloc(size);
 if (NULL == ptr) // if malloc fails, fall back to emergency stash
@@ -221,6 +219,4 @@
 std::free(ptr);
 }
 
-#pragma GCC visibility pop
-
 } // namespace __cxxabiv1
Index: src/cxa_unexpected.cpp
===
--- src/cxa_unexpected.cpp
+++ src/cxa_unexpected.cpp
@@ -14,14 +14,10 @@
 namespace __cxxabiv1
 {
 
-#pragma GCC visibility push(default)
-
 extern "C"
 {
 
 }
 
-#pragma GCC visibility pop
-
 }  // namespace __cxxabiv1
 
Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -20,7 +20,7 @@
 #ifndef HAVE___CXA_THREAD_ATEXIT_IMPL
   // A weak symbol is used to detect this function's presence in the C library
   // at 

[PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2017-02-06 Thread Ben Harper via Phabricator via cfe-commits
bmharper updated this revision to Diff 87361.
bmharper added a comment.

This looks a lot better IMO. Thanks @daphnediane - you should recognize the 
code ;)
The special closing paren logic inside of nestingAndIndentLevel() is indeed 
redundant now.


https://reviews.llvm.org/D21279

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9404,12 +9404,11 @@
"};",
Alignment);
 
-  // FIXME: Should align all three assignments
   verifyFormat(
   "int i  = 1;\n"
   "SomeType a = SomeFunction(looongParameterA,\n"
   "  loongParameterB);\n"
-  "int j = 2;",
+  "int j  = 2;",
   Alignment);
 
   verifyFormat("template  2) ? 3 : 4);\n"
"float b[1][] = {{3.f}};\n",
Alignment);
+  verifyFormat("for (int i = 0; i < 1; i++)\n"
+   "  int x = 1;\n",
+   Alignment);
+  verifyFormat("for (i = 0; i < 1; i++)\n"
+   "  x = 1;\n"
+   "y = 1;\n",
+   Alignment);
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
@@ -9491,7 +9497,57 @@
"unsigned oneTwoThree = 123;\n"
"int oneTwo = 12;",
Alignment));
+  // Function prototype alignment
+  verifyFormat("inta();\n"
+   "double b();",
+   Alignment);
+  verifyFormat("inta(int x);\n"
+   "double b();",
+   Alignment);
+  unsigned OldColumnLimit = Alignment.ColumnLimit;
+  // We need to set ColumnLimit to zero, in order to stress nested alignments,
+  // otherwise the function parameters will be re-flowed onto a single line.
+  Alignment.ColumnLimit = 0;
+  EXPECT_EQ("inta(int   x,\n"
+" float y);\n"
+"double b(intx,\n"
+" double y);",
+format("int a(int x,\n"
+   " float y);\n"
+   "double b(int x,\n"
+   " double y);",
+   Alignment));
+  // This ensures that function parameters of function declarations are
+  // correctly indented when their owning functions are indented.
+  // The failure case here is for 'double y' to not be indented enough.
+  EXPECT_EQ("double a(int x);\n"
+"intb(inty,\n"
+" double z);",
+format("double a(int x);\n"
+   "int b(int y,\n"
+   " double z);",
+   Alignment));
+  // Set ColumnLimit low so that we induce wrapping immediately after
+  // the function name and opening paren.
+  Alignment.ColumnLimit = 13;
+  verifyFormat("int function(\n"
+   "int  x,\n"
+   "bool y);",
+   Alignment);
+  Alignment.ColumnLimit = OldColumnLimit;
+  // Ensure function pointers don't screw up recursive alignment
+  verifyFormat("inta(int x, void (*fp)(int y));\n"
+   "double b();",
+   Alignment);
   Alignment.AlignConsecutiveAssignments = true;
+  // Ensure recursive alignment is broken by function braces, so that the
+  // "a = 1" does not align with subsequent assignments inside the function
+  // body.
+  verifyFormat("int func(int a = 1) {\n"
+   "  int b  = 2;\n"
+   "  int cc = 3;\n"
+   "}",
+   Alignment);
   verifyFormat("float  something = 2000;\n"
"double another   = 911;\n"
"inti = 1, j = 10;\n"
@@ -9501,6 +9557,28 @@
   verifyFormat("int  oneTwoThree = {0}; // comment\n"
"unsigned oneTwo  = 0;   // comment",
Alignment);
+  // Make sure that scope is correctly tracked, in the absence of braces
+  verifyFormat("for (int i = 0; i < n; i++)\n"
+   "  j = i;\n"
+   "double x = 1;\n",
+   Alignment);
+  verifyFormat("if (int i = 0)\n"
+   "  j = i;\n"
+   "double x = 1;\n",
+   Alignment);
+  // Ensure operator[] and operator() are comprehended
+  verifyFormat("struct test {\n"
+   "  long long int foo();\n"
+   "  int   operator[](int a);\n"
+   "  doublebar();\n"
+   "};\n",
+   Alignment);
+  verifyFormat("struct test {\n"
+   "  long long int foo();\n"
+   "  int   operator()(int a);\n"
+   "  doublebar();\n"
+   "};\n",
+   Alignment);
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"
 "  int * j   = 2;\n"
@@ -9602,17 +9680,16 @@
Alignment);
   

[PATCH] D29162: AMDGPU: Add a test checking alignments of emitted globals/allocas

2017-02-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r294278


https://reviews.llvm.org/D29162



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


r294278 - AMDGPU: Add a test checking alignments of emitted globals/allocas

2017-02-06 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Feb  6 22:28:02 2017
New Revision: 294278

URL: http://llvm.org/viewvc/llvm-project?rev=294278=rev
Log:
AMDGPU: Add a test checking alignments of emitted globals/allocas

Make sure the spec required type alignments are used in preparation
for a possible change which may break this.

Added:
cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl

Added: cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl?rev=294278=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-alignment.cl Mon Feb  6 22:28:02 2017
@@ -0,0 +1,522 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -disable-llvm-passes 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+typedef char __attribute__((ext_vector_type(2))) char2;
+typedef char __attribute__((ext_vector_type(3))) char3;
+typedef char __attribute__((ext_vector_type(4))) char4;
+typedef char __attribute__((ext_vector_type(8))) char8;
+typedef char __attribute__((ext_vector_type(16))) char16;
+
+typedef short __attribute__((ext_vector_type(2))) short2;
+typedef short __attribute__((ext_vector_type(3))) short3;
+typedef short __attribute__((ext_vector_type(4))) short4;
+typedef short __attribute__((ext_vector_type(8))) short8;
+typedef short __attribute__((ext_vector_type(16))) short16;
+
+typedef int __attribute__((ext_vector_type(2))) int2;
+typedef int __attribute__((ext_vector_type(3))) int3;
+typedef int __attribute__((ext_vector_type(4))) int4;
+typedef int __attribute__((ext_vector_type(8))) int8;
+typedef int __attribute__((ext_vector_type(16))) int16;
+
+typedef long __attribute__((ext_vector_type(2))) long2;
+typedef long __attribute__((ext_vector_type(3))) long3;
+typedef long __attribute__((ext_vector_type(4))) long4;
+typedef long __attribute__((ext_vector_type(8))) long8;
+typedef long __attribute__((ext_vector_type(16))) long16;
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+typedef half __attribute__((ext_vector_type(3))) half3;
+typedef half __attribute__((ext_vector_type(4))) half4;
+typedef half __attribute__((ext_vector_type(8))) half8;
+typedef half __attribute__((ext_vector_type(16))) half16;
+
+typedef float __attribute__((ext_vector_type(2))) float2;
+typedef float __attribute__((ext_vector_type(3))) float3;
+typedef float __attribute__((ext_vector_type(4))) float4;
+typedef float __attribute__((ext_vector_type(8))) float8;
+typedef float __attribute__((ext_vector_type(16))) float16;
+
+typedef double __attribute__((ext_vector_type(2))) double2;
+typedef double __attribute__((ext_vector_type(3))) double3;
+typedef double __attribute__((ext_vector_type(4))) double4;
+typedef double __attribute__((ext_vector_type(8))) double8;
+typedef double __attribute__((ext_vector_type(16))) double16;
+
+// CHECK: @local_memory_alignment_global.lds_i8 = internal addrspace(3) global 
[4 x i8] undef, align 1
+// CHECK: @local_memory_alignment_global.lds_v2i8 = internal addrspace(3) 
global [4 x <2 x i8>] undef, align 2
+// CHECK: @local_memory_alignment_global.lds_v3i8 = internal addrspace(3) 
global [4 x <3 x i8>] undef, align 4
+// CHECK: @local_memory_alignment_global.lds_v4i8 = internal addrspace(3) 
global [4 x <4 x i8>] undef, align 4
+// CHECK: @local_memory_alignment_global.lds_v8i8 = internal addrspace(3) 
global [4 x <8 x i8>] undef, align 8
+// CHECK: @local_memory_alignment_global.lds_v16i8 = internal addrspace(3) 
global [4 x <16 x i8>] undef, align 16
+// CHECK: @local_memory_alignment_global.lds_i16 = internal addrspace(3) 
global [4 x i16] undef, align 2
+// CHECK: @local_memory_alignment_global.lds_v2i16 = internal addrspace(3) 
global [4 x <2 x i16>] undef, align 4
+// CHECK: @local_memory_alignment_global.lds_v3i16 = internal addrspace(3) 
global [4 x <3 x i16>] undef, align 8
+// CHECK: @local_memory_alignment_global.lds_v4i16 = internal addrspace(3) 
global [4 x <4 x i16>] undef, align 8
+// CHECK: @local_memory_alignment_global.lds_v8i16 = internal addrspace(3) 
global [4 x <8 x i16>] undef, align 16
+// CHECK: @local_memory_alignment_global.lds_v16i16 = internal addrspace(3) 
global [4 x <16 x i16>] undef, align 32
+// CHECK: @local_memory_alignment_global.lds_i32 = internal addrspace(3) 
global [4 x i32] undef, align 4
+// CHECK: @local_memory_alignment_global.lds_v2i32 = internal addrspace(3) 
global [4 x <2 x i32>] undef, align 8
+// CHECK: @local_memory_alignment_global.lds_v3i32 = internal addrspace(3) 
global [4 x <3 x i32>] undef, align 16
+// CHECK: @local_memory_alignment_global.lds_v4i32 = internal addrspace(3) 
global [4 x <4 x i32>] undef, align 16
+// CHECK: @local_memory_alignment_global.lds_v8i32 = internal addrspace(3) 
global [4 x <8 x i32>] undef, align 32

Buildbot numbers for the week of 01/22/2017 - 01/28/2017

2017-02-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 01/22/2017 - 01/28/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 sanitizer-x86_64-linux | 110:22:30
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 91:21:29
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 84:15:58
 perf-x86_64-penryn-O3  | 82:05:43
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 78:52:21
 perf-x86_64-penryn-O3-polly| 78:50:42
 perf-x86_64-penryn-O3-polly-unprofitable   | 78:26:52
 perf-x86_64-penryn-O3-polly-parallel-fast  | 78:16:50
 perf-x86_64-penryn-O3-polly-fast   | 76:27:45
 lldb-windows7-android  | 60:49:15
 libomp-ompt-clang-x86_64-linux-debian  | 37:19:35
 sanitizer-x86_64-linux-fuzzer  | 33:33:24
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 24:51:08
 clang-ppc64be-linux-multistage | 24:45:54
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 24:42:10
 clang-ppc64le-linux-lnt| 24:28:20
 clang-ppc64be-linux| 23:19:28
 clang-ppc64le-linux| 23:06:43
 sanitizer-ppc64le-linux| 22:56:24
 sanitizer-ppc64be-linux| 22:28:03
 clang-ppc64be-linux-lnt| 22:26:44
 clang-cmake-aarch64-lld| 19:27:24
 sanitizer-x86_64-linux-bootstrap   | 18:40:55
 sanitizer-x86_64-linux-autoconf| 18:02:36
 clang-cmake-armv7-a15-selfhost | 14:23:03
 sanitizer-x86_64-linux-fast| 14:01:37
 clang-cuda-build   | 13:35:48
 clang-native-aarch64-full  | 13:29:54
 clang-cmake-armv7-a15-full | 12:27:04
 clang-cmake-armv7-a15  | 12:20:14
 clang-hexagon-elf  | 12:05:20
 llvm-hexagon-elf   | 12:04:32
 clang-cmake-aarch64-42vma  | 12:04:00
 clang-cmake-aarch64-39vma  | 12:03:42
 clang-cmake-aarch64-quick  | 12:03:22
 clang-cmake-thumbv7-a15-full-sh| 12:01:47
 clang-cmake-thumbv7-a15| 11:59:35
 clang-cmake-armv7-a15-selfhost-neon| 11:37:03
 clang-cmake-aarch64-full   | 11:31:15
 clang-with-lto-ubuntu  | 09:05:58
 clang-x64-ninja-win7   | 08:41:46
 clang-x86_64-debian-fast   | 08:34:02
 clang-x86_64-linux-selfhost-modules| 08:14:36
 clang-with-thin-lto-ubuntu | 08:01:05
 clang-native-arm-lnt   | 07:57:44
 lld-x86_64-darwin13| 07:23:46
 lld-x86_64-win7| 07:22:20
 lld-x86_64-freebsd | 07:17:15
 clang-bpf-build| 06:45:17
 clang-lld-x86_64-2stage| 06:33:25
 clang-x86-windows-msvc2015 | 05:10:49
 lldb-amd64-ninja-netbsd7   | 04:58:55
 lldb-x86_64-ubuntu-14.04-android   | 04:39:10
 polly-amd64-linux  | 04:19:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 04:16:57
 clang-s390x-linux  | 04:14:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 04:10:06
 libcxx-libcxxabi-libunwind-arm-linux   | 03:56:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 03:54:00
 

buildbot numbers for the week of 01/15/2017 - 01/21/2017

2017-02-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 01/15/2017 - 01/21/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-3stage-ubuntu| 68:57:56
 sanitizer-x86_64-linux | 66:57:59
 llvm-sphinx-docs   | 52:51:07
 clang-ppc64be-linux-multistage | 38:21:54
 clang-ppc64be-linux-lnt| 36:03:16
 clang-x64-ninja-win7   | 31:23:47
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 30:10:03
 clang-x86-windows-msvc2015 | 29:51:13
 sanitizer-x86_64-linux-fuzzer  | 29:34:25
 lld-x86_64-win7| 24:16:13
 clang-cmake-thumbv7-a15-full-sh| 19:37:35
 sanitizer-x86_64-linux-fast| 13:41:12
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions  | 13:37:16
 sanitizer-x86_64-linux-bootstrap   | 13:26:39
 lldb-windows7-android  | 10:55:24
 perf-x86_64-penryn-O3-polly| 10:41:08
 clang-cmake-aarch64-lld| 09:35:35
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 09:21:02
 sanitizer-ppc64be-linux| 06:40:40
 perf-x86_64-penryn-O3-polly-parallel-fast  | 06:00:57
 lldb-x86_64-darwin-13.4| 05:47:22
 lldb-x86_64-ubuntu-14.04-android   | 05:46:09
 perf-x86_64-penryn-O3-polly-unprofitable   | 05:22:06
 libcxx-libcxxabi-x86_64-linux-debian   | 04:57:18
 clang-cmake-aarch64-full   | 04:53:32
 lldb-x86_64-ubuntu-14.04-buildserver   | 03:49:05
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions  | 03:46:25
 clang-cmake-armv7-a15-selfhost-neon| 03:15:56
 clang-cmake-armv7-a15-selfhost | 03:13:01
 clang-cmake-aarch64-quick  | 03:10:30
 clang-cmake-armv7-a15-full | 03:07:35
 clang-lld-x86_64-2stage| 02:58:45
 clang-with-thin-lto-ubuntu | 02:41:36
 clang-with-lto-ubuntu  | 02:27:18
 clang-x86_64-linux-selfhost-modules-2  | 02:18:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 01:56:49
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 01:53:54
 clang-ppc64le-linux| 01:51:42
 sanitizer-ppc64le-linux| 01:51:28
 llvm-avr-linux | 01:36:35
 clang-x86_64-linux-selfhost-modules| 01:25:08
 clang-cuda-build   | 01:23:49
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions  | 01:22:32
 libcxx-libcxxabi-libunwind-arm-linux   | 01:22:30
 libcxx-libcxxabi-libunwind-aarch64-linux   | 01:22:15
 lldb-amd64-ninja-netbsd7   | 01:19:27
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 01:08:49
 polly-arm-linux| 01:04:14
 llvm-hexagon-elf   | 01:04:00
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 01:02:42
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 01:00:28
 polly-amd64-linux  | 00:57:26
 sanitizer-x86_64-linux-autoconf| 00:53:34
 lld-x86_64-freebsd | 00:52:49
 clang-hexagon-elf  | 00:52:42
 sanitizer-windows  | 00:51:10
 clang-bpf-build| 00:49:58
 clang-cmake-armv7-a15  | 00:49:19
 clang-cmake-aarch64-42vma  | 00:47:32
 clang-x86_64-debian-fast 

LLBM master is back to work

2017-02-06 Thread Galina Kistanova via cfe-commits
LLBM master is back to work now.

Thanks

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


[PATCH] D29545: Driver: Do not link safestack with --whole-archive.

2017-02-06 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294274: Driver: Do not link safestack with --whole-archive. 
(authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D29545?vs=87106=87358#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29545

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/sanitizer-ld.c


Index: cfe/trunk/test/Driver/sanitizer-ld.c
===
--- cfe/trunk/test/Driver/sanitizer-ld.c
+++ cfe/trunk/test/Driver/sanitizer-ld.c
@@ -416,7 +416,9 @@
 //
 // CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-SAFESTACK-LINUX-NOT: "-lc"
+// CHECK-SAFESTACK-LINUX-NOT: whole-archive
 // CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-LINUX: "-u" "__safestack_init"
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3365,8 +3365,10 @@
 if (SanArgs.linkCXXRuntimes())
   StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
-  if (SanArgs.needsSafeStackRt())
-StaticRuntimes.push_back("safestack");
+  if (SanArgs.needsSafeStackRt()) {
+NonWholeStaticRuntimes.push_back("safestack");
+RequiredSymbols.push_back("__safestack_init");
+  }
   if (SanArgs.needsCfiRt())
 StaticRuntimes.push_back("cfi");
   if (SanArgs.needsCfiDiagRt()) {
@@ -3417,7 +3419,7 @@
   if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic)
 CmdArgs.push_back("-export-dynamic-symbol=__cfi_check");
 
-  return !StaticRuntimes.empty();
+  return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,


Index: cfe/trunk/test/Driver/sanitizer-ld.c
===
--- cfe/trunk/test/Driver/sanitizer-ld.c
+++ cfe/trunk/test/Driver/sanitizer-ld.c
@@ -416,7 +416,9 @@
 //
 // CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-SAFESTACK-LINUX-NOT: "-lc"
+// CHECK-SAFESTACK-LINUX-NOT: whole-archive
 // CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-LINUX: "-u" "__safestack_init"
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3365,8 +3365,10 @@
 if (SanArgs.linkCXXRuntimes())
   StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
-  if (SanArgs.needsSafeStackRt())
-StaticRuntimes.push_back("safestack");
+  if (SanArgs.needsSafeStackRt()) {
+NonWholeStaticRuntimes.push_back("safestack");
+RequiredSymbols.push_back("__safestack_init");
+  }
   if (SanArgs.needsCfiRt())
 StaticRuntimes.push_back("cfi");
   if (SanArgs.needsCfiDiagRt()) {
@@ -3417,7 +3419,7 @@
   if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic)
 CmdArgs.push_back("-export-dynamic-symbol=__cfi_check");
 
-  return !StaticRuntimes.empty();
+  return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r294274 - Driver: Do not link safestack with --whole-archive.

2017-02-06 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Feb  6 21:21:57 2017
New Revision: 294274

URL: http://llvm.org/viewvc/llvm-project?rev=294274=rev
Log:
Driver: Do not link safestack with --whole-archive.

This allows it to be used with the other sanitizers.

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=294274=294273=294274=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Feb  6 21:21:57 2017
@@ -3365,8 +3365,10 @@ collectSanitizerRuntimes(const ToolChain
 if (SanArgs.linkCXXRuntimes())
   StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
-  if (SanArgs.needsSafeStackRt())
-StaticRuntimes.push_back("safestack");
+  if (SanArgs.needsSafeStackRt()) {
+NonWholeStaticRuntimes.push_back("safestack");
+RequiredSymbols.push_back("__safestack_init");
+  }
   if (SanArgs.needsCfiRt())
 StaticRuntimes.push_back("cfi");
   if (SanArgs.needsCfiDiagRt()) {
@@ -3417,7 +3419,7 @@ static bool addSanitizerRuntimes(const T
   if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic)
 CmdArgs.push_back("-export-dynamic-symbol=__cfi_check");
 
-  return !StaticRuntimes.empty();
+  return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=294274=294273=294274=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Mon Feb  6 21:21:57 2017
@@ -416,7 +416,9 @@
 //
 // CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-SAFESTACK-LINUX-NOT: "-lc"
+// CHECK-SAFESTACK-LINUX-NOT: whole-archive
 // CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-LINUX: "-u" "__safestack_init"
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 


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


Re: LLVM buildmaster is unavailable due to power outage in our area

2017-02-06 Thread Galina Kistanova via cfe-commits
It does not make much difference but it's ATT network outage not power.

Thanks

Galina


On Mon, Feb 6, 2017 at 6:19 PM, Galina Kistanova 
wrote:

> Hello everyone,
>
> LLVM buildmaster is unavailable currently due to power outage in our area.
> Thank you for understanding.
>
> Thanks
>
> Galina
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r294270 - filesystem: return the constructed object

2017-02-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Feb  6 20:46:59 2017
New Revision: 294270

URL: http://llvm.org/viewvc/llvm-project?rev=294270=rev
Log:
filesystem: return the constructed object

This really should get identified properly by the compiler to convert to
a NVRO, but compress the code anyways.  This makes the implementation
identical to directory_iterator.cpp

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=294270=294269=294270=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Mon Feb  6 20:46:59 
2017
@@ -35,12 +35,9 @@ namespace detail { namespace  {
 using value_type = path::value_type;
 using string_type = path::string_type;
 
-
-
 inline std::error_code capture_errno() {
-_LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
-std::error_code m_ec(errno, std::generic_category());
-return m_ec;
+  _LIBCPP_ASSERT(errno, "Expected errno to be non-zero");
+  return std::error_code(errno, std::generic_category());
 }
 
 void set_or_throw(std::error_code const& m_ec, std::error_code* ec,


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


LLVM buildmaster is unavailable due to power outage in our area

2017-02-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster is unavailable currently due to power outage in our area.
Thank you for understanding.

Thanks

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


r294266 - P0091R3: Implement basic parsing support for C++17 deduction-guides.

2017-02-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Feb  6 19:37:30 2017
New Revision: 294266

URL: http://llvm.org/viewvc/llvm-project?rev=294266=rev
Log:
P0091R3: Implement basic parsing support for C++17 deduction-guides.

We model deduction-guides as functions with a new kind of name that identifies
the template whose deduction they guide; the bulk of this patch is adding the
new name kind. This gives us a clean way to attach an extensible list of guides
to a class template in a way that doesn't require any special handling in AST
files etc (and we're going to need these functions we come to performing
deduction).

Added:
cfe/trunk/test/CXX/temp/temp.deduct.guide/
cfe/trunk/test/CXX/temp/temp.deduct.guide/p1.cpp
cfe/trunk/test/CXX/temp/temp.deduct.guide/p2.cpp
cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Ownership.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclarationName.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=294266=294265=294266=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Feb  6 19:37:30 2017
@@ -1931,6 +1931,12 @@ public:
   bool isDeletedAsWritten() const { return IsDeleted && !IsDefaulted; }
   void setDeletedAsWritten(bool D = true) { IsDeleted = D; }
 
+  /// \brief Determines whether this function is a deduction guide.
+  bool isDeductionGuide() const {
+return getDeclName().getNameKind() ==
+   DeclarationName::CXXDeductionGuideName;
+  }
+
   /// \brief Determines whether this function is "main", which is the
   /// entry point into an executable program.
   bool isMain() const;

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=294266=294265=294266=diff
==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Feb  6 19:37:30 2017
@@ -23,6 +23,7 @@ namespace llvm {
 
 namespace clang {
   class ASTContext;
+  class CXXDeductionGuideNameExtra;
   class CXXLiteralOperatorIdName;
   class CXXOperatorIdName;
   class CXXSpecialName;
@@ -32,6 +33,7 @@ namespace clang {
   enum OverloadedOperatorKind : int;
   struct PrintingPolicy;
   class QualType;
+  class TemplateDecl;
   class Type;
   class TypeSourceInfo;
   class UsingDirectiveDecl;
@@ -56,6 +58,7 @@ public:
 CXXConstructorName,
 CXXDestructorName,
 CXXConversionFunctionName,
+CXXDeductionGuideName,
 CXXOperatorName,
 CXXLiteralOperatorName,
 CXXUsingDirective
@@ -118,42 +121,36 @@ private:
   CXXSpecialName *getAsCXXSpecialName() const {
 NameKind Kind = getNameKind();
 if (Kind >= CXXConstructorName && Kind <= CXXConversionFunctionName)
-  return reinterpret_cast(Ptr & ~PtrMask);
+  return reinterpret_cast(getExtra());
+return nullptr;
+  }
+
+  /// If the stored pointer is actually a CXXDeductionGuideNameExtra, returns a
+  /// pointer to it. Otherwise, returns a NULL pointer.
+  CXXDeductionGuideNameExtra *getAsCXXDeductionGuideNameExtra() const {
+if (getNameKind() == CXXDeductionGuideName)
+  return reinterpret_cast(getExtra());
 return nullptr;
   }
 
   /// getAsCXXOperatorIdName
   CXXOperatorIdName *getAsCXXOperatorIdName() const {
 if (getNameKind() == CXXOperatorName)
-  return reinterpret_cast(Ptr & ~PtrMask);
+  return reinterpret_cast(getExtra());
 return nullptr;
   }
 
   CXXLiteralOperatorIdName *getAsCXXLiteralOperatorIdName() const {
 if (getNameKind() == CXXLiteralOperatorName)
-  

[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-06 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 87339.

Repository:
  rL LLVM

https://reviews.llvm.org/D26654

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake

Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,59 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-06 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 87334.
vsk edited the summary of this revision.
vsk added a comment.

@arphaman thank you for the feedback!

Per Alex's comments:

- Add test for explicit use of the 'this' pointer.
- Handle cases where the 'this' pointer may be casted (implicitly, or 
otherwise).

We're able to eliminate more null checks with this version of the patch. See 
the updated patch summary for the X86FastISel.cpp numbers.


https://reviews.llvm.org/D29530

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/sanitize-recover.c
  test/CodeGenCXX/ubsan-suppress-null-checks.cpp

Index: test/CodeGenCXX/ubsan-suppress-null-checks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-suppress-null-checks.cpp
@@ -0,0 +1,126 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
+
+struct A {
+  int foo;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
+  int load_member() {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
+  int call_method() {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
+  void assign_member_1() {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_2Ev
+  void assign_member_2() {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+this->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZNK1A15assign_member_3Ev
+  void assign_member_3() const {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+const_cast(this)->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A22call_through_referenceERS_
+  static int call_through_reference(A ) {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return a.load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A20call_through_pointerEPS_
+  static int call_through_pointer(A *a) {
+// CHECK: call void @__ubsan_handle_type_mismatch
+return a->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct B {
+  operator A*() const { return nullptr; }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEv
+  static int load_member() {
+// Null-check  before converting it to an A*.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// Null-check the result of the conversion before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+B b;
+return static_cast(b)->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct Base {
+  int foo;
+
+  virtual int load_member_1() = 0;
+};
+
+struct Derived : public Base {
+  int bar;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_2Ev
+  int load_member_2() {
+// Null-check the result of the cast before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return dynamic_cast(this)->load_member_1();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_3Ev
+  int load_member_3() {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return reinterpret_cast(static_cast(this))->foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_1Ev
+  int load_member_1() override {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return foo + bar;
+// CHECK: ret i32
+  }
+};
+
+void force_irgen() {
+  A *a;
+  a->load_member();
+  a->call_method();
+  a->assign_member_1();
+  a->assign_member_2();
+  a->assign_member_3();
+  A::call_through_reference(*a);
+  A::call_through_pointer(a);
+
+  B::load_member();
+
+  Base *b = new Derived;
+  b->load_member_1();
+
+  Derived *d;
+  d->load_member_2();
+  d->load_member_3();
+}
Index: test/CodeGen/sanitize-recover.c
===
--- test/CodeGen/sanitize-recover.c
+++ test/CodeGen/sanitize-recover.c
@@ -19,20 +19,17 @@
 void foo() {
   union { int i; } u;
   u.i=1;
-  // PARTIAL:  %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
-
   // PARTIAL:  %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false)
-  // PARTIAL-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
+  // PARTIAL-NEXT: %[[CHECK0:.*]] = icmp uge i64 %[[SIZE]], 4
 
   // PARTIAL:  %[[MISALIGN:.*]] = and i64 {{.*}}, 3
-  // PARTIAL-NEXT: 

Re: r294177 - [AVR] Allow specifying the CPU on the command line

2017-02-06 Thread Dylan McKay via cfe-commits
No problem - thanks for reverting this.

I'll fix up the patch and re-commit later today.

On Tue, Feb 7, 2017 at 12:47 AM, Diana Picus via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Dylan,
>
> I reverted this in r294180 because I think it broke some of the
> buildbots. See for example
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/3599
> http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/2271
>
> Sorry,
> Diana
>
> On 6 February 2017 at 10:07, Dylan McKay via cfe-commits
>  wrote:
> > Author: dylanmckay
> > Date: Mon Feb  6 03:07:56 2017
> > New Revision: 294177
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=294177=rev
> > Log:
> > [AVR] Allow specifying the CPU on the command line
> >
> > Summary:
> > This tells clang about all of the different AVR microcontrollers.
> >
> > It also adds code to define the correct preprocessor macros for each
> > device.
> >
> > Reviewers: jroelofs, asl
> >
> > Reviewed By: asl
> >
> > Subscribers: asl, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D28346
> >
> > Added:
> > cfe/trunk/test/CodeGen/avr/
> > cfe/trunk/test/CodeGen/avr/target-cpu-defines/
> > cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
> > cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
> > cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
> > Modified:
> > cfe/trunk/lib/Basic/Targets.cpp
> >
> > Modified: cfe/trunk/lib/Basic/Targets.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/
> Targets.cpp?rev=294177=294176=294177=diff
> > 
> ==
> > --- cfe/trunk/lib/Basic/Targets.cpp (original)
> > +++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 03:07:56 2017
> > @@ -8435,6 +8435,254 @@ public:
> >}
> >  };
> >
> > +/// Information about a specific microcontroller.
> > +struct MCUInfo {
> > +  const char *Name;
> > +  const char *DefineName;
> > +};
> > +
> > +// This list should be kept up-to-date with AVRDevices.td in LLVM.
> > +static ArrayRef AVRMcus = {
> > +  { "at90s1200", "__AVR_AT90S1200__" },
> > +  { "attiny11", "__AVR_ATtiny11" },
> > +  { "attiny12", "__AVR_ATtiny12" },
> > +  { "attiny15", "__AVR_ATtiny15" },
> > +  { "attiny28", "__AVR_ATtiny28" },
> > +  { "at90s2313", "__AVR_AT90S2313" },
> > +  { "at90s2323", "__AVR_AT90S2323" },
> > +  { "at90s2333", "__AVR_AT90S2333" },
> > +  { "at90s2343", "__AVR_AT90S2343" },
> > +  { "attiny22", "__AVR_ATtiny22" },
> > +  { "attiny26", "__AVR_ATtiny26" },
> > +  { "at86rf401", "__AVR_AT86RF401" },
> > +  { "at90s4414", "__AVR_AT90S4414" },
> > +  { "at90s4433", "__AVR_AT90S4433" },
> > +  { "at90s4434", "__AVR_AT90S4434" },
> > +  { "at90s8515", "__AVR_AT90S8515" },
> > +  { "at90c8534", "__AVR_AT90c8534" },
> > +  { "at90s8535", "__AVR_AT90S8535" },
> > +  { "ata5272", "__AVR_ATA5272" },
> > +  { "attiny13", "__AVR_ATtiny13" },
> > +  { "attiny13a", "__AVR_ATtiny13A" },
> > +  { "attiny2313", "__AVR_ATtiny2313" },
> > +  { "attiny2313a", "__AVR_ATtiny2313A" },
> > +  { "attiny24", "__AVR_ATtiny24" },
> > +  { "attiny24a", "__AVR_ATtiny24A" },
> > +  { "attiny4313", "__AVR_ATtiny4313" },
> > +  { "attiny44", "__AVR_ATtiny44" },
> > +  { "attiny44a", "__AVR_ATtiny44A" },
> > +  { "attiny84", "__AVR_ATtiny84" },
> > +  { "attiny84a", "__AVR_ATtiny84A" },
> > +  { "attiny25", "__AVR_ATtiny25" },
> > +  { "attiny45", "__AVR_ATtiny45" },
> > +  { "attiny85", "__AVR_ATtiny85" },
> > +  { "attiny261", "__AVR_ATtiny261" },
> > +  { "attiny261a", "__AVR_ATtiny261A" },
> > +  { "attiny461", "__AVR_ATtiny461" },
> > +  { "attiny461a", "__AVR_ATtiny461A" },
> > +  { "attiny861", "__AVR_ATtiny861" },
> > +  { "attiny861a", "__AVR_ATtiny861A" },
> > +  { "attiny87", "__AVR_ATtiny87" },
> > +  { "attiny43u", "__AVR_ATtiny43U" },
> > +  { "attiny48", "__AVR_ATtiny48" },
> > +  { "attiny88", "__AVR_ATtiny88" },
> > +  { "attiny828", "__AVR_ATtiny828" },
> > +  { "at43usb355", "__AVR_AT43USB355" },
> > +  { "at76c711", "__AVR_AT76C711" },
> > +  { "atmega103", "__AVR_ATmega103" },
> > +  { "at43usb320", "__AVR_AT43USB320" },
> > +  { "attiny167", "__AVR_ATtiny167" },
> > +  { "at90usb82", "__AVR_AT90USB82" },
> > +  { "at90usb162", "__AVR_AT90USB162" },
> > +  { "ata5505", "__AVR_ATA5505" },
> > +  { "atmega8u2", "__AVR_ATmega8U2" },
> > +  { "atmega16u2", "__AVR_ATmega16U2" },
> > +  { "atmega32u2", "__AVR_ATmega32U2" },
> > +  { "attiny1634", "__AVR_ATtiny1634" },
> > +  { "atmega8", "__AVR_ATmega8" },
> > +  { "ata6289", "__AVR_ATA6289" },
> > +  { "atmega8a", "__AVR_ATmega8A" },
> > +  { "ata6285", "__AVR_ATA6285" },
> > +  { "ata6286", "__AVR_ATA6286" },
> > +  { "atmega48", "__AVR_ATmega48" },
> > +  { "atmega48a", "__AVR_ATmega48A" },
> > +  { "atmega48pa", "__AVR_ATmega48PA" },
> > +  { "atmega48p", "__AVR_ATmega48P" },
> > +  { "atmega88", "__AVR_ATmega88" },
> > +  { "atmega88a", "__AVR_ATmega88A" },
> > +  { 

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There were review comments still outstanding when you commit the patch. Can you 
please address those post-commit?


Repository:
  rL LLVM

https://reviews.llvm.org/D29267



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


[clang-tools-extra] r294255 - [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Mon Feb  6 16:57:14 2017
New Revision: 294255

URL: http://llvm.org/viewvc/llvm-project?rev=294255=rev
Log:
[clang-tidy] safety-no-assembler

Summary:
Add a new clang-tidy module for safety-critical checks.

Include a check for inline assembler.

Reviewers: Prazek, dtarditi, malcolm.parsons, alexfh, aaron.ballman, idlecode

Reviewed By: idlecode

Subscribers: idlecode, JonasToth, Eugene.Zelenko, mgorny, JDevlieghere, 
cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/safety/
clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp
clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.h
clang-tools-extra/trunk/clang-tidy/safety/SafetyTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/safety-no-assembler.rst
clang-tools-extra/trunk/test/clang-tidy/safety-no-assembler.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=294255=294254=294255=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Mon Feb  6 16:57:14 2017
@@ -38,4 +38,5 @@ add_subdirectory(modernize)
 add_subdirectory(mpi)
 add_subdirectory(performance)
 add_subdirectory(readability)
+add_subdirectory(safety)
 add_subdirectory(utils)

Added: clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt?rev=294255=auto
==
--- clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt Mon Feb  6 
16:57:14 2017
@@ -0,0 +1,14 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidySafetyModule
+  NoAssemblerCheck.cpp
+  SafetyTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )

Added: clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp?rev=294255=auto
==
--- clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp Mon Feb  6 
16:57:14 2017
@@ -0,0 +1,52 @@
+//===--- NoAssemblerCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "NoAssemblerCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace ast_matchers {
+AST_MATCHER(VarDecl, isAsm) { return Node.hasAttr(); }
+const internal::VariadicDynCastAllOfMatcher
+fileScopeAsmDecl;
+}
+}
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+void NoAssemblerCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(asmStmt().bind("asm-stmt"), this);
+  Finder->addMatcher(fileScopeAsmDecl().bind("asm-file-scope"), this);
+  Finder->addMatcher(varDecl(isAsm()).bind("asm-var"), this);
+}
+
+void NoAssemblerCheck::check(const MatchFinder::MatchResult ) {
+  Optional ASMLocation;
+  if (const auto *ASM = Result.Nodes.getNodeAs("asm-stmt"))
+ASMLocation = ASM->getAsmLoc();
+  else if (const auto *ASM =
+   Result.Nodes.getNodeAs("asm-file-scope"))
+ASMLocation = ASM->getAsmLoc();
+  else if (const auto *ASM = Result.Nodes.getNodeAs("asm-var"))
+ASMLocation = ASM->getLocation();
+  else
+llvm_unreachable("Unhandled case in matcher.");
+
+  diag(*ASMLocation, "do not use inline assembler in safety-critical code");
+}
+
+} // namespace safety
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.h?rev=294255=auto
==
--- 

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294255: [clang-tidy] safety-no-assembler (authored by jbcoe).

Changed prior to commit:
  https://reviews.llvm.org/D29267?vs=87207=87314#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29267

Files:
  clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.cpp
  clang-tools-extra/trunk/clang-tidy/safety/NoAssemblerCheck.h
  clang-tools-extra/trunk/clang-tidy/safety/SafetyTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/safety-no-assembler.rst
  clang-tools-extra/trunk/test/clang-tidy/safety-no-assembler.cpp

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -57,7 +57,10 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `safety-no-assembler
+  `_ check
+
+  Finds uses of inline assembler.
 
 Improvements to include-fixer
 -
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
@@ -152,3 +152,4 @@
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
+   safety-no-assembler
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/safety-no-assembler.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/safety-no-assembler.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/safety-no-assembler.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - safety-no-assembler
+
+safety-no-assembler
+===
+
+Check for assembler statements. No fix is offered.
+
+Inline assembler is forbidden by safety-critical C++ standards like `High
+Intergrity C++ `_ as it restricts the
+portability of code.
Index: clang-tools-extra/trunk/test/clang-tidy/safety-no-assembler.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/safety-no-assembler.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/safety-no-assembler.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s safety-no-assembler %t
+
+__asm__(".symver foo, bar@v");
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+
+static int s asm("spam");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+
+void f() {
+  __asm("mov al, 2");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+}
+
Index: clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/safety/CMakeLists.txt
@@ -0,0 +1,14 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidySafetyModule
+  NoAssemblerCheck.cpp
+  SafetyTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )
Index: clang-tools-extra/trunk/clang-tidy/safety/SafetyTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/safety/SafetyTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/safety/SafetyTidyModule.cpp
@@ -0,0 +1,38 @@
+//===--- SafetyTidyModule.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "NoAssemblerCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+class SafetyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"safety-no-assembler");
+  }
+};
+
+// Register the SafetyModule using this statically initialized variable.
+static 

[PATCH] D21626: Lit C++11 Compatibility Patch #10

2017-02-06 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 87312.
tigerleapgorge added a comment.

Remove 2 tests reviewed under https://reviews.llvm.org/D29520.


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/a.h
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/OpenMP/declare_reduction_messages.cpp
  test/OpenMP/openmp_check.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/format-strings.cpp
  test/SemaCXX/printf-cstr.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,10 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1465,21 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+// expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/printf-cstr.cpp
===
--- test/SemaCXX/printf-cstr.cpp
+++ test/SemaCXX/printf-cstr.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wformat -verify %s -Wno-error=non-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++98 %s -Wno-error=non-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++11 %s -Wno-error=non-pod-varargs
 
 #include 
 
@@ -31,12 +33,39 @@
   int n = 10;
 
   printf("%d: %s\n", n, hcs.c_str());
-  printf("%d: %s\n", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}}
-  printf("%d: %s\n", n, hncs); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}}
-  sprintf(str, "%d: %s", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}}
-
-  printf(formatString, hcs, hncs); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} expected-warning{{cannot pass object of non-POD type 'HasNoCStr' through variadic function}}
-  printf(extstr, hcs, n); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}}
+  printf("%d: %s\n", n, hcs);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}}
+  // expected-note@-3 {{did you mean to call the c_str() method?}}
+#else
+  // expected-warning@-5 {{format specifies type 'char *' but the argument has type 'HasCStr'}}
+#endif
+
+  printf("%d: %s\n", n, hncs);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}}
+#else
+  // expected-warning@-4 {{format specifies type 'char *' but the argument has type 'HasNoCStr'}}
+#endif
+
+  sprintf(str, "%d: %s", n, hcs);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{cannot pass non-POD object of 

[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 87311.
mgorny added a comment.

Removed the i386 branch. Now the i486+ are used unconditionally.


https://reviews.llvm.org/D29542

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/atomic-ops.c
  test/CodeGen/ms-volatile.c
  test/CodeGenCXX/atomicinit.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -target-cpu i686 -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i486-linux-gnu -target-cpu i486 -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
@@ -14,22 +15,34 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+#if defined(__i486__)
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
+#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
 _Static_assert(__c11_atomic_is_lock_free(2), "");
 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(4), "");
+#if defined(__i486__)
+_Static_assert(__c11_atomic_is_lock_free(8), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__c11_atomic_is_lock_free(8), "");
+#endif
 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
 
 _Static_assert(__atomic_is_lock_free(1, 0), "");
 _Static_assert(__atomic_is_lock_free(2, 0), "");
 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, 0), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, 0), "");
+#endif
 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
 
@@ -56,13 +69,21 @@
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, ), "");
+#endif
 
 _Static_assert(__atomic_always_lock_free(1, 0), "");
 _Static_assert(__atomic_always_lock_free(2, 0), "");
 _Static_assert(!__atomic_always_lock_free(3, 0), "");
 _Static_assert(__atomic_always_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, 0), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, 0), "");
+#endif
 _Static_assert(!__atomic_always_lock_free(16, 0), "");
 _Static_assert(!__atomic_always_lock_free(17, 0), "");
 
@@ -79,7 +100,11 @@
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(!__atomic_always_lock_free(8, ), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, ), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, ), "");
+#endif
 
 #define _AS1 __attribute__((address_space(1)))
 #define _AS2 __attribute__((address_space(2)))
Index: test/CodeGenCXX/atomicinit.cpp
===
--- test/CodeGenCXX/atomicinit.cpp
+++ test/CodeGenCXX/atomicinit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -target-cpu i686 -std=c++11 | FileCheck %s
 
 // CHECK-DAG: @PR22043 = local_unnamed_addr global i32 0, align 4
 typedef _Atomic(int) AtomicInt;
Index: test/CodeGen/ms-volatile.c
===
--- test/CodeGen/ms-volatile.c
+++ test/CodeGen/ms-volatile.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -fms-volatile -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu i686 -fms-extensions -emit-llvm -fms-volatile -o - < %s | FileCheck %s
 struct foo {
   volatile int x;
 };
Index: test/CodeGen/atomic-ops.c
===
--- 

[PATCH] D20710: Lit C++11 Compatibility Patch #9

2017-02-06 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 87309.
tigerleapgorge added a comment.

2 tests have been reviewed in https://reviews.llvm.org/D29520
They are: implicit-virtual-member-functions.cpp and virtual-member-functions.cpp
Remove these from this patch.


https://reviews.llvm.org/D20710

Files:
  test/CodeGenCXX/debug-info-use-after-free.cpp
  test/CodeGenCXX/dynamic-cast-hint.cpp
  test/SemaCXX/i-c-e-cxx.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/no-wchar.cpp
  test/SemaCXX/virtual-member-functions-key-function.cpp
  test/SemaCXX/warn-bool-conversion.cpp
  test/SemaCXX/zero-length-arrays.cpp
  test/SemaTemplate/instantiate-c99.cpp
  test/SemaTemplate/temp_explicit.cpp
  test/SemaTemplate/value-dependent-null-pointer-constant.cpp

Index: test/SemaTemplate/value-dependent-null-pointer-constant.cpp
===
--- test/SemaTemplate/value-dependent-null-pointer-constant.cpp
+++ test/SemaTemplate/value-dependent-null-pointer-constant.cpp
@@ -1,17 +1,30 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 template
 struct X0 {
   const char *f0(bool Cond) {
 return Cond? "honk" : N;
+#if __cplusplus >= 201103L
+// expected-error@-2 {{incompatible operand types ('const char *' and 'int')}}
+#else
+// expected-no-diagnostics
+#endif
   }
 
   const char *f1(bool Cond) {
 return Cond? N : "honk";
+#if __cplusplus >= 201103L
+// expected-error@-2 {{incompatible operand types ('int' and 'const char *')}}
+#endif
   }
   
   bool f2(const char *str) {
 return str == N;
+#if __cplusplus >= 201103L
+// expected-error@-2 {{comparison between pointer and integer ('const char *' and 'int')}}
+#endif
   }
 };
 
Index: test/SemaTemplate/temp_explicit.cpp
===
--- test/SemaTemplate/temp_explicit.cpp
+++ test/SemaTemplate/temp_explicit.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
 //
 // Tests explicit instantiation of templates.
 template class X0 { };
@@ -98,7 +100,12 @@
 template struct X5::Inner2; // expected-note{{instantiation}}
 
 namespace N3 {
-  template struct N2::X5::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+  template struct N2::X5::Inner2;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+#else
+// expected-error@-4 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+#endif
 }
 
 struct X6 {
@@ -145,7 +152,17 @@
 namespace N2 {
   using namespace N1;
 
-  template struct X7; // expected-warning{{must occur in namespace}}
-
-  template struct X9; // expected-warning{{must occur at global scope}}
+  template struct X7;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}}
+#else
+// expected-error@-4 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}}
+#endif
+
+  template struct X9;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{explicit instantiation of 'X9' must occur at global scope}}
+#else
+// expected-error@-4 {{explicit instantiation of 'X9' must occur at global scope}}
+#endif
 }
Index: test/SemaTemplate/instantiate-c99.cpp
===
--- test/SemaTemplate/instantiate-c99.cpp
+++ test/SemaTemplate/instantiate-c99.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // Test template instantiation for C99-specific features.
 
@@ -9,8 +11,13 @@
 struct DesigInit0 {
   void f(XType x, YType y) {
 T agg = { 
+#if __cplusplus <= 199711L
   .y = y, // expected-error{{does not refer}}
   .x = x  // expected-error{{does not refer}}
+#else
+  .y = static_cast(y), // expected-error{{does not refer}}
+  .x = static_cast(x)  // expected-error{{does not refer}}
+#endif
 };
   }
 };
@@ -44,7 +51,11 @@
 struct DesigArrayInit0 {
   void f(Val1 val1, Val2 val2) {
 T array = {
+#if __cplusplus <= 199711L
   [Subscript1] = val1,
+#else
+  [Subscript1] = static_cast(val1),
+#endif
   [Subscript2] = val2 // expected-error{{exceeds array bounds}}
 };
 
@@ -60,7 +71,11 @@
 struct DesigArrayRangeInit0 {
   void f(Val1 val1) {
 T array = {
+#if __cplusplus <= 199711L
   [Subscript1...Subscript2] = val1 // expected-error{{exceeds}}
+#else
+  [Subscript1...Subscript2] = static_cast(val1) // expected-error{{exceeds}}
+#endif
 };
   }
 };
@@ -74,7 +89,11 @@
 template
 

Re: [libcxx] r294138 - Adjust Linux ABI list after r294133

2017-02-06 Thread Hans Wennborg via cfe-commits
The diff here is huge compared to the Apple one (r294139).

Did the file format change and this file was previously not updated?

This makes it hard to merge the change. Can you advise on how to
generate this file or how to do the same change on 4.0?

On Sun, Feb 5, 2017 at 12:14 PM, Eric Fiselier via cfe-commits
 wrote:
> Author: ericwf
> Date: Sun Feb  5 14:14:18 2017
> New Revision: 294138
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294138=rev
> Log:
> Adjust Linux ABI list after r294133
>
> Modified:
> libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist
>
> Modified: libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist?rev=294138=294137=294138=diff
> ==
> --- libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist (original)
> +++ libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist Sun Feb  5 14:14:18 
> 2017
> @@ -1,1904 +1,1905 @@
> -{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
> -{'is_defined': True, 'name': '_ZNKSt12bad_any_cast4whatEv', 'type': 'FUNC'}
> -{'is_defined': True, 'name': 
> '_ZNKSt12experimental15fundamentals_v112bad_any_cast4whatEv', 'type': 'FUNC'}
> -{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
> -{'is_defined': True, 'name': '_ZNKSt16nested_exception14rethrow_nestedEv', 
> 'type': 'FUNC'}
> -{'is_defined': True, 'name': '_ZNKSt18bad_variant_access4whatEv', 'type': 
> 'FUNC'}
> -{'is_defined': True, 'name': 
> '_ZNKSt3__110__time_put8__do_putEPcRS1_PK2tmcc', 'type': 'FUNC'}
> -{'is_defined': True, 'name': 
> '_ZNKSt3__110__time_put8__do_putEPwRS1_PK2tmcc', 'type': 'FUNC'}

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


Re: [libcxx] r294133 - Change the base class of std::bad_optional_access. This is a (subtle) ABI change, and is in response to http://http://wg21.link/LWG2806, which I *expect* to be adopted in Kona.

2017-02-06 Thread Hans Wennborg via cfe-commits
I've merged this, together with your r294142, to 4.0 in r294249, as requested.

If I understand correctly, we should also merge Eric's follow-ups
r294138 and r294139, but I get merge conflicts for the Linux one so
I've asked about how to handle that.

Thanks,
Hans

On Sun, Feb 5, 2017 at 12:06 PM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Sun Feb  5 14:06:38 2017
> New Revision: 294133
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294133=rev
> Log:
> Change the base class of std::bad_optional_access.  This is a (subtle) ABI 
> change, and is in response to http://http://wg21.link/LWG2806, which I 
> *expect* to be adopted in Kona. I am making this change now in anticipation, 
> and will get it into 4.0, because (a) 4.0 is the first release with 
> std::optional, and (b) I don't want to make an ABI-change later, when the 
> user base should be significantly larger. Note that I didn't change 
> std::experimental::bad_optional_access, because that's still specified to 
> derive from std::logic_error.
>
> Modified:
> libcxx/trunk/include/experimental/optional
> libcxx/trunk/include/optional
> libcxx/trunk/src/optional.cpp
> 
> libcxx/trunk/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r294249 - Merging r294133 and r294142:

2017-02-06 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Feb  6 15:59:19 2017
New Revision: 294249

URL: http://llvm.org/viewvc/llvm-project?rev=294249=rev
Log:
Merging r294133 and r294142:

r294133 | marshall | 2017-02-05 12:06:38 -0800 (Sun, 05 Feb 2017) | 1 line

Change the base class of std::bad_optional_access.  This is a (subtle) ABI 
change, and is in response to http://http://wg21.link/LWG2806, which I *expect* 
to be adopted in Kona. I am making this change now in anticipation, and will 
get it into 4.0, because (a) 4.0 is the first release with std::optional, and 
(b) I don't want to make an ABI-change later, when the user base should be 
significantly larger. Note that I didn't change 
std::experimental::bad_optional_access, because that's still specified to 
derive from std::logic_error.



r294142 | marshall | 2017-02-05 12:52:32 -0800 (Sun, 05 Feb 2017) | 1 line

Restore the _NOEXCEPT on the dtor of bad_optional_access. Destructors are 
noexcept by default, so it's not really needed, but the other exception classes 
have the _NOEXCEPT, and gcc complains if these are missing. I think we should 
remove them all - but not today.


Modified:
libcxx/branches/release_40/   (props changed)
libcxx/branches/release_40/include/optional
libcxx/branches/release_40/src/optional.cpp

libcxx/branches/release_40/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb  6 15:59:19 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581
+/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581,294133,294142

Modified: libcxx/branches/release_40/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/optional?rev=294249=294248=294249=diff
==
--- libcxx/branches/release_40/include/optional (original)
+++ libcxx/branches/release_40/include/optional Mon Feb  6 15:59:19 2017
@@ -160,14 +160,12 @@ namespace std  // purposefully not using
 {
 
 class _LIBCPP_EXCEPTION_ABI bad_optional_access
-: public logic_error
+: public exception
 {
 public:
-_LIBCPP_INLINE_VISIBILITY
-bad_optional_access() : logic_error("bad optional access") {}
-
 // Get the key function ~bad_optional_access() into the dylib
 virtual ~bad_optional_access() _NOEXCEPT;
+virtual const char* what() const _NOEXCEPT;
 };
 
 }  // std

Modified: libcxx/branches/release_40/src/optional.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/src/optional.cpp?rev=294249=294248=294249=diff
==
--- libcxx/branches/release_40/src/optional.cpp (original)
+++ libcxx/branches/release_40/src/optional.cpp Mon Feb  6 15:59:19 2017
@@ -15,6 +15,10 @@ namespace std
 
 bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
 
+const char* bad_optional_access::what() const _NOEXCEPT {
+  return "bad_optional_access";
+  }
+
 } // std
 
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL

Modified: 
libcxx/branches/release_40/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp?rev=294249=294248=294249=diff
==
--- 
libcxx/branches/release_40/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
 (original)
+++ 
libcxx/branches/release_40/test/std/utilities/optional/optional.bad_optional_access/derive.pass.cpp
 Mon Feb  6 15:59:19 2017
@@ -11,7 +11,7 @@
 
 // 
 
-// class bad_optional_access : public logic_error
+// class bad_optional_access : public exception
 
 #include 
 #include 
@@ -20,6 +20,6 @@ int main()
 {
 using std::bad_optional_access;
 
-static_assert(std::is_base_of::value, "");
-static_assert(std::is_convertible::value, "");
+static_assert(std::is_base_of::value, 
"");
+static_assert(std::is_convertible::value, "");
 }


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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+

aaron.ballman wrote:
> Is this include needed?
Will be good idea to run Include What You Use.


https://reviews.llvm.org/D29267



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


[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.

2017-02-06 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D29151#668197, @zaks.anna wrote:

> > I tried to come up with some advice on where checks should go in 
> > http://clang.llvm.org/extra/clang-tidy/#choosing-the-right-place-for-your-check
>
> The guidelines stated on the clang-tidy page seem reasonable to me.
>
> > For example, IMO, AST-based analyses make more sense in clang-tidy for a 
> > few reasons:
> > 
> > They usually are easier expressible in terms of AST matchers, and 
> > clang-tidy allows to use AST matchers with less boilerplate.
> >  Clang Static Analyzer is linked into clang, where AST matchers are 
> > undesired, since they tend to blow the size of binary significantly.
> >  It's more consistent to keep all similar analyses together, it simplifies 
> > search for already implemented similar functionality and code reviews.
>
> I agree that there is a gray area specifically in the AST-matching-based bug 
> finding, which unfortunately leads to duplication of effort. However, we 
> currently cannot ban/move all AST-based checks out of the analyzer. The main 
> problem I see with restricting the AST-based analysis to clang-tidy is impact 
> on the end users. While clang-tidy does export the clang static analyzer 
> results, the reverse does not hold. There are many end users who do not use 
> clang-tidy but do use the clang static analyzer (either directly or through 
> scan-build). Until that is the case, I do not think we should disallow AST 
> based checks from the analyzer, especially if they come from contributors who 
> are interested in contributing to this tool. Note that the format in which 
> the results are presented from these tools is not uniform, which makes 
> transition more complicated.
>
> The AST matchers can be used from the analyzer and if the code size becomes a 
> problem, we could consider moving the analyzer out of the clang codebase.
>
> Generally, I am not a big fan of the split between the checks based on the 
> technology used to implement them since it does not lead to a great user 
> interface - the end users do not think in terms of 
> path-sensitive/flow-sensitive/AST-matching, they just want to enable specific 
> functionality such as find bugs or ensure they follow coding guidelines. This 
> is why I like the existing guidelines with their focus on what clang-tidy is 
> from user perspective:


Agree with it.

>> clang-tidy check is a good choice for linter-style checks, checks that are 
>> related to a certain coding style, checks that address code readability, etc.
> 
> Another thing that could be worth adding here is that clang-tidy finds bugs 
> that tend to be easy to fix and, in most cases, provide the fixits. (I 
> believe, this is one of the major strengths of the clang-tidy tool!)
> 
>> Flow-sensitive analyses (that don't need any path-sensitivity) seem to be 
>> equally suitable for SA and clang-tidy (unless I'm missing something), so I 
>> don't feel strongly as to where they should go.
> 
> As far as I know, currently, all flow-sensitive analysis are in the Analysis 
> library in clang. These are analysis for compiler warnings and analysis used 
> by the static analyzer. I believe this is where future analysis should go as 
> well, especially, for analysis that could have multiple clients. If clang 
> code size impact turns out to be a serious problem, we could also have that 
> library provide APIs that could be used from other tools/checks. (Note, the 
> analysis could be implemented in the library, but the users of the analysis 
> (checks) can be elsewhere.)
> 
> Regarding the points about "heuristics" and "flexibility", the analyzer is 
> full of heuristics and fuzzy API matching. These techniques are very common 
> in static analysis in general as we are trying to solve undecidable problems 
> and heuristics is the only way to go.

I guess the main problem is that you can't use clang-tidy checks from scan 
build, where there are some checks like use-after-move, and bunch of misc 
checks, that would totally fit into what user want from scan build.


Repository:
  rL LLVM

https://reviews.llvm.org/D29151



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


[PATCH] D29151: [clang-tidy] Add misc-invalidated-iterators check.

2017-02-06 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> I tried to come up with some advice on where checks should go in 
> http://clang.llvm.org/extra/clang-tidy/#choosing-the-right-place-for-your-check

The guidelines stated on the clang-tidy page seem reasonable to me.

> For example, IMO, AST-based analyses make more sense in clang-tidy for a few 
> reasons:
> 
> They usually are easier expressible in terms of AST matchers, and clang-tidy 
> allows to use AST matchers with less boilerplate.
>  Clang Static Analyzer is linked into clang, where AST matchers are 
> undesired, since they tend to blow the size of binary significantly.
>  It's more consistent to keep all similar analyses together, it simplifies 
> search for already implemented similar functionality and code reviews.

I agree that there is a gray area specifically in the AST-matching-based bug 
finding, which unfortunately leads to duplication of effort. However, we 
currently cannot ban/move all AST-based checks out of the analyzer. The main 
problem I see with restricting the AST-based analysis to clang-tidy is impact 
on the end users. While clang-tidy does export the clang static analyzer 
results, the reverse does not hold. There are many end users who do not use 
clang-tidy but do use the clang static analyzer (either directly or through 
scan-build). Until that is the case, I do not think we should disallow AST 
based checks from the analyzer, especially if they come from contributors who 
are interested in contributing to this tool. Note that the format in which the 
results are presented from these tools is not uniform, which makes transition 
more complicated.

The AST matchers can be used from the analyzer and if the code size becomes a 
problem, we could consider moving the analyzer out of the clang codebase.

Generally, I am not a big fan of the split between the checks based on the 
technology used to implement them since it does not lead to a great user 
interface - the end users do not think in terms of 
path-sensitive/flow-sensitive/AST-matching, they just want to enable specific 
functionality such as find bugs or ensure they follow coding guidelines. This 
is why I like the existing guidelines with their focus on what clang-tidy is 
from user perspective:

> clang-tidy check is a good choice for linter-style checks, checks that are 
> related to a certain coding style, checks that address code readability, etc.

Another thing that could be worth adding here is that clang-tidy finds bugs 
that tend to be easy to fix and, in most cases, provide the fixits. (I believe, 
this is one of the major strengths of the clang-tidy tool!)

> Flow-sensitive analyses (that don't need any path-sensitivity) seem to be 
> equally suitable for SA and clang-tidy (unless I'm missing something), so I 
> don't feel strongly as to where they should go.

As far as I know, currently, all flow-sensitive analysis are in the Analysis 
library in clang. These are analysis for compiler warnings and analysis used by 
the static analyzer. I believe this is where future analysis should go as well, 
especially, for analysis that could have multiple clients. If clang code size 
impact turns out to be a serious problem, we could also have that library 
provide APIs that could be used from other tools/checks. (Note, the analysis 
could be implemented in the library, but the users of the analysis (checks) can 
be elsewhere.)

Regarding the points about "heuristics" and "flexibility", the analyzer is full 
of heuristics and fuzzy API matching. These techniques are very common in 
static analysis in general as we are trying to solve undecidable problems and 
heuristics is the only way to go.


Repository:
  rL LLVM

https://reviews.llvm.org/D29151



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+

Is this include needed?



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:36
+void NoAssemblerCheck::check(const MatchFinder::MatchResult ) {
+  Optional ASMLocation;
+  if (const auto *ASM = Result.Nodes.getNodeAs("asm-stmt"))

No need for this to be an `Optional`, is there?


https://reviews.llvm.org/D29267



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

Hello! Just a small ping to see if anyone has taken a look at this change? I 
fully understand that everyone's really busy, but perhaps you can recommend 
another reviewer? Or if you're presently giving this change a whirl, just let 
me know! Cheers :)


https://reviews.llvm.org/D29221



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode accepted this revision.
idlecode added a comment.
This revision is now accepted and ready to land.

Sure, but I don't have commit rights so someone else have to push it :)


https://reviews.llvm.org/D29267



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think you're running into https://llvm.org/bugs/show_bug.cgi?id=31620 .


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

There's still something strange here.  If I compile the following on 
i386-freebsd12, with `clang -march=i486 -O2 -S`:

  _Atomic(long long) ll;
  
  void f(void)
  {
++ll;
  }

the result is:

.globl  f
.p2align4, 0x90
.type   f,@function
  f:  # @f
  # BB#0: # %entry
pushl   %ebp
movl%esp, %ebp
pushl   %ebx
movlll+4, %edx
movlll, %eax
.p2align4, 0x90
  .LBB0_1:# %atomicrmw.start
  # =>This Inner Loop Header: Depth=1
movl%eax, %ebx
addl$1, %ebx
movl%edx, %ecx
adcl$0, %ecx
lockcmpxchg8b   ll
jne .LBB0_1
  # BB#2: # %atomicrmw.end
popl%ebx
popl%ebp
retl
  .Lfunc_end0:
.size   f, .Lfunc_end0-f
  
.type   ll,@object  # @ll
.comm   ll,8,4

So what gives?  It's still inserting a `cmpxchg8b`!  AFAIK it should now insert 
a call to `__atomic_fetch_add_8` instead.

Note that this changes if you use C++ atomics, e.g.:

  #include 
  
  void f(std::atomic& x)
  {
++x;
  }

compiles to:

.globl  _Z1fRNSt3__16atomicIxEE
.p2align4, 0x90
.type   _Z1fRNSt3__16atomicIxEE,@function
  _Z1fRNSt3__16atomicIxEE:# @_Z1fRNSt3__16atomicIxEE
  .Lfunc_begin0:
.cfi_sections .debug_frame
.cfi_startproc
.cfi_personality 0, __gxx_personality_v0
.cfi_lsda 0, .Lexception0
  # BB#0: # %entry
pushl   %ebp
movl%esp, %ebp
subl$16, %esp
movl8(%ebp), %eax
  .Ltmp0:
movl%eax, (%esp)
movl$5, 12(%esp)
movl$0, 8(%esp)
movl$1, 4(%esp)
calll   __atomic_fetch_add_8
  .Ltmp1:
  # BB#1: # 
%_ZNSt3__113__atomic_baseIxLb1EEppEv.exit
addl$16, %esp
popl%ebp
retl
  .LBB0_2:# %lpad.i.i
  .Ltmp2:
movl%eax, (%esp)
calll   __cxa_call_unexpected
subl$4, %esp
  .Lfunc_end0:
.size   _Z1fRNSt3__16atomicIxEE, .Lfunc_end0-_Z1fRNSt3__16atomicIxEE
.cfi_endproc


https://reviews.llvm.org/D29542



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


[PATCH] D29520: Lit C++11 Compatibility - Microsoft diagnostics

2017-02-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294225: [Lit Test] Make tests C++11 compatible - Microsoft 
diagnostics (authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D29520?vs=87044=87274#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29520

Files:
  cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
  cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp
  cfe/trunk/test/SemaCXX/virtual-base-used.cpp
  cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp

Index: cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
===
--- cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
+++ cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++98 -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++11 -verify %s
 
 namespace PR5557 {
 template  struct A {
@@ -76,34 +80,76 @@
 }
 
 namespace PR7114 {
-  class A { virtual ~A(); }; // expected-note{{declared private here}}
+  class A { virtual ~A(); };
+#if __cplusplus <= 199711L
+  // expected-note@-2{{declared private here}}
+#else
+  // expected-note@-4 3 {{overridden virtual function is here}}
+#endif
 
   template
   class B {
   public:
-class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}}
+class Inner : public A { };
+#if __cplusplus <= 199711L
+// expected-error@-2{{base class 'PR7114::A' has private destructor}}
+#else
+// expected-error@-4 2 {{deleted function '~Inner' cannot override a non-deleted function}}
+// expected-note@-5 2 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#ifdef MSABI
+// expected-note@-7 1 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
+#endif
+
 static Inner i;
 static const unsigned value = sizeof(i) == 4;
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+// expected-note@-3 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+#endif
   };
 
   int f() { return B::value; }
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
 
 #ifdef MSABI
-  void test_typeid(B::Inner bfi) { // expected-note{{implicit destructor}}
+  void test_typeid(B::Inner bfi) {
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor}}
+#else
+// expected-error@-4 {{attempt to use a deleted function}}
+// expected-note@-5 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
+
 (void)typeid(bfi);
 #else
   void test_typeid(B::Inner bfi) {
-(void)typeid(bfi); // expected-note{{implicit destructor}}
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
+(void)typeid(bfi);
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor}}
+#endif
 #endif
   }
 
   template
   struct X : A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~X' cannot override a non-deleted function}}
+// expected-note@-3  {{destructor of 'X' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
 void f() { }
   };
 
   void test_X(X , X ) {
 xi.f();
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::X' requested here}}
+#endif
   }
 }
 
Index: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
===
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
 
 #if TEST1
@@ -23,11 +25,17 @@
 };
 
 class A {
-  virtual ~A() throw();  // 

r294225 - [Lit Test] Make tests C++11 compatible - Microsoft diagnostics

2017-02-06 Thread Charles Li via cfe-commits
Author: lcharles
Date: Mon Feb  6 13:32:38 2017
New Revision: 294225

URL: http://llvm.org/viewvc/llvm-project?rev=294225=rev
Log:
[Lit Test] Make tests C++11 compatible - Microsoft diagnostics

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

Modified:
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp
cfe/trunk/test/SemaCXX/virtual-base-used.cpp
cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=294225=294224=294225=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Mon Feb  6 13:32:38 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft 
-Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions 
-fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft 
-Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
 
 #if TEST1
@@ -23,11 +25,17 @@ struct Derived : Base {
 };
 
 class A {
-  virtual ~A() throw();  // expected-note {{overridden virtual function is 
here}}
+  virtual ~A() throw();
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{overridden virtual function is here}}
+#endif
 };
 
 class B : public A {
-  virtual ~B();  // expected-warning {{exception specification of overriding 
function is more lax than base version}}
+  virtual ~B();
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{exception specification of overriding function is 
more lax than base version}}
+#endif
 };
 
 }
@@ -174,11 +182,18 @@ const int seventeen = 17;
 typedef int Int;
 
 struct X0 {
-  enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration 
types with a fixed underlying type are a C++11 extension}}
+  enum E1 : Int { SomeOtherValue } field;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{enumeration types with a fixed underlying type are 
a C++11 extension}}
+#endif
+
   enum E1 : seventeen;
 };
 
-enum : long long {  // expected-warning{{enumeration types with a fixed 
underlying type are a C++11 extension}}
+#if __cplusplus <= 199711L
+// expected-warning@+2 {{enumeration types with a fixed underlying type are a 
C++11 extension}}
+#endif
+enum : long long {
   SomeValue = 0x1
 };
 
@@ -450,7 +465,9 @@ struct SealedType sealed : SomeBase {
   // FIXME. warning can be suppressed if we're also issuing error for 
overriding a 'final' function.
   virtual void SealedFunction(); // expected-warning {{'SealedFunction' 
overrides a member function but is not marked 'override'}}
 
-  // expected-warning@+1 {{'override' keyword is a C++11 extension}}
+#if __cplusplus <= 199711L
+  // expected-warning@+2 {{'override' keyword is a C++11 extension}}
+#endif
   virtual void OverrideMe() override;
 };
 

Modified: cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp?rev=294225=294224=294225=diff
==
--- cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp Mon Feb  6 
13:32:38 2017
@@ -1,33 +1,87 @@
 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify 
-std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify 
-std=c++11 %s
 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify 
-std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify 
-std=c++11 %s
+
 struct A {
   virtual ~A();
+#if __cplusplus >= 201103L
+// expected-note@-2 3 {{overridden virtual function is here}}
+#endif
 };
 
-struct B : A { // expected-error {{no suitable member 'operator delete' in 
'B'}}
+struct B : A {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{no suitable member 'operator delete' in 'B'}}
+#else
+// expected-error@-4 {{deleted function '~B' cannot override a non-deleted 
function}}
+// expected-note@-5  {{virtual destructor requires an unambiguous, accessible 
'operator delete'}}
+#ifdef MSABI
+// expected-note@-7 {{virtual destructor requires an unambiguous, 

[PATCH] D29599: Clang Changes for alloc_align

2017-02-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Requires this LLVM commit: https://reviews.llvm.org/D29598


https://reviews.llvm.org/D29599



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


[PATCH] D29599: Clang Changes for alloc_align

2017-02-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

GCC has the alloc_align attribute, which is similar to assume_aligned, except 
the attribute's parameter is the index of the integer parameter that needs 
aligning to.


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4225,7 +4225,11 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal = IRCallArgs[AA->getParamIndex() - 1];
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
+
   }
 
   return Ret;
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2412,6 +2412,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1484,6 +1484,13 @@
  Attr.getAttributeSpellingListIndex());
 }
 
+static void handleAllocAlignAttr(Sema , Decl *D,
+   const AttributeList ) {
+  Expr *E = Attr.getArgAsExpr(0);
+  S.AddAllocAlignAttr(Attr.getRange(), D, E, Attr,
+   Attr.getAttributeSpellingListIndex());
+}
+
 void Sema::AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
 Expr *OE, unsigned SpellingListIndex) {
   QualType ResultType = getFunctionOrMethodResultType(D);
@@ -1535,6 +1542,34 @@
 AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
 }
 
+void Sema::AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
+ const AttributeList ,
+ unsigned SpellingListIndex) {
+  QualType ResultType = getFunctionOrMethodResultType(D);
+  SourceRange SR = getFunctionOrMethodResultSourceRange(D);
+
+  AllocAlignAttr TmpAttr(AttrRange, Context, 0, SpellingListIndex);
+  SourceLocation AttrLoc = AttrRange.getBegin();
+
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
+<<  << AttrRange << SR;
+return;
+  }
+
+  int IndexVal;
+  if (!checkPositiveIntArgument(*this, Attr, ParamExpr, IndexVal, /*Index=*/1))
+return;
+
+  const auto *FuncDecl = cast(D);
+  if (!checkParamIsIntegerType(*this, FuncDecl, Attr, IndexVal,
+   /*AttrArgNo=*/0))
+return;
+
+  D->addAttr(::new (Context) AllocAlignAttr(AttrRange, Context, IndexVal,
+SpellingListIndex));
+}
+
 /// Normalize the attribute, __foo__ becomes foo.
 /// Returns true if normalization was applied.
 static bool normalizeName(StringRef ) {
@@ -5837,6 +5872,9 @@
   case AttributeList::AT_AssumeAligned:
 handleAssumeAlignedAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AllocAlign:
+handleAllocAlignAttr(S, D, Attr);
+break;
   case AttributeList::AT_Overloadable:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8125,6 +8125,11 @@
   void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
 unsigned SpellingListIndex);
 
+  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
+  /// declaration.
+  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
+ const AttributeList , unsigned SpellingListIndex);
+
   /// AddAlignValueAttr - Adds an align_value attribute to a particular
   /// declaration.
   void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
Index: include/clang/Basic/AttrDocs.td

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

@idlecode please can you approve if it LGTY?


https://reviews.llvm.org/D29267



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-02-06 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested review of this revision.
dexonsmith added a comment.

This has changed enough it needs another review.  Richard or Ben, could you 
take a(nother) look?


https://reviews.llvm.org/D28299



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> Well, the thing is, we don't call HostTarget->setCPU() before this function. 
> We just call AllocateTarget(), and it does not set the CPU.

Ah, got it.  LGTM for the nvptx changes.


https://reviews.llvm.org/D29542



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-02-06 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 87257.
dexonsmith added a comment.
Herald added subscribers: mgorny, nemanjai.

Rebased on top of the current https://reviews.llvm.org/D27689.  This also has 
some substantive changes:

- Renamed the data structure PCMCache to MemoryBufferCache, and split it out 
into its own files with tests.

- Simplified logic around whether a MemoryBuffer has already been used.  
Tracking of what has already been validated now takes O(1) memory instead of 
O(n^2).

- Moved FileManager::BufferMgr (the instance of PCMCache) to 
CompilerInstance::PCMCache and ModuleManager::PCMCache (instances of 
IntrusiveRefCntPtr).  This took some work to thread through, 
but since the PCMCache isn't related to the FileManager, this seemed like a 
cleaner result.

- Added some testcases for bugs we've found in the meantime (thanks to Adrian 
Prantl).  Primarily, we no longer error or cause a use-after-free if a 
MemoryBuffer was validated by an ancestor.


https://reviews.llvm.org/D28299

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td
  clang/include/clang/Basic/MemoryBufferCache.h
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/Module.h
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/MemoryBufferCache.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/GeneratePCH.cpp
  clang/lib/Serialization/ModuleManager.cpp
  clang/test/Modules/Inputs/outofdate-rebuild/AppKit.h
  clang/test/Modules/Inputs/outofdate-rebuild/Cocoa.h
  clang/test/Modules/Inputs/outofdate-rebuild/CoreText.h
  clang/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h
  clang/test/Modules/Inputs/outofdate-rebuild/Foundation.h
  clang/test/Modules/Inputs/outofdate-rebuild/module.modulemap
  clang/test/Modules/Inputs/system-out-of-date/X.h
  clang/test/Modules/Inputs/system-out-of-date/Y.h
  clang/test/Modules/Inputs/system-out-of-date/Z.h
  clang/test/Modules/Inputs/system-out-of-date/module.map
  clang/test/Modules/Inputs/warning-mismatch/Mismatch.h
  clang/test/Modules/Inputs/warning-mismatch/System.h
  clang/test/Modules/Inputs/warning-mismatch/module.modulemap
  clang/test/Modules/outofdate-rebuild.m
  clang/test/Modules/system-out-of-date-test.m
  clang/test/Modules/warning-mismatch.m
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/MemoryBufferCacheTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp
  clang/unittests/Lex/LexerTest.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp
  clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Index: clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
===
--- clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
+++ clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/MemoryBufferCache.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
@@ -93,10 +94,11 @@
   SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
 
   VoidModuleLoader ModLoader;
+  MemoryBufferCache PCMCache;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, Target.get());
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
-  SourceMgr, HeaderInfo, ModLoader,
+  SourceMgr, PCMCache, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
   PP.Initialize(*Target);
Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/MemoryBufferCache.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
@@ -161,13 +162,14 @@
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
 
 VoidModuleLoader ModLoader;
+MemoryBufferCache PCMCache;
 
 HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
 Diags, LangOpts, Target.get());
 AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader);
 
 Preprocessor PP(std::make_shared(), Diags, LangOpts,
-SourceMgr, HeaderInfo, 

[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Basic/Targets.cpp:4244
+} else // allow locked atomics up to 4 bytes
+  MaxAtomicPromoteWidth = 32;
+  }

ahatanak wrote:
> mgorny wrote:
> > dim wrote:
> > > Are you purposefully not setting `MaxAtomicInlineWidth` here?  (It seems 
> > > from `TargetInfo` that the default value is zero.)
> > > 
> > Yes. I've based this on what's done for ARM. Unless I misunderstood 
> > something, this means that on 'plain' i386 there is no inline atomics 
> > support but we still want to do atomics-via-locking up to 32-bit types. I'm 
> > not sure about 32/64 here to match i486.
> If there isn't a test case for plain i386, is it possible to add one (perhaps 
> in test/Sema/atomic-ops.c)?
I could do that. However, @joerg suggested dropping i386 branch entirely, and 
assuming i486+.


https://reviews.llvm.org/D29542



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


[PATCH] D28835: [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.

2017-02-06 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added a comment.

Gentle and melodic ping.


https://reviews.llvm.org/D28835



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Basic/Targets.cpp:4244
+} else // allow locked atomics up to 4 bytes
+  MaxAtomicPromoteWidth = 32;
+  }

mgorny wrote:
> dim wrote:
> > Are you purposefully not setting `MaxAtomicInlineWidth` here?  (It seems 
> > from `TargetInfo` that the default value is zero.)
> > 
> Yes. I've based this on what's done for ARM. Unless I misunderstood 
> something, this means that on 'plain' i386 there is no inline atomics support 
> but we still want to do atomics-via-locking up to 32-bit types. I'm not sure 
> about 32/64 here to match i486.
If there isn't a test case for plain i386, is it possible to add one (perhaps 
in test/Sema/atomic-ops.c)?


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Generic should imply i486+. I don't think any general purpose system supports 
i386 at this point, simply because it has an annoying number of bugs in 
critical components. The i486 (esp. the non-crippled ones) are reasonable easy 
to support and there are still people around with hardware, esp. clones.


https://reviews.llvm.org/D29542



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


[PATCH] D16135: Macro Debug Info support in Clang

2017-02-06 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Few more inline comments.
I think the code itself is looking good now. Why doesn't this patch include any 
test cases? I would have expected some that exercise the command line include 
handling, etc., ...




Comment at: lib/CodeGen/MacroPPCallbacks.h:35
+
+  /// Counts current number of command line included files, which was entered
+  /// and was not exited yet.

s/was/were/



Comment at: lib/CodeGen/MacroPPCallbacks.h:37
+  /// and was not exited yet.
+  int CommandIncludeFiles = 0;
+

What about EnteredCommandLineIncludes or EnteredCommandLineIncludeFiles?


https://reviews.llvm.org/D16135



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D29542#667814, @joerg wrote:

> At this point, I don't think there is any use on pretending that 
> i386-as-default makes sense. So I would request that the i386 case should be 
> made explicit or just dropped, with a preference for the latter.


By the former, do you mean making `CK_Generic` imply i486+ or i586+? What about 
line ~3947 where the same conditions are used to control other definitions? 
Should they be changed too?


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Basic/Targets.cpp:1808
+if (HostTriple.getArch() == llvm::Triple::x86)
+  HostTarget->setCPU("i586");
+

jlebar wrote:
> mgorny wrote:
> > jlebar wrote:
> > > Okay, is this still needed now?
> > Yes. I've specifically tested with it commented out, and the CPU gets 
> > initiated to generic (=no inline atomics) then.
> Yes, but is that a bug?  Does that break the test?
> 
> I thought the problem we were trying to solve here was that CUDA host and 
> device builds did not define the same macros.  And I thought that setCPU 
> modified the values for MaxAtomicInlineWidth and MaxAtomicPromoteWidth.  
> Moreover I thought that we called HostTarget->setCPU before calling this 
> function.
> 
> If all of those things are true, I don't see what problem we're solving by 
> calling HostTarget->setCPU("i586") here.
Well, the thing is, we don't call `HostTarget->setCPU()` before this function. 
We just call `AllocateTarget()`, and it does not set the CPU.

Normally the CPU is set in Driver, based on `-march` etc. if provided, with 
fallback to platform-specific defaults. In the case of host-side CUDA build, 
the Driver sets x86-specific CPU. While the defaults differ per platform, for 
all platforms supporting CUDA it's i586+.

Now, for the target-side, the Driver creates NVPTX target, and sets 
NVPTX-specific CPU. The `HostTarget` instance is only created within 
`NVPTXTargetInfo`, and so we need to `setCPU()` explicitly. Since we can 
reliably assume that the host-side will be i586+, we use `i586` here.

So far this didn't matter since all atomic properties were defined statically. 
However, this patch changes them to adjust to the CPU used, and so if the 
`X8632TargetInfo` instance is allocated without an explicit `setCPU()` call, it 
defaults to generic x86 (= no inline atomics available) which is different from 
the host platform default. As a result, different macros are defined and the 
test fails.


https://reviews.llvm.org/D29542



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


[PATCH] D28445: [Analyzer] Extend taint propagation and checking

2017-02-06 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 87237.
vlad.tsyrklevich marked 4 inline comments as done.
vlad.tsyrklevich added a comment.

As Artem mentioned, I reworked `getLCVSymbol()` to get the default bindings 
directly from the StoreManager which required adding a new method. I also 
reverted the tainting logic to add taint more conservatively. I have another 
change that will fix the new FIXME test that is added, but it might involved 
some refactoring and discussion so I've left it out to make this change as 
simple as possible.


https://reviews.llvm.org/D28445

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -169,6 +169,43 @@
   sock = socket(AF_LOCAL, SOCK_STREAM, 0);
   read(sock, buffer, 100);
   execl(buffer, "filename", 0); // no-warning
+
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  // References to both buffer and  as an argument should taint the argument
+  read(sock, , 100);
+  execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testStruct() {
+  struct {
+char buf[16];
+int length;
+  } tainted;
+
+  char buffer[16];
+  int sock;
+
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  read(sock, , sizeof(tainted));
+  __builtin_memcpy(buffer, tainted.buf, tainted.length); // expected-warning {{Untrusted data is used to specify the buffer size}}
+}
+
+void testStructArray() {
+  struct {
+char buf[16];
+struct {
+  int length;
+} st[1];
+  } tainted;
+
+  char buffer[16];
+  int sock;
+
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  read(sock, [0], sizeof(tainted.buf));
+  read(sock, [0], sizeof(tainted.st));
+  // FIXME: tainted.st[0].length should be marked tainted
+  __builtin_memcpy(buffer, tainted.buf, tainted.st[0].length); // no-warning
 }
 
 int testDivByZero() {
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -494,6 +494,18 @@
 return getBinding(getRegionBindings(S), L, T);
   }
 
+  SVal getDefaultBinding(Store S, nonloc::LazyCompoundVal L) override {
+if (!L.getRegion())
+  return UnknownVal();
+
+RegionBindingsRef B = getRegionBindings(S);
+const MemRegion *MR  = L.getRegion()->getBaseRegion();
+if (Optional V = B.getDefaultBinding(MR))
+  return *V;
+
+return UnknownVal();
+  }
+
   SVal getBinding(RegionBindingsConstRef B, Loc L, QualType T = QualType());
 
   SVal getBindingForElement(RegionBindingsConstRef B, const ElementRegion *R);
Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -65,6 +65,10 @@
   /// and thus, is tainted.
   static bool isStdin(const Expr *E, CheckerContext );
 
+  /// \brief Get the symbol for the region underlying a LazyCompoundVal.
+  static SymbolRef getLCVSymbol(CheckerContext ,
+nonloc::LazyCompoundVal );
+
   /// \brief Given a pointer argument, get the symbol of the value it contains
   /// (points to).
   static SymbolRef getPointedToSymbol(CheckerContext , const Expr *Arg);
@@ -423,6 +427,22 @@
   return false;
 }
 
+SymbolRef GenericTaintChecker::getLCVSymbol(CheckerContext ,
+nonloc::LazyCompoundVal ) {
+  StoreManager  = C.getStoreManager();
+  SymbolRef Sym = StoreMgr.getDefaultBinding(LCV.getStore(), LCV).getAsSymbol();
+  if (!Sym)
+return nullptr;
+
+  // If the LCV covers an entire base region, return the default conjured symbol
+  if (LCV.getRegion() == LCV.getRegion()->getBaseRegion())
+return Sym;
+
+  // Otherwise, return a derived symbol indicating only a sub-region is tainted
+  SymbolManager  = C.getSymbolManager();
+  return SM.getDerivedSymbol(Sym, LCV.getRegion());
+}
+
 SymbolRef GenericTaintChecker::getPointedToSymbol(CheckerContext ,
   const Expr* Arg) {
   ProgramStateRef State = C.getState();
@@ -438,6 +458,10 @@
 dyn_cast(Arg->getType().getCanonicalType().getTypePtr());
   SVal Val = State->getSVal(*AddrLoc,
 ArgTy ? ArgTy->getPointeeType(): QualType());
+
+  if (auto LCV = Val.getAs())
+return getLCVSymbol(C, *LCV);
+
   return Val.getAsSymbol();
 }
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ 

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D29267#667487, @alexfh wrote:

> I wonder whether there's a compiler diagnostic for this purpose. Compiler 
> diagnostics are more efficient at reaching users and should be preferred 
> where they are appropriate (this seems like one of such cases).


I don't think a compiler diagnostic would be appropriate for this. It would be 
incredibly chatty for people who do need to use the assembler.


https://reviews.llvm.org/D29267



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


r294197 - [SystemZ] Provide predefined __ARCH__ and __VX__ macros

2017-02-06 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Mon Feb  6 11:04:22 2017
New Revision: 294197

URL: http://llvm.org/viewvc/llvm-project?rev=294197=rev
Log:
[SystemZ] Provide predefined __ARCH__ and __VX__ macros

GCC 7 will predefine two new macros on s390x:

- __ARCH__ indicates the ISA architecture level
- __VX__ indicates that the vector facility is available

This adds those macros to clang as well to ensure continued
compatibility with GCC.


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=294197=294196=294197=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 11:04:22 2017
@@ -7037,6 +7037,15 @@ public:
 Builder.defineMacro("__zarch__");
 Builder.defineMacro("__LONG_DOUBLE_128__");
 
+const std::string ISARev = llvm::StringSwitch(CPU)
+   .Cases("arch8", "z10", "8")
+   .Cases("arch9", "z196", "9")
+   .Cases("arch10", "zEC12", "10")
+   .Cases("arch11", "z13", "11")
+   .Default("");
+if (!ISARev.empty())
+  Builder.defineMacro("__ARCH__", ISARev);
+
 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");
@@ -7044,6 +7053,8 @@ public:
 
 if (HasTransactionalExecution)
   Builder.defineMacro("__HTM__");
+if (HasVector)
+  Builder.defineMacro("__VX__");
 if (Opts.ZVector)
   Builder.defineMacro("__VEC__", "10301");
   }

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=294197=294196=294197=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Feb  6 11:04:22 
2017
@@ -2035,35 +2035,76 @@
 
 // Begin SystemZ/GCC/Linux tests 
 //
+// RUN: %clang -march=arch8 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
 // RUN: %clang -march=z10 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_Z10
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
 //
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
-// CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390x__ 1
-// CHECK_SYSTEMZ_Z10: #define __zarch__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __ARCH__ 8
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH8: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __zarch__ 1
 //
-// RUN: %clang -march=zEC12 -E -dM %s -o - 2>&1 \
+// RUN: %clang -march=arch9 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+// RUN: %clang -march=z196 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+//
+// CHECK_SYSTEMZ_ARCH9: #define __ARCH__ 9
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH9: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __zarch__ 1
+//
 // RUN: %clang -march=arch10 -E -dM %s -o - 2>&1 \
 // RUN: -target s390x-unknown-linux \
-// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN:   | FileCheck -match-full-lines %s 

[PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2017-02-06 Thread Daphne Pfister via Phabricator via cfe-commits
daphnediane added a comment.

In https://reviews.llvm.org/D21279#667471, @bmharper wrote:

> Thanks @daphnediane. I only read your comment after merging, but that would 
> have been helpful.


If you still want my diff let me know as it is slightly different from yours. 
No longer has NestingAndIndent level as a data member of Changes ( but has a 
inline method that gets the values though not 100% sure that is needed as I 
experimented with a version without it), no longer needs propagateIndentLevels, 
etc.


https://reviews.llvm.org/D21279



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

At this point, I don't think there is any use on pretending that 
i386-as-default makes sense. So I would request that the i386 case should be 
made explicit or just dropped, with a preference for the latter.


https://reviews.llvm.org/D29542



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


[PATCH] D29162: AMDGPU: Add a test checking alignments of emitted globals/allocas

2017-02-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks!


https://reviews.llvm.org/D29162



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: lib/Basic/Targets.cpp:1808
+if (HostTriple.getArch() == llvm::Triple::x86)
+  HostTarget->setCPU("i586");
+

mgorny wrote:
> jlebar wrote:
> > Okay, is this still needed now?
> Yes. I've specifically tested with it commented out, and the CPU gets 
> initiated to generic (=no inline atomics) then.
Yes, but is that a bug?  Does that break the test?

I thought the problem we were trying to solve here was that CUDA host and 
device builds did not define the same macros.  And I thought that setCPU 
modified the values for MaxAtomicInlineWidth and MaxAtomicPromoteWidth.  
Moreover I thought that we called HostTarget->setCPU before calling this 
function.

If all of those things are true, I don't see what problem we're solving by 
calling HostTarget->setCPU("i586") here.


https://reviews.llvm.org/D29542



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


[PATCH] D29162: AMDGPU: Add a test checking alignments of emitted globals/allocas

2017-02-06 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D29162



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


[PATCH] D29162: AMDGPU: Add a test checking alignments of emitted globals/allocas

2017-02-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


https://reviews.llvm.org/D29162



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


r294195 - [OpenMP] Remove fixme comment in regression test and related unnecessary statement

2017-02-06 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Mon Feb  6 10:03:41 2017
New Revision: 294195

URL: http://llvm.org/viewvc/llvm-project?rev=294195=rev
Log:
[OpenMP] Remove fixme comment in regression test and related unnecessary 
statement

https://reviews.llvm.org/D29501

It looks like I forgot to remove a FIXME comment with the associated statement. 
The test does not need it and it gives the wrong impression of being an 
incomplete test.


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

Modified: cfe/trunk/test/OpenMP/distribute_lastprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_lastprivate_codegen.cpp?rev=294195=294194=294195=diff
==
--- cfe/trunk/test/OpenMP/distribute_lastprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_lastprivate_codegen.cpp Mon Feb  6 
10:03:41 2017
@@ -229,8 +229,6 @@ int main() {
 // the distribute loop
 // CHECK: call void @__kmpc_for_static_init_4(
 // assignment: vec[i] = t_var;
-// the following is extremely weak, because it assumes ordering of this load 
with no reference after the call to static_init: fix
-// CHECK: [[IV_VAL:%.+]] =
 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* 
[[T_VAR_PRIV]],
 // CHECK: [[VEC_PTR:%.+]] = getelementptr inbounds [2 x i{{[0-9]+}}], [2 x 
i{{[0-9]+}}]* [[VEC_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} {{.+}}
 // CHECK:  store i{{[0-9]+}} [[T_VAR_PRIV_VAL]], i{{[0-9]+}}* [[VEC_PTR]],


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


[libcxx] r294194 - Add some tests to verify that we implement LWG#2837 correctly. No functional change.

2017-02-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Feb  6 10:03:23 2017
New Revision: 294194

URL: http://llvm.org/viewvc/llvm-project?rev=294194=rev
Log:
Add some tests to verify that we implement LWG#2837 correctly. No functional 
change.

Modified:
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
libcxx/trunk/www/upcoming_meeting.html

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp?rev=294194=294193=294194=diff
==
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp Mon 
Feb  6 10:03:23 2017
@@ -129,4 +129,11 @@ int main()
 assert((do_test(non_cce)));
 assert((do_test(non_cce)));
 assert((do_test(non_cce)));
+
+//  LWG#2837
+{
+auto res = std::gcd((int64_t)1234, (int32_t)-2147483648);
+static_assert( std::is_same::type>::value, "");
+assert(res == 2);
+}
 }

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp?rev=294194=294193=294194=diff
==
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp Mon 
Feb  6 10:03:23 2017
@@ -128,4 +128,11 @@ int main()
 assert((do_test(non_cce)));
 assert((do_test(non_cce)));
 assert((do_test(non_cce)));
+
+//  LWG#2837
+{
+auto res = std::lcm((int64_t)1234, (int32_t)-2147483648);
+static_assert( std::is_same::type>::value, "");
+assert(res == -1324997410816LL);
+}
 }

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=294194=294193=294194=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon Feb  6 10:03:23 2017
@@ -77,7 +77,7 @@
http://wg21.link/LWG2826;>2826string_view 
iterators use old wordingKonaNothing to do
http://wg21.link/LWG2834;>2834Resolution 
LWG 2223 is missing wording about end iteratorsKonaNothing 
to do
http://wg21.link/LWG2835;>2835LWG 2536 
seems to misspecify tgmath.hKona
-   http://wg21.link/LWG2837;>2837gcd and lcm 
should support a wider range of input valuesKona
+   http://wg21.link/LWG2837;>2837gcd and lcm 
should support a wider range of input valuesKonaWe do this 
already
http://wg21.link/LWG2838;>2838is_literal_type specification 
needs a little cleanupKonaNothing to do
http://wg21.link/LWG2842;>2842in_place_t 
check for optional::optional(U) should decay 
UKona
http://wg21.link/LWG2850;>2850std::function move constructor 
does unnecessary workKona
@@ -111,7 +111,7 @@
 2826 - Nothing to do; just moving words around
 2834 - Nothing to do; just moving words around
 2835 - I'm pretty sure we already do this.
-2837 - Doesn't look too hard.
+2837 - Added some tests to ensure we do this already.
 2838 - Nothing to do; just moving words around
 2842 - This should be easy; trick will be devising tests.
 2850 - I think we already do this.


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


[clang-tools-extra] r294193 - [clang-tidy] misc-argument-comment support for gmock

2017-02-06 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb  6 09:47:17 2017
New Revision: 294193

URL: http://llvm.org/viewvc/llvm-project?rev=294193=rev
Log:
[clang-tidy] misc-argument-comment support for gmock

Now for real. The use case supported previously is used by approximately nobody.
What's needed is support for matching argument comments in EXPECT_xxx calls to
the names of parameters of the mocked methods.

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment-gmock.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=294193=294192=294193=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Mon Feb  6 
09:47:17 2017
@@ -12,6 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
+#include "../utils/LexerUtils.h"
 
 using namespace clang::ast_matchers;
 
@@ -86,8 +87,26 @@ getCommentsInRange(ASTContext *Ctx, Char
   return Comments;
 }
 
-bool ArgumentCommentCheck::isLikelyTypo(llvm::ArrayRef Params,
-StringRef ArgName, unsigned ArgIndex) {
+static std::vector>
+getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) {
+  std::vector> Comments;
+  while (Loc.isValid()) {
+clang::Token Tok =
+utils::lexer::getPreviousToken(*Ctx, Loc, /*SkipComments=*/false);
+if (Tok.isNot(tok::comment))
+  break;
+Loc = Tok.getLocation();
+Comments.emplace_back(
+Loc,
+Lexer::getSourceText(CharSourceRange::getCharRange(
+ Loc, Loc.getLocWithOffset(Tok.getLength())),
+ Ctx->getSourceManager(), Ctx->getLangOpts()));
+  }
+  return Comments;
+}
+
+static bool isLikelyTypo(llvm::ArrayRef Params,
+ StringRef ArgName, unsigned ArgIndex) {
   std::string ArgNameLowerStr = ArgName.lower();
   StringRef ArgNameLower = ArgNameLowerStr;
   // The threshold is arbitrary.
@@ -128,72 +147,129 @@ static bool sameName(StringRef InComment
   return InComment.compare_lower(InDecl) == 0;
 }
 
+// This uses implementation details of MOCK_METHODx_ macros: for each mocked
+// method M it defines M() with appropriate signature and a method used to set
+// up expectations - gmock_M() - with each argument's type changed the
+// corresponding matcher. This function finds M by gmock_M.
+static const CXXMethodDecl *
+findMockedMethod(const CXXMethodDecl *ExpectMethod) {
+  if (!ExpectMethod->getNameInfo().getName().isIdentifier())
+return nullptr;
+  StringRef Name = ExpectMethod->getName();
+  if (!Name.startswith("gmock_"))
+return nullptr;
+  Name = Name.substr(strlen("gmock_"));
+
+  const DeclContext *Ctx = ExpectMethod->getDeclContext();
+  if (Ctx == nullptr || !Ctx->isRecord())
+return nullptr;
+  for (const auto *D : Ctx->decls()) {
+if (const auto *Method = dyn_cast(D)) {
+  if (Method->getName() != Name)
+continue;
+  // Sanity check the mocked method.
+  if (Method->getNextDeclInContext() == ExpectMethod &&
+  Method->getLocation().isMacroID() &&
+  Method->getNumParams() == ExpectMethod->getNumParams()) {
+return Method;
+  }
+}
+  }
+  return nullptr;
+}
+
+// For gmock expectation builder method (the target of the call generated by
+// `EXPECT_CALL(obj, Method(...))`) tries to find the real method being mocked
+// (returns nullptr, if the mock method doesn't override anything). For other
+// functions returns the function itself.
+static const FunctionDecl *resolveMocks(const FunctionDecl *Func) {
+  if (const auto *Method = dyn_cast(Func)) {
+if (const auto *MockedMethod = findMockedMethod(Method)) {
+  // If mocked method overrides the real one, we can use its parameter
+  // names, otherwise we're out of luck.
+  if (MockedMethod->size_overridden_methods() > 0) {
+return *MockedMethod->begin_overridden_methods();
+  }
+  return nullptr;
+}
+  }
+  return Func;
+}
+
 void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
- const FunctionDecl *Callee,
+ const FunctionDecl *OriginalCallee,
  SourceLocation ArgBeginLoc,
  llvm::ArrayRef Args) {
+  const FunctionDecl *Callee = resolveMocks(OriginalCallee);
+  if (!Callee)
+return;
+
   Callee = 

[clang-tools-extra] r294192 - [clang-tidy] getPreviousNonCommentToken -> getPreviousToken

2017-02-06 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb  6 09:46:33 2017
New Revision: 294192

URL: http://llvm.org/viewvc/llvm-project?rev=294192=rev
Log:
[clang-tidy] getPreviousNonCommentToken -> getPreviousToken

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=294192=294191=294192=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Mon Feb  6 09:46:33 2017
@@ -125,12 +125,12 @@ struct IntializerInsertion {
 SourceLocation Location;
 switch (Placement) {
 case InitializerPlacement::New:
-  Location = utils::lexer::getPreviousNonCommentToken(
+  Location = utils::lexer::getPreviousToken(
  Context, Constructor.getBody()->getLocStart())
  .getLocation();
   break;
 case InitializerPlacement::Before:
-  Location = utils::lexer::getPreviousNonCommentToken(
+  Location = utils::lexer::getPreviousToken(
  Context, Where->getSourceRange().getBegin())
  .getLocation();
   break;

Modified: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp?rev=294192=294191=294192=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp Mon 
Feb  6 09:46:33 2017
@@ -40,7 +40,7 @@ void SuspiciousSemicolonCheck::check(con
 return;
 
   ASTContext  = *Result.Context;
-  auto Token = utils::lexer::getPreviousNonCommentToken(Ctxt, LocStart);
+  auto Token = utils::lexer::getPreviousToken(Ctxt, LocStart);
   auto  = *Result.SourceManager;
   unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart);
 

Modified: clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp?rev=294192=294191=294192=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/FixItHintUtils.cpp Mon Feb  6 
09:46:33 2017
@@ -18,7 +18,7 @@ namespace fixit {
 
 FixItHint changeVarDeclToReference(const VarDecl , ASTContext ) {
   SourceLocation AmpLocation = Var.getLocation();
-  auto Token = utils::lexer::getPreviousNonCommentToken(Context, AmpLocation);
+  auto Token = utils::lexer::getPreviousToken(Context, AmpLocation);
   if (!Token.is(tok::unknown))
 AmpLocation = Lexer::getLocForEndOfToken(Token.getLocation(), 0,
  Context.getSourceManager(),

Modified: clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp?rev=294192=294191=294192=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.cpp Mon Feb  6 09:46:33 
2017
@@ -14,8 +14,8 @@ namespace tidy {
 namespace utils {
 namespace lexer {
 
-Token getPreviousNonCommentToken(const ASTContext ,
- SourceLocation Location) {
+Token getPreviousToken(const ASTContext , SourceLocation Location,
+   bool SkipComments) {
   const auto  = Context.getSourceManager();
   Token Token;
   Token.setKind(tok::unknown);
@@ -27,7 +27,7 @@ Token getPreviousNonCommentToken(const A
   Context.getLangOpts());
 if (!Lexer::getRawToken(Location, Token, SourceManager,
 Context.getLangOpts()) &&
-!Token.is(tok::comment)) {
+(!SkipComments || !Token.is(tok::comment))) {
   break;
 }
 Location = Location.getLocWithOffset(-1);

Modified: clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/LexerUtils.h?rev=294192=294191=294192=diff
==
--- 

[PATCH] D24933: Enable configuration files in clang

2017-02-06 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked 2 inline comments as done.
sepavloff added inline comments.



Comment at: lib/Driver/ToolChain.cpp:183
   std::string Target;
-  if (llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError)) {
+  if (!VerifyTarget || llvm::TargetRegistry::lookupTarget(Prefix, 
IgnoredError))
 Target = Prefix;

hfinkel wrote:
> I don't think that we can do it this way; it is a behavior change (we now 
> might try to set the target to some string which did not validate as a known 
> target, whereas we did not previously).
> 
> How about you always return the prefix, but also return a boolean indicating 
> whether or not the prefix is a valid target? Then, after processing the 
> config file, you can clear out the string if it was not a valid target.
Changed implementation of this function. Indeed using explicit flag looks more 
clear than conditional setting target name.



Comment at: tools/driver/driver.cpp:363
+   TargetAndMode.first + ".cfg");
+TargetAndMode.first.clear();
+  }

hfinkel wrote:
> I don't think that you can clear the string here. We might need it later to 
> call insertTargetAndModeArgs.
With new implementation of `ToolChain::getTargetAndModeFromProgramName` it is 
not needed anymore.


https://reviews.llvm.org/D24933



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


[PATCH] D24933: Enable configuration files in clang

2017-02-06 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 87229.
sepavloff added a comment.
Herald added a subscriber: klimek.

Updated patch


https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Tooling/Tooling.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/config-file.c
  test/Driver/config-file2.c
  test/Driver/lit.local.cfg
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -199,22 +199,23 @@
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
 
-static void insertTargetAndModeArgs(StringRef Target, StringRef Mode,
+static void insertTargetAndModeArgs(const ToolChain::DriverNameParts ,
 SmallVectorImpl ,
 std::set ) {
-  if (!Mode.empty()) {
+  if (!NameParts.ModeSuffix.empty()) {
 // Add the mode flag to the arguments.
 auto it = ArgVector.begin();
 if (it != ArgVector.end())
   ++it;
-ArgVector.insert(it, GetStableCStr(SavedStrings, Mode));
+ArgVector.insert(it, GetStableCStr(SavedStrings, NameParts.ModeSuffix));
   }
 
-  if (!Target.empty()) {
+  if (NameParts.TargetIsValid) {
 auto it = ArgVector.begin();
 if (it != ArgVector.end())
   ++it;
-const char *arr[] = {"-target", GetStableCStr(SavedStrings, Target)};
+const char *arr[] = {"-target", GetStableCStr(SavedStrings,
+  NameParts.TargetPrefix)};
 ArgVector.insert(it, std::begin(arr), std::end(arr));
   }
 }
@@ -305,6 +306,16 @@
   return 1;
 }
 
+// Directories searched for configuration specified by option '--config'.
+static const ArrayRef SearchDirs = {
+#if defined(CLANG_CONFIG_FILE_USER_DIR)
+  CLANG_CONFIG_FILE_USER_DIR,
+#endif
+#if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
+  CLANG_CONFIG_FILE_SYSTEM_DIR
+#endif
+};
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -324,21 +335,52 @@
 
   llvm::InitializeAllTargets();
   std::string ProgName = argv[0];
-  std::pair TargetAndMode =
-  ToolChain::getTargetAndModeFromProgramName(ProgName);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(ProgName);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
+  // Try reading options from configuration file.
+  llvm::SmallString<128> ConfigFile;
+  bool CfgFound;
+  std::string ErrText;
+
+  // First try config file specified in command line. It has higher priority
+  // than any other way to specify configuration.
+  CfgFound = llvm::cl::findConfigFile(ConfigFile, argv, SearchDirs, true,
+  ErrText);
+  if (!CfgFound && !ErrText.empty()) {
+llvm::errs() << ProgName << ": CommandLine Error :" << ErrText << '\n';
+return 1;
+  }
+
+  // If config file is not specified explicitly, try to determine configuration
+  // implicitly. First try to deduce configuration from executable name. For
+  // instance, a file 'armv7l-clang' applies config file 'armv7l.cfg'.
+  if (!CfgFound && !TargetAndMode.TargetPrefix.empty())
+CfgFound = llvm::cl::searchForFile(ConfigFile, SearchDirs, ProgName,
+   TargetAndMode.TargetPrefix + ".cfg");
+
+  // If config file is found, read options from it.
+  unsigned NumConfigOptions = 0;
+  if (CfgFound) {
+if (!llvm::cl::readConfigFile(ConfigFile, Saver, argv, NumConfigOptions)) {
+  llvm::errs() << ProgName <<
+": CommandLine Error : Cannot read configuration file '" <<
+ConfigFile.c_str() << "'\n";
+  return 1;
+}
+  }
+
   // Parse response files using the GNU syntax, unless we're in CL mode. There
   // are two ways to put clang in CL compatibility mode: argv[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
   // command line parsing can't happen until after response file parsing, so we
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
-  if (TargetAndMode.second == "--driver-mode=cl" ||
+  if (TargetAndMode.ModeSuffix == "--driver-mode=cl" ||
   std::find_if(argv.begin(), argv.end(), [](const char *F) {
 return F && strcmp(F, 

[libcxx] r294189 - Set up 'upcoming meeting' bug list

2017-02-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Feb  6 09:17:22 2017
New Revision: 294189

URL: http://llvm.org/viewvc/llvm-project?rev=294189=rev
Log:
Set up 'upcoming meeting' bug list

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=294189=294188=294189=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon Feb  6 09:17:22 2017
@@ -59,163 +59,71 @@
   
Issue #Issue 
NameMeetingStatus
 
-http://wg21.link/LWG2062;>2062Effect 
contradictions w/o no-throw guarantee of std::function 
swapsIssaquahNothing to do.
-http://wg21.link/LWG2166;>2166Heap 
property underspecified?Issaquah
-http://wg21.link/LWG2221;>2221No 
formatted output operator for nullptrIssaquahPatch 
ready
-http://wg21.link/LWG2223;>2223shrink_to_fit effect on 
iterator validityIssaquahNothing to do.
-http://wg21.link/LWG2261;>2261Are 
containers required to use their 'pointer' type 
internally?Issaquah
-http://wg21.link/LWG2394;>2394locale::name specification 
unclear - what is implementation-defined?IssaquahNothing to 
do.
-http://wg21.link/LWG2460;>2460LWG issue 
2408 and value categoriesIssaquahNothing to do.
-http://wg21.link/LWG2468;>2468Self-move-assignment of 
library typesIssaquah
-http://wg21.link/LWG2475;>2475Allow 
overwriting of std::basic_string terminator with charT() to allow cleaner 
interoperation with legacy APIsIssaquahNothing to 
do.
-http://wg21.link/LWG2503;>2503multiline 
option should be added to syntax_option_typeIssaquah
-http://wg21.link/LWG2510;>2510Tag types 
should not be DefaultConstructibleIssaquah
-http://wg21.link/LWG2514;>2514Type 
traits must not be finalIssaquahNothing to do
-http://wg21.link/LWG2519;>2519Iterator 
operator-= has gratuitous undefined behaviourIssaquahNothing 
to do
-http://wg21.link/LWG2531;>2531future::get should explicitly 
state that the shared state is releasedIssaquah
-http://wg21.link/LWG2534;>2534Constrain 
rvalue stream operatorsIssaquah
-http://wg21.link/LWG2536;>2536What 
should complex.h do?IssaquahWe already do 
this
-http://wg21.link/LWG2540;>2540unordered_multimap::insert 
hint iteratorIssaquahWe already do this
-http://wg21.link/LWG2543;>2543LWG 2148 
(hash support for enum types) seems under-specifiedIssaquahWe 
already do this
-http://wg21.link/LWG2544;>2544istreambuf_iterator(basic_streambuf* s) effects unclear when s is 0IssaquahWe already do 
this
-http://wg21.link/LWG2556;>2556Wide 
contract for future::share()IssaquahPatch ready
-http://wg21.link/LWG2562;>2562Consistent 
total ordering of pointers by comparison 
functorsIssaquah
-http://wg21.link/LWG2567;>2567Specification of logical 
operator traits uses BaseCharacteristic, which is defined only for 
UnaryTypeTraits and BinaryTypeTraitsIssaquahNothing to 
do.
-http://wg21.link/LWG2569;>2569conjunction and disjunction 
requirements are too strictIssaquahNothing to do.
-http://wg21.link/LWG2570;>2570[fund.ts.v2] conjunction and 
disjunction requirements are too strictIssaquah
-http://wg21.link/LWG2578;>2578Iterator 
requirements should reference iterator traitsIssaquahNothing 
to do
-http://wg21.link/LWG2584;>2584 
ECMAScript IdentityEscape is ambiguousIssaquah
-http://wg21.link/LWG2589;>2589match_results can't satisfy 
the requirements of a containerIssaquahNothing to do
-http://wg21.link/LWG2591;>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquah
-http://wg21.link/LWG2598;>2598addressof 
works on temporariesIssaquahPatch ready
-http://wg21.link/LWG2664;>2664operator/ 
(and other append) semantics not useful if argument has 
rootIssaquahNothing to do
-http://wg21.link/LWG2665;>2665remove_filename() post 
condition is incorrectIssaquahSee Below
-http://wg21.link/LWG2672;>2672Should 
is_empty use error_code in its specification?IssaquahWe 
already do this
-http://wg21.link/LWG2678;>2678std::filesystem enum classes 
overspecifiedIssaquahNothing to do
-http://wg21.link/LWG2679;>2679Inconsistent Use of Effects 
and Equivalent ToIssaquahNothing to do
-http://wg21.link/LWG2680;>2680Add 
"Equivalent to" to filesystemIssaquahNothing to do
-http://wg21.link/LWG2681;>2681filesystem::copy() cannot copy 
symlinksIssaquahWe already do this
-http://wg21.link/LWG2682;>2682filesystem::copy() won't 
create a symlink to a directoryIssaquahImplemented in 
trunk
-http://wg21.link/LWG2686;>2686Why is 
std::hash specialized for error_code, but not 
error_condition?IssaquahPatch ready
-

[PATCH] D20689: [clang-tidy] Suspicious Call Argument checker

2017-02-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I think this might be better as a readability checker to find misleading 
variable or parameter names.

It would also be great to consider types. Unfortunately it probably means 
reimplementing some of the logic from Sema, since that information is not 
available at this point.

@varjujan
Do you actually use all of the heuristics that are implemented?


https://reviews.llvm.org/D20689



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-02-06 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 87228.
JDevlieghere added a comment.

- Add explicit check to matcher as suggested by @aaron.ballman


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,188 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+// libc++'s implementation
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E 
+  typedef const _E _reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+
+template 
+class vector {
+public:
+  vector(T){};
+  vector(std::initializer_list) {}
+};
+}
+
+class Bar {};
+
+Bar b;
+
+class Foo {
+public:
+  Foo(Bar);
+  explicit Foo(Bar, unsigned int);
+  Foo(unsigned int);
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar){};
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b;
+  return A(b);
+}
+
+Foo f5() {
+  Bar b;
+  return Quux(b);
+}
+
+Foo f6() {
+  Bar b;
+  return Foo(b, 1);
+}
+
+std::vector f7() {
+  int i = 1;
+  return std::vector(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {i};
+}
+
+Bar f8() {
+  return {};
+}
+
+Bar f9() {
+  return Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {};
+}
+
+Bar f10() {
+  return Bar{};
+}
+
+Foo f11(Bar b) {
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f12() {
+  return f11(Bar());
+}
+
+Foo f13() {
+  return Foo(Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {Bar()};
+}
+
+Foo f14() {
+  // FIXME: Type narrowing should not occur!
+  return Foo(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {-1};
+}
+
+Foo f15() {
+  return Foo(f10());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {f10()};
+}
+
+template 
+T f16() {
+  return T();
+}
+
+Bar i1 = f16();
+Baz i2 = f16();
+
+template 
+Foo f17(T t) {
+  return Foo(t);
+}
+
+Foo i3 = f17(b);
+
+template 
+class BazT {
+public:
+  T m() {
+Bar b;
+return T(b);
+  }
+
+  Foo m2(T t) {
+return Foo(t);
+  }
+};
+
+BazT bazFoo;
+Foo i4 = bazFoo.m();
+Foo i5 = bazFoo.m2(b);
+
+BazT bazQuux;
+Foo i6 = bazQuux.m();
+Foo i7 = bazQuux.m2(b);
+
+auto v1 = []() { return std::vector({1, 2}); }();
+auto v2 = []() -> std::vector { return std::vector({1, 2}); }();
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ 

[PATCH] D29451: Add a prototype for clangd v0.1

2017-02-06 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer updated this revision to Diff 87226.
bkramer marked 8 inline comments as done.
bkramer added a comment.

Address review comments. Make test actually run (missing cmake file)


https://reviews.llvm.org/D29451

Files:
  CMakeLists.txt
  clangd/CMakeLists.txt
  clangd/ClangDMain.cpp
  clangd/DocumentStore.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/CMakeLists.txt
  test/clangd/formatting.test

Index: test/clangd/formatting.test
===
--- /dev/null
+++ test/clangd/formatting.test
@@ -0,0 +1,53 @@
+# RUN: sed -e '/^#/d' %s | clangd | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+# CHECK: Content-Length: 191
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true
+# CHECK: }}}
+#
+Content-Length: 193
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"int foo ( int x ) {\nx = x+1;\nreturn x;\n}"}}}
+#
+#
+Content-Length: 233
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":1,"character":4},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 0, "character": 19}, "end": {"line": 1, "character": 4}}, "newText": "\n  "},{"range": {"start": {"line": 1, "character": 9}, "end": {"line": 1, "character": 9}}, "newText": " "},{"range": {"start": {"line": 1, "character": 10}, "end": {"line": 1, "character": 10}}, "newText": " "},{"range": {"start": {"line": 1, "character": 12}, "end": {"line": 2, "character": 4}}, "newText": "\n  "}]}
+#
+#
+Content-Length: 197
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":5},"contentChanges":[{"text":"int foo ( int x ) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 233
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":1,"character":2},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[]}
+#
+Content-Length: 153
+
+{"jsonrpc":"2.0","id":3,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":[{"range": {"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range": {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}}, "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end": {"line": 0, "character": 16}}, "newText": ""},{"range": {"start": {"line": 2, "character": 11}, "end": {"line": 3, "character": 4}}, "newText": "\n"}]}
+#
+#
+Content-Length: 190
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":9},"contentChanges":[{"text":"int foo(int x) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 153
+
+{"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":4,"result":[]}
+#
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -43,6 +43,7 @@
   # Individual tools we test.
   clang-apply-replacements
   clang-change-namespace
+  clangd
   clang-include-fixer
   clang-move
   clang-query
Index: clangd/ProtocolHandlers.h
===
--- /dev/null
+++ clangd/ProtocolHandlers.h
@@ -0,0 +1,100 @@
+//===--- ProtocolHandlers.h - LSP callbacks -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains the actions performed when the server gets a specific
+// request.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOLHANDLERS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOLHANDLERS_H
+
+#include 

[PATCH] D29451: Add a prototype for clangd v0.1

2017-02-06 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer marked 19 inline comments as done.
bkramer added a comment.

In https://reviews.llvm.org/D29451#667606, @arphaman wrote:

> This might be a bad question, but is there any particular reason why you 
> didn't use the YAML Traits API for parsing instead of the raw YAML Stream 
> API? In my experience the traits based API is quite convenient for structured 
> data like various options and parameters in this protocol.


It's an excellent question. I actually tried to make YAMLTraits work for this, 
but it gets annoying due to the dynamic parts of JSONRPC. You have to first 
parse the method string and then dispatch based on that string. This is not 
something that the YAMLTraits interface supports. I think it could be extended 
to allow mixing code written against YAMLParser with YAMLTraits code and then 
we can clean up the manual code here. Before that happens I want the YAMLParser 
implementation working, because there are some complicated union types in the 
Language Server Protocol that might require additional tweaks to the YAML 
infrastructure.




Comment at: clangd/ClangDMain.cpp:52
+llvm::StringRef LineRef(Line);
+if (LineRef.trim().empty())
+  continue;

djasper wrote:
> Nit: string also has "empty()", right? Maybe only convert to StringRef after 
> this check.
But string doesn't have trim(). An "empty" line still has a \n, which I want to 
discard.



Comment at: clangd/ClangDMain.cpp:65
+// Now read the JSON.
+std::vector JSON;
+JSON.resize(Len);

klimek wrote:
> Adi wrote:
> > Avoid unnecessary JSON.resize(Len) & potential reallocation during 
> > JSON.push_back('\0') by allocating enough space in advance: 
> > std::vector JSON(Len + 1);
> Shouldn't that be unsigned char for raw bytes?
I agree, but that would add pointer punning on every usage, as iostreams and 
YAML parser want normal chars.



Comment at: clangd/ClangDMain.cpp:73-77
+  // Log the message.
+  Logs << "<-- ";
+  Logs.write(JSON.data(), JSON.size());
+  Logs << '\n';
+  Logs.flush();

Adi wrote:
> Since llvm::StringRef does not own the data, I think it would make more sense 
> to do the logging after Dispatcher.call().
But that will confuse the logging. You'd get the query after the answer.



Comment at: clangd/ClangDMain.cpp:74
+  // Log the message.
+  Logs << "<-- ";
+  Logs.write(JSON.data(), JSON.size());

djasper wrote:
> So you currently always print this to std::err.. Should you guard this in 
> DEBUG or something?
My goal is to wire this up to the editor in some way and make it possible to 
discard the log with a command line flag (send it to nulls()). I think using 
DEBUG only makes that more complicated.

That said, the logging parts of clangd probably need a redesign at some point ;)



Comment at: clangd/ClangDMain.cpp:80
+  // Finally, execute the action for this JSON message.
+  Dispatcher.call(llvm::StringRef(JSON.data(), JSON.size() - 1));
+}

Adi wrote:
> Adi wrote:
> > You are building llvm::StringRef without the trailing null byte here, yet 
> > comment above states that YAML parser requires a null byte.
> Perhaps make a log entry if Dispatcher.call() failed.
This is intentional. YAML parser treats the pointer inside of the StringRef as 
a null terminated string, reading past the end of the StringRef.



Comment at: clangd/DocumentStore.h:25
+  /// Add a document to the store. Overwrites existing contents.
+  void setDocument(StringRef Uri, StringRef Text) { Docs[Uri] = Text; }
+  /// Delete a document from the store.

djasper wrote:
> I'd call this addDocument for symmetry with removeDocument. The fact that you 
> phrase the comment that way, also make me think that this will be the more 
> intuitive name.
I picked set because it can overwrite contents and that's how it used. Your 
comment makes sense though so I changed it back to add.



Comment at: clangd/JSONRPCDispatcher.cpp:32-40
+  Logs << "Method ignored.\n";
+  // Return that this method is unsupported.
+  writeMessage(
+  R"({"jsonrpc":"2.0","id":)" + ID +
+  R"(,"error":{"code":-32601}})");
+}
+

Adi wrote:
> I would extract this implementation to the separate handler class (e.g. 
> OperationNotSupportedHandler) and make this an interface class. It would make 
> code and intent more explicit.
The goal of the default methods is to make it easy to implement only one of the 
two methods. If I want to do that with an OperationNotSupportedHandler I'd have 
to inherit from that, which is more awkward.



Comment at: clangd/JSONRPCDispatcher.cpp:82-83
+  // This should be "2.0". Always.
+  Version = dyn_cast(Value);
+  if (Version->getRawValue() != "2.0")
+return false;

Adi wrote:
> dyn_cast might 

[PATCH] D23423: [Clang-tidy] Comparison Function Address

2017-02-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Hi Benedek, could you do the merge or should anybody commandeer these revisions?


Repository:
  rL LLVM

https://reviews.llvm.org/D23423



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


[PATCH] D23421: [Clang-tidy] CERT-MSC53-CPP (checker for std namespace modification)

2017-02-06 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Benedek, do you have time to address the review comments or do you want me to 
commandeer this revision?


Repository:
  rL LLVM

https://reviews.llvm.org/D23421



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


[PATCH] [clang-format]: Add support for changing case/default indent/outdent with clang-format

2017-02-06 Thread Ryan Livingston via cfe-commits
Hi all,


First time submitting a patch here. Any feedback is appreciated.


This proposed patch adds a new configuration option CaseLabelOffset for 
clang-format which behaves similarly to AccessModifierOffset. Namely, it 
permits modifying the indent/outdent of case and default labels.


With indent level 4, IndentCaseLabels false, and CaseLabelOffset 2 you'll get a 
switch like:


switch (x) {
  case 1:
break;
  case (2):
break;
}

Our team uses this style of formatting and when investigating switching to 
clang-format, I couldn't find a way to accomplish it. So I thought trying a 
patch would be a good route.

For verification, I ran:

  make clang-test

My new tests failed and I iterated running:

  tools/clang/unittests/Format/FormatTests

until everything passed.

Thanks,
Ryan Livingston

Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst	(revision 294126)
+++ docs/ClangFormatStyleOptions.rst	(working copy)
@@ -414,6 +414,10 @@
 **BreakStringLiterals** (``bool``)
   Allow breaking string literals when formatting.
 
+**CaseLabelOffset** (``int``)
+  The extra indent or outdent of case/default labels
+  e.g. ``case:``, ``default:``.
+
 **ColumnLimit** (``unsigned``)
   The column limit.
 
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h	(revision 294126)
+++ include/clang/Format/Format.h	(working copy)
@@ -292,6 +292,10 @@
   /// \brief Allow breaking string literals when formatting.
   bool BreakStringLiterals;
 
+  /// \brief The extra indent or outdent of case/default labels
+  /// e.g. ``case:``, ``default:``.
+  int CaseLabelOffset;
+
   /// \brief The column limit.
   ///
   /// A column limit of ``0`` means that there is no column limit. In this case,
@@ -667,6 +671,7 @@
R.BreakConstructorInitializersBeforeComma &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
BreakStringLiterals == R.BreakStringLiterals &&
+   CaseLabelOffset == R.CaseLabelOffset &&
ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
ConstructorInitializerAllOnOneLineOrOnePerLine ==
R.ConstructorInitializerAllOnOneLineOrOnePerLine &&
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp	(revision 294126)
+++ lib/Format/Format.cpp	(working copy)
@@ -295,6 +295,7 @@
 IO.mapOptional("BreakAfterJavaFieldAnnotations",
Style.BreakAfterJavaFieldAnnotations);
 IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals);
+IO.mapOptional("CaseLabelOffset", Style.CaseLabelOffset);
 IO.mapOptional("ColumnLimit", Style.ColumnLimit);
 IO.mapOptional("CommentPragmas", Style.CommentPragmas);
 IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
@@ -520,6 +521,7 @@
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
   LLVMStyle.BreakConstructorInitializersBeforeComma = false;
   LLVMStyle.BreakStringLiterals = true;
+  LLVMStyle.CaseLabelOffset = 0;  
   LLVMStyle.ColumnLimit = 80;
   LLVMStyle.CommentPragmas = "^ IWYU pragma:";
   LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false;
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp	(revision 294126)
+++ lib/Format/UnwrappedLineFormatter.cpp	(working copy)
@@ -94,6 +94,8 @@
 (RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
  RootToken.Next && RootToken.Next->is(tok::colon)))
   return Style.AccessModifierOffset;
+if (RootToken.isOneOf(tok::kw_case, tok::kw_default))
+  return Style.CaseLabelOffset;
 return 0;
   }
 
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp	(revision 294126)
+++ unittests/Format/FormatTest.cpp	(working copy)
@@ -778,6 +778,20 @@
getLLVMStyleWithColumns(34));
 }
 
+TEST_F(FormatTest, CaseOffset) {
+  FormatStyle Style = getLLVMStyle();
+  Style.CaseLabelOffset = 2;
+  Style.IndentCaseLabels = false;
+  Style.IndentWidth = 4;
+  verifyFormat("switch (x) {\n"
+   "  case 1:\n"
+   "break;\n"
+   "  case (2):\n"
+   "break;\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTest, CaseRanges) {
   verifyFormat("switch (x) {\n"
"case 'A' ... 'Z':\n"
@@ -10367,6 +10381,7 @@
   FormatStyle Style = {};
   Style.Language = FormatStyle::LK_Cpp;
   CHECK_PARSE("AccessModifierOffset: -1234", AccessModifierOffset, -1234);
+  CHECK_PARSE("CaseLabelOffset: -1235", CaseLabelOffset, -1235);
   CHECK_PARSE("ConstructorInitializerIndentWidth: 1234",
   

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode added a comment.

LGTM. HIC++ Standard seems worth implementing.


https://reviews.llvm.org/D29267



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


Re: r294177 - [AVR] Allow specifying the CPU on the command line

2017-02-06 Thread Diana Picus via cfe-commits
Hi Dylan,

I reverted this in r294180 because I think it broke some of the
buildbots. See for example
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/3599
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/2271

Sorry,
Diana

On 6 February 2017 at 10:07, Dylan McKay via cfe-commits
 wrote:
> Author: dylanmckay
> Date: Mon Feb  6 03:07:56 2017
> New Revision: 294177
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294177=rev
> Log:
> [AVR] Allow specifying the CPU on the command line
>
> Summary:
> This tells clang about all of the different AVR microcontrollers.
>
> It also adds code to define the correct preprocessor macros for each
> device.
>
> Reviewers: jroelofs, asl
>
> Reviewed By: asl
>
> Subscribers: asl, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D28346
>
> Added:
> cfe/trunk/test/CodeGen/avr/
> cfe/trunk/test/CodeGen/avr/target-cpu-defines/
> cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
> cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
> cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294177=294176=294177=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 03:07:56 2017
> @@ -8435,6 +8435,254 @@ public:
>}
>  };
>
> +/// Information about a specific microcontroller.
> +struct MCUInfo {
> +  const char *Name;
> +  const char *DefineName;
> +};
> +
> +// This list should be kept up-to-date with AVRDevices.td in LLVM.
> +static ArrayRef AVRMcus = {
> +  { "at90s1200", "__AVR_AT90S1200__" },
> +  { "attiny11", "__AVR_ATtiny11" },
> +  { "attiny12", "__AVR_ATtiny12" },
> +  { "attiny15", "__AVR_ATtiny15" },
> +  { "attiny28", "__AVR_ATtiny28" },
> +  { "at90s2313", "__AVR_AT90S2313" },
> +  { "at90s2323", "__AVR_AT90S2323" },
> +  { "at90s2333", "__AVR_AT90S2333" },
> +  { "at90s2343", "__AVR_AT90S2343" },
> +  { "attiny22", "__AVR_ATtiny22" },
> +  { "attiny26", "__AVR_ATtiny26" },
> +  { "at86rf401", "__AVR_AT86RF401" },
> +  { "at90s4414", "__AVR_AT90S4414" },
> +  { "at90s4433", "__AVR_AT90S4433" },
> +  { "at90s4434", "__AVR_AT90S4434" },
> +  { "at90s8515", "__AVR_AT90S8515" },
> +  { "at90c8534", "__AVR_AT90c8534" },
> +  { "at90s8535", "__AVR_AT90S8535" },
> +  { "ata5272", "__AVR_ATA5272" },
> +  { "attiny13", "__AVR_ATtiny13" },
> +  { "attiny13a", "__AVR_ATtiny13A" },
> +  { "attiny2313", "__AVR_ATtiny2313" },
> +  { "attiny2313a", "__AVR_ATtiny2313A" },
> +  { "attiny24", "__AVR_ATtiny24" },
> +  { "attiny24a", "__AVR_ATtiny24A" },
> +  { "attiny4313", "__AVR_ATtiny4313" },
> +  { "attiny44", "__AVR_ATtiny44" },
> +  { "attiny44a", "__AVR_ATtiny44A" },
> +  { "attiny84", "__AVR_ATtiny84" },
> +  { "attiny84a", "__AVR_ATtiny84A" },
> +  { "attiny25", "__AVR_ATtiny25" },
> +  { "attiny45", "__AVR_ATtiny45" },
> +  { "attiny85", "__AVR_ATtiny85" },
> +  { "attiny261", "__AVR_ATtiny261" },
> +  { "attiny261a", "__AVR_ATtiny261A" },
> +  { "attiny461", "__AVR_ATtiny461" },
> +  { "attiny461a", "__AVR_ATtiny461A" },
> +  { "attiny861", "__AVR_ATtiny861" },
> +  { "attiny861a", "__AVR_ATtiny861A" },
> +  { "attiny87", "__AVR_ATtiny87" },
> +  { "attiny43u", "__AVR_ATtiny43U" },
> +  { "attiny48", "__AVR_ATtiny48" },
> +  { "attiny88", "__AVR_ATtiny88" },
> +  { "attiny828", "__AVR_ATtiny828" },
> +  { "at43usb355", "__AVR_AT43USB355" },
> +  { "at76c711", "__AVR_AT76C711" },
> +  { "atmega103", "__AVR_ATmega103" },
> +  { "at43usb320", "__AVR_AT43USB320" },
> +  { "attiny167", "__AVR_ATtiny167" },
> +  { "at90usb82", "__AVR_AT90USB82" },
> +  { "at90usb162", "__AVR_AT90USB162" },
> +  { "ata5505", "__AVR_ATA5505" },
> +  { "atmega8u2", "__AVR_ATmega8U2" },
> +  { "atmega16u2", "__AVR_ATmega16U2" },
> +  { "atmega32u2", "__AVR_ATmega32U2" },
> +  { "attiny1634", "__AVR_ATtiny1634" },
> +  { "atmega8", "__AVR_ATmega8" },
> +  { "ata6289", "__AVR_ATA6289" },
> +  { "atmega8a", "__AVR_ATmega8A" },
> +  { "ata6285", "__AVR_ATA6285" },
> +  { "ata6286", "__AVR_ATA6286" },
> +  { "atmega48", "__AVR_ATmega48" },
> +  { "atmega48a", "__AVR_ATmega48A" },
> +  { "atmega48pa", "__AVR_ATmega48PA" },
> +  { "atmega48p", "__AVR_ATmega48P" },
> +  { "atmega88", "__AVR_ATmega88" },
> +  { "atmega88a", "__AVR_ATmega88A" },
> +  { "atmega88p", "__AVR_ATmega88P" },
> +  { "atmega88pa", "__AVR_ATmega88PA" },
> +  { "atmega8515", "__AVR_ATmega8515" },
> +  { "atmega8535", "__AVR_ATmega8535" },
> +  { "atmega8hva", "__AVR_ATmega8HVA" },
> +  { "at90pwm1", "__AVR_AT90PWM1" },
> +  { "at90pwm2", "__AVR_AT90PWM2" },
> +  { "at90pwm2b", "__AVR_AT90PWM2B" },
> +  { "at90pwm3", "__AVR_AT90PWM3" },
> +  { "at90pwm3b", "__AVR_AT90PWM3B" },
> +  { "at90pwm81", "__AVR_AT90PWM81" },
> +  { 

r294180 - Revert "[AVR] Allow specifying the CPU on the command line"

2017-02-06 Thread Diana Picus via cfe-commits
Author: rovka
Date: Mon Feb  6 05:35:42 2017
New Revision: 294180

URL: http://llvm.org/viewvc/llvm-project?rev=294180=rev
Log:
Revert "[AVR] Allow specifying the CPU on the command line"

This reverts commit r294177. It seems to have broken some buildbots.

Removed:
cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294180=294179=294180=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 05:35:42 2017
@@ -8435,254 +8435,6 @@ public:
   }
 };
 
-/// Information about a specific microcontroller.
-struct MCUInfo {
-  const char *Name;
-  const char *DefineName;
-};
-
-// This list should be kept up-to-date with AVRDevices.td in LLVM.
-static ArrayRef AVRMcus = {
-  { "at90s1200", "__AVR_AT90S1200__" },
-  { "attiny11", "__AVR_ATtiny11" },
-  { "attiny12", "__AVR_ATtiny12" },
-  { "attiny15", "__AVR_ATtiny15" },
-  { "attiny28", "__AVR_ATtiny28" },
-  { "at90s2313", "__AVR_AT90S2313" },
-  { "at90s2323", "__AVR_AT90S2323" },
-  { "at90s2333", "__AVR_AT90S2333" },
-  { "at90s2343", "__AVR_AT90S2343" },
-  { "attiny22", "__AVR_ATtiny22" },
-  { "attiny26", "__AVR_ATtiny26" },
-  { "at86rf401", "__AVR_AT86RF401" },
-  { "at90s4414", "__AVR_AT90S4414" },
-  { "at90s4433", "__AVR_AT90S4433" },
-  { "at90s4434", "__AVR_AT90S4434" },
-  { "at90s8515", "__AVR_AT90S8515" },
-  { "at90c8534", "__AVR_AT90c8534" },
-  { "at90s8535", "__AVR_AT90S8535" },
-  { "ata5272", "__AVR_ATA5272" },
-  { "attiny13", "__AVR_ATtiny13" },
-  { "attiny13a", "__AVR_ATtiny13A" },
-  { "attiny2313", "__AVR_ATtiny2313" },
-  { "attiny2313a", "__AVR_ATtiny2313A" },
-  { "attiny24", "__AVR_ATtiny24" },
-  { "attiny24a", "__AVR_ATtiny24A" },
-  { "attiny4313", "__AVR_ATtiny4313" },
-  { "attiny44", "__AVR_ATtiny44" },
-  { "attiny44a", "__AVR_ATtiny44A" },
-  { "attiny84", "__AVR_ATtiny84" },
-  { "attiny84a", "__AVR_ATtiny84A" },
-  { "attiny25", "__AVR_ATtiny25" },
-  { "attiny45", "__AVR_ATtiny45" },
-  { "attiny85", "__AVR_ATtiny85" },
-  { "attiny261", "__AVR_ATtiny261" },
-  { "attiny261a", "__AVR_ATtiny261A" },
-  { "attiny461", "__AVR_ATtiny461" },
-  { "attiny461a", "__AVR_ATtiny461A" },
-  { "attiny861", "__AVR_ATtiny861" },
-  { "attiny861a", "__AVR_ATtiny861A" },
-  { "attiny87", "__AVR_ATtiny87" },
-  { "attiny43u", "__AVR_ATtiny43U" },
-  { "attiny48", "__AVR_ATtiny48" },
-  { "attiny88", "__AVR_ATtiny88" },
-  { "attiny828", "__AVR_ATtiny828" },
-  { "at43usb355", "__AVR_AT43USB355" },
-  { "at76c711", "__AVR_AT76C711" },
-  { "atmega103", "__AVR_ATmega103" },
-  { "at43usb320", "__AVR_AT43USB320" },
-  { "attiny167", "__AVR_ATtiny167" },
-  { "at90usb82", "__AVR_AT90USB82" },
-  { "at90usb162", "__AVR_AT90USB162" },
-  { "ata5505", "__AVR_ATA5505" },
-  { "atmega8u2", "__AVR_ATmega8U2" },
-  { "atmega16u2", "__AVR_ATmega16U2" },
-  { "atmega32u2", "__AVR_ATmega32U2" },
-  { "attiny1634", "__AVR_ATtiny1634" },
-  { "atmega8", "__AVR_ATmega8" },
-  { "ata6289", "__AVR_ATA6289" },
-  { "atmega8a", "__AVR_ATmega8A" },
-  { "ata6285", "__AVR_ATA6285" },
-  { "ata6286", "__AVR_ATA6286" },
-  { "atmega48", "__AVR_ATmega48" },
-  { "atmega48a", "__AVR_ATmega48A" },
-  { "atmega48pa", "__AVR_ATmega48PA" },
-  { "atmega48p", "__AVR_ATmega48P" },
-  { "atmega88", "__AVR_ATmega88" },
-  { "atmega88a", "__AVR_ATmega88A" },
-  { "atmega88p", "__AVR_ATmega88P" },
-  { "atmega88pa", "__AVR_ATmega88PA" },
-  { "atmega8515", "__AVR_ATmega8515" },
-  { "atmega8535", "__AVR_ATmega8535" },
-  { "atmega8hva", "__AVR_ATmega8HVA" },
-  { "at90pwm1", "__AVR_AT90PWM1" },
-  { "at90pwm2", "__AVR_AT90PWM2" },
-  { "at90pwm2b", "__AVR_AT90PWM2B" },
-  { "at90pwm3", "__AVR_AT90PWM3" },
-  { "at90pwm3b", "__AVR_AT90PWM3B" },
-  { "at90pwm81", "__AVR_AT90PWM81" },
-  { "ata5790", "__AVR_ATA5790" },
-  { "ata5795", "__AVR_ATA5795" },
-  { "atmega16", "__AVR_ATmega16" },
-  { "atmega16a", "__AVR_ATmega16A" },
-  { "atmega161", "__AVR_ATmega161" },
-  { "atmega162", "__AVR_ATmega162" },
-  { "atmega163", "__AVR_ATmega163" },
-  { "atmega164a", "__AVR_ATmega164A" },
-  { "atmega164p", "__AVR_ATmega164P" },
-  { "atmega164pa", "__AVR_ATmega164PA" },
-  { "atmega165", "__AVR_ATmega165" },
-  { "atmega165a", "__AVR_ATmega165A" },
-  { "atmega165p", "__AVR_ATmega165P" },
-  { "atmega165pa", "__AVR_ATmega165PA" },
-  { "atmega168", "__AVR_ATmega168" },
-  { "atmega168a", "__AVR_ATmega168A" },
-  { "atmega168p", "__AVR_ATmega168P" },
-  { "atmega168pa", "__AVR_ATmega168PA" },
-  { "atmega169", "__AVR_ATmega169" },
-  { "atmega169a", "__AVR_ATmega169A" },
-  { "atmega169p", "__AVR_ATmega169P" },
-  { "atmega169pa", "__AVR_ATmega169PA" },
-  { 

[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In https://reviews.llvm.org/D29267#667614, @jbcoe wrote:

> @alexfh Can we defer moving this to a compiler diagnostic? I'm keen to get a 
> target in place for people to write more safety checks.


+1 from me :) 
and assembler might be bad style, but is it worth a warning? I think people 
writing assembly in their code wouldnt be amused and turn it off anyway, since 
they believe its necessary and worth it.


https://reviews.llvm.org/D29267



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

@alexfh Can we defer moving this to a compiler diagnostic? I'm keen to get a 
target in place for people to write more safety checks.


https://reviews.llvm.org/D29267



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I feel like you should have at least one statement in the test that uses 
explicit 'this' to access a field/method.

Does your patch handle fields/methods in base classes as well? I think 'this' 
might be implicitly converted in the base of the member expression.

Also, what about cases like this one:

  struct A {
int x;
  
void methodNotConst() const {
  const_cast(this)->x = 0;
}
  };




https://reviews.llvm.org/D29530



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


[PATCH] D29451: Add a prototype for clangd v0.1

2017-02-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

This might be a bad question, but is there any particular reason why you didn't 
use the YAML Traits API for parsing instead of the raw YAML Stream API? In my 
experience the traits based API is quite convenient for structured data like 
various options and parameters in this protocol.


https://reviews.llvm.org/D29451



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


[PATCH] D24703: [clang-format] BreakBeforeBinaryOperations and AlignAfterOpenBracket conflict, bug 30304

2017-02-06 Thread Daniel Jasper via Phabricator via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r294179. Sorry I missed this before.


https://reviews.llvm.org/D24703



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


r294179 - clang-format: Fix bug with conflicting BreakBeforeBinaryOperations and AlignAfterOpenBracket

2017-02-06 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  6 04:55:49 2017
New Revision: 294179

URL: http://llvm.org/viewvc/llvm-project?rev=294179=rev
Log:
clang-format: Fix bug with conflicting BreakBeforeBinaryOperations and 
AlignAfterOpenBracket

Fix for the formatting options combination of
BreakBeforeBinaryOperators: All, AlignAfterOpenBracket: AlwaysBreak not
handling long templates correctly. This patch allows a break after an
opening left parenthesis, TemplateOpener, or bracket when both options
are enabled.

Patch by Daphne Pfister, thank you!

Fixes llvm.org/PR30304.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=294179=294178=294179=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb  6 04:55:49 2017
@@ -2635,7 +2635,8 @@ bool TokenAnnotator::canBreakBefore(cons
tok::colon, tok::l_square, tok::at) ||
  (Left.is(tok::r_paren) &&
   Right.isOneOf(tok::identifier, tok::kw_const)) ||
- (Left.is(tok::l_paren) && !Right.is(tok::r_paren));
+ (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
+ (Left.is(TT_TemplateOpener) && !Right.is(TT_TemplateCloser));
 }
 
 void TokenAnnotator::printDebugInfo(const AnnotatedLine ) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=294179=294178=294179=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  6 04:55:49 2017
@@ -6140,6 +6140,44 @@ TEST_F(FormatTest, WrapsTemplateDeclarat
"};");
 }
 
+TEST_F(FormatTest, WrapsTemplateParameters) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
+  verifyFormat(
+  "template  struct q {};\n"
+  "extern q\n"
+  "y;",
+  Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat(
+  "template  struct r {};\n"
+  "extern r\n"
+  "y;",
+  Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
+  verifyFormat(
+  "template  struct s {};\n"
+  "extern s<\n"
+  "aa, aa, 
aa,\n"
+  "aa, aa, 
aa>\n"
+  "y;",
+  Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat(
+  "template  struct t {};\n"
+  "extern t<\n"
+  "aa, aa, 
aa,\n"
+  "aa, aa, 
aa>\n"
+  "y;",
+  Style);
+}
+
 TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
   verifyFormat(
   
"::\n"


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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

alright :)


https://reviews.llvm.org/D29267



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

@JonasToth My main intention with this patch is to provide such a starting 
point. A few people have mentioned that they'd be keen to contribute checks.


https://reviews.llvm.org/D29267



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

out of curiousity:
i would like to contribute to the safety module as well. but currently there is 
no starting point in master. is there a way to get some code that i can start 
with? I think the module file where the registration happens would be enough.

this is not specifically patch related, but dunno where to ask else.

e.g. could it be possible to commit the std::vector thing, even though 
temlate parameters dont work right now. this could be added as a known 
limitation.


https://reviews.llvm.org/D29267



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked an inline comment as done.
jbcoe added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp:32
+
+  diag(ASM->getAsmLoc(), "'%0' is an inline assembler statement") << 
SourceText;
+}

aaron.ballman wrote:
> The diagnostic text doesn't help the user to understand why the code is being 
> diagnosed. Also, does printing the source text add any clarity? The 
> diagnostic already appears on the line in which the assembly statement 
> appears, and since this is a statement (rather than an expression), it seems 
> unlikely to be useful to repeat that text.
Agreed. Fixed.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:156
+   safety-no-assembler
+   safety-no-vector-bool

idlecode wrote:
> `safety-no-vector-bool` seems to belong to the other patch.
Well spotted. Thought I'd got rid of all of those.


https://reviews.llvm.org/D29267



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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-02-06 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 87207.
jbcoe marked an inline comment as done.
jbcoe added a comment.

Improve diagnostic message. Find other sorts of inline assembler. Minor fixes 
for other review comments.


https://reviews.llvm.org/D29267

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp
  clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.h
  clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
  clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp

Index: clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s safety-no-assembler %t
+
+__asm__(".symver foo, bar@v");
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+
+static int s asm("spam");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+
+void f() {
+  __asm("mov al, 2");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - safety-no-assembler
+
+safety-no-assembler
+===
+
+Check for assembler statements. No fix is offered.
+
+Inline assembler is forbidden by safety-critical C++ standards like `High
+Intergrity C++ `_ as it restricts the
+portability of code.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -152,3 +152,4 @@
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
+   safety-no-assembler
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -57,7 +57,10 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `safety-no-assembler
+  `_ check
+
+  Finds uses of inline assembler.
 
 Improvements to include-fixer
 -
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -475,6 +475,11 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
+// This anchor is used to force the linker to link the SafetyModule.
+extern volatile int SafetyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED SafetyModuleAnchorDestination =
+SafetyModuleAnchorSource;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -23,6 +23,7 @@
   clangTidyMPIModule
   clangTidyPerformanceModule
   clangTidyReadabilityModule
+  clangTidySafetyModule
   clangTooling
   )
 
Index: clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
@@ -0,0 +1,38 @@
+//===--- SafetyTidyModule.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "NoAssemblerCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+class SafetyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+

Re: r294008 - [Sema][ObjC++] Typo correction should handle ivars and properties

2017-02-06 Thread Alex L via cfe-commits
Thanks!

On 3 February 2017 at 22:34, Hans Wennborg  wrote:

> Thanks! r294059.
>
> On Fri, Feb 3, 2017 at 2:29 PM, Richard Smith 
> wrote:
> > It looks like the only cases it should have any real impact on are those
> > where we would previously miscompile/crash, so this seems OK to me to
> merge
> > to Clang 4.
> >
> >
> > On 3 February 2017 at 13:45, Hans Wennborg  wrote:
> >>
> >> IIUC, this isn't strictly fixing a regression from 3.9, but it looks
> >> like a pretty small diff.
> >>
> >> Richard, what do you think?
> >>
> >> On Fri, Feb 3, 2017 at 6:37 AM, Alex L  wrote:
> >> > Hi Hans,
> >> >
> >> > Is there any chance we can merge this for 4.0? It fixed a nasty bug
> >> > where
> >> > clang didn't catch invalid ObjC++ code during semantic analysis which
> >> > led to
> >> > invalid object files or crashes in CodeGen.
> >> >
> >> > Cheers,
> >> > Alex
> >> >
> >> > On 3 February 2017 at 14:22, Alex Lorenz via cfe-commits
> >> >  wrote:
> >> >>
> >> >> Author: arphaman
> >> >> Date: Fri Feb  3 08:22:33 2017
> >> >> New Revision: 294008
> >> >>
> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=294008=rev
> >> >> Log:
> >> >> [Sema][ObjC++] Typo correction should handle ivars and properties
> >> >>
> >> >> After r260016 and r260017 disabled typo correction for ivars and
> >> >> properties
> >> >> clang didn't report errors about unresolved identifier in the base of
> >> >> ivar
> >> >> and
> >> >> property ref expressions. This meant that clang invoked CodeGen on
> >> >> invalid
> >> >> AST
> >> >> which then caused a crash.
> >> >>
> >> >> This commit re-enables typo correction for ivars and properites, and
> >> >> fixes
> >> >> the
> >> >> PR25113 & PR26486 (that were originally fixed in r260017 and r260016)
> >> >> in a
> >> >> different manner by transforming the Objective-C ivar reference
> >> >> expression
> >> >> with
> >> >> 'IsFreeIvar' preserved.
> >> >>
> >> >> rdar://30310772
> >> >>
> >> >> Modified:
> >> >> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >> >> cfe/trunk/lib/Sema/TreeTransform.h
> >> >> cfe/trunk/test/SemaObjCXX/typo-correction.mm
> >> >>
> >> >> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >> >> URL:
> >> >>
> >> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExprCXX.cpp?rev=294008=294007=294008=diff
> >> >>
> >> >>
> >> >> 
> ==
> >> >> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> >> >> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Feb  3 08:22:33 2017
> >> >> @@ -7250,14 +7250,6 @@ public:
> >> >>
> >> >>ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
> >> >>
> >> >> -  ExprResult TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
> >> >> -return Owned(E);
> >> >> -  }
> >> >> -
> >> >> -  ExprResult TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
> >> >> -return Owned(E);
> >> >> -  }
> >> >> -
> >> >>ExprResult Transform(Expr *E) {
> >> >>  ExprResult Res;
> >> >>  while (true) {
> >> >>
> >> >> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> >> >> URL:
> >> >>
> >> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> TreeTransform.h?rev=294008=294007=294008=diff
> >> >>
> >> >>
> >> >> 
> ==
> >> >> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> >> >> +++ cfe/trunk/lib/Sema/TreeTransform.h Fri Feb  3 08:22:33 2017
> >> >> @@ -2982,16 +2982,17 @@ public:
> >> >>ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl
> *Ivar,
> >> >>SourceLocation IvarLoc,
> >> >>bool IsArrow, bool
> >> >> IsFreeIvar)
> >> >> {
> >> >> -// FIXME: We lose track of the IsFreeIvar bit.
> >> >>  CXXScopeSpec SS;
> >> >>  DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
> >> >> -return getSema().BuildMemberReferenceExpr(BaseArg,
> >> >> BaseArg->getType(),
> >> >> -  /*FIXME:*/IvarLoc,
> >> >> IsArrow,
> >> >> -  SS, SourceLocation(),
> >> >> -
> >> >> /*FirstQualifierInScope=*/nullptr,
> >> >> -  NameInfo,
> >> >> -
> >> >> /*TemplateArgs=*/nullptr,
> >> >> -  /*S=*/nullptr);
> >> >> +ExprResult Result = getSema().BuildMemberReferenceExpr(
> >> >> +BaseArg, BaseArg->getType(),
> >> >> +/*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
> >> >> +/*FirstQualifierInScope=*/nullptr, NameInfo,
> >> >> +/*TemplateArgs=*/nullptr,
> >> >> +/*S=*/nullptr);
> >> >> +if (IsFreeIvar && Result.isUsable())
> >> >> +  cast(Result.get())->setIsFreeIvar(
> IsFreeIvar);
> >> >> +return Result;
> >> >>}
> >> >>
> 

Re: [libcxx] r294107 - Recommit [libcxx] Never use within libc++

2017-02-06 Thread Eric Fiselier via cfe-commits
I should have made it more clear that this change actually caused 100's of
assertions to be turned on. And good news! They found bugs!
On initial inspection in appears that the new path parser implementation
has some issues. I'll work on fixing them in the coming days.
After I commit the fixes I'll setup bots to test with assertions enabled.
For now I would suggest disabling assertions if you need the test suite to
be clean.

Thanks,

/Eric

On Mon, Feb 6, 2017 at 3:10 AM, Hahnfeld, Jonas  wrote:

> Hi Eric,
>
> I'm getting quite a few failures with LIBCXX_ENABLE_ASSERTIONS=On (didn't
> do a
> clean build at first):
> Failing Tests (32):
> libc++ ::
> std/experimental/filesystem/class.directory_entry/
> directory_entry.cons.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.directory_entry/
> directory_entry.mods.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.directory_entry/directory_entry.obs/
> comparisons.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.directory_iterator/
> directory_iterator.members/ctor.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.directory_iterator/
> directory_iterator.members/increment.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.directory_iterator/
> directory_iterator.nonmembers/begin_end.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.append.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> assign/source.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> decompose/path.decompose.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> modifiers/make_preferred.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> modifiers/remove_filename.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> modifiers/replace_extension.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.path/path.member/path.
> modifiers/swap.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.
> members/ctor.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.
> members/depth.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.
> members/increment.pass.cpp
> libc++ ::
> std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.
> nonmembers/begin_end.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
> libc++ :: std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.
> pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.permissions/
> permissions.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.read_
> symlink/read_symlink.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.remove/remove.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.remove_all/
> remove_all.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.resize_file/
> resize_file.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.space/space.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.symlink_
> status/symlink_status.pass.cpp
> libc++ ::
> std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_
> path/temp_directory_path.pass.cpp
>
> They go away with LIBCXX_ENABLE_ASSERTIONS=Off which is the new default. Is
> this expected to happen?
>
> Thanks,
> Jonas
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> > Of Eric Fiselier via cfe-commits
> > Sent: Sunday, February 05, 2017 12:22 AM
> > To: cfe-commits@lists.llvm.org
> > Subject: [libcxx] r294107 - Recommit [libcxx] Never use  within
> > libc++
> >
> > Author: ericwf
> > Date: Sat Feb  4 17:22:28 2017
> > New Revision: 294107
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=294107=rev
> > Log:
> > Recommit [libcxx] Never use  within libc++
> >
> > It is my opinion that libc++ should never use ``, including in
> the
> > `dylib`.
> > This patch remove all uses of `assert` from within libc++ and replaces
> most
> > of
> > them with `_LIBCPP_ASSERT` instead.
> >
> > Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS`  off by default,
> > because the standard library should not be aborting user programs unless
> > explicitly asked to.
> >
> > Modified:
> > 

Re: r293518 - [ASTMatchers] Sprinkle some constexpr on the global matcher constructors.

2017-02-06 Thread Alex L via cfe-commits
Adrian has filed PR 31860 at https://llvm.org/bugs/show_bug.cgi?id=31860 .

On 3 February 2017 at 23:10, Duncan P. N. Exon Smith 
wrote:

> Note that this also failed on Linux:
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-
> selfhost-modules/builds/2728
>
> This looks like a modules compiler bug, as opposed to a problem in the
> commit itself.  Alex, can you file a PR for this?
>
> > On 2017-Feb-01, at 07:35, Alex L via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > I've narrowed the problem down to the difference in the linkage type for
> "clang::ast_matchers::recordDecl" between the module and non-module build:
> >
> > Module:
> > @_ZN5clang12ast_matchersL10recordDeclE = external global
> %"class.clang::ast_matchers::internal::VariadicDynCastAllOfMatcher.847",
> align 1
> >
> > Non-module:
> > @_ZN5clang12ast_matchersL10recordDeclE = internal constant
> %"class.clang::ast_matchers::internal::VariadicDynCastAllOfMatcher.916"
> undef, align 1, !dbg !7
> >
> > On 1 February 2017 at 11:03, Alex L  wrote:
> > Hi Benjamin,
> >
> > This commit has caused a linking in our stage 2 modules buildbot at
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-modulesRDA/.
> Specifically, after this commit 'clang-reorder-fields' gets the following
> linking error:
> >
> > FAILED: bin/clang-reorder-fields
> > : && /Users/buildslave/jenkins/sharedspace/clang-stage2-
> cmake-modulesRDA@2/host-compiler/bin/clang++   -fPIC
> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings
> -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long
> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
> -Wstring-conversion -Werror=date-time -std=c++11 -fmodules
> -fmodules-cache-path=/Users/buildslave/jenkins/sharedspace/clang-stage2-
> cmake-modulesRDA@2/clang-build/module.cache -fcxx-modules -gmodules
> -fcolor-diagnostics -fno-common -Woverloaded-virtual -Wno-nested-anon-types
> -O2 -g -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names
> -Wl,-dead_strip tools/clang/tools/extra/clang-reorder-fields/tool/
> CMakeFiles/clang-reorder-fields.dir/ClangReorderFields.cpp.o  -o
> bin/clang-reorder-fields  lib/libLLVMSupport.a lib/libclangBasic.a
> lib/libclangFrontend.a lib/libclangReorderFields.a lib/libclangRewrite.a
> lib/libclangTooling.a lib/libclangToolingCore.a lib/libclangIndex.a
> lib/libclangFrontend.a lib/libclangParse.a lib/libLLVMMCParser.a
> lib/libclangSerialization.a lib/libclangSema.a lib/libclangEdit.a
> lib/libclangAnalysis.a lib/libLLVMBitReader.a lib/libLLVMProfileData.a
> lib/libclangDriver.a lib/libLLVMOption.a lib/libclangASTMatchers.a
> lib/libclangFormat.a lib/libclangToolingCore.a lib/libclangRewrite.a
> lib/libclangAST.a lib/libclangLex.a lib/libclangBasic.a lib/libLLVMCore.a
> lib/libLLVMMC.a lib/libLLVMSupport.a -lcurses -lz -lm lib/libLLVMDemangle.a
> -Wl,-rpath,@loader_path/../lib && :
> > Undefined symbols for architecture x86_64:
> >   "clang::ast_matchers::recordDecl", referenced from:
> >   clang::reorder_fields::(anonymous namespace)::ReorderingConsumer::
> HandleTranslationUnit(clang::ASTContext&) in libclangReorderFields.a(
> ReorderFieldsAction.cpp.o)
> > ld: symbol(s) not found for architecture x86_64
> >
> > This might be a bug/regression in clang and modules since in my opinion
> the link should succeed. I've reverted your commit in r293759 while we are
> investigating.
> >
> > Thanks,
> > Alex
> >
> >
> > On 30 January 2017 at 18:20, Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> > Author: d0k
> > Date: Mon Jan 30 12:20:00 2017
> > New Revision: 293518
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=293518=rev
> > Log:
> > [ASTMatchers] Sprinkle some constexpr on the global matcher constructors.
> >
> > This dramatically reduces the size of the global constructors we emit
> > for those variables in debug mode.
> >
> > Modified:
> > cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> >
> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/ASTMatchers/ASTMatchersInternal.h?rev=293518=293517=293518&
> view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Jan
> 30 12:20:00 2017
> > @@ -1459,7 +1459,7 @@ class VariadicDynCastAllOfMatcher
> >  : public VariadicFunction Matcher,
> >makeDynCastAllOfComposite TargetT>> {
> >  public:
> > -  VariadicDynCastAllOfMatcher() {}
> > +  constexpr VariadicDynCastAllOfMatcher() {}
> >  };
> >
> >  /// \brief A \c VariadicAllOfMatcher object is a variadic functor
> that takes
> > @@ -1477,7 +1477,7 @@ class VariadicAllOfMatcher
> >  : public 

RE: [libcxx] r294107 - Recommit [libcxx] Never use within libc++

2017-02-06 Thread Hahnfeld, Jonas via cfe-commits
Hi Eric,

I'm getting quite a few failures with LIBCXX_ENABLE_ASSERTIONS=On (didn't do a 
clean build at first):
Failing Tests (32):
libc++ :: 
std/experimental/filesystem/class.directory_entry/directory_entry.cons.pass.cpp
libc++ :: 
std/experimental/filesystem/class.directory_entry/directory_entry.mods.pass.cpp
libc++ :: 
std/experimental/filesystem/class.directory_entry/directory_entry.obs/comparisons.pass.cpp
libc++ :: 
std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
libc++ :: 
std/experimental/filesystem/class.directory_iterator/directory_iterator.members/increment.pass.cpp
libc++ :: 
std/experimental/filesystem/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.append.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.modifiers/make_preferred.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.modifiers/remove_filename.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.modifiers/replace_extension.pass.cpp
libc++ :: 
std/experimental/filesystem/class.path/path.member/path.modifiers/swap.pass.cpp
libc++ :: 
std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
libc++ :: 
std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
libc++ :: 
std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
libc++ :: 
std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
libc++ :: std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.read_symlink/read_symlink.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.remove/remove.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.resize_file/resize_file.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.space/space.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
libc++ :: 
std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp

They go away with LIBCXX_ENABLE_ASSERTIONS=Off which is the new default. Is 
this expected to happen?

Thanks,
Jonas

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Eric Fiselier via cfe-commits
> Sent: Sunday, February 05, 2017 12:22 AM
> To: cfe-commits@lists.llvm.org
> Subject: [libcxx] r294107 - Recommit [libcxx] Never use  within
> libc++
>
> Author: ericwf
> Date: Sat Feb  4 17:22:28 2017
> New Revision: 294107
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294107=rev
> Log:
> Recommit [libcxx] Never use  within libc++
>
> It is my opinion that libc++ should never use ``, including in the
> `dylib`.
> This patch remove all uses of `assert` from within libc++ and replaces most 
> of
> them with `_LIBCPP_ASSERT` instead.
>
> Additionally this patch turn `LIBCXX_ENABLE_ASSERTIONS`  off by default,
> because the standard library should not be aborting user programs unless
> explicitly asked to.
>
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/include/__config
> libcxx/trunk/include/__threading_support
> libcxx/trunk/src/condition_variable.cpp
> libcxx/trunk/src/experimental/filesystem/path.cpp
> libcxx/trunk/src/mutex.cpp
> libcxx/trunk/src/system_error.cpp
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-
> project/libcxx/trunk/CMakeLists.txt?rev=294107=294106=294107
> w=diff
> ==
> 
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Sat Feb  4 17:22:28 2017
> @@ -60,7 +60,7 @@ endif()
>  include(CMakeDependentOption)
>
>  # Basic 
> options ---
> 

r294177 - [AVR] Allow specifying the CPU on the command line

2017-02-06 Thread Dylan McKay via cfe-commits
Author: dylanmckay
Date: Mon Feb  6 03:07:56 2017
New Revision: 294177

URL: http://llvm.org/viewvc/llvm-project?rev=294177=rev
Log:
[AVR] Allow specifying the CPU on the command line

Summary:
This tells clang about all of the different AVR microcontrollers.

It also adds code to define the correct preprocessor macros for each
device.

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/avr/
cfe/trunk/test/CodeGen/avr/target-cpu-defines/
cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294177=294176=294177=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 03:07:56 2017
@@ -8435,6 +8435,254 @@ public:
   }
 };
 
+/// Information about a specific microcontroller.
+struct MCUInfo {
+  const char *Name;
+  const char *DefineName;
+};
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static ArrayRef AVRMcus = {
+  { "at90s1200", "__AVR_AT90S1200__" },
+  { "attiny11", "__AVR_ATtiny11" },
+  { "attiny12", "__AVR_ATtiny12" },
+  { "attiny15", "__AVR_ATtiny15" },
+  { "attiny28", "__AVR_ATtiny28" },
+  { "at90s2313", "__AVR_AT90S2313" },
+  { "at90s2323", "__AVR_AT90S2323" },
+  { "at90s2333", "__AVR_AT90S2333" },
+  { "at90s2343", "__AVR_AT90S2343" },
+  { "attiny22", "__AVR_ATtiny22" },
+  { "attiny26", "__AVR_ATtiny26" },
+  { "at86rf401", "__AVR_AT86RF401" },
+  { "at90s4414", "__AVR_AT90S4414" },
+  { "at90s4433", "__AVR_AT90S4433" },
+  { "at90s4434", "__AVR_AT90S4434" },
+  { "at90s8515", "__AVR_AT90S8515" },
+  { "at90c8534", "__AVR_AT90c8534" },
+  { "at90s8535", "__AVR_AT90S8535" },
+  { "ata5272", "__AVR_ATA5272" },
+  { "attiny13", "__AVR_ATtiny13" },
+  { "attiny13a", "__AVR_ATtiny13A" },
+  { "attiny2313", "__AVR_ATtiny2313" },
+  { "attiny2313a", "__AVR_ATtiny2313A" },
+  { "attiny24", "__AVR_ATtiny24" },
+  { "attiny24a", "__AVR_ATtiny24A" },
+  { "attiny4313", "__AVR_ATtiny4313" },
+  { "attiny44", "__AVR_ATtiny44" },
+  { "attiny44a", "__AVR_ATtiny44A" },
+  { "attiny84", "__AVR_ATtiny84" },
+  { "attiny84a", "__AVR_ATtiny84A" },
+  { "attiny25", "__AVR_ATtiny25" },
+  { "attiny45", "__AVR_ATtiny45" },
+  { "attiny85", "__AVR_ATtiny85" },
+  { "attiny261", "__AVR_ATtiny261" },
+  { "attiny261a", "__AVR_ATtiny261A" },
+  { "attiny461", "__AVR_ATtiny461" },
+  { "attiny461a", "__AVR_ATtiny461A" },
+  { "attiny861", "__AVR_ATtiny861" },
+  { "attiny861a", "__AVR_ATtiny861A" },
+  { "attiny87", "__AVR_ATtiny87" },
+  { "attiny43u", "__AVR_ATtiny43U" },
+  { "attiny48", "__AVR_ATtiny48" },
+  { "attiny88", "__AVR_ATtiny88" },
+  { "attiny828", "__AVR_ATtiny828" },
+  { "at43usb355", "__AVR_AT43USB355" },
+  { "at76c711", "__AVR_AT76C711" },
+  { "atmega103", "__AVR_ATmega103" },
+  { "at43usb320", "__AVR_AT43USB320" },
+  { "attiny167", "__AVR_ATtiny167" },
+  { "at90usb82", "__AVR_AT90USB82" },
+  { "at90usb162", "__AVR_AT90USB162" },
+  { "ata5505", "__AVR_ATA5505" },
+  { "atmega8u2", "__AVR_ATmega8U2" },
+  { "atmega16u2", "__AVR_ATmega16U2" },
+  { "atmega32u2", "__AVR_ATmega32U2" },
+  { "attiny1634", "__AVR_ATtiny1634" },
+  { "atmega8", "__AVR_ATmega8" },
+  { "ata6289", "__AVR_ATA6289" },
+  { "atmega8a", "__AVR_ATmega8A" },
+  { "ata6285", "__AVR_ATA6285" },
+  { "ata6286", "__AVR_ATA6286" },
+  { "atmega48", "__AVR_ATmega48" },
+  { "atmega48a", "__AVR_ATmega48A" },
+  { "atmega48pa", "__AVR_ATmega48PA" },
+  { "atmega48p", "__AVR_ATmega48P" },
+  { "atmega88", "__AVR_ATmega88" },
+  { "atmega88a", "__AVR_ATmega88A" },
+  { "atmega88p", "__AVR_ATmega88P" },
+  { "atmega88pa", "__AVR_ATmega88PA" },
+  { "atmega8515", "__AVR_ATmega8515" },
+  { "atmega8535", "__AVR_ATmega8535" },
+  { "atmega8hva", "__AVR_ATmega8HVA" },
+  { "at90pwm1", "__AVR_AT90PWM1" },
+  { "at90pwm2", "__AVR_AT90PWM2" },
+  { "at90pwm2b", "__AVR_AT90PWM2B" },
+  { "at90pwm3", "__AVR_AT90PWM3" },
+  { "at90pwm3b", "__AVR_AT90PWM3B" },
+  { "at90pwm81", "__AVR_AT90PWM81" },
+  { "ata5790", "__AVR_ATA5790" },
+  { "ata5795", "__AVR_ATA5795" },
+  { "atmega16", "__AVR_ATmega16" },
+  { "atmega16a", "__AVR_ATmega16A" },
+  { "atmega161", "__AVR_ATmega161" },
+  { "atmega162", "__AVR_ATmega162" },
+  { "atmega163", "__AVR_ATmega163" },
+  { "atmega164a", "__AVR_ATmega164A" },
+  { "atmega164p", "__AVR_ATmega164P" },
+  { "atmega164pa", "__AVR_ATmega164PA" },
+  { "atmega165", "__AVR_ATmega165" },
+  { "atmega165a", "__AVR_ATmega165A" },
+  { "atmega165p", "__AVR_ATmega165P" },
+  { "atmega165pa", "__AVR_ATmega165PA" },
+  { "atmega168", "__AVR_ATmega168" },
+  { 

r294176 - [AVR] Add support for the full set of inline asm constraints

2017-02-06 Thread Dylan McKay via cfe-commits
Author: dylanmckay
Date: Mon Feb  6 03:01:59 2017
New Revision: 294176

URL: http://llvm.org/viewvc/llvm-project?rev=294176=rev
Log:
[AVR] Add support for the full set of inline asm constraints

Summary:
Previously the method would simply return false, causing every single
inline assembly constraint to trigger a compile error.

This adds inline assembly constraint support for the AVR target.

This patch is derived from the code in
AVRISelLowering::getConstraintType.

More details can be found on the AVR-GCC reference wiki
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, ahatanak, saaadhu, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
cfe/trunk/test/CodeGen/avr-unsupported-inline-asm-constraints.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294176=294175=294176=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  6 03:01:59 2017
@@ -8517,6 +8517,57 @@ public:
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
+// There aren't any multi-character AVR specific constraints.
+if (StringRef(Name).size() > 1) return false;
+
+switch (*Name) {
+  default: return false;
+  case 'a': // Simple upper registers
+  case 'b': // Base pointer registers pairs
+  case 'd': // Upper register
+  case 'l': // Lower registers
+  case 'e': // Pointer register pairs
+  case 'q': // Stack pointer register
+  case 'r': // Any register
+  case 'w': // Special upper register pairs
+  case 't': // Temporary register
+  case 'x': case 'X': // Pointer register pair X
+  case 'y': case 'Y': // Pointer register pair Y
+  case 'z': case 'Z': // Pointer register pair Z
+Info.setAllowsRegister();
+return true;
+  case 'I': // 6-bit positive integer constant
+Info.setRequiresImmediate(0, 63);
+return true;
+  case 'J': // 6-bit negative integer constant
+Info.setRequiresImmediate(-63, 0);
+return true;
+  case 'K': // Integer constant (Range: 2)
+Info.setRequiresImmediate(2);
+return true;
+  case 'L': // Integer constant (Range: 0)
+Info.setRequiresImmediate(0);
+return true;
+  case 'M': // 8-bit integer constant
+Info.setRequiresImmediate(0, 0xff);
+return true;
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+return true;
+  case 'O': // Integer constant (Range: 8, 16, 24)
+Info.setRequiresImmediate({8, 16, 24});
+return true;
+  case 'P': // Integer constant (Range: 1)
+Info.setRequiresImmediate(1);
+return true;
+  case 'R': // Integer constant (Range: -6 to 5)
+Info.setRequiresImmediate(-6, 5);
+return true;
+  case 'G': // Floating point constant
+  case 'Q': // A memory address based on Y or Z pointer with displacement.
+return true;
+}
+
 return false;
   }
 

Added: cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c?rev=294176=auto
==
--- cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c (added)
+++ cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c Mon Feb  6 03:01:59 2017
@@ -0,0 +1,124 @@
+// REQUIRES: avr-registered-target
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | FileCheck 
%s
+
+int data;
+
+void a() {
+  // CHECK: call void asm sideeffect "add r5, $0", "a"(i16 %0)
+  asm("add r5, %0" :: "a"(data));
+}
+
+void b() {
+  // CHECK: call void asm sideeffect "add r5, $0", "b"(i16 %0)
+  asm("add r5, %0" :: "b"(data));
+}
+
+void d() {
+  // CHECK: call void asm sideeffect "add r5, $0", "d"(i16 %0)
+  asm("add r5, %0" :: "d"(data));
+}
+
+void l() {
+  // CHECK: call void asm sideeffect "add r5, $0", "l"(i16 %0)
+  asm("add r5, %0" :: "l"(data));
+}
+
+void e() {
+  // CHECK: call void asm sideeffect "add r5, $0", "e"(i16 %0)
+  asm("add r5, %0" :: "e"(data));
+}
+
+void q() {
+  // CHECK: call void asm sideeffect "add r5, $0", "q"(i16 %0)
+  asm("add r5, %0" :: "q"(data));
+}
+
+void r() {
+  // CHECK: call void asm sideeffect "add r5, $0", "r"(i16 %0)
+  asm("add r5, %0" :: "r"(data));
+}
+
+void w() {
+  // CHECK: call void asm sideeffect "add r5, $0", "w"(i16 %0)
+  asm("add r5, %0" :: "w"(data));
+}
+
+void t() {
+  // CHECK: call void asm sideeffect "add r5, $0", "t"(i16 %0)
+  asm("add r5, %0" :: "t"(data));
+}
+
+void x() {
+  // CHECK: call void 

[PATCH] D28346: [AVR] Allow specifying the CPU on the command line

2017-02-06 Thread Dylan McKay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dylanmckay marked an inline comment as done.
Closed by commit rL294177: [AVR] Allow specifying the CPU on the command line 
(authored by dylanmckay).

Changed prior to commit:
  https://reviews.llvm.org/D28346?vs=87172=87195#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28346

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
  cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
  cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c

Index: cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
===
--- cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
+++ cfe/trunk/test/CodeGen/avr/target-cpu-defines/attiny104.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny104 /dev/null | FileCheck -match-full-lines %s
+
+// CHECK: #define AVR 1
+// CHECK: #define __AVR 1
+// CHECK: #define __AVR_ATtiny104 1
+// CHECK: #define __AVR__ 1
Index: cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
===
--- cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
+++ cfe/trunk/test/CodeGen/avr/target-cpu-defines/atmega328p.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu atmega328p /dev/null | FileCheck -match-full-lines %s
+
+// CHECK: #define AVR 1
+// CHECK: #define __AVR 1
+// CHECK: #define __AVR_ATmega328P 1
+// CHECK: #define __AVR__ 1
Index: cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
===
--- cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
+++ cfe/trunk/test/CodeGen/avr/target-cpu-defines/common.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown /dev/null | FileCheck -match-full-lines %s
+
+// CHECK: #define AVR 1
+// CHECK: #define __AVR 1
+// CHECK: #define __AVR__ 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -8435,6 +8435,254 @@
   }
 };
 
+/// Information about a specific microcontroller.
+struct MCUInfo {
+  const char *Name;
+  const char *DefineName;
+};
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static ArrayRef AVRMcus = {
+  { "at90s1200", "__AVR_AT90S1200__" },
+  { "attiny11", "__AVR_ATtiny11" },
+  { "attiny12", "__AVR_ATtiny12" },
+  { "attiny15", "__AVR_ATtiny15" },
+  { "attiny28", "__AVR_ATtiny28" },
+  { "at90s2313", "__AVR_AT90S2313" },
+  { "at90s2323", "__AVR_AT90S2323" },
+  { "at90s2333", "__AVR_AT90S2333" },
+  { "at90s2343", "__AVR_AT90S2343" },
+  { "attiny22", "__AVR_ATtiny22" },
+  { "attiny26", "__AVR_ATtiny26" },
+  { "at86rf401", "__AVR_AT86RF401" },
+  { "at90s4414", "__AVR_AT90S4414" },
+  { "at90s4433", "__AVR_AT90S4433" },
+  { "at90s4434", "__AVR_AT90S4434" },
+  { "at90s8515", "__AVR_AT90S8515" },
+  { "at90c8534", "__AVR_AT90c8534" },
+  { "at90s8535", "__AVR_AT90S8535" },
+  { "ata5272", "__AVR_ATA5272" },
+  { "attiny13", "__AVR_ATtiny13" },
+  { "attiny13a", "__AVR_ATtiny13A" },
+  { "attiny2313", "__AVR_ATtiny2313" },
+  { "attiny2313a", "__AVR_ATtiny2313A" },
+  { "attiny24", "__AVR_ATtiny24" },
+  { "attiny24a", "__AVR_ATtiny24A" },
+  { "attiny4313", "__AVR_ATtiny4313" },
+  { "attiny44", "__AVR_ATtiny44" },
+  { "attiny44a", "__AVR_ATtiny44A" },
+  { "attiny84", "__AVR_ATtiny84" },
+  { "attiny84a", "__AVR_ATtiny84A" },
+  { "attiny25", "__AVR_ATtiny25" },
+  { "attiny45", "__AVR_ATtiny45" },
+  { "attiny85", "__AVR_ATtiny85" },
+  { "attiny261", "__AVR_ATtiny261" },
+  { "attiny261a", "__AVR_ATtiny261A" },
+  { "attiny461", "__AVR_ATtiny461" },
+  { "attiny461a", "__AVR_ATtiny461A" },
+  { "attiny861", "__AVR_ATtiny861" },
+  { "attiny861a", "__AVR_ATtiny861A" },
+  { "attiny87", "__AVR_ATtiny87" },
+  { "attiny43u", "__AVR_ATtiny43U" },
+  { "attiny48", "__AVR_ATtiny48" },
+  { "attiny88", "__AVR_ATtiny88" },
+  { "attiny828", "__AVR_ATtiny828" },
+  { "at43usb355", "__AVR_AT43USB355" },
+  { "at76c711", "__AVR_AT76C711" },
+  { "atmega103", "__AVR_ATmega103" },
+  { "at43usb320", "__AVR_AT43USB320" },
+  { "attiny167", "__AVR_ATtiny167" },
+  { "at90usb82", "__AVR_AT90USB82" },
+  { "at90usb162", "__AVR_AT90USB162" },
+  { "ata5505", "__AVR_ATA5505" },
+  { "atmega8u2", "__AVR_ATmega8U2" },
+  { "atmega16u2", "__AVR_ATmega16U2" },
+  { "atmega32u2", "__AVR_ATmega32U2" },
+  { "attiny1634", "__AVR_ATtiny1634" },
+  { "atmega8", "__AVR_ATmega8" },
+  { "ata6289", "__AVR_ATA6289" },
+  { "atmega8a", "__AVR_ATmega8A" },
+  { "ata6285", "__AVR_ATA6285" },
+  { "ata6286", "__AVR_ATA6286" },
+  { "atmega48", "__AVR_ATmega48" },
+  { "atmega48a", "__AVR_ATmega48A" },
+  { "atmega48pa", "__AVR_ATmega48PA" },
+  { "atmega48p", "__AVR_ATmega48P" },
+  { 

[PATCH] D28344: [AVR] Add support for the full set of inline asm constraints

2017-02-06 Thread Dylan McKay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294176: [AVR] Add support for the full set of inline asm 
constraints (authored by dylanmckay).

Changed prior to commit:
  https://reviews.llvm.org/D28344?vs=87191=87194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28344

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
  cfe/trunk/test/CodeGen/avr-unsupported-inline-asm-constraints.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -8517,6 +8517,57 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
+// There aren't any multi-character AVR specific constraints.
+if (StringRef(Name).size() > 1) return false;
+
+switch (*Name) {
+  default: return false;
+  case 'a': // Simple upper registers
+  case 'b': // Base pointer registers pairs
+  case 'd': // Upper register
+  case 'l': // Lower registers
+  case 'e': // Pointer register pairs
+  case 'q': // Stack pointer register
+  case 'r': // Any register
+  case 'w': // Special upper register pairs
+  case 't': // Temporary register
+  case 'x': case 'X': // Pointer register pair X
+  case 'y': case 'Y': // Pointer register pair Y
+  case 'z': case 'Z': // Pointer register pair Z
+Info.setAllowsRegister();
+return true;
+  case 'I': // 6-bit positive integer constant
+Info.setRequiresImmediate(0, 63);
+return true;
+  case 'J': // 6-bit negative integer constant
+Info.setRequiresImmediate(-63, 0);
+return true;
+  case 'K': // Integer constant (Range: 2)
+Info.setRequiresImmediate(2);
+return true;
+  case 'L': // Integer constant (Range: 0)
+Info.setRequiresImmediate(0);
+return true;
+  case 'M': // 8-bit integer constant
+Info.setRequiresImmediate(0, 0xff);
+return true;
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+return true;
+  case 'O': // Integer constant (Range: 8, 16, 24)
+Info.setRequiresImmediate({8, 16, 24});
+return true;
+  case 'P': // Integer constant (Range: 1)
+Info.setRequiresImmediate(1);
+return true;
+  case 'R': // Integer constant (Range: -6 to 5)
+Info.setRequiresImmediate(-6, 5);
+return true;
+  case 'G': // Floating point constant
+  case 'Q': // A memory address based on Y or Z pointer with displacement.
+return true;
+}
+
 return false;
   }
 
Index: cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
===
--- cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
+++ cfe/trunk/test/CodeGen/avr-inline-asm-constraints.c
@@ -0,0 +1,124 @@
+// REQUIRES: avr-registered-target
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+int data;
+
+void a() {
+  // CHECK: call void asm sideeffect "add r5, $0", "a"(i16 %0)
+  asm("add r5, %0" :: "a"(data));
+}
+
+void b() {
+  // CHECK: call void asm sideeffect "add r5, $0", "b"(i16 %0)
+  asm("add r5, %0" :: "b"(data));
+}
+
+void d() {
+  // CHECK: call void asm sideeffect "add r5, $0", "d"(i16 %0)
+  asm("add r5, %0" :: "d"(data));
+}
+
+void l() {
+  // CHECK: call void asm sideeffect "add r5, $0", "l"(i16 %0)
+  asm("add r5, %0" :: "l"(data));
+}
+
+void e() {
+  // CHECK: call void asm sideeffect "add r5, $0", "e"(i16 %0)
+  asm("add r5, %0" :: "e"(data));
+}
+
+void q() {
+  // CHECK: call void asm sideeffect "add r5, $0", "q"(i16 %0)
+  asm("add r5, %0" :: "q"(data));
+}
+
+void r() {
+  // CHECK: call void asm sideeffect "add r5, $0", "r"(i16 %0)
+  asm("add r5, %0" :: "r"(data));
+}
+
+void w() {
+  // CHECK: call void asm sideeffect "add r5, $0", "w"(i16 %0)
+  asm("add r5, %0" :: "w"(data));
+}
+
+void t() {
+  // CHECK: call void asm sideeffect "add r5, $0", "t"(i16 %0)
+  asm("add r5, %0" :: "t"(data));
+}
+
+void x() {
+  // CHECK: call void asm sideeffect "add r5, $0", "x"(i16 %0)
+  asm("add r5, %0" :: "x"(data));
+}
+
+void y() {
+  // CHECK: call void asm sideeffect "add r5, $0", "y"(i16 %0)
+  asm("add r5, %0" :: "y"(data));
+}
+
+void z() {
+  // CHECK: call void asm sideeffect "add r5, $0", "z"(i16 %0)
+  asm("add r5, %0" :: "z"(data));
+}
+
+void I() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "I"(i16 50)
+  asm("subi r30, %0" :: "I"(50));
+}
+
+void J() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "J"(i16 -50)
+  asm("subi r30, %0" :: "J"(-50));
+}
+
+void K() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "K"(i16 2)
+  asm("subi r30, %0" :: "K"(2));
+}
+
+void L() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "L"(i16 0)
+  

[PATCH] D28344: [AVR] Add support for the full set of inline asm constraints

2017-02-06 Thread Anton Korobeynikov via Phabricator via cfe-commits
asl accepted this revision.
asl added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Basic/Targets.cpp:8570
+}
   }
 

don't you want to have "return false" here, just to silence warning for some 
compilers?


https://reviews.llvm.org/D28344



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


  1   2   >