r328404 - [ODRHash] Support pointer and reference types.

2018-03-23 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar 23 17:52:44 2018
New Revision: 328404

URL: http://llvm.org/viewvc/llvm-project?rev=328404=rev
Log:
[ODRHash] Support pointer and reference types.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=328404=328403=328404=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Mar 23 17:52:44 2018
@@ -642,6 +642,24 @@ public:
 VisitFunctionType(T);
   }
 
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeTypeAsWritten());
+VisitType(T);
+  }
+
+  void VisitLValueReferenceType(const LValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
+  void VisitRValueReferenceType(const RValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=328404=328403=328404=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Mar 23 17:52:44 2018
@@ -2287,6 +2287,128 @@ Invalid1 i1;
 }  // namespace BaseClass
 
 
+namespace PointersAndReferences {
+#if defined(FIRST) || defined(SECOND)
+template struct Wrapper{};
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S1 {
+  Wrapper x;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{PointersAndReferences::S1::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S1' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S2 {
+  Wrapper x;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{PointersAndReferences::S2::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S2' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S3 {
+  Wrapper x;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{PointersAndReferences::S3::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S3' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S4 {
+  Wrapper x;
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{PointersAndReferences::S4::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S4' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S5 {
+  Wrapper x;
+};
+#else
+S5 s5;
+// expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 
'SecondModule' is not present in definition of 'PointersAndReferences::S5' in 
module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S6 {
+  Wrapper x;
+};
+#else
+S6 s6;
+// expected-error@first.h:* {{PointersAndReferences::S6::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S6' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#define DECLS\
+  Wrapper x1; \
+  Wrapper x2;   \
+  Wrapper x3; \
+  Wrapper x4; \
+  Wrapper x5;\
+  Wrapper x6;   \
+  Wrapper x7;  \
+  Wrapper x8;  \
+  Wrapper x9;
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
+}  // namespace PointersAndReferences
+
+
 // Collection of interesting cases below.
 
 // Naive parsing of AST can lead to cycles in processing.  Ensure


___
cfe-commits mailing list

[PATCH] D44765: PR36643 Make clang-format support more generic TMarcos

2018-03-23 Thread Teodor Petrov via Phabricator via cfe-commits
obfuscated updated this revision to Diff 139686.
obfuscated added a comment.

Added an option


Repository:
  rC Clang

https://reviews.llvm.org/D44765

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7937,6 +7937,7 @@
 
 TEST_F(FormatTest, BreaksStringLiteralsWithin_GenericTMacro) {
   FormatStyle Style = getLLVMStyleWithColumns(25);
+  Style.TMacros.push_back("blablaT");
   EXPECT_EQ(
   "blablaT(\"aa\")\n"
   "blablaT(\"aa\")\n"
@@ -10688,6 +10689,17 @@
   "  - 'CPPEVAL'\n"
   "CanonicalDelimiter: 'cc'",
   RawStringFormats, ExpectedRawStringFormats);
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.
+  Style.TMacros.clear();
+  std::vector TestTMarco;
+  TestTMarco.push_back("_T");
+  CHECK_PARSE("TMacros: [_T]", TMacros, TestTMarco);
+  std::vector TestTMarcoAndMyT;
+  TestTMarcoAndMyT.push_back("_T");
+  TestTMarcoAndMyT.push_back("myT");
+  CHECK_PARSE("TMacros: [_T, myT]", TMacros, TestTMarcoAndMyT);
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -368,7 +368,8 @@
 return false;
 
   FormatToken *Macro = Tokens[Tokens.size() - 4];
-  if (Macro->TokenText.empty() || !String->TokenText.startswith("\"") || 
!String->TokenText.endswith("\""))
+  if (std::find(Style.TMacros.begin(), Style.TMacros.end(), Macro->TokenText) 
==
+  Style.TMacros.end())
 return false;
 
   const char *Start = Macro->TokenText.data();
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -430,6 +430,7 @@
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("TabWidth", Style.TabWidth);
+IO.mapOptional("TMacros", Style.TMacros);
 IO.mapOptional("UseTab", Style.UseTab);
   }
 };
@@ -686,6 +687,7 @@
   LLVMStyle.DisableFormat = false;
   LLVMStyle.SortIncludes = true;
   LLVMStyle.SortUsingDeclarations = true;
+  LLVMStyle.TMacros.push_back("_T");
 
   return LLVMStyle;
 }
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1673,6 +1673,22 @@
   /// \brief The number of columns used for tab stops.
   unsigned TabWidth;
 
+  /// \brief A vector of macros that should be interpreted as string wrapping
+  /// macros instead of as function calls.
+  ///
+  /// These are expected to be macros of the form:
+  /// \code
+  ///   _T("...some string...")
+  /// \endcode
+  ///
+  /// In the .clang-format configuration file, this can be configured like:
+  /// \code{.yaml}
+  ///   TMarcos: ['_T', 'myT']
+  /// \endcode
+  ///
+  /// For example: _T.
+  std::vector TMacros;
+
   /// \brief Different ways to use tab in formatting.
   enum UseTabStyle {
 /// Never use tab.
@@ -1781,7 +1797,7 @@
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
-   UseTab == R.UseTab;
+   TMacros == R.TMacros && UseTab == R.UseTab;
   }
 
   llvm::Optional GetLanguageStyle(LanguageKind Language) const;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7937,6 +7937,7 @@
 
 TEST_F(FormatTest, BreaksStringLiteralsWithin_GenericTMacro) {
   FormatStyle Style = getLLVMStyleWithColumns(25);
+  Style.TMacros.push_back("blablaT");
   EXPECT_EQ(
   "blablaT(\"aa\")\n"
   "blablaT(\"aa\")\n"
@@ -10688,6 +10689,17 @@
   "  - 'CPPEVAL'\n"
   "CanonicalDelimiter: 'cc'",
   RawStringFormats, ExpectedRawStringFormats);
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.
+  Style.TMacros.clear();
+  std::vector TestTMarco;
+  TestTMarco.push_back("_T");
+  CHECK_PARSE("TMacros: [_T]", TMacros, TestTMarco);
+  std::vector TestTMarcoAndMyT;
+  TestTMarcoAndMyT.push_back("_T");
+  TestTMarcoAndMyT.push_back("myT");
+  CHECK_PARSE("TMacros: [_T, myT]", TMacros, TestTMarcoAndMyT);
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
Index: 

[PATCH] D44765: PR36643 Make clang-format support more generic TMarcos

2018-03-23 Thread Teodor Petrov via Phabricator via cfe-commits
obfuscated updated this revision to Diff 139687.
obfuscated added a comment.

Attached both commits in a single diff...


Repository:
  rC Clang

https://reviews.llvm.org/D44765

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7935,6 +7935,48 @@
"_T(\"Xn\"));"));
 }
 
+TEST_F(FormatTest, BreaksStringLiteralsWithin_GenericTMacro) {
+  FormatStyle Style = getLLVMStyleWithColumns(25);
+  Style.TMacros.push_back("blablaT");
+  EXPECT_EQ(
+  "blablaT(\"aa\")\n"
+  "blablaT(\"aa\")\n"
+  "blablaT(\"\")",
+  format("  blablaT(\"\")", Style));
+  EXPECT_EQ("f(x,\n"
+"  blablaT(\"\")\n"
+"  blablaT(\"aaa\"),\n"
+"  z);",
+format("f(x, blablaT(\"aaa\"), z);", Style));
+
+  // FIXME: Handle embedded spaces in one iteration.
+  //  EXPECT_EQ("blablaT(\"a\")\n"
+  //"blablaT(\"a\")\n"
+  //"blablaT(\"a\")\n"
+  //"blablaT(\"a\")",
+  //format("  blablaT ( \"\" )",
+  //   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ(
+  "blablaT ( \"\" )",
+  format("  blablaT ( \"\" )", Style));
+  EXPECT_EQ("f(\n"
+"#if !TEST\n"
+"blablaT(\"Xn\")\n"
+"#endif\n"
+");",
+format("f(\n"
+   "#if !TEST\n"
+   "blablaT(\"Xn\")\n"
+   "#endif\n"
+   ");"));
+  EXPECT_EQ("f(\n"
+"\n"
+"blablaT(\"Xn\"));",
+format("f(\n"
+   "\n"
+   "blablaT(\"Xn\"));"));
+}
+
 TEST_F(FormatTest, BreaksStringLiteralOperands) {
   // In a function call with two operands, the second can be broken with no line
   // break before it.
@@ -10647,6 +10689,17 @@
   "  - 'CPPEVAL'\n"
   "CanonicalDelimiter: 'cc'",
   RawStringFormats, ExpectedRawStringFormats);
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.
+  Style.TMacros.clear();
+  std::vector TestTMarco;
+  TestTMarco.push_back("_T");
+  CHECK_PARSE("TMacros: [_T]", TMacros, TestTMarco);
+  std::vector TestTMarcoAndMyT;
+  TestTMarcoAndMyT.push_back("_T");
+  TestTMarcoAndMyT.push_back("myT");
+  CHECK_PARSE("TMacros: [_T, myT]", TMacros, TestTMarcoAndMyT);
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -368,7 +368,8 @@
 return false;
 
   FormatToken *Macro = Tokens[Tokens.size() - 4];
-  if (Macro->TokenText != "_T")
+  if (std::find(Style.TMacros.begin(), Style.TMacros.end(), Macro->TokenText) ==
+  Style.TMacros.end())
 return false;
 
   const char *Start = Macro->TokenText.data();
@@ -382,6 +383,7 @@
   String->TokenText, String->OriginalColumn, Style.TabWidth, Encoding);
   String->NewlinesBefore = Macro->NewlinesBefore;
   String->HasUnescapedNewline = Macro->HasUnescapedNewline;
+  String->TMacroStringLiteral = true;
 
   Tokens.pop_back();
   Tokens.pop_back();
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -134,6 +134,9 @@
   /// Token.
   bool HasUnescapedNewline = false;
 
+  /// \brief Whether this is a string literal similar to _T("sdfsdf").
+  bool TMacroStringLiteral = false;
+
   /// \brief The range of the whitespace immediately preceding the \c Token.
   SourceRange WhitespaceRange;
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -430,6 +430,7 @@
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("TabWidth", Style.TabWidth);
+IO.mapOptional("TMacros", Style.TMacros);
 IO.mapOptional("UseTab", Style.UseTab);
   }
 };
@@ -686,6 +687,7 @@
   LLVMStyle.DisableFormat = false;
   LLVMStyle.SortIncludes = true;
   LLVMStyle.SortUsingDeclarations = true;
+  

[PATCH] D43696: Reduce hash collisions for reference and pointer types

2018-03-23 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

r328404 has been committed to support references and pointers.


Repository:
  rC Clang

https://reviews.llvm.org/D43696



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


r328406 - [analyzer] Do not crash in CallEvent.getReturnType()

2018-03-23 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Mar 23 18:53:12 2018
New Revision: 328406

URL: http://llvm.org/viewvc/llvm-project?rev=328406=rev
Log:
[analyzer] Do not crash in CallEvent.getReturnType()

When the call expression is not available.

Added:
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability-cxx.h
cfe/trunk/test/Analysis/trustnonnullchecker_test.mm
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=328406=328405=328406=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Fri Mar 23 18:53:12 2018
@@ -67,11 +67,13 @@ using namespace clang;
 using namespace ento;
 
 QualType CallEvent::getResultType() const {
+  ASTContext  = getState()->getStateManager().getContext();
   const Expr *E = getOriginExpr();
-  assert(E && "Calls without origin expressions do not have results");
-  QualType ResultTy = E->getType();
+  if (!E)
+return Ctx.VoidTy;
+  assert(E);
 
-  ASTContext  = getState()->getStateManager().getContext();
+  QualType ResultTy = E->getType();
 
   // A function that returns a reference to 'int' will have a result type
   // of simply 'int'. Check the origin expr's value kind to recover the

Added: 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability-cxx.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability-cxx.h?rev=328406=auto
==
--- 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability-cxx.h 
(added)
+++ 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability-cxx.h 
Fri Mar 23 18:53:12 2018
@@ -0,0 +1,9 @@
+#pragma clang system_header
+
+struct S {
+  ~S(){}
+};
+
+void foo() {
+  S s;
+}

Added: cfe/trunk/test/Analysis/trustnonnullchecker_test.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/trustnonnullchecker_test.mm?rev=328406=auto
==
--- cfe/trunk/test/Analysis/trustnonnullchecker_test.mm (added)
+++ cfe/trunk/test/Analysis/trustnonnullchecker_test.mm Fri Mar 23 18:53:12 2018
@@ -0,0 +1,9 @@
+// RUN: %clang_analyze_cc1 -fblocks -analyze 
-analyzer-checker=core,nullability,apiModeling  -verify %s
+
+#include "Inputs/system-header-simulator-for-nullability-cxx.h"
+
+// expected-no-diagnostics
+
+void blah() {
+  foo(); // no-crash
+}


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


[clang-tools-extra] r328302 - [clangd] Remove 'static' from a function inside anonymous ns. NFC

2018-03-23 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Mar 23 03:39:15 2018
New Revision: 328302

URL: http://llvm.org/viewvc/llvm-project?rev=328302=rev
Log:
[clangd] Remove 'static' from a function inside anonymous ns. NFC

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=328302=328301=328302=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Fri Mar 23 
03:39:15 2018
@@ -42,7 +42,7 @@ using ::testing::UnorderedElementsAre;
 
 namespace {
 
-static bool diagsContainErrors(const std::vector ) {
+bool diagsContainErrors(const std::vector ) {
   for (auto D : Diagnostics) {
 if (D.Severity == DiagnosticsEngine::Error ||
 D.Severity == DiagnosticsEngine::Fatal)


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


[PATCH] D43967: [ASTImporter] Add test helper Fixture

2018-03-23 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 139567.
martong marked 3 inline comments as done.
martong added a comment.

- Add some minor changes based on xazax's comments


Repository:
  rC Clang

https://reviews.llvm.org/D43967

Files:
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/DeclMatcher.h

Index: unittests/AST/DeclMatcher.h
===
--- /dev/null
+++ unittests/AST/DeclMatcher.h
@@ -0,0 +1,68 @@
+//===- unittest/AST/DeclMatcher.h - AST unit test support ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_UNITTESTS_AST_DECLMATCHER_H
+#define LLVM_CLANG_UNITTESTS_AST_DECLMATCHER_H
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+namespace clang {
+namespace ast_matchers {
+
+enum class DeclMatcherKind { First, Last };
+
+// Matcher class to retrieve the first/last matched node under a given AST.
+template 
+class DeclMatcher : public MatchFinder::MatchCallback {
+  NodeType *Node = nullptr;
+  void run(const MatchFinder::MatchResult ) override {
+if ((MatcherKind == DeclMatcherKind::First && Node == nullptr) ||
+MatcherKind == DeclMatcherKind::Last) {
+  Node = const_cast(Result.Nodes.getNodeAs(""));
+}
+  }
+public:
+  // Returns the first/last matched node under the tree rooted in `D`.
+  template 
+  NodeType *match(const Decl *D, const MatcherType ) {
+MatchFinder Finder;
+Finder.addMatcher(AMatcher.bind(""), this);
+Finder.matchAST(D->getASTContext());
+assert(Node);
+return Node;
+  }
+};
+template 
+using LastDeclMatcher = DeclMatcher;
+template 
+using FirstDeclMatcher = DeclMatcher;
+
+template 
+class DeclCounter : public MatchFinder::MatchCallback {
+  unsigned Count = 0;
+  void run(const MatchFinder::MatchResult ) override {
+  if(Result.Nodes.getNodeAs("")) {
+++Count;
+  }
+  }
+public:
+  // Returns the number of matched nodes under the tree rooted in `D`.
+  template 
+  unsigned match(const Decl *D, const MatcherType ) {
+MatchFinder Finder;
+Finder.addMatcher(AMatcher.bind(""), this);
+Finder.matchAST(D->getASTContext());
+return Count;
+  }
+};
+
+} // end namespace ast_matchers
+} // end namespace clang
+
+#endif
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -17,6 +17,8 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+
+#include "DeclMatcher.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -29,7 +31,7 @@
   return Lang == Lang_CXX || Lang == Lang_CXX11;
 }
 
-static RunOptions getRunOptionsForLanguage(Language Lang) {
+static ArgVector getBasicRunOptionsForLanguage(Language Lang) {
   ArgVector BasicArgs;
   // Test with basic arguments.
   switch (Lang) {
@@ -49,6 +51,11 @@
   case Lang_OBJCXX:
 llvm_unreachable("Not implemented yet!");
   }
+  return BasicArgs;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs = getBasicRunOptionsForLanguage(Lang);
 
   // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
   // default behaviour.
@@ -61,6 +68,19 @@
   return {BasicArgs};
 }
 
+// Creates a virtual file and assigns that to the context of given AST. If the
+// file already exists then the file will not be created again as a duplicate.
+static void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
+  const std::string ) {
+  assert(ToAST);
+  ASTContext  = ToAST->getASTContext();
+  auto *OFS = static_cast(
+  ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
+  auto *MFS =
+  static_cast(OFS->overlays_begin()->get());
+  MFS->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Code.c_str()));
+}
+
 template
 testing::AssertionResult
 testImport(const std::string , const ArgVector ,
@@ -79,11 +99,7 @@
 
   // Add input.cc to virtual file system so importer can 'find' it
   // while importing SourceLocations.
-  vfs::OverlayFileSystem *OFS = static_cast(
-ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
-  vfs::InMemoryFileSystem *MFS = static_cast(
-OFS->overlays_begin()->get());
-  MFS->addFile(InputFileName, 0, llvm::MemoryBuffer::getMemBuffer(FromCode));
+  createVirtualFileIfNeeded(ToAST.get(), InputFileName, FromCode);
 
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
@@ -133,6 +149,165 @@
  Verifier, AMatcher));
 }
 

[PATCH] D43967: [ASTImporter] Add test helper Fixture

2018-03-23 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:276
+// This will not create the file more than once.
+createVirtualFile(ToAST.get(), It->FileName, It->Code);
+

xazax.hun wrote:
> Maybe an IfNeeded suffix or something like that rather than a comment?
Added the suffix.



Comment at: unittests/AST/ASTImporterTest.cpp:289
+for (auto  : FromTUs) {
+  if (Tu.Unit) {
+llvm::errs() << "FromAST:\n";

xazax.hun wrote:
> When can the TU.Unit be nullptr here?  Should this be an assert instead?
Good catch, changed it.



Comment at: unittests/AST/ASTImporterTest.cpp:1045
+
+  assert(Check(From));
+  Check(To);

xazax.hun wrote:
> I wonder why we only assert on the first one and if we should use GTEST 
> macros here. Same questions below.
Changed to use GTEST macros.
The reason why we assert only on the first is this: In the first check we 
verify the original "from" AST, if the assumption we made on the original AST 
is false then there is no point to continue. However, in the second check we do 
verify the logic of the importer which may fail. But that is not a fatal 
failure, because if there were any other checks after that we would like to 
know if those checks pass or not.
The main difference between `EXPECT_*` and `ASSERT_*` is that `ASSERT_*` will 
terminate the given test if it fails, but `EXPECT_*` keep on going and 
subsequent checks will be executed in the same test.



Repository:
  rC Clang

https://reviews.llvm.org/D43967



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-23 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Escaping exception is certainly a bug, so it should go into `bugprone` then.


https://reviews.llvm.org/D33537



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


[PATCH] D44823: [libcxx] Improving std::vector and std::deque perfomance

2018-03-23 Thread Danila Kutenin via Phabricator via cfe-commits
danlark created this revision.
danlark added reviewers: EricWF, mclow.lists.
Herald added subscribers: cfe-commits, christof.

Consider the following code.

  #include 
  #include 
  
  class TestClass {
  public:
  TestClass(size_t size)
  : Data(size)
  {
  }
  private:
  std::vector Data;
  };
  
  int main(void) {
  std::unique_ptr test;
  for (int i = 0; i < 10; ++i)
  test.reset(new TestClass(0x1));
  return 0;
  }

For clang 5.0.1 it works for 14sec on my laptop. If you replace `char` by 
`short` it becomes 35 times faster(wow). The main difference in the generated 
code that for `char` no `memset` is called inside `__construct_at_end` function.

By manipulating a local variable in the loop, this lets it be fully optimized 
away.

Prior to this change, this would be generated (on x86-64):

  51,79c58,66
  <   movq  %rax, 8(%rbx)
  <   movq  %rax, (%rbx)
  <   movq  %rax, %rcx
  <   addq  $65536, %rcx# imm = 0x1
  <   movq  %rcx, 16(%rbx)
  <   movq  $-65536, %rcx   # imm = 0x
  <   .align  16, 0x90
  < .LBB0_4:#   Parent Loop BB0_1 Depth=1
  < # =>  This Inner Loop Header: 
Depth=2
  <   movb  $0, (%rax)
  <   movq  8(%rbx), %rax
  <   leaq  1(%rax), %rdx
  <   movq  %rdx, 8(%rbx)
  <   movb  $0, 1(%rax)
  <   movq  8(%rbx), %rax
  <   leaq  1(%rax), %rdx
  <   movq  %rdx, 8(%rbx)
  <   movb  $0, 1(%rax)
  <   movq  8(%rbx), %rax
  <   leaq  1(%rax), %rdx
  <   movq  %rdx, 8(%rbx)
  <   movb  $0, 1(%rax)
  <   movq  8(%rbx), %rax
  <   incq  %rax
  <   movq  %rax, 8(%rbx)
  <   addq  $4, %rcx
  <   jne  .LBB0_4
  < # BB#5: # %_ZN9TestClassC2Em.exit
  < #   in Loop: Header=BB0_1 Depth=1
  ---
  >   movq  %rax, (%r12)
  >   movq  %rax, %rbx
  >   addq  $65536, %rbx# imm = 0x1
  >   movq  %rbx, 16(%r12)
  >   xorl  %esi, %esi
  >   movl  $65536, %edx# imm = 0x1
  >   movq  %rax, %rdi
  >   callq  memset
  >   movq  %rbx, 8(%r12)
  81,82c68,69


Repository:
  rCXX libc++

https://reviews.llvm.org/D44823

Files:
  libcxx/trunk/include/__split_buffer
  libcxx/trunk/include/vector


Index: libcxx/trunk/include/vector
===
--- libcxx/trunk/include/vector
+++ libcxx/trunk/include/vector
@@ -984,11 +984,13 @@
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
 {
 allocator_type& __a = this->__alloc();
+pointer __to_be_end = this->__end_;
 do
 {
 __RAII_IncreaseAnnotator __annotator(*this);
-__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
-++this->__end_;
+__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__to_be_end));
+++__to_be_end;
+this->__end_ = __to_be_end;
 --__n;
 __annotator.__done();
 } while (__n > 0);
@@ -1006,11 +1008,13 @@
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
 {
 allocator_type& __a = this->__alloc();
+pointer __to_be_end = this->__end_;
 do
 {
 __RAII_IncreaseAnnotator __annotator(*this);
-__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), 
__x);
-++this->__end_;
+__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__to_be_end), 
__x);
+++__to_be_end;
+this->__end_ = __to_be_end;
 --__n;
 __annotator.__done();
 } while (__n > 0);
Index: libcxx/trunk/include/__split_buffer
===
--- libcxx/trunk/include/__split_buffer
+++ libcxx/trunk/include/__split_buffer
@@ -198,10 +198,12 @@
 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
 {
 __alloc_rr& __a = this->__alloc();
+pointer __to_be_end = this->__end_;
 do
 {
-__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
-++this->__end_;
+__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__to_be_end));
+++__to_be_end;
+this->__end_ = __to_be_end;
 --__n;
 } while (__n > 0);
 }
@@ -217,10 +219,12 @@
 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, 
const_reference __x)
 {
 __alloc_rr& __a = this->__alloc();
+pointer __to_be_end = this->__end_;
 do
 {
-__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), 
__x);
-++this->__end_;
+__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__to_be_end), 
__x);
+++__to_be_end;
+this->__end_ = __to_be_end;
 --__n;
 } while (__n > 0);
 }


Index: libcxx/trunk/include/vector
===
--- libcxx/trunk/include/vector
+++ libcxx/trunk/include/vector
@@ -984,11 +984,13 @@
 vector<_Tp, 

[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks again. This generally looks LGTM, just a last drop of small nits. Will 
approve as soon as they land.




Comment at: clangd/DraftStore.cpp:75
+  return llvm::make_error(
+  llvm::formatv("Range's end position (line={0}, character={1}) is "
+"before start position (line={2}, character={3}).",

Could we add a format provide for `Position` to make this formatting code 
shorter?
We'll need to define the corresponding specialization in `Protocol.h`:

```
namespace llvm {
  template <>
  struct format_provider {
static void format(const clang::clangd::Position , raw_ostream , 
StringRef Style) { 
 assert(Style.empty() && "style modifiers for this type are not supported");
 OS << Pos;
}
  };
}
```

This will allow to simplify this call site to:
```
llvm::formatv("Range's end position ({0}) is before start position ({1})", End, 
Start)
```



Comment at: clangd/DraftStore.cpp:100
+  EntryIt->second = Contents;
+  return std::move(Contents);
+}

Doing `return std::move(localvar)` is a pessimization. Use `return Contents;` 
instead.
 (for reference see 
[[https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value|this
 SO post]], clang should give a warning for that case too)



Comment at: clangd/DraftStore.h:36
   /// Replace contents of the draft for \p File with \p Contents.
-  void updateDraft(PathRef File, StringRef Contents);
+  void addDraft(PathRef File, StringRef Contents);
+

simark wrote:
> ilya-biryukov wrote:
> > ilya-biryukov wrote:
> > > simark wrote:
> > > > ilya-biryukov wrote:
> > > > > Could we add versions from LSP's `VersionedTextDocumentIdentifier` 
> > > > > here and make the relevant sanity checks?
> > > > > Applying diffs to the wrong version will cause everything to fall 
> > > > > apart, so we should detect this error and signal it to the client as 
> > > > > soon as possible.
> > > > I agree that applying diffs to the wrong version will break basically 
> > > > everything, but even if we detect a version mismatch, I don't see what 
> > > > we could do, since we don't have a mean to report the error to the 
> > > > client.  The only thing we could do is log it (which we already do.
> > > If we couldn't apply a diff, we should return errors from all future 
> > > operations on this file until it gets closed and reopened. Otherwise 
> > > clangd and the editor would see inconsistent contents for the file and 
> > > results provided by clangd would be unreliable.
> > > The errors from any actions on the invalid file would actually be visible 
> > > to the users.
> > > 
> > > The simplest way to achieve that is to remove the file from `DraftStore` 
> > > and `ClangdServer` on errors from `updateDraft`.
> > > This will give "calling action on non-tracked file" errors for future 
> > > operations and the actual root cause can be figured out from the logs.
> > We still ignore version numbers from the LSP.
> > Is this another change that didn't get in?
> The more I think about it, the less sure I am that this is the intended usage 
> of the version.  The spec doesn't even say what the initial version of a file 
> should be, 0 or 1?  Then, it just says that the version optionally contained 
> in the `VersionedTextDocumentIdentifier` reflects the version of the document 
> after having applied the edit.  But I don't think we can predict and validate 
> what that version should be.  Most clients will probably just use a sequence 
> number, but I guess they don't have to...
> 
> Also, I initially assumed that having N changes in the `contentChanges` array 
> would mean that the version number would be bumped by N.  But now that I 
> re-read it, there's really nothing that says it should behave like this.
> 
> I think that we should just record the version number and treat it as opaque, 
> so that we can use it later when sending text edits to the client, for 
> example.  The client can then verify that the edit is for the same version of 
> the document that it has at the moment.
> 
> Therefore, I don't think it would really be useful in this patch.
The initial version is provided in `didOpen` (see `TextDocumentItem`).
I've also misread description of `contentChanges` in the same way. It's true 
that versions might grow by any  
[[https://github.com/Microsoft/language-server-protocol/issues/241|any positive 
number]], so we can't rely on them for the checks I propose here.
Thanks for looking into that and explaining the spec :-)



Comment at: clangd/DraftStore.h:26
 /// filenames. The contents are owned by the DraftStore.
 class DraftStore {
 public:

Could we also mention in the comment that this class now handles applying 
incremental document changes?



Comment at: unittests/clangd/DraftStoreTests.cpp:36
+/// Send the 

[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please also mention new warning in Release Notes and documentation.

Will this warning be part of -Wall or -Wextra?


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D44837: [CUDA] Fixed false error reporting in case of calling H->G->HD->D.

2018-03-23 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added a subscriber: sanjoy.

Launching a kernel from the host code does not generate code for the
kernel itself. This fixes an issue with clang erroneously reporting
an error for a HD->D call from within the kernel.


https://reviews.llvm.org/D44837

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/SemaCUDA/call-device-fn-from-host.cu


Index: clang/test/SemaCUDA/call-device-fn-from-host.cu
===
--- clang/test/SemaCUDA/call-device-fn-from-host.cu
+++ clang/test/SemaCUDA/call-device-fn-from-host.cu
@@ -83,3 +83,10 @@
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = _fn;  // Not an error because the template isn't 
instantiated.
 }
+
+// Launching a kernel from a host function does not result in code generation
+// for it, so calling HD function which calls a D function should not trigger
+// errors.
+static __host__ __device__ void hd_func() { device_fn(); }
+__global__ void kernel() { hd_func(); }
+void host_func(void) { kernel<<<1, 1>>>(); }
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -790,9 +790,12 @@
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
   bool CallerKnownEmitted = IsKnownEmitted(*this, Caller);
-  if (CallerKnownEmitted)
-MarkKnownEmitted(*this, Caller, Callee, Loc);
-  else {
+  if (CallerKnownEmitted) {
+// Host-side references to a __global__ function refer to the stub, so the
+// function itself is never emitted and therefore should not be marked.
+if (getLangOpts().CUDAIsDevice || IdentifyCUDATarget(Callee) != CFT_Global)
+  MarkKnownEmitted(*this, Caller, Callee, Loc);
+  } else {
 // If we have
 //   host fn calls kernel fn calls host+device,
 // the HD function does not get instantiated on the host.  We model this by


Index: clang/test/SemaCUDA/call-device-fn-from-host.cu
===
--- clang/test/SemaCUDA/call-device-fn-from-host.cu
+++ clang/test/SemaCUDA/call-device-fn-from-host.cu
@@ -83,3 +83,10 @@
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = _fn;  // Not an error because the template isn't instantiated.
 }
+
+// Launching a kernel from a host function does not result in code generation
+// for it, so calling HD function which calls a D function should not trigger
+// errors.
+static __host__ __device__ void hd_func() { device_fn(); }
+__global__ void kernel() { hd_func(); }
+void host_func(void) { kernel<<<1, 1>>>(); }
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -790,9 +790,12 @@
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
   bool CallerKnownEmitted = IsKnownEmitted(*this, Caller);
-  if (CallerKnownEmitted)
-MarkKnownEmitted(*this, Caller, Callee, Loc);
-  else {
+  if (CallerKnownEmitted) {
+// Host-side references to a __global__ function refer to the stub, so the
+// function itself is never emitted and therefore should not be marked.
+if (getLangOpts().CUDAIsDevice || IdentifyCUDATarget(Callee) != CFT_Global)
+  MarkKnownEmitted(*this, Caller, Callee, Loc);
+  } else {
 // If we have
 //   host fn calls kernel fn calls host+device,
 // the HD function does not get instantiated on the host.  We model this by
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44842: Add Parameters to DW_AT_name Attribute of Template Variables

2018-03-23 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

CC'ing LLDB developers because I'm not sure if this could break symbol lookup.


Repository:
  rC Clang

https://reviews.llvm.org/D44842



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


r328362 - [CUDA] Fixed false error reporting in case of calling H->G->HD->D.

2018-03-23 Thread Artem Belevich via cfe-commits
Author: tra
Date: Fri Mar 23 12:49:03 2018
New Revision: 328362

URL: http://llvm.org/viewvc/llvm-project?rev=328362=rev
Log:
[CUDA] Fixed false error reporting in case of calling H->G->HD->D.

Launching a kernel from the host code does not generate code for the
kernel itself. This fixes an issue with clang erroneously reporting
an error for a HD->D call from within the kernel.

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

Modified:
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=328362=328361=328362=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Fri Mar 23 12:49:03 2018
@@ -790,9 +790,12 @@ bool Sema::CheckCUDACall(SourceLocation
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
   bool CallerKnownEmitted = IsKnownEmitted(*this, Caller);
-  if (CallerKnownEmitted)
-MarkKnownEmitted(*this, Caller, Callee, Loc);
-  else {
+  if (CallerKnownEmitted) {
+// Host-side references to a __global__ function refer to the stub, so the
+// function itself is never emitted and therefore should not be marked.
+if (getLangOpts().CUDAIsDevice || IdentifyCUDATarget(Callee) != CFT_Global)
+  MarkKnownEmitted(*this, Caller, Callee, Loc);
+  } else {
 // If we have
 //   host fn calls kernel fn calls host+device,
 // the HD function does not get instantiated on the host.  We model this by

Modified: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu?rev=328362=328361=328362=diff
==
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu (original)
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu Fri Mar 23 12:49:03 2018
@@ -83,3 +83,10 @@ template 
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = _fn;  // Not an error because the template isn't 
instantiated.
 }
+
+// Launching a kernel from a host function does not result in code generation
+// for it, so calling HD function which calls a D function should not trigger
+// errors.
+static __host__ __device__ void hd_func() { device_fn(); }
+__global__ void kernel() { hd_func(); }
+void host_func(void) { kernel<<<1, 1>>>(); }


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


[PATCH] D44778: [clang-format] Wildcard expansion on Windows.

2018-03-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: tools/clang-format/ClangFormat.cpp:348
+  if (EC) {
+llvm::errs() << "error: couldn'g get arguments: " << EC.message() << '\n';
+  }

s/couldn'g/couldn't/


Repository:
  rC Clang

https://reviews.llvm.org/D44778



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


[PATCH] D44652: [vfs] Don't bail out after a missing -ivfsoverlay file

2018-03-23 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir closed this revision.
benlangmuir marked an inline comment as done.
benlangmuir added a comment.

r328337


Repository:
  rC Clang

https://reviews.llvm.org/D44652



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

This duplicates Clang-tidy misc-unused-using-decls 
. 
If Clang will provide same or better functionality, it should be removed.


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: CarlosAlbertoEnciso.
dblaikie added a comment.

While implementing the warning is great (wonder if there's any codebase
that isn't -Wunused-using clean, that we could use to compare Clang and
GCC's behavior broadly - make sure it's catching the same cases (or
justify/investigate differences)) - and using it to motivate the debug info
is an improvement to the debug info - it won't quite address all the wasted
debug info, unfortunately :/

Consider this:

namespace a {

  struct b;

};
namespace x {

  using a::b;
  inline void f(b*) {
  }

}

Now the using declaration is used, but if 'f' is never called in this
translation unit, it's a bit weird to produce debug info for the using decl
and could still substantially bloat debug info. (indeed most of the bloat
that the using decl/directive debug info is producing is probably from
directives that are used, but not in a way that's relevant to a certain
translation unit)

I've not looked at the change yet, but if it's particularly
expensive/complicated to wire up the debug info side, it might not be worth
it given it's probably not a significant savings & somewhat of a dead-end
compared to what would be needed for a more complete fix. But I guess it's
probably not expensive/complicated, so probably some fine low hanging fruit
to pick until a more complete fix/improvement is implemented.


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-03-23 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added subscribers: lebedev.ri, kimgr.
kimgr added a comment.

I have to say I disagree that either the nested struct/function or macros
(in any form) should count toward a function's total variable count.

Both are valid forms of abstraction, and they both remove complexity from
the containing function since they factor details *out of the function's
immediate lexical contents* (I avoid 'scope' as macros do pollute the
scope) in a way that improves readability.

There are cases where macros can make things more complex but it seems
unfair to flag variables declared by macros as making expanding functions
more complex.

In short, I think I agree with Aaron's last example classifications.

- Kim

Den tors 22 mars 2018 14:56Eugene Zelenko via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> skrev:

> Eugene.Zelenko added inline comments.
> 
> 
>  Comment at: docs/ReleaseNotes.rst:127
> 
> +- Added `VariableThreshold` option to `readability-function-size
>  +  <
>  
> http://clang.llvm.org/extra/clang-tidy/checks/readability-function-size.html>`_
> check
> 
>  
> 
> Please rebase from trunk and use //:doc:// for link.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D44602
> 
>  ___
> 
> cfe-commits mailing list
>  cfe-commits@lists.llvm.org
>  http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602



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


Re: [PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-03-23 Thread Kim Gräsman via cfe-commits
I have to say I disagree that either the nested struct/function or macros
(in any form) should count toward a function's total variable count.

Both are valid forms of abstraction, and they both remove complexity from
the containing function since they factor details *out of the function's
immediate lexical contents* (I avoid 'scope' as macros do pollute the
scope) in a way that improves readability.

There are cases where macros can make things more complex but it seems
unfair to flag variables declared by macros as making expanding functions
more complex.

In short, I think I agree with Aaron's last example classifications.

- Kim


Den tors 22 mars 2018 14:56Eugene Zelenko via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> skrev:

> Eugene.Zelenko added inline comments.
>
>
> 
> Comment at: docs/ReleaseNotes.rst:127
>
> +- Added `VariableThreshold` option to `readability-function-size
> +  <
> http://clang.llvm.org/extra/clang-tidy/checks/readability-function-size.html>`_
> check
> 
> Please rebase from trunk and use //:doc:// for link.
>
>
> Repository:
>   rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D44602
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44842: Add Parameters to DW_AT_name Attribute of Template Variables

2018-03-23 Thread Matthew Voss via Phabricator via cfe-commits
ormris created this revision.
ormris added reviewers: dblaikie, aprantl, probinson, JDevlieghere.

This patch adds the associated template parameters to the DWARF name attribute
of all template variable specializations, mirroring how they are referenced in
the source code.


Repository:
  rC Clang

https://reviews.llvm.org/D44842

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-template.cpp


Index: test/CodeGenCXX/debug-info-template.cpp
===
--- test/CodeGenCXX/debug-info-template.cpp
+++ test/CodeGenCXX/debug-info-template.cpp
@@ -160,3 +160,14 @@
 };
 
 PaddingAtEndTemplate<> PaddedTemplateObj;
+
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++14 | FileCheck %s --check-prefix=CXX14
+// CXX14: !DIGlobalVariable(name: "vartemp"
+// CXX14: !DIGlobalVariable(name: "arraytemp"
+template  T vartemp = T();
+template  T arraytemp[N];
+
+void func() {
+  vartemp = 5;
+  arraytemp[0] = 1;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2982,8 +2982,27 @@
 
   Name = VD->getName();
   if (VD->getDeclContext() && !isa(VD->getDeclContext()) &&
-  !isa(VD->getDeclContext()))
+  !isa(VD->getDeclContext())) {
 LinkageName = CGM.getMangledName(VD);
+// If this node refers to an instantiation of a variable template, add the
+// template parameters to its name. This disambiguates it from other
+// instantiations.
+if (auto *VSD = dyn_cast(VD)) {
+  std::string NameString = Name.str();
+  llvm::raw_string_ostream ParameterizedName(NameString);
+  ParameterizedName << "<";
+  bool first = true;
+  for (auto Parameter : VSD->getTemplateArgs().asArray()) {
+if (!first)
+  ParameterizedName << ",";
+Parameter.print(getPrintingPolicy(), ParameterizedName);
+first = false;
+  }
+  ParameterizedName << ">";
+  Name = internString(ParameterizedName.str());
+}
+  }
+
   if (LinkageName == Name)
 LinkageName = StringRef();
 


Index: test/CodeGenCXX/debug-info-template.cpp
===
--- test/CodeGenCXX/debug-info-template.cpp
+++ test/CodeGenCXX/debug-info-template.cpp
@@ -160,3 +160,14 @@
 };
 
 PaddingAtEndTemplate<> PaddedTemplateObj;
+
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++14 | FileCheck %s --check-prefix=CXX14
+// CXX14: !DIGlobalVariable(name: "vartemp"
+// CXX14: !DIGlobalVariable(name: "arraytemp"
+template  T vartemp = T();
+template  T arraytemp[N];
+
+void func() {
+  vartemp = 5;
+  arraytemp[0] = 1;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2982,8 +2982,27 @@
 
   Name = VD->getName();
   if (VD->getDeclContext() && !isa(VD->getDeclContext()) &&
-  !isa(VD->getDeclContext()))
+  !isa(VD->getDeclContext())) {
 LinkageName = CGM.getMangledName(VD);
+// If this node refers to an instantiation of a variable template, add the
+// template parameters to its name. This disambiguates it from other
+// instantiations.
+if (auto *VSD = dyn_cast(VD)) {
+  std::string NameString = Name.str();
+  llvm::raw_string_ostream ParameterizedName(NameString);
+  ParameterizedName << "<";
+  bool first = true;
+  for (auto Parameter : VSD->getTemplateArgs().asArray()) {
+if (!first)
+  ParameterizedName << ",";
+Parameter.print(getPrintingPolicy(), ParameterizedName);
+first = false;
+  }
+  ParameterizedName << ">";
+  Name = internString(ParameterizedName.str());
+}
+  }
+
   if (LinkageName == Name)
 LinkageName = StringRef();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44533: [AMDGPU] Fix codegen for inline assembly

2018-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328359: [AMDGPU] Fix codegen for inline assembly (authored 
by yaxunl, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D44533

Files:
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGStmt.cpp
  test/CodeGenOpenCL/inline-asm-amdgcn.cl
  test/Sema/inline-asm-validate-amdgpu.cl


Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -285,6 +285,19 @@
 return true;
   }
 
+  // \p Constraint will be left pointing at the last character of
+  // the constraint.  In practice, it won't be changed unless the
+  // constraint is longer than one character.
+  std::string convertConstraint(const char *) const override {
+const char *Begin = Constraint;
+TargetInfo::ConstraintInfo Info("", "");
+if (validateAsmConstraint(Constraint, Info))
+  return std::string(Begin).substr(0, Constraint - Begin + 1);
+
+Constraint = Begin;
+return std::string(1, *Constraint);
+  }
+
   bool
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1926,7 +1926,7 @@
 // Simplify the output constraint.
 std::string OutputConstraint(S.getOutputConstraint(i));
 OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1,
-  getTarget());
+  getTarget(), );
 
 const Expr *OutExpr = S.getOutputExpr(i);
 OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
Index: test/Sema/inline-asm-validate-amdgpu.cl
===
--- test/Sema/inline-asm-validate-amdgpu.cl
+++ test/Sema/inline-asm-validate-amdgpu.cl
@@ -74,3 +74,8 @@
 
 c[i] = ci;
 }
+
+void test_long(int arg0) {
+  long v15_16;
+  __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : 
"v"(arg0));
+}
Index: test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+
+kernel void test_long(int arg0) {
+  long v15_16;
+  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", 
"={v[15:16]},v"(i32 %arg0)
+  __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : 
"v"(arg0));
+}


Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -285,6 +285,19 @@
 return true;
   }
 
+  // \p Constraint will be left pointing at the last character of
+  // the constraint.  In practice, it won't be changed unless the
+  // constraint is longer than one character.
+  std::string convertConstraint(const char *) const override {
+const char *Begin = Constraint;
+TargetInfo::ConstraintInfo Info("", "");
+if (validateAsmConstraint(Constraint, Info))
+  return std::string(Begin).substr(0, Constraint - Begin + 1);
+
+Constraint = Begin;
+return std::string(1, *Constraint);
+  }
+
   bool
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1926,7 +1926,7 @@
 // Simplify the output constraint.
 std::string OutputConstraint(S.getOutputConstraint(i));
 OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1,
-  getTarget());
+  getTarget(), );
 
 const Expr *OutExpr = S.getOutputExpr(i);
 OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
Index: test/Sema/inline-asm-validate-amdgpu.cl
===
--- test/Sema/inline-asm-validate-amdgpu.cl
+++ test/Sema/inline-asm-validate-amdgpu.cl
@@ -74,3 +74,8 @@
 
 c[i] = ci;
 }
+
+void test_long(int arg0) {
+  long v15_16;
+  __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
+}
Index: test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+
+kernel void test_long(int arg0) {
+  long v15_16;
+  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 

[PATCH] D44745: [HWASan] Port HWASan to Linux x86-64 (clang)

2018-03-23 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328361: [HWASan] Port HWASan to Linux x86-64 (clang) 
(authored by alekseyshl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44745?vs=139513=139640#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44745

Files:
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.hwasan-x86_64.a.syms
  test/Driver/fsanitize-blacklist.c
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -30,7 +30,7 @@
   NeedsUbsanCxxRt = Vptr | CFI,
   NotAllowedWithTrap = Vptr,
   NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | Scudo,
+  RequiresPIE = DataFlow | HWAddress | Scudo,
   NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
   SupportsCoverage = Address | HWAddress | KernelAddress | Memory | Leak |
  Undefined | Integer | Nullability | DataFlow | Fuzzer |
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -879,7 +879,7 @@
 Res |= SanitizerKind::Function;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch)
 Res |= SanitizerKind::Scudo;
-  if (IsAArch64)
+  if (IsX86_64 || IsAArch64)
 Res |= SanitizerKind::HWAddress;
   return Res;
 }
Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -696,54 +696,100 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-HWASAN-LINUX %s
+// RUN:   | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s
+//
+// CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-HWASAN-X86-64-LINUX: "-pie"
+// CHECK-HWASAN-X86-64-LINUX-NOT: "-lc"
+// CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a"
+// CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic"
+// CHECK-HWASAN-X86-64-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-x86_64.a.syms"
+// CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic"
+// CHECK-HWASAN-X86-64-LINUX: "-lpthread"
+// CHECK-HWASAN-X86-64-LINUX: "-lrt"
+// CHECK-HWASAN-X86-64-LINUX: "-ldl"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
+// RUN: -shared-libsan -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s
+//
+// CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc"
+// CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lrt"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-ldl"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "--export-dynamic"
+// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "--dynamic-list"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
+// RUN: -shared-libsan -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s
 //
-// CHECK-HWASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-HWASAN-LINUX-NOT: "-lc"
-// CHECK-HWASAN-LINUX: libclang_rt.hwasan-aarch64.a"
-// CHECK-HWASAN-LINUX-NOT: "--export-dynamic"
-// CHECK-HWASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-aarch64.a.syms"
-// CHECK-HWASAN-LINUX-NOT: "--export-dynamic"
-// CHECK-HWASAN-LINUX: "-lpthread"
-// CHECK-HWASAN-LINUX: "-lrt"
-// CHECK-HWASAN-LINUX: "-ldl"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lrt"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-ldl"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "--export-dynamic"
+// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "--dynamic-list"
 

r328361 - [HWASan] Port HWASan to Linux x86-64 (clang)

2018-03-23 Thread Alex Shlyapnikov via cfe-commits
Author: alekseyshl
Date: Fri Mar 23 12:47:45 2018
New Revision: 328361

URL: http://llvm.org/viewvc/llvm-project?rev=328361=rev
Log:
[HWASan] Port HWASan to Linux x86-64 (clang)

Summary: Porting HWASan to Linux x86-64, the third of the three patches, clang 
part.

Reviewers: eugenis

Subscribers: cryptoad, cfe-commits

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

Added:

cfe/trunk/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.hwasan-x86_64.a.syms
Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/fsanitize-blacklist.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=328361=328360=328361=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Mar 23 12:47:45 2018
@@ -30,7 +30,7 @@ enum : SanitizerMask {
   NeedsUbsanCxxRt = Vptr | CFI,
   NotAllowedWithTrap = Vptr,
   NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | Scudo,
+  RequiresPIE = DataFlow | HWAddress | Scudo,
   NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
   SupportsCoverage = Address | HWAddress | KernelAddress | Memory | Leak |
  Undefined | Integer | Nullability | DataFlow | Fuzzer |

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=328361=328360=328361=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Fri Mar 23 12:47:45 2018
@@ -879,7 +879,7 @@ SanitizerMask Linux::getSupportedSanitiz
 Res |= SanitizerKind::Function;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch)
 Res |= SanitizerKind::Scudo;
-  if (IsAArch64)
+  if (IsX86_64 || IsAArch64)
 Res |= SanitizerKind::HWAddress;
   return Res;
 }

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.hwasan-x86_64.a.syms
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.hwasan-x86_64.a.syms?rev=328361=auto
==
(empty)

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=328361=328360=328361=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Fri Mar 23 12:47:45 2018
@@ -23,7 +23,7 @@
 // Check that the default blacklist is not added as an extra dependency.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry 
--implicit-check-not=-fsanitize-blacklist=
 // CHECK-DEFAULT-BLACKLIST-ASAN: 
-fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt
-// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN 
--implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN 
--implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
 // CHECK-DEFAULT-BLACKLIST-HWASAN: 
-fsanitize-blacklist={{.*}}hwasan_blacklist.txt
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST 
--implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=328361=328360=328361=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Mar 23 12:47:45 2018
@@ -83,13 +83,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address,address 
-fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANKA-SANA
 // CHECK-SANKA-SANA: '-fsanitize=kernel-address' not allowed with 
'-fsanitize=address'
 
-// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress,thread -fno-rtti 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANT
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress,thread 

Re: [PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread David Blaikie via cfe-commits
While implementing the warning is great (wonder if there's any codebase
that isn't -Wunused-using clean, that we could use to compare Clang and
GCC's behavior broadly - make sure it's catching the same cases (or
justify/investigate differences)) - and using it to motivate the debug info
is an improvement to the debug info - it won't quite address all the wasted
debug info, unfortunately :/

Consider this:

namespace a {
  struct b;
};
namespace x {
  using a::b;
  inline void f(b*) {
  }
}

Now the using declaration is used, but if 'f' is never called in this
translation unit, it's a bit weird to produce debug info for the using decl
and could still substantially bloat debug info. (indeed most of the bloat
that the using decl/directive debug info is producing is probably from
directives that are used, but not in a way that's relevant to a certain
translation unit)

I've not looked at the change yet, but if it's particularly
expensive/complicated to wire up the debug info side, it might not be worth
it given it's probably not a significant savings & somewhat of a dead-end
compared to what would be needed for a more complete fix. But I guess it's
probably not expensive/complicated, so probably some fine low hanging fruit
to pick until a more complete fix/improvement is implemented.

On Fri, Mar 23, 2018 at 8:22 AM Carlos Alberto Enciso via Phabricator <
revi...@reviews.llvm.org> wrote:

> CarlosAlbertoEnciso added a comment.
>
> In https://reviews.llvm.org/D44826#1046671, @erichkeane wrote:
>
> > My opinion matters less than @rsmith or @dblaikie on the review, but it
> seems to me that Typedef and Using are SO similar that the implementations
> should just be combined.  You'd likely have to change a couple of types
> along the way to be more generic, but the implementations are essentially a
> copy/paste of eachother.
>
>
> That is a very valid point and it simplifies quite a lot the patch.
>
> If the other reviewers do not have any objection, I will combine both
> implementations and update the uploaded patch.
>
> Thanks,
> Carlos
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D44826
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r328354 - Fix misuse of llvm::YAML in clangd test.

2018-03-23 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Fri Mar 23 12:16:07 2018
New Revision: 328354

URL: http://llvm.org/viewvc/llvm-project?rev=328354=rev
Log:
Fix misuse of llvm::YAML in clangd test.

Caught by LLVM r328345!

Modified:
clang-tools-extra/trunk/unittests/clangd/TraceTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/TraceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TraceTests.cpp?rev=328354=328353=328354=diff
==
--- clang-tools-extra/trunk/unittests/clangd/TraceTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/TraceTests.cpp Fri Mar 23 12:16:07 
2018
@@ -41,7 +41,7 @@ bool VerifyObject(yaml::Node , std::ma
   }
   bool Match = true;
   SmallString<32> Tmp;
-  for (auto Prop : *M) {
+  for (auto  : *M) {
 auto *K = dyn_cast_or_null(Prop.getKey());
 if (!K)
   continue;


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


r328359 - [AMDGPU] Fix codegen for inline assembly

2018-03-23 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Mar 23 12:43:42 2018
New Revision: 328359

URL: http://llvm.org/viewvc/llvm-project?rev=328359=rev
Log:
[AMDGPU] Fix codegen for inline assembly

Need to override convertConstraint to recognise amdgpu specific register names.

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

Added:
cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl
Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=328359=328358=328359=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Fri Mar 23 12:43:42 2018
@@ -285,6 +285,19 @@ public:
 return true;
   }
 
+  // \p Constraint will be left pointing at the last character of
+  // the constraint.  In practice, it won't be changed unless the
+  // constraint is longer than one character.
+  std::string convertConstraint(const char *) const override {
+const char *Begin = Constraint;
+TargetInfo::ConstraintInfo Info("", "");
+if (validateAsmConstraint(Constraint, Info))
+  return std::string(Begin).substr(0, Constraint - Begin + 1);
+
+Constraint = Begin;
+return std::string(1, *Constraint);
+  }
+
   bool
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=328359=328358=328359=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Mar 23 12:43:42 2018
@@ -1926,7 +1926,7 @@ void CodeGenFunction::EmitAsmStmt(const
 // Simplify the output constraint.
 std::string OutputConstraint(S.getOutputConstraint(i));
 OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1,
-  getTarget());
+  getTarget(), );
 
 const Expr *OutExpr = S.getOutputExpr(i);
 OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());

Added: cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl?rev=328359=auto
==
--- cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl Fri Mar 23 12:43:42 2018
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+
+kernel void test_long(int arg0) {
+  long v15_16;
+  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", 
"={v[15:16]},v"(i32 %arg0)
+  __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : 
"v"(arg0));
+}

Modified: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl?rev=328359=328358=328359=diff
==
--- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl (original)
+++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl Fri Mar 23 12:43:42 2018
@@ -74,3 +74,8 @@ test_double(const __global double *a, co
 
 c[i] = ci;
 }
+
+void test_long(int arg0) {
+  long v15_16;
+  __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : 
"v"(arg0));
+}


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


[PATCH] D44774: [Driver] Allow use of -fsyntax-only together with -MJ

2018-03-23 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

IMO we should explicitly error out. That combination is nonsense to me. 
Creating useless JSON database fragments is not an improvement.


Repository:
  rC Clang

https://reviews.llvm.org/D44774



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


[PATCH] D44747: Set calling convention for CUDA kernel

2018-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 139625.
yaxunl retitled this revision from "[AMDGPU] Set calling convention for CUDA 
kernel" to "Set calling convention for CUDA kernel".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by John's comments. Introduce CC_CUDAKernel calling convention in AST, 
which is translated to target calling convention in IR.


https://reviews.llvm.org/D44747

Files:
  include/clang/Basic/Specifiers.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -626,6 +626,8 @@
   TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_OpenCLKernel: return CXCallingConv_Unexposed;
+case CC_CUDAKernel:
+  return CXCallingConv_Unexposed;
   break;
 }
 #undef TCALLINGCONV
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3316,6 +3316,18 @@
   CallingConv CC = S.Context.getDefaultCallingConvention(FTI.isVariadic,
  IsCXXInstanceMethod);
 
+  // Attribute AT_CUDAGlobal affects the calling convention for AMDGPU targets.
+  // This is the simplest place to infer calling convention for CUDA kernels.
+  if (S.getLangOpts().CUDA && S.getLangOpts().CUDAIsDevice) {
+for (const AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
+ Attr; Attr = Attr->getNext()) {
+  if (Attr->getKind() == AttributeList::AT_CUDAGlobal) {
+CC = CC_CUDAKernel;
+break;
+  }
+}
+  }
+
   // Attribute AT_OpenCLKernel affects the calling convention for SPIR
   // and AMDGPU targets, hence it cannot be treated as a calling
   // convention attribute. This is the simplest place to infer
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1482,6 +1482,15 @@
   Changed = true;
 }
 
+// Drop cuda_kernel calling convention since function pointer can only
+// be used in host code.
+if (getLangOpts().CUDA && FromFPT->getCallConv() == CC_CUDAKernel &&
+FromFPT->getCallConv() != ToFPT->getCallConv()) {
+  FromFn = Context.adjustFunctionType(
+  FromFn, FromEInfo.withCallingConv(ToFPT->getCallConv()));
+  Changed = true;
+}
+
 // Convert FromFPT's ExtParameterInfo if necessary. The conversion is valid
 // only if the ExtParameterInfo lists of the two function prototypes can be
 // merged and the merged list is identical to ToFPT's ExtParameterInfo list.
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -223,6 +223,9 @@
   /// Get LLVM calling convention for OpenCL kernel.
   virtual unsigned getOpenCLKernelCallingConv() const;
 
+  /// Get LLVM calling convention for CUDA kernel.
+  virtual unsigned getCUDAKernelCallingConv() const;
+
   /// Get target specific null pointer.
   /// \param T is the LLVM type of the null pointer.
   /// \param QT is the clang QualType of the null pointer.
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -431,6 +431,10 @@
   return llvm::CallingConv::SPIR_KERNEL;
 }
 
+unsigned TargetCodeGenInfo::getCUDAKernelCallingConv() const {
+  return llvm::CallingConv::C;
+}
+
 llvm::Constant *TargetCodeGenInfo::getNullPointer(const CodeGen::CodeGenModule ,
 llvm::PointerType *T, QualType QT) const {
   return llvm::ConstantPointerNull::get(T);
@@ -7630,6 +7634,7 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;
   unsigned getOpenCLKernelCallingConv() const override;
+  unsigned getCUDAKernelCallingConv() const override;
 
   llvm::Constant *getNullPointer(const CodeGen::CodeGenModule ,
   llvm::PointerType *T, QualType QT) const override;
@@ -7711,6 +7716,10 @@
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
+unsigned AMDGPUTargetCodeGenInfo::getCUDAKernelCallingConv() const {
+  return llvm::CallingConv::AMDGPU_KERNEL;
+}
+
 // Currently LLVM assumes null pointers always have value 0,
 // which results in incorrectly transformed IR. Therefore, instead of
 // emitting null pointers in private and local address spaces, a null
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp

[PATCH] D44837: [CUDA] Fixed false error reporting in case of calling H->G->HD->D.

2018-03-23 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328362: [CUDA] Fixed false error reporting in case of 
calling H-G-HD-D. (authored by tra, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44837?vs=139621=139642#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44837

Files:
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu


Index: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
===
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
@@ -83,3 +83,10 @@
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = _fn;  // Not an error because the template isn't 
instantiated.
 }
+
+// Launching a kernel from a host function does not result in code generation
+// for it, so calling HD function which calls a D function should not trigger
+// errors.
+static __host__ __device__ void hd_func() { device_fn(); }
+__global__ void kernel() { hd_func(); }
+void host_func(void) { kernel<<<1, 1>>>(); }
Index: cfe/trunk/lib/Sema/SemaCUDA.cpp
===
--- cfe/trunk/lib/Sema/SemaCUDA.cpp
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp
@@ -790,9 +790,12 @@
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
   bool CallerKnownEmitted = IsKnownEmitted(*this, Caller);
-  if (CallerKnownEmitted)
-MarkKnownEmitted(*this, Caller, Callee, Loc);
-  else {
+  if (CallerKnownEmitted) {
+// Host-side references to a __global__ function refer to the stub, so the
+// function itself is never emitted and therefore should not be marked.
+if (getLangOpts().CUDAIsDevice || IdentifyCUDATarget(Callee) != CFT_Global)
+  MarkKnownEmitted(*this, Caller, Callee, Loc);
+  } else {
 // If we have
 //   host fn calls kernel fn calls host+device,
 // the HD function does not get instantiated on the host.  We model this by


Index: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
===
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
@@ -83,3 +83,10 @@
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = _fn;  // Not an error because the template isn't instantiated.
 }
+
+// Launching a kernel from a host function does not result in code generation
+// for it, so calling HD function which calls a D function should not trigger
+// errors.
+static __host__ __device__ void hd_func() { device_fn(); }
+__global__ void kernel() { hd_func(); }
+void host_func(void) { kernel<<<1, 1>>>(); }
Index: cfe/trunk/lib/Sema/SemaCUDA.cpp
===
--- cfe/trunk/lib/Sema/SemaCUDA.cpp
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp
@@ -790,9 +790,12 @@
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
   bool CallerKnownEmitted = IsKnownEmitted(*this, Caller);
-  if (CallerKnownEmitted)
-MarkKnownEmitted(*this, Caller, Callee, Loc);
-  else {
+  if (CallerKnownEmitted) {
+// Host-side references to a __global__ function refer to the stub, so the
+// function itself is never emitted and therefore should not be marked.
+if (getLangOpts().CUDAIsDevice || IdentifyCUDATarget(Callee) != CFT_Global)
+  MarkKnownEmitted(*this, Caller, Callee, Loc);
+  } else {
 // If we have
 //   host fn calls kernel fn calls host+device,
 // the HD function does not get instantiated on the host.  We model this by
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44846: [MS] Fix late-parsed template infinite loop in eager instantiation

2018-03-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: rsmith, thakis, hans.

This fixes PR33561 and PR34185.

Don't store pending template instantiations for late-parsed templates in
the normal PendingInstantiations queue. Instead, use a separate list
that will only be parsed and instantiated at end of TU when late
template parsing actually works and doesn't infinite loop.


https://reviews.llvm.org/D44846

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp


Index: clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++14 -verify %s
+
+// pr33561
+class ArrayBuffer;
+template  class Trans_NS_WTF_RefPtr {
+public:
+  ArrayBuffer *operator->() { return nullptr; }
+};
+Trans_NS_WTF_RefPtr get();
+template 
+constexpr void visit(_Visitor __visitor) {
+  __visitor(get()); // expected-note {{in instantiation}}
+}
+class ArrayBuffer {
+  char data() {
+visit([](auto buffer) -> char { // expected-note {{in instantiation}}
+  buffer->data();
+}); // expected-warning {{control reaches end of non-void lambda}}
+  } // expected-warning {{control reaches end of non-void function}}
+};
+
+// pr34185
+template  struct coroutine_handle {
+  Promise () const { return
+*static_cast(nullptr); // expected-warning {{binding 
dereferenced null}}
+  }
+};
+
+template  auto GetCurrenPromise() {
+  struct Awaiter { // expected-note {{in instantiation}}
+void await_suspend(coroutine_handle h) {
+  h.promise(); // expected-note {{in instantiation}}
+}
+  };
+  return Awaiter{};
+}
+
+void foo() {
+  auto & = GetCurrenPromise(); // expected-note {{in instantiation}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3837,8 +3837,8 @@
   if (PatternDecl->isLateTemplateParsed() &&
   !LateTemplateParser) {
 Function->setInstantiationIsPending(true);
-PendingInstantiations.push_back(
-  std::make_pair(Function, PointOfInstantiation));
+LateParsedInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
 return;
   }
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -879,8 +879,20 @@
   PendingInstantiations.insert(PendingInstantiations.begin(),
Pending.begin(), Pending.end());
 }
+
+// Now that we are at the end of the TU and we have the late template
+// parser, transfer late parsed instantiations onto PendingInstantiations.
+PendingInstantiations.insert(PendingInstantiations.end(),
+ LateParsedInstantiations.begin(),
+ LateParsedInstantiations.end());
+LateParsedInstantiations.clear();
+
 PerformPendingInstantiations();
 
+assert(LateParsedInstantiations.empty() &&
+   "end of TU template instantiation should not create more "
+   "late-parsed templates");
+
 if (LateTemplateParserCleanup)
   LateTemplateParserCleanup(OpaqueParser);
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -7550,6 +7550,10 @@
   /// but have not yet been performed.
   std::deque PendingInstantiations;
 
+  /// Queue of implicit template instantiations that cannot be performed
+  /// eagerly.
+  SmallVector LateParsedInstantiations;
+
   class GlobalEagerInstantiationScope {
   public:
 GlobalEagerInstantiationScope(Sema , bool Enabled)


Index: clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++14 -verify %s
+
+// pr33561
+class ArrayBuffer;
+template  class Trans_NS_WTF_RefPtr {
+public:
+  ArrayBuffer *operator->() { return nullptr; }
+};
+Trans_NS_WTF_RefPtr get();
+template 
+constexpr void visit(_Visitor __visitor) {
+  __visitor(get()); // expected-note {{in instantiation}}
+}
+class ArrayBuffer {
+  char data() {
+visit([](auto buffer) -> char { // expected-note {{in instantiation}}
+  buffer->data();
+}); // expected-warning {{control reaches end of non-void lambda}}
+  } // expected-warning {{control reaches end of non-void function}}
+};
+
+// pr34185
+template  struct coroutine_handle {
+  Promise () const { return
+

[PATCH] D44589: [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

2018-03-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 139650.
vsapsai added a comment.

Address review comments:

- update comments for tryParseObjCMethodName, use isValidIdentifier.
- make MultiSourceLocation more lightweight.

I have rebased my patch, so diff between changes can be noisy.


https://reviews.llvm.org/D44589

Files:
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Sema/DelayedDiagnostic.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/DelayedDiagnostic.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
  clang/unittests/Basic/CharInfoTest.cpp

Index: clang/unittests/Basic/CharInfoTest.cpp
===
--- clang/unittests/Basic/CharInfoTest.cpp
+++ clang/unittests/Basic/CharInfoTest.cpp
@@ -432,6 +432,7 @@
   EXPECT_TRUE(isValidIdentifier("z"));
   EXPECT_TRUE(isValidIdentifier("A"));
   EXPECT_TRUE(isValidIdentifier("Z"));
+  EXPECT_TRUE(isValidIdentifier("$", /*AllowDollar=*/true));
 
   // 2 characters, '_' suffix
   EXPECT_FALSE(isValidIdentifier("._"));
@@ -448,6 +449,7 @@
   EXPECT_TRUE(isValidIdentifier("z_"));
   EXPECT_TRUE(isValidIdentifier("A_"));
   EXPECT_TRUE(isValidIdentifier("Z_"));
+  EXPECT_TRUE(isValidIdentifier("$_", /*AllowDollar=*/true));
 
   // 2 characters, '_' prefix
   EXPECT_FALSE(isValidIdentifier("_."));
@@ -464,6 +466,7 @@
   EXPECT_TRUE(isValidIdentifier("_z"));
   EXPECT_TRUE(isValidIdentifier("_A"));
   EXPECT_TRUE(isValidIdentifier("_Z"));
+  EXPECT_TRUE(isValidIdentifier("_$", /*AllowDollar=*/true));
 
   // 3 characters, '__' prefix
   EXPECT_FALSE(isValidIdentifier("__."));
@@ -480,6 +483,7 @@
   EXPECT_TRUE(isValidIdentifier("__z"));
   EXPECT_TRUE(isValidIdentifier("__A"));
   EXPECT_TRUE(isValidIdentifier("__Z"));
+  EXPECT_TRUE(isValidIdentifier("__$", /*AllowDollar=*/true));
 
   // 3 characters, '_' prefix and suffix
   EXPECT_FALSE(isValidIdentifier("_._"));
@@ -496,4 +500,5 @@
   EXPECT_TRUE(isValidIdentifier("_z_"));
   EXPECT_TRUE(isValidIdentifier("_A_"));
   EXPECT_TRUE(isValidIdentifier("_Z_"));
+  EXPECT_TRUE(isValidIdentifier("_$_", /*AllowDollar=*/true));
 }
Index: clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --implicit-check-not fix-it: %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -fixit -x objective-c %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -Werror -x objective-c %t
+
+#if !__has_feature(attribute_deprecated_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+#if !__has_feature(attribute_availability_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+#define DEPRECATED(replacement) __attribute__((deprecated("message", replacement)))
+
+@protocol SuccessfulMultiParameterRenames
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
+- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)varArgs:(int)params, ... DEPRECATED("renameVarArgs:");
+- (void)renameVarArgs:(int)params, ...;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)leadingMinus:(int)param DEPRECATED("-leadingMinusRenamed:");
+- (void)leadingMinusRenamed:(int)param;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)leadingPlus:(int)param DEPRECATED("+leadingPlusRenamed:");
+- (void)leadingPlusRenamed:(int)param;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)sourceEmptyName:(int)param1 :(int)param2 DEPRECATED("renameEmptyName:toNonEmpty:");
+- (void)renameEmptyName:(int)param1 toNonEmpty:(int)param2;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)target:(int)param1 willBecomeEmpty:(int)param2 emptyName:(int)param3 DEPRECATED("target::emptyName:");
+- (void)target:(int)param1 :(int)param2 emptyName:(int)param3;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)extra:(int)param1 whiteSpace:(int)param2 DEPRECATED("renameExtra:whiteSpace:");
+- (void)renameExtra:(int)param1 whiteSpace:(int)param2;
+
+// Test renaming that was producing valid code earlier is still producing valid
+// code. The difference is that now we detect different number of parameters.
+//
+// expected-note@+1 {{has been explicitly marked deprecated 

[PATCH] D44231: [clang-tidy] Check for sizeof that call functions

2018-03-23 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 updated this revision to Diff 139649.

https://reviews.llvm.org/D44231

Files:
  clang-tidy/misc/SizeofExpressionCheck.cpp
  clang-tidy/misc/SizeofExpressionCheck.h
  docs/clang-tidy/checks/misc-sizeof-expression.rst
  test/clang-tidy/misc-sizeof-expression.cpp

Index: test/clang-tidy/misc-sizeof-expression.cpp
===
--- test/clang-tidy/misc-sizeof-expression.cpp
+++ test/clang-tidy/misc-sizeof-expression.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-sizeof-expression %t
+// RUN: %check_clang_tidy %s misc-sizeof-expression %t -- -config="{CheckOptions: [{key: misc-sizeof-expression.WarnOnSizeOfIntegerExpression, value: 1}]}" --
 
 class C {
   int size() { return sizeof(this); }
@@ -14,14 +14,82 @@
 #pragma pack(1)
 struct  S { char a, b, c; };
 
+enum E { E_VALUE = 0 };
+enum class EC { VALUE = 0 };
+
+bool AsBool() { return false; }
+int AsInt() { return 0; }
+E AsEnum() { return E_VALUE; }
+EC AsEnumClass() { return EC::VALUE; }
+S AsStruct() { return {}; }
+
+struct M {
+  int AsInt() { return 0; }
+  E AsEnum() { return E_VALUE; }
+  S AsStruct() { return {}; }
+};
+
+int ReturnOverload(int) { return {}; }
+S ReturnOverload(S) { return {}; }
+
+template 
+T ReturnTemplate(T) { return {}; }
+
+template 
+bool TestTrait1() {
+  return sizeof(ReturnOverload(T{})) == sizeof(A);
+}
+
+template 
+bool TestTrait2() {
+  return sizeof(ReturnTemplate(T{})) == sizeof(A);
+}
+
+template 
+bool TestTrait3() {
+  return sizeof(ReturnOverload(0)) == sizeof(T{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+}
+
+template 
+bool TestTrait4() {
+  return sizeof(ReturnTemplate(0)) == sizeof(T{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+}
+
+bool TestTemplates() {
+  bool b = true;
+  b &= TestTrait1();
+  b &= TestTrait1();
+  b &= TestTrait2();
+  b &= TestTrait2();
+  b &= TestTrait3();
+  b &= TestTrait3();
+  b &= TestTrait4();
+  b &= TestTrait4();
+  return b;
+}
+
 int Test1(const char* ptr) {
   int sum = 0;
   sum += sizeof(LEN);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
   sum += sizeof(LEN + 1);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
   sum += sizeof(sum, LEN);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(..., ...)'
+  sum += sizeof(AsBool());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+  sum += sizeof(AsInt());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+  sum += sizeof(AsEnum());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+  sum += sizeof(AsEnumClass());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+  sum += sizeof(M{}.AsInt());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
+  sum += sizeof(M{}.AsEnum());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
   sum += sizeof(sizeof(X));
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
   sum += sizeof(LEN + sizeof(X));
@@ -171,6 +239,8 @@
   if (sizeof(A) < 10)
 sum += sizeof(A);
   sum += sizeof(int);
+  sum += sizeof(AsStruct());
+  sum += sizeof(M{}.AsStruct());
   sum += sizeof(A[sizeof(A) / sizeof(int)]);
   sum += sizeof([sizeof(A) / sizeof(int)]);
   sum += sizeof(sizeof(0));  // Special case: sizeof size_t.
Index: docs/clang-tidy/checks/misc-sizeof-expression.rst
===
--- docs/clang-tidy/checks/misc-sizeof-expression.rst
+++ docs/clang-tidy/checks/misc-sizeof-expression.rst
@@ -22,6 +22,36 @@
   char buf[BUFLEN];
   memset(buf, 0, sizeof(BUFLEN));  // sizeof(42) ==> sizeof(int)
 
+Suspicious usage of 'sizeof(expr)'
+--
+
+In cases, where there is an enum or integer to represent a type, a common
+mistake is to query the ``sizeof`` on the integer or enum that represents the
+type that should be used by ``sizeof``. This results in the size of the integer
+and not of the type the integer represents:
+
+.. code-block:: c++
+
+  enum data_type {
+FLOAT_TYPE,
+DOUBLE_TYPE
+  };
+
+  struct data {
+data_type type;
+void* buffer;
+data_type get_type() {
+  return type;
+}
+  };
+
+  void f(data d, int numElements) {
+// should be sizeof(float) or sizeof(double), depending on d.get_type()
+int numBytes = numElements * sizeof(d.get_type());
+...
+  }
+
+
 Suspicious usage of 

[PATCH] D44846: [MS] Fix late-parsed template infinite loop in eager instantiation

2018-03-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:855
   // instantiations. PCH files do not.
   if (TUKind != TU_Prefix) {
 DiagnoseUseOfUnimplementedSelectors();

In the TUPrefix case, we'll need to write these instantiations to the PCH file.


https://reviews.llvm.org/D44846



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


r328347 - [AMDGPU] Remove use of OpenCL triple environment and replace with function attribute for AMDGPU (CLANG)

2018-03-23 Thread Tony Tye via cfe-commits
Author: t-tye
Date: Fri Mar 23 11:43:15 2018
New Revision: 328347

URL: http://llvm.org/viewvc/llvm-project?rev=328347=rev
Log:
[AMDGPU] Remove use of OpenCL triple environment and replace with function 
attribute for AMDGPU (CLANG)


- Remove use of the opencl and amdopencl environment member of the target 
triple for the AMDGPU target.
- Use a function attribute to communicate to the AMDGPU backend.

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=328347=328346=328347=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Mar 23 11:43:15 2018
@@ -2180,7 +2180,7 @@ to the target, for example:
.. code-block:: console
 
  $ clang -target nvptx64-unknown-unknown test.cl
- $ clang -target amdgcn-amd-amdhsa-opencl test.cl
+ $ clang -target amdgcn-amd-amdhsa -mcpu=gfx900 test.cl
 
 Compiling to bitcode can be done as follows:
 
@@ -2288,7 +2288,7 @@ There is a set of concrete HW architectu
 
.. code-block:: console
 
- $ clang -target amdgcn-amd-amdhsa-opencl test.cl
+ $ clang -target amdgcn-amd-amdhsa -mcpu=gfx900 test.cl
 
 - For Nvidia architectures:
 

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=328347=328346=328347=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Mar 23 11:43:15 2018
@@ -7661,6 +7661,11 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   const auto *ReqdWGS = M.getLangOpts().OpenCL ?
 FD->getAttr() : nullptr;
+
+  if (M.getLangOpts().OpenCL && FD->hasAttr() &&
+  (M.getTriple().getOS() == llvm::Triple::AMDHSA))
+F->addFnAttr("amdgpu-implicitarg-num-bytes", "32");
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=328347=328346=328347=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Fri Mar 23 11:43:15 2018
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -O0 -emit-llvm -o - %s 
| FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu tahiti -O0 -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -O0 -emit-llvm -o - %s 
| FileCheck %s -check-prefix=NONAMDHSA
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -emit-llvm -verify -o 
- %s | FileCheck -check-prefix=X86 %s
 
 __attribute__((amdgpu_flat_work_group_size(0, 0))) // expected-no-diagnostics
@@ -138,12 +139,18 @@ kernel void reqd_work_group_size_32_2_1_
 // CHECK: define amdgpu_kernel void 
@reqd_work_group_size_32_2_1_flat_work_group_size_16_128() 
[[FLAT_WORK_GROUP_SIZE_16_128:#[0-9]+]]
 }
 
+void a_function() {
+// CHECK: define void @a_function() [[A_FUNCTION:#[0-9]+]]
+}
+
 
 // Make sure this is silently accepted on other targets.
 // X86-NOT: "amdgpu-flat-work-group-size"
 // X86-NOT: "amdgpu-waves-per-eu"
 // X86-NOT: "amdgpu-num-vgpr"
 // X86-NOT: "amdgpu-num-sgpr"
+// X86-NOT: "amdgpu-implicitarg-num-bytes"
+// NONAMDHSA-NOT: "amdgpu-implicitarg-num-bytes"
 
 // CHECK-NOT: "amdgpu-flat-work-group-size"="0,0"
 // CHECK-NOT: "amdgpu-waves-per-eu"="0"
@@ -151,28 +158,30 @@ kernel void reqd_work_group_size_32_2_1_
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-num-vgpr"="64"
-
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone 

r328350 - [AMDGPU] Update OpenCL to use 48 bytes of implicit arguments for AMDGPU (CLANG)

2018-03-23 Thread Tony Tye via cfe-commits
Author: t-tye
Date: Fri Mar 23 11:51:45 2018
New Revision: 328350

URL: http://llvm.org/viewvc/llvm-project?rev=328350=rev
Log:
[AMDGPU] Update OpenCL to use 48 bytes of implicit arguments for AMDGPU (CLANG)

Add two additional implicit arguments for OpenCL for the AMDGPU target using 
the AMDHSA runtime to support device enqueue.

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=328350=328349=328350=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Mar 23 11:51:45 2018
@@ -7664,7 +7664,7 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   if (M.getLangOpts().OpenCL && FD->hasAttr() &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
-F->addFnAttr("amdgpu-implicitarg-num-bytes", "32");
+F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
 
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=328350=328349=328350=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Fri Mar 23 11:51:45 2018
@@ -158,30 +158,30 @@ void a_function() {
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="32" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="32" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="32" "amdgpu-num-vgpr"="64" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48" 
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="32" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="32" "amdgpu-num-vgpr"="64" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="32" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: 

[PATCH] D44844: [PR36880] Avoid -Wunused-lambda-capture false positive for explicit this capture used in an unresolved member in a generic lambda

2018-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: malcolm.parsons, ahatanak, vsapsai.
Herald added a subscriber: jkorous-apple.

Clang emits an incorrect -Wunused-lambda-capture for 'this' capture in a 
generic lambda in a template where 'this' is used implicitly in an unresolved 
member expression. This patch ensures that the use of 'this' is checked as a 
potential lambda capture use when the lambda is instantiated.

rdar://38803903


Repository:
  rC Clang

https://reviews.llvm.org/D44844

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


Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -200,3 +200,21 @@
   auto vla_unused = [] {}; // expected-warning{{lambda capture 'c' is not 
used}}
 }
 } // namespace pr3
+
+namespace pr36880 {
+
+template  struct DummyTemplate {
+  template  void methodTemplate(const T2 &) {}
+
+  void ToTemplate(const int ) {
+[this](const auto ) { methodTemplate(p); }(param); // no warning
+  }
+};
+
+void main() {
+  int i = 0;
+  DummyTemplate dt;
+  dt.ToTemplate(i);
+}
+
+} // namespace pr36880
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -11264,6 +11264,12 @@
   return ExprError();
 BaseType = Base.get()->getType();
   } else {
+// Check an implicit 'this' base expression to ensure that an explicit
+// 'this' capture is marked as 'used'.
+if (Old->isImplicitCXXThisAccess())
+  getSema().CheckCXXThisCapture(Old->getMemberNameInfo().getLoc(),
+/*Explicit=*/false,
+/*BuildAndDiagnose=*/false);
 BaseType = getDerived().TransformType(Old->getBaseType());
   }
 
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -1246,6 +1246,12 @@
   return cast(Base)->isImplicitCXXThis();
 }
 
+bool UnresolvedMemberExpr::isImplicitCXXThisAccess() const {
+  if (!Base)
+return false;
+  return cast(Base)->isImplicitCXXThis();
+}
+
 UnresolvedMemberExpr *UnresolvedMemberExpr::Create(
 const ASTContext , bool HasUnresolvedUsing, Expr *Base, QualType 
BaseType,
 bool IsArrow, SourceLocation OperatorLoc,
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -3505,6 +3505,9 @@
   /// The source location of the operator is invalid in this case.
   bool isImplicitAccess() const;
 
+  /// True if this an implicit access with a 'this' base object.
+  bool isImplicitCXXThisAccess() const;
+
   /// \brief Retrieve the base object of this member expressions,
   /// e.g., the \c x in \c x.m.
   Expr *getBase() {


Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -200,3 +200,21 @@
   auto vla_unused = [] {}; // expected-warning{{lambda capture 'c' is not used}}
 }
 } // namespace pr3
+
+namespace pr36880 {
+
+template  struct DummyTemplate {
+  template  void methodTemplate(const T2 &) {}
+
+  void ToTemplate(const int ) {
+[this](const auto ) { methodTemplate(p); }(param); // no warning
+  }
+};
+
+void main() {
+  int i = 0;
+  DummyTemplate dt;
+  dt.ToTemplate(i);
+}
+
+} // namespace pr36880
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -11264,6 +11264,12 @@
   return ExprError();
 BaseType = Base.get()->getType();
   } else {
+// Check an implicit 'this' base expression to ensure that an explicit
+// 'this' capture is marked as 'used'.
+if (Old->isImplicitCXXThisAccess())
+  getSema().CheckCXXThisCapture(Old->getMemberNameInfo().getLoc(),
+/*Explicit=*/false,
+/*BuildAndDiagnose=*/false);
 BaseType = getDerived().TransformType(Old->getBaseType());
   }
 
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -1246,6 +1246,12 @@
   return cast(Base)->isImplicitCXXThis();
 }
 
+bool UnresolvedMemberExpr::isImplicitCXXThisAccess() const {
+  if (!Base)
+return false;
+  return cast(Base)->isImplicitCXXThis();
+}
+
 UnresolvedMemberExpr *UnresolvedMemberExpr::Create(
 const ASTContext , bool HasUnresolvedUsing, Expr *Base, QualType BaseType,
 bool IsArrow, SourceLocation OperatorLoc,
Index: include/clang/AST/ExprCXX.h

[PATCH] D44589: [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

2018-03-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai marked 2 inline comments as done.
vsapsai added inline comments.



Comment at: clang/include/clang/Basic/SourceLocation.h:202
+/// Can be used transparently in places where SourceLocation is expected.
+class MultiSourceLocation {
+  bool IsSingleLoc;

erik.pilkington wrote:
> Why can't we just use an ArrayRef for this? It looks like 
> that type already has a converting constructor from SourceLocation, so we 
> should be able to use in in DiagnoseUseOfDecl without any noise.
I've tried to go middle way this time and have `MultiSourceLocation` just as 
typedef. I modeled it after `MultiExprArg` which is `using MultiExprArg = 
MutableArrayRef;` But that approach can have different reasons and 
isn't necessarily applicable in this case.

My problem here is that on one hand I think `MultiSourceLocation` might be a 
useful abstraction and in that case probably `Sema::BuildInstanceMessage` 
should use this type for its parameter. On the other hand I am struggling to 
come up with good explanation what `MultiSourceLocation` is. And that's an 
indication it's not a good abstraction. What do you think?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6934-6938
+// Returns a number of method parameters if parsing is successful.
+// In case of unsuccessful parsing SlotNames can contain invalid data.
+static Optional
+parseObjCMethodName(StringRef Name, SmallVectorImpl ,
+const LangOptions ) {

erik.pilkington wrote:
> Maybe tryParseReplacementObjCMethodName or something would be better? 
> parseObjCMethodName() is pretty vague. Also the comment above should probably 
> be a `///` doxygen comment. It would be nice if you mentioned that `Name` 
> originated from an availability attribute in the comment.
I like "try" part. But not sure about "Replacement". This function doesn't care 
how its output will be used so I don't think it is worth mentioning.

I've updated comment for `Name` but not entirely satisfied with the wording. 
Will try to come up with something better and suggestions are welcome.


https://reviews.llvm.org/D44589



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


[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-03-23 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 139646.
zinovy.nis added a comment.

- Rebased.
- Added 1 more test for namespaced base clases
- Fixed minor issues.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ParentVirtualCallCheck.cpp
  clang-tidy/bugprone/ParentVirtualCallCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-parent-virtual-call.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-parent-virtual-call.cpp

Index: test/clang-tidy/bugprone-parent-virtual-call.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-parent-virtual-call.cpp
@@ -0,0 +1,177 @@
+// RUN: %check_clang_tidy %s bugprone-parent-virtual-call %t
+
+extern int foo();
+
+class A {
+public:
+  A() = default;
+  virtual ~A() = default;
+
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+
+  int non_virt() { return foo() + 3; }
+  static int stat() { return foo() + 4; }
+};
+
+class B : public A {
+public:
+  B() = default;
+
+  // Nothing to fix: calls to direct parent.
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+
+class C : public B {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'B' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'B' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_2() override { return B::virt_1() + B::virt_1(); }
+
+  // Test that non-virtual and static methods are not affected by this cherker.
+  int method_c() { return A::stat() + A::non_virt(); }
+};
+
+// Check aliased type names
+using A1 = A;
+typedef A A2;
+
+class C2 : public B {
+public:
+  int virt_1() override { return A1::virt_1() + A2::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'B' [bugprone-parent-virtual-call]
+  // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'B' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1(); }
+};
+
+// Test that the check affects grand-grand..-parent calls too.
+class D : public C {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'C' [bugprone-parent-virtual-call]
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' refers to a member which was overridden in subclass 'C' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'C' [bugprone-parent-virtual-call]
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' refers to a member which was overridden in subclass 'C' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_2() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+};
+
+// Test classes in namespaces.
+namespace {
+class BN : public A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace
+
+namespace N1 {
+class A {
+public:
+  A() = default;
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+};
+} // namespace N1
+
+namespace N2 {
+class BN : public N1::A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace N2
+
+class CN : public BN {
+public:
+  int virt_1() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'BN' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return BN::virt_1() + BN::virt_1(); }
+  int virt_2() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member which was overridden in subclass 'BN' [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_2() override { return BN::virt_1() + BN::virt_1(); }
+};
+

[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri planned changes to this revision.
lebedev.ri added a comment.

Ok then :)
Let's only count the variables in the function itself, not in macros/nested 
functions/nested lambdas/nested classes/...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-03-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 139644.
juliehockett added a comment.

Rebasing and updating.


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Reducer.cpp
  clang-doc/Reducer.h
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/bc-comment.cpp
  test/clang-doc/bc-namespace.cpp
  test/clang-doc/bc-record.cpp

Index: test/clang-doc/bc-record.cpp
===
--- /dev/null
+++ test/clang-doc/bc-record.cpp
@@ -0,0 +1,178 @@
+// This test requires Linux due to the system-dependent USR for the
+// inner class in function H.
+// REQUIRES: system-linux
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/docs.bc --dump | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+enum class Bc { A, B };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+class X {
+  class Y {};
+};
+
+void H() {
+  class I {};
+}
+
+// CHECK: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'E'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '~E'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'ProtectedMethod'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'H'
+  // CHECK-NEXT:  blob data = '3433664532ABFCC39301646A10E768C1882BF194'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'A'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'A::X'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'A::Y'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'C'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'C::i'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'D'
+  // CHECK-NEXT:  blob data = 'E3B54702FABFF4037025BA194FC27C47006330B5'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'E'
+  // CHECK-NEXT:  blob data = 'E3B54702FABFF4037025BA194FC27C47006330B5'
+  // CHECK-NEXT:  blob data = 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+  // CHECK-NEXT:  blob data = 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+  // CHECK-NEXT:  blob data = 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+  // CHECK-NEXT:  blob data = 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+  // CHECK-NEXT:  blob data = '5093D428CDC62096A67547BA52566E4FB9404EEE'
+  // CHECK-NEXT:  blob data = '5093D428CDC62096A67547BA52566E4FB9404EEE'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'F'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT:  blob data = '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'X'
+  // CHECK-NEXT:  blob data = '641AB4A3D36399954ACDE29C7A8833032BF40472'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // 

[PATCH] D44844: [PR36880] Avoid -Wunused-lambda-capture false positive for explicit this capture used in an unresolved member in a generic lambda

2018-03-23 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Sema/TreeTransform.h:11269
+// 'this' capture is marked as 'used'.
+if (Old->isImplicitCXXThisAccess())
+  getSema().CheckCXXThisCapture(Old->getMemberNameInfo().getLoc(),

This doesn't make sense; in general, you can't tell whether an 
UnresolvedMemberExpr requires a "this" capture.

```
template class C : T {
static int f(int);
int f(double);
public:
int g() {
  return []{ return f(T::x); }();
}
};

struct A { static int x; };
void x(C c) { c.g(); }
```


Repository:
  rC Clang

https://reviews.llvm.org/D44844



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


[PATCH] D44801: Add the -fsanitize=shadow-call-stack flag

2018-03-23 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 139652.
vlad.tsyrklevich marked 6 inline comments as done.
vlad.tsyrklevich added a comment.

- Address Kostya's documentation feedback


Repository:
  rC Clang

https://reviews.llvm.org/D44801

Files:
  docs/ShadowCallStack.rst
  docs/index.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/shadowcallstack-attr.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -557,6 +557,21 @@
 // CHECK-SAFESTACK-LINUX: "-lpthread"
 // CHECK-SAFESTACK-LINUX: "-ldl"
 
+// RUN: %clang -fsanitize=shadow-call-stack %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-X86-64 %s
+// CHECK-SHADOWCALLSTACK-LINUX-X86-64-NOT: error:
+
+// RUN: %clang -fsanitize=shadow-call-stack %s -### -o %t.o 2>&1 \
+// RUN: -target x86-unknown-linux -fuse-ld=ld \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-X86 %s
+// CHECK-SHADOWCALLSTACK-LINUX-X86: error: unsupported option '-fsanitize=shadow-call-stack' for target 'x86-unknown-linux'
+
+// RUN: %clang -fsanitize=shadow-call-stack %s -### -o %t.o 2>&1 \
+// RUN: -fsanitize=safe-stack -target x86_64-unknown-linux -fuse-ld=ld \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-SAFESTACK %s
+// CHECK-SHADOWCALLSTACK-SAFESTACK: error: invalid argument '-fsanitize=shadow-call-stack' not allowed with '-fsanitize=safe-stack'
+
 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/CodeGen/shadowcallstack-attr.c
===
--- /dev/null
+++ test/CodeGen/shadowcallstack-attr.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-linux-unknown -emit-llvm -o - %s -fsanitize=shadow-call-stack | FileCheck %s
+
+__attribute__((no_sanitize("shadow-call-stack")))
+int foo(int *a) { return *a; }
+
+ int bar(int *a) { return *a; }
+
+// CHECK: define i32 @foo(i32* %a) #[[FOO_ATTR:[0-9]+]] {
+// CHECK: define i32 @bar(i32* %a) #[[BAR_ATTR:[0-9]+]] {
+
+// CHECK-NOT: attributes #[[FOO_ATTR]] = { {{.*}}shadowcallstack{{.*}} }
+// CHECK: attributes #[[BAR_ATTR]] = { {{.*}}shadowcallstack{{.*}} }
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1275,6 +1275,8 @@
   .Case("is_union", LangOpts.CPlusPlus)
   .Case("modules", LangOpts.Modules)
   .Case("safe_stack", LangOpts.Sanitize.has(SanitizerKind::SafeStack))
+  .Case("shadow_call_stack",
+LangOpts.Sanitize.has(SanitizerKind::ShadowCallStack))
   .Case("tls", PP.getTargetInfo().isTLSSupported())
   .Case("underlying_type", LangOpts.CPlusPlus)
   .Default(false);
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -814,6 +814,8 @@
   getTriple().getArch() == llvm::Triple::wasm32 ||
   getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
+  if (getTriple().getArch() == llvm::Triple::x86_64)
+Res |= ShadowCallStack;
   return Res;
 }
 
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -343,7 +343,10 @@
   std::make_pair(Scudo, Address | HWAddress | Leak | Thread | Memory |
 KernelAddress | Efficiency),
   std::make_pair(SafeStack, Address | HWAddress | Leak | Thread | Memory |
-KernelAddress | Efficiency)};
+KernelAddress | Efficiency),
+  std::make_pair(ShadowCallStack, Address | HWAddress | Leak | Thread |
+  Memory | KernelAddress | Efficiency |
+  SafeStack)};
 
   // Enable toolchain specific default sanitizers if not explicitly disabled.
   SanitizerMask Default = TC.getDefaultSanitizers() & ~AllRemove;
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -861,6 +861,8 @@
 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
+  if (SanOpts.has(SanitizerKind::ShadowCallStack))
+Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
 
   // Ignore TSan memory acesses from 

[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

My opinion matters less than @rsmith or @dblaikie on the review, but it seems 
to me that Typedef and Using are SO similar that the implementations should 
just be combined.  You'd likely have to change a couple of types along the way 
to be more generic, but the implementations are essentially a copy/paste of 
eachother.


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:68
+- New :doc:`bugprone-exception-escape
+  
` 
check
+

Please fix link. See other checks as example.


https://reviews.llvm.org/D33537



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-23 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 139583.
baloghadamsoftware added a comment.

Moved to bugprone.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/bugprone/ExceptionEscapeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-exception-escape.rst
  test/clang-tidy/bugprone-exception-escape.cpp

Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -0,0 +1,256 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: bugprone-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: bugprone-exception-escape.EnabledFunctions, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  if (n) throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+if (n) throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1; 
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' throws
+  

[PATCH] D44790: [clang-format] Fix ObjC style guesser to also iterate over child lines

2018-03-23 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: cfe/trunk/lib/Format/Format.cpp:1544
+return true;
+  for (auto ChildLine : Line->Children) {
+if (LineContainsObjCCode(*ChildLine))

Sorry that I missed this in the original review. But doesn't this still fail 
for Children of Child lines, etc.? I think this probably needs to be fully 
recursive.


Repository:
  rL LLVM

https://reviews.llvm.org/D44790



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/checks/misc-exception-escape.rst:1
+.. title:: clang-tidy - bugprone-exception-escape
+

This file should be renamed as well.


https://reviews.llvm.org/D33537



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


[PATCH] D33440: clang-format: better handle statement macros

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: lib/Format/Format.cpp:647-648
   LLVMStyle.SortUsingDeclarations = true;
+  LLVMStyle.StatementMacros.push_back("Q_UNUSED");
+  LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
 

What's the reason to have these in the LLVM style? The macros aren't used in 
LLVM code.



Comment at: unittests/Format/FormatTest.cpp:2424
+
+  // Some macros contain an implicit semicolon
+  FormatStyle Style = getLLVMStyle();

nit: Add a trailing period.


https://reviews.llvm.org/D33440



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso created this revision.
CarlosAlbertoEnciso added reviewers: rsmith, erichkeane, probinson, dblaikie.
CarlosAlbertoEnciso added a project: clang.
Herald added subscribers: cfe-commits, JDevlieghere, aprantl.

Add -Wunused-using, a warning that finds unused using declarations.
Also added an alias -Wunused-usings.

This patch uses a similar approach as the work done for the typedefs
as discussed in:

https://reviews.llvm.org/rC217298

It uses the 'used' and 'referenced' available bits for the declarations.

As consequence of a previous work on Debug Information done by:

https://reviews.llvm.org/D6173

The size of the Debug Information increased by a considerable factor,
as discussed in:

http://clang-developers.42468.n3.nabble.com/r20-causes-real-debug-info-bloat-td4045257.html

For the below test:

  namespace nsp {
void foo();
  }
  
  using foo;

A debug information entries are generated for the namespace
and for the using declaration.

In order to reduce the debug information for those specific cases,
the work is divided in 2 parts:

- Emit a warning for the unused using
- Do not generate debug information for the unused using

The current patch deals with the first part and it covers global
and local detection of unused using declarations.

For the below test, I have marked the generated warnings

  namespace nsp {
void foo();
int var;
  }
  
  using foo; <-- warning
  using var; <-- warning  
  
  void bar() {
using foo; <-- warning
using var; <-- warning
  }

However, there is a specific case, where an unused using
escapes the warning.

Adding the following function 'bar'

  void bar() {
nsp::var = 1;
  }

it causes the warning to the global unused 'using var'
not being issued, as the assignment sets the 'used' bit,
despite of using the qualified 'var'.

  namespace nsp {
void foo();
int var;
  }using var
  
  using foo; <-- warning
  using var; <-- MISSING warning  
  
  void bar() {
using foo; <-- warning
using var; <-- warning
  }
  
  void bar() {
nsp::var = 1;
  }

Thanks for your view on this issue and on the general approach.


Repository:
  rC Clang

https://reviews.llvm.org/D44826

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ExternalSemaSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/FixIt/fixit.cpp
  test/Modules/Inputs/module.map
  test/Modules/Inputs/warn-unused-using.h
  test/Modules/warn-unused-using.cpp
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/warn-unused-using-serialize.cpp
  test/SemaCXX/warn-unused-using.cpp

Index: test/SemaCXX/warn-unused-using.cpp
===
--- test/SemaCXX/warn-unused-using.cpp
+++ test/SemaCXX/warn-unused-using.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-using -verify -std=c++1y %s
+
+namespace nsp {
+  void Print();
+  int var;
+  typedef int INT;
+  typedef char CHAR;
+  typedef float FLOAT;
+}
+
+using nsp::Print; // expected-warning {{unused using 'Print'}}
+using nsp::var; // expected-warning {{unused using 'var'}}
+
+void Foo() {
+  using nsp::Print; // expected-warning {{unused using 'Print'}}
+  {
+using nsp::var; // expected-warning {{unused using 'var'}}
+{
+  using nsp::INT; // expected-warning {{unused using 'INT'}}
+  using nsp::FLOAT; // expected-warning {{unused using 'FLOAT'}}
+}
+  }
+}
+
+void Bar() {
+  using nsp::FLOAT; // no diag
+  FLOAT f;
+  f = 2.0;
+}
+
+struct A {
+  virtual void Foo(double x) const;
+};
+struct B : A {
+  using A::Foo;  // expected-warning {{unused using 'Foo'}}
+  virtual void Foo(double x) const;
+};
+
+void one() {
+  B b;
+  b.Foo(1.0);
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-using"
+using nsp::CHAR; // no diag
+#pragma clang diagnostic pop
+
+using nsp::CHAR;  // expected-warning {{unused using 'CHAR'}}
Index: test/SemaCXX/warn-unused-using-serialize.cpp
===
--- test/SemaCXX/warn-unused-using-serialize.cpp
+++ test/SemaCXX/warn-unused-using-serialize.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang -x c++-header -c -Wunused-using %s -o %t.gch -Werror
+// RUN: %clang -DBE_THE_SOURCE -c -Wunused-using -include %t %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -DBE_THE_SOURCE -c -Wunused-using -include %t %s -o /dev/null 2>&1 | FileCheck %s
+
+#ifndef BE_THE_SOURCE
+namespace nsp {
+  typedef int INT;
+}
+//inline void foo() {
+// The warning should fire every time the pch file is used, not when it's built.
+// CHECK: warning: unused using 'INT'

[PATCH] D44790: [clang-format] Fix ObjC style guesser to also iterate over child lines

2018-03-23 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: cfe/trunk/lib/Format/Format.cpp:1544
+return true;
+  for (auto ChildLine : Line->Children) {
+if (LineContainsObjCCode(*ChildLine))

djasper wrote:
> Sorry that I missed this in the original review. But doesn't this still fail 
> for Children of Child lines, etc.? I think this probably needs to be fully 
> recursive.
Oh, of course. I'll send a follow-up.


Repository:
  rL LLVM

https://reviews.llvm.org/D44790



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


[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-23 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 10 inline comments as done.
simark added inline comments.



Comment at: clangd/DraftStore.cpp:75
+  return llvm::make_error(
+  llvm::formatv("Range's end position (line={0}, character={1}) is "
+"before start position (line={2}, character={3}).",

ilya-biryukov wrote:
> Could we add a format provide for `Position` to make this formatting code 
> shorter?
> We'll need to define the corresponding specialization in `Protocol.h`:
> 
> ```
> namespace llvm {
>   template <>
>   struct format_provider {
> static void format(const clang::clangd::Position , raw_ostream , 
> StringRef Style) { 
>  assert(Style.empty() && "style modifiers for this type are not 
> supported");
>  OS << Pos;
> }
>   };
> }
> ```
> 
> This will allow to simplify this call site to:
> ```
> llvm::formatv("Range's end position ({0}) is before start position ({1})", 
> End, Start)
> ```
Good idea, this is good for printing them in a consistent way too.



Comment at: clangd/DraftStore.cpp:100
+  EntryIt->second = Contents;
+  return std::move(Contents);
+}

ilya-biryukov wrote:
> Doing `return std::move(localvar)` is a pessimization. Use `return Contents;` 
> instead.
>  (for reference see 
> [[https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value|this
>  SO post]], clang should give a warning for that case too)
Thanks, good catch.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44272



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


[PATCH] D44778: [clang-format] Wildcard expansion on Windows.

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I've not tested this on Windows, but I hope 
llvm::sys::Process::GetArgumentVector should have been tested by someone 
already.


Repository:
  rC Clang

https://reviews.llvm.org/D44778



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


[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-23 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 139596.
simark marked 2 inline comments as done.
simark added a comment.

Address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44272

Files:
  clangd/ClangdLSPServer.cpp
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/textdocument-didchange-fail.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/DraftStoreTests.cpp

Index: unittests/clangd/DraftStoreTests.cpp
===
--- /dev/null
+++ unittests/clangd/DraftStoreTests.cpp
@@ -0,0 +1,352 @@
+//===-- DraftStoreTests.cpp - Clangd unit tests -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "DraftStore.h"
+#include "SourceCode.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using namespace llvm;
+
+struct IncrementalTestStep {
+  StringRef Src;
+  StringRef Contents;
+};
+
+int rangeLength(StringRef Code, const Range ) {
+  llvm::Expected Start = positionToOffset(Code, Rng.start);
+  llvm::Expected End = positionToOffset(Code, Rng.end);
+  assert(Start);
+  assert(End);
+  return *End - *Start;
+}
+
+/// Send the changes one by one to updateDraft, verify the intermediate results.
+void stepByStep(llvm::ArrayRef Steps) {
+  DraftStore DS;
+  Annotations InitialSrc(Steps.front().Src);
+  constexpr StringLiteral Path("/hello.cpp");
+
+  // Set the initial content.
+  DS.addDraft(Path, InitialSrc.code());
+
+  for (size_t i = 1; i < Steps.size(); i++) {
+Annotations SrcBefore(Steps[i - 1].Src);
+Annotations SrcAfter(Steps[i].Src);
+StringRef Contents = Steps[i - 1].Contents;
+TextDocumentContentChangeEvent Event{
+SrcBefore.range(),
+rangeLength(SrcBefore.code(), SrcBefore.range()),
+Contents.str(),
+};
+
+llvm::Expected Result = DS.updateDraft(Path, {Event});
+ASSERT_TRUE(!!Result);
+EXPECT_EQ(*Result, SrcAfter.code());
+EXPECT_EQ(*DS.getDraft(Path), SrcAfter.code());
+  }
+}
+
+/// Send all the changes at once to updateDraft, check only the final result.
+void allAtOnce(llvm::ArrayRef Steps) {
+  DraftStore DS;
+  Annotations InitialSrc(Steps.front().Src);
+  Annotations FinalSrc(Steps.back().Src);
+  constexpr StringLiteral Path("/hello.cpp");
+  std::vector Changes;
+
+  for (size_t i = 0; i < Steps.size() - 1; i++) {
+Annotations Src(Steps[i].Src);
+StringRef Contents = Steps[i].Contents;
+
+Changes.push_back({
+Src.range(),
+rangeLength(Src.code(), Src.range()),
+Contents.str(),
+});
+  }
+
+  // Set the initial content.
+  DS.addDraft(Path, InitialSrc.code());
+
+  llvm::Expected Result = DS.updateDraft(Path, Changes);
+
+  ASSERT_TRUE(!!Result) << llvm::toString(Result.takeError());
+  EXPECT_EQ(*Result, FinalSrc.code());
+  EXPECT_EQ(*DS.getDraft(Path), FinalSrc.code());
+}
+
+TEST(DraftStoreIncrementalUpdateTest, Simple) {
+  // clang-format off
+  IncrementalTestStep Steps[] =
+{
+  // Replace a range
+  {
+R"cpp(static int
+hello[[World]]()
+{})cpp",
+"Universe"
+  },
+  // Delete a range
+  {
+R"cpp(static int
+hello[[Universe]]()
+{})cpp",
+""
+  },
+  // Add a range
+  {
+R"cpp(static int
+hello[[]]()
+{})cpp",
+"Monde"
+  },
+  {
+R"cpp(static int
+helloMonde()
+{})cpp",
+""
+  }
+};
+  // clang-format on
+
+  stepByStep(Steps);
+  allAtOnce(Steps);
+}
+
+TEST(DraftStoreIncrementalUpdateTest, MultiLine) {
+  // clang-format off
+  IncrementalTestStep Steps[] =
+{
+  // Replace a range
+  {
+R"cpp(static [[int
+helloWorld]]()
+{})cpp",
+R"cpp(char
+welcome)cpp"
+  },
+  // Delete a range
+  {
+R"cpp(static char[[
+welcome]]()
+{})cpp",
+""
+  },
+  // Add a range
+  {
+R"cpp(static char[[]]()
+{})cpp",
+R"cpp(
+cookies)cpp"
+  },
+  // Replace the whole file
+  {
+R"cpp([[static char
+cookies()
+{}]])cpp",
+R"cpp(#include 
+)cpp"
+  },
+  // Delete the whole file
+  {
+R"cpp([[#include 
+]])cpp",
+"",
+  },
+  // Add something to an empty file
+  {
+"[[]]",
+R"cpp(int main() {
+)cpp",
+  },
+  {
+R"cpp(int main() {
+)cpp",
+""
+  }
+};
+  // clang-format on
+
+  stepByStep(Steps);
+  allAtOnce(Steps);
+}
+
+TEST(DraftStoreIncrementalUpdateTest, WrongRangeLength) {
+  DraftStore DS;
+  Path File = "foo.cpp";
+
+  DS.addDraft(File, "int main() {}\n");
+
+  TextDocumentContentChangeEvent Change;
+  

[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm not familiar with clang-format internals, sorry if questions are dumb.

My first inclination is that doing something reasonable for incomplete inputs 
makes sense, but it doesn't seem to be worth spending complexity on things that 
are actually intended to not be protos - people should just not use R"pb in 
this case.

I recall you had a reason for wanting to try this out anyway though, but I 
can't remember what it is. (Can you add it to the description?)




Comment at: lib/Format/TokenAnnotator.cpp:665
   }
+  if ((Style.Language == FormatStyle::LK_Proto ||
+   Style.Language == FormatStyle::LK_TextProto) &&

I don't really understand what this is doing.
It seems to be detecting some particular sequence of invalid tokens 
`}:`,`]:`,`>:`. Why are these special? 

What's the contract of consumeToken()? It's hard to see from the callsites.



Comment at: lib/Format/TokenAnnotator.cpp:773
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)

In what sense of "line" is this true?


Repository:
  rC Clang

https://reviews.llvm.org/D44203



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:24-25
+
+const TypeVec _throws(const FunctionDecl *Func);
+const TypeVec _throws(const Stmt *St, const TypeVec );
+} // namespace

Function names should follow llvm conventions 
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:24-25
+
+const TypeVec _throws(const FunctionDecl *Func);
+const TypeVec _throws(const Stmt *St, const TypeVec );
+} // namespace

alexfh wrote:
> Function names should follow llvm conventions 
> http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
If there's no need to pass nullptr to these functions, the arguments can be 
const references.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:115
+return Result;
+  } else {
+TypeVec Result;

No `else` after `return`.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:142
+  if (const auto *TD = ThrownType->getAsTagDecl()) {
+if (TD->getNameAsString() == "bad_alloc")
+  return Results;

Don't use getNameAsString when not necessary. `if 
(TD->getDeclName().isIdentifier() && TD->getName() == "bad_alloc")` will work 
as good, but without unnecessary string copies.


https://reviews.llvm.org/D33537



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


[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/checks/bugprone-parent-virtual-call.rst:26
+  int foo() override {... A::foo()...}
+   warning: qualified name A::foo refers to a
+member which was overridden in 

The formatting looks weird. Could you move `warning: .*` to the start of the 
next line and put the whole message on the same line?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/readability/UnnecessaryIntermediateVarCheck.cpp:28
+  auto File = Context->getCurrentFile();
+  auto Style = format::getStyle(*Context->getOptionsForFile(File).FormatStyle,
+File, "none");

I've just noticed this use of format::getStyle. The problem is that it will use 
the real file system, which is completely wrong for some clang-tidy use cases. 
I guess, we'll either have to roll this back to use a check option or create 
some way for checks to get the formatting style that can be implemented 
correctly by the client, when clang-tidy is used as a library.

I suggest going back to the option and leave a FIXME to investigate the other 
possibility.


https://reviews.llvm.org/D37014



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


[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-23 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 139601.
benhamilton added a comment.

Update from correct base revision


Repository:
  rC Clang

https://reviews.llvm.org/D44831

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,6 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
@@ -1538,13 +1539,18 @@
   }
   return false;
 };
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
+llvm::DenseSet LinesToCheckSet;
+LinesToCheckSet.reserve(AnnotatedLines.size());
+LinesToCheckSet.insert(AnnotatedLines.begin(), AnnotatedLines.end());
+while (!LinesToCheckSet.empty()) {
+  const auto NextLineIter = LinesToCheckSet.begin();
+  const auto NextLine = *NextLineIter;
+  if (LineContainsObjCCode(*NextLine))
 return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
-  return true;
-  }
+  LinesToCheckSet.erase(NextLineIter);
+  LinesToCheckSet.reserve(NextLine->Children.size());
+  LinesToCheckSet.insert(NextLine->Children.begin(),
+ NextLine->Children.end());
 }
 return false;
   }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,6 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
@@ -1538,13 +1539,18 @@
   }
   return false;
 };
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
+llvm::DenseSet LinesToCheckSet;
+LinesToCheckSet.reserve(AnnotatedLines.size());
+LinesToCheckSet.insert(AnnotatedLines.begin(), AnnotatedLines.end());
+while (!LinesToCheckSet.empty()) {
+  const auto NextLineIter = LinesToCheckSet.begin();
+  const auto NextLine = *NextLineIter;
+  if (LineContainsObjCCode(*NextLine))
 return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
-  return true;
-  }
+  LinesToCheckSet.erase(NextLineIter);
+  LinesToCheckSet.reserve(NextLine->Children.size());
+  LinesToCheckSet.insert(NextLine->Children.begin(),
+ NextLine->Children.end());
 }
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44533: [AMDGPU] Fix codegen for inline assembly

2018-03-23 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D44533



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


[PATCH] D44778: [clang-format] Wildcard expansion on Windows.

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 139593.
alexfh added a comment.

- Use llvm::sys::Process::GetArgumentVector.


Repository:
  rC Clang

https://reviews.llvm.org/D44778

Files:
  tools/clang-format/ClangFormat.cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 
 using namespace llvm;
@@ -339,11 +340,19 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
+  SmallVector Args;
+  llvm::SpecificBumpPtrAllocator ArgAllocator;
+  std::error_code EC = llvm::sys::Process::GetArgumentVector(
+  Args, llvm::makeArrayRef(argv, argc), ArgAllocator);
+  if (EC) {
+llvm::errs() << "error: couldn'g get arguments: " << EC.message() << '\n';
+  }
+
   cl::HideUnrelatedOptions(ClangFormatCategory);
 
   cl::SetVersionPrinter(PrintVersion);
   cl::ParseCommandLineOptions(
-  argc, argv,
+  Args.size(), [0],
   "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n"
   "If no arguments are specified, it formats the code from standard 
input\n"
   "and writes the result to the standard output.\n"


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 
 using namespace llvm;
@@ -339,11 +340,19 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
+  SmallVector Args;
+  llvm::SpecificBumpPtrAllocator ArgAllocator;
+  std::error_code EC = llvm::sys::Process::GetArgumentVector(
+  Args, llvm::makeArrayRef(argv, argc), ArgAllocator);
+  if (EC) {
+llvm::errs() << "error: couldn'g get arguments: " << EC.message() << '\n';
+  }
+
   cl::HideUnrelatedOptions(ClangFormatCategory);
 
   cl::SetVersionPrinter(PrintVersion);
   cl::ParseCommandLineOptions(
-  argc, argv,
+  Args.size(), [0],
   "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n"
   "If no arguments are specified, it formats the code from standard input\n"
   "and writes the result to the standard output.\n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44764: [clangd] Move GTest printers to separate file

2018-03-23 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 139598.
malaperle added a comment.

Use a header for common inclusions for tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44764

Files:
  unittests/clangd/ClangdTesting.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/CodeCompletionStringsTests.cpp
  unittests/clangd/ContextTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/FuzzyMatchTests.cpp
  unittests/clangd/HeadersTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/JSONExprTests.cpp
  unittests/clangd/Matchers.h
  unittests/clangd/Printers.h
  unittests/clangd/SourceCodeTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/ThreadingTests.cpp
  unittests/clangd/TraceTests.cpp
  unittests/clangd/URITests.cpp
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -7,32 +7,21 @@
 //
 //===--===//
 #include "Annotations.h"
+#include "ClangdTesting.h"
 #include "ClangdUnit.h"
 #include "Compiler.h"
-#include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "XRefs.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
 #include "llvm/Support/Path.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
 using namespace llvm;
 
-void PrintTo(const DocumentHighlight , std::ostream *O) {
-  llvm::raw_os_ostream OS(*O);
-  OS << V.range;
-  if (V.kind == DocumentHighlightKind::Read)
-OS << "(r)";
-  if (V.kind == DocumentHighlightKind::Write)
-OS << "(w)";
-}
-
 namespace {
 using testing::ElementsAre;
 using testing::Field;
Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -7,10 +7,9 @@
 //
 //===--===//
 
+#include "ClangdTesting.h"
 #include "TestFS.h"
 #include "URI.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
Index: unittests/clangd/TraceTests.cpp
===
--- unittests/clangd/TraceTests.cpp
+++ unittests/clangd/TraceTests.cpp
@@ -7,15 +7,14 @@
 //
 //===--===//
 
+#include "ClangdTesting.h"
 #include "Trace.h"
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/YAMLParser.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
Index: unittests/clangd/ThreadingTests.cpp
===
--- unittests/clangd/ThreadingTests.cpp
+++ unittests/clangd/ThreadingTests.cpp
@@ -7,8 +7,8 @@
 //
 //===--===//
 
+#include "ClangdTesting.h"
 #include "Threading.h"
-#include "gtest/gtest.h"
 #include 
 
 namespace clang {
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -7,8 +7,8 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "ClangdTesting.h"
 #include "llvm/Support/Errc.h"
-#include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -7,11 +7,10 @@
 //
 //===--===//
 
+#include "ClangdTesting.h"
 #include "Context.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 #include 
 #include 
 
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdTesting.h"
 #include "TestFS.h"
 #include "index/SymbolCollector.h"
 #include "index/SymbolYAML.h"
@@ -21,8 +22,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "gmock/gmock.h"
-#include 

[PATCH] D44764: [clangd] Use a header for common inclusions for tests

2018-03-23 Thread Simon Marchi via Phabricator via cfe-commits
simark accepted this revision.
simark added inline comments.



Comment at: unittests/clangd/Printers.h:12
+// objects on failure. Otherwise, it is possible that there will be two
+// different instantiations of the printer template for a given type and some
+// tests could end up calling the wrong (default) one.

To be more precise, I think it's linker keeping only one of the two versions, 
so it's _all_ tests, not some, that may end up calling the wrong (default) one.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44764



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


[PATCH] D44764: [clangd] Use a header for common inclusions for tests

2018-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D44764#1045992, @malaperle wrote:

> In https://reviews.llvm.org/D44764#1045682, @ilya-biryukov wrote:
>
> > In https://reviews.llvm.org/D44764#1045648, @simark wrote:
> >
> > > We could create a file `ClangdTesting.h" which includes everything tested 
> > > related (gtest, gmock, printers, syncapi, etc). The convention would be 
> > > that test files would just include that.
> >
> >
> > Yeah, sounds good. I would exclude syncapi from the list, though. Not all 
> > tests should necessarily depend on `ClangdServer`.
> >  @sammccall , @ioeric , @hokein, @bkramer are you on board with the idea to 
> > have an umbrella header for gtest+gmock+printers?
>
>
> Sounds good to me too. I can update the patch once there is an agreement.


(Sorry, have been OOO)
I understand the template instantiations here are a mess and we need to solve 
the problem. However I'm not sure this is the right direction:

- it violates IWYU, and we expect people consistently to get gmock transitively 
via this header. This goes against common practice, is inconsistent with the 
rest of LLVM, and confuses tools (including clangd itself!). It would need to 
be carefully documented, but I don't think this is enough.
- it's fragile - as soon as one test includes gmock directly we have this 
problem again
- `printers.h` takes a horizontal slice of the types we have - it seems to 
suffer from the same problem as "not all tests should depend on clangdserver".

I'd suggest instead:

- where there's a fairly nice general-purpose debugging representation of a 
type, we should name that `operator<<` and declare it in the header alongside 
the type. That way it's clear that it's available, there's no risk of ODR 
violation, and it can be used for debugging as well as by gtest.
  - where there isn't one (or it's insufficiently detailed), we should use 
something more primitive like `EXPECT_THAT(foo, ...) << dump(foo)` with `dump` 
defined locally in the cpp file. We can't share these, but these aren't really 
sharable anyway. This isn't ideal (nested matcher messages) but should be good 
enough in practice.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44764



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


[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-03-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:62
 
 - New `bugprone-throw-keyword-missing
   
`_
 check

Please rebase from trunk and use //:doc:// for link.



Comment at: docs/ReleaseNotes.rst:82
+
+  This new check detects unnecessary intermediate variables before `return`
+  statements that return the result of a simple comparison. This check also

Please remove This new check. Please enclose return in ``, also in other places.



Comment at: 
docs/clang-tidy/checks/readability-unnecessary-intermediate-var.rst:7
+Detects unnecessary intermediate variables before `return` statements 
returning the
+result of a simple comparison. This checker also suggests to directly inline 
the
+initializer expression of the variable declaration into the `return` 
expression.

Checker -> check.


https://reviews.llvm.org/D37014



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


[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-23 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added a reviewer: djasper.
Herald added subscribers: cfe-commits, klimek.

This fixes an issue brought up by djasper@ in his review of 
https://reviews.llvm.org/D44790. We
handled top-level child lines, but if those child lines themselves
had child lines, we didn't handle them.

Rather than use recursion (which could blow out the stack), I use a
DenseSet to hold the set of lines we haven't yet checked (since order
doesn't matter), and update the set to add the children of each
line as we check it.

Test Plan: New tests added. Confirmed tests failed before fix

  and passed after fix.


Repository:
  rC Clang

https://reviews.llvm.org/D44831

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,10 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
-  EXPECT_EQ(FormatStyle::LK_Cpp,
-guessLanguage("foo.h", "#define FOO ({ ({ std::string s; }) })"));
-  EXPECT_EQ(FormatStyle::LK_ObjC,
-guessLanguage("foo.h", "#define FOO ({ ({ NSString *s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
@@ -1538,13 +1539,18 @@
   }
   return false;
 };
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
+llvm::DenseSet LinesToCheckSet;
+LinesToCheckSet.reserve(AnnotatedLines.size());
+LinesToCheckSet.insert(AnnotatedLines.begin(), AnnotatedLines.end());
+while (!LinesToCheckSet.empty()) {
+  const auto NextLineIter = LinesToCheckSet.begin();
+  const auto NextLine = *NextLineIter;
+  if (LineContainsObjCCode(*NextLine))
 return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
-  return true;
-  }
+  LinesToCheckSet.erase(NextLineIter);
+  LinesToCheckSet.reserve(NextLine->Children.size());
+  LinesToCheckSet.insert(NextLine->Children.begin(),
+ NextLine->Children.end());
 }
 return false;
   }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,10 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
-  EXPECT_EQ(FormatStyle::LK_Cpp,
-guessLanguage("foo.h", "#define FOO ({ ({ std::string s; }) })"));
-  EXPECT_EQ(FormatStyle::LK_ObjC,
-guessLanguage("foo.h", "#define FOO ({ ({ NSString *s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
@@ -1538,13 +1539,18 @@
   }
   return false;
 };
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
+llvm::DenseSet LinesToCheckSet;
+LinesToCheckSet.reserve(AnnotatedLines.size());
+LinesToCheckSet.insert(AnnotatedLines.begin(), AnnotatedLines.end());
+while (!LinesToCheckSet.empty()) {
+  const auto NextLineIter = LinesToCheckSet.begin();
+  const auto NextLine = *NextLineIter;
+  if (LineContainsObjCCode(*NextLine))
 return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
-  return true;
-  }
+  LinesToCheckSet.erase(NextLineIter);
+  

[PATCH] D44790: [clang-format] Fix ObjC style guesser to also iterate over child lines

2018-03-23 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton marked an inline comment as done.
benhamilton added inline comments.



Comment at: cfe/trunk/lib/Format/Format.cpp:1544
+return true;
+  for (auto ChildLine : Line->Children) {
+if (LineContainsObjCCode(*ChildLine))

benhamilton wrote:
> djasper wrote:
> > Sorry that I missed this in the original review. But doesn't this still 
> > fail for Children of Child lines, etc.? I think this probably needs to be 
> > fully recursive.
> Oh, of course. I'll send a follow-up.
Follow-up in D44831.


Repository:
  rL LLVM

https://reviews.llvm.org/D44790



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


[PATCH] D41240: [Solaris] __float128 is supported on Solaris/x86

2018-03-23 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev accepted this revision.
fedor.sergeev added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D41240



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


[PATCH] D44854: [analyzer] Be more careful about C++17 copy elision.

2018-03-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

Just wanted to play safer in a couple of places.

In https://reviews.llvm.org/D44597 i said:

> If the object has trivial destructor then CXXBindTemporaryExpr is not there, 
> and the AST is pretty much indistinguishable from the simple case so we 
> re-use SimpleVariableConstructionContext and 
> SimpleReturnedValueConstructionContext. I'm not entirely sure that this is 
> indeed the same case, but for the purposes of the analyzer, which is the 
> primary user of construction contexts, this seems fine because when the 
> object has trivial destructor it is not scary to inline the constructor.

Well, this is actually an easy question. There certainly are cases where the 
AST is quite distinguishable, eg. ternary conditional operator. However, 
because construction contexts are implemented as a whitelist of possible ASTs 
that we support, it's easy to see that the ternary operator is in fact the only 
case. The patch suppresses construction contexts in this case for now, because 
the example from http://lists.llvm.org/pipermail/cfe-dev/2018-March/057357.html 
made me nervous (even though this particular example works well when there are 
no destructors involved, so this is a speculative play-safe thingy without an 
actual analyzer-based test).

Also raise the improperly-constructed flag for the return value construction 
context into a non-temporary. This also has no effect on the analyzer because 
we'd inline the constructor anyway. Additionally i added a test case to 
demonstrate how this is broken.


Repository:
  rC Clang

https://reviews.llvm.org/D44854

Files:
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/cxx17-mandatory-elision.cpp

Index: test/Analysis/cxx17-mandatory-elision.cpp
===
--- /dev/null
+++ test/Analysis/cxx17-mandatory-elision.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++17 -verify %s
+
+void clang_analyzer_eval(bool);
+
+template  struct AddressVector {
+  T *buf[10];
+  int len;
+
+  AddressVector() : len(0) {}
+
+  void push(T *t) {
+buf[len] = t;
+++len;
+  }
+};
+
+class ClassWithoutDestructor {
+  AddressVector 
+
+public:
+  ClassWithoutDestructor(AddressVector ) : v(v) {
+v.push(this);
+  }
+
+  ClassWithoutDestructor(ClassWithoutDestructor &) : v(c.v) { v.push(this); }
+  ClassWithoutDestructor(const ClassWithoutDestructor ) : v(c.v) {
+v.push(this);
+  }
+};
+
+ClassWithoutDestructor make1(AddressVector ) {
+  return ClassWithoutDestructor(v);
+}
+ClassWithoutDestructor make2(AddressVector ) {
+  return make1(v);
+}
+ClassWithoutDestructor make3(AddressVector ) {
+  return make2(v);
+}
+
+void testMultipleReturns() {
+  AddressVector v;
+  ClassWithoutDestructor c = make3(v);
+
+#if __cplusplus >= 201703L
+  // FIXME: Both should be TRUE.
+  clang_analyzer_eval(v.len == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[0] == ); // expected-warning{{FALSE}}
+#else
+  clang_analyzer_eval(v.len == 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[0] != v.buf[1]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[1] != v.buf[2]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[2] != v.buf[3]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[3] != v.buf[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[4] == ); // expected-warning{{TRUE}}
+#endif
+}
Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -108,6 +108,9 @@
   C c = C::get();
 }
 
+// FIXME: Find construction contexts for both branches in C++17.
+// Note that once it gets detected, the test for the get() branch would not
+// fail, because FileCheck allows partial matches.
 // CHECK: void simpleVariableWithTernaryOperator(bool coin)
 // CHECK:[B1]
 // CXX11-NEXT: 1: [B4.2] ? [B2.5] : [B3.6]
@@ -122,15 +125,15 @@
 // CXX11-NEXT: 3: [B2.2]() (CXXRecordTypedCall, [B2.4])
 // CXX11-NEXT: 4: [B2.3]
 // CXX11-NEXT: 5: [B2.4] (CXXConstructExpr, [B1.2], class C)
-// CXX17-NEXT: 3: [B2.2]() (CXXRecordTypedCall, [B1.2])
+// CXX17-NEXT: 3: [B2.2]()
 // CHECK:[B3]
 // CHECK-NEXT: 1: 0
 // CHECK-NEXT: 2: [B3.1] (ImplicitCastExpr, NullToPointer, class C *)
 // CXX11-NEXT: 3: [B3.2] (CXXConstructExpr, [B3.5], class C)
 // CXX11-NEXT: 4: C([B3.3]) (CXXFunctionalCastExpr, ConstructorConversion, class C)
 // CXX11-NEXT: 5: [B3.4]
 // CXX11-NEXT: 6: [B3.5] (CXXConstructExpr, [B1.2], class C)
-// CXX17-NEXT: 

[PATCH] D44130: Driver: Add gcc search path for RHEL devtoolset-7

2018-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D44130



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


[PATCH] D42608: Driver: Prefer vendor supplied gcc toolchain

2018-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

The change seems fine.

Perhaps add tests to make sure this won't cause problems in the future? 
Something along the lines of test/Driver/linux-ld.c?


Repository:
  rC Clang

https://reviews.llvm.org/D42608



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


[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

2018-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: test/CXX/except/except.spec/libc-empty-except.cpp:3
+// RUN: not %clang_cc1 -std=c++11 -I %S/libc-empty-except-sys -fexceptions 
-fcxx-exceptions -fsyntax-only -verify %s
+
+// expected-no-diagnostics

Since this is intended to fix a problem you are seeing with modules on, perhaps 
you should create modulemaps and test this with -fmodules? 



Comment at: test/CXX/except/except.spec/libc-empty-except.cpp:6
+#include "libc-empty-except.h"
+
+void f() {

In a testcase like this but using the actual real headers, if you do:

#include 
#include 

does it also compiles fine?


Repository:
  rC Clang

https://reviews.llvm.org/D43871



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


[PATCH] D34848: Driver: Don't mix system tools with devtoolset tools on RHEL

2018-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Is there a way to test this?




Comment at: lib/Driver/ToolChains/Linux.cpp:220
+ "/../bin").str());
+  }
+

You can remove the curly braces here.


https://reviews.llvm.org/D34848



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


[PATCH] D44846: [MS] Fix late-parsed template infinite loop in eager instantiation

2018-03-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/Sema.cpp:855
   // instantiations. PCH files do not.
   if (TUKind != TU_Prefix) {
 DiagnoseUseOfUnimplementedSelectors();

rnk wrote:
> rsmith wrote:
> > In the TUPrefix case, we'll need to write these instantiations to the PCH 
> > file.
> I think this addresses that. Now that we are at global scope, nobody will 
> eagerly attempt to instantiate everything on the pending instantiation queue 
> until end of TU.
Subtle, but I agree. Thanks!


https://reviews.llvm.org/D44846



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


[PATCH] D44842: Add Parameters to DW_AT_name Attribute of Template Variables

2018-03-23 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a project: debug-info.
ormris added a comment.

Adding debug-info project tag.


Repository:
  rC Clang

https://reviews.llvm.org/D44842



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


r328380 - Change for an LLVM header file move

2018-03-23 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Mar 23 15:16:59 2018
New Revision: 328380

URL: http://llvm.org/viewvc/llvm-project?rev=328380=rev
Log:
Change for an LLVM header file move

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=328380=328379=328380=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Mar 23 15:16:59 2018
@@ -46,13 +46,13 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
-#include "llvm/Transforms/GCOVProfiler.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
+#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"


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


[PATCH] D44844: [PR36880] Avoid -Wunused-lambda-capture false positive for explicit this capture used in an unresolved member in a generic lambda

2018-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/TreeTransform.h:11269
+// 'this' capture is marked as 'used'.
+if (Old->isImplicitCXXThisAccess())
+  getSema().CheckCXXThisCapture(Old->getMemberNameInfo().getLoc(),

efriedma wrote:
> This doesn't make sense; in general, you can't tell whether an 
> UnresolvedMemberExpr requires a "this" capture.
> 
> ```
> template class C : T {
> static int f(int);
> int f(double);
> public:
> int g() {
>   return []{ return f(T::x); }();
> }
> };
> 
> struct A { static int x; };
> void x(C c) { c.g(); }
> ```
Good point, we still emit a false positive warning for 

```
template  struct DummyTemplate {
  template  void methodTemplate(const T2 &) {}
  static void methodTemplate(float *) { }

  void ToTemplate(const int ) {
[this](const auto ) { methodTemplate(p); }(param); // incorrect warning!
  }
};

void main() {
  int i = 0;
  DummyTemplate dt;
  dt.ToTemplate(i);
}
```

I will work on a better fix.


Repository:
  rC Clang

https://reviews.llvm.org/D44844



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


[PATCH] D44852: [CodeGen] Mark fma as const for Android

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: spatel, efriedma, srhines, chh, enh.
Herald added a subscriber: cfe-commits.

r318093 sets fma, fmaf, fmal as const for Gnu and MSVC.  Android also
does not set errno for these functions.  So mark these const for
Android.


Repository:
  rC Clang

https://reviews.llvm.org/D44852

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - 
-emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, 
x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { 
{{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: 

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139667.
pirama added a comment.

- [CodeGen] Mark fma as const for Android


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define 

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139670.
pirama added a comment.

Remove unexpected change from another patch.


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44798: [libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.

2018-03-23 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 139673.
morehouse added a comment.

- Remove new substitutions.  Use -O0 to avoid optimization.


https://reviews.llvm.org/D44798

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  compiler-rt/test/fuzzer/SimpleCmpTest.cpp
  compiler-rt/test/fuzzer/SwapCmpTest.cpp
  compiler-rt/test/fuzzer/fuzzer-leak.test
  compiler-rt/test/fuzzer/lit.cfg
  compiler-rt/test/fuzzer/trace-malloc-threaded.test

Index: compiler-rt/test/fuzzer/trace-malloc-threaded.test
===
--- compiler-rt/test/fuzzer/trace-malloc-threaded.test
+++ compiler-rt/test/fuzzer/trace-malloc-threaded.test
@@ -2,7 +2,9 @@
 // printing a stack trace repeatedly
 UNSUPPORTED: darwin
 
-RUN: %cpp_compiler %S/TraceMallocThreadedTest.cpp -o %t-TraceMallocThreadedTest
+// Avoid optimizing since it causes the malloc to go away.
+RUN: %cpp_compiler -O0 %S/TraceMallocThreadedTest.cpp -o \
+RUN:   %t-TraceMallocThreadedTest
 
 RUN: %t-TraceMallocThreadedTest -trace_malloc=2 -runs=1 2>&1 | FileCheck %s
 CHECK: {{MALLOC\[[0-9]+] +0x[0-9]+ 5639}}
Index: compiler-rt/test/fuzzer/lit.cfg
===
--- compiler-rt/test/fuzzer/lit.cfg
+++ compiler-rt/test/fuzzer/lit.cfg
@@ -64,7 +64,7 @@
   sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers))
   isysroot_cmd = config.osx_sysroot_flag if config.osx_sysroot_flag else ''
   include_cmd = '-I%s' % libfuzzer_src_root
-  return '%s %s %s -gline-tables-only %s %s %s' % (
+  return '%s %s %s -O2 -gline-tables-only %s %s %s' % (
   compiler_cmd, std_cmd, link_cmd, isysroot_cmd, sanitizers_cmd, include_cmd)
 
 config.substitutions.append(('%cpp_compiler',
Index: compiler-rt/test/fuzzer/fuzzer-leak.test
===
--- compiler-rt/test/fuzzer/fuzzer-leak.test
+++ compiler-rt/test/fuzzer/fuzzer-leak.test
@@ -1,6 +1,9 @@
 REQUIRES: lsan
-RUN: %cpp_compiler %S/LeakTest.cpp -o %t-LeakTest
-RUN: %cpp_compiler %S/ThreadedLeakTest.cpp -o %t-ThreadedLeakTest
+
+// Avoid optimizing since it causes these leaks to go away.
+RUN: %cpp_compiler -O0 %S/LeakTest.cpp -o %t-LeakTest
+RUN: %cpp_compiler -O0 %S/ThreadedLeakTest.cpp -o %t-ThreadedLeakTest
+
 RUN: %cpp_compiler %S/LeakTimeoutTest.cpp -o %t-LeakTimeoutTest
 
 RUN: rm -rf %t-corpus && mkdir -p %t-corpus
Index: compiler-rt/test/fuzzer/SwapCmpTest.cpp
===
--- compiler-rt/test/fuzzer/SwapCmpTest.cpp
+++ compiler-rt/test/fuzzer/SwapCmpTest.cpp
@@ -11,22 +11,22 @@
   if (Size < 14) return 0;
   uint64_t x = 0;
   uint32_t y = 0;
-  uint16_t z = 0;
+  uint32_t z = 0;
   memcpy(, Data, sizeof(x));
   memcpy(, Data + Size / 2, sizeof(y));
   memcpy(, Data + Size - sizeof(z), sizeof(z));
 
   x = __builtin_bswap64(x);
   y = __builtin_bswap32(y);
-  z = __builtin_bswap16(z);
+  z = __builtin_bswap32(z);
   const bool k32bit = sizeof(void*) == 4;
 
   if ((k32bit || x == 0x46555A5A5A5A5546ULL) &&
   z == 0x4F4B &&
   y == 0x66757A7A &&
   true
   ) {
-if (Data[Size - 3] == 'z') {
+if (Data[Size - 5] == 'z') {
   fprintf(stderr, "BINGO; Found the target\n");
   exit(1);
 }
Index: compiler-rt/test/fuzzer/SimpleCmpTest.cpp
===
--- compiler-rt/test/fuzzer/SimpleCmpTest.cpp
+++ compiler-rt/test/fuzzer/SimpleCmpTest.cpp
@@ -17,15 +17,15 @@
 }
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-  if (Size != 22) return 0;
+  if (Size != 24) return 0;
   uint64_t x = 0;
   int64_t  y = 0;
   int32_t z = 0;
-  uint16_t a = 0;
+  uint32_t a = 0;
   memcpy(, Data, 8);  // 8
   memcpy(, Data + 8, 8);  // 16
   memcpy(, Data + 16, sizeof(z));  // 20
-  memcpy(, Data + 20, sizeof(a));  // 22
+  memcpy(, Data + 20, sizeof(a));  // 24
   const bool k32bit = sizeof(void*) == 4;
 
   if ((k32bit || x > 1234567890) && PrintOnce(__LINE__) &&
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -862,6 +862,10 @@
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  // Apply fuzzing attribute to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
+Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
+
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
   // .cxx_destruct, __destroy_helper_block_ and all of their calees at run time.
   if (SanOpts.has(SanitizerKind::Thread)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44846: [MS] Fix late-parsed template infinite loop in eager instantiation

2018-03-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 139663.
rnk added a comment.

- make late-parsed templates pending at end of TU prefix


https://reviews.llvm.org/D44846

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/PCH/late-parsed-instantiations.cpp
  clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp

Index: clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++14 -verify %s
+
+// pr33561
+class ArrayBuffer;
+template  class Trans_NS_WTF_RefPtr {
+public:
+  ArrayBuffer *operator->() { return nullptr; }
+};
+Trans_NS_WTF_RefPtr get();
+template 
+constexpr void visit(_Visitor __visitor) {
+  __visitor(get()); // expected-note {{in instantiation}}
+}
+class ArrayBuffer {
+  char data() {
+visit([](auto buffer) -> char { // expected-note {{in instantiation}}
+  buffer->data();
+}); // expected-warning {{control reaches end of non-void lambda}}
+  } // expected-warning {{control reaches end of non-void function}}
+};
+
+// pr34185
+template  struct coroutine_handle {
+  Promise () const { return
+*static_cast(nullptr); // expected-warning {{binding dereferenced null}}
+  }
+};
+
+template  auto GetCurrenPromise() {
+  struct Awaiter { // expected-note {{in instantiation}}
+void await_suspend(coroutine_handle h) {
+  h.promise(); // expected-note {{in instantiation}}
+}
+  };
+  return Awaiter{};
+}
+
+void foo() {
+  auto & = GetCurrenPromise(); // expected-note {{in instantiation}}
+}
Index: clang/test/PCH/late-parsed-instantiations.cpp
===
--- /dev/null
+++ clang/test/PCH/late-parsed-instantiations.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -emit-pch %s -o %t.pch -verify
+// RUN: %clang_cc1 -fdelayed-template-parsing -std=c++14 -include-pch %t.pch %s -verify
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+// pr33561
+class ArrayBuffer;
+template  class Trans_NS_WTF_RefPtr {
+public:
+  ArrayBuffer *operator->() { return nullptr; }
+};
+Trans_NS_WTF_RefPtr get();
+template 
+constexpr void visit(_Visitor __visitor) {
+  __visitor(get()); // expected-note {{in instantiation}}
+}
+class ArrayBuffer {
+  char data() {
+visit([](auto buffer) -> char { // expected-note {{in instantiation}}
+  buffer->data();
+}); // expected-warning {{control reaches end of non-void lambda}}
+  } // expected-warning {{control reaches end of non-void function}}
+};
+
+#else
+
+// expected-no-diagnostics
+
+#endif
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3837,8 +3837,8 @@
   if (PatternDecl->isLateTemplateParsed() &&
   !LateTemplateParser) {
 Function->setInstantiationIsPending(true);
-PendingInstantiations.push_back(
-  std::make_pair(Function, PointOfInstantiation));
+LateParsedInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
 return;
   }
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -850,6 +850,13 @@
   if (PP.isCodeCompletionEnabled())
 return;
 
+  // Transfer late parsed template instantiations over to the pending template
+  // instantiation list.
+  PendingInstantiations.insert(PendingInstantiations.end(),
+   LateParsedInstantiations.begin(),
+   LateParsedInstantiations.end());
+  LateParsedInstantiations.clear();
+
   // Complete translation units and modules define vtables and perform implicit
   // instantiations. PCH files do not.
   if (TUKind != TU_Prefix) {
@@ -879,8 +886,13 @@
   PendingInstantiations.insert(PendingInstantiations.begin(),
Pending.begin(), Pending.end());
 }
+
 PerformPendingInstantiations();
 
+assert(LateParsedInstantiations.empty() &&
+   "end of TU template instantiation should not create more "
+   "late-parsed templates");
+
 if (LateTemplateParserCleanup)
   LateTemplateParserCleanup(OpaqueParser);
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -7550,6 +7550,10 @@
   /// but have not yet been performed.
   std::deque PendingInstantiations;
 
+  /// Queue of implicit template instantiations that cannot be performed
+  /// eagerly.
+  SmallVector LateParsedInstantiations;
+
   class GlobalEagerInstantiationScope {
   

[PATCH] D44846: [MS] Fix late-parsed template infinite loop in eager instantiation

2018-03-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:855
   // instantiations. PCH files do not.
   if (TUKind != TU_Prefix) {
 DiagnoseUseOfUnimplementedSelectors();

rsmith wrote:
> In the TUPrefix case, we'll need to write these instantiations to the PCH 
> file.
I think this addresses that. Now that we are at global scope, nobody will 
eagerly attempt to instantiate everything on the pending instantiation queue 
until end of TU.


https://reviews.llvm.org/D44846



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


r328384 - [libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.

2018-03-23 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Fri Mar 23 16:35:28 2018
New Revision: 328384

URL: http://llvm.org/viewvc/llvm-project?rev=328384=rev
Log:
[libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.

Summary:
Disables certain CMP optimizations to improve fuzzing signal under -O1
and -O2.

Switches all fuzzer tests to -O2 except for a few leak tests where the
leak is optimized out under -O2.

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, llvm-commits

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

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

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=328384=328383=328384=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar 23 16:35:28 2018
@@ -862,6 +862,10 @@ void CodeGenFunction::StartFunction(Glob
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  // Apply fuzzing attribute to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
+Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
+
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
   // .cxx_destruct, __destroy_helper_block_ and all of their calees at run 
time.
   if (SanOpts.has(SanitizerKind::Thread)) {


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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139666.
pirama added a comment.

- [CodeGen] Mark fma as const for Android


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define 

[PATCH] D44798: [libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.

2018-03-23 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328384: [libFuzzer] Use OptForFuzzing attribute with 
-fsanitize=fuzzer. (authored by morehouse, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44798?vs=139673=139675#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44798

Files:
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -862,6 +862,10 @@
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  // Apply fuzzing attribute to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
+Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
+
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
   // .cxx_destruct, __destroy_helper_block_ and all of their calees at run 
time.
   if (SanOpts.has(SanitizerKind::Thread)) {


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -862,6 +862,10 @@
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  // Apply fuzzing attribute to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
+Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
+
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
   // .cxx_destruct, __destroy_helper_block_ and all of their calees at run time.
   if (SanOpts.has(SanitizerKind::Thread)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r328388 - Partially Revert "Workaround GCC bug PR78489 - SFINAE order is not respected."

2018-03-23 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar 23 16:42:30 2018
New Revision: 328388

URL: http://llvm.org/viewvc/llvm-project?rev=328388=rev
Log:
Partially Revert "Workaround GCC bug PR78489 - SFINAE order is not respected."

This partially reverts commit r328261. The GCC bug has been fixed in
trunk and has never existed in a released version. Therefore the changes
to variant are unneeded.

However, the additional tests have been left in place.

Modified:
libcxx/trunk/include/variant

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=328388=328387=328388=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Fri Mar 23 16:42:30 2018
@@ -1156,24 +1156,29 @@ public:
   : __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {}
 
   template  _Ip2 = _Ip,
-class _Tp = variant_alternative_t<_Ip2, variant<_Types...>>,
-enable_if_t::value, int> = 0>
+class = enable_if_t<(_Ip < sizeof...(_Types)), int>,
+class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
+enable_if_t, int> = 0>
   inline _LIBCPP_INLINE_VISIBILITY
-  explicit constexpr variant(in_place_index_t<_Ip>,
- _Args&&... __args)
-noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
+  explicit constexpr variant(
+  in_place_index_t<_Ip>,
+  _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
   : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
 
-  template  _Ip2 = _Ip,
-  class _Tp = variant_alternative_t<_Ip2, variant<_Types...>>,
+  template <
+  size_t _Ip,
+  class _Up,
+  class... _Args,
+  enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
+  class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
   enable_if_t&, _Args...>,
   int> = 0>
   inline _LIBCPP_INLINE_VISIBILITY
-  explicit constexpr variant(in_place_index_t<_Ip>, initializer_list<_Up> __il,
- _Args&&... __args)
-noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, 
_Args...>)
+  explicit constexpr variant(
+  in_place_index_t<_Ip>,
+  initializer_list<_Up> __il,
+  _Args&&... __args) noexcept(
+  is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>)
   : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
 
   template <


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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-23 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

In https://reviews.llvm.org/D44826#1046671, @erichkeane wrote:

> My opinion matters less than @rsmith or @dblaikie on the review, but it seems 
> to me that Typedef and Using are SO similar that the implementations should 
> just be combined.  You'd likely have to change a couple of types along the 
> way to be more generic, but the implementations are essentially a copy/paste 
> of eachother.


That is a very valid point and it simplifies quite a lot the patch.

If the other reviewers do not have any objection, I will combine both 
implementations and update the uploaded patch.

Thanks,
Carlos


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D44765: PR36643 Make clang-format support more generic TMarcos

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D44765#1045789, @obfuscated wrote:

> In https://reviews.llvm.org/D44765#1045373, @alexfh wrote:
>
> > We can't just treat `anything("")` like the _T macro. There should be a 
> > whitelist configurable with an option. By default only _T should be handled.
>
>
> What cases could break with this version of the patch?


It is fine to split `_T("veeery 
lng 
string")` as

  _T("veeery ")
  _T("lng ")
  _T("string")

and it's incorrect to split it like this:

  _T("veeery "
 "lng "
 "string")

since only the first string literal will get the L prefix in case when `_T(x)` 
is defined as `L ## x`. The same is valid for `wxT()` as I understand.

However, it's wrong to do so for any function or any macro which uses its 
argument in any way different from that of _T. E.g. `strlen("aaa bbb")` is not 
the same as

  strlen("aaa ")
  strlen("bbb")



> I'm fine adding an option if this is deemed acceptable.

I'd say this should be an option.


Repository:
  rC Clang

https://reviews.llvm.org/D44765



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


[PATCH] D44753: [Preprocessor] Rename __is_{target -> host}_* function-like builtin macros

2018-03-23 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

Bummer, I didn't realize this had already shipped.

I'm happy to discuss on the mailing list. Indeed I responded there first 
  but it would 
appear nobody saw my message. Should I reply to my own message with a summary 
and link of this read, or would one of you like to do that?


Repository:
  rC Clang

https://reviews.llvm.org/D44753



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


[PATCH] D41456: [clang-tidy] readability-else-after-return: also diagnose noreturn function calls.

2018-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

The problem with this proposed functionality is that it's not always obvious at 
the call site whether a function is noreturn. exit() may be an easy case, but 
there may be much less obvious names and whether the function is noreturn may 
depend on compile-time configuration or be instantiation-dependent in template 
code (https://godbolt.org/g/fNtpCy):

  template
  struct X {
void f();
  };
  template<>
  struct X {
  [[noreturn]] void f();
  };
  template
  void f(int x) {
if (x) {
  X().f();
} else {  // Should the check complain here?
  //...
}
  }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41456



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


Re: A proposal for adding OpenCL C++ support (Spec v2.2)

2018-03-23 Thread Anastasia Stulova via cfe-commits
There were no objections to this so far. I assume it means nobody is opposing 
this new feature.


Just to give a bit more info and a chance for the last feedback. We don't plan 
to contribute the whole patch but only around 3K lines + tests. The overall 
changes will be smaller than OpenCL 2.0. And they will mainly affect C++ code 
paths in Sema and CodeGen, but some parsing bits too.


The time frame to start this work will hopefully be the beginning of April.


Cheers,

Anastasia


From: cfe-dev  on behalf of Anastasia Stulova 
via cfe-dev 
Sent: 23 February 2018 16:29
To: clang-dev developer list
Cc: nd
Subject: [cfe-dev] A proposal for adding OpenCL C++ support (Spec v2.2)


Hello,


A number of developers from the member companies within the Khronos Group are 
interested to contribute the prototype implementation of OpenCL C++ that is 
currently located on github and based on version 3.6:

https://github.com/KhronosGroup/SPIR/commit/0cfb6f7533d42ae3398a8574efd8abbdac88ac44


This implementation is compliant to OpenCL v2.2 standard:

https://www.khronos.org/registry/OpenCL/specs/opencl-2.2-cplusplus.pdf

Similarly to OpenCL C being based on C99, OpenCL C++ support is entirely based 
on C++14 with a number of extensions (some of which will be shared with OpenCL 
C) and a few minor restrictions.


The plan would be to take small patches from the github repository and perform 
any necessary rework and clean up before putting up for review. From the OpenCL 
side, I don't see any issue with this plan as it doesn't interfere with any 
current development I am aware of, and also it would be great to progress to 
the next OpenCL standard. I just want to check if there are any objections from 
anyone or things we should be aware of before the start. I'm particularly 
looking for feedback from C++ implementers as there might be some overlap.


Additionally, there are two more related threads, which I plan to discuss 
separately. There is:

(i) standard library support libclcxx: https://github.com/KhronosGroup/libclcxx.

(ii) and IR generation to SPIRV: 
http://lists.llvm.org/pipermail/llvm-dev/2018-February/121317.html

that we would like to provide as well, in order to allow Clang to produce an 
end binary targeting a wider range of architectures directly (not just AMD 
GPU). We expect that the complete open source solution for OpenCL C++ will 
increase significantly Clang users and unify our development forces i.e. 
refactoring, bug hunting, etc. The plan would be to do similar for OpenCL C too 
at a later point of time.


Please, contact me if you have any thoughts or comments.


Cheers,

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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-23 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT marked 5 inline comments as done.
DHowett-MSFT added a comment.

@compnerd CL warns for `__forceinline` variadics in C code as well:

  test.c(1): warning C4714: function 'void hello(int,...)' marked as 
__forceinline not inlined


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


r328337 - [vfs] Don't bail out after a missing -ivfsoverlay file

2018-03-23 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Fri Mar 23 10:37:27 2018
New Revision: 328337

URL: http://llvm.org/viewvc/llvm-project?rev=328337=rev
Log:
[vfs] Don't bail out after a missing -ivfsoverlay file

This make -ivfsoverlay behave more like other fatal errors (e.g. missing
-include file) by skipping the missing file instead of bailing out of
the whole compilation. This makes it possible for libclang to still
provide some functionallity as well as to correctly produce the fatal
error diagnostic (previously we lost the diagnostic in libclang since
there was no TU to tie it to).

rdar://33385423

Added:
cfe/trunk/test/Index/missing_vfs.c
cfe/trunk/test/VFS/Inputs/MissingVFS/
cfe/trunk/test/VFS/Inputs/MissingVFS/a.h
cfe/trunk/test/VFS/Inputs/MissingVFS/module.modulemap
cfe/trunk/test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
cfe/trunk/test/VFS/module_missing_vfs.m
Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=328337=328336=328337=diff
==
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Fri Mar 23 10:37:27 
2018
@@ -289,7 +289,6 @@ enum class BuildPreambleError {
   PreambleIsEmpty = 1,
   CouldntCreateTempFile,
   CouldntCreateTargetInfo,
-  CouldntCreateVFSOverlay,
   BeginSourceFileFailed,
   CouldntEmitPCH
 };

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=328337=328336=328337=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Mar 23 10:37:27 2018
@@ -1354,7 +1354,6 @@ ASTUnit::getMainBufferWithPrecompiledPre
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
-  case BuildPreambleError::CouldntCreateVFSOverlay:
 // These erros are more likely to repeat, retry after some period.
 PreambleRebuildCounter = DefaultPreambleRebuildInterval;
 return nullptr;
@@ -1456,8 +1455,6 @@ ASTUnit::create(std::shared_ptr VFS =
   createVFSFromCompilerInvocation(*CI, *Diags);
-  if (!VFS)
-return nullptr;
   AST->Diagnostics = Diags;
   AST->FileSystemOpts = CI->getFileSystemOpts();
   AST->Invocation = std::move(CI);
@@ -1735,14 +1732,14 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   // Create the AST unit.
   std::unique_ptr AST;
   AST.reset(new ASTUnit(false));
+  AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
+  AST->StoredDiagnostics.swap(StoredDiagnostics);
   ConfigureDiags(Diags, *AST, CaptureDiagnostics);
   AST->Diagnostics = Diags;
   AST->FileSystemOpts = CI->getFileSystemOpts();
   if (!VFS)
 VFS = vfs::getRealFileSystem();
   VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
-  if (!VFS)
-return nullptr;
   AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
   AST->PCMCache = new MemoryBufferCache;
   AST->OnlyLocalDecls = OnlyLocalDecls;
@@ -1752,8 +1749,6 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   AST->IncludeBriefCommentsInCodeCompletion
 = IncludeBriefCommentsInCodeCompletion;
   AST->UserFilesAreVolatile = UserFilesAreVolatile;
-  AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
-  AST->StoredDiagnostics.swap(StoredDiagnostics);
   AST->Invocation = CI;
   if (ForSerialization)
 AST->WriterData.reset(new ASTWriterData(*AST->PCMCache));

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=328337=328336=328337=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Mar 23 10:37:27 2018
@@ -302,11 +302,9 @@ CompilerInstance::createDiagnostics(Diag
 
 FileManager *CompilerInstance::createFileManager() {
   if (!hasVirtualFileSystem()) {
-if (IntrusiveRefCntPtr VFS =
-createVFSFromCompilerInvocation(getInvocation(), getDiagnostics()))
-  setVirtualFileSystem(VFS);
-else
-  return nullptr;
+IntrusiveRefCntPtr VFS =
+createVFSFromCompilerInvocation(getInvocation(), getDiagnostics());
+setVirtualFileSystem(VFS);
   }
   FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem);
   return FileMgr.get();

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

r328409 - [C++17] Fix class template argument deduction for default constructors without an initializer

2018-03-23 Thread Zhihao Yuan via cfe-commits
Author: lichray
Date: Fri Mar 23 21:32:11 2018
New Revision: 328409

URL: http://llvm.org/viewvc/llvm-project?rev=328409=rev
Log:
[C++17] Fix class template argument deduction for default constructors without 
an initializer

Summary:
As the title says, this makes following code compile:

```
template struct Foo {};
Foo() -> Foo;

Foo f; // ok
```

Thanks Nicolas Lesser for coining the fix.

Reviewers: rsmith, lichray

Reviewed By: rsmith, lichray

Subscribers: lichray, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=328409=328408=328409=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Mar 23 21:32:11 2018
@@ -10396,12 +10396,22 @@ QualType Sema::deduceVarTypeFromInitiali
   // C++11 [dcl.spec.auto]p3
   if (!Init) {
 assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
+
+// Except for class argument deduction, and then for an initializing
+// declaration only, i.e. no static at class scope or extern.
+if (!isa(Deduced) ||
+VDecl->hasExternalStorage() ||
+VDecl->isStaticDataMember()) {
+  Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
+<< VDecl->getDeclName() << Type;
+  return QualType();
+}
   }
 
-  ArrayRef DeduceInits = Init;
+  ArrayRef DeduceInits;
+  if (Init)
+DeduceInits = Init;
+
   if (DirectInit) {
 if (auto *PL = dyn_cast_or_null(Init))
   DeduceInits = PL->exprs();

Modified: 
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp?rev=328409=328408=328409=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp 
(original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp 
Fri Mar 23 21:32:11 2018
@@ -5,8 +5,7 @@ A() -> A;
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are 
permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
@@ -16,3 +15,5 @@ struct B {
   static A a; // expected-error {{requires an initializer}}
 };
 extern A x; // expected-error {{requires an initializer}}
+static A y;
+

Modified: cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp?rev=328409=328408=328409=diff
==
--- cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp (original)
+++ cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp Fri Mar 
23 21:32:11 2018
@@ -137,7 +137,6 @@ namespace expr {
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -150,7 +149,7 @@ namespace decl {
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' 
requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring 
variable with deduced class template specialization type}}


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


[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer

2018-03-23 Thread Zhihao Yuan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328409: [C++17] Fix class template argument deduction for 
default constructors without… (authored by lichray, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D38216

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
  test/Parser/cxx1z-class-template-argument-deduction.cpp


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are 
permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
@@ -16,3 +15,5 @@
   static A a; // expected-error {{requires an initializer}}
 };
 extern A x; // expected-error {{requires an initializer}}
+static A y;
+
Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -137,7 +137,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -150,7 +149,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' 
requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring 
variable with deduced class template specialization type}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10396,12 +10396,22 @@
   // C++11 [dcl.spec.auto]p3
   if (!Init) {
 assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
+
+// Except for class argument deduction, and then for an initializing
+// declaration only, i.e. no static at class scope or extern.
+if (!isa(Deduced) ||
+VDecl->hasExternalStorage() ||
+VDecl->isStaticDataMember()) {
+  Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
+<< VDecl->getDeclName() << Type;
+  return QualType();
+}
   }
 
-  ArrayRef DeduceInits = Init;
+  ArrayRef DeduceInits;
+  if (Init)
+DeduceInits = Init;
+
   if (DirectInit) {
 if (auto *PL = dyn_cast_or_null(Init))
   DeduceInits = PL->exprs();


Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
@@ -16,3 +15,5 @@
   static A a; // expected-error {{requires an initializer}}
 };
 extern A x; // expected-error {{requires an initializer}}
+static A y;
+
Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -137,7 +137,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -150,7 +149,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10396,12 +10396,22 @@
   // C++11 [dcl.spec.auto]p3
   if (!Init) {
 assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
+
+// Except for class argument deduction, and then for an initializing
+// declaration only, i.e. no static at class scope or extern.

[PATCH] D44747: Set calling convention for CUDA kernel

2018-03-23 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/AST/Type.cpp:2762
+  case CC_CUDAKernel:
+return "cuda_kernel";
   }

For consistency with the rest of this switch, please put the return on the same 
line as its case.



Comment at: lib/AST/TypePrinter.cpp:781
 case CC_OpenCLKernel:
+case CC_CUDAKernel:
   // Do nothing. These CCs are not available as attributes.

I think the spelling for this is `__global__`.  You might need to adjust 
printing because this isn't the right place to print it, of course.



Comment at: lib/CodeGen/CGCall.cpp:68
+  case CC_CUDAKernel:
+return CGM.getTargetCodeGenInfo().getCUDAKernelCallingConv();
   }

For consistency with the rest of this switch, please put the return on the same 
line as its case.



Comment at: lib/Sema/SemaOverload.cpp:1492
+  Changed = true;
+}
+

It's cheaper not to check the CUDA language mode here; pulling the CC out of 
the FPT is easy.

Why is this necessary, anyway?  From the spec, it doesn't look to me like 
kernel function pointers can be converted to ordinary function pointers.  A 
kernel function pointer is supposed to be declared with something like 
`__global__ void (*fn)(void)`.  You'll need to change your patch to SemaType to 
apply the CC even when compiling for the host, of course.

I was going to say that you should use this CC in your validation that calls 
with execution configurations go to kernel functions, but... I can't actually 
find where you do that validation.

Do you need these function pointers to be a different size from the host 
function pointer?



Comment at: tools/libclang/CXType.cpp:630
+case CC_CUDAKernel:
+  return CXCallingConv_Unexposed;
   break;

Formatting.


https://reviews.llvm.org/D44747



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