[PATCH] D44634: [clang-format] Detect Objective-C for #import

2018-07-10 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.
Herald added a subscriber: acoomans.

I think we should reconsider applying this change, at least for a very common 
"#import ".


Repository:
  rC Clang

https://reviews.llvm.org/D44634



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


[PATCH] D48720: [clang-format/ObjC] Put ObjC method arguments into one line when they fit

2018-07-10 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak closed this revision.
jolesiak added a comment.

This change was submitted (for some reason (probably some rebase operations) it 
was not automatically connected to the commit):
https://reviews.llvm.org/rC336521, https://reviews.llvm.org/rL336521.


Repository:
  rC Clang

https://reviews.llvm.org/D48720



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


[PATCH] D48719: [clang-format/ObjC] Improve split priorities for ObjC methods

2018-07-10 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak closed this revision.
jolesiak added a comment.

This change was submitted (for some reason (probably some rebase operations) it 
was not automatically connected to the commit):
https://reviews.llvm.org/rC336520, https://reviews.llvm.org/rL336520


Repository:
  rC Clang

https://reviews.llvm.org/D48719



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


[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-07-10 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/CodeGen/CGObjCMac.cpp:7457-7460
 CGObjCNonFragileABIMac::GetEHType(QualType T) {
   // There's a particular fixed type info for 'id'.
   if (T->isObjCIdType() || T->isObjCQualifiedIdType()) {
+if (CGM.getTriple().isWindowsMSVCEnvironment())

rjmccall wrote:
> smeenai wrote:
> > rjmccall wrote:
> > > rnk wrote:
> > > > @rjmccall how should this be organized in the long run? At this point, 
> > > > the naming seems totally wrong. Is the non-fragile ABI sort of the 
> > > > canonical way forward for Obj-C, i.e. it's what a new platform would 
> > > > want to use to best stay in sync with the future of obj-c?
> > > For Darwin, yes, absolutely.
> > > 
> > > I think this method should probably just completely delegate to the 
> > > `CGCXXABI` using a new `getAddrOfObjCRTTIDescriptor` method.
> > To be clear, you'd want the entirety of the EHType emission logic to be 
> > shifted to CGCXXABI? I think that would make sense, and I can look into it.
> Right.
Sorry, getting back to this now.

What did you have in mind for handling the different Obj-C runtimes? Were you 
envisioning the new getAddrOfObjCRTTIDescriptor method supporting just the 
non-fragile Mac ABI or all of them?


Repository:
  rC Clang

https://reviews.llvm.org/D47233



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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-10 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- updated this revision to Diff 154921.
0x8000- added a comment.
Herald added a subscriber: mgrang.

Incorporate review comments. Add support for floating point detection.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MagicNumbersCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-magic-numbers.rst
  test/clang-tidy/readability-magic-numbers.cpp

Index: test/clang-tidy/readability-magic-numbers.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-magic-numbers.cpp
@@ -0,0 +1,107 @@
+// RUN: %check_clang_tidy %s readability-magic-numbers %t
+
+template 
+struct ValueBucket {
+  T value[V];
+};
+
+int BadGlobalInt = 5;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 5 [readability-magic-numbers]
+
+int IntSquarer(int param) {
+  return param * param;
+}
+
+void BuggyFunction() {
+  int BadLocalInt = 6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: magic number integer literal 6 [readability-magic-numbers]
+
+  (void)IntSquarer(7);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 7 [readability-magic-numbers]
+
+  int LocalArray[8];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: magic number integer literal 8 [readability-magic-numbers]
+
+  for (int ii = 0; ii < 8; ++ii)
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: magic number integer literal 8 [readability-magic-numbers]
+  {
+LocalArray[ii] = 3 * ii;
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: magic number integer literal 3 [readability-magic-numbers]
+  }
+
+  ValueBucket Bucket;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: magic number integer literal 4 [readability-magic-numbers]
+}
+
+class TwoIntContainer {
+public:
+  TwoIntContainer(int val) : anotherMember(val * val), yetAnotherMember(6), anotherConstant(val + val) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:73: warning: magic number integer literal 6 [readability-magic-numbers]
+
+  int getValue() const;
+
+private:
+  int oneMember = 9;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: magic number integer literal 9 [readability-magic-numbers]
+
+  int anotherMember;
+
+  int yetAnotherMember;
+
+  const int oneConstant = 2;
+
+  const int anotherConstant;
+};
+
+int ValueArray[] = {3, 5};
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: magic number integer literal 3 [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: magic number integer literal 5 [readability-magic-numbers]
+
+float FloatPiVariable = 3.1415926535f;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: magic number float literal 3.141592741 [readability-magic-numbers]
+double DoublePiVariable = 6.283185307;
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: magic number float literal 6.283185307 [readability-magic-numbers]
+
+/*
+ * Clean code
+ */
+
+#define INT_MACRO 5
+
+const int GoodGlobalIntContant = 42;
+
+constexpr int AlsoGoodGlobalIntContant = 42;
+
+void SolidFunction() {
+  const int GoodLocalIntContant = 43;
+
+  (void)IntSquarer(GoodLocalIntContant);
+
+  int LocalArray[INT_MACRO];
+
+  ValueBucket Bucket;
+}
+
+const int ConstValueArray[] = {7, 9};
+
+const int ConstValueArray2D[2][2] = {{7, 9}, {13, 15}};
+
+/*
+ * no warnings for grandfathered values
+ */
+int GrandfatheredValues[] = {0, 1, 2, 10, 100, -1, -10, -100};
+
+/*
+ * no warnings for enums
+ */
+enum Smorgasbord {
+  STARTER,
+  ALPHA = 3,
+  BETA = 1 << 5,
+};
+
+const float FloatPiConstant = 3.1415926535f;
+const double DoublePiConstant = 6.283185307;
+
+double DoubleZeroIsAccepted = 0.0;
+float FloatZeroIsAccepted = 0.0f;
Index: docs/clang-tidy/checks/readability-magic-numbers.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-magic-numbers.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - readability-magic-numbers
+
+readability-magic-numbers
+==
+
+Detects magic numbers, integer or floating point literal that are embedded in
+code and not introduced via constants or symbols.
+
+Bad example:
+
+.. code-block:: c++
+
+   double circleArea = 3.1415926535 * radius * radius;
+
+Good example:
+
+.. code-block:: c++
+
+   double circleArea = M_PI * radius * radius;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -217,6 +217,7 @@
readability-identifier-naming
readability-implicit-bool-conversion
readability-inconsistent-declaration-parameter-name
+   readability-magic-numbers
readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
Index: docs/ReleaseNotes.rst
===

r336756 - [analyzer] Fix bots by changing the analyzer-config tests.

2018-07-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jul 10 19:01:18 2018
New Revision: 336756

URL: http://llvm.org/viewvc/llvm-project?rev=336756&view=rev
Log:
[analyzer] Fix bots by changing the analyzer-config tests.

To be investigated.

Modified:
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/test/Analysis/analyzer-config.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.c?rev=336756&r1=336755&r2=336756&view=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.c (original)
+++ cfe/trunk/test/Analysis/analyzer-config.c Tue Jul 10 19:01:18 2018
@@ -25,7 +25,6 @@ void foo() {
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
-// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -36,4 +35,4 @@ void foo() {
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 24
+// CHECK-NEXT: num-entries = 23

Modified: cfe/trunk/test/Analysis/analyzer-config.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.cpp?rev=336756&r1=336755&r2=336756&view=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.cpp (original)
+++ cfe/trunk/test/Analysis/analyzer-config.cpp Tue Jul 10 19:01:18 2018
@@ -40,7 +40,6 @@ public:
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
-// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -51,4 +50,4 @@ public:
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 31
+// CHECK-NEXT: num-entries = 30


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


r336755 - [analyzer] Partial revert of https://reviews.llvm.org/D49050

2018-07-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jul 10 18:58:08 2018
New Revision: 336755

URL: http://llvm.org/viewvc/llvm-project?rev=336755&view=rev
Log:
[analyzer] Partial revert of https://reviews.llvm.org/D49050

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp?rev=336755&r1=336754&r2=336755&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp Tue Jul 10 
18:58:08 2018
@@ -56,12 +56,6 @@ class DynamicTypePropagation:
 check::PostStmt,
 check::PreObjCMessage,
 check::PostObjCMessage > {
-private:
-  /// This value is set to true, when the Generics checker is turned on.
-  bool CheckGenerics;
-public:
-  DynamicTypePropagation(bool CheckGenerics)
-  : CheckGenerics(CheckGenerics) {}
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr 
*MsgE,
 CheckerContext &C) const;
 
@@ -113,6 +107,9 @@ public:
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
+
+  /// This value is set to true, when the Generics checker is turned on.
+  DefaultBool CheckGenerics;
 };
 } // end anonymous namespace
 
@@ -998,9 +995,11 @@ DynamicTypePropagation::GenericsBugVisit
 
 /// Register checkers.
 void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
-  mgr.registerChecker(/*CheckGenerics=*/true);
+  DynamicTypePropagation *checker =
+  mgr.registerChecker();
+  checker->CheckGenerics = true;
 }
 
 void ento::registerDynamicTypePropagation(CheckerManager &mgr) {
-  mgr.registerChecker(/*CheckGenerics=*/false);
+  mgr.registerChecker();
 }


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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-10 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- marked 7 inline comments as done.
0x8000- added inline comments.



Comment at: docs/clang-tidy/checks/readability-magic-numbers.rst:11
+
+   double circleArea = 3.1415926535 * radius * radius;
+

Eugene.Zelenko wrote:
> JonasToth wrote:
> > This example is good, but right now the code only checks for integer 
> > literals. Maybe an integer example would be better?
> Please use .. code-block:: c++. Same for good example.
@JonasToth I raked my brain but I just can't come up with a short and effective 
example. I haven't given up yet.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


r336753 - [analyzer] Pass through all arguments from the registerChecker() to the checker constructor

2018-07-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jul 10 18:23:27 2018
New Revision: 336753

URL: http://llvm.org/viewvc/llvm-project?rev=336753&view=rev
Log:
[analyzer] Pass through all arguments from the registerChecker() to the checker 
constructor

A lot of checkers could be cleaned up in a similar way

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=336753&r1=336752&r2=336753&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Tue Jul 10 
18:23:27 2018
@@ -144,31 +144,18 @@ public:
 
//===--===//
 
   /// Used to register checkers.
+  /// All arguments are automatically passed through to the checker
+  /// constructor.
   ///
   /// \returns a pointer to the checker object.
-  template 
-  CHECKER *registerChecker() {
+  template 
+  CHECKER *registerChecker(AT... Args) {
 CheckerTag tag = getTag();
 CheckerRef &ref = CheckerTags[tag];
 if (ref)
   return static_cast(ref); // already registered.
 
-CHECKER *checker = new CHECKER();
-checker->Name = CurrentCheckName;
-CheckerDtors.push_back(CheckerDtor(checker, destruct));
-CHECKER::_register(checker, *this);
-ref = checker;
-return checker;
-  }
-
-  template 
-  CHECKER *registerChecker(AnalyzerOptions &AOpts) {
-CheckerTag tag = getTag();
-CheckerRef &ref = CheckerTags[tag];
-if (ref)
-  return static_cast(ref); // already registered.
-
-CHECKER *checker = new CHECKER(AOpts);
+CHECKER *checker = new CHECKER(Args...);
 checker->Name = CurrentCheckName;
 CheckerDtors.push_back(CheckerDtor(checker, destruct));
 CHECKER::_register(checker, *this);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp?rev=336753&r1=336752&r2=336753&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp Tue Jul 10 
18:23:27 2018
@@ -56,6 +56,12 @@ class DynamicTypePropagation:
 check::PostStmt,
 check::PreObjCMessage,
 check::PostObjCMessage > {
+private:
+  /// This value is set to true, when the Generics checker is turned on.
+  bool CheckGenerics;
+public:
+  DynamicTypePropagation(bool CheckGenerics)
+  : CheckGenerics(CheckGenerics) {}
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr 
*MsgE,
 CheckerContext &C) const;
 
@@ -107,9 +113,6 @@ public:
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
-
-  /// This value is set to true, when the Generics checker is turned on.
-  DefaultBool CheckGenerics;
 };
 } // end anonymous namespace
 
@@ -995,11 +998,9 @@ DynamicTypePropagation::GenericsBugVisit
 
 /// Register checkers.
 void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
-  DynamicTypePropagation *checker =
-  mgr.registerChecker();
-  checker->CheckGenerics = true;
+  mgr.registerChecker(/*CheckGenerics=*/true);
 }
 
 void ento::registerDynamicTypePropagation(CheckerManager &mgr) {
-  mgr.registerChecker();
+  mgr.registerChecker(/*CheckGenerics=*/false);
 }


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


[PATCH] D49050: [analyzer] Pass through all arguments from the registerChecker() to the checker constructor

2018-07-10 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC336753: [analyzer] Pass through all arguments from the 
registerChecker() to the checker… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D49050

Files:
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp


Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -56,6 +56,12 @@
 check::PostStmt,
 check::PreObjCMessage,
 check::PostObjCMessage > {
+private:
+  /// This value is set to true, when the Generics checker is turned on.
+  bool CheckGenerics;
+public:
+  DynamicTypePropagation(bool CheckGenerics)
+  : CheckGenerics(CheckGenerics) {}
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr 
*MsgE,
 CheckerContext &C) const;
 
@@ -107,9 +113,6 @@
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
-
-  /// This value is set to true, when the Generics checker is turned on.
-  DefaultBool CheckGenerics;
 };
 } // end anonymous namespace
 
@@ -995,11 +998,9 @@
 
 /// Register checkers.
 void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
-  DynamicTypePropagation *checker =
-  mgr.registerChecker();
-  checker->CheckGenerics = true;
+  mgr.registerChecker(/*CheckGenerics=*/true);
 }
 
 void ento::registerDynamicTypePropagation(CheckerManager &mgr) {
-  mgr.registerChecker();
+  mgr.registerChecker(/*CheckGenerics=*/false);
 }
Index: include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -144,31 +144,18 @@
 
//===--===//
 
   /// Used to register checkers.
+  /// All arguments are automatically passed through to the checker
+  /// constructor.
   ///
   /// \returns a pointer to the checker object.
-  template 
-  CHECKER *registerChecker() {
-CheckerTag tag = getTag();
-CheckerRef &ref = CheckerTags[tag];
-if (ref)
-  return static_cast(ref); // already registered.
-
-CHECKER *checker = new CHECKER();
-checker->Name = CurrentCheckName;
-CheckerDtors.push_back(CheckerDtor(checker, destruct));
-CHECKER::_register(checker, *this);
-ref = checker;
-return checker;
-  }
-
-  template 
-  CHECKER *registerChecker(AnalyzerOptions &AOpts) {
+  template 
+  CHECKER *registerChecker(AT... Args) {
 CheckerTag tag = getTag();
 CheckerRef &ref = CheckerTags[tag];
 if (ref)
   return static_cast(ref); // already registered.
 
-CHECKER *checker = new CHECKER(AOpts);
+CHECKER *checker = new CHECKER(Args...);
 checker->Name = CurrentCheckName;
 CheckerDtors.push_back(CheckerDtor(checker, destruct));
 CHECKER::_register(checker, *this);


Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -56,6 +56,12 @@
 check::PostStmt,
 check::PreObjCMessage,
 check::PostObjCMessage > {
+private:
+  /// This value is set to true, when the Generics checker is turned on.
+  bool CheckGenerics;
+public:
+  DynamicTypePropagation(bool CheckGenerics)
+  : CheckGenerics(CheckGenerics) {}
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE,
 CheckerContext &C) const;
 
@@ -107,9 +113,6 @@
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
-
-  /// This value is set to true, when the Generics checker is turned on.
-  DefaultBool CheckGenerics;
 };
 } // end anonymous namespace
 
@@ -995,11 +998,9 @@
 
 /// Register checkers.
 void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
-  DynamicTypePropagation *checker =
-  mgr.registerChecker();
-  checker->CheckGenerics = true;
+  mgr.registerChecker(/*CheckGenerics=*/true);
 }
 
 void ento::registerDynamicTypePropagation(CheckerManager &mgr) {
-  mgr.registerChecker();
+  mgr.registerChecker(/*CheckGenerics=*/fa

r336750 - [SemaCXX] Remove comment from coroutines test, NFC

2018-07-10 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Tue Jul 10 18:00:53 2018
New Revision: 336750

URL: http://llvm.org/viewvc/llvm-project?rev=336750&view=rev
Log:
[SemaCXX] Remove comment from coroutines test, NFC

Summary:
The file name was accidentally included when the test file was added.

Test Plan: check-clang


Modified:
cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp

Modified: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp?rev=336750&r1=336749&r2=336750&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Tue Jul 10 
18:00:53 2018
@@ -1,5 +1,3 @@
-// test/SemaCXX/coroutine-traits-undefined-template.cpp
-
 // This file contains references to sections of the Coroutines TS, which can be
 // found at http://wg21.link/coroutines.
 


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


[PATCH] D35388: [libc++] Give extern templates default visibility on gcc

2018-07-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a reviewer: ldionne.
EricWF added a subscriber: ldionne.
EricWF added a comment.

Adding @ldionne as an observer, since he's knee-deep in the visibility mess 
right now.

After re-evaluating, I think I was being overly cautious the last time I looked 
at this. I think this patch should be acceptable ABI wise. But I would 
appreciate a second opinion.


https://reviews.llvm.org/D35388



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


[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:11103
 
+  if (const auto *DeclRef = dyn_cast(LHSExpr))
+checkNullConstantToNonNull(DeclRef->getType(), RHS.get());

jordan_rose wrote:
> This could come later, but what about struct members or ObjC properties or 
> ObjC subscripts? Seems like you could just check the type of the LHS.
I removed the check for DeclRef so that it warns on struct members (see test 
case in null_constant_to_nonnull.c). 

CheckNonNullArgument already checks null arguments passed to ObjC properties 
and subscripts setter methods. I added a new test case to 
test/SemaObjC/nullability.m.



Comment at: test/Analysis/nullability_nullonly.mm:103
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}} 
expected-warning{{implicitly casting a null constant to non-nullable pointer 
type 'TestObject * _Nonnull __strong'}}
 }

NoQ wrote:
> jordan_rose wrote:
> > @dergachev.a, what do you think here? Is it okay that the analyzer 
> > diagnoses this in addition to the new warning?
> We're usually trying to avoid this when we notice it, but there are many 
> cases where we didn't notice it because both warnings and the analyzer are 
> becoming better independently. I guess you could just give us a heads up with 
> a bug report if you don't want to bother with this.
> 
> In this case i think it should be easy to fix though, because the analyzer 
> already has `static isARCNilInitializedLocal()` that suppresses implicit null 
> initializers, we could teach it to suppress all null initializers instead.
I think the warning in nullability-no-arc.mm should be suppressed too? I made 
changes to isARCNilInitializedLocal so that it returns true when the 
initializer is explicit or when it is not ARC. I'm not sure whether this is the 
right way to fix it, but it doesn't cause any regression tests to fail.



Comment at: test/Sema/conditional-expr.c:20
   vp = 0 ? (double *)0 : (void *)0;
-  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer 
types assigning to 'int *' from 'double *'}}
+  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer 
types assigning to 'int *' from 'double * _Nullable'}}
 

jordan_rose wrote:
> This seems like an unfortunate change to make, since most people do not 
> bother with nullability.
Yes, this is unfortunate, but I'm not sure what's the right way to avoid 
printing nullability specifiers in the diagnostic message. Do you have any 
suggestions?


Repository:
  rC Clang

https://reviews.llvm.org/D22391



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


[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-07-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 154912.
vsapsai added a comment.

- In C++03 call allocator's `destroy` when available.
- Rename `_Args` as it's not a variadic template pack.


https://reviews.llvm.org/D48753

Files:
  libcxx/include/memory
  
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
  
libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
  
libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
  libcxx/test/support/min_allocator.h

Index: libcxx/test/support/min_allocator.h
===
--- libcxx/test/support/min_allocator.h
+++ libcxx/test/support/min_allocator.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 
@@ -131,6 +132,59 @@
 friend bool operator!=(malloc_allocator x, malloc_allocator y) {return !(x == y);}
 };
 
+template 
+struct cpp03_allocator : bare_allocator
+{
+typedef T value_type;
+typedef value_type* pointer;
+
+static bool construct_called;
+
+// Returned value is not used but it's not prohibited.
+pointer construct(pointer p, const value_type& val)
+{
+::new(p) value_type(val);
+construct_called = true;
+return p;
+}
+
+std::size_t max_size() const
+{
+return UINT_MAX / sizeof(T);
+}
+};
+template  bool cpp03_allocator::construct_called = false;
+
+template 
+struct cpp03_overload_allocator : bare_allocator
+{
+typedef T value_type;
+typedef value_type* pointer;
+
+static bool construct_called;
+
+void construct(pointer p, const value_type& val)
+{
+construct(p, val, std::is_class());
+}
+void construct(pointer p, const value_type& val, std::true_type)
+{
+::new(p) value_type(val);
+construct_called = true;
+}
+void construct(pointer p, const value_type& val, std::false_type)
+{
+::new(p) value_type(val);
+construct_called = true;
+}
+
+std::size_t max_size() const
+{
+return UINT_MAX / sizeof(T);
+}
+};
+template  bool cpp03_overload_allocator::construct_called = false;
+
 
 #if TEST_STD_VER >= 11
 
Index: libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
===
--- libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
+++ libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -73,7 +73,6 @@
   std::aligned_storage::type store;
   std::allocator_traits::destroy(a, (VT*)&store);
 }
-#if TEST_STD_VER >= 11
 {
 A0::count = 0;
 b_destroy = 0;
@@ -86,5 +85,4 @@
 assert(A0::count == 1);
 assert(b_destroy == 1);
 }
-#endif
 }
Index: libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
===
--- libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -129,9 +129,39 @@
 }
 
 void test_ctor_under_alloc() {
-#if TEST_STD_VER >= 11
   int arr1[] = {42};
   int arr2[] = {1, 101, 42};
+  {
+typedef std::vector > C;
+typedef C::allocator_type Alloc;
+Alloc a;
+{
+  Alloc::construct_called = false;
+  C v(arr1, arr1 + 1, a);
+  assert(Alloc::construct_called);
+}
+{
+  Alloc::construct_called = false;
+  C v(arr2, arr2 + 3, a);
+  assert(Alloc::construct_called);
+}
+  }
+  {
+typedef std::vector > C;
+typedef C::allocator_type Alloc;
+Alloc a;
+{
+  Alloc::construct_called = false;
+  C v(arr1, arr1 + 1, a);
+  assert(Alloc::construct_called);
+}
+{
+  Alloc::construct_called = false;
+  C v(arr2, arr2 + 3, a);
+  assert(Alloc::construct_called);
+}
+  }
+#if TEST_STD_VER >= 11
   {
 using C = TCT::vector<>;
 using T = typename C::value_type;
Index: libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
===
--- libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -116,9 +116,37 @@
 }
 
 void test_ctor_under_alloc() {
-#if TEST_STD_VER >= 11
   int arr1[] = {42};
   int arr2[] = {1, 101, 42};
+  {
+typedef std::vector > C;
+typedef C::allocator_type Alloc;
+{
+  Alloc::construct_called = false;
+  C v(arr1, arr1 + 1);
+  assert(Alloc::construct_called);
+}
+{
+  Alloc::construct_called = false;
+  C v(arr2, arr2 + 3);
+  assert(Alloc::construct_called);
+}
+  }
+  {
+

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 154908.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability-no-arc.mm
  test/Analysis/nullability.mm
  test/Analysis/nullability_nullonly.mm
  test/Sema/conditional-expr.c
  test/Sema/null_constant_to_nonnull.c
  test/SemaObjC/nullability.m

Index: test/SemaObjC/nullability.m
===
--- test/SemaObjC/nullability.m
+++ test/SemaObjC/nullability.m
@@ -38,6 +38,7 @@
 // expected-note@-1{{use nullability type specifier '_Nonnull' to affect the innermost pointer type of 'NSFoo **'}}
 - (nonnull NSFoo * _Nullable)conflictingMethod1; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
 - (nonnull NSFoo * _Nonnull)redundantMethod1; // expected-warning{{duplicate nullability specifier '_Nonnull'}}
+- (void)setObject:(id _Nonnull)object atIndexedSubscript:(int)index;
 
 @property(nonnull,retain) NSFoo *property1;
 @property(nullable,assign) NSFoo ** invalidProperty1; // expected-error{{nullability keyword 'nullable' cannot be applied to multi-level pointer type 'NSFoo **'}}
@@ -65,6 +66,7 @@
   [bar setProperty1: 0]; // expected-warning{{null passed to a callee that requires a non-null argument}}
   [bar setProperty2: 0]; // expected-warning{{null passed to a callee that requires a non-null argument}}
   int *ptr = bar.property1; // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'NSFoo * _Nonnull'}}
+  bar[1] = 0; // expected-warning{{null passed to a callee that requires a non-null argument}}
 }
 
 // Check returning nil from a nonnull-returning method.
@@ -84,6 +86,9 @@
   int *ip = 0;
   return ip; // expected-warning{{result type 'NSFoo * _Nonnull'}}
 }
+- (void)setObject:(id _Nonnull)object atIndexedSubscript:(int)index {
+}
+
 @end
 
 __attribute__((objc_root_class))
Index: test/Sema/null_constant_to_nonnull.c
===
--- /dev/null
+++ test/Sema/null_constant_to_nonnull.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnullable-to-nonnull-conversion %s -verify
+
+struct S {
+  int * _Nonnull f;
+};
+
+void null_const_to_nonnull(int c, struct S *s) {
+  int * _Nonnull p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  p0 = (int * _Nonnull)0; // explicit cast silences warnings
+  int * _Nonnull p1;
+  int * _Nonnull p2 = c ? p1 : 0; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+  p2 = c ? p1 : (int * _Nonnull)0; // explicit cast silences warnings
+  s->f = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+}
Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -17,7 +17,7 @@
   dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}}
   dp = 0 ? (double *)0 : (void *)0;
   vp = 0 ? (double *)0 : (void *)0;
-  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double * _Nullable'}}
 
   const int *cip;
   vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
@@ -90,7 +90,7 @@
 
 int f0(int a) {
   // GCC considers this a warning.
-  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
+  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void * _Nullable' from a function with result type 'int'}}
 }
 
 int f2(int x) {
Index: test/Analysis/nullability_nullonly.mm
===
--- test/Analysis/nullability_nullonly.mm
+++ test/Analysis/nullability_nullonly.mm
@@ -100,7 +100,7 @@
 }
 
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which

[PATCH] D49099: Remove qualtype qualifier in coroutine error to prevent assert in debug

2018-07-10 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC336748: Remove qualtype qualifier in coroutine error to 
prevent assert in debug (authored by modocache, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49099?vs=154692&id=154910#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49099

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/SemaCXX/coroutine-traits-undefined-template.cpp


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9082,7 +9082,7 @@
   "this function cannot be a coroutine: %0 is an incomplete type">;
 def err_coroutine_type_missing_specialization : Error<
   "this function cannot be a coroutine: missing definition of "
-  "specialization %q0">;
+  "specialization %0">;
 def err_coroutine_promise_incompatible_return_functions : Error<
   "the coroutine promise type %0 declares both 'return_value' and 
'return_void'">;
 def err_coroutine_promise_requires_return_function : Error<
Index: test/SemaCXX/coroutine-traits-undefined-template.cpp
===
--- test/SemaCXX/coroutine-traits-undefined-template.cpp
+++ test/SemaCXX/coroutine-traits-undefined-template.cpp
@@ -0,0 +1,21 @@
+// test/SemaCXX/coroutine-traits-undefined-template.cpp
+
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions 
-fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+
+template
+struct coroutine_traits {
+  struct promise_type {};
+};
+
+template<> struct coroutine_traits; // expected-note {{forward 
declaration of 'std::experimental::coroutine_traits'}}
+}} // namespace std::experimental
+
+void uses_forward_declaration() {
+  co_return; // expected-error {{this function cannot be a coroutine: missing 
definition of specialization 'coroutine_traits'}}
+}


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9082,7 +9082,7 @@
   "this function cannot be a coroutine: %0 is an incomplete type">;
 def err_coroutine_type_missing_specialization : Error<
   "this function cannot be a coroutine: missing definition of "
-  "specialization %q0">;
+  "specialization %0">;
 def err_coroutine_promise_incompatible_return_functions : Error<
   "the coroutine promise type %0 declares both 'return_value' and 'return_void'">;
 def err_coroutine_promise_requires_return_function : Error<
Index: test/SemaCXX/coroutine-traits-undefined-template.cpp
===
--- test/SemaCXX/coroutine-traits-undefined-template.cpp
+++ test/SemaCXX/coroutine-traits-undefined-template.cpp
@@ -0,0 +1,21 @@
+// test/SemaCXX/coroutine-traits-undefined-template.cpp
+
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+
+template
+struct coroutine_traits {
+  struct promise_type {};
+};
+
+template<> struct coroutine_traits; // expected-note {{forward declaration of 'std::experimental::coroutine_traits'}}
+}} // namespace std::experimental
+
+void uses_forward_declaration() {
+  co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits'}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r336748 - Remove qualtype qualifier in coroutine error to prevent assert in debug

2018-07-10 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Tue Jul 10 17:45:48 2018
New Revision: 336748

URL: http://llvm.org/viewvc/llvm-project?rev=336748&view=rev
Log:
Remove qualtype qualifier in coroutine error to prevent assert in debug

Summary:
A forward-declared coroutine_traits should trip an error; we need
a complete type.

Unfortunately, in debug mode only, we trip an assert when attempting
to provide the fully qualified type for the error message.
If you try to compile a program with a forward-declared
coroutine_traits in debug mode, clang will crash.

I've included a test for the behavior and removed the q modifier
on the error message. This prevents the crash in debug mode and
does not change the behavior for the error message on a
forward-declaration of a coroutine_traits type.

Test Plan:
I've included a test for the forward-declaration.

Patch by Tanoy Sinha!

Reviewers: modocache, GorNishanov

Reviewed By: modocache

Subscribers: cfe-commits

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


Added:
cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=336748&r1=336747&r2=336748&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 10 17:45:48 
2018
@@ -9082,7 +9082,7 @@ def err_coroutine_promise_type_incomplet
   "this function cannot be a coroutine: %0 is an incomplete type">;
 def err_coroutine_type_missing_specialization : Error<
   "this function cannot be a coroutine: missing definition of "
-  "specialization %q0">;
+  "specialization %0">;
 def err_coroutine_promise_incompatible_return_functions : Error<
   "the coroutine promise type %0 declares both 'return_value' and 
'return_void'">;
 def err_coroutine_promise_requires_return_function : Error<

Added: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp?rev=336748&view=auto
==
--- cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp (added)
+++ cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Tue Jul 10 
17:45:48 2018
@@ -0,0 +1,21 @@
+// test/SemaCXX/coroutine-traits-undefined-template.cpp
+
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions 
-fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+
+template
+struct coroutine_traits {
+  struct promise_type {};
+};
+
+template<> struct coroutine_traits; // expected-note {{forward 
declaration of 'std::experimental::coroutine_traits'}}
+}} // namespace std::experimental
+
+void uses_forward_declaration() {
+  co_return; // expected-error {{this function cannot be a coroutine: missing 
definition of specialization 'coroutine_traits'}}
+}


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


r336747 - [docs] List correct default for -ftemplate-depth; also add missing

2018-07-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 10 17:34:54 2018
New Revision: 336747

URL: http://llvm.org/viewvc/llvm-project?rev=336747&view=rev
Log:
[docs] List correct default for -ftemplate-depth; also add missing
documentation for -fconstexpr-steps.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=336747&r1=336746&r2=336747&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Jul 10 17:34:54 2018
@@ -2116,10 +2116,15 @@ Controlling implementation limits
   Sets the limit for recursive constexpr function invocations to N.  The
   default is 512.
 
+.. option:: -fconstexpr-steps=N
+
+  Sets the limit for the number of full-expressions evaluated in a single
+  constant expression evaluation.  The default is 1048576.
+
 .. option:: -ftemplate-depth=N
 
   Sets the limit for recursively nested template instantiations to N.  The
-  default is 256.
+  default is 1024.
 
 .. option:: -foperator-arrow-depth=N
 


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


[PATCH] D48681: [CFG] [analyzer] Add construction contexts for function arguments.

2018-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/Analysis/ConstructionContext.cpp:186
+isa(TopLayer->getTriggerStmt())) {
+  return create(
+  C, cast(TopLayer->getTriggerStmt()), TopLayer->getIndex(),

Should assert that we only have one layer.


Repository:
  rC Clang

https://reviews.llvm.org/D48681



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


r336746 - PR38095: Allow constant-folding of loads through bitcasted pointers if

2018-07-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 10 17:29:05 2018
New Revision: 336746

URL: http://llvm.org/viewvc/llvm-project?rev=336746&view=rev
Log:
PR38095: Allow constant-folding of loads through bitcasted pointers if
the bitcast only changed cvr-qualifications within the pointer type.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/diagnose_if.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=336746&r1=336745&r2=336746&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Jul 10 17:29:05 2018
@@ -5787,8 +5787,8 @@ bool PointerExprEvaluator::VisitUnaryAdd
   return evaluateLValue(E->getSubExpr(), Result);
 }
 
-bool PointerExprEvaluator::VisitCastExpr(const CastExpr* E) {
-  const Expr* SubExpr = E->getSubExpr();
+bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
+  const Expr *SubExpr = E->getSubExpr();
 
   switch (E->getCastKind()) {
   default:
@@ -5805,7 +5805,11 @@ bool PointerExprEvaluator::VisitCastExpr
 // permitted in constant expressions in C++11. Bitcasts from cv void* are
 // also static_casts, but we disallow them as a resolution to DR1312.
 if (!E->getType()->isVoidPointerType()) {
-  Result.Designator.setInvalid();
+  // If we changed anything other than cvr-qualifiers, we can't use this
+  // value for constant folding. FIXME: Qualification conversions should
+  // always be CK_NoOp, but we get this wrong in C.
+  if (!Info.Ctx.hasCvrSimilarType(E->getType(), 
E->getSubExpr()->getType()))
+Result.Designator.setInvalid();
   if (SubExpr->getType()->isVoidPointerType())
 CCEDiag(E, diag::note_constexpr_invalid_cast)
   << 3 << SubExpr->getType();

Modified: cfe/trunk/test/Sema/diagnose_if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diagnose_if.c?rev=336746&r1=336745&r2=336746&view=diff
==
--- cfe/trunk/test/Sema/diagnose_if.c (original)
+++ cfe/trunk/test/Sema/diagnose_if.c Tue Jul 10 17:29:05 2018
@@ -157,3 +157,13 @@ void runAlwaysWarnWithArg(int a) {
 // Bug: we would complain about `a` being undeclared if this was spelled
 // __diagnose_if__.
 void underbarName(int a) __attribute__((__diagnose_if__(a, "", "warning")));
+
+// PR38095
+void constCharStar(const char *str) __attribute__((__diagnose_if__(!str[0], 
"empty string not allowed", "error"))); // expected-note {{from}}
+void charStar(char *str) __attribute__((__diagnose_if__(!str[0], "empty string 
not allowed", "error"))); // expected-note {{from}}
+void runConstCharStar() {
+  constCharStar("foo");
+  charStar("bar");
+  constCharStar(""); // expected-error {{empty string not allowed}}
+  charStar(""); // expected-error {{empty string not allowed}}
+}


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


r336745 - DR330: look through array types when forming the cv-decomposition of a type.

2018-07-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 10 17:19:19 2018
New Revision: 336745

URL: http://llvm.org/viewvc/llvm-project?rev=336745&view=rev
Log:
DR330: look through array types when forming the cv-decomposition of a type.

This allows more qualification conversions, eg. conversion from
   'int *(*)[]' -> 'const int *const (*)[]'
is now permitted, along with all the consequences of that: more types
are similar, more cases are permitted by const_cast, and conversely,
fewer "casting away constness" cases are permitted by reinterpret_cast.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/CXX/drs/dr3xx.cpp
cfe/trunk/test/SemaCXX/const-cast.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=336745&r1=336744&r2=336745&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jul 10 17:19:19 2018
@@ -2282,7 +2282,19 @@ public:
   bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
const ObjCMethodDecl *MethodImp);
 
-  bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2);
+  bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
+
+  /// Determine if two types are similar, according to the C++ rules. That is,
+  /// determine if they are the same other than qualifiers on the initial
+  /// sequence of pointer / pointer-to-member / array (and in Clang, object
+  /// pointer) types and their element types.
+  ///
+  /// Clang offers a number of qualifiers in addition to the C++ qualifiers;
+  /// those qualifiers are also ignored in the 'similarity' check.
+  bool hasSimilarType(QualType T1, QualType T2);
+
+  /// Determine if two types are similar, ignoring only CVR qualifiers.
+  bool hasCvrSimilarType(QualType T1, QualType T2);
 
   /// Retrieves the "canonical" nested name specifier for a
   /// given nested name specifier.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=336745&r1=336744&r2=336745&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 10 17:19:19 2018
@@ -4965,15 +4965,49 @@ QualType ASTContext::getUnqualifiedArray
 SourceRange());
 }
 
-/// UnwrapSimilarPointerTypes - If T1 and T2 are pointer types  that
-/// may be similar (C++ 4.4), replaces T1 and T2 with the type that
-/// they point to and return true. If T1 and T2 aren't pointer types
-/// or pointer-to-member types, or if they are not similar at this
-/// level, returns false and leaves T1 and T2 unchanged. Top-level
-/// qualifiers on T1 and T2 are ignored. This function will typically
-/// be called in a loop that successively "unwraps" pointer and
-/// pointer-to-member types to compare them at each level.
-bool ASTContext::UnwrapSimilarPointerTypes(QualType &T1, QualType &T2) {
+/// Attempt to unwrap two types that may both be array types with the same 
bound
+/// (or both be array types of unknown bound) for the purpose of comparing the
+/// cv-decomposition of two types per C++ [conv.qual].
+static void unwrapSimilarArrayTypes(ASTContext &Ctx, QualType &T1,
+QualType &T2) {
+  while (true) {
+auto *AT1 = Ctx.getAsArrayType(T1);
+if (!AT1) return;
+
+auto *AT2 = Ctx.getAsArrayType(T2);
+if (!AT2) return;
+
+// If we don't have two array types with the same constant bound nor two
+// incomplete array types, we've unwrapped everything we can.
+if (auto *CAT1 = dyn_cast(AT1)) {
+  auto *CAT2 = dyn_cast(AT2);
+  if (!CAT2 || CAT1->getSize() != CAT2->getSize())
+return;
+} else if (!isa(AT1) ||
+   !isa(AT2)) {
+  return;
+}
+
+T1 = AT1->getElementType();
+T2 = AT2->getElementType();
+  }
+}
+
+/// Attempt to unwrap two types that may be similar (C++ [conv.qual]).
+///
+/// If T1 and T2 are both pointer types of the same kind, or both array types
+/// with the same bound, unwraps layers from T1 and T2 until a pointer type is
+/// unwrapped. Top-level qualifiers on T1 and T2 are ignored.
+///
+/// This function will typically be called in a loop that successively
+/// "unwraps" pointer and pointer-to-member types to compare them at each
+/// level.
+///
+/// \return \c true if a pointer type was unwrapped, \c false if we reached a
+/// pair of types that can't be unwrapped further.
+bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2) {
+  unwrapSimilarArrayTypes(*this, T1, T2);
+
   const auto *T1PtrTyp

[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

2018-07-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:318
 
-  Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
+  Value *EmitScalarConversion(Value *Src, QualType SrcType, QualType DstType,
   SourceLocation Loc, bool TreatBooleanAsSigned);

vsk wrote:
> I think the number of overloads here is really unwieldy. There should be a 
> simpler way to structure this. What about consolidating all four overloads 
> into one? Maybe:
> 
> ```
> struct ScalarConversionsOpts {
>   bool TreatBoolAsUnsigned = false;
>   bool EmitImplicitIntegerTruncationCheck = false;
> };
> 
> Value *EmitScalarConversion(Src, SrcTy, DstTy, Loc, Opts = 
> ScalarConversionOpts())
> ```
> 
> It's not necessary to pass CastExpr in, right? There's only one place where 
> that's done. It seems simpler to just do the SanOpts / 
> isCastPartOfExplicitCast checking there.
The number of overloads is indeed unwieldy.



Comment at: lib/CodeGen/CGExprScalar.cpp:1694
 // handle things like function to ptr-to-function decay etc.
 Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
   Expr *E = CE->getSubExpr();

vsk wrote:
> I think maintaining a stack of visited cast exprs in the emitter be 
> cheaper/simpler than using ASTContext::getParents. You could push CE here and 
> use a RAII helper to pop it. The 'isCastPartOfExplicitCast' check then 
> simplifies to a quick stack traversal.
Hmm, two things come to mind:
1. This pessimizes the (most popular) case when the sanitizer is disabled.
2. `ASTContext::getParents()` may return more than one parent. I'm not sure if 
that matters here?
I'll take a look..


Repository:
  rC Clang

https://reviews.llvm.org/D48958



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


[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

2018-07-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for working on this!




Comment at: docs/ReleaseNotes.rst:277
+  behaviour. But they are not *always* intentional, and are somewhat hard to
+  track down.
 

Could you mention whether the group is enabled by -fsanitize=undefined?



Comment at: lib/CodeGen/CGExprScalar.cpp:318
 
-  Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
+  Value *EmitScalarConversion(Value *Src, QualType SrcType, QualType DstType,
   SourceLocation Loc, bool TreatBooleanAsSigned);

I think the number of overloads here is really unwieldy. There should be a 
simpler way to structure this. What about consolidating all four overloads into 
one? Maybe:

```
struct ScalarConversionsOpts {
  bool TreatBoolAsUnsigned = false;
  bool EmitImplicitIntegerTruncationCheck = false;
};

Value *EmitScalarConversion(Src, SrcTy, DstTy, Loc, Opts = 
ScalarConversionOpts())
```

It's not necessary to pass CastExpr in, right? There's only one place where 
that's done. It seems simpler to just do the SanOpts / isCastPartOfExplicitCast 
checking there.



Comment at: lib/CodeGen/CGExprScalar.cpp:951
+//   implicit cast -> explicit cast <- that is an explicit 
cast.
+static bool CastIsPartOfExplictCast(ASTContext &Ctx, const Expr *E) {
+  // If it's a nulllptr, or not a cast, then it's not a part of Explict Cast.

nit, function names typically begin with a verb: 'isCastPartOf...'



Comment at: lib/CodeGen/CGExprScalar.cpp:1694
 // handle things like function to ptr-to-function decay etc.
 Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
   Expr *E = CE->getSubExpr();

I think maintaining a stack of visited cast exprs in the emitter be 
cheaper/simpler than using ASTContext::getParents. You could push CE here and 
use a RAII helper to pop it. The 'isCastPartOfExplicitCast' check then 
simplifies to a quick stack traversal.


Repository:
  rC Clang

https://reviews.llvm.org/D48958



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


[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

2018-07-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 154877.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

@vsk thank you for taking a look!

Addressed the trivial part of nits.


Repository:
  rC Clang

https://reviews.llvm.org/D48958

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  test/CodeGen/catch-implicit-integer-truncations.c
  test/CodeGenCXX/catch-implicit-integer-truncations.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -31,6 +31,21 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope"
 // CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}}
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fno-sanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-NORECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-trap=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-TRAP
+// CHECK-IMPLICIT-CAST: "-fsanitize={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ???
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+
 // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS
 // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}}
 
Index: test/CodeGenCXX/catch-implicit-integer-truncations.cpp
===
--- /dev/null
+++ test/CodeGenCXX/catch-implicit-integer-truncations.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fno-sanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-trap=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP
+
+extern "C" { // Disable name mangling.
+
+// For now, all the true-positives are tested in the C test in ../CodeGen/
+
+// == //
+// The expected false-negatives.
+// == //
+
+// Explicit truncating casts.
+// == //
+
+// CHECK-LABEL: @explicit_unsigned_int_to_unsigned_char
+unsigned char explicit_unsigned_int_to_unsigned_char(unsigned int src) {
+  // CHECK-SANITIZE-NOT: call
+  // CHECK: }
+  return (unsigned char)src;
+}
+
+// CHECK-LABEL: @explicit_signed_int_to_unsigned_char
+unsigned char explicit_signed_int_to_unsigned_char(signed int src) {
+  // CHECK-SANITIZE-NOT: call
+  // CHECK: }
+  return (unsigned char)src;
+}
+
+// CHECK-LABEL: @explicit_unsigned_int_to_signed_char
+signed char exp

[PATCH] D48845: [Sema] Add fixit for unused lambda captures

2018-07-10 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

I'm kind of interested in this fixit, but one thought which i have - probably 
it should be more conservative (i.e. fix captures by reference, integral types, 
etc) (since the code might rely on side-effects of copy-ctors/move-ctors or 
extend the lifetime of an object), but fixing only simple cases still seems to 
be useful imo. CC: @aaron.ballman , @arphaman, @ahatanak


Repository:
  rC Clang

https://reviews.llvm.org/D48845



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


r336740 - [X86] Also fix the test for _mm512_mullo_epi64 to test the intrinsic instead of a copy of the intrinsic implementation.

2018-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Jul 10 16:28:05 2018
New Revision: 336740

URL: http://llvm.org/viewvc/llvm-project?rev=336740&view=rev
Log:
[X86] Also fix the test for _mm512_mullo_epi64 to test the intrinsic instead of 
a copy of the intrinsic implementation.

This had the same issue I just fixed in r336739. Apparently I copy pasted 
_mm512_mullo_epi64 when I added _mm512_mullox_epi64.

Modified:
cfe/trunk/test/CodeGen/avx512dq-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512dq-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512dq-builtins.c?rev=336740&r1=336739&r2=336740&view=diff
==
--- cfe/trunk/test/CodeGen/avx512dq-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512dq-builtins.c Tue Jul 10 16:28:05 2018
@@ -6,7 +6,7 @@
 __m512i test_mm512_mullo_epi64 (__m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_mullo_epi64
   // CHECK: mul <8 x i64>
-  return (__m512i) ((__v8di) __A * (__v8di) __B);
+  return (__m512i) _mm512_mullo_epi64(__A, __B);
 }
 
 __m512i test_mm512_mask_mullo_epi64 (__m512i __W, __mmask8 __U, __m512i __A, 
__m512i __B) {


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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-10 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- added inline comments.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:42
+
+const auto &Parents = Result.Context->getParents(*MatchedDecl);
+for (const auto &Parent : Parents) {

Eugene.Zelenko wrote:
> Please don't use auto where type is not easily deducible. Same in other 
> places.
This is the same code pattern as bugprone/MultipleStatementMacroCheck.cpp and 
readability/RedundantDeclarationCheck.cpp. What type shall I use for Parent 
instead? DynTypedNodeList::DynTypedNode ?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


r336739 - [X86] Fix the test for _mm512_mullox_epi64 to test the intrinsic instead of a copy of the intrinsic implementation.

2018-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Jul 10 16:13:01 2018
New Revision: 336739

URL: http://llvm.org/viewvc/llvm-project?rev=336739&view=rev
Log:
[X86] Fix the test for _mm512_mullox_epi64 to test the intrinsic instead of a 
copy of the intrinsic implementation.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=336739&r1=336738&r2=336739&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue Jul 10 16:13:01 2018
@@ -3060,7 +3060,7 @@ __m512i test_mm512_mullo_epi32(__m512i _
 __m512i test_mm512_mullox_epi64 (__m512i __A, __m512i __B) {
   // CHECK-LABEL: @test_mm512_mullox_epi64
   // CHECK: mul <8 x i64>
-  return (__m512i) ((__v8di) __A * (__v8di) __B);
+  return (__m512i) _mm512_mullox_epi64(__A, __B);
 }
 
 __m512i test_mm512_mask_mullox_epi64 (__m512i __W, __mmask8 __U, __m512i __A, 
__m512i __B) {


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


r336738 - Fix determination of whether a reinterpret_cast casts away constness.

2018-07-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 10 16:04:35 2018
New Revision: 336738

URL: http://llvm.org/viewvc/llvm-project?rev=336738&view=rev
Log:
Fix determination of whether a reinterpret_cast casts away constness.

The "casts away constness" check doesn't care at all how the different
layers of the source and destination type were formed: for example, if
the source is a pointer and the destination is a pointer-to-member, the
types are still decomposed and their pointee qualifications are still
checked.

This rule is bizarre and somewhat ridiculous, so as an extension we
accept code making use of such reinterpret_casts with a warning outside
of SFINAE contexts.

Added:
cfe/trunk/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/Sema/warn-cast-qual.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=336738&r1=336737&r2=336738&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 10 16:04:35 
2018
@@ -6184,6 +6184,12 @@ def err_bad_cxx_cast_bitfield : Error<
 def err_bad_cxx_cast_qualifiers_away : Error<
   "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
   "functional-style cast}0 from %1 to %2 casts away qualifiers">;
+def ext_bad_cxx_cast_qualifiers_away_incoherent : ExtWarn<
+  "ISO C++ does not allow "
+  "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
+  "functional-style cast}0 from %1 to %2 because it casts away qualifiers, "
+  "even though the source and destination types are unrelated">,
+  SFINAEFailure, InGroup>;
 def err_bad_const_cast_dest : Error<
   "%select{const_castC-style cast|functional-style cast}0 to %2, "
   "which is not a reference, pointer-to-object, or pointer-to-data-member">;

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=336738&r1=336737&r2=336738&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Jul 10 16:04:35 2018
@@ -33,10 +33,16 @@ using namespace clang;
 enum TryCastResult {
   TC_NotApplicable, ///< The cast method is not applicable.
   TC_Success,   ///< The cast method is appropriate and successful.
+  TC_Extension, ///< The cast method is appropriate and accepted as a
+///< language extension.
   TC_Failed ///< The cast method is appropriate, but failed. A
 ///< diagnostic has been emitted.
 };
 
+static bool isValidCast(TryCastResult TCR) {
+  return TCR == TC_Success || TCR == TC_Extension;
+}
+
 enum CastType {
   CT_Const,   ///< const_cast
   CT_Static,  ///< static_cast
@@ -431,95 +437,68 @@ static void diagnoseBadCast(Sema &S, uns
   }
 }
 
-/// UnwrapDissimilarPointerTypes - Like Sema::UnwrapSimilarPointerTypes,
-/// this removes one level of indirection from both types, provided that 
they're
-/// the same kind of pointer (plain or to-member). Unlike the Sema function,
-/// this one doesn't care if the two pointers-to-member don't point into the
-/// same class. This is because CastsAwayConstness doesn't care.
-/// And additionally, it handles C++ references. If both the types are
-/// references, then their pointee types are returned,
-/// else if only one of them is reference, it's pointee type is returned,
-/// and the other type is returned as-is.
-static bool UnwrapDissimilarPointerTypes(QualType& T1, QualType& T2) {
-  const PointerType *T1PtrType = T1->getAs(),
-*T2PtrType = T2->getAs();
-  if (T1PtrType && T2PtrType) {
-T1 = T1PtrType->getPointeeType();
-T2 = T2PtrType->getPointeeType();
-return true;
-  }
-  const ObjCObjectPointerType *T1ObjCPtrType = 
-T1->getAs(),
-  *T2ObjCPtrType = 
-T2->getAs();
-  if (T1ObjCPtrType) {
-if (T2ObjCPtrType) {
-  T1 = T1ObjCPtrType->getPointeeType();
-  T2 = T2ObjCPtrType->getPointeeType();
-  return true;
-}
-else if (T2PtrType) {
-  T1 = T1ObjCPtrType->getPointeeType();
-  T2 = T2PtrType->getPointeeType();
-  return true;
-}
-  }
-  else if (T2ObjCPtrType) {
-if (T1PtrType) {
-  T2 = T2ObjCPtrType->getPointeeType();
-  T1 = T1PtrType->getPointeeType();
-  return true;
-}
-  }
-  
-  const MemberPointerType *T1MPType = T1->getAs(),
-  *T2MPType = T2->getAs();
-  if (T1MPType && T2MPType) {
-T1 = T1MPType->getPointeeType();
-T2 = T2MPType->getPointeeType();
-retu

[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-10 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
shuaiwang marked an inline comment as done.
Closed by commit rL336737: Use ExprMutationAnalyzer in 
performance-for-range-copy (authored by shuaiwang, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48854

Files:
  clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp


Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,7 +8,7 @@
 
//===--===//
 
 #include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
 
@@ -79,8 +79,8 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
-   Context))
+  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar))
 return false;
   diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "
Index: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
@@ -117,6 +117,11 @@
   ~Mutable() {}
 };
 
+struct Point {
+  ~Point() {}
+  int x, y;
+};
+
 Mutable& operator<<(Mutable &Out, bool B) {
   Out.setBool(B);
   return Out;
@@ -214,6 +219,15 @@
   }
 }
 
+void positiveOnlyAccessedFieldAsConst() {
+  for (auto UsedAsConst : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]
+// CHECK-FIXES: for (const auto& UsedAsConst : View>()) {
+use(UsedAsConst.x);
+use(UsedAsConst.y);
+  }
+}
+
 void positiveOnlyUsedInCopyConstructor() {
   for (auto A : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]


Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,7 +8,7 @@
 //===--===//
 
 #include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
 
@@ -79,8 +79,8 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
-   Context))
+  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar))
 return false;
   diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "
Index: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
@@ -117,6 +117,11 @@
   ~Mutable() {}
 };
 
+struct Point {
+  ~Point() {}
+  int x, y;
+};
+
 Mutable& operator<<(Mutable &Out, bool B) {
   Out.setBool(B);
   return Out;
@@ -214,6 +219,15 @@
   }
 }
 
+void positiveOnlyAccessedFieldAsConst() {
+  for (auto UsedAsConst : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
+// CHECK-FIXES: for (const auto& UsedAsConst : View>()) {
+use(UsedAsConst.x);
+use(UsedAsConst.y);
+  }
+}
+
 void positiveOnlyUsedInCopyConstructor() {
   for (auto A : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
__

[clang-tools-extra] r336737 - Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-10 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Tue Jul 10 15:51:06 2018
New Revision: 336737

URL: http://llvm.org/viewvc/llvm-project?rev=336737&view=rev
Log:
Use ExprMutationAnalyzer in performance-for-range-copy

Summary:
This gives better coverage to the check as ExprMutationAnalyzer is more
accurate comparing to isOnlyUsedAsConst.

Majority of wins come from const usage of member field, e.g.:
for (auto widget : container) { // copy of loop variable
  if (widget.type == BUTTON) { // const usage only recognized by 
ExprMutationAnalyzer
// ...
  }
}

Reviewers: george.karpenkov

Subscribers: a.sidorin, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp?rev=336737&r1=336736&r2=336737&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp Tue 
Jul 10 15:51:06 2018
@@ -8,7 +8,7 @@
 
//===--===//
 
 #include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
 
@@ -79,8 +79,8 @@ bool ForRangeCopyCheck::handleCopyIsOnly
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
-   Context))
+  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar))
 return false;
   diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "

Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=336737&r1=336736&r2=336737&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Tue 
Jul 10 15:51:06 2018
@@ -117,6 +117,11 @@ struct Mutable {
   ~Mutable() {}
 };
 
+struct Point {
+  ~Point() {}
+  int x, y;
+};
+
 Mutable& operator<<(Mutable &Out, bool B) {
   Out.setBool(B);
   return Out;
@@ -214,6 +219,15 @@ void positiveOnlyUsedAsConstArguments()
   }
 }
 
+void positiveOnlyAccessedFieldAsConst() {
+  for (auto UsedAsConst : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]
+// CHECK-FIXES: for (const auto& UsedAsConst : View>()) {
+use(UsedAsConst.x);
+use(UsedAsConst.y);
+  }
+}
+
 void positiveOnlyUsedInCopyConstructor() {
   for (auto A : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]


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


[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-07-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D48753#1157907, @Quuxplusone wrote:

> In https://reviews.llvm.org/D48753#1157695, @EricWF wrote:
>
> > Why are we doing this?
> >
> > I can't find the language in the C++03 specification that requires us to 
> > call an allocators `construct` method if it's present.
>
>
> I think it's being proposed under "quality of implementation."
>
> It has only just now occurred to me: a quality implementation should probably 
> never //mismatch// calls to `construct` and `destroy`. Does libc++ currently 
> call `destroy` in C++03? Does it call `destroy` in C++03 after this patch?  
> If this patch is making libc++ call `construct` but not `destroy`, that's a 
> bug. If before this patch libc++ would call `destroy` but not `construct`, 
> this patch is a bugfix!  (And please add a test case for matched pairs of 
> `construct` and `destroy`.)


In C++03 `destroy` isn't called neither before my patch nor after. Will fix 
that. Though it's harder to find specification for `destroy` in C++03.


https://reviews.llvm.org/D48753



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


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-07-10 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 154895.
manojgupta added a comment.

Do not generate calls with "nonnull" attribute with 
"-fno-delete-null-pointer-checks".
The warnings are still generated when nullptr is passed to a function with 
nonnull
attribute.


Repository:
  rC Clang

https://reviews.llvm.org/D47894

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/delete-null-pointer-checks.c
  test/CodeGen/nonnull.c
  test/CodeGen/vla.c
  test/CodeGenCXX/address-space-ref.cpp
  test/CodeGenCXX/constructors.cpp
  test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  test/CodeGenCXX/temporaries.cpp
  test/Driver/clang_f_opts.c
  test/Sema/nonnull.c

Index: test/Sema/nonnull.c
===
--- test/Sema/nonnull.c
+++ test/Sema/nonnull.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fno-delete-null-pointer-checks -verify %s
 // rdar://9584012
 
 typedef struct {
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -348,7 +348,6 @@
 // RUN: -fwhole-program   \
 // RUN: -fcaller-saves\
 // RUN: -freorder-blocks  \
-// RUN: -fdelete-null-pointer-checks  \
 // RUN: -ffat-lto-objects \
 // RUN: -fmerge-constants \
 // RUN: -finline-small-functions  \
@@ -414,7 +413,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
-// CHECK-WARNING-DAG: optimization flag '-fdelete-null-pointer-checks' is not supported
 // CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported
 // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported
@@ -526,3 +524,10 @@
 // RUN: %clang -### -S -fno-merge-all-constants -fmerge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-MERGE-ALL-CONSTANTS %s
 // CHECK-NO-MERGE-ALL-CONSTANTS-NOT: "-fmerge-all-constants"
 // CHECK-MERGE-ALL-CONSTANTS: "-fmerge-all-constants"
+
+// RUN: %clang -### -S -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fdelete-null-pointer-checks -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fno-delete-null-pointer-checks -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s
+// CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks"
+// CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks"
Index: test/CodeGenCXX/temporaries.cpp
===
--- test/CodeGenCXX/temporaries.cpp
+++ test/CodeGenCXX/temporaries.cpp
@@ -1,52 +1,53 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 | FileCheck %s -check-prefixes=CHECK-COMMON,CHECK-NONNULL
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 -fno-delete-null-pointer-checks | FileCheck %s -check-prefixes=CHECK-COMMON,CHECK-NO-NULL
 
 namespace PR16263 {
   const unsigned int n = 1234;
   extern const int &r = (const int&)n;
-  // CHECK: @_ZGRN7PR162631rE_ = internal constant i32 1234,
-  // CHECK: @_ZN7PR162631rE = constant i32* @_ZGRN7PR162631rE_,
+  // CHECK-COMMON: @_ZGRN7PR162631rE_ = internal constant i32 1234,
+  // CHECK-COMMON: @_ZN7PR162631rE = constant i32* @_ZGRN7PR162631rE_,
 
   extern const int &s = reinterpret_cast(n);
-  // CHECK: @_ZN7PR16263L1nE = internal constant i32 1234, align 4
-  // CHECK: @_ZN7PR162631sE = constant i32* @_ZN7PR16263L1nE, align 8
+  // CHECK-COMMON: @_ZN7PR16263L1nE = internal constant i32 1234, align 4
+  // CHECK-COMMON: @_ZN7PR162631sE = constant i32* @_ZN7PR16263L1nE, align 8
 
   struct A { int n; };
   struct B { int n; };
   struct C : A, B {};
   extern const A &&a = (A&&)(A&&)(C&&)(C{});
-  // CHECK: @_ZGRN7PR162631aE_ = internal global {{.*}} zeroinitializer,
-  // CHECK: @_ZN7PR162631aE = constant {{.*}} bitcast ({{.*}}* @_ZGRN

[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 154894.
yaxunl marked an inline comment as done.
yaxunl added a comment.

clean up function prefix.


https://reviews.llvm.org/D49083

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -19,7 +19,7 @@
 // RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - -x hip \
-// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,HIP,HIPRDC
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,HIP
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - -x hip\
 // RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
@@ -79,11 +79,11 @@
 // CUDA-SAME: section ".nvFatBinSegment"
 // HIP-SAME: section ".hipFatBinSegment"
 // * variable to save GPU binary handle after initialization
-// NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
+// CUDANORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
+// HIP: @__[[PREFIX]]_gpubin_handle = linkonce global i8** null
 // * constant unnamed string with NVModuleID
 // RDC: [[MODULE_ID_GLOBAL:@.*]] = private constant
 // CUDARDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
-// HIPRDC-SAME: c"[[MODULE_ID:.+]]\00", section "__hip_module_id", align 32
 // * Make sure our constructor was added to global ctor list.
 // ALL: @llvm.global_ctors = appending global {{.*}}@__[[PREFIX]]_module_ctor
 // * Alias to global symbol containing the NVModuleID.
@@ -120,10 +120,18 @@
 // ALL: define internal void @__[[PREFIX]]_module_ctor
 
 // In separate mode it calls __[[PREFIX]]RegisterFatBinary(&__[[PREFIX]]_fatbin_wrapper)
+// HIP only register fat binary once.
+// HIP: load i8**, i8*** @__hip_gpubin_handle
+// HIP-NEXT: icmp eq i8** {{.*}}, null
+// HIP-NEXT: br i1 {{.*}}, label %if, label %exit
+// HIP: if:
 // NORDC: call{{.*}}[[PREFIX]]RegisterFatBinary{{.*}}__[[PREFIX]]_fatbin_wrapper
 //   .. stores return value in __[[PREFIX]]_gpubin_handle
 // NORDC-NEXT: store{{.*}}__[[PREFIX]]_gpubin_handle
 //   .. and then calls __[[PREFIX]]_register_globals
+// HIP-NEXT: br label %exit
+// HIP: exit:
+// HIP-NEXT: load i8**, i8*** @__hip_gpubin_handle
 // NORDC-NEXT: call void @__[[PREFIX]]_register_globals
 // * In separate mode we also register a destructor.
 // NORDC-NEXT: call i32 @atexit(void (i8*)* @__[[PREFIX]]_module_dtor)
@@ -136,7 +144,14 @@
 // Test that we've created destructor.
 // NORDC: define internal void @__[[PREFIX]]_module_dtor
 // NORDC: load{{.*}}__[[PREFIX]]_gpubin_handle
-// NORDC-NEXT: call void @__[[PREFIX]]UnregisterFatBinary
+// CUDANORDC-NEXT: call void @__[[PREFIX]]UnregisterFatBinary
+// HIP-NEXT: icmp ne i8** {{.*}}, null
+// HIP-NEXT: br i1 {{.*}}, label %if, label %exit
+// HIP: if:
+// HIP-NEXT: call void @__[[PREFIX]]UnregisterFatBinary
+// HIP-NEXT: store i8** null, i8*** @__hip_gpubin_handle
+// HIP-NEXT: br label %exit
+// HIP: exit:
 
 // There should be no __[[PREFIX]]_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -427,22 +427,54 @@
   /*constant*/ true);
   FatbinWrapper->setSection(FatbinSectionName);
 
-  // Register binary with CUDA/HIP runtime. This is substantially different in
-  // default mode vs. separate compilation!
-  if (!RelocatableDeviceCode) {
-// GpuBinaryHandle = __{cuda|hip}RegisterFatBinary(&FatbinWrapper);
+  // There is only one HIP fat binary per linked module, however there are
+  // multiple constructor functions. Make sure the fat binary is registered
+  // only once.
+  if (IsHIP) {
+llvm::BasicBlock *IfBlock =
+llvm::BasicBlock::Create(Context, "if", ModuleCtorFunc);
+llvm::BasicBlock *ExitBlock =
+llvm::BasicBlock::Create(Context, "exit", ModuleCtorFunc);
+GpuBinaryHandle = new llvm::GlobalVariable(
+TheModule, VoidPtrPtrTy, /*isConstant=*/false,
+llvm::GlobalValue::LinkOnceAnyLinkage,
+/*Initializer=*/llvm::ConstantPointerNull::get(VoidPtrPtrTy),
+"__hip_gpubin_handle");
+auto HandleValue =
+CtorBuilder.CreateAlignedLoad(GpuBinaryHandle, CGM.getPointerAlign());
+llvm::Constant *Zero = llvm::Constant::getNullValue(HandleValue->getType());
+llvm::Value *EQZero = CtorBuilder.CreateICmpEQ(HandleValue, Zero);
+CtorBuilder.CreateCondBr(EQZero, IfBlock, ExitBlock);
+CtorBuilder.SetInsertPoint(IfBlock);
+// GpuBinaryHandle = __hipRegisterFatBinary(&FatbinWrapper);
+llvm::CallInst *RegisterFatbinCall = CtorBuilder.CreateCall(
+RegisterFatbinFunc,
+CtorBuilder.CreateBitCast(FatbinWrapper, VoidPtrTy));
+CtorBuild

[PATCH] D49158: [clang-tidy] Fixing segfault when there's no IdentifierInfo

2018-07-10 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: aaron.ballman, hokein, ilya-biryukov.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

Bug 36150 found a segfault on mac when a CXXRecordDecl has no IdentifierInfo, 
this fixes it.


https://reviews.llvm.org/D49158

Files:
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,21 +30,27 @@
 // previously.
 void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
  bool isInterface) {
-  StringRef Name = Node->getIdentifier()->getName();
-  InterfaceMap.insert(std::make_pair(Name, isInterface));
+  if (const auto *Id = Node->getIdentifier()) {
+StringRef Name = Id->getName();
+InterfaceMap.insert(std::make_pair(Name, isInterface));
+  }
 }
 
 // Returns "true" if the boolean "isInterface" has been set to the
 // interface status of the current Node. Return "false" if the
 // interface status for the current node is not yet known.
 bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
   bool &isInterface) const {
-  StringRef Name = Node->getIdentifier()->getName();
-  llvm::StringMapConstIterator Pair = InterfaceMap.find(Name);
-  if (Pair == InterfaceMap.end())
-return false;
-  isInterface = Pair->second;
-  return true;
+  if (!Node) return false;
+  if (const auto *Id = Node->getIdentifier()) {
+StringRef Name = Id->getName();
+llvm::StringMapConstIterator Pair = InterfaceMap.find(Name);
+if (Pair == InterfaceMap.end())
+  return false;
+isInterface = Pair->second;
+return true;
+  }
+  return false;
 }
 
 bool MultipleInheritanceCheck::isCurrentClassInterface(
@@ -104,7 +110,7 @@
   const auto *Base = cast(Ty->getDecl()->getDefinition());
   if (!isInterface(Base)) NumConcrete++;
 }
-
+
 // Check virtual bases to see if there is more than one concrete 
 // non-virtual base.
 for (const auto &V : D->vbases()) {


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -30,21 +30,27 @@
 // previously.
 void MultipleInheritanceCheck::addNodeToInterfaceMap(const CXXRecordDecl *Node,
  bool isInterface) {
-  StringRef Name = Node->getIdentifier()->getName();
-  InterfaceMap.insert(std::make_pair(Name, isInterface));
+  if (const auto *Id = Node->getIdentifier()) {
+StringRef Name = Id->getName();
+InterfaceMap.insert(std::make_pair(Name, isInterface));
+  }
 }
 
 // Returns "true" if the boolean "isInterface" has been set to the
 // interface status of the current Node. Return "false" if the
 // interface status for the current node is not yet known.
 bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
   bool &isInterface) const {
-  StringRef Name = Node->getIdentifier()->getName();
-  llvm::StringMapConstIterator Pair = InterfaceMap.find(Name);
-  if (Pair == InterfaceMap.end())
-return false;
-  isInterface = Pair->second;
-  return true;
+  if (!Node) return false;
+  if (const auto *Id = Node->getIdentifier()) {
+StringRef Name = Id->getName();
+llvm::StringMapConstIterator Pair = InterfaceMap.find(Name);
+if (Pair == InterfaceMap.end())
+  return false;
+isInterface = Pair->second;
+return true;
+  }
+  return false;
 }
 
 bool MultipleInheritanceCheck::isCurrentClassInterface(
@@ -104,7 +110,7 @@
   const auto *Base = cast(Ty->getDecl()->getDefinition());
   if (!isInterface(Base)) NumConcrete++;
 }
-
+
 // Check virtual bases to see if there is more than one concrete 
 // non-virtual base.
 for (const auto &V : D->vbases()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-07-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.



Comment at: include/clang/Sema/Sema.h:4000-4004
+  ExpressionEvaluationContextRecord::ExpressionKind Type = 
ExpressionEvaluationContextRecord::EK_Other);
   enum ReuseLambdaContextDecl_t { ReuseLambdaContextDecl };
-  void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-   ReuseLambdaContextDecl_t,
-   bool IsDecltype = false);
+  void PushExpressionEvaluationContext(
+  ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
+  ExpressionEvaluationContextRecord::ExpressionKind Type = 
ExpressionEvaluationContextRecord::EK_Other);

Please check this fits into 80 columns and wrap the line if not.


https://reviews.llvm.org/D37442



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-07-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!




Comment at: lib/Parse/ParseExprCXX.cpp:2956
+const Token Next = GetLookAheadToken(2);
+const auto GetAfter = [this] { return GetLookAheadToken(3); };
+

I don't think this lambda is useful: since you're not caching the result of 
`GetLookAheadToken(3)` between calls, you may as well call it directly below.



Comment at: lib/Parse/ParseExprCXX.cpp:2961-2962
+(Next.is(tok::l_paren) &&
+ (GetAfter().is(tok::r_paren) ||
+  (GetAfter().is(tok::identifier) &&
+   GetLookAheadToken(4).is(tok::identifier) {

Use `GetLookAheadToken(3).isOneOf(tok::r_paren, tok::identifier)` here.



Comment at: lib/Parse/ParseExprCXX.cpp:2971-2980
+  Diag(Start, diag::err_lambda_after_delete)
+  << SourceRange(Start, StartLoc.getLocWithOffset(1));
+
+  Diag(StartLoc, diag::note_lambda_after_delete)
+  << FixItHint::CreateInsertion(StartLoc, "(")
+  << FixItHint::CreateInsertion(
+ Lexer::getLocForEndOfToken(Lambda.get()->getLocEnd(), 1,

Because we can be very confident the fix is correct, and we're recovering as if 
the fix were applied, you can combine the `err_` diagnostic and the `note_` 
diagnostic into one. That way, tools like `clang -fixit` will apply your fixit.



Comment at: lib/Parse/ParseExprCXX.cpp:2972
+  Diag(Start, diag::err_lambda_after_delete)
+  << SourceRange(Start, StartLoc.getLocWithOffset(1));
+

If you want the location of the `]` token for the end of the range here, it'd 
be best to save `NextToken().getLocation()` prior to calling 
`ParseLambdaExpression()`. Adding 1 to the location of the `[` token isn't 
necessarily the right location (for instance, if there's whitespace between the 
`[` and `]`, or if the left square bracket is spelled as `<:`).


https://reviews.llvm.org/D36357



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-07-10 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 154882.
Rakete added a comment.

Rebased + friendly ping :)


https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp

Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,7 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+  // expected-note@-1 {{add parentheses around the lambda}}
 }
+
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,8 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+// expected-note@-1 {{add parentheses around the lambda}}
 delete [&] { return new int; } (); // ok, lambda
   }
 
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2951,15 +2951,47 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
-ArrayDelete = true;
-BalancedDelimiterTracker T(*this, tok::l_square);
 
-T.consumeOpen();
-T.consumeClose();
-if (T.getCloseLocation().isInvalid())
-  return ExprError();
+const Token Next = GetLookAheadToken(2);
+const auto GetAfter = [this] { return GetLookAheadToken(3); };
+
+// Basic lookahead to check if we have a lambda expression.
+if (Next.isOneOf(tok::l_brace, tok::less) ||
+(Next.is(tok::l_paren) &&
+ (GetAfter().is(tok::r_paren) ||
+  (GetAfter().is(tok::identifier) &&
+   GetLookAheadToken(4).is(tok::identifier) {
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = ParseLambdaExpression();
+  if (Lambda.isInvalid())
+return ExprError();
+
+  SourceLocation StartLoc = Lambda.get()->getLocStart();
+  Diag(Start, diag::err_lambda_after_delete)
+  << SourceRange(Start, StartLoc.getLocWithOffset(1));
+
+  Diag(StartLoc, diag::note_lambda_after_delete)
+  << FixItHint::CreateInsertion(StartLoc, "(")
+  << FixItHint::CreateInsertion(
+ Lexer::getLocForEndOfToken(Lambda.get()->getLocEnd(), 1,
+Actions.getSourceManager(),
+getLangOpts()),
+ ")");
+
+  // Evaluate any postfix expressions used on the lambda.
+  Lambda = ParsePostfixExpressionSuffix(Lambda);
+  return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+Lambda.get());
+} else {
+  ArrayDelete = true;
+  BalancedDelimiterTracker T(*this, tok::l_square);
+
+  T.consumeOpen();
+  T.consumeClose();
+  if (T.getCloseLocation().isInvalid())
+return ExprError();
+}
   }
 
   ExprResult Operand(ParseCastExpression(false));
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -99,6 +99,10 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, InGroup;
+def err_lambda_after_delete : Error<
+  "'[]' after delete interpreted as 'delete[]'">;
+def note_lambda_after_delete : Note<
+  "add parentheses around the lambda">;
 
 def warn_microsoft_dependent_exists : Warning<
   "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked an inline comment as done.
shuaiwang added inline comments.



Comment at: test/clang-tidy/performance-for-range-copy.cpp:120
 
+struct Point {
+  ~Point() {}

JonasToth wrote:
> I feel that `const` methods should be added as a test as well.
const methods are already tested with existing test cases.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48854



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


[PATCH] D10480: Implement shared_mutex re: N4508

2018-07-10 Thread Kenneth Camann via Phabricator via cfe-commits
kjcamann added a comment.

I have recently benchmarked this (platform was RHEL 7 and Haswell), and the 
libc++ version has about twice the latency of a pthread_rwlock for both classes 
of locking. libc++ is also about twice the latency of the libstdc++ 
implementation, because it is just a lightweight wrapper around pthread_rwlocks.


https://reviews.llvm.org/D10480



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


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-07-10 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 154880.
Rakete added a comment.

Rebased + friendly ping


https://reviews.llvm.org/D37442

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/TreeTransform.h
  test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp

Index: test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++17 %s -verify
+
+template struct Nothing {};
+
+void pr33696() {
+Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3859,6 +3859,10 @@
 bool TreeTransform::TransformTemplateArgument(
  const TemplateArgumentLoc &Input,
  TemplateArgumentLoc &Output, bool Uneval) {
+  EnterExpressionEvaluationContext EEEC(
+  SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+  /*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+  Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
   const TemplateArgument &Arg = Input.getArgument();
   switch (Arg.getKind()) {
   case TemplateArgument::Null:
@@ -5494,7 +5498,7 @@
   // decltype expressions are not potentially evaluated contexts
   EnterExpressionEvaluationContext Unevaluated(
   SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
-  /*IsDecltype=*/true);
+  Sema::ExpressionEvaluationContextRecord::EK_Decltype);
 
   ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
   if (E.isInvalid())
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6434,7 +6434,8 @@
   if (RD->isInvalidDecl() || RD->isDependentContext())
 return E;
 
-  bool IsDecltype = ExprEvalContexts.back().IsDecltype;
+  bool IsDecltype = ExprEvalContexts.back().ExprContext ==
+ExpressionEvaluationContextRecord::EK_Decltype;
   CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD);
 
   if (Destructor) {
@@ -6516,7 +6517,9 @@
 /// are omitted for the 'topmost' call in the decltype expression. If the
 /// topmost call bound a temporary, strip that temporary off the expression.
 ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
-  assert(ExprEvalContexts.back().IsDecltype && "not in a decltype expression");
+  assert(ExprEvalContexts.back().ExprContext ==
+ ExpressionEvaluationContextRecord::EK_Decltype &&
+ "not in a decltype expression");
 
   // C++11 [expr.call]p11:
   //   If a function call is a prvalue of object type,
@@ -6558,7 +6561,8 @@
 TopBind = nullptr;
 
   // Disable the special decltype handling now.
-  ExprEvalContexts.back().IsDecltype = false;
+  ExprEvalContexts.back().ExprContext =
+  ExpressionEvaluationContextRecord::EK_Other;
 
   // In MS mode, don't perform any extra checking of call return types within a
   // decltype expression.
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14132,53 +14132,53 @@
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  Decl *LambdaContextDecl,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
-LambdaContextDecl, IsDecltype);
+LambdaContextDecl, ExprContext);
   Cleanup.reset();
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  ReuseLambdaContextDecl_t,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
-  PushExpressionEvaluationConte

r336729 - [NFC] Switch CodeGenFunction to use value init instead of member init lists

2018-07-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jul 10 14:07:50 2018
New Revision: 336729

URL: http://llvm.org/viewvc/llvm-project?rev=336729&view=rev
Log:
[NFC] Switch CodeGenFunction to use value init instead of member init lists

The member init list for the sole constructor for CodeGenFunction
has gotten out of hand, so this patch moves the non-parameter-dependent
initializations into the member value inits.

Note: This is what was intended to be committed in r336726


Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=336729&r1=336728&r2=336729&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Jul 10 14:07:50 2018
@@ -65,25 +65,9 @@ CodeGenFunction::CodeGenFunction(CodeGen
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
-  CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
-  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
-  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
-  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
-  NormalCleanupDest(Address::invalid()), NextCleanupDestIndex(1),
-  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
-  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
-  DisableDebugInfo(false), DidCallStackSave(false), 
IndirectBranch(nullptr),
-  PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
-  CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
-  NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
-  CXXABIThisValue(nullptr), CXXThisValue(nullptr),
-  CXXStructorImplicitParamDecl(nullptr),
-  CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
-  CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
-  TerminateHandler(nullptr), TrapBB(nullptr), LargestVectorWidth(0),
-  ShouldEmitLifetimeMarkers(
-  shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), CGM.getLangOpts())) {
+  SanOpts(CGM.getLangOpts().Sanitize), DebugInfo(CGM.getModuleDebugInfo()),
+  PGO(cgm), ShouldEmitLifetimeMarkers(shouldEmitLifetimeMarkers(
+CGM.getCodeGenOpts(), CGM.getLangOpts())) {
   if (!suppressNewContext)
 CGM.getCXXABI().getMangleContext().startNewFunction();
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=336729&r1=336728&r2=336729&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jul 10 14:07:50 2018
@@ -214,7 +214,7 @@ public:
   const Decl *CurCodeDecl;
   const CGFunctionInfo *CurFnInfo;
   QualType FnRetTy;
-  llvm::Function *CurFn;
+  llvm::Function *CurFn = nullptr;
 
   // Holds coroutine data if the current function is a coroutine. We use a
   // wrapper to manage its lifetime, so that we don't have to define CGCoroData
@@ -242,7 +242,7 @@ public:
 
   /// ReturnValue - The temporary alloca to hold the return
   /// value. This is invalid iff the function has no return value.
-  Address ReturnValue;
+  Address ReturnValue = Address::invalid();
 
   /// Return true if a label was seen in the current scope.
   bool hasLabelBeenSeenInCurrentScope() const {
@@ -321,7 +321,7 @@ public:
 /// Captured 'this' type.
 FieldDecl *CXXThisFieldDecl;
   };
-  CGCapturedStmtInfo *CapturedStmtInfo;
+  CGCapturedStmtInfo *CapturedStmtInfo = nullptr;
 
   /// RAII for correct setting/restoring of CapturedStmtInfo.
   class CGCapturedStmtRAII {
@@ -366,7 +366,7 @@ public:
   SanitizerSet SanOpts;
 
   /// True if CodeGen currently emits code implementing sanitizer checks.
-  bool IsSanitizerScope;
+  bool IsSanitizerScope = false;
 
   /// RAII object to set/unset CodeGenFunction::IsSanitizerScope.
   class SanitizerScope {
@@ -378,26 +378,26 @@ public:
 
   /// In C++, whether we are code generating a thunk.  This controls whether we
   /// should emit cleanups.
-  bool CurFuncIsThunk;
+  bool CurFuncIsThunk = false;
 
   /// In ARC, whether we should autorelease the return value.
-  bool AutoreleaseResult;
+  bool AutoreleaseResult = false;
 
   /// Whether we processed a Microsoft-style asm block during CodeGen. These 
can
   /// potentially set the return value.
-  bool SawAsmBlock;
+  bool SawAsmBlock = false;
 
   const FunctionDecl *CurSEHParent = nullptr;
 
   /// True if the current function is an outlined SEH

[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It's highly likely that this part of coding guidelines.




Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:42
+
+const auto &Parents = Result.Context->getParents(*MatchedDecl);
+for (const auto &Parent : Parents) {

Please don't use auto where type is not easily deducible. Same in other places.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `readability-magic-numbers
+  
`_
 check

Please move into new checks list in alphabetical order.



Comment at: docs/ReleaseNotes.rst:63
+
+  Detect usage of magic numbers, numbers that are used as literals instead of
+  introduced via constants or symbols.

Please use //Detects//.



Comment at: docs/clang-tidy/checks/readability-magic-numbers.rst:11
+
+   double circleArea = 3.1415926535 * radius * radius;
+

JonasToth wrote:
> This example is good, but right now the code only checks for integer 
> literals. Maybe an integer example would be better?
Please use .. code-block:: c++. Same for good example.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-07-10 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In https://reviews.llvm.org/D48753#1157695, @EricWF wrote:

> Why are we doing this?
>
> I can't find the language in the C++03 specification that requires us to call 
> an allocators `construct` method if it's present.


I think it's being proposed under "quality of implementation."

It has only just now occurred to me: a quality implementation should probably 
never //mismatch// calls to `construct` and `destroy`. Does libc++ currently 
call `destroy` in C++03? Does it call `destroy` in C++03 after this patch?  If 
this patch is making libc++ call `construct` but not `destroy`, that's a bug. 
If before this patch libc++ would call `destroy` but not `construct`, this 
patch is a bugfix!  (And please add a test case for matched pairs of 
`construct` and `destroy`.)




Comment at: libcxx/include/memory:1470
+decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Pointer>(),
+_VSTD::declval<_Args>())),
+void

vsapsai wrote:
> Quuxplusone wrote:
> > vsapsai wrote:
> > > Quuxplusone wrote:
> > > > I think you should replace this `)))` with `)), void())` for absolute 
> > > > correctness (e.g. `construct` might plausibly return a pointer to the 
> > > > constructed object, and I think C++03 is okay with that).
> > > > Otherwise, awesome, this looks like what I'd expect. :)
> > > The standard says the result of `construct` is not used but I haven't 
> > > found any mention it **must** be `void`.
> > > 
> > > That being said, the proposed change fails for the C++03 macro-based 
> > > decltype shim:
> > > 
> > > error: too many arguments provided to function-like macro invocation
> > > _VSTD::declval<_Args>()), void()),
> > >   ^
> > > 
> > > One option to fix that is to use
> > > 
> > > is_same
> > > <
> > > decltype(_as_before_),
> > > decltype(_the_same_copy_pasted_argument_)
> > > >
> > > 
> > > But I don't think this use case is worth such hacks.
> > I think the workaround is easier. Try
> > 
> > ```
> > template 
> > struct __has_construct<_Alloc, _Pointer, _A0, typename enable_if<
> >   is_same<
> > decltype((_VSTD::declval<_Alloc>().construct(
> >   _VSTD::declval<_Pointer>(),
> >   _VSTD::declval<_A0>()
> > ), void() )),
> > void
> >   >::value
> > >::type> : std::true_type {};
> > ```
> > 
> > i.e. with an extra set of parens to group the argument to the `decltype` 
> > macro: `decltype(())` instead of `decltype()`. I also drive-by edited 
> > `Args` to `A0`, matching how it's done elsewhere in 
> > pseudo-variadic-templates in this file.
> Thanks for the suggestion, Arthur, that worked.
> 
> Regarding `_Args` vs `_A0`, I am deliberately using `_Args` because it's not 
> a manual pseudo-variadic-template expansion and it's not inside 
> `_LIBCPP_HAS_NO_VARIADICS` block. But I don't feel strong about it, can 
> change to `_A0`.
Please change it (as far as I'm concerned, anyway). "`_Args`" plural implies a 
pack, and there's no pack here.


https://reviews.llvm.org/D48753



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


[PATCH] D39679: [C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list

2018-07-10 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 154875.
Rakete added a comment.

Rebased + friendly ping :)


https://reviews.llvm.org/D39679

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/references.cpp

Index: test/SemaCXX/references.cpp
===
--- test/SemaCXX/references.cpp
+++ test/SemaCXX/references.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 
 int g(int);
 
 void f() {
@@ -55,6 +56,24 @@
   //  const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0
   const volatile int cvi = 1;
   const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+#if __cplusplus >= 201103L
+  const int& r2{cvi}; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+  const int a = 2;
+  int& r3{a}; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const'}}
+
+  const int&& r4{a}; // expected-error{{rvalue reference to type 'const int' cannot bind to lvalue of type 'const int'}}
+
+  void func();
+  void func(int);
+  int &ptr1 = {func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+  int &&ptr2{func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+  // expected-note@-4{{candidate function}}
+  // expected-note@-4{{candidate function}}
+  // expected-note@-6{{candidate function}}
+  // expected-note@-6{{candidate function}}
+#endif
 }
 
 // C++ [dcl.init.ref]p3
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7567,6 +7567,19 @@
   if (!Failed())
 return false;
 
+  // When we want to diagnose only one element of a braced-init-list,
+  // we need to factor it out.
+  Expr *OnlyArg;
+  if (Args.size() == 1) {
+auto *List = dyn_cast(Args[0]);
+if (List && List->getNumInits() == 1)
+  OnlyArg = List->getInit(0);
+else
+  OnlyArg = Args[0];
+  }
+  else
+OnlyArg = nullptr;
+
   QualType DestType = Entity.getType();
   switch (Failure) {
   case FK_TooManyInitsForReference:
@@ -7627,7 +7640,7 @@
   ? diag::err_array_init_different_type
   : diag::err_array_init_non_constant_array))
   << DestType.getNonReferenceType()
-  << Args[0]->getType()
+  << OnlyArg->getType()
   << Args[0]->getSourceRange();
 break;
 
@@ -7638,17 +7651,17 @@
 
   case FK_AddressOfOverloadFailed: {
 DeclAccessPair Found;
-S.ResolveAddressOfOverloadedFunction(Args[0],
+S.ResolveAddressOfOverloadedFunction(OnlyArg,
  DestType.getNonReferenceType(),
  true,
  Found);
 break;
   }
 
   case FK_AddressOfUnaddressableFunction: {
-auto *FD = cast(cast(Args[0])->getDecl());
+auto *FD = cast(cast(OnlyArg)->getDecl());
 S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true,
-Args[0]->getLocStart());
+OnlyArg->getLocStart());
 break;
   }
 
@@ -7658,11 +7671,11 @@
 case OR_Ambiguous:
   if (Failure == FK_UserConversionOverloadFailed)
 S.Diag(Kind.getLocation(), diag::err_typecheck_ambiguous_condition)
-  << Args[0]->getType() << DestType
+  << OnlyArg->getType() << DestType
   << Args[0]->getSourceRange();
   else
 S.Diag(Kind.getLocation(), diag::err_ref_init_ambiguous)
-  << DestType << Args[0]->getType()
+  << DestType << OnlyArg->getType()
   << Args[0]->getSourceRange();
 
   FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args);
@@ -7672,18 +7685,18 @@
   if (!S.RequireCompleteType(Kind.getLocation(),
  DestType.getNonReferenceType(),
   diag::err_typecheck_nonviable_condition_incomplete,
-   Args[0]->getType(), Args[0]->getSourceRange()))
+   OnlyArg->getType(), Args[0]->getSourceRange()))
 S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
   << (Entity.getKind() == InitializedEntity::EK_Result)
-  << Args[0]->getType() << Args[0]->getSourceRange()
+  << OnlyArg->getType() << Args[0]->getSourceRange()
   << DestType.getNonReferenceType();
 
   FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args);
   break;
 
 case OR_Deleted: {
   S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
-<< Args[0]->getType() << DestType.getNonReferenceType()
+<< OnlyArg->getType() << DestType.getNonReferenceType()
 << Args

RE: r336726 - [NFC] Switch CodeGenFunction to use value init instead of member init lists

2018-07-10 Thread Keane, Erich via cfe-commits
Sorry everyone, I didn't police my subversion directory correctly.  I noticed 
when I got the email that the 'commit' list was too large!  Reverted in 336727.

-Original Message-
From: Erich Keane via cfe-commits [mailto:cfe-commits@lists.llvm.org] 
Sent: Tuesday, July 10, 2018 1:47 PM
To: cfe-commits@lists.llvm.org
Subject: r336726 - [NFC] Switch CodeGenFunction to use value init instead of 
member init lists

Author: erichkeane
Date: Tue Jul 10 13:46:46 2018
New Revision: 336726

URL: http://llvm.org/viewvc/llvm-project?rev=336726&view=rev
Log:
[NFC] Switch CodeGenFunction to use value init instead of member init lists

The member init list for the sole constructor for CodeGenFunction
has gotten out of hand, so this patch moves the non-parameter-dependent
initializations into the member value inits.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaCXX/vector.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jul 10 13:46:46 2018
@@ -168,6 +168,7 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet
   DependentAddressSpaceTypes;
   mutable llvm::FoldingSet VectorTypes;
+  mutable llvm::FoldingSet DependentVectorTypes;
   mutable llvm::FoldingSet FunctionNoProtoTypes;
   mutable llvm::ContextualFoldingSet
 FunctionProtoTypes;
@@ -1321,6 +1322,11 @@ public:
   /// \pre \p VectorType must be a built-in type.
   QualType getVectorType(QualType VectorType, unsigned NumElts,
  VectorType::VectorKind VecKind) const;
+  /// Return the unique reference to the type for a dependently sized vector of
+  /// the specified element type.
+  QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
+  SourceLocation AttrLoc,
+  VectorType::VectorKind VecKind) const;
 
   /// Return the unique reference to an extended vector type
   /// of the specified element type and size.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jul 10 13:46:46 2018
@@ -993,6 +993,12 @@ DEF_TRAVERSE_TYPE(DependentAddressSpaceT
   TRY_TO(TraverseType(T->getPointeeType()));
 })
 
+DEF_TRAVERSE_TYPE(DependentVectorType, {
+  if (T->getSizeExpr())
+TRY_TO(TraverseStmt(T->getSizeExpr()));
+  TRY_TO(TraverseType(T->getElementType()));
+})
+
 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
   if (T->getSizeExpr())
 TRY_TO(TraverseStmt(T->getSizeExpr()));
@@ -1221,6 +1227,12 @@ DEF_TRAVERSE_TYPELOC(VectorType, {
   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
 })
 
+DEF_TRAVERSE_TYPELOC(DependentVectorType, {
+  if (TL.getTypePtr()->getSizeExpr())
+TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
+  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
+})
+
 // FIXME: size and attributes
 // FIXME: base VectorTypeLoc is unfinished
 DEF_TRAVERSE_TYPELOC(ExtVectorType, {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 10 13:46:46 2018
@@ -1590,6 +1590,7 @@ protected:
 
   class VectorTypeBitfields {
 friend class VectorType;
+friend class DependentVectorType;
 
 unsigned : NumTypeBits;
 
@@ -3079,6 +3080,51 @@ public:
   }
 };
 

r336727 - Revert -r336726, which included more files than intended.

2018-07-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jul 10 13:51:41 2018
New Revision: 336727

URL: http://llvm.org/viewvc/llvm-project?rev=336727&view=rev
Log:
Revert -r336726, which included more files than intended.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaCXX/vector.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=336727&r1=336726&r2=336727&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jul 10 13:51:41 2018
@@ -168,7 +168,6 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet
   DependentAddressSpaceTypes;
   mutable llvm::FoldingSet VectorTypes;
-  mutable llvm::FoldingSet DependentVectorTypes;
   mutable llvm::FoldingSet FunctionNoProtoTypes;
   mutable llvm::ContextualFoldingSet
 FunctionProtoTypes;
@@ -1322,11 +1321,6 @@ public:
   /// \pre \p VectorType must be a built-in type.
   QualType getVectorType(QualType VectorType, unsigned NumElts,
  VectorType::VectorKind VecKind) const;
-  /// Return the unique reference to the type for a dependently sized vector of
-  /// the specified element type.
-  QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
-  SourceLocation AttrLoc,
-  VectorType::VectorKind VecKind) const;
 
   /// Return the unique reference to an extended vector type
   /// of the specified element type and size.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=336727&r1=336726&r2=336727&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jul 10 13:51:41 2018
@@ -993,12 +993,6 @@ DEF_TRAVERSE_TYPE(DependentAddressSpaceT
   TRY_TO(TraverseType(T->getPointeeType()));
 })
 
-DEF_TRAVERSE_TYPE(DependentVectorType, {
-  if (T->getSizeExpr())
-TRY_TO(TraverseStmt(T->getSizeExpr()));
-  TRY_TO(TraverseType(T->getElementType()));
-})
-
 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
   if (T->getSizeExpr())
 TRY_TO(TraverseStmt(T->getSizeExpr()));
@@ -1227,12 +1221,6 @@ DEF_TRAVERSE_TYPELOC(VectorType, {
   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
 })
 
-DEF_TRAVERSE_TYPELOC(DependentVectorType, {
-  if (TL.getTypePtr()->getSizeExpr())
-TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
-  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
-})
-
 // FIXME: size and attributes
 // FIXME: base VectorTypeLoc is unfinished
 DEF_TRAVERSE_TYPELOC(ExtVectorType, {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=336727&r1=336726&r2=336727&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 10 13:51:41 2018
@@ -1590,7 +1590,6 @@ protected:
 
   class VectorTypeBitfields {
 friend class VectorType;
-friend class DependentVectorType;
 
 unsigned : NumTypeBits;
 
@@ -3080,51 +3079,6 @@ public:
   }
 };
 
-/// Represents a vector type where either the type or sizeis dependent.
-
-/// For example:
-/// \code
-/// template
-/// class vector {
-///   typedef T __attribute__((vector_size(Size))) type;
-/// }
-/// \endcode
-class DependentVectorType : public Type, public llvm::FoldingSetNode {
-  friend class ASTContext;
-
-  const ASTContext &Context;
-  QualType ElementType;
-  Expr *SizeExpr;
-  SourceLocation Loc;
-
-  DependentVectorType(const ASTContext &Context, QualType ElementType,
-  QualType CanonType, Expr *SizeExpr, SourceLocation Loc,
-  VectorType::VectorKind vecKin

[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-07-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D48753#1157695, @EricWF wrote:

> Why are we doing this?
>
> I can't find the language in the C++03 specification that requires us to call 
> an allocators `construct` method if it's present.


The main reason I've ended up doing this because I thought correct 
`__has_construct` is required for https://reviews.llvm.org/D48342. It's not the 
case but I think this change is useful on its own.

I agree that C++03 specification doesn't require to call `construct` method. 
Requirement for containers 23.1[lib.container.requirements]p9 mentions that 
allocator should be used for memory allocation:

> Copy constructors for all container types defined in this clause copy an 
> allocator argument from their respective first parameters. All other 
> constructors for these container types take an Allocator& argument (20.1.6), 
> an allocator whose value type is the same as the container’s value type. A 
> copy of this argument is used for any memory allocation performed, by these 
> constructors and by all member functions, during the lifetime of each 
> container object. In all container types defined in this clause, the member 
> get_allocator() returns a copy of the Allocator object used to construct the 
> container.

And requirement for `allocate` 20.1.6[lib.allocator.requirements]table34 is not 
to construct objects:

> Memory is allocated for n objects of type T but objects are not 
> constructed.[...]

Also for specific containers you can have a requirement to construct a 
container using the specified allocator, without explaining what exactly does 
it mean. E.g. 23.2.1.1[lib.deque.cons]p3:

>   explicit deque(size_type n, const T& value = T(),
>  const Allocator & = Allocator ());
> 
> Effects: Constructs a deque with n copies of value , using the specified 
> allocator.

So these requirements tell that at some point you need to construct an object 
and you have to use an allocator but they don't explicitly spell out that you 
have to call `construct`.

My main motivation for this change is that in C++11 and later we do call 
`construct` if it is available and it is required per 
23.2.1[container.requirements.general]p3:

> For the components affected by this subclause that declare an allocator_type, 
> objects stored in these components shall be constructed using the 
> allocator_traits::construct function and destroyed using the 
> allocator_traits::destroy function (20.7.8.2). These 
> functions are called only for the container’s element type, not for internal 
> types used by the container. [Note: This means, for example, that a 
> node-based container might need to construct nodes containing aligned buffers 
> and call construct to place the element into the buffer. — end note ]

I believe it is valuable and desirable to have the same behavior in different 
versions of C++ unless the semantic was explicitly changed. As far as I know, 
`allocator_traits` in C++11 wasn't supposed to be a breaking change.


https://reviews.llvm.org/D48753



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


r336726 - [NFC] Switch CodeGenFunction to use value init instead of member init lists

2018-07-10 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jul 10 13:46:46 2018
New Revision: 336726

URL: http://llvm.org/viewvc/llvm-project?rev=336726&view=rev
Log:
[NFC] Switch CodeGenFunction to use value init instead of member init lists

The member init list for the sole constructor for CodeGenFunction
has gotten out of hand, so this patch moves the non-parameter-dependent
initializations into the member value inits.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaCXX/vector.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jul 10 13:46:46 2018
@@ -168,6 +168,7 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet
   DependentAddressSpaceTypes;
   mutable llvm::FoldingSet VectorTypes;
+  mutable llvm::FoldingSet DependentVectorTypes;
   mutable llvm::FoldingSet FunctionNoProtoTypes;
   mutable llvm::ContextualFoldingSet
 FunctionProtoTypes;
@@ -1321,6 +1322,11 @@ public:
   /// \pre \p VectorType must be a built-in type.
   QualType getVectorType(QualType VectorType, unsigned NumElts,
  VectorType::VectorKind VecKind) const;
+  /// Return the unique reference to the type for a dependently sized vector of
+  /// the specified element type.
+  QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
+  SourceLocation AttrLoc,
+  VectorType::VectorKind VecKind) const;
 
   /// Return the unique reference to an extended vector type
   /// of the specified element type and size.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jul 10 13:46:46 2018
@@ -993,6 +993,12 @@ DEF_TRAVERSE_TYPE(DependentAddressSpaceT
   TRY_TO(TraverseType(T->getPointeeType()));
 })
 
+DEF_TRAVERSE_TYPE(DependentVectorType, {
+  if (T->getSizeExpr())
+TRY_TO(TraverseStmt(T->getSizeExpr()));
+  TRY_TO(TraverseType(T->getElementType()));
+})
+
 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
   if (T->getSizeExpr())
 TRY_TO(TraverseStmt(T->getSizeExpr()));
@@ -1221,6 +1227,12 @@ DEF_TRAVERSE_TYPELOC(VectorType, {
   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
 })
 
+DEF_TRAVERSE_TYPELOC(DependentVectorType, {
+  if (TL.getTypePtr()->getSizeExpr())
+TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
+  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
+})
+
 // FIXME: size and attributes
 // FIXME: base VectorTypeLoc is unfinished
 DEF_TRAVERSE_TYPELOC(ExtVectorType, {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=336726&r1=336725&r2=336726&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 10 13:46:46 2018
@@ -1590,6 +1590,7 @@ protected:
 
   class VectorTypeBitfields {
 friend class VectorType;
+friend class DependentVectorType;
 
 unsigned : NumTypeBits;
 
@@ -3079,6 +3080,51 @@ public:
   }
 };
 
+/// Represents a vector type where either the type or sizeis dependent.
+
+/// For example:
+/// \code
+/// template
+/// class vector {
+///   typedef T __attribute__((vector_size(Size))) type;
+/// }
+/// \endcode
+class DependentVectorType : public Type, public llvm::FoldingSetNode {
+  friend class ASTContext;
+
+  const ASTContext &Context;
+  QualType ElementType;
+  Expr *SizeExpr;
+  SourceLocation Loc;
+
+

[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

2018-07-10 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.
Herald added a subscriber: omtcyfz.

I took a look at `SymbolCollector`'s `toURI`, and I am not sure what to get 
from it. It seems like a lot of it could be replaced with a call to 
`FileSystem::getRealPath`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687



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


[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

2018-07-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 154863.
lebedev.ri added a comment.

- Check that sanitizer is actually enabled before doing the AST upwalk. I 
didn't measure, but it would be logical for this to be better.


Repository:
  rC Clang

https://reviews.llvm.org/D48958

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  test/CodeGen/catch-implicit-integer-truncations.c
  test/CodeGenCXX/catch-implicit-integer-truncations.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -31,6 +31,21 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope"
 // CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}}
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fno-sanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-NORECOVER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-trap=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-TRAP
+// CHECK-IMPLICIT-CAST: "-fsanitize={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ???
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+
 // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS
 // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}}
 
Index: test/CodeGenCXX/catch-implicit-integer-truncations.cpp
===
--- /dev/null
+++ test/CodeGenCXX/catch-implicit-integer-truncations.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fno-sanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-trap=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP
+
+extern "C" { // Disable name mangling.
+
+// For now, all the true-positives are tested in the C test in ../CodeGen/
+
+// == //
+// The expected false-negatives.
+// == //
+
+// Explicit truncating casts.
+// == //
+
+// CHECK-LABEL: @explicit_unsigned_int_to_unsigned_char
+unsigned char explicit_unsigned_int_to_unsigned_char(unsigned int src) {
+  // CHECK-SANITIZE-NOT: call
+  // CHECK: }
+  return (unsigned char)src;
+}
+
+// CHECK-LABEL: @explicit_signed_int_to_unsigned_char
+unsigned char explicit_signed_int_to_unsigned_char(signed int src) {
+  // CHECK-SANITIZE-NOT: call
+  // CHECK: }
+  return (unsigned char)src;
+}
+
+// CHECK-LABEL: @explicit_unsigned_int_to_signed

[PATCH] D48721: Patch to fix pragma metadata for do-while loops

2018-07-10 Thread Bjorn Pettersson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336717: Patch to fix pragma metadata for do-while loops 
(authored by bjope, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48721?vs=154244&id=154865#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48721

Files:
  cfe/trunk/lib/CodeGen/CGStmt.cpp
  cfe/trunk/test/CodeGen/pragma-do-while.cpp


Index: cfe/trunk/test/CodeGen/pragma-do-while.cpp
===
--- cfe/trunk/test/CodeGen/pragma-do-while.cpp
+++ cfe/trunk/test/CodeGen/pragma-do-while.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// We expect to get a loop structure like this:
+//do.body:   ; preds = %do.cond, ...
+//  ...
+//  br label %do.cond
+//do.cond:   ; preds = %do.body
+//  ...
+//  br i1 %cmp, label %do.body, label %do.end
+//do.end:; preds = %do.cond
+//  ...
+//
+// Verify that the loop metadata only is put on the backedge.
+//
+// CHECK-NOT: llvm.loop
+// CHECK-LABEL: do.cond:
+// CHECK: br {{.*}}, label %do.body, label %do.end, !llvm.loop ![[LMD1:[0-9]+]]
+// CHECK-LABEL: do.end:
+// CHECK-NOT: llvm.loop
+// CHECK: ![[LMD1]] = distinct !{![[LMD1]], ![[LMD2:[0-9]+]]}
+// CHECK: ![[LMD2]] = !{!"llvm.loop.unroll.count", i32 4}
+
+int test(int a[], int n) {
+  int i = 0;
+  int sum = 0;
+
+#pragma unroll 4
+  do
+  {
+a[i] = a[i] + 1;
+sum = sum + a[i];
+i++;
+  } while (i < n);
+
+  return sum;
+}
Index: cfe/trunk/lib/CodeGen/CGStmt.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmt.cpp
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp
@@ -777,19 +777,19 @@
   // Emit the body of the loop.
   llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
 
-  const SourceRange &R = S.getSourceRange();
-  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
- SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()));
-
   EmitBlockWithFallThrough(LoopBody, &S);
   {
 RunCleanupsScope BodyScope(*this);
 EmitStmt(S.getBody());
   }
 
   EmitBlock(LoopCond.getBlock());
 
+  const SourceRange &R = S.getSourceRange();
+  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
+ SourceLocToDebugLoc(R.getBegin()),
+ SourceLocToDebugLoc(R.getEnd()));
+
   // C99 6.8.5.2: "The evaluation of the controlling expression takes place
   // after each execution of the loop body."
 


Index: cfe/trunk/test/CodeGen/pragma-do-while.cpp
===
--- cfe/trunk/test/CodeGen/pragma-do-while.cpp
+++ cfe/trunk/test/CodeGen/pragma-do-while.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// We expect to get a loop structure like this:
+//do.body:   ; preds = %do.cond, ...
+//  ...
+//  br label %do.cond
+//do.cond:   ; preds = %do.body
+//  ...
+//  br i1 %cmp, label %do.body, label %do.end
+//do.end:; preds = %do.cond
+//  ...
+//
+// Verify that the loop metadata only is put on the backedge.
+//
+// CHECK-NOT: llvm.loop
+// CHECK-LABEL: do.cond:
+// CHECK: br {{.*}}, label %do.body, label %do.end, !llvm.loop ![[LMD1:[0-9]+]]
+// CHECK-LABEL: do.end:
+// CHECK-NOT: llvm.loop
+// CHECK: ![[LMD1]] = distinct !{![[LMD1]], ![[LMD2:[0-9]+]]}
+// CHECK: ![[LMD2]] = !{!"llvm.loop.unroll.count", i32 4}
+
+int test(int a[], int n) {
+  int i = 0;
+  int sum = 0;
+
+#pragma unroll 4
+  do
+  {
+a[i] = a[i] + 1;
+sum = sum + a[i];
+i++;
+  } while (i < n);
+
+  return sum;
+}
Index: cfe/trunk/lib/CodeGen/CGStmt.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmt.cpp
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp
@@ -777,19 +777,19 @@
   // Emit the body of the loop.
   llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
 
-  const SourceRange &R = S.getSourceRange();
-  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
- SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()));
-
   EmitBlockWithFallThrough(LoopBody, &S);
   {
 RunCleanupsScope BodyScope(*this);
 EmitStmt(S.getBody());
   }
 
   EmitBlock(LoopCond.getBlock());
 
+  const SourceRange &R = S.getSourceRange();
+  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
+ SourceLocToDebugLoc(R.getBegin()),
+ SourceLocToDebugLoc(R.getEnd()));
+
   // C99 6.8.5.2: "The evaluation of the controlling expression takes place
   // after each execution of the loop body."
 
___
cfe-commits mailin

r336717 - Patch to fix pragma metadata for do-while loops

2018-07-10 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Tue Jul 10 12:55:02 2018
New Revision: 336717

URL: http://llvm.org/viewvc/llvm-project?rev=336717&view=rev
Log:
Patch to fix pragma metadata for do-while loops

Summary:
Make sure that loop metadata only is put on the backedge
when expanding a do-while loop.
Previously we added the loop metadata also on the branch
in the pre-header. That could confuse optimization passes
and result in the loop metadata being associated with the
wrong loop.

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

Committing on behalf of deepak2427 (Deepak Panickal)

Reviewers: #clang, ABataev, hfinkel, aaron.ballman, bjope

Reviewed By: bjope

Subscribers: bjope, rsmith, shenhan, zzheng, xbolva00, lebedev.ri, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/pragma-do-while.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=336717&r1=336716&r2=336717&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Jul 10 12:55:02 2018
@@ -777,11 +777,6 @@ void CodeGenFunction::EmitDoStmt(const D
   // Emit the body of the loop.
   llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
 
-  const SourceRange &R = S.getSourceRange();
-  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
- SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()));
-
   EmitBlockWithFallThrough(LoopBody, &S);
   {
 RunCleanupsScope BodyScope(*this);
@@ -790,6 +785,11 @@ void CodeGenFunction::EmitDoStmt(const D
 
   EmitBlock(LoopCond.getBlock());
 
+  const SourceRange &R = S.getSourceRange();
+  LoopStack.push(LoopBody, CGM.getContext(), DoAttrs,
+ SourceLocToDebugLoc(R.getBegin()),
+ SourceLocToDebugLoc(R.getEnd()));
+
   // C99 6.8.5.2: "The evaluation of the controlling expression takes place
   // after each execution of the loop body."
 

Added: cfe/trunk/test/CodeGen/pragma-do-while.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-do-while.cpp?rev=336717&view=auto
==
--- cfe/trunk/test/CodeGen/pragma-do-while.cpp (added)
+++ cfe/trunk/test/CodeGen/pragma-do-while.cpp Tue Jul 10 12:55:02 2018
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// We expect to get a loop structure like this:
+//do.body:   ; preds = %do.cond, ...
+//  ...
+//  br label %do.cond
+//do.cond:   ; preds = %do.body
+//  ...
+//  br i1 %cmp, label %do.body, label %do.end
+//do.end:; preds = %do.cond
+//  ...
+//
+// Verify that the loop metadata only is put on the backedge.
+//
+// CHECK-NOT: llvm.loop
+// CHECK-LABEL: do.cond:
+// CHECK: br {{.*}}, label %do.body, label %do.end, !llvm.loop ![[LMD1:[0-9]+]]
+// CHECK-LABEL: do.end:
+// CHECK-NOT: llvm.loop
+// CHECK: ![[LMD1]] = distinct !{![[LMD1]], ![[LMD2:[0-9]+]]}
+// CHECK: ![[LMD2]] = !{!"llvm.loop.unroll.count", i32 4}
+
+int test(int a[], int n) {
+  int i = 0;
+  int sum = 0;
+
+#pragma unroll 4
+  do
+  {
+a[i] = a[i] + 1;
+sum = sum + a[i];
+i++;
+  } while (i < n);
+
+  return sum;
+}


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


r336716 - Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"

2018-07-10 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Jul 10 12:49:07 2018
New Revision: 336716

URL: http://llvm.org/viewvc/llvm-project?rev=336716&view=rev
Log:
Revert r336590 "[libclang] evalute compound statement cursors before trying to 
evaluate"

New memory leaks in
LibclangParseTest_EvaluateChildExpression_Test::TestBody()

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/libclang/LibclangTest.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716&r1=336715&r2=336716&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018
@@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp
 }
 
 CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {
-const CompoundStmt *compoundStmt = cast(getCursorStmt(C));
-Expr *expr = nullptr;
-for (auto *bodyIterator : compoundStmt->body()) {
-  if ((expr = dyn_cast(bodyIterator))) {
-break;
-  }
-}
-if (expr)
-  return const_cast(
-  reinterpret_cast(evaluateExpr(expr, C)));
-  }
-
   const Decl *D = getCursorDecl(C);
   if (D) {
 const Expr *expr = nullptr;
@@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCur
   evaluateExpr(const_cast(expr), C)));
 return nullptr;
   }
+
+  const CompoundStmt *compoundStmt = 
dyn_cast_or_null(getCursorStmt(C));
+  if (compoundStmt) {
+Expr *expr = nullptr;
+for (auto *bodyIterator : compoundStmt->body()) {
+  if ((expr = dyn_cast(bodyIterator))) {
+break;
+  }
+}
+if (expr)
+  return const_cast(
+  reinterpret_cast(evaluateExpr(expr, C)));
+  }
   return nullptr;
 }
 

Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716&r1=336715&r2=336716&view=diff
==
--- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07 2018
@@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang
   clang_disposeSourceRangeList(Ranges);
 }
 
-TEST_F(LibclangParseTest, EvaluateChildExpression) {
-  std::string Main = "main.m";
-  WriteFile(Main, "#define kFOO @\"foo\"\n"
-  "void foobar(void) {\n"
-  " {kFOO;}\n"
-  "}\n");
-  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, 
nullptr,
-   0, TUFlags);
-
-  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
-  clang_visitChildren(
-  C,
-  [](CXCursor cursor, CXCursor parent,
- CXClientData client_data) -> CXChildVisitResult {
-if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
-  int numberedStmt = 0;
-  clang_visitChildren(
-  cursor,
-  [](CXCursor cursor, CXCursor parent,
- CXClientData client_data) -> CXChildVisitResult {
-int &numberedStmt = *((int *)client_data);
-if (clang_getCursorKind(cursor) == CXCursor_CompoundStmt) {
-  if (numberedStmt) {
-CXEvalResult RE = clang_Cursor_Evaluate(cursor);
-EXPECT_NE(RE, nullptr);
-EXPECT_EQ(clang_EvalResult_getKind(RE),
-  CXEval_ObjCStrLiteral);
-return CXChildVisit_Break;
-  }
-  numberedStmt++;
-}
-return CXChildVisit_Recurse;
-  },
-  &numberedStmt);
-  EXPECT_EQ(numberedStmt, 1);
-}
-return CXChildVisit_Continue;
-  },
-  nullptr);
-}
-
 class LibclangReparseTest : public LibclangParseTest {
 public:
   void DisplayDiagnostics() {


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


r336715 - Revert r336591 "[libclang] NFC, simplify clang_Cursor_Evaluate"

2018-07-10 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Jul 10 12:48:53 2018
New Revision: 336715

URL: http://llvm.org/viewvc/llvm-project?rev=336715&view=rev
Log:
Revert r336591 "[libclang] NFC, simplify clang_Cursor_Evaluate"

This change is blocking r336590 which is being reverted due to memory leaks.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336715&r1=336714&r2=336715&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:48:53 2018
@@ -3889,32 +3889,33 @@ static const ExprEvalResult* evaluateExp
   return nullptr;
 }
 
-static const Expr *evaluateDeclExpr(const Decl *D) {
-  if (!D)
-return nullptr;
-  if (auto *Var = dyn_cast(D))
-return Var->getInit();
-  else if (auto *Field = dyn_cast(D))
-return Field->getInClassInitializer();
-  return nullptr;
-}
-
-static const Expr *evaluateCompoundStmtExpr(const CompoundStmt *CS) {
-  assert(CS && "invalid compound statement");
-  for (auto *bodyIterator : CS->body()) {
-if (const auto *E = dyn_cast(bodyIterator))
-  return E;
+CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
+  if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {
+const CompoundStmt *compoundStmt = cast(getCursorStmt(C));
+Expr *expr = nullptr;
+for (auto *bodyIterator : compoundStmt->body()) {
+  if ((expr = dyn_cast(bodyIterator))) {
+break;
+  }
+}
+if (expr)
+  return const_cast(
+  reinterpret_cast(evaluateExpr(expr, C)));
   }
-  return nullptr;
-}
 
-CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  if (const Expr *E =
-  clang_getCursorKind(C) == CXCursor_CompoundStmt
-  ? evaluateCompoundStmtExpr(cast(getCursorStmt(C)))
-  : evaluateDeclExpr(getCursorDecl(C)))
-return const_cast(
-reinterpret_cast(evaluateExpr(const_cast(E), 
C)));
+  const Decl *D = getCursorDecl(C);
+  if (D) {
+const Expr *expr = nullptr;
+if (auto *Var = dyn_cast(D)) {
+  expr = Var->getInit();
+} else if (auto *Field = dyn_cast(D)) {
+  expr = Field->getInClassInitializer();
+}
+if (expr)
+  return const_cast(reinterpret_cast(
+  evaluateExpr(const_cast(expr), C)));
+return nullptr;
+  }
   return nullptr;
 }
 


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


Re: r336590 - [libclang] evalute compound statement cursors before trying to evaluate

2018-07-10 Thread Evgenii Stepanov via cfe-commits
Reverting...

On Mon, Jul 9, 2018 at 8:18 PM, Vlad Tsyrklevich  wrote:
> The ASan bot is failing with a LeakSanitizer failure that appears related to
> one of your libclang changes:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/6282/steps/check-clang%20asan/logs/stdio
>
> Direct leak of 24 byte(s) in 1 object(s) allocated from:
> #0 0x52c638 in operator new(unsigned long)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106
> #1 0x7fd236783b89 in make_unique
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1057:29
> #2 0x7fd236783b89 in evaluateExpr
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3755
> #3 0x7fd236783b89 in clang_Cursor_Evaluate
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3917
> #4 0x54e743 in operator()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:487:39
> #5 0x54e743 in
> LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::operator()(CXCursor,
> CXCursor, void*) const::'lambda'(CXCursor, CXCursor,
> void*)::__invoke(CXCursor, CXCursor, void*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:482
> #6 0x7fd23677de00 in
> clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector 10u>&)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3019:17
> #7 0x7fd23675c3a8 in clang::cxcursor::CursorVisitor::Visit(clang::Stmt
> const*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:3164:17
> #8 0x7fd236755d2f in
> clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp
> #9 0x7fd236754e5d in clang::cxcursor::CursorVisitor::Visit(CXCursor,
> bool)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:225:16
> #10 0x7fd23676487c in
> clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:889:9
> #11 0x7fd236759e24 in
> clang::declvisitor::Base clang::cxcursor::CursorVisitor, bool>::Visit(clang::Decl*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/include/clang/AST/DeclVisitor.h
> #12 0x7fd236755c17 in
> clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:506:34
> #13 0x7fd23678a558 in clang_visitChildren
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20
> #14 0x54e024 in operator()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:480:11
> #15 0x54e024 in
> LibclangParseTest_EvaluateChildExpression_Test::TestBody()::$_0::__invoke(CXCursor,
> CXCursor, void*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:476
> #16 0x7fd236754d49 in clang::cxcursor::CursorVisitor::Visit(CXCursor,
> bool)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:217:11
> #17 0x7fd23675cb87 in
> clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:674:7
> #18 0x7fd23675cefe in
> clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:635:30
> #19 0x7fd236756399 in
> clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:540:20
> #20 0x7fd23678a558 in clang_visitChildren
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4352:20
> #21 0x537fa1 in
> LibclangParseTest_EvaluateChildExpression_Test::TestBody()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/libclang/LibclangTest.cpp:474:3
> #22 0x5cae31 in testing::Test::Run()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
> #23 0x5cd068 in testing::TestInfo::Run()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
> #24 0x5ce430 in testing::TestCase::Run()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
> #25 0x5ec1d4 in testing::internal::UnitTestImpl::RunAllTests()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
> #26 0x5eb380 in testing::UnitTest::Run()
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
> #27 0x5b3983 in RUN

[PATCH] D48721: Patch to fix pragma metadata for do-while loops

2018-07-10 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In https://reviews.llvm.org/D48721#1157571, @deepak2427 wrote:

> @Bjorn, Thanks for reviewing and accepting the patch.
>
> Could you please advise on the next steps?
>  Would someone else commit this on my behalf or should I request for commit 
> access?
>
> Thanks,
>  Deepak Panickal


I can commit this for you, and then you should be able to close the bugzilla 
ticket. Include a reference to the SVN id that will be the result of my commit 
when closing the bugzilla ticket.


https://reviews.llvm.org/D48721



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


[libcxxabi] r336713 - [CMake] Set per-runtime library directory suffix in runtimes build

2018-07-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 10 12:13:33 2018
New Revision: 336713

URL: http://llvm.org/viewvc/llvm-project?rev=336713&view=rev
Log:
[CMake] Set per-runtime library directory suffix in runtimes build

Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=336713&r1=336712&r2=336713&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Jul 10 12:13:33 2018
@@ -161,7 +161,7 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(DEFAULT_INSTALL_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
-  set(LIBCXXABI_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LLVM_RUNTIMES_LIBDIR_SUFFIX})
+  set(LIBCXXABI_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 else()


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


[libcxx] r336713 - [CMake] Set per-runtime library directory suffix in runtimes build

2018-07-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 10 12:13:33 2018
New Revision: 336713

URL: http://llvm.org/viewvc/llvm-project?rev=336713&view=rev
Log:
[CMake] Set per-runtime library directory suffix in runtimes build

Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=336713&r1=336712&r2=336713&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Jul 10 12:13:33 2018
@@ -387,7 +387,7 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(DEFAULT_INSTALL_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
   set(DEFAULT_INSTALL_HEADER_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/)
-  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LLVM_RUNTIMES_LIBDIR_SUFFIX})
+  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXX_LIBDIR_SUFFIX})
   set(LIBCXX_HEADER_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})


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


[libunwind] r336713 - [CMake] Set per-runtime library directory suffix in runtimes build

2018-07-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 10 12:13:33 2018
New Revision: 336713

URL: http://llvm.org/viewvc/llvm-project?rev=336713&view=rev
Log:
[CMake] Set per-runtime library directory suffix in runtimes build

Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=336713&r1=336712&r2=336713&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Jul 10 12:13:33 2018
@@ -176,7 +176,7 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(DEFAULT_INSTALL_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
-  set(LIBUNWIND_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LLVM_RUNTIMES_LIBDIR_SUFFIX})
+  set(LIBUNWIND_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBUNWIND_LIBDIR_SUFFIX})
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 else()


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


[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.

2018-07-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: echristo.
Herald added subscribers: JDevlieghere, aprantl.

Some targets support only default set of the debug options and do not
support additional debug options, like NVPTX target. Patch introduced
virtual function supportsNonDefaultDebugOptions() that can be overloaded
by the toolchain, checks if the target supports some additional debug
options and emits warning when an unsupported debug option is
found.


Repository:
  rC Clang

https://reviews.llvm.org/D49148

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-unsupported-debug-options.cu
  test/Driver/openmp-unsupported-debug-options.c

Index: test/Driver/openmp-unsupported-debug-options.c
===
--- /dev/null
+++ test/Driver/openmp-unsupported-debug-options.c
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gz 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-info-for-profiling 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -glldb 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gcodeview 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gmodules 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gembed-source -gdwarf-5 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-macro 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -ggnu-pubnames 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gdwarf-aranges 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-types-section 2>&1 | FileCheck %s
+// CHECK: debug option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx64-nvidia-cuda' [-Wunsupported-target-opt]
+// CHECK-NOT: debug option '{{.*}}' is not supported for target 'x86
+// CHECK: "-triple" "nvptx64-nvidia-cuda"
+// CHECK-NOT: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}}
+// CHECK: "-triple" "x86_64
+// CHECK-SAME: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}}
Index: test/Driver/cuda-unsupported-debug-options.cu
===
--- /dev/null
+++ test/Driver/cuda-unsupported-debug-options.cu
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-info-for-profiling 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -glldb 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gcodeview 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gmodules 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gembed-source -gdwarf-5 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-macro 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -ggnu-pubnames 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gdwarf-aranges 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-types-section 2>&1 | FileCheck %s
+// CHECK: debug option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ edited subscribers, added: NoQ; removed: dergachev.a.
NoQ added inline comments.



Comment at: test/Analysis/nullability_nullonly.mm:103
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}} 
expected-warning{{implicitly casting a null constant to non-nullable pointer 
type 'TestObject * _Nonnull __strong'}}
 }

jordan_rose wrote:
> @dergachev.a, what do you think here? Is it okay that the analyzer diagnoses 
> this in addition to the new warning?
We're usually trying to avoid this when we notice it, but there are many cases 
where we didn't notice it because both warnings and the analyzer are becoming 
better independently. I guess you could just give us a heads up with a bug 
report if you don't want to bother with this.

In this case i think it should be easy to fix though, because the analyzer 
already has `static isARCNilInitializedLocal()` that suppresses implicit null 
initializers, we could teach it to suppress all null initializers instead.


Repository:
  rC Clang

https://reviews.llvm.org/D22391



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


[PATCH] D49057: [analyzer] Track multiple raw pointer symbols in DanglingInternalBufferChecker

2018-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Looks great, thanks!


https://reviews.llvm.org/D49057



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


[PATCH] D48753: [libcxx] Use custom allocator's `construct` in C++03 when available.

2018-07-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Why are we doing this?

I can't find the language in the C++03 specification that requires us to call 
an allocators `construct` method if it's present.


https://reviews.llvm.org/D48753



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


[PATCH] D49118: [libc++] P0898R3 1 of 12: changes to common_type; implement common_reference

2018-07-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D49118#1157438, @mclow.lists wrote:

> >   I've conservatively hidden everything behind _LIBCPP_STD_VER > 17, 
> > although it could be made available in C++11 mode with some edits.
>
> If we have a use for this in pre c++2a code, the libc++ convention would be 
> to implement `__common_reference` that works most everywhere, and then have 
> `common_reference` that only works > 17, but inherits from the ugly name.
>
> That might be difficult in this case, because users can extend 
> `common_reference`.


I was thinking more about implementing the new bullet for `common_type` 
unconditionally. Despite that it wouldn't quite conform in older modes, it 
would avoid introducing an obscure difference between 20-mode `common_type` and 
11-mode `common_type`. That said, I wouldn't do so in MSFTL so I assumed you 
wouldn't in libc++.


https://reviews.llvm.org/D49118



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


[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC336710: Fix a typo/regression in r335495. (authored by jhb, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49143?vs=154840&id=154845#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49143

Files:
  lib/Driver/ToolChains/FreeBSD.cpp
  test/Driver/fsanitize.c


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -316,6 +316,12 @@
 // RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS
 // CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 
'mips-unknown-linux'
 
+// RUN: %clang -target mips-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS-FREEBSD
+// CHECK-SANL-MIPS-FREEBSD: unsupported option '-fsanitize=leak' for target 
'mips-unknown-freebsd'
+
+// RUN: %clang -target mips64-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS64-FREEBSD
+// CHECK-SANL-MIPS64-FREEBSD: "-fsanitize=leak"
+
 // RUN: %clang -target powerpc64-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // RUN: %clang -target powerpc64le-unknown-linux -fsanitize=leak %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // CHECK-SANL-PPC64: "-fsanitize=leak"


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -316,6 +316,12 @@
 // RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS
 // CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux'
 
+// RUN: %clang -target mips-unknown-freebsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS-FREEBSD
+// CHECK-SANL-MIPS-FREEBSD: unsupported option '-fsanitize=leak' for target 'mips-unknown-freebsd'
+
+// RUN: %clang -target mips64-unknown-freebsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS64-FREEBSD
+// CHECK-SANL-MIPS64-FREEBSD: "-fsanitize=leak"
+
 // RUN: %clang -target powerpc64-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // RUN: %clang -target powerpc64le-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // CHECK-SANL-PPC64: "-fsanitize=leak"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r336710 - Fix a typo/regression in r335495.

2018-07-10 Thread John Baldwin via cfe-commits
Author: jhb
Date: Tue Jul 10 10:44:08 2018
New Revision: 336710

URL: http://llvm.org/viewvc/llvm-project?rev=336710&view=rev
Log:
Fix a typo/regression in r335495.

Use getTriple.isMIPS64() to detect 64-bit MIPS ABIs in
FreeBSD::getSupportedSanitizers() instead of getTriple.isMIPS32().

Reviewed By: atanasyan

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

Modified:
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=336710&r1=336709&r2=336710&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Tue Jul 10 10:44:08 2018
@@ -408,7 +408,7 @@ bool FreeBSD::isPIEDefault() const { ret
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=336710&r1=336709&r2=336710&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue Jul 10 10:44:08 2018
@@ -316,6 +316,12 @@
 // RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS
 // CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 
'mips-unknown-linux'
 
+// RUN: %clang -target mips-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS-FREEBSD
+// CHECK-SANL-MIPS-FREEBSD: unsupported option '-fsanitize=leak' for target 
'mips-unknown-freebsd'
+
+// RUN: %clang -target mips64-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS64-FREEBSD
+// CHECK-SANL-MIPS64-FREEBSD: "-fsanitize=leak"
+
 // RUN: %clang -target powerpc64-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // RUN: %clang -target powerpc64le-unknown-linux -fsanitize=leak %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // CHECK-SANL-PPC64: "-fsanitize=leak"


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


[libcxx] r336709 - [libc++] Declare noop_coroutine() with _LIBCPP_INLINE_VISIBILITY

2018-07-10 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Jul 10 10:38:30 2018
New Revision: 336709

URL: http://llvm.org/viewvc/llvm-project?rev=336709&view=rev
Log:
[libc++] Declare noop_coroutine() with _LIBCPP_INLINE_VISIBILITY

Summary:
It was defined with the right visibility, but declared without any visibility.
This function was left out of a prior revision that did the same to several
functions in  (r336665) because the compiler I used didn't support
coroutines. This reinforces the need for automated checks -- there might
still be several cases of this throughout the library.

Reviewers: EricWF

Subscribers: modocache, christof, dexonsmith, llvm-commits

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

Modified:
libcxx/trunk/include/experimental/coroutine

Modified: libcxx/trunk/include/experimental/coroutine
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=336709&r1=336708&r2=336709&view=diff
==
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Tue Jul 10 10:38:30 2018
@@ -283,6 +283,7 @@ public:
   _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
 
 private:
+  _LIBCPP_INLINE_VISIBILITY
   friend coroutine_handle noop_coroutine() _NOEXCEPT;
 
   _LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT {


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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray marked an inline comment as done.
lichray added inline comments.



Comment at: include/charconv:89
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LIBCPP_ENUM_VIS chars_format

lichray wrote:
> mclow.lists wrote:
> > Quuxplusone wrote:
> > > lichray wrote:
> > > > mclow.lists wrote:
> > > > > lichray wrote:
> > > > > > EricWF wrote:
> > > > > > > We need to hide these names when `_LIBCPP_STD_VER < 17`, since 
> > > > > > > we're not allowed to introduce new names into namespace `std` in 
> > > > > > > older dialects.
> > > > > > But this header is backported to C++11, so I intended to not to 
> > > > > > guard it.
> > > > > > But this header is backported to C++11, so I intended to not to 
> > > > > > guard it.
> > > > > 
> > > > > In general, we don't provide new features for old language versions.
> > > > > 
> > > > > The only time we've ever done that is for `string_view`, and I'm 
> > > > > **still** not sure I did the right thing there.
> > > > We need to decide on this... From my point of view this header will be 
> > > > widely used by formatting and logging libraries, and it doesn't add 
> > > > much to the community by enforcing C++17 here, especially when the 
> > > > interface we specified are very simple and not using any features 
> > > > beyond C++11.
> > > This question is also relevant to my interests, in re ``.
> > > From my point of view this header will be widely used by formatting and 
> > > logging libraries,
> > 
> > Non-portable formatting and logging libraries - if we provide it before 
> > C++17 and they use it.
> > 
> When they use it, what's next?
> 
> 1. Someone try to use the library against libstdc++, he/she
>- file a bug report to the library, or
>- file a bug report to libstdc++
> 2. The library has too little users, so it's okay for it to be non-portable.
> 
> Looks good to me.
Back-ported to C++14, in-line with libstdc++.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 154842.
lichray added a comment.

Dropping C++11 support.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458

Files:
  include/CMakeLists.txt
  include/charconv
  include/module.modulemap
  src/charconv.cpp
  test/libcxx/double_include.sh.cpp
  test/std/utilities/charconv/
  test/std/utilities/charconv/charconv.from.chars/
  test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/std/utilities/charconv/charconv.to.chars/
  test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h

Index: test/support/charconv_test_helpers.h
===
--- /dev/null
+++ test/support/charconv_test_helpers.h
@@ -0,0 +1,232 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_CHARCONV_TEST_HELPERS_H
+#define SUPPORT_CHARCONV_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+#if TEST_STD_VER <= 11
+#error This file requires C++14
+#endif
+
+using std::false_type;
+using std::true_type;
+
+template 
+constexpr auto
+is_non_narrowing(From a) -> decltype(To{a}, true_type())
+{
+return {};
+}
+
+template 
+constexpr auto
+is_non_narrowing(...) -> false_type
+{
+return {};
+}
+
+template 
+constexpr bool
+_fits_in(T, true_type /* non-narrowing*/, ...)
+{
+return true;
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed*/, true_type /* X signed */)
+{
+return xl::lowest() <= v && v <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed */, false_type /* X unsigned*/)
+{
+return 0 <= v && std::make_unsigned_t(v) <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, false_type /* T unsigned */, ...)
+{
+return v <= std::make_unsigned_t((xl::max)());
+}
+
+template 
+constexpr bool
+fits_in(T v)
+{
+return _fits_in(v, is_non_narrowing(v), std::is_signed(),
+   std::is_signed());
+}
+
+template 
+struct to_chars_test_base
+{
+template 
+void test(T v, char const (&expect)[N], Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+constexpr size_t len = N - 1;
+static_assert(len > 0, "expected output won't be empty");
+
+if (!fits_in(v))
+return;
+
+r = to_chars(buf, buf + len - 1, X(v), args...);
+assert(r.ptr == buf + len - 1);
+assert(r.ec == std::errc::value_too_large);
+
+r = to_chars(buf, buf + sizeof(buf), X(v), args...);
+assert(r.ptr == buf + len);
+assert(r.ec == std::errc{});
+assert(memcmp(buf, expect, len) == 0);
+}
+
+template 
+void test_value(X v, Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+*r.ptr = '\0';
+
+auto a = fromchars(buf, r.ptr, args...);
+assert(v == a);
+
+auto ep = r.ptr - 1;
+r = to_chars(buf, ep, v, args...);
+assert(r.ptr == ep);
+assert(r.ec == std::errc::value_too_large);
+}
+
+private:
+static auto fromchars(char const* p, char const* ep, int base, true_type)
+{
+char* last;
+auto r = strtoll(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base, false_type)
+{
+char* last;
+auto r = strtoull(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base = 10)
+{
+return fromchars(p, ep, base, std::is_signed());
+}
+
+char buf[100];
+};
+
+template 
+struct roundtrip_test_base
+{
+template 
+void test(T v, Ts... args)
+{
+using std::from_chars;
+using std::to_chars;
+std::from_chars_result r2;
+std::to_chars_result r;
+X x = 0xc;
+
+if (fits_in(v))
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+assert(r2.ptr == r.ptr);
+assert(x == X(v));
+}
+else
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, 

[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D49143



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


[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 154840.
bsdjhb added a comment.

Add tests.


Repository:
  rC Clang

https://reviews.llvm.org/D49143

Files:
  lib/Driver/ToolChains/FreeBSD.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -316,6 +316,12 @@
 // RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS
 // CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 
'mips-unknown-linux'
 
+// RUN: %clang -target mips-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS-FREEBSD
+// CHECK-SANL-MIPS-FREEBSD: unsupported option '-fsanitize=leak' for target 
'mips-unknown-freebsd'
+
+// RUN: %clang -target mips64-unknown-freebsd -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-MIPS64-FREEBSD
+// CHECK-SANL-MIPS64-FREEBSD: "-fsanitize=leak"
+
 // RUN: %clang -target powerpc64-unknown-linux -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // RUN: %clang -target powerpc64le-unknown-linux -fsanitize=leak %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // CHECK-SANL-PPC64: "-fsanitize=leak"
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -316,6 +316,12 @@
 // RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS
 // CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux'
 
+// RUN: %clang -target mips-unknown-freebsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS-FREEBSD
+// CHECK-SANL-MIPS-FREEBSD: unsupported option '-fsanitize=leak' for target 'mips-unknown-freebsd'
+
+// RUN: %clang -target mips64-unknown-freebsd -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS64-FREEBSD
+// CHECK-SANL-MIPS64-FREEBSD: "-fsanitize=leak"
+
 // RUN: %clang -target powerpc64-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // RUN: %clang -target powerpc64le-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC64
 // CHECK-SANL-PPC64: "-fsanitize=leak"
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48903: [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name

2018-07-10 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 154835.
simark added a comment.

Bump SmallString size from 32 to 256


Repository:
  rC Clang

https://reviews.llvm.org/D48903

Files:
  lib/Basic/FileManager.cpp
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp
  unittests/Driver/ToolChainTest.cpp

Index: unittests/Driver/ToolChainTest.cpp
===
--- unittests/Driver/ToolChainTest.cpp
+++ unittests/Driver/ToolChainTest.cpp
@@ -113,7 +113,7 @@
   std::replace(S.begin(), S.end(), '\\', '/');
 #endif
   EXPECT_EQ("Found candidate GCC installation: "
-"/home/test/lib/gcc/arm-linux-gnueabi/4.6.1\n"
+"/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n"
 "Selected GCC installation: "
 "/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n"
 "Candidate multilib: .;@m32\n"
Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -794,7 +794,7 @@
 
   auto Stat = FS.status("/b/c");
   ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
-  ASSERT_EQ("c", Stat->getName());
+  ASSERT_EQ("/b/c", Stat->getName());
   ASSERT_EQ("/b", *FS.getCurrentWorkingDirectory());
 
   Stat = FS.status("c");
@@ -919,6 +919,37 @@
   ASSERT_TRUE(Stat->isRegularFile());
 }
 
+// Test that the name returned by status() is in the same form as the path that
+// was requested (to match the behavior of RealFileSystem).
+TEST_F(InMemoryFileSystemTest, StatusName) {
+  NormalizedFS.addFile("/a/b/c", 0, MemoryBuffer::getMemBuffer("abc"),
+   /*User=*/None,
+   /*Group=*/None, sys::fs::file_type::regular_file);
+  NormalizedFS.setCurrentWorkingDirectory("/a/b");
+
+  // Access using InMemoryFileSystem::status.
+  auto Stat = NormalizedFS.status("../b/c");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n"
+<< NormalizedFS.toString();
+  ASSERT_TRUE(Stat->isRegularFile());
+  ASSERT_EQ("../b/c", Stat->getName());
+
+  // Access using InMemoryFileAdaptor::status.
+  auto File = NormalizedFS.openFileForRead("../b/c");
+  ASSERT_FALSE(File.getError()) << File.getError() << "\n"
+<< NormalizedFS.toString();
+  Stat = (*File)->status();
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n"
+<< NormalizedFS.toString();
+  ASSERT_TRUE(Stat->isRegularFile());
+  ASSERT_EQ("../b/c", Stat->getName());
+
+  // Access using a directory iterator.
+  std::error_code EC;
+  clang::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC);
+  ASSERT_EQ("../b/c", It->getName());
+}
+
 // NOTE: in the tests below, we use '//root/' as our root directory, since it is
 // a legal *absolute* path on Windows as well as *nix.
 class VFSFromYAMLTest : public ::testing::Test {
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -471,15 +471,33 @@
 /// The in memory file system is a tree of Nodes. Every node can either be a
 /// file or a directory.
 class InMemoryNode {
-  Status Stat;
   InMemoryNodeKind Kind;
+  Status Stat;
+
+protected:
+  /// Return Stat.  This should only be used for internal/debugging use.  When
+  /// clients wants the Status of this node, they should use
+  /// \p getStatus(StringRef).
+  const Status& getStatus() const {
+return Stat;
+  }
 
 public:
   InMemoryNode(Status Stat, InMemoryNodeKind Kind)
-  : Stat(std::move(Stat)), Kind(Kind) {}
+  : Kind(Kind), Stat(std::move(Stat)) {}
   virtual ~InMemoryNode() = default;
 
-  const Status &getStatus() const { return Stat; }
+  /// Return the \p Status for this node. \p RequestedName should be the name
+  /// through which the caller referred to this node. It will override
+  /// \p Status::Name in the return value, to mimic the behavior of \p RealFile.
+  Status getStatus(StringRef RequestedName) const {
+return Status::copyWithNewName(Stat, RequestedName);
+  }
+
+  /// Get the filename of this node (the name without the directory part).
+  StringRef getFileName() const {
+return llvm::sys::path::filename(Stat.getName());
+  }
   InMemoryNodeKind getKind() const { return Kind; }
   virtual std::string toString(unsigned Indent) const = 0;
 };
@@ -504,14 +522,22 @@
   }
 };
 
-/// Adapt a InMemoryFile for VFS' File interface.
+/// Adapt a InMemoryFile for VFS' File interface.  The goal is to make
+/// \p InMemoryFileAdaptor mimic as much as possible the behavior of
+/// \p RealFile.
 class InMemoryFileAdaptor : public File {
   InMemoryFile &Node;
 
+  /// The name to use when returning a Status for this file.
+  std::string RequestedName;
+
 public:
-  explicit InMemoryFileAdaptor(InMem

[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I'm working on this! I'll be taking what is hopefully a final pass at the tests 
today.


https://reviews.llvm.org/D46845



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


[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a subscriber: dergachev.a.
jordan_rose added a comment.

Sorry for the delay. I think this is mostly good, but I do still have a concern 
about the diagnostics change.




Comment at: lib/Sema/SemaExpr.cpp:7117
+if (E && S.checkNonNullExpr(E))
+  return NullabilityKind::Nullable;
+

ahatanak wrote:
> jordan_rose wrote:
> > This isn't quite correct, unfortunately. `(_Nonnull id)nil` should be 
> > considered non-nullable, since it's the canonical way to avoid all these 
> > warnings. It might just be good enough to move this check below the 
> > `getNullability` one, though.
> Sema::CheckNonNullExpr checks the nullability of the type of the expression 
> first and returns false if there is a cast to `_Nonnull`.
Hm, okay, I see you have a test. Sorry for the noise.



Comment at: lib/Sema/SemaExpr.cpp:7162
+  bool IsBin, Expr *LHSExpr,
+  Expr *RHSExpr, ASTContext &Ctx) {
   if (!ResTy->isAnyPointerType())

Nitpick: you could use `const` on the Exprs here.



Comment at: lib/Sema/SemaExpr.cpp:11103
 
+  if (const auto *DeclRef = dyn_cast(LHSExpr))
+checkNullConstantToNonNull(DeclRef->getType(), RHS.get());

This could come later, but what about struct members or ObjC properties or ObjC 
subscripts? Seems like you could just check the type of the LHS.



Comment at: test/Analysis/nullability_nullonly.mm:103
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have non-null value}} 
expected-warning{{implicitly casting a null constant to non-nullable pointer 
type 'TestObject * _Nonnull __strong'}}
 }

@dergachev.a, what do you think here? Is it okay that the analyzer diagnoses 
this in addition to the new warning?



Comment at: test/Sema/conditional-expr.c:20
   vp = 0 ? (double *)0 : (void *)0;
-  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer 
types assigning to 'int *' from 'double *'}}
+  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer 
types assigning to 'int *' from 'double * _Nullable'}}
 

This seems like an unfortunate change to make, since most people do not bother 
with nullability.


Repository:
  rC Clang

https://reviews.llvm.org/D22391



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


[PATCH] D48903: [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name

2018-07-10 Thread Simon Marchi via Phabricator via cfe-commits
simark marked an inline comment as done.
simark added a comment.

In https://reviews.llvm.org/D48903#1157330, @ilya-biryukov wrote:

> LGTM if that does not introduce any regressions in clang and clang-tools.


Thanks.  I have seen no failures in `check-clang` and `check-clang-tools`, so I 
will push it.


Repository:
  rC Clang

https://reviews.llvm.org/D48903



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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: ldionne.
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D46845



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


[PATCH] D49112: [Sema] Implement -Wmemset-transposed-args

2018-07-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:662
+def note_suspicious_sizeof_memset_silence : Note<
+  "%select{parenthesize the third argument|cast the second argument to 'int'}0 
to silence">;
+

Quuxplusone wrote:
> If it were my codebase, I'd rather see a cast to `(unsigned char)` than a 
> cast to `(int)`. (The second argument to memset is supposed to be a single 
> byte.) Why did you pick `(int)` specifically?
I chose `int` because that's the actual type of the second parameter to 
`memset`, it just gets casted down to `unsigned char` internally. FWIW, either 
type will suppress the warning. I'm fine with recommending `unsigned char` if 
you have a strong preference for it.



Comment at: clang/lib/Sema/SemaChecking.cpp:7962
+  if (auto *BO = dyn_cast(SizeofExpr)) {
+if (BO->getOpcode() != BO_Mul)
+  return false;

Quuxplusone wrote:
> Honestly, if the second argument to `memset` involves `sizeof` *at all*, it's 
> probably a bug, isn't it?
> 
> memset(&buf, sizeof foo + 10, 0xff);
> memset(&buf, sizeof foo * sizeof bar, 0xff);
> 
> Should Clang really go out of its way to silence the warning in these cases?
Sure, that seems reasonable. The new patch makes this check less conservative.


https://reviews.llvm.org/D49112



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


[PATCH] D49112: [Sema] Implement -Wmemset-transposed-args

2018-07-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 154833.
erik.pilkington added a comment.

Address @Quuxplusone comments.


https://reviews.llvm.org/D49112

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/transpose-memset.c

Index: clang/test/Sema/transpose-memset.c
===
--- /dev/null
+++ clang/test/Sema/transpose-memset.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1   -Wmemset-transposed-args -verify %s
+// RUN: %clang_cc1 -xc++ -Wmemset-transposed-args -verify %s
+
+#define memset(...) __builtin_memset(__VA_ARGS__)
+
+int array[10];
+int *ptr;
+
+int main() {
+  memset(array, sizeof(array), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
+  memset(array, sizeof(array), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+  memset(ptr, sizeof(ptr), 0); // expected-warning{{'size' argument to memset is '0'; did you mean to transpose the last two arguments?}} expected-note{{parenthesize the third argument to silence}}
+  memset(ptr, sizeof(*ptr) * 10, 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+  memset(ptr, 10 * sizeof(int *), 1); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+  memset(ptr, 10 * sizeof(int *) + 10, 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+  memset(ptr, sizeof(char) * sizeof(int *), 0xff); // expected-warning{{setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments?}} expected-note{{cast the second argument to 'int' to silence}}
+  memset(array, sizeof(array), sizeof(array)); // Uh... fine I guess.
+  memset(array, 0, sizeof(array));
+  memset(ptr, 0, sizeof(int *) * 10);
+  memset(array, (int)sizeof(array), (0)); // no warning
+  memset(array, (int)sizeof(array), 32); // no warning
+  memset(array, 32, (0)); // no warning
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7839,24 +7839,26 @@
   return nullptr;
 }
 
+static const UnaryExprOrTypeTraitExpr *getAsSizeOfExpr(const Expr *E) {
+  if (const auto *Unary = dyn_cast(E))
+if (Unary->getKind() == UETT_SizeOf)
+  return Unary;
+  return nullptr;
+}
+
 /// If E is a sizeof expression, returns its argument expression,
 /// otherwise returns NULL.
 static const Expr *getSizeOfExprArg(const Expr *E) {
-  if (const UnaryExprOrTypeTraitExpr *SizeOf =
-  dyn_cast(E))
-if (SizeOf->getKind() == UETT_SizeOf && !SizeOf->isArgumentType())
+  if (const UnaryExprOrTypeTraitExpr *SizeOf = getAsSizeOfExpr(E))
+if (!SizeOf->isArgumentType())
   return SizeOf->getArgumentExpr()->IgnoreParenImpCasts();
-
   return nullptr;
 }
 
 /// If E is a sizeof expression, returns its argument type.
 static QualType getSizeOfArgType(const Expr *E) {
-  if (const UnaryExprOrTypeTraitExpr *SizeOf =
-  dyn_cast(E))
-if (SizeOf->getKind() == UETT_SizeOf)
-  return SizeOf->getTypeOfArgument();
-
+  if (const UnaryExprOrTypeTraitExpr *SizeOf = getAsSizeOfExpr(E))
+return SizeOf->getTypeOfArgument();
   return QualType();
 }
 
@@ -7952,6 +7954,56 @@
 
 }
 
+/// Detect if \c SizeofExpr is likely to calculate the sizeof an object.
+static bool doesExprLikelyComputeSize(const Expr *SizeofExpr) {
+  SizeofExpr = SizeofExpr->IgnoreParenImpCasts();
+
+  if (auto *BO = dyn_cast(SizeofExpr)) {
+if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
+  return false;
+
+return doesExprLikelyComputeSize(BO->getLHS()) ||
+   doesExprLikelyComputeSize(BO->getRHS());
+  }
+
+  return getAsSizeOfExpr(SizeofExpr) != nullptr;
+}
+
+/// Diagnose cases like 'memset(buf, sizeof(buf), 0)', which should have the
+/// last two arguments transposed.
+static void CheckMemsetSizeof(Sema &S, unsigned BId, const CallExpr *Call) {
+  if (BId != Builtin::BImemset)
+return;
+
+  int WarningKind;
+  SourceLocation DiagLoc;
+
+  // If we're memsetting 0 bytes, then this is likely a programmer error.
+  const Expr *ThirdArg = Call->getArg(2)->IgnoreImpCasts();
+  if (isa(ThirdArg) &&
+  cast(ThirdArg)->getValue() == 0) {
+WarningKind = 0;
+DiagLoc = ThirdArg->getExprLoc();
+  }
+  // If the second argument is a sizeof expression and the third isn't

[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D49083#1157568, @tra wrote:

> > HIP generates one fat binary for all devices after linking. However, for 
> > each compilation
> >  unit a ctor function is emitted which register the same fat binary. 
> >  Measures need to be taken to make sure the fat binary is only registered 
> > once.
>
> Are you saying that for HIP there's only one fatbin file with GPU code for 
> the complete host executable, even if it consists of multiple HIP TUs?


By 'TU' do you mean 'target unit'?

For HIP there is only one fatbin file with GPU code for the complete host 
executable even if there are mulitple GPU sub-targets. Device code for 
different sub-targets are bundled together by clang-offload-bundler as one 
fatbin. Runtime will extract device code for different sub-targets.


https://reviews.llvm.org/D49083



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


[PATCH] D48982: [mips] Add '-mvirt', '-mno-virt', '-mginv', '-mno-ginv' options

2018-07-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D48982



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


[PATCH] D48721: Patch to fix pragma metadata for do-while loops

2018-07-10 Thread Deepak Panickal via Phabricator via cfe-commits
deepak2427 marked an inline comment as done.
deepak2427 added a comment.

@Bjorn, Thanks for reviewing and accepting the patch.

Could you please advise on the next steps?
Would someone else commit this on my behalf or should I request for commit 
access?

Thanks,
Deepak Panickal


https://reviews.llvm.org/D48721



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


[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> HIP generates one fat binary for all devices after linking. However, for each 
> compilation
>  unit a ctor function is emitted which register the same fat binary. 
>  Measures need to be taken to make sure the fat binary is only registered 
> once.

Are you saying that for HIP there's only one fatbin file with GPU code for the 
complete host executable, even if it consists of multiple HIP TUs?




Comment at: lib/CodeGen/CGCUDANV.cpp:449
+CtorBuilder.SetInsertPoint(IfBlock);
+// GpuBinaryHandle = __{cuda|hip}RegisterFatBinary(&FatbinWrapper);
+llvm::CallInst *RegisterFatbinCall = CtorBuilder.CreateCall(

Given that it's HIP-only code, there will be no `cuda`.


https://reviews.llvm.org/D49083



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


[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

AFAICT, I don't see a way to ask clang "which sanitizers are supported by this 
target".  Hmm, the CHECK-SANL-MIPS test in tests/Driver/fsanitize.c seems like 
the closest match.


Repository:
  rC Clang

https://reviews.llvm.org/D49143



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


[PATCH] D48862: Fix lib paths for OpenEmbedded targets

2018-07-10 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Ping for reviews, please.


https://reviews.llvm.org/D48862



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


[PATCH] D48721: Patch to fix pragma metadata for do-while loops

2018-07-10 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope accepted this revision.
bjope added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D48721



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


[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

It would be nice to have a test for this regression.


Repository:
  rC Clang

https://reviews.llvm.org/D49143



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


[PATCH] D49143: Fix a typo/regression in r335495.

2018-07-10 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb created this revision.
bsdjhb added a reviewer: arichardson.
Herald added subscribers: atanasyan, krytarowski, sdardis, emaste.

Use getTriple.isMIPS64() to detect 64-bit MIPS ABIs in
FreeBSD::getSupportedSanitizers() instead of getTriple.isMIPS32().


Repository:
  rC Clang

https://reviews.llvm.org/D49143

Files:
  lib/Driver/ToolChains/FreeBSD.cpp


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;


Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -408,7 +408,7 @@
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
-  const bool IsMIPS64 = getTriple().isMIPS32();
+  const bool IsMIPS64 = getTriple().isMIPS64();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Vptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49142: [clangd] Extract FileSystemProvider into a separate header. NFC

2018-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: jkorous, MaskRay, ioeric, mgorny.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49142

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FSProvider.cpp
  clangd/FSProvider.h

Index: clangd/FSProvider.h
===
--- /dev/null
+++ clangd/FSProvider.h
@@ -0,0 +1,38 @@
+//===--- FSProvider.h - VFS provider for ClangdServer *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
+
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+
+namespace clang {
+namespace clangd {
+
+class FileSystemProvider {
+public:
+  virtual ~FileSystemProvider() = default;
+  /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
+  /// Context::current() will be the context passed to the clang entrypoint,
+  /// such as addDocument(), and will also be propagated to result callbacks.
+  /// Embedders may use this to isolate filesystem accesses.
+  virtual IntrusiveRefCntPtr getFileSystem() = 0;
+};
+
+class RealFileSystemProvider : public FileSystemProvider {
+public:
+  /// Returns getRealFileSystem().
+  IntrusiveRefCntPtr getFileSystem() override;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clangd/FSProvider.cpp
===
--- /dev/null
+++ clangd/FSProvider.cpp
@@ -0,0 +1,19 @@
+//===--- FSProvider.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---===//
+
+#include "FSProvider.h"
+
+namespace clang {
+namespace clangd {
+
+IntrusiveRefCntPtr RealFileSystemProvider::getFileSystem() {
+  return vfs::getRealFileSystem();
+}
+} // namespace clangd
+} // namespace clang
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -12,6 +12,7 @@
 
 #include "ClangdUnit.h"
 #include "CodeComplete.h"
+#include "FSProvider.h"
 #include "Function.h"
 #include "GlobalCompilationDatabase.h"
 #include "Protocol.h"
@@ -42,22 +43,6 @@
   std::vector Diagnostics) = 0;
 };
 
-class FileSystemProvider {
-public:
-  virtual ~FileSystemProvider() = default;
-  /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
-  /// Context::current() will be the context passed to the clang entrypoint,
-  /// such as addDocument(), and will also be propagated to result callbacks.
-  /// Embedders may use this to isolate filesystem accesses.
-  virtual IntrusiveRefCntPtr getFileSystem() = 0;
-};
-
-class RealFileSystemProvider : public FileSystemProvider {
-public:
-  /// Returns getRealFileSystem().
-  IntrusiveRefCntPtr getFileSystem() override;
-};
-
 /// Provides API to manage ASTs for a collection of C++ files and request
 /// various language features.
 /// Currently supports async diagnostics, code completion, formatting and goto
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -68,10 +68,6 @@
 
 } // namespace
 
-IntrusiveRefCntPtr RealFileSystemProvider::getFileSystem() {
-  return vfs::getRealFileSystem();
-}
-
 ClangdServer::Options ClangdServer::optsForTest() {
   ClangdServer::Options Opts;
   Opts.UpdateDebounce = std::chrono::steady_clock::duration::zero(); // Faster!
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -18,8 +18,9 @@
   Context.cpp
   Diagnostics.cpp
   DraftStore.cpp
-  FindSymbols.cpp
   FileDistance.cpp
+  FindSymbols.cpp
+  FSProvider.cpp
   FuzzyMatch.cpp
   GlobalCompilationDatabase.cpp
   Headers.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray marked an inline comment as done.
lichray added inline comments.



Comment at: include/charconv:234
+to_chars(char* __first, char* __last, _Tp __value, int __base)
+-> to_chars_result
+{

mclow.lists wrote:
> lichray wrote:
> > mclow.lists wrote:
> > > Why use the trailing return type here?
> > > I don't see any advantage - it doesn't depend on the parameters (template 
> > > or runtime).
> > > 
> > > 
> > Because clang-format doesn't distinguish storage specifiers and 
> > simple-type-specifiers, and I want to format return types along with 
> > function signatures rather than letting hanging somewhere.
> That's an argument for fixing clang-format, not for writing the code this way.
> 
Yes... I did some research on ClangFormat, until... Anyway, I moved most of the 
trailing return types to the front, leaving two which are too complex in the 
header, and a few necessary ones in the tests.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D49118: [libc++] P0898R3 1 of 12: changes to common_type; implement common_reference

2018-07-10 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

>   I've conservatively hidden everything behind _LIBCPP_STD_VER > 17, although 
> it could be made available in C++11 mode with some edits.

If we have a use for this in pre c++2a code, the libc++ convention would be to 
implement `__common_reference` that works most everywhere, and then have 
`common_reference` that only works > 17, but inherits from the ugly name.

That might be difficult in this case, because users can extend 
`common_reference`.


https://reviews.llvm.org/D49118



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 154816.
lichray added a comment.

Less trailing return types


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458

Files:
  include/CMakeLists.txt
  include/charconv
  include/module.modulemap
  src/charconv.cpp
  test/libcxx/double_include.sh.cpp
  test/std/utilities/charconv/
  test/std/utilities/charconv/charconv.from.chars/
  test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/std/utilities/charconv/charconv.to.chars/
  test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h

Index: test/support/charconv_test_helpers.h
===
--- /dev/null
+++ test/support/charconv_test_helpers.h
@@ -0,0 +1,233 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_CHARCONV_TEST_HELPERS_H
+#define SUPPORT_CHARCONV_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+using std::false_type;
+using std::true_type;
+
+template 
+constexpr auto
+is_non_narrowing(From a) -> decltype(To{a}, true_type())
+{
+return {};
+}
+
+template 
+constexpr auto
+is_non_narrowing(...) -> false_type
+{
+return {};
+}
+
+template 
+constexpr bool
+_fits_in(T, true_type /* non-narrowing*/, ...)
+{
+return true;
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed*/, true_type /* X signed */)
+{
+return xl::lowest() <= v && v <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed */, false_type /* X unsigned*/)
+{
+return 0 <= v && typename std::make_unsigned::type(v) <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, false_type /* T unsigned */, ...)
+{
+return v <= typename std::make_unsigned::type((xl::max)());
+}
+
+template 
+constexpr bool
+fits_in(T v)
+{
+return _fits_in(v, is_non_narrowing(v), std::is_signed(),
+   std::is_signed());
+}
+
+template 
+struct to_chars_test_base
+{
+template 
+void test(T v, char const (&expect)[N], Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+constexpr size_t len = N - 1;
+static_assert(len > 0, "expected output won't be empty");
+
+if (!fits_in(v))
+return;
+
+r = to_chars(buf, buf + len - 1, X(v), args...);
+assert(r.ptr == buf + len - 1);
+assert(r.ec == std::errc::value_too_large);
+
+r = to_chars(buf, buf + sizeof(buf), X(v), args...);
+assert(r.ptr == buf + len);
+assert(r.ec == std::errc{});
+assert(memcmp(buf, expect, len) == 0);
+}
+
+template 
+void test_value(X v, Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+*r.ptr = '\0';
+
+auto a = fromchars(buf, r.ptr, args...);
+assert(v == a);
+
+auto ep = r.ptr - 1;
+r = to_chars(buf, ep, v, args...);
+assert(r.ptr == ep);
+assert(r.ec == std::errc::value_too_large);
+}
+
+private:
+using max_t = typename std::conditional::value, long long,
+unsigned long long>::type;
+
+static auto fromchars(char const* p, char const* ep, int base, true_type)
+-> long long
+{
+char* last;
+auto r = strtoll(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base, false_type)
+-> unsigned long long
+{
+char* last;
+auto r = strtoull(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base = 10) -> max_t
+{
+return fromchars(p, ep, base, std::is_signed());
+}
+
+char buf[100];
+};
+
+template 
+struct roundtrip_test_base
+{
+template 
+void test(T v, Ts... args)
+{
+using std::from_chars;
+using std::to_chars;
+std::from_chars_result r2;
+std::to_chars_result r;
+X x = 0xc;
+
+if (fits_in(v))
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+assert(r2.ptr == r.ptr);
+assert(x == X(v));
+}
+   

[PATCH] D48989: -fdebug-prefix-map option for cc1as

2018-07-10 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC336685: Support -fdebug-prefix-map for assembler source 
(pass to cc1as).  This (authored by probinson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48989?vs=154669&id=154811#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48989

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/debug-prefix-map.S
  tools/driver/cc1as_main.cpp

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1741,7 +1741,8 @@
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group,
   Flags<[CC1Option]>;
 def fdebug_prefix_map_EQ
-  : Joined<["-"], "fdebug-prefix-map=">, Group, Flags<[CC1Option]>,
+  : Joined<["-"], "fdebug-prefix-map=">, Group,
+Flags<[CC1Option,CC1AsOption]>,
 HelpText<"remap file source paths in debug info">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
Index: test/Driver/debug-prefix-map.S
===
--- test/Driver/debug-prefix-map.S
+++ test/Driver/debug-prefix-map.S
@@ -0,0 +1,6 @@
+// RUN: %clang -### -g -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s
+
+// CHECK: cc1as
+// CHECK-SAME: -fdebug-prefix-map=old=new
+
+// More tests for this flag in debug-prefix-map.c.
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -600,6 +600,18 @@
   }
 }
 
+/// Add a CC1 and CC1AS option to specify the debug file path prefix map.
+static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, ArgStringList &CmdArgs) {
+  for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
+StringRef Map = A->getValue();
+if (Map.find('=') == StringRef::npos)
+  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
+else
+  CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
+A->claim();
+  }
+}
+
 /// Vectorize at all optimization levels greater than 1 except for -Oz.
 /// For -Oz the loop vectorizer is disable, while the slp vectorizer is enabled.
 static bool shouldEnableVectorizerAtOLevel(const ArgList &Args, bool isSlpVec) {
@@ -3800,14 +3812,7 @@
   // Add in -fdebug-compilation-dir if necessary.
   addDebugCompDirArg(Args, CmdArgs);
 
-  for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
-StringRef Map = A->getValue();
-if (Map.find('=') == StringRef::npos)
-  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
-else
-  CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
-A->claim();
-  }
+  addDebugPrefixMapArg(D, Args, CmdArgs);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_,
options::OPT_ftemplate_depth_EQ)) {
@@ -5352,6 +5357,8 @@
 // Add the -fdebug-compilation-dir flag if needed.
 addDebugCompDirArg(Args, CmdArgs);
 
+addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs);
+
 // Set the AT_producer to the clang version when using the integrated
 // assembler on assembly source files.
 CmdArgs.push_back("-dwarf-debug-producer");
Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -94,6 +94,7 @@
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
+  std::map DebugPrefixMap;
   llvm::DebugCompressionType CompressDebugSections =
   llvm::DebugCompressionType::None;
   std::string MainFileName;
@@ -233,6 +234,9 @@
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
 
+  for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
+Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
+
   // Frontend Options
   if (Args.hasArg(OPT_INPUT)) {
 bool First = true;
@@ -377,6 +381,9 @@
 Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer));
   if (!Opts.DebugCompilationDir.empty())
 Ctx.setCompilationDir(Opts.DebugCompilationDir);
+  if (!Opts.DebugPrefixMap.empty())
+for (const auto &KV : Opts.DebugPrefixMap)
+  Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
   if (!Opts.MainFileName.empty())
 Ctx.setMainFileName(StringRef(Opts.MainFileName));
   Ctx.setDwarfVersion(Opts.DwarfVersion);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r336685 - Support -fdebug-prefix-map for assembler source (pass to cc1as). This

2018-07-10 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Jul 10 08:15:24 2018
New Revision: 336685

URL: http://llvm.org/viewvc/llvm-project?rev=336685&view=rev
Log:
Support -fdebug-prefix-map for assembler source (pass to cc1as).  This
is useful to omit the debug compilation dir when compiling assembly
files with -g.  Part of PR38050.

Patch by Siddhartha Bagaria!

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

Added:
cfe/trunk/test/Driver/debug-prefix-map.S
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=336685&r1=336684&r2=336685&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jul 10 08:15:24 2018
@@ -1741,7 +1741,8 @@ def fsplit_dwarf_inlining: Flag <["-"],
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, 
Group,
   Flags<[CC1Option]>;
 def fdebug_prefix_map_EQ
-  : Joined<["-"], "fdebug-prefix-map=">, Group, Flags<[CC1Option]>,
+  : Joined<["-"], "fdebug-prefix-map=">, Group,
+Flags<[CC1Option,CC1AsOption]>,
 HelpText<"remap file source paths in debug info">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=336685&r1=336684&r2=336685&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Jul 10 08:15:24 2018
@@ -600,6 +600,18 @@ static void addDebugCompDirArg(const Arg
   }
 }
 
+/// Add a CC1 and CC1AS option to specify the debug file path prefix map.
+static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, 
ArgStringList &CmdArgs) {
+  for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
+StringRef Map = A->getValue();
+if (Map.find('=') == StringRef::npos)
+  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
+else
+  CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
+A->claim();
+  }
+}
+
 /// Vectorize at all optimization levels greater than 1 except for -Oz.
 /// For -Oz the loop vectorizer is disable, while the slp vectorizer is 
enabled.
 static bool shouldEnableVectorizerAtOLevel(const ArgList &Args, bool isSlpVec) 
{
@@ -3800,14 +3812,7 @@ void Clang::ConstructJob(Compilation &C,
   // Add in -fdebug-compilation-dir if necessary.
   addDebugCompDirArg(Args, CmdArgs);
 
-  for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
-StringRef Map = A->getValue();
-if (Map.find('=') == StringRef::npos)
-  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
-else
-  CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
-A->claim();
-  }
+  addDebugPrefixMapArg(D, Args, CmdArgs);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_,
options::OPT_ftemplate_depth_EQ)) {
@@ -5352,6 +5357,8 @@ void ClangAs::ConstructJob(Compilation &
 // Add the -fdebug-compilation-dir flag if needed.
 addDebugCompDirArg(Args, CmdArgs);
 
+addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs);
+
 // Set the AT_producer to the clang version when using the integrated
 // assembler on assembly source files.
 CmdArgs.push_back("-dwarf-debug-producer");

Added: cfe/trunk/test/Driver/debug-prefix-map.S
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-prefix-map.S?rev=336685&view=auto
==
--- cfe/trunk/test/Driver/debug-prefix-map.S (added)
+++ cfe/trunk/test/Driver/debug-prefix-map.S Tue Jul 10 08:15:24 2018
@@ -0,0 +1,6 @@
+// RUN: %clang -### -g -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s
+
+// CHECK: cc1as
+// CHECK-SAME: -fdebug-prefix-map=old=new
+
+// More tests for this flag in debug-prefix-map.c.

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=336685&r1=336684&r2=336685&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Jul 10 08:15:24 2018
@@ -94,6 +94,7 @@ struct AssemblerInvocation {
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
+  std::map DebugPrefixMap;
   llvm::DebugCompressionType CompressDebugSections =
   llvm::DebugCompressionType::None;
   std::string MainFileName;
@@ -233,6 +234

[PATCH] D47172: [FileCheck] Add -allow-deprecated-dag-overlap to failing clang tests

2018-07-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D47172



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


r336681 - AMDGPU: Try to fix test again

2018-07-10 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Jul 10 07:47:31 2018
New Revision: 336681

URL: http://llvm.org/viewvc/llvm-project?rev=336681&view=rev
Log:
AMDGPU: Try to fix test again

Modified:
cfe/trunk/test/CodeGen/backend-unsupported-error.ll

Modified: cfe/trunk/test/CodeGen/backend-unsupported-error.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/backend-unsupported-error.ll?rev=336681&r1=336680&r2=336681&view=diff
==
--- cfe/trunk/test/CodeGen/backend-unsupported-error.ll (original)
+++ cfe/trunk/test/CodeGen/backend-unsupported-error.ll Tue Jul 10 07:47:31 2018
@@ -21,7 +21,7 @@ entry:
   ret i32 %call, !dbg !15
 }
 
-attributes #0 = { nounwind uwtable "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #0 = { nounwind noinline "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!9, !10}


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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray marked 3 inline comments as done.
lichray added inline comments.



Comment at: include/charconv:89
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LIBCPP_ENUM_VIS chars_format

mclow.lists wrote:
> Quuxplusone wrote:
> > lichray wrote:
> > > mclow.lists wrote:
> > > > lichray wrote:
> > > > > EricWF wrote:
> > > > > > We need to hide these names when `_LIBCPP_STD_VER < 17`, since 
> > > > > > we're not allowed to introduce new names into namespace `std` in 
> > > > > > older dialects.
> > > > > But this header is backported to C++11, so I intended to not to guard 
> > > > > it.
> > > > > But this header is backported to C++11, so I intended to not to guard 
> > > > > it.
> > > > 
> > > > In general, we don't provide new features for old language versions.
> > > > 
> > > > The only time we've ever done that is for `string_view`, and I'm 
> > > > **still** not sure I did the right thing there.
> > > We need to decide on this... From my point of view this header will be 
> > > widely used by formatting and logging libraries, and it doesn't add much 
> > > to the community by enforcing C++17 here, especially when the interface 
> > > we specified are very simple and not using any features beyond C++11.
> > This question is also relevant to my interests, in re ``.
> > From my point of view this header will be widely used by formatting and 
> > logging libraries,
> 
> Non-portable formatting and logging libraries - if we provide it before C++17 
> and they use it.
> 
When they use it, what's next?

1. Someone try to use the library against libstdc++, he/she
   - file a bug report to the library, or
   - file a bug report to libstdc++
2. The library has too little users, so it's okay for it to be non-portable.

Looks good to me.



Comment at: include/charconv:151
+
+#if __has_builtin(__builtin_clzll)
+if (__tx::digits <= __diff || __tx::width(__value) <= __diff)

mclow.lists wrote:
> lichray wrote:
> > EricWF wrote:
> > > `` already has a `__clz` wrapper for `__builtin_clz` et al. We 
> > > should use that instead. That also allows us to get rid of the fallback 
> > > implementation, and it correctly uses the builtin for compilers like GCC 
> > > which don't provide `__has_builtin`.
> > I saw that, and I agree this can be improved, however `` would 
> > be too heavy to include here.  Thoughts?
> We could make this depend on `` once P0553 is adopted. (use 
> `countl_zero`)
> 
>  My intention there is to provide `__countl_zero` etc for internal use before 
> C++20, and the public names for C++20 and later.  That approach could be used 
> here as well, if we choose.
> 
OK.



Comment at: 
test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp:133
+{
+// If the pattern allows for an optional sign,
+char s[] = " - 9+12";

mclow.lists wrote:
> Rather than attempting to reuse bits of the string here, I would define a 
> struct:
> 
> struct test_data {
> const char *input;
> const char *output;
> std::errc err;
> T value;
> };
> 
> and then write a bunch of test cases and iterate over them.
No longer reusing parts from the string.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 154804.
lichray marked an inline comment as done.
lichray added a comment.

Respond to the 2nd round review


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458

Files:
  include/CMakeLists.txt
  include/charconv
  include/module.modulemap
  src/charconv.cpp
  test/libcxx/double_include.sh.cpp
  test/std/utilities/charconv/
  test/std/utilities/charconv/charconv.from.chars/
  test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/std/utilities/charconv/charconv.to.chars/
  test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h

Index: test/support/charconv_test_helpers.h
===
--- /dev/null
+++ test/support/charconv_test_helpers.h
@@ -0,0 +1,233 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_CHARCONV_TEST_HELPERS_H
+#define SUPPORT_CHARCONV_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+using std::false_type;
+using std::true_type;
+
+template 
+constexpr auto
+is_non_narrowing(From a) -> decltype(To{a}, true_type())
+{
+return {};
+}
+
+template 
+constexpr auto
+is_non_narrowing(...) -> false_type
+{
+return {};
+}
+
+template 
+constexpr bool
+_fits_in(T, true_type /* non-narrowing*/, ...)
+{
+return true;
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed*/, true_type /* X signed */)
+{
+return xl::lowest() <= v && v <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed */, false_type /* X unsigned*/)
+{
+return 0 <= v && typename std::make_unsigned::type(v) <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, false_type /* T unsigned */, ...)
+{
+return v <= typename std::make_unsigned::type((xl::max)());
+}
+
+template 
+constexpr bool
+fits_in(T v)
+{
+return _fits_in(v, is_non_narrowing(v), std::is_signed(),
+   std::is_signed());
+}
+
+template 
+struct to_chars_test_base
+{
+template 
+void test(T v, char const (&expect)[N], Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+constexpr size_t len = N - 1;
+static_assert(len > 0, "expected output won't be empty");
+
+if (!fits_in(v))
+return;
+
+r = to_chars(buf, buf + len - 1, X(v), args...);
+assert(r.ptr == buf + len - 1);
+assert(r.ec == std::errc::value_too_large);
+
+r = to_chars(buf, buf + sizeof(buf), X(v), args...);
+assert(r.ptr == buf + len);
+assert(r.ec == std::errc{});
+assert(memcmp(buf, expect, len) == 0);
+}
+
+template 
+void test_value(X v, Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+*r.ptr = '\0';
+
+auto a = fromchars(buf, r.ptr, args...);
+assert(v == a);
+
+auto ep = r.ptr - 1;
+r = to_chars(buf, ep, v, args...);
+assert(r.ptr == ep);
+assert(r.ec == std::errc::value_too_large);
+}
+
+private:
+using max_t = typename std::conditional::value, long long,
+unsigned long long>::type;
+
+static auto fromchars(char const* p, char const* ep, int base, true_type)
+-> long long
+{
+char* last;
+auto r = strtoll(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base, false_type)
+-> unsigned long long
+{
+char* last;
+auto r = strtoull(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base = 10) -> max_t
+{
+return fromchars(p, ep, base, std::is_signed());
+}
+
+char buf[100];
+};
+
+template 
+struct roundtrip_test_base
+{
+template 
+void test(T v, Ts... args)
+{
+using std::from_chars;
+using std::to_chars;
+std::from_chars_result r2;
+std::to_chars_result r;
+X x = 0xc;
+
+if (fits_in(v))
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+assert(r2.ptr == r.ptr);

[PATCH] D47196: [Time-report ](2): Recursive timers in Clang

2018-07-10 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 updated this revision to Diff 154802.
avt77 added a comment.

I fixed all issues raised by efriedma: GlobalDecl(FD), function body, class 
names, etc. Many tnx for your help.


https://reviews.llvm.org/D47196

Files:
  include/clang/Frontend/Utils.h
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/FrontendTiming.cpp
  lib/Parse/CMakeLists.txt
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  test/Frontend/ftime-report-template-decl.cpp
  test/Headers/opencl-c-header.cl

Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -71,4 +71,5 @@
 }
 #endif //__OPENCL_C_VERSION__
 
-// CHECK-MOD: Reading modules
+// CHECK-DAG-MOD: Clang Timers: CodeGen Functions
+// CHECK-DAG-MOD: Reading modules
Index: test/Frontend/ftime-report-template-decl.cpp
===
--- test/Frontend/ftime-report-template-decl.cpp
+++ test/Frontend/ftime-report-template-decl.cpp
@@ -3,9 +3,15 @@
 
 // Template function declarations
 template 
-void foo();
+T foo(T bar) {
+  T Result = bar * bar + bar / 1.2 + bar;
+  return Result;
+};
 template 
-void foo();
+T foo(T bar, U bar2) {
+  T Result = bar2 * bar + bar / 1.2 + bar2;
+  return Result;
+};
 
 // Template function definitions.
 template 
@@ -130,9 +136,15 @@
 template 
 oneT L<0>::O::Fun(U) { return one; }
 
-void Instantiate() {
+double Instantiate() {
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
+  int R1 = foo(123) + foo(177.2) - foo(331.442);
+  char R2 = foo('d', 1234) * foo(1.26);
+  int R3 = foo(1.2) + foo(11.22) / foo(66.77);
+  double R4 = foo(34.56, 1234);
+  double R5 = R1 + R2 * R3 - R4 + one[0]*foo(15.52) - two[1]/foo(51.25);
+  return R5 * R1 + R4 / R3 + R2;
 }
 }
 
@@ -150,7 +162,10 @@
 };
 _Wrap_alloc::rebind w;
 
-// CHECK: Miscellaneous Ungrouped Timers
+// FIXME:  We need more complex test to increase the compilation time;
+// otherwise we see the foolowing message from time to time only.
+// VIOLATILE-CHECK: Clang Timers: CodeGen Functions
+// CHECK-DAG: Miscellaneous Ungrouped Timers
 // CHECK-DAG: LLVM IR Generation Time
 // CHECK-DAG: Code Generation Time
 // CHECK: Total
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -27,6 +27,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtOpenMP.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Ownership.h"
@@ -10951,6 +10952,11 @@
 
   LSI->CallOperator = NewCallOperator;
 
+  if (FrontendTimesIsEnabled) {
+getFrontendFunctionTimeCtx()->startFrontendTimer(
+{NewCallOperator, 0.0});
+  }
+
   for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
I != NumParams; ++I) {
 auto *P = NewCallOperator->getParamDecl(I);
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -10,17 +10,18 @@
 //  This file implements semantic analysis for C++ lambda expressions.
 //
 //===--===//
-#include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/SemaLambda.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
-#include "clang/Sema/SemaLambda.h"
 using namespace clang;
 using namespace sema;
 
@@ -1433,6 +1434,11 @@
 ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, 
  Scope *CurScope) {
   LambdaScopeInfo LSI = *cast(FunctionScopes.back());
+
+  if (FrontendTimesIsEnabled) {
+getFrontendFunctionTimeCtx()->startFrontendTimer(
+{LSI.CallOperator, 0.0});
+  }
   ActOnFinishFunctionBody(LSI.CallOperator, Body);
   return BuildLambdaExpr(StartLoc, Body->getLocEnd(), &LSI);
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -28,6 +28,7 @@
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearch.h" // TODO: Sema shouldn't depend on Lex
 #include "clang/Lex/Lexer.h" // TODO: Extract static functions to fix layering.
 #include "clang/

[PATCH] D48903: [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name

2018-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM if that does not introduce any regressions in clang and clang-tools.




Comment at: lib/Basic/VirtualFileSystem.cpp:770
+if (I != E) {
+  SmallString<32> Path(RequestedDirName);
+  llvm::sys::path::append(Path, I->second->getFileName());

NIT: maybe increase the size to 256? This could save an extra allocation in 
some cases, and hopefully won't be expensive, stack allocs are cheap in most 
cases.


Repository:
  rC Clang

https://reviews.llvm.org/D48903



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


  1   2   >