[PATCH] D29986: Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

2017-02-24 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Sorry for the noise. I was expecting some more formal approval in the usual 
form of "Ready to land" but if you think it is OK I will commit it shortly.

Regards.


https://reviews.llvm.org/D29986



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


r296098 - Add clazy to external Clang examples page

2017-02-24 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Fri Feb 24 02:29:46 2017
New Revision: 296098

URL: http://llvm.org/viewvc/llvm-project?rev=296098&view=rev
Log:
Add clazy to external Clang examples page

Reviewers: silvas, rizsotto.mailinglist, sergio.martins

Reviewed By: rizsotto.mailinglist

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

Modified:
cfe/trunk/docs/ExternalClangExamples.rst

Modified: cfe/trunk/docs/ExternalClangExamples.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ExternalClangExamples.rst?rev=296098&r1=296097&r2=296098&view=diff
==
--- cfe/trunk/docs/ExternalClangExamples.rst (original)
+++ cfe/trunk/docs/ExternalClangExamples.rst Fri Feb 24 02:29:46 2017
@@ -85,3 +85,8 @@ List of projects and tools
 errors, fixit hints).  See also ``_ for
 step-by-step instructions."
 
+``_
+   "clazy is a compiler plugin which allows clang to understand Qt semantics.
+   You get more than 50 Qt related compiler warnings, ranging from unneeded
+   memory allocations to misusage of API, including fix-its for automatic
+   refactoring."


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


[PATCH] D29986: Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

2017-02-24 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296099: Fix crash when an incorrect redeclaration only 
differs in __unaligned type… (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D29986?vs=88514&id=89617#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29986

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/Sema/unaligned-qualifier.c


Index: cfe/trunk/test/Sema/unaligned-qualifier.c
===
--- cfe/trunk/test/Sema/unaligned-qualifier.c
+++ cfe/trunk/test/Sema/unaligned-qualifier.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions
+
+int __unaligned * p1; // expected-note {{previous definition is here}}
+int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int 
*' vs '__unaligned int *'}}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8077,7 +8077,8 @@
 // mismatch.
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
-LQuals.getObjCLifetime() != RQuals.getObjCLifetime())
+LQuals.getObjCLifetime() != RQuals.getObjCLifetime() ||
+LQuals.hasUnaligned() != RQuals.hasUnaligned())
   return QualType();
 
 // Exactly one GC qualifier difference is allowed: __strong is


Index: cfe/trunk/test/Sema/unaligned-qualifier.c
===
--- cfe/trunk/test/Sema/unaligned-qualifier.c
+++ cfe/trunk/test/Sema/unaligned-qualifier.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions
+
+int __unaligned * p1; // expected-note {{previous definition is here}}
+int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int *' vs '__unaligned int *'}}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8077,7 +8077,8 @@
 // mismatch.
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
-LQuals.getObjCLifetime() != RQuals.getObjCLifetime())
+LQuals.getObjCLifetime() != RQuals.getObjCLifetime() ||
+LQuals.hasUnaligned() != RQuals.hasUnaligned())
   return QualType();
 
 // Exactly one GC qualifier difference is allowed: __strong is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296099 - Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

2017-02-24 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Fri Feb 24 02:41:09 2017
New Revision: 296099

URL: http://llvm.org/viewvc/llvm-project?rev=296099&view=rev
Log:
Fix crash when an incorrect redeclaration only differs in __unaligned 
type-qualifier

Fix an assertion that is hit when a redeclaration with differing types only
differs in the unaligned type-qualifier.

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


Added:
cfe/trunk/test/Sema/unaligned-qualifier.c
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=296099&r1=296098&r2=296099&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 24 02:41:09 2017
@@ -8077,7 +8077,8 @@ QualType ASTContext::mergeTypes(QualType
 // mismatch.
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
-LQuals.getObjCLifetime() != RQuals.getObjCLifetime())
+LQuals.getObjCLifetime() != RQuals.getObjCLifetime() ||
+LQuals.hasUnaligned() != RQuals.hasUnaligned())
   return QualType();
 
 // Exactly one GC qualifier difference is allowed: __strong is

Added: cfe/trunk/test/Sema/unaligned-qualifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unaligned-qualifier.c?rev=296099&view=auto
==
--- cfe/trunk/test/Sema/unaligned-qualifier.c (added)
+++ cfe/trunk/test/Sema/unaligned-qualifier.c Fri Feb 24 02:41:09 2017
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions
+
+int __unaligned * p1; // expected-note {{previous definition is here}}
+int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int 
*' vs '__unaligned int *'}}


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


Re: [PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-24 Thread Manuel Klimek via cfe-commits
On Thu, Feb 23, 2017 at 10:40 PM Sam McCall  wrote:

>
>
> On Feb 23, 2017 8:48 PM, "Haojian Wu via Phabricator" <
> revi...@reviews.llvm.org> wrote:
>
> hokein added inline comments.
>
>
> 
> Comment at:
> unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:40
> +  void reportSymbols(llvm::StringRef FileName,
> + SymbolInfo::SignalMap NewSymbols) override {
> +for (const auto &Entry : NewSymbols)
> 
> A new catch: `NewSymbols` should be passed by reference, otherwise a copy
> will be generated.
>
> I did actually intend by-value here, FindAllSymbols no longer needs the
> map once it's reported, so it is moved rather than copied (see the end of
> FindAllSymbols.cpp)
>
> If this is too surprising, I can change it.
>

I'd say that that couples the call site and the function too much.


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


[clang-tools-extra] r296100 - [clang-tidy] Fix readability-redundant-declaration false positive

2017-02-24 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Fri Feb 24 03:02:44 2017
New Revision: 296100

URL: http://llvm.org/viewvc/llvm-project?rev=296100&view=rev
Log:
[clang-tidy] Fix readability-redundant-declaration false positive

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp?rev=296100&r1=296099&r2=296100&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp 
Fri Feb 24 03:02:44 2017
@@ -19,7 +19,10 @@ namespace tidy {
 namespace readability {
 
 void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(namedDecl(anyOf(varDecl(), functionDecl())).bind("Decl"),
+  auto UnlessDefinition = unless(isDefinition());
+  Finder->addMatcher(namedDecl(anyOf(varDecl(UnlessDefinition),
+ functionDecl(UnlessDefinition)))
+ .bind("Decl"),
  this);
 }
 
@@ -41,9 +44,6 @@ void RedundantDeclarationCheck::check(co
 
   bool MultiVar = false;
   if (const auto *VD = dyn_cast(D)) {
-if (VD->getPreviousDecl()->getStorageClass() == SC_Extern &&
-VD->getStorageClass() != SC_Extern)
-  return;
 // Is this a multivariable declaration?
 for (const auto Other : VD->getDeclContext()->decls()) {
   if (Other != D && Other->getLocStart() == VD->getLocStart()) {
@@ -51,10 +51,6 @@ void RedundantDeclarationCheck::check(co
 break;
   }
 }
-  } else {
-const auto *FD = cast(D);
-if (FD->isThisDeclarationADefinition())
-  return;
   }
 
   SourceLocation EndLoc = Lexer::getLocForEndOfToken(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp?rev=296100&r1=296099&r2=296100&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-declaration.cpp 
Fri Feb 24 03:02:44 2017
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s readability-redundant-declaration %t
 
 extern int Xyz;
-extern int Xyz;
+extern int Xyz; // Xyz
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Xyz' declaration 
[readability-redundant-declaration]
-// CHECK-FIXES: {{^}}{{$}}
+// CHECK-FIXES: {{^}}// Xyz{{$}}
 int Xyz = 123;
 
 extern int A;
@@ -12,19 +12,25 @@ extern int A, B;
 // CHECK-FIXES: {{^}}extern int A, B;{{$}}
 
 extern int Buf[10];
-extern int Buf[10];
+extern int Buf[10]; // Buf[10]
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Buf' declaration
-// CHECK-FIXES: {{^}}{{$}}
+// CHECK-FIXES: {{^}}// Buf[10]{{$}}
 
 static int f();
-static int f();
+static int f(); // f
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'f' declaration
-// CHECK-FIXES: {{^}}{{$}}
+// CHECK-FIXES: {{^}}// f{{$}}
 static int f() {}
 
 // Original check crashed for the code below.
 namespace std {
-  typedef decltype(sizeof(0)) size_t;
+typedef decltype(sizeof(0)) size_t;
 }
-void* operator new(std::size_t) __attribute__((__externally_visible__));
-void* operator new[](std::size_t) __attribute__((__externally_visible__));
+void *operator new(std::size_t) __attribute__((__externally_visible__));
+void *operator new[](std::size_t) __attribute__((__externally_visible__));
+
+// Don't warn about static member definition.
+struct C {
+  static int I;
+};
+int C::I;


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


[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-24 Thread Javed Absar via Phabricator via cfe-commits
javed.absar created this revision.

This patch enables the msvc pragma section to choose whether zero initialized 
variables are to be placed in data_seg or bss_seg. The current 
implementation  ignores bss_seg directive for variables that are initialized 
(i.e. it does not check if the initialization is, in fact, to all zeros). 
This patch now allows that. The variables are now placed in named bss_seg but 
only so If (a) the initialization is all zeros; AND (b) ''-falways-use-bss flag 
is set'. In other words, current functionality is not impacted and a useful 
feature is provided to users.


https://reviews.llvm.org/D30326

Files:
  include/clang/AST/APValue.h
  include/clang/AST/Expr.h
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/AST/APValue.cpp
  lib/AST/Expr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCXX/zi-sections.cpp

Index: test/CodeGenCXX/zi-sections.cpp
===
--- /dev/null
+++ test/CodeGenCXX/zi-sections.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ZI-DATA
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -falways-use-bss -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ZI-BSS
+// Test that when '-falways-use-bss' is specified, variables initialized with zero are assigned to bss_seg.
+#pragma bss_seg(".bss.1")
+#pragma data_seg(".data.1")
+extern "C" {
+short ShortZero = 0;
+short ShortTwo = 2;
+short ShortMinusTwo = -2;
+short ShortUnInit;
+
+int IntZero = 0;
+int IntTwo = 2;
+int IntMinusTwo = -2;
+int IntUnInit;
+
+float FloatZero = 0.0;
+float FloatMinusZero = -0.0;
+float FloatTwo = 2.0;
+float FloatUnInit;
+
+double DoubleZero = 0.0;
+double DoubleMinusZero = -0.0;
+double DoubleTwo = 2.0;
+double DoubleUnInit;
+
+struct S {
+  int x, y;
+  int z;
+};
+struct S StructZero = { 0, 0, 0 };
+struct S StructTwo = { 0, 0, 2};
+struct S StructMinusTwo = {0, -2, 0};
+struct S StructUnInit;
+
+int ArrayZero[] = {0, 0, 0};
+int ArrayTwo[] = {0, 2, 0};
+int ArrayMinusTwo[] = {0, -2, 0};
+int ArrayUnInit;
+// CHECK-ZI-DATA: @ShortZero = global i16 0, section ".data.1", align 2
+// CHECK-ZI-BSS: @ShortZero = global i16 0, section ".bss.1", align 2
+// CHECK: @ShortTwo = global i16 2, section ".data.1", align 2
+// CHECK: @ShortMinusTwo = global i16 -2, section ".data.1", align 2
+// CHECK: @ShortUnInit = global i16 0, section ".bss.1", align 2
+//
+// CHECK-ZI-DATA: @IntZero = global i32 0, section ".data.1", align 4
+// CHECK-ZI-BSS: @IntZero = global i32 0, section ".bss.1", align 4
+// CHECK: @IntTwo = global i32 2, section ".data.1", align 4
+// CHECK: @IntMinusTwo = global i32 -2, section ".data.1", align 4
+// CHECK: @IntUnInit = global i32 0, section ".bss.1", align 4
+//
+// CHECK-ZI-DATA: @FloatZero = global float 0.00e+00, section ".data.1", align 4
+// CHECK-ZI-BSS: @FloatZero = global float 0.00e+00, section ".bss.1", align 4
+// CHECK: @FloatMinusZero = global float -0.00e+00, section ".data.1", align 4
+// CHECK: @FloatTwo = global float 2.00e+00, section ".data.1", align 4
+// CHECK: @FloatUnInit = global float 0.00e+00, section ".bss.1", align 4
+//
+// CHECK-ZI-DATA: @DoubleZero = global double 0.00e+00, section ".data.1", align 8
+// CHECK-ZI-BSS: @DoubleZero = global double 0.00e+00, section ".bss.1", align 8
+// CHECK: @DoubleMinusZero = global double -0.00e+00, section ".data.1", align 8
+// CHECK: @DoubleTwo = global double 2.00e+00, section ".data.1", align 8
+// CHECK: @DoubleUnInit = global double 0.00e+00, section ".bss.1", align 8
+//
+// CHECK-ZI-DATA: @StructZero = global %struct.S zeroinitializer, section ".data.1", align 4
+// CHECK-ZI-BSS: @StructZero = global %struct.S zeroinitializer, section ".bss.1", align 4
+// CHECK: @StructTwo = global %struct.S { i32 0, i32 0, i32 2 }, section ".data.1", align 4
+// CHECK: @StructMinusTwo = global %struct.S { i32 0, i32 -2, i32 0 }, section ".data.1", align 4
+// CHECK: @StructUnInit = global %struct.S zeroinitializer, section ".data.1", align 4
+//
+// CHECK-ZI-DATA: @ArrayZero = global [3 x i32] zeroinitializer, section ".data.1", align 4
+// CHECK-ZI-BSS: @ArrayZero = global [3 x i32] zeroinitializer, section ".bss.1", align 4
+// CHECK: @ArrayTwo = global [3 x i32] [i32 0, i32 2, i32 0], section ".data.1", align 4
+// CHECK: @ArrayMinusTwo = global [3 x i32] [i32 0, i32 -2, i32 0], section ".data.1", align 4
+// CHECK: @ArrayUnInit = global i32 0, section ".bss.1", align 4
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10736,6 +10736,18 @@
AttrEnd.isValid() ? AttrEnd : IdentLoc);
 }
 
+/// Check if initialization is to zero
+bool Sema

[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

2017-02-24 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.

Don't warn about unused lambda captures that involve copying a
value of a type that cannot be trivially copied and destroyed.

Fixes PR31977


https://reviews.llvm.org/D30327

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/warn-unused-lambda-capture.cpp

Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -1,10 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++1z %s
 
 class NonTrivialConstructor {
 public:
   NonTrivialConstructor() {}
 };
 
+class NonTrivialCopyConstructor {
+public:
+  NonTrivialCopyConstructor() = default;
+  NonTrivialCopyConstructor(const NonTrivialCopyConstructor &) {}
+};
+
 class NonTrivialDestructor {
 public:
   ~NonTrivialDestructor() {}
@@ -57,14 +63,64 @@
 auto explicit_by_value_used = [i] { return i + 1; };
 auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
   };
+
+  Trivial trivial;
+  auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda capture 'trivial' is not used}}
+
+  NonTrivialConstructor cons;
+  auto explicit_by_value_non_trivial_constructor = [cons] {}; // expected-warning{{lambda capture 'cons' is not used}}
+
+  NonTrivialCopyConstructor copy_cons;
+  auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {};
+
+  NonTrivialDestructor dest;
+  auto explicit_by_value_non_trivial_destructor = [dest] {};
 }
 
-class Foo
-{
+class TrivialThis : Trivial {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {}; // expected-warning{{lambda capture 'this' is not used}}
+  }
+  int i;
+};
+
+class NonTrivialConstructorThis : NonTrivialConstructor {
   void test() {
 auto explicit_this_used = [this] { return i; };
 auto explicit_this_used_void = [this] { (void)this; };
 auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {}; // expected-warning{{lambda capture 'this' is not used}}
+  }
+  int i;
+};
+
+class NonTrivialCopyConstructorThis : NonTrivialCopyConstructor {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {};
+  }
+  int i;
+};
+
+class NonTrivialDestructorThis : NonTrivialDestructor {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {};
   }
   int i;
 };
@@ -107,6 +163,18 @@
 auto explicit_by_value_used = [i] { return i + 1; };
 auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
   };
+
+  Trivial trivial;
+  auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda capture 'trivial' is not used}}
+
+  NonTrivialConstructor cons;
+  auto explicit_by_value_non_trivial_constructor = [cons] {}; // expected-warning{{lambda capture 'cons' is not used}}
+
+  NonTrivialCopyConstructor copy_cons;
+  auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {};
+
+  NonTrivialDestructor dest;
+  auto explicit_by_value_non_trivial_destructor = [dest] {};
 }
 
 void test_use_template() {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1438,13 +1438,30 @@
   llvm_unreachable("Unknown implicit capture style");
 }
 
-void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture &From) {
+bool Sema::CaptureHasSideEffects(const LambdaScopeInfo::Capture &From) {
   if (!From.isVLATypeCapture()) {
 Expr *Init = F

[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.

2017-02-24 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.h:21
+/// std::random_shuffle will be removed as of C++17. This check will find and
+/// replace all occurences of std::random_shuffle with std::shuffle.
+///

Typo - should be occurrences.
Same in 2 other places.


https://reviews.llvm.org/D30158



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


[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.

https://reviews.llvm.org/D30328

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/ClangChangeNamespace.cpp
  test/change-namespace/Inputs/fake-std.h
  test/change-namespace/white-list.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -37,8 +37,10 @@
 clang::FileID ID = Context.createInMemoryFile(FileName, Code);
 
 std::map FileToReplacements;
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
 change_namespace::ChangeNamespaceTool NamespaceTool(
-OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+&FileToReplacements);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers(&Finder);
 std::unique_ptr Factory =
Index: test/change-namespace/white-list.cpp
===
--- /dev/null
+++ test/change-namespace/white-list.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" %s -- | sed 's,// CHECK.*,,' | FileCheck %s
+
+#include "Inputs/fake-std.h"
+
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
+namespace na {
+namespace nb {
+void f() {
+  std::STD x1;
+  STD x2;
+// CHECK: {{^}}  std::STD x1;{{$}}
+// CHECK-NEXT: {{^}}  STD x2;{{$}}
+}
+// CHECK: } // namespace y
+// CHECK-NEXT: } // namespace x
+}
+}
Index: test/change-namespace/Inputs/fake-std.h
===
--- /dev/null
+++ test/change-namespace/Inputs/fake-std.h
@@ -0,0 +1,5 @@
+namespace std {
+  class STD {};
+}
+
+using namespace std;
Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -73,6 +73,10 @@
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+// Patterns of symbol names whose references are not expected to be updated when
+// changing namespaces around them.
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
+
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
@@ -82,7 +86,8 @@
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
+  OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+  &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -50,6 +50,7 @@
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@
   // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
   // been processed so that we don't handle them twice.
   llvm::SmallPtrSet ProcessedFuncRefs;
+  // Patterns of symbol names whose references are not expected to be updated
+  // when changing namespaces around them.
+  std::vector WhiteListedSymbolRegexes;
 };
 
 } // namespace change_namespace
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -290,6 +290,7 @@
 
 ChangeNamespaceTool::ChangeNamespaceTool(
 llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+llvm::ArrayRef WhiteListedSymbolPatterns,
 std::map *FileToReplacements,
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
@@ -308,6 +309,11 @@
   }
   DiffOldNamespace = joinNamespaces(OldNsSplitted);
   DiffNewNamespace = joinNamespaces(NewNsSplitted);
+
+  for (const char *Pattern : WhiteListedSymbolPatterns) {
+llvm::errs() << "Whitelisting " << Pattern << "\n";
+WhiteListedSymbolRegexes.emplace_back(Pattern);
+  }
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -736,6 +742,

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 89627.
ioeric added a comment.

- removed a debug message


https://reviews.llvm.org/D30328

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/ClangChangeNamespace.cpp
  test/change-namespace/Inputs/fake-std.h
  test/change-namespace/white-list.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -37,8 +37,10 @@
 clang::FileID ID = Context.createInMemoryFile(FileName, Code);
 
 std::map FileToReplacements;
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
 change_namespace::ChangeNamespaceTool NamespaceTool(
-OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+&FileToReplacements);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers(&Finder);
 std::unique_ptr Factory =
Index: test/change-namespace/white-list.cpp
===
--- /dev/null
+++ test/change-namespace/white-list.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" %s -- | sed 's,// CHECK.*,,' | FileCheck %s
+
+#include "Inputs/fake-std.h"
+
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
+namespace na {
+namespace nb {
+void f() {
+  std::STD x1;
+  STD x2;
+// CHECK: {{^}}  std::STD x1;{{$}}
+// CHECK-NEXT: {{^}}  STD x2;{{$}}
+}
+// CHECK: } // namespace y
+// CHECK-NEXT: } // namespace x
+}
+}
Index: test/change-namespace/Inputs/fake-std.h
===
--- /dev/null
+++ test/change-namespace/Inputs/fake-std.h
@@ -0,0 +1,5 @@
+namespace std {
+  class STD {};
+}
+
+using namespace std;
Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -73,6 +73,10 @@
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+// Patterns of symbol names whose references are not expected to be updated when
+// changing namespaces around them.
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
+
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
@@ -82,7 +86,8 @@
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
+  OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+  &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -50,6 +50,7 @@
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@
   // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
   // been processed so that we don't handle them twice.
   llvm::SmallPtrSet ProcessedFuncRefs;
+  // Patterns of symbol names whose references are not expected to be updated
+  // when changing namespaces around them.
+  std::vector WhiteListedSymbolRegexes;
 };
 
 } // namespace change_namespace
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -290,6 +290,7 @@
 
 ChangeNamespaceTool::ChangeNamespaceTool(
 llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+llvm::ArrayRef WhiteListedSymbolPatterns,
 std::map *FileToReplacements,
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
@@ -308,6 +309,9 @@
   }
   DiffOldNamespace = joinNamespaces(OldNsSplitted);
   DiffNewNamespace = joinNamespaces(NewNsSplitted);
+
+  for (const char *Pattern : WhiteListedSymbolPatterns)
+WhiteListedSymbolRegexes.emplace_back(Pattern);
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -736,6 +740

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: change-namespace/tool/ClangChangeNamespace.cpp:78
+// changing namespaces around them.
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
+

Maybe consider create a command-line option for it? It will make the tool more 
pluggable IMO.


https://reviews.llvm.org/D30328



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


Re: [PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-24 Thread Sam McCall via cfe-commits
That's two votes for "this is too surprising" - changed.

https://imgflip.com/i/1k93rm
https://68.media.tumblr.com/8db2fe0a6f84ff128157a2b615f519bf/tumblr_inline_nenq4hMoQA1sb080b.gif

On Fri, Feb 24, 2017 at 9:54 AM, Manuel Klimek  wrote:

> On Thu, Feb 23, 2017 at 10:40 PM Sam McCall  wrote:
>
>>
>>
>> On Feb 23, 2017 8:48 PM, "Haojian Wu via Phabricator" <
>> revi...@reviews.llvm.org> wrote:
>>
>> hokein added inline comments.
>>
>>
>> 
>> Comment at: unittests/include-fixer/find-all-symbols/
>> FindAllSymbolsTests.cpp:40
>> +  void reportSymbols(llvm::StringRef FileName,
>> + SymbolInfo::SignalMap NewSymbols) override {
>> +for (const auto &Entry : NewSymbols)
>> 
>> A new catch: `NewSymbols` should be passed by reference, otherwise a copy
>> will be generated.
>>
>> I did actually intend by-value here, FindAllSymbols no longer needs the
>> map once it's reported, so it is moved rather than copied (see the end of
>> FindAllSymbols.cpp)
>>
>> If this is too surprising, I can change it.
>>
>
> I'd say that that couples the call site and the function too much.
>
>
>>
>>
>>
>>
>>
>> https://reviews.llvm.org/D30210
>>
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 89632.
sammccall added a comment.

Report symbols by reference.


https://reviews.llvm.org/D30210

Files:
  include-fixer/InMemorySymbolIndex.cpp
  include-fixer/InMemorySymbolIndex.h
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndex.h
  include-fixer/SymbolIndexManager.cpp
  include-fixer/YamlSymbolIndex.cpp
  include-fixer/YamlSymbolIndex.h
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/Inputs/merge/a.yaml
  test/include-fixer/Inputs/merge/b.yaml
  test/include-fixer/merge.test
  unittests/include-fixer/IncludeFixerTest.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -19,6 +19,7 @@
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
@@ -31,34 +32,39 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
+class TestSymbolReporter : public SymbolReporter {
 public:
   ~TestSymbolReporter() override {}
 
-  void reportSymbol(llvm::StringRef FileName,
-const SymbolInfo &Symbol) override {
-Symbols.push_back(Symbol);
+  void reportSymbols(llvm::StringRef FileName,
+ const SymbolInfo::SignalMap &NewSymbols) override {
+for (const auto &Entry : NewSymbols)
+  Symbols[Entry.first] += Entry.second;
   }
 
   bool hasSymbol(const SymbolInfo &Symbol) const {
-for (const auto &S : Symbols) {
-  if (S == Symbol)
-return true;
-}
-return false;
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Seen > 0;
+  }
+
+  bool hasUse(const SymbolInfo &Symbol) const {
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Used > 0;
   }
 
 private:
-  std::vector Symbols;
+  SymbolInfo::SignalMap Symbols;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); }
+
+  bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
@@ -88,7 +94,7 @@
 InMemoryFileSystem->addFile(InternalHeader, 0,
 llvm::MemoryBuffer::getMemBuffer(InternalCode));
 
-std::unique_ptr Factory(
+std::unique_ptr Factory(
 new FindAllSymbolsActionFactory(&Reporter, &RegexMap));
 
 tooling::ToolInvocation Invocation(
@@ -98,7 +104,7 @@
 std::make_shared());
 
 InMemoryFileSystem->addFile(HeaderName, 0,
-llvm::MemoryBuffer::getMemBuffer(Code));
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 
 std::string Content = "#include\"" + std::string(HeaderName) +
   "\"\n"
@@ -118,6 +124,7 @@
 SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class,
CleanHeader, 2, {});
 #endif // _MSC_VER && __MINGW32__
+Content += "\n" + MainCode.str();
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
@@ -135,49 +142,64 @@
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern int xargc;
   namespace na {
   static bool  = false;
   namespace nb { const long long *; }
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  auto y = &na::nb::;
+  int main() { if (na::) return xargc; }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = Sy

[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks, still LGTM with one nit.




Comment at: include-fixer/find-all-symbols/FindAllSymbols.cpp:262
+  if (Filename != "") {
+Reporter->reportSymbols(Filename, std::move(FileSymbols));
+FileSymbols = {};

We don't need `std::move` right now.


https://reviews.llvm.org/D30210



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


[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 89636.
sammccall added a comment.

Remove redundant std::move


https://reviews.llvm.org/D30210

Files:
  include-fixer/InMemorySymbolIndex.cpp
  include-fixer/InMemorySymbolIndex.h
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndex.h
  include-fixer/SymbolIndexManager.cpp
  include-fixer/YamlSymbolIndex.cpp
  include-fixer/YamlSymbolIndex.h
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/Inputs/merge/a.yaml
  test/include-fixer/Inputs/merge/b.yaml
  test/include-fixer/merge.test
  unittests/include-fixer/IncludeFixerTest.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -19,6 +19,7 @@
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
@@ -31,34 +32,39 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
+class TestSymbolReporter : public SymbolReporter {
 public:
   ~TestSymbolReporter() override {}
 
-  void reportSymbol(llvm::StringRef FileName,
-const SymbolInfo &Symbol) override {
-Symbols.push_back(Symbol);
+  void reportSymbols(llvm::StringRef FileName,
+ const SymbolInfo::SignalMap &NewSymbols) override {
+for (const auto &Entry : NewSymbols)
+  Symbols[Entry.first] += Entry.second;
   }
 
   bool hasSymbol(const SymbolInfo &Symbol) const {
-for (const auto &S : Symbols) {
-  if (S == Symbol)
-return true;
-}
-return false;
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Seen > 0;
+  }
+
+  bool hasUse(const SymbolInfo &Symbol) const {
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Used > 0;
   }
 
 private:
-  std::vector Symbols;
+  SymbolInfo::SignalMap Symbols;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); }
+
+  bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
@@ -88,7 +94,7 @@
 InMemoryFileSystem->addFile(InternalHeader, 0,
 llvm::MemoryBuffer::getMemBuffer(InternalCode));
 
-std::unique_ptr Factory(
+std::unique_ptr Factory(
 new FindAllSymbolsActionFactory(&Reporter, &RegexMap));
 
 tooling::ToolInvocation Invocation(
@@ -98,7 +104,7 @@
 std::make_shared());
 
 InMemoryFileSystem->addFile(HeaderName, 0,
-llvm::MemoryBuffer::getMemBuffer(Code));
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 
 std::string Content = "#include\"" + std::string(HeaderName) +
   "\"\n"
@@ -118,6 +124,7 @@
 SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class,
CleanHeader, 2, {});
 #endif // _MSC_VER && __MINGW32__
+Content += "\n" + MainCode.str();
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
@@ -135,49 +142,64 @@
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern int xargc;
   namespace na {
   static bool  = false;
   namespace nb { const long long *; }
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  auto y = &na::nb::;
+  int main() { if (na::) return xargc; }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(hasUse(Symbol));
 
   Symbol = Symb

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 89637.
ioeric marked an inline comment as done.
ioeric added a comment.

- Make the whitelist an option.


https://reviews.llvm.org/D30328

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/ClangChangeNamespace.cpp
  test/change-namespace/Inputs/fake-std.h
  test/change-namespace/Inputs/white-list.txt
  test/change-namespace/white-list.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -37,8 +37,10 @@
 clang::FileID ID = Context.createInMemoryFile(FileName, Code);
 
 std::map FileToReplacements;
+std::vector WhiteList;
 change_namespace::ChangeNamespaceTool NamespaceTool(
-OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+OldNamespace, NewNamespace, FilePattern, WhiteList,
+&FileToReplacements);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers(&Finder);
 std::unique_ptr Factory =
Index: test/change-namespace/white-list.cpp
===
--- /dev/null
+++ test/change-namespace/white-list.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --whitelist_file %S/Inputs/white-list.txt %s -- | sed 's,// CHECK.*,,' | FileCheck %s
+
+#include "Inputs/fake-std.h"
+
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
+namespace na {
+namespace nb {
+void f() {
+  std::STD x1;
+  STD x2;
+// CHECK: {{^}}  std::STD x1;{{$}}
+// CHECK-NEXT: {{^}}  STD x2;{{$}}
+}
+// CHECK: } // namespace y
+// CHECK-NEXT: } // namespace x
+}
+}
Index: test/change-namespace/Inputs/white-list.txt
===
--- /dev/null
+++ test/change-namespace/Inputs/white-list.txt
@@ -0,0 +1 @@
+^std::.*$
Index: test/change-namespace/Inputs/fake-std.h
===
--- /dev/null
+++ test/change-namespace/Inputs/fake-std.h
@@ -0,0 +1,5 @@
+namespace std {
+  class STD {};
+}
+
+using namespace std;
Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -73,16 +73,43 @@
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+cl::opt WhiteListFile(
+"whitelist_file",
+cl::desc("A file containing regexes of symbol names that are not expected "
+ "to be updated when changing namespaces around them."),
+cl::init(""), cl::cat(ChangeNamespaceCategory));
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;
+  if (!WhiteListFile.empty()) {
+llvm::ErrorOr> File =
+llvm::MemoryBuffer::getFile(WhiteListFile);
+if (!File)
+  return File.getError();
+llvm::StringRef Content = File.get()->getBuffer();
+Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  }
+  return std::vector(Lines.begin(), Lines.end());
+}
+
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
+  llvm::ErrorOr> WhiteListPatterns =
+  GetWhiteListedSymbolPatterns();
+  if (!WhiteListPatterns) {
+llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
+ << WhiteListPatterns.getError().message() << "\n";
+return 1;
+  }
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -50,6 +50,7 @@
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@
   // CallExpr and one as DeclRefExpr), we record al

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

PTAL




Comment at: change-namespace/tool/ClangChangeNamespace.cpp:78
+// changing namespaces around them.
+constexpr const char *WhiteListedSymbolPatterns[] = {"^std::.*$"};
+

hokein wrote:
> Maybe consider create a command-line option for it? It will make the tool 
> more pluggable IMO.
Good idea. Done.


https://reviews.llvm.org/D30328



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


[PATCH] D30157: [analyzer] Improve valist check

2017-02-24 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ValistChecker.cpp:189
+  const auto *EReg = dyn_cast_or_null(Reg);
+  return EReg && VaListModelledAsArray ? EReg->getSuperRegion() : Reg;
+}

I would personally recommend parentheses around EReg and VaListModelledAsArray 
to highlight the precedence.



https://reviews.llvm.org/D30157



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


[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:82
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;

Instead `std::vector`, maybe std::vector is better, 
with that we don't need to do transform stuff in `ChangeNamespaceTool`.



Comment at: test/change-namespace/Inputs/white-list.txt:1
+^std::.*$

As this is only one-line file, I'd create this file in `whitelist` lint test 
like `echo XX > whitelist.txt` to avoid adding a new file in test.



Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:42
 change_namespace::ChangeNamespaceTool NamespaceTool(
-OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+OldNamespace, NewNamespace, FilePattern, WhiteList,
+&FileToReplacements);

`/*WhiteListedSymbolPatterns*/{}` is enough.


https://reviews.llvm.org/D30328



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


[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 89640.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D30328

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/ClangChangeNamespace.cpp
  test/change-namespace/Inputs/fake-std.h
  test/change-namespace/white-list.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -38,7 +38,8 @@
 
 std::map FileToReplacements;
 change_namespace::ChangeNamespaceTool NamespaceTool(
-OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+OldNamespace, NewNamespace, FilePattern,
+/*WhiteListedSymbolPatterns*/ {}, &FileToReplacements);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers(&Finder);
 std::unique_ptr Factory =
Index: test/change-namespace/white-list.cpp
===
--- /dev/null
+++ test/change-namespace/white-list.cpp
@@ -0,0 +1,19 @@
+// RUN: echo "^std::.*$" > %T/white-list.txt
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --whitelist_file %T/white-list.txt %s -- | sed 's,// CHECK.*,,' | FileCheck %s
+
+#include "Inputs/fake-std.h"
+
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
+namespace na {
+namespace nb {
+void f() {
+  std::STD x1;
+  STD x2;
+// CHECK: {{^}}  std::STD x1;{{$}}
+// CHECK-NEXT: {{^}}  STD x2;{{$}}
+}
+// CHECK: } // namespace y
+// CHECK-NEXT: } // namespace x
+}
+}
Index: test/change-namespace/Inputs/fake-std.h
===
--- /dev/null
+++ test/change-namespace/Inputs/fake-std.h
@@ -0,0 +1,5 @@
+namespace std {
+  class STD {};
+}
+
+using namespace std;
Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -73,16 +73,43 @@
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+cl::opt WhiteListFile(
+"whitelist_file",
+cl::desc("A file containing regexes of symbol names that are not expected "
+ "to be updated when changing namespaces around them."),
+cl::init(""), cl::cat(ChangeNamespaceCategory));
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;
+  if (!WhiteListFile.empty()) {
+llvm::ErrorOr> File =
+llvm::MemoryBuffer::getFile(WhiteListFile);
+if (!File)
+  return File.getError();
+llvm::StringRef Content = File.get()->getBuffer();
+Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  }
+  return std::vector(Lines.begin(), Lines.end());
+}
+
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
+  llvm::ErrorOr> WhiteListPatterns =
+  GetWhiteListedSymbolPatterns();
+  if (!WhiteListPatterns) {
+llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
+ << WhiteListPatterns.getError().message() << "\n";
+return 1;
+  }
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -50,6 +50,7 @@
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@
   // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
   // been processed so that we don't handle them twice.
   llvm::SmallPtrSet ProcessedFuncRefs;
+  // Patterns of symbol names whose references are not expected to be updated
+  // when changing namespaces around them.
+  std::vector WhiteListedSymbolRegexes;
 };
 
 } /

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:82
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;

hokein wrote:
> Instead `std::vector`, maybe std::vector is better, 
> with that we don't need to do transform stuff in `ChangeNamespaceTool`.
I'd like `ChangeNamespaceTool` to own the Regex vector and make sure it is not 
shared since Regex is not thread safe. 


https://reviews.llvm.org/D30328



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


[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-02-24 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 89641.
danielmarjamaki added a comment.

Fixed review comment. Broke out function.


Repository:
  rL LLVM

https://reviews.llvm.org/D28278

Files:
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  test/Analysis/uninit-vals-ps.c


Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -57,6 +57,12 @@
   return s.x; // no-warning
 }
 
+void f6(int x) {
+  int a[20];
+  if (x == 25) {}
+  if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a 
garbage value due to array index out of bounds}}
+}
+
 int ret_uninit() {
   int i;
   int *p = &i;
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -35,6 +35,30 @@
 };
 } // end anonymous namespace
 
+static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
+  ProgramStateRef state = C.getState();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  if (!isa(Ex))
+return false;
+
+  SVal Loc = state->getSVal(Ex, LCtx);
+  if (!Loc.isValid())
+return false;
+
+  const MemRegion *MR = Loc.castAs().getRegion();
+  const ElementRegion *ER = dyn_cast(MR);
+  if (!ER)
+return false;
+
+  DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+  DefinedOrUnknownSVal NumElements = C.getStoreManager().getSizeInElements(
+  state, ER->getSuperRegion(), ER->getValueType());
+  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  return StOutBound && !StInBound;
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -77,6 +101,8 @@
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
+  if (isArrayIndexOutOfBounds(C, Ex))
+OS << " due to array index out of bounds";
 }
 else {
   // Neither operand was undefined, but the result is undefined.


Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -57,6 +57,12 @@
   return s.x; // no-warning
 }
 
+void f6(int x) {
+  int a[20];
+  if (x == 25) {}
+  if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a garbage value due to array index out of bounds}}
+}
+
 int ret_uninit() {
   int i;
   int *p = &i;
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -35,6 +35,30 @@
 };
 } // end anonymous namespace
 
+static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
+  ProgramStateRef state = C.getState();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  if (!isa(Ex))
+return false;
+
+  SVal Loc = state->getSVal(Ex, LCtx);
+  if (!Loc.isValid())
+return false;
+
+  const MemRegion *MR = Loc.castAs().getRegion();
+  const ElementRegion *ER = dyn_cast(MR);
+  if (!ER)
+return false;
+
+  DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+  DefinedOrUnknownSVal NumElements = C.getStoreManager().getSizeInElements(
+  state, ER->getSuperRegion(), ER->getValueType());
+  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  return StOutBound && !StInBound;
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -77,6 +101,8 @@
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
+  if (isArrayIndexOutOfBounds(C, Ex))
+OS << " due to array index out of bounds";
 }
 else {
   // Neither operand was undefined, but the result is undefined.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Feb 24 05:54:45 2017
New Revision: 296110

URL: http://llvm.org/viewvc/llvm-project?rev=296110&view=rev
Log:
[change-namepsace] make it possible to whitelist symbols so they don't get 
updated.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/test/change-namespace/Inputs/
clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
clang-tools-extra/trunk/test/change-namespace/white-list.cpp
Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb 24 
05:54:45 2017
@@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
 
 ChangeNamespaceTool::ChangeNamespaceTool(
 llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+llvm::ArrayRef WhiteListedSymbolPatterns,
 std::map *FileToReplacements,
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
@@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
   }
   DiffOldNamespace = joinNamespaces(OldNsSplitted);
   DiffNewNamespace = joinNamespaces(NewNsSplitted);
+
+  for (const auto &Pattern : WhiteListedSymbolPatterns)
+WhiteListedSymbolRegexes.emplace_back(Pattern);
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
   std::string FromDeclName = FromDecl->getQualifiedNameAsString();
+  for (llvm::Regex &RE : WhiteListedSymbolRegexes)
+if (RE.match(FromDeclName))
+  return;
   std::string ReplaceName =
   getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
   // Checks if there is any using namespace declarations that can shorten the

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=296110&r1=296109&r2=296110&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb 24 
05:54:45 2017
@@ -50,6 +50,7 @@ public:
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef 
FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@ private:
   // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
   // been processed so that we don't handle them twice.
   llvm::SmallPtrSet ProcessedFuncRefs;
+  // Patterns of symbol names whose references are not expected to be updated
+  // when changing namespaces around them.
+  std::vector WhiteListedSymbolRegexes;
 };
 
 } // namespace change_namespace

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Fri 
Feb 24 05:54:45 2017
@@ -73,6 +73,25 @@ cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+cl::opt WhiteListFile(
+"whitelist_file",
+cl::desc("A file containing regexes of symbol names that are not expected "
+ "to be updated when changing namespaces around them."),
+cl::init(""), cl::cat(ChangeNamespaceCategory));
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;
+  if (!WhiteListFile.empty()) {
+llvm::ErrorOr> File =
+llvm::MemoryBuffer::getFile(WhiteListFile);
+if (!File)
+  return File.getError();
+llvm::StringRef Content = File.get()->getBuffer();
+Content.split(L

[PATCH] D30328: [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296110: [change-namepsace] make it possible to whitelist 
symbols so they don't get… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D30328?vs=89640&id=89643#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30328

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
  clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
  clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
  clang-tools-extra/trunk/test/change-namespace/white-list.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
@@ -73,16 +73,43 @@
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
 
+cl::opt WhiteListFile(
+"whitelist_file",
+cl::desc("A file containing regexes of symbol names that are not expected "
+ "to be updated when changing namespaces around them."),
+cl::init(""), cl::cat(ChangeNamespaceCategory));
+
+llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  llvm::SmallVector Lines;
+  if (!WhiteListFile.empty()) {
+llvm::ErrorOr> File =
+llvm::MemoryBuffer::getFile(WhiteListFile);
+if (!File)
+  return File.getError();
+llvm::StringRef Content = File.get()->getBuffer();
+Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  }
+  return std::vector(Lines.begin(), Lines.end());
+}
+
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
+  llvm::ErrorOr> WhiteListPatterns =
+  GetWhiteListedSymbolPatterns();
+  if (!WhiteListPatterns) {
+llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
+ << WhiteListPatterns.getError().message() << "\n";
+return 1;
+  }
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
@@ -50,6 +50,7 @@
   // files matching `FilePattern`.
   ChangeNamespaceTool(
   llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+  llvm::ArrayRef WhiteListedSymbolPatterns,
   std::map *FileToReplacements,
   llvm::StringRef FallbackStyle = "LLVM");
 
@@ -164,6 +165,9 @@
   // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
   // been processed so that we don't handle them twice.
   llvm::SmallPtrSet ProcessedFuncRefs;
+  // Patterns of symbol names whose references are not expected to be updated
+  // when changing namespaces around them.
+  std::vector WhiteListedSymbolRegexes;
 };
 
 } // namespace change_namespace
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -290,6 +290,7 @@
 
 ChangeNamespaceTool::ChangeNamespaceTool(
 llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
+llvm::ArrayRef WhiteListedSymbolPatterns,
 std::map *FileToReplacements,
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
@@ -308,6 +309,9 @@
   }
   DiffOldNamespace = joinNamespaces(OldNsSplitted);
   DiffNewNamespace = joinNamespaces(NewNsSplitted);
+
+  for (const auto &Pattern : WhiteListedSymbolPatterns)
+WhiteListedSymbolRegexes.emplace_back(Pattern);
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -736,6 +740,9 @@
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, Result.Context->getLangOpts());
   std::string FromDeclName = FromDecl->getQualifie

Re: [PATCH] D29303: In VirtualCallChecker, handle indirect calls

2017-02-24 Thread Sam McCall via cfe-commits
Thanks Anna, I'm new to the release process here.

Hans: this is a simple fix for a null-dereference in the static analyzer.
Does it make sense to cherrypick?

On Sat, Feb 18, 2017 at 2:46 AM, Anna Zaks via Phabricator <
revi...@reviews.llvm.org> wrote:

> zaks.anna added a comment.
>
> Has this been cherry-picked into the clang 4.0 release branch? If not, we
> should definitely do that!
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D29303
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r296113 - [change-namespace] fix asan failure in r296110.

2017-02-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Feb 24 06:56:51 2017
New Revision: 296113

URL: http://llvm.org/viewvc/llvm-project?rev=296113&view=rev
Log:
[change-namespace] fix asan failure in r296110.

Modified:
clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=296113&r1=296112&r2=296113&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Fri 
Feb 24 06:56:51 2017
@@ -80,15 +80,16 @@ cl::opt WhiteListFile(
 cl::init(""), cl::cat(ChangeNamespaceCategory));
 
 llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  if (WhiteListFile.empty())
+return std::vector();
+
   llvm::SmallVector Lines;
-  if (!WhiteListFile.empty()) {
-llvm::ErrorOr> File =
-llvm::MemoryBuffer::getFile(WhiteListFile);
-if (!File)
-  return File.getError();
-llvm::StringRef Content = File.get()->getBuffer();
-Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
-  }
+  llvm::ErrorOr> File =
+  llvm::MemoryBuffer::getFile(WhiteListFile);
+  if (!File)
+return File.getError();
+  llvm::StringRef Content = File.get()->getBuffer();
+  Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
   return std::vector(Lines.begin(), Lines.end());
 }
 


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


r296116 - Made test more target agnostic

2017-02-24 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Fri Feb 24 07:15:08 2017
New Revision: 296116

URL: http://llvm.org/viewvc/llvm-project?rev=296116&view=rev
Log:
Made test more target agnostic

Recommits r295975 (Added regression tests), reverted in r295975,
because it did not work on non-X86 targets.

Added:
cfe/trunk/test/SemaCXX/friend3.cpp

Added: cfe/trunk/test/SemaCXX/friend3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend3.cpp?rev=296116&view=auto
==
--- cfe/trunk/test/SemaCXX/friend3.cpp (added)
+++ cfe/trunk/test/SemaCXX/friend3.cpp Fri Feb 24 07:15:08 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -std=c++11 -emit-llvm %s -o 
- | FileCheck %s
+
+namespace pr8852 {
+void foo();
+struct S {
+  friend void foo() {}
+};
+
+void main() {
+  foo();
+}
+// CHECK: define {{.*}} @_ZN6pr88523fooEv
+}
+
+namespace pr9518 {
+template
+struct provide {
+  friend T f() { return T(); }
+};
+
+void g() {
+  void f();
+  provide p;
+  f();
+}
+// CHECK: define {{.*}} @_ZN6pr95181fEv
+}


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


[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.

Also support dumping global variables.


https://reviews.llvm.org/D30337

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/var_test.cpp
  test/clang-move/Inputs/var_test.h
  test/clang-move/move-var.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -539,6 +539,8 @@
 "enum class E2 { Red };\n"
 "typedef int Int2;\n"
 "using Int = int;\n"
+"extern int kGlobalInt;\n"
+"extern const char* const kGlobalStr;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -553,7 +555,8 @@
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
   {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
-  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"},
+  {"a::b::kGlobalInt", "Variable"}, {"a::b::kGlobalStr", "Variable"}};
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
   std::set Results;
   for (const auto& DelPair : Reporter.getDeclarationList())
Index: test/clang-move/move-var.cpp
===
--- /dev/null
+++ test/clang-move/move-var.cpp
@@ -0,0 +1,47 @@
+// RUN: mkdir -p %T/move-var
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: cd %T/move-var
+// RUN: clang-move -names="a::kGlobalInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE1 %s
+
+// CHECK-OLD-VAR-H-CASE1-NOT: extern int kGlobalInt;
+// CHECK-OLD-VAR-H-CASE1: int kGlobalInt = 3;
+
+// CHECK-OLD-VAR-CPP-CASE1-NOT: int kGlobalInt = 1;
+
+// CHECK-NEW-VAR-H-CASE1: extern int kGlobalInt;
+// CHECK-NEW-VAR-H-CASE1-NOT: int kGlobalInt = 3;
+
+// CHECK-NEW-VAR-CPP-CASE1: int kGlobalInt = 1;
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="a::kGlobalStr" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE2 %s
+
+// CHECK-OLD-VAR-H-CASE2-NOT: extern const char *const kGlobalStr;
+// CHECK-OLD-VAR-H-CASE2: const char *const kGlobalStr = "Hello2";
+
+// CHECK-OLD-VAR-CPP-CASE2-NOT: const char *const kGlobalStr = "Hello";
+
+// CHECK-NEW-VAR-H-CASE2: extern const char *const kGlobalStr;
+// CHECK-NEW-VAR-H-CASE2-NOT: const char *const kGlobalStr = "Hello2";
+
+// CHECK-NEW-VAR-CPP-CASE2: const char *const kGlobalStr = "Hello";
+
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="kEvilInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE3 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE3 %s
+
+// CHECK-OLD-VAR-H-CASE3-NOT: int kEvilInt = 2;
+
+// CHECK-NEW-VAR-H-CASE3: int kEvilInt = 2;
Index: test/clang-move/Inputs/var_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.h
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}
Index: test/clang-move/Inputs/var_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.cpp
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *const kGlobalStr = "H

[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 89659.
hokein added a comment.

No accident changes.


https://reviews.llvm.org/D30337

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/var_test.cpp
  test/clang-move/Inputs/var_test.h
  test/clang-move/move-var.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -539,6 +539,8 @@
 "enum class E2 { Red };\n"
 "typedef int Int2;\n"
 "using Int = int;\n"
+"extern int kGlobalInt;\n"
+"extern const char* const kGlobalStr;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -553,7 +555,8 @@
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
   {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
-  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"},
+  {"a::b::kGlobalInt", "Variable"}, {"a::b::kGlobalStr", "Variable"}};
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
   std::set Results;
   for (const auto& DelPair : Reporter.getDeclarationList())
Index: test/clang-move/move-var.cpp
===
--- /dev/null
+++ test/clang-move/move-var.cpp
@@ -0,0 +1,46 @@
+// RUN: mkdir -p %T/move-var
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: cd %T/move-var
+// RUN: clang-move -names="a::kGlobalInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE1 %s
+
+// CHECK-OLD-VAR-H-CASE1-NOT: extern int kGlobalInt;
+// CHECK-OLD-VAR-H-CASE1: int kGlobalInt = 3;
+
+// CHECK-OLD-VAR-CPP-CASE1-NOT: int kGlobalInt = 1;
+
+// CHECK-NEW-VAR-H-CASE1: extern int kGlobalInt;
+// CHECK-NEW-VAR-H-CASE1-NOT: int kGlobalInt = 3;
+
+// CHECK-NEW-VAR-CPP-CASE1: int kGlobalInt = 1;
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="a::kGlobalStr" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/var_test.cpp -check-prefix=CHECK-OLD-VAR-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.cpp -check-prefix=CHECK-NEW-VAR-CPP-CASE2 %s
+
+// CHECK-OLD-VAR-H-CASE2-NOT: extern const char *const kGlobalStr;
+// CHECK-OLD-VAR-H-CASE2: const char *const kGlobalStr = "Hello2";
+
+// CHECK-OLD-VAR-CPP-CASE2-NOT: const char *const kGlobalStr = "Hello";
+
+// CHECK-NEW-VAR-H-CASE2: extern const char *const kGlobalStr;
+// CHECK-NEW-VAR-H-CASE2-NOT: const char *const kGlobalStr = "Hello2";
+
+// CHECK-NEW-VAR-CPP-CASE2: const char *const kGlobalStr = "Hello";
+
+
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: clang-move -names="kEvilInt" -new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h -old_cc=../move-var/var_test.cpp -new_cc=%T/move-var/new_var_test.cpp %T/move-var/var_test.cpp --
+// RUN: FileCheck -input-file=%T/move-var/var_test.h -check-prefix=CHECK-OLD-VAR-H-CASE3 %s
+// RUN: FileCheck -input-file=%T/move-var/new_var_test.h -check-prefix=CHECK-NEW-VAR-H-CASE3 %s
+
+// CHECK-OLD-VAR-H-CASE3-NOT: int kEvilInt = 2;
+
+// CHECK-NEW-VAR-H-CASE3: int kEvilInt = 2;
Index: test/clang-move/Inputs/var_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.h
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}
Index: test/clang-move/Inputs/var_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/var_test.cpp
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *con

[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 89664.
rmaprath added a comment.

Different take on the patch: Externalize this function only for the 
externally-thread-api variant.

This is much less intrusive. Note that I haven't added the declaration of 
`__libcpp_thread_hw_concurrency()` into `__threading_support` because it 
doesn't belong there (needs to be provided through a custom 
`__external_threading` header instead).

There is no easy way to test this apart from building an actual 
external-thread-api libc++ variant. We could do some form of testing with the 
external-thread-library configuration, but it still requires some not-so-pretty 
changes that is probably best avoided.


https://reviews.llvm.org/D29757

Files:
  src/thread.cpp


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
 unsigned
 thread::hardware_concurrency() _NOEXCEPT
 {
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Defer to the external threading implementation
+return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -77,7 +77,10 @@
 unsigned
 thread::hardware_concurrency() _NOEXCEPT
 {
-#if defined(CTL_HW) && defined(HW_NCPU)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+// Defer to the external threading implementation
+return __libcpp_thread_hw_concurrency();
+#elif defined(CTL_HW) && defined(HW_NCPU)
 unsigned n;
 int mib[2] = {CTL_HW, HW_NCPU};
 std::size_t s = sizeof(n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 89665.
rmaprath added a comment.

Different approach: Externalize these functions only for the 
external-thread-api library variant.

(Similar to https://reviews.llvm.org/D29757)


https://reviews.llvm.org/D29818

Files:
  src/chrono.cpp


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,6 +12,8 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
+#include "__threading_support"
+
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime(&tp))
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(&tv, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic(&tp))
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,6 +12,8 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
+#include "__threading_support"
+
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime(&tp))
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(&tv, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic(&tp))
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Multiple versions of VS

2017-02-24 Thread Ammarguellat, Zahira via cfe-commits
Hello,

Is there any plan from the community to have clang support multiple versions of 
VS?
Thanks.
-Zahira

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


[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-24 Thread Eric Liu via Phabricator 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/D30337



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


[PATCH] D30339: Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

We've been having issues with using libcxxabi and libunwind for baremetal 
targets because fprintf is dependent on io functions, this patch disable calls 
to fprintf when building for baremetal targets in release mode.


https://reviews.llvm.org/D30339

Files:
  src/abort_message.cpp


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

We've been having issues with using libcxxabi and libunwind for baremetal 
targets because fprintf is dependent on io functions, this patch disable calls 
to fprintf when building for baremetal targets in release mode.


https://reviews.llvm.org/D30340

Files:
  src/config.h


Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
 __LINE__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  \
+  do { \
+abort();   \
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
 __LINE__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   \
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D30340



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D30339



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-24 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.

This patch clarify the error messages about uninitialized function arguments.

It can be really hard to see the problem if there are 10-20 arguments like:

  printf("debug:", a, b.c, d, e, ...);

with no info about which argument is uninitialized and with a complicated path 
to investigate it's hard to see the bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/diagnostics/undef-value-param.m
  test/Analysis/malloc.m
  test/Analysis/misc-ps-region-store.m
  test/Analysis/misc-ps.m
  test/Analysis/null-deref-ps.c
  test/Analysis/nullptr.cpp
  test/Analysis/uninit-const.c
  test/Analysis/uninit-const.cpp
  test/Analysis/uninit-msg-expr.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.cpp

Index: test/Analysis/uninit-vals.cpp
===
--- test/Analysis/uninit-vals.cpp
+++ test/Analysis/uninit-vals.cpp
@@ -27,7 +27,7 @@
   // case with undefined values, too.
   c1.b.a = c2->b.a;
 #else
-  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+  c1.b.a = c2->b.a; // expected-warning{{Function call argument number '1' is an uninitialized value}}
 #endif
 }
 }
Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -14,7 +14,7 @@
 
 int f1_b() {
   int x;
-  return bar(x)+1;  // expected-warning{{Function call argument is an uninitialized value}}
+  return bar(x)+1;  // expected-warning{{Function call argument number '1' is an uninitialized value}}
 }
 
 int f2() {
Index: test/Analysis/uninit-msg-expr.m
===
--- test/Analysis/uninit-msg-expr.m
+++ test/Analysis/uninit-msg-expr.m
@@ -52,5 +52,5 @@
 void f3() {
   NSMutableArray *aArray = [NSArray array];
   NSString *aString;
-  [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+  [aArray addObject:aString]; // expected-warning {{Argument number '1' in message expression is an uninitialized value}}
 }
Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
   int &p = t;
   int &s = p;
   int &q = s;  //expected-note {{'q' initialized here}}
-  doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(q); //expected-warning {{Function call argument number '1' is an uninitialized value}}
+   //expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 }
 
 void doStuff6_3(int& q_, int *ptr_) {}
@@ -78,32 +78,32 @@
   int &p = t;
   int &s = p;
   int &q = s;
-  doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6_3(q,ptr); //expected-warning {{Function call argument number '2' is an uninitialized value}}
+   //expected-note@-1 {{Function call argument number '2' is an uninitialized value}}
 
 }
 
 void f6(void) {
   int k;   // expected-note {{'k' declared without an initial value}}
-  doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}}
-   // expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(k); // expected-warning {{Function call argument number '1' is an uninitialized value}}
+   // expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 
 }
 
 
 
 void f5(void) {
   int t;
   int* tp = &t;// expected-note {{'tp' initialized here}}
-  doStuff_uninit(tp);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit(tp);  // expected-warning {{Function call argument number '1' is a pointer to uninitialized value}}
+   // expected-note@-1 {{Function call argument number '1' is a pointer to uninitialized value}}
 }
 
 
 void f4(void) {
   int y;// expected-note {{'y' declared without an initial value}}
-  doStuff4(y);  // expected-warning {{Function call argument is an uninitialized value}}
-// expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff4(y);  // expected-warning {{Function call argument number '1' is an uninitialized value}}
+// expected-note@-1 {{Function call argument number '1' is an uninitialized value}}
 }
 
 voi

[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296136: [libcxxabi] Disable calls to fprintf for baremetal 
targets. (authored by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30339?vs=89674&id=89681#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30339

Files:
  libcxxabi/trunk/src/abort_message.cpp


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,14 +35,16 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
 va_list list;
 va_start(list, format);
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296136 - [libcxxabi] Disable calls to fprintf for baremetal targets.

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 10:43:36 2017
New Revision: 296136

URL: http://llvm.org/viewvc/llvm-project?rev=296136&view=rev
Log:
[libcxxabi] Disable calls to fprintf for baremetal targets.

We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

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


Modified:
libcxxabi/trunk/src/abort_message.cpp

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296136&r1=296135&r2=296136&view=diff
==
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Fri Feb 24 10:43:36 2017
@@ -35,6 +35,7 @@ __attribute__((visibility("hidden"), nor
 void abort_message(const char* format, ...)
 {
 // write message to stderr
+#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
@@ -43,6 +44,7 @@ void abort_message(const char* format, .
 vfprintf(stderr, format, list);
 va_end(list);
 fprintf(stderr, "\n");
+#endif
 
 #if defined(__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
 // record message in crash report


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


[libunwind] r296135 - [libunwind] Disable calls to fprintf for baremetal targets.

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 10:38:05 2017
New Revision: 296135

URL: http://llvm.org/viewvc/llvm-project?rev=296135&view=rev
Log:
[libunwind] Disable calls to fprintf for baremetal targets.

We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

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


Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=296135&r1=296134&r2=296135&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Fri Feb 24 10:38:05 2017
@@ -78,6 +78,12 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
@@ -85,9 +91,14 @@
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


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


[PATCH] D30340: [libunwind] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296135: [libunwind] Disable calls to fprintf for baremetal 
targets. (authored by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30340?vs=89676&id=89679#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30340

Files:
  libunwind/trunk/src/config.h


Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  
\
+  do { 
\
+abort();   
\
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  
\
   do { 
\
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  
\
 __LINE__, msg);
\
 fflush(stderr);
\
 abort();   
\
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   
\
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds


Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -78,16 +78,27 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)  \
+  do { \
+abort();   \
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
 fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,  \
 __LINE__, msg);\
 fflush(stderr);\
 abort();   \
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)   \
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

isn't this incorrect because `config.h` always defines LIBCXX_BAREMETAL?


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D30339#685888, @EricWF wrote:

> isn't this incorrect because `config.h` always defines LIBCXX_BAREMETAL?


Oh, right, it needs to be:

  #if !LIBCXXABI_BAREMETAL || !defined(NDEBUG)


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation point

2017-02-24 Thread Hans Wennborg via cfe-commits
Oops, it did. Thanks for reminding me; I've merged that in r296139.

On Thu, Feb 23, 2017 at 11:13 PM, Hahnfeld, Jonas
 wrote:
> Hi Hans,
>
> Did r295474 fall off your radar? Sorry that I asked for both commits in one 
> email, should I reply to the other original commit?
>
> Thanks,
> Jonas
>
>> -Original Message-
>> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf
>> Of Hans Wennborg
>> Sent: Thursday, February 23, 2017 7:46 PM
>> To: Alexey Bataev
>> Cc: Hahnfeld, Jonas; cfe-commits@lists.llvm.org
>> Subject: Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation
>> point
>>
>> Thanks! r296000.
>>
>> On Wed, Feb 22, 2017 at 8:15 PM, Alexey Bataev 
>> wrote:
>> > Yes, approved
>> >
>> > Best regards,
>> > Alexey Bataev
>> >
>> >> 23 февр. 2017 г., в 1:00, Hans Wennborg 
>> написал(а):
>> >>
>> >> Alexey: ping?
>> >>
>> >>> On Tue, Feb 21, 2017 at 11:07 AM, Hans Wennborg
>>  wrote:
>> >>> I'm Ok with it if Alexey approves.
>> >>>
>> >>> On Fri, Feb 17, 2017 at 10:52 AM, Hahnfeld, Jonas
>> >>>  wrote:
>>  Hi Hans, Alexey,
>> 
>>  can we merge this commit and r295474 for the 4.0 release or is it
>>  already too late for that? I will totally understand that and can
>>  apply these commits locally prior to installing.
>>  However, I think that these changes are quite focussed and bear
>>  minimal possibility of introducing regressions.
>> 
>>  Thanks,
>>  Jonas
>> 
>>  Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via
>>  cfe-commits:
>> 
>>  Author: hahnfeld
>>  Date: Fri Feb 17 12:32:51 2017
>>  New Revision: 295473
>> 
>>  URL: http://llvm.org/viewvc/llvm-project?rev=295473&view=rev
>>  Log:
>>  [OpenMP] Remove barriers at cancel and cancellation point
>> 
>>  This resolves a deadlock with the cancel directive when there is no
>>  explicit cancellation point. In that case, the implicit barrier
>>  acts as cancellation point. After removing the barrier after
>>  cancel, the now unmatched barrier for the explicit cancellation
>>  point has to go as well.
>> 
>>  This has probably worked before rL255992: With the calls for the
>>  explicit barrier, it was sure that all threads passed a barrier before
>> exiting.
>> 
>>  Reported by Simon Convent and Joachim Protze!
>> 
>>  Differential Revision: https://reviews.llvm.org/D30088
>> 
>>  Modified:
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> cfe/trunk/test/OpenMP/cancel_codegen.cpp
>> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r295474 - [OpenMP] Fix cancellation point in task with no cancel

2017-02-24 Thread Hans Wennborg via cfe-commits
Merged to 4.0 in r296139 as requested on the r295473 commit thread.

On Fri, Feb 17, 2017 at 10:32 AM, Jonas Hahnfeld via cfe-commits
 wrote:
> Author: hahnfeld
> Date: Fri Feb 17 12:32:58 2017
> New Revision: 295474
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295474&view=rev
> Log:
> [OpenMP] Fix cancellation point in task with no cancel
>
> With tasks, the cancel may happen in another task. This has a different
> region info which means that we can't find it here.
>
> Differential Revision: https://reviews.llvm.org/D30091
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295474&r1=295473&r2=295474&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:58 2017
> @@ -4716,7 +4716,9 @@ void CGOpenMPRuntime::emitCancellationPo
>// global_tid, kmp_int32 cncl_kind);
>if (auto *OMPRegionInfo =
>dyn_cast_or_null(CGF.CapturedStmtInfo)) {
> -if (OMPRegionInfo->hasCancel()) {
> +// For 'cancellation point taskgroup', the task region info may not have 
> a
> +// cancel. This may instead happen in another adjacent task.
> +if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
>llvm::Value *Args[] = {
>emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
>CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
>
> Modified: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp?rev=295474&r1=295473&r2=295474&view=diff
> ==
> --- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp Fri Feb 17 12:32:58 
> 2017
> @@ -78,6 +78,12 @@ for (int i = 0; i < argc; ++i) {
>  }
>  // CHECK: call i8* @__kmpc_omp_task_alloc(
>  // CHECK: call i32 @__kmpc_omp_task(
> +#pragma omp task
> +{
> +#pragma omp cancellation point taskgroup
> +}
> +// CHECK: call i8* @__kmpc_omp_task_alloc(
> +// CHECK: call i32 @__kmpc_omp_task(
>  #pragma omp parallel sections
>  {
>{
> @@ -118,6 +124,15 @@ for (int i = 0; i < argc; ++i) {
>
>  // CHECK: define internal i32 @{{[^(]+}}(i32
>  // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
> +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
> +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
> +// CHECK: [[EXIT]]
> +// CHECK: br label %[[RETURN:.+]]
> +// CHECK: [[RETURN]]
> +// CHECK: ret i32 0
> +
> +// CHECK: define internal i32 @{{[^(]+}}(i32
> +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
>  // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
>  // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
>  // CHECK: [[EXIT]]
>
>
> ___
> 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] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

Perhaps change `config.h` and remove the definition there and adjust other 
places accordingly?

The current form is very easy to trip over.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:

> Perhaps change `config.h` and remove the definition there and adjust other 
> places accordingly?
>
> The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
defined/not-defined flag. Please don't change from one form to the other... 
it's disruptive to build systems.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


r296140 - [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma

2017-02-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Feb 24 11:45:16 2017
New Revision: 296140

URL: http://llvm.org/viewvc/llvm-project?rev=296140&view=rev
Log:
[Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
in macro argument pre-expansion mode when skipping a function body

This commit fixes a token caching problem that currently occurs when clang is
skipping a function body (e.g. when looking for a code completion token) and at
the same time caching the tokens for _Pragma when lexing it in macro argument
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the
tokens so that it can avoid interpreting the pragma immediately (as the macro
argument may not be used in the macro body), and then either backtracks over or
commits these tokens. The problem is that, when we're backtracking/committing in
such a scenario, there's already a previous backtracking position stored in
BacktrackPositions (as we're skipping the function body), and this leads to a
situation where the cached tokens from the pragma (like '(' 'string_literal'
and ')') will remain in the cached tokens array incorrectly even after they're
consumed (in the case of backtracking) or just ignored (in the case when they're
committed). Furthermore, what makes it even worse, is that because of a previous
backtracking position, the logic that deals with when should we call
ExitCachingLexMode in CachingLex no longer works for us in this situation, and
more tokens in the macro argument get cached, to the point where the EOF token
that corresponds to the macro argument EOF is cached. This problem leads to all
sorts of issues in code completion mode, where incorrect errors get presented
and code completion completely fails to produce completion results.

rdar://28523863

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

Added:
cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPCaching.cpp
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=296140&r1=296139&r2=296140&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Feb 24 11:45:16 2017
@@ -1077,6 +1077,24 @@ public:
   /// \brief Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
 
+  struct CachedTokensRange {
+CachedTokensTy::size_type Begin, End;
+  };
+
+private:
+  /// \brief A range of cached tokens that should be erased after lexing
+  /// when backtracking requires the erasure of such cached tokens.
+  Optional CachedTokenRangeToErase;
+
+public:
+  /// \brief Returns the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  CachedTokensRange LastCachedTokenRange();
+
+  /// \brief Erase the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  void EraseCachedTokens(CachedTokensRange TokenRange);
+
   /// \brief Make Preprocessor re-lex the tokens that were lexed since
   /// EnableBacktrackAtThisPos() was previously called.
   void Backtrack();

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=296140&r1=296139&r2=296140&view=diff
==
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Fri Feb 24 11:45:16 2017
@@ -35,6 +35,29 @@ void Preprocessor::CommitBacktrackedToke
   BacktrackPositions.pop_back();
 }
 
+Preprocessor::CachedTokensRange Preprocessor::LastCachedTokenRange() {
+  assert(isBacktrackEnabled());
+  auto PrevCachedLexPos = BacktrackPositions.back();
+  return CachedTokensRange{PrevCachedLexPos, CachedLexPos};
+}
+
+void Preprocessor::EraseCachedTokens(CachedTokensRange TokenRange) {
+  assert(TokenRange.Begin <= TokenRange.End);
+  if (CachedLexPos == TokenRange.Begin && TokenRange.Begin != TokenRange.End) {
+// We have backtracked to the start of the token range as we want to 
consume
+// them again. Erase the tokens only after consuming then.
+assert(!CachedTokenRangeToErase);
+CachedTokenRangeToErase = TokenRange;
+return;
+  }
+  // The cached tokens were committed, so they should be erased now.
+  assert(TokenRange.End == CachedLexPos);
+  CachedTokens.erase(CachedTokens.begin() + TokenRange.Begin,
+ CachedTokens.begin() + TokenRange.End);
+  CachedLexPos = TokenRange.Begin;
+  ExitCachingLexMode();
+}
+
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
@@ -51,6 +74,13 @@ void Preprocessor::CachingLex(Token &Res
 
   if (C

[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.

Made a mistake in the condition typo because LIBCXXABI_BAREMETAL is always 
defined, I should have been checking the contents to see if it's enabled


https://reviews.llvm.org/D30343

Files:
  src/abort_message.cpp


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


Index: src/abort_message.cpp
===
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

Ah sorry for the mistake. Fix is here https://reviews.llvm.org/D30343


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[PATCH] D28772: [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma in macro argument pre-expansion mode when skipping a function body

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296140: [Preprocessor] Fix incorrect token caching that 
occurs when lexing _Pragma (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D28772?vs=87801&id=89688#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28772

Files:
  cfe/trunk/include/clang/Lex/Preprocessor.h
  cfe/trunk/lib/Lex/PPCaching.cpp
  cfe/trunk/lib/Lex/Pragma.cpp
  cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c

Index: cfe/trunk/include/clang/Lex/Preprocessor.h
===
--- cfe/trunk/include/clang/Lex/Preprocessor.h
+++ cfe/trunk/include/clang/Lex/Preprocessor.h
@@ -1077,6 +1077,24 @@
   /// \brief Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
 
+  struct CachedTokensRange {
+CachedTokensTy::size_type Begin, End;
+  };
+
+private:
+  /// \brief A range of cached tokens that should be erased after lexing
+  /// when backtracking requires the erasure of such cached tokens.
+  Optional CachedTokenRangeToErase;
+
+public:
+  /// \brief Returns the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  CachedTokensRange LastCachedTokenRange();
+
+  /// \brief Erase the range of cached tokens that were lexed since
+  /// EnableBacktrackAtThisPos() was previously called.
+  void EraseCachedTokens(CachedTokensRange TokenRange);
+
   /// \brief Make Preprocessor re-lex the tokens that were lexed since
   /// EnableBacktrackAtThisPos() was previously called.
   void Backtrack();
Index: cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
===
--- cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
+++ cfe/trunk/test/CodeCompletion/pragma-macro-token-caching.c
@@ -0,0 +1,18 @@
+
+#define Outer(action) action
+
+void completeParam(int param) {
+;
+Outer(__extension__({ _Pragma("clang diagnostic push") }));
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:1 %s | FileCheck %s
+// CHECK: param : [#int#]param
+
+void completeParamPragmaError(int param) {
+Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s
Index: cfe/trunk/lib/Lex/PPCaching.cpp
===
--- cfe/trunk/lib/Lex/PPCaching.cpp
+++ cfe/trunk/lib/Lex/PPCaching.cpp
@@ -35,6 +35,29 @@
   BacktrackPositions.pop_back();
 }
 
+Preprocessor::CachedTokensRange Preprocessor::LastCachedTokenRange() {
+  assert(isBacktrackEnabled());
+  auto PrevCachedLexPos = BacktrackPositions.back();
+  return CachedTokensRange{PrevCachedLexPos, CachedLexPos};
+}
+
+void Preprocessor::EraseCachedTokens(CachedTokensRange TokenRange) {
+  assert(TokenRange.Begin <= TokenRange.End);
+  if (CachedLexPos == TokenRange.Begin && TokenRange.Begin != TokenRange.End) {
+// We have backtracked to the start of the token range as we want to consume
+// them again. Erase the tokens only after consuming then.
+assert(!CachedTokenRangeToErase);
+CachedTokenRangeToErase = TokenRange;
+return;
+  }
+  // The cached tokens were committed, so they should be erased now.
+  assert(TokenRange.End == CachedLexPos);
+  CachedTokens.erase(CachedTokens.begin() + TokenRange.Begin,
+ CachedTokens.begin() + TokenRange.End);
+  CachedLexPos = TokenRange.Begin;
+  ExitCachingLexMode();
+}
+
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
@@ -51,6 +74,13 @@
 
   if (CachedLexPos < CachedTokens.size()) {
 Result = CachedTokens[CachedLexPos++];
+// Erase the some of the cached tokens after they are consumed when
+// asked to do so.
+if (CachedTokenRangeToErase &&
+CachedTokenRangeToErase->End == CachedLexPos) {
+  EraseCachedTokens(*CachedTokenRangeToErase);
+  CachedTokenRangeToErase = None;
+}
 return;
   }
 
Index: cfe/trunk/lib/Lex/Pragma.cpp
===
--- cfe/trunk/lib/Lex/Pragma.cpp
+++ cfe/trunk/lib/Lex/Pragma.cpp
@@ -160,12 +160,23 @@
 
   ~LexingFor_PragmaRAII() {
 if (InMacroArgPreExpansion) {
+  // When committing/backtracking the cached pragma tokens in a macro
+  // argument pre-expansion we want to ensure that either the tokens which
+  // have been committed will be removed from the cache or that the tokens
+  // over which we just backtracked won't remain in the cache after they're
+  // consumed and that the caching will stop after consuming them.
+  // Otherwise the caching will interfere with the way macro expansion
+  // works, because we will continue to cach

[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

Going for post-commit.


https://reviews.llvm.org/D30343



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


[libcxxabi] r296146 - [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Fri Feb 24 12:22:59 2017
New Revision: 296146

URL: http://llvm.org/viewvc/llvm-project?rev=296146&view=rev
Log:
[libcxxabi] Fix condition typo in rL296136

Made a mistake in the condition typo because LIBCXXABI_BAREMETAL is always
defined, I should have been checking the contents to see if it's enabled.

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


Modified:
libcxxabi/trunk/src/abort_message.cpp

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296146&r1=296145&r2=296146&view=diff
==
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Fri Feb 24 12:22:59 2017
@@ -35,7 +35,7 @@ __attribute__((visibility("hidden"), nor
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


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


[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296146: [libcxxabi] Fix condition typo in rL296136 (authored 
by rsingh).

Changed prior to commit:
  https://reviews.llvm.org/D30343?vs=89687&id=89693#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30343

Files:
  libcxxabi/trunk/src/abort_message.cpp


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif


Index: libcxxabi/trunk/src/abort_message.cpp
===
--- libcxxabi/trunk/src/abort_message.cpp
+++ libcxxabi/trunk/src/abort_message.cpp
@@ -35,7 +35,7 @@
 void abort_message(const char* format, ...)
 {
 // write message to stderr
-#if !defined(NDEBUG) && !defined(LIBCXXABI_BAREMETAL)
+#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
 #ifdef __APPLE__
 fprintf(stderr, "libc++abi.dylib: ");
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch refactors the code figures out which block captures need to be 
copied/destroyed using special copy/destroy code.
This is a preparation patch for work on merging block copy/destroy routines.

Thanks for taking a look!


Repository:
  rL LLVM

https://reviews.llvm.org/D30345

Files:
  lib/CodeGen/CGBlocks.cpp

Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1373,6 +1373,110 @@
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy operation that should be performed for an entity
+/// that's captured by a block.
+enum class BlockCaptureCopyType {
+  CXXCopyCtor,
+  ARCWeak,
+  ARCStrong,
+  BlockObjectAssign
+};
+
+/// Represents a type of destroy operation that should be performed on an
+/// entity that's captured by a block.
+enum class BlockCaptureDestroyType {
+  CXXDtor,
+  ARCWeak,
+  ARCStrong,
+  BlockRelease
+};
+
+template  struct BlockCaptureCopyDestroyGenericInfo {
+  T Type;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture &CI;
+  const CGBlockInfo::Capture &Capture;
+
+  BlockCaptureCopyDestroyGenericInfo(T Type, BlockFieldFlags Flags,
+ const BlockDecl::Capture &CI,
+ const CGBlockInfo::Capture &Capture)
+  : Type(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+using BlockCaptureCopyInfo =
+BlockCaptureCopyDestroyGenericInfo;
+
+using BlockCaptureDestroyInfo =
+BlockCaptureCopyDestroyGenericInfo;
+
+} // end anonymous namespace
+
+/// Find the set of block captures that need to be explicitly copied.
+static void
+computeBlockCopyEntries(const CGBlockInfo &BlockInfo,
+const LangOptions &LangOpts,
+SmallVectorImpl &CopiedCaptures) {
+  for (const auto &CI : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+QualType Type = Variable->getType();
+const CGBlockInfo::Capture &Capture = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+if (CI.getCopyExpr()) {
+  assert(!CI.isByRef());
+  // don't bother computing flags
+  CopiedCaptures.emplace_back(BlockCaptureCopyType::CXXCopyCtor,
+  BlockFieldFlags(), CI, Capture);
+  continue;
+}
+BlockFieldFlags Flags;
+BlockCaptureCopyType CopyType = BlockCaptureCopyType::BlockObjectAssign;
+if (CI.isByRef()) {
+  Flags = BLOCK_FIELD_IS_BYREF;
+  if (Type.isObjCGCWeak())
+Flags |= BLOCK_FIELD_IS_WEAK;
+} else if (Type->isObjCRetainableType()) {
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = Type->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = Type.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak) {
+CopyType = BlockCaptureCopyType::ARCWeak;
+
+// We need to retain the copied value for __strong direct captures.
+  } else if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+if (!isBlockPointer)
+  CopyType = BlockCaptureCopyType::ARCStrong;
+
+// Non-ARC captures of retainable pointers are strong and
+// therefore require a call to _Block_object_assign.
+  } else if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount) {
+// fall through
+
+// Otherwise the memcpy is fine.
+  } else {
+continue;
+  }
+
+  // For all other types, the memcpy is fine.
+} else {
+  continue;
+}
+CopiedCaptures.emplace_back(CopyType, Flags, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1535,27 @@
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl = blockInfo.getBlockDecl();
-
-  for (const auto &CI : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-const Expr *copyExpr = CI.getCopyExpr();
-BlockFieldFlags flags;
-
-bool useARCWeakCopy = false;
-bool useARCStrongCopy = false;
-
-if (copyExpr) {
-  assert(!CI.isByRef());
-  // don't bother computing flags
-
-} else if (CI

Re: r296063 - Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"

2017-02-24 Thread Hans Wennborg via cfe-commits
Merged to 4.0 in r296152.

On Thu, Feb 23, 2017 at 5:16 PM, Hans Wennborg via cfe-commits
 wrote:
> Author: hans
> Date: Thu Feb 23 19:16:34 2017
> New Revision: 296063
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296063&view=rev
> Log:
> Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match 
> builtin"
>
> It caused PR31864. There is a patch in progress to fix that, but let's
> revert in the meantime.
>
> Modified:
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Sema/atomic-ops.c
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=296063&r1=296062&r2=296063&view=diff
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Feb 23 19:16:34 2017
> @@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned T
>
>  /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
>  /// the specified properties.
> -static const char *getLockFreeValue(unsigned TypeWidth, unsigned 
> InlineWidth) {
> +static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
> +unsigned InlineWidth) {
>// Fully-aligned, power-of-2 sizes no larger than the inline
>// width will be inlined as lock-free operations.
> -  // Note: we do not need to check alignment since _Atomic(T) is always
> -  // appropriately-aligned in clang.
> -  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
> +  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> +  TypeWidth <= InlineWidth)
>  return "2"; // "always lock free"
>// We cannot be certain what operations the lib calls might be
>// able to implement as lock-free on future processors.
> @@ -886,6 +886,7 @@ static void InitializePredefinedMacros(c
>  #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
>  Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
>  getLockFreeValue(TI.get##Type##Width(), \
> + TI.get##Type##Align(), \
>   InlineWidthBits));
>  DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
>  DEFINE_LOCK_FREE_MACRO(CHAR, Char);
> @@ -898,6 +899,7 @@ static void InitializePredefinedMacros(c
>  DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
>  Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
>  getLockFreeValue(TI.getPointerWidth(0),
> + TI.getPointerAlign(0),
>   InlineWidthBits));
>  #undef DEFINE_LOCK_FREE_MACRO
>}
>
> Modified: cfe/trunk/test/Sema/atomic-ops.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=296063&r1=296062&r2=296063&view=diff
> ==
> --- cfe/trunk/test/Sema/atomic-ops.c (original)
> +++ cfe/trunk/test/Sema/atomic-ops.c Thu Feb 23 19:16:34 2017
> @@ -14,7 +14,11 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK
>  _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
>  _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
>  _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
> +#ifdef __i386__
> +_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
> +#else
>  _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
> +#endif
>  _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
>
>  _Static_assert(__c11_atomic_is_lock_free(1), "");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29303: In VirtualCallChecker, handle indirect calls

2017-02-24 Thread Hans Wennborg via cfe-commits
Yes, this looks very straight-forward. Merged in r296154.

On Fri, Feb 24, 2017 at 4:29 AM, Sam McCall via cfe-commits
 wrote:
> Thanks Anna, I'm new to the release process here.
>
> Hans: this is a simple fix for a null-dereference in the static analyzer.
> Does it make sense to cherrypick?
>
> On Sat, Feb 18, 2017 at 2:46 AM, Anna Zaks via Phabricator
>  wrote:
>>
>> zaks.anna added a comment.
>>
>> Has this been cherry-picked into the clang 4.0 release branch? If not, we
>> should definitely do that!
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D29303
>>
>>
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r293604 - In VirtualCallChecker, handle indirect calls

2017-02-24 Thread Hans Wennborg via cfe-commits
On Mon, Jan 30, 2017 at 9:23 PM, Sam McCall via cfe-commits
 wrote:
> Author: sammccall
> Date: Mon Jan 30 23:23:20 2017
> New Revision: 293604
>
> URL: http://llvm.org/viewvc/llvm-project?rev=293604&view=rev
> Log:
> In VirtualCallChecker, handle indirect calls
>
> Summary:
> In VirtualCallChecker, handle indirect calls.
>
> getDirectCallee() can be nullptr, and dyn_cast(nullptr) is UB
>
> Reviewers: bkramer
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D29303
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
> cfe/trunk/test/Analysis/virtualcall.cpp

Merged to 4.0 in r296154 as suggested in the code review email thread.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296160 - clang-format: Fix many Objective-C formatting regressions from r289428

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 13:10:12 2017
New Revision: 296160

URL: http://llvm.org/viewvc/llvm-project?rev=296160&view=rev
Log:
clang-format: Fix many Objective-C formatting regressions from r289428

r289428 added a separate language kind for Objective-C, but kept many
"Language == LK_Cpp" checks untouched.  This introduced a "IsCpp()"
method that returns true for both C++ and Objective-C++, and replaces
all comparisons of Language with LK_Cpp with calls to this new method.

Also add a lot more test coverge for formatting things in LK_ObjC mode,
by having FormatTest's verifyFormat() test for LK_ObjC everything that's
being tested for LK_Cpp at the moment.

Fixes PR32060 and many other things.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=296160&r1=296159&r2=296160&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri Feb 24 13:10:12 2017
@@ -465,7 +465,7 @@ struct FormatStyle {
 LK_Java,
 /// Should be used for JavaScript.
 LK_JavaScript,
-/// Should be used for ObjectiveC, ObjectiveC++.
+/// Should be used for Objective-C, Objective-C++.
 LK_ObjC,
 /// Should be used for Protocol Buffers
 /// (https://developers.google.com/protocol-buffers/).
@@ -473,6 +473,7 @@ struct FormatStyle {
 /// Should be used for TableGen code.
 LK_TableGen
   };
+  bool IsCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
 
   /// \brief Language, this format style is targeted at.
   LanguageKind Language;
@@ -872,6 +873,8 @@ inline StringRef getLanguageName(FormatS
   switch (Language) {
   case FormatStyle::LK_Cpp:
 return "C++";
+  case FormatStyle::LK_ObjC:
+return "Objective-C";
   case FormatStyle::LK_Java:
 return "Java";
   case FormatStyle::LK_JavaScript:

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=296160&r1=296159&r2=296160&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Feb 24 13:10:12 2017
@@ -156,7 +156,7 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
-Style.Language == FormatStyle::LK_Cpp &&
+Style.IsCpp() &&
 // FIXME: This is a temporary workaround for the case where 
clang-format
 // sets BreakBeforeParameter to avoid bin packing and this creates a
 // completely unnecessary line break after a template type that isn't
@@ -598,9 +598,7 @@ unsigned ContinuationIndenter::addTokenO
   // Any break on this level means that the parent level has been broken
   // and we need to avoid bin packing there.
   bool NestedBlockSpecialCase =
-  Style.Language != FormatStyle::LK_Cpp &&
-  Style.Language != FormatStyle::LK_ObjC &&
-  Current.is(tok::r_brace) && State.Stack.size() > 1 &&
+  !Style.IsCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined;
   if (!NestedBlockSpecialCase)
 for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i)

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296160&r1=296159&r2=296160&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Feb 24 13:10:12 2017
@@ -1662,7 +1662,7 @@ bool isDeletedHeader(llvm::StringRef Hea
 tooling::Replacements
 fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
 const FormatStyle &Style) {
-  if (Style.Language != FormatStyle::LanguageKind::LK_Cpp)
+  if (!Style.IsCpp())
 return Replaces;
 
   tooling::Replacements HeaderInsertions;
@@ -1864,7 +1864,7 @@ LangOptions getFormattingLangOpts(const
   LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.LineComment = 1;
-  bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp;
+  bool AlternativeOperators = Style.IsCpp();
   LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;
   LangOpts.Boo

r296161 - clang-format: Enable include sorting for style=Chromium

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 13:13:59 2017
New Revision: 296161

URL: http://llvm.org/viewvc/llvm-project?rev=296161&view=rev
Log:
clang-format: Enable include sorting for style=Chromium

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296161&r1=296160&r2=296161&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Feb 24 13:13:59 2017
@@ -656,7 +656,6 @@ FormatStyle getChromiumStyle(FormatStyle
 if (Language == FormatStyle::LK_ObjC)
   ChromiumStyle.ColumnLimit = 80;
   }
-  ChromiumStyle.SortIncludes = false;
   return ChromiumStyle;
 }
 


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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a reviewer: doug.gregor.
mgorny added a subscriber: doug.gregor.
mgorny added a comment.

If I read the git correctly, the change that forbid defining builtins was 
initially made in https://reviews.llvm.org/rL64639. @doug.gregor, any chance 
you could help us over here? Is clang supposed to unconditionally reject those 
definitions, and are we supposed to always work-around it in compiler-rt, or 
should we consider adding some additional switch to allow them in clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

aaron.ballman wrote:
> arphaman wrote:
> > aaron.ballman wrote:
> > > arphaman wrote:
> > > > aaron.ballman wrote:
> > > > > I have strong reservations about this -- users are going to have no 
> > > > > idea what attributes are and are not supported because they're not 
> > > > > going to know whether the attribute has a subject list or requires 
> > > > > delayed parsing. We have a considerable number of attributes for 
> > > > > which the Subjects line is currently commented out simply because no 
> > > > > one has bothered to fix that. This means those attributes can't be 
> > > > > used with this pragma until someone fixes that, but when it happens, 
> > > > > they magically can be used, which is a good thing. But the converse 
> > > > > is more problematic -- if there's an existing Subjects line that gets 
> > > > > removed because a subject is added that is difficult to express in 
> > > > > TableGen it may break user code.
> > > > > 
> > > > > We can fix the discoverability issues somewhat by updating the 
> > > > > documentation emitter to spit out some wording that says when an 
> > > > > attribute is/is not supported by this feature, but that only works 
> > > > > for attributes which have documentation and so it's not a 
> > > > > particularly reliable workaround.
> > > > > I have strong reservations about this -- users are going to have no 
> > > > > idea what attributes are and are not supported because they're not 
> > > > > going to know whether the attribute has a subject list or requires 
> > > > > delayed parsing. We have a considerable number of attributes for 
> > > > > which the Subjects line is currently commented out simply because no 
> > > > > one has bothered to fix that. This means those attributes can't be 
> > > > > used with this pragma until someone fixes that, but when it happens, 
> > > > > they magically can be used, which is a good thing. But the converse 
> > > > > is more problematic -- if there's an existing Subjects line that gets 
> > > > > removed because a subject is added that is difficult to express in 
> > > > > TableGen it may break user code.
> > > > 
> > > > That's a good point. I think we can address this problem by creating a 
> > > > test that verifies the list of attributes that support the pragma. This 
> > > > would allow us to ensure that no attributes loose the ability to use 
> > > > the pragma.
> > > > 
> > > > > We can fix the discoverability issues somewhat by updating the 
> > > > > documentation emitter to spit out some wording that says when an 
> > > > > attribute is/is not supported by this feature, but that only works 
> > > > > for attributes which have documentation and so it's not a 
> > > > > particularly reliable workaround.
> > > > 
> > > > We can enforce the rule that the attributes can only be used with 
> > > > '#pragma clang attribute' when they're documented. This way we can 
> > > > ensure that all attributes that can be used with the pragma are 
> > > > explicitly documented.
> > > > That's a good point. I think we can address this problem by creating a 
> > > > test that verifies the list of attributes that support the pragma. This 
> > > > would allow us to ensure that no attributes loose the ability to use 
> > > > the pragma.
> > > 
> > > That would be good.
> > > 
> > > > We can enforce the rule that the attributes can only be used with 
> > > > '#pragma clang attribute' when they're documented. This way we can 
> > > > ensure that all attributes that can be used with the pragma are 
> > > > explicitly documented.
> > > 
> > > This addresses the concern about discoverability, but it worsens the 
> > > concerns about fragility. The biggest problem is: the user has very 
> > > little hope of understanding what attributes will apply to what 
> > > declarations with which version of the compiler they're using. With this 
> > > sort of thing, the act of us adding documentation can impact the behavior 
> > > of a user's program from one release to the next.
> > > 
> > > While I can imagine this pragma reducing some amount of code clutter, it 
> > > is far too "magical" for me to feel comfortable with it (at least in the 
> > > proposed form). I cannot read the user's source code and understand what 
> > > attributes are going to be applied to which declarations, and that's not 
> > > a good story for usability of the feature.
> > What about the following idea:
> > 
> > The user has to include a **strict** set of declarations that receive the 
> > attribute explicitly, e.g.:
> > 
> > ```
> > #pragma clang attribute push([[noreturn]], apply_to={ function })
> > ``` 
> > 
> > The compiler then would verify tha

[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks! I assume you will make corresponding changes in backend.


https://reviews.llvm.org/D30316



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


[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:2380
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope(&CGF);

I don't think you need the isIntegerType check here?


https://reviews.llvm.org/D29437



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


RE: [clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-24 Thread Yung, Douglas via cfe-commits
Hi Eric,

I don't know if you are aware, but one of the tests you added in this change is 
failing on the PS4 Windows bot. The test is " Clang Tools :: 
change-namespace/white-list.cpp". Can you please take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Eric Liu via cfe-commits
> Sent: Friday, February 24, 2017 3:55
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r296110 - [change-namepsace] make it possible to
> whitelist symbols so they don't get updated.
> 
> Author: ioeric
> Date: Fri Feb 24 05:54:45 2017
> New Revision: 296110
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296110&view=rev
> Log:
> [change-namepsace] make it possible to whitelist symbols so they don't get
> updated.
> 
> Reviewers: hokein
> 
> Reviewed By: hokein
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D30328
> 
> Added:
> clang-tools-extra/trunk/test/change-namespace/Inputs/
> clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
> clang-tools-extra/trunk/test/change-namespace/white-list.cpp
> Modified:
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> clang-tools-extra/trunk/unittests/change-
> namespace/ChangeNamespaceTests.cpp
> 
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/ChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb
> +++ 24 05:54:45 2017
> @@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
> 
>  ChangeNamespaceTool::ChangeNamespaceTool(
>  llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +llvm::ArrayRef WhiteListedSymbolPatterns,
>  std::map *FileToReplacements,
>  llvm::StringRef FallbackStyle)
>  : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
> @@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
>}
>DiffOldNamespace = joinNamespaces(OldNsSplitted);
>DiffNewNamespace = joinNamespaces(NewNsSplitted);
> +
> +  for (const auto &Pattern : WhiteListedSymbolPatterns)
> +WhiteListedSymbolRegexes.emplace_back(Pattern);
>  }
> 
>  void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder)
> { @@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
>Result.SourceManager->getSpellingLoc(End)),
>*Result.SourceManager, Result.Context->getLangOpts());
>std::string FromDeclName = FromDecl->getQualifiedNameAsString();
> +  for (llvm::Regex &RE : WhiteListedSymbolRegexes)
> +if (RE.match(FromDeclName))
> +  return;
>std::string ReplaceName =
>getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
>// Checks if there is any using namespace declarations that can shorten the
> 
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/ChangeNamespace.h?rev=296110&r1=296109&r2=296110&view=diff
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb
> +++ 24 05:54:45 2017
> @@ -50,6 +50,7 @@ public:
>// files matching `FilePattern`.
>ChangeNamespaceTool(
>llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +  llvm::ArrayRef WhiteListedSymbolPatterns,
>std::map *FileToReplacements,
>llvm::StringRef FallbackStyle = "LLVM");
> 
> @@ -164,6 +165,9 @@ private:
>// CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
>// been processed so that we don't handle them twice.
>llvm::SmallPtrSet ProcessedFuncRefs;
> +  // Patterns of symbol names whose references are not expected to be
> + updated  // when changing namespaces around them.
> +  std::vector WhiteListedSymbolRegexes;
>  };
> 
>  } // namespace change_namespace
> 
> Modified: clang-tools-extra/trunk/change-
> namespace/tool/ClangChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-
> namespace/tool/ClangChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=di
> ff
> ==
> --- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.c
> +++ pp Fri Feb 24 05:54:45 2

[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

This works for me, but the idiomatic macro usage in libc++, and (hopefully) 
libc++abi should always use `defined(FOO)` as opposed to `!FOO`. I'll clean 
this up in the next week if nobody else wants to.


Repository:
  rL LLVM

https://reviews.llvm.org/D30343



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


[PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:

> In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:
>
> > Perhaps change `config.h` and remove the definition there and adjust other 
> > places accordingly?
> >
> > The current form is very easy to trip over.
>
>
> Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
> defined/not-defined flag. Please don't change from one form to the other... 
> it's disruptive to build systems.


I actually think it's better to maintain consistency between libc++ and 
libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in 
`config.h`.

Frankly I don't care that it is disruptive to build systems unless it's the 
build system owned by LLVM.


Repository:
  rL LLVM

https://reviews.llvm.org/D30339



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


[libclc] r296164 - .gitignore: Ignore amdgcn-mesa object directory

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 14:32:18 2017
New Revision: 296164

URL: http://llvm.org/viewvc/llvm-project?rev=296164&view=rev
Log:
.gitignore: Ignore amdgcn-mesa object directory

Modified:
libclc/trunk/.gitignore

Modified: libclc/trunk/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.gitignore?rev=296164&r1=296163&r2=296164&view=diff
==
--- libclc/trunk/.gitignore (original)
+++ libclc/trunk/.gitignore Fri Feb 24 14:32:18 2017
@@ -1,6 +1,7 @@
 Makefile
 amdgcn--
 amdgcn--amdhsa
+amdgcn-mesa-mesa3d
 build/*.pyc
 built_libs/
 generic--


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


Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via cfe-commits



On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:

EricWF added a comment.

In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:


In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:


Perhaps change `config.h` and remove the definition there and adjust other 
places accordingly?

The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a 
defined/not-defined flag. Please don't change from one form to the other... 
it's disruptive to build systems.


I actually think it's better to maintain consistency between libc++ and 
libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in 
`config.h`.

Frankly I don't care that it is disruptive to build systems unless it's the 
build system owned by LLVM.


What I really care about is the interface between the build system owned 
by LLVM, and the one driving it.



Jon




Repository:
   rL LLVM

https://reviews.llvm.org/D30339





--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Eric Fiselier via cfe-commits
Inserting arbitrary feature macros into CMake should not be a supported
scenario because it results is macros, such as this one, which are
seemingly dead.

/Eric

On Fri, Feb 24, 2017 at 1:44 PM, Jonathan Roelofs  wrote:

>
>
> On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:
>
>> EricWF added a comment.
>>
>> In https://reviews.llvm.org/D30339#685921, @jroelofs wrote:
>>
>> In https://reviews.llvm.org/D30339#685919, @rmaprath wrote:
>>>
>>> Perhaps change `config.h` and remove the definition there and adjust
 other places accordingly?

 The current form is very easy to trip over.

>>>
>>> Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag, not a
>>> defined/not-defined flag. Please don't change from one form to the other...
>>> it's disruptive to build systems.
>>>
>>
>> I actually think it's better to maintain consistency between libc++ and
>> libc++abi. And libc++ never uses 0/1 flags. So I would rather see a fix in
>> `config.h`.
>>
>> Frankly I don't care that it is disruptive to build systems unless it's
>> the build system owned by LLVM.
>>
>
> What I really care about is the interface between the build system owned
> by LLVM, and the one driving it.
>
>
> Jon
>
>
>
>>
>> Repository:
>>rL LLVM
>>
>> https://reviews.llvm.org/D30339
>>
>>
>>
>>
> --
> Jon Roelofs
> jonat...@codesourcery.com
> CodeSourcery / Mentor Embedded
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296166 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 14:49:00 2017
New Revision: 296166

URL: http://llvm.org/viewvc/llvm-project?rev=296166&view=rev
Log:
clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

Fix and analysis by Wei Mao  (see bug), test by me.

Added:
cfe/trunk/test/Format/inplace.cpp
Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp

Added: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296166&view=auto
==
--- cfe/trunk/test/Format/inplace.cpp (added)
+++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 14:49:00 2017
@@ -0,0 +1,263 @@
+// Regression test to check that clang-format does not leave behind temporary
+// files on Windows when doing in-place formatting.
+// RUN: rm %T/*
+// RUN: cp %s %T/inplace.cpp
+// RUN: clang-format -style=LLVM -i %T/inplace.cpp
+// RUN: ls %T > %T/files.txt
+// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
+
+// CHECK-NOT: RF{{.*}}.TMP
+
+// The file needs to be larger than 16kiB so that Windows creates a real file
+// mapping object for it.
+ int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
+int this_is_my_int_there_are_many_like_it_but_this_o

[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge accepted this revision.
tigerleapgorge added a comment.
This revision is now accepted and ready to land.

Of the 3 tests.
format-strings.cpp and printf-cstr.cpp have been commited in r294979
For warn-thread-safety-parsing.cpp, bug 32066 has been filed to track the lack 
of thread safety errors in C++11

Closing out this code review.


https://reviews.llvm.org/D29685



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


r296170 - [ODRHash] Add handling of bitfields

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 14:59:28 2017
New Revision: 296170

URL: http://llvm.org/viewvc/llvm-project?rev=296170&view=rev
Log:
[ODRHash] Add handling of bitfields

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296170&r1=296169&r2=296170&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Feb 24 
14:59:28 2017
@@ -133,14 +133,20 @@ def err_module_odr_violation_mismatch_de
   "static assert with condition|"
   "static assert with message|"
   "static assert with %select{|no }4message|"
-  "field %4|field %4 with type %5}3">;
+  "field %4|"
+  "field %4 with type %5|"
+  "%select{non-|}5bitfield %4|"
+  "bitfield %4 with one width expression}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
   "static assert with different condition|"
   "static assert with different message|"
   "static assert with %select{|no }2message|"
-  "field %2|field %2 with type %3}1">;
+  "field %2|"
+  "field %2 with type %3|"
+  "%select{non-|}3bitfield %2|"
+  "bitfield %2 with different width expression}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296170&r1=296169&r2=296170&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 14:59:28 2017
@@ -183,6 +183,13 @@ public:
 
   void VisitFieldDecl(const FieldDecl *D) {
 Inherited::VisitFieldDecl(D);
+
+const bool IsBitfield = D->isBitField();
+Hash.AddBoolean(IsBitfield);
+
+if (IsBitfield) {
+  AddStmt(D->getBitWidth());
+}
   }
 };
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296170&r1=296169&r2=296170&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb 24 14:59:28 2017
@@ -9063,6 +9063,8 @@ void ASTReader::diagnoseOdrViolations()
 StaticAssertOnlyMessage,
 FieldName,
 FieldTypeName,
+FieldSingleBitField,
+FieldDifferentWidthBitField
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9213,6 +9215,30 @@ void ASTReader::diagnoseOdrViolations()
   }
 }
 
+const bool IsFirstBitField = FirstField->isBitField();
+const bool IsSecondBitField = SecondField->isBitField();
+if (IsFirstBitField != IsSecondBitField) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleBitField)
+  << FirstII << IsFirstBitField;
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleBitField)
+  << SecondII << IsSecondBitField;
+  Diagnosed = true;
+  break;
+}
+
+if (IsFirstBitField && IsSecondBitField) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldDifferentWidthBitField)
+  << FirstII << FirstField->getBitWidth()->getSourceRange();
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldDifferentWidthBitField)
+  << SecondII << SecondField->getBitWidth()->getSourceRange();
+  Diagnosed = true;
+  break;
+}
+
 break;
   }
   }

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=296170&r1=296169&r2=296170&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Feb 24 14:59:28 2017
@@ -191,6 +191,47 @@ S5 s5;
 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 
'A' (aka 'int')}}
 #endif
 
+#if defined(FIRST)
+struct S6 {
+  unsigned x;
+};
+#elif defined(SECOND)
+struct S6 {
+  unsigned x : 1;
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'Field::S6' has different definitions in 
different modules; first diff

r296171 - Try to unbreak tests after r296166

2017-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 24 15:01:43 2017
New Revision: 296171

URL: http://llvm.org/viewvc/llvm-project?rev=296171&view=rev
Log:
Try to unbreak tests after r296166

Looks like %T isn't per-test but per-test-directory, and
the rm was deleting temp files written by other tests in
test/Format.  Limit the rm's scope a bit.

Modified:
cfe/trunk/test/Format/inplace.cpp

Modified: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296171&r1=296170&r2=296171&view=diff
==
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 15:01:43 2017
@@ -1,6 +1,6 @@
 // Regression test to check that clang-format does not leave behind temporary
 // files on Windows when doing in-place formatting.
-// RUN: rm %T/*
+// RUN: rm %T/inplace*
 // RUN: cp %s %T/inplace.cpp
 // RUN: clang-format -style=LLVM -i %T/inplace.cpp
 // RUN: ls %T > %T/files.txt


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


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

2017-02-24 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D20710



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


Re: [PATCH] D30339: [libcxxabi] Disable calls to fprintf when building for baremetal targets in release mode

2017-02-24 Thread Jonathan Roelofs via cfe-commits



On 2/24/17 1:48 PM, Eric Fiselier wrote:
Inserting arbitrary feature macros into CMake should not be a 
supported scenario because it results is macros, such as this one, 
which are seemingly dead.


Good point.


Jon



/Eric

On Fri, Feb 24, 2017 at 1:44 PM, Jonathan Roelofs 
mailto:jonat...@codesourcery.com>> wrote:




On 2/24/17 1:30 PM, Eric Fiselier via Phabricator wrote:

EricWF added a comment.

In https://reviews.llvm.org/D30339#685921
, @jroelofs wrote:

In https://reviews.llvm.org/D30339#685919
, @rmaprath wrote:

Perhaps change `config.h` and remove the definition
there and adjust other places accordingly?

The current form is very easy to trip over.


Eric's point is that LIBCXXABI_BAREMETAL is a 0/1 flag,
not a defined/not-defined flag. Please don't change from
one form to the other... it's disruptive to build systems.


I actually think it's better to maintain consistency between
libc++ and libc++abi. And libc++ never uses 0/1 flags. So I
would rather see a fix in `config.h`.

Frankly I don't care that it is disruptive to build systems
unless it's the build system owned by LLVM.


What I really care about is the interface between the build system
owned by LLVM, and the one driving it.


Jon




Repository:
   rL LLVM

https://reviews.llvm.org/D30339 




-- 
Jon Roelofs

jonat...@codesourcery.com 
CodeSourcery / Mentor Embedded




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


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

2017-02-24 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM with a couple of changes.




Comment at: test/Modules/Inputs/merge-using-decls/a.h:25
 
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 template struct E : X, T {

I don't see a reason to `#ifdef` this portion, which should work either way, 
and likewise for the other change to this file. (The changes to the other 
header and to the cpp file look fine and appropriate, though.)



Comment at: test/SemaCXX/warn-thread-safety-parsing.cpp:1273
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif

Please add FIXMEs to this test. These cases are not supposed to be permitted.


https://reviews.llvm.org/D21626



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


[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

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

In https://reviews.llvm.org/D30316#686089, @yaxunl wrote:

> LGTM. Thanks! I assume you will make corresponding changes in backend.


This is to match r295891, so then https://reviews.llvm.org/D28937 is required 
to fix addrspacecast


https://reviews.llvm.org/D30316



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


r296173 - Factor out more commonality between handling of deletion and exception specifications for special member functions.

2017-02-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 24 15:18:47 2017
New Revision: 296173

URL: http://llvm.org/viewvc/llvm-project?rev=296173&view=rev
Log:
Factor out more commonality between handling of deletion and exception 
specifications for special member functions.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=296173&r1=296172&r2=296173&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 24 15:18:47 2017
@@ -6371,11 +6371,28 @@ struct SpecialMemberVisitor {
   Sema::CXXSpecialMember CSM;
   Sema::InheritedConstructorInfo *ICI;
 
-  bool ConstArg = false;
+  // Properties of the special member, computed for convenience.
+  bool IsConstructor = false, IsAssignment = false, ConstArg = false;
 
   SpecialMemberVisitor(Sema &S, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM,
Sema::InheritedConstructorInfo *ICI)
   : S(S), MD(MD), CSM(CSM), ICI(ICI) {
+switch (CSM) {
+case Sema::CXXDefaultConstructor:
+case Sema::CXXCopyConstructor:
+case Sema::CXXMoveConstructor:
+  IsConstructor = true;
+  break;
+case Sema::CXXCopyAssignment:
+case Sema::CXXMoveAssignment:
+  IsAssignment = true;
+  break;
+case Sema::CXXDestructor:
+  break;
+case Sema::CXXInvalid:
+  llvm_unreachable("invalid special member kind");
+}
+
 if (MD->getNumParams()) {
   if (const ReferenceType *RT =
   MD->getParamDecl(0)->getType()->getAs())
@@ -6383,6 +6400,13 @@ struct SpecialMemberVisitor {
 }
   }
 
+  Derived &getDerived() { return static_cast(*this); }
+
+  /// Is this a "move" special member?
+  bool isMove() const {
+return CSM == Sema::CXXMoveConstructor || CSM == Sema::CXXMoveAssignment;
+  }
+
   /// Look up the corresponding special member in the given class.
   Sema::SpecialMemberOverloadResult lookupIn(CXXRecordDecl *Class,
  unsigned Quals, bool IsMutable) {
@@ -6390,16 +6414,68 @@ struct SpecialMemberVisitor {
ConstArg && !IsMutable);
   }
 
+  /// Look up the constructor for the specified base class to see if it's
+  /// overridden due to this being an inherited constructor.
+  Sema::SpecialMemberOverloadResult lookupInheritedCtor(CXXRecordDecl *Class) {
+if (!ICI)
+  return {};
+assert(CSM == Sema::CXXDefaultConstructor);
+auto *BaseCtor =
+  cast(MD)->getInheritedConstructor().getConstructor();
+if (auto *MD = ICI->findConstructorForBase(Class, BaseCtor).first)
+  return MD;
+return {};
+  }
+
   /// A base or member subobject.
   typedef llvm::PointerUnion Subobject;
 
+  /// Get the location to use for a subobject in diagnostics.
   static SourceLocation getSubobjectLoc(Subobject Subobj) {
+// FIXME: For an indirect virtual base, the direct base leading to
+// the indirect virtual base would be a more useful choice.
 if (auto *B = Subobj.dyn_cast())
   return B->getBaseTypeLoc();
 else
   return Subobj.get()->getLocation();
   }
 
+  enum BasesToVisit {
+/// Visit all non-virtual (direct) bases.
+VisitNonVirtualBases,
+/// Visit all direct bases, virtual or not.
+VisitDirectBases,
+/// Visit all non-virtual bases, and all virtual bases if the class
+/// is not abstract.
+VisitPotentiallyConstructedBases,
+/// Visit all direct or virtual bases.
+VisitAllBases
+  };
+
+  // Visit the bases and members of the class.
+  bool visit(BasesToVisit Bases) {
+CXXRecordDecl *RD = MD->getParent();
+
+if (Bases == VisitPotentiallyConstructedBases)
+  Bases = RD->isAbstract() ? VisitNonVirtualBases : VisitAllBases;
+
+for (auto &B : RD->bases())
+  if ((Bases == VisitDirectBases || !B.isVirtual()) &&
+  getDerived().visitBase(&B))
+return true;
+
+if (Bases == VisitAllBases)
+  for (auto &B : RD->vbases())
+if (getDerived().visitBase(&B))
+  return true;
+
+for (auto *F : RD->fields())
+  if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
+  getDerived().visitField(F))
+return true;
+
+return false;
+  }
 };
 }
 
@@ -6408,8 +6484,6 @@ struct SpecialMemberDeletionInfo
 : SpecialMemberVisitor {
   bool Diagnose;
 
-  // Properties of the special member, computed for convenience.
-  bool IsConstructor, IsAssignment, IsMove;
   SourceLocation Loc;
 
   bool AllFieldsAreConst;
@@ -6418,30 +6492,7 @@ struct SpecialMemberDeletionInfo
 Sema::CXXSpecialMember CSM,
 Sema::InheritedConstructorInfo *ICI, bool Diagnose)
   : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
-IsConstructor(false), IsAssignment(false), IsMove(false),
-Loc(MD->g

[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

2017-02-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

AMDGPUTargetMachine::getNullPointerValue needs also be changed to match this, 
otherwise the static initializer will be incorrect for null pointer to private 
addr space. Do you plan to change that?


https://reviews.llvm.org/D30316



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


[PATCH] D30316: AMDGPU: Make 0 the private nullptr value

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

In https://reviews.llvm.org/D30316#686174, @yaxunl wrote:

>   AMDGPUTargetMachine::getNullPointerValue needs also be changed to match 
> this, otherwise the static initializer will be incorrect for null pointer to 
> private addr space. Do you plan to change that?


Yes, that came after I posted the initial version. I need to update to re-use 
that


https://reviews.llvm.org/D30316



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


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Looks NFC to me.




Comment at: lib/CodeGen/CGBlocks.cpp:1414
+
+} // end anonymous namespace
+

I don't see the need for two GenericInfo types (although it's plausible it'll 
make sense with your upcoming changes!). I had in mind a single 'enum 
BlockCaptureOperationType' with 8 entries, and a 'struct BlockCaptureOperation'.



Comment at: lib/CodeGen/CGBlocks.cpp:1478
+  }
+}
+

Ditto (re: removing continue statements where possible).



Comment at: lib/CodeGen/CGBlocks.cpp:1666
+  }
+}
+

It looks like there are 4 paths which prep some part of a DestroyInfo and then 
fall through to the emplace_back. I think this logic would be easier to follow 
if the emplace_backs occurred right after the DestroyInfo is prepped (i.e, have 
4 emplace_backs, and none at the end of the for loop). That should let you get 
rid of 3 continue statements (imo those were hard to follow).


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


Re: r296166 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

2017-02-24 Thread Renato Golin via cfe-commits
On 24 February 2017 at 20:49, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri Feb 24 14:49:00 2017
> New Revision: 296166
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296166&view=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows, PR26125
>
> Fix and analysis by Wei Mao  (see bug), test by me.

Hi Nico,

This one looks yours:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5005

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/4075

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/4386

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/4439

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/4450

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


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

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

Changed prior to commit:
  https://reviews.llvm.org/D20710?vs=87309&id=89728#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20710

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

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

[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-02-24 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Dominic, this (https://reviews.llvm.org/D28952) and  
https://reviews.llvm.org/D26061 look get to me! Let's get these two committed! 
We'd like to get to a place where in-tree incremental development can be done 
on the Z3 constraint manager.

On my machine total Analysis test time increases from 25s to 90s when the Z3 
tests are enabled using a static Z3 library. Testing time when Z3 is not 
enabled does not change measurably.

Here's how I suggest staging these in. Please give the bots time to settle 
after each commit.

1. Apply the refactoring changes from https://reviews.llvm.org/D26061. This is 
NFC (no functional change).
2. Split out the test changes from https://reviews.llvm.org/D28952. This would 
change the tests to use 'clang_analyze_cc1' and change the lit.cfg to add a 
normal substitution for it. (But not call the analyzer twice). This is also NFC.
3. Add the new constraint solver and the lit/CMake changes for for the rest of 
https://reviews.llvm.org/D28952.

This will separate the stuff that is unlikely to break from the build system 
changes, which might need to be reverted quickly.

Once this is done, we (I) will add a bot that automatically runs the Z3 tests 
to make sure we catch regressions that affect the Z3 solver.

With the bot in place we will review  https://reviews.llvm.org/D28953,  
https://reviews.llvm.org/D28954, and https://reviews.llvm.org/D28955 separately.

Does that sound good to you?


https://reviews.llvm.org/D28952



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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-24 Thread Julian Bangert via Phabricator via cfe-commits
jbangert updated this revision to Diff 89730.
jbangert marked an inline comment as done.
jbangert added a comment.

use llvm::report_fatal_error instead of unreachable.


https://reviews.llvm.org/D29621

Files:
  include/clang/Tooling/RefactoringCallbacks.h
  lib/Tooling/RefactoringCallbacks.cpp
  unittests/Tooling/RefactoringCallbacksTest.cpp

Index: unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- unittests/Tooling/RefactoringCallbacksTest.cpp
+++ unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -7,31 +7,30 @@
 //
 //===--===//
 
-#include "clang/Tooling/RefactoringCallbacks.h"
 #include "RewriterTestContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/RefactoringCallbacks.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
 using namespace ast_matchers;
 
 template 
-void expectRewritten(const std::string &Code,
- const std::string &Expected,
- const T &AMatcher,
- RefactoringCallback &Callback) {
-  MatchFinder Finder;
+void expectRewritten(const std::string &Code, const std::string &Expected,
+ const T &AMatcher, RefactoringCallback &Callback) {
+  std::map FileToReplace;
+  ASTMatchRefactorer Finder(FileToReplace);
   Finder.addMatcher(AMatcher, &Callback);
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory(&Finder));
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
   << "Parsing error in \"" << Code << "\"";
   RewriterTestContext Context;
   FileID ID = Context.createInMemoryFile("input.cc", Code);
-  EXPECT_TRUE(tooling::applyAllReplacements(Callback.getReplacements(),
+  EXPECT_TRUE(tooling::applyAllReplacements(FileToReplace["input.cc"],
 Context.Rewrite));
   EXPECT_EQ(Expected, Context.getRewrittenText(ID));
 }
@@ -61,40 +60,94 @@
   std::string Code = "void f() { int i = 1; }";
   std::string Expected = "void f() { int i = 2; }";
   ReplaceStmtWithText Callback("id", "2");
-  expectRewritten(Code, Expected, id("id", expr(integerLiteral())),
-  Callback);
+  expectRewritten(Code, Expected, id("id", expr(integerLiteral())), Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesStmtWithStmt) {
   std::string Code = "void f() { int i = false ? 1 : i * 2; }";
   std::string Expected = "void f() { int i = i * 2; }";
   ReplaceStmtWithStmt Callback("always-false", "should-be");
-  expectRewritten(Code, Expected,
-  id("always-false", conditionalOperator(
-  hasCondition(cxxBoolLiteral(equals(false))),
-  hasFalseExpression(id("should-be", expr(),
+  expectRewritten(
+  Code, Expected,
+  id("always-false",
+ conditionalOperator(hasCondition(cxxBoolLiteral(equals(false))),
+ hasFalseExpression(id("should-be", expr(),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesIfStmt) {
   std::string Code = "bool a; void f() { if (a) f(); else a = true; }";
   std::string Expected = "bool a; void f() { f(); }";
   ReplaceIfStmtWithItsBody Callback("id", true);
-  expectRewritten(Code, Expected,
-  id("id", ifStmt(
-  hasCondition(implicitCastExpr(hasSourceExpression(
-  declRefExpr(to(varDecl(hasName("a"),
+  expectRewritten(
+  Code, Expected,
+  id("id", ifStmt(hasCondition(implicitCastExpr(hasSourceExpression(
+   declRefExpr(to(varDecl(hasName("a"),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, RemovesEntireIfOnEmptyElse) {
   std::string Code = "void f() { if (false) int i = 0; }";
   std::string Expected = "void f() {  }";
   ReplaceIfStmtWithItsBody Callback("id", false);
   expectRewritten(Code, Expected,
-  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
-  Callback);
+  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
+  Callback);
 }
 
+TEST(RefactoringCallbacksTest, TemplateJustText) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { FOO }";
+  auto Callback = ReplaceNodeWithTemplate::create("id", "FOO");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected, id("id", declStmt()), **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateSimpleSubst) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { long x = 1; }";
+  auto Callback = ReplaceNodeWithTemplate::create("decl", "long x = ${init}");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected,
+  id("decl", varDecl(hasInitializer(id("init", expr(),
+  **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateLiteral) {
+  std::string Code = "void f() { int i = 1; }";

[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-24 Thread Julian Bangert via Phabricator via cfe-commits
jbangert added inline comments.



Comment at: lib/Tooling/RefactoringCallbacks.cpp:213
+llvm::errs() << "Node " << Element.Value
+ << " used in replacement template not bound in Matcher 
\n";
+llvm_unreachable("Unbound node in replacement template.");

sbenza wrote:
> I don't know if stderr is the best place for this error output.
> Maybe we should take a sink of some sort in the constructor.
There's a FIXME: above that addresses the need for better error handling, and 
this one just duplicated their workaround. 
Ultimately, clang::tooling:: should probably provide infrastructure for 
reporting problems (I would imagine all refactoring tools have errors 
occassionally, and they need some way of reporting/handling them). 



Comment at: lib/Tooling/RefactoringCallbacks.cpp:214
+ << " used in replacement template not bound in Matcher 
\n";
+llvm_unreachable("Unbound node in replacement template.");
+  }

sbenza wrote:
> I don't think this is ok.
> afaik, llvm_unreachable leads to undefined behavior if it is reached in opt 
> mode.
> This error can be triggered from user input. We should not fail that way.
Using llvm::report_fatal_error for now. See the above for better error 
handling. 


https://reviews.llvm.org/D29621



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


[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 89733.
vsk added a comment.

- Make the suggested readability improvements, and fix a comment in the test 
case.


https://reviews.llvm.org/D29369

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/compound-assign-overflow.c
  test/CodeGen/ubsan-promoted-arith.cpp
  test/CodeGen/unsigned-promotion.c

Index: test/CodeGen/unsigned-promotion.c
===
--- test/CodeGen/unsigned-promotion.c
+++ test/CodeGen/unsigned-promotion.c
@@ -7,53 +7,6 @@
 // RUN:   -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=CHECKU
 
 unsigned short si, sj, sk;
-unsigned char ci, cj, ck;
-
-extern void opaqueshort(unsigned short);
-extern void opaquechar(unsigned char);
-
-// CHECKS-LABEL:   define void @testshortadd()
-// CHECKU-LABEL: define void @testshortadd()
-void testshortadd() {
-  // CHECKS:load i16, i16* @sj
-  // CHECKS:load i16, i16* @sk
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_add_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i16, i16* @sj
-  // CHECKU:  [[T2:%.*]] = zext i16 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i16, i16* @sk
-  // CHECKU:  [[T4:%.*]] = zext i16 [[T3]]
-  // CHECKU-NOT:  llvm.sadd
-  // CHECKU-NOT:  llvm.uadd
-  // CHECKU:  [[T5:%.*]] = add nsw i32 [[T2]], [[T4]]
-
-  si = sj + sk;
-}
-
-// CHECKS-LABEL:   define void @testshortsub()
-// CHECKU-LABEL: define void @testshortsub()
-void testshortsub() {
-
-  // CHECKS:load i16, i16* @sj
-  // CHECKS:load i16, i16* @sk
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_sub_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i16, i16* @sj
-  // CHECKU:  [[T2:%.*]] = zext i16 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i16, i16* @sk
-  // CHECKU:  [[T4:%.*]] = zext i16 [[T3]]
-  // CHECKU-NOT:  llvm.ssub
-  // CHECKU-NOT:  llvm.usub
-  // CHECKU:  [[T5:%.*]] = sub nsw i32 [[T2]], [[T4]]
-
-  si = sj - sk;
-}
 
 // CHECKS-LABEL:   define void @testshortmul()
 // CHECKU-LABEL: define void @testshortmul()
@@ -75,69 +28,3 @@
   // CHECKU:  [[T5:%.*]] = mul nsw i32 [[T2]], [[T4]]
   si = sj * sk;
 }
-
-// CHECKS-LABEL:   define void @testcharadd()
-// CHECKU-LABEL: define void @testcharadd()
-void testcharadd() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_add_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, i8* @ck
-  // CHECKU:  [[T4:%.*]] = zext i8 [[T3]]
-  // CHECKU-NOT:  llvm.sadd
-  // CHECKU-NOT:  llvm.uadd
-  // CHECKU:  [[T5:%.*]] = add nsw i32 [[T2]], [[T4]]
-
-  ci = cj + ck;
-}
-
-// CHECKS-LABEL:   define void @testcharsub()
-// CHECKU-LABEL: define void @testcharsub()
-void testcharsub() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_sub_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, i8* @ck
-  // CHECKU:  [[T4:%.*]] = zext i8 [[T3]]
-  // CHECKU-NOT:  llvm.ssub
-  // CHECKU-NOT:  llvm.usub
-  // CHECKU:  [[T5:%.*]] = sub nsw i32 [[T2]], [[T4]]
-
-  ci = cj - ck;
-}
-
-// CHECKS-LABEL:   define void @testcharmul()
-// CHECKU-LABEL: define void @testcharmul()
-void testcharmul() {
-
-  // CHECKS:load i8, i8* @cj
-  // CHECKS:load i8, i8* @ck
-  // CHECKS:[[T1:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[T2:%.*]], i32 [[T3:%.*]])
-  // CHECKS-NEXT:   [[T4:%.*]] = extractvalue { i32, i1 } [[T1]], 0
-  // CHECKS-NEXT:   [[T5:%.*]] = extractvalue { i32, i1 } [[T1]], 1
-  // CHECKS:call void @__ubsan_handle_mul_overflow
-  //
-  // CHECKU:  [[T1:%.*]] = load i8, i8* @cj
-  // CHECKU:  [[T2:%.*]] = zext i8 [[T1]]
-  // CHECKU:  [[T3:%.*]] = load i8, i8*

[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 89734.
vsk added a comment.

- Add a small test that shows why the 'isIntegerType' check is required (we'd 
crash otherwise).


https://reviews.llvm.org/D29437

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ubsan-promoted-arith.cpp


Index: test/CodeGen/ubsan-promoted-arith.cpp
===
--- test/CodeGen/ubsan-promoted-arith.cpp
+++ test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope(&CGF);
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())


Index: test/CodeGen/ubsan-promoted-arith.cpp
===
--- test/CodeGen/ubsan-promoted-arith.cpp
+++ test/CodeGen/ubsan-promoted-arith.cpp
@@ -2,6 +2,7 @@
 
 typedef unsigned char uchar;
 typedef unsigned short ushort;
+typedef int int4 __attribute__((ext_vector_type(4)));
 
 enum E1 : int {
   a
@@ -101,12 +102,14 @@
 // CHECK-NOT: ubsan_handle_divrem_overflow
 uchar rem2(uchar uc) { return uc % uc; }
 
-// FIXME: This is a long-standing false negative.
-//
 // CHECK-LABEL: define signext i8 @_Z4rem3
-// rdar30301609: ubsan_handle_divrem_overflow
+// CHECK: ubsan_handle_divrem_overflow
 char rem3(int i, char c) { return i % c; }
 
+// CHECK-LABEL: define signext i8 @_Z4rem4
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem4(char c, int i) { return c % i; }
+
 // CHECK-LABEL: define signext i8 @_Z4inc1
 // CHECK-NOT: sadd.with.overflow
 char inc1(char c) { return c++ + (char)0; }
@@ -122,3 +125,7 @@
 // CHECK-LABEL: define void @_Z4inc4
 // CHECK-NOT: uadd.with.overflow
 void inc4(uchar uc) { uc++; }
+
+// CHECK-LABEL: define <4 x i32> @_Z4vremDv4_iS_
+// CHECK-NOT: ubsan_handle_divrem_overflow
+int4 vrem(int4 a, int4 b) { return a % b; }
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
   // Rem in C can't be a floating point type: C99 6.5.5p2.
-  if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) {
+  if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) ||
+   CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) &&
+  Ops.Ty->isIntegerType()) {
 CodeGenFunction::SanitizerScope SanScope(&CGF);
 llvm::Value *Zero = llvm::Constant::getNullValue(ConvertType(Ops.Ty));
-
-if (Ops.Ty->isIntegerType())
-  EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
+EmitUndefinedBehaviorIntegerDivAndRemCheck(Ops, Zero, false);
   }
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29972: Make Lit tests C++11 compatible - accessible destructors

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge abandoned this revision.
tigerleapgorge added a comment.

https://reviews.llvm.org/D20710 is a superset of this patch.
https://reviews.llvm.org/D20710 has been committed in 
https://reviews.llvm.org/rL296184.
No need for this patch.


https://reviews.llvm.org/D29972



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


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

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

Updated patch in accordance to Richard Smith's comments.


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,11 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1466,24 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+// expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/default-constructor-initializers.cpp
===
--- test/SemaCXX/default-constructor-initializers.cpp
+++ test/SemaCXX/default-constructor-initializers.cpp
@@ -1,26 +1,59 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct X1 { // has no implicit default constructor
X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note@-2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-// expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{must explicitly initialize the member 'x2'}}
+// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{member is declared here}}
+#else
+  // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}}
+#endif
+
+  X2 & rx2;
+#if __cplusplus <= 19

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

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge marked 2 inline comments as done.
tigerleapgorge added inline comments.



Comment at: test/SemaCXX/PR9572.cpp:34
+// expected-error@-2 {{non-deleted function '~Bar' cannot override a deleted 
function}}
+// expected-note@-3 {{while declaring the implicit destructor for 'Bar'}}
+#endif

Clang added this note quite recently.


https://reviews.llvm.org/D21626



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


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

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

Changed prior to commit:
  https://reviews.llvm.org/D21626?vs=89736&id=89737#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21626

Files:
  cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h
  cfe/trunk/test/Modules/merge-using-decls.cpp
  cfe/trunk/test/SemaCXX/PR9572.cpp
  cfe/trunk/test/SemaCXX/default-assignment-operator.cpp
  cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
  cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Index: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,11 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1466,24 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error@-3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+// expected-error@-3 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
+++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
@@ -1,26 +1,59 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct X1 { // has no implicit default constructor
X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note@-2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-// expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{must explicitly initialize the member 'x2'}}
+// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#i

[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-24 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge closed this revision.
tigerleapgorge added a comment.

warn-thread-safety-parsing.cpp has been commited in 
https://reviews.llvm.org/rL296193.
The following FIXME has been added to track this bug.

//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect


https://reviews.llvm.org/D29685



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


[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D29437



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


r296198 - [ODRHash] Finish FieldDecl support by handling mutable and initializers.

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 17:35:37 2017
New Revision: 296198

URL: http://llvm.org/viewvc/llvm-project?rev=296198&view=rev
Log:
[ODRHash] Finish FieldDecl support by handling mutable and initializers.

https://reviews.llvm.org/rL296170

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296198&r1=296197&r2=296198&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Feb 24 
17:35:37 2017
@@ -136,7 +136,10 @@ def err_module_odr_violation_mismatch_de
   "field %4|"
   "field %4 with type %5|"
   "%select{non-|}5bitfield %4|"
-  "bitfield %4 with one width expression}3">;
+  "bitfield %4 with one width expression|"
+  "%select{non-|}5mutable field %4|"
+  "field %4 with %select{no|an}5 initalizer|"
+  "field %4 with an initializer}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -146,7 +149,10 @@ def note_module_odr_violation_mismatch_d
   "field %2|"
   "field %2 with type %3|"
   "%select{non-|}3bitfield %2|"
-  "bitfield %2 with different width expression}1">;
+  "bitfield %2 with different width expression|"
+  "%select{non-|}3mutable field %2|"
+  "field %2 with %select{no|an}3 initializer|"
+  "field %2 with a different initializer}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296198&r1=296197&r2=296198&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 17:35:37 2017
@@ -190,6 +190,9 @@ public:
 if (IsBitfield) {
   AddStmt(D->getBitWidth());
 }
+
+Hash.AddBoolean(D->isMutable());
+AddStmt(D->getInClassInitializer());
   }
 };
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296198&r1=296197&r2=296198&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Feb 24 17:35:37 2017
@@ -9064,7 +9064,10 @@ void ASTReader::diagnoseOdrViolations()
 FieldName,
 FieldTypeName,
 FieldSingleBitField,
-FieldDifferentWidthBitField
+FieldDifferentWidthBitField,
+FieldSingleMutable,
+FieldSingleInitializer,
+FieldDifferentInitializers,
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9239,6 +9242,50 @@ void ASTReader::diagnoseOdrViolations()
   break;
 }
 
+const bool IsFirstMutable = FirstField->isMutable();
+const bool IsSecondMutable = SecondField->isMutable();
+if (IsFirstMutable != IsSecondMutable) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleMutable)
+  << FirstII << IsFirstMutable;
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleMutable)
+  << SecondII << IsSecondMutable;
+  Diagnosed = true;
+  break;
+}
+
+const Expr *FirstInitializer = FirstField->getInClassInitializer();
+const Expr *SecondInitializer = SecondField->getInClassInitializer();
+if ((!FirstInitializer && SecondInitializer) ||
+(FirstInitializer && !SecondInitializer)) {
+  ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+   FieldSingleInitializer)
+  << FirstII << (FirstInitializer != nullptr);
+  ODRDiagNote(SecondField->getLocation(), 
SecondField->getSourceRange(),
+  FieldSingleInitializer)
+  << SecondII << (SecondInitializer != nullptr);
+  Diagnosed = true;
+  break;
+}
+
+if (FirstInitializer && SecondInitializer) {
+  unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
+  unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
+  if (FirstInitHash != SecondInitHash) {
+ODRDiagError(FirstField->getLocation(),
+ FirstField->getSourceRange(),
+ FieldDifferentInitializers)
+<< FirstII << FirstInitializer->getSource

r296209 - [PS4] Set our default dialect to C++11. NFC for other targets.

2017-02-24 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 24 18:15:45 2017
New Revision: 296209

URL: http://llvm.org/viewvc/llvm-project?rev=296209&view=rev
Log:
[PS4] Set our default dialect to C++11. NFC for other targets.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=296209&r1=296208&r2=296209&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 24 18:15:45 2017
@@ -1582,7 +1582,11 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  LangStd = LangStandard::lang_gnucxx98;
+  // The PS4 uses C++11 as the default C++ standard.
+  if (T.isPS4())
+LangStd = LangStandard::lang_gnucxx11;
+  else
+LangStd = LangStandard::lang_gnucxx98;
   break;
 case IK_RenderScript:
   LangStd = LangStandard::lang_c99;


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


[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Will Dietz via Phabricator via cfe-commits
dtzWill accepted this revision.
dtzWill added a comment.
This revision is now accepted and ready to land.

Sorry for the delay!

LGTM, thanks!


https://reviews.llvm.org/D29369



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


  1   2   >