[PATCH] D26839: [analyzer] An attempt to fix pr19539 - crashes on temporaries life-extended via members

2016-11-18 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.



Comment at: test/Analysis/lifetime-extension.cpp:11
+  int j[2];
+  S s;
+  A() : i(1) {

what is the role of S in this test ?


https://reviews.llvm.org/D26839



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


[PATCH] D26839: [analyzer] An attempt to fix pr19539 - crashes on temporaries life-extended via members

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 78478.

https://reviews.llvm.org/D26839

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/lifetime-extension.cpp

Index: test/Analysis/lifetime-extension.cpp
===
--- /dev/null
+++ test/Analysis/lifetime-extension.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -Wno-unused -std=c++11 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+
+struct A {
+  int i;
+  int j[2];
+  A() : i(1) {
+j[0] = 2;
+j[1] = 3;
+  }
+  ~A() {}
+};
+
+void clang_analyzer_eval(bool);
+
+void f() {
+  const int &x = A().i; // no-crash
+  const int &y = A().j[1]; // no-crash
+  const int &z = (A().j[1], A().j[0]); // no-crash
+
+  // FIXME: All of these should be TRUE, but constructors aren't inlined.
+  clang_analyzer_eval(x == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(y == 3); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z == 2); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -202,51 +202,56 @@
   MemRegionManager &MRMgr = StateMgr.getRegionManager();
   StoreManager &StoreMgr = StateMgr.getStoreManager();
 
-  // We need to be careful about treating a derived type's value as
-  // bindings for a base type. Unless we're creating a temporary pointer region,
-  // start by stripping and recording base casts.
-  SmallVector Casts;
-  const Expr *Inner = Ex->IgnoreParens();
-  if (!Loc::isLocType(Result->getType())) {
-while (const CastExpr *CE = dyn_cast(Inner)) {
-  if (CE->getCastKind() == CK_DerivedToBase ||
-  CE->getCastKind() == CK_UncheckedDerivedToBase)
-Casts.push_back(CE);
-  else if (CE->getCastKind() != CK_NoOp)
-break;
-
-  Inner = CE->getSubExpr()->IgnoreParens();
-}
-  }
+  // MaterializeTemporaryExpr may appear out of place, after a few field and
+  // base-class accesses have been made to the object, even though semantically
+  // it is the whole object that gets materialized and lifetime-extended.
+  // Use the usual methods for obtaining the expression of the base object,
+  // and record the adjustments that we need to make to obtain the sub-object
+  // that the whole expression 'Ex' refers to. This trick is usual,
+  // in the sense that CodeGen takes a similar route.
+  SmallVector CommaLHSs;
+  SmallVector Adjustments;
+
+  const Expr *Init = Ex->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
 
-  // Create a temporary object region for the inner expression (which may have
-  // a more derived type) and bind the value into it.
   const TypedValueRegion *TR = nullptr;
   if (const MaterializeTemporaryExpr *MT =
   dyn_cast(Result)) {
 StorageDuration SD = MT->getStorageDuration();
 // If this object is bound to a reference with static storage duration, we
 // put it in a different region to prevent "address leakage" warnings.
 if (SD == SD_Static || SD == SD_Thread)
-TR = MRMgr.getCXXStaticTempObjectRegion(Inner);
+  TR = MRMgr.getCXXStaticTempObjectRegion(Init);
   }
   if (!TR)
-TR = MRMgr.getCXXTempObjectRegion(Inner, LC);
+TR = MRMgr.getCXXTempObjectRegion(Init, LC);
 
   SVal Reg = loc::MemRegionVal(TR);
 
+  // Make the necessary adjustments to obtain the sub-object.
+  for (auto I = Adjustments.rbegin(), E = Adjustments.rend(); I != E; ++I) {
+const SubobjectAdjustment &Adj = *I;
+switch (Adj.Kind) {
+case SubobjectAdjustment::DerivedToBaseAdjustment:
+  Reg = StoreMgr.evalDerivedToBase(Reg, Adj.DerivedToBase.BasePath);
+  break;
+case SubobjectAdjustment::FieldAdjustment:
+  Reg = StoreMgr.getLValueField(Adj.Field, Reg);
+  break;
+case SubobjectAdjustment::MemberPointerAdjustment:
+  // FIXME: Unimplemented.
+  State->bindDefault(Reg, UnknownVal());
+  return State;
+}
+  }
+
+  // Try to recover some path sensitivity in case we couldn't compute the value.
   if (V.isUnknown())
 V = getSValBuilder().conjureSymbolVal(Result, LC, TR->getValueType(),
   currBldrCtx->blockCount());
+  // Bind the value of the expression to the sub-object region, and then bind
+  // the sub-object region to our expression.
   State = State->bindLoc(Reg, V);
-
-  // Re-apply the casts (from innermost to outermost) for type sanity.
-  for (SmallVectorImpl::reverse_iterator I = Casts.rbegin(),
-   E = Casts.rend();
-   I != E; ++I) {
-Reg = StoreMgr.evalDerivedToBase(Reg, *I);
-  }
-
   State = State->BindExpr(Result, LC, Reg);
   return State;
 }
@@ -596,9 +601,9 @@
   SVal dest = state->getLValue(varDecl, Pred->getLocationContext());
   const MemRegion *Region = dest.castAs().getRegion();
 
-  if (const ReferenceType *refType = varType->getA

[PATCH] D26839: [analyzer] An attempt to fix pr19539 - crashes on temporaries life-extended via members

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: test/Analysis/lifetime-extension.cpp:11
+  int j[2];
+  S s;
+  A() : i(1) {

alexshap wrote:
> what is the role of S in this test ?
I copy-pasted this from the original bug report. The only purpose of S is to 
provide a non-trivial destructor. I also thought it'd be a nice twist to the 
test to make the destructor non-obvious, but it doesn't really matter. Removed.


https://reviews.llvm.org/D26839



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

@mclow.lists is working on this in https://reviews.llvm.org/D26667.
The review comments from that apply here too.


https://reviews.llvm.org/D26829



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Should this review be closed then?


https://reviews.llvm.org/D26829



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


[PATCH] D26837: [analyzer] Litter the SVal/SymExpr/MemRegion class hierarchy with asserts.

2016-11-18 Thread Sean Eveson via cfe-commits
seaneveson added inline comments.



Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:334
 void BlockCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
+  locTy->getTypePtr()->isBlockPointerType();
   BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);

Was this meant to be an assert?


https://reviews.llvm.org/D26837



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


[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D26844

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp


Index: test/clang-move/move-multiple-classes.cpp
===
--- test/clang-move/move-multiple-classes.cpp
+++ test/clang-move/move-multiple-classes.cpp
@@ -1,8 +1,8 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- | FileCheck %s 
-check-prefix=CHECK-EMPTY
-// RUN: clang-move -names="a::Move1, 
b::Move2,c::Move3,c::Move4,c::EnclosingMove5" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h 
%T/move-multiple-classes/multiple_class_test.cpp --
+// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- -std=c++11| FileCheck %s 
-check-prefix=CHECK-EMPTY
+// RUN: clang-move -names="a::Move1, 
b::Move2,c::Move3,c::Move4,c::EnclosingMove5" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h 
%T/move-multiple-classes/multiple_class_test.cpp -- -std=c++11
 // RUN: FileCheck 
-input-file=%T/move-multiple-classes/new_multiple_class_test.cpp 
-check-prefix=CHECK-NEW-TEST-CPP %s
 // RUN: FileCheck 
-input-file=%T/move-multiple-classes/new_multiple_class_test.h 
-check-prefix=CHECK-NEW-TEST-H %s
 // RUN: FileCheck -input-file=%T/move-multiple-classes/multiple_class_test.cpp 
-check-prefix=CHECK-OLD-TEST-CPP %s
@@ -18,6 +18,10 @@
 // CHECK-OLD-TEST-H: } // namespace c
 
 // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: using a::Move1;
+// CHECK-OLD-TEST-CPP: using namespace a;
+// CHECK-OLD-TEST-CPP: using A = a::Move1;
+// CHECK-OLD-TEST-CPP: static int g = 0;
 // CHECK-OLD-TEST-CPP: namespace {
 // CHECK-OLD-TEST-CPP: using a::Move1;
 // CHECK-OLD-TEST-CPP: using namespace a;
@@ -70,6 +74,10 @@
 // CHECK-NEW-TEST-H: #endif // {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
+// CHECK-NEW-TEST-CPP: using a::Move1;
+// CHECK-NEW-TEST-CPP: using namespace a;
+// CHECK-NEW-TEST-CPP: using A = a::Move1;
+// CHECK-NEW-TEST-CPP: static int g = 0;
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; }
 // CHECK-NEW-TEST-CPP: } // namespace a
Index: test/clang-move/Inputs/multiple_class_test.cpp
===
--- test/clang-move/Inputs/multiple_class_test.cpp
+++ test/clang-move/Inputs/multiple_class_test.cpp
@@ -1,5 +1,10 @@
 #include "multiple_class_test.h"
 
+using a::Move1;
+using namespace a;
+using A = a::Move1;
+static int g = 0;
+
 namespace a {
 int Move1::f() {
   return 0;
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -453,15 +453,17 @@
   
//
   // Matchers for old cc
   
//
-  auto InOldCCNamedNamespace =
-  allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC);
-  // Matching using decls/type alias decls which are in named namespace. Those
-  // in classes, functions and anonymous namespaces are covered in other
-  // matchers.
+  auto InOldCCNamedOrGlobalNamespace =
+  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
+ translationUnitDecl(,
+InOldCC);
+  // Matching using decls/type alias decls which are in named namespace or
+  // global namespace. Those in classes, functions and anonymous namespaces are
+  // covered in other matchers.
   Finder->addMatcher(
-  namedDecl(anyOf(usingDecl(InOldCCNamedNamespace),
-  us

[PATCH] D26837: [analyzer] Litter the SVal/SymExpr/MemRegion class hierarchy with asserts.

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 78489.
NoQ marked an inline comment as done.
NoQ added a comment.

Remove unused expression.


https://reviews.llvm.org/D26837

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  lib/StaticAnalyzer/Core/MemRegion.cpp
  lib/StaticAnalyzer/Core/SVals.cpp

Index: lib/StaticAnalyzer/Core/SVals.cpp
===
--- lib/StaticAnalyzer/Core/SVals.cpp
+++ lib/StaticAnalyzer/Core/SVals.cpp
@@ -29,25 +29,6 @@
 // Utility methods.
 //===--===//
 
-bool SVal::hasConjuredSymbol() const {
-  if (Optional SV = getAs()) {
-SymbolRef sym = SV->getSymbol();
-if (isa(sym))
-  return true;
-  }
-
-  if (Optional RV = getAs()) {
-const MemRegion *R = RV->getRegion();
-if (const SymbolicRegion *SR = dyn_cast(R)) {
-  SymbolRef sym = SR->getSymbol();
-  if (isa(sym))
-return true;
-}
-  }
-
-  return false;
-}
-
 const FunctionDecl *SVal::getAsFunctionDecl() const {
   if (Optional X = getAs()) {
 const MemRegion* R = X->getRegion();
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -379,10 +379,8 @@
 //===--===//
 
 void GlobalsSpaceRegion::anchor() { }
-void HeapSpaceRegion::anchor() { }
-void UnknownSpaceRegion::anchor() { }
-void StackLocalsSpaceRegion::anchor() { }
-void StackArgumentsSpaceRegion::anchor() { }
+void NonStaticGlobalSpaceRegion::anchor() { }
+void StackSpaceRegion::anchor() { }
 void TypedRegion::anchor() { }
 void TypedValueRegion::anchor() { }
 void CodeTextRegion::anchor() { }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -44,7 +44,10 @@
 
 public:
   SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
-: SymbolData(SymbolRegionValueKind, sym), R(r) {}
+  : SymbolData(SymbolRegionValueKind, sym), R(r) {
+assert(r);
+assert(isValidTypeForSymbol(r->getValueType()));
+  }
 
   const TypedValueRegion* getRegion() const { return R; }
 
@@ -81,7 +84,15 @@
   SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
  QualType t, unsigned count, const void *symbolTag)
   : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
-LCtx(lctx), SymbolTag(symbolTag) {}
+LCtx(lctx), SymbolTag(symbolTag) {
+// FIXME: 's' might be a nullptr if we're conducting invalidation
+// that was caused by a destructor call on a temporary object,
+// which has no statement associated with it.
+// Due to this, we might be creating the same invalidation symbol for
+// two different invalidation passes (for two different temporaries).
+assert(lctx);
+assert(isValidTypeForSymbol(t));
+  }
 
   const Stmt *getStmt() const { return S; }
   unsigned getCount() const { return Count; }
@@ -120,7 +131,11 @@
 
 public:
   SymbolDerived(SymbolID sym, SymbolRef parent, const TypedValueRegion *r)
-: SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {}
+  : SymbolData(SymbolDerivedKind, sym), parentSymbol(parent), R(r) {
+assert(parent);
+assert(r);
+assert(isValidTypeForSymbol(r->getValueType()));
+  }
 
   SymbolRef getParentSymbol() const { return parentSymbol; }
   const TypedValueRegion *getRegion() const { return R; }
@@ -155,7 +170,9 @@
   
 public:
   SymbolExtent(SymbolID sym, const SubRegion *r)
-  : SymbolData(SymbolExtentKind, sym), R(r) {}
+  : SymbolData(SymbolExtentKind, sym), R(r) {
+assert(r);
+  }
 
   const SubRegion *getRegion() const { return R; }
 
@@ -193,7 +210,13 @@
   SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
  const LocationContext *LCtx, unsigned count, const void *tag)
   : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
-Count(count), Tag(tag) {}
+Count(count), Tag(tag) {
+  assert(r);
+  assert(s);
+  assert(isValidTypeForSymbol(t));
+  assert(LCtx);
+  assert(tag);
+}
 
   const MemRegion *getRegion() const { return R; }
   const Stmt *getStmt() const { return S; }
@@ -236,8 +259,13 @@
   QualType ToTy;
 
 public:
-  SymbolCast(const SymExpr *In, QualType From, QualType To) :
-SymExpr(SymbolCastKind), Operand(In), FromTy(From), ToTy(To) { }
+  SymbolCast(con

[PATCH] D26837: [analyzer] Litter the SVal/SymExpr/MemRegion class hierarchy with asserts.

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:334
 void BlockCodeRegion::Profile(llvm::FoldingSetNodeID& ID) const {
+  locTy->getTypePtr()->isBlockPointerType();
   BlockCodeRegion::ProfileRegion(ID, BD, locTy, AC, superRegion);

seaneveson wrote:
> Was this meant to be an assert?
Whoops thanks :) No, it's misplaced code, the similar assert is in the 
constructor.


https://reviews.llvm.org/D26837



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


[libcxxabi] r287327 - Rename TU names to not conflict with libc++.

2016-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Nov 18 03:54:49 2016
New Revision: 287327

URL: http://llvm.org/viewvc/llvm-project?rev=287327&view=rev
Log:
Rename TU names to not conflict with libc++.

In order to easily merge libc++ and libc++abi static archives it's important
that none of the source files share the same name.
(See 
http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one)

This patch renames source files which share a name with libc++ sources.

Added:
libcxxabi/trunk/src/stdlib_exception.cpp
libcxxabi/trunk/src/stdlib_stdexcept.cpp
libcxxabi/trunk/src/stdlib_typeinfo.cpp
Removed:
libcxxabi/trunk/src/exception.cpp
libcxxabi/trunk/src/stdexcept.cpp
libcxxabi/trunk/src/typeinfo.cpp
Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=287327&r1=287326&r2=287327&view=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Fri Nov 18 03:54:49 2016
@@ -1,6 +1,6 @@
 # Get sources
 set(LIBCXXABI_SOURCES
-  abort_message.cpp
+  # C++ABI files
   cxa_aux_runtime.cpp
   cxa_default_handlers.cpp
   cxa_demangle.cpp
@@ -11,11 +11,14 @@ set(LIBCXXABI_SOURCES
   cxa_unexpected.cpp
   cxa_vector.cpp
   cxa_virtual.cpp
-  exception.cpp
+  # C++ STL files
+  stdlib_exception.cpp
+  stdlib_stdexcept.cpp
+  stdlib_typeinfo.cpp
+  # Internal files
+  abort_message.cpp
   fallback_malloc.cpp
   private_typeinfo.cpp
-  stdexcept.cpp
-  typeinfo.cpp
 )
 
 if (LIBCXXABI_ENABLE_EXCEPTIONS)

Removed: libcxxabi/trunk/src/exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/exception.cpp?rev=287326&view=auto
==
--- libcxxabi/trunk/src/exception.cpp (original)
+++ libcxxabi/trunk/src/exception.cpp (removed)
@@ -1,41 +0,0 @@
-//=== exception.cpp 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include 
-
-#pragma GCC visibility push(default)
-
-namespace std
-{
-
-// exception
-
-exception::~exception() _NOEXCEPT
-{
-}
-
-const char* exception::what() const _NOEXCEPT
-{
-  return "std::exception";
-}
-
-// bad_exception
-
-bad_exception::~bad_exception() _NOEXCEPT
-{
-}
-
-const char* bad_exception::what() const _NOEXCEPT
-{
-  return "std::bad_exception";
-}
-
-}  // std
-
-#pragma GCC visibility pop

Removed: libcxxabi/trunk/src/stdexcept.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/stdexcept.cpp?rev=287326&view=auto
==
--- libcxxabi/trunk/src/stdexcept.cpp (original)
+++ libcxxabi/trunk/src/stdexcept.cpp (removed)
@@ -1,48 +0,0 @@
-//=== stdexcept.cpp 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "__refstring"
-#include "stdexcept"
-#include "new"
-#include 
-#include 
-#include 
-#include 
-
-static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
-
-namespace std  // purposefully not using versioning namespace
-{
-
-logic_error::~logic_error() _NOEXCEPT {}
-
-const char*
-logic_error::what() const _NOEXCEPT
-{
-return __imp_.c_str();
-}
-
-runtime_error::~runtime_error() _NOEXCEPT {}
-
-const char*
-runtime_error::what() const _NOEXCEPT
-{
-return __imp_.c_str();
-}
-
-domain_error::~domain_error() _NOEXCEPT {}
-invalid_argument::~invalid_argument() _NOEXCEPT {}
-length_error::~length_error() _NOEXCEPT {}
-out_of_range::~out_of_range() _NOEXCEPT {}
-
-range_error::~range_error() _NOEXCEPT {}
-overflow_error::~overflow_error() _NOEXCEPT {}
-underflow_error::~underflow_error() _NOEXCEPT {}
-
-}  // std

Added: libcxxabi/trunk/src/stdlib_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/stdlib_exception.cpp?rev=287327&view=auto
==
--- libcxxabi/trunk/src/stdlib_exception.cpp (added)
+++ libcxxabi/trunk/src/stdlib_exception.cpp Fri Nov 18 03:54:49 2016
@@ -0,0 +1,41 @@
+//=== exception.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT fo

[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: test/clang-move/move-multiple-classes.cpp:21
 // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: using a::Move1;
+// CHECK-OLD-TEST-CPP: using namespace a;

Would there be empty lines between these using decls? If so, please add FIXME 
if you want to handle this in the future.


https://reviews.llvm.org/D26844



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78490.

https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/Lexer.cpp


Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1713,6 +1713,13 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
+  if (Chars == 2 && Buffer[0] == 's' && Buffer[1] == 'v') {
+IsUDSuffix = true;
+if (!getLangOpts().CPlusPlus1z)
+  Diag(CurPtr, diag::warn_cxx1z_string_view_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+break;
+  }
   IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
NumericLiteralParser::isValidUDSuffix(
getLangOpts(), StringRef(Buffer, Chars));
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def warn_cxx1z_string_view_literal : Warning<
+  "string_view literals are a C++1z feature">, InGroup;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<


Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1713,6 +1713,13 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
+  if (Chars == 2 && Buffer[0] == 's' && Buffer[1] == 'v') {
+IsUDSuffix = true;
+if (!getLangOpts().CPlusPlus1z)
+  Diag(CurPtr, diag::warn_cxx1z_string_view_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+break;
+  }
   IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
NumericLiteralParser::isValidUDSuffix(
getLangOpts(), StringRef(Buffer, Chars));
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def warn_cxx1z_string_view_literal : Warning<
+  "string_view literals are a C++1z feature">, InGroup;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: test/clang-move/move-multiple-classes.cpp:21
 // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: using a::Move1;
+// CHECK-OLD-TEST-CPP: using namespace a;

ioeric wrote:
> Would there be empty lines between these using decls? If so, please add FIXME 
> if you want to handle this in the future.
Yes. Done.


https://reviews.llvm.org/D26844



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


[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 78491.
hokein marked an inline comment as done.
hokein added a comment.

Add FIXME.


https://reviews.llvm.org/D26844

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp


Index: test/clang-move/move-multiple-classes.cpp
===
--- test/clang-move/move-multiple-classes.cpp
+++ test/clang-move/move-multiple-classes.cpp
@@ -1,8 +1,8 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- | FileCheck %s 
-check-prefix=CHECK-EMPTY
-// RUN: clang-move -names="a::Move1, 
b::Move2,c::Move3,c::Move4,c::EnclosingMove5" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h 
%T/move-multiple-classes/multiple_class_test.cpp --
+// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- -std=c++11| FileCheck %s 
-check-prefix=CHECK-EMPTY
+// RUN: clang-move -names="a::Move1, 
b::Move2,c::Move3,c::Move4,c::EnclosingMove5" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h 
%T/move-multiple-classes/multiple_class_test.cpp -- -std=c++11
 // RUN: FileCheck 
-input-file=%T/move-multiple-classes/new_multiple_class_test.cpp 
-check-prefix=CHECK-NEW-TEST-CPP %s
 // RUN: FileCheck 
-input-file=%T/move-multiple-classes/new_multiple_class_test.h 
-check-prefix=CHECK-NEW-TEST-H %s
 // RUN: FileCheck -input-file=%T/move-multiple-classes/multiple_class_test.cpp 
-check-prefix=CHECK-OLD-TEST-CPP %s
@@ -18,6 +18,10 @@
 // CHECK-OLD-TEST-H: } // namespace c
 
 // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h"
+// CHECK-OLD-TEST-CPP: using a::Move1;
+// CHECK-OLD-TEST-CPP: using namespace a;
+// CHECK-OLD-TEST-CPP: using A = a::Move1;
+// CHECK-OLD-TEST-CPP: static int g = 0;
 // CHECK-OLD-TEST-CPP: namespace {
 // CHECK-OLD-TEST-CPP: using a::Move1;
 // CHECK-OLD-TEST-CPP: using namespace a;
@@ -70,6 +74,10 @@
 // CHECK-NEW-TEST-H: #endif // {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
+// CHECK-NEW-TEST-CPP: using a::Move1;
+// CHECK-NEW-TEST-CPP: using namespace a;
+// CHECK-NEW-TEST-CPP: using A = a::Move1;
+// CHECK-NEW-TEST-CPP: static int g = 0;
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; }
 // CHECK-NEW-TEST-CPP: } // namespace a
Index: test/clang-move/Inputs/multiple_class_test.cpp
===
--- test/clang-move/Inputs/multiple_class_test.cpp
+++ test/clang-move/Inputs/multiple_class_test.cpp
@@ -1,5 +1,10 @@
 #include "multiple_class_test.h"
 
+using a::Move1;
+using namespace a;
+using A = a::Move1;
+static int g = 0;
+
 namespace a {
 int Move1::f() {
   return 0;
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -373,6 +373,7 @@
 }
 // If the moved declaration is in same namespace CurrentNamespace, add
 // a preceeding `\n' before the moved declaration.
+// FIXME: Don't add empty lines between using declarations.
 if (!IsInNewNamespace)
   NewCode += "\n";
 NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
@@ -453,15 +454,17 @@
   
//
   // Matchers for old cc
   
//
-  auto InOldCCNamedNamespace =
-  allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC);
-  // Matching using decls/type alias decls which are in named namespace. Those
-  // in classes, functions and anonymous namespaces are covered in other
-  // matchers.
+  auto InOldCCNamedOrGlobalNamespace =
+  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
+  

[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D26844



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


[PATCH] D26844: [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287330: [clang-move] Fix not moving using-decls in global 
namespace in old.cc (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D26844?vs=78491&id=78492#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26844

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
  clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp


Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -373,6 +373,7 @@
 }
 // If the moved declaration is in same namespace CurrentNamespace, add
 // a preceeding `\n' before the moved declaration.
+// FIXME: Don't add empty lines between using declarations.
 if (!IsInNewNamespace)
   NewCode += "\n";
 NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
@@ -453,15 +454,17 @@
   
//
   // Matchers for old cc
   
//
-  auto InOldCCNamedNamespace =
-  allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC);
-  // Matching using decls/type alias decls which are in named namespace. Those
-  // in classes, functions and anonymous namespaces are covered in other
-  // matchers.
+  auto InOldCCNamedOrGlobalNamespace =
+  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
+ translationUnitDecl(,
+InOldCC);
+  // Matching using decls/type alias decls which are in named namespace or
+  // global namespace. Those in classes, functions and anonymous namespaces are
+  // covered in other matchers.
   Finder->addMatcher(
-  namedDecl(anyOf(usingDecl(InOldCCNamedNamespace),
-  usingDirectiveDecl(InOldCC, InOldCCNamedNamespace),
-  typeAliasDecl(InOldCC, InOldCCNamedNamespace)))
+  namedDecl(anyOf(usingDecl(InOldCCNamedOrGlobalNamespace),
+  usingDirectiveDecl(InOldCCNamedOrGlobalNamespace),
+  typeAliasDecl( InOldCCNamedOrGlobalNamespace)))
   .bind("using_decl"),
   this);
 
@@ -472,7 +475,7 @@
   // Match static functions/variable definitions which are defined in named
   // namespaces.
   auto IsOldCCStaticDefinition =
-  allOf(isDefinition(), unless(InMovedClass), InOldCCNamedNamespace,
+  allOf(isDefinition(), unless(InMovedClass), 
InOldCCNamedOrGlobalNamespace,
 isStaticStorageClass());
   Finder->addMatcher(namedDecl(anyOf(functionDecl(IsOldCCStaticDefinition),
  varDecl(IsOldCCStaticDefinition)))
Index: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
@@ -1,5 +1,10 @@
 #include "multiple_class_test.h"
 
+using a::Move1;
+using namespace a;
+using A = a::Move1;
+static int g = 0;
+
 namespace a {
 int Move1::f() {
   return 0;
Index: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
@@ -1,8 +1,8 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- | FileCheck %s 
-check-prefix=CHECK-EMPTY
-// RUN: clang-move -names="a::Move1, 
b::Move2,c::Move3,c::Move4,c::EnclosingMove5" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h 
%T/move-multiple-classes/multiple_class_test.cpp --
+// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multi

[clang-tools-extra] r287330 - [clang-move] Fix not moving using-decls in global namespace in old.cc

2016-11-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Nov 18 04:51:16 2016
New Revision: 287330

URL: http://llvm.org/viewvc/llvm-project?rev=287330&view=rev
Log:
[clang-move] Fix not moving using-decls in global namespace in old.cc

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=287330&r1=287329&r2=287330&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Nov 18 04:51:16 2016
@@ -373,6 +373,7 @@ createInsertedReplacements(const std::ve
 }
 // If the moved declaration is in same namespace CurrentNamespace, add
 // a preceeding `\n' before the moved declaration.
+// FIXME: Don't add empty lines between using declarations.
 if (!IsInNewNamespace)
   NewCode += "\n";
 NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
@@ -453,15 +454,17 @@ void ClangMoveTool::registerMatchers(ast
   
//
   // Matchers for old cc
   
//
-  auto InOldCCNamedNamespace =
-  allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC);
-  // Matching using decls/type alias decls which are in named namespace. Those
-  // in classes, functions and anonymous namespaces are covered in other
-  // matchers.
+  auto InOldCCNamedOrGlobalNamespace =
+  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
+ translationUnitDecl(,
+InOldCC);
+  // Matching using decls/type alias decls which are in named namespace or
+  // global namespace. Those in classes, functions and anonymous namespaces are
+  // covered in other matchers.
   Finder->addMatcher(
-  namedDecl(anyOf(usingDecl(InOldCCNamedNamespace),
-  usingDirectiveDecl(InOldCC, InOldCCNamedNamespace),
-  typeAliasDecl(InOldCC, InOldCCNamedNamespace)))
+  namedDecl(anyOf(usingDecl(InOldCCNamedOrGlobalNamespace),
+  usingDirectiveDecl(InOldCCNamedOrGlobalNamespace),
+  typeAliasDecl( InOldCCNamedOrGlobalNamespace)))
   .bind("using_decl"),
   this);
 
@@ -472,7 +475,7 @@ void ClangMoveTool::registerMatchers(ast
   // Match static functions/variable definitions which are defined in named
   // namespaces.
   auto IsOldCCStaticDefinition =
-  allOf(isDefinition(), unless(InMovedClass), InOldCCNamedNamespace,
+  allOf(isDefinition(), unless(InMovedClass), 
InOldCCNamedOrGlobalNamespace,
 isStaticStorageClass());
   Finder->addMatcher(namedDecl(anyOf(functionDecl(IsOldCCStaticDefinition),
  varDecl(IsOldCCStaticDefinition)))

Modified: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp?rev=287330&r1=287329&r2=287330&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp Fri 
Nov 18 04:51:16 2016
@@ -1,5 +1,10 @@
 #include "multiple_class_test.h"
 
+using a::Move1;
+using namespace a;
+using A = a::Move1;
+static int g = 0;
+
 namespace a {
 int Move1::f() {
   return 0;

Modified: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp?rev=287330&r1=287329&r2=287330&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp Fri Nov 
18 04:51:16 2016
@@ -1,8 +1,8 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="c::EnclosingMove5::Nested" 
-new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp 
-new_header=%T/move-multiple-classes/new_multiple_class_test.h 
-old_cc=%T/move-multiple-classes/multiple_class_test.cpp 
-old_header=../move-multiple-classes/multiple_class_test.h -dump_result 
%T/move-multiple-classes/multiple_class_test.cpp -- | FileCheck %s 
-check-prefix=CHECK-EMPTY
-// RUN: clang

[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78493.
AntonBikineev marked an inline comment as done.

https://reviews.llvm.org/D26830

Files:
  include/string_view
  test/std/strings/string.view/string.view.literals/literal.pass.cpp
  test/std/strings/string.view/string.view.literals/literal1.fail.cpp
  test/std/strings/string.view/string.view.literals/literal1.pass.cpp
  test/std/strings/string.view/string.view.literals/literal2.fail.cpp
  test/std/strings/string.view/string.view.literals/literal2.pass.cpp
  test/std/strings/string.view/string.view.literals/literal3.pass.cpp

Index: test/std/strings/string.view/string.view.literals/literal3.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal3.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std;
+
+string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals::string_view_literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.fail.cpp
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+std::string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal1.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal1.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using std::string_view;
+
+string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal.pass.cpp
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+/

[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev added inline comments.



Comment at: include/string_view:749
 
+inline namespace literals
+{

EricWF wrote:
> If this is new to C++17 then the new declarations should be guarded by `#if 
> _LIBCPP_VERSION > 14`.
Eric, I was thinking about it, but the fact that the whole string_view code is 
not guarded by _LIBCPP_VERSION > 14 (I guess it's because it can be compiled 
with lower Standards just fine) stopped me from doing that. I'm still not sure 
though.


https://reviews.llvm.org/D26830



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


r287335 - Wdocumentation fix

2016-11-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Nov 18 05:18:28 2016
New Revision: 287335

URL: http://llvm.org/viewvc/llvm-project?rev=287335&view=rev
Log:
Wdocumentation fix

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

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=287335&r1=287334&r2=287335&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Nov 18 05:18:28 2016
@@ -251,9 +251,9 @@ private:
   /// other reproducer related files (.sh, .cache, etc). If not found, suggest 
a
   /// directory for the user to look at.
   ///
-  /// \param The file path to copy the .crash to.
-  /// \param The suggested directory for the user to look at in case the search
-  /// or copy fails.
+  /// \param ReproCrashFilename The file path to copy the .crash to.
+  /// \param CrashDiagDir   The suggested directory for the user to look at
+  ///   in case the search or copy fails.
   ///
   /// \returns If the .crash is found and successfully copied return true,
   /// otherwise false and return the suggested directory in \p CrashDiagDir.


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


[PATCH] D25869: [Driver] Add unit tests for Distro detection

2016-11-18 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[Driver] Add unit tests for DetectDistro()" 
to "[Driver] Add unit tests for Distro detection".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 78494.
mgorny added a comment.

Ok, here are the tests updated for the new API. I'll try to look into adding 
more distributions later today.


https://reviews.llvm.org/D25869

Files:
  unittests/Driver/CMakeLists.txt
  unittests/Driver/DistroTest.cpp

Index: unittests/Driver/DistroTest.cpp
===
--- /dev/null
+++ unittests/Driver/DistroTest.cpp
@@ -0,0 +1,195 @@
+//===- unittests/Driver/DistroTest.cpp --- ToolChains tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for Distro detection.
+//
+//===--===//
+
+#include "clang/Driver/Distro.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+// The tests include all release-related files for each distribution
+// in the VFS, in order to make sure that earlier tests do not
+// accidentally result in incorrect distribution guess.
+
+TEST(DistroTest, DetectUbuntu) {
+  vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
+  // Ubuntu uses Debian Sid version.
+  UbuntuTrustyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("jessie/sid\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=14.04\n"
+   "DISTRIB_CODENAME=trusty\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 14.04 LTS\"\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"14.04, Trusty Tahr\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 14.04 LTS\"\n"
+   "VERSION_ID=\"14.04\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n";
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n";
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n";));
+
+  Distro UbuntuTrusty{UbuntuTrustyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuTrusty), UbuntuTrusty);
+  ASSERT_TRUE(UbuntuTrusty.IsUbuntu());
+  ASSERT_FALSE(UbuntuTrusty.IsRedhat());
+  ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuTrusty.IsDebian());
+
+  vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
+  UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=16.10\n"
+   "DISTRIB_CODENAME=yakkety\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 16.10\"\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"16.10 (Yakkety Yak)\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 16.10\"\n"
+   "VERSION_ID=\"16.10\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n";
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n";
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n";
+   "PRIVACY_POLICY_URL=\"http://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n";
+   "VERSION_CODENAME=yakkety\n"
+   "UBUNTU_CODENAME=yakkety\n"));
+
+  Distro UbuntuYakkety{UbuntuYakketyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuYakkety), UbuntuYakkety);
+  ASSERT_TRUE(UbuntuYakkety.IsUbuntu());
+  ASSERT_FALSE(UbuntuYakkety.IsRedhat());
+  ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuYakkety.IsDebian());
+}
+
+TEST(DistroTest, DetectRedhat) {
+  vfs::InMemoryFileSystem Fedora25FileSystem;
+  Fedora25FileSystem.addFile("/etc

[libcxx] r287336 - Add merge_archives.py utility

2016-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Nov 18 05:26:14 2016
New Revision: 287336

URL: http://llvm.org/viewvc/llvm-project?rev=287336&view=rev
Log:
Add merge_archives.py utility

Added:
libcxx/trunk/utils/merge_archives.py

Added: libcxx/trunk/utils/merge_archives.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/merge_archives.py?rev=287336&view=auto
==
--- libcxx/trunk/utils/merge_archives.py (added)
+++ libcxx/trunk/utils/merge_archives.py Fri Nov 18 05:26:14 2016
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
+from argparse import ArgumentParser
+import distutils.spawn
+import glob
+import tempfile
+import os
+import shutil
+import subprocess
+import signal
+import sys
+
+temp_directory_root = None
+def exit_with_cleanups(status):
+if temp_directory_root is not None:
+shutil.rmtree(temp_directory_root)
+sys.exit(status)
+
+def print_and_exit(msg):
+sys.stderr.write(msg + '\n')
+exit_with_cleanups(1)
+
+def diagnose_missing(file):
+if not os.path.exists(file):
+print_and_exit("input '%s' does not exist" % file)
+
+
+def execute_command(cmd, cwd=None):
+"""
+Execute a command, capture and return its output.
+"""
+kwargs = {
+'stdin': subprocess.PIPE,
+'stdout': subprocess.PIPE,
+'stderr': subprocess.PIPE,
+'cwd': cwd
+}
+p = subprocess.Popen(cmd, **kwargs)
+out, err = p.communicate()
+exitCode = p.wait()
+if exitCode == -signal.SIGINT:
+raise KeyboardInterrupt
+return out, err, exitCode
+
+
+def execute_command_verbose(cmd, cwd=None, verbose=False):
+"""
+Execute a command and print its output on failure.
+"""
+out, err, exitCode = execute_command(cmd, cwd=cwd)
+if exitCode != 0 or verbose:
+report = "Command: %s\n" % ' '.join(["'%s'" % a for a in cmd])
+if exitCode != 0:
+report += "Exit Code: %d\n" % exitCode
+if out:
+report += "Standard Output:\n--\n%s--" % out
+if err:
+report += "Standard Error:\n--\n%s--" % err
+if exitCode != 0:
+report += "\n\nFailed!"
+sys.stderr.write('%s\n' % report)
+if exitCode != 0:
+exit_with_cleanups(exitCode)
+
+def main():
+parser = ArgumentParser(
+description="Merge multiple archives into a single library")
+parser.add_argument(
+'-v', '--verbose', dest='verbose', action='store_true', default=False)
+parser.add_argument(
+'-o', '--output', dest='output', required=True,
+help='The output file. stdout is used if not given',
+type=str, action='store')
+parser.add_argument(
+'archives', metavar='archives',  nargs='+',
+help='The archives to merge')
+
+args = parser.parse_args()
+
+ar_exe = distutils.spawn.find_executable('ar')
+if not ar_exe:
+print_and_exit("failed to find 'ar' executable")
+
+if len(args.archives) < 2:
+print_and_exit('fewer than 2 inputs provided')
+archives = []
+for ar in args.archives:
+diagnose_missing(ar)
+# Make the path absolute so it isn't affected when we change the PWD.
+archives += [os.path.abspath(ar)]
+
+if not os.path.exists(os.path.dirname(args.output)):
+print_and_exit("output path doesn't exist: '%s'" % args.output)
+
+global temp_directory_root
+temp_directory_root = tempfile.mkdtemp('.libcxx.merge.archives')
+
+for arc in archives:
+execute_command_verbose([ar_exe, '-x', arc], cwd=temp_directory_root,
+verbose=args.verbose)
+
+files = glob.glob(os.path.join(temp_directory_root, '*.o'))
+if not files:
+print_and_exit('Failed to glob for %s' % glob_path)
+cmd = [ar_exe, '-qc', args.output] + files
+execute_command_verbose(cmd, cwd=temp_directory_root, verbose=args.verbose)
+
+
+if __name__ == '__main__':
+main()
+exit_with_cleanups(0)


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


[libcxx] r287337 - Make merge_archives.py executable

2016-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Nov 18 05:29:05 2016
New Revision: 287337

URL: http://llvm.org/viewvc/llvm-project?rev=287337&view=rev
Log:
Make merge_archives.py executable

Modified:
libcxx/trunk/utils/merge_archives.py   (props changed)

Propchange: libcxx/trunk/utils/merge_archives.py
--
svn:executable = *


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


[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.



Comment at: include/string_view:749
 
+inline namespace literals
+{

AntonBikineev wrote:
> EricWF wrote:
> > If this is new to C++17 then the new declarations should be guarded by `#if 
> > _LIBCPP_VERSION > 14`.
> Eric, I was thinking about it, but the fact that the whole string_view code 
> is not guarded by _LIBCPP_VERSION > 14 (I guess it's because it can be 
> compiled with lower Standards just fine) stopped me from doing that. I'm 
> still not sure though.
Understandable. The decision to backport most of `string_view` was intentional. 

However we shouldn't backport these, since the literal suffix is only supported 
by the compiler in C++17.


https://reviews.llvm.org/D26830



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


[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78497.

https://reviews.llvm.org/D26830

Files:
  include/string_view
  test/std/strings/string.view/string.view.literals/literal.pass.cpp
  test/std/strings/string.view/string.view.literals/literal1.fail.cpp
  test/std/strings/string.view/string.view.literals/literal1.pass.cpp
  test/std/strings/string.view/string.view.literals/literal2.fail.cpp
  test/std/strings/string.view/string.view.literals/literal2.pass.cpp
  test/std/strings/string.view/string.view.literals/literal3.pass.cpp

Index: test/std/strings/string.view/string.view.literals/literal3.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal3.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std;
+
+string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals::string_view_literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.fail.cpp
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+std::string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal1.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal1.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using std::string_view;
+
+string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal.pass.cpp
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and t

[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78498.

https://reviews.llvm.org/D26830

Files:
  include/string_view
  test/std/strings/string.view/string.view.literals/literal.pass.cpp
  test/std/strings/string.view/string.view.literals/literal1.fail.cpp
  test/std/strings/string.view/string.view.literals/literal1.pass.cpp
  test/std/strings/string.view/string.view.literals/literal2.fail.cpp
  test/std/strings/string.view/string.view.literals/literal2.pass.cpp
  test/std/strings/string.view/string.view.literals/literal3.pass.cpp

Index: test/std/strings/string.view/string.view.literals/literal3.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal3.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std;
+
+string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals::string_view_literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.fail.cpp
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+std::string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal1.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal1.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using std::string_view;
+
+string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal.pass.cpp
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and t

[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev marked an inline comment as done.
AntonBikineev added inline comments.



Comment at: include/string_view:749
 
+inline namespace literals
+{

EricWF wrote:
> AntonBikineev wrote:
> > EricWF wrote:
> > > If this is new to C++17 then the new declarations should be guarded by 
> > > `#if _LIBCPP_VERSION > 14`.
> > Eric, I was thinking about it, but the fact that the whole string_view code 
> > is not guarded by _LIBCPP_VERSION > 14 (I guess it's because it can be 
> > compiled with lower Standards just fine) stopped me from doing that. I'm 
> > still not sure though.
> Understandable. The decision to backport most of `string_view` was 
> intentional. 
> 
> However we shouldn't backport these, since the literal suffix is only 
> supported by the compiler in C++17.
Agreed



https://reviews.llvm.org/D26830



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


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Paulo Matos via cfe-commits
pmatos created this revision.
pmatos added a reviewer: efriedma.
pmatos added a subscriber: cfe-commits.

Ensure sizeof expression context is partially evaluated so that potential 
typeof operators inside are evaluated if necessary.

Fixes PR31042.


https://reviews.llvm.org/D26843

Files:
  lib/Parse/ParseExpr.cpp


Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1881,7 +1881,10 @@
   if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
 Diag(OpTok, diag::warn_cxx98_compat_alignof);
 
-  EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated,
+  EnterExpressionEvaluationContext Unevaluated(Actions,
+  OpTok.is(tok::kw_sizeof) ?
+  Sema::PotentiallyEvaluated :
+  Sema::Unevaluated,
Sema::ReuseLambdaContextDecl);
 
   bool isCastExpr;


Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1881,7 +1881,10 @@
   if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
 Diag(OpTok, diag::warn_cxx98_compat_alignof);
 
-  EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated,
+  EnterExpressionEvaluationContext Unevaluated(Actions,
+	   OpTok.is(tok::kw_sizeof) ?
+	   Sema::PotentiallyEvaluated :
+	   Sema::Unevaluated,
Sema::ReuseLambdaContextDecl);
 
   bool isCastExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

This isn't correct. For example this change breaks:

  struct T { int m; };
  int x = sizeof(T::m);


https://reviews.llvm.org/D26843



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


[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-11-18 Thread Kevin Puetz via cfe-commits
puetzk created this revision.
puetzk added a subscriber: cfe-commits.
puetzk set the repository for this revision to rL LLVM.

Although not specifically mentioned in the documentation, MSVC accepts 
__uuidof(…) and declspec(uuid("…")) attributes on enumeration types in addition 
to structs/classes. This is meaningful, as such types *do* have associated 
UUIDs in ActiveX typelibs, and such attributes are included by default in the 
wrappers generated by their #import construct, so they are not particularly 
unusual.

clang currently rejects the declspec with a –Wignored-attributes warning, and 
errors on __uuidof() with “cannot call operator __uuidof on a type with no 
GUID” (because it rejected the uuid attribute, and therefore finds no value). 
This is causing problems for us while trying to use clang-tidy on a codebase 
that makes heavy use of ActiveX.

I believe I have found the relevant places to add this functionality, this 
patch adds this case to clang’s implementation of these MS extensions. 
patch is against r285994 (or actually the git mirror 80464680ce).

Both include an update to test/Parser/MicrosoftExtensions.cpp to exercise the 
new functionality.

This is my first time contributing to LLVM, so if I’ve missed anything else 
needed to prepare this for review just let me know!

__uuidof: https://msdn.microsoft.com/en-us/library/zaah6a61.aspx
declspec(uuid("…")): https://msdn.microsoft.com/en-us/library/3b6wkewa.aspx
#import: https://msdn.microsoft.com/en-us/library/8etzzkb6.aspx


Repository:
  rL LLVM

https://reviews.llvm.org/D26846

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Parser/MicrosoftExtensions.cpp

Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -65,6 +65,10 @@
 struct
 struct_with_uuid2 {} ;
 
+enum __declspec(uuid("00A0---C000-0046"))
+enum_with_uuid { };
+enum enum_without_uuid { };
+
 int uuid_sema_test()
 {
struct_with_uuid var_with_uuid[1];
@@ -81,6 +85,15 @@
__uuidof(const struct_with_uuid[1][1]);
__uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
 
+   __uuidof(enum_with_uuid);
+   __uuidof(enum_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(enum_with_uuid*);
+   __uuidof(enum_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(enum_with_uuid[1]);
+   __uuidof(enum_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(const enum_with_uuid[1][1]);
+   __uuidof(const enum_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
__uuidof(var_with_uuid);
__uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(var_with_uuid[1]);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -520,7 +520,7 @@
   else if (QT->isArrayType())
 Ty = Ty->getBaseElementTypeUnsafe();
 
-  const auto *RD = Ty->getAsCXXRecordDecl();
+  const auto *RD = Ty->getAsTagDecl();
   if (!RD)
 return;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4666,9 +4666,9 @@
 return;
   }
 
-  if (!isa(D)) {
+  if (!(isa(D) || isa(D))) {
 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << Attr.getName() << ExpectedClass;
+  << Attr.getName() << ExpectedEnumOrClass;
 return;
   }
 
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -924,7 +924,8 @@
   ExpectedVariableEnumFieldOrTypedef,
   ExpectedFunctionMethodEnumOrClass,
   ExpectedStructClassVariableFunctionOrInlineNamespace,
-  ExpectedForMaybeUnused
+  ExpectedForMaybeUnused,
+  ExpectedEnumOrClass
 };
 
 }  // end namespace clang
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2633,7 +2633,8 @@
   "|variables, enums, fields and typedefs"
   "|functions, methods, enums, and classes"
   "|structs, classes, variables, functions, and inline namespaces"
-  "|variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members}1">,
+  "|variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members"

[Patch] D26847: Fix Internal Compiler Error compiling Clang with the latest version of MSVC

2016-11-18 Thread Hugh Bellamy via cfe-commits
I'm new here, so not sure who should review this, thanks.

See the patch for details of the problem: https://reviews.llvm.org/D26847

Works around
https://connect.microsoft.com/VisualStudio/feedback/details/3111599/microsoft-c-c-compiler-driver-crashes-building-llvm
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26849: [Sema] Set range end of constructors and destructors in template instantiations

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, rsmith.
malcolm.parsons added a subscriber: cfe-commits.

clang-tidy checks frequently use source ranges of functions.
The source range of constructors and destructors in template instantiations
is currently a single token.
The factory method for constructors and destructors does not allow the 
end source location to be specified.
Set end location manually after creating instantiation.


https://reviews.llvm.org/D26849

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26847: Fix Internal Compiler Error compiling Clang with the latest version of MSVC

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

This file doesn't exist in clang.
Did you mean to report this to swift-clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D26847



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


[PATCH] D26849: [Sema] Set range end of constructors and destructors in template instantiations

2016-11-18 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

Is it possible to add a test for this change? Maybe you could dump the AST and 
check if the range is the one that you would expect (See 
test/Misc/ast-dump-decl.cpp for an example).


https://reviews.llvm.org/D26849



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


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Paulo Matos via cfe-commits
pmatos added a comment.

In https://reviews.llvm.org/D26843#599635, @EricWF wrote:

> This isn't correct. For example this change breaks:
>
>   struct T { int m; };
>   int x = sizeof(T::m);
>


But that is not valid in C afaik and in C++ I get:

  error: invalid use of non-static data member 'm'
int x = sizeof(T::m);
   ~~~^

Can you post a full reproducible example of what the change breaks?


https://reviews.llvm.org/D26843



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


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

> But that is not valid in C afaik and in C++ I get:
> 
>   error: invalid use of non-static data member 'm'
> int x = sizeof(T::m);
>~~~^
> 
> 
> Can you post a full reproducible example of what the change breaks?

That is a full reproducible example because it's valid C++. Clang currently 
compiles it .


https://reviews.llvm.org/D26843



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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-11-18 Thread Kirill Romanenkov via cfe-commits
kromanenkov added a comment.

ping


https://reviews.llvm.org/D25475



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


[PATCH] D25869: [Driver] Add unit tests for Distro detection

2016-11-18 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 78506.
mgorny added a comment.

Added tests for SUSE and Arch Linux (and found a bug for the former, 
https://reviews.llvm.org/D26850).


https://reviews.llvm.org/D25869

Files:
  unittests/Driver/CMakeLists.txt
  unittests/Driver/DistroTest.cpp

Index: unittests/Driver/DistroTest.cpp
===
--- /dev/null
+++ unittests/Driver/DistroTest.cpp
@@ -0,0 +1,284 @@
+//===- unittests/Driver/DistroTest.cpp --- ToolChains tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for Distro detection.
+//
+//===--===//
+
+#include "clang/Driver/Distro.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+// The tests include all release-related files for each distribution
+// in the VFS, in order to make sure that earlier tests do not
+// accidentally result in incorrect distribution guess.
+
+TEST(DistroTest, DetectUbuntu) {
+  vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
+  // Ubuntu uses Debian Sid version.
+  UbuntuTrustyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("jessie/sid\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=14.04\n"
+   "DISTRIB_CODENAME=trusty\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 14.04 LTS\"\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"14.04, Trusty Tahr\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 14.04 LTS\"\n"
+   "VERSION_ID=\"14.04\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n";
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n";
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n";));
+
+  Distro UbuntuTrusty{UbuntuTrustyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuTrusty), UbuntuTrusty);
+  ASSERT_TRUE(UbuntuTrusty.IsUbuntu());
+  ASSERT_FALSE(UbuntuTrusty.IsRedhat());
+  ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuTrusty.IsDebian());
+
+  vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
+  UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=16.10\n"
+   "DISTRIB_CODENAME=yakkety\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 16.10\"\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"16.10 (Yakkety Yak)\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 16.10\"\n"
+   "VERSION_ID=\"16.10\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n";
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n";
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n";
+   "PRIVACY_POLICY_URL=\"http://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n";
+   "VERSION_CODENAME=yakkety\n"
+   "UBUNTU_CODENAME=yakkety\n"));
+
+  Distro UbuntuYakkety{UbuntuYakketyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuYakkety), UbuntuYakkety);
+  ASSERT_TRUE(UbuntuYakkety.IsUbuntu());
+  ASSERT_FALSE(UbuntuYakkety.IsRedhat());
+  ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuYakkety.IsDebian());
+}
+
+TEST(DistroTest, DetectRedhat) {
+  vfs::InMemoryFileSystem Fedora25FileSystem;
+  Fedora25FileSystem.addFile("/etc/system-release-cpe", 0,
+  llvm::MemoryBuffer::getMemBuffer("cpe:/o:fedoraproject:fedora:25\n"));
+  // Both files are symlinks to fedora-release.
+  Fedora25FileSystem.addFile("/

[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated the summary for this revision.
AntonBikineev updated this revision to Diff 78507.

https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/LiteralSupport.h
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp

Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -1708,3 +1708,28 @@
 
   return SpellingPtr-SpellingStart;
 }
+
+/// Determine whether a suffix is a valid ud-suffix. We avoid treating reserved
+/// suffixes as ud-suffixes, because the diagnostic experience is better if we
+/// treat it as an invalid suffix.
+StringLiteralParser::UDSuffixResult
+StringLiteralParser::isValidUDSuffix(const LangOptions &LangOpts,
+ StringRef Suffix) {
+  if (!LangOpts.CPlusPlus11 || Suffix.empty())
+return UDSuffixResult::Invalid;
+
+  // By C++11 [lex.ext]p10, ud-suffixes starting with an '_' are always valid.
+  if (Suffix[0] == '_')
+return UDSuffixResult::Valid;
+
+  // In C++11, there are no library suffixes.
+  if (!LangOpts.CPlusPlus14)
+return UDSuffixResult::Invalid;
+
+  // C++1z adds "sv" literals
+  if (Suffix == "sv")
+return LangOpts.CPlusPlus1z ? UDSuffixResult::Valid
+: UDSuffixResult::SVIncompatible;
+
+  return Suffix == "s" ? UDSuffixResult::Valid : UDSuffixResult::Invalid;
+}
Index: include/clang/Lex/LiteralSupport.h
===
--- include/clang/Lex/LiteralSupport.h
+++ include/clang/Lex/LiteralSupport.h
@@ -259,6 +259,13 @@
 return UDSuffixOffset;
   }
 
+  enum class UDSuffixResult : uint8_t {
+Valid, Invalid, SVIncompatible
+  };
+
+  static UDSuffixResult isValidUDSuffix(const LangOptions &LangOpts,
+   StringRef Suffix);
+
 private:
   void init(ArrayRef StringToks);
   bool CopyStringFragment(const Token &Tok, const char *TokBegin,
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def err_cxx1z_string_view_literal : Error<
+  "string_view literals are a C++1z feature">;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1697,6 +1697,8 @@
   // likely to be a ud-suffix than a macro, however, and accept that.
   if (!Consumed) {
 bool IsUDSuffix = false;
+StringLiteralParser::UDSuffixResult IsStringUDSuffix =
+StringLiteralParser::UDSuffixResult::Invalid;
 if (C == '_')
   IsUDSuffix = true;
 else if (IsStringLiteral && getLangOpts().CPlusPlus14) {
@@ -1713,9 +1715,18 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
-  IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
-   NumericLiteralParser::isValidUDSuffix(
-   getLangOpts(), StringRef(Buffer, Chars));
+  const StringRef CompleteSuffix = StringRef(Buffer, Chars);
+  const LangOptions &LangOpts = getLangOpts();
+  // First, check if the suffix is a numeric suffix (s,sv)
+  IsUDSuffix =
+  NumericLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+  // If it is not, check for a string suffix
+  if (!IsUDSuffix) {
+IsStringUDSuffix =
+StringLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+IsUDSuffix =
+IsStringUDSuffix == StringLiteralParser::UDSuffixResult::Valid;
+  }
   break;
 }
 
@@ -1730,10 +1741,16 @@
 
 if (!IsUDSuffix) {
   if (!isLexingRawMode())
-Diag(CurPtr, getLangOpts().MSVCCompat
- ? diag::ext_ms_reserved_user_defined_literal
- : diag::ext_reserved_user_defined_literal)
-  << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+if (IsStringUDSuffix ==
+StringLiteralParser::UDSuffixResult::SVIncompatible) {
+  Diag(CurPtr, diag::err_cxx1z_string_view_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+} else {
+  Diag(CurPtr, getLangOpts().MSVCCompat
+   ? diag::ext_ms_reserved_user_defined_literal
+   : diag::ext_reserved_user_defined_literal)
+<< FixItHint::CreateInsertion(getSource

[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78510.

https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/LiteralSupport.h
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp

Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -1708,3 +1708,28 @@
 
   return SpellingPtr-SpellingStart;
 }
+
+/// Determine whether a suffix is a valid ud-suffix. We avoid treating reserved
+/// suffixes as ud-suffixes, because the diagnostic experience is better if we
+/// treat it as an invalid suffix.
+StringLiteralParser::UDSuffixResult
+StringLiteralParser::isValidUDSuffix(const LangOptions &LangOpts,
+ StringRef Suffix) {
+  if (!LangOpts.CPlusPlus11 || Suffix.empty())
+return UDSuffixResult::Invalid;
+
+  // By C++11 [lex.ext]p10, ud-suffixes starting with an '_' are always valid.
+  if (Suffix[0] == '_')
+return UDSuffixResult::Valid;
+
+  // In C++11, there are no library suffixes.
+  if (!LangOpts.CPlusPlus14)
+return UDSuffixResult::Invalid;
+
+  // C++1z adds "sv" literals
+  if (Suffix == "sv")
+return LangOpts.CPlusPlus1z ? UDSuffixResult::Valid
+: UDSuffixResult::SVIncompatible;
+
+  return Suffix == "s" ? UDSuffixResult::Valid : UDSuffixResult::Invalid;
+}
Index: include/clang/Lex/LiteralSupport.h
===
--- include/clang/Lex/LiteralSupport.h
+++ include/clang/Lex/LiteralSupport.h
@@ -259,6 +259,13 @@
 return UDSuffixOffset;
   }
 
+  enum class UDSuffixResult : uint8_t {
+Valid, Invalid, SVIncompatible
+  };
+
+  static UDSuffixResult isValidUDSuffix(const LangOptions &LangOpts,
+StringRef Suffix);
+
 private:
   void init(ArrayRef StringToks);
   bool CopyStringFragment(const Token &Tok, const char *TokBegin,
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def err_cxx1z_string_view_literal : Error<
+  "string_view literals are a C++1z feature">;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1697,6 +1697,8 @@
   // likely to be a ud-suffix than a macro, however, and accept that.
   if (!Consumed) {
 bool IsUDSuffix = false;
+StringLiteralParser::UDSuffixResult IsStringUDSuffix =
+StringLiteralParser::UDSuffixResult::Invalid;
 if (C == '_')
   IsUDSuffix = true;
 else if (IsStringLiteral && getLangOpts().CPlusPlus14) {
@@ -1713,9 +1715,18 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
-  IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
-   NumericLiteralParser::isValidUDSuffix(
-   getLangOpts(), StringRef(Buffer, Chars));
+  const StringRef CompleteSuffix = StringRef(Buffer, Chars);
+  const LangOptions &LangOpts = getLangOpts();
+  // First, check if the suffix is a numeric suffix (s,sv)
+  IsUDSuffix =
+  NumericLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+  // If it is not, check for a string suffix
+  if (!IsUDSuffix) {
+IsStringUDSuffix =
+StringLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+IsUDSuffix =
+IsStringUDSuffix == StringLiteralParser::UDSuffixResult::Valid;
+  }
   break;
 }
 
@@ -1730,10 +1741,16 @@
 
 if (!IsUDSuffix) {
   if (!isLexingRawMode())
-Diag(CurPtr, getLangOpts().MSVCCompat
- ? diag::ext_ms_reserved_user_defined_literal
- : diag::ext_reserved_user_defined_literal)
-  << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+if (IsStringUDSuffix ==
+StringLiteralParser::UDSuffixResult::SVIncompatible) {
+  Diag(CurPtr, diag::err_cxx1z_string_view_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+} else {
+  Diag(CurPtr, getLangOpts().MSVCCompat
+   ? diag::ext_ms_reserved_user_defined_literal
+   : diag::ext_reserved_user_defined_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+}
   return CurPtr;

[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78511.

https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/LiteralSupport.h
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp

Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -1708,3 +1708,28 @@
 
   return SpellingPtr-SpellingStart;
 }
+
+/// Determine whether a suffix is a valid ud-suffix. We avoid treating reserved
+/// suffixes as ud-suffixes, because the diagnostic experience is better if we
+/// treat it as an invalid suffix.
+StringLiteralParser::UDSuffixResult
+StringLiteralParser::isValidUDSuffix(const LangOptions &LangOpts,
+ StringRef Suffix) {
+  if (!LangOpts.CPlusPlus11 || Suffix.empty())
+return UDSuffixResult::Invalid;
+
+  // By C++11 [lex.ext]p10, ud-suffixes starting with an '_' are always valid.
+  if (Suffix[0] == '_')
+return UDSuffixResult::Valid;
+
+  // In C++11, there are no library suffixes.
+  if (!LangOpts.CPlusPlus14)
+return UDSuffixResult::Invalid;
+
+  // C++1z adds "sv" literals
+  if (Suffix == "sv")
+return LangOpts.CPlusPlus1z ? UDSuffixResult::Valid
+: UDSuffixResult::SVIncompatible;
+
+  return Suffix == "s" ? UDSuffixResult::Valid : UDSuffixResult::Invalid;
+}
Index: include/clang/Lex/LiteralSupport.h
===
--- include/clang/Lex/LiteralSupport.h
+++ include/clang/Lex/LiteralSupport.h
@@ -259,6 +259,13 @@
 return UDSuffixOffset;
   }
 
+  enum class UDSuffixResult : uint8_t {
+Valid, Invalid, SVIncompatible
+  };
+
+  static UDSuffixResult isValidUDSuffix(const LangOptions &LangOpts,
+StringRef Suffix);
+
 private:
   void init(ArrayRef StringToks);
   bool CopyStringFragment(const Token &Tok, const char *TokBegin,
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def err_cxx1z_string_view_literal : Error<
+  "string_view literals are a C++1z feature">;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1697,6 +1697,8 @@
   // likely to be a ud-suffix than a macro, however, and accept that.
   if (!Consumed) {
 bool IsUDSuffix = false;
+StringLiteralParser::UDSuffixResult IsStringUDSuffix =
+StringLiteralParser::UDSuffixResult::Invalid;
 if (C == '_')
   IsUDSuffix = true;
 else if (IsStringLiteral && getLangOpts().CPlusPlus14) {
@@ -1713,9 +1715,18 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
-  IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
-   NumericLiteralParser::isValidUDSuffix(
-   getLangOpts(), StringRef(Buffer, Chars));
+  const StringRef CompleteSuffix(Buffer, Chars);
+  const LangOptions &LangOpts = getLangOpts();
+  // First, check if the suffix is a numeric suffix (s,sv)
+  IsUDSuffix =
+  NumericLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+  // If it is not, check for a string suffix
+  if (!IsUDSuffix) {
+IsStringUDSuffix =
+StringLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+IsUDSuffix =
+IsStringUDSuffix == StringLiteralParser::UDSuffixResult::Valid;
+  }
   break;
 }
 
@@ -1729,11 +1740,18 @@
 }
 
 if (!IsUDSuffix) {
-  if (!isLexingRawMode())
-Diag(CurPtr, getLangOpts().MSVCCompat
- ? diag::ext_ms_reserved_user_defined_literal
- : diag::ext_reserved_user_defined_literal)
-  << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+  if (!isLexingRawMode()) {
+if (IsStringUDSuffix ==
+StringLiteralParser::UDSuffixResult::SVIncompatible) {
+  Diag(CurPtr, diag::err_cxx1z_string_view_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+} else {
+  Diag(CurPtr, getLangOpts().MSVCCompat
+   ? diag::ext_ms_reserved_user_defined_literal
+   : diag::ext_reserved_user_defined_literal)
+<< FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+   

[PATCH] D26837: [analyzer] Litter the SVal/SymExpr/MemRegion class hierarchy with asserts.

2016-11-18 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Personally, I like this change because it makes our assumptions clearer. My 
comments are below.




Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:54
+  : store(st), region(r) {
+assert(r->getValueType()->isRecordType() ||
+   r->getValueType()->isArrayType() ||

Could you extract `r->getValueType()` to a separate variable?



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:319
 public:
-  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) {}
+  SymbolVal() = delete;
+  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { assert(sym); }

I cannot completely agree with this change. For example, some STL container 
methods require their type to be default constructible. Yes, it is a very 
limited usage case but  I don't see strong reason to do it because there also 
may be some another usage scenarios.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:478
 public:
-  explicit GotoLabel(LabelDecl *Label) : Loc(GotoLabelKind, Label) {}
+  explicit GotoLabel(LabelDecl *Label) : Loc(GotoLabelKind, Label) {
+assert(Label);

By the way, why does this ctor accept a non-constant pointer?



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h:46
+  static bool isValidTypeForSymbol(QualType T) {
+// FIXME: Depending on wether we choose to deprecate structural symbols,
+// this may become much stricter.

s/wether/whether


https://reviews.llvm.org/D26837



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


r287343 - [OpenCL] Introduce ReadPipeType and WritePipeType.

2016-11-18 Thread Joey Gouly via cfe-commits
Author: joey
Date: Fri Nov 18 08:10:54 2016
New Revision: 287343

URL: http://llvm.org/viewvc/llvm-project?rev=287343&view=rev
Log:
[OpenCL] Introduce ReadPipeType and WritePipeType.

This allows Sema to diagnose passing a read_only pipe to a
write_only pipe argument.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/TypePrinter.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/test/Misc/ast-dump-pipe.cl
cfe/trunk/test/SemaOpenCL/access-qualifier.cl
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=287343&r1=287342&r2=287343&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Nov 18 08:10:54 2016
@@ -135,7 +135,8 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet AutoTypes;
   mutable llvm::FoldingSet AtomicTypes;
   llvm::FoldingSet AttributedTypes;
-  mutable llvm::FoldingSet PipeTypes;
+  mutable llvm::FoldingSet ReadPipeTypes;
+  mutable llvm::FoldingSet WritePipeTypes;
 
   mutable llvm::FoldingSet QualifiedTemplateNames;
   mutable llvm::FoldingSet DependentTemplateNames;
@@ -1120,8 +1121,10 @@ public:
   /// blocks.
   QualType getBlockDescriptorType() const;
 
-  /// \brief Return pipe type for the specified type.
-  QualType getPipeType(QualType T) const;
+  /// \brief Return a read_only pipe type for the specified type.
+  QualType getReadPipeType(QualType T) const;
+  /// \brief Return a write_only pipe type for the specified type.
+  QualType getWritePipeType(QualType T) const;
 
   /// Gets the struct used to keep track of the extended descriptor for
   /// pointer to blocks.

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=287343&r1=287342&r2=287343&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Nov 18 08:10:54 2016
@@ -5285,18 +5285,18 @@ class AtomicType : public Type, public l
 
 /// PipeType - OpenCL20.
 class PipeType : public Type, public llvm::FoldingSetNode {
+protected:
   QualType ElementType;
+  bool isRead;
 
-  PipeType(QualType elemType, QualType CanonicalPtr) :
+  PipeType(QualType elemType, QualType CanonicalPtr, bool isRead) :
 Type(Pipe, CanonicalPtr, elemType->isDependentType(),
  elemType->isInstantiationDependentType(),
  elemType->isVariablyModifiedType(),
  elemType->containsUnexpandedParameterPack()),
-ElementType(elemType) {}
-  friend class ASTContext;  // ASTContext creates these.
+ElementType(elemType), isRead(isRead) {}
 
 public:
-
   QualType getElementType() const { return ElementType; }
 
   bool isSugared() const { return false; }
@@ -5311,11 +5311,23 @@ public:
 ID.AddPointer(T.getAsOpaquePtr());
   }
 
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == Pipe;
   }
 
+  bool isReadOnly() const { return isRead; }
+};
+
+class ReadPipeType : public PipeType {
+  ReadPipeType(QualType elemType, QualType CanonicalPtr) :
+PipeType(elemType, CanonicalPtr, true) {}
+  friend class ASTContext;  // ASTContext creates these.
+};
+
+class WritePipeType : public PipeType {
+  WritePipeType(QualType elemType, QualType CanonicalPtr) :
+PipeType(elemType, CanonicalPtr, false) {}
+  friend class ASTContext;  // ASTContext creates these.
 };
 
 /// A qualifier set is used to build a set of qualifiers.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=287343&r1=287342&r2=287343&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 18 08:10:54 2016
@@ -1303,7 +1303,9 @@ public:
  SourceLocation Loc, DeclarationName Entity);
   QualType BuildParenType(QualType T);
   QualType BuildAtomicType(QualType T, SourceLocation Loc);
-  QualType BuildPipeType(QualType T,
+  QualType BuildReadPipeType(QualType T,
+ SourceLocation Loc);
+  QualType BuildWritePipeType(QualType T,
  SourceLocation Loc);
 
   TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S);

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include

[PATCH] D26746: [OpenCL] Split PipeType into ReadPipe/WritePipe

2016-11-18 Thread Joey Gouly via cfe-commits
joey closed this revision.
joey marked 3 inline comments as done.
joey added a comment.

Committed as r287343.


Repository:
  rL LLVM

https://reviews.llvm.org/D26746



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


[PATCH] D26838: [analyzer] Enforce super-region classes for various memory regions through compile-time and run-time type checks.

2016-11-18 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Hi Artem!
I like this change mostly but I also have some remarks.




Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1279
   ///  associated element type, index, and super region.
   const ElementRegion *getElementRegion(QualType elementType, NonLoc Idx,
+const SubRegion *superRegion,

I think we should perform a `cast<>` to `SubRegion` internally in order to keep 
API simple and do not force clients to introduce casts in their code. This will 
still allow us to keep nice suggestions about SubRegions/MemSpaces in our 
hierarchy.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1347
 private:
-  template 
-  RegionTy* getSubRegion(const A1 a1, const MemRegion* superRegion);
+  template 
+  RegionTy* getSubRegion(const A1 a1, const SuperTy* superRegion);

Maybe we should give types and paramers some more meaningful names as a part of 
refactoring? At least, the number in `A1` is not needed now.


https://reviews.llvm.org/D26838



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


[PATCH] D26853: Make llvm::Error generated from replacement interfaces more specific.

2016-11-18 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: klimek, djasper, bkramer.
ioeric added a subscriber: cfe-commits.

The new error information contains the type of error (e.g. overlap or bad file 
path)
and the replacement(s) that is causing the error. This enables us to resolve 
some errors.
For example, for insertion at the same location conflict, we need to know the
existing replacement which conflicts with the new replacement in order to 
calculate
the new position to be insert before/after the existing replacement (for 
merging).


https://reviews.llvm.org/D26853

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -100,21 +100,71 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
+// Checks that an llvm::Error instance contains a ReplacementError with expected
+// error code, expected new replacement, and expected existing replacement.
+static bool checkReplacementError(
+llvm::Error&& Error, replacement_error ExpectedErr,
+llvm::Optional ExpectedExisting,
+llvm::Optional ExpectedNew) {
+  if (!Error) {
+llvm::errs() << "Error is a success.";
+return false;
+  }
+  std::string ErrorMessage;
+  llvm::raw_string_ostream OS(ErrorMessage);
+  llvm::handleAllErrors(std::move(Error), [&](const ReplacementError &RE) {
+llvm::errs() << "Handling error...\n";
+if (ExpectedErr != RE.get())
+  OS << "Unexpected error code: " << int(RE.get()) << "\n";
+if (ExpectedExisting != RE.getExistingReplacement()) {
+  OS << "Expected Existing != Actual Existing.\n";
+  if (ExpectedExisting.hasValue())
+OS << "Expected existing replacement: " << ExpectedExisting->toString()
+   << "\n";
+  if (RE.getExistingReplacement().hasValue())
+OS << "Actual existing replacement: "
+   << RE.getExistingReplacement()->toString() << "\n";
+}
+if (ExpectedNew != RE.getNewReplacement()) {
+  OS << "Expected New != Actual New.\n";
+  if (ExpectedNew.hasValue())
+OS << "Expected new replacement: " << ExpectedNew->toString() << "\n";
+  if (RE.getNewReplacement().hasValue())
+OS << "Actual new replacement: " << RE.getNewReplacement()->toString()
+   << "\n";
+}
+  });
+  OS.flush();
+  if (ErrorMessage.empty()) return true;
+  llvm::errs() << ErrorMessage;
+  return false;
+}
+
 TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
   Replacement Deletion("x.cc", 0, 10, "3");
   auto Err = Replaces.add(Deletion);
   EXPECT_TRUE(!Err);
   llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 0, 2, "a"));
-  EXPECT_TRUE((bool)Err);
-  llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("x.cc", 2, 2, "a"));
-  EXPECT_TRUE((bool)Err);
-  llvm::consumeError(std::move(Err));
-  Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
-  EXPECT_TRUE((bool)Err);
-  llvm::consumeError(std::move(Err));
+
+  Replacement OverlappingReplacement("x.cc", 0, 2, "a");
+  Err = Replaces.add(OverlappingReplacement);
+  EXPECT_TRUE(checkReplacementError(std::move(Err),
+replacement_error::overlap_conflict,
+Deletion, OverlappingReplacement));
+
+  Replacement ContainedReplacement("x.cc", 2, 2, "a");
+  Err = Replaces.add(Replacement(ContainedReplacement));
+  EXPECT_TRUE(checkReplacementError(std::move(Err),
+replacement_error::overlap_conflict,
+Deletion, ContainedReplacement));
+
+  Replacement WrongPathReplacement("y.cc", 20, 2, "");
+  Err = Replaces.add(WrongPathReplacement);
+  EXPECT_TRUE(checkReplacementError(std::move(Err),
+replacement_error::wrong_file_path,
+Deletion, WrongPathReplacement));
+
   EXPECT_EQ(1u, Replaces.size());
   EXPECT_EQ(Deletion, *Replaces.begin());
 }
@@ -299,9 +349,11 @@
 
   // Make sure we find the overlap with the first entry when inserting a
   // replacement that ends exactly at the seam of the existing replacements.
-  Err = Replaces.add(Replacement("x.cc", 5, 5, "fail"));
-  EXPECT_TRUE((bool)Err);
-  llvm::consumeError(std::move(Err));
+  Replacement OverlappingReplacement("x.cc", 5, 5, "fail");
+  Err = Replaces.add(OverlappingReplacement);
+  EXPECT_TRUE(checkReplacementError(std::move(Err),
+replacement_error::overlap_conflict,
+*Replaces.begin(), OverlappingReplacement));
 
   Err = Replaces.add(Replacement("x.cc", 10, 0, ""));
   EXPECT_TRUE(!Err);
@@ -333,9 +385,11 @@
   auto Err = Replaces.add(Replacement("x.cc", 10, 0, "a"));
   EXPECT_TRUE(!Err);
   llvm::consumeError

[PATCH] D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-18 Thread Melanie Blower via cfe-commits
mibintc removed rL LLVM as the repository for this revision.
mibintc updated this revision to Diff 78518.
mibintc added a comment.

I regenerated the diff using diff -x -U99


https://reviews.llvm.org/D26636

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/warn-float-conversion.cpp

Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -87,3 +87,29 @@
   char e = 1.0 / 0.0;  // expected-warning{{implicit conversion of out of range value from 'double' to 'char' changes value from +Inf to 127}}
 }
 #endif  // OVERFLOW
+
+int m(int argc)
+{
+  float f = argc;
+  // Test that float-to-bool conversion warnings are not issued
+  // for conditions.
+ 
+
+  if (f)  	
+return 1;
+  else  
+return f
+   ? 1 
+   : 0;
+
+  if (f+1)  	//Question: also suppress for this expresson?
+return 1;
+
+  while (f) ;
+
+  do ; while (f) ;
+
+  for (; f ; ) ;
+
+  return 0;
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1264,6 +1264,7 @@
   if (CondResult.isInvalid())
 return StmtError();
   Cond = CondResult.get();
+  Cond->setIsCondition();
 
   CondResult = ActOnFinishFullExpr(Cond, DoLoc);
   if (CondResult.isInvalid())
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14607,10 +14607,12 @@
   ExprResult Cond;
   switch (CK) {
   case ConditionKind::Boolean:
+SubExpr->setIsCondition();
 Cond = CheckBooleanCondition(Loc, SubExpr);
 break;
 
   case ConditionKind::ConstexprIf:
+SubExpr->setIsCondition();
 Cond = CheckBooleanCondition(Loc, SubExpr, true);
 break;
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9020,6 +9020,10 @@
   if (S.SourceMgr.isInSystemMacro(CC))
 return;
 
+  // Suppress float-to-bool diagnostic in conditions.
+  if (TargetBT->isBooleanType() && E->isCondition())
+return;
+
   DiagnoseFloatingImpCast(S, E, T, CC);
 }
 
@@ -9222,7 +9226,10 @@
 /// of competing diagnostics here, -Wconversion and -Wsign-compare.
 void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
   QualType T = OrigE->getType();
+  bool isCondition = OrigE->isCondition();
   Expr *E = OrigE->IgnoreParenImpCasts();
+  if (isCondition)
+E->setIsCondition(isCondition);
 
   if (E->isTypeDependent() || E->isValueDependent())
 return;
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -309,6 +309,8 @@
 TernaryMiddle = nullptr;
 Diag(Tok, diag::ext_gnu_conditional_expr);
   }
+  if (!LHS.isInvalid()) 
+LHS.get()->setIsCondition();
 
   if (!TryConsumeToken(tok::colon, ColonLoc)) {
 // Otherwise, we're missing a ':'.  Assume that this was a typo that
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -131,8 +131,9 @@
 unsigned ValueDependent : 1;
 unsigned InstantiationDependent : 1;
 unsigned ContainsUnexpandedParameterPack : 1;
+unsigned IsCondition : 1;
   };
-  enum { NumExprBits = 16 };
+  enum { NumExprBits = 17 };
 
   class CharacterLiteralBitfields {
 friend class CharacterLiteral;
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -116,6 +116,7 @@
 ExprBits.ValueKind = VK;
 ExprBits.ObjectKind = OK;
 ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack;
+ExprBits.IsCondition = 0;
 setType(T);
   }
 
@@ -219,6 +220,17 @@
 ExprBits.ContainsUnexpandedParameterPack = PP;
   }
 
+  /// \brief Whether this expression appears in condition expression context.
+  bool isCondition() const {
+return ExprBits.IsCondition;
+  }
+
+  /// \brief Set the bit that describes whether this expression
+  /// appears in condition context e.g.: if(expr) while(expr) ?: etc.
+  void setIsCondition(bool PP = true) {
+ExprBits.IsCondition = PP;
+  }
+
   /// getExprLoc - Return the preferred location for the arrow when diagnosing
   /// a problem with a generic expression.
   SourceLocation getExprLoc() const LLVM_READONLY;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26849: [Sema] Set range end of constructors and destructors in template instantiations

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 78522.
malcolm.parsons added a comment.

Add test.


https://reviews.llvm.org/D26849

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/Misc/ast-dump-decl.cpp


Index: test/Misc/ast-dump-decl.cpp
===
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -223,6 +223,10 @@
   class D { };
 
   template class TestClassTemplate {
+  public:
+TestClassTemplate();
+~TestClassTemplate();
+int j();
 int i;
   };
 
@@ -252,10 +256,18 @@
 // CHECK-NEXT:   TemplateTypeParmDecl
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: TemplateArgument{{.*}}A
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
 // CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
@@ -269,11 +281,19 @@
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}C
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}D
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplatePartialSpecializationDecl{{.*}} class 
TestClassTemplatePartial
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,


Index: test/Misc/ast-dump-decl.cpp
===
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -223,6 +223,10 @@
   class D { };
 
   template class TestClassTemplate {
+  public:
+TestClassTemplate();
+~TestClassTemplate();
+int j();
 int i;
   };
 
@@ -252,10 +256,18 @@
 // CHECK-NEXT:   TemplateTypeParmDecl
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: TemplateArgument{{.*}}A
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
 // CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
@@ -269,11 +281,19 @@
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}C
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   Ac

[PATCH] D26847: Fix Internal Compiler Error compiling Clang with the latest version of MSVC

2016-11-18 Thread Hugh Bellamy via cfe-commits
hughbe added a comment.

Thanks Malcolm. You're right, my bad! Sorry for wasting your time


Repository:
  rL LLVM

https://reviews.llvm.org/D26847



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78523.
AntonBikineev added a comment.

Just added a small test case


https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/LiteralSupport.h
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp
  test/SemaCXX/cxx1z-user-defined-literals.cpp

Index: test/SemaCXX/cxx1z-user-defined-literals.cpp
===
--- test/SemaCXX/cxx1z-user-defined-literals.cpp
+++ test/SemaCXX/cxx1z-user-defined-literals.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  using size_t = decltype(sizeof(0));
+
+  struct string_view {};
+  string_view operator""sv(const char*, size_t);
+}
+
+#else
+
+using namespace std;
+string_view s = "foo"sv;
+const char* p = "bar"sv; // expected-error {{no viable conversion}}
+char error = 'x'sv; // expected-error {{invalid suffix}} expected-error {{expected ';'}}
+
+#endif
Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -1708,3 +1708,28 @@
 
   return SpellingPtr-SpellingStart;
 }
+
+/// Determine whether a suffix is a valid ud-suffix. We avoid treating reserved
+/// suffixes as ud-suffixes, because the diagnostic experience is better if we
+/// treat it as an invalid suffix.
+StringLiteralParser::UDSuffixResult
+StringLiteralParser::isValidUDSuffix(const LangOptions &LangOpts,
+ StringRef Suffix) {
+  if (!LangOpts.CPlusPlus11 || Suffix.empty())
+return UDSuffixResult::Invalid;
+
+  // By C++11 [lex.ext]p10, ud-suffixes starting with an '_' are always valid.
+  if (Suffix[0] == '_')
+return UDSuffixResult::Valid;
+
+  // In C++11, there are no library suffixes.
+  if (!LangOpts.CPlusPlus14)
+return UDSuffixResult::Invalid;
+
+  // C++1z adds "sv" literals
+  if (Suffix == "sv")
+return LangOpts.CPlusPlus1z ? UDSuffixResult::Valid
+: UDSuffixResult::SVIncompatible;
+
+  return Suffix == "s" ? UDSuffixResult::Valid : UDSuffixResult::Invalid;
+}
Index: include/clang/Lex/LiteralSupport.h
===
--- include/clang/Lex/LiteralSupport.h
+++ include/clang/Lex/LiteralSupport.h
@@ -259,6 +259,13 @@
 return UDSuffixOffset;
   }
 
+  enum class UDSuffixResult : uint8_t {
+Valid, Invalid, SVIncompatible
+  };
+
+  static UDSuffixResult isValidUDSuffix(const LangOptions &LangOpts,
+StringRef Suffix);
+
 private:
   void init(ArrayRef StringToks);
   bool CopyStringFragment(const Token &Tok, const char *TokBegin,
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
+def err_cxx1z_string_view_literal : Error<
+  "string_view literals are a C++1z feature">;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1697,6 +1697,8 @@
   // likely to be a ud-suffix than a macro, however, and accept that.
   if (!Consumed) {
 bool IsUDSuffix = false;
+StringLiteralParser::UDSuffixResult IsStringUDSuffix =
+StringLiteralParser::UDSuffixResult::Invalid;
 if (C == '_')
   IsUDSuffix = true;
 else if (IsStringLiteral && getLangOpts().CPlusPlus14) {
@@ -1713,9 +1715,18 @@
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
-  IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
-   NumericLiteralParser::isValidUDSuffix(
-   getLangOpts(), StringRef(Buffer, Chars));
+  const StringRef CompleteSuffix(Buffer, Chars);
+  const LangOptions &LangOpts = getLangOpts();
+  // First, check if the suffix is a numeric suffix (s,sv)
+  IsUDSuffix =
+  NumericLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+  // If it is not, check for a string suffix
+  if (!IsUDSuffix) {
+IsStringUDSuffix =
+StringLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix);
+IsUDSuffix =
+IsStringUDSuffix == StringLiteralParser::UDSuffixResult::Valid;
+  }
   break;
 }
 
@@ -1729,11 +1740,18 @@
 }
 
 if (!IsUDSuffix) {
-  if (!isLexingRa

[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-11-18 Thread David Majnemer via cfe-commits
majnemer added a comment.

Do we have a testcase where the declspec is applied to something inappropriate 
like an int?




Comment at: lib/Sema/SemaDeclAttr.cpp:4669-4673
+  if (!(isa(D) || isa(D))) {
 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << Attr.getName() << ExpectedClass;
+  << Attr.getName() << ExpectedEnumOrClass;
 return;
   }

I don't think you need this now that you've got this in Attr.td



Comment at: lib/Sema/SemaExprCXX.cpp:523
 
-  const auto *RD = Ty->getAsCXXRecordDecl();
+  const auto *RD = Ty->getAsTagDecl();
   if (!RD)

Please renamed `RD` to something more appropriate like `TD`.


Repository:
  rL LLVM

https://reviews.llvm.org/D26846



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-18 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 78527.
baloghadamsoftware added a comment.

Test updated to include test case where system headers are inlined.


https://reviews.llvm.org/D25660

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/Inputs/system-header-simulator-for-iterators.h
  test/Analysis/iterator-past-end.cpp

Index: test/Analysis/iterator-past-end.cpp
===
--- /dev/null
+++ test/Analysis/iterator-past-end.cpp
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-for-iterators.h"
+
+void simple_good(const std::vector &v) {
+  auto i = v.end();
+  if (i != v.end())
+*i; // no-warning
+}
+
+void simple_good_negated(const std::vector &v) {
+  auto i = v.end();
+  if (!(i == v.end()))
+*i; // no-warning
+}
+
+void simple_bad(const std::vector &v) {
+  auto i = v.end();
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void decrease(const std::vector &v) {
+  auto i = v.end();
+  --i;
+  *i; // no-warning
+}
+
+void copy_and_decrease1(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i1; // no-warning
+}
+
+void copy_and_decrease2(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy_and_increase1(const std::vector &v) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i1 == v.end())
+*i2; // no-warning
+}
+
+void copy_and_increase2(const std::vector &v) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i2 == v.end())
+*i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find(std::vector &vec, int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find(std::vector &vec, int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_end(std::vector &vec, std::vector &seq) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_find_end(std::vector &vec, std::vector &seq) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_first_of(std::vector &vec, std::vector &seq) {
+  auto first =
+  std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_first_of(std::vector &vec, std::vector &seq) {
+  auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+bool odd(int i) { return i % 2; }
+
+void good_find_if(std::vector &vec) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if(std::vector &vec, int e) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_if_not(std::vector &vec) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if_not(std::vector &vec, int e) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_lower_bound(std::vector &vec, int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_lower_bound(std::vector &vec, int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_upper_bound(std::vector &vec, int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_upper_bound(std::vector &vec, int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_search(std::vector &vec, std::vector &seq) {
+  auto first = std::search(vec.be

[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Paulo Matos via cfe-commits
pmatos added a comment.

In https://reviews.llvm.org/D26843#599673, @EricWF wrote:

> > But that is not valid in C afaik and in C++ I get:
> > 
> >   error: invalid use of non-static data member 'm'
> > int x = sizeof(T::m);
> >~~~^
> > 
> > 
> > Can you post a full reproducible example of what the change breaks?
>
> That is a full reproducible example because it's valid C++. Clang currently 
> compiles it .


But what was in the link was:

  typedef struct { int m; } T;
  int x = sizeof(T);
  int main() {}

This is different from your initial snippet and compiles fine with my patch.


https://reviews.llvm.org/D26843



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


[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-11-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1621
   let Args = [StringArgument<"Guid">];
-//  let Subjects = SubjectList<[CXXRecord]>;
+  let Subjects = SubjectList<[CXXRecord, Enum], WarnDiag, 
"ExpectedEnumOrClass">;
   let LangOpts = [MicrosoftExt, Borland];

You can drop the `WarnDiag` and `ExpectedEnumOrClass` -- that should be handled 
automatically by the tablegen emitter once you change `CalculateDiagnostic()` 
in ClangAttrEmitter.cpp to handle it properly.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2637
+  "|variables, functions, methods, types, enumerations, enumerators, labels, 
and non-static data members"
+  "|classes, enums}1">,
   InGroup;

This should read `classes and enumerations`.



Comment at: lib/Sema/SemaDeclAttr.cpp:4669-4673
+  if (!(isa(D) || isa(D))) {
 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << Attr.getName() << ExpectedClass;
+  << Attr.getName() << ExpectedEnumOrClass;
 return;
   }

majnemer wrote:
> I don't think you need this now that you've got this in Attr.td
Correct, this entire block should go away.


Repository:
  rL LLVM

https://reviews.llvm.org/D26846



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


[PATCH] D26858: [AArch64] Don't constrain the assembler when using -mgeneral-regs-only

2016-11-18 Thread silviu.bara...@arm.com via cfe-commits
sbaranga created this revision.
sbaranga added reviewers: jmolloy, rengolin, t.p.northover.
sbaranga added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

We use the neonasm, cryptoasm, fp-armv8asm and fullfp16asm features
to enable the assembling of instructions that were disabled when
disabling neon, crypto, and fp-armv8 features.

  

This makes the -mgeneral-regs-only behaviour compatible with gcc.

  

Fixes https://llvm.org/bugs/show_bug.cgi?id=30792


https://reviews.llvm.org/D26858

Files:
  docs/UsersManual.rst
  lib/Driver/Tools.cpp
  test/Driver/aarch64-mgeneral_regs_only.c


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2623,9 +2623,33 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
+// Find the last of each feature.
+llvm::StringMap LastOpt;
+for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+  StringRef Name = Features[I];
+  assert(Name[0] == '-' || Name[0] == '+');
+  LastOpt[Name.drop_front(1)] = I;
+}
+
+llvm::StringMap::iterator I = LastOpt.find("neon");
+if (I != LastOpt.end() && Features[I->second] == "+neon")
+  Features.push_back("+neonasm");
+
+I = LastOpt.find("crypto");
+if (I != LastOpt.end() && Features[I->second] == "+crypto")
+  Features.push_back("+cryptoasm");
+
+I = LastOpt.find("fp-armv8");
+if (I != LastOpt.end() && Features[I->second] == "+fp-armv8")
+  Features.push_back("+fp-armv8asm");
+
+I = LastOpt.find("fullfp16");
+if (I != LastOpt.end() && Features[I->second] == "+fullfp16")
+  Features.push_back("+fullfp16asm");
+
 Features.push_back("-fp-armv8");
-Features.push_back("-crypto");
 Features.push_back("-neon");
+Features.push_back("-crypto");
   }
 
   // En/disable crc
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1188,7 +1188,8 @@
Generate code which only uses the general purpose registers.
 
This option restricts the generated code to use general registers
-   only. This only applies to the AArch64 architecture.
+   only but does not restrict the assembler. This only applies to the
+   AArch64 architecture.
 
 .. option:: -mcompact-branches=[values]
 
Index: test/Driver/aarch64-mgeneral_regs_only.c
===
--- test/Driver/aarch64-mgeneral_regs_only.c
+++ test/Driver/aarch64-mgeneral_regs_only.c
@@ -4,6 +4,19 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FP %s
 // RUN: %clang -target arm64-linux-eabi -mgeneral-regs-only %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FP %s
+// RUN: %clang -target aarch64-linux-eabi -mgeneral-regs-only 
-mfpu=crypto-neon-fp-armv8 -%s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP %s
+
+// CHECK-NO-FP: "-target-feature" "+neonasm"
+// CHECK-NO-FP-NOT: "-target-feature" "+fp-armv8asm"
+// CHECK-NO-FP-NOT: "-target-feature" "+cryptoasm"
 // CHECK-NO-FP: "-target-feature" "-fp-armv8"
 // CHECK-NO-FP: "-target-feature" "-crypto"
 // CHECK-NO-FP: "-target-feature" "-neon"
+
+// CHECK-FP: "-target-feature" "+neonasm"
+// CHECK-FP: "-target-feature" "+fp-armv8asm"
+// CHECK-FP: "-target-feature" "+cryptoasm"
+// CHECK-FP: "-target-feature" "-fp-armv8"
+// CHECK-FP: "-target-feature" "-crypto"
+// CHECK-FP: "-target-feature" "-neon"


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2623,9 +2623,33 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
+// Find the last of each feature.
+llvm::StringMap LastOpt;
+for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+  StringRef Name = Features[I];
+  assert(Name[0] == '-' || Name[0] == '+');
+  LastOpt[Name.drop_front(1)] = I;
+}
+
+llvm::StringMap::iterator I = LastOpt.find("neon");
+if (I != LastOpt.end() && Features[I->second] == "+neon")
+  Features.push_back("+neonasm");
+
+I = LastOpt.find("crypto");
+if (I != LastOpt.end() && Features[I->second] == "+crypto")
+  Features.push_back("+cryptoasm");
+
+I = LastOpt.find("fp-armv8");
+if (I != LastOpt.end() && Features[I->second] == "+fp-armv8")
+  Features.push_back("+fp-armv8asm");
+
+I = LastOpt.find("fullfp16");
+if (I != LastOpt.end() && Features[I->second] == "+fullfp16")
+  Features.push_back("+fullfp16asm");
+
 Features.push_back("-fp-armv8");
-Features.push_back("-crypto");
 Features.push_back("-neon");
+Features.push_back("-crypto");
   }
 
   // En/disable crc
Index: docs/UsersManual.rst
==

[PATCH] D26830: [libcxx] Add string_view literals

2016-11-18 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 78532.
AntonBikineev marked an inline comment as done.
AntonBikineev added a comment.

Fixing typos...


https://reviews.llvm.org/D26830

Files:
  include/string_view
  test/std/strings/string.view/string.view.literals/literal.pass.cpp
  test/std/strings/string.view/string.view.literals/literal1.fail.cpp
  test/std/strings/string.view/string.view.literals/literal1.pass.cpp
  test/std/strings/string.view/string.view.literals/literal2.fail.cpp
  test/std/strings/string.view/string.view.literals/literal2.pass.cpp
  test/std/strings/string.view/string.view.literals/literal3.pass.cpp

Index: test/std/strings/string.view/string.view.literals/literal3.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal3.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std;
+
+string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals::string_view_literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal2.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal2.fail.cpp
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+std::string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal1.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.pass.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using namespace std::literals;
+
+std::string_view foo  =   ""sv;
+}
Index: test/std/strings/string.view/string.view.literals/literal1.fail.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+int main()
+{
+using std::string_view;
+
+string_view foo  =   ""sv;  // should fail w/conversion operator not found
+}
Index: test/std/strings/string.view/string.view.literals/literal.pass.cpp
===
--- /dev/null
+++ test/std/strings/string.view/string.view.literals/literal.pass.cpp
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===--===//
+//
+//   

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-11-18 Thread Simon Dardis via cfe-commits
sdardis added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:8064
+  ScalarCast = CK_FloatingCast;
+} else if (ScalarTy->isIntegralType(S.Context)) {
+  // Determine if the integer constant can be expressed as a floating point

bruno wrote:
> I don't see why it's necessary to check for all specific cases where the 
> scalar is a constant. For all the others scenarios it should be enough to get 
> the right answer via `getIntegerTypeOrder` or `getFloatTypeOrder`. For this 
> is specific condition, the `else` part for the `CstScalar` below should also 
> handle the constant case, right? 
> 
> 
If we have a scalar constant, it is necessary to examine it's actual value to 
see if it can be casted without truncation. The scalar constant's type is 
somewhat irrelevant. Consider:

   v4f32 f(v4f32 a) {
 return a + (double)1.0;
   }

In this case examining the order only works if the vector's order is greater 
than or equal to the scalar constant's order. Instead, if we ask whether the 
scalar constant can be represented as a constant scalar of the vector's element 
type, then we know if we can convert without the loss of precision.

For integers, the case is a little more contrived due to native integer width, 
but the question is the same. Can a scalar constant X be represented as a given 
floating point type. Consider:

   v4f32 f(v4f32 a) {
 return a + (signed int)1;
}

This would rejected for platforms where a signed integer's width is greater 
than the precision of float if we examined it based purely on types and their 
sizes. Instead, if we convert the integer to the float point's type with 
APFloat and convert back to see if we have the same value, we can determine if 
the scalar constant can be safely converted without the loss of precision.

I based the logic examining the value of the constant scalar based on GCC's 
behaviour, which implicitly converts scalars regardless of their type if they 
can be represented in the same type of the vector's element type without the 
loss of precision. If the scalar cannot be evaluated to a constant at compile 
time, then the size in bits for the scalar's type determines if it can be 
converted safely.



Comment at: lib/Sema/SemaExpr.cpp:8267
+  }
+
   // Otherwise, use the generic diagnostic.

bruno wrote:
> This change seems orthogonal to this patch. Can you make it a separated patch 
> with the changes from test/Sema/vector-cast.c?
This change is a necessary part of this patch and it can't be split out in 
sensible fashion.

For example, line 329 of test/Sema/zvector.c adds a scalar signed character to 
a vector of signed characters. With just this change we would report "cannot 
convert between scalar type 'signed char' and vector type '__vector signed 
char' (vector of 16 'signed char' values) as implicit conversion would cause 
truncation".

This is heavily misleading for C and C++ code as we don't perform implicit 
conversions and signed char could be implicitly converted to a vector of signed 
char without the loss of precision.

To make this diagnostic precise without performing implicit conversions 
requires determining cases where implicit conversion would cause truncation and 
reporting that failure reason, or defaulting to the generic diagnostic.

Keeping this change as part of this patch is cleaner and simpler as it covers 
both implicit conversions and more precise diagnostics.


https://reviews.llvm.org/D25866



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-11-18 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 78531.
sdardis marked 4 inline comments as done.
sdardis added a comment.

Addressed review comments.


https://reviews.llvm.org/D25866

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-gcc-compat.c
  test/Sema/zvector.c
  test/SemaCXX/vector-no-lax.cpp

Index: test/SemaCXX/vector-no-lax.cpp
===
--- test/SemaCXX/vector-no-lax.cpp
+++ test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@
 
 vSInt32 foo (vUInt32 a) {
   vSInt32 b = { 0, 0, 0, 0 };
-  b += a; // expected-error{{cannot convert between vector values}}
+  b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}}
   return b;
 }
Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-gcc-compat.c
===
--- /dev/null
+++ test/Sema/vector-gcc-compat.c
@@ -0,0 +1,304 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+typedef long long v2i64 __attribute__((vector_size(16)));
+typedef int v2i32 __attribute__((vector_size(8)));
+typedef short v2i16 __attribute__((vector_size(4)));
+typedef char v2i8 __attribute__((vector_size(2)));
+
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+typedef unsigned int v2u32 __attribute__((vector_size(8)));
+typedef unsigned short v2u16 __attribute__((vector_size(4)));
+typedef unsigned char v2u8 __attribute__((vector_size(2)));
+
+typedef float v4f32 __attribute__((vector_size(16)));
+typedef double v4f64 __attribute__((vector_size(32)));
+
+void arithmeticTest(void);
+void logicTest(void);
+void comparisonTest(void);
+void floatTestSignedType(char a, short b, int c, long long d);
+void floatTestUnsignedType(unsigned char a, unsigned short b, unsigned int c,
+   unsigned long long d);
+void floatTestConstant(void);
+void intTestType(char a, short b, int c, long long d);
+void intTestTypeUnsigned(unsigned char a, unsigned short b, unsigned int c,
+ unsigned long long d);
+void uintTestType(char a, short b, int c, long long d);
+void uintTestTypeUnsigned(unsigned char a, unsigned short b, unsigned int c,
+  unsigned long long d);
+void uintTestConstant(v2u64 v2u64_a, v2u32 v2u32_a, v2u16 v2u16_a, v2u8 v2u8_a);
+void intTestConstant(v2i64 v2i64_a, v2i32 

[PATCH] D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-18 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

Besides "it triggers on SPEC", why should the warning be disabled here? I think 
it is perfectly sensible to have a warning for all six conditional contexts 
here.


https://reviews.llvm.org/D26636



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

Does `Sema::CheckLiteralOperatorDeclaration` need to check 
`StringLiteralParser::isValidUDSuffix`?


https://reviews.llvm.org/D26829



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


[PATCH] D26845: [analyzer] Fix crash on the access to a union's region.

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Thanks for looking into this! It seems to be exactly the same as 
https://reviews.llvm.org/D26442. I was just about to commit this last one, 
however maybe we should actually have a more careful investigation on this 
issue now that we have duplicates.


Repository:
  rL LLVM

https://reviews.llvm.org/D26845



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


[PATCH] D26588: Add LocationContext to members of check::RegionChanges

2016-11-18 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/Checker.h:325
+  const CallEvent *Call,
+  const LocationContext *LCtx) {
+return ((const CHECKER *) checker)->checkRegionChanges(state, invalidated,

zaks.anna wrote:
> NoQ wrote:
> > zaks.anna wrote:
> > > k-wisniewski wrote:
> > > > NoQ wrote:
> > > > > zaks.anna wrote:
> > > > > > LocationContext can be obtained by calling 
> > > > > > CallEvent::getLocationContext(). I do not think that adding another 
> > > > > > parameter here buys us much. Am I missing something?
> > > > > CallEvent* is optional here - it's there only for invalidations 
> > > > > through calls.
> > > > How about the situation when this callback is triggered by something 
> > > > other than a call, like variable assignment? I've tried using that 
> > > > location context and had lots of segfaults as in such cases it appeared 
> > > > to be null. Do you have some info that it should be non-null in such a 
> > > > case?
> > > Ok, makes sense. Have you looked into providing a checker context there? 
> > > How much more difficult would that be? If that is too difficult, adding 
> > > LocationContext is good as well.
> > > 
> > > If Call is optional and LocationContext is not, should the Call parameter 
> > > be last.
> > If we add a CheckerContext, then we may end up calling callbacks that split 
> > states within callbacks that split states, and that'd be quite a mess to 
> > support.
> > 
> > Right now a checker may trigger `checkRegionChanges()` within its callback 
> > by manipulating the Store, which already leads to callbacks within 
> > callbacks, but that's bearable as long as you can't add transitions within 
> > the inner callbacks.
> This argument by itself does not seem to be preventing us from providing 
> CheckerContext. For example, we could disallow splitting states (ex: by 
> setting some flag within the CheckerContext) but still provide most of the 
> convenience APIs. 
> 
> The advantage of providing CheckerContext is that it is a class that provides 
> access to different analyzer APIs that the checker writer might want to 
> access. It is also familiar and somewhat expected as it is available in most 
> other cases. It might be difficult to pipe enough information to construct 
> it... I suspect that is the reason we do not provide it in this case.
> 
> I am OK with the patch as is but it would be good to explore if we could 
> extend this API by providing the full CheckerContext.
Hmm, with this kind of plan we should probably move all transition 
functionality into a sub-class of `CheckerContext`(?) So that it was obvious 
from the signature that some of those are restricted, and some are 
full-featured.

This definitely sounds like a big task, useful though, maybe a separate patch 
over all callbacks might be a good idea.


https://reviews.llvm.org/D26588



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


[PATCH] D26858: [AArch64] Don't constrain the assembler when using -mgeneral-regs-only

2016-11-18 Thread silviu.bara...@arm.com via cfe-commits
sbaranga updated this revision to Diff 78541.
sbaranga added a comment.

Update regression tests.


https://reviews.llvm.org/D26858

Files:
  docs/UsersManual.rst
  lib/Driver/Tools.cpp
  test/Driver/aarch64-mgeneral_regs_only.c


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2623,9 +2623,33 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
+// Find the last of each feature.
+llvm::StringMap LastOpt;
+for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+  StringRef Name = Features[I];
+  assert(Name[0] == '-' || Name[0] == '+');
+  LastOpt[Name.drop_front(1)] = I;
+}
+
+llvm::StringMap::iterator I = LastOpt.find("neon");
+if (I != LastOpt.end() && Features[I->second] == "+neon")
+  Features.push_back("+neonasm");
+
+I = LastOpt.find("crypto");
+if (I != LastOpt.end() && Features[I->second] == "+crypto")
+  Features.push_back("+cryptoasm");
+
+I = LastOpt.find("fp-armv8");
+if (I != LastOpt.end() && Features[I->second] == "+fp-armv8")
+  Features.push_back("+fp-armv8asm");
+
+I = LastOpt.find("fullfp16");
+if (I != LastOpt.end() && Features[I->second] == "+fullfp16")
+  Features.push_back("+fullfp16asm");
+
 Features.push_back("-fp-armv8");
-Features.push_back("-crypto");
 Features.push_back("-neon");
+Features.push_back("-crypto");
   }
 
   // En/disable crc
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1188,7 +1188,8 @@
Generate code which only uses the general purpose registers.
 
This option restricts the generated code to use general registers
-   only. This only applies to the AArch64 architecture.
+   only but does not restrict the assembler. This only applies to the
+   AArch64 architecture.
 
 .. option:: -mcompact-branches=[values]
 
Index: test/Driver/aarch64-mgeneral_regs_only.c
===
--- test/Driver/aarch64-mgeneral_regs_only.c
+++ test/Driver/aarch64-mgeneral_regs_only.c
@@ -4,6 +4,18 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FP %s
 // RUN: %clang -target arm64-linux-eabi -mgeneral-regs-only %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FP %s
+// RUN: %clang -target aarch64-linux-eabi -mgeneral-regs-only 
-march=armv8.1a+crypto %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP %s
+
+// CHECK-NO-FP: "-target-feature" "+neonasm"
+// CHECK-NO-FP-NOT: "-target-feature" "+fp-armv8asm"
+// CHECK-NO-FP-NOT: "-target-feature" "+cryptoasm"
 // CHECK-NO-FP: "-target-feature" "-fp-armv8"
-// CHECK-NO-FP: "-target-feature" "-crypto"
 // CHECK-NO-FP: "-target-feature" "-neon"
+// CHECK-NO-FP: "-target-feature" "-crypto"
+
+// CHECK-FP: "-target-feature" "+neonasm"
+// CHECK-FP: "-target-feature" "+cryptoasm"
+// CHECK-FP: "-target-feature" "-fp-armv8"
+// CHECK-FP: "-target-feature" "-neon"
+// CHECK-FP: "-target-feature" "-crypto"


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2623,9 +2623,33 @@
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
+// Find the last of each feature.
+llvm::StringMap LastOpt;
+for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+  StringRef Name = Features[I];
+  assert(Name[0] == '-' || Name[0] == '+');
+  LastOpt[Name.drop_front(1)] = I;
+}
+
+llvm::StringMap::iterator I = LastOpt.find("neon");
+if (I != LastOpt.end() && Features[I->second] == "+neon")
+  Features.push_back("+neonasm");
+
+I = LastOpt.find("crypto");
+if (I != LastOpt.end() && Features[I->second] == "+crypto")
+  Features.push_back("+cryptoasm");
+
+I = LastOpt.find("fp-armv8");
+if (I != LastOpt.end() && Features[I->second] == "+fp-armv8")
+  Features.push_back("+fp-armv8asm");
+
+I = LastOpt.find("fullfp16");
+if (I != LastOpt.end() && Features[I->second] == "+fullfp16")
+  Features.push_back("+fullfp16asm");
+
 Features.push_back("-fp-armv8");
-Features.push_back("-crypto");
 Features.push_back("-neon");
+Features.push_back("-crypto");
   }
 
   // En/disable crc
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1188,7 +1188,8 @@
Generate code which only uses the general purpose registers.
 
This option restricts the generated code to use general registers
-   only. This only applies to the AArch64 architecture.
+   only but does not restrict the assembler. This only applies to the
+   AArch64 architecture.
 
 .. option:: -mcompact-branc

[PATCH] D21099: [Sema] Teach -Wcast-align to look at the aligned attribute of the declared variables

2016-11-18 Thread Alex Lorenz via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10270
 
+static void setSrcAlign(Expr *SE, CharUnits &SrcAlign, ASTContext &Context) {
+  if (const auto *DRE = dyn_cast(SE))

I'm not sure if you can, since I don't really know `CharUnits`, but I think you 
should just return it instead of passing it as a parameter if it's a POD type 
(if you will end up doing that you should rename this function as well).



Comment at: lib/Sema/SemaChecking.cpp:10270
 
+static void setSrcAlign(Expr *SE, CharUnits &SrcAlign, ASTContext &Context) {
+  if (const auto *DRE = dyn_cast(SE))

arphaman wrote:
> I'm not sure if you can, since I don't really know `CharUnits`, but I think 
> you should just return it instead of passing it as a parameter if it's a POD 
> type (if you will end up doing that you should rename this function as well).
Please add a brief doc comment as well.


https://reviews.llvm.org/D21099



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


[PATCH] D26863: [AMDGPU] Change frexp.exp builtin to return i16 for f16 input

2016-11-18 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: tstellarAMD, arsenm.
kzhuravl added subscribers: b-sumner, cfe-commits.
Herald added subscribers: tony-tye, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D26863

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/CodeGenOpenCL/builtins-amdgcn.cl


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -166,14 +166,14 @@
 }
 
 // CHECK-LABEL: @test_frexp_exp_f32
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f32
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f32
 void test_frexp_exp_f32(global int* out, float a)
 {
   *out = __builtin_amdgcn_frexp_expf(a);
 }
 
 // CHECK-LABEL: @test_frexp_exp_f64
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f64
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f64
 void test_frexp_exp_f64(global int* out, double a)
 {
   *out = __builtin_amdgcn_frexp_exp(a);
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -55,7 +55,7 @@
 }
 
 // CHECK-LABEL: @test_frexp_exp_f16
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f16
+// CHECK: call i16 @llvm.amdgcn.frexp.exp.i16.f16
 void test_frexp_exp_f16(global short* out, half a)
 {
   *out = __builtin_amdgcn_frexp_exph(a);
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -8250,9 +8250,18 @@
   case AMDGPU::BI__builtin_amdgcn_frexp_manth:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_frexp_mant);
   case AMDGPU::BI__builtin_amdgcn_frexp_exp:
-  case AMDGPU::BI__builtin_amdgcn_frexp_expf:
-  case AMDGPU::BI__builtin_amdgcn_frexp_exph:
-return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_frexp_exp);
+  case AMDGPU::BI__builtin_amdgcn_frexp_expf: {
+Value *Src0 = EmitScalarExpr(E->getArg(0));
+Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_frexp_exp,
+{ Builder.getInt32Ty(), Src0->getType() });
+return Builder.CreateCall(F, Src0);
+  }
+  case AMDGPU::BI__builtin_amdgcn_frexp_exph: {
+Value *Src0 = EmitScalarExpr(E->getArg(0));
+Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_frexp_exp,
+{ Builder.getInt16Ty(), Src0->getType() });
+return Builder.CreateCall(F, Src0);
+  }
   case AMDGPU::BI__builtin_amdgcn_fract:
   case AMDGPU::BI__builtin_amdgcn_fractf:
   case AMDGPU::BI__builtin_amdgcn_fracth:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -92,7 +92,7 @@
 TARGET_BUILTIN(__builtin_amdgcn_cosh, "hh", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ldexph, "hhi", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_frexp_manth, "hh", "nc", "16-bit-insts")
-TARGET_BUILTIN(__builtin_amdgcn_frexp_exph, "ih", "nc", "16-bit-insts")
+TARGET_BUILTIN(__builtin_amdgcn_frexp_exph, "sh", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_fracth, "hh", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -166,14 +166,14 @@
 }
 
 // CHECK-LABEL: @test_frexp_exp_f32
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f32
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f32
 void test_frexp_exp_f32(global int* out, float a)
 {
   *out = __builtin_amdgcn_frexp_expf(a);
 }
 
 // CHECK-LABEL: @test_frexp_exp_f64
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f64
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f64
 void test_frexp_exp_f64(global int* out, double a)
 {
   *out = __builtin_amdgcn_frexp_exp(a);
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -55,7 +55,7 @@
 }
 
 // CHECK-LABEL: @test_frexp_exp_f16
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f16
+// CHECK: call i16 @llvm.amdgcn.frexp.exp.i16.f16
 void test_frexp_exp_f16(global short* out, half a)
 {
   *out = __builtin_amdgcn_frexp_exph(a);
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -8250,9 +8250,18 @@
   case AMDGPU::BI__builtin_amdgcn_frexp_manth:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_frexp_mant);
   case AM

[PATCH] D25869: [Driver] Add unit tests for Distro detection

2016-11-18 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

LGTM! Please add this before https://reviews.llvm.org/D26850, which should 
contain a testcase on top of this!

Thanks


https://reviews.llvm.org/D25869



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


RE: D26636: patch for llvm/clang bug 25965, suppress warning diagnostic on float-to-bool conversion when in condition context

2016-11-18 Thread Blower, Melanie via cfe-commits
Thanks for your question

The bug was originally posted in llvm bugs database, see 25965, there is 
discussion between Richard Smith and the submitter Gregory Pakosz which 
concludes "maybe we should suppress the diagnostic entirely".

Evidently there is fairly usage to guard against divide by zero like this:

if (f)  e/f; 

The spec warning in particular is driving the interest from Intel since it's 
difficult to get the spec source code changed

--Melanie

-Original Message-
From: Joerg Sonnenberger [mailto:jo...@netbsd.org] 
Sent: Friday, November 18, 2016 11:16 AM
To: Blower, Melanie ; rich...@metafoo.co.uk; Keane, 
Erich ; david.majne...@gmail.com
Cc: cfe-commits@lists.llvm.org
Subject: [PATCH] D26636: patch for llvm/clang bug 25965, suppress warning 
diagnostic on float-to-bool conversion when in condition context

joerg added a comment.

Besides "it triggers on SPEC", why should the warning be disabled here? I think 
it is perfectly sensible to have a warning for all six conditional contexts 
here.


https://reviews.llvm.org/D26636



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


[PATCH] D26863: [AMDGPU] Change frexp.exp builtin to return i16 for f16 input

2016-11-18 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D26863



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


[PATCH] D26833: LTO support for -fsave-optimization-record on Darwin

2016-11-18 Thread Adam Nemet via cfe-commits
anemet added a comment.

Mehdi offered to help out making this work for ThinLTO on the LLVM side.  For 
now this option will be ignored by ThinLTO.


https://reviews.llvm.org/D26833



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


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

> This is different from your initial snippet and compiles fine with my patch.

Your confused. Both examples compile fine w/o your patch and are rejected with 
it. I just double checked.


https://reviews.llvm.org/D26843



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


[PATCH] D26544: [PPC] support for arithmetic builtins in the FE

2016-11-18 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D26544



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


r287358 - LTO support for -fsave-optimization-record on Darwin

2016-11-18 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Fri Nov 18 12:17:36 2016
New Revision: 287358

URL: http://llvm.org/viewvc/llvm-project?rev=287358&view=rev
Log:
LTO support for -fsave-optimization-record on Darwin

I guess this would have to be added for each linker.

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

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=287358&r1=287357&r2=287358&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Nov 18 12:17:36 2016
@@ -8416,6 +8416,19 @@ void darwin::Linker::ConstructJob(Compil
   // we follow suite for ease of comparison.
   AddLinkArgs(C, Args, CmdArgs, Inputs);
 
+  // For LTO, pass the name of the optimization record file.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-pass-remarks-output");
+CmdArgs.push_back("-mllvm");
+
+SmallString<128> F;
+F = Output.getFilename();
+F += ".opt.yaml";
+CmdArgs.push_back(Args.MakeArgString(F));
+  }
+
   // It seems that the 'e' option is completely ignored for dynamic executables
   // (the default), and with static executables, the last one wins, as 
expected.
   Args.AddAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, 
options::OPT_t,

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=287358&r1=287357&r2=287358&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Fri Nov 18 12:17:36 2016
@@ -327,3 +327,12 @@
 // LINK_VERSION_DIGITS: invalid version number in 
'-mlinker-version=133.3.0.1.2.6'
 // LINK_VERSION_DIGITS: invalid version number in 
'-mlinker-version=133.3.0.1.a'
 // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1a'
+
+// Check that we're passing -pass-remarks-output for LTO
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log
+// PASS_REMARKS_OUTPUT: "-mllvm" "-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.yaml"
+
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log
+// PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-pass-remarks-output" "-mllvm" 
"a.out.opt.yaml"


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


r287357 - Fix a comment for -fsave-optimization-record

2016-11-18 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Fri Nov 18 12:17:33 2016
New Revision: 287357

URL: http://llvm.org/viewvc/llvm-project?rev=287357&view=rev
Log:
Fix a comment for -fsave-optimization-record

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=287357&r1=287356&r2=287357&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Nov 18 12:17:33 2016
@@ -6225,7 +6225,7 @@ void Clang::ConstructJob(Compilation &C,
   Args.hasArg(options::OPT_S))) {
 F = Output.getFilename();
   } else {
-// Use the compilation directory.
+// Use the input filename.
 F = llvm::sys::path::stem(Input.getBaseInput());
 
 // If we're compiling for an offload architecture (i.e. a CUDA device),


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


[PATCH] D26807: Fix a comment for -fsave-optimization-record

2016-11-18 Thread Adam Nemet via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287357: Fix a comment for -fsave-optimization-record 
(authored by anemet).

Changed prior to commit:
  https://reviews.llvm.org/D26807?vs=78389&id=78551#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26807

Files:
  cfe/trunk/lib/Driver/Tools.cpp


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6225,7 +6225,7 @@
   Args.hasArg(options::OPT_S))) {
 F = Output.getFilename();
   } else {
-// Use the compilation directory.
+// Use the input filename.
 F = llvm::sys::path::stem(Input.getBaseInput());
 
 // If we're compiling for an offload architecture (i.e. a CUDA device),


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6225,7 +6225,7 @@
   Args.hasArg(options::OPT_S))) {
 F = Output.getFilename();
   } else {
-// Use the compilation directory.
+// Use the input filename.
 F = llvm::sys::path::stem(Input.getBaseInput());
 
 // If we're compiling for an offload architecture (i.e. a CUDA device),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26833: LTO support for -fsave-optimization-record on Darwin

2016-11-18 Thread Adam Nemet via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287358: LTO support for -fsave-optimization-record on Darwin 
(authored by anemet).

Changed prior to commit:
  https://reviews.llvm.org/D26833?vs=78464&id=78552#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26833

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


Index: cfe/trunk/test/Driver/darwin-ld.c
===
--- cfe/trunk/test/Driver/darwin-ld.c
+++ cfe/trunk/test/Driver/darwin-ld.c
@@ -327,3 +327,12 @@
 // LINK_VERSION_DIGITS: invalid version number in 
'-mlinker-version=133.3.0.1.2.6'
 // LINK_VERSION_DIGITS: invalid version number in 
'-mlinker-version=133.3.0.1.a'
 // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1a'
+
+// Check that we're passing -pass-remarks-output for LTO
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log
+// PASS_REMARKS_OUTPUT: "-mllvm" "-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.yaml"
+
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log
+// PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-pass-remarks-output" "-mllvm" 
"a.out.opt.yaml"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8416,6 +8416,19 @@
   // we follow suite for ease of comparison.
   AddLinkArgs(C, Args, CmdArgs, Inputs);
 
+  // For LTO, pass the name of the optimization record file.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-pass-remarks-output");
+CmdArgs.push_back("-mllvm");
+
+SmallString<128> F;
+F = Output.getFilename();
+F += ".opt.yaml";
+CmdArgs.push_back(Args.MakeArgString(F));
+  }
+
   // It seems that the 'e' option is completely ignored for dynamic executables
   // (the default), and with static executables, the last one wins, as 
expected.
   Args.AddAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, 
options::OPT_t,


Index: cfe/trunk/test/Driver/darwin-ld.c
===
--- cfe/trunk/test/Driver/darwin-ld.c
+++ cfe/trunk/test/Driver/darwin-ld.c
@@ -327,3 +327,12 @@
 // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1.2.6'
 // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1.a'
 // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1a'
+
+// Check that we're passing -pass-remarks-output for LTO
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log
+// PASS_REMARKS_OUTPUT: "-mllvm" "-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml"
+
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log
+// PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-pass-remarks-output" "-mllvm" "a.out.opt.yaml"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8416,6 +8416,19 @@
   // we follow suite for ease of comparison.
   AddLinkArgs(C, Args, CmdArgs, Inputs);
 
+  // For LTO, pass the name of the optimization record file.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-pass-remarks-output");
+CmdArgs.push_back("-mllvm");
+
+SmallString<128> F;
+F = Output.getFilename();
+F += ".opt.yaml";
+CmdArgs.push_back(Args.MakeArgString(F));
+  }
+
   // It seems that the 'e' option is completely ignored for dynamic executables
   // (the default), and with static executables, the last one wins, as expected.
   Args.AddAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, options::OPT_t,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22955: [MSVC] Improved late parsing of template functions.

2016-11-18 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D22955#598081, @rnk wrote:

> If I understand correctly, this patch takes template function patterns, 
> copies them into instantiated context, parses them in that context, and then 
> instantiates them in that context. The key difference is that today's 
> fdelayed-template-parsing doesn't parse the body of the function in the 
> instantiation context. It just allows access to names at global scope that 
> were encountered after the template pattern.
>
> So, if I run -ast-dump, do I end up seeing both the pattern and the fully 
> instantiated function with this patch?
>
> This patch removes a lot of warnings from our tests. We lose a lot of our 
> ability to diagnose MSVC-isms with this approach. I wonder if there's a 
> better way to do delayed template parsing the way we were before, but make 
> the template arguments available during lookup.




In https://reviews.llvm.org/D22955#598081, @rnk wrote:

> If I understand correctly, this patch takes template function patterns, 
> copies them into instantiated context, parses them in that context, and then 
> instantiates them in that context. The key difference is that today's 
> fdelayed-template-parsing doesn't parse the body of the function in the 
> instantiation context. It just allows access to names at global scope that 
> were encountered after the template pattern.


Yes, you're right.

> So, if I run -ast-dump, do I end up seeing both the pattern and the fully 
> instantiated function with this patch?

No, you will see only instantiated function.

> This patch removes a lot of warnings from our tests. We lose a lot of our 
> ability to diagnose MSVC-isms with this approach. I wonder if there's a 
> better way to do delayed template parsing the way we were before, but make 
> the template arguments available during lookup.

Yes, this is the price we should pay for better MSVC compatibility. I tried 
several different solutions before ended up with this one and have to say this 
one is the best I was able to find.


https://reviews.llvm.org/D22955



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


[PATCH] D26845: [analyzer] Fix crash on the access to a union's region.

2016-11-18 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thanks, - just want to have one of them (https://reviews.llvm.org/D26442 or 
this one) checked in sooner rather than later.
Looks like i have missed that diff on cfe-commits, 
I'm ok to abandon my patch in favor of https://reviews.llvm.org/D26442.


Repository:
  rL LLVM

https://reviews.llvm.org/D26845



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


[PATCH] D26808: [Sema] Don't allow applying address-of operator to a call to a function with __unknown_anytype return type

2016-11-18 Thread Sean Callanan via cfe-commits
spyffe accepted this revision.
spyffe added a comment.
This revision is now accepted and ready to land.

I think it's all right to be conservative here.  The inference rules could get 
quite complicated if (for example) the use looked like this

  extern void foo (double *bar);
  extern __unknown_anytype func();
  // ...
  foo(&func());

One could come up with even more complicated cases.  It's probably not worth 
making sure they all work.


https://reviews.llvm.org/D26808



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


[libcxxabi] r287364 - __cxa_demangle: use default member initialization

2016-11-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Nov 18 13:01:53 2016
New Revision: 287364

URL: http://llvm.org/viewvc/llvm-project?rev=287364&view=rev
Log:
__cxa_demangle: use default member initialization

Sink the Db initialization into the structure rather than out-of-line at the
declaration size.  This just makes it easier to see what initialization is being
performed.  NFC.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=287364&r1=287363&r2=287364&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Nov 18 13:01:53 2016
@@ -4952,13 +4952,13 @@ struct Db
 sub_type names;
 template_param_type subs;
 Vector template_param;
-unsigned cv;
-unsigned ref;
-unsigned encoding_depth;
-bool parsed_ctor_dtor_cv;
-bool tag_templates;
-bool fix_forward_references;
-bool try_to_parse_template_args;
+unsigned cv = 0;
+unsigned ref = 0;
+unsigned encoding_depth = 0;
+bool parsed_ctor_dtor_cv = false;
+bool tag_templates = true;
+bool fix_forward_references = false;
+bool try_to_parse_template_args = true;
 
 template 
 Db(arena& ar) :
@@ -4993,14 +4993,7 @@ __cxa_demangle(const char *mangled_name,
 size_t internal_size = buf != nullptr ? *n : 0;
 arena a;
 Db db(a);
-db.cv = 0;
-db.ref = 0;
-db.encoding_depth = 0;
-db.parsed_ctor_dtor_cv = false;
-db.tag_templates = true;
 db.template_param.emplace_back(a);
-db.fix_forward_references = false;
-db.try_to_parse_template_args = true;
 int internal_status = success;
 demangle(mangled_name, mangled_name + len, db,
  internal_status);


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


[PATCH] D26560: Add a test for vcall on a null ptr.

2016-11-18 Thread Ivan Krasin via cfe-commits
krasin added inline comments.



Comment at: test/ubsan/TestCases/TypeCheck/null.cpp:1
-// RUN: %clangxx -fsanitize=null %s -O3 -o %t
-// RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
-// RUN: %expect_crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
-// RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
-// RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
-// RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// RUN: %clangxx -fsanitize=null -fno-sanitize-recover=null -g %s -O3 -o %t
+// RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD

pcc wrote:
> Why add the -g?
It's a debug left over. Thank you for the catch.



Comment at: test/ubsan/TestCases/TypeCheck/null.cpp:10
+
+#include 
 

pcc wrote:
> Is this #include needed?
Debug leftover. Removed. Thank you for spotting this.



Comment at: test/ubsan/TestCases/TypeCheck/null.cpp:35
+
+  if (argv[1][0] == 'T') {
+t = new T;

pcc wrote:
> Did you intend to add tests for these cases?
Actually, the real reason for adding these is that break_optimization didn't 
really fool the compiler, and I had to add some more logic to avoid letting it 
know that the pointer is always null => it's undefined behavior. In my case, I 
saw my return being ignored and two switch statements executed together.

I can't currently reproduce it now, most likely, because the fix has eliminated 
the virtual call on a pointer that is guaranteed to be null. So, I have removed 
these as well as break_optimization calls.



https://reviews.llvm.org/D26560



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


[PATCH] D26560: Add a test for vcall on a null ptr.

2016-11-18 Thread Ivan Krasin via cfe-commits
krasin updated this revision to Diff 78557.
krasin added a comment.

sync & address the comments.


https://reviews.llvm.org/D26560

Files:
  test/ubsan/TestCases/TypeCheck/null.cpp


Index: test/ubsan/TestCases/TypeCheck/null.cpp
===
--- test/ubsan/TestCases/TypeCheck/null.cpp
+++ test/ubsan/TestCases/TypeCheck/null.cpp
@@ -1,20 +1,34 @@
-// RUN: %clangxx -fsanitize=null %s -O3 -o %t
-// RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
-// RUN: %expect_crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
-// RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
-// RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
-// RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// RUN: %clangxx -fsanitize=null -fno-sanitize-recover=null %s -O3 -o %t
+// RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
+// RUN: not %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
+// RUN: not %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
+// RUN: not %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
+// RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// RUN: not %run %t t 2>&1 | FileCheck %s --check-prefix=CHECK-VCALL
+// RUN: not %run %t u 2>&1 | FileCheck %s --check-prefix=CHECK-VCALL2
 
 struct S {
   int f() { return 0; }
   int k;
 };
 
+struct T {
+  virtual int v() { return 1; }
+};
+
+struct U : T {
+  virtual int v() { return 2; }
+};
+
 int main(int, char **argv) {
   int *p = 0;
   S *s = 0;
+  T *t = 0;
+  U *u = 0;
 
   (void)*p; // ok!
+  (void)*t; // ok!
+  (void)*u; // ok!
 
   switch (argv[1][0]) {
   case 'l':
@@ -34,5 +48,11 @@
   case 'f':
 // CHECK-MEMFUN: null.cpp:[[@LINE+1]]:15: runtime error: member call on 
null pointer of type 'S'
 return s->f();
+  case 't':
+// CHECK-VCALL: null.cpp:[[@LINE+1]]:15: runtime error: member call on 
null pointer of type 'T'
+return t->v();
+  case 'u':
+// CHECK-VCALL2: null.cpp:[[@LINE+1]]:15: runtime error: member call on 
null pointer of type 'U'
+return u->v();
   }
 }


Index: test/ubsan/TestCases/TypeCheck/null.cpp
===
--- test/ubsan/TestCases/TypeCheck/null.cpp
+++ test/ubsan/TestCases/TypeCheck/null.cpp
@@ -1,20 +1,34 @@
-// RUN: %clangxx -fsanitize=null %s -O3 -o %t
-// RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
-// RUN: %expect_crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
-// RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
-// RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
-// RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// RUN: %clangxx -fsanitize=null -fno-sanitize-recover=null %s -O3 -o %t
+// RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
+// RUN: not %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
+// RUN: not %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
+// RUN: not %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
+// RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
+// RUN: not %run %t t 2>&1 | FileCheck %s --check-prefix=CHECK-VCALL
+// RUN: not %run %t u 2>&1 | FileCheck %s --check-prefix=CHECK-VCALL2
 
 struct S {
   int f() { return 0; }
   int k;
 };
 
+struct T {
+  virtual int v() { return 1; }
+};
+
+struct U : T {
+  virtual int v() { return 2; }
+};
+
 int main(int, char **argv) {
   int *p = 0;
   S *s = 0;
+  T *t = 0;
+  U *u = 0;
 
   (void)*p; // ok!
+  (void)*t; // ok!
+  (void)*u; // ok!
 
   switch (argv[1][0]) {
   case 'l':
@@ -34,5 +48,11 @@
   case 'f':
 // CHECK-MEMFUN: null.cpp:[[@LINE+1]]:15: runtime error: member call on null pointer of type 'S'
 return s->f();
+  case 't':
+// CHECK-VCALL: null.cpp:[[@LINE+1]]:15: runtime error: member call on null pointer of type 'T'
+return t->v();
+  case 'u':
+// CHECK-VCALL2: null.cpp:[[@LINE+1]]:15: runtime error: member call on null pointer of type 'U'
+return u->v();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In case your wondering *why* this happens

In https://reviews.llvm.org/D26843#599804, @pmatos wrote:

> In https://reviews.llvm.org/D26843#599673, @EricWF wrote:
>
> > > But that is not valid in C afaik and in C++ I get:
> > > 
> > >   error: invalid use of non-static data member 'm'
> > > int x = sizeof(T::m);
> > >~~~^
> > > 
> > > 
> > > Can you post a full reproducible example of what the change breaks?
> >
> > That is a full reproducible example because it's valid C++. Clang currently 
> > compiles it .
>
>
> But what was in the link was:
>
>   typedef struct { int m; } T;
>   int x = sizeof(T);
>   int main() {}
>
>
> This is different from your initial snippet and compiles fine with my patch.


Sorry your right. That should still say `sizeof(T::m)`. My mistake.


https://reviews.llvm.org/D26843



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


[PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Paulo Matos via cfe-commits
pmatos added a comment.

Apologies if I am being shallow and wasting your time but `sizeof(T::m)` 
doesn't compile at the moment with clang trunk. Using the same service you used 
before .


https://reviews.llvm.org/D26843



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


r287366 - [CMake] Fixing variable names that were mistyped

2016-11-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Nov 18 13:20:39 2016
New Revision: 287366

URL: http://llvm.org/viewvc/llvm-project?rev=287366&view=rev
Log:
[CMake] Fixing variable names that were mistyped

This is a silly bug that I'm sure I caused...

Modified:
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=287366&r1=287365&r2=287366&view=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Nov 18 13:20:39 2016
@@ -74,7 +74,7 @@ if (APPLE)
 
   set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
   set(TOOL_INFO_VERSION "${CLANG_VERSION}")
-  set(TOOL_INFO_BUILD_VERSION "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}")
+  set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
   
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang


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


Re: [PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Aaron Ballman via cfe-commits
On Fri, Nov 18, 2016 at 2:22 PM, Paulo Matos via cfe-commits
 wrote:
> pmatos added a comment.
>
> Apologies if I am being shallow and wasting your time but `sizeof(T::m)` 
> doesn't compile at the moment with clang trunk. Using the same service you 
> used before .

Compile for C++11 instead of C++03.

~Aaron

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


[PATCH] D26234: [Frontend] Add a predefined macro that describes the Objective-C bool type

2016-11-18 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a reviewer: t.p.northover.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Looks reasonable to me.

Tim.


Repository:
  rL LLVM

https://reviews.llvm.org/D26234



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


r287371 - Adapt to llvm NamedRegionTimer changes

2016-11-18 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri Nov 18 13:43:25 2016
New Revision: 287371

URL: http://llvm.org/viewvc/llvm-project?rev=287371&view=rev
Log:
Adapt to llvm NamedRegionTimer changes

We have to specify a name and description for the timers and groups now.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=287371&r1=287370&r2=287371&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Nov 18 13:43:25 2016
@@ -102,7 +102,7 @@ public:
  const clang::TargetOptions &TOpts,
  const LangOptions &LOpts, Module *M)
   : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
-TheModule(M), CodeGenerationTime("Code Generation Time") {}
+TheModule(M), CodeGenerationTime("codegen", "Code Generation Time") {}
 
   ~EmitAssemblyHelper() {
 if (CodeGenOpts.DisableFree)

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=287371&r1=287370&r2=287371&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Nov 18 13:43:25 2016
@@ -75,7 +75,7 @@ namespace clang {
 : Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts),
   TargetOpts(TargetOpts), LangOpts(LangOpts),
   AsmOutStream(std::move(OS)), Context(nullptr),
-  LLVMIRGeneration("LLVM IR Generation Time"),
+  LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
   LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)) {

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=287371&r1=287370&r2=287371&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Nov 18 13:43:25 2016
@@ -522,9 +522,11 @@ void CompilerInstance::createCodeComplet
 }
 
 void CompilerInstance::createFrontendTimer() {
-  FrontendTimerGroup.reset(new llvm::TimerGroup("Clang front-end time 
report"));
+  FrontendTimerGroup.reset(
+  new llvm::TimerGroup("frontend", "Clang front-end time report"));
   FrontendTimer.reset(
-  new llvm::Timer("Clang front-end timer", *FrontendTimerGroup));
+  new llvm::Timer("frontend", "Clang front-end timer",
+  *FrontendTimerGroup));
 }
 
 CodeCompleteConsumer *
@@ -1324,7 +1326,8 @@ void CompilerInstance::createModuleManag
 const PreprocessorOptions &PPOpts = getPreprocessorOpts();
 std::unique_ptr ReadTimer;
 if (FrontendTimerGroup)
-  ReadTimer = llvm::make_unique("Reading modules",
+  ReadTimer = llvm::make_unique("reading_modules",
+ "Reading modules",
  *FrontendTimerGroup);
 ModuleManager = new ASTReader(
 getPreprocessor(), getASTContext(), getPCHContainerReader(),
@@ -1357,7 +1360,8 @@ void CompilerInstance::createModuleManag
 bool CompilerInstance::loadModuleFile(StringRef FileName) {
   llvm::Timer Timer;
   if (FrontendTimerGroup)
-Timer.init("Preloading " + FileName.str(), *FrontendTimerGroup);
+Timer.init("preloading." + FileName.str(), "Preloading " + FileName.str(),
+   *FrontendTimerGroup);
   llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
 
   // Helper to recursively read the module names for all modules we're adding.
@@ -1509,7 +1513,8 @@ CompilerInstance::loadModule(SourceLocat
 
 llvm::Timer Timer;
 if (FrontendTimerGroup)
-  Timer.init("Loading " + ModuleFileName, *FrontendTimerGroup);
+  Timer.init("loading." + ModuleFileName, "Loading " + ModuleFileName,
+ *FrontendTimerGroup);
 llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
 
 // Try to load the module file. If we are trying to load from the prebuilt

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=287371&r1=287370&r2=287371&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Fro

[libcxx] r287373 - Make LIBCXX_ENABLE_STATIC_ABI_LIBRARY merge libc++.a and libc++abi.a

2016-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Nov 18 13:53:45 2016
New Revision: 287373

URL: http://llvm.org/viewvc/llvm-project?rev=287373&view=rev
Log:
Make LIBCXX_ENABLE_STATIC_ABI_LIBRARY merge libc++.a and libc++abi.a

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/utils/merge_archives.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=287373&r1=287372&r2=287373&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Fri Nov 18 13:53:45 2016
@@ -251,6 +251,9 @@ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
   else()
 message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental 
option")
   endif()
+  if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND)
+message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but 
it was not found.")
+  endif()
 endif()
 
 if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=287373&r1=287372&r2=287373&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Fri Nov 18 13:53:45 2016
@@ -193,6 +193,28 @@ if (LIBCXX_ENABLE_STATIC)
   OUTPUT_NAME   "c++"
   )
   list(APPEND LIBCXX_TARGETS "cxx_static")
+  # Attempt to merge the libc++.a archive and the ABI library archive into one.
+  if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+set(MERGE_ARCHIVES_SEARCH_PATHS "")
+if (LIBCXX_CXX_ABI_LIBRARY_PATH)
+  set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
+endif()
+if (TARGET ${LIBCXX_CXX_ABI_LIBRARY})
+  set(MERGE_ARCHIVES_ABI_TARGET 
"$")
+else()
+  set(MERGE_ARCHIVES_ABI_TARGET "lib${LIBCXX_CXX_ABI_LIBRARY}.a")
+endif()
+add_custom_command(TARGET cxx_static POST_BUILD
+COMMAND
+  ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py
+ARGS
+  -o $
+  "$"
+  "${MERGE_ARCHIVES_ABI_TARGET}"
+  "${MERGE_ARCHIVES_SEARCH_PATHS}"
+WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
+)
+  endif()
 endif()
 
 # Add a meta-target for both libraries.

Modified: libcxx/trunk/utils/merge_archives.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/merge_archives.py?rev=287373&r1=287372&r2=287373&view=diff
==
--- libcxx/trunk/utils/merge_archives.py (original)
+++ libcxx/trunk/utils/merge_archives.py Fri Nov 18 13:53:45 2016
@@ -9,6 +9,7 @@
 #===--===##
 
 from argparse import ArgumentParser
+from ctypes.util import find_library
 import distutils.spawn
 import glob
 import tempfile
@@ -28,9 +29,18 @@ def print_and_exit(msg):
 sys.stderr.write(msg + '\n')
 exit_with_cleanups(1)
 
-def diagnose_missing(file):
-if not os.path.exists(file):
-print_and_exit("input '%s' does not exist" % file)
+def find_and_diagnose_missing(lib, search_paths):
+if os.path.exists(lib):
+return os.path.abspath(lib)
+if not lib.startswith('lib') or not lib.endswith('.a'):
+print_and_exit(("input file '%s' not not name a static library. "
+   "It should start with 'lib' and end with '.a") % lib)
+for sp in search_paths:
+assert type(sp) is list and len(sp) == 1
+path = os.path.join(sp[0], lib)
+if os.path.exists(path):
+return os.path.abspath(path)
+print_and_exit("input '%s' does not exist" % lib)
 
 
 def execute_command(cmd, cwd=None):
@@ -80,6 +90,10 @@ def main():
 help='The output file. stdout is used if not given',
 type=str, action='store')
 parser.add_argument(
+'-L', dest='search_paths',
+help='Paths to search for the libraries along', action='append',
+nargs=1)
+parser.add_argument(
 'archives', metavar='archives',  nargs='+',
 help='The archives to merge')
 
@@ -91,12 +105,9 @@ def main():
 
 if len(args.archives) < 2:
 print_and_exit('fewer than 2 inputs provided')
-archives = []
-for ar in args.archives:
-diagnose_missing(ar)
-# Make the path absolute so it isn't affected when we change the PWD.
-archives += [os.path.abspath(ar)]
-
+archives = [find_and_diagnose_missing(ar, args.search_paths)
+for ar in args.archives]
+print ('Merging archives: %s' % archives)
 if not os.path.exists(os.path.dirname(args.output)):
 print_and_exit("output path doesn't exist: '%s'" % args.output)
 


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


Re: [PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Paulo Matos via cfe-commits


On 18/11/16 20:30, Aaron Ballman wrote:
> On Fri, Nov 18, 2016 at 2:22 PM, Paulo Matos via cfe-commits
>  wrote:
>> pmatos added a comment.
>>
>> Apologies if I am being shallow and wasting your time but `sizeof(T::m)` 
>> doesn't compile at the moment with clang trunk. Using the same service you 
>> used before .
> 
> Compile for C++11 instead of C++03.
> 

OK, I can see the problem. Interestingly, the error you get with the
patch and c++11 is the same you used to get with c++03.

I will take a look at this.

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


[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-11-18 Thread Kevin Puetz via cfe-commits
puetzk updated this revision to Diff 78569.
puetzk added a comment.

Address comments from @aaron.ballman and @majnemer

Add a test case wihich triggers "the 'uuid' attribute only applies to classes 
and enumerations" warning


Repository:
  rL LLVM

https://reviews.llvm.org/D26846

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Parser/MicrosoftExtensions.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2681,6 +2681,7 @@
 case ObjCProtocol | ObjCInterface:
   return "ExpectedObjectiveCInterfaceOrProtocol";
 case Field | Var: return "ExpectedFieldOrGlobalVar";
+case Class | Enum: return "ExpectedEnumOrClass";
   }
 
   PrintFatalError(S.getLoc(),
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -65,6 +65,12 @@
 struct
 struct_with_uuid2 {} ;
 
+enum __declspec(uuid("00A0---C000-0046"))
+enum_with_uuid { };
+enum enum_without_uuid { };
+
+int __declspec(uuid("00A0---C000-0046")) inappropriate_uuid; // expected-warning {{'uuid' attribute only applies to classes and enumerations}}
+
 int uuid_sema_test()
 {
struct_with_uuid var_with_uuid[1];
@@ -81,6 +87,15 @@
__uuidof(const struct_with_uuid[1][1]);
__uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
 
+   __uuidof(enum_with_uuid);
+   __uuidof(enum_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(enum_with_uuid*);
+   __uuidof(enum_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(enum_with_uuid[1]);
+   __uuidof(enum_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+   __uuidof(const enum_with_uuid[1][1]);
+   __uuidof(const enum_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
__uuidof(var_with_uuid);
__uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(var_with_uuid[1]);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -520,17 +520,17 @@
   else if (QT->isArrayType())
 Ty = Ty->getBaseElementTypeUnsafe();
 
-  const auto *RD = Ty->getAsCXXRecordDecl();
-  if (!RD)
+  const auto *TD = Ty->getAsTagDecl();
+  if (!TD)
 return;
 
-  if (const auto *Uuid = RD->getMostRecentDecl()->getAttr()) {
+  if (const auto *Uuid = TD->getMostRecentDecl()->getAttr()) {
 UuidAttrs.insert(Uuid);
 return;
   }
 
   // __uuidof can grab UUIDs from template arguments.
-  if (const auto *CTSD = dyn_cast(RD)) {
+  if (const auto *CTSD = dyn_cast(TD)) {
 const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
 for (const TemplateArgument &TA : TAL.asArray()) {
   const UuidAttr *UuidForTA = nullptr;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4666,12 +4666,6 @@
 return;
   }
 
-  if (!isa(D)) {
-S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << Attr.getName() << ExpectedClass;
-return;
-  }
-
   StringRef StrRef;
   SourceLocation LiteralLoc;
   if (!S.checkStringLiteralArgumentAttr(Attr, 0, StrRef, &LiteralLoc))
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -925,7 +925,8 @@
   ExpectedVariableEnumFieldOrTypedef,
   ExpectedFunctionMethodEnumOrClass,
   ExpectedStructClassVariableFunctionOrInlineNamespace,
-  ExpectedForMaybeUnused
+  ExpectedForMaybeUnused,
+  ExpectedEnumOrClass
 };
 
 }  // end namespace clang
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2641,7 +2641,8 @@
   "|variables, enums, fields and typedefs"
   "|functions, methods, enums, and classes"
   "|structs, classes, variables, functions, and inline namespaces"
-  "|variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members}1">,
+  "|variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members"
+  "|classes and enumerations}1">,
   InGroup;
 def err_attribute_wrong_decl_type : Error;

[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-11-18 Thread Kevin Puetz via cfe-commits
puetzk added a comment.

Also rebased against r287335/496a3f56c7


Repository:
  rL LLVM

https://reviews.llvm.org/D26846



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


Re: [PATCH] D26843: Make sizeof expression context partially evaluated

2016-11-18 Thread Eric Fiselier via cfe-commits
FYI I took the example from the [C++1z standard](
http://eel.is/c++draft/expr.prim.id#2)

> [expr.prim.id]p2:
> An id-expression that denotes a non-static data member or non-static
member function of a class can only
> be used [...] if that id-expression denotes a non-static data member and
it appears in an unevaluated operand.

Here is another example that works in C++03 as well as C++11:

```
template 
T foo() {
  _Static_assert(sizeof(T) != sizeof(T),
 "foo can not appear in a potentially evaluated
expression");
}
typedef __typeof(foo()) T; // OK. Unevaluated context.
int x = sizeof(foo()); // Ill-formed. Triggers assertion because a
definition is required.
```

/Eric

On Fri, Nov 18, 2016 at 12:52 PM, Paulo Matos via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On 18/11/16 20:30, Aaron Ballman wrote:
> > On Fri, Nov 18, 2016 at 2:22 PM, Paulo Matos via cfe-commits
> >  wrote:
> >> pmatos added a comment.
> >>
> >> Apologies if I am being shallow and wasting your time but
> `sizeof(T::m)` doesn't compile at the moment with clang trunk. Using the
> same service you used before  permlink/C4pCnoVGmS0qBUxf>.
> >
> > Compile for C++11 instead of C++03.
> >
>
> OK, I can see the problem. Interestingly, the error you get with the
> patch and c++11 is the same you used to get with c++03.
>
> I will take a look at this.
>
> --
> Paulo Matos
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26773: [analyzer] Refactor recursive symbol reachability check to use symbol_iterator

2016-11-18 Thread Dominic Chen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287380: [analyzer] Refactor recursive symbol reachability 
check to use symbol_iterator (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26773?vs=78392&id=78575#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26773

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -824,8 +824,9 @@
 }
 
 /// \class ScanReachableSymbols
-/// A Utility class that allows to visit the reachable symbols using a custom
-/// SymbolVisitor.
+/// A utility class that visits the reachable symbols using a custom
+/// SymbolVisitor. Terminates recursive traversal when the visitor function
+/// returns false.
 class ScanReachableSymbols {
   typedef llvm::DenseSet VisitedItems;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -527,32 +527,17 @@
 }
 
 bool ScanReachableSymbols::scan(const SymExpr *sym) {
-  bool wasVisited = !visited.insert(sym).second;
-  if (wasVisited)
-return true;
-
-  if (!visitor.VisitSymbol(sym))
-return false;
+  for (SymExpr::symbol_iterator SI = sym->symbol_begin(),
+SE = sym->symbol_end();
+   SI != SE; ++SI) {
+bool wasVisited = !visited.insert(*SI).second;
+if (wasVisited)
+  continue;
 
-  // TODO: should be rewritten using SymExpr::symbol_iterator.
-  switch (sym->getKind()) {
-case SymExpr::SymbolRegionValueKind:
-case SymExpr::SymbolConjuredKind:
-case SymExpr::SymbolDerivedKind:
-case SymExpr::SymbolExtentKind:
-case SymExpr::SymbolMetadataKind:
-  break;
-case SymExpr::SymbolCastKind:
-  return scan(cast(sym)->getOperand());
-case SymExpr::SymIntExprKind:
-  return scan(cast(sym)->getLHS());
-case SymExpr::IntSymExprKind:
-  return scan(cast(sym)->getRHS());
-case SymExpr::SymSymExprKind: {
-  const SymSymExpr *x = cast(sym);
-  return scan(x->getLHS()) && scan(x->getRHS());
-}
+if (!visitor.VisitSymbol(*SI))
+  return false;
   }
+
   return true;
 }
 


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -824,8 +824,9 @@
 }
 
 /// \class ScanReachableSymbols
-/// A Utility class that allows to visit the reachable symbols using a custom
-/// SymbolVisitor.
+/// A utility class that visits the reachable symbols using a custom
+/// SymbolVisitor. Terminates recursive traversal when the visitor function
+/// returns false.
 class ScanReachableSymbols {
   typedef llvm::DenseSet VisitedItems;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -527,32 +527,17 @@
 }
 
 bool ScanReachableSymbols::scan(const SymExpr *sym) {
-  bool wasVisited = !visited.insert(sym).second;
-  if (wasVisited)
-return true;
-
-  if (!visitor.VisitSymbol(sym))
-return false;
+  for (SymExpr::symbol_iterator SI = sym->symbol_begin(),
+SE = sym->symbol_end();
+   SI != SE; ++SI) {
+bool wasVisited = !visited.insert(*SI).second;
+if (wasVisited)
+  continue;
 
-  // TODO: should be rewritten using SymExpr::symbol_iterator.
-  switch (sym->getKind()) {
-case SymExpr::SymbolRegionValueKind:
-case SymExpr::SymbolConjuredKind:
-case SymExpr::SymbolDerivedKind:
-case SymExpr::SymbolExtentKind:
-case SymExpr::SymbolMetadataKind:
-  break;
-case SymExpr::SymbolCastKind:
-  return scan(cast(sym)->getOperand());
-case SymExpr::SymIntExprKind:
-  return scan(cast(sym)->getLHS());
-case SymExpr::IntSymExprKind:
-  return scan(cast(sym)->getRHS());
-case SymExpr::SymSymExprKind: {
-  const SymSymExpr *x = cast(sym);
-  return scan(x->getLHS()) && scan(x->getRHS());
-}
+if (!visitor.VisitSymbol(*SI))
+  return false;
   }
+
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r287380 - [analyzer] Refactor recursive symbol reachability check to use symbol_iterator

2016-11-18 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Fri Nov 18 15:07:03 2016
New Revision: 287380

URL: http://llvm.org/viewvc/llvm-project?rev=287380&view=rev
Log:
[analyzer] Refactor recursive symbol reachability check to use symbol_iterator

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=287380&r1=287379&r2=287380&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Fri Nov 18 15:07:03 2016
@@ -824,8 +824,9 @@ CB ProgramState::scanReachableSymbols(co
 }
 
 /// \class ScanReachableSymbols
-/// A Utility class that allows to visit the reachable symbols using a custom
-/// SymbolVisitor.
+/// A utility class that visits the reachable symbols using a custom
+/// SymbolVisitor. Terminates recursive traversal when the visitor function
+/// returns false.
 class ScanReachableSymbols {
   typedef llvm::DenseSet VisitedItems;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=287380&r1=287379&r2=287380&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Fri Nov 18 15:07:03 2016
@@ -527,32 +527,17 @@ bool ScanReachableSymbols::scan(nonloc::
 }
 
 bool ScanReachableSymbols::scan(const SymExpr *sym) {
-  bool wasVisited = !visited.insert(sym).second;
-  if (wasVisited)
-return true;
+  for (SymExpr::symbol_iterator SI = sym->symbol_begin(),
+SE = sym->symbol_end();
+   SI != SE; ++SI) {
+bool wasVisited = !visited.insert(*SI).second;
+if (wasVisited)
+  continue;
 
-  if (!visitor.VisitSymbol(sym))
-return false;
-
-  // TODO: should be rewritten using SymExpr::symbol_iterator.
-  switch (sym->getKind()) {
-case SymExpr::SymbolRegionValueKind:
-case SymExpr::SymbolConjuredKind:
-case SymExpr::SymbolDerivedKind:
-case SymExpr::SymbolExtentKind:
-case SymExpr::SymbolMetadataKind:
-  break;
-case SymExpr::SymbolCastKind:
-  return scan(cast(sym)->getOperand());
-case SymExpr::SymIntExprKind:
-  return scan(cast(sym)->getLHS());
-case SymExpr::IntSymExprKind:
-  return scan(cast(sym)->getRHS());
-case SymExpr::SymSymExprKind: {
-  const SymSymExpr *x = cast(sym);
-  return scan(x->getLHS()) && scan(x->getRHS());
-}
+if (!visitor.VisitSymbol(*SI))
+  return false;
   }
+
   return true;
 }
 


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


r287378 - [ARM] Fix sema check of ARM special register names

2016-11-18 Thread Oleg Ranevskyy via cfe-commits
Author: oleg
Date: Fri Nov 18 15:00:08 2016
New Revision: 287378

URL: http://llvm.org/viewvc/llvm-project?rev=287378&view=rev
Log:
[ARM] Fix sema check of ARM special register names

Summary:
This is a simple sema check patch for arguments of `__builtin_arm_rsr` and the 
related builtins, which currently do not allow special registers with indexes 
>7.

Some of the possible register name formats these builtins accept are:
```
{c}p::c:c:
```
```
o0:op1:CRn:CRm:op2
```
where `op1` / `op2` are integers in the range [0, 7] and `CRn` / `CRm` are 
integers in the range [0, 15].

The current sema check does not allow `CRn` > 7 and accepts `op2` up to 15.

Reviewers: LukeCheeseman, rengolin

Subscribers: asl, aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/aarch64-special-register.c
cfe/trunk/test/Sema/arm-special-register.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=287378&r1=287377&r2=287378&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 18 15:00:08 2016
@@ -4194,7 +4194,7 @@ bool Sema::SemaBuiltinARMSpecialReg(unsi
 
 SmallVector Ranges;
 if (FiveFields)
-  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 7, 15, 15});
+  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
 else
   Ranges.append({15, 7, 15});
 

Modified: cfe/trunk/test/Sema/aarch64-special-register.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/aarch64-special-register.c?rev=287378&r1=287377&r2=287378&view=diff
==
--- cfe/trunk/test/Sema/aarch64-special-register.c (original)
+++ cfe/trunk/test/Sema/aarch64-special-register.c Fri Nov 18 15:00:08 2016
@@ -41,7 +41,7 @@ void wsr64_2(unsigned long v) {
 }
 
 unsigned rsr_2() {
-  return __builtin_arm_rsr("0:1:2:3:4");
+  return __builtin_arm_rsr("0:1:15:15:4");
 }
 
 void *rsrp_2() {
@@ -49,7 +49,7 @@ void *rsrp_2() {
 }
 
 unsigned long rsr64_2() {
-  return __builtin_arm_rsr64("0:1:2:3:4");
+  return __builtin_arm_rsr64("0:1:15:15:4");
 }
 
 void wsr_3(unsigned v) {
@@ -68,6 +68,18 @@ unsigned rsr_3() {
   return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special 
register for builtin}}
 }
 
+unsigned rsr_4() {
+  return __builtin_arm_rsr("0:1:2:3:8"); //expected-error {{invalid special 
register for builtin}}
+}
+
+unsigned rsr_5() {
+  return __builtin_arm_rsr("0:8:1:2:3"); //expected-error {{invalid special 
register for builtin}}
+}
+
+unsigned rsr_6() {
+  return __builtin_arm_rsr("0:1:16:16:2"); //expected-error {{invalid special 
register for builtin}}
+}
+
 void *rsrp_3() {
   return __builtin_arm_rsrp("0:1:2"); //expected-error {{invalid special 
register for builtin}}
 }
@@ -75,3 +87,15 @@ void *rsrp_3() {
 unsigned long rsr64_3() {
   return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special 
register for builtin}}
 }
+
+unsigned long rsr64_4() {
+  return __builtin_arm_rsr64("0:1:2:3:8"); //expected-error {{invalid special 
register for builtin}}
+}
+
+unsigned long rsr64_5() {
+  return __builtin_arm_rsr64("0:8:2:3:4"); //expected-error {{invalid special 
register for builtin}}
+}
+
+unsigned long rsr64_6() {
+  return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid 
special register for builtin}}
+}

Modified: cfe/trunk/test/Sema/arm-special-register.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-special-register.c?rev=287378&r1=287377&r2=287378&view=diff
==
--- cfe/trunk/test/Sema/arm-special-register.c (original)
+++ cfe/trunk/test/Sema/arm-special-register.c Fri Nov 18 15:00:08 2016
@@ -41,7 +41,7 @@ void wsr64_2(unsigned long v) {
 }
 
 unsigned rsr_2() {
-  return __builtin_arm_rsr("cp0:1:c2:c3:4");
+  return __builtin_arm_rsr("cp0:1:c15:c15:4");
 }
 
 void *rsrp_2() {
@@ -73,13 +73,25 @@ void *rsrp_3() {
 }
 
 unsigned long rsr64_3() {
-  return __builtin_arm_rsr64("cp0:1:c2");
+  return __builtin_arm_rsr64("cp0:1:c15");
 }
 
 unsigned rsr_4() {
   return __builtin_arm_rsr("0:1:2:3:4"); //expected-error {{invalid special 
register for builtin}}
 }
 
+unsigned rsr_5() {
+  return __builtin_arm_rsr("cp0:1:c2:c3:8"); //expected-error {{invalid 
special register for builtin}}
+}
+
+unsigned rsr_6() {
+  return __builtin_arm_rsr("cp0:8:c1:c2:3"); //expected-error {{invalid 
special register for builtin}}
+}
+
+unsigned rsr_7() {
+  return __builtin_arm_rsr("cp0:1:c16:c16:2"); //expected-error {{invalid 
special register for builtin}}
+}
+
 void *rsrp_4() {
   return __builtin_arm_rsrp("0:1:2:3:4"); //expected-error {{invalid special 
register for builtin}}
 }
@@ -87,3 +99,11 @@ void *rsrp_

[PATCH] D26868: Sema: As of MSVC 2015, a user-declared move operation causes the deletion of both copy operations.

2016-11-18 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: rnk, rsmith.
pcc added a subscriber: cfe-commits.

https://reviews.llvm.org/D26868

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -99,23 +99,39 @@
 namespace PR11826 {
   struct pair {
 pair(int v) { }
+#if _MSC_VER >= 1900
+void operator=(pair&& rhs) { } // expected-note {{copy constructor is 
implicitly deleted because 'pair' has a user-declared move assignment operator}}
+#else
 void operator=(pair&& rhs) { }
+#endif
   };
   void f() {
 pair p0(3);
+#if _MSC_VER >= 1900
+pair p = p0; // expected-error {{call to implicitly-deleted copy 
constructor of 'PR11826::pair'}}
+#else
 pair p = p0;
+#endif
   }
 }
 
 namespace PR11826_for_symmetry {
   struct pair {
 pair(int v) { }
+#if _MSC_VER >= 1900
+pair(pair&& rhs) { } // expected-note {{copy assignment operator is 
implicitly deleted because 'pair' has a user-declared move constructor}}
+#else
 pair(pair&& rhs) { }
+#endif
   };
   void f() {
 pair p0(3);
 pair p(4);
+#if _MSC_VER >= 1900
+p = p0; // expected-error {{object of type 'PR11826_for_symmetry::pair' 
cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
 p = p0;
+#endif
   }
 }
 
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6711,10 +6711,15 @@
   (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
 CXXMethodDecl *UserDeclaredMove = nullptr;
 
-// In Microsoft mode, a user-declared move only causes the deletion of the
-// corresponding copy operation, not both copy operations.
+// In Microsoft mode up to MSVC 2013, a user-declared move only causes the
+// deletion of the corresponding copy operation, not both copy operations.
+// MSVC 2015 has adopted the standards conforming behavior.
+bool DeletesOnlyMatchingCopy =
+getLangOpts().MSVCCompat &&
+!getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2015);
+
 if (RD->hasUserDeclaredMoveConstructor() &&
-(!getLangOpts().MSVCCompat || CSM == CXXCopyConstructor)) {
+(!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
   if (!Diagnose) return true;
 
   // Find any user-declared move constructor.
@@ -6726,7 +6731,7 @@
   }
   assert(UserDeclaredMove);
 } else if (RD->hasUserDeclaredMoveAssignment() &&
-   (!getLangOpts().MSVCCompat || CSM == CXXCopyAssignment)) {
+   (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
   if (!Diagnose) return true;
 
   // Find any user-declared move assignment operator.


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -99,23 +99,39 @@
 namespace PR11826 {
   struct pair {
 pair(int v) { }
+#if _MSC_VER >= 1900
+void operator=(pair&& rhs) { } // expected-note {{copy constructor is implicitly deleted because 'pair' has a user-declared move assignment operator}}
+#else
 void operator=(pair&& rhs) { }
+#endif
   };
   void f() {
 pair p0(3);
+#if _MSC_VER >= 1900
+pair p = p0; // expected-error {{call to implicitly-deleted copy constructor of 'PR11826::pair'}}
+#else
 pair p = p0;
+#endif
   }
 }
 
 namespace PR11826_for_symmetry {
   struct pair {
 pair(int v) { }
+#if _MSC_VER >= 1900
+pair(pair&& rhs) { } // expected-note {{copy assignment operator is implicitly deleted because 'pair' has a user-declared move constructor}}
+#else
 pair(pair&& rhs) { }
+#endif
   };
   void f() {
 pair p0(3);
 pair p(4);
+#if _MSC_VER >= 1900
+p = p0; // expected-error {{object of type 'PR11826_for_symmetry::pair' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
 p = p0;
+#endif
   }
 }
 
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6711,10 +6711,15 @@
   (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
 CXXMethodDecl *UserDeclaredMove = nullptr;
 
-// In Microsoft mode, a user-declared move only causes the deletion of the
-// corresponding copy operation, not both copy operations.
+// In Microsoft mode up to MSVC 2013, a user-declared move only causes the
+// deletion of the corresponding copy operation, not both copy operations.
+// MSVC 2015 has adopted the standards conforming behavior.
+bool DeletesOnlyMatchingCopy =
+getL

[PATCH] D26816: [libcxx] [test] Fix non-Standard assumptions when testing sample().

2016-11-18 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT marked an inline comment as done.
STL_MSFT added a comment.

Added the requested comment, will commit.




Comment at: 
test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp:74
   assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, oa + os, oa1));
+  LIBCPP_ASSERT(std::equal(oa, oa + os, oa1));
   end = std::sample(PopulationIterator(ia),

EricWF wrote:
> Please add a comment here explaining that the algorithm is non-reproducable.
Adding:
  // sample() is deterministic but non-reproducible;
  // its results can vary between implementations.



https://reviews.llvm.org/D26816



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


[libcxx] r287383 - [libcxx] [test] D26816: Fix non-Standard assumptions when testing sample().

2016-11-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Nov 18 15:54:43 2016
New Revision: 287383

URL: http://llvm.org/viewvc/llvm-project?rev=287383&view=rev
Log:
[libcxx] [test] D26816: Fix non-Standard assumptions when testing sample().

sample() isn't specified with a reproducible algorithm, so expecting
exact output is non-Standard. Mark those tests with LIBCPP_ASSERT.

In test_small_population(), we're guaranteed to get all of the elements,
but not necessarily in their original order. When PopulationCategory is
forward, we're guaranteed stability (and can therefore test equal()).
Otherwise, we can only test is_permutation(). (As it happens, both libcxx
and MSVC's STL provide stability in this scenario for input-only iterators.)

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp?rev=287383&r1=287382&r2=287383&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.pass.cpp
 Fri Nov 18 15:54:43 2016
@@ -19,9 +19,11 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "test_iterators.h"
+#include "test_macros.h"
 
 struct ReservoirSampleExpectations {
   enum { os = 4 };
@@ -60,19 +62,23 @@ void test() {
   const unsigned os = Expectations::os;
   SampleItem oa[os];
   const int *oa1 = Expectations::oa1;
+  ((void)oa1); // Prevent unused warning
   const int *oa2 = Expectations::oa2;
+  ((void)oa2); // Prevent unused warning
   std::minstd_rand g;
   SampleIterator end;
   end = std::sample(PopulationIterator(ia),
   PopulationIterator(ia + is),
   SampleIterator(oa), os, g);
   assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, oa + os, oa1));
+  // sample() is deterministic but non-reproducible;
+  // its results can vary between implementations.
+  LIBCPP_ASSERT(std::equal(oa, oa + os, oa1));
   end = std::sample(PopulationIterator(ia),
   PopulationIterator(ia + is),
   SampleIterator(oa), os, std::move(g));
   assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, oa + os, oa2));
+  LIBCPP_ASSERT(std::equal(oa, oa + os, oa2));
 }
 
 template  class PopulationIteratorType, class 
PopulationItem,
@@ -122,7 +128,12 @@ void test_small_population() {
   PopulationIterator(ia + is),
   SampleIterator(oa), os, g);
   assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, end.base(), oa1));
+  typedef typename std::iterator_traits::iterator_category 
PopulationCategory;
+  if (std::is_base_of::value) {
+assert(std::equal(oa, end.base(), oa1));
+  } else {
+assert(std::is_permutation(oa, end.base(), oa1));
+  }
 }
 
 int main() {


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


[libcxx] r287381 - [libcxx] [test] D26813: allocator is non-Standard.

2016-11-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Nov 18 15:54:31 2016
New Revision: 287381

URL: http://llvm.org/viewvc/llvm-project?rev=287381&view=rev
Log:
[libcxx] [test] D26813: allocator is non-Standard.

N4582 17.6.3.5 [allocator.requirements] says that allocators are given
cv-unqualified object types, and N4582 20.9.9 [default.allocator]
implies that allocator is ill-formed (due to colliding
address() overloads). Therefore, tests for allocator
should be marked as libcxx-specific (if not removed outright).

Modified:

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp?rev=287381&r1=287380&r2=287381&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
 Fri Nov 18 15:54:31 2016
@@ -16,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 void test_max(size_t count)
 {
@@ -27,23 +29,19 @@ void test_max(size_t count)
 }
 }
 
-int main()
+template 
+void test()
 {
-{  // Bug 26812 -- allocating too large
-typedef double T;
-std::allocator a;
-test_max (a.max_size() + 1);// just barely too large
-test_max (a.max_size() * 2);// significantly too 
large
-test_max (((size_t) -1) / sizeof(T) + 1);   // multiply will 
overflow
-test_max ((size_t) -1); // way too large
-}
+// Bug 26812 -- allocating too large
+std::allocator a;
+test_max (a.max_size() + 1);// just barely too large
+test_max (a.max_size() * 2);// significantly too large
+test_max (((size_t) -1) / sizeof(T) + 1);   // multiply will overflow
+test_max ((size_t) -1); // way too large
+}
 
-{
-typedef const double T;
-std::allocator a;
-test_max (a.max_size() + 1);// just barely too large
-test_max (a.max_size() * 2);// significantly too 
large
-test_max (((size_t) -1) / sizeof(T) + 1);   // multiply will 
overflow
-test_max ((size_t) -1); // way too large
-}
+int main()
+{
+test();
+LIBCPP_ONLY(test());
 }

Modified: 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp?rev=287381&r1=287380&r2=287381&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
 Fri Nov 18 15:54:31 2016
@@ -32,6 +32,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 static_assert((std::is_same::size_type, 
std::size_t>::value), "");
@@ -45,7 +47,7 @@ int main()
 std::allocator >::value), "");
 
 static_assert((std::is_same::is_always_equal, 
std::true_type>::value), "");
-static_assert((std::is_same::is_always_equal, 
std::true_type>::value), "");
+LIBCPP_STATIC_ASSERT((std::is_same::is_always_equal, std::true_type>::value), "");
 
 std::allocator a;
 std::allocator a2 = a;


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


[libcxx] r287382 - [libcxx] [test] D26815: Fix an assumption about the state of moved-from std::functions.

2016-11-18 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Nov 18 15:54:38 2016
New Revision: 287382

URL: http://llvm.org/viewvc/llvm-project?rev=287382&view=rev
Log:
[libcxx] [test] D26815: Fix an assumption about the state of moved-from 
std::functions.

The Standard doesn't provide any guarantees beyond "valid but unspecified" for
moved-from std::functions. libcxx moves from small targets and leaves them
there, while MSVC's STL empties out the source. Mark these assertions as
libcxx-specific.

Modified:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp?rev=287382&r1=287381&r2=287382&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
 Fri Nov 18 15:54:38 2016
@@ -132,7 +132,7 @@ int main()
 assert(A::count == 1);
 assert(f2.target() == nullptr);
 assert(f2.target());
-assert(f.target()); // f is unchanged because the target is small
+LIBCPP_ASSERT(f.target()); // f is unchanged because the target 
is small
 }
 {
 // Test that moving a function constructed from a function pointer
@@ -146,7 +146,7 @@ int main()
 std::function f2(std::move(f));
 assert(f2.target() == nullptr);
 assert(f2.target());
-assert(f.target()); // f is unchanged because the target is small
+LIBCPP_ASSERT(f.target()); // f is unchanged because the target 
is small
 }
 #endif  // TEST_STD_VER >= 11
 }


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


  1   2   >