[PATCH] D89528: [clang][test] Fix prefix operator++ signature in iterators

2020-10-19 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D89528#2334795 , @martong wrote:

> What is the context here? Did it cause any crash/bug or were you just reading 
> through the code for a good night sleep? :D

Actually I was debugging thru iterator-related code and was making assumptions 
on the signature of operators.
Then I noticed the assymetry of return types in case of operator++ (fundamental 
types have ref return values in prefix case, but the simulator header did-not).

Note that the libc++ implementation uses reference return types:
https://github.com/llvm/llvm-project/blob/master/libcxx/include/iterator
So does the libstd++ implementation:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_iterator.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89528

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


[clang] 45a15dc - [clang-rename] Fix rename on function template specializations.

2020-10-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-19T09:32:17+02:00
New Revision: 45a15dc682c06b95cd9182a889e972e93b58aa8e

URL: 
https://github.com/llvm/llvm-project/commit/45a15dc682c06b95cd9182a889e972e93b58aa8e
DIFF: 
https://github.com/llvm/llvm-project/commit/45a15dc682c06b95cd9182a889e972e93b58aa8e.diff

LOG: [clang-rename] Fix rename on function template specializations.

previously, we missed to rename occurrences to explicit function template
specilizations.

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

Added: 
clang/test/clang-rename/FunctionTemplate.cpp

Modified: 
clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp 
b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
index 886c8ee551a0..e4056f701683 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -80,6 +80,12 @@ class AdditionalUSRFinder : public 
RecursiveASTVisitor {
 } else if (const auto *TemplateDecl =
dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  USRSet.insert(getUSRForDecl(FD));
+  if (const auto *FTD = FD->getPrimaryTemplate())
+handleFunctionTemplateDecl(FTD);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  handleFunctionTemplateDecl(FD);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
@@ -119,6 +125,13 @@ class AdditionalUSRFinder : public 
RecursiveASTVisitor {
 addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
   }
 
+  void handleFunctionTemplateDecl(const FunctionTemplateDecl *FTD) {
+USRSet.insert(getUSRForDecl(FTD));
+USRSet.insert(getUSRForDecl(FTD->getTemplatedDecl()));
+for (const auto *S : FTD->specializations())
+  USRSet.insert(getUSRForDecl(S));
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
 const auto* RecordDecl = RD->getDefinition();
 

diff  --git a/clang/test/clang-rename/FunctionTemplate.cpp 
b/clang/test/clang-rename/FunctionTemplate.cpp
new file mode 100644
index ..51b2515b8894
--- /dev/null
+++ b/clang/test/clang-rename/FunctionTemplate.cpp
@@ -0,0 +1,19 @@
+template 
+void Foo(T t); // CHECK: void Bar(T t);
+
+template <>
+void Foo(int a); // CHECK: void Bar(int a);
+
+void test() {
+  Foo(1); // CHECK: Bar(1);
+}
+
+// Test 1.
+// RUN: clang-rename -offset=28 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=81 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=137 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 



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


[PATCH] D89221: [clang-rename] Fix rename on function template specializations.

2020-10-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45a15dc682c0: [clang-rename] Fix rename on function template 
specializations. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89221

Files:
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  clang/test/clang-rename/FunctionTemplate.cpp


Index: clang/test/clang-rename/FunctionTemplate.cpp
===
--- /dev/null
+++ clang/test/clang-rename/FunctionTemplate.cpp
@@ -0,0 +1,19 @@
+template 
+void Foo(T t); // CHECK: void Bar(T t);
+
+template <>
+void Foo(int a); // CHECK: void Bar(int a);
+
+void test() {
+  Foo(1); // CHECK: Bar(1);
+}
+
+// Test 1.
+// RUN: clang-rename -offset=28 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=81 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=137 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -80,6 +80,12 @@
 } else if (const auto *TemplateDecl =
dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  USRSet.insert(getUSRForDecl(FD));
+  if (const auto *FTD = FD->getPrimaryTemplate())
+handleFunctionTemplateDecl(FTD);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  handleFunctionTemplateDecl(FD);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
@@ -119,6 +125,13 @@
 addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
   }
 
+  void handleFunctionTemplateDecl(const FunctionTemplateDecl *FTD) {
+USRSet.insert(getUSRForDecl(FTD));
+USRSet.insert(getUSRForDecl(FTD->getTemplatedDecl()));
+for (const auto *S : FTD->specializations())
+  USRSet.insert(getUSRForDecl(S));
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
 const auto* RecordDecl = RD->getDefinition();
 


Index: clang/test/clang-rename/FunctionTemplate.cpp
===
--- /dev/null
+++ clang/test/clang-rename/FunctionTemplate.cpp
@@ -0,0 +1,19 @@
+template 
+void Foo(T t); // CHECK: void Bar(T t);
+
+template <>
+void Foo(int a); // CHECK: void Bar(int a);
+
+void test() {
+  Foo(1); // CHECK: Bar(1);
+}
+
+// Test 1.
+// RUN: clang-rename -offset=28 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=81 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=137 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -80,6 +80,12 @@
 } else if (const auto *TemplateDecl =
dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  USRSet.insert(getUSRForDecl(FD));
+  if (const auto *FTD = FD->getPrimaryTemplate())
+handleFunctionTemplateDecl(FTD);
+} else if (const auto *FD = dyn_cast(FoundDecl)) {
+  handleFunctionTemplateDecl(FD);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
@@ -119,6 +125,13 @@
 addUSRsOfCtorDtors(TemplateDecl->getTemplatedDecl());
   }
 
+  void handleFunctionTemplateDecl(const FunctionTemplateDecl *FTD) {
+USRSet.insert(getUSRForDecl(FTD));
+USRSet.insert(getUSRForDecl(FTD->getTemplatedDecl()));
+for (const auto *S : FTD->specializations())
+  USRSet.insert(getUSRForDecl(S));
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
 const auto* RecordDecl = RD->getDefinition();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1e32df2 - [clang-rename] Fix rename on variable templates.

2020-10-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-19T09:44:59+02:00
New Revision: 1e32df2f91f1aa1f8cd400ce50a621578fa0534e

URL: 
https://github.com/llvm/llvm-project/commit/1e32df2f91f1aa1f8cd400ce50a621578fa0534e
DIFF: 
https://github.com/llvm/llvm-project/commit/1e32df2f91f1aa1f8cd400ce50a621578fa0534e.diff

LOG: [clang-rename] Fix rename on variable templates.

This patch adds support for renaming variable templates.

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

Added: 
clang/test/clang-rename/VariableTemplate.cpp

Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/DeclTemplate.cpp
clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index d10103752d81..5f3525739091 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -3095,7 +3095,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
   /// Retrieve the set of partial specializations of this class
   /// template.
   llvm::FoldingSetVector &
-  getPartialSpecializations();
+  getPartialSpecializations() const;
 
   VarTemplateDecl(ASTContext , DeclContext *DC, SourceLocation L,
   DeclarationName Name, TemplateParameterList *Params,
@@ -3191,7 +3191,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
 
   /// Retrieve the partial specializations as an ordered list.
   void getPartialSpecializations(
-  SmallVectorImpl );
+  SmallVectorImpl ) const;
 
   /// Find a variable template partial specialization which was
   /// instantiated

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 5538651a453d..d99a9c19c506 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1142,7 +1142,7 @@ VarTemplateDecl::getSpecializations() const {
 }
 
 llvm::FoldingSetVector &
-VarTemplateDecl::getPartialSpecializations() {
+VarTemplateDecl::getPartialSpecializations() const {
   LoadLazySpecializations();
   return getCommonPtr()->PartialSpecializations;
 }
@@ -1198,7 +1198,7 @@ void VarTemplateDecl::AddPartialSpecialization(
 }
 
 void VarTemplateDecl::getPartialSpecializations(
-SmallVectorImpl ) {
+SmallVectorImpl ) const {
   llvm::FoldingSetVector  =
   getPartialSpecializations();
   PS.clear();

diff  --git a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp 
b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
index e4056f701683..a69b76a3c971 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -86,6 +86,16 @@ class AdditionalUSRFinder : public 
RecursiveASTVisitor {
 handleFunctionTemplateDecl(FTD);
 } else if (const auto *FD = dyn_cast(FoundDecl)) {
   handleFunctionTemplateDecl(FD);
+} else if (const auto *VTD = dyn_cast(FoundDecl)) {
+  handleVarTemplateDecl(VTD);
+} else if (const auto *VD =
+   dyn_cast(FoundDecl)) {
+  // FIXME: figure out why FoundDecl can be a 
VarTemplateSpecializationDecl.
+  handleVarTemplateDecl(VD->getSpecializedTemplate());
+} else if (const auto *VD = dyn_cast(FoundDecl)) {
+  USRSet.insert(getUSRForDecl(VD));
+  if (const auto *VTD = VD->getDescribedVarTemplate())
+handleVarTemplateDecl(VTD);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
@@ -132,6 +142,19 @@ class AdditionalUSRFinder : public 
RecursiveASTVisitor {
   USRSet.insert(getUSRForDecl(S));
   }
 
+  void handleVarTemplateDecl(const VarTemplateDecl *VTD) {
+USRSet.insert(getUSRForDecl(VTD));
+USRSet.insert(getUSRForDecl(VTD->getTemplatedDecl()));
+llvm::for_each(VTD->specializations(), [&](const auto *Spec) {
+  USRSet.insert(getUSRForDecl(Spec));
+});
+SmallVector PartialSpecs;
+VTD->getPartialSpecializations(PartialSpecs);
+llvm::for_each(PartialSpecs, [&](const auto *Spec) {
+  USRSet.insert(getUSRForDecl(Spec));
+});
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
 const auto* RecordDecl = RD->getDefinition();
 

diff  --git a/clang/test/clang-rename/VariableTemplate.cpp 
b/clang/test/clang-rename/VariableTemplate.cpp
new file mode 100644
index ..a345ede5a7f6
--- /dev/null
+++ b/clang/test/clang-rename/VariableTemplate.cpp
@@ -0,0 +1,32 @@
+template 
+bool Foo = true;  // CHECK: bool Bar = true;
+
+// explicit template specialization
+template <>
+bool Foo = false; // CHECK: bool Bar = false;
+
+// partial template specialization
+template 
+bool Foo = false; // bool Bar = false;
+
+void k() {
+  // ref to the explicit template specialization
+  Foo;   // CHECK: Bar;
+  // ref to the primary template.
+  Foo;   // CHECK: Bar;
+}
+
+
+// Test 1.
+// RUN: clang-rename -offset=34 -new-name=Bar %s -- | sed 's,//.*,,' | 

[PATCH] D89300: [clang-rename] Fix rename on variable templates.

2020-10-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e32df2f91f1: [clang-rename] Fix rename on variable 
templates. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89300

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  clang/test/clang-rename/VariableTemplate.cpp

Index: clang/test/clang-rename/VariableTemplate.cpp
===
--- /dev/null
+++ clang/test/clang-rename/VariableTemplate.cpp
@@ -0,0 +1,32 @@
+template 
+bool Foo = true;  // CHECK: bool Bar = true;
+
+// explicit template specialization
+template <>
+bool Foo = false; // CHECK: bool Bar = false;
+
+// partial template specialization
+template 
+bool Foo = false; // bool Bar = false;
+
+void k() {
+  // ref to the explicit template specialization
+  Foo;   // CHECK: Bar;
+  // ref to the primary template.
+  Foo;   // CHECK: Bar;
+}
+
+
+// Test 1.
+// RUN: clang-rename -offset=34 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=128 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=248 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 4.
+// RUN: clang-rename -offset=357 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 5.
+// RUN: clang-rename -offset=431 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 
Index: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -86,6 +86,16 @@
 handleFunctionTemplateDecl(FTD);
 } else if (const auto *FD = dyn_cast(FoundDecl)) {
   handleFunctionTemplateDecl(FD);
+} else if (const auto *VTD = dyn_cast(FoundDecl)) {
+  handleVarTemplateDecl(VTD);
+} else if (const auto *VD =
+   dyn_cast(FoundDecl)) {
+  // FIXME: figure out why FoundDecl can be a VarTemplateSpecializationDecl.
+  handleVarTemplateDecl(VD->getSpecializedTemplate());
+} else if (const auto *VD = dyn_cast(FoundDecl)) {
+  USRSet.insert(getUSRForDecl(VD));
+  if (const auto *VTD = VD->getDescribedVarTemplate())
+handleVarTemplateDecl(VTD);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
@@ -132,6 +142,19 @@
   USRSet.insert(getUSRForDecl(S));
   }
 
+  void handleVarTemplateDecl(const VarTemplateDecl *VTD) {
+USRSet.insert(getUSRForDecl(VTD));
+USRSet.insert(getUSRForDecl(VTD->getTemplatedDecl()));
+llvm::for_each(VTD->specializations(), [&](const auto *Spec) {
+  USRSet.insert(getUSRForDecl(Spec));
+});
+SmallVector PartialSpecs;
+VTD->getPartialSpecializations(PartialSpecs);
+llvm::for_each(PartialSpecs, [&](const auto *Spec) {
+  USRSet.insert(getUSRForDecl(Spec));
+});
+  }
+
   void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
 const auto* RecordDecl = RD->getDefinition();
 
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -1142,7 +1142,7 @@
 }
 
 llvm::FoldingSetVector &
-VarTemplateDecl::getPartialSpecializations() {
+VarTemplateDecl::getPartialSpecializations() const {
   LoadLazySpecializations();
   return getCommonPtr()->PartialSpecializations;
 }
@@ -1198,7 +1198,7 @@
 }
 
 void VarTemplateDecl::getPartialSpecializations(
-SmallVectorImpl ) {
+SmallVectorImpl ) const {
   llvm::FoldingSetVector  =
   getPartialSpecializations();
   PS.clear();
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -3095,7 +3095,7 @@
   /// Retrieve the set of partial specializations of this class
   /// template.
   llvm::FoldingSetVector &
-  getPartialSpecializations();
+  getPartialSpecializations() const;
 
   VarTemplateDecl(ASTContext , DeclContext *DC, SourceLocation L,
   DeclarationName Name, TemplateParameterList *Params,
@@ -3191,7 +3191,7 @@
 
   /// Retrieve the partial specializations as an ordered list.
   void getPartialSpecializations(
-  SmallVectorImpl );
+  SmallVectorImpl ) const;
 
   /// Find a variable template partial specialization which was
   /// instantiated
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89690: [clang] update of the DragonFlyBSD's driver for the 5.8.x releases.

2020-10-19 Thread David CARLIER via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13e22961f8b4: [clang] update of the DragonFlyBSDs 
driver for the 5.8.x releases (authored by devnexen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89690

Files:
  clang/lib/Driver/ToolChains/DragonFly.cpp


Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -120,11 +120,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-CmdArgs.push_back("-L/usr/lib/gcc50");
+CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
   CmdArgs.push_back("-rpath");
-  CmdArgs.push_back("/usr/lib/gcc50");
+  CmdArgs.push_back("/usr/lib/gcc80");
 }
 
 if (D.CCCIsCXX()) {
@@ -189,7 +189,7 @@
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  getFilePaths().push_back("/usr/lib/gcc50");
+  getFilePaths().push_back("/usr/lib/gcc80");
 }
 
 Tool *DragonFly::buildAssembler() const {


Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -120,11 +120,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-CmdArgs.push_back("-L/usr/lib/gcc50");
+CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
   CmdArgs.push_back("-rpath");
-  CmdArgs.push_back("/usr/lib/gcc50");
+  CmdArgs.push_back("/usr/lib/gcc80");
 }
 
 if (D.CCCIsCXX()) {
@@ -189,7 +189,7 @@
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  getFilePaths().push_back("/usr/lib/gcc50");
+  getFilePaths().push_back("/usr/lib/gcc80");
 }
 
 Tool *DragonFly::buildAssembler() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 13e2296 - [clang] update of the DragonFlyBSD's driver for the 5.8.x releases

2020-10-19 Thread David Carlier via cfe-commits

Author: David Carlier
Date: 2020-10-19T14:04:49+01:00
New Revision: 13e22961f8b45fb76e6d60c0f987a07009815f02

URL: 
https://github.com/llvm/llvm-project/commit/13e22961f8b45fb76e6d60c0f987a07009815f02
DIFF: 
https://github.com/llvm/llvm-project/commit/13e22961f8b45fb76e6d60c0f987a07009815f02.diff

LOG: [clang] update of the DragonFlyBSD's driver for the 5.8.x releases

Reviewers: sepavloff, jyknight

Reviewed By: sepavloff

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/DragonFly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 08176e507eed..9568b47e89e6 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -120,11 +120,11 @@ void dragonfly::Linker::ConstructJob(Compilation , 
const JobAction ,
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-CmdArgs.push_back("-L/usr/lib/gcc50");
+CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
   CmdArgs.push_back("-rpath");
-  CmdArgs.push_back("/usr/lib/gcc50");
+  CmdArgs.push_back("/usr/lib/gcc80");
 }
 
 if (D.CCCIsCXX()) {
@@ -189,7 +189,7 @@ DragonFly::DragonFly(const Driver , const llvm::Triple 
,
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  getFilePaths().push_back("/usr/lib/gcc50");
+  getFilePaths().push_back("/usr/lib/gcc80");
 }
 
 Tool *DragonFly::buildAssembler() const {



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


[PATCH] D87989: [Flang][Driver] Add infrastructure for basic frontend actions and file I/O

2020-10-19 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 299033.
awarzynski added a comment.

Simplify the API for creating output files

The originally implemented API was overly complicated and not yet required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87989

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/Types.cpp
  clang/test/Driver/immediate-options.c
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendAction.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/FrontendTool/Utils.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/CMakeLists.txt
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Frontend/Inputs/hello-world.f90
  flang/test/Frontend/input-output-file.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/lit.cfg.py
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CMakeLists.txt
  flang/unittests/Frontend/CompilerInstanceTest.cpp
  flang/unittests/Frontend/InputOutputTest.cpp

Index: flang/unittests/Frontend/InputOutputTest.cpp
===
--- /dev/null
+++ flang/unittests/Frontend/InputOutputTest.cpp
@@ -0,0 +1,72 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/FrontendOptions.h"
+#include "flang/FrontendTool/Utils.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace Fortran::frontend;
+
+namespace {
+
+TEST(FrontendAction, TestInputOutputTestAction) {
+  std::string inputFile = "io-file-test.f";
+  std::error_code ec;
+
+  // 1. Create the input file for the file manager
+  // AllSources (which is used to manage files inside every compiler instance),
+  // works with paths. This means that it requires a physical file. Create one.
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+FAIL() << "Failed to create the input file";
+
+  // Populate the input file with the pre-defined input and flush it.
+  *(os) << "End Program arithmetic";
+  os.reset();
+
+  // Get the path of the input file
+  llvm::SmallString<64> cwd;
+  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+FAIL() << "Failed to obtain the current working directory";
+  std::string testFilePath(cwd.c_str());
+  testFilePath += "/" + inputFile;
+
+  // 2. Prepare the compiler (CompilerInvocation + CompilerInstance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->GetFrontendOpts().programAction_ = InputOutputTest;
+  compInst.SetInvocation(std::move(invocation));
+  compInst.GetFrontendOpts().inputs_.push_back(
+  FrontendInputFile(/*File=*/testFilePath, Language::Fortran));
+
+  // 3. Set-up the output stream. Using output buffer wrapped as an output
+  // stream, as opposed to an actual file (or a file descriptor).
+  llvm::SmallVector outputFileBuffer;
+  std::unique_ptr outputFileStream(
+  new llvm::raw_svector_ostream(outputFileBuffer));
+  compInst.SetOutputStream(std::move(outputFileStream));
+
+  // 4. Run the earlier defined FrontendAction
+  bool success = ExecuteCompilerInvocation();
+
+  EXPECT_TRUE(success);
+  EXPECT_TRUE(!outputFileBuffer.empty());
+  EXPECT_TRUE(llvm::StringRef(outputFileBuffer.data())
+  .startswith("End Program arithmetic"));
+
+  // 5. Clear the output files. Since we used an output buffer, there are no
+  // physical files to delete.
+  compInst.ClearOutputFiles(/*EraseFiles=*/false);
+}
+} // namespace
Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -9,6 +9,7 @@
 #include "flang/Frontend/CompilerInstance.h"
 #include 

[PATCH] D89571: [clangd] Add textDocument/ast extension method to dump the AST

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 298959.
sammccall added a comment.

Oops, forgot newly added files :-\


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89571

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/CMakeLists.txt

Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -51,6 +51,7 @@
   DexTests.cpp
   DiagnosticsTests.cpp
   DraftStoreTests.cpp
+  DumpASTTests.cpp
   ExpectedTypeTest.cpp
   FileDistanceTests.cpp
   FileIndexTests.cpp
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -5,6 +5,7 @@
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"capabilities": {
+# CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1576,6 +1576,45 @@
 };
 llvm::json::Value toJSON(const FoldingRange );
 
+/// Payload for textDocument/ast request.
+/// This request is a clangd extension.
+struct ASTParams {
+  /// The text document.
+  TextDocumentIdentifier textDocument;
+
+  /// The position of the node to be dumped.
+  /// The highest-level node that entirely contains the range will be returned.
+  Range range;
+};
+bool fromJSON(const llvm::json::Value &, ASTParams &, llvm::json::Path);
+
+/// Simplified description of a clang AST node.
+/// This is clangd's internal representation of C++ code.
+struct ASTNode {
+  /// The general kind of node, such as "expression"
+  /// Corresponds to the base AST node type such as Expr.
+  std::string role;
+  /// The specific kind of node this is, such as "BinaryOperator".
+  /// This is usually a concrete node class (with Expr etc suffix dropped).
+  /// When there's no hierarchy (e.g. TemplateName), the variant (NameKind).
+  std::string kind;
+  /// Brief additional information, such as "||" for the particular operator.
+  /// The information included depends on the node kind, and may be empty.
+  std::string detail;
+  /// A one-line dump of detailed information about the node.
+  /// This includes role/kind/description information, but is rather cryptic.
+  /// It is similar to the output from `clang -Xclang -ast-dump`.
+  /// May be empty for certain types of nodes.
+  std::string arcana;
+  /// The range of the original source file covered by this node.
+  /// May be missing for implicit nodes, or those created by macro expansion.
+  llvm::Optional range;
+  /// Nodes nested within this one, such as the operands of a BinaryOperator.
+  std::vector children;
+};
+llvm::json::Value toJSON(const ASTNode &);
+llvm::raw_ostream <<(llvm::raw_ostream &, const ASTNode &);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1300,5 +1300,41 @@
   return Result;
 }
 
+bool fromJSON(const llvm::json::Value , ASTParams ,
+  llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
+}
+
+llvm::json::Value toJSON(const ASTNode ) {
+  llvm::json::Object Result{
+  {"role", N.role},
+  {"kind", N.kind},
+  };
+  if (!N.children.empty())
+Result["children"] = N.children;
+  if (!N.detail.empty())
+Result["detail"] = N.detail;
+  if (!N.arcana.empty())
+Result["arcana"] = N.arcana;
+  if (N.range)
+Result["range"] = *N.range;
+  return Result;
+}
+
+llvm::raw_ostream <<(llvm::raw_ostream , const ASTNode ) {
+  std::function Print = [&](const ASTNode ,
+ unsigned Level) {
+OS.indent(2 * Level) << N.role << ": " << N.kind;
+if (!N.detail.empty())
+  OS << " - " << N.detail;
+OS << "\n";
+for (const ASTNode  : N.children)
+  Print(C, Level + 1);
+  };
+  Print(Root, 0);
+  return OS;
+}
+
 } // namespace clangd
 } // namespace clang
Index: 

[PATCH] D89520: Don't permit array bound constant folding in OpenCL.

2020-10-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89520

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


[clang-tools-extra] d0f2874 - [clangd] Add $/memoryUsage LSP extension

2020-10-19 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-10-19T12:30:25+02:00
New Revision: d0f287464d8a2b6940cc968850b7a013c665981a

URL: 
https://github.com/llvm/llvm-project/commit/d0f287464d8a2b6940cc968850b7a013c665981a
DIFF: 
https://github.com/llvm/llvm-project/commit/d0f287464d8a2b6940cc968850b7a013c665981a.diff

LOG: [clangd] Add $/memoryUsage LSP extension

Performs a detailed profiling of clangd lsp server and conveys the
result to the client as a json object. It is of the form:
   {
 "_self": 0,
 "_total": 8,
 "child1": {
   "_self": 4,
   "_total": 4,
 }
 "child2": {
   "_self": 2,
   "_total": 4,
   "child_deep": {
 "_self": 2,
 "_total": 2,
   }
 }
   }

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

Added: 
clang-tools-extra/clangd/test/memory_tree.test

Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index d46147ac89cd..99c2465a579c 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -36,8 +36,11 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SHA1.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -617,6 +620,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
+{"memoryUsageProvider", true}, // clangd extension.
 ;
   if (Opts.Encoding)
 Result["offsetEncoding"] = *Opts.Encoding;
@@ -1383,6 +1387,14 @@ void ClangdLSPServer::onSemanticTokensDelta(
   });
 }
 
+void ClangdLSPServer::onMemoryUsage(const NoParams &,
+Callback Reply) {
+  llvm::BumpPtrAllocator DetailAlloc;
+  MemoryTree MT();
+  profile(MT);
+  Reply(std::move(MT));
+}
+
 ClangdLSPServer::ClangdLSPServer(class Transport ,
  const ThreadsafeFS ,
  const ClangdLSPServer::Options )
@@ -1425,6 +1437,7 @@ ClangdLSPServer::ClangdLSPServer(class Transport ,
   MsgHandler->bind("textDocument/documentLink", 
::onDocumentLink);
   MsgHandler->bind("textDocument/semanticTokens/full", 
::onSemanticTokens);
   MsgHandler->bind("textDocument/semanticTokens/full/delta", 
::onSemanticTokensDelta);
+  MsgHandler->bind("$/memoryUsage", ::onMemoryUsage);
   if (Opts.FoldingRanges)
 MsgHandler->bind("textDocument/foldingRange", 
::onFoldingRange);
   // clang-format on

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 7054c48652c5..9fb23a07f6c5 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -24,6 +24,7 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -141,6 +142,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
   void onSemanticTokens(const SemanticTokensParams &, 
Callback);
   void onSemanticTokensDelta(const SemanticTokensDeltaParams &,
  Callback);
+  /// This is a clangd extension. Provides a json tree representing memory 
usage
+  /// hierarchy.
+  void onMemoryUsage(const NoParams &, Callback);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic );
 

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index f41cea28fea3..0b89c622e6f8 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1300,5 +1300,17 @@ llvm::json::Value toJSON(const FoldingRange ) {
   return Result;
 }
 
+llvm::json::Value toJSON(const MemoryTree ) {
+  llvm::json::Object Out;
+  int64_t Total = MT.self();
+  Out["_self"] = Total;
+  for (const auto  : MT.children()) {
+auto Child = toJSON(Entry.getSecond());
+Total += *Child.getAsObject()->getInteger("_total");
+Out[Entry.first] = std::move(Child);
+  }
+  Out["_total"] = Total;
+  return Out;
+}
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 6f395ffb21c5..165a4a89e1cd 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -25,6 +25,7 @@
 
 #include "URI.h"
 #include "index/SymbolID.h"
+#include "support/MemoryTree.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/JSON.h"
@@ -1576,6 

[PATCH] D89332: [clang-tidy] performance-unnecessary-copy-initialization: Always allow std::function to be copied.

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Come to think of it, this is a pretty illogical way to solve this problem, just 
append `::std::function` to the AllowedTypes vector in `registerMatchers` and 
be do with it. Will require dropping the const Qualifier on AllowedTypes, but 
aside from that it is a much simpler fix.
The has(Any)Name matcher has logic for skipping inline namespaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89332

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


[PATCH] D89690: [clang] update of the DragonFlyBSD's driver for the 5.8.x releases.

2020-10-19 Thread David CARLIER via Phabricator via cfe-commits
devnexen created this revision.
devnexen added reviewers: sepavloff, jyknight.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
devnexen requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89690

Files:
  clang/lib/Driver/ToolChains/DragonFly.cpp


Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -120,11 +120,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-CmdArgs.push_back("-L/usr/lib/gcc50");
+CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
   CmdArgs.push_back("-rpath");
-  CmdArgs.push_back("/usr/lib/gcc50");
+  CmdArgs.push_back("/usr/lib/gcc80");
 }
 
 if (D.CCCIsCXX()) {
@@ -189,7 +189,7 @@
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  getFilePaths().push_back("/usr/lib/gcc50");
+  getFilePaths().push_back("/usr/lib/gcc80");
 }
 
 Tool *DragonFly::buildAssembler() const {


Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -120,11 +120,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-CmdArgs.push_back("-L/usr/lib/gcc50");
+CmdArgs.push_back("-L/usr/lib/gcc80");
 
 if (!Args.hasArg(options::OPT_static)) {
   CmdArgs.push_back("-rpath");
-  CmdArgs.push_back("/usr/lib/gcc50");
+  CmdArgs.push_back("/usr/lib/gcc80");
 }
 
 if (D.CCCIsCXX()) {
@@ -189,7 +189,7 @@
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  getFilePaths().push_back("/usr/lib/gcc50");
+  getFilePaths().push_back("/usr/lib/gcc80");
 }
 
 Tool *DragonFly::buildAssembler() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-19 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 299014.
david-arm added a comment.

- Rebase.


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

https://reviews.llvm.org/D89031

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp

Index: clang/test/CodeGenCXX/pragma-loop.cpp
===
--- clang/test/CodeGenCXX/pragma-loop.cpp
+++ clang/test/CodeGenCXX/pragma-loop.cpp
@@ -158,6 +158,30 @@
   for_template_constant_expression_test(List, Length);
 }
 
+// Verify do loop is performing fixed width vectorization
+void do_test_fixed(int *List, int Length) {
+  int i = 0;
+
+#pragma clang loop vectorize_width(16, fixed) interleave_count(4) unroll(disable) distribute(disable)
+  do {
+// CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_15:.*]]
+List[i] = i * 2;
+i++;
+  } while (i < Length);
+}
+
+// Verify do loop is performing scalable vectorization
+void do_test_scalable(int *List, int Length) {
+  int i = 0;
+
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  do {
+// CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_16:.*]]
+List[i] = i * 2;
+i++;
+  } while (i < Length);
+}
+
 // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
 // CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
 
@@ -215,3 +239,10 @@
 
 // CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[WIDTH_10:.*]], ![[VECTORIZE_ENABLE]]}
 // CHECK: ![[WIDTH_10]] = !{!"llvm.loop.vectorize.width", i32 10}
+
+// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_FIXED]] = !{!"llvm.loop.vectorize.width", i32 16}
+
+// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_SCALABLE:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_SCALABLE]] = !{!"llvm.loop.vectorize.width", ![[ELEMENT_COUNT_16_SCALABLE:.*]]}
+// CHECK: ![[ELEMENT_COUNT_16_SCALABLE]] = !{i32 16, i32 1}
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -139,10 +139,17 @@
LoopHintAttr::PipelineInitiationInterval)
  .Case("distribute", LoopHintAttr::Distribute)
  .Default(LoopHintAttr::Vectorize);
-if (Option == LoopHintAttr::VectorizeWidth ||
-Option == LoopHintAttr::InterleaveCount ||
-Option == LoopHintAttr::UnrollCount ||
-Option == LoopHintAttr::PipelineInitiationInterval) {
+if (Option == LoopHintAttr::VectorizeWidth) {
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;
+  if (StateLoc && StateLoc->Ident && StateLoc->Ident->isStr("scalable"))
+State = LoopHintAttr::ScalableNumeric;
+  else
+State = LoopHintAttr::Numeric;
+} else if (Option == LoopHintAttr::InterleaveCount ||
+   Option == LoopHintAttr::UnrollCount ||
+   Option == LoopHintAttr::PipelineInitiationInterval) {
   assert(ValueExpr && "Attribute must have a valid value expression.");
   if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
 return nullptr;
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -1193,6 +1193,24 @@
 
 ExprResult R = ParseConstantExpression();
 
+if (OptionInfo && OptionInfo->getName() == "vectorize_width" &&
+Tok.is(tok::comma)) {
+  PP.Lex(Tok); // ,
+
+  SourceLocation StateLoc = Tok.getLocation();
+  IdentifierInfo *StateInfo = Tok.getIdentifierInfo();
+  StringRef IsScalableStr = StateInfo->getName();
+
+  if (IsScalableStr != "scalable" && IsScalableStr != "fixed") {
+Diag(Tok.getLocation(), diag::err_pragma_loop_invalid_vectorize_option);
+return false;
+  }
+  PP.Lex(Tok); // Identifier
+
+  Hint.StateLoc =
+  IdentifierLoc::create(Actions.Context, StateLoc, StateInfo);
+}
+
 // Tokens following an error in an ill-formed constant expression will
 // remain in the token stream and must be removed.
 if (Tok.isNot(tok::eof)) {
Index: clang/lib/CodeGen/CGLoopInfo.h
===
--- clang/lib/CodeGen/CGLoopInfo.h
+++ clang/lib/CodeGen/CGLoopInfo.h
@@ -19,6 

[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked 2 inline comments as done.
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:59
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))

kbobyrev wrote:
> ArcsinX wrote:
> > kbobyrev wrote:
> > > nit: maybe it's time to change type of `RemoteIndexRoot` field to 
> > > `llvm::SmallString<256>` and use 
> > > `!this->RemoteIndexRoot.endswith(PosixSeparator)` instead of additional 
> > > variable. Not really important for this patch but I should probably do it 
> > > anyway if it's not changed in this patch.
> > But `llvm::sys::path::convert_to_slash()` returns `std::string`.  
> > Could you give me an advice how to copy `std::string` into 
> > `llvm::SmallString<256>` here?
> > 
> > E.g. the following code looks strange for me
> > ```
> >   llvm::Optional> RemoteIndexRoot;
> > 
> > 
> > 
> > this->RemoteIndexRoot = 
> > llvm::SmallString<256>(llvm::sys::path::convert_to_slash(
> > RemoteIndexRoot, llvm::sys::path::Style::windows));
> > ```
> > 
> Hmm, yeah right nevermind, this should be OK for this patch, I'll deal with 
> this later.
So, I have made no changes here



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:98
 llvm::sys::path::append(LocalPath, Path);
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));

kbobyrev wrote:
> Please add a comment explaining why it is needed here: these paths are not 
> converted to URIs and have to be specific to the server platform in order for 
> the query to work correctly.
Add more comments in try to explain, that `Path` is a relative path here and it 
could be  with any slashes, so convert it to native to make sure it's 
compatible with the current system.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:242
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());

kbobyrev wrote:
> ArcsinX wrote:
> > kbobyrev wrote:
> > > Why remove this test?
> > As far as I understand, idea of this code is to use absolute path (i.e. 
> > /usr/local/user/home/project/Header.h) to be relative to "/". I do not know 
> > how to make this on Windows.
> > 
> > Also, Marshaller ProtobufMarshaller(convert_to_slash("/"), 
> > convert_to_slash("/")); leads to assertions on Windows:
> > ```
> > assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
> > ...
> > assert(llvm::sys::path::is_absolute(LocalIndexRoot));
> > ```
> > 
> Ah, I see now, makes sense! Yeah, okay then in this case this should be 
> something like `testPath("project/Header.h")` which will be absolut path 
> (what we want) and also relative to `testPath("")` (test path root).
Thanks for advice, fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D87830: [clang-tidy][test] Allow empty checks in check_clang_tidy.py

2020-10-19 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D87830#2336572 , @njames93 wrote:

> Probably not quite as verbose but should do the job
>
>   // RUN: clang-tidy %s --checks=-*,my-check-to-test --warnings-as-errors=* 
> -- -std=c++11

Thanks  ! I can live with this solution as well. If however there is a 
suggestion on how to handle this in an idiomatic way, please share, maybe I can 
help implement it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87830

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 299034.
ArcsinX added a comment.

Comments fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -239,8 +239,8 @@
 
   clangd::Symbol::IncludeHeaderWithReferences Header;
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());
+  Header.IncludeHeader =
+  Strings.save(URI::createFile(testPath("project/Header.h")).toString());
   Header.References = 21;
   Sym.IncludeHeaders.push_back(Header);
   Header.IncludeHeader = Strings.save("");
@@ -250,7 +250,7 @@
   Header.References = 200;
   Sym.IncludeHeaders.push_back(Header);
 
-  Marshaller ProtobufMarshaller(convert_to_slash("/"), convert_to_slash("/"));
+  Marshaller ProtobufMarshaller(testPath(""), testPath(""));
 
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
   ASSERT_TRUE(bool(Serialized));
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -50,20 +50,23 @@
 Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
llvm::StringRef LocalIndexRoot)
 : Strings(Arena) {
+  llvm::StringRef PosixSeparator =
+  llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
   if (!RemoteIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
-assert(RemoteIndexRoot ==
-   llvm::sys::path::convert_to_slash(RemoteIndexRoot));
-this->RemoteIndexRoot = RemoteIndexRoot.str();
-if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->RemoteIndexRoot += llvm::sys::path::get_separator();
+this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->RemoteIndexRoot += PosixSeparator;
   }
   if (!LocalIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(LocalIndexRoot));
-assert(LocalIndexRoot == llvm::sys::path::convert_to_slash(LocalIndexRoot));
-this->LocalIndexRoot = LocalIndexRoot.str();
-if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->LocalIndexRoot += llvm::sys::path::get_separator();
+this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
+LocalIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->LocalIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->LocalIndexRoot += PosixSeparator;
   }
   assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty());
 }
@@ -92,6 +95,9 @@
   for (const auto  : Message->proximity_paths()) {
 llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);
 llvm::sys::path::append(LocalPath, Path);
+// FuzzyFindRequest requires proximity paths to have platform-native format
+// in order for SymbolIndex to process the query correctly.
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));
   }
   for (const auto  : Message->preferred_types())
@@ -209,7 +215,7 @@
 llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
 if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, ""))
   RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
-  RelativePath, llvm::sys::path::Style::posix));
+  RelativePath, llvm::sys::path::Style::windows));
   }
   for (const auto  : From.PreferredTypes)
 RPCRequest.add_preferred_types(Type);
@@ -315,12 +321,17 @@
   if (ParsedURI->scheme() != "file")
 return error("Can not use URI schemes other than file, given: '{0}'.", URI);
   llvm::SmallString<256> Result = ParsedURI->body();
+  llvm::StringRef Path(Result);
+  // Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
+  if (llvm::sys::path::is_absolute(Path.substr(1),
+   llvm::sys::path::Style::windows))
+Result = Path.drop_front();
   if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
 return error("File path '{0}' doesn't start with '{1}'.", Result.str(),
  *RemoteIndexRoot);
-  // Make sure the result has UNIX slashes.
-  return llvm::sys::path::convert_to_slash(Result,
-  

[PATCH] D89571: [clangd] Add textDocument/ast extension method to dump the AST

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 298961.
sammccall added a comment.

(for real this time)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89571

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/DumpAST.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/ast.test
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp

Index: clang-tools-extra/clangd/unittests/DumpASTTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/DumpASTTests.cpp
@@ -0,0 +1,135 @@
+//===-- DumpASTTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "DumpAST.h"
+#include "TestTU.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using testing::SizeIs;
+
+TEST(DumpASTTests, BasicInfo) {
+  std::pair Cases[] = {
+  {R"cpp(
+float root(int *x) {
+  return *x + 1;
+}
+  )cpp",
+   R"(
+declaration: Function - root
+  type: FunctionProto
+type: Builtin - float
+declaration: ParmVar - x
+  type: Pointer
+type: Builtin - int
+  statement: Compound
+statement: Return
+  expression: ImplicitCast - IntegralToFloating
+expression: BinaryOperator - +
+  expression: ImplicitCast - LValueToRValue
+expression: UnaryOperator - *
+  expression: ImplicitCast - LValueToRValue
+expression: DeclRef - x
+  expression: IntegerLiteral - 1
+  )"},
+  {R"cpp(
+namespace root {
+struct S { static const int x = 0; };
+int y = S::x + root::S().x;
+}
+  )cpp",
+   R"(
+declaration: Namespace - root
+  declaration: CXXRecord - S
+declaration: Var - x
+  type: Qualified - const
+type: Builtin - int
+  expression: IntegerLiteral - 0
+declaration: CXXConstructor
+declaration: CXXConstructor
+declaration: CXXConstructor
+declaration: CXXDestructor
+  declaration: Var - y
+type: Builtin - int
+expression: ExprWithCleanups
+  expression: BinaryOperator - +
+expression: ImplicitCast - LValueToRValue
+  expression: DeclRef - x
+specifier: TypeSpec
+  type: Record - S
+expression: ImplicitCast - LValueToRValue
+  expression: Member - x
+expression: MaterializeTemporary - rvalue
+  expression: CXXTemporaryObject - S
+type: Elaborated
+  specifier: Namespace - root::
+  type: Record - S
+  )"},
+  {R"cpp(
+template  int root() {
+  (void)root();
+  return T::value;
+}
+  )cpp",
+   R"(
+declaration: FunctionTemplate - root
+  declaration: TemplateTypeParm - T
+  declaration: Function - root
+type: FunctionProto
+  type: Builtin - int
+statement: Compound
+  expression: CStyleCast - ToVoid
+type: Builtin - void
+expression: Call
+  expression: ImplicitCast - FunctionToPointerDecay
+expression: DeclRef - root
+  template argument: Type
+type: Builtin - unsigned int
+  statement: Return
+expression: DependentScopeDeclRef - value
+  specifier: TypeSpec
+type: TemplateTypeParm - T
+  )"},
+  };
+  for (const auto  : Cases) {
+ParsedAST AST = TestTU::withCode(Case.first).build();
+auto Node = dumpAST(DynTypedNode::create(findDecl(AST, "root")),
+AST.getTokens(), AST.getASTContext());
+EXPECT_EQ(llvm::StringRef(Case.second).trim(),
+  llvm::StringRef(llvm::to_string(Node)).trim());
+  }
+}
+
+TEST(DumpASTTests, Range) {
+  Annotations Case("$var[[$type[[int]] x]];");
+  ParsedAST AST = TestTU::withCode(Case.code()).build();
+  auto Node = dumpAST(DynTypedNode::create(findDecl(AST, "x")), AST.getTokens(),
+  AST.getASTContext());
+  EXPECT_EQ(Node.range, Case.range("var"));
+  ASSERT_THAT(Node.children, SizeIs(1)) << "Expected one child typeloc";
+  EXPECT_EQ(Node.children.front().range, Case.range("type"));
+}
+
+TEST(DumpASTTests, Arcana) {
+  ParsedAST AST = TestTU::withCode("int 

[PATCH] D89684: [AIX] Add mvecnvol and mnovecnvol options to enable the AIX extended and default vector ABIs.

2020-10-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: Xiangling_L, cebowleratibm, sfertile.
Herald added subscribers: llvm-commits, cfe-commits, dang, dmgreen, arphaman, 
kbarton, hiraditya, nemanjai.
Herald added projects: clang, LLVM.
ZarkoCA requested review of this revision.

Added support for the options mvecnvol and mnovecnvol which are analogous to 
qvecnvol and qnovecnvol when using XL on AIX.
The extended Altivec ABI on AIX is enabled using mvecnvol in clang and vecnvol 
in llc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89684

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-default-vec-abi.ll
  llvm/test/CodeGen/PowerPC/aix-func-align.ll
  llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll
  llvm/test/CodeGen/PowerPC/aix-internal.ll
  llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
  llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
  llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
  llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
  llvm/test/CodeGen/PowerPC/aix-return55.ll
  llvm/test/CodeGen/PowerPC/aix-space.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-large.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-textdisassembly.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
  llvm/test/CodeGen/PowerPC/aix32-crsave.mir
  llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
  llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
  llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
  llvm/test/CodeGen/PowerPC/ppc64-crsave.mir

Index: llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
===
--- llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
+++ llvm/test/CodeGen/PowerPC/ppc64-crsave.mir
@@ -7,7 +7,7 @@
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
 
-# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 \
+# RUN: llc -mtriple powerpc64-unknown-aix-xcoff -x mir -mcpu=pwr4 -vecnvol \
 # RUN: -run-pass=prologepilog --verify-machineinstrs < %s | \
 # RUN: FileCheck %s --check-prefixes=CHECK,SAVEALL
 
Index: llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
===
--- llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
+++ llvm/test/CodeGen/PowerPC/ppc32-i64-to-float-conv.ll
@@ -1,4 +1,4 @@
-; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
+; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 -vecnvol \
 ; RUN: -mtriple=powerpc-ibm-aix-xcoff 2>&1 | FileCheck %s
 
 ; RUN: llc -verify-machineinstrs < %s -mcpu=pwr4 \
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr64-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc64-ibm-aix-xcoff \
 ; RUN: -code-model=large < %s | FileCheck %s --check-prefix=LARGE
 
 @a = common global i32 0
Index: llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
===
--- llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
+++ llvm/test/CodeGen/PowerPC/lower-globaladdr32-aix-asm.ll
@@ -1,7 +1,7 @@
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc-ibm-aix-xcoff \
 ; RUN: -code-model=small < %s | FileCheck %s --check-prefix=SMALL
 
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -vecnvol -mtriple powerpc-ibm-aix-xcoff \
 ; RUN: -code-model=large < %s | FileCheck %s --check-prefix=LARGE
 
 @a = common global i32 0
Index: llvm/test/CodeGen/PowerPC/aix32-crsave.mir
===
--- llvm/test/CodeGen/PowerPC/aix32-crsave.mir
+++ 

[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 299017.
ArcsinX added a comment.

auto => StringRef
add comment for `llvm::sys::path::native()` call
Result.str().str() => std::string(Result)
add back removed test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -239,8 +239,8 @@
 
   clangd::Symbol::IncludeHeaderWithReferences Header;
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());
+  Header.IncludeHeader =
+  Strings.save(URI::createFile(testPath("project/Header.h")).toString());
   Header.References = 21;
   Sym.IncludeHeaders.push_back(Header);
   Header.IncludeHeader = Strings.save("");
@@ -250,7 +250,7 @@
   Header.References = 200;
   Sym.IncludeHeaders.push_back(Header);
 
-  Marshaller ProtobufMarshaller(convert_to_slash("/"), convert_to_slash("/"));
+  Marshaller ProtobufMarshaller(testPath(""), testPath(""));
 
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
   ASSERT_TRUE(bool(Serialized));
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -50,20 +50,23 @@
 Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
llvm::StringRef LocalIndexRoot)
 : Strings(Arena) {
+  llvm::StringRef PosixSeparator =
+  llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
   if (!RemoteIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
-assert(RemoteIndexRoot ==
-   llvm::sys::path::convert_to_slash(RemoteIndexRoot));
-this->RemoteIndexRoot = RemoteIndexRoot.str();
-if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->RemoteIndexRoot += llvm::sys::path::get_separator();
+this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->RemoteIndexRoot += PosixSeparator;
   }
   if (!LocalIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(LocalIndexRoot));
-assert(LocalIndexRoot == llvm::sys::path::convert_to_slash(LocalIndexRoot));
-this->LocalIndexRoot = LocalIndexRoot.str();
-if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->LocalIndexRoot += llvm::sys::path::get_separator();
+this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
+LocalIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->LocalIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->LocalIndexRoot += PosixSeparator;
   }
   assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty());
 }
@@ -90,8 +93,12 @@
 Result.Limit = Message->limit();
   Result.RestrictForCodeCompletion = Message->restricted_for_code_completion();
   for (const auto  : Message->proximity_paths()) {
+// Create an absolute path from `Path` using the prefix `RemoteIndexRoot`.
 llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);
 llvm::sys::path::append(LocalPath, Path);
+// `Path` could be in the non-native form, thus the created absolute path
+// could be incompatible with the local system, so fix this.
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));
   }
   for (const auto  : Message->preferred_types())
@@ -209,7 +216,7 @@
 llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
 if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, ""))
   RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
-  RelativePath, llvm::sys::path::Style::posix));
+  RelativePath, llvm::sys::path::Style::windows));
   }
   for (const auto  : From.PreferredTypes)
 RPCRequest.add_preferred_types(Type);
@@ -315,12 +322,17 @@
   if (ParsedURI->scheme() != "file")
 return error("Can not use URI schemes other than file, given: '{0}'.", URI);
   llvm::SmallString<256> Result = ParsedURI->body();
+  llvm::StringRef Path(Result);
+  // Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
+  if (llvm::sys::path::is_absolute(Path.substr(1),
+   llvm::sys::path::Style::windows))
+Result = 

[PATCH] D88239: [clang-format] Fix spaces around */& in multi-variable declarations

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88239

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


[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3696-3697
+
+if (E->isValueDependent() || E->isTypeDependent())
+  continue;
+

Should this move up above the point where we're checking whether the expression 
has an array type?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3706
+
+if (!Result || !Notes.empty()) {
+  Diag(E->getBeginLoc(), diag::err_attribute_argument_n_type)

I'm surprised that the presence of notes alone would mean the attribute 
argument has an error and should be skipped. Are there circumstances under 
which `Result` is true but `Notes` is non-empty?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3693
+if (E->isValueDependent() || E->isTypeDependent() ||
+(CE && CE->hasAPValueResult()))
+  continue;

Tyker wrote:
> aaron.ballman wrote:
> > What is the rationale for bailing out when the constant expression has an 
> > `APValue` result?
> the intent was that during nested template instantiation arguement will be 
> evaluated as soon as they are neither value nor type dependent and the result 
> will be stored in the ConstantExpr. if an arguement has already been 
> evaluated in a previous instantiation we don't want to evaluate it again.
> but because of SubstExpr ConstantExpr are getting removed so it removed it.
Ah, thank you for the explanation and change.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:195
+  return;
+else
+  Args.push_back(Result.get());

No `else` after a `return`.



Comment at: clang/test/SemaCXX/attr-annotate.cpp:96
+}
+
+void test() {}

Some more tests for various constant expression situations that may be weird:
```
int n = 10;
int vla[n];

[[clang::annotate("vlas are awful", sizeof(vla[++n]))] int i = 0; // reject, 
the sizeof is not unevaluated

[[clang::annotate("_Generic selection expression should be fine", _Generic(n, 
int : 0, default : 1))]] int j = 0; // second arg should resolve to 0 fine

void designator();
[[clang::annotate("function designators?", designator)]] int k = 0; // Should 
work?
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

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


[PATCH] D89277: [clangd] Add $/dumpMemoryTree LSP extension

2020-10-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0f287464d8a: [clangd] Add $/memoryUsage LSP extension 
(authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D89277?vs=298644=298990#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89277

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/memory_tree.test

Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -0,0 +1,81 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void func() {}"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"$/memoryUsage","params":{}}
+# CHECK:"id": 1,
+# CHECK-NEXT:   "jsonrpc": "2.0",
+# CHECK-NEXT:   "result": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "clangd_server": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "dynamic_index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}},
+# CHECK-NEXT: "main_file": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "references": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "relations": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "preamble": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "index": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "tuscheduler": {
+# CHECK-NEXT: "{{.*}}main.cpp": {
+# CHECK-NEXT:   "_self": {{[0-9]+}},
+# CHECK-NEXT:   "_total": {{[0-9]+}},
+# CHECK-NEXT:   "ast": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "preamble": {
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: },
+# CHECK-NEXT: "_self": {{[0-9]+}},
+# CHECK-NEXT: "_total": {{[0-9]+}}
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+# CHECK-NEXT:   }
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
+
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -66,6 +66,7 @@
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "hoverProvider": true,
+# CHECK-NEXT:  "memoryUsageProvider": true
 # CHECK-NEXT:  "referencesProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "selectionRangeProvider": true,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -25,6 +25,7 @@
 
 

[clang] 0628bea - Revert "[PM/CC1] Add -f[no-]split-cold-code CC1 option to toggle splitting"

2020-10-19 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-19T12:31:14+02:00
New Revision: 0628bea5137047232f37c94b74bf26aa9b55f605

URL: 
https://github.com/llvm/llvm-project/commit/0628bea5137047232f37c94b74bf26aa9b55f605
DIFF: 
https://github.com/llvm/llvm-project/commit/0628bea5137047232f37c94b74bf26aa9b55f605.diff

LOG: Revert "[PM/CC1] Add -f[no-]split-cold-code CC1 option to toggle splitting"

This broke Chromium's PGO build, it seems because hot-cold-splitting got turned
on unintentionally. See comment on the code review for repro etc.

> This patch adds -f[no-]split-cold-code CC1 options to clang. This allows
> the splitting pass to be toggled on/off. The current method of passing
> `-mllvm -hot-cold-split=true` to clang isn't ideal as it may not compose
> correctly (say, with `-O0` or `-Oz`).
>
> To implement the -fsplit-cold-code option, an attribute is applied to
> functions to indicate that they may be considered for splitting. This
> removes some complexity from the old/new PM pipeline builders, and
> behaves as expected when LTO is enabled.
>
> Co-authored by: Saleem Abdulrasool 
> Differential Revision: https://reviews.llvm.org/D57265
> Reviewed By: Aditya Kumar, Vedant Kumar
> Reviewers: Teresa Johnson, Aditya Kumar, Fedor Sergeev, Philip Pfaffe, Vedant 
> Kumar

This reverts commit 273c299d5d649a0222fbde03c9a41e41913751b4.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/X86/lto-hot-cold-split.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-pgo.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Other/opt-hot-cold-split.ll
llvm/test/Other/pass-pipelines.ll
llvm/test/Transforms/CodeExtractor/extract-assume.ll
llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
llvm/test/Transforms/HotColdSplit/addr-taken.ll
llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
llvm/test/Transforms/HotColdSplit/apply-successor-penalty.ll
llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
llvm/test/Transforms/HotColdSplit/coldentrycount.ll
llvm/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll
llvm/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
llvm/test/Transforms/HotColdSplit/eh-pads.ll
llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-1.ll
llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
llvm/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll
llvm/test/Transforms/HotColdSplit/minsize.ll
llvm/test/Transforms/HotColdSplit/multiple-exits.ll
llvm/test/Transforms/HotColdSplit/noreturn.ll
llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
llvm/test/Transforms/HotColdSplit/outline-if-then-else.ll
llvm/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll
llvm/test/Transforms/HotColdSplit/outline-while-loop.ll
llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
llvm/test/Transforms/HotColdSplit/region-overlap.ll
llvm/test/Transforms/HotColdSplit/resume.ll
llvm/test/Transforms/HotColdSplit/retain-section.ll
llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
llvm/test/Transforms/HotColdSplit/split-cold-2.ll
llvm/test/Transforms/HotColdSplit/split-out-dbg-label.ll
llvm/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
llvm/test/Transforms/HotColdSplit/split-phis-in-exit-blocks.ll
llvm/test/Transforms/HotColdSplit/stale-assume-in-original-func.ll
llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
llvm/test/Transforms/HotColdSplit/swifterror.ll
llvm/test/Transforms/HotColdSplit/transfer-debug-info.ll
llvm/test/Transforms/HotColdSplit/unwind.ll
llvm/test/Transforms/HotColdSplit/update-split-loop-metadata.ll


[PATCH] D57265: [PM/CC1] Add -f[no-]split-cold-code CC1 options to toggle splitting

2020-10-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This broke Chromium's build, causing it to fail with
"Cannot pop empty stack!" from one of the backend passes.

That specific error is probably a perhaps a previously existing problem, but I 
think it was triggered by hot-cold-splitting getting enabled by this pass. This 
was a surprise to us, because we're not passing any flags to enable 
hot-cold-splitting, instead it seems to get enabled by this patch anyway in our 
PGO-enabled builds.

See https://bugs.chromium.org/p/chromium/issues/detail?id=1139384#c5 for a 
repro.

I've reverted in 0628bea5137047232f37c94b74bf26aa9b55f605 
 until 
this can be investigated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57265

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


[PATCH] D89297: [clangd] Add a TestWorkspace utility

2020-10-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks this mostly looks good.

can you move implementations from TestWorkspace.h to TestWorkspace.cpp ?




Comment at: clang-tools-extra/clangd/unittests/FileIndexTests.cpp:431
+TEST(FileIndexTest, RelationsMultiFile) {
+  TestWorkspace Workspace({{"Base.h", "class Base {};", false},
+   {"A.cpp", R"cpp(

nit: if you decide to keep the constructor can you prepend `/*IsMainFile=*/` to 
last parameters?



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:12
+//
+// The tests can exercise both index- and AST-based operations.
+//

s/index-/index/
s/AST-based/AST based/



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:32
+public:
+  struct SourceFile {
+std::string Filename;

i think it would be better to move this struct to private, and only have 
addSoruce/addMainFile helpers with comments explaining only TUs rooted at 
mainfiles will be indexed.

if you prefer to keep this struct then we should probably have comments about 
it too. especially the `IsMainFile` bit.



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:46
+  void addSource(llvm::StringRef Filename, llvm::StringRef Code) {
+addInput({std::string(Filename), std::string(Code), false});
+  }

nit: Filename.str() (same for `Code` and usages in `addMainFile` below.



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:56
+for (const auto  : Inputs) {
+  if (Input.IsMainFile) {
+TU.Code = Input.Code;

nit: prefer early exit, `if(!MainFile) continue;`



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:75
+if (!Input)
+  return llvm::None;
+TU.Code = Input->Code;

should this be a failure instead? e.g. `ADD_FAILURE() << "Accessing 
non-existing file: "  << Filename;`



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:77
+TU.Code = Input->Code;
+TU.Filename = std::string(Filename);
+return TU.build();

nit: `Input->Filename`



Comment at: clang-tools-extra/clangd/unittests/TestWorkspace.h:82
+private:
+  std::vector Inputs;
+  TestTU TU;

nit: maybe move filename out of the struct, and keep a map here instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89297

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


[clang-tools-extra] accda62 - [nfc][clang-change-namespace] Remove unnecessary isScoped EnumDecl Matcher

2020-10-19 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-10-19T12:53:51+01:00
New Revision: accda625b8e10393f5ea681845dd6602c0096680

URL: 
https://github.com/llvm/llvm-project/commit/accda625b8e10393f5ea681845dd6602c0096680
DIFF: 
https://github.com/llvm/llvm-project/commit/accda625b8e10393f5ea681845dd6602c0096680.diff

LOG: [nfc][clang-change-namespace] Remove unnecessary isScoped EnumDecl Matcher

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 61ae7c4cc703..c5ff44c4e50b 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -324,10 +324,6 @@ bool conflictInNamespace(const ASTContext , 
llvm::StringRef QualifiedSymbol,
   return false;
 }
 
-AST_MATCHER(EnumDecl, isScoped) {
-return Node.isScoped();
-}
-
 bool isTemplateParameter(TypeLoc Type) {
   while (!Type.isNull()) {
 if (Type.getTypeLocClass() == TypeLoc::SubstTemplateTypeParm)



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


[PATCH] D89559: PR47372: Fix Lambda invoker calling conventions

2020-10-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D89559#2336335 , @rjmccall wrote:

> We can't have it always match, that would require us to reject the conversion 
> to a bare function-pointer type, which is required by the standard.
>
> I'm not sure if MSVC's multiple conversions hack is conformant or not, but 
> it's at least more conformant than that.

Right, I should have remembered that.  Though, I guess that brings up the 
alternative, which is to simply produce ALL of the conversion/invoke functions 
like MSVC.  I was originally attempting to implement that (under a MSVCCompat 
flag) and decided fixing this first would be an easier way to go, but I could 
just continue with that implementation for ALL valid CCs on all platforms.

It is slightly more difficult than just this I believe, as there is some 
codegen error that I need to fix, but otherwise it should be fine.


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

https://reviews.llvm.org/D89559

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

Also, please hit "Done" on the comments you resolved so that it's easier to 
track which ones are fixed, otherwise it's hard to follow :(

The patch looks good now, almost ready to go: comments are not really clear 
right now, I suggested possible alternatives.




Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:96
   for (const auto  : Message->proximity_paths()) {
+// Create an absolute path from `Path` using the prefix `RemoteIndexRoot`.
 llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);

We normally don't escape variable names a-la Markdown.

Right now it's no very clear what it means, maybe just `Construct full path 
using local prefix.` or optionally just remove this one.



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:100
+// `Path` could be in the non-native form, thus the created absolute path
+// could be incompatible with the local system, so fix this.
+llvm::sys::path::native(LocalPath);

Maybe just `FuzzyFindRequest requires proximity paths to have platform-native 
format in order for SymbolIndex to process the query correctly.`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D89520: Don't permit array bound constant folding in OpenCL.

2020-10-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D89520#2335628 , @rsmith wrote:

> In D89520#2334477 , @Anastasia wrote:
>
>>> I couldn't find any spec justification for accepting the kinds of cases
>>> that D20090  accepts, so a reference to 
>>> where in the OpenCL specification
>>> this is permitted would be useful.
>>
>> Thanks for fixing this. I agree that the original change was not compliant 
>> with the spec. OpenCL indeed doesn't allow constant folding for array 
>> bounds. The idea of the change was to allow using expressions that are 
>> compile time constant in the array bound because this doesn't result in VLA.
>>
>> Regarding the spec reference, I think we can refer to the section 6.5.3 
>> describing variables in the `__constant` address space:
>>
>>   These variables  are  required  to  be  initialized  and  the  values  
>> used  to  initialize  these  variables  must  be  a compile time constant. 
>> Writing to such a variable results in a compile-time error.
>>
>> I.e. the `__constant` address space variables are semantically similar to 
>> `constexpr` in C++.
>
> I don't see any way to read this wording that way. That talks about how the 
> variables are initialized and says they're immutable, but I can't find 
> anything in the OpenCL specification that says they can be used in integer 
> constant expressions. The C definition of "integral constant expression" does 
> not allow the use of variables:
>
> C11 6.6/6: "An integer constant expression shall have integer type and shall 
> only have operands that are integer constants, enumeration constants, 
> character constants, sizeof expressions whose results are integer constants, 
> _Alignof expressions, and floating constants that are the immediate operands 
> of casts."
>
> ... and absent a modification to that, nor would OpenCL. That said, I'm happy 
> to take your word for it that the OpenCL specification //intends// for such 
> variable uses to be permitted in constant expressions.

Yes, I agree it is not explicit. I will attempt to improve it. However 
considering that your change doesn't add this feature but modifies existing 
implementation, I think it makes sense to go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89520

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:59
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))

kbobyrev wrote:
> nit: maybe it's time to change type of `RemoteIndexRoot` field to 
> `llvm::SmallString<256>` and use 
> `!this->RemoteIndexRoot.endswith(PosixSeparator)` instead of additional 
> variable. Not really important for this patch but I should probably do it 
> anyway if it's not changed in this patch.
But `llvm::sys::path::convert_to_slash()` returns `std::string`.  
Could you give me an advice how to copy `std::string` into 
`llvm::SmallString<256>` here?

E.g. the following code looks strange for me
```
  llvm::Optional> RemoteIndexRoot;



this->RemoteIndexRoot = 
llvm::SmallString<256>(llvm::sys::path::convert_to_slash(
RemoteIndexRoot, llvm::sys::path::Style::windows));
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-10-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 298994.
ZarkoCA added a comment.

Fixed typo in test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88676

Files:
  llvm/lib/Target/PowerPC/PPCCallingConv.td
  llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
  llvm/test/CodeGen/PowerPC/aix-csr-vector.ll

Index: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
@@ -0,0 +1,308 @@
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vecnvol -verify-machineinstrs -mcpu=pwr7 \
+; RUN: -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR32 %s
+
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM32 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR64 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM64 %s
+
+
+define dso_local void @vec_regs() {
+entry:
+  call void asm sideeffect "", "~{v13},~{v20},~{v26},~{v31}"()
+  ret void
+}
+
+; MIR32: name:vec_regs
+
+; MIR32-LABEL:   fixedStack:
+; MIR32-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:stack:
+
+; MIR32: liveins: $v20, $v26, $v31
+
+; MIR32-DAG: STXVD2X killed $v20, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR32-DAG: STXVD2X killed $v26, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR32-DAG: STXVD2X killed $v31, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR32: INLINEASM
+
+; MIR32-DAG: $v20 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; MIR32-DAG: $v26 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.1)
+; MIR32-DAG: $v31 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.0)
+; MIR32: BLR implicit $lr, implicit $rm
+
+; MIR64: name:vec_regs
+
+; MIR64-LABEL:   fixedStack:
+; MIR64-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:stack:
+
+; MIR64: liveins: $v20, $v26, $v31
+
+; MIR64-DAG: STXVD2X killed $v20, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR64-DAG: STXVD2X killed $v26, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR64-DAG: STXVD2X killed $v31, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR64: INLINEASM
+
+; MIR64-DAG: $v20 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; MIR64-DAG: $v26 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.1)
+; MIR64-DAG: $v31 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.0)
+; MIR64: BLR8 implicit $lr8, implicit $rm
+
+
+; ASM32-LABEL:   .vec_regs:
+
+; ASM32: li {{[0-9]+}}, -192
+; ASM32-DAG: stxvd2x 52, 1, {{[0-9]+}}   # 16-byte Folded Spill
+; ASM32-DAG: li 

[PATCH] D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums-over-unscoped

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

It may be a pain, but I'd also like to see an option like `RemovePrefix`.
Generally most unscoped enums constants have prefixes based on the enum name. A 
simple way around this would just be to get the longest common prefix in all 
the enums constants. There is probably some other heuristics that could be used 
like maybe stop after you reach an underscore or change of case but probably 
not essential.




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:82
+
+  Checks for unscoped enumerations.
+

Could this perhaps be a little more informative?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-scoped-enums.rst:35-36
+
+Note: Although ``enum struct`` and ``enum class`` are exactly equivalent, the
+latter is used mainly.

I'd prefer if this was user controlled, An option like `UseEnumStruct` that 
defaults to false. Just because its mainly used, doesn't mean there aren't some 
projects that prefer to use `enum struct`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85697

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


[clang] 7fe7d9b - Fix MSVC "not all control paths return a value" warning. NFCI.

2020-10-19 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-19T11:48:31+01:00
New Revision: 7fe7d9b130d4318274eb8b17f15542013e59ca32

URL: 
https://github.com/llvm/llvm-project/commit/7fe7d9b130d4318274eb8b17f15542013e59ca32
DIFF: 
https://github.com/llvm/llvm-project/commit/7fe7d9b130d4318274eb8b17f15542013e59ca32.diff

LOG: Fix MSVC "not all control paths return a value" warning. NFCI.

Added: 


Modified: 
clang/lib/CodeGen/CGExprAgg.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index bf7c1adb6810..9106b90525db 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1463,6 +1463,7 @@ static bool castPreservesZero(const CastExpr *CE) {
   case CK_UncheckedDerivedToBase:
 return false;
   }
+  llvm_unreachable("Unhandled clang::CastKind enum");
 }
 
 /// isSimpleZero - If emitting this value will obviously just cause a store of



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


[PATCH] D89651: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Should point out there is already a check for cert-oop57-cpp, added in D72488 
. Do these play nice with each other or should 
they perhaps be merged or share code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89651

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


[PATCH] D89690: [clang] update of the DragonFlyBSD's driver for the 5.8.x releases.

2020-10-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89690

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-19 Thread David Sherwood via Phabricator via cfe-commits
david-arm marked an inline comment as done.
david-arm added inline comments.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:144
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;

fhahn wrote:
> Is there a way to only accept `fixed_width/scalable` for targets that support 
> it? Not sure if we have enough information here, but we might be able to 
> reject it eg per target basis or something
Hi @fhahn, I think if possible we'd prefer not to reject scalable vectors at 
this point. Theoretically there is no reason why we can't perform scalable 
vectorisation for targets that don't have hardware support for scalable 
vectors. In this case it simply means that vscale is 1. If you want we could 
add some kind of opt-remark in the vectoriser that says something like "target 
does not support scalable vectors, vectorising for vscale=1"?


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

https://reviews.llvm.org/D89031

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


[PATCH] D77062: [analyzer] [NFC] Simplify CStringChecke::assumeZero function

2020-10-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 299018.
ASDenysPetrov retitled this revision from "[analyzer] Improve zero assumption 
in CStringChecke::assumeZero" to "[analyzer] [NFC] Simplify 
CStringChecke::assumeZero function".
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.

Updated. Requalified this patch to non-functional changes.

What do you think we should do with the thing that `ProgramState::assume()` 
doesn't support `CompoundVal` and `LazyCompoundVal` kinds of `SVal`?


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

https://reviews.llvm.org/D77062

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -196,9 +196,8 @@
   void evalBzero(CheckerContext , const CallExpr *CE) const;
 
   // Utility methods
-  std::pair
-  static assumeZero(CheckerContext ,
-ProgramStateRef state, SVal V, QualType Ty);
+  std::pair static assumeZero(
+  ProgramStateRef state, SVal V);
 
   static ProgramStateRef setCStringLength(ProgramStateRef state,
   const MemRegion *MR,
@@ -279,16 +278,18 @@
 // Individual checks and utility methods.
 //===--===//
 
-std::pair
-CStringChecker::assumeZero(CheckerContext , ProgramStateRef state, SVal V,
-   QualType Ty) {
-  Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+std::pair
+CStringChecker::assumeZero(ProgramStateRef state, SVal V) {
+  auto states = std::make_pair(state, state);
 
-  SValBuilder  = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  // FIXME: Not all SVal kinds are handled by ProgramState::assume().
+  // See SimpleConstraintManager::assumeAux().
+  if (!V.getAs() && !V.getAs())
+if (auto val = V.getAs())
+  // Returned pair shall be {null, non-null} so reorder states.
+  std::tie(states.second, states.first) = state->assume(*val);
+
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext ,
@@ -299,8 +300,7 @@
 return nullptr;
 
   ProgramStateRef stateNull, stateNonNull;
-  std::tie(stateNull, stateNonNull) =
-  assumeZero(C, State, l, Arg.Expression->getType());
+  std::tie(stateNull, stateNonNull) = assumeZero(State, l);
 
   if (stateNull && !stateNonNull) {
 if (Filter.CheckCStringNullArg) {
@@ -1071,8 +1071,7 @@
 CharVal = svalBuilder.evalCast(CharVal, Ctx.UnsignedCharTy, Ctx.IntTy);
 
 ProgramStateRef StateNullChar, StateNonNullChar;
-std::tie(StateNullChar, StateNonNullChar) =
-assumeZero(C, State, CharVal, Ctx.UnsignedCharTy);
+std::tie(StateNullChar, StateNonNullChar) = assumeZero(State, CharVal);
 
 if (StateWholeReg && !StateNotWholeReg && StateNullChar &&
 !StateNonNullChar) {
@@ -1133,11 +1132,9 @@
   // See if the size argument is zero.
   const LocationContext *LCtx = C.getLocationContext();
   SVal sizeVal = state->getSVal(Size.Expression, LCtx);
-  QualType sizeTy = Size.Expression->getType();
 
   ProgramStateRef stateZeroSize, stateNonZeroSize;
-  std::tie(stateZeroSize, stateNonZeroSize) =
-  assumeZero(C, state, sizeVal, sizeTy);
+  std::tie(stateZeroSize, stateNonZeroSize) = assumeZero(state, sizeVal);
 
   // Get the value of the Dest.
   SVal destVal = state->getSVal(Dest.Expression, LCtx);
@@ -1287,11 +1284,9 @@
 
   // See if the size argument is zero.
   SVal sizeVal = State->getSVal(Size.Expression, LCtx);
-  QualType sizeTy = Size.Expression->getType();
 
   ProgramStateRef stateZeroSize, stateNonZeroSize;
-  std::tie(stateZeroSize, stateNonZeroSize) =
-  assumeZero(C, State, sizeVal, sizeTy);
+  std::tie(stateZeroSize, stateNonZeroSize) = assumeZero(State, sizeVal);
 
   // If the size can be zero, the result will be 0 in that case, and we don't
   // have to check either of the buffers.
@@ -1367,8 +1362,7 @@
 SVal maxlenVal = state->getSVal(maxlenExpr, LCtx);
 
 ProgramStateRef stateZeroSize, stateNonZeroSize;
-std::tie(stateZeroSize, stateNonZeroSize) =
-  assumeZero(C, state, maxlenVal, maxlenExpr->getType());
+std::tie(stateZeroSize, stateNonZeroSize) = assumeZero(state, maxlenVal);
 
 // If the size can be zero, the result will be 0 in that case, and we don't
 // have to check the string itself.
@@ -1706,7 +1700,7 @@
 // as the last element accessed, so n == 0 is problematic.
 ProgramStateRef StateZeroSize, StateNonZeroSize;
 std::tie(StateZeroSize, StateNonZeroSize) =
-assumeZero(C, state, *lenValNL, sizeTy);
+assumeZero(state, *lenValNL);
 
 // If the size is 

[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-10-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 298991.
ZarkoCA marked 3 inline comments as done.
ZarkoCA retitled this revision from "[PPC][AIX] Add vector callee saved 
registers for AIX extended vector ABI and add clang and llvm option" to 
"[PPC][AIX] Add vector callee saved registers for AIX extended vector ABI".
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.

Separated the option portion of the previous diff (now found here: 
https://reviews.llvm.org/D89684).
Addressed other comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88676

Files:
  llvm/lib/Target/PowerPC/PPCCallingConv.td
  llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
  llvm/test/CodeGen/PowerPC/aix-csr-vector.ll

Index: llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-csr-vector.ll
@@ -0,0 +1,308 @@
+ RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vecnvol -verify-machineinstrs -mcpu=pwr7 \
+; RUN: -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR32 %s
+
+; RUN: llc -mtriple=powerpc-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM32 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec -stop-after=prologepilog < %s | \
+; RUN:   FileCheck --check-prefix=MIR64 %s
+
+; RUN: llc -mtriple=powerpc64-unknown-aix-xcoff -vecnvol -verify-machineinstrs \
+; RUN: -mcpu=pwr7 -mattr=+altivec < %s | \
+; RUN:   FileCheck --check-prefix=ASM64 %s
+
+
+define dso_local void @vec_regs() {
+entry:
+  call void asm sideeffect "", "~{v13},~{v20},~{v26},~{v31}"()
+  ret void
+}
+
+; MIR32: name:vec_regs
+
+; MIR32-LABEL:   fixedStack:
+; MIR32-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR32-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR32-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR32-NEXT:stack:
+
+; MIR32: liveins: $v20, $v26, $v31
+
+; MIR32-DAG: STXVD2X killed $v20, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR32-DAG: STXVD2X killed $v26, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR32-DAG: STXVD2X killed $v31, $r1, killed $r{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR32: INLINEASM
+
+; MIR32-DAG: $v20 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; MIR32-DAG: $v26 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.1)
+; MIR32-DAG: $v31 = LXVD2X $r1, killed $r{{[0-9]+}} :: (load 16 from %fixed-stack.0)
+; MIR32: BLR implicit $lr, implicit $rm
+
+; MIR64: name:vec_regs
+
+; MIR64-LABEL:   fixedStack:
+; MIR64-NEXT:- { id: 0, type: spill-slot, offset: -16, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v31', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 1, type: spill-slot, offset: -96, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v26', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:- { id: 2, type: spill-slot, offset: -192, size: 16, alignment: 16, stack-id: default,
+; MIR64-NEXT:callee-saved-register: '$v20', callee-saved-restored: true, debug-info-variable: '',
+; MIR64-NEXT:debug-info-expression: '', debug-info-location: '' }
+; MIR64-NEXT:stack:
+
+; MIR64: liveins: $v20, $v26, $v31
+
+; MIR64-DAG: STXVD2X killed $v20, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.2)
+; MIR64-DAG: STXVD2X killed $v26, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.1)
+; MIR64-DAG: STXVD2X killed $v31, $x1, killed $x{{[0-9]+}} :: (store 16 into %fixed-stack.0)
+
+; MIR64: INLINEASM
+
+; MIR64-DAG: $v20 = LXVD2X $x1, killed $x{{[0-9]+}} :: (load 16 from %fixed-stack.2)
+; 

[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:59
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))

ArcsinX wrote:
> kbobyrev wrote:
> > nit: maybe it's time to change type of `RemoteIndexRoot` field to 
> > `llvm::SmallString<256>` and use 
> > `!this->RemoteIndexRoot.endswith(PosixSeparator)` instead of additional 
> > variable. Not really important for this patch but I should probably do it 
> > anyway if it's not changed in this patch.
> But `llvm::sys::path::convert_to_slash()` returns `std::string`.  
> Could you give me an advice how to copy `std::string` into 
> `llvm::SmallString<256>` here?
> 
> E.g. the following code looks strange for me
> ```
>   llvm::Optional> RemoteIndexRoot;
> 
> 
> 
> this->RemoteIndexRoot = 
> llvm::SmallString<256>(llvm::sys::path::convert_to_slash(
> RemoteIndexRoot, llvm::sys::path::Style::windows));
> ```
> 
Hmm, yeah right nevermind, this should be OK for this patch, I'll deal with 
this later.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:242
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());

ArcsinX wrote:
> kbobyrev wrote:
> > Why remove this test?
> As far as I understand, idea of this code is to use absolute path (i.e. 
> /usr/local/user/home/project/Header.h) to be relative to "/". I do not know 
> how to make this on Windows.
> 
> Also, Marshaller ProtobufMarshaller(convert_to_slash("/"), 
> convert_to_slash("/")); leads to assertions on Windows:
> ```
> assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
> ...
> assert(llvm::sys::path::is_absolute(LocalIndexRoot));
> ```
> 
Ah, I see now, makes sense! Yeah, okay then in this case this should be 
something like `testPath("project/Header.h")` which will be absolut path (what 
we want) and also relative to `testPath("")` (test path root).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

In D89529#2337197 , @ArcsinX wrote:

> In D89529#2334517 , @kbobyrev wrote:
>
>> The solution would be to just convert to the POSIX path instead of asserting 
>> it.
>
> I have updated the patch according to this advice.
> It seems to me it looks more consistent now, thank you.

Thank you for noticing it and taking action! The patch looks good, there are 
few comments that I left but it should be good to go afterwards.




Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:53
 : Strings(Arena) {
+  auto PosixSeparator =
+  llvm::sys::path::get_separator(llvm::sys::path::Style::posix);

Please explicitly spell out `StringRef` here, otherwise visually it is 
appealing to put `const auto` there but it would be a `StringRef` which is no 
obvious.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:59
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))

nit: maybe it's time to change type of `RemoteIndexRoot` field to 
`llvm::SmallString<256>` and use 
`!this->RemoteIndexRoot.endswith(PosixSeparator)` instead of additional 
variable. Not really important for this patch but I should probably do it 
anyway if it's not changed in this patch.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:98
 llvm::sys::path::append(LocalPath, Path);
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));

Please add a comment explaining why it is needed here: these paths are not 
converted to URIs and have to be specific to the server platform in order for 
the query to work correctly.



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:332
+   Result, llvm::sys::path::Style::windows));
+  return Result.str().str();
 }

nit: `.str().str()` is a bit unfortunate, I have had some discussions about 
this in the past and I guess explicit conversion via `std::string(...)` looks a 
bit cleaner.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:242
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());

Why remove this test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:242
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());

kbobyrev wrote:
> Why remove this test?
As far as I understand, idea of this code is to use absolute path (i.e. 
/usr/local/user/home/project/Header.h) to be relative to "/". I do not know how 
to make this on Windows.

Also, Marshaller ProtobufMarshaller(convert_to_slash("/"), 
convert_to_slash("/")); leads to assertions on Windows:
```
assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
...
assert(llvm::sys::path::is_absolute(LocalIndexRoot));
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D89685: [clangd] Rename edge name for filesymbols to slabs in memorytree

2020-10-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This was causing duplicate `symbols` components on the path as both the
edge from an index to filesymbols and filesymbols to symbolslabs were named
symbols.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89685

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/test/memory_tree.test
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp


Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -672,9 +672,9 @@
   UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
 
   ASSERT_THAT(MT.child("preamble").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
   ASSERT_THAT(MT.child("main_file").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
 
   ASSERT_THAT(MT.child("preamble").child("index").total(), Gt(0U));
   ASSERT_THAT(MT.child("main_file").child("index").total(), Gt(0U));
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -927,7 +927,7 @@
   MemoryTree MT();
   Idx.profile(MT);
   ASSERT_THAT(MT.children(),
-  UnorderedElementsAre(Pair("symbols", _), Pair("index", _)));
+  UnorderedElementsAre(Pair("slabs", _), Pair("index", _)));
 }
 
 } // namespace clangd
Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- clang-tools-extra/clangd/test/memory_tree.test
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -22,7 +22,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "{{.*}}main.cpp": {
 # CHECK-NEXT:   "_self": {{[0-9]+}},
 # CHECK-NEXT:   "_total": {{[0-9]+}},
@@ -50,7 +50,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   }
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -478,11 +478,11 @@
 }
 
 void FileIndex::profile(MemoryTree ) const {
-  PreambleSymbols.profile(MT.child("preamble").child("symbols"));
+  PreambleSymbols.profile(MT.child("preamble").child("slabs"));
   MT.child("preamble")
   .child("index")
   .addUsage(PreambleIndex.estimateMemoryUsage());
-  MainFileSymbols.profile(MT.child("main_file").child("symbols"));
+  MainFileSymbols.profile(MT.child("main_file").child("slabs"));
   MT.child("main_file")
   .child("index")
   .addUsage(MainFileIndex.estimateMemoryUsage());
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -416,7 +416,7 @@
 }
 
 void BackgroundIndex::profile(MemoryTree ) const {
-  IndexedSymbols.profile(MT.child("symbols"));
+  IndexedSymbols.profile(MT.child("slabs"));
   // We don't want to mix memory used by index and symbols, so call base class.
   MT.child("index").addUsage(SwapIndex::estimateMemoryUsage());
 }


Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -672,9 +672,9 @@
   UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
 
   ASSERT_THAT(MT.child("preamble").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
   

[PATCH] D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums-over-unscoped

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D85697#2234468 , 
@janosbenjaminantal wrote:

> The known "limitations" are mostly similar to other checks:
>
> - It cannot detect unfixable cases from other translation units. Practically 
> that means if an `enum` is used in multiple source files, one of them might 
> end up not fixed. I tried to work around this, but I haven't found any 
> solution for this, moreover this cause problems for other checks also. 
> Therefore I think it shouldn't be a blocking issue.

That's what the run_clang_tidy.py script is meant to handle.

> - It doesn't take into account if an `enum` is defined in a header that is 
> filtered out. Similarly to the previous one, I tried to find a solution for 
> this, but I was unable (the `ClangTidyCheck` class can access the header 
> filter information, but it doesn't expose it for the descendant classes). I 
> also checked other checks, and they behave in the same way. Therefore I also 
> think it is shouldn't be a blocking issue.

I recently pushed an upgrade to readability-identifier-naming where it would 
check the naming style for identifiers declared in header files, maybe thats 
something this could also use, this is the commit 4888c9ce97d8 


> It is not strongly connected to this review, but in the future I am planning 
> to extend the check with:
>
> - options to exclude enums, because changing them to scoped enumerations 
> might not be suitable for every cases

Not strictly necessary, if people don't want the fix they could annotate the 
code with a `// NOLINT(*prefer-unscoped-enums)` comment.

> - options to force the doable fixes: based on my little experience it might 
> be easier to force the doable fixes and manually fix the remaining ones

Forcing the fix is usually just a case of converting implicit cast usages of 
the constants into static casts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85697

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


[PATCH] D89065: [clang] Tweaked fixit for static assert with no message

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89065

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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:621-623
+  if (auto AT = TL->getAs())
+S = AT.getModifiedLoc()
+.getSourceRange(); // should we just return false?

dgoldman wrote:
> Let me know if you think it would be better to return false here
Yes, it's better to return false, which is more conservative. As written, this 
code will prevent targeting things within the attribute. (We can't currently 
target the attribute itself due to DynTypedNode limitations, but I'd like to 
fix that)



Comment at: clang-tools-extra/clangd/Selection.cpp:607
 SourceRange S = N.getSourceRange();
 if (auto *TL = N.get()) {
   // DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to





Comment at: clang-tools-extra/clangd/Selection.cpp:619
 S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
+  // AttributeTypeLoc points to the attribute's range, NOT the modified
+  // type's range.

AttributeTypeLoc -> AttributedTypeLoc

This isn't true in general actually - attributes can be prefix or postfix (or 
other things...) and the heuristics in TypeLoc::get{Begin,End}Loc basically 
assume postfix for `Attributed`, which is right sometimes and wrong sometimes. 
(And getSourceRange() doesn't have enough information to get this right - it'd 
need the SourceManager to compare locations).

TypeLoc ranges in general seem pretty error prone. I've suggested a comment - 
we should consider just bailing out entirely here in future.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:2008
+  }},
+  // Should work even with nullability attribute.
+  {

this is the same as the above case (apart from the selection changes, which are 
tested in SelectionTests)

same for the rest of the MYObject tests.
The ones after that are good as they're testing hovering on a different type of 
entity.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:2052
+  {
+  R"cpp(
+  @class ForwardDeclared;

these tests seem good (though unrelated to the rest of the patch, you might 
want to land them separately).

The Fooey test relies on selection of a protocol in a protocol-list, you may 
want to test this directly in SelectionTests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

kpn wrote:
> sepavloff wrote:
> > Why they are wrong?
> Because the #pragma covers the entire file and sets exception handling to 
> "strict". Thus all constrained intrinsic calls should be "strict", and if 
> they are "maytrap" or "ignore" then we have a bug.
What is the reason for that? Does `#pragma float_control` work incorrectly? Why 
 in `clang/test/CodeGen/complex-math-strictfp.c` exception handling is correct?


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

https://reviews.llvm.org/D88913

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


[PATCH] D89696: [OpenMP] Fixing OpenMP/driver.c failing on 32-bit hosts

2020-10-19 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a project: clang.
jhuber6 requested review of this revision.
Herald added a subscriber: sstefan1.

The changes made in D88594  caused the test 
OpenMP/driver.c to fail on a 32-bit host becuase it was offloading to a 64-bit 
architecture by default. The offloading test was moved to a new file and a 
feature was added to the lit config to check for a 64-bit host.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89696

Files:
  clang/test/OpenMP/driver-openmp-target.c
  clang/test/OpenMP/driver.c
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -1,6 +1,7 @@
 # -*- Python -*-
 
 import os
+import sys
 import platform
 import re
 import subprocess
@@ -167,6 +168,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('can-remove-opened-file')
 
+# Check 64-bit host
+if sys.maxsize > 2**32:
+  config.available_features.add("clang-64-bits")
+
 
 def calculate_arch_features(arch_string):
 features = []
Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -27,7 +27,6 @@
 
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck 
--check-prefix=CHECK-45-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-simd 
| FileCheck --check-prefix=CHECK-45-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 
-fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck 
--check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
 // CHECK-45-VERSION: #define _OPENMP 201511
 // CHECK-45-VERSION2: #define _OPENMP 201511
 
Index: clang/test/OpenMP/driver-openmp-target.c
===
--- /dev/null
+++ clang/test/OpenMP/driver-openmp-target.c
@@ -0,0 +1,5 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: clang-64-bits
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 
-fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck 
--check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
+// CHECK-45-VERSION: #define _OPENMP 201511
+// CHECK-45-VERSION2: #define _OPENMP 201511


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -1,6 +1,7 @@
 # -*- Python -*-
 
 import os
+import sys
 import platform
 import re
 import subprocess
@@ -167,6 +168,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('can-remove-opened-file')
 
+# Check 64-bit host
+if sys.maxsize > 2**32:
+  config.available_features.add("clang-64-bits")
+
 
 def calculate_arch_features(arch_string):
 features = []
Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -27,7 +27,6 @@
 
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck --check-prefix=CHECK-45-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-simd | FileCheck --check-prefix=CHECK-45-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck --check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
 // CHECK-45-VERSION: #define _OPENMP 201511
 // CHECK-45-VERSION2: #define _OPENMP 201511
 
Index: clang/test/OpenMP/driver-openmp-target.c
===
--- /dev/null
+++ clang/test/OpenMP/driver-openmp-target.c
@@ -0,0 +1,5 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: clang-64-bits
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck --check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
+// CHECK-45-VERSION: #define _OPENMP 201511
+// CHECK-45-VERSION2: #define _OPENMP 201511
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88956: [clang-format] Fix misformatted macro definitions after D86959

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 299039.
arichardson added a comment.
Herald added a subscriber: mgorny.

Split the token annotion test into a separate file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88956

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TestLexer.h
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -0,0 +1,70 @@
+//===- unittest/Format/TokenAnnotatorTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class FormatTest : public ::testing::Test {
+protected:
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle  = getLLVMStyle()) {
+return TestLexer(Style).annotate(Code);
+  }
+};
+
+#define EXPECT_TOKEN_KIND(FormatTok, Kind) \
+  EXPECT_EQ((FormatTok)->Tok.getKind(), Kind) << *(FormatTok)
+#define EXPECT_TOKEN_TYPE(FormatTok, Type) \
+  EXPECT_EQ((FormatTok)->getType(), Type) << *(FormatTok)
+#define EXPECT_TOKEN(FormatTok, Kind, Type)\
+  do { \
+EXPECT_TOKEN_KIND(FormatTok, Kind);\
+EXPECT_TOKEN_TYPE(FormatTok, Type);\
+  } while (false);
+
+TEST_F(FormatTest, UnderstandsUsesOfStarAndAmpInMacroDefinition) {
+  // This is a regression test for mis-parsing the & after decltype as a binary
+  // operator instead of a reference (when inside a macro definition).
+  auto Tokens = annotate("auto x = [](const decltype(x) ) {};");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::kw_decltype, TT_Unknown);
+  EXPECT_TOKEN(Tokens[8], tok::l_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_PointerOrReference);
+  // Same again with * instead of &:
+  Tokens = annotate("auto x = [](const decltype(x) *ptr) {};");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
+
+  // Also check that we parse correctly within a macro definition:
+  Tokens = annotate("#define lambda [](const decltype(x) ) {}");
+  EXPECT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::kw_decltype, TT_Unknown);
+  EXPECT_TOKEN(Tokens[8], tok::l_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_PointerOrReference);
+  // Same again with * instead of &:
+  Tokens = annotate("#define lambda [](const decltype(x) *ptr) {}");
+  EXPECT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
+}
+
+} // namespace
+} // namespace format
+} // namespace clang
Index: clang/unittests/Format/TestLexer.h
===
--- clang/unittests/Format/TestLexer.h
+++ clang/unittests/Format/TestLexer.h
@@ -16,6 +16,9 @@
 #define CLANG_UNITTESTS_FORMAT_TESTLEXER_H
 
 #include "../../lib/Format/FormatTokenLexer.h"
+#include "../../lib/Format/TokenAnalyzer.h"
+#include "../../lib/Format/TokenAnnotator.h"
+#include "../../lib/Format/UnwrappedLineParser.h"
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
@@ -29,7 +32,8 @@
 typedef llvm::SmallVector TokenList;
 
 inline std::ostream <<(std::ostream , const FormatToken ) {
-  Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\")";
+  Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\" , "
+ << getTokenTypeName(Tok.getType()) << ")";
   return Stream;
 }
 inline std::ostream <<(std::ostream , const TokenList ) {
@@ -37,7 +41,7 @@
   for (size_t I = 0, E = Tokens.size(); I != E; ++I) {
 Stream << (I > 0 ? ", " : "") << *Tokens[I];
   }
-  Stream << "}";
+  Stream << "} (" << 

[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2020-10-19 Thread Francesco Stefanni via Phabricator via cfe-commits
FStefanni added a comment.

Hi,

thank you for the suggestion, but it does **not**, at least with 
`BreakConstructorInitializers: AfterColon` (which is what I use).
If initializers are "small enough" to fit the constructor line, all will finish 
on the same line.

E.g.

  MyClass::MyClass(): a(), b()
  {}

But what I like is:

  MyClass::MyClass(): 
  a(), 
  b()
  {}

Regards.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-10-19 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin marked an inline comment as done.
AlexanderLanin added a comment.

Could someone commit this as I cannot? Thanks a lot!
Alexander Lanin 

Thanks for review @aaron.ballman!


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

https://reviews.llvm.org/D74299

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


[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 299044.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Add constructors to StreamingDiagnostic.


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

https://reviews.llvm.org/D84362

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Attr.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclarationName.h
  clang/include/clang/AST/DependentDiagnostic.h
  clang/include/clang/AST/NestedNameSpecifier.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/AST/TemplateName.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/PartialDiagnostic.h
  clang/include/clang/Sema/DelayedDiagnostic.h
  clang/include/clang/Sema/Ownership.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/unittests/Basic/DiagnosticTest.cpp

Index: clang/unittests/Basic/DiagnosticTest.cpp
===
--- clang/unittests/Basic/DiagnosticTest.cpp
+++ clang/unittests/Basic/DiagnosticTest.cpp
@@ -74,7 +74,7 @@
 TEST(DiagnosticTest, diagnosticError) {
   DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions,
   new IgnoringDiagConsumer());
-  PartialDiagnostic::StorageAllocator Alloc;
+  PartialDiagnostic::DiagStorageAllocator Alloc;
   llvm::Expected> Value = DiagnosticError::create(
   SourceLocation(), PartialDiagnostic(diag::err_cannot_open_file, Alloc)
 << "file"
Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -40,8 +40,8 @@
 
 using namespace clang;
 
-const DiagnosticBuilder ::operator<<(const DiagnosticBuilder ,
-   DiagNullabilityKind nullability) {
+const StreamingDiagnostic ::operator<<(const StreamingDiagnostic ,
+ DiagNullabilityKind nullability) {
   StringRef string;
   switch (nullability.first) {
   case NullabilityKind::NonNull:
@@ -61,8 +61,8 @@
   return DB;
 }
 
-const DiagnosticBuilder ::operator<<(const DiagnosticBuilder ,
-   llvm::Error &) {
+const StreamingDiagnostic ::operator<<(const StreamingDiagnostic ,
+ llvm::Error &) {
   DB.AddString(toString(std::move(E)));
   return DB;
 }
@@ -482,13 +482,15 @@
 
   CurDiagLoc = storedDiag.getLocation();
   CurDiagID = storedDiag.getID();
-  NumDiagArgs = 0;
+  DiagStorage.NumDiagArgs = 0;
 
-  DiagRanges.clear();
-  DiagRanges.append(storedDiag.range_begin(), storedDiag.range_end());
+  DiagStorage.DiagRanges.clear();
+  DiagStorage.DiagRanges.append(storedDiag.range_begin(),
+storedDiag.range_end());
 
-  DiagFixItHints.clear();
-  DiagFixItHints.append(storedDiag.fixit_begin(), storedDiag.fixit_end());
+  DiagStorage.FixItHints.clear();
+  DiagStorage.FixItHints.append(storedDiag.fixit_begin(),
+storedDiag.fixit_end());
 
   assert(Client && "DiagnosticConsumer not set!");
   Level DiagLevel = storedDiag.getLevel();
@@ -1141,13 +1143,13 @@
   return Target.IncludeInDiagnosticCounts();
 }
 
-PartialDiagnostic::StorageAllocator::StorageAllocator() {
+PartialDiagnostic::DiagStorageAllocator::DiagStorageAllocator() {
   for (unsigned I = 0; I != NumCached; ++I)
 FreeList[I] = Cached + I;
   NumFreeListEntries = NumCached;
 }
 
-PartialDiagnostic::StorageAllocator::~StorageAllocator() {
+PartialDiagnostic::DiagStorageAllocator::~DiagStorageAllocator() {
   // Don't assert if we are in a CrashRecovery context, as this invariant may
   // be invalidated during a crash.
   assert((NumFreeListEntries == NumCached ||
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -254,8 +254,8 @@
   }
 }
 
-const DiagnosticBuilder ::operator<<(const DiagnosticBuilder ,
-   TemplateName N) {
+const StreamingDiagnostic ::operator<<(const StreamingDiagnostic ,
+ TemplateName N) {
   std::string NameStr;
   llvm::raw_string_ostream OS(NameStr);
   LangOptions LO;
@@ -268,20 +268,6 @@
   return DB << NameStr;
 }
 
-const PartialDiagnostic::operator<<(const PartialDiagnostic ,
-   TemplateName N) {
-  std::string NameStr;
-  llvm::raw_string_ostream 

[PATCH] D89407: [clang-tidy] Add scoped enum constants to identifier naming check

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor nit.




Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:410
+  if (const auto *EnumConst = dyn_cast(D)) {
+assert(isa(EnumConst->getDeclContext()) &&
+   "DeclContext of EnumConstant should be EnumDecl");

There's no need for this assertion, the use of `cast<>` below will assert if 
the type is wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89407

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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:611
+  // robust.
+  return false;
 if (!SelChecker.mayHit(S)) {

I'm not sure we actually want to *do it* at this point, as you're seeing we may 
have some unintended consequences.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-10-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:63
+
+llvm::GlobalVariable *CGOpenMPRuntimeNVPTX::allocateTransferMediumGlobal(
+CodeGenModule , llvm::ArrayType *Ty, StringRef TransferMediumName) {

Perhaps (typed into browser):
```
llvm::GlobalVariable *CGOpenMPRuntimeNVPTX::createGlobal( CodeGenModule , 
llvm::ArrayType *Ty, StringRef Name) {
  return new llvm::GlobalVariable(
  CGM.getModule(), Ty, /*isConstant=*/false,
  llvm::GlobalVariable::CommonLinkage, llvm::Constant::getNullValue(Ty),
  Name,
  /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal,
  CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared),
/*isExternallyInitialized*/ true);
}

llvm::GlobalVariable *CGOpenMPRuntimeAMDGCN::createGlobal( CodeGenModule , 
llvm::ArrayType *Ty, StringRef Name) {
  return new llvm::GlobalVariable(
  CGM.getModule(), Ty, /*isConstant=*/false,
  llvm::GlobalVariable::WeakAnyLinkage, llvm::Constant::getNullValue(Ty),
  Name,
  /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal,
  CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared),
/*isExternallyInitialized*/ false);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86097

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


[PATCH] D89702: [clang] [msvc] Automatically link against oldnames just as linking against libcmt

2020-10-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, amccarth.
Herald added a project: clang.
mstorsjo requested review of this revision.

If invoking clang-cl, both libcmt (or another lib, depending on the /M[TD](|d) 
options) and oldnames are passed as dependent libs. If compiling and linking 
via the clang driver, we used to just pass libcmt when linking; include 
oldnames consistently there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89702

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-link.c


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -2,6 +2,7 @@
 // BASIC: link.exe"
 // BASIC: "-out:a.exe"
 // BASIC: "-defaultlib:libcmt"
+// BASIC: "-defaultlib:oldnames"
 // BASIC: "-nologo"
 // BASIC-NOT: "-Brepro"
 
@@ -9,6 +10,7 @@
 // DLL: link.exe"
 // DLL: "-out:a.dll"
 // DLL: "-defaultlib:libcmt"
+// DLL: "-defaultlib:oldnames"
 // DLL: "-nologo"
 // DLL: "-dll"
 
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -333,8 +333,10 @@
 Args.MakeArgString(std::string("-out:") + Output.getFilename()));
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
-  !C.getDriver().IsCLMode())
+  !C.getDriver().IsCLMode()) {
 CmdArgs.push_back("-defaultlib:libcmt");
+CmdArgs.push_back("-defaultlib:oldnames");
+  }
 
   if (!llvm::sys::Process::GetEnv("LIB")) {
 // If the VC environment hasn't been configured (perhaps because the user


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -2,6 +2,7 @@
 // BASIC: link.exe"
 // BASIC: "-out:a.exe"
 // BASIC: "-defaultlib:libcmt"
+// BASIC: "-defaultlib:oldnames"
 // BASIC: "-nologo"
 // BASIC-NOT: "-Brepro"
 
@@ -9,6 +10,7 @@
 // DLL: link.exe"
 // DLL: "-out:a.dll"
 // DLL: "-defaultlib:libcmt"
+// DLL: "-defaultlib:oldnames"
 // DLL: "-nologo"
 // DLL: "-dll"
 
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -333,8 +333,10 @@
 Args.MakeArgString(std::string("-out:") + Output.getFilename()));
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
-  !C.getDriver().IsCLMode())
+  !C.getDriver().IsCLMode()) {
 CmdArgs.push_back("-defaultlib:libcmt");
+CmdArgs.push_back("-defaultlib:oldnames");
+  }
 
   if (!llvm::sys::Process::GetEnv("LIB")) {
 // If the VC environment hasn't been configured (perhaps because the user
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89649: Fix __has_unique_object_representations with no_unique_address

2020-10-19 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2580-2581
   if (!isStructEmpty(Base.getType())) {
 llvm::Optional Size = structHasUniqueObjectRepresentations(
 Context, Base.getType()->castAs()->getDecl());
 if (!Size)

rsmith wrote:
> We need to do this for non-empty `[[no_unique_address]]` members of class 
> type too, to handle tail padding reuse in cases such as:
> 
> ```
> struct A {
> ~A();
> int a;
> char b;
> };
> struct B {
> [[no_unique_address]] A a;
> char c[3];
> };
> static_assert(sizeof(B) == 8, "");
> static_assert(__has_unique_object_representations(B), "");
> ```
You're right, I missed the case of reusing tail padding. I'll try to update 
this review to include this soon. 

But I don't think that this exact example is incorrect now as `A` is not 
trivially copyable due to the user defined destructor. 
It should return true when the class type member is trivially copyable but 
non-standard-layout though: 

```
struct A {
private:
int a;
public:
char b;
};
struct B {
[[no_unique_address]] A a;
char c[3];
};
static_assert(sizeof(B) == 8, "");
static_assert(__has_unique_object_representations(B), "");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89649

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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345

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


[PATCH] D89696: [OpenMP] Fixing OpenMP/driver.c failing on 32-bit hosts

2020-10-19 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 299081.
jhuber6 added a comment.

Checking tests again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89696

Files:
  clang/test/OpenMP/driver-openmp-target.c
  clang/test/OpenMP/driver.c
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -1,6 +1,7 @@
 # -*- Python -*-
 
 import os
+import sys
 import platform
 import re
 import subprocess
@@ -167,6 +168,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('can-remove-opened-file')
 
+# Check 64-bit host
+if sys.maxsize > 2**32:
+  config.available_features.add("clang-64-bits")
+
 
 def calculate_arch_features(arch_string):
 features = []
Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -27,7 +27,6 @@
 
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck 
--check-prefix=CHECK-45-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-simd 
| FileCheck --check-prefix=CHECK-45-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 
-fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck 
--check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
 // CHECK-45-VERSION: #define _OPENMP 201511
 // CHECK-45-VERSION2: #define _OPENMP 201511
 
Index: clang/test/OpenMP/driver-openmp-target.c
===
--- /dev/null
+++ clang/test/OpenMP/driver-openmp-target.c
@@ -0,0 +1,5 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: clang-64-bits
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 
-fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck 
--check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
+// CHECK-45-VERSION: #define _OPENMP 201511
+// CHECK-45-VERSION2: #define _OPENMP 201511


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -1,6 +1,7 @@
 # -*- Python -*-
 
 import os
+import sys
 import platform
 import re
 import subprocess
@@ -167,6 +168,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('can-remove-opened-file')
 
+# Check 64-bit host
+if sys.maxsize > 2**32:
+  config.available_features.add("clang-64-bits")
+
 
 def calculate_arch_features(arch_string):
 features = []
Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -27,7 +27,6 @@
 
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck --check-prefix=CHECK-45-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-simd | FileCheck --check-prefix=CHECK-45-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck --check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
 // CHECK-45-VERSION: #define _OPENMP 201511
 // CHECK-45-VERSION2: #define _OPENMP 201511
 
Index: clang/test/OpenMP/driver-openmp-target.c
===
--- /dev/null
+++ clang/test/OpenMP/driver-openmp-target.c
@@ -0,0 +1,5 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: clang-64-bits
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck --check-prefix=CHECK-45-VERSION --check-prefix=CHECK-45-VERSION2 %s
+// CHECK-45-VERSION: #define _OPENMP 201511
+// CHECK-45-VERSION2: #define _OPENMP 201511
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:131
+}
+/*FunctionCallCollector Collector{[](const CallExpr *CE) {
+  if (isa(CE->getCalleeDecl()))

Remove commented-out code?



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:162
+
+  if (StrictConformingFunctions.count(II->getName()))
+return true;

You may want a FIXME here that this will eventually be wrong in C++ mode. 
Consider declarations like:
```
namespace foo {
void abort();

inline namespace bar {
void quick_exit(int);
}
}

namespace {
void signal();
}
```
If we form a FunctionDecl to any of those functions, we shouldn't count those 
as the conforming functions.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:175
+   "calling it from a signal handler may be dangerous")
+  << CalledFunction->getNameAsString();
+  diag(SignalCall->getSourceRange().getBegin(),

You can pass `CalledFunction` directly -- any `NamedDecl` gets automatically 
formatted by the diagnostics engine. You should also drop the single quotes 
around `%0` as they'll be automatically added by the diagnostics engine.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:33
+
+  for (const FunctionDecl *D : Node.redecls())
+if (D->getASTContext().getSourceManager().isInSystemHeader(

balazske wrote:
> aaron.ballman wrote:
> > balazske wrote:
> > > aaron.ballman wrote:
> > > > balazske wrote:
> > > > > aaron.ballman wrote:
> > > > > > I'm not certain I understand why we're looking through the entire 
> > > > > > redeclaration chain to see if the function is ever mentioned in a 
> > > > > > system header. I was expecting we'd look at the expansion location 
> > > > > > of the declaration and see if that's in a system header, which is 
> > > > > > already handled by the `isExpansionInSystemHeader()` matcher. 
> > > > > > Similar below.
> > > > > This function is called from ` SignalHandlerCheck::check` when any 
> > > > > function call is found. So the check for system header is needed. It 
> > > > > was unclear to me what the "expansion location" means but it seems to 
> > > > > work if using that expansion location and checking for system header, 
> > > > > instead of this loop. I will update the code.
> > > > > This function is called from  SignalHandlerCheck::check when any 
> > > > > function call is found. So the check for system header is needed. 
> > > > 
> > > > The check for the system header isn't what I was concerned by, it was 
> > > > the fact that we're walking the entire redeclaration chain to see if 
> > > > *any* declaration is in a system header that I don't understand the 
> > > > purpose of.
> > > > 
> > > > > It was unclear to me what the "expansion location" means but it seems 
> > > > > to work if using that expansion location and checking for system 
> > > > > header, instead of this loop. I will update the code.
> > > > 
> > > > The spelling location is where the user wrote the code and the 
> > > > expansion location is where the macro name is written, but thinking on 
> > > > it harder, that shouldn't matter for this situation as either location 
> > > > would be in the system header anyway.
> > > The function declaration is not often a macro name so there is no 
> > > "expansion location" or the same as the original location. My concern was 
> > > that if there is a declaration of system call function in a source file 
> > > (like `void abort(void);` in .c file) for any reason, we may find this 
> > > declaration instead of the one in the header file, if not looping over 
> > > the declaration chain.
> > > The function declaration is not often a macro name so there is no 
> > > "expansion location" or the same as the original location.
> > 
> > Agreed.
> > 
> > > My concern was that if there is a declaration of system call function in 
> > > a source file (like `void abort(void);` in .c file) for any reason, we 
> > > may find this declaration instead of the one in the header file, if not 
> > > looping over the declaration chain.
> > 
> > Typically, when a C user does something like that, it's because they're 
> > explicitly *not* including the header file at all (they're just forward 
> > declaring the function so they can use it) and so we'd get the logic wrong 
> > for them anyway because we'd never find the declaration in the system 
> > header.
> > 
> > Using the canonical declaration is more typical and would realistically 
> > fail only in circumstances like forward declaring a system header function 
> > and then later including the system header itself. That said, I suppose 
> > your approach is defensible enough. Redeclaration chains are hopefully 
> > short enough that it isn't a performance hit.
> I changed back to the original code to search the entire redeclaration 

[PATCH] D79674: [clang-tidy] Better support for Override function in RenamerClangTidy based checks

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG866dc0978449: [clang-tidy] Better support for Override 
function in RenamerClangTidy based… (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D79674?vs=298616=299043#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79674

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -266,14 +266,32 @@
   virtual ~AOverridden() = default;
   virtual void BadBaseMethod() = 0;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual method 'BadBaseMethod'
+  // CHECK-FIXES: {{^}}  virtual void v_Bad_Base_Method() = 0;
 };
 
 class COverriding : public AOverridden {
 public:
   // Overriding a badly-named base isn't a new violation.
   void BadBaseMethod() override {}
+  // CHECK-FIXES: {{^}}  void v_Bad_Base_Method() override {}
+  
+  void foo() {
+BadBaseMethod();
+// CHECK-FIXES: {{^}}v_Bad_Base_Method();
+this->BadBaseMethod();
+// CHECK-FIXES: {{^}}this->v_Bad_Base_Method();
+AOverridden::BadBaseMethod();
+// CHECK-FIXES: {{^}}AOverridden::v_Bad_Base_Method();
+COverriding::BadBaseMethod();
+// CHECK-FIXES: {{^}}COverriding::v_Bad_Base_Method();
+  }
 };
 
+void VirtualCall(AOverridden _vItem) {
+  a_vItem.BadBaseMethod();
+  // CHECK-FIXES: {{^}}  a_vItem.v_Bad_Base_Method();
+}
+
 template 
 class CRTPBase {
 public:
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -125,6 +125,9 @@
   Added an option `GetConfigPerFile` to support including files which use
   different naming styles.
 
+  Now renames overridden virtual methods if the method they override has a
+  style violation.
+
 - Removed `google-runtime-references` check because the rule it checks does
   not exist in the Google Style Guide anymore.
 
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -135,6 +135,23 @@
  this));
 }
 
+/// Returns the function that \p Method is overridding. If There are none or
+/// multiple overrides it returns nullptr. If the overridden function itself is
+/// overridding then it will recurse up to find the first decl of the function.
+static const CXXMethodDecl *getOverrideMethod(const CXXMethodDecl *Method) {
+  if (Method->size_overridden_methods() != 1)
+return nullptr;
+  while (true) {
+Method = *Method->begin_overridden_methods();
+assert(Method && "Overridden method shouldn't be null");
+unsigned NumOverrides = Method->size_overridden_methods();
+if (NumOverrides == 0)
+  return Method;
+if (NumOverrides > 1)
+  return nullptr;
+  }
+}
+
 void RenamerClangTidyCheck::addUsage(
 const RenamerClangTidyCheck::NamingCheckId , SourceRange Range,
 SourceManager *SourceMgr) {
@@ -172,6 +189,10 @@
 
 void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
  SourceManager *SourceMgr) {
+  if (const auto *Method = dyn_cast(Decl)) {
+if (const CXXMethodDecl *Overridden = getOverrideMethod(Method))
+  Decl = Overridden;
+  }
   Decl = cast(Decl->getCanonicalDecl());
   return addUsage(RenamerClangTidyCheck::NamingCheckId(Decl->getLocation(),
Decl->getNameAsString()),
@@ -412,6 +433,14 @@
   }
 }
 
+// Fix overridden methods
+if (const auto *Method = Result.Nodes.getNodeAs("decl")) {
+  if (const CXXMethodDecl *Overridden = getOverrideMethod(Method)) {
+addUsage(Overridden, Method->getLocation());
+return; // Don't try to add the actual decl as a Failure.
+  }
+}
+
 // Ignore ClassTemplateSpecializationDecl which are creating duplicate
 // replacements with CXXRecordDecl.
 if (isa(Decl))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 866dc09 - [clang-tidy] Better support for Override function in RenamerClangTidy based checks

2020-10-19 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-10-19T15:21:06+01:00
New Revision: 866dc09784495bd2c204945144cd31cd8e653f0e

URL: 
https://github.com/llvm/llvm-project/commit/866dc09784495bd2c204945144cd31cd8e653f0e
DIFF: 
https://github.com/llvm/llvm-project/commit/866dc09784495bd2c204945144cd31cd8e653f0e.diff

LOG: [clang-tidy] Better support for Override function in RenamerClangTidy 
based checks

Methods that override virtual methods will now get renamed if the initial 
virtual method has a name violation.
Addresses https://bugs.llvm.org/show_bug.cgi?id=34879

Reviewed By: alexfh

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 2d67ca4a1618..bb8caf1d84e2 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -135,6 +135,23 @@ void RenamerClangTidyCheck::registerPPCallbacks(
  this));
 }
 
+/// Returns the function that \p Method is overridding. If There are none or
+/// multiple overrides it returns nullptr. If the overridden function itself is
+/// overridding then it will recurse up to find the first decl of the function.
+static const CXXMethodDecl *getOverrideMethod(const CXXMethodDecl *Method) {
+  if (Method->size_overridden_methods() != 1)
+return nullptr;
+  while (true) {
+Method = *Method->begin_overridden_methods();
+assert(Method && "Overridden method shouldn't be null");
+unsigned NumOverrides = Method->size_overridden_methods();
+if (NumOverrides == 0)
+  return Method;
+if (NumOverrides > 1)
+  return nullptr;
+  }
+}
+
 void RenamerClangTidyCheck::addUsage(
 const RenamerClangTidyCheck::NamingCheckId , SourceRange Range,
 SourceManager *SourceMgr) {
@@ -172,6 +189,10 @@ void RenamerClangTidyCheck::addUsage(
 
 void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
  SourceManager *SourceMgr) {
+  if (const auto *Method = dyn_cast(Decl)) {
+if (const CXXMethodDecl *Overridden = getOverrideMethod(Method))
+  Decl = Overridden;
+  }
   Decl = cast(Decl->getCanonicalDecl());
   return addUsage(RenamerClangTidyCheck::NamingCheckId(Decl->getLocation(),

Decl->getNameAsString()),
@@ -412,6 +433,14 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult ) {
   }
 }
 
+// Fix overridden methods
+if (const auto *Method = Result.Nodes.getNodeAs("decl")) {
+  if (const CXXMethodDecl *Overridden = getOverrideMethod(Method)) {
+addUsage(Overridden, Method->getLocation());
+return; // Don't try to add the actual decl as a Failure.
+  }
+}
+
 // Ignore ClassTemplateSpecializationDecl which are creating duplicate
 // replacements with CXXRecordDecl.
 if (isa(Decl))

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6e6d46df4933..595b1c465d5f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -125,6 +125,9 @@ Changes in existing checks
   Added an option `GetConfigPerFile` to support including files which use
   
diff erent naming styles.
 
+  Now renames overridden virtual methods if the method they override has a
+  style violation.
+
 - Removed `google-runtime-references` check because the rule it checks does
   not exist in the Google Style Guide anymore.
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
index fed362bbecde..de53dddc0f92 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -266,14 +266,32 @@ class AOverridden {
   virtual ~AOverridden() = default;
   virtual void BadBaseMethod() = 0;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for virtual 
method 'BadBaseMethod'
+  // CHECK-FIXES: {{^}}  virtual void v_Bad_Base_Method() = 0;
 };
 
 class COverriding : public AOverridden {
 public:
   // Overriding a badly-named base isn't a new violation.
   void BadBaseMethod() override {}
+  // CHECK-FIXES: {{^}}  void v_Bad_Base_Method() override {}
+  
+  void foo() {
+BadBaseMethod();
+// CHECK-FIXES: {{^}}v_Bad_Base_Method();
+this->BadBaseMethod();
+// CHECK-FIXES: {{^}}

[PATCH] D89708: Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added a reviewer: bkramer.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
arichardson requested review of this revision.

This allows removing the clangAST dependency from libclangToolingCore and
therefore allows clang-format to be built without depending on clangAST.
Before 1166 files had to be compiled for clang-format, now only 796.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89708

Files:
  clang/include/clang/Tooling/Core/Lookup.h
  clang/include/clang/Tooling/Refactoring/Lookup.h
  clang/lib/Format/FormatInternal.h
  clang/lib/Tooling/Core/CMakeLists.txt
  clang/lib/Tooling/Core/Lookup.cpp
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Lookup.cpp
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Tooling/LookupTest.cpp

Index: clang/unittests/Tooling/LookupTest.cpp
===
--- clang/unittests/Tooling/LookupTest.cpp
+++ clang/unittests/Tooling/LookupTest.cpp
@@ -6,8 +6,8 @@
 //
 //===--===//
 
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "TestVisitor.h"
-#include "clang/Tooling/Core/Lookup.h"
 using namespace clang;
 
 namespace {
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -21,7 +21,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "clang/Tooling/Refactoring/Rename/SymbolName.h"
 #include "clang/Tooling/Refactoring/Rename/USRFinder.h"
Index: clang/lib/Tooling/Refactoring/Lookup.cpp
===
--- clang/lib/Tooling/Refactoring/Lookup.cpp
+++ clang/lib/Tooling/Refactoring/Lookup.cpp
@@ -10,7 +10,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -6,6 +6,7 @@
   AtomicChange.cpp
   Extract/Extract.cpp
   Extract/SourceExtraction.cpp
+  Lookup.cpp
   RefactoringActions.cpp
   Rename/RenamingAction.cpp
   Rename/SymbolOccurrences.cpp
Index: clang/lib/Tooling/Core/CMakeLists.txt
===
--- clang/lib/Tooling/Core/CMakeLists.txt
+++ clang/lib/Tooling/Core/CMakeLists.txt
@@ -2,11 +2,9 @@
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  Lookup.cpp
   Replacement.cpp
 
   LINK_LIBS
-  clangAST
   clangBasic
   clangLex
   clangRewrite
Index: clang/lib/Format/FormatInternal.h
===
--- clang/lib/Format/FormatInternal.h
+++ clang/lib/Format/FormatInternal.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_LIB_FORMAT_FORMATINTERNAL_H
 
 #include "BreakableToken.h"
-#include "clang/Tooling/Core/Lookup.h"
 #include 
 
 namespace clang {
Index: clang/include/clang/Tooling/Refactoring/Lookup.h
===
--- clang/include/clang/Tooling/Refactoring/Lookup.h
+++ clang/include/clang/Tooling/Refactoring/Lookup.h
@@ -10,8 +10,8 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLING_CORE_LOOKUP_H
-#define LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
+#define LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -47,4 +47,4 @@
 } // end namespace tooling
 } // end namespace clang
 
-#endif // LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#endif // LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89699: [ExtVector] Make .even/.odd/.lo/.hi return vectors for single elements.

2020-10-19 Thread Steve Canon via Phabricator via cfe-commits
scanon added a comment.

I'm fairly certain that this will cause some breaks internally at Apple, but 
I'm also pretty sure that it's a step in the right direction, and we should 
just sign up to fix any issues it causes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89699

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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

With that change, somehow this extract test is now failing:

- TEST 'Clangd Unit Tests :: ./ClangdTests/ExtractFunctionTest.FunctionTest' 
FAILED 

Note: Google Test filter = ExtractFunctionTest.FunctionTest
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from ExtractFunctionTest
[ RUN  ] ExtractFunctionTest.FunctionTest
/Users/davg/dev/github/llvm-project/clang-tools-extra/clangd/unittests/TweakTests.cpp:595:
 Failure
Value of: apply("int [[x = 0]];")
Expected: is equal to "unavailable"

  Actual: "void extracted() {\nint x = 0;\n}\nvoid 
wrapperFunction(){\nextracted();\n}"

[  FAILED  ] ExtractFunctionTest.FunctionTest (615 ms)
[--] 1 test from ExtractFunctionTest (615 ms total)

[--] Global test environment tear-down
[==] 1 test from 1 test case ran. (615 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] ExtractFunctionTest.FunctionTest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D89332: [clang-tidy] performance-unnecessary-copy-initialization: Always allow std::function to be copied.

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D89332#2338319 , @njames93 wrote:

> Come to think of it, this is a pretty illogical way to solve this problem, 
> just append `::std::function` to the AllowedTypes vector in 
> `registerMatchers` and be do with it. Will require dropping the const 
> Qualifier on AllowedTypes, but aside from that it is a much simpler fix.
> The has(Any)Name matcher has logic for skipping inline namespaces.

This also seems like a reasonable alternative, to me.




Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:39
+// is unnecessary.
+AST_MATCHER(NamedDecl, isStdFunction) {
+  // First use the fast getName() method to avoid unnecessary calls to the

njames93 wrote:
> It's better to use `node.isInStdNamespace()` instead of checking the 
> qualified name as its designed for that very purpose. Is should probably take 
> a `CXXRecordDecl` instead of a `NamedDecl` aswell.
There's no need for this matcher -- `hasName("::std::function")` is the correct 
way to test for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89332

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


[clang-tools-extra] b91a236 - Revert "Extend tests of run-clang-tidy"

2020-10-19 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-10-19T10:37:22-04:00
New Revision: b91a236ee1c3e9fa068df058164385732cb46bba

URL: 
https://github.com/llvm/llvm-project/commit/b91a236ee1c3e9fa068df058164385732cb46bba
DIFF: 
https://github.com/llvm/llvm-project/commit/b91a236ee1c3e9fa068df058164385732cb46bba.diff

LOG: Revert "Extend tests of run-clang-tidy"

This reverts commit 627c01bee0deb353b3e3e90c1b8d0b6d73464466.

Some failing build bots:
http://lab.llvm.org:8011/#/builders/109/builds/690
http://lab.llvm.org:8011/#/builders/14/builds/476

Added: 
clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp

Modified: 


Removed: 

clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp

clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp



diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
new file mode 100644
index ..0d0e41e022ae
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
@@ -0,0 +1,18 @@
+// RUN: %run_clang_tidy --help
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: echo "CheckOptions:" >> %t/.clang-tidy
+// RUN: echo "  - key: modernize-use-auto.MinTypeNameLength" >> 
%t/.clang-tidy
+// RUN: echo "value:   '0'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "test.cpp"
+
+int main()
+{
+  int* x = new int();
+  delete x;
+}

diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
deleted file mode 100644
index 3976ccf8860d..
--- 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// under test:
-// - .clang-tidy read from file & treat warnings as errors
-// - return code of run-clang-tidy on those errors
-
-// First make sure clang-tidy is executable and can print help without 
crashing:
-// RUN: %run_clang_tidy --help
-
-// use %t as directory instead of file:
-// RUN: rm -rf %t
-// RUN: mkdir %t
-
-// add this file to %t, add compile_commands for it and .clang-tidy config:
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
-// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
-// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
-// RUN: echo "CheckOptions:" >> %t/.clang-tidy
-// RUN: echo "  - key: modernize-use-auto.MinTypeNameLength" >> 
%t/.clang-tidy
-// RUN: echo "value:   '0'" >> %t/.clang-tidy
-// RUN: cp "%s" "%t/test.cpp"
-
-// execute and check:
-// RUN: cd "%t"
-// RUN: not %run_clang_tidy "test.cpp" > %t/msg.txt 2>&1
-// RUN: FileCheck -input-file=%t/msg.txt -check-prefix=CHECK-MESSAGES %s \
-// RUN:   -implicit-check-not='{{warning|error|note}}:'
-
-int main()
-{
-  int* x = new int();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: error: {{.+}} 
[modernize-use-auto,-warnings-as-errors]
-
-  delete x;
-}

diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
deleted file mode 100644
index f2c97269391e..
--- 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// under test:
-// - parsing and using compile_commands
-// - export fixes to yaml file
-
-// use %t as directory instead of file,
-// because "compile_commands.json" must have exactly that name:
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: echo '[{"directory":"%/S","command":"clang++ -c %s","file":"%s"}]' \
-// RUN:  > %t/compile_commands.json
-
-// execute and check:
-// RUN: cd "%t"
-// RUN: %run_clang_tidy 
-checks='-*,bugprone-sizeof-container,modernize-use-auto' \
-// RUN: -p="%/t" -export-fixes=%t/fixes.yaml > %t/msg.txt 2>&1
-// RUN: FileCheck -input-file=%t/msg.txt -check-prefix=CHECK-MESSAGES %s \
-// RUN:   -implicit-check-not='{{warning|error|note}}:'
-// RUN: FileCheck -input-file=%t/fixes.yaml -check-prefix=CHECK-YAML %s
-
-#include 
-int main()
-{
-  std::vector vec;
-  std::vector::iterator iter = vec.begin();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
-  // CHECK-YAML: modernize-use-auto
-  
-  return sizeof(vec);
-  // CHECK-MESSAGES: 

[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D74299#2338823 , @aaron.ballman 
wrote:

> In D74299#2338772 , @AlexanderLanin 
> wrote:
>
>> Could someone commit this as I cannot? Thanks a lot!
>> Alexander Lanin 
>>
>> Thanks for review @aaron.ballman!
>
> Happy to do so! I've commit on your behalf in 
> 627c01bee0deb353b3e3e90c1b8d0b6d73464466 
> 

Unfortunately, I had to revert in b91a236ee1c3e9fa068df058164385732cb46bba 
 because 
of failing build bots. Would you mind taking a look?


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

https://reviews.llvm.org/D74299

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


[PATCH] D86936: [clang] Limit the maximum level of fold-expr expansion.

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: rsmith.
sammccall added a comment.

In D86936#2338664 , @erichkeane wrote:

> Why did we select the 'bracket-depth' for this?  The documentation on that 
> doesn't seem to be anything close to what this should be based on:

Based on a discussion with @rsmith - the formal definition of pack expansion is 
that it expands to nested parenthesized expressions expressions.

>   Sets the limit for nested parentheses, brackets, and braces to N in blocks, 
> declarators, expressions, and struct or union declarations.
>
> The 256 default limit is REALLY small for a fold expression, particularly 
> since the instantiation depth limit is 1024 by default.  I think this patch 
> needs to be changed to use the InstantiationDepth instead.  @rjmccall, 
> thoughts?

One motivation here is to limit exposure of tools to stack overflows. A modest 
increase in the stack size of DynTypedNode triggered stack overflows in various 
traversals on real code.
While it's possible in principle to write traversals that use only data 
recursion (and I've also fixed the ones in clang itself that I can find), in 
practice a lot of code and tools rely on recursive traversals, so trivially 
creating arbitrarily deep ASTs without any limit is certain to break things 
with unclear responsibility. (Whereas this change places responsibility with 
boost numerics).

FWIW, somewhere between 1024 and 2048 was the critical depth on the systems we 
looked at, so 1024 seems... plausible, but large.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86936

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


[PATCH] D89709: [clang-format] Drop clangFrontend dependency for FormatTests

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: klimek, MyDeveloperDay.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
arichardson requested review of this revision.

This allows building the clang-format unit tests in only 657 ninja steps
rather than 1257 which allows for much faster incremental builds after a
git pull.

Depends on D89708 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89709

Files:
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/CleanupTest.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp
  clang/unittests/Format/FormatTestObjC.cpp
  clang/unittests/Format/FormatTestRawStrings.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
  clang/unittests/Tooling/RewriterTestContext.h

Index: clang/unittests/Tooling/RewriterTestContext.h
===
--- clang/unittests/Tooling/RewriterTestContext.h
+++ clang/unittests/Tooling/RewriterTestContext.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -26,6 +25,22 @@
 
 namespace clang {
 
+/// \brief A very simple diagnostic consumer that prints to stderr and keeps
+/// track of the number of diagnostics.
+///
+/// This avoids a dependency on clangFrontend for FormatTests.
+struct RewriterDiagnosticConsumer : public DiagnosticConsumer {
+  RewriterDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+++NumDiagnosticsSeen;
+SmallString<100> OutStr;
+Info.FormatDiagnostic(OutStr);
+llvm::errs() << OutStr;
+  }
+  unsigned NumDiagnosticsSeen;
+};
+
 /// \brief A class that sets up a ready to use Rewriter.
 ///
 /// Useful in unit tests that need a Rewriter. Creates all dependencies
@@ -37,7 +52,6 @@
: DiagOpts(new DiagnosticOptions()),
  Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs),
  &*DiagOpts),
- DiagnosticPrinter(llvm::outs(), &*DiagOpts),
  InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
  OverlayFileSystem(
  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())),
@@ -113,7 +127,7 @@
 
   IntrusiveRefCntPtr DiagOpts;
   DiagnosticsEngine Diagnostics;
-  TextDiagnosticPrinter DiagnosticPrinter;
+  RewriterDiagnosticConsumer DiagnosticPrinter;
   IntrusiveRefCntPtr InMemoryFileSystem;
   IntrusiveRefCntPtr OverlayFileSystem;
   FileManager Files;
Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Format/Format.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
Index: clang/unittests/Format/FormatTestRawStrings.cpp
===
--- clang/unittests/Format/FormatTestRawStrings.cpp
+++ clang/unittests/Format/FormatTestRawStrings.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12,7 +12,6 @@
 #include "FormatTestUtils.h"
 #include "TestLexer.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 

[PATCH] D86936: [clang] Limit the maximum level of fold-expr expansion.

2020-10-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D86936#2338664 , @erichkeane wrote:

> Why did we select the 'bracket-depth' for this?  The documentation on that 
> doesn't seem to be anything close to what this should be based on:
>
>   Sets the limit for nested parentheses, brackets, and braces to N in blocks, 
> declarators, expressions, and struct or union declarations.
>
> The 256 default limit is REALLY small for a fold expression, particularly 
> since the instantiation depth limit is 1024 by default.  I think this patch 
> needs to be changed to use the InstantiationDepth instead.  @rjmccall, 
> thoughts?

Even that limit (1024) seems like it is perhaps a little conservative. 
Apparently, this comes up in Boost Numerics, where they use a pack of size 1089 
at one point that they use a '+' fold expression that this causes us to no 
longer be able to build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86936

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


[PATCH] D89649: Fix __has_unique_object_representations with no_unique_address

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2608
+continue;
+  else if (!Context.hasUniqueObjectRepresentations(Field->getType()))
+return llvm::None;

You can drop the `else` after this sorta-return if you'd like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89649

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


[PATCH] D89705: [clang] Use SourceLocation as key in std::map, NFCI

2020-10-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added a reviewer: dexonsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
miyuki requested review of this revision.

SourceLocation implements `operator<`, so `SourceLocation`-s can be used
as keys in `std::map` directly, there is no need to extract the internal
representation.

Since the `operator<` simply compares the internal representations of
its operands, this patch does not introduce any functional changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89705

Files:
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp

Index: clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -44,13 +44,13 @@
   bool ShowLineMarkers; ///< Show #line markers.
   bool UseLineDirectives; ///< Use of line directives or line markers.
   /// Tracks where inclusions that change the file are found.
-  std::map FileIncludes;
+  std::map FileIncludes;
   /// Tracks where inclusions that import modules are found.
-  std::map ModuleIncludes;
+  std::map ModuleIncludes;
   /// Tracks where inclusions that enter modules (in a module build) are found.
-  std::map ModuleEntryIncludes;
+  std::map ModuleEntryIncludes;
   /// Tracks where #if and #elif directives get evaluated and whether to true.
-  std::map IfConditions;
+  std::map IfConditions;
   /// Used transitively for building up the FileIncludes mapping over the
   /// various \c PPCallbacks callbacks.
   SourceLocation LastInclusionLocation;
@@ -65,7 +65,7 @@
   void detectMainFileEOL();
   void handleModuleBegin(Token ) {
 assert(Tok.getKind() == tok::annot_module_begin);
-ModuleEntryIncludes.insert({Tok.getLocation().getRawEncoding(),
+ModuleEntryIncludes.insert({Tok.getLocation(),
 (Module *)Tok.getAnnotationValue()});
   }
 private:
@@ -164,7 +164,7 @@
 return;
   FileID Id = FullSourceLoc(Loc, SM).getFileID();
   auto P = FileIncludes.insert(
-  std::make_pair(LastInclusionLocation.getRawEncoding(),
+  std::make_pair(LastInclusionLocation,
  IncludedFile(Id, NewFileType, PP.GetCurDirLookup(;
   (void)P;
   assert(P.second && "Unexpected revisitation of the same include directive");
@@ -199,8 +199,7 @@
const Module *Imported,
SrcMgr::CharacteristicKind FileType){
   if (Imported) {
-auto P = ModuleIncludes.insert(
-std::make_pair(HashLoc.getRawEncoding(), Imported));
+auto P = ModuleIncludes.insert(std::make_pair(HashLoc, Imported));
 (void)P;
 assert(P.second && "Unexpected revisitation of the same include directive");
   } else
@@ -209,8 +208,7 @@
 
 void InclusionRewriter::If(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue) {
-  auto P = IfConditions.insert(
-  std::make_pair(Loc.getRawEncoding(), ConditionValue == CVK_True));
+  auto P = IfConditions.insert(std::make_pair(Loc, ConditionValue == CVK_True));
   (void)P;
   assert(P.second && "Unexpected revisitation of the same if directive");
 }
@@ -218,8 +216,7 @@
 void InclusionRewriter::Elif(SourceLocation Loc, SourceRange ConditionRange,
  ConditionValueKind ConditionValue,
  SourceLocation IfLoc) {
-  auto P = IfConditions.insert(
-  std::make_pair(Loc.getRawEncoding(), ConditionValue == CVK_True));
+  auto P = IfConditions.insert(std::make_pair(Loc, ConditionValue == CVK_True));
   (void)P;
   assert(P.second && "Unexpected revisitation of the same elif directive");
 }
@@ -228,7 +225,7 @@
 /// an inclusion directive) in the map of inclusion information, FileChanges.
 const InclusionRewriter::IncludedFile *
 InclusionRewriter::FindIncludeAtLocation(SourceLocation Loc) const {
-  const auto I = FileIncludes.find(Loc.getRawEncoding());
+  const auto I = FileIncludes.find(Loc);
   if (I != FileIncludes.end())
 return >second;
   return nullptr;
@@ -238,7 +235,7 @@
 /// an inclusion directive) in the map of module inclusion information.
 const Module *
 InclusionRewriter::FindModuleAtLocation(SourceLocation Loc) const {
-  const auto I = ModuleIncludes.find(Loc.getRawEncoding());
+  const auto I = ModuleIncludes.find(Loc);
   if (I != ModuleIncludes.end())
 return I->second;
   return nullptr;
@@ -248,14 +245,14 @@
 /// an inclusion directive) in the map of module entry information.
 const Module *
 InclusionRewriter::FindEnteredModule(SourceLocation Loc) const {
-  const auto I = ModuleEntryIncludes.find(Loc.getRawEncoding());
+  const auto I = ModuleEntryIncludes.find(Loc);
   if (I != ModuleEntryIncludes.end())
 return I->second;
   return nullptr;
 }
 
 bool 

[PATCH] D89699: [ExtVector] Make .even/.odd/.lo/.hi return vectors for single elements.

2020-10-19 Thread Steve Canon via Phabricator via cfe-commits
scanon added a comment.

I guess the counterargument here would be that `.x` does not produce an 
extvector(1), and there is at least a plausible argument that `.x` should be 
the same as `.lo` for a two-element vector. I'm not really convinced by this, 
but it's not totally outrageous.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89699

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


[PATCH] D86936: [clang] Limit the maximum level of fold-expr expansion.

2020-10-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: rjmccall, erichkeane.
erichkeane added a comment.

Why did we select the 'bracket-depth' for this?  The documentation on that 
doesn't seem to be anything close to what this should be based on:

  Sets the limit for nested parentheses, brackets, and braces to N in blocks, 
declarators, expressions, and struct or union declarations.

The 256 default limit is REALLY small for a fold expression, particularly since 
the instantiation depth limit is 1024 by default.  I think this patch needs to 
be changed to use the InstantiationDepth instead.  @rjmccall, thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86936

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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 299038.
dgoldman marked 5 inline comments as done.
dgoldman added a comment.

Update with changes requested

- Looking into extract failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -356,6 +356,22 @@
 )cpp",
   "DeclRefExpr"},
 
+  // Objective-C nullability attributes.
+  {
+  R"cpp(
+@interface I{}
+@property(nullable) [[^I]] *x;
+@end
+  )cpp",
+  "ObjCInterfaceTypeLoc"},
+  {
+  R"cpp(
+@interface I{}
+- (void)doSomething:(nonnull [[i^d]])argument;
+@end
+  )cpp",
+  "TypedefTypeLoc"},
+
   // Objective-C OpaqueValueExpr/PseudoObjectExpr has weird ASTs.
   // Need to traverse the contents of the OpaqueValueExpr to the POE,
   // and ensure we traverse only the syntactic form of the PseudoObjectExpr.
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1991,6 +1991,34 @@
 HI.NamespaceScope = "ObjC::"; // FIXME: fix it
 HI.Definition = "char data";
   }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface Interface
+  @property(retain) [[MYOb^ject]] *x;
+  @end
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "MYObject";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "";
+HI.Definition = "@interface MYObject\n@end";
+  }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface Interface
+  - (void)doWith:([[MYOb^ject]] *)object;
+  @end
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "MYObject";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "";
+HI.Definition = "@interface MYObject\n@end";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -820,6 +820,24 @@
   EXPECT_DECLS("ObjCPropertyRefExpr",
"@property(atomic, retain, readwrite) I *x");
 
+  Code = R"cpp(
+@interface MYObject
+@end
+@interface Interface
+@property(retain) [[MYObject]] *x;
+@end
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject");
+
+  Code = R"cpp(
+@interface MYObject2
+@end
+@interface Interface
+@property(retain, nonnull) [[MYObject2]] *x;
+@end
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject2");
+
   Code = R"cpp(
 @protocol Foo
 @end
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -604,19 +604,11 @@
   // don't intersect the selection may be recursively skipped.
   bool canSafelySkipNode(const DynTypedNode ) {
 SourceRange S = N.getSourceRange();
-if (auto *TL = N.get()) {
-  // DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to
-  // failing
-  // to descend into the child expression.
-  // decltype(2+2);
-  // ~ <-- correct range
-  //   <-- range reported by getSourceRange()
-  //   <-- range with this hack(i.e, missing closing paren)
-  // FIXME: Alter DecltypeTypeLoc to contain parentheses locations and get
-  // rid of this patch.
-  if (auto DT = TL->getAs())
-S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
-}
+if (auto *TL = N.get())
+  // TypeLoc::getBeginLoc()/getEndLoc() are pretty fragile heuristics.
+  // We might consider only pruning critical TypeLoc nodes, to be more
+  // robust.
+  return false;
 if (!SelChecker.mayHit(S)) {
   dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
   dlog("{1}skipped range = {0}", S.printToString(SM), indent(1));

[PATCH] D89699: [ExtVector] Make .even/.odd/.lo/.hi return vectors for single elements.

2020-10-19 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, jfb, scanon, rsmith, hfinkel.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.
fhahn requested review of this revision.

Currently the 'swizzle' accessors .even/.odd/.lo/.hi return a scalar
instead of a vector with a single element when the result has a single
element. The current behavior of Clang can lead to unexpected failures
when working with ext_vector_types  in templates that paramterize the
number of elements.

In the example below, currently `c.even` returns a scalar, which is then
converted to `char` and broadcasted to both elements of `b`.

  typedef uint16_t __attribute__ ((__ext_vector_type__(2))) ushort2;
  typedef uint8_t  __attribute__ ((__ext_vector_type__(2))) uchar2;
  
  ushort2 c = 0x0102;
  uchar2 b = (uchar2) c.even;

This patch changes the behavior so that swizzels return single element
vectors in that case. This should make the behavior consistent with
vectors with more than 1 element.

Just from looking at the implementation, it seems like the current
behavior is mostly a side-effect of the implementation, where the
handling of element accesses and swizzels is combined.

This patch changes existing behavior and may break some code that relies
on the current behavior. Unfortunately I could not find any
specification for the ext_vector_type so it is hard to tell if the
existing behavior is actually intentional or not. At least there are no
unit tests for the current behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89699

Files:
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/CodeGen/ext-vector.c
  clang/test/Sema/ext_vector_components.c


Index: clang/test/Sema/ext_vector_components.c
===
--- clang/test/Sema/ext_vector_components.c
+++ clang/test/Sema/ext_vector_components.c
@@ -72,3 +72,12 @@
 float2 hi(float3 x) { return x.hi; }
 float2 ev(float3 x) { return x.even; }
 float2 od(float3 x) { return x.odd; }
+
+float lo2(float2 x) { return x.lo; }
+// expected-error@-1 {{returning 'float __attribute__((ext_vector_type(1)))' 
(vector of 1 'float' value) from a function with incompatible result type 
'float'}}
+float hi2(float2 x) { return x.hi; }
+// expected-error@-1 {{returning 'float __attribute__((ext_vector_type(1)))' 
(vector of 1 'float' value) from a function with incompatible result type 
'float'}}
+float ev2(float2 x) { return x.even; }
+// expected-error@-1 {{returning 'float __attribute__((ext_vector_type(1)))' 
(vector of 1 'float' value) from a function with incompatible result type 
'float'}}
+float od2(float2 x) { return x.odd; }
+// expected-error@-1 {{returning 'float __attribute__((ext_vector_type(1)))' 
(vector of 1 'float' value) from a function with incompatible result type 
'float'}}
Index: clang/test/CodeGen/ext-vector.c
===
--- clang/test/CodeGen/ext-vector.c
+++ clang/test/CodeGen/ext-vector.c
@@ -2,6 +2,7 @@
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__((ext_vector_type(1))) float float1;
 typedef __attribute__(( ext_vector_type(4) )) int int4;
 typedef __attribute__(( ext_vector_type(4) )) unsigned int uint4;
 
@@ -17,6 +18,7 @@
   return V.wzyx+V;
 }
 
+float1 vec1;
 float2 vec2, vec2_2;
 float4 vec4, vec4_2;
 float f;
@@ -338,3 +340,44 @@
   // CHECK: shufflevector {{.*}} 
   vec4_2 = vec16.sabcd;
 }
+
+void test_swizzle() {
+  // CHECK:  [[L0_VEC4:%.+]] = load <4 x float>, <4 x float>* @vec4, align 
16
+  // CHECK-NEXT: [[ODD:%.+]]  = shufflevector <4 x float> [[L0_VEC4]], <4 x 
float> undef, <2 x i32> 
+  // CHECK-NEXT:  [[L1_VEC4:%.+]] = load <4 x float>, <4 x float>* @vec4, 
align 16
+  // CHECK-NEXT:  [[EVEN:%.+]] = shufflevector <4 x float> [[L1_VEC4]], <4 x 
float> undef, <2 x i32> 
+  // CHECK-NEXT:  [[FADD:%.+]] = fadd <2 x float> [[ODD]], [[EVEN]]
+  // CHECK-NEXT:  store <2 x float> [[FADD]], <2 x float>* @vec2, align 8
+  vec2 = vec4.odd + vec4.even;
+
+  // CHECK-NEXT: [[L2_VEC4:%.+]] = load <4 x float>, <4 x float>* @vec4, align 
16
+  // CHECK-NEXT: [[LO:%.+]] = shufflevector <4 x float> [[L2_VEC4]], <4 x 
float> undef, <2 x i32> 
+  // CHECK-NEXT: [[L3_VEC4:%.+]] = load <4 x float>, <4 x float>* @vec4, align 
16
+  // CHECK-NEXT: [[HI:%.+]]  = shufflevector <4 x float> [[L3_VEC4]], <4 x 
float> undef, <2 x i32> 
+  // CHECK-NEXT: [[FSUB:%.+]] = fsub <2 x float> [[LO]], [[HI]]
+  // CHECK-NEXT: store <2 x float> [[FSUB]], <2 x float>* @vec2, align 8
+  vec2 = vec4.lo - vec4.hi;
+
+  // CHECK-NEXT: [[L4_VEC4:%.+]]  = load <4 x float>, <4 x float>* @vec4, 
align 16
+  // CHECK-NEXT: [[ODD2:%.+]]  = shufflevector <4 x float> [[L4_VEC4]], <4 x 
float> undef, <2 x i32> 
+  // CHECK-NEXT: [[L5_VEC4_2:%.+]] = load <4 x float>, <4 x float>* @vec4_2, 
align 16
+  // CHECK-NEXT: [[ODD3:%.+]] = shufflevector <2 

[PATCH] D89212: PR47663: Warn if an entity becomes weak after its first use.

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6435-6436
+Attr *WeakA = nullptr;
+for (Attr *A : VD->getAttrs()) {
+  if (!isa(A))
+continue;

rsmith wrote:
> aaron.ballman wrote:
> > Ah, it's too bad that `Decl::specific_attrs()` doesn't accept a pack of 
> > attributes...
> I took a brief look at fixing that, but it's not a completely natural 
> extension because we would want to use a different `value_type` for the 
> iterator if there's more than one kind under consideration. Probably not 
> worth it for only one user.
Agreed, thank you for looking into it!



Comment at: clang/lib/Sema/SemaDecl.cpp:18288
 
-  if (PrevDecl) {
-PrevDecl->addAttr(WeakAttr::CreateImplicit(Context, PragmaLoc, 
AttributeCommonInfo::AS_Pragma));
+  if (NamedDecl *PrevDecl =
+  LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName)) {

rsmith wrote:
> aaron.ballman wrote:
> > Same request for `const` here as above.
> Can't make this `const`; this function modifies the declaration by adding an 
> attribute :) But I can make `VD` below const.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89212

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


[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D74299

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


[clang-tools-extra] 4074914 - [clangd] Rename edge name for filesymbols to slabs in memorytree

2020-10-19 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-10-19T16:09:46+02:00
New Revision: 40749141030b8172b8490ebbdcd0d3440cbe041b

URL: 
https://github.com/llvm/llvm-project/commit/40749141030b8172b8490ebbdcd0d3440cbe041b
DIFF: 
https://github.com/llvm/llvm-project/commit/40749141030b8172b8490ebbdcd0d3440cbe041b.diff

LOG: [clangd] Rename edge name for filesymbols to slabs in memorytree

This was causing duplicate `symbols` components on the path as both the
edge from an index to filesymbols and filesymbols to symbolslabs were named
symbols.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/test/memory_tree.test
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Background.cpp 
b/clang-tools-extra/clangd/index/Background.cpp
index 4779cb8d4c23..1649bffea2ed 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -416,7 +416,7 @@ BackgroundIndex::loadProject(std::vector 
MainFiles) {
 }
 
 void BackgroundIndex::profile(MemoryTree ) const {
-  IndexedSymbols.profile(MT.child("symbols"));
+  IndexedSymbols.profile(MT.child("slabs"));
   // We don't want to mix memory used by index and symbols, so call base class.
   MT.child("index").addUsage(SwapIndex::estimateMemoryUsage());
 }

diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index 587c7eb78170..9a376df8dfec 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -478,11 +478,11 @@ void FileIndex::updateMain(PathRef Path, ParsedAST ) {
 }
 
 void FileIndex::profile(MemoryTree ) const {
-  PreambleSymbols.profile(MT.child("preamble").child("symbols"));
+  PreambleSymbols.profile(MT.child("preamble").child("slabs"));
   MT.child("preamble")
   .child("index")
   .addUsage(PreambleIndex.estimateMemoryUsage());
-  MainFileSymbols.profile(MT.child("main_file").child("symbols"));
+  MainFileSymbols.profile(MT.child("main_file").child("slabs"));
   MT.child("main_file")
   .child("index")
   .addUsage(MainFileIndex.estimateMemoryUsage());

diff  --git a/clang-tools-extra/clangd/test/memory_tree.test 
b/clang-tools-extra/clangd/test/memory_tree.test
index 41efdfb49e7a..c0a6aaf266ab 100644
--- a/clang-tools-extra/clangd/test/memory_tree.test
+++ b/clang-tools-extra/clangd/test/memory_tree.test
@@ -22,7 +22,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "{{.*}}main.cpp": {
 # CHECK-NEXT:   "_self": {{[0-9]+}},
 # CHECK-NEXT:   "_total": {{[0-9]+}},
@@ -50,7 +50,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   }

diff  --git a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp 
b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
index 4f089519530a..cc0ca6f54a7f 100644
--- a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -927,7 +927,7 @@ TEST(BackgroundIndex, Profile) {
   MemoryTree MT();
   Idx.profile(MT);
   ASSERT_THAT(MT.children(),
-  UnorderedElementsAre(Pair("symbols", _), Pair("index", _)));
+  UnorderedElementsAre(Pair("slabs", _), Pair("index", _)));
 }
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp 
b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
index 2b20b7e7fef0..4abe0bf5e5dc 100644
--- a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -672,9 +672,9 @@ TEST(FileIndexTest, Profile) {
   UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
 
   ASSERT_THAT(MT.child("preamble").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
   ASSERT_THAT(MT.child("main_file").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
 
   ASSERT_THAT(MT.child("preamble").child("index").total(), Gt(0U));
   ASSERT_THAT(MT.child("main_file").child("index").total(), Gt(0U));


   

[PATCH] D89685: [clangd] Rename edge name for filesymbols to slabs in memorytree

2020-10-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40749141030b: [clangd] Rename edge name for filesymbols to 
slabs in memorytree (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89685

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/test/memory_tree.test
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp


Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -672,9 +672,9 @@
   UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
 
   ASSERT_THAT(MT.child("preamble").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
   ASSERT_THAT(MT.child("main_file").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
 
   ASSERT_THAT(MT.child("preamble").child("index").total(), Gt(0U));
   ASSERT_THAT(MT.child("main_file").child("index").total(), Gt(0U));
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -927,7 +927,7 @@
   MemoryTree MT();
   Idx.profile(MT);
   ASSERT_THAT(MT.children(),
-  UnorderedElementsAre(Pair("symbols", _), Pair("index", _)));
+  UnorderedElementsAre(Pair("slabs", _), Pair("index", _)));
 }
 
 } // namespace clangd
Index: clang-tools-extra/clangd/test/memory_tree.test
===
--- clang-tools-extra/clangd/test/memory_tree.test
+++ clang-tools-extra/clangd/test/memory_tree.test
@@ -22,7 +22,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "{{.*}}main.cpp": {
 # CHECK-NEXT:   "_self": {{[0-9]+}},
 # CHECK-NEXT:   "_total": {{[0-9]+}},
@@ -50,7 +50,7 @@
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   },
-# CHECK-NEXT:   "symbols": {
+# CHECK-NEXT:   "slabs": {
 # CHECK-NEXT: "_self": {{[0-9]+}},
 # CHECK-NEXT: "_total": {{[0-9]+}}
 # CHECK-NEXT:   }
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -478,11 +478,11 @@
 }
 
 void FileIndex::profile(MemoryTree ) const {
-  PreambleSymbols.profile(MT.child("preamble").child("symbols"));
+  PreambleSymbols.profile(MT.child("preamble").child("slabs"));
   MT.child("preamble")
   .child("index")
   .addUsage(PreambleIndex.estimateMemoryUsage());
-  MainFileSymbols.profile(MT.child("main_file").child("symbols"));
+  MainFileSymbols.profile(MT.child("main_file").child("slabs"));
   MT.child("main_file")
   .child("index")
   .addUsage(MainFileIndex.estimateMemoryUsage());
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -416,7 +416,7 @@
 }
 
 void BackgroundIndex::profile(MemoryTree ) const {
-  IndexedSymbols.profile(MT.child("symbols"));
+  IndexedSymbols.profile(MT.child("slabs"));
   // We don't want to mix memory used by index and symbols, so call base class.
   MT.child("index").addUsage(SwapIndex::estimateMemoryUsage());
 }


Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -672,9 +672,9 @@
   UnorderedElementsAre(Pair("preamble", _), Pair("main_file", _)));
 
   ASSERT_THAT(MT.child("preamble").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", _)));
   ASSERT_THAT(MT.child("main_file").children(),
-  UnorderedElementsAre(Pair("index", _), Pair("symbols", _)));
+  UnorderedElementsAre(Pair("index", _), Pair("slabs", 

[PATCH] D89696: [OpenMP] Fixing OpenMP/driver.c failing on 32-bit hosts

2020-10-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89696

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


[clang-tools-extra] 86ef379 - [clang-tidy] Add scoped enum constants to identifier naming check

2020-10-19 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-10-19T15:57:47+01:00
New Revision: 86ef379800162e5d6bb0d478c5bfb4b56498a272

URL: 
https://github.com/llvm/llvm-project/commit/86ef379800162e5d6bb0d478c5bfb4b56498a272
DIFF: 
https://github.com/llvm/llvm-project/commit/86ef379800162e5d6bb0d478c5bfb4b56498a272.diff

LOG: [clang-tidy] Add scoped enum constants to identifier naming check

Added option `ScopedEnumConstant(Prefix|Case|Suffix)` to 
readability-identitied-naming.
This controls the style for constants in scoped enums, declared as enum 
(class|struct).
If this option is unspecified the EnumConstant style will be used instead.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index c2a32474b2a8..f0444049f5ac 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -55,6 +55,7 @@ namespace readability {
 m(Namespace) \
 m(InlineNamespace) \
 m(EnumConstant) \
+m(ScopedEnumConstant) \
 m(ConstexprVariable) \
 m(ConstantMember) \
 m(PrivateMember) \
@@ -405,7 +406,11 @@ static StyleKind findStyleKind(
   if (isa(D) && NamingStyles[SK_Enum])
 return SK_Enum;
 
-  if (isa(D)) {
+  if (const auto *EnumConst = dyn_cast(D)) {
+if (cast(EnumConst->getDeclContext())->isScoped() &&
+NamingStyles[SK_ScopedEnumConstant])
+  return SK_ScopedEnumConstant;
+
 if (NamingStyles[SK_EnumConstant])
   return SK_EnumConstant;
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 595b1c465d5f..9a182d534615 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -127,6 +127,9 @@ Changes in existing checks
 
   Now renames overridden virtual methods if the method they override has a
   style violation.
+  
+  Added support for specifying the style of scoped ``enum`` constants. If 
+  unspecified, will fall back to the style for regular ``enum`` constants.
 
 - Removed `google-runtime-references` check because the rule it checks does
   not exist in the Google Style Guide anymore.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
index 9eec3c03f7d7..036103e7e80e 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -76,6 +76,7 @@ The following options are describe below:
  - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, 
:option:`ProtectedMethodSuffix`
  - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, 
:option:`PublicMemberSuffix`
  - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, 
:option:`PublicMethodSuffix`
+ - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, 
:option:`ScopedEnumConstantSuffix`
  - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, 
:option:`StaticConstantSuffix`
  - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, 
:option:`StaticVariableSuffix`
  - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix`
@@ -1595,6 +1596,41 @@ After:
   int pre_member_method_post();
 }
 
+.. option:: ScopedEnumConstantCase
+
+When defined, the check will ensure scoped enum constant names conform to 
+the selected casing.
+
+.. option:: ScopedEnumConstantPrefix
+
+When defined, the check will ensure scoped enum constant names will add the
+prefixed with the given value (regardless of casing).
+
+.. option:: ScopedEnumConstantSuffix
+
+When defined, the check will ensure scoped enum constant names will add the
+suffix with the given value (regardless of casing).
+
+For example using values of:
+
+   - ScopedEnumConstantCase of ``lower_case``
+   - ScopedEnumConstantPrefix of ``pre_``
+   - ScopedEnumConstantSuffix of ``_post``
+
+Identifies and/or transforms enumeration constant names as follows:
+
+Before:
+
+.. code-block:: c++
+
+enum class FOO { One, Two, Three };
+
+After:
+
+.. code-block:: c++
+
+enum class FOO { pre_One_post, pre_Two_post, pre_Three_post };
+
 .. option:: StaticConstantCase
 
 When defined, the check will ensure static constant names conform to the

diff  --git 

[PATCH] D89407: [clang-tidy] Add scoped enum constants to identifier naming check

2020-10-19 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86ef37980016: [clang-tidy] Add scoped enum constants to 
identifier naming check (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D89407?vs=298349=299058#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89407

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -18,6 +18,7 @@
 // RUN: {key: readability-identifier-naming.ConstexprVariableCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.EnumCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.EnumPrefix, value: 'E'}, \
+// RUN: {key: readability-identifier-naming.ScopedEnumConstantCase, value: CamelCase}, \
 // RUN: {key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack}, \
 // RUN: {key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE}, \
@@ -160,6 +161,18 @@
 // CHECK-FIXES: {{^}}THIS_CONST_VALUE = 1,{{$}}
 };
 
+enum class EMyEnumeration {
+myConstant = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'myConstant'
+// CHECK-FIXES: {{^}}MyConstant = 1,{{$}}
+your_CONST = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'your_CONST'
+// CHECK-FIXES: {{^}}YourConst = 1,{{$}}
+THIS_ConstValue = 1,
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for scoped enum constant 'THIS_ConstValue'
+// CHECK-FIXES: {{^}}ThisConstValue = 1,{{$}}
+};
+
 constexpr int ConstExpr_variable = MyConstant;
 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for constexpr variable 'ConstExpr_variable'
 // CHECK-FIXES: {{^}}constexpr int const_expr_variable = MY_CONSTANT;{{$}}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -76,6 +76,7 @@
  - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix`
  - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix`
  - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix`
+ - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix`
  - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix`
  - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix`
  - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix`
@@ -1595,6 +1596,41 @@
   int pre_member_method_post();
 }
 
+.. option:: ScopedEnumConstantCase
+
+When defined, the check will ensure scoped enum constant names conform to 
+the selected casing.
+
+.. option:: ScopedEnumConstantPrefix
+
+When defined, the check will ensure scoped enum constant names will add the
+prefixed with the given value (regardless of casing).
+
+.. option:: ScopedEnumConstantSuffix
+
+When defined, the check will ensure scoped enum constant names will add the
+suffix with the given value (regardless of casing).
+
+For example using values of:
+
+   - ScopedEnumConstantCase of ``lower_case``
+   - ScopedEnumConstantPrefix of ``pre_``
+   - ScopedEnumConstantSuffix of ``_post``
+
+Identifies and/or transforms enumeration constant names as follows:
+
+Before:
+
+.. code-block:: c++
+
+enum class FOO { One, Two, Three };
+
+After:
+
+.. code-block:: c++
+
+enum class FOO { pre_One_post, pre_Two_post, pre_Three_post };
+
 .. option:: StaticConstantCase
 
 When defined, the check will ensure static constant names conform to the
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -127,6 +127,9 @@
 
   Now renames overridden virtual methods if the method they override has a
   style violation.
+  
+  Added support for specifying the style of scoped ``enum`` constants. If 
+ 

[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D72218#2334787 , @ffrankies wrote:

> Addressed comments by @aaron.ballman regarding the diagnostic warning.
>
> I tried to add a test case for when the filename is `kernel.cl`, 
> `verilog.cl`, or `vhdl.cl`, but that did not work because the test suite 
> appends `.tmp.cpp` to the end of the test files, and `kernel.cl.tmp.cpp` is 
> not a restricted filename. If you know of a way to include this test case in 
> the test suite, please let me know.

Oh, that's an interesting fact I hadn't considered before. I don't know of a 
better way to do that.

> In the meantime, I tested this functionality manually, and found a minor bug 
> that has since been fixed.

Great!

> The bug was: if `kernel.cl` does not have any include directives, then the 
> warning would not show up. Fixed this by rearranging the code to check the 
> main file name before checking the include directives.

That makes sense to me.

The check LGTM aside from some minor nits. If you need me to commit on your 
behalf once you've made the changes, just let me know. Thanks!




Comment at: 
clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp:60-63
+SourceLocation HashLoc, const Token , StringRef FileName,
+bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
+StringRef SearchPath, StringRef RelativePath, const Module *Imported,
+SrcMgr::CharacteristicKind FileType) {

It looks like you can leave a bunch of identifiers off the parameters to 
shorten the declaration and avoid unused parameter diagnostics in some 
compilers.



Comment at: 
clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp:73-74
+  StringRef FileName = llvm::sys::path::filename(Entry->getName());
+  if (FileName.equals_lower("kernel.cl") ||
+  FileName.equals_lower("verilog.cl") || FileName.equals_lower("vhdl.cl"))
+Check.diag(SM.getLocForStartOfFile(SM.getMainFileID()),

Rather than duplicate the checking logic here and below, I'd like a small 
helper function to check whether the name is problematic that gets called from 
both places.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/altera-kernel-name-restriction.rst:7
+Finds kernel files and include directives whose filename is `kernel.cl`,
+`Verilog.cl`, or `VHDL.cl`.
+

We should explicitly document that the check is case insensitive.


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

https://reviews.llvm.org/D72218

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

In D89529#2338794 , @kbobyrev wrote:

> Thank you for the patch! Ready to land it now.

Thank you for review!

> Please update the patch message before commiting though:
>
>> Without this patch 7 marshalling tests fails on Windows.

7 => 6

>> This patch contains the following changes:
>> Allow paths with Windows slashes.
>
> This is not correct anymore, right?

We allow paths with Windows slashes now (convert to the POSIX style instead of 
assertion). I have updated description about this.

>> Add support for URI with Windows path.
>> Change the value of the second parameter of several 
>> llvm::sys::path::convert_to_slash() calls: We should use windows instead of 
>> posix to ensure UNIX slashes in the path.
>> Remove part of RemoteMarshallingTest::IncludeHeaderURI test which could not 
>> be ported on Windows.
>
> This should not be the case anymor.

I have changed: "Remove" => "Port to Windows"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[PATCH] D69840: [Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

Yes, I am still interested in working on this. For now, I've split out some 
changes that don't require any modifications in `SourceLocation` into 
https://reviews.llvm.org/D89705.

> A general comment is that there are a couple of functional changes in this 
> patch, where hash values are changing and data structures are being changed, 
> but they're buried in the noise of the refactoring that's going on at the 
> same time. I suggest splitting this up at least into two

Will do.


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

https://reviews.llvm.org/D69840

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


[PATCH] D89684: [AIX] Add mvecnvol and mnovecnvol options to enable the AIX extended and default vector ABIs.

2020-10-19 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2868
 
+Only supported On AIX. Specify usage of volatile and nonvolatile vector 
registers, the extended vector ABI on AIX. Defaults to '-mnovecnvol' when 
Altivec is enabled.
+

s/On/on;




Comment at: clang/lib/CodeGen/BackendUtil.cpp:532
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
+  Options.AIXExtendedAltivecABI = CodeGenOpts.AIXExtendedAltivecABI;
   Options.ValueTrackingVariableLocations =

The ABI specifies `When the option to use nonvolatile vector registers is 
enalbed. the compilation environment must also predefine __EXTABI__`. I didn't 
see this. Should we also cover this in this patch?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4571
   }
 
+  if (Arg *A =

On clang, when we do: 
`clang -target powerpc-ibm-aix-xcoff -maltivec -S -emit-llvm test_faltivec.c`,  
clang driver passes `-target-cpu pwr4` as default arch to frontend without 
issuing any error.

However, with XL, we have: 
`"-qaltivec" is not compatible with "-qarch=pwr4". "-qnoaltivec" is being set.` 
 The same error will be issued if `pwr5` is used as well. 

So I suppose for AIX in clang, when user use `-maltivec` without specifying 
arch level, we can do:
1)  by default pass `-target-cpu pwr6` to frontend 
or  2) issue error for "-qarch=pwr4"+ enable altivec
or 3) issue error for `-qacrh = pwr4` + diable altivec like XL does?

Also we should emit error when user use `-maltivec` with -mcpu=pwr5.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4579
+
+bool haveMaltivec = false;
+

I would suggest `s/haveMaltivec/HasAltivec` to be consistent with other places 
where if altivec enabled is tested.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4581
+
+for (const Arg *A : Args) {
+  auto optID = A->getOption().getID();

Any reason why we cannot use `Args.getLastArg` here for `OPT_maltivec` as well?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4591
+
+if (A->getOption().matches(options::OPT_mnovecnvol) && haveMaltivec)
+  D.Diag(diag::err_aix_default_altivec_abi);

Since we are defaulting to default altivec ABI, so I think the logic here 
should be if (HasAltivec && !Args.getLastArg(options::OPT_mvecnvol)), then we 
emit `D.Diag(diag::err_aix_default_altivec_abi)` error?



Comment at: clang/test/CodeGen/altivec.c:53
 }
+
+// AIX-ERROR:  error: The default Altivec ABI on AIX is not yet supported, use 
'-mvecnvol' for the extended Altivec ABI

Could we also add a testcase to test `-mvecnvol/-mnovecnvol` are AIX only 
options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:611
+  // robust.
+  return false;
 if (!SelChecker.mayHit(S)) {

sammccall wrote:
> I'm not sure we actually want to *do it* at this point, as you're seeing we 
> may have some unintended consequences.
Ah, I think I found the cause: claimRange will claim tokens for the TypeLoc 
even if the TypeLoc is unselected. So the VarDecl later on appears to be 
completely selected since the `int` token has been claimed and `claimRange` 
doesn't check the status of the children.

Before:



> Built preamble of size 206192 for file /clangd-test/TestTU.cpp version null
> Computing selection for 
>  push: VarDecl 
>   hit selection: 
>   push: NestedNameSpecifierLoc 
>   pop: NestedNameSpecifierLoc  selected: 3
>   skip: BuiltinTypeLoc 
>skipped range = 
>   push: IntegerLiteral 
>hit selection: 
>   pop: IntegerLiteral  selected: 2
>   hit selection: 
>  pop: VarDecl  selected: 1
> Built selection tree
>  TranslationUnitDecl 
>   .VarDecl int x = 0
> *IntegerLiteral 0




After:


> Built preamble of size 206192 for file /clangd-test/TestTU.cpp version null
> Computing selection for 
>  push: VarDecl
>   hit selection: 
>   push: NestedNameSpecifierLoc
>   pop: NestedNameSpecifierLoc  selected: 3
>   push: BuiltinTypeLoc
>   pop: BuiltinTypeLoc  selected: 0
>   push: IntegerLiteral
>hit selection: 
>   pop: IntegerLiteral  selected: 2
>   hit selection: 
>  pop: VarDecl  selected: 2
> Built selection tree
>  TranslationUnitDecl
>   *VarDecl int x = 0
> *IntegerLiteral 0

Like you said probably worth fixing in a follow up, and I should revert to my 
previous code?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I tend to be very skeptical of the value of checks that basically throw out 
entire usable chunks of the base language because the check is effectively 
impossible to apply to an existing code base. Have you run the check over large 
C++ code bases to see just how often the diagnostic triggers and whether there 
are ways we might want to reduce false-positives that the C++ Core Guidelines 
haven't considered as part of their enforcement strategy?

Btw, one fear I have with this check is that the automated fixits are somewhat 
risky -- unscoped vs scoped enumerations has ABI implications and changing from 
one to the other may break the ABI.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:22
+const LangOptions ) const {
+  return LangOpts.CPlusPlus11;
+}

FWIW, Clang accepts scoped enumerations as a conforming language extension in 
older language modes. Should this check be enabled for any C++ mode?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:26
+void PreferScopedEnumsCheck::registerMatchers(MatchFinder *Finder) {
+  const auto UnscopedEnumDecl = []() { return enumDecl(unless(isScoped())); };
+

Drop top-level `const` qualifiers on things that are not pointers or references 
(it's not a pattern we typically use in the project). This applies elsewhere in 
the patch as well.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:28
+
+  Finder->addMatcher(UnscopedEnumDecl().bind("enumDecl"), this);
+

This should be checking whether the enumeration comes from a system header or 
not -- we should definitely not warn about enumerations the user cannot change.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:91
+  llvm::SmallString<128> Buffer;
+  const StringRef ClassInsertion{"class "};
+

This feels a bit like it's a user option given that `enum struct` is also used. 
I think using `class` is a sensible default, though.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:94-95
+  for (const auto  : UnscopedEnumInfos) {
+const auto *UnscopedEnumDecl = EnumDeclAndInfo.first;
+const auto  = EnumDeclAndInfo.second;
+

Please do not use `auto` when the type is not spelled out in the initialization 
(or is blindingly obvious from context, like iterators, or is unutterable, like 
lambdas).



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:124
+
+  for (const auto *const EnumUsage : UnscopedEnumInfo.Usages)
+DiagUsageWarning(EnumUsage, UnscopedEnumDecl);

I would drop the top-level `const` pointer qualification (elsewhere as well). 
The object being pointed at is fine, I'm only suggesting removing the 
qualification for the pointer itself.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:134
+
+  for (const auto *const ForwardDecl : UnscopedEnumInfo.ForwardDecls)
+DiagDeclWarning(ForwardDecl);

`llvm::for_each()`? This may actually shorten many of the loops in this 
function.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:167
+  } else if (const auto *Definition = UnscopedEnumDecl->getDefinition()) {
+auto  = UnscopedEnumInfos[Definition];
+

Please don't use `auto` here.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.cpp:194
+return UnscopedEnumDecl->getTypeForDecl()->getCanonicalTypeInternal() !=
+   Qualifier->getAsType()->getCanonicalTypeInternal();
+  }();

Why are you using the internal interfaces here?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.h:33
+
+  void onEndOfTranslationUnit() override;
+

Does this need to be `public`?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferScopedEnumsCheck.h:38-42
+std::vector Usages{};
+std::vector ForwardDecls{};
+std::vector UsagesPreventFix{};
+std::vector ForwardDeclsPreventFix{};
+std::vector ImplicitCasts{};

Please remove the unnecessary empty initializers.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-scoped-enums.rst:3
+
+cppcoreguidelines-prefer-scoped-enums
+===

Underlining looks to be the wrong length.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-scoped-enums.rst:35-36
+
+Note: Although ``enum struct`` and ``enum class`` are 

[PATCH] D89684: [AIX] Add mvecnvol and mnovecnvol options to enable the AIX extended and default vector ABIs.

2020-10-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

There's frontend changes anyway, so there should be changes for the predefined 
macros?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

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


[PATCH] D89490: Introduce __attribute__((darwin_abi))

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1481
+def DarwinABI : DeclOrTypeAttr {
+  let Spellings = [GCC<"darwin_abi">];
+//  let Subjects = [Function, ObjCMethod];

I suspect this should be using the `Clang` spelling as I don't believe GCC 
supports this attribute.



Comment at: clang/include/clang/Basic/AttrDocs.td:2258
+  let Content = [{
+On Linux ARM64 targets, this attribute changes the calling convention of
+a function to match the default convention used on Apple ARM64. This

Adding more details about what that ABI actually is, or linking to a place 
where the user can learn more on their own, would be appreciated.



Comment at: clang/include/clang/Basic/Specifiers.h:269
 
+  // clang-format off
   /// CallingConv - Specifies the calling convention that a function uses.

My personal opinion is that these formatting markers are noise. However, 
there's a fair number of enumerations this could cover and disabling the format 
behavior may be reasonable.

I think I'd rather see the formatting comments removed from this patch. They 
can be added in a different commit but perhaps the file can be restructured so 
that we don't feel the need to sprinkle so many comments around.



Comment at: clang/lib/AST/Type.cpp:3115
 
+// clang-format off
 StringRef FunctionType::getNameForCallConv(CallingConv CC) {

I'd remove these as well.



Comment at: clang/lib/CodeGen/CGCall.cpp:46
 
+// clang-format off
 unsigned CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {

These too.



Comment at: clang/lib/CodeGen/CGCall.cpp:238
+  if (D->hasAttr())
+return IsDarwin ? CC_C : CC_AArch64Darwin;
+

Can you help me understand this change a bit better? If the declaration uses 
the Darwin ABI and the platform is Darwin, you want to use the cdecl convention?



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:70
+// Returns true if AArch64 Darwin ABI is explicitly used.
+const bool IsCtorOrDtor = (isa(GD.getDecl()) ||
+   (isa(GD.getDecl()) &&

We don't typically go with top-level `const` on non-pointer/reference types, so 
I'd drop the `const`.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:78-79
+cast(GD.getDecl())->getType()->getAs();
+const auto FCC = FTy->getCallConv();
+return FCC == CallingConv::CC_AArch64Darwin;
+  }

`return FTy->getCallConv() == CallingConv::CC_Aarch64Darwin;`

(Removes a questionable use of `auto` and a top-level `const` at the same time.)



Comment at: clang/lib/CodeGen/TargetInfo.cpp:5449
   bool isDarwinPCS() const { return Kind == DarwinPCS; }
+  bool isDarwinPCS(const unsigned CConv) const {
+return isDarwinPCS() || CConv == llvm::CallingConv::AArch64Darwin;

Drop the top-level `const` in the parameter.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4640
+  case ParsedAttr::AT_DarwinABI:
+CC = Context.getTargetInfo().getTriple().isOSDarwin() ? CC_C
+  : CC_AArch64Darwin;

Similar confusion on my part here -- if the OS is Darwin, we want to default to 
cdecl?



Comment at: llvm/lib/IR/AsmWriter.cpp:379
+Out << "aarch64_darwincc";
+break;
   case CallingConv::SPIR_FUNC: Out << "spir_func"; break;

mstorsjo wrote:
> aguinet wrote:
> > mstorsjo wrote:
> > > The new code here has a different indentation than the rest; the same in 
> > > a couple other places throughout the patch.
> > As clang-format changed that formatting for me, should I reformat the whole 
> > switch-case to be "clang-format compatible", or should we set this section 
> > as ignored?
> As the manually laid out custom formatting here is kinda beneficial, I think 
> it's preferred to keep it as is. If there are annotations to make 
> clang-format stay off of it, that's probably good (but I don't know what our 
> policy regarding use of such annotations is, if we have any).
FWIW, I'm on the side of "don't use the comments to turn off clang-format" 
because it adds an extra two lines of noise every time we have to use the 
markup. I'd rather see either clang-format improved for the cases that cause us 
pain or the code change to be fine with what's produced by clang-format for 
most cases (there will always be one-offs where it makes sense to use the 
comments, I'm sure).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89490

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


[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thank you for the patch! Ready to land it now.

Please update the patch message before commiting though:

> Without this patch 7 marshalling tests fails on Windows.
> This patch contains the following changes:
> Allow paths with Windows slashes.

This is not correct anymore, right?

> Add support for URI with Windows path.
> Change the value of the second parameter of several 
> llvm::sys::path::convert_to_slash() calls: We should use windows instead of 
> posix to ensure UNIX slashes in the path.
> Remove part of RemoteMarshallingTest::IncludeHeaderURI test which could not 
> be ported on Windows.

This should not be the case anymor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

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


[clang-tools-extra] 627c01b - Extend tests of run-clang-tidy

2020-10-19 Thread Aaron Ballman via cfe-commits

Author: Alexander Lanin
Date: 2020-10-19T10:29:08-04:00
New Revision: 627c01bee0deb353b3e3e90c1b8d0b6d73464466

URL: 
https://github.com/llvm/llvm-project/commit/627c01bee0deb353b3e3e90c1b8d0b6d73464466
DIFF: 
https://github.com/llvm/llvm-project/commit/627c01bee0deb353b3e3e90c1b8d0b6d73464466.diff

LOG: Extend tests of run-clang-tidy

new test: parsing and using compile_commands
new test: export fixes to yaml file
old test extended with CHECK-MESSAGES in order to ensure that they "fail as 
intended"

Added: 

clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp

clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp

Modified: 


Removed: 
clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp



diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
deleted file mode 100644
index 0d0e41e022ae..
--- a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %run_clang_tidy --help
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
-// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
-// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
-// RUN: echo "CheckOptions:" >> %t/.clang-tidy
-// RUN: echo "  - key: modernize-use-auto.MinTypeNameLength" >> 
%t/.clang-tidy
-// RUN: echo "value:   '0'" >> %t/.clang-tidy
-// RUN: cp "%s" "%t/test.cpp"
-// RUN: cd "%t"
-// RUN: not %run_clang_tidy "test.cpp"
-
-int main()
-{
-  int* x = new int();
-  delete x;
-}

diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
new file mode 100644
index ..3976ccf8860d
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_config-file.cpp
@@ -0,0 +1,33 @@
+// under test:
+// - .clang-tidy read from file & treat warnings as errors
+// - return code of run-clang-tidy on those errors
+
+// First make sure clang-tidy is executable and can print help without 
crashing:
+// RUN: %run_clang_tidy --help
+
+// use %t as directory instead of file:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// add this file to %t, add compile_commands for it and .clang-tidy config:
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: echo "CheckOptions:" >> %t/.clang-tidy
+// RUN: echo "  - key: modernize-use-auto.MinTypeNameLength" >> 
%t/.clang-tidy
+// RUN: echo "value:   '0'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+
+// execute and check:
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "test.cpp" > %t/msg.txt 2>&1
+// RUN: FileCheck -input-file=%t/msg.txt -check-prefix=CHECK-MESSAGES %s \
+// RUN:   -implicit-check-not='{{warning|error|note}}:'
+
+int main()
+{
+  int* x = new int();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: error: {{.+}} 
[modernize-use-auto,-warnings-as-errors]
+
+  delete x;
+}

diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
new file mode 100644
index ..f2c97269391e
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/infrastructure/run-clang-tidy_export-diagnostics.cpp
@@ -0,0 +1,33 @@
+// under test:
+// - parsing and using compile_commands
+// - export fixes to yaml file
+
+// use %t as directory instead of file,
+// because "compile_commands.json" must have exactly that name:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo '[{"directory":"%/S","command":"clang++ -c %s","file":"%s"}]' \
+// RUN:  > %t/compile_commands.json
+
+// execute and check:
+// RUN: cd "%t"
+// RUN: %run_clang_tidy 
-checks='-*,bugprone-sizeof-container,modernize-use-auto' \
+// RUN: -p="%/t" -export-fixes=%t/fixes.yaml > %t/msg.txt 2>&1
+// RUN: FileCheck -input-file=%t/msg.txt -check-prefix=CHECK-MESSAGES %s \
+// RUN:   -implicit-check-not='{{warning|error|note}}:'
+// RUN: FileCheck -input-file=%t/fixes.yaml -check-prefix=CHECK-YAML %s
+
+#include 
+int main()
+{
+  std::vector vec;
+  std::vector::iterator iter = vec.begin();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
+  // CHECK-YAML: modernize-use-auto
+  
+  return sizeof(vec);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: sizeof() doesn't 

[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-10-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D74299#2338772 , @AlexanderLanin 
wrote:

> Could someone commit this as I cannot? Thanks a lot!
> Alexander Lanin 
>
> Thanks for review @aaron.ballman!

Happy to do so! I've commit on your behalf in 
627c01bee0deb353b3e3e90c1b8d0b6d73464466 



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

https://reviews.llvm.org/D74299

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


[PATCH] D89700: [clangd] Don't offer to expand auto in structured binding declarations.

2020-10-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: usaxena95.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

auto must be used for the code to parse.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89700

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -572,6 +572,8 @@
 R"cpp(const char * x = "test";)cpp");
 
   EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
+  // expanding types in structured bindings is syntactically invalid.
+  EXPECT_UNAVAILABLE("const ^auto &[x,y] = (int[]){1,2};");
 
   // FIXME: Auto-completion in a template requires disabling delayed template
   // parsing.
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -53,13 +53,24 @@
 
 std::string ExpandAutoType::title() const { return "Expand auto type"; }
 
+// Structured bindings must use auto, e.g. `const auto& [a,b,c] = ...;`.
+// Return whether N (an AutoTypeLoc) is such an auto that must not be expanded.
+bool isStructuredBindingType(const SelectionTree::Node *N) {
+  // Walk up the TypeLoc chain, because auto may be qualified.
+  while (N && N->ASTNode.get())
+N = N->Parent;
+  // The relevant type is the only direct type child of a Decomposition.
+  return N && N->ASTNode.get();
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
 if (auto *TypeNode = Node->ASTNode.get()) {
   if (const AutoTypeLoc Result = TypeNode->getAs()) {
 // Code in apply() does handle 'decltype(auto)' yet.
-if (!Result.getTypePtr()->isDecltypeAuto())
+if (!Result.getTypePtr()->isDecltypeAuto() &&
+!isStructuredBindingType(Node))
   CachedLocation = Result;
   }
 }


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -572,6 +572,8 @@
 R"cpp(const char * x = "test";)cpp");
 
   EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
+  // expanding types in structured bindings is syntactically invalid.
+  EXPECT_UNAVAILABLE("const ^auto &[x,y] = (int[]){1,2};");
 
   // FIXME: Auto-completion in a template requires disabling delayed template
   // parsing.
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -53,13 +53,24 @@
 
 std::string ExpandAutoType::title() const { return "Expand auto type"; }
 
+// Structured bindings must use auto, e.g. `const auto& [a,b,c] = ...;`.
+// Return whether N (an AutoTypeLoc) is such an auto that must not be expanded.
+bool isStructuredBindingType(const SelectionTree::Node *N) {
+  // Walk up the TypeLoc chain, because auto may be qualified.
+  while (N && N->ASTNode.get())
+N = N->Parent;
+  // The relevant type is the only direct type child of a Decomposition.
+  return N && N->ASTNode.get();
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
 if (auto *TypeNode = Node->ASTNode.get()) {
   if (const AutoTypeLoc Result = TypeNode->getAs()) {
 // Code in apply() does handle 'decltype(auto)' yet.
-if (!Result.getTypePtr()->isDecltypeAuto())
+if (!Result.getTypePtr()->isDecltypeAuto() &&
+!isStructuredBindingType(Node))
   CachedLocation = Result;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88956: [clang-format] Fix misformatted macro definitions after D86959

2020-10-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 299054.
arichardson added a comment.

fix name of test class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88956

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TestLexer.h
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -0,0 +1,70 @@
+//===- unittest/Format/TokenAnnotatorTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class TokenAnnotatorTest : public ::testing::Test {
+protected:
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle  = getLLVMStyle()) {
+return TestLexer(Style).annotate(Code);
+  }
+};
+
+#define EXPECT_TOKEN_KIND(FormatTok, Kind) \
+  EXPECT_EQ((FormatTok)->Tok.getKind(), Kind) << *(FormatTok)
+#define EXPECT_TOKEN_TYPE(FormatTok, Type) \
+  EXPECT_EQ((FormatTok)->getType(), Type) << *(FormatTok)
+#define EXPECT_TOKEN(FormatTok, Kind, Type)\
+  do { \
+EXPECT_TOKEN_KIND(FormatTok, Kind);\
+EXPECT_TOKEN_TYPE(FormatTok, Type);\
+  } while (false);
+
+TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmpInMacroDefinition) {
+  // This is a regression test for mis-parsing the & after decltype as a binary
+  // operator instead of a reference (when inside a macro definition).
+  auto Tokens = annotate("auto x = [](const decltype(x) ) {};");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::kw_decltype, TT_Unknown);
+  EXPECT_TOKEN(Tokens[8], tok::l_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_PointerOrReference);
+  // Same again with * instead of &:
+  Tokens = annotate("auto x = [](const decltype(x) *ptr) {};");
+  EXPECT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
+
+  // Also check that we parse correctly within a macro definition:
+  Tokens = annotate("#define lambda [](const decltype(x) ) {}");
+  EXPECT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::kw_decltype, TT_Unknown);
+  EXPECT_TOKEN(Tokens[8], tok::l_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_PointerOrReference);
+  // Same again with * instead of &:
+  Tokens = annotate("#define lambda [](const decltype(x) *ptr) {}");
+  EXPECT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_TypeDeclarationParen);
+  EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
+}
+
+} // namespace
+} // namespace format
+} // namespace clang
Index: clang/unittests/Format/TestLexer.h
===
--- clang/unittests/Format/TestLexer.h
+++ clang/unittests/Format/TestLexer.h
@@ -16,6 +16,9 @@
 #define CLANG_UNITTESTS_FORMAT_TESTLEXER_H
 
 #include "../../lib/Format/FormatTokenLexer.h"
+#include "../../lib/Format/TokenAnalyzer.h"
+#include "../../lib/Format/TokenAnnotator.h"
+#include "../../lib/Format/UnwrappedLineParser.h"
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
@@ -29,7 +32,8 @@
 typedef llvm::SmallVector TokenList;
 
 inline std::ostream <<(std::ostream , const FormatToken ) {
-  Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\")";
+  Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\" , "
+ << getTokenTypeName(Tok.getType()) << ")";
   return Stream;
 }
 inline std::ostream <<(std::ostream , const TokenList ) {
@@ -37,7 +41,7 @@
   for (size_t I = 0, E = Tokens.size(); I != E; ++I) {
 Stream << (I > 0 ? ", " : "") << *Tokens[I];
   }
-  Stream << "}";
+  Stream << "} (" << Tokens.size() << " tokens)";
   return Stream;
 }
 
@@ 

[clang-tools-extra] cf814fc - [clangd] Add test for structured-binding completion. NFC

2020-10-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-19T16:45:51+02:00
New Revision: cf814fcd3939a705f8bdf67bcf54cbf821aa6f75

URL: 
https://github.com/llvm/llvm-project/commit/cf814fcd3939a705f8bdf67bcf54cbf821aa6f75
DIFF: 
https://github.com/llvm/llvm-project/commit/cf814fcd3939a705f8bdf67bcf54cbf821aa6f75.diff

LOG: [clangd] Add test for structured-binding completion. NFC

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 510f358920c1..15576eddf76e 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2579,6 +2579,29 @@ TEST(CompletionTest, Lambda) {
   EXPECT_EQ(A.SnippetSuffix, "(${1:int a}, ${2:const double })");
 }
 
+TEST(CompletionTest, StructuredBinding) {
+  clangd::CodeCompleteOptions Opts = {};
+
+  auto Results = completions(R"cpp(
+struct S {
+  using Float = float;
+  int x;
+  Float y;
+};
+void function() {
+  const auto &[xxx, yyy] = S{};
+  yyy^
+}
+  )cpp",
+ {}, Opts);
+
+  ASSERT_EQ(Results.Completions.size(), 1u);
+  const auto  = Results.Completions.front();
+  EXPECT_EQ(A.Name, "yyy");
+  EXPECT_EQ(A.Kind, CompletionItemKind::Variable);
+  EXPECT_EQ(A.ReturnType, "const Float");
+}
+
 TEST(CompletionTest, ObjectiveCMethodNoArguments) {
   auto Results = completions(R"objc(
   @interface Foo



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


[PATCH] D89559: PR47372: Fix Lambda invoker calling conventions

2020-10-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, it might be reasonable to just do that on targets where the defaults are 
different (just MSVC, I think?) and otherwise preserve the method's calling 
convention.


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

https://reviews.llvm.org/D89559

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


[PATCH] D89559: PR47372: Fix Lambda invoker calling conventions

2020-10-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D89559#2339192 , @rjmccall wrote:

> Yeah, it might be reasonable to just do that on targets where the defaults 
> are different (just MSVC, I think?) and otherwise preserve the method's 
> calling convention.

I think it is actually just MSVC-32 bit!

Since the work is 99% the same, I think I should start doing that (emitting 
BOTH in the case where it matches the default member but NOT the default free 
function CC) in this review, then do a separate commit for the MSVC compat mode 
where we emit a version for ALL of the calling conventions.

Thanks for the feedback!


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

https://reviews.llvm.org/D89559

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


  1   2   >