[PATCH] D66538: [AST] AST structural equivalence to work internally with pairs.

2019-09-02 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.

Looks good, thank you for addressing the comments!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66538/new/

https://reviews.llvm.org/D66538



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


r370621 - [ASTImporter] At import of records re-order indirect fields too.

2019-09-02 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Mon Sep  2 00:17:01 2019
New Revision: 370621

URL: http://llvm.org/viewvc/llvm-project?rev=370621&view=rev
Log:
[ASTImporter] At import of records re-order indirect fields too.

Summary:
Correct order of fields and indirect fields in imported RecordDecl
is needed for correct work of record layout calculations.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: martong, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=370621&r1=370620&r2=370621&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Sep  2 00:17:01 2019
@@ -1702,7 +1702,7 @@ ASTNodeImporter::ImportDeclContext(DeclC
   // Remove all declarations, which may be in wrong order in the
   // lexical DeclContext and then add them in the proper order.
   for (auto *D : FromRD->decls()) {
-if (isa(D) || isa(D)) {
+if (isa(D) || isa(D) || isa(D)) {
   assert(D && "DC contains a null decl");
   Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
   // Remove only the decls which we successfully imported.

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=370621&r1=370620&r2=370621&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Sep  2 00:17:01 2019
@@ -1421,12 +1421,15 @@ TEST_P(ASTImporterOptionSpecificTestBase
 
 AST_MATCHER_P(RecordDecl, hasFieldOrder, std::vector, Order) {
   size_t Index = 0;
-  for (FieldDecl *Field : Node.fields()) {
-if (Index == Order.size())
-  return false;
-if (Field->getName() != Order[Index])
-  return false;
-++Index;
+  for (Decl *D : Node.decls()) {
+if (isa(D) || isa(D)) {
+  auto *ND = cast(D);
+  if (Index == Order.size())
+return false;
+  if (ND->getName() != Order[Index])
+return false;
+  ++Index;
+}
   }
   return Index == Order.size();
 }
@@ -1493,6 +1496,31 @@ TEST_P(ASTImporterOptionSpecificTestBase
   Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"};
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   CXXRecordDeclFieldAndIndirectFieldOrder) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  // First field is "a", then the field for unnamed union, then "b" and "c"
+  // from it (indirect fields), then "d".
+  R"s(
+  struct declToImport {
+int a = d;
+union { 
+  int b;
+  int c;
+};
+int d;
+  };
+  )s",
+  Lang_CXX11, "", Lang_CXX11);
+
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(
+  From, cxxRecordDecl(hasFieldOrder({"a", "", "b", "c", "d"};
+  EXPECT_TRUE(Verifier.match(
+  To, cxxRecordDecl(hasFieldOrder({"a", "", "b", "c", "d"};
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ShouldImportImplicitCXXRecordDecl) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(


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


[PATCH] D66866: [ASTImporter] At import of records re-order indirect fields too.

2019-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370621: [ASTImporter] At import of records re-order indirect 
fields too. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66866?vs=217816&id=218294#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66866/new/

https://reviews.llvm.org/D66866

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1702,7 +1702,7 @@
   // Remove all declarations, which may be in wrong order in the
   // lexical DeclContext and then add them in the proper order.
   for (auto *D : FromRD->decls()) {
-if (isa(D) || isa(D)) {
+if (isa(D) || isa(D) || isa(D)) {
   assert(D && "DC contains a null decl");
   Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
   // Remove only the decls which we successfully imported.
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -1421,12 +1421,15 @@
 
 AST_MATCHER_P(RecordDecl, hasFieldOrder, std::vector, Order) {
   size_t Index = 0;
-  for (FieldDecl *Field : Node.fields()) {
-if (Index == Order.size())
-  return false;
-if (Field->getName() != Order[Index])
-  return false;
-++Index;
+  for (Decl *D : Node.decls()) {
+if (isa(D) || isa(D)) {
+  auto *ND = cast(D);
+  if (Index == Order.size())
+return false;
+  if (ND->getName() != Order[Index])
+return false;
+  ++Index;
+}
   }
   return Index == Order.size();
 }
@@ -1493,6 +1496,31 @@
   Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"};
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   CXXRecordDeclFieldAndIndirectFieldOrder) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  // First field is "a", then the field for unnamed union, then "b" and "c"
+  // from it (indirect fields), then "d".
+  R"s(
+  struct declToImport {
+int a = d;
+union { 
+  int b;
+  int c;
+};
+int d;
+  };
+  )s",
+  Lang_CXX11, "", Lang_CXX11);
+
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(
+  From, cxxRecordDecl(hasFieldOrder({"a", "", "b", "c", "d"};
+  EXPECT_TRUE(Verifier.match(
+  To, cxxRecordDecl(hasFieldOrder({"a", "", "b", "c", "d"};
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ShouldImportImplicitCXXRecordDecl) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1702,7 +1702,7 @@
   // Remove all declarations, which may be in wrong order in the
   // lexical DeclContext and then add them in the proper order.
   for (auto *D : FromRD->decls()) {
-if (isa(D) || isa(D)) {
+if (isa(D) || isa(D) || isa(D)) {
   assert(D && "DC contains a null decl");
   Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
   // Remove only the decls which we successfully imported.
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -1421,12 +1421,15 @@
 
 AST_MATCHER_P(RecordDecl, hasFieldOrder, std::vector, Order) {
   size_t Index = 0;
-  for (FieldDecl *Field : Node.fields()) {
-if (Index == Order.size())
-  return false;
-if (Field->getName() != Order[Index])
-  return false;
-++Index;
+  for (Decl *D : Node.decls()) {
+if (isa(D) || isa(D)) {
+  auto *ND = cast(D);
+  if (Index == Order.size())
+return false;
+  if (ND->getName() != Order[Index])
+return false;
+  ++Index;
+}
   }
   return Index == Order.size();
 }
@@ -1493,6 +1496,31 @@
   Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"};
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   CXXRecordDeclFieldAndIndirectFieldOrder) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  // First field is "a", then the field for unnamed union, then "b" and "c"
+  // from it (indirect fields), then "d".
+  R"s(
+  struct declToImport {
+int a = d;
+union { 
+  int b;
+  int c;
+};
+int d;
+  };
+  )s",
+  Lang_CXX11, "", Lang_CXX11);
+
+  MatchVerifier Verifier;
+  ASSERT_TRUE(Verifier.match(
+  From, cxxRecordDecl(hasField

[PATCH] D66018: [ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

2019-09-02 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

Hi, I do agree that giving the user a warning that the argument is ignored is 
the best solution. If you wouldn't mind adding it to this patch, that would be 
great. Thanks.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66018/new/

https://reviews.llvm.org/D66018



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


[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

LGTM, but could you also verify that references are not an issue?

  using D = void();
  D &d = ...; ///< \return none


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66706/new/

https://reviews.llvm.org/D66706



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


[PATCH] D66990: [clangd] Add distinct highlightings for declarations of functions and methods

2019-09-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D66990#1653833 , @nridge wrote:

> There is precedent for highlighting declarations and uses differently in 
> other C++ editors. For example, Eclipse CDT has separate highlightings for 
> function and functions declarations (see screenshot below).


Acknowledged.

> Objectively speaking, I think it makes sense to style function declarations 
> differently from function uses for emphasis. For example, you can use the 
> same color for both, but make the declarations bold. I have found this to aid 
> readability.

As mentioned before, I think doing this:

- adds some confusion: the **same** thing highlighted in **two** different 
colors,
- provides almost zero value: function declarations have completely different 
syntax from function usages anyway, there are more than enough signals to 
distinguish them and we don't need semantic highlighting for that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66990/new/

https://reviews.llvm.org/D66990



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


[PATCH] D66990: [clangd] Add distinct highlightings for declarations of functions and methods

2019-09-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D66990#1653833 , @nridge wrote:

> I think it makes sense to style function declarations differently from 
> function uses for emphasis. For example, you can use the same color for both, 
> but make the declarations bold. I have found this to aid readability.


I think this makes sense, but it should be done for **all** declarations and 
not just functions.
But doing that in the current design would mean we need to double the number of 
styles. In addition to `field`, `method`, `function`, we would need 
`field-declaration`, `method-declaration`, `function-declaration`, etc.
Combinatorial explosion of that kind is bad, so I would rather avoid it.

That would also mean we would rely on every editor to apply consistent styling 
for this, at least by default: make `somethind-decl` just like `decl` but bold.
I don't think there's any way to enforce this.

If there was an alternative design we could use for this that would not cause 
combinatorial explosion and would allow us to consistently apply the same 
modifier to different kinds of highlighting (e.g. something that will 
**consistently** turn to bold in all editors that support this), I would be 
supportive of implementing this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66990/new/

https://reviews.llvm.org/D66990



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


[PATCH] D64480: [ASTImporter] Added visibility context check for TypedefNameDecl.

2019-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 218310.
balazske added a comment.

Improved the tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64480/new/

https://reviews.llvm.org/D64480

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -39,6 +39,18 @@
   using DeclTy = EnumDecl;
   BindableMatcher operator()() { return enumDecl(hasName("E")); }
 };
+struct GetTypedefPattern {
+  using DeclTy = TypedefDecl;
+  BindableMatcher operator()() { return typedefDecl(hasName("T")); }
+};
+struct GetTypeAliasPattern {
+  using DeclTy = TypeAliasDecl;
+  BindableMatcher operator()() { return typeAliasDecl(hasName("T")); }
+};
+struct GetTypedefNamePattern {
+  using DeclTy = TypedefNameDecl;
+  BindableMatcher operator()() { return typedefNameDecl(hasName("T")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -55,6 +67,11 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+// TypedefNameDecl:
+const auto *ExternTypedef = "typedef int T;";
+const auto *AnonTypedef = "namespace { typedef int T; }";
+const auto *ExternUsing = "using T = int;";
+const auto *AnonUsing = "namespace { using T = int; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -243,6 +260,7 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportTypedefNameVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -272,6 +290,13 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+// TypedefNameDecl.
+TEST_P(ImportTypedefNameVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -318,6 +343,30 @@
   std::make_tuple(ExternE, AnonE, ExpectNotLink),
   std::make_tuple(AnonE, ExternE, ExpectNotLink),
   std::make_tuple(AnonE, AnonE, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportTypedefNameVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternTypedef, ExternTypedef, ExpectLink),
+std::make_tuple(ExternTypedef, AnonTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, ExternTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, AnonTypedef, ExpectNotLink),
+
+std::make_tuple(ExternUsing, ExternUsing, ExpectLink),
+std::make_tuple(ExternUsing, AnonUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, ExternUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, AnonUsing, ExpectNotLink),
+
+std::make_tuple(ExternUsing, ExternTypedef, ExpectLink),
+std::make_tuple(ExternUsing, AnonTypedef, ExpectNotLink),
+std::make_tuple(AnonUsing, ExternTypedef, ExpectNotLink),
+std::make_tuple(AnonUsing, AnonTypedef, ExpectNotLink),
+
+std::make_tuple(ExternTypedef, ExternUsing, ExpectLink),
+std::make_tuple(ExternTypedef, AnonUsing, ExpectNotLink),
+std::make_tuple(AnonTypedef, ExternUsing, ExpectNotLink),
+std::make_tuple(AnonTypedef, AnonUsing, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -932,6 +932,27 @@
   EllipsisLoc);
 }
 
+template 
+bool ASTNodeImporter::hasSameVisibilityContext(T *Found, T *From) {
+  if (From->hasExternalFormalLinkage())
+return Found->hasExternalFormalLinkage();
+  if (Importer.GetFromTU(Found) != From->getTranslationUnitDecl())
+return false;
+  if (From->isInAnonymousNamespace())
+return Found->isInAnonymousNamespace();
+  else
+return !Found->isInAnonymousNamespace() &&
+   !Found->hasExternalFormalLinkage();
+}
+
+template <>
+bool ASTNodeImporter::hasSameVisibilityContext(TypedefNameDecl *Found,
+   TypedefNameDecl *From) {
+  if (From->isInAnonymousNamespace() && Found->isInAnonymousNamespace())
+return Importer.GetFromTU(Found) == From->getTranslationUnitDecl();
+  return From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
+}
+

[PATCH] D64480: [ASTImporter] Added visibility context check for TypedefNameDecl.

2019-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 218311.
balazske added a comment.

- Removed unneeded structs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64480/new/

https://reviews.llvm.org/D64480

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -39,6 +39,10 @@
   using DeclTy = EnumDecl;
   BindableMatcher operator()() { return enumDecl(hasName("E")); }
 };
+struct GetTypedefNamePattern {
+  using DeclTy = TypedefNameDecl;
+  BindableMatcher operator()() { return typedefNameDecl(hasName("T")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -55,6 +59,11 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+// TypedefNameDecl:
+const auto *ExternTypedef = "typedef int T;";
+const auto *AnonTypedef = "namespace { typedef int T; }";
+const auto *ExternUsing = "using T = int;";
+const auto *AnonUsing = "namespace { using T = int; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -243,6 +252,7 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportTypedefNameVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -272,6 +282,13 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+// TypedefNameDecl.
+TEST_P(ImportTypedefNameVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -318,6 +335,30 @@
   std::make_tuple(ExternE, AnonE, ExpectNotLink),
   std::make_tuple(AnonE, ExternE, ExpectNotLink),
   std::make_tuple(AnonE, AnonE, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportTypedefNameVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternTypedef, ExternTypedef, ExpectLink),
+std::make_tuple(ExternTypedef, AnonTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, ExternTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, AnonTypedef, ExpectNotLink),
+
+std::make_tuple(ExternUsing, ExternUsing, ExpectLink),
+std::make_tuple(ExternUsing, AnonUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, ExternUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, AnonUsing, ExpectNotLink),
+
+std::make_tuple(ExternUsing, ExternTypedef, ExpectLink),
+std::make_tuple(ExternUsing, AnonTypedef, ExpectNotLink),
+std::make_tuple(AnonUsing, ExternTypedef, ExpectNotLink),
+std::make_tuple(AnonUsing, AnonTypedef, ExpectNotLink),
+
+std::make_tuple(ExternTypedef, ExternUsing, ExpectLink),
+std::make_tuple(ExternTypedef, AnonUsing, ExpectNotLink),
+std::make_tuple(AnonTypedef, ExternUsing, ExpectNotLink),
+std::make_tuple(AnonTypedef, AnonUsing, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -932,6 +932,27 @@
   EllipsisLoc);
 }
 
+template 
+bool ASTNodeImporter::hasSameVisibilityContext(T *Found, T *From) {
+  if (From->hasExternalFormalLinkage())
+return Found->hasExternalFormalLinkage();
+  if (Importer.GetFromTU(Found) != From->getTranslationUnitDecl())
+return false;
+  if (From->isInAnonymousNamespace())
+return Found->isInAnonymousNamespace();
+  else
+return !Found->isInAnonymousNamespace() &&
+   !Found->hasExternalFormalLinkage();
+}
+
+template <>
+bool ASTNodeImporter::hasSameVisibilityContext(TypedefNameDecl *Found,
+   TypedefNameDecl *From) {
+  if (From->isInAnonymousNamespace() && Found->isInAnonymousNamespace())
+return Importer.GetFromTU(Found) == From->getTranslationUnitDecl();
+  return From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
+}
+
 } // namespace clang
 
 //
@@ -2352,6 +2373,9 @@
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
 continue;
   if (auto *FoundTypedef = dyn_cast(FoundDecl)) {
+

[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp:214
+class Bar {};
+Bar *bar;

It is very unclear what this test does, if I didn't know about this bug. Could 
you add a comment?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945



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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests missing.
Is that what gcc does? I'd personally thought those should be internalized.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



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


[PATCH] D67024: [analyzer] NFC: Replace intrusive list of bug reports with a vector of pointers.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

Thanks for the simplification!




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:460
+  using iterator = ReportList::iterator;
+  using const_iterator = ReportList::const_iterator;
+

I don't think we intend users to use `ReportList`, so it would be better to not 
expose it. Instead:

```
using iterator = SmallVectorImpl>::iterator;
using const_iterator = 
SmallVectorImpl>::const_iterator;
```

... and move it closer to the usage point, right above `begin()` / `end()`. 
WDYT?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67024/new/

https://reviews.llvm.org/D67024



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


[PATCH] D64480: [ASTImporter] Added visibility context check for TypedefNameDecl.

2019-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added a comment.

In D64480#1653629 , @shafik wrote:

> It is worth noting that:
>
>   typedef int T;
>   typedef int T;
>
>
> is not valid C99 see godbolt 


Should we handle this case? This can be special for C99 only when the 
declarations must be merged instead of linked. Probably this does not cause 
functional problems if we leave it as is.




Comment at: lib/AST/ASTImporter.cpp:949
+return Importer.GetFromTU(Found) == From->getTranslationUnitDecl();
+  return From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
+}

shafik wrote:
> I am not sure what case this covers? Can you elaborate? I see the case the 
> condition above is catching.
This (last line) should mean that root level in source file (non-anonymous 
namespace) in different files is treated as same visibility context (like 
"extern" declarations). If namespace is different (anonymous and non-anonymous) 
the context is different.
For `TypedefNameDecl` there is no possibility of external formal linkage (it is 
like always external).



Comment at: unittests/AST/ASTImporterVisibilityTest.cpp:348
+::testing::Values(
+std::make_tuple(ExternTypedef, ExternTypedef, ExpectLink),
+std::make_tuple(ExternTypedef, AnonTypedef, ExpectNotLink),

shafik wrote:
> Perhaps `ExpectLink` would be better as `ExpectLinkedDeclChain` and the same 
> for `ExpectNotLink`.
> 
> It was actually confusing at first because link is an overload term.
I can change it in a later patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64480/new/

https://reviews.llvm.org/D64480



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


[PATCH] D67065: [RISCV] Define __riscv_cmodel_medlow and __riscv_cmodel_medany correctly

2019-09-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
kito-cheng added reviewers: asb, apazos, lewis-revill.
Herald added subscribers: cfe-commits, pzheng, s.egerton, lenary, Jim, benna, 
psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, MaskRay, jrtc27, shiva0217, niosHD, sabuasal, simoncook, 
johnrusso, rbar.
Herald added a project: clang.

RISC-V LLVM was only implement small/medlow code model, so it defined
__riscv_cmodel_medlow directly without check.

Now, we have medium/medany code model in RISC-V back-end, it should
define according the actually code model.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67065

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/Preprocessor/riscv-cmodel.c


Index: clang/test/Preprocessor/riscv-cmodel.c
===
--- /dev/null
+++ clang/test/Preprocessor/riscv-cmodel.c
@@ -0,0 +1,20 @@
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
+// CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
+// CHECK-MEDLOW-NOT: __riscv_cmodel_medany
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+
+// CHECK-MEDANY: #define __riscv_cmodel_medany 1
+// CHECK-MEDANY-NOT: __riscv_cmodel_medlow
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -89,7 +89,14 @@
   bool Is64Bit = getTriple().getArch() == llvm::Triple::riscv64;
   Builder.defineMacro("__riscv_xlen", Is64Bit ? "64" : "32");
   // TODO: modify when more code models are supported.
-  Builder.defineMacro("__riscv_cmodel_medlow");
+  StringRef CodeModel = getTargetOpts().CodeModel;
+  if (CodeModel == "default")
+CodeModel = "small";
+
+  if (CodeModel == "small")
+Builder.defineMacro("__riscv_cmodel_medlow");
+  else if (CodeModel == "medium")
+Builder.defineMacro("__riscv_cmodel_medany");
 
   StringRef ABIName = getABI();
   if (ABIName == "ilp32f" || ABIName == "lp64f")


Index: clang/test/Preprocessor/riscv-cmodel.c
===
--- /dev/null
+++ clang/test/Preprocessor/riscv-cmodel.c
@@ -0,0 +1,20 @@
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
+// CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
+// CHECK-MEDLOW-NOT: __riscv_cmodel_medany
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+
+// CHECK-MEDANY: #define __riscv_cmodel_medany 1
+// CHECK-MEDANY-NOT: __riscv_cmodel_medlow
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -89,7 +89,14 @@
   bool Is64Bit = getTriple().getArch() == llvm::Triple::riscv64;
   Builder.defineMacro("__riscv_xlen", Is64Bit ? "64" : "32");
   // TODO: modify when more code models are supported.
-  Builder.defineMacro("__riscv_cmodel_medlow");
+  StringRef CodeModel = getTargetOpts().CodeModel;
+  if (CodeModel == "default")
+CodeModel = "small";
+
+  if (CodeModel == "small")
+Builder.defineMacro("__riscv_cmodel_medlow");
+  else if (CodeModel == "medium")
+Builder.defineMacro("__riscv_cmodel_medany");
 
   StringRef ABIName = getABI();
   if (ABIName == "ilp32f" || ABIName == "lp64f")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D67066: [RISCV] Add option aliases: -mcmodel=medany and -mcmodel=medlow

2019-09-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
kito-cheng added reviewers: asb, apazos.
Herald added subscribers: cfe-commits, pzheng, s.egerton, lenary, Jim, benna, 
psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, 
johnrusso, rbar.
Herald added a project: clang.
kito-cheng added a parent revision: D67065: [RISCV] Define 
__riscv_cmodel_medlow and __riscv_cmodel_medany correctly.

RISC-V GCC use -mcmodel=medany and -mcmodel=medlow, but LLVM use -mcmodel=small 
and -mcmodel=medium.

Add those two option aliases to provide same user interface between GCC and 
LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67066

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Preprocessor/riscv-cmodel.c


Index: clang/test/Preprocessor/riscv-cmodel.c
===
--- clang/test/Preprocessor/riscv-cmodel.c
+++ clang/test/Preprocessor/riscv-cmodel.c
@@ -8,6 +8,11 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
 // RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
 // CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
 // CHECK-MEDLOW-NOT: __riscv_cmodel_medany
 
@@ -16,5 +21,10 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
 // RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+
 // CHECK-MEDANY: #define __riscv_cmodel_medany 1
 // CHECK-MEDANY-NOT: __riscv_cmodel_medlow
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2166,6 +2166,12 @@
   HelpText<"Enable using library calls for save and restore">;
 def mno_save_restore : Flag<["-"], "mno-save-restore">, 
Group,
   HelpText<"Disable using library calls for save and restore">;
+def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, 
Group,
+  Flags<[CC1Option]>, Alias, AliasArgs<["small"]>,
+  HelpText<"Equivalent to -mcmodel=small, compatible with RISC-V gcc.">;
+def mcmodel_EQ_medany : Flag<["-"], "mcmodel=medany">, 
Group,
+  Flags<[CC1Option]>, Alias, AliasArgs<["medium"]>,
+  HelpText<"Equivalent to -mcmodel=medium, compatible with RISC-V gcc.">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
   HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;


Index: clang/test/Preprocessor/riscv-cmodel.c
===
--- clang/test/Preprocessor/riscv-cmodel.c
+++ clang/test/Preprocessor/riscv-cmodel.c
@@ -8,6 +8,11 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
 // RUN: -mcmodel=small -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medlow -o - | FileCheck --check-prefix=CHECK-MEDLOW %s
+
 // CHECK-MEDLOW: #define __riscv_cmodel_medlow 1
 // CHECK-MEDLOW-NOT: __riscv_cmodel_medany
 
@@ -16,5 +21,10 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
 // RUN: -mcmodel=medium -o - | FileCheck --check-prefix=CHECK-MEDANY %s
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -mcmodel=medany -o - | FileCheck --check-prefix=CHECK-MEDANY %s
+
 // CHECK-MEDANY: #define __riscv_cmodel_medany 1
 // CHECK-MEDANY-NOT: __riscv_cmodel_medlow
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2166,6 +2166,12 @@
   HelpText<"Enable using library calls for save and restore">;
 def mno_save_restore : Flag<["-"], "mno-save-restore">, Group,
   HelpText<"Disable using library calls for save and restore">;
+def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, Group,
+  Flags<[CC1Option]>, Alias, AliasArgs<["small"]>,
+  He

[PATCH] D66524: [SVE][Inline-Asm] Add constraints for SVE predicate registers

2019-09-02 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

Just some drive-by suggestions :)




Comment at: lib/Target/AArch64/AArch64ISelLowering.cpp:5747
+
+PredicateConstraint isPredicateConstraint(StringRef Constraint) {
+  PredicateConstraint P = PredicateConstraint::Invalid;

Nit: I think get- or parsePredicateConstraint reads better, since this doesn't 
return a simple yes/no answer.



Comment at: test/CodeGen/AArch64/aarch64-sve-asm.ll:50
+; CHECK: [[ARG3:%[0-9]+]]:ppr = COPY $p0
+; CHECK: [[ARG4:%[0-9]+]]:ppr_3b = COPY [[ARG3]]
+define  @test_svfadd_f16( %Pg,  %Zn,  %Zm) {

Nit: I would be a bit pedantic here and also check that they are used for the 
inline asm.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66524/new/

https://reviews.llvm.org/D66524



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


[PATCH] D67065: [RISCV] Define __riscv_cmodel_medlow and __riscv_cmodel_medany correctly

2019-09-02 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill accepted this revision.
lewis-revill added a comment.
This revision is now accepted and ready to land.

Thanks Kito. This looks good to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67065/new/

https://reviews.llvm.org/D67065



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


[PATCH] D67024: [analyzer] NFC: Replace intrusive list of bug reports with a vector of pointers.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:460
+  using iterator = ReportList::iterator;
+  using const_iterator = ReportList::const_iterator;
+

gribozavr wrote:
> I don't think we intend users to use `ReportList`, so it would be better to 
> not expose it. Instead:
> 
> ```
> using iterator = SmallVectorImpl>::iterator;
> using const_iterator = 
> SmallVectorImpl>::const_iterator;
> ```
> 
> ... and move it closer to the usage point, right above `begin()` / `end()`. 
> WDYT?
Could even do away with all these typedefs, and four begin/end overloads, and 
replace everything with:

```
ArrayRef> Reports() const;
```

I believe we don't even need a non-const overload since `unique_ptr` allows 
mutations regardless.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67024/new/

https://reviews.llvm.org/D67024



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


[PATCH] D67024: [analyzer] NFC: Replace intrusive list of bug reports with a vector of pointers.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:460
+  using iterator = ReportList::iterator;
+  using const_iterator = ReportList::const_iterator;
+

gribozavr wrote:
> gribozavr wrote:
> > I don't think we intend users to use `ReportList`, so it would be better to 
> > not expose it. Instead:
> > 
> > ```
> > using iterator = SmallVectorImpl>::iterator;
> > using const_iterator = 
> > SmallVectorImpl>::const_iterator;
> > ```
> > 
> > ... and move it closer to the usage point, right above `begin()` / `end()`. 
> > WDYT?
> Could even do away with all these typedefs, and four begin/end overloads, and 
> replace everything with:
> 
> ```
> ArrayRef> Reports() const;
> ```
> 
> I believe we don't even need a non-const overload since `unique_ptr` allows 
> mutations regardless.
`BugReports` would be a better name.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67024/new/

https://reviews.llvm.org/D67024



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


r370639 - [AST] AST structural equivalence to work internally with pairs.

2019-09-02 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Mon Sep  2 04:01:09 2019
New Revision: 370639

URL: http://llvm.org/viewvc/llvm-project?rev=370639&view=rev
Log:
[AST] AST structural equivalence to work internally with pairs.

Summary:
The structural equivalence check stores now pairs of nodes in the
'from' and 'to' context instead of only the node in 'from' context
and a corresponding one in 'to' context. This is needed to handle
cases when a Decl in the 'from' context is to be compared with
multiple Decls in the 'to' context.

Reviewers: martong, a_sidorin

Reviewed By: martong, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Modified: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h?rev=370639&r1=370638&r2=370639&view=diff
==
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h (original)
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h Mon Sep  2 04:01:09 
2019
@@ -18,7 +18,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
-#include 
+#include 
 #include 
 
 namespace clang {
@@ -42,14 +42,13 @@ struct StructuralEquivalenceContext {
   /// AST contexts for which we are checking structural equivalence.
   ASTContext &FromCtx, &ToCtx;
 
-  /// The set of "tentative" equivalences between two canonical
-  /// declarations, mapping from a declaration in the first context to the
-  /// declaration in the second context that we believe to be equivalent.
-  llvm::DenseMap TentativeEquivalences;
-
-  /// Queue of declarations in the first context whose equivalence
-  /// with a declaration in the second context still needs to be verified.
-  std::deque DeclsToCheck;
+  // Queue of from-to Decl pairs that are to be checked to determine the final
+  // result of equivalence of a starting Decl pair.
+  std::queue> DeclsToCheck;
+
+  // Set of from-to Decl pairs that are already visited during the check
+  // (are in or were once in \c DeclsToCheck) of a starting Decl pair.
+  llvm::DenseSet> VisitedDecls;
 
   /// Declaration (from, to) pairs that are known not to be equivalent
   /// (which we have already complained about).
@@ -88,14 +87,14 @@ struct StructuralEquivalenceContext {
   /// Implementation functions (all static functions in
   /// ASTStructuralEquivalence.cpp) must never call this function because that
   /// will wreak havoc the internal state (\c DeclsToCheck and
-  /// \c TentativeEquivalences members) and can cause faulty equivalent 
results.
+  /// \c VisitedDecls members) and can cause faulty equivalent results.
   bool IsEquivalent(Decl *D1, Decl *D2);
 
   /// Determine whether the two types are structurally equivalent.
   /// Implementation functions (all static functions in
   /// ASTStructuralEquivalence.cpp) must never call this function because that
   /// will wreak havoc the internal state (\c DeclsToCheck and
-  /// \c TentativeEquivalences members) and can cause faulty equivalent 
results.
+  /// \c VisitedDecls members) and can cause faulty equivalent results.
   bool IsEquivalent(QualType T1, QualType T2);
 
   /// Find the index of the given anonymous struct/union within its

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=370639&r1=370638&r2=370639&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Mon Sep  2 04:01:09 2019
@@ -1574,20 +1574,24 @@ static bool IsStructurallyEquivalent(Str
  Decl *D1, Decl *D2) {
   // FIXME: Check for known structural equivalences via a callback of some 
sort.
 
+  D1 = D1->getCanonicalDecl();
+  D2 = D2->getCanonicalDecl();
+  std::pair P{D1, D2};
+
   // Check whether we already know that these two declarations are not
   // structurally equivalent.
-  if (Context.NonEquivalentDecls.count(
-  std::make_pair(D1->getCanonicalDecl(), D2->getCanonicalDecl(
+  if (Context.NonEquivalentDecls.count(P))
 return false;
 
-  // Determine whether we've already produced a tentative equivalence for D1.
-  Decl *&EquivToD1 = Context.TentativeEquivalences[D1->getCanonicalDecl()];
-  if (EquivToD1)
-return EquivToD1 == D2->getCanonicalDecl();
-
-  // Produce a tentative equivalence D1 <-> D2, which will be checked later.
-  EquivToD1 = D2->getCanonicalDecl();
-  Context.DeclsToCheck.push_back(D1->getCanonicalDecl());
+  // Check if a check for these declarations is alre

[PATCH] D66538: [AST] AST structural equivalence to work internally with pairs.

2019-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370639: [AST] AST structural equivalence to work internally 
with pairs. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66538?vs=217105&id=218327#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66538/new/

https://reviews.llvm.org/D66538

Files:
  cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
  cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
  cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Index: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
===
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
@@ -18,7 +18,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
-#include 
+#include 
 #include 
 
 namespace clang {
@@ -42,14 +42,13 @@
   /// AST contexts for which we are checking structural equivalence.
   ASTContext &FromCtx, &ToCtx;
 
-  /// The set of "tentative" equivalences between two canonical
-  /// declarations, mapping from a declaration in the first context to the
-  /// declaration in the second context that we believe to be equivalent.
-  llvm::DenseMap TentativeEquivalences;
-
-  /// Queue of declarations in the first context whose equivalence
-  /// with a declaration in the second context still needs to be verified.
-  std::deque DeclsToCheck;
+  // Queue of from-to Decl pairs that are to be checked to determine the final
+  // result of equivalence of a starting Decl pair.
+  std::queue> DeclsToCheck;
+
+  // Set of from-to Decl pairs that are already visited during the check
+  // (are in or were once in \c DeclsToCheck) of a starting Decl pair.
+  llvm::DenseSet> VisitedDecls;
 
   /// Declaration (from, to) pairs that are known not to be equivalent
   /// (which we have already complained about).
@@ -88,14 +87,14 @@
   /// Implementation functions (all static functions in
   /// ASTStructuralEquivalence.cpp) must never call this function because that
   /// will wreak havoc the internal state (\c DeclsToCheck and
-  /// \c TentativeEquivalences members) and can cause faulty equivalent results.
+  /// \c VisitedDecls members) and can cause faulty equivalent results.
   bool IsEquivalent(Decl *D1, Decl *D2);
 
   /// Determine whether the two types are structurally equivalent.
   /// Implementation functions (all static functions in
   /// ASTStructuralEquivalence.cpp) must never call this function because that
   /// will wreak havoc the internal state (\c DeclsToCheck and
-  /// \c TentativeEquivalences members) and can cause faulty equivalent results.
+  /// \c VisitedDecls members) and can cause faulty equivalent results.
   bool IsEquivalent(QualType T1, QualType T2);
 
   /// Find the index of the given anonymous struct/union within its
Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
===
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
@@ -1574,20 +1574,24 @@
  Decl *D1, Decl *D2) {
   // FIXME: Check for known structural equivalences via a callback of some sort.
 
+  D1 = D1->getCanonicalDecl();
+  D2 = D2->getCanonicalDecl();
+  std::pair P{D1, D2};
+
   // Check whether we already know that these two declarations are not
   // structurally equivalent.
-  if (Context.NonEquivalentDecls.count(
-  std::make_pair(D1->getCanonicalDecl(), D2->getCanonicalDecl(
+  if (Context.NonEquivalentDecls.count(P))
 return false;
 
-  // Determine whether we've already produced a tentative equivalence for D1.
-  Decl *&EquivToD1 = Context.TentativeEquivalences[D1->getCanonicalDecl()];
-  if (EquivToD1)
-return EquivToD1 == D2->getCanonicalDecl();
-
-  // Produce a tentative equivalence D1 <-> D2, which will be checked later.
-  EquivToD1 = D2->getCanonicalDecl();
-  Context.DeclsToCheck.push_back(D1->getCanonicalDecl());
+  // Check if a check for these declarations is already pending.
+  // If yes D1 and D2 will be checked later (from DeclsToCheck),
+  // or these are already checked (and equivalent).
+  bool Inserted = Context.VisitedDecls.insert(P).second;
+  if (!Inserted)
+return true;
+
+  Context.DeclsToCheck.push(P);
+
   return true;
 }
 
@@ -1703,11 +1707,13 @@
   // Ensure that the implementation functions (all static functions in this TU)
   // never call the public ASTStructuralEquivalence::IsEquivalent() functions,
   // because that will wreak havoc the internal state (DeclsToCheck and
-  // TentativeEquivalences members) and can cause faulty behaviour. For
-  // instance, some leaf declarations can be stated and cached as inequivalent
-  // as a side effect of one 

[PATCH] D65182: [analyzer] Add fix-it hint support.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:350
+
+  llvm::ArrayRef getFixits() const { return Fixits; }
+

No need to qualify with "llvm::".



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:491
+   ArrayRef Ranges = None,
+   ArrayRef Fixits = None);
 

I'm not sure if this is the right model for fixits. Fixits are usually 
associated with a message that explains what the fixit does. Only in the 
unusual case where Clang or ClangTidy is very confident that the fixit is 
correct, it is attached to the warning. Most commonly, fixits are attached to 
notes.

Also, for IDE support, it would be really nice if we could provide short 
descriptions of edits themselves (e.g., "replace 'virtual' with 'override") 
that can be displayed to the user instead of the diff when possible -- right 
now we don't and tools using ClangTidy have to use a subpar UI because of that. 
For example, when we show UI for fixing a warning, displaying the complete diff 
is too much; a concise description would be a lot better.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65182/new/

https://reviews.llvm.org/D65182



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


[PATCH] D59922: [Attributor] Deduce "no-capture" argument attribute

2019-09-02 Thread Hideto Ueno via Phabricator via cfe-commits
uenoku accepted this revision.
uenoku added a comment.
This revision is now accepted and ready to land.

I think the logic is sound. It looks good to me.




Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2618
+else
+  Attrs.emplace_back(Attribute::get(Ctx, "no-capture-maybe-returned"));
+  }

Maybe we need an exact definition for `no-capture-maybe-returned` in LangRef.



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2674
+  /// "no-capture-maybe-returned", the user is added to the \p PotentialCopies
+  /// set. All values in \p PotentialCopies are later tracked aswell. For every
+  /// explored use we decrement \p RemainingUsesToExplore. Once it reaches 0,

aswell



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2761
+  /// Register \p CS as potential copy of the value we are checking.
+  void addPotentialCopyIfNecessary(CallSite CS) {
+PotentialCopies.push_back(CS.getInstruction());

Why `IfNecessary`? It seems there is no check.



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2819
+
+  AAAlign::StateType T;
+  // TODO: Once we have memory behavior attributes we should use them here

Align?



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:2864
+// TODO: Once we have call site specific value information we can provide
+//   call site specific liveness liveness information and then it makes
+//   sense to specialize attributes for call sites arguments instead of

liveness liveness


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59922/new/

https://reviews.llvm.org/D59922



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


r370642 - Revert [Clang Interpreter] Initial patch for the constexpr interpreter

2019-09-02 Thread Nandor Licker via cfe-commits
Author: nand
Date: Mon Sep  2 04:34:47 2019
New Revision: 370642

URL: http://llvm.org/viewvc/llvm-project?rev=370642&view=rev
Log:
Revert [Clang Interpreter] Initial patch for the constexpr interpreter

This reverts r370636 (git commit 8327fed9475a14c3376b4860c75370c730e08f33)

Removed:
cfe/trunk/docs/ConstantInterpreter.rst
cfe/trunk/include/clang/AST/OptionalDiagnostic.h
cfe/trunk/lib/AST/Interp/
cfe/trunk/test/AST/Interp/
cfe/trunk/utils/TableGen/ClangOpcodesEmitter.cpp
Modified:
cfe/trunk/docs/index.rst
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
cfe/trunk/test/SemaCXX/shift.cpp
cfe/trunk/utils/TableGen/CMakeLists.txt
cfe/trunk/utils/TableGen/TableGen.cpp
cfe/trunk/utils/TableGen/TableGenBackends.h

Removed: cfe/trunk/docs/ConstantInterpreter.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ConstantInterpreter.rst?rev=370641&view=auto
==
--- cfe/trunk/docs/ConstantInterpreter.rst (original)
+++ cfe/trunk/docs/ConstantInterpreter.rst (removed)
@@ -1,194 +0,0 @@
-
-Constant Interpreter
-
-
-.. contents::
-   :local:
-
-Introduction
-
-
-The constexpr interpreter aims to replace the existing tree evaluator in 
clang, improving performance on constructs which are executed inefficiently by 
the evaluator. The interpreter is activated using the following flags:
-
-* ``-fexperimental-new-constant-interpreter`` enables the interpreter, falling 
back to the evaluator for unsupported features
-* ``-fforce-experimental-new-constant-interpreter`` forces the use of the 
interpreter, bailing out if an unsupported feature is encountered
-
-Bytecode Compilation
-
-
-Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements and 
``ByteCodeExprGen.h`` for expressions. The compiler has two different backends: 
one to generate bytecode for functions (``ByteCodeEmitter``) and one to 
directly evaluate expressions as they are compiled, without generating bytecode 
(``EvalEmitter``). All functions are compiled to bytecode, while toplevel 
expressions used in constant contexts are directly evaluated since the bytecode 
would never be reused. This mechanism aims to pave the way towards replacing 
the evaluator, improving its performance on functions and loops, while being 
just as fast on single-use toplevel expressions.
-
-The interpreter relies on stack-based, strongly-typed opcodes. The glue logic 
between the code generator, along with the enumeration and description of 
opcodes, can be found in ``Opcodes.td``. The opcodes are implemented as generic 
template methods in ``Interp.h`` and instantiated with the relevant primitive 
types by the interpreter loop or by the evaluating emitter.
-
-Primitive Types

-
-* ``PT_{U|S}int{8|16|32|64}``
-
-  Signed or unsigned integers of a specific bit width, implemented using the 
```Integral``` type.
-
-* ``PT_{U|S}intFP``
-
-  Signed or unsigned integers of an arbitrary, but fixed width used to 
implement
-  integral types which are required by the target, but are not supported by 
the host.
-  Under the hood, they rely on APValue. The ``Integral`` specialisation for 
these
-  types is required by opcodes to share an implementation with fixed integrals.
-
-* ``PT_Bool``
-
-  Representation for boolean types, essentially a 1-bit unsigned ``Integral``.
-
-* ``PT_RealFP``
-
-  Arbitrary, but fixed precision floating point numbers. Could be specialised 
in
-  the future similarly to integers in order to improve floating point 
performance.
-
-* ``PT_Ptr``
-
-  Pointer type, defined in ``"Pointer.h"``.
-
-* ``PT_FnPtr``
-
-  Function pointer type, can also be a null function pointer. Defined in 
``"Pointer.h"``.
-
-* ``PT_MemPtr``
-
-  Member pointer type, can also be a null member pointer. Defined in 
``"Pointer.h"``
-
-Composite types

-
-The interpreter distinguishes two kinds of composite types: arrays and 
records. Unions are represented as records, except a single field can be marked 
as active. The contents of inactive fields are kept until they
-are reactivated and overwritten.
-
-
-Bytecode Execution
-==
-
-Bytecode is executed using a stack-based interpreter. The execution context 
consists of an ``InterpStack``, along with a chain of ``InterpFrame`` objects 
storing the call frames. Frames are built by call instructions and destroyed by 
return instructi

Re: r370642 - Revert [Clang Interpreter] Initial patch for the constexpr interpreter

2019-09-02 Thread Roman Lebedev via cfe-commits
When reverting a commit it is customary to mention *why* it is getting reverted.

On Mon, Sep 2, 2019 at 2:33 PM Nandor Licker via cfe-commits
 wrote:
>
> Author: nand
> Date: Mon Sep  2 04:34:47 2019
> New Revision: 370642
>
> URL: http://llvm.org/viewvc/llvm-project?rev=370642&view=rev
> Log:
> Revert [Clang Interpreter] Initial patch for the constexpr interpreter
>
> This reverts r370636 (git commit 8327fed9475a14c3376b4860c75370c730e08f33)
>
> Removed:
> cfe/trunk/docs/ConstantInterpreter.rst
> cfe/trunk/include/clang/AST/OptionalDiagnostic.h
> cfe/trunk/lib/AST/Interp/
> cfe/trunk/test/AST/Interp/
> cfe/trunk/utils/TableGen/ClangOpcodesEmitter.cpp
> Modified:
> cfe/trunk/docs/index.rst
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/CMakeLists.txt
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
> cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
> cfe/trunk/test/SemaCXX/shift.cpp
> cfe/trunk/utils/TableGen/CMakeLists.txt
> cfe/trunk/utils/TableGen/TableGen.cpp
> cfe/trunk/utils/TableGen/TableGenBackends.h
>
> Removed: cfe/trunk/docs/ConstantInterpreter.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ConstantInterpreter.rst?rev=370641&view=auto
> ==
> --- cfe/trunk/docs/ConstantInterpreter.rst (original)
> +++ cfe/trunk/docs/ConstantInterpreter.rst (removed)
> @@ -1,194 +0,0 @@
> -
> -Constant Interpreter
> -
> -
> -.. contents::
> -   :local:
> -
> -Introduction
> -
> -
> -The constexpr interpreter aims to replace the existing tree evaluator in 
> clang, improving performance on constructs which are executed inefficiently 
> by the evaluator. The interpreter is activated using the following flags:
> -
> -* ``-fexperimental-new-constant-interpreter`` enables the interpreter, 
> falling back to the evaluator for unsupported features
> -* ``-fforce-experimental-new-constant-interpreter`` forces the use of the 
> interpreter, bailing out if an unsupported feature is encountered
> -
> -Bytecode Compilation
> -
> -
> -Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements and 
> ``ByteCodeExprGen.h`` for expressions. The compiler has two different 
> backends: one to generate bytecode for functions (``ByteCodeEmitter``) and 
> one to directly evaluate expressions as they are compiled, without generating 
> bytecode (``EvalEmitter``). All functions are compiled to bytecode, while 
> toplevel expressions used in constant contexts are directly evaluated since 
> the bytecode would never be reused. This mechanism aims to pave the way 
> towards replacing the evaluator, improving its performance on functions and 
> loops, while being just as fast on single-use toplevel expressions.
> -
> -The interpreter relies on stack-based, strongly-typed opcodes. The glue 
> logic between the code generator, along with the enumeration and description 
> of opcodes, can be found in ``Opcodes.td``. The opcodes are implemented as 
> generic template methods in ``Interp.h`` and instantiated with the relevant 
> primitive types by the interpreter loop or by the evaluating emitter.
> -
> -Primitive Types
> 
> -
> -* ``PT_{U|S}int{8|16|32|64}``
> -
> -  Signed or unsigned integers of a specific bit width, implemented using the 
> ```Integral``` type.
> -
> -* ``PT_{U|S}intFP``
> -
> -  Signed or unsigned integers of an arbitrary, but fixed width used to 
> implement
> -  integral types which are required by the target, but are not supported by 
> the host.
> -  Under the hood, they rely on APValue. The ``Integral`` specialisation for 
> these
> -  types is required by opcodes to share an implementation with fixed 
> integrals.
> -
> -* ``PT_Bool``
> -
> -  Representation for boolean types, essentially a 1-bit unsigned 
> ``Integral``.
> -
> -* ``PT_RealFP``
> -
> -  Arbitrary, but fixed precision floating point numbers. Could be 
> specialised in
> -  the future similarly to integers in order to improve floating point 
> performance.
> -
> -* ``PT_Ptr``
> -
> -  Pointer type, defined in ``"Pointer.h"``.
> -
> -* ``PT_FnPtr``
> -
> -  Function pointer type, can also be a null function pointer. Defined in 
> ``"Pointer.h"``.
> -
> -* ``PT_MemPtr``
> -
> -  Member pointer type, can also be a null member pointer. Defined in 
> ``"Pointer.h"``
> -
> -Composite types
> 
> -
> -The interpreter distinguishes two kinds of composite types: arrays and 
> records. Unions are represented as records, except a single field can

[PATCH] D66572: [analyzer] NFC: BugReporter Separation Ep.I.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Thank you for the conversation so far! This is not a complete review from me, 
but I'm trying to avoid branching in too many directions at once.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:122
+  /// Get the location on which the report should be uniqued.
+  virtual PathDiagnosticLocation getUniqueingLocation() const {
+return Location;

NoQ wrote:
> gribozavr wrote:
> > Where can I read about the uniqueing logic? Does it mean that out of two 
> > bug reports with the same location only one gets displayed, regardless of 
> > other properties?
> Added some comments ^^
Thanks for the comments, but sorry, this one is still unclear.

(1)

```
// Imagine a ClangTidy checker that finds calls to math functions where it is 

double foo() {
  return sqrt(-1); // warning: 'sqrt' will always return NaN
}
```

What should be the "decl with issue" here? 'foo' or 'sqrt'?

(2)

```
#include 
using std::vector; // warning: using names from 'std' is error-prone
```

(3)

```
void foo(Foo f) {
  bar(std::move(f)); // warning: passing result of 'std::move' as a const 
reference argument, no move will actually happen
}
```

Is it 'foo', 'bar', 'std::move', or the copy constructor of 'Foo'?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:126-135
+  /// Get the declaration containing the uniqueing location.
+  virtual const Decl *getUniqueingDecl() const {
+return DeclWithIssue;
+  }
+
+  /// Return the canonical declaration, be it a method or class, where
+  /// this issue semantically occurred.

NoQ wrote:
> gribozavr wrote:
> > I don't think `getUniqueingDecl()` and `getDeclWithIssue()` make sense for 
> > most ClangTidy checkers.
> `getDeclWithIssue()` corresponds to the "Function/Method" column we have in 
> our scan-build index page:
> 
> {F9881207}
> 
> This column is not super important but probably kinda nice to have. I don't 
> mind leaving it empty for clang-tidy checks, or possibly auto-detect it post 
> factum when possible (e.g., find the smallest decl in which the warning 
> location is contained).
> 
> `getUniqueingDecl()` is, as far as i understand, only currently used by the 
> issue hash mechanism which governs deduplication across translation units 
> (e.g., we emit a warning against the same header in multiple translation 
> units - it's vital for the static analyzer because it's not uncommon for an 
> execution path that starts in the main file to end in a header). And even 
> then, it's only present in plist output. I'm not convinced it's useful at 
> all. It's likely that we can remove it.
> 
> Also clang-tidy checks wouldn't need to specify their `UniqueingDecl` 
> manually as it silently defaults to their `DeclWithIssue`.
> 
> So basically we have these two methods on the base class for bureaucratic 
> reasons: our existing algorithms handle all kinds of warnings uniformly based 
> on these computed properties of bug reports. I think we should be perfectly 
> fine if some kinds of bug reports return null from them, indicating that 
> "this property doesn't make sense for them". We could instead reinvent 
> protocols on top of our custom RTTI ("does this warning conform to 
> `Uniqueable`? if so, i'll try to unique it"), but i don't think it's worth 
> the complexity.
> `getDeclWithIssue()` corresponds to the "Function/Method" column we have in 
> our scan-build index page:

Judging from the screenshot, that column seems to play a function of a 
human-readable summary of the warning location. Is that correct?

Should we determine it automatically from `getLocation()`? Is there a use case 
for `getDeclWithIssue()` be different from the function/class that 
`getLocation()` is pointing into?

> (e.g., find the smallest decl in which the warning location is contained).

Oh you are saying the same thing. Why not have it always be auto-detected? Is 
there a use case for manual curation?

> `getUniqueingDecl()` [...] I'm not convinced it's useful at all. It's likely 
> that we can remove it.

I agree about eliminating it -- actually, replacing it with comparing source 
locations. In our experience running ClangTidy, uniquing bug reports based on 
source locations works quite well. Can you give it a go in a separate patch 
that we can land ahead of time? I see there are only 4 callers of the BugReport 
constructor that accepts the location.

Also the doc comment is somewhat contradictory. "declarations that ... contains 
... the uniqueing location. This is not actively used for uniqueing..."



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:186
+  /// ranges.
+  void addRange(SourceRange R) {
+assert((R.isValid() || Ranges.empty()) && "Invalid range can only be used "

NoQ wrote:
> gribozavr wrote:
> > Ranges should be associated with a message.
> Mmm, what do you mean?
> 
>

[PATCH] D65182: [analyzer] Add fix-it hint support.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/test/Analysis/dead-stores.c:11
   long idx=abc+3*5; // expected-warning {{never read}} 
expected-warning{{unused variable 'idx'}}
+  // expected-remark-re@-1.*}}:11 - {{.*}}:18 - ''}}
 }

NoQ wrote:
> gribozavr wrote:
> > If the tests ignore the line number anyway, why even print it?
> I anyway hope that this facility is temporary(c).
What's the eventual replacement?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65182/new/

https://reviews.llvm.org/D65182



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


[PATCH] D66652: [libTooling] Transformer: refine `SourceLocation` specified as anchor of changes.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

> So, I plan to rework this into two revisions: one to match 
> https://reviews.llvm.org/D66676 (and keep the tests esssentially as they are) 
> and one to add getRuleMatchLoc for future use.

That SGTM.

I don't have an opinion about whether they should be separate revisions or not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66652/new/

https://reviews.llvm.org/D66652



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


[PATCH] D66806: [LifetimeAnalysis] Fix some false positives

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

Looks like a reasonable way to suppress some false positives. It will suppress 
some true positives (e.g., imagine an "identity" function that returns the same 
pointer as was provided to it), but I guess you're aware of that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66806/new/

https://reviews.llvm.org/D66806



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


r370650 - [unittests][AST] CommentParser: don't name variable 'DEBUG'

2019-09-02 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Sep  2 05:34:21 2019
New Revision: 370650

URL: http://llvm.org/viewvc/llvm-project?rev=370650&view=rev
Log:
[unittests][AST] CommentParser: don't name variable 'DEBUG'

It's may be an already-defined macro name,
resulting in compilation errors.

Modified:
cfe/trunk/unittests/AST/CommentParser.cpp

Modified: cfe/trunk/unittests/AST/CommentParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentParser.cpp?rev=370650&r1=370649&r2=370650&view=diff
==
--- cfe/trunk/unittests/AST/CommentParser.cpp (original)
+++ cfe/trunk/unittests/AST/CommentParser.cpp Mon Sep  2 05:34:21 2019
@@ -28,7 +28,7 @@ namespace comments {
 
 namespace {
 
-const bool DEBUG = true;
+const bool MY_DEBUG = true;
 
 class CommentParserTest : public ::testing::Test {
 protected:
@@ -62,7 +62,7 @@ FullComment *CommentParserTest::parseStr
   Parser P(L, S, Allocator, SourceMgr, Diags, Traits);
   FullComment *FC = P.parseFullComment();
 
-  if (DEBUG) {
+  if (MY_DEBUG) {
 llvm::errs() << "=== Source:\n" << Source << "\n=== AST:\n";
 FC->dump(llvm::errs(), &Traits, &SourceMgr);
   }


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


[PATCH] D66572: [analyzer] NFC: BugReporter Separation Ep.I.

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:174
+  ///  This location is used by clients rendering diagnostics.
+  virtual PathDiagnosticLocation getLocation(const SourceManager &SM) const {
+assert(Location.isValid());

gribozavr wrote:
> Another location-related method... I guess I would appreciate a more abstract 
> writeup about what BugReport's data model is (in its doc comment).
What I meant by "data model" is a high-level description like this.

A bug report is one instance of a problem found by a checker. It is similar to 
a warning in Clang.

A bug report has:

- a description which is ...

- a short description (optional), which is ...

- zero or more ranges, which ...

- zero or more fixits, which provide advice about ...

- zero  or more notes, which ...

Each fixit has: ...

Each note has...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66572/new/

https://reviews.llvm.org/D66572



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


[PATCH] D67077: [libclang] Refactored SharedParsedRegionsStorage

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
gribozavr added a reviewer: jkorous.
Herald added a subscriber: dexonsmith.

Removed the `PPRegionSetTy` typedef because it is only used 3 times, and
obscures code more than it helps.

Renamed SharedParsedRegionsStorage to ThreadSafeParsedRegions, because
that better reflects the reason for this type to exist.

Replaced the `copyTo()` method that had an out parameter with a getter.

Renamed the `merge()` method to `addParsedRegions()`.

Renamed `ParsedSrcLocationsTracker::ParsedRegions` to
`ParsedRegionsSnapshot`, which better reflects its role.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67077

Files:
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -88,8 +88,6 @@
   }
 };
 
-typedef llvm::DenseSet PPRegionSetTy;
-
 } // end anonymous namespace
 
 namespace llvm {
@@ -124,20 +122,20 @@
 /// Keeps track of function bodies that have already been parsed.
 ///
 /// Is thread-safe.
-class SharedParsedRegionsStorage {
-  std::mutex Mux;
-  PPRegionSetTy ParsedRegions;
+class ThreadSafeParsedRegions {
+  mutable std::mutex Mutex;
+  llvm::DenseSet ParsedRegions;
 
 public:
-  ~SharedParsedRegionsStorage() = default;
+  ~ThreadSafeParsedRegions() = default;
 
-  void copyTo(PPRegionSetTy &Set) {
-std::lock_guard MG(Mux);
-Set = ParsedRegions;
+  llvm::DenseSet getParsedRegions() const {
+std::lock_guard MG(Mutex);
+return ParsedRegions;
   }
 
-  void merge(ArrayRef Regions) {
-std::lock_guard MG(Mux);
+  void addParsedRegions(ArrayRef Regions) {
+std::lock_guard MG(Mutex);
 ParsedRegions.insert(Regions.begin(), Regions.end());
   }
 };
@@ -147,13 +145,13 @@
 ///
 /// Is NOT thread-safe.
 class ParsedSrcLocationsTracker {
-  SharedParsedRegionsStorage &ParsedRegionsStorage;
+  ThreadSafeParsedRegions &ParsedRegionsStorage;
   PPConditionalDirectiveRecord &PPRec;
   Preprocessor &PP;
 
   /// Snapshot of the shared state at the point when this instance was
   /// constructed.
-  PPRegionSetTy ParsedRegions;
+  llvm::DenseSet ParsedRegionsSnapshot;
   /// Regions that were queried during this instance lifetime.
   SmallVector NewParsedRegions;
 
@@ -163,12 +161,11 @@
 
 public:
   /// Creates snapshot of \p ParsedRegionsStorage.
-  ParsedSrcLocationsTracker(SharedParsedRegionsStorage &ParsedRegionsStorage,
+  ParsedSrcLocationsTracker(ThreadSafeParsedRegions &ParsedRegionsStorage,
 PPConditionalDirectiveRecord &ppRec,
 Preprocessor &pp)
-  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp) {
-ParsedRegionsStorage.copyTo(ParsedRegions);
-  }
+  : ParsedRegionsStorage(ParsedRegionsStorage), PPRec(ppRec), PP(pp),
+ParsedRegionsSnapshot(ParsedRegionsStorage.getParsedRegions()) {}
 
   /// \returns true iff \p Loc has already been parsed.
   ///
@@ -190,14 +187,16 @@
 // That means if we hit the same region again, it's a different location in
 // the same region and so the "is parsed" value from the snapshot is still
 // correct.
-LastIsParsed = ParsedRegions.count(region);
+LastIsParsed = ParsedRegionsSnapshot.count(region);
 if (!LastIsParsed)
   NewParsedRegions.emplace_back(std::move(region));
 return LastIsParsed;
   }
 
   /// Updates ParsedRegionsStorage with newly parsed regions.
-  void syncWithStorage() { ParsedRegionsStorage.merge(NewParsedRegions); }
+  void syncWithStorage() {
+ParsedRegionsStorage.addParsedRegions(NewParsedRegions);
+  }
 
 private:
   PPRegion getRegion(SourceLocation Loc, FileID FID, const FileEntry *FE) {
@@ -336,13 +335,13 @@
   std::shared_ptr DataConsumer;
   IndexingOptions Opts;
 
-  SharedParsedRegionsStorage *SKData;
+  ThreadSafeParsedRegions *SKData;
   std::unique_ptr ParsedLocsTracker;
 
 public:
   IndexingFrontendAction(std::shared_ptr dataConsumer,
  const IndexingOptions &Opts,
- SharedParsedRegionsStorage *skData)
+ ThreadSafeParsedRegions *skData)
   : DataConsumer(std::move(dataConsumer)), Opts(Opts), SKData(skData) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
@@ -431,10 +430,10 @@
 
 struct IndexSessionData {
   CXIndex CIdx;
-  std::unique_ptr SkipBodyData;
+  std::unique_ptr SkipBodyData =
+  std::make_unique();
 
-  explicit IndexSessionData(CXIndex cIdx)
-  : CIdx(cIdx), SkipBodyData(new SharedParsedRegionsStorage) {}
+  explicit IndexSessionData(CXIndex cIdx) : CIdx(cIdx) {}
 };
 
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66694: [libclang][index][NFCi] Refactor machinery for skipping already parsed function bodies

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/tools/libclang/Indexing.cpp:134
   void copyTo(PPRegionSetTy &Set) {
 std::lock_guard MG(Mux);
 Set = ParsedRegions;

jkorous wrote:
> gribozavr wrote:
> > I think we should lock both the source and destination mutexes (use 
> > `std::scoped_lock` that allows to lock multiple mutexes).
> > 
> > Also, it would be more idiomatic to express this API as a copy constructor 
> > and an assignment operator.
> Sorry, I am not following. You are aware of the argument being a `DenseSet`, 
> right? This doesn't look like a named copy-ctor to me.
> 
> The way this works is that `ParsedSrcLocationsTracker` takes snapshot of the 
> `SharedParsedRegionsStorage` in its constructor (using `copyTo()`), then uses 
> its own local data and synchronizes the local data with 
> `SharedParsedRegionsStorage` in `syncWithStorage()` method.
> 
> Maybe you just made a case for removing the typedef?
> Sorry, I am not following. You are aware of the argument being a DenseSet, 
> right? This doesn't look like a named copy-ctor to me.

Sorry -- you're right. I confused `PPRegionSetTy` with 
`SharedParsedRegionsStorage`.

> Maybe you just made a case for removing the typedef?

I think that would be an improvement and happy to do that! PTAL at 
https://reviews.llvm.org/D67077 .




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66694/new/

https://reviews.llvm.org/D66694



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


[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Tests look great - please can you pre-commit them and update the patch to show 
the diff? Also, maybe call the test file x86-vec-i128.c and add a comment in 
the file describing PR42607?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64672/new/

https://reviews.llvm.org/D64672



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


[PATCH] D67023: Diagnose use of ATOMIC_VAR_INIT

2019-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67023#1654070 , @jfb wrote:

> I refer you to http://wg21.link/p0883
>  I don’t think this diagnostic should be added to clang until p0883 is fully 
> implemented, even just for C. Otherwise we leave users with no portable way 
> to do the right thing without diagnostic.


P0883 has not been adopted, that I can tell (it has strong support, but isn't 
[expected to be] a part of C++2a)? Also, this functionality is implemented by 
libc++ and libstdc++, so I'm not certain what you mean by "until p0883 is fully 
implemented" or why that paper would be implemented "even just for C". Are you 
suggesting to gate this deprecation for C functionality based on what C++ 
standard library implementations are doing?

I'm sorry if I'm being dense here, but I am still not seeing the issue you're 
concerned by. C has already deprecated this feature and is planning to remove 
it shortly. I am diagnosing that fact in C, which seems perfectly appropriate 
to do regardless of what C++ is doing in this space.

Users have a portable way to write their code already because `ATOMIC_VAR_INIT` 
does not do any special magic and no implementation requires a user to use it 
to achieve portable atomic initialization semantics. If they get the diagnostic 
(which only triggers in C mode and only if the macro was defined in 
stdatomic.h), they should remove the use of `ATOMIC_VAR_INIT` from their code, 
or disable the deprecation diagnostic. If neither of those options appeals to 
the user, they can write something along the lines of:

  _Atomic(int) i = 
  #if defined(__cplusplus)
  ATOMIC_VAR_INIT(12);
  #else
  12;
  #endif

(not that I think anyone will want to write that, but strict adherence to a 
broken part of both standards does not seem like something we want to encourage 
anyway -- this is deprecated functionality, so the whole point is to discourage 
its use.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67023/new/

https://reviews.llvm.org/D67023



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


[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-09-02 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard updated this revision to Diff 218363.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63932/new/

https://reviews.llvm.org/D63932

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
  clang/test/CodeGenCXX/virtual-function-elimination.cpp
  clang/test/Driver/virtual-function-elimination.cpp
  llvm/docs/LangRef.rst
  llvm/docs/TypeMetadata.rst
  llvm/include/llvm/Analysis/TypeMetadataUtils.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/GlobalObject.h
  llvm/include/llvm/Transforms/IPO/GlobalDCE.h
  llvm/lib/Analysis/TypeMetadataUtils.cpp
  llvm/lib/IR/Metadata.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/GlobalDCE.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/LTO/ARM/lto-linking-metadata.ll
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions.ll
  llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
  llvm/test/Transforms/Internalize/vcall-visibility.ll

Index: llvm/test/Transforms/Internalize/vcall-visibility.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/vcall-visibility.ll
@@ -0,0 +1,64 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+
+%struct.A = type { i32 (...)** }
+%struct.B = type { i32 (...)** }
+%struct.C = type { i32 (...)** }
+
+; Class A has default visibility, so has no !vcall_visibility metadata before
+; or after LTO.
+; CHECK-NOT: @_ZTV1A = {{.*}}!vcall_visibility
+@_ZTV1A = dso_local unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1
+
+; Class B has hidden visibility but public LTO visibility, so has no
+; !vcall_visibility metadata before or after LTO.
+; CHECK-NOT: @_ZTV1B = {{.*}}!vcall_visibility
+@_ZTV1B = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !2, !type !3
+
+; Class C has hidden visibility, so the !vcall_visibility metadata is set to 1
+; (linkage unit) before LTO, and 2 (translation unit) after LTO.
+; CHECK: @_ZTV1C ={{.*}}!vcall_visibility [[MD_TU_VIS:![0-9]+]]
+@_ZTV1C = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)] }, align 8, !type !4, !type !5, !vcall_visibility !6
+
+; Class D has translation unit visibility before LTO, and this is not changed
+; by LTO.
+; CHECK: @_ZTVN12_GLOBAL__N_11DE = {{.*}}!vcall_visibility [[MD_TU_VIS:![0-9]+]]
+@_ZTVN12_GLOBAL__N_11DE = internal unnamed_addr constant { [3 x i8*] } zeroinitializer, align 8, !type !7, !type !9, !vcall_visibility !11
+
+define dso_local void @_ZN1A3fooEv(%struct.A* nocapture %this) {
+entry:
+  ret void
+}
+
+define hidden void @_ZN1B3fooEv(%struct.B* nocapture %this) {
+entry:
+  ret void
+}
+
+define hidden void @_ZN1C3fooEv(%struct.C* nocapture %this) {
+entry:
+  ret void
+}
+
+define hidden noalias nonnull i8* @_Z6make_dv() {
+entry:
+  %call = tail call i8* @_Znwm(i64 8) #3
+  %0 = bitcast i8* %call to i32 (...)***
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTVN12_GLOBAL__N_11DE, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
+  ret i8* %call
+}
+
+declare dso_local noalias nonnull i8* @_Znwm(i64)
+
+; CHECK: [[MD_TU_VIS]] = !{i64 2}
+!0 = !{i64 16, !"_ZTS1A"}
+!1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
+!2 = !{i64 16, !"_ZTS1B"}
+!3 = !{i64 16, !"_ZTSM1BFvvE.virtual"}
+!4 = !{i64 16, !"_ZTS1C"}
+!5 = !{i64 16, !"_ZTSM1CFvvE.virtual"}
+!6 = !{i64 1}
+!7 = !{i64 16, !8}
+!8 = distinct !{}
+!9 = !{i64 16, !10}
+!10 = distinct !{}
+!11 = !{i64 2}
Index: llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
===
--- /dev/null
+++ llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
@@ -0,0 +1,47 @@
+; RUN: opt < %s -globaldce -S | FileCheck %s
+
+; We currently only use llvm.type.checked.load for virtual function pointers,
+; not any other part of the vtable, so we can't remove the RTTI pointer even if
+; it's never going to be 

[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-09-02 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard marked 4 inline comments as done.
ostannard added a comment.

> It isn't that common, but it seems worth doing if it can be done easily.



> That said, I note that it does appear that your implementation will end up 
> preserving the pointer in the vtable in this case because you're relying on 
> the use list to make decisions about what to GC. So it doesn't seem easy to 
> do at this point, but if for example we made this compatible with ThinLTO at 
> some point we would probably not be able to rely on the use list, and the 
> resulting changes to this feature might make this easier to do.

Ok, I think that it makes sense to leave this for a separate patch, as long as 
we currently generate correct code. I've added partial linking of the LTO unit 
to my fuzzer, and haven't found any problems.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63932/new/

https://reviews.llvm.org/D63932



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


[PATCH] D67079: [analyzer] CastValueChecker: Model inheritance

2019-09-02 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

The key is `CXXRecordDecl::isDerivedFrom()`.


Repository:
  rC Clang

https://reviews.llvm.org/D67079

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/test/Analysis/cast-value-hierarchy.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
-// CHECK-NEXT:   "dynamic_casts": null,
+// CHECK-NEXT:   "failed_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/cast-value-state-dump.cpp
===
--- clang/test/Analysis/cast-value-state-dump.cpp
+++ clang/test/Analysis/cast-value-state-dump.cpp
@@ -11,19 +11,31 @@
 class Triangle : public Shape {};
 class Circle : public Shape {};
 class Square : public Shape {};
+class Octagram : public Shape {};
 } // namespace clang
 
 using namespace llvm;
 using namespace clang;
 
 void evalNonNullParamNonNullReturn(const Shape *S) {
+  if (isa(S)) {
+// expected-note@-1 {{Assuming 'S' is not a 'Triangle'}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  }
+
+  if (isa(S)) {
+// expected-note@-1 {{Assuming 'S' is not an 'Octagram'}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  }
+
   const auto *C = dyn_cast_or_null(S);
   // expected-note@-1 {{Assuming 'S' is a 'Circle'}}
   // expected-note@-2 {{'C' initialized here}}
 
-  // FIXME: We assumed that 'S' is a 'Circle' therefore it is not a 'Square'.
   if (dyn_cast_or_null(S)) {
-// expected-note@-1 {{Assuming 'S' is not a 'Square'}}
+// expected-note@-1 {{'S' is not a 'Square'}}
 // expected-note@-2 {{Taking false branch}}
 return;
   }
@@ -33,11 +45,11 @@
   // CHECK:  "dynamic_types": [
   // CHECK-NEXT:   { "region": "SymRegion{reg_$0}", "dyn_type": "const class clang::Circle", "sub_classable": true }
   // CHECK-NEXT: ],
-  // CHECK-NEXT: "dynamic_casts": [
-  // CHECK:{ "region": "SymRegion{reg_$0}", "casts": [
-  // CHECK-NEXT: { "from": "const struct clang::Shape *", "to": "const class clang::Circle *", "kind": "success" },
-  // CHECK-NEXT: { "from": "const struct clang::Shape *", "to": "const class clang::Square *", "kind": "fail" }
+  // CHECK-NEXT: "failed_casts": [
+  // CHECK-NEXT:   { "region": "SymRegion{reg_$0}", "casts": [
+  // CHECK-NEXT: "const class clang::Square *", "class clang::Triangle *", "class clang::Octagram *"
   // CHECK-NEXT:   ]}
+  // CHECK-NEXT: ],
 
   (void)(1 / !C);
   // expected-note@-1 {{'C' is non-null}}
Index: clang/test/Analysis/cast-value-notes.cpp
===
--- clang/test/Analysis/cast-value-notes.cpp
+++ clang/test/Analysis/cast-value-notes.cpp
@@ -37,12 +37,6 @@
 return;
   }
 
-  if (dyn_cast_or_null(C)) {
-// expected-note@-1 {{Assuming 'C' is not a 'Triangle'}}
-// expected-note@-2 {{Taking false branch}}
-return;
-  }
-
   if (isa(C)) {
 // expected-note@-1 {{'C' is not a 'Triangle'}}
 // expected-note@-2 {{Taking false branch}}
@@ -65,14 +59,8 @@
   // expected-note@-1 {{'S' is a 'Circle'}}
   // expected-note@-2 {{'C' initialized here}}
 
-  if (!isa(C)) {
-// expected-note@-1 {{Assuming 'C' is a 'Triangle'}}
-// expected-note@-2 {{Taking false branch}}
-return;
-  }
-
-  if (!isa(C)) {
-// expected-note@-1 {{'C' is a 'Triangle'}}
+  if (isa(C)) {
+// expected-note@-1 {{'C' is not a 'Triangle'}}
 // expected-note@-2 {{Taking false branch}}
 return;
   }
Index: clang/test/Analysis/cast-value-hierarchy.cpp
===
--- /dev/null
+++ clang/test/Analysis/cast-value-hierarchy.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
+// RUN:  -verify %s
+
+#include "Inputs/llvm.h"
+
+using namespace llvm;
+
+void clang_analyzer_numTimesReached();
+void clang_analyzer_printState();
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval(bool);
+
+

[PATCH] D67079: [analyzer] CastValueChecker: Model inheritance

2019-09-02 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 2 inline comments as done.
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:211
   },
-  /*IsPrunable=*/true);
+  /*IsPrunable=*/!CastCtx.CastSucceeds);
 }

That could be helpful, but I am not sure.



Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:239
+C.generateSink(C.getState(), C.getPredecessor());
 return;
+  }

Previously possible false positives happened because we kept flow the modeling.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:42
+  return MR->StripCasts();
+}
+

Probably a consistent way of `MemRegion` handling is more appropriate.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67079/new/

https://reviews.llvm.org/D67079



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


[PATCH] D67080: Fix bugprone-argument-comment bug if there are marcos.

2019-09-02 Thread Yubo Xie via Phabricator via cfe-commits
xyb created this revision.
xyb added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix bugprone-argument-comment bug if there are marcos.

For example:

  #define X(x) (x)
  void j(int a, int b, int c);
  j(X(1), /*b=*/1, X(1));

clang-tidy can't recognize comment "/*b=*/". It suggests fix like this:

  j(X(1), /*b=*//*b=*/1, X(1));

This change tries to fix this issue.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67080

Files:





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


[PATCH] D66699: [PowerPC][Altivec] Fix constant argument for vec_dss

2019-09-02 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

Ping..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66699/new/

https://reviews.llvm.org/D66699



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


[PATCH] D67080: Fix bugprone-argument-comment bug if there are marcos.

2019-09-02 Thread Yubo Xie via Phabricator via cfe-commits
xyb updated this revision to Diff 218372.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67080/new/

https://reviews.llvm.org/D67080

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -15,10 +15,12 @@
 };
 
 #define FOO 1
+#define X(x) (x)
 
 void g(int a);
 void h(double b);
 void i(const char *c);
+void j(int a, int b, int c);
 
 double operator"" _km(long double);
 
@@ -106,6 +108,39 @@
   // CHECK-FIXES: h(/*b=*/1.0f);
   i(__FILE__);
 
+  j(1, X(1), X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), X(1));
+  j(/*a=*/1, X(1), X(1));
+
+  j(X(1), 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, X(1));
+  j(X(1), /*b=*/1, X(1));
+
+  j(X(1), X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), X(1), /*c=*/1);
+  j(X(1), X(1), /*c=*/1);
+
+  j(X(1), 1, 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:14: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, /*c=*/1);
+  j(X(1), /*b=*/1, /*c=*/1);
+
+  j(1, X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:14: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), /*c=*/1);
+  j(/*a=*/1, X(1), /*c=*/1);
+
+  j(1, 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, /*b=*/1, X(1));
+  j(/*a=*/1, /*b=*/1, X(1));
+
   // FIXME Would like the below to add argument comments.
   g((1));
   // FIXME But we should not add argument comments here.
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -322,8 +322,8 @@
   Comments = getCommentsInRange(Ctx, BeforeArgument);
 } else {
   // Fall back to parsing back from the start of the argument.
-  CharSourceRange ArgsRange = MakeFileCharRange(
-  Args[I]->getBeginLoc(), Args[NumArgs - 1]->getEndLoc());
+  CharSourceRange ArgsRange =
+  MakeFileCharRange(Args[I]->getBeginLoc(), Args[I]->getEndLoc());
   Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());
 }
 


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -15,10 +15,12 @@
 };
 
 #define FOO 1
+#define X(x) (x)
 
 void g(int a);
 void h(double b);
 void i(const char *c);
+void j(int a, int b, int c);
 
 double operator"" _km(long double);
 
@@ -106,6 +108,39 @@
   // CHECK-FIXES: h(/*b=*/1.0f);
   i(__FILE__);
 
+  j(1, X(1), X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for literal argument 'a' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), X(1));
+  j(/*a=*/1, X(1), X(1));
+
+  j(X(1), 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, X(1));
+  j(X(1), /*b=*/1, X(1));
+
+  j(X(1), X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument comment missing for literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), X(1), /*c=*/1);
+  j(X(1), X(1), /*c=*/1);
+
+  j(X(1), 1, 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for literal argument 'b' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:14: warning: argument comment missing for literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, /*c=*/1);
+  j(X(1), /*b=*/1, /*c=*/1);
+
+  j(1, 

[PATCH] D66748: [PowerPC][Altivec][Clang] Check compile-time constant for vec_dst*

2019-09-02 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

Ping..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66748/new/

https://reviews.llvm.org/D66748



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


r370671 - ThinLTO: Document the option BOOTSTRAP_LLVM_ENABLE_LTO

2019-09-02 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Sep  2 08:34:53 2019
New Revision: 370671

URL: http://llvm.org/viewvc/llvm-project?rev=370671&view=rev
Log:
ThinLTO: Document the option BOOTSTRAP_LLVM_ENABLE_LTO

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=370671&r1=370670&r2=370671&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Mon Sep  2 08:34:53 2019
@@ -225,6 +225,10 @@ To bootstrap clang/LLVM with ThinLTO, fo
``CMAKE_EXE_LINKER_FLAGS:STRING=``. Note the configure may fail if
linker plugin options are instead specified directly in the previous step.
 
+The `BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO for stage 2 and
+stage 3 in case the compiler used for stage 1 does not support the ThinLTO
+option.
+
 More Information
 
 


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


[PATCH] D66588: [ARM NEON] Avoid duplicated decarations

2019-09-02 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

LGTM with one small nit.




Comment at: clang/utils/TableGen/NeonEmitter.cpp:1906
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and small endians
+  if (isBigEndianSafe()) {

s/small endians/little endian/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66588/new/

https://reviews.llvm.org/D66588



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


[PATCH] D66302: [SVE][Inline-Asm] Support for SVE asm operands

2019-09-02 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370673: [SVE][Inline-Asm] Support for SVE asm operands 
(authored by kmclaughlin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66302?vs=216655&id=218376#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66302/new/

https://reviews.llvm.org/D66302

Files:
  llvm/trunk/docs/LangRef.rst
  llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/trunk/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
  llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm.ll
  llvm/trunk/test/CodeGen/AArch64/arm64-inline-asm.ll

Index: llvm/trunk/test/CodeGen/AArch64/arm64-inline-asm.ll
===
--- llvm/trunk/test/CodeGen/AArch64/arm64-inline-asm.ll
+++ llvm/trunk/test/CodeGen/AArch64/arm64-inline-asm.ll
@@ -138,6 +138,8 @@
   %a = alloca [2 x float], align 4
   %arraydecay = getelementptr inbounds [2 x float], [2 x float]* %a, i32 0, i32 0
   %0 = load <2 x float>, <2 x float>* %data, align 8
+  call void asm sideeffect "ldr ${1:z}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
+  ; CHECK: ldr {{z[0-9]+}}, [{{x[0-9]+}}]
   call void asm sideeffect "ldr ${1:q}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
   ; CHECK: ldr {{q[0-9]+}}, [{{x[0-9]+}}]
   call void asm sideeffect "ldr ${1:d}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
Index: llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
===
--- llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
+++ llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
@@ -0,0 +1,12 @@
+; RUN: not llc -mtriple aarch64-none-linux-gnu -mattr=+neon -o %t.s -filetype=asm %s 2>&1 | FileCheck %s
+
+; The 'y' constraint only applies to SVE vector registers (Z0-Z7)
+; The test below ensures that we get an appropriate error should the
+; constraint be used with a Neon register.
+
+; Function Attrs: nounwind readnone
+; CHECK: error: couldn't allocate input reg for constraint 'y'
+define <4 x i32> @test_neon(<4 x i32> %in1, <4 x i32> %in2) {
+  %1 = tail call <4 x i32> asm "add $0.4s, $1.4s, $2.4s", "=w,w,y"(<4 x i32> %in1, <4 x i32> %in2)
+  ret <4 x i32> %1
+}
Index: llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm.ll
===
--- llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm.ll
+++ llvm/trunk/test/CodeGen/AArch64/aarch64-sve-asm.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s -mtriple aarch64-none-linux-gnu -mattr=+sve -stop-after=finalize-isel | FileCheck %s --check-prefix=CHECK
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-none-linux-gnu"
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_3b = COPY [[ARG1]]
+define  @test_svadd_i8( %Zn,  %Zm) {
+  %1 = tail call  asm "add $0.b, $1.b, $2.b", "=w,w,y"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_4b = COPY [[ARG1]]
+define  @test_svsub_i64( %Zn,  %Zm) {
+  %1 = tail call  asm "sub $0.d, $1.d, $2.d", "=w,w,x"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_3b = COPY [[ARG1]]
+define  @test_svfmul_f16( %Zn,  %Zm) {
+  %1 = tail call  asm "fmul $0.h, $1.h, $2.h", "=w,w,y"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_4b = COPY [[ARG1]]
+define  @test_svfmul_f( %Zn,  %Zm) {
+  %1 = tail call  asm "fmul $0.s, $1.s, $2.s", "=w,w,x"( %Zn,  %Zm)
+  ret  %1
+}
Index: llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
===
--- llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -150,7 +150,7 @@
   void printOperand(const MachineInstr *MI, unsigned OpNum, raw_ostream &O);
   bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
   bool printAsmRegInClass(const MachineOperand &MO,
-  const TargetRegisterClass *RC, bool isVector,
+  const TargetRegisterClass *RC, unsigned AltName,
   raw_os

[PATCH] D50147: clang-format: support external styles

2019-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I am not opposed to this idea, I actually think this has some mileage based on 
a use case I've encountered:

our team tends to use windows builds of clang-format from 
(https://llvm.org/builds/) because its easy to distribute the installer, this 
is ok but sometimes these snapshot builds can lag new features by 1-2 months

This can make introducing a new configuration option a problem because it 
requires us to have to get everyone upgraded before we can change the checked 
in .clang-format at the top of the tree.

If everyone isn't upgraded they start getting complaints about unknown 
configurations. Its not 100% obvious if those styles are being ignored, if no 
formatting at all is being done or if when clang-format is embedded inside 
Visual Studio or VIM what exactly is happening.

I see this feature would allow those on the bleeding edge to use an alternate 
.clang-format file (even if that was also in the root /.clang-format-next


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50147/new/

https://reviews.llvm.org/D50147



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


[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 218377.
Mordante added a comment.

Adds extra unit tests for references.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66706/new/

https://reviews.llvm.org/D66706

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation.cpp
  clang/test/Sema/warn-documentation.m


Index: clang/test/Sema/warn-documentation.m
===
--- clang/test/Sema/warn-documentation.m
+++ clang/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1360,3 +1360,34 @@
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function 
pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void CC();
+typedef void C();
+C &c = CC; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using DD = void(*)();
+using D = DD();
+D *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using E = void();
+E *e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void FF();
+using F = void();
+F &f = FF; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+} // namespace PR42844
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -588,6 +588,8 @@
   if (isObjCPropertyDecl())
 return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+assert(!ThisDeclInfo->ReturnType.isNull() &&
+   "should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@
   // can be ignored.
   if (QT->getAs())
 return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
   return QT->isFunctionPointerType() || QT->isBlockPointerType();
 }
 


Index: clang/test/Sema/warn-documentation.m
===
--- clang/test/Sema/warn-documentation.m
+++ clang/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1360,3 +1360,34 @@
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+
+void CC();
+typedef void C();
+C &c = CC; ///< \return none
+// expected-warning@-1 {{'\return' command

[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for the review.

  using D = void();
  D &d = ...; ///< \return none

Is no issue, I added tests for it.

Can you commit the code for me?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66706/new/

https://reviews.llvm.org/D66706



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


[PATCH] D50147: clang-format: support external styles

2019-09-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

but perhaps I'm really just agreeing to @sammccall  's suggestion of 
"-style=" which kind of feels sufficient to me..


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50147/new/

https://reviews.llvm.org/D50147



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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D67058#1654347 , @lebedev.ri wrote:

> Tests missing.
>  Is that what gcc does? I'd personally thought those should be internalized.


GCC doesn't implement CPU dispatch, this is an ICC thing.  ICC uses the Windows 
behavior on both, but when implementing in Clang we opted to use IFuncs for 
Linux.  This is troublesome, as it can result in the 'FuncName' symbol not 
existing (so a separate TU treating this function as an extern function on 
Linux wouldn't link).

I accept this approach, but need to spend some time tomorrow doing some 
additional review.

That said, this definitely still needs to be covered by lit tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



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


r370677 - [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Sep  2 11:24:33 2019
New Revision: 370677

URL: http://llvm.org/viewvc/llvm-project?rev=370677&view=rev
Log:
[Wdocumentation] fixes an assertion failure with typedefed function and block 
pointer

Summary:
The assertion happens when compiling with -Wdocumentation with variable 
declaration to a typedefed function pointer. I not too familiar with the ObjC 
syntax but first two tests assert without this patch.

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

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=370677&r1=370676&r2=370677&view=diff
==
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Mon Sep  2 11:24:33 2019
@@ -588,6 +588,8 @@ void Sema::checkReturnsCommand(const Blo
   if (isObjCPropertyDecl())
 return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+assert(!ThisDeclInfo->ReturnType.isNull() &&
+   "should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@ bool Sema::isFunctionOrBlockPointerVarLi
   // can be ignored.
   if (QT->getAs())
 return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
   return QT->isFunctionPointerType() || QT->isBlockPointerType();
 }
 

Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=370677&r1=370676&r2=370677&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Mon Sep  2 11:24:33 2019
@@ -1360,3 +1360,34 @@ using VariadicFnType2 = void (*)(int a,
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function 
pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void CC();
+typedef void C();
+C &c = CC; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using DD = void(*)();
+using D = DD();
+D *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using E = void();
+E *e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void FF();
+using F = void();
+F &f = FF; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+} // namespace PR42844

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=370677&r1=370676&r2=370677&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Mon Sep  2 11:24:33 2019
@@ -310,3 +310,11 @@ void (^_Nullable blockPointerVariableTha
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}


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


[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370677: [Wdocumentation] fixes an assertion failure with 
typedefed function and block… (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66706?vs=218377&id=218384#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66706/new/

https://reviews.llvm.org/D66706

Files:
  cfe/trunk/lib/AST/CommentSema.cpp
  cfe/trunk/test/Sema/warn-documentation.cpp
  cfe/trunk/test/Sema/warn-documentation.m


Index: cfe/trunk/lib/AST/CommentSema.cpp
===
--- cfe/trunk/lib/AST/CommentSema.cpp
+++ cfe/trunk/lib/AST/CommentSema.cpp
@@ -588,6 +588,8 @@
   if (isObjCPropertyDecl())
 return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+assert(!ThisDeclInfo->ReturnType.isNull() &&
+   "should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@
   // can be ignored.
   if (QT->getAs())
 return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
   return QT->isFunctionPointerType() || QT->isBlockPointerType();
 }
 
Index: cfe/trunk/test/Sema/warn-documentation.m
===
--- cfe/trunk/test/Sema/warn-documentation.m
+++ cfe/trunk/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
Index: cfe/trunk/test/Sema/warn-documentation.cpp
===
--- cfe/trunk/test/Sema/warn-documentation.cpp
+++ cfe/trunk/test/Sema/warn-documentation.cpp
@@ -1360,3 +1360,34 @@
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function 
pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void CC();
+typedef void C();
+C &c = CC; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using DD = void(*)();
+using D = DD();
+D *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using E = void();
+E *e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+void FF();
+using F = void();
+F &f = FF; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+} // namespace PR42844


Index: cfe/trunk/lib/AST/CommentSema.cpp
===
--- cfe/trunk/lib/AST/CommentSema.cpp
+++ cfe/trunk/lib/AST/CommentSema.cpp
@@ -588,6 +588,8 @@
   if (isObjCPropertyDecl())
 return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+assert(!ThisDeclInfo->ReturnType.isNull() &&
+   "should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@
   // can be ignored.
   if (QT->getAs())
 return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
   return QT->isFunctionPointerType() || QT->isBlockPointerType();
 }
 
Index: cfe/trunk/test/Sema/warn-documentation.m
===
--- cfe/trunk/test/Sema/warn-documentation.m
+++ cfe/trunk/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures w

[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Thanks!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66706/new/

https://reviews.llvm.org/D66706



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


[PATCH] D67084: Fix bugprone-argument-comment bug: negative literal number is not checked.

2019-09-02 Thread Yubo Xie via Phabricator via cfe-commits
xyb created this revision.
xyb added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For example:

  void foo(int a);
  foo(-2);

should be fixed as:

  foo(/*a=*/-2);

This change tries to fix this issue.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67084

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'strabc' [bugprone-argument-comment]
@@ -98,14 +109,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/402.0_km);
 
+  a.foo(-402.0_km);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-402.0_km);
+
   a.foo('A');
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for 
literal argument 'chabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*chabc=*/'A');
 
   g(FOO);
+  g(-FOO);
   h(1.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
   // CHECK-FIXES: h(/*b=*/1.0f);
+  h(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: h(/*b=*/-1.0f);
   i(__FILE__);
 
   j(1, X(1), X(1));
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -236,9 +236,11 @@
 // Given the argument type and the options determine if we should
 // be adding an argument comment.
 bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
+  Arg = Arg->IgnoreImpCasts();
+  if (isa(Arg))
+  Arg = cast(Arg)->getSubExpr();
   if (Arg->getExprLoc().isMacroID())
 return false;
-  Arg = Arg->IgnoreImpCasts();
   return (CommentBoolLiterals && isa(Arg)) ||
  (CommentIntegerLiterals && isa(Arg)) ||
  (CommentFloatLiterals && isa(Arg)) ||


Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -69,18 +69,29 @@
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
 
+  a.foo(-1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/-1.0f);
+
   a.foo(1.0);
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
   // CHECK-FIXES: a.foo(/*dabc=*/1.0);
 
+  a.foo(-1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/-1.0);
+
   int val3 = 10;
   a.foo(val3);
+  a.foo(-val3);
 
   float val4 = 10.0;
   a.foo(val4);
+  a.foo(-val4);
 
   double val5 = 10.0;
   a.foo(val5);
+  a.foo(-val5);
 
   a.foo("Hello World");
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'strabc' [bugprone-argument-comment]
@@ -

[PATCH] D67065: [RISCV] Define __riscv_cmodel_medlow and __riscv_cmodel_medany correctly

2019-09-02 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:91
   Builder.defineMacro("__riscv_xlen", Is64Bit ? "64" : "32");
   // TODO: modify when more code models are supported.
+  StringRef CodeModel = getTargetOpts().CodeModel;

This TODO can probably be deleted - now it's more obvious where to add more 
code when we support more code models.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67065/new/

https://reviews.llvm.org/D67065



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


[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D64672#1654687 , @RKSimon wrote:

> Tests look great - please can you pre-commit them and update the patch to 
> show the diff? Also, maybe call the test file x86-vec-i128.c and add a 
> comment in the file describing PR42607?


How do you want me to show the diff? There a couple options. Three of the check 
lines have to be removed from the pre-commit since they use a command line 
option that doesn't exist. Do you want me to change the check lines that say 
NEWABI to use the old code? Or do you want me to manipulate the FileCheck 
command lines to use the OLDABI check lines?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64672/new/

https://reviews.llvm.org/D64672



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


[PATCH] D66018: [ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

2019-09-02 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 218388.
krisb marked an inline comment as done.
krisb added a comment.

Applied the comment: enable 'sha2' and 'aes' only for armv8 A profile, report 
warning and disable 'crypto' for other archs. Add more tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66018/new/

https://reviews.llvm.org/D66018

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-features.c

Index: test/Driver/arm-features.c
===
--- test/Driver/arm-features.c
+++ test/Driver/arm-features.c
@@ -37,7 +37,8 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.2a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2 %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.3a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2 %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.4a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2 %s
-// CHECK-CRYPTO2: "-cc1"{{.*}} "-target-cpu" "generic"{{.*}} "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes"
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.5a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2 %s
+// CHECK-CRYPTO2: "-cc1"{{.*}} "-target-cpu" "generic"{{.*}} "-target-feature" "+crypto"{{.*}} "-target-feature" "+sha2" "-target-feature" "+aes"
 //
 // Check -crypto:
 //
@@ -45,14 +46,36 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.2a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2 %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.3a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2 %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.4a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2 %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.5a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2 %s
 // CHECK-NOCRYPTO2-NOT: "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes"
 //
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2-CPU %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57 -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO2-CPU %s
+// CHECK-CRYPTO2-CPU: "-cc1"{{.*}} "-target-cpu" "cortex-a57"{{.*}} "-target-feature" "+crypto"{{.*}} "-target-feature" "+sha2" "-target-feature" "+aes"
+//
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+norypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2-CPU %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57 -mfpu=neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO2-CPU %s
+// CHECK-NOCRYPTO2-CPU-NOT: "-cc1"{{.*}} "-target-cpu" "cortex-a57"{{.*}} "-target-feature" "+crypto"{{.*}} "-target-feature" "+sha2" "-target-feature" "+aes"
+//
 // Check +crypto -sha2 -aes:
 //
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1a+crypto+nosha2+noaes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO3 %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+crypto+nosha2+noaes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO3 %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+nosha2+noaes -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO3 %s
 // CHECK-CRYPTO3-NOT: "-target-feature" "+sha2" "-target-feature" "+aes"
 //
 // Check -crypto +sha2 +aes:
 //
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1a+nocrypto+sha2+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO4 %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+nocrypto+sha2+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO4 %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a57+sha2+aes -mfpu=neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO4 %s
 // CHECK-CRYPTO4: "-target-feature" "+sha2" "-target-feature" "+aes"
+//
+// Check +crypto for M and R profiles:
+//
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-r+crypto   -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO5 %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.base+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO5 %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO5 %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-m23+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO5 %s
+// CHECK-NOCRYPTO5: warning: ignoring extension 'crypto' because the {{.*}} architecture does not support it
+// CHECK-NOCRYPTO5-NOT: "-target-feature" "+crypto"{{.*}} "-target-feature" "+sha2" "-target-feature" "+aes"
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.c

[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D64672#1654983 , @craig.topper 
wrote:

> In D64672#1654687 , @RKSimon wrote:
>
> > Tests look great - please can you pre-commit them and update the patch to 
> > show the diff? Also, maybe call the test file x86-vec-i128.c and add a 
> > comment in the file describing PR42607?
>
>
> How do you want me to show the diff? There a couple options. Three of the 
> check lines have to be removed from the pre-commit since they use a command 
> line option that doesn't exist. Do you want me to change the check lines that 
> say NEWABI to use the old code? Or do you want me to manipulate the FileCheck 
> command lines to use the OLDABI check lines?


How about CLANG9ABI and CLANG10ABI? And the patch just adds the 
-fclang-abi-compat=9 tests?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64672/new/

https://reviews.llvm.org/D64672



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


[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-02 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane updated this revision to Diff 218392.
jpakkane added a comment.

Updated to fix review comments. NOTE: detecting the include fix is broken 
because I could not get it to work.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64671/new/

https://reviews.llvm.org/D64671

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp

Index: clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
@@ -0,0 +1,99 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t
+
+#define DO_NOTHING(x) ((void)x)
+
+// Ensure that function declarations are not changed.
+void some_func(int x, double d, bool b, const char *p);
+
+// Ensure that function arguments are not changed
+int identity_function(int x) {
+  return x;
+}
+
+int do_not_modify_me;
+
+typedef struct {
+  int unaltered1;
+  int unaltered2;
+} UnusedStruct;
+
+typedef int my_int_type;
+#define MACRO_INT int
+#define FULL_DECLARATION() int macrodecl;
+
+template 
+void template_test_function() {
+  T t;
+  int uninitialized;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'uninitialized' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int uninitialized = 0;{{$}}
+
+  DO_NOTHING(t);
+  DO_NOTHING(uninitialized);
+}
+
+void init_unit_tests() {
+  int x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x = 0;{{$}}
+  my_int_type myint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'myint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  my_int_type myint = 0;{{$}}
+
+  MACRO_INT macroint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'macroint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  MACRO_INT macroint = 0;{{$}}
+  FULL_DECLARATION();
+
+  int x0 = 1, x1, x2 = 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'x1' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x0 = 1, x1 = 0, x2 = 2;{{$}}
+  int y0, y1 = 1, y2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'y0' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: variable 'y2' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int y0 = 0, y1 = 1, y2 = 0;{{$}}
+  int hasval = 42;
+
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  float f = NAN;{{$}}
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: Include math.h for definition of NAN [cppcoreguidelines-init-variables]
+  float fval = 85.0;
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: variable 'd' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  double d = NAN;{{$}}
+  double dval = 99.0;
+
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  bool bval = true;
+
+  const char *ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'ptr' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  const char *ptr = nullptr;{{$}}
+  const char *ptrval = "a string";
+
+  UnusedStruct u;
+
+  DO_NOTHING(x);
+  DO_NOTHING(myint);
+  DO_NOTHING(macroint);
+  DO_NOTHING(macrodecl);
+  DO_NOTHING(x0);
+  DO_NOTHING(x1);
+  DO_NOTHING(x2);
+  DO_NOTHING(y0);
+  DO_NOTHING(y1);
+  DO_NOTHING(y2);
+  DO_NOTHING(hasval);
+  DO_NOTHING(f);
+  DO_NOTHING(fval);
+  DO_NOTHING(d);
+  DO_NOTHING(dval);
+  DO_NOTHING(b);
+  DO_NOTHING(bval);
+  DO_NOTHING(ptr);
+  DO_NOTHING(ptrval);
+  DO_NOTHING(u);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -193,6 +193,7 @@
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-explicit-virtual-functions (redirects to modernize-use-override) 
+   cppcoreguidelines-init-variables
cppcoreguide

[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-02 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane marked 9 inline comments as done.
jpakkane added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:21
+  Finder->addMatcher(
+  varDecl(unless(hasInitializer(anything())), unless(isInstantiated()))
+  .bind("vardecl"),

aaron.ballman wrote:
> This should not match on variable declarations that are automatically 
> zero-initialized or have a default constructor, no?
That is correct. The test file has checks for global variables and struct 
members without initialisation.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:31-32
+
+  if (!MatchedDecl->isLocalVarDecl())
+return;
+

aaron.ballman wrote:
> I think this should be made into a local AST matcher so the check can be 
> hoisted into the matchers.
As was discussed earlier, the use of isLocalVarDecl is used here because:

- it has the exact semantics needed in this particular case
- it is not available as a matcher, I could not make plain matchers replicate 
its behaviour and even if I could, reimplementing it from scratch seems a bit 
pointless

If there is a way to use that function directly in the matcher code, let me 
know how it's done and I will fix this. But if not, then sadly I have no idea 
how that should be fixed and it is probably a bigger development task than this 
checker itself.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:59
+  } else if (TypePtr->isFloatingType()) {
+InitializationString = " = (0.0/0.0)"; // NaN without needing #includes
+  } else if (TypePtr->isPointerType()) {

aaron.ballman wrote:
> I would rather see the correct NaN inserted along with the include. See 
> StringFindStartswithCheck.cpp for an example of how to use the include 
> inserter.
I copied the implementation and could make it add the update. However I could 
not for the life of me make the test framework accept this. It will always flag 
an error even though there should be a comment that declares it in the test 
source. Any help is appreciated.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64671/new/

https://reviews.llvm.org/D64671



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


[PATCH] D66990: [clangd] Add distinct highlightings for declarations of functions and methods

2019-09-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D66990#1654312 , @ilya-biryukov 
wrote:

> I think this makes sense, but it should be done for **all** declarations and 
> not just functions.
>  But doing that in the current design would mean we need to double the number 
> of styles. In addition to `field`, `method`, `function`, we would need 
> `field-declaration`, `method-declaration`, `function-declaration`, etc.
>  Combinatorial explosion of that kind is bad, so I would rather avoid it.


I agree that a combinatorial explosion would be unfortunate. I actually think 
that having a linear list of semantic highlighting kinds is a weakness of this 
protocol extension for exactly this reason.

I think the way cquery does it 

 it better in this regard: in place of a single kind enum, they essentially 
have a 4-tuple of `(kind, parent kind, storage class, role)`. With this setup:

- The kinds can be a relatively small set of fundamental language entity kinds 
(variable, function, class, namespace, etc.)
- Things like "field" can be expressed as `kind = variable, parentKind = class`
- The storage class allows differentiating things like static vs. nonstatic 
without having to introduce distinct kinds for those.
- The role allows differentiating declarations from uses, and even fancier 
things like read occurrences from write occurrences.

I've been meaning to comment on the upstream protocol proposal to suggest a 
more flexible approach like this, though I'm not sure how it would integrate 
with TextMate scopes (which cquery doesn't bother with).

I was hoping though that a patch like this, which would bring us largely to 
parity with Eclipse CDT's highlightings, wouldn't need to blocked on a change 
to the upstream protocol proposal, which could take a while.

> That would also mean we would rely on every editor to apply consistent 
> styling for this, at least by default: make `somethind-decl` just like `decl` 
> but bold.
>  I don't think there's any way to enforce this.

Keep in mind that since the scopes for declarations just add `.declaration` to 
the scopes for the base entities, by default they would be highlighted the same 
as the base entity. Only if a user or theme goes to the trouble of adding a 
specific rule for the `.declaration`, would they look different, and in that 
case I think we can trust the judgment of the user or theme author.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66990/new/

https://reviews.llvm.org/D66990



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


[PATCH] D59637: [analyzer] Use the custom propagation rules and sinks in GenericTaintChecker

2019-09-02 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 218395.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59637/new/

https://reviews.llvm.org/D59637

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -338,3 +338,43 @@
   if (i < rhs)
 *(volatile int *) 0; // no-warning
 }
+
+
+// Test configuration
+int mySource1();
+void mySource2(int*);
+void myScanf(const char*, ...);
+int myPropagator(int, int*);
+int mySnprintf(char*, size_t, const char*, ...);
+void mySink(int, int, int);
+
+void testConfigurationSources1() {
+  int x = mySource1();
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationSources2() {
+  int x;
+  mySource2(&x);
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationSources3() {
+  int x, y;
+  myScanf("%d %d", &x, &y);
+  Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationPropagation() {
+  int x = mySource1();
+  int y;
+  myPropagator(x, &y);
+  Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationSinks() {
+  int x = mySource1();
+  mySink(x, 1, 2); // expected-warning {{Untrusted data is passed to a user-defined sink}}
+  mySink(1, x, 2); // no-warning
+  mySink(1, 2, x); // expected-warning {{Untrusted data is passed to a user-defined sink}}
+}
Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -115,25 +115,38 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Check for CWE-134: Uncontrolled Format String.
-  static const char MsgUncontrolledFormatString[];
+  static constexpr llvm::StringLiteral MsgUncontrolledFormatString =
+  "Untrusted data is used as a format string "
+  "(CWE-134: Uncontrolled Format String)";
   bool checkUncontrolledFormatString(const CallExpr *CE,
  CheckerContext &C) const;
 
   /// Check for:
   /// CERT/STR02-C. "Sanitize data passed to complex subsystems"
   /// CWE-78, "Failure to Sanitize Data into an OS Command"
-  static const char MsgSanitizeSystemArgs[];
+  static constexpr llvm::StringLiteral MsgSanitizeSystemArgs =
+  "Untrusted data is passed to a system call "
+  "(CERT/STR02-C. Sanitize data passed to complex subsystems)";
   bool checkSystemCall(const CallExpr *CE, StringRef Name,
CheckerContext &C) const;
 
   /// Check if tainted data is used as a buffer size ins strn.. functions,
   /// and allocators.
-  static const char MsgTaintedBufferSize[];
+  static constexpr llvm::StringLiteral MsgTaintedBufferSize =
+  "Untrusted data is used to specify the buffer size "
+  "(CERT/STR31-C. Guarantee that storage for strings has sufficient space "
+  "for character data and the null terminator)";
   bool checkTaintedBufferSize(const CallExpr *CE, const FunctionDecl *FDecl,
   CheckerContext &C) const;
 
+  /// Check if tainted data is used as a custom sink's parameter.
+  static constexpr llvm::StringLiteral MsgCustomSink =
+  "Untrusted data is passed to a user-defined sink";
+  bool checkCustomSinks(const CallExpr *CE, StringRef Name,
+CheckerContext &C) const;
+
   /// Generate a report if the expression is tainted or points to tainted data.
-  bool generateReportIfTainted(const Expr *E, const char Msg[],
+  bool generateReportIfTainted(const Expr *E, const StringRef Msg,
CheckerContext &C) const;
 
   /// A struct used to specify taint propagation rules for a function.
@@ -175,7 +188,8 @@
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
-getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
+getTaintPropagationRule(const GenericTaintChecker *Checker,
+const FunctionDecl *FDecl, StringRef Name,
 CheckerContext &C);
 
 void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
@@ -227,19 +241,6 @@
 
 const unsigned GenericTaintChecker::ReturnValueIndex;
 const unsigned GenericTaintChecker::InvalidArgIndex;
-
-const char GenericTaintChecker::MsgUncontrolledFormatString[] =
-"Untrusted data is used as a format string "
-"(CWE-134: Uncontrolled Format String)";
-
-const char GenericTaintChecker::MsgSanitizeSystemArgs[] =
-"Untrusted data is passed to a system call "
-"(CERT/STR02-C. Sanitize data passed to complex subsystems)";
-
-const char GenericTaintChecker::MsgTaintedBufferSize[] =
-"Untrusted data is used to specify the buffer s

[PATCH] D66711: [clang] Warning for non-final classes with final destructors

2019-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This is a cool warning. Could the note have a fixit attached to it, so that 
it's easy to mass-clean-up the warning automatically?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66711/new/

https://reviews.llvm.org/D66711



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2019-09-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

I went back to read notes from when we deployed `-Wstrict-prototypes` (which we 
have had on-by-default for our users for a couple of years, since it catches 
lots of `-fblocks`-related bugs).  I was mainly objecting because I had 
(mis)remembered trying and backing out the specific behaviour you're adding.  
On the contrary, our notes say that we might want to strengthen the diagnostic 
as you're doing.

I'm still nervous about this, but I'm withdrawing my objection.

In D66919#1653188 , @aaronpuchert 
wrote:

> Do we have any precedence for a warning that's treated as error by default? I 
> haven't seen that before, that's why I'm asking. Even `-Wreturn-type` isn't 
> treated as error by default.


There are tons of `-Werror`-by-default in Objective-C, at least.  I'm not sure 
if it's used elsewhere, but for almost-guaranteed bugs it seems like the right 
thing to do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66919/new/

https://reviews.llvm.org/D66919



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


r370688 - Split -Wreorder into different warnings for reordering a constructor

2019-09-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Sep  2 16:17:32 2019
New Revision: 370688

URL: http://llvm.org/viewvc/llvm-project?rev=370688&view=rev
Log:
Split -Wreorder into different warnings for reordering a constructor
mem-initializer list and for reordering a designated initializer list.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=370688&r1=370687&r2=370688&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Sep  2 16:17:32 2019
@@ -632,7 +632,9 @@ def UnusedGetterReturnValue : DiagGroup<
 def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">;
 def UserDefinedLiterals : DiagGroup<"user-defined-literals">;
 def UserDefinedWarnings : DiagGroup<"user-defined-warnings">;
-def Reorder : DiagGroup<"reorder">;
+def ReorderCtor : DiagGroup<"reorder-ctor">;
+def ReorderInitList : DiagGroup<"reorder-init-list">;
+def Reorder : DiagGroup<"reorder", [ReorderCtor, ReorderInitList]>;
 def UndeclaredSelector : DiagGroup<"undeclared-selector">;
 def ImplicitAtomic : DiagGroup<"implicit-atomic-properties">;
 def CustomAtomic : DiagGroup<"custom-atomic-properties">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=370688&r1=370687&r2=370688&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep  2 16:17:32 
2019
@@ -208,7 +208,7 @@ def ext_designated_init_nested : ExtWarn
   "nested designators are a C99 extension">, InGroup;
 def ext_designated_init_reordered : ExtWarn<
   "ISO C++ requires field designators to be specified in declaration order; "
-  "field %1 will be initialized after field %0">, InGroup,
+  "field %1 will be initialized after field %0">, InGroup,
   SFINAEFailure;
 def note_previous_field_init : Note<
   "previous initialization for field %0 is here">;
@@ -7644,7 +7644,7 @@ def err_mem_init_not_member_or_class : E
 def warn_initializer_out_of_order : Warning<
   "%select{field|base class}0 %1 will be initialized after "
   "%select{field|base}2 %3">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_abstract_vbase_init_ignored : Warning<
   "initializer for virtual base class %0 of abstract class %1 "
   "will never be used">,

Modified: cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp?rev=370688&r1=370687&r2=370688&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp Mon Sep  2 16:17:32 
2019
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic,override,reorder 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic 
-Werror=c99-designator -Wno-reorder -Wno-initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,reorder -Wno-c99-designator 
-Werror=reorder -Wno-initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,override -Wno-c99-designator 
-Wno-reorder -Werror=initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify -Wno-c99-designator -Wno-reorder 
-Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic 
-Werror=c99-designator -Wno-reorder-init-list -Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=expected,reorder -Wno-c99-designator 
-Werror=reorder-init-list -Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=expected,override -Wno-c99-designator 
-Wno-reorder-init-list -Werror=initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify -Wno-c99-designator 
-Wno-reorder-init-list -Wno-initializer-overrides
 
 
 namespace class_with_ctor {


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


r370689 - Rename -Wc++20-designator to -Wc++2a-designator for consistency and add

2019-09-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Sep  2 16:27:54 2019
New Revision: 370689

URL: http://llvm.org/viewvc/llvm-project?rev=370689&view=rev
Log:
Rename -Wc++20-designator to -Wc++2a-designator for consistency and add
some test coverage for the flag.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=370689&r1=370688&r2=370689&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Sep  2 16:27:54 2019
@@ -146,9 +146,9 @@ def Deprecated : DiagGroup<"deprecated",
   DeprecatedWritableStr]>,
  DiagCategory<"Deprecations">;
 
-def CXX2aDesignator : DiagGroup<"c++20-designator">;
+def CXX2aDesignator : DiagGroup<"c++2a-designator">;
 // Allow -Wno-c99-designator to be used to turn off all warnings on valid C99
-// designators (including the warning controlled by -Wc++20-designator).
+// designators (including the warning controlled by -Wc++2a-designator).
 def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
 def GNUDesignator : DiagGroup<"gnu-designator">;
 

Modified: cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp?rev=370689&r1=370688&r2=370689&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-initializer-aggregates.cpp Mon Sep  2 16:27:54 
2019
@@ -1,17 +1,18 @@
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic,override,reorder 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic 
-Werror=c99-designator -Wno-reorder-init-list -Wno-initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,reorder -Wno-c99-designator 
-Werror=reorder-init-list -Wno-initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify=expected,override -Wno-c99-designator 
-Wno-reorder-init-list -Werror=initializer-overrides
-// RUN: %clang_cc1 -std=c++2a %s -verify -Wno-c99-designator 
-Wno-reorder-init-list -Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s 
-verify=cxx20,expected,pedantic,override,reorder -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s -verify=expected,pedantic,override,reorder 
-Wno-c++2a-designator -pedantic-errors
+// RUN: %clang_cc1 -std=c++2a %s -verify=cxx20,expected,pedantic 
-Werror=c99-designator -Wno-reorder-init-list -Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=cxx20,expected,reorder 
-Wno-c99-designator -Werror=reorder-init-list -Wno-initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=cxx20,expected,override 
-Wno-c99-designator -Wno-reorder-init-list -Werror=initializer-overrides
+// RUN: %clang_cc1 -std=c++2a %s -verify=cxx20,expected -Wno-c99-designator 
-Wno-reorder-init-list -Wno-initializer-overrides
 
 
 namespace class_with_ctor {
-  struct A { // expected-note 6{{candidate}}
-A() = default; // expected-note 3{{candidate}}
+  struct A { // cxx20-note 6{{candidate}}
+A() = default; // cxx20-note 3{{candidate}}
 int x;
 int y;
   };
-  A a = {1, 2}; // expected-error {{no matching constructor}}
+  A a = {1, 2}; // cxx20-error {{no matching constructor}}
 
   struct B {
 int x;
@@ -24,7 +25,7 @@ namespace class_with_ctor {
 A a;
   };
   C c1 = {{}, {}}; // ok, call default ctor twice
-  C c2 = {{1, 2}, {3, 4}}; // expected-error 2{{no matching constructor}}
+  C c2 = {{1, 2}, {3, 4}}; // cxx20-error 2{{no matching constructor}}
 }
 
 namespace designator {


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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2019-09-02 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D66919#1655048 , @dexonsmith wrote:

> I went back to read notes from when we deployed `-Wstrict-prototypes` (which 
> we have had on-by-default for our users for a couple of years, since it 
> catches lots of `-fblocks`-related bugs).  I was mainly objecting because I 
> had (mis)remembered trying and backing out the specific behaviour you're 
> adding.  On the contrary, our notes say that we might want to strengthen the 
> diagnostic as you're doing.


Thank you for having a look at the notes, that's good to hear.

Your users are Xcode/Apple Clang users? @aaron.ballman suggested to turn the 
warning on per default, and if Apple has that deployed already, it might be 
another argument in favor of doing so in vanilla Clang as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66919/new/

https://reviews.llvm.org/D66919



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


r370691 - [x86] Fix bugs of some intrinsic functions in CLANG : _mm512_stream_ps, _mm512_stream_pd, _mm512_stream_si512

2019-09-02 Thread Pengfei Wang via cfe-commits
Author: pengfei
Date: Mon Sep  2 19:06:15 2019
New Revision: 370691

URL: http://llvm.org/viewvc/llvm-project?rev=370691&view=rev
Log:
[x86] Fix bugs of some intrinsic functions in CLANG : _mm512_stream_ps, 
_mm512_stream_pd, _mm512_stream_si512

Reviewers: craig.topper, pengfei, LuoYuanke, RKSimon, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

Patch by Bing Yu (yubing)

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=370691&r1=370690&r2=370691&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Sep  2 19:06:15 2019
@@ -8436,7 +8436,7 @@ _store_mask16(__mmask16 *__A, __mmask16
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS512
-_mm512_stream_si512 (__m512i * __P, __m512i __A)
+_mm512_stream_si512 (void * __P, __m512i __A)
 {
   typedef __v8di __v8di_aligned __attribute__((aligned(64)));
   __builtin_nontemporal_store((__v8di_aligned)__A, (__v8di_aligned*)__P);
@@ -8450,14 +8450,14 @@ _mm512_stream_load_si512 (void const *__
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS512
-_mm512_stream_pd (double *__P, __m512d __A)
+_mm512_stream_pd (void *__P, __m512d __A)
 {
   typedef __v8df __v8df_aligned __attribute__((aligned(64)));
   __builtin_nontemporal_store((__v8df_aligned)__A, (__v8df_aligned*)__P);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS512
-_mm512_stream_ps (float *__P, __m512 __A)
+_mm512_stream_ps (void *__P, __m512 __A)
 {
   typedef __v16sf __v16sf_aligned __attribute__((aligned(64)));
   __builtin_nontemporal_store((__v16sf_aligned)__A, (__v16sf_aligned*)__P);

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=370691&r1=370690&r2=370691&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Sep  2 19:06:15 2019
@@ -8575,6 +8575,12 @@ void test_mm512_stream_si512(__m512i * _
   _mm512_stream_si512(__P, __A); 
 }
 
+void test_mm512_stream_si512_2(void * __P, __m512i __A) {
+  // CHECK-LABEL: @test_mm512_stream_si512
+  // CHECK: store <8 x i64> %{{.*}}, <8 x i64>* %{{.*}}, align 64, !nontemporal
+  _mm512_stream_si512(__P, __A); 
+}
+
 __m512i test_mm512_stream_load_si512(void *__P) {
   // CHECK-LABEL: @test_mm512_stream_load_si512
   // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal
@@ -8593,12 +8599,23 @@ void test_mm512_stream_pd(double *__P, _
   return _mm512_stream_pd(__P, __A); 
 }
 
+void test_mm512_stream_pd_2(void *__P, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_stream_pd
+  // CHECK: store <8 x double> %{{.*}}, <8 x double>* %{{.*}}, align 64, 
!nontemporal
+  return _mm512_stream_pd(__P, __A); 
+}
+
 void test_mm512_stream_ps(float *__P, __m512 __A) {
   // CHECK-LABEL: @test_mm512_stream_ps
   // CHECK: store <16 x float> %{{.*}}, <16 x float>* %{{.*}}, align 64, 
!nontemporal
   _mm512_stream_ps(__P, __A); 
 }
 
+void test_mm512_stream_ps_2(void *__P, __m512 __A) {
+  // CHECK-LABEL: @test_mm512_stream_ps
+  // CHECK: store <16 x float> %{{.*}}, <16 x float>* %{{.*}}, align 64, 
!nontemporal
+  _mm512_stream_ps(__P, __A); 
+}
 __m512d test_mm512_mask_compress_pd(__m512d __W, __mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_mask_compress_pd
   // CHECK: @llvm.x86.avx512.mask.compress


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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-02 Thread Sr.Zhang via Phabricator via cfe-commits
zsrkmyn added a comment.

Thanks @lebedev.ri , I'm currently under discussion with @erichkeane  , and 
I'll add lit test after the final decision on how to solve the issue.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



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


[PATCH] D66699: [PowerPC][Altivec] Fix constant argument for vec_dss

2019-09-02 Thread Zixuan Wu (Zeson) via Phabricator via cfe-commits
wuzish added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-error.c:78
+void testDSS(int index) {
+  vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must 
be a constant integer}}
+

It would be better if add range constraint check at 
Sema::CheckPPCBuiltinFunctionCall


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66699/new/

https://reviews.llvm.org/D66699



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


[PATCH] D66042: [analyzer] Analysis: Silence checkers

2019-09-02 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@Charusso This probably should be added to the release notes:
https://clang.llvm.org/docs/ReleaseNotes.html#static-analyzer
and detailed in the doc.
Please let me know if you need help!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66042/new/

https://reviews.llvm.org/D66042



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