[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=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=296097=296098=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


[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=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=296099=296100=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=296099=296100=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] 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=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=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=296098=296099=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=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


[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 

[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 ) {
+bool Sema::CaptureHasSideEffects(const LambdaScopeInfo::Capture ) {
   if (!From.isVLATypeCapture()) {
 Expr *Init = 

[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 ) override {
-Symbols.push_back(Symbol);
+  void reportSymbols(llvm::StringRef FileName,
+ const SymbolInfo::SignalMap ) override {
+for (const auto  : NewSymbols)
+  Symbols[Entry.first] += Entry.second;
   }
 
   bool hasSymbol(const SymbolInfo ) const {
-for (const auto  : 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 ) 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 ) {
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool hasUse(const SymbolInfo ) { 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(, ));
 
 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 = ::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 = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
 

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  : 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] 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, );
+OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers();
 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  = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, (), Style);
+  OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+  (), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers();
   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) {
@@ 

[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] 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 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  : 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] 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, );
+OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers();
 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  = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, (), Style);
+  OldNamespace, NewNamespace, FilePattern, WhiteListedSymbolPatterns,
+  (), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers();
   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) {
@@ 

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


[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 ) override {
-Symbols.push_back(Symbol);
+  void reportSymbols(llvm::StringRef FileName,
+ const SymbolInfo::SignalMap ) override {
+for (const auto  : NewSymbols)
+  Symbols[Entry.first] += Entry.second;
   }
 
   bool hasSymbol(const SymbolInfo ) const {
-for (const auto  : 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 ) 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 ) {
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool hasUse(const SymbolInfo ) { 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(, ));
 
 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 = ::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 = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4,
   

[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, );
+OldNamespace, NewNamespace, FilePattern, WhiteList,
+);
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers();
 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  = 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, (), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  (), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers();
   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 

[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] 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, );
+OldNamespace, NewNamespace, FilePattern,
+/*WhiteListedSymbolPatterns*/ {}, );
 ast_matchers::MatchFinder Finder;
 NamespaceTool.registerMatchers();
 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  = 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, (), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  (), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers();
   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 

[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 = 
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 , 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 ) 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 = 
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 , 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 ) 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=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=296109=296110=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  : 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  : 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=296109=296110=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=296109=296110=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();
+

[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=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  = 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, (), Style);
+  OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+  (), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers();
   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  : WhiteListedSymbolPatterns)
+WhiteListedSymbolRegexes.emplace_back(Pattern);
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -736,6 +740,9 @@
   Result.SourceManager->getSpellingLoc(End)),
   *Result.SourceManager, 

[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, );
+OldNamespace, NewNamespace, FilePattern, WhiteList,
+);

`/*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] 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, );
   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 *const 

[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())
+__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, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 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())
+__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())
+__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, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(, 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())
+__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


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=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=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


[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=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=296112=296113=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


[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, );
   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 = "Hello";

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=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=295473=295474=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=295473=295474=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


r296221 - [ODRHash] Move inherited visitor call to end of function.

2017-02-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 24 19:29:34 2017
New Revision: 296221

URL: http://llvm.org/viewvc/llvm-project?rev=296221=rev
Log:
[ODRHash] Move inherited visitor call to end of function.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296221=296220=296221=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 19:29:34 2017
@@ -182,8 +182,6 @@ public:
   }
 
   void VisitFieldDecl(const FieldDecl *D) {
-Inherited::VisitFieldDecl(D);
-
 const bool IsBitfield = D->isBitField();
 Hash.AddBoolean(IsBitfield);
 
@@ -193,6 +191,8 @@ public:
 
 Hash.AddBoolean(D->isMutable());
 AddStmt(D->getInClassInitializer());
+
+Inherited::VisitFieldDecl(D);
   }
 };
 


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


r296231 - [profiling] Fix profile counter increment when emitting selects (PR32019)

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 20:30:03 2017
New Revision: 296231

URL: http://llvm.org/viewvc/llvm-project?rev=296231=rev
Log:
[profiling] Fix profile counter increment when emitting selects (PR32019)

Clang has logic to lower certain conditional expressions directly into
llvm select instructions. However, it does not emit the correct profile
counter increment as it does this: it emits an unconditional increment
of the counter for the 'then branch', even if the value selected is from
the 'else branch' (this is PR32019).

That means, given the following snippet, we would report that "0" is
selected twice, and that "1" is never selected:

  int f1(int x) {
return x ? 0 : 1;
   ^2  ^0
  }

  f1(0);
  f1(1);

Fix the problem by using the instrprof_increment_step intrinsic to do
the proper increment.

Added:
cfe/trunk/test/Profile/c-ternary.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 20:30:03 2017
@@ -3414,9 +3414,11 @@ VisitAbstractConditionalOperator(const A
   // safe to evaluate the LHS and RHS unconditionally.
   if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) &&
   isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) {
-CGF.incrementProfileCounter(E);
-
 llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr);
+llvm::Value *StepV = Builder.CreateZExtOrBitCast(CondV, CGF.Int64Ty);
+
+CGF.incrementProfileCounter(E, StepV);
+
 llvm::Value *LHS = Visit(lhsExpr);
 llvm::Value *RHS = Visit(rhsExpr);
 if (!LHS) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Feb 24 20:30:03 2017
@@ -1127,10 +1127,11 @@ private:
 uint64_t LoopCount);
 
 public:
-  /// Increment the profiler's counter for the given statement.
-  void incrementProfileCounter(const Stmt *S) {
+  /// Increment the profiler's counter for the given statement by \p StepV.
+  /// If \p StepV is null, the default increment is 1.
+  void incrementProfileCounter(const Stmt *S, llvm::Value *StepV = nullptr) {
 if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S);
+  PGO.emitCounterIncrement(Builder, S, StepV);
 PGO.setCurrentStmt(S);
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296231=296230=296231=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Feb 24 20:30:03 2017
@@ -739,7 +739,8 @@ CodeGenPGO::applyFunctionAttributes(llvm
   Fn->setEntryCount(FunctionCount);
 }
 
-void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S) {
+void CodeGenPGO::emitCounterIncrement(CGBuilderTy , const Stmt *S,
+  llvm::Value *StepV) {
   if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
 return;
   if (!Builder.GetInsertBlock())
@@ -747,11 +748,17 @@ void CodeGenPGO::emitCounterIncrement(CG
 
   unsigned Counter = (*RegionCounterMap)[S];
   auto *I8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-  Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
- {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
-  Builder.getInt64(FunctionHash),
-  Builder.getInt32(NumRegionCounters),
-  Builder.getInt32(Counter)});
+
+  ArrayRef Args = {
+  llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+  Builder.getInt64(FunctionHash), Builder.getInt32(NumRegionCounters),
+  Builder.getInt32(Counter), StepV};
+  if (!StepV)
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment),
+   Args.drop_back(1));
+  else
+Builder.CreateCall(
+CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args);
 }
 
 // This method either inserts a call to the profile run-time during

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=296231=296230=296231=diff
==

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=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=296208=296209=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


r296213 - [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 18:43:36 2017
New Revision: 296213

URL: http://llvm.org/viewvc/llvm-project?rev=296213=rev
Log:
[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

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

Added:
cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/compound-assign-overflow.c
cfe/trunk/test/CodeGen/unsigned-promotion.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296213=296212=296213=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 18:43:36 2017
@@ -24,6 +24,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
@@ -58,6 +59,59 @@ static bool MustVisitNullValue(const Exp
   return E->getType()->isNullPtrType();
 }
 
+/// If \p E is a widened promoted integer, get its base (unpromoted) type.
+static llvm::Optional getUnwidenedIntegerType(const ASTContext ,
+const Expr *E) {
+  const Expr *Base = E->IgnoreImpCasts();
+  if (E == Base)
+return llvm::None;
+
+  QualType BaseTy = Base->getType();
+  if (!BaseTy->isPromotableIntegerType() ||
+  Ctx.getTypeSize(BaseTy) >= Ctx.getTypeSize(E->getType()))
+return llvm::None;
+
+  return BaseTy;
+}
+
+/// Check if \p E is a widened promoted integer.
+static bool IsWidenedIntegerOp(const ASTContext , const Expr *E) {
+  return getUnwidenedIntegerType(Ctx, E).hasValue();
+}
+
+/// Check if we can skip the overflow check for \p Op.
+static bool CanElideOverflowCheck(const ASTContext , const BinOpInfo ) {
+  assert(isa(Op.E) ||
+ isa(Op.E) && "Expected a unary or binary operator");
+
+  if (const auto *UO = dyn_cast(Op.E))
+return IsWidenedIntegerOp(Ctx, UO->getSubExpr());
+
+  const auto *BO = cast(Op.E);
+  auto OptionalLHSTy = getUnwidenedIntegerType(Ctx, BO->getLHS());
+  if (!OptionalLHSTy)
+return false;
+
+  auto OptionalRHSTy = getUnwidenedIntegerType(Ctx, BO->getRHS());
+  if (!OptionalRHSTy)
+return false;
+
+  QualType LHSTy = *OptionalLHSTy;
+  QualType RHSTy = *OptionalRHSTy;
+
+  // We usually don't need overflow checks for binary operations with widened
+  // operands. Multiplication with promoted unsigned operands is a special 
case.
+  if ((Op.Opcode != BO_Mul && Op.Opcode != BO_MulAssign) ||
+  !LHSTy->isUnsignedIntegerType() || !RHSTy->isUnsignedIntegerType())
+return true;
+
+  // The overflow check can be skipped if either one of the unpromoted types
+  // are less than half the size of the promoted type.
+  unsigned PromotedSize = Ctx.getTypeSize(Op.E->getType());
+  return (2 * Ctx.getTypeSize(LHSTy)) < PromotedSize ||
+ (2 * Ctx.getTypeSize(RHSTy)) < PromotedSize;
+}
+
 class ScalarExprEmitter
   : public StmtVisitor {
   CodeGenFunction 
@@ -482,12 +536,15 @@ public:
   return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
 // Fall through.
   case LangOptions::SOB_Trapping:
+if (CanElideOverflowCheck(CGF.getContext(), Ops))
+  return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
 return EmitOverflowCheckedBinOp(Ops);
   }
 }
 
 if (Ops.Ty->isUnsignedIntegerType() &&
-CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow))
+CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow) &&
+!CanElideOverflowCheck(CGF.getContext(), Ops))
   return EmitOverflowCheckedBinOp(Ops);
 
 if (Ops.LHS->getType()->isFPOrFPVectorTy())
@@ -1663,6 +1720,8 @@ llvm::Value *ScalarExprEmitter::EmitIncD
   return Builder.CreateNSWAdd(InVal, Amount, Name);
 // Fall through.
   case LangOptions::SOB_Trapping:
+if (IsWidenedIntegerOp(CGF.getContext(), E->getSubExpr()))
+  return Builder.CreateNSWAdd(InVal, Amount, Name);
 return EmitOverflowCheckedBinOp(createBinOpInfoFromIncDec(E, InVal, 
IsInc));
   }
   llvm_unreachable("Unknown SignedOverflowBehaviorTy");
@@ -2281,8 +2340,10 @@ void ScalarExprEmitter::EmitUndefinedBeh
 SanitizerKind::IntegerDivideByZero));
   }
 
+  const auto *BO = cast(Ops.E);
   if (CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow) &&
- 

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

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296214: [ubsan] Detect signed overflow UB in remainder 
operations (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29437?vs=89734=89753#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29437

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


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // 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();
 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: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/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: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2403,12 +2403,12 @@
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // 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();
 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: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/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; }
___
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 Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296213: [ubsan] Omit superflous overflow checks for promoted 
arithmetic (PR20193) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29369?vs=89733=89752#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29369

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

Index: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
===
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+
+enum E1 : int {
+  a
+};
+
+enum E2 : char {
+  b
+};
+
+// CHECK-LABEL: define signext i8 @_Z4add1
+// CHECK-NOT: sadd.with.overflow
+char add1(char c) { return c + c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4add2
+// CHECK-NOT: uadd.with.overflow
+uchar add2(uchar uc) { return uc + uc; }
+
+// CHECK-LABEL: define i32 @_Z4add3
+// CHECK: sadd.with.overflow
+int add3(E1 e) { return e + a; }
+
+// CHECK-LABEL: define signext i8 @_Z4add4
+// CHECK-NOT: sadd.with.overflow
+char add4(E2 e) { return e + b; }
+
+// CHECK-LABEL: define signext i8 @_Z4sub1
+// CHECK-NOT: ssub.with.overflow
+char sub1(char c) { return c - c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4sub2
+// CHECK-NOT: usub.with.overflow
+uchar sub2(uchar uc) { return uc - uc; }
+
+// CHECK-LABEL: define signext i8 @_Z4sub3
+// CHECK-NOT: ssub.with.overflow
+char sub3(char c) { return -c; }
+
+// Note: -INT_MIN can overflow.
+//
+// CHECK-LABEL: define i32 @_Z4sub4
+// CHECK: ssub.with.overflow
+int sub4(int i) { return -i; }
+
+// CHECK-LABEL: define signext i8 @_Z4mul1
+// CHECK-NOT: smul.with.overflow
+char mul1(char c) { return c * c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4mul2
+// CHECK-NOT: smul.with.overflow
+uchar mul2(uchar uc) { return uc * uc; }
+
+// Note: USHRT_MAX * USHRT_MAX can overflow.
+//
+// CHECK-LABEL: define zeroext i16 @_Z4mul3
+// CHECK: smul.with.overflow
+ushort mul3(ushort us) { return us * us; }
+
+// CHECK-LABEL: define i32 @_Z4mul4
+// CHECK: smul.with.overflow
+int mul4(int i, char c) { return i * c; }
+
+// CHECK-LABEL: define i32 @_Z4mul5
+// CHECK: smul.with.overflow
+int mul5(int i, char c) { return c * i; }
+
+// CHECK-LABEL: define signext i16 @_Z4mul6
+// CHECK-NOT: smul.with.overflow
+short mul6(short s) { return s * s; }
+
+// CHECK-LABEL: define signext i8 @_Z4div1
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char div1(char c) { return c / c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4div2
+// CHECK-NOT: ubsan_handle_divrem_overflow
+uchar div2(uchar uc) { return uc / uc; }
+
+// CHECK-LABEL: define signext i8 @_Z4div3
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char div3(char c, int i) { return c / i; }
+
+// CHECK-LABEL: define signext i8 @_Z4div4
+// CHECK: ubsan_handle_divrem_overflow
+char div4(int i, char c) { return i / c; }
+
+// Note: INT_MIN / -1 can overflow.
+//
+// CHECK-LABEL: define signext i8 @_Z4div5
+// CHECK: ubsan_handle_divrem_overflow
+char div5(int i, char c) { return i / c; }
+
+// CHECK-LABEL: define signext i8 @_Z4rem1
+// CHECK-NOT: ubsan_handle_divrem_overflow
+char rem1(char c) { return c % c; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4rem2
+// 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
+char rem3(int i, char c) { return i % c; }
+
+// CHECK-LABEL: define signext i8 @_Z4inc1
+// CHECK-NOT: sadd.with.overflow
+char inc1(char c) { return c++ + (char)0; }
+
+// CHECK-LABEL: define zeroext i8 @_Z4inc2
+// CHECK-NOT: uadd.with.overflow
+uchar inc2(uchar uc) { return uc++ + (uchar)0; }
+
+// CHECK-LABEL: define void @_Z4inc3
+// CHECK-NOT: sadd.with.overflow
+void inc3(char c) { c++; }
+
+// CHECK-LABEL: define void @_Z4inc4
+// CHECK-NOT: uadd.with.overflow
+void inc4(uchar uc) { uc++; }
Index: cfe/trunk/test/CodeGen/unsigned-promotion.c
===
--- cfe/trunk/test/CodeGen/unsigned-promotion.c
+++ cfe/trunk/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:  

r296214 - [ubsan] Detect signed overflow UB in remainder operations

2017-02-24 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 24 18:43:39 2017
New Revision: 296214

URL: http://llvm.org/viewvc/llvm-project?rev=296214=rev
Log:
[ubsan] Detect signed overflow UB in remainder operations

Teach ubsan to diagnose remainder operations which have undefined
behavior due to signed overflow (e.g INT_MIN % -1).

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

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296214=296213=296214=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Feb 24 18:43:39 2017
@@ -2403,12 +2403,12 @@ Value *ScalarExprEmitter::EmitDiv(const
 
 Value *ScalarExprEmitter::EmitRem(const BinOpInfo ) {
   // 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();
 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())

Modified: cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp?rev=296214=296213=296214=diff
==
--- cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp (original)
+++ cfe/trunk/test/CodeGen/ubsan-promoted-arith.cpp Fri Feb 24 18:43:39 2017
@@ -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 @@ char rem1(char c) { return c % c; }
 // 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 @@ void inc3(char c) { c++; }
 // 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; }


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


r296216 - Revert r296209, still one more test to go.

2017-02-24 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 24 18:50:34 2017
New Revision: 296216

URL: http://llvm.org/viewvc/llvm-project?rev=296216=rev
Log:
Revert r296209, still one more test to go.

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=296216=296215=296216=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 24 18:50:34 2017
@@ -1582,11 +1582,7 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  // The PS4 uses C++11 as the default C++ standard.
-  if (T.isPS4())
-LangStd = LangStandard::lang_gnucxx11;
-  else
-LangStd = LangStandard::lang_gnucxx98;
+  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


RE: r296171 - Try to unbreak tests after r296166

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

The test you added is causing a failure on the PS4 Windows bot. The root of the 
cause is that the Windows version of rm does not accept wildcards 
unfortunately. To fix make it work on Windows, you likely need to specify 
exactly what files/directories you want to delete without using a wildcard:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6030:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/*':
 Invalid argument

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6031:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/inplace*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/inplace*':
 Invalid argument

Can you fix the test?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Nico Weber via cfe-commits
> Sent: Friday, February 24, 2017 13:02
> To: cfe-commits@lists.llvm.org
> Subject: r296171 - Try to unbreak tests after r296166
> 
> Author: nico
> Date: Fri Feb 24 15:01:43 2017
> New Revision: 296171
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296171=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=296170=296171=
> 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
___
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  = t;
   int  = p;
   int  = 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  = t;
   int  = p;
   int  = 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 = // 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}}
 }
 
 void f3(void) {

[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=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=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=296135=296136=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


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] 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] 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=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] 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] 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


[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=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=296134=296135=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] 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#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


[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


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=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


[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=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=296145=296146=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=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 
+  const CGBlockInfo::Capture 
+
+  BlockCaptureCopyDestroyGenericInfo(T Type, BlockFieldFlags Flags,
+ const BlockDecl::Capture ,
+ const CGBlockInfo::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 ,
+const LangOptions ,
+SmallVectorImpl ) {
+  for (const auto  : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+QualType Type = Variable->getType();
+const CGBlockInfo::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  : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::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.isByRef()) {
-  flags = BLOCK_FIELD_IS_BYREF;
-  if 

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=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


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=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=296109=296110=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  : 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  : 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=296109=296110=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=296109=296110=di
> ff
> ==
> --- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.c
> +++ 

[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


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


[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();

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: 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=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=296062=296063=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=296062=296063=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


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=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=296160=296161=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] 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


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=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=296139=296140=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=296139=296140=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 
 
   if (CachedLexPos < 

[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=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 cache 

[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


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=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=296159=296160=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=296159=296160=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=296159=296160=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 ,
 const FormatStyle ) {
-  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.Bool = 1;
   LangOpts.ObjC1 = 1;

Modified: 

[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 

[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] 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


[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 
> 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] 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


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=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=296169=296170=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=296169=296170=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=296169=296170=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=296169=296170=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 difference is definition in module 'SecondModule' 

[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] 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=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
   }
 
  

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=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=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 

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=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=296170=296171=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] 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


[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=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] D28952: [analyzer] Add new Z3 constraint manager backend

2017-02-24 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

Sounds good, I will commit https://reviews.llvm.org/D26061 and split out the 
tests from this (https://reviews.llvm.org/D28952).


https://reviews.llvm.org/D28952



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


r296241 - AMDGPU: export s_sendmsg{halt} instrinsics

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:24 2017
New Revision: 296241

URL: http://llvm.org/viewvc/llvm-project?rev=296241=rev
Log:
AMDGPU: export s_sendmsg{halt} instrinsics

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296241=296240=296241=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:24 2017
@@ -37,6 +37,8 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
+BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
+BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296241=296240=296241=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:24 2017
@@ -284,6 +284,34 @@ void test_s_waitcnt()
   __builtin_amdgcn_s_waitcnt(0);
 }
 
+// CHECK-LABEL: @test_s_sendmsg
+// CHECK: call void @llvm.amdgcn.s.sendmsg(
+void test_s_sendmsg()
+{
+  __builtin_amdgcn_s_sendmsg(1, 0);
+}
+
+// CHECK-LABEL: @test_s_sendmsg_var
+// CHECK: call void @llvm.amdgcn.s.sendmsg(
+void test_s_sendmsg_var(int in)
+{
+  __builtin_amdgcn_s_sendmsg(1, in);
+}
+
+// CHECK-LABEL: @test_s_sendmsghalt
+// CHECK: call void @llvm.amdgcn.s.sendmsghalt(
+void test_s_sendmsghalt()
+{
+  __builtin_amdgcn_s_sendmsghalt(1, 0);
+}
+
+// CHECK-LABEL: @test_s_sendmsghalt
+// CHECK: call void @llvm.amdgcn.s.sendmsghalt(
+void test_s_sendmsghalt_var(int in)
+{
+  __builtin_amdgcn_s_sendmsghalt(1, in);
+}
+
 // CHECK-LABEL: @test_s_barrier
 // CHECK: call void @llvm.amdgcn.s.barrier(
 void test_s_barrier()

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=296241=296240=296241=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Fri Feb 24 22:20:24 2017
@@ -23,6 +23,26 @@ void test_s_waitcnt(int x)
   __builtin_amdgcn_s_waitcnt(x); // expected-error {{argument to 
'__builtin_amdgcn_s_waitcnt' must be a constant integer}}
 }
 
+void test_s_sendmsg(int in)
+{
+  __builtin_amdgcn_s_sendmsg(in, 1); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsg' must be a constant integer}}
+}
+
+void test_s_sendmsg_var(int in1, int in2)
+{
+  __builtin_amdgcn_s_sendmsg(in1, in2); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsg' must be a constant integer}}
+}
+
+void test_s_sendmsghalt(int in)
+{
+  __builtin_amdgcn_s_sendmsghalt(in, 1); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
+}
+
+void test_s_sendmsghalt_var(int in1, int in2)
+{
+  __builtin_amdgcn_s_sendmsghalt(in1, in2); // expected-error {{argument to 
'__builtin_amdgcn_s_sendmsghalt' must be a constant integer}}
+}
+
 void test_s_incperflevel(int x)
 {
   __builtin_amdgcn_s_incperflevel(x); // expected-error {{argument to 
'__builtin_amdgcn_s_incperflevel' must be a constant integer}}


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


r296239 - AMDGPU: export s_waitcnt builtin

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:20 2017
New Revision: 296239

URL: http://llvm.org/viewvc/llvm-project?rev=296239=rev
Log:
AMDGPU: export s_waitcnt builtin

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296239=296238=296239=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:20 2017
@@ -36,6 +36,7 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 // Instruction builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
+BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296239=296238=296239=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:20 2017
@@ -263,6 +263,13 @@ void test_class_f64(global double* out,
   *out = __builtin_amdgcn_class(a, b);
 }
 
+// CHECK-LABEL: @test_s_waitcnt
+// CHECK: call void @llvm.amdgcn.s.waitcnt(
+void test_s_waitcnt()
+{
+  __builtin_amdgcn_s_waitcnt(0);
+}
+
 // CHECK-LABEL: @test_s_barrier
 // CHECK: call void @llvm.amdgcn.s.barrier(
 void test_s_barrier()

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=296239=296238=296239=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Fri Feb 24 22:20:20 2017
@@ -18,6 +18,11 @@ void test_s_sleep(int x)
   __builtin_amdgcn_s_sleep(x); // expected-error {{argument to 
'__builtin_amdgcn_s_sleep' must be a constant integer}}
 }
 
+void test_s_waitcnt(int x)
+{
+  __builtin_amdgcn_s_waitcnt(x); // expected-error {{argument to 
'__builtin_amdgcn_s_waitcnt' must be a constant integer}}
+}
+
 void test_s_incperflevel(int x)
 {
   __builtin_amdgcn_s_incperflevel(x); // expected-error {{argument to 
'__builtin_amdgcn_s_incperflevel' must be a constant integer}}


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


r296240 - AMDGPU: export l1 cache invalidation intrinsics

2017-02-24 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Feb 24 22:20:22 2017
New Revision: 296240

URL: http://llvm.org/viewvc/llvm-project?rev=296240=rev
Log:
AMDGPU: export l1 cache invalidation intrinsics

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=296240=296239=296240=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Feb 24 22:20:22 2017
@@ -39,6 +39,8 @@ BUILTIN(__builtin_amdgcn_s_getreg, "UiIi
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
+BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
+BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
 BUILTIN(__builtin_amdgcn_div_fmas, "b", "nc")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=296240=296239=296240=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Feb 24 22:20:22 2017
@@ -263,6 +263,20 @@ void test_class_f64(global double* out,
   *out = __builtin_amdgcn_class(a, b);
 }
 
+// CHECK-LABEL: @test_buffer_wbinvl1
+// CHECK: call void @llvm.amdgcn.buffer.wbinvl1(
+void test_buffer_wbinvl1()
+{
+  __builtin_amdgcn_buffer_wbinvl1();
+}
+
+// CHECK-LABEL: @test_s_dcache_inv
+// CHECK: call void @llvm.amdgcn.s.dcache.inv(
+void test_s_dcache_inv()
+{
+  __builtin_amdgcn_s_dcache_inv();
+}
+
 // CHECK-LABEL: @test_s_waitcnt
 // CHECK: call void @llvm.amdgcn.s.waitcnt(
 void test_s_waitcnt()


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


r296242 - [analyzer] Refactor and simplify SimpleConstraintManager

2017-02-24 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Fri Feb 24 22:51:31 2017
New Revision: 296242

URL: http://llvm.org/viewvc/llvm-project?rev=296242=rev
Log:
[analyzer] Refactor and simplify SimpleConstraintManager

Summary: SimpleConstraintManager is difficult to use, and makes assumptions 
about capabilities of the constraint manager. This patch refactors out those 
portions into a new RangedConstraintManager, and also fixes some issues with 
camel case, formatting, and confusing naming.

Reviewers: zaks.anna, dcoughlin

Subscribers: mgorny, xazax.hun, NoQ, rgov, cfe-commits

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

Added:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
  - copied, changed from r296241, 
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
Removed:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=296242=296241=296242=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
Fri Feb 24 22:51:31 2017
@@ -139,6 +139,8 @@ public:
 return nullptr;
   }
 
+  /// Scan all symbols referenced by the constraints. If the symbol is not
+  /// alive, remove it.
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
  SymbolReaper& SymReaper) = 0;
 

Added: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h?rev=296242=auto
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
 (added)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
 Fri Feb 24 22:51:31 2017
@@ -0,0 +1,92 @@
+//== SimpleConstraintManager.h --*- C++ 
-*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Simplified constraint manager backend.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SIMPLECONSTRAINTMANAGER_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+
+namespace clang {
+
+namespace ento {
+
+class SimpleConstraintManager : public ConstraintManager {
+  SubEngine *SU;
+  SValBuilder 
+
+public:
+  SimpleConstraintManager(SubEngine *subengine, SValBuilder )
+  : SU(subengine), SVB(SB) {}
+
+  ~SimpleConstraintManager() override;
+
+  //===--===//
+  // Implementation for interface from ConstraintManager.
+  //===--===//
+
+  /// Ensures that the DefinedSVal conditional is expressed as a NonLoc by
+  /// creating boolean casts to handle Loc's.
+  ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond,
+ bool Assumption) override;
+
+  ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value,
+   const llvm::APSInt ,
+   const llvm::APSInt ,
+   bool InRange) override;
+
+protected:
+  //===--===//
+  // Interface that subclasses must implement.
+  //===--===//
+
+  /// Given a symbolic expression that can be reasoned about, assume that it is
+  /// true/false and generate the new program state.
+  virtual ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
+

[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

2017-02-24 Thread Dominic Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296242: [analyzer] Refactor and simplify 
SimpleConstraintManager (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26061?vs=89054=89773#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26061

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ConstraintManager.cpp
@@ -20,8 +20,8 @@
 
 static DefinedSVal getLocFromSymbol(const ProgramStateRef ,
 SymbolRef Sym) {
-  const MemRegion *R = State->getStateManager().getRegionManager()
-   .getSymbolicRegion(Sym);
+  const MemRegion *R =
+  State->getStateManager().getRegionManager().getSymbolicRegion(Sym);
   return loc::MemRegionVal(R);
 }
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangedConstraintManager.h
@@ -0,0 +1,102 @@
+//== RangedConstraintManager.h --*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Ranged constraint manager, built on SimpleConstraintManager.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
+#define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
+
+namespace clang {
+
+namespace ento {
+
+class RangedConstraintManager : public SimpleConstraintManager {
+public:
+  RangedConstraintManager(SubEngine *SE, SValBuilder )
+  : SimpleConstraintManager(SE, SB) {}
+
+  ~RangedConstraintManager() override;
+
+  //===--===//
+  // Implementation for interface from SimpleConstraintManager.
+  //===--===//
+
+  ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
+bool Assumption) override;
+
+  ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ,
+  bool InRange) override;
+
+  ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym,
+   bool Assumption) override;
+
+protected:
+  /// Assume a constraint between a symbolic expression and a concrete integer.
+  virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
+   BinaryOperator::Opcode op,
+   const llvm::APSInt );
+
+  //===--===//
+  // Interface that subclasses must implement.
+  //===--===//
+
+  // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison
+  // operation for the method being invoked.
+
+  virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) = 0;
+
+  virtual ProgramStateRef assumeSymGT(ProgramStateRef State, 

[PATCH] D30289: [Analyzer] Add bug visitor for taint checker

2017-02-24 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Looks great!


https://reviews.llvm.org/D30289



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


  1   2   >