[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-24 Thread Liao Chunyu via Phabricator via cfe-commits
liaolucy added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c:11
 // ASM-NOT: warning
-#include 
+#include 
 

riscv_vector_overloaded.h ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99189

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


[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Is it feasible to outline the initial segment that you don't want to be part of 
the coroutine, and then have coroutine splitting force that outlined function 
to be inlined into the ramp function?  IIUC, you were saying that the splitting 
patch was difficult, but maybe thinking about it as outlining simplifies 
things.  I know we had some nasty representational problems with the async 
lowering that we solved with outlining and force-inlining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D99227#2646710 , @lxfind wrote:

>> I think you just set `ShouldEmitLifetimeMarkers` correctly in the first 
>> place instead of adding this as an extra condition to every place that 
>> considers it, however.
>
> This was set when a CodeGenFunction is constructed, at that point it doesn't 
> yet know if this function is a coroutine.
> I could turn ShouldEmitLifetimeMarkers to non-const, and then modify it once 
> it realizes it's a coroutine though, if that's better than the current 
> approach.

That would be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-03-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1645
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
+  if (Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

I am a bit confused now :)
Is `flang` using this clang's library?
I think we should be careful here, since I am not sure C/C++ -O0 code has any 
benefits of using this, but the DWARF size might be increased insanely.



Comment at: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll:12
 
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option 
-O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name 
%s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s 
-o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG

I don't think this should be tested this way. We should be testing `Driver` 
itself.


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

https://reviews.llvm.org/D99238

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

I'm gonna continue the conversation here if that's ok, the inline comments are 
rather cramped and confusing.

So, I just double-checked this and `Attrs.Range.getBegin()` returns the 
location of the first `[`, which is correct and not a problem. 
`Lexer::getRawToken(Attrs.Range.getBegin(), ...)` then returns the token as 
expected, no problem either.

The test code I'm looking at now is:

  template struct Template {};
  template struct [[]] Template;

and `Attrs.Range.getBegin()` correctly returns line 2, column 17 and 
`.getEnd()` is line 2 column 20. All correct.

But using `Lexer::findLocationAfterToken()` will return column 19, not 18, so 
the first `]`. However, it seems like directly calling `Lexer::findNextToken()` 
with the location of the first token (without a 
`Lexer::findLocationAfterToken()` in betwee) will return column 19, so the 
second `[`.


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

https://reviews.llvm.org/D97362

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


[PATCH] D99243: [CMake][Fuchsia] Include llvm-lipo

2021-03-24 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: leonardchan, haowei.
Herald added a subscriber: mgorny.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We want to use llvm-lipo for building universal libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99243

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -263,6 +263,7 @@
   llvm-elfabi
   llvm-gsymutil
   llvm-lib
+  llvm-lipo
   llvm-mt
   llvm-nm
   llvm-objcopy


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -263,6 +263,7 @@
   llvm-elfabi
   llvm-gsymutil
   llvm-lib
+  llvm-lipo
   llvm-mt
   llvm-nm
   llvm-objcopy
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 332886.

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

https://reviews.llvm.org/D97362

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot 
appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list 
cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list 
cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow 
GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation 
&&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1607,7 +1607,30 @@
 }
 
 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
- unsigned DiagID) {
+ unsigned DiagID, bool DiagnoseEmptyAttrs) 
{
+
+  if (DiagnoseEmptyAttrs && Attrs.empty() && Attrs.Range.isValid()) {
+// An attribute list has been parsed, but it was empty.
+// This is the case for [[]].
+auto &SM = PP.getSourceManager();
+
+Token FirstLSquare;
+Lexer::getRawToken(Attrs.Range.getBegin(), FirstLSquare, SM, 
getLangOpts());
+
+if (FirstLSquare.is(tok::l_square)) {
+  llvm::Optional SecondLSquare =
+  Lexer::findNextToken(FirstLSquare.getLocation(), SM, getLangOpts());
+
+  if (SecondLSquare && SecondLSquare->is(tok::l_square)) {
+// The attribute range starts with [[, but is empty. So this must
+// be [[]], which we are supposed to diagnose since
+// DiagnoseEmptyAttrs is true.
+Diag(Attrs.Range.getBegin(), DiagID) << Attrs.Range;
+return;
+  }
+}
+  }
+
   for (const ParsedAttr &AL : Attrs) {
 if (!AL.isCXX11Attribute() && !AL.isC2xAttribute())
   continue;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2639,7 +2639,8 @@
   // which standard permits but we don't supported yet, for example, attributes
   // appertain to decl specifiers.
   void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
-   unsigned DiagID);
+   unsigned DiagID,
+   bool DiagnoseEmptyAttrs = false);
 
   /// Skip C++11 and C2x attributes and return the end location of the
   /// last one.


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Pa

[PATCH] D99188: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.

2021-03-24 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6cdb2c0a714: [clang][ASTImporter] Add import of 
DeducedTemplateSpecializationType. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99188

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -631,6 +631,15 @@
  
fieldDecl(hasType(dependentTemplateSpecializationType(;
 }
 
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType(;
+}
+
 const internal::VariadicDynCastAllOfMatcher
 sizeOfPackExpr;
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@
 ExpectedType VisitDecltypeType(const DecltypeType *T);
 ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
 ExpectedType VisitAutoType(const AutoType *T);
+ExpectedType VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T);
 ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@
   ToTemplateArgs);
 }
 
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T) {
+  // FIXME: Make sure that the "to" context supports C++17!
+  Expected ToTemplateNameOrErr = import(T->getTemplateName());
+  if (!ToTemplateNameOrErr)
+return ToTemplateNameOrErr.takeError();
+  ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+  if (!ToDeducedTypeOrErr)
+return ToDeducedTypeOrErr.takeError();
+
+  return Importer.getToContext().getDeducedTemplateSpecializationType(
+  *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
 const InjectedClassNameType *T) {
   Expected ToDeclOrErr = import(T->getDecl());


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -631,6 +631,15 @@
  fieldDecl(hasType(dependentTemplateSpecializationType(;
 }
 
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType(;
+}
+
 const internal::VariadicDynCastAllOfMatcher
 sizeOfPackExpr;
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@
 ExpectedType VisitDecltypeType(const DecltypeType *T);
 ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
 ExpectedType VisitAutoType(const AutoType *T);
+ExpectedType VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T);
 ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@
   ToTemplateArgs);
 }
 
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T) {
+  // FIXME: Make sure that the "to" context supports C++17!
+  Expected ToTemplateNameOrErr = import(T->getTemplateName());
+  if (!ToTemplateNameOrErr)
+return ToTemplateNameOrErr.takeError();
+  ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+  if (!ToDeducedTypeOrErr)
+return ToDeducedTypeOrErr.takeError();
+
+  return Importer.getToContext().getDeducedTemplateSpecializationType(
+  *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
 const InjectedClassNameType *T) {
   Expected ToDeclOrErr = import(T->getDecl());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f6cdb2c - [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.

2021-03-24 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-03-24T09:43:58+01:00
New Revision: f6cdb2c0a714f8921688de08858f34d8c776f0e6

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

LOG: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.

Reviewed By: shafik

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c4f36b50db9d3..ef7a3ea8a66c2 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@ namespace clang {
 ExpectedType VisitDecltypeType(const DecltypeType *T);
 ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
 ExpectedType VisitAutoType(const AutoType *T);
+ExpectedType VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T);
 ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@ ExpectedType ASTNodeImporter::VisitAutoType(const 
AutoType *T) {
   ToTemplateArgs);
 }
 
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T) {
+  // FIXME: Make sure that the "to" context supports C++17!
+  Expected ToTemplateNameOrErr = import(T->getTemplateName());
+  if (!ToTemplateNameOrErr)
+return ToTemplateNameOrErr.takeError();
+  ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+  if (!ToDeducedTypeOrErr)
+return ToDeducedTypeOrErr.takeError();
+
+  return Importer.getToContext().getDeducedTemplateSpecializationType(
+  *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
 const InjectedClassNameType *T) {
   Expected ToDeclOrErr = import(T->getDecl());

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 40383bcabc3f0..fdbf811c94dc1 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -631,6 +631,15 @@ TEST_P(ImportType, ImportDependentTemplateSpecialization) {
  
fieldDecl(hasType(dependentTemplateSpecializationType(;
 }
 
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType(;
+}
+
 const internal::VariadicDynCastAllOfMatcher
 sizeOfPackExpr;
 



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


[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-24 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Overall, this seems reasonable to me. I have a slight concern that it might 
cause surprising failures for downstream users, that aren't picked up at build 
time (due to implicit conversions), but I don't think you need to worry too 
much about that.




Comment at: llvm/include/llvm/Support/MemoryBuffer.h:78-80
   /// if successful, otherwise returning null. If FileSize is specified, this
   /// means that the client knows that the file exists and that it has the
   /// specified size.

You need to remove the reference to FileSize from the description here.



Comment at: llvm/lib/Support/MemoryBuffer.cpp:108
 static ErrorOr>
 getFileAux(const Twine &Filename, int64_t FileSize, uint64_t MapSize,
+   uint64_t Offset, bool IsText, bool RequiresNullTerminator,

Are there users of the `FileSize` here? If not, can you repeat the change for 
this function?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

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


[PATCH] D99248: [RFC][CodeGen] Emit range metadata for array subscript.

2021-03-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet requested review of this revision.
Herald added a project: clang.

To allow LLVM to do better alias anaysis. See RFC on llvm-dev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99248

Files:
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1249,7 +1249,7 @@
 
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
-  if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
+  if (isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
@@ -3691,6 +3691,32 @@
   return Address(eltPtr, eltAlign);
 }
 
+// Add range metadata: It is UB to subscript outside of the array, therefore
+// array indices are known to be in range:
+//   * [0, indexing_bound) if the array is accessed.
+//   * [0, indexing_bound] if only address computation is preformed.
+static llvm::Value *addArrayIndexingRangeMetadata(CodeGenFunction &CGF,
+  const Expr *Base,
+  llvm::Value *Idx,
+  bool Accessed) {
+  QualType IdxTy;
+  llvm::ConstantInt *Bound = dyn_cast_or_null(
+  getArrayIndexingBound(CGF, Base, IdxTy));
+  if (Bound == nullptr)
+return Idx;
+  llvm::Instruction *AnnotatedIdx =
+  CGF.Builder.CreateIntrinsic(llvm::Intrinsic::annotation, 
{Idx->getType()},
+  {Idx, llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int32Ty)});
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  AnnotatedIdx->setMetadata(
+  llvm::LLVMContext::MD_range,
+  MDHelper.createRange(llvm::APInt(Bound->getBitWidth(), 0),
+   Bound->getValue() + (Accessed ? 0 : 1)));
+  return AnnotatedIdx;
+}
+
 LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
bool Accessed) {
   // The index must always be an integer, which is not an aggregate.  Emit it
@@ -3716,6 +3742,9 @@
 if (Promote && Idx->getType() != IntPtrTy)
   Idx = Builder.CreateIntCast(Idx, IntPtrTy, IdxSigned, "idxprom");
 
+if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+  Idx = addArrayIndexingRangeMetadata(*this, E->getBase(), Idx, Accessed);
+
 return Idx;
   };
   IdxPre = nullptr;


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1249,7 +1249,7 @@
 
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
-  if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
+  if (isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
@@ -3691,6 +3691,32 @@
   return Address(eltPtr, eltAlign);
 }
 
+// Add range metadata: It is UB to subscript outside of the array, therefore
+// array indices are known to be in range:
+//   * [0, indexing_bound) if the array is accessed.
+//   * [0, indexing_bound] if only address computation is preformed.
+static llvm::Value *addArrayIndexingRangeMetadata(CodeGenFunction &CGF,
+  const Expr *Base,
+  llvm::Value *Idx,
+  bool Accessed) {
+  QualType IdxTy;
+  llvm::ConstantInt *Bound = dyn_cast_or_null(
+  getArrayIndexingBound(CGF, Base, IdxTy));
+  if (Bound == nullptr)
+return Idx;
+  llvm::Instruction *AnnotatedIdx =
+  CGF.Builder.CreateIntrinsic(llvm::Intrinsic::annotation, {Idx->getType()},
+  {Idx, llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int32Ty)});
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  AnnotatedIdx->setMetadata(
+  llvm::LLVMContext::MD_range,
+  MDHelper.createRange(llvm::APInt(Bound->getBitWidth(), 0),
+   Bound->getValue() + (Accessed ? 0 : 1)));
+  return AnnotatedIdx;
+}
+
 LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
bool Accessed) {
   // The index must always be an integer, which is not an aggregate.  Emit it
@@ -3716,6 +3742,9 @@
 if (Promote && Idx->getType() != IntPtrTy)
   Idx = Builder.CreateIntCast(Idx, IntPtrTy, IdxSigned, "idxprom");
 
+if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+  Idx = addArrayIndexingRangeMetadata(*this, E->getBase(), Idx, Accessed);
+
 re

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 332904.
curdeius added a comment.

- Address review comments (newline + remove diagnostic).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/FixIt/fixit-c++11.cpp
  clang/test/Parser/cxx-concepts-requires-clause.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/Parser/cxx1z-constexpr-lambdas.cpp
  clang/test/Parser/cxx2a-template-lambdas.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- clang/test/SemaOpenCLCXX/address-space-lambda.cl
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -61,7 +61,10 @@
   [&] () __global {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__global'}}
   [&] () __private {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
 
-  [&] __private {} (); //expected-error{{lambda requires '()' before attribute specifier}} expected-error{{expected body of lambda expression}}
+  [&] __private {} (); // expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
+#if __cplusplus <= 202002L
+// expected-warning@-2{{lambda without a parameter clause is a C++2b extension}}
+#endif
 
   [&] () mutable __private {} ();
   [&] () __private mutable {} (); //expected-error{{expected body of lambda expression}}
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto LL0 = [] {};
+auto LL1 = []() {};
+auto LL2 = []() mutable {};
+auto LL3 = []() constexpr {};
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
+auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
+   // expected-error{{function parameter cannot be constexpr}} \
+   // expected-error{{C++ requires}} \
+   // expected-error{{expected ')'}} \
+   // expected-note{{to match this '('}} \
+   // expected-error{{expected body}} \
+   // expected-warning{{duplicate 'constexpr'}}
Index: clang/test/Parser/cxx2a-template-lambdas.cpp
===
--- clang/test/Parser/cxx2a-template-lambdas.cpp
+++ clang/test/Parser/cxx2a-template-lambdas.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
 // RUN: %clang_cc1 -std=c++2a %s -verify
 
 auto L0 = []<> { }; //expected-error {{cannot be empty}}
Index: clang/test/Parser/cxx1z-constexpr-lambdas.cpp
===
--- clang/test/Parser/cxx1z-constexpr-lambdas.cpp
+++ clang/test/Parser/cxx1z-constexpr-lambdas.cpp
@@ -1,12 +1,19 @@
-// RUN: %

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 resigned from this revision.
jansvoboda11 added a comment.

Thanks for the update. Changes touching the command line LGTM, but I'll let 
others confirm the changes to `CodeGen` are fine too.


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

https://reviews.llvm.org/D82547

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


[PATCH] D95516: [clang][cli] Benchmark command line round-trip

2021-03-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 332905.
jansvoboda11 added a comment.

Benchmark compilation and preprocessing as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95516

Files:
  clang/CMakeLists.txt
  clang/benchmarks/CMakeLists.txt
  clang/benchmarks/CompilerInvocationBench.cpp

Index: clang/benchmarks/CompilerInvocationBench.cpp
===
--- /dev/null
+++ clang/benchmarks/CompilerInvocationBench.cpp
@@ -0,0 +1,101 @@
+//===-- CompilerInvocationBench.cpp - Argument parsing benchmark --===//
+//
+// 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/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+
+#include "benchmark/benchmark.h"
+
+using namespace llvm;
+using namespace clang;
+
+int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr);
+
+// After '--' in Argv.
+static const char **Begin;
+
+// The end of Argv.
+static const char **End;
+
+static const char *RoundTrip = "-round-trip-args";
+static const char *NoRoundTrip = "-no-round-trip-args";
+
+static void BM_CompilerInvocationCreate(benchmark::State &State) {
+  SmallVector Args{Begin, End};
+  Args.emplace_back(State.range(0) ? RoundTrip : NoRoundTrip);
+
+  auto Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions,
+   new TextDiagnosticBuffer);
+
+  for (auto _ : State) {
+CompilerInvocation Invocation;
+CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+benchmark::DoNotOptimize(Invocation);
+  }
+
+  assert(Diags->getNumErrors() == 0);
+  assert(Diags->getNumWarnings() == 0);
+}
+
+static void BM_Preprocess(benchmark::State &State) {
+  SmallVector Args{Begin, End};
+  Args.emplace_back(State.range(0) ? RoundTrip : NoRoundTrip);
+  Args.emplace_back("-E");
+
+  for (auto _ : State) {
+int ExitCode = cc1_main(Args, "clang", nullptr);
+benchmark::DoNotOptimize(ExitCode);
+  }
+}
+
+static void BM_Compile(benchmark::State &State) {
+  SmallVector Args{Begin, End};
+  Args.emplace_back(State.range(0) ? RoundTrip : NoRoundTrip);
+  Args.emplace_back("-emit-obj");
+
+  for (auto _ : State) {
+int ExitCode = cc1_main(Args, "clang", nullptr);
+benchmark::DoNotOptimize(ExitCode);
+  }
+}
+
+BENCHMARK(BM_CompilerInvocationCreate)->Arg(false);
+BENCHMARK(BM_CompilerInvocationCreate)->Arg(true);
+
+BENCHMARK(BM_Preprocess)->Arg(false);
+BENCHMARK(BM_Preprocess)->Arg(true);
+
+BENCHMARK(BM_Compile)->Arg(false);
+BENCHMARK(BM_Compile)->Arg(true);
+
+// USAGE:
+// CompilerInvocationBench [ Google Benchmark arguments ... ] \
+//  -- [ Clang CC1 arguments ... ]
+int main(int Argc, const char *Argv[]) {
+  // Find the '--' argument.
+  int DashDashIndex = 0;
+  for (int i = 0; i < Argc; ++i)
+if (StringRef(Argv[i]) == "--")
+  DashDashIndex = i;
+
+  if (DashDashIndex == 0) {
+llvm::errs() << "USAGE:\n"
+ << "  " << Argv[0] << " [ Google Benchmark options ... ] -- "
+ << "[ CompilerInvocation::CreateFromArgs arguments ... ]\n";
+return 1;
+  }
+
+  Begin = Argv + DashDashIndex + 1;
+  End = Argv + Argc;
+
+  int BenchmarkArgc = DashDashIndex - Argc;
+
+  benchmark::Initialize(&BenchmarkArgc, const_cast(Argv));
+  benchmark::RunSpecifiedBenchmarks();
+}
Index: clang/benchmarks/CMakeLists.txt
===
--- /dev/null
+++ clang/benchmarks/CMakeLists.txt
@@ -0,0 +1,41 @@
+add_benchmark(CompilerInvocationBench
+  CompilerInvocationBench.cpp
+  ${CLANG_SOURCE_DIR}/tools/driver/cc1_main.cpp)
+
+foreach(llvm_target ${LLVM_TARGETS_TO_BUILD})
+  set(target_codegen "LLVM${llvm_target}CodeGen")
+  if(TARGET "${target_codegen}")
+list(APPEND llvm_target_libraries "${target_codegen}")
+  endif()
+
+  set(target_asm_parser "LLVM${llvm_target}AsmParser")
+  if(TARGET "${target_asm_parser}")
+list(APPEND llvm_target_libraries "${target_asm_parser}")
+  endif()
+endforeach()
+
+target_link_libraries(CompilerInvocationBench PRIVATE
+  clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
+  clangFrontendTool
+  clangSerialization
+
+  ${llvm_target_libraries}
+  LLVMAnalysis
+  LLVMCodeGen
+  LLVMCore
+#  LLVMIPO
+  LLVMAggressiveInstCombine
+  LLVMInstCombine
+  LLVMInstrumentation
+  LLVMMC
+  LLVMMCParser
+  LLVMObjCARCOpts
+  LLVMOption
+  LLVMScalarOpts
+  LLVMSupport
+  LLVMTarget
+  LLVMTransformUtils
+  LLVMVectorize)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++

[PATCH] D99250: [DebugInfo] Fix the C++ language tags for Dwarf versions.

2021-03-24 Thread EsmeYi via Phabricator via cfe-commits
Esme created this revision.
Esme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Solve the problem of tags and version mismatch


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99250

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  clang/test/Modules/ModuleDebugInfo.cpp


Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s 
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -567,9 +567,9 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;


Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++14 \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s 
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++14 \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -567,9 +567,9 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;

[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-24 Thread Zakk Chen via Phabricator via cfe-commits
khchen marked 3 inline comments as done.
khchen added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c:11
 // ASM-NOT: warning
-#include 
+#include 
 

liaolucy wrote:
> riscv_vector_overloaded.h ?
Sorry, I forget to have a discussion in rvv-intrinsic-doc first about header 
file organization.
We prefer the toolchain only provide one vector intrinsic header for users.
Let we discuss it in https://github.com/riscv/rvv-intrinsic-doc/issues/73.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99189

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


[PATCH] D99181: [analyzer] Fix crash on spaceship operator (PR47511)

2021-03-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'm always in favor of bugfixes. However, I have some concerns about this one.




Comment at: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:169-171
+  } else if (B->getOpcode() == BinaryOperatorKind::BO_Cmp) {
+// We can't reason about C++20 spaceship operator yet.
+return;

What a madness, we deal with every binary operator kind here O.O

Why do we get Undefined here? If we don't model something - theoretically - we 
should get Unknown.
I'm confused.



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:331
 
   // Note: LAnd, LOr, Comma are handled specially by higher-level logic.
 

So, there are some corner cases already.
I can't see any way of implementing this reasonably here, as you pointed out 
the return value of the function is not a good fit.

Shouldn't put your mock 'implementation' to a different place?
I'm just nitpicking though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99181

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


[PATCH] D98918: [clang][lit] Allow test cases to use the compiler that are used to compile Clang

2021-03-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D98918#2636790 , @OikawaKirie wrote:

> Please commit this patch on my behalf (Ella Ma ), so 
> that I can continue with D83660  with your 
> mocked solver.

Oh, I forgot about this one. My apologies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98918

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-24 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D99152#2644373 , @LuoYuanke wrote:

>> To be honest i don't really understand why `x86_amx` type is even there.
>> It seems to me that if you just directly used 
>> `@llvm.x86.tileloadd64.internal` / `@llvm.x86.tilestored64.internal`,
>> and `s/x86_amx/<256 x i32>/`, none of these problems would be here.
>
> I explained in llvm-dev. I copy the content below.
>
> Bitcasts is introduced by the frontend call amx intrinsics. We use vector to 
> represent 2D amx tile in C language, on the other hand we don’t want to mix 
> our amx tile to other vector operation, so x86_amx is introduced to isolate 
> amx intrinsics from normal vector operation. The bitcast is to monitor that a 
> normal vector is passed to amx intrinsics. In below example, we need to 
> transform the bitcast to a vector store and an amx load intrinsic. The 
> x86_amx* is unexpected at the beginning, but in the pass of InstrCombine the 
> middle-end generate the x86_amx pointer.
>
> entry:
>
>   %add = add <256 x i32> %y, %x
>   %t = bitcast <256 x i32> %add to x86_amx
>   call void @llvm.x86.tilestored64.internal(i16 %r, i16 %c, i8* %buf, i64 %s, 
> x86_amx %t)
>   ret void

IIUC you need this to transfer/convert data from a consecutive vector to an 
`AMX` tile. To express that, emitting an intrinsic for the conversion instead a 
`bit cast` seems the right thing to me.

IIUC Roman was saying that from that example alone it is not clear why the 
explicit conversion in IR is actually needed (please correct me if I am wrong). 
For the example, you *could* have a version of `llvm.x86.tilestored64.internal` 
that takes an `<256 x i32>` and does the conversion internally. Having a 
separate intrinsic to do the conversion gives greater composability in the IR, 
but I think at the moment it is hard to judge if that is needed, because it is 
not easy to get an overview of all AMX operations that need support. Is there a 
summary/documentation of the AMX builtins supported in Clang?

With respect to the `load` issue, it is not clear to me at the moment under 
which circumstances regular `load` instructions are generated & interact with 
AMX. If `load` is used to load `x` consecutive elements, than that's fine. But 
if the actual intended operation is a strided load, then `load` should not be 
used (this has also been discussed on llvm-dev).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

2021-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 332925.
hokein added a comment.

- jrefine the fix of the crash: if the element type of an variable-length array

is incomplete, the array type is incomplete;

- simplify the testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,10 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in 
scalar initializer}}
 }
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+  Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@
 return !Rec->isCompleteDefinition();
   }
   case ConstantArray:
+  case VariableArray:
 // An array is incomplete if its element type is incomplete
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).
+// We don't handle dependent-sized arrays (dependent types are never 
treated
+// as incomplete).
 return cast(CanonicalType)->getElementType()
  ->isIncompleteType(Def);
   case IncompleteArray:


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,10 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
 }
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+  Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@
 return !Rec->isCompleteDefinition();
   }
   case ConstantArray:
+  case VariableArray:
 // An array is incomplete if its element type is incomplete
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as incomplete).
+// We don't handle dependent-sized arrays (dependent types are never treated
+// as incomplete).
 return cast(CanonicalType)->getElementType()
  ->isIncompleteType(Def);
   case IncompleteArray:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1d8fc08 - [clang][lit] Allow test cases to use the compiler that are used to compile Clang

2021-03-24 Thread Balazs Benics via cfe-commits

Author: Ella Ma
Date: 2021-03-24T11:32:57+01:00
New Revision: 1d8fc086ae26a1f973b25387b5063f1e801dc0f7

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

LOG: [clang][lit] Allow test cases to use the compiler that are used to compile 
Clang

Required by D83660.
Test cases may want to use the host compiler to compile some mocks for the
test case.

This patch adds two substitutions `%host_cc` and `%host_cxx` to use the host
compilers set via variable `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.

Patch by Ella Ma!

Reviewed By: steakhal

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

Added: 


Modified: 
clang/test/lit.cfg.py
clang/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 863ab444fb02..f9f49d7d2278 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -92,6 +92,9 @@
 ('%hmaptool', "'%s' %s" % (config.python_executable,
  os.path.join(config.clang_tools_dir, 
'hmaptool'
 
+config.substitutions.append(('%host_cc', config.host_cc))
+config.substitutions.append(('%host_cxx', config.host_cxx))
+
 
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index c3382e2c1c42..85526b9d30d6 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -15,6 +15,7 @@ config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@")
 config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_cc = "@CMAKE_C_COMPILER@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@



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


[PATCH] D98918: [clang][lit] Allow test cases to use the compiler that are used to compile Clang

2021-03-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d8fc086ae26: [clang][lit] Allow test cases to use the 
compiler that are used to compile Clang (authored by OikawaKirie, committed by 
Balazs Benics ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98918

Files:
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -15,6 +15,7 @@
 config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_cc = "@CMAKE_C_COMPILER@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -92,6 +92,9 @@
 ('%hmaptool', "'%s' %s" % (config.python_executable,
  os.path.join(config.clang_tools_dir, 
'hmaptool'
 
+config.substitutions.append(('%host_cc', config.host_cc))
+config.substitutions.append(('%host_cxx', config.host_cxx))
+
 
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:


Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -15,6 +15,7 @@
 config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_cc = "@CMAKE_C_COMPILER@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -92,6 +92,9 @@
 ('%hmaptool', "'%s' %s" % (config.python_executable,
  os.path.join(config.clang_tools_dir, 'hmaptool'
 
+config.substitutions.append(('%host_cc', config.host_cc))
+config.substitutions.append(('%host_cxx', config.host_cxx))
+
 
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-03-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D97462#2644406 , @arichardson wrote:

> How expensive are these checks? If it is non-trivial overhead, maybe it 
> should default to `${LLVM_ENABLE_EXPENSIVE_CHECKS}` instead?

Thanks for bringing that up. I measured the performance overhead of 
round-tripping here: https://reviews.llvm.org/D95516. Command-line parsing 
itself is ~3x slower, but still takes under .5 ms. Compared to other parts of 
the compiler, this is insignificant.

Changing the default to `LLVM_ENABLE_EXPENSIVE_CHECKS` would shift the check 
from local development to post-commit testing on built bots for most people. I 
don't think that would be a great trade-off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

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


[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

2021-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D99165#2644243 , @sammccall wrote:

> The fix doesn't look obviously correct: the side effect of marking the 
> destructor reference seems important if we actually generate code. It's not 
> obvious to me why the type can only be incomplete if there are errors.
>
> This was introduced between clang 8 and clang 9, I would guess by 
> f8ccf052935adaf405e581fd31e8bc634cc5bbc7.
> @erik.pilkington 
> Looking at that patch, mostly this function was just a rename, but there's a 
> new callsite for array-types that seems to be what we're hitting here.
> Maybe a slightly less-invasive version would be to guard that callsite with 
> "and if the element type is complete"?

ok, after taking a closer look on the crash, you're right.  fixing 
checkDestructorReference or guarding at that particular callsite is not a root 
fix.

I managed to reduce a smaller case `ForwardClass array[var_size] = {0};`, and 
the crash occurs when clang is performing an initializer check on an 
incomplete-type var decl, this should not be happened --
because an incomplete type of decl should be marked invalid in clang (e.g. 
`ForwardClass array[var_size];`, `ForwardClass var;`), but for the crash case, 
the type of variable-length array is not treated as an incomplete type (this is 
the bug), 
thus the var decl is considered valid, and clang performs the initializer check 
on it.

So I think the right solution is to fix type of variable-length array -- if the 
element type of the variable-length array is incomplete, then the type of array 
is incomplete.




Comment at: clang/lib/AST/Type.cpp:2234
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).

This comment is pretty old, and was added in 
2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is correct 
anymore, variable-length array is allowed in C++, and from 
http://eel.is/c++draft/basic.types.general#5, 

> an array of unknown bound or of incomplete element type, is an 
> incompletely-defined object type.36 Incompletely-defined object types and cv 
> void are incomplete types



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

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


[clang] f8a850c - [Analyzer][NFC] Fix typos in comments

2021-03-24 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-03-24T11:46:10+01:00
New Revision: f8a850ccf452f9709c652823f11f1e95fd2c0e24

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

LOG: [Analyzer][NFC] Fix typos in comments

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 58a88f452ed95..2975d50de3334 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -93,7 +93,7 @@ enum class TrackingKind {
   /// gathered about the tracked expression value as possible.
   Thorough,
   /// Specifies that a more moderate tracking should be used for the expression
-  /// value. This will essentially make sure that functions relevant to the it
+  /// value. This will essentially make sure that functions relevant to it
   /// aren't pruned, but otherwise relies on the user reading the code or
   /// following the arrows.
   Condition

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index a12a78af7a9ee..0edd6e3f731b6 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1942,7 +1942,7 @@ bool bugreporter::trackExpressionValue(const ExplodedNode 
*InputNode,
   const StackFrameContext *SFC = LVNode->getStackFrame();
 
   // We only track expressions if we believe that they are important. Chances
-  // are good that control dependencies to the tracking point are also 
improtant
+  // are good that control dependencies to the tracking point are also 
important
   // because of this, let's explain why we believe control reached this point.
   // TODO: Shouldn't we track control dependencies of every bug location, 
rather
   // than only tracked expressions?



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


[PATCH] D99121: [IR][InstCombine] IntToPtr Produces Typeless Pointer To Byte

2021-03-24 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D99121#2645593 , @dblaikie wrote:

> In D99121#2644362 , @lebedev.ri 
> wrote:
>
>> In D99121#2644223 , @nlopes wrote:
>>
>>> The pointee type in LLVM doesn't really matter. It's even supposed to 
>>> disappear one day after the migration is completed.
>>> E.g., i8* and i64* are exactly the same thing: they are pointers to data.
>>
>> Yep. That will be indeed a great to see.
>>
>>> So, I don't understand the motivation for this patch. It doesn't solve the 
>>> root cause of the problem (which one btw?).
>>
>> It is indeed temporary until Opaque pointers are here.
>> The problem has been stated last time in D99051 
>>  by @ruiling:
>> https://godbolt.org/z/x7E1EjWvv, i.e. given the same integer,
>> there can be any number of pointers `inttoptr`'d from it,
>> and passes won't be able to tell that they are identical.
>>
>> @dblaikie @t.p.northover can anyone comment on the Opaque Pointers progress? 
>> Is there a checklist somewhere?
>
> no checklist, unfortunately - myself, @t.p.northover, @jyknight, and @arsenm 
> have all done bits and pieces of work on it lately.
>
> I think we've got most of the big IR changes (adding explicit types where 
> they'll be needed when they're no longer carried on the type of pointer 
> parameters) - @arsenm's D98146  is another 
> piece in that area, hopefully near the last I think.
>
> After all that's in place, the next step I think would be to introduce the 
> typeless pointer, support it as an operand to these various operations - and 
> then try producing it as a result of instructions too. But I'm probably 
> missing a bunch of important steps we'll find are necessary...

Do you have an ETA for when the switch will happen? Just to inform us where we 
should proceed with temp fixes like this one or we should just wait.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99121

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


[clang] 0e4f5f3 - [PowerPC] Change option to mrop-protect

2021-03-24 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-03-24T05:51:35-05:00
New Revision: 0e4f5f3ea6e11c3e697504b9c43a328a8b85cd13

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

LOG: [PowerPC] Change option to mrop-protect

In order to have the same option on power PC LLVM and power PC gcc
the option will be changed from -mrop-protection to -mrop-protect.

The feature will be off by default and turned on when the option is used.

Reviewed By: lei, amyk

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/test/Driver/ppc-mrop-protection-support-check.c
clang/test/Preprocessor/init-ppc64.c
llvm/lib/Target/PowerPC/PPC.td
llvm/lib/Target/PowerPC/PPCSubtarget.cpp
llvm/lib/Target/PowerPC/PPCSubtarget.h
llvm/test/CodeGen/PowerPC/future-check-features.ll

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 975ab3a93379..86167202398a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3245,7 +3245,7 @@ def mno_longcall : Flag<["-"], "mno-longcall">,
 Group;
 def mmma: Flag<["-"], "mmma">, Group;
 def mno_mma: Flag<["-"], "mno-mma">, Group;
-def mrop_protection : Flag<["-"], "mrop-protection">,
+def mrop_protect : Flag<["-"], "mrop-protect">,
 Group;
 def maix_struct_return : Flag<["-"], "maix-struct-return">,
   Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 57f5de1d0c66..c420028b3e69 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -66,8 +66,8 @@ bool 
PPCTargetInfo::handleTargetFeatures(std::vector &Features,
   PairedVectorMemops = true;
 } else if (Feature == "+mma") {
   HasMMA = true;
-} else if (Feature == "+rop-protection") {
-  HasROPProtection = true;
+} else if (Feature == "+rop-protect") {
+  HasROPProtect = true;
 }
 // TODO: Finish this list and add an assert that we've handled them
 // all.
@@ -195,8 +195,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__POWER9_VECTOR__");
   if (HasMMA)
 Builder.defineMacro("__MMA__");
-  if (HasROPProtection)
-Builder.defineMacro("__ROP_PROTECTION__");
+  if (HasROPProtect)
+Builder.defineMacro("__ROP_PROTECT__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
   if (HasPCRelativeMemops)
@@ -325,8 +325,8 @@ bool PPCTargetInfo::initFeatureMap(
 .Case("pwr8", true)
 .Default(false);
 
-  // ROP Protection is off by default.
-  Features["rop-protection"] = false;
+  // ROP Protect is off by default.
+  Features["rop-protect"] = false;
 
   Features["spe"] = llvm::StringSwitch(CPU)
 .Case("8548", true)
@@ -365,9 +365,9 @@ bool PPCTargetInfo::initFeatureMap(
   }
 
   if (!(ArchDefs & ArchDefinePwr8) &&
-  llvm::find(FeaturesVec, "+rop-protection") != FeaturesVec.end()) {
-// We can turn on ROP Protection on Power 8 and above.
-Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protection" << 
CPU;
+  llvm::find(FeaturesVec, "+rop-protect") != FeaturesVec.end()) {
+// We can turn on ROP Protect on Power 8 and above.
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protect" << CPU;
 return false;
   }
 
@@ -409,7 +409,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   .Case("pcrelative-memops", HasPCRelativeMemops)
   .Case("spe", HasSPE)
   .Case("mma", HasMMA)
-  .Case("rop-protection", HasROPProtection)
+  .Case("rop-protect", HasROPProtect)
   .Default(false);
 }
 

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 0f9713a4c015..095ce03f6fd2 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -59,7 +59,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   // Target cpu features.
   bool HasAltivec = false;
   bool HasMMA = false;
-  bool HasROPProtection = false;
+  bool HasROPProtect = false;
   bool HasVSX = false;
   bool HasP8Vector = false;
   bool HasP8Crypto = false;

diff  --git a/clang/test/Driver/ppc-mrop-protection-support-check.c 
b/clang/test/Driver/ppc-mrop-protection-support-check.c
index c2761d21c9d1..50eaef3ed770 100644
--- a/clang/test/Driver/ppc-mrop-protection-support-check.c
+++ b/clang/test/Driver/ppc-mrop-protection-support-check.c
@@ -1,26 +1,26 @@
 // RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
-// RUN:   -mcpu=pwr10 -mrop-protection %s 2>&1 | FileCheck %s 
--check-prefix=HASROP

[PATCH] D99185: [PowerPC] Change option to mrop-protect

2021-03-24 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e4f5f3ea6e1: [PowerPC] Change option to mrop-protect 
(authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99185

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mrop-protection-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -112,7 +112,7 @@
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
   bool HasMMA;
-  bool HasROPProtection;
+  bool HasROPProtect;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -274,7 +274,7 @@
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
-  bool hasROPProtection() const { return HasROPProtection; }
+  bool hasROPProtect() const { return HasROPProtect; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -87,7 +87,7 @@
   HasP9Vector = false;
   HasP9Altivec = false;
   HasMMA = false;
-  HasROPProtection = false;
+  HasROPProtect = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -252,9 +252,9 @@
   "Enable MMA instructions",
   [FeatureP8Vector, FeatureP9Altivec,
FeaturePairedVectorMemops]>;
-def FeatureROPProtection :
-  SubtargetFeature<"rop-protection", "HasROPProtection", "false",
-   "Add ROP protection">;
+def FeatureROPProtect :
+  SubtargetFeature<"rop-protect", "HasROPProtect", "true",
+   "Add ROP protect">;
 
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
@@ -323,8 +323,7 @@
  FeatureDirectMove,
  FeatureICBT,
  FeaturePartwordAtomic,
- FeaturePredictableSelectIsExpensive,
- FeatureROPProtection
+ FeaturePredictableSelectIsExpensive
 ];
 
   list P8SpecificFeatures = [FeatureAddiLoadFusion,
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -566,7 +566,7 @@
 // PPCPWR8-NOT:#define _ARCH_PWR6X 1
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
-// PPCPWR8-NOT:#define __ROP_PROTECTION__ 1
+// PPCPWR8-NOT:#define __ROP_PROTECT__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -584,7 +584,7 @@
 // PPCPOWER8-NOT:#define _ARCH_PWR6X 1
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
-// PPCPOWER8-NOT:#define __ROP_PROTECTION__ 1
+// PPCPOWER8-NOT:#define __ROP_PROTECT__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPWR9 %s
 //
@@ -599,7 +599,7 @@
 // PPCPWR9-NOT:#define _ARCH_PWR6X 1
 // PPCPWR9:#define _ARCH_PWR7 1
 

[PATCH] D99248: [RFC][CodeGen] Emit range metadata for array subscript.

2021-03-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 332931.
courbet added a comment.

Forgot to add test file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99248

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/array-bounds.cpp

Index: clang/test/CodeGen/array-bounds.cpp
===
--- /dev/null
+++ clang/test/CodeGen/array-bounds.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
+// RUN: -emit-llvm -o - | FileCheck %s
+//
+// Check that we generate array bound information for accesses to array
+// elements.
+
+struct A { int i; };
+struct B { A a[1]; };
+struct C { int i; int x[3]; };
+struct D { int i; int* x; };
+struct E { int x[3][5]; };
+
+//TODO: std::array
+
+int deref(C *c, int j) {
+// CHECK-LABEL: _Z5derefP1Ci
+// CHECK: [[INDEX:%.*]] = call i64 @llvm.annotation{{.*}}, !range [[RANGE_0_3:!.*]]
+// CHECK: getelementptr {{.*}} [[INDEX]]
+  return c->x[j];
+}
+
+int deref_noindex(B *b) {
+// CHECK-LABEL: _Z13deref_noindexP1B
+// CHECK-NOT: llvm.annotation
+// CHECK: getelementptr {{.*}}
+  return b->a->i;
+}
+
+int deref_ptr(D *d, int j) {
+// CHECK-LABEL: _Z9deref_ptrP1Di
+// CHECK-NOT: llvm.annotation
+// CHECK: getelementptr {{.*}}
+  return d->x[j];
+}
+
+int deref_multi(E *e, int j, int k) {
+// CHECK-LABEL: _Z11deref_multiP1Eii
+// CHECK: [[INDEX1:%.*]] =  call i64 @llvm.annotation{{.*}}, !range [[RANGE_0_3]]
+// CHECK: getelementptr {{.*}} [[INDEX1]]
+// CHECK: [[INDEX2:%.*]] =  call i64 @llvm.annotation{{.*}}, !range [[RANGE_0_5:!.*]]
+// CHECK: getelementptr {{.*}} [[INDEX2]]
+  return e->x[j][k];
+}
+
+// We are not dereferencing the computed address, it is valid to compute a
+// past-the-end address.
+int* addr(C *c, int j) {
+// CHECK-LABEL: _Z4addrP1Ci
+// CHECK: [[INDEX:%.*]] = call i64 @llvm.annotation{{.*}}, !range [[RANGE_0_4:!.*]]
+// CHECK: getelementptr {{.*}} [[INDEX]]
+  return &c->x[j];
+}
+
+// CHECK-DAG: [[RANGE_0_3]] = !{i64 0, i64 3}
+// CHECK-DAG: [[RANGE_0_4]] = !{i64 0, i64 4}
+// CHECK-DAG: [[RANGE_0_5]] = !{i64 0, i64 5}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1249,7 +1249,7 @@
 
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
-  if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
+  if (isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
@@ -3691,6 +3691,32 @@
   return Address(eltPtr, eltAlign);
 }
 
+// Add range metadata: It is UB to subscript outside of the array, therefore
+// array indices are known to be in range:
+//   * [0, indexing_bound) if the array is accessed.
+//   * [0, indexing_bound] if only address computation is preformed.
+static llvm::Value *addArrayIndexingRangeMetadata(CodeGenFunction &CGF,
+  const Expr *Base,
+  llvm::Value *Idx,
+  bool Accessed) {
+  QualType IdxTy;
+  llvm::ConstantInt *Bound = dyn_cast_or_null(
+  getArrayIndexingBound(CGF, Base, IdxTy));
+  if (Bound == nullptr)
+return Idx;
+  llvm::Instruction *AnnotatedIdx =
+  CGF.Builder.CreateIntrinsic(llvm::Intrinsic::annotation, {Idx->getType()},
+  {Idx, llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int8PtrTy),
+   llvm::UndefValue::get(CGF.Int32Ty)});
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  AnnotatedIdx->setMetadata(
+  llvm::LLVMContext::MD_range,
+  MDHelper.createRange(llvm::APInt(Bound->getBitWidth(), 0),
+   Bound->getValue() + (Accessed ? 0 : 1)));
+  return AnnotatedIdx;
+}
+
 LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
bool Accessed) {
   // The index must always be an integer, which is not an aggregate.  Emit it
@@ -3716,6 +3742,9 @@
 if (Promote && Idx->getType() != IntPtrTy)
   Idx = Builder.CreateIntCast(Idx, IntPtrTy, IdxSigned, "idxprom");
 
+if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+  Idx = addArrayIndexingRangeMetadata(*this, E->getBase(), Idx, Accessed);
+
 return Idx;
   };
   IdxPre = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3190cf2 - [clang][deps] NFC: Extract ModuleID struct

2021-03-24 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-03-24T11:57:43+01:00
New Revision: 3190cf2017511e7a0570ea9a050a5f28f99d2bf6

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

LOG: [clang][deps] NFC: Extract ModuleID struct

This patch extracts the `ModuleName` and `ContextHash` members of 
`ClangModuleDep`, `FullDependencies` and `ModuleDeps` into a single struct 
`ModuleID`. This makes it easier to understand how the full dependency graph 
works.

Reviewed By: Bigcheese, dexonsmith

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 1c106ed4b765a..b4fa27f531e32 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -22,19 +22,10 @@ namespace dependencies{
 
 /// The full dependencies and module graph for a specific input.
 struct FullDependencies {
-  /// The name of the C++20 module this translation unit exports. This may
-  /// include `:` for C++20 module partitons.
+  /// The identifier of the C++20 module this translation unit exports.
   ///
-  /// If the translation unit is not a module then this will be empty.
-  std::string ExportedModuleName;
-
-  /// The context hash represents the set of compiler options that may make one
-  /// version of a module incompatible with another. This includes things like
-  /// language mode, predefined macros, header search paths, etc...
-  ///
-  /// Modules with the same name but a 
diff erent \c ContextHash should be
-  /// treated as separate modules for the purpose of a build.
-  std::string ContextHash;
+  /// If the translation unit is not a module then \c ID.ModuleName is empty.
+  ModuleID ID;
 
   /// A collection of absolute paths to files that this translation unit
   /// directly depends on, not including transitive dependencies.
@@ -45,7 +36,7 @@ struct FullDependencies {
   ///
   /// This may include modules with a 
diff erent context hash when it can be
   /// determined that the 
diff erences are benign for this compilation.
-  std::vector ClangModuleDeps;
+  std::vector ClangModuleDeps;
 
   /// A partial addtional set of command line arguments that can be used to
   /// build this translation unit.
@@ -65,8 +56,8 @@ struct FullDependencies {
   /// transitive set of dependencies for this
   /// compilation.
   std::vector getAdditionalCommandLine(
-  std::function LookupPCMPath,
-  std::function LookupModuleDeps) 
const;
+  std::function LookupPCMPath,
+  std::function LookupModuleDeps) const;
 };
 
 struct FullDependenciesResult {

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index c490bb38c167d..2e487c7d89f3b 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -28,16 +28,9 @@ namespace dependencies {
 
 class DependencyConsumer;
 
-/// This is used to refer to a specific module.
-///
-/// See \c ModuleDeps for details about what these members mean.
-struct ClangModuleDep {
-  std::string ModuleName;
-  std::string ContextHash;
-};
-
-struct ModuleDeps {
-  /// The name of the module. This may include `:` for C++20 module partitons,
+/// This is used to identify a specific module.
+struct ModuleID {
+  /// The name of the module. This may include `:` for C++20 module partitions,
   /// or a header-name for C++20 header units.
   std::string ModuleName;
 
@@ -48,6 +41,11 @@ struct ModuleDeps {
   /// Modules with the same name but a 
diff erent \c ContextHash should be
   /// treated as separate modules for the purpose of a build.
   std::string ContextHash;
+};
+
+struct ModuleDeps {
+  /// The identifier of the module.
+  ModuleID ID;
 
   /// The path to the modulemap file which defines this module.
   ///
@@ -62,12 +60,12 @@ struct ModuleDeps {
   /// on, not including transitive dependencies.
   llvm::StringSet<> FileDeps;
 
-  /// A list of modules this module directly depends on, not including
-  /// transitive dependencies.
+  /// A list of module identifiers this module directly depends on, not
+  /// including trans

[PATCH] D98943: [clang][deps] NFC: Extract ModuleID struct

2021-03-24 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3190cf201751: [clang][deps] NFC: Extract ModuleID struct 
(authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98943

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -222,16 +222,16 @@
   return llvm::json::Array(Strings);
 }
 
-static llvm::json::Array toJSONSorted(std::vector V) {
-  llvm::sort(V, [](const ClangModuleDep &A, const ClangModuleDep &B) {
+static llvm::json::Array toJSONSorted(std::vector V) {
+  llvm::sort(V, [](const ModuleID &A, const ModuleID &B) {
 return std::tie(A.ModuleName, A.ContextHash) <
std::tie(B.ModuleName, B.ContextHash);
   });
 
   llvm::json::Array Ret;
-  for (const ClangModuleDep &CMD : V)
+  for (const ModuleID &MID : V)
 Ret.push_back(llvm::json::Object(
-{{"module-name", CMD.ModuleName}, {"context-hash", CMD.ContextHash}}));
+{{"module-name", MID.ModuleName}, {"context-hash", MID.ContextHash}}));
   return Ret;
 }
 
@@ -244,26 +244,25 @@
 
 InputDeps ID;
 ID.FileName = std::string(Input);
-ID.ContextHash = std::move(FD.ContextHash);
+ID.ContextHash = std::move(FD.ID.ContextHash);
 ID.FileDeps = std::move(FD.FileDeps);
 ID.ModuleDeps = std::move(FD.ClangModuleDeps);
 
 std::unique_lock ul(Lock);
 for (const ModuleDeps &MD : FDR.DiscoveredModules) {
-  auto I = Modules.find({MD.ContextHash, MD.ModuleName, 0});
+  auto I = Modules.find({MD.ID, 0});
   if (I != Modules.end()) {
 I->first.InputIndex = std::min(I->first.InputIndex, InputIndex);
 continue;
   }
-  Modules.insert(
-  I, {{MD.ContextHash, MD.ModuleName, InputIndex}, std::move(MD)});
+  Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
 if (FullCommandLine)
   ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
-  [&](ClangModuleDep CMD) { return lookupPCMPath(CMD); },
-  [&](ClangModuleDep CMD) -> const ModuleDeps & {
-return lookupModuleDeps(CMD);
+  [&](ModuleID MID) { return lookupPCMPath(MID); },
+  [&](ModuleID MID) -> const ModuleDeps & {
+return lookupModuleDeps(MID);
   });
 
 Inputs.push_back(std::move(ID));
@@ -271,13 +270,13 @@
 
   void printFullOutput(raw_ostream &OS) {
 // Sort the modules by name to get a deterministic order.
-std::vector ModuleNames;
+std::vector ModuleIDs;
 for (auto &&M : Modules)
-  ModuleNames.push_back(M.first);
-llvm::sort(ModuleNames,
-   [](const ContextModulePair &A, const ContextModulePair &B) {
- return std::tie(A.ModuleName, A.InputIndex) <
-std::tie(B.ModuleName, B.InputIndex);
+  ModuleIDs.push_back(M.first);
+llvm::sort(ModuleIDs,
+   [](const IndexedModuleID &A, const IndexedModuleID &B) {
+ return std::tie(A.ID.ModuleName, A.InputIndex) <
+std::tie(B.ID.ModuleName, B.InputIndex);
});
 
 llvm::sort(Inputs, [](const InputDeps &A, const InputDeps &B) {
@@ -287,20 +286,20 @@
 using namespace llvm::json;
 
 Array OutModules;
-for (auto &&ModName : ModuleNames) {
-  auto &MD = Modules[ModName];
+for (auto &&ModID : ModuleIDs) {
+  auto &MD = Modules[ModID];
   Object O{
-  {"name", MD.ModuleName},
-  {"context-hash", MD.ContextHash},
+  {"name", MD.ID.ModuleName},
+  {"context-hash", MD.ID.ContextHash},
   {"file-deps", toJSONSorted(MD.FileDeps)},
   {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)},
   {"clang-modulemap-file", MD.ClangModuleMapFile},
   {"command-line",
FullCommandLine
? MD.getFullCommandLine(
- [&](ClangModuleDep CMD) { return lookupPCMPath(CMD); },
- [&](ClangModuleDep CMD) -> const ModuleDeps & {
-   return lookupModuleDeps(CMD);
+ [&](ModuleID MID) { return lookupPCMPath(MID); },
+ [&](ModuleID MID) -> const ModuleDeps & {
+   return lookupModuleDeps(MID);
  })
: MD.NonPathCommandLine},
   };
@@ -328,33 +327,31 @@
   }
 
 private:
-  StringRef lookupPCMPath(ClangModuleDep CMD) {
-return Modules[ContextModulePai

[clang] 772e9f8 - [clang][deps] NFC: Document collector, rename members

2021-03-24 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-03-24T11:58:43+01:00
New Revision: 772e9f88dd78e6295bd71f1add4bcd7be0582817

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

LOG: [clang][deps] NFC: Document collector, rename members

This patch documents how `ModuleDepCollector{,PP}` work and what their members 
store. Also renames somewhat vague `MainDeps` to `FileDeps` and `Deps` to 
`ModularDeps`.

Depends on D98943.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 2e487c7d89f3..87bb1b86c279 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -104,6 +104,10 @@ void appendCommonModuleArguments(
 
 class ModuleDepCollector;
 
+/// Callback that records textual includes and direct modular includes/imports
+/// during preprocessing. At the end of the main file, it also collects
+/// transitive modular dependencies and passes everything to the
+/// \c DependencyConsumer of the parent \c ModuleDepCollector.
 class ModuleDepCollectorPP final : public PPCallbacks {
 public:
   ModuleDepCollectorPP(CompilerInstance &I, ModuleDepCollector &MDC)
@@ -124,11 +128,18 @@ class ModuleDepCollectorPP final : public PPCallbacks {
   void EndOfMainFile() override;
 
 private:
+  /// The compiler instance for the current translation unit.
   CompilerInstance &Instance;
+  /// The parent dependency collector.
   ModuleDepCollector &MDC;
-  llvm::DenseSet DirectDeps;
+  /// Working set of direct modular dependencies.
+  llvm::DenseSet DirectModularDeps;
 
   void handleImport(const Module *Imported);
+
+  /// Traverses the previously collected direct modular dependencies to 
discover
+  /// transitive modular dependencies and fills the parent \c 
ModuleDepCollector
+  /// with both.
   void handleTopLevelModule(const Module *M);
   void addAllSubmoduleDeps(const Module *M, ModuleDeps &MD,
llvm::DenseSet &AddedModules);
@@ -136,6 +147,8 @@ class ModuleDepCollectorPP final : public PPCallbacks {
 llvm::DenseSet &AddedModules);
 };
 
+/// Collects modular and non-modular dependencies of the main file by attaching
+/// \c ModuleDepCollectorPP to the preprocessor.
 class ModuleDepCollector final : public DependencyCollector {
 public:
   ModuleDepCollector(std::unique_ptr Opts,
@@ -147,12 +160,20 @@ class ModuleDepCollector final : public 
DependencyCollector {
 private:
   friend ModuleDepCollectorPP;
 
+  /// The compiler instance for the current translation unit.
   CompilerInstance &Instance;
+  /// The consumer of collected dependency information.
   DependencyConsumer &Consumer;
+  /// Path to the main source file.
   std::string MainFile;
+  /// The module hash identifying the compilation conditions.
   std::string ContextHash;
-  std::vector MainDeps;
-  std::unordered_map Deps;
+  /// Non-modular file dependencies. This includes the main source file and
+  /// textually included header files.
+  std::vector FileDeps;
+  /// Direct and transitive modular dependencies of the main source file.
+  std::unordered_map ModularDeps;
+  /// Options that control the dependency output generation.
   std::unique_ptr Opts;
 };
 

diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 42a0b5af9d22..1fee831143e6 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -79,7 +79,7 @@ void ModuleDepCollectorPP::FileChanged(SourceLocation Loc,
   // We do not want #line markers to affect dependency generation!
   if (Optional Filename =
   SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc
-MDC.MainDeps.push_back(
+MDC.FileDeps.push_back(
 std::string(llvm::sys::path::remove_leading_dotslash(*Filename)));
 }
 
@@ -91,7 +91,7 @@ void ModuleDepCollectorPP::InclusionDirective(
   if (!File && !Imported) {
 // This is a non-modular include that HeaderSearch failed to find. Add it
 // here as `FileChanged` will never see it.
-MDC.MainDeps.push_back(std::string(FileName));
+MDC.FileDeps.push_back(std::string(FileName));
   }
   handleImport(Imported);
 }
@@ -106,9 +106,10 @@ void ModuleDepCollectorPP::handleImport(const Module 
*Imported) {
   if (!Imported)
 return;
 
-  MDC.Deps[MDC.ContextHash +

[PATCH] D98950: [clang][deps] NFC: Document collector, rename members

2021-03-24 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG772e9f88dd78: [clang][deps] NFC: Document collector, rename 
members (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98950

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -79,7 +79,7 @@
   // We do not want #line markers to affect dependency generation!
   if (Optional Filename =
   SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc
-MDC.MainDeps.push_back(
+MDC.FileDeps.push_back(
 std::string(llvm::sys::path::remove_leading_dotslash(*Filename)));
 }
 
@@ -91,7 +91,7 @@
   if (!File && !Imported) {
 // This is a non-modular include that HeaderSearch failed to find. Add it
 // here as `FileChanged` will never see it.
-MDC.MainDeps.push_back(std::string(FileName));
+MDC.FileDeps.push_back(std::string(FileName));
   }
   handleImport(Imported);
 }
@@ -106,9 +106,10 @@
   if (!Imported)
 return;
 
-  MDC.Deps[MDC.ContextHash + Imported->getTopLevelModule()->getFullModuleName()]
+  const Module *TopLevelModule = Imported->getTopLevelModule();
+  MDC.ModularDeps[MDC.ContextHash + TopLevelModule->getFullModuleName()]
   .ImportedByMainFile = true;
-  DirectDeps.insert(Imported->getTopLevelModule());
+  DirectModularDeps.insert(TopLevelModule);
 }
 
 void ModuleDepCollectorPP::EndOfMainFile() {
@@ -116,21 +117,20 @@
   MDC.MainFile = std::string(
   Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
 
-  for (const Module *M : DirectDeps) {
+  for (const Module *M : DirectModularDeps)
 handleTopLevelModule(M);
-  }
 
-  for (auto &&I : MDC.Deps)
+  for (auto &&I : MDC.ModularDeps)
 MDC.Consumer.handleModuleDependency(I.second);
 
-  for (auto &&I : MDC.MainDeps)
+  for (auto &&I : MDC.FileDeps)
 MDC.Consumer.handleFileDependency(*MDC.Opts, I);
 }
 
 void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
   assert(M == M->getTopLevelModule() && "Expected top level module!");
 
-  auto ModI = MDC.Deps.insert(
+  auto ModI = MDC.ModularDeps.insert(
   std::make_pair(MDC.ContextHash + M->getFullModuleName(), ModuleDeps{}));
 
   if (!ModI.first->second.ID.ModuleName.empty())
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -104,6 +104,10 @@
 
 class ModuleDepCollector;
 
+/// Callback that records textual includes and direct modular includes/imports
+/// during preprocessing. At the end of the main file, it also collects
+/// transitive modular dependencies and passes everything to the
+/// \c DependencyConsumer of the parent \c ModuleDepCollector.
 class ModuleDepCollectorPP final : public PPCallbacks {
 public:
   ModuleDepCollectorPP(CompilerInstance &I, ModuleDepCollector &MDC)
@@ -124,11 +128,18 @@
   void EndOfMainFile() override;
 
 private:
+  /// The compiler instance for the current translation unit.
   CompilerInstance &Instance;
+  /// The parent dependency collector.
   ModuleDepCollector &MDC;
-  llvm::DenseSet DirectDeps;
+  /// Working set of direct modular dependencies.
+  llvm::DenseSet DirectModularDeps;
 
   void handleImport(const Module *Imported);
+
+  /// Traverses the previously collected direct modular dependencies to discover
+  /// transitive modular dependencies and fills the parent \c ModuleDepCollector
+  /// with both.
   void handleTopLevelModule(const Module *M);
   void addAllSubmoduleDeps(const Module *M, ModuleDeps &MD,
llvm::DenseSet &AddedModules);
@@ -136,6 +147,8 @@
 llvm::DenseSet &AddedModules);
 };
 
+/// Collects modular and non-modular dependencies of the main file by attaching
+/// \c ModuleDepCollectorPP to the preprocessor.
 class ModuleDepCollector final : public DependencyCollector {
 public:
   ModuleDepCollector(std::unique_ptr Opts,
@@ -147,12 +160,20 @@
 private:
   friend ModuleDepCollectorPP;
 
+  /// The compiler instance for the current translation unit.
   CompilerInstance &Instance;
+  /// The consumer of collected dependency information.
   DependencyConsumer &Consumer;
+  /// Path to the main source file.
   std::string MainFile;
+  /// The module hash identifying the compilation conditions.
   std::string ContextHash;
-  std::vector MainDeps;
-  std::unordered_map Deps;
+  /// Non-modular file depende

Re: [clang] 874bdc8 - [Driver] Clean up Debian multiarch /usr/include/ madness

2021-03-24 Thread Fangrui Song via cfe-commits
On Tue, Mar 23, 2021 at 7:09 PM Nico Weber  wrote:
>
> Was this reviewed anywhere?

No. This is a nice code cleanup. Do you find a case it does not handle
correctly?

> On Mon, Mar 22, 2021 at 1:40 AM Fangrui Song via cfe-commits 
>  wrote:
>>
>>
>> Author: Fangrui Song
>> Date: 2021-03-21T22:40:38-07:00
>> New Revision: 874bdc8e61662b5f39a9626b9132e0979fae556f
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f.diff
>>
>> LOG: [Driver] Clean up Debian multiarch /usr/include/ madness
>>
>> Debian multiarch additionally adds /usr/include/ and somehow
>> Android borrowed the idea. (Note /usr//include is already an
>> include dir...). On Debian, we should just assume a GCC installation is
>> available and use its triple.
>>
>> Added:
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crt1.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crti.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crtn.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crt1.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crti.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crtn.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crt1.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crti.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crtn.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crt1.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crti.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crtn.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabi/10/crtbegin.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabihf/10/crtbegin.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabi/10/crtbegin.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabihf/10/crtbegin.o
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabihf/.keep
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>> 
>> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>>
>> Modified:
>> clang/lib/Driver/ToolChains/Gnu.cpp
>> clang/lib/Driver/ToolChains/Linux.cpp
>> clang/test/Driver/arm-multilibs.c
>>
>> Removed:
>> 
>> clang/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>> 
>> clang/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>> 
>> clang/test/Driver/Inputs/multilib_armhf_linux_tree/usr/include/arm-linux-gnueabihf/.keep
>>
>>
>> 
>> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
>> b/clang/lib/Driver/ToolChains/Gnu.cpp
>> index c554047beac3..972044fb615e 100644
>> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
>> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
>> @@ -2999,8 +2999,6 @@ Generic_GCC::addGCCLibStdCxxIncludePaths(const 
>> llvm::opt::ArgList &DriverArgs,
>>const Multilib &Multilib = GCCInstallation.getMultilib();
>>const std::string Triple = getMultiarchTriple(
>>getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
>> -  const std::string TargetMultiarchTriple =
>> -  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
>>const GCCVersion &Version = GCCInstallation.getVersion();
>>
>>// Try /../$triple/include/c++/$version then /../include/c++/$version.
>>
>> diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
>> b/clang/lib/Driver/ToolChains/Linux.cpp
>> index cbfa5152bc8e..e889791d19b2 100644
>> --- a/clang/lib/Driver/ToolChains/Linux.cpp
>> +++ b/clang/lib/Driver/ToolChains/Linux.cpp
>> @@ -604,172 +604,16 @@ void Linux::AddClangSystemIncludeArgs(const ArgList 
>> &DriverArgs,
>>  return;
>>}
>>
>> -  // Implement generic Debian multiarch support.
>> -  const StringRef X86_64MultiarchIncludeDirs[] = {
>> -  "/usr/include/x86_64-linux-gnu",
>> -
>> -  // FIXME: These are older forms of multiarch. It's not clear that 
>> they're
>> -  // in use in any released version of Debian, so we should consider
>> -  // removing them.
>> -  "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
>> -  const StringRef X86MultiarchIncludeDirs[] = {
>> -  "/usr/include/i386-linux-gnu",
>> -
>> -  // FIXME: These are older forms of multiarch. It's not clear that 
>>

Re: [clang] 874bdc8 - [Driver] Clean up Debian multiarch /usr/include/ madness

2021-03-24 Thread Fangrui Song via cfe-commits
On Tue, Mar 23, 2021 at 9:22 PM Nico Weber  wrote:
>
> Yes.
>
> 1. Download 
> https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/500976182686961e34974ea7bdc0a21fca32be06/debian_sid_amd64_sysroot.tar.xz
> 2. Unpack somewhere
> 3. Delete the lib/ folder in it
> 4. Try to use that sysroot like so:
>
> thakis@thakis:~/src/llvm-project$ cat test.cc
> #include 
> int main(int argc, char* argv[]) {
> }
> thakis@thakis:~/src/llvm-project$ out/gn/bin/clang --sysroot 
> ~/src/chrome/src/build/linux/debian_sid_amd64-sysroot -c test.cc
> In file included from test.cc:1:
> /usr/local/google/home/thakis/src/chrome/src/build/linux/debian_sid_amd64-sysroot/usr/include/features.h:461:12:
>  fatal error: 'sys/cdefs.h' file not found
> #  include 
>^
> 1 error generated.

There is another debian/ directory in the unpacked directory.
clang++ --sysroot=/tmp/c/debian /tmp/c/a.cc  works fine.

If your `Delete the lib/ folder in it` steps means to delete
lib/x86_64-linux-gnu, that compile error is expected.
Even if the previous behavior does not error for the compile action,
it will fail for the link action.

If you want to make compile action work, you need
lib/x86_64-linux-gnu. I think it is fairly reasonable for clang to
assume that some directories need to exist
for a sysroot to look less like a fake one.

If you really want to make compile action work without an empty
lib/x86_64-linux-gnu, perhaps
delete some D.getVFS().exists in
clang/lib/Driver/ToolChains/Linux.cpp:Linux::getMultiarchTriple.
This is actually something I intend to do next.


>
>
> On Tue, Mar 23, 2021 at 11:01 PM Fangrui Song  wrote:
>>
>> On Tue, Mar 23, 2021 at 7:09 PM Nico Weber  wrote:
>> >
>> > Was this reviewed anywhere?
>>
>> No. This is a nice code cleanup. Do you find a case it does not handle
>> correctly?
>>
>> > On Mon, Mar 22, 2021 at 1:40 AM Fangrui Song via cfe-commits 
>> >  wrote:
>> >>
>> >>
>> >> Author: Fangrui Song
>> >> Date: 2021-03-21T22:40:38-07:00
>> >> New Revision: 874bdc8e61662b5f39a9626b9132e0979fae556f
>> >>
>> >> URL: 
>> >> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f
>> >> DIFF: 
>> >> https://github.com/llvm/llvm-project/commit/874bdc8e61662b5f39a9626b9132e0979fae556f.diff
>> >>
>> >> LOG: [Driver] Clean up Debian multiarch /usr/include/ madness
>> >>
>> >> Debian multiarch additionally adds /usr/include/ and somehow
>> >> Android borrowed the idea. (Note /usr//include is already an
>> >> include dir...). On Debian, we should just assume a GCC installation is
>> >> available and use its triple.
>> >>
>> >> Added:
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crt1.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crti.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabi/crtn.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crt1.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crti.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/arm-linux-gnueabihf/crtn.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crt1.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crti.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabi/crtn.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crt1.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crti.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/armeb-linux-gnueabihf/crtn.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabi/10/crtbegin.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/arm-linux-gnueabihf/10/crtbegin.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabi/10/crtbegin.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/lib/gcc/armeb-linux-gnueabihf/10/crtbegin.o
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/arm-linux-gnueabihf/.keep
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>> >> 
>> >> clang/test/Driver/Inputs/multilib_arm_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>> >>
>> >> Modified:
>> >> clang/lib/Driver/ToolChains/Gnu.cpp
>> >> clang/lib/Driver/ToolChains/Linux.cpp
>> >> clang/test/Driver/arm-multilibs.c
>> >>
>> >> Removed:
>> >> 
>> >> clang/test/Driver/Inputs/multilib_armeb_linux_tree/usr/include/armeb-linux-gnueabi/.keep
>> >> 
>> >> clang/test/Driver/Inputs/multilib_armebhf_linux_tree/usr/include/armeb-linux-gnueabihf/.keep
>> >> 
>> >> clang/test/Driver/Inputs/multilib_armhf_linux_t

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks.

I feel like this is ready to go. Any additional comment?


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

https://reviews.llvm.org/D82547

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


[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

2021-03-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for digging!




Comment at: clang/lib/AST/Type.cpp:2234
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).

hokein wrote:
> This comment is pretty old, and was added in 
> 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is 
> correct anymore, variable-length array is allowed in C++, and from 
> http://eel.is/c++draft/basic.types.general#5, 
> 
> > an array of unknown bound or of incomplete element type, is an 
> > incompletely-defined object type.36 Incompletely-defined object types and 
> > cv void are incomplete types
> 
> This comment is pretty old, and was added in 
> 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is 
> correct anymore

Agree, VLA in C++ were supported in clang in e7545b33ff79 (5 years ago)

> variable-length array is allowed in C++

Not by the standard! It's an extension, copied from gcc.

> an array of unknown bound or of incomplete element type

Yeah, it makes sense to treat VLA like array here.
(I was confused, but "unknown bound" doesn't refer to VLAs, that's rather 
`extern int x[];` which is `IncompleteArray`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

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


[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-03-24 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:572
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;

Seems we miss to handle `DW_LANG_C_plus_plus_03` which is also a DWARF 5 
language name value? We always generate `DW_LANG_C_plus_plus` for `-std=c++03` 
even at `-gdwarf-5`? If so, maybe we also need to fix this in another patch.



Comment at: clang/test/CodeGenCXX/debug-info-programming-language.cpp:3
+// RUN:   -x c++ -std=c++14 \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \

the alignment is a little strange, 80 characters one line?



Comment at: clang/test/CodeGenCXX/debug-info-programming-language.cpp:9
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s

is limited debug info kind enough for this test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-24 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

> IIUC you need this to transfer/convert data from a consecutive vector to an 
> `AMX` tile. To express that, emitting an intrinsic for the conversion instead 
> a `bit cast` seems the right thing to me.

Yes. We need to transfer/convert data from a consecutive vector to an `AMX` 
tile. Because in the C language interface the tile defined as vector. `typedef 
int _tile1024i __attribute__((__vector_size__(1024), __aligned__(64)));`  Take 
below code (https://gcc.godbolt.org/z/noaWEWd6n) as an example.

  #include 
  
  char buf[1024];
  void foo() {
_tile1024i tile;
tile = __builtin_ia32_tileloadd64_internal(16, 64, buf, 64);
  }

Compile it with "clang -S -emit-llvm simple_amx.c -mamx-int8" we got below IR.

  define dso_local void @foo() #0 !dbg !15 {
%1 = alloca <256 x i32>, align 64
call void @llvm.dbg.declare(metadata <256 x i32>* %1, metadata !18, 
metadata !DIExpression()), !dbg !25
%2 = call x86_amx @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* 
getelementptr inbounds ([1024 x i8], [1024 x i8]* @buf, i64 0, i64 0), i64 64), 
!dbg !26
%3 = bitcast x86_amx %2 to <256 x i32>, !dbg !26
store <256 x i32> %3, <256 x i32>* %1, align 64, !dbg !27
ret void, !dbg !28
  }

Front-end alloca <256 x i32> for the local variable tile. When the return value 
of __builtin_ia32_tileloadd64_internal is assigned to tile. Front-end bitcast 
x86_amx to <256 x i32>. The x86_amx is the type returned from 
__builtin_ia32_tileloadd64_internal.

> IIUC Roman was saying that from that example alone it is not clear why the 
> explicit conversion in IR is actually needed (please correct me if I am 
> wrong). For the example, you *could* have a version of 
> `llvm.x86.tilestored64.internal` that takes an `<256 x i32>` and does the 
> conversion internally. Having a separate intrinsic to do the conversion gives 
> greater composability in the IR, but I think at the moment it is hard to 
> judge if that is needed, because it is not easy to get an overview of all AMX 
> operations that need support. Is there a summary/documentation of the AMX 
> builtins supported in Clang?

I plan to add AMX operation to Clang doc when the AMX support in LLVM is 
stable. There are only load/store, zero, dotproduct operations for AMX. We 
don't have full ISA support to matrix operation.

  __builtin_ia32_tileloadd64_internal
  __builtin_ia32_tdpbssd_internal
  __builtin_ia32_tilestored64_internal
  __builtin_ia32_tilezero_internal



> With respect to the `load` issue, it is not clear to me at the moment under 
> which circumstances regular `load` instructions are generated & interact with 
> AMX. If `load` is used to load `x` consecutive elements, than that's fine. 
> But if the actual intended operation is a strided load, then `load` should 
> not be used (this has also been discussed on llvm-dev).

The `load` instructions are generated because it is a vector in C language. See 
https://gcc.godbolt.org/z/qv5jnjK48. If we use -O0, there is load instruction 
generated. If we use -O2, the load instruction is eliminated. The -O2 version 
is what we want. There is no <256 x i32> in the generated code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 332946.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

I've removed FileSize from getFileAux and WritableMemoryBuffer::getFile as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter &Writer) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(errorCodeToError(EC), File);
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1524,14 +1524,16 @@
   // properly though, so if using that to append paths below, this early
   // exception case could be removed.)
   if (sys::path::has_root_directory(File))
-return errorOr

[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 2 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: llvm/include/llvm/Support/MemoryBuffer.h:78-80
   /// if successful, otherwise returning null. If FileSize is specified, this
   /// means that the client knows that the file exists and that it has the
   /// specified size.

jhenderson wrote:
> You need to remove the reference to FileSize from the description here.
Thanks for catching that, I updated the comment.



Comment at: llvm/lib/Support/MemoryBuffer.cpp:108
 static ErrorOr>
 getFileAux(const Twine &Filename, int64_t FileSize, uint64_t MapSize,
+   uint64_t Offset, bool IsText, bool RequiresNullTerminator,

jhenderson wrote:
> Are there users of the `FileSize` here? If not, can you repeat the change for 
> this function?
No, I was able to remove FileSize from here as well as 
WritableMemoryBuffer::getFile too. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

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


[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-24 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.

I think this basically LGTM with a few minor nits, but I'd like to make sure 
@rsmith doesn't have concerns, so please wait a few days before landing in case 
he wants to chime in.




Comment at: clang/lib/Parse/ParseDecl.cpp:1618
+Token FirstLSquare;
+Lexer::getRawToken(Attrs.Range.getBegin(), FirstLSquare, SM, 
getLangOpts());
+

We may as well hoist the call to `getLangOpts()` the same as we do for 
`getSourceManager()`.



Comment at: clang/lib/Parse/ParseDecl.cpp:1626
+// The attribute range starts with [[, but is empty. So this must
+// be [[]], which we are supposed to diagnose since
+// DiagnoseEmptyAttrs is true.




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

https://reviews.llvm.org/D97362

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


[clang] d1c8a15 - [OpenCL] Added distinct file extension for C++ for OpenCL.

2021-03-24 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-03-24T13:07:04Z
New Revision: d1c8a151df830c6c727f0bb7d33774bd3eb96824

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

LOG: [OpenCL] Added distinct file extension for C++ for OpenCL.

Files compiled with C++ for OpenCL mode can now have a distinct
file extension - clcpp, then clang driver picks the compilation
mode automatically (-x clcpp) without the use of -cl-std=clc++.

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

Added: 
clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
clang/test/CodeGenOpenCLCXX/address-space-deduction2.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
clang/test/CodeGenOpenCLCXX/atexit.clcpp
clang/test/CodeGenOpenCLCXX/constexpr.clcpp
clang/test/CodeGenOpenCLCXX/global_init.clcpp
clang/test/CodeGenOpenCLCXX/local_addrspace_init.clcpp
clang/test/CodeGenOpenCLCXX/method-overload-address-space.clcpp
clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
clang/test/Driver/cxx_for_opencl.clcpp
clang/test/SemaOpenCLCXX/address-space-castoperators.clcpp
clang/test/SemaOpenCLCXX/address-space-cond.clcpp
clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.clcpp
clang/test/SemaOpenCLCXX/address-space-of-this.clcpp
clang/test/SemaOpenCLCXX/address-space-references.clcpp
clang/test/SemaOpenCLCXX/address-space-templates.clcpp
clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp
clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
clang/test/SemaOpenCLCXX/members.clcpp
clang/test/SemaOpenCLCXX/method-overload-address-space.clcpp
clang/test/SemaOpenCLCXX/newdelete.clcpp
clang/test/SemaOpenCLCXX/references.clcpp
clang/test/SemaOpenCLCXX/restricted.clcpp

Modified: 
clang/include/clang/Basic/LangStandard.h
clang/include/clang/Driver/Types.def
clang/lib/Driver/Types.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/FrontendOptions.cpp
clang/test/Driver/lit.local.cfg
clang/test/lit.cfg.py

Removed: 
clang/test/CodeGenOpenCLCXX/address-space-deduction.cl
clang/test/CodeGenOpenCLCXX/address-space-deduction2.cl
clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl
clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
clang/test/CodeGenOpenCLCXX/addrspace-references.cl
clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
clang/test/CodeGenOpenCLCXX/addrspace_cast.cl
clang/test/CodeGenOpenCLCXX/atexit.cl
clang/test/CodeGenOpenCLCXX/constexpr.cl
clang/test/CodeGenOpenCLCXX/global_init.cl
clang/test/CodeGenOpenCLCXX/local_addrspace_init.cl
clang/test/CodeGenOpenCLCXX/method-overload-address-space.cl
clang/test/CodeGenOpenCLCXX/template-address-spaces.cl
clang/test/SemaOpenCLCXX/address-space-castoperators.cl
clang/test/SemaOpenCLCXX/address-space-cond.cl
clang/test/SemaOpenCLCXX/address-space-deduction.cl
clang/test/SemaOpenCLCXX/address-space-lambda.cl
clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
clang/test/SemaOpenCLCXX/address-space-of-this.cl
clang/test/SemaOpenCLCXX/address-space-references.cl
clang/test/SemaOpenCLCXX/address-space-templates.cl
clang/test/SemaOpenCLCXX/address_space_overloading.cl
clang/test/SemaOpenCLCXX/addrspace-auto.cl
clang/test/SemaOpenCLCXX/addrspace_cast.cl
clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cl
clang/test/SemaOpenCLCXX/invalid-kernel.cl
clang/test/SemaOpenCLCXX/members.cl
clang/test/SemaOpenCLCXX/method-overload-address-space.cl
clang/test/SemaOpenCLCXX/newdelete.cl
clang/test/SemaOpenCLCXX/references.cl
clang/test/SemaOpenCLCXX/restricted.cl



diff  --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index f82ce05a63692..b0785409628c4 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/

[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-24 Thread Anastasia Stulova 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 rGd1c8a151df83: [OpenCL] Added distinct file extension for C++ 
for OpenCL. (authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D96771?vs=331317&id=332952#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96771

Files:
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.cl
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace_cast.cl
  clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
  clang/test/CodeGenOpenCLCXX/atexit.cl
  clang/test/CodeGenOpenCLCXX/atexit.clcpp
  clang/test/CodeGenOpenCLCXX/constexpr.cl
  clang/test/CodeGenOpenCLCXX/constexpr.clcpp
  clang/test/CodeGenOpenCLCXX/global_init.cl
  clang/test/CodeGenOpenCLCXX/global_init.clcpp
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.cl
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.clcpp
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.cl
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/Driver/cxx_for_opencl.clcpp
  clang/test/Driver/lit.local.cfg
  clang/test/SemaOpenCLCXX/address-space-castoperators.cl
  clang/test/SemaOpenCLCXX/address-space-castoperators.clcpp
  clang/test/SemaOpenCLCXX/address-space-cond.cl
  clang/test/SemaOpenCLCXX/address-space-cond.clcpp
  clang/test/SemaOpenCLCXX/address-space-deduction.cl
  clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.clcpp
  clang/test/SemaOpenCLCXX/address-space-of-this.cl
  clang/test/SemaOpenCLCXX/address-space-of-this.clcpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaOpenCLCXX/address-space-references.clcpp
  clang/test/SemaOpenCLCXX/address-space-templates.cl
  clang/test/SemaOpenCLCXX/address-space-templates.clcpp
  clang/test/SemaOpenCLCXX/address_space_overloading.cl
  clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
  clang/test/SemaOpenCLCXX/addrspace-auto.cl
  clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
  clang/test/SemaOpenCLCXX/addrspace_cast.cl
  clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cl
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp
  clang/test/SemaOpenCLCXX/invalid-kernel.cl
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
  clang/test/SemaOpenCLCXX/members.cl
  clang/test/SemaOpenCLCXX/members.clcpp
  clang/test/SemaOpenCLCXX/method-overload-address-space.cl
  clang/test/SemaOpenCLCXX/method-overload-address-space.clcpp
  clang/test/SemaOpenCLCXX/newdelete.cl
  clang/test/SemaOpenCLCXX/newdelete.clcpp
  clang/test/SemaOpenCLCXX/references.cl
  clang/test/SemaOpenCLCXX/references.clcpp
  clang/test/SemaOpenCLCXX/restricted.cl
  clang/test/SemaOpenCLCXX/restricted.clcpp
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -26,7 +26,7 @@
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
-   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
+   '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude fro

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-24 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, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D99258: [OpenCL] Fix AST check in address-space-templates test

2021-03-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: bader.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

See comment: https://reviews.llvm.org/D95624#2621226


https://reviews.llvm.org/D99258

Files:
  clang/test/SemaOpenCLCXX/address-space-templates.clcpp


Index: clang/test/SemaOpenCLCXX/address-space-templates.clcpp
===
--- clang/test/SemaOpenCLCXX/address-space-templates.clcpp
+++ clang/test/SemaOpenCLCXX/address-space-templates.clcpp
@@ -31,7 +31,7 @@
 // Check address space deduction in template parameter deduction.
 struct rep {
   // When there is no address space on a reference use __generic.
-  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
&__private) __generic'
+  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
&__private){{.*}} __generic'
   template::type>
   rep(U&& v) {}
 };
@@ -57,6 +57,6 @@
   rep_outer r;
   int i;
   // Preserve the address space of the type in forwarding reference.
-  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) 
const __generic'
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int 
&__private){{.*}} const __generic'
   foo4(i, [](auto&& x){;});
 }


Index: clang/test/SemaOpenCLCXX/address-space-templates.clcpp
===
--- clang/test/SemaOpenCLCXX/address-space-templates.clcpp
+++ clang/test/SemaOpenCLCXX/address-space-templates.clcpp
@@ -31,7 +31,7 @@
 // Check address space deduction in template parameter deduction.
 struct rep {
   // When there is no address space on a reference use __generic.
-  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep &__private) __generic'
+  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep &__private){{.*}} __generic'
   template::type>
   rep(U&& v) {}
 };
@@ -57,6 +57,6 @@
   rep_outer r;
   int i;
   // Preserve the address space of the type in forwarding reference.
-  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) const __generic'
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private){{.*}} const __generic'
   foo4(i, [](auto&& x){;});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95624: [OpenCL][PR48896] Fix default address space in template argument deduction

2021-03-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.
Herald added a subscriber: ldrumm.



Comment at: clang/test/SemaOpenCLCXX/address-space-templates.cl:60
+  // Preserve the address space of the type in forwarding reference.
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) 
const __generic'
+  foo4(i, [](auto&& x){;});

bader wrote:
> This check fails on 32-bit Windows platform where compiler adds  
> `__attribute__((thiscall))` both constructor and call operator.
> 
> Something like this should fix the problem:
> 
> ```
>   // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
> &__private){{.*}} __generic'
>   // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int 
> &__private){{.*}} const __generic'
> ```
Sure: https://reviews.llvm.org/D99258


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95624

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


[PATCH] D99259: [WebAssembly] Don't inline -emscripten-cxx-exceptions-allowed functions

2021-03-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: sbc100.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, dschuff.
aheejin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Functions specified in `-emscripten-cxx-exceptions-allowed`, which is
set by Emscripten's `EXCEPTION_CATCHING_ALLOWED` setting, can be inlined
in LLVM middle ends before we reach WebAssemblyLowerEmscriptenEHSjLj
pass in the wasm backend and thus don't get transformed for exception
catching.

This fixes the issue by adding `--force-attribute=FUNC_NAME:noinline`
for each function name in `-emscripten-cxx-exceptions-allowed`, which
adds `noinline` attribute to the specified function and thus excludes
the function from inlining candidates in optimization passes.

Fixes the remaining half of
https://github.com/emscripten-core/emscripten/issues/10721.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99259

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,6 +79,21 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with 
'-mno-sign-ext'
 
+// '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
+// '-mllvm --force-attribute=foo:noinline -mllvm 
--force-attribute=bar:noinline'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm -enable-emscripten-cxx-exceptions \
+// RUN:-mllvm -emscripten-cxx-exceptions-allowed=foo,bar 2>&1 \
+// RUN:  | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_NOINLINE %s
+// EMSCRIPTEN_EH_ALLOWED_NOINLINE: clang{{.*}}" "-cc1" {{.*}} "-mllvm" 
"--force-attribute=foo:noinline" "-mllvm" "--force-attribute=bar:noinline"
+
+// '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -emscripten-cxx-exceptions-allowed 2>&1 \
+// RUN:   | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
+// EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm 
-emscripten-cxx-exceptions-allowed' only allowed with '-mllvm 
-enable-emscripten-cxx-exceptions'
+
 // '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -294,6 +294,33 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
   }
+
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
+StringRef Opt = A->getValue(0);
+if (Opt.startswith("-emscripten-cxx-exceptions-allowed")) {
+  // '-mllvm -emscripten-cxx-exceptions-allowed' is only allowed with
+  // '-mllvm -enable-emscripten-cxx-exceptions'
+  bool EmExceptionArgExists = false;
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm))
+if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
+  EmExceptionArgExists = true;
+  if (!EmExceptionArgExists)
+getDriver().Diag(diag::err_drv_argument_only_allowed_with)
+<< "-mllvm -emscripten-cxx-exceptions-allowed"
+<< "-mllvm -enable-emscripten-cxx-exceptions";
+
+  // Prevent functions specified in -emscripten-cxx-exceptions-allowed list
+  // from being inlined before reaching the wasm backend.
+  StringRef FuncNamesStr = Opt.split('=').second;
+  SmallVector FuncNames;
+  FuncNamesStr.split(FuncNames, ',');
+  for (auto Name : FuncNames) {
+CC1Args.push_back("-mllvm");
+CC1Args.push_back(DriverArgs.MakeArgString("--force-attribute=" + Name 
+
+   ":noinline"));
+  }
+}
+  }
 }
 
 ToolChain::RuntimeLibType WebAssembly::GetDefaultRuntimeLibType() const {


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,6 +79,21 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
 
+// '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
+// '-mllvm --force-attribute=foo:noinline -mllvm --force-attribute=bar:noinline'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm 

[PATCH] D99165: [clang] Treat variable-length array of incomplete element type as incomplete type.

2021-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/Type.cpp:2234
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).

sammccall wrote:
> hokein wrote:
> > This comment is pretty old, and was added in 
> > 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is 
> > correct anymore, variable-length array is allowed in C++, and from 
> > http://eel.is/c++draft/basic.types.general#5, 
> > 
> > > an array of unknown bound or of incomplete element type, is an 
> > > incompletely-defined object type.36 Incompletely-defined object types and 
> > > cv void are incomplete types
> > 
> > This comment is pretty old, and was added in 
> > 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is 
> > correct anymore
> 
> Agree, VLA in C++ were supported in clang in e7545b33ff79 (5 years ago)
> 
> > variable-length array is allowed in C++
> 
> Not by the standard! It's an extension, copied from gcc.
> 
> > an array of unknown bound or of incomplete element type
> 
> Yeah, it makes sense to treat VLA like array here.
> (I was confused, but "unknown bound" doesn't refer to VLAs, that's rather 
> `extern int x[];` which is `IncompleteArray`)
> Not by the standard! It's an extension, copied from gcc.

oh, right. VLA is allowed by C99 standard, but not in C++ standard, weird..



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

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


[PATCH] D99260: [analyzer] Fix false positives in inner pointer checker (PR49628)

2021-03-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, steakhal, xazax.hun, ASDenysPetrov.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch supports std::data and std::addressof functions.

rdar://73463300


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99260

Files:
  clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  clang/test/Analysis/inner-pointer.cpp

Index: clang/test/Analysis/inner-pointer.cpp
===
--- clang/test/Analysis/inner-pointer.cpp
+++ clang/test/Analysis/inner-pointer.cpp
@@ -17,6 +17,11 @@
 string my_string = "default";
 void default_arg(int a = 42, string &b = my_string);
 
+template 
+T *addressof(T &arg);
+
+char *data(std::string &c);
+
 } // end namespace std
 
 void consume(const char *) {}
@@ -273,6 +278,15 @@
   // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
 }
 
+void deref_after_std_data() {
+  const char *c;
+  std::string s;
+  c = std::data(s); // expected-note {{Pointer to inner buffer of 'std::string' obtained here}}
+  s.push_back('c'); // expected-note {{Inner buffer of 'std::string' reallocated by call to 'push_back'}}
+  consume(c);   // expected-warning {{Inner pointer of container used after re/deallocation}}
+  // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
+}
+
 struct S {
   std::string s;
   const char *name() {
@@ -361,8 +375,24 @@
   // expected-note@-1 {{Inner pointer of container used after re/deallocation}}
 }
 
+void func_addressof() {
+  const char *c;
+  std::string s;
+  c = s.c_str();
+  addressof(s);
+  consume(c); // no-warning
+}
+
+void func_std_data() {
+  const char *c;
+  std::string s;
+  c = std::data(s);
+  consume(c); // no-warning
+}
+
 struct T {
   std::string to_string() { return s; }
+
 private:
   std::string s;
 };
Index: clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
@@ -34,9 +34,9 @@
 class InnerPointerChecker
 : public Checker {
 
-  CallDescription AppendFn, AssignFn, ClearFn, CStrFn, DataFn, EraseFn,
-  InsertFn, PopBackFn, PushBackFn, ReplaceFn, ReserveFn, ResizeFn,
-  ShrinkToFitFn, SwapFn;
+  CallDescription AppendFn, AssignFn, AddressofFn, ClearFn, CStrFn, DataFn,
+  DataMemberFn, EraseFn, InsertFn, PopBackFn, PushBackFn, ReplaceFn,
+  ReserveFn, ResizeFn, ShrinkToFitFn, SwapFn;
 
 public:
   class InnerPointerBRVisitor : public BugReporterVisitor {
@@ -73,9 +73,10 @@
   InnerPointerChecker()
   : AppendFn({"std", "basic_string", "append"}),
 AssignFn({"std", "basic_string", "assign"}),
+AddressofFn({"std", "addressof"}),
 ClearFn({"std", "basic_string", "clear"}),
-CStrFn({"std", "basic_string", "c_str"}),
-DataFn({"std", "basic_string", "data"}),
+CStrFn({"std", "basic_string", "c_str"}), DataFn({"std", "data"}),
+DataMemberFn({"std", "basic_string", "data"}),
 EraseFn({"std", "basic_string", "erase"}),
 InsertFn({"std", "basic_string", "insert"}),
 PopBackFn({"std", "basic_string", "pop_back"}),
@@ -90,6 +91,9 @@
   /// pointers referring to the container object's inner buffer.
   bool isInvalidatingMemberFunction(const CallEvent &Call) const;
 
+  /// Check whether the called function returns a raw inner pointer.
+  bool isInnerPointerAccessFunction(const CallEvent &Call) const;
+
   /// Mark pointer symbols associated with the given memory region released
   /// in the program state.
   void markPtrSymbolsReleased(const CallEvent &Call, ProgramStateRef State,
@@ -130,6 +134,12 @@
   Call.isCalled(SwapFn));
 }
 
+bool InnerPointerChecker::isInnerPointerAccessFunction(
+const CallEvent &Call) const {
+  return (Call.isCalled(CStrFn) || Call.isCalled(DataFn) ||
+  Call.isCalled(DataMemberFn));
+}
+
 void InnerPointerChecker::markPtrSymbolsReleased(const CallEvent &Call,
  ProgramStateRef State,
  const MemRegion *MR,
@@ -172,6 +182,11 @@
   if (!ArgRegion)
 continue;
 
+  // std::addressof function accepts a non-const reference as an argument,
+  // but doesn't modify it.
+  if (Call.isCalled(AddressofFn))
+continue;
+
   markPtrSymbolsReleased(Call, State, ArgRegion, C);
 }
   }
@@ -195,36 +210,49 @@
 CheckerContext &C) const {
   ProgramStateRef State = C.getState();
 
+  // TODO: Do we need these to be typed?
+  const TypedValueRegion *ObjRegion

[PATCH] D99259: [WebAssembly] Don't inline -emscripten-cxx-exceptions-allowed functions

2021-03-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 332957.
aheejin added a comment.

Comment fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99259

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,6 +79,21 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with 
'-mno-sign-ext'
 
+// '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
+// '-mllvm --force-attribute=foo:noinline -mllvm 
--force-attribute=bar:noinline'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm -enable-emscripten-cxx-exceptions \
+// RUN:-mllvm -emscripten-cxx-exceptions-allowed=foo,bar 2>&1 \
+// RUN:  | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_NOINLINE %s
+// EMSCRIPTEN_EH_ALLOWED_NOINLINE: clang{{.*}}" "-cc1" {{.*}} "-mllvm" 
"--force-attribute=foo:noinline" "-mllvm" "--force-attribute=bar:noinline"
+
+// '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -emscripten-cxx-exceptions-allowed 2>&1 \
+// RUN:   | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
+// EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm 
-emscripten-cxx-exceptions-allowed' only allowed with '-mllvm 
-enable-emscripten-cxx-exceptions'
+
 // '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -294,6 +294,33 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
   }
+
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
+StringRef Opt = A->getValue(0);
+if (Opt.startswith("-emscripten-cxx-exceptions-allowed")) {
+  // '-mllvm -emscripten-cxx-exceptions-allowed' should be used with
+  // '-mllvm -enable-emscripten-cxx-exceptions'
+  bool EmExceptionArgExists = false;
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm))
+if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
+  EmExceptionArgExists = true;
+  if (!EmExceptionArgExists)
+getDriver().Diag(diag::err_drv_argument_only_allowed_with)
+<< "-mllvm -emscripten-cxx-exceptions-allowed"
+<< "-mllvm -enable-emscripten-cxx-exceptions";
+
+  // Prevent functions specified in -emscripten-cxx-exceptions-allowed list
+  // from being inlined before reaching the wasm backend.
+  StringRef FuncNamesStr = Opt.split('=').second;
+  SmallVector FuncNames;
+  FuncNamesStr.split(FuncNames, ',');
+  for (auto Name : FuncNames) {
+CC1Args.push_back("-mllvm");
+CC1Args.push_back(DriverArgs.MakeArgString("--force-attribute=" + Name 
+
+   ":noinline"));
+  }
+}
+  }
 }
 
 ToolChain::RuntimeLibType WebAssembly::GetDefaultRuntimeLibType() const {


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,6 +79,21 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
 
+// '-mllvm -emscripten-cxx-exceptions-allowed=foo,bar' sets
+// '-mllvm --force-attribute=foo:noinline -mllvm --force-attribute=bar:noinline'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm -enable-emscripten-cxx-exceptions \
+// RUN:-mllvm -emscripten-cxx-exceptions-allowed=foo,bar 2>&1 \
+// RUN:  | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_NOINLINE %s
+// EMSCRIPTEN_EH_ALLOWED_NOINLINE: clang{{.*}}" "-cc1" {{.*}} "-mllvm" "--force-attribute=foo:noinline" "-mllvm" "--force-attribute=bar:noinline"
+
+// '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -emscripten-cxx-exceptions-allowed 2>&1 \
+// RUN:   | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
+// EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' o

[PATCH] D99258: [OpenCL] Fix AST check in address-space-templates test

2021-03-24 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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

https://reviews.llvm.org/D99258

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


[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-24 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

khchen wrote:
> nit: skip the temporary file and remove +experimental-zfh and 
> -fallow-half-arguments-and-returns.
Can we please stop putting ASM tests in Clang, and if they really are needed, 
splitting them out into their own files separate from the IR tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


[clang] cfc36bf - [clang] Treat variable-length array of incomplete element type as

2021-03-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-03-24T14:22:15+01:00
New Revision: cfc36bf0179435ecbd489761bd7d5dae00846c87

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

LOG: [clang] Treat variable-length array of incomplete element type as
incomplete type.

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

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 51289ce45ab9..611c30d9c767 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@ bool Type::isIncompleteType(NamedDecl **Def) const {
 return !Rec->isCompleteDefinition();
   }
   case ConstantArray:
+  case VariableArray:
 // An array is incomplete if its element type is incomplete
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).
+// We don't handle dependent-sized arrays (dependent types are never 
treated
+// as incomplete).
 return cast(CanonicalType)->getElementType()
  ->isIncompleteType(Def);
   case IncompleteArray:

diff  --git a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp 
b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
index 7a7b92b7d04f..94fee530aea6 100644
--- a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,10 @@ namespace array_addressof {
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in 
scalar initializer}}
 }
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+  Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}



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


[PATCH] D99165: [clang] Treat variable-length array of incomplete element type as incomplete type.

2021-03-24 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 rGcfc36bf01794: [clang] Treat variable-length array of 
incomplete element type as (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,10 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in 
scalar initializer}}
 }
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+  Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@
 return !Rec->isCompleteDefinition();
   }
   case ConstantArray:
+  case VariableArray:
 // An array is incomplete if its element type is incomplete
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as 
incomplete).
+// We don't handle dependent-sized arrays (dependent types are never 
treated
+// as incomplete).
 return cast(CanonicalType)->getElementType()
  ->isIncompleteType(Def);
   case IncompleteArray:


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,10 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
 }
+
+namespace no_crash {
+class Foo; // expected-note {{forward declaration}}
+void test(int size) {
+  Foo array[size] = {0}; // expected-error {{variable has incomplete type}}
+}
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2229,10 +2229,11 @@
 return !Rec->isCompleteDefinition();
   }
   case ConstantArray:
+  case VariableArray:
 // An array is incomplete if its element type is incomplete
 // (C++ [dcl.array]p1).
-// We don't handle variable arrays (they're not allowed in C++) or
-// dependent-sized arrays (dependent types are never treated as incomplete).
+// We don't handle dependent-sized arrays (dependent types are never treated
+// as incomplete).
 return cast(CanonicalType)->getElementType()
  ->isIncompleteType(Def);
   case IncompleteArray:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 91f4c11 - [PowerPC] Add mprivileged option

2021-03-24 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-03-24T08:33:22-05:00
New Revision: 91f4c1113350e847397bcfa5b98d2029a5160da9

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

LOG: [PowerPC] Add mprivileged option

Add an option to tell the compiler that it can use privileged instructions.

This patch only adds the option. Backend implementation will be added in a
future patch.

Reviewed By: lei, amyk

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

Added: 
clang/test/Driver/ppc-mprivileged-support-check.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/test/Preprocessor/init-ppc64.c
llvm/lib/Target/PowerPC/PPC.td
llvm/lib/Target/PowerPC/PPCSubtarget.cpp
llvm/lib/Target/PowerPC/PPCSubtarget.h
llvm/test/CodeGen/PowerPC/future-check-features.ll

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 86167202398a2..e0881dc608f31 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3247,6 +3247,8 @@ def mmma: Flag<["-"], "mmma">, 
Group;
 def mno_mma: Flag<["-"], "mno-mma">, Group;
 def mrop_protect : Flag<["-"], "mrop-protect">,
 Group;
+def mprivileged : Flag<["-"], "mprivileged">,
+Group;
 def maix_struct_return : Flag<["-"], "maix-struct-return">,
   Group, Flags<[CC1Option]>,
   HelpText<"Return all structs in memory (PPC32 only)">;

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index c420028b3e698..0703691f4c5b3 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -68,6 +68,8 @@ bool 
PPCTargetInfo::handleTargetFeatures(std::vector &Features,
   HasMMA = true;
 } else if (Feature == "+rop-protect") {
   HasROPProtect = true;
+} else if (Feature == "+privileged") {
+  HasPrivileged = true;
 }
 // TODO: Finish this list and add an assert that we've handled them
 // all.
@@ -197,6 +199,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__MMA__");
   if (HasROPProtect)
 Builder.defineMacro("__ROP_PROTECT__");
+  if (HasPrivileged)
+Builder.defineMacro("__PRIVILEGED__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
   if (HasPCRelativeMemops)
@@ -327,6 +331,8 @@ bool PPCTargetInfo::initFeatureMap(
 
   // ROP Protect is off by default.
   Features["rop-protect"] = false;
+  // Privileged instructions are off by default.
+  Features["privileged"] = false;
 
   Features["spe"] = llvm::StringSwitch(CPU)
 .Case("8548", true)
@@ -371,6 +377,12 @@ bool PPCTargetInfo::initFeatureMap(
 return false;
   }
 
+  if (!(ArchDefs & ArchDefinePwr8) &&
+  llvm::find(FeaturesVec, "+privileged") != FeaturesVec.end()) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mprivileged" << CPU;
+return false;
+  }
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
@@ -410,6 +422,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   .Case("spe", HasSPE)
   .Case("mma", HasMMA)
   .Case("rop-protect", HasROPProtect)
+  .Case("privileged", HasPrivileged)
   .Default(false);
 }
 

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 095ce03f6fd24..1c6c63bdfa90b 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -60,6 +60,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   bool HasAltivec = false;
   bool HasMMA = false;
   bool HasROPProtect = false;
+  bool HasPrivileged = false;
   bool HasVSX = false;
   bool HasP8Vector = false;
   bool HasP8Crypto = false;

diff  --git a/clang/test/Driver/ppc-mprivileged-support-check.c 
b/clang/test/Driver/ppc-mprivileged-support-check.c
new file mode 100644
index 0..164b4d9483d32
--- /dev/null
+++ b/clang/test/Driver/ppc-mprivileged-support-check.c
@@ -0,0 +1,26 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mprivileged %s 2>&1 | FileCheck %s 
--check-prefix=HASPRIV
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mprivileged %s 2>&1 | FileCheck %s 
--check-prefix=HASPRIV
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mprivileged %s 2>&1 | FileCheck %s --check-prefix=HASPRIV
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power9 -mprivileged %s 2>&1 | FileCheck %s 
--check-prefix=HASPRIV
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mprivileged %s 2>&1 | File

[PATCH] D98364: [clangd] Use ref counted strings throughout for File Contents

2021-03-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.
Herald added a project: clang-tools-extra.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:678
   }
-  Server->addDocument(File, NewCode, 
encodeVersion(Params.textDocument.version),
-  WantDiags, Params.forceRebuild);
+  Server->addDocument(File, std::move(NewCode),
+  encodeVersion(Params.textDocument.version), WantDiags,

you're moving into a stringref here



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:214
 
-void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
+void ClangdServer::addDocument(PathRef File, StringRef Contents,
llvm::StringRef Version,

nit: we generally prefer to qualify the types, can you revert here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98364

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


[PATCH] D99193: [PowerPC] Add mprivileged option

2021-03-24 Thread Stefan Pintilie 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 rG91f4c1113350: [PowerPC] Add mprivileged option (authored by 
stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mprivileged-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -113,6 +113,7 @@
   bool HasPCRelativeMemops;
   bool HasMMA;
   bool HasROPProtect;
+  bool HasPrivileged;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -275,6 +276,7 @@
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
   bool hasROPProtect() const { return HasROPProtect; }
+  bool hasPrivileged() const { return HasPrivileged; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -88,6 +88,7 @@
   HasP9Altivec = false;
   HasMMA = false;
   HasROPProtect = false;
+  HasPrivileged = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -256,6 +256,10 @@
   SubtargetFeature<"rop-protect", "HasROPProtect", "true",
"Add ROP protect">;
 
+def FeaturePrivileged :
+  SubtargetFeature<"privileged", "HasPrivileged", "true",
+   "Add privileged instructions">;
+
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
"PredictableSelectIsExpensive",
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -567,6 +567,7 @@
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
 // PPCPWR8-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -585,6 +586,7 @@
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
 // PPCPOWER8-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPWR9 %s
 //
@@ -600,6 +602,7 @@
 // PPCPWR9:#define _ARCH_PWR7 1
 // PPCPWR9:#define _ARCH_PWR9 1
 // PPCPWR9-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR9-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER9 %s
 //
@@ -615,6 +618,7 @@
 // PPCPOWER9:#define _ARCH_PWR7 1
 // PPCPOWER9:#define _ARCH_PWR9 1
 // PPCPOWER9-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER9-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr10 -fno-signed-char < /dev/null | FileCheck -match-full-li

[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 332964.
tbaeder added a comment.

Alright, thanks for the review.


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

https://reviews.llvm.org/D97362

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot 
appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list 
cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list 
cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow 
GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation 
&&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1607,7 +1607,30 @@
 }
 
 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
- unsigned DiagID) {
+ unsigned DiagID, bool DiagnoseEmptyAttrs) 
{
+
+  if (DiagnoseEmptyAttrs && Attrs.empty() && Attrs.Range.isValid()) {
+// An attribute list has been parsed, but it was empty.
+// This is the case for [[]].
+auto &SM = PP.getSourceManager();
+auto &LangOpts = getLangOpts();
+Token FirstLSquare;
+Lexer::getRawToken(Attrs.Range.getBegin(), FirstLSquare, SM, LangOpts);
+
+if (FirstLSquare.is(tok::l_square)) {
+  llvm::Optional SecondLSquare =
+  Lexer::findNextToken(FirstLSquare.getLocation(), SM, LangOpts);
+
+  if (SecondLSquare && SecondLSquare->is(tok::l_square)) {
+// The attribute range starts with [[, but is empty. So this must
+// be [[]], which we are supposed to diagnose since
+// DiagnoseEmptyAttrs is true.
+Diag(Attrs.Range.getBegin(), DiagID) << Attrs.Range;
+return;
+  }
+}
+  }
+
   for (const ParsedAttr &AL : Attrs) {
 if (!AL.isCXX11Attribute() && !AL.isC2xAttribute())
   continue;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2639,7 +2639,8 @@
   // which standard permits but we don't supported yet, for example, attributes
   // appertain to decl specifiers.
   void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
-   unsigned DiagID);
+   unsigned DiagID,
+   bool DiagnoseEmptyAttrs = false);
 
   /// Skip C++11 and C2x attributes and return the end location of the
   /// last one.


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   g

[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 332966.
tbaeder marked 6 inline comments as done.

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

https://reviews.llvm.org/D97362

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot 
appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list 
cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list 
cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow 
GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation 
&&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1607,7 +1607,30 @@
 }
 
 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
- unsigned DiagID) {
+ unsigned DiagID, bool DiagnoseEmptyAttrs) 
{
+
+  if (DiagnoseEmptyAttrs && Attrs.empty() && Attrs.Range.isValid()) {
+// An attribute list has been parsed, but it was empty.
+// This is the case for [[]].
+auto &SM = PP.getSourceManager();
+auto &LangOpts = getLangOpts();
+Token FirstLSquare;
+Lexer::getRawToken(Attrs.Range.getBegin(), FirstLSquare, SM, LangOpts);
+
+if (FirstLSquare.is(tok::l_square)) {
+  llvm::Optional SecondLSquare =
+  Lexer::findNextToken(FirstLSquare.getLocation(), SM, LangOpts);
+
+  if (SecondLSquare && SecondLSquare->is(tok::l_square)) {
+// The attribute range starts with [[, but is empty. So this must
+// be [[]], which we are supposed to diagnose because
+// DiagnoseEmptyAttrs is true.
+Diag(Attrs.Range.getBegin(), DiagID) << Attrs.Range;
+return;
+  }
+}
+  }
+
   for (const ParsedAttr &AL : Attrs) {
 if (!AL.isCXX11Attribute() && !AL.isC2xAttribute())
   continue;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2639,7 +2639,8 @@
   // which standard permits but we don't supported yet, for example, attributes
   // appertain to decl specifiers.
   void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
-   unsigned DiagID);
+   unsigned DiagID,
+   bool DiagnoseEmptyAttrs = false);
 
   /// Skip C++11 and C2x attributes and return the end location of the
   /// last one.


Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -179,6 +179,7 @@
 struct [[]] Template t; // expected-error {{an attribute list cannot appear here}}
 struct [[]] ::template Template u; // expected-error {{an attribute list cannot appear here}}
 template struct [[]] Template; // expected-error {{an attribute list cannot appear here}}
+template struct __attribute__((pure)) Template; // We still allow GNU-style attributes here
 template <> struct [[]] Template;
 
 enum [[]] E1 {};
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1836,7 +1836,8 @@
 } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
 TUK == Sema::TUK_Declaration) {
   // This is an explicit instantiation of a class template.
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
 
   TagOrTempResult = Actions.ActOnExplicitInstantiation(
   getCurScope(), T

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-24 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0620e6f4b76a: [clang] [C++2b] [P1102] Accept lambdas without 
parameter list (). (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D98433?vs=332904&id=332967#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/FixIt/fixit-c++11.cpp
  clang/test/Parser/cxx-concepts-requires-clause.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/Parser/cxx1z-constexpr-lambdas.cpp
  clang/test/Parser/cxx2a-template-lambdas.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
===
--- clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
+++ clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
@@ -61,7 +61,10 @@
   [&] () __global {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__global'}}
   [&] () __private {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
 
-  [&] __private {} (); //expected-error{{lambda requires '()' before attribute specifier}} expected-error{{expected body of lambda expression}}
+  [&] __private {} (); // expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
+#if __cplusplus <= 202002L
+// expected-warning@-2{{lambda without a parameter clause is a C++2b extension}}
+#endif
 
   [&] () mutable __private {} ();
   [&] () __private mutable {} (); //expected-error{{expected body of lambda expression}}
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto LL0 = [] {};
+auto LL1 = []() {};
+auto LL2 = []() mutable {};
+auto LL3 = []() constexpr {};
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
+auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
+   // expected-error{{function parameter cannot be constexpr}} \
+   // expected-error{{C++ requires}} \
+   // expected-error{{expected ')'}} \
+   // expected-note{{to match this '('}} \
+   // expected-error{{expected body}} \
+   // expected-warning{{duplicate 'constexpr'}}
Index: clang/test/Parser/cxx2a-template-lambdas.cpp
===
--- clang/test/Parser/cxx2a-template-lambdas.cpp
+++ clang/test/Parser/cxx2a-template-lambdas.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
 // RUN: %clang_cc1 -std=c++2a %s -verify
 
 auto L0 = []<> { }; //expected-error {{cannot be empty}}
Index: clang/test/Parser/cxx1z-constexpr-lambdas.cpp
==

[clang] 0620e6f - [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-24 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-03-24T14:42:27+01:00
New Revision: 0620e6f4b76a9725dbd82454d58c5a68a7e47074

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

LOG: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

As an extension, accept such lambdas in previous standards with a warning.

* http://eel.is/c++draft/expr.prim.lambda
* http://wg21.link/P1102

Reviewed By: aaron.ballman

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

Added: 
clang/test/Parser/cxx2b-lambdas.cpp

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExprCXX.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
clang/test/FixIt/fixit-c++11.cpp
clang/test/Parser/cxx-concepts-requires-clause.cpp
clang/test/Parser/cxx0x-lambda-expressions.cpp
clang/test/Parser/cxx1z-constexpr-lambdas.cpp
clang/test/Parser/cxx2a-template-lambdas.cpp
clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 7957fb8b75a4..b0f9b317a020 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -949,9 +949,6 @@ def err_expected_lambda_body : Error<"expected body of 
lambda expression">;
 def warn_cxx98_compat_lambda : Warning<
   "lambda expressions are incompatible with C++98">,
   InGroup, DefaultIgnore;
-def err_lambda_missing_parens : Error<
-  "lambda requires '()' before %select{'mutable'|return type|"
-  "attribute specifier|'constexpr'|'consteval'|'requires' clause}0">;
 def err_lambda_decl_specifier_repeated : Error<
   "%select{'mutable'|'constexpr'|'consteval'}0 cannot appear multiple times in 
a lambda declarator">;
 def err_lambda_capture_misplaced_ellipsis : Error<
@@ -964,6 +961,9 @@ def err_capture_default_first : Error<
 def ext_decl_attrs_on_lambda : ExtWarn<
   "an attribute specifier sequence in this position is a C++2b extension">,
   InGroup;
+def ext_lambda_missing_parens : ExtWarn<
+  "lambda without a parameter clause is a C++2b extension">,
+  InGroup;
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "an attribute specifier sequence in this position is incompatible with C++ "
   "standards before C++2b">, InGroup, DefaultIgnore;

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index befa7709f2d9..c2e74b5a7bbd 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@ ExprResult Parser::ParseCXXIdExpression(bool 
isAddressOfOperand) {
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@ ExprResult Parser::ParseCXXIdExpression(bool 
isAddressOfOperand) {
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1249,7 +1253,6 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
   Actions.PushLambdaScope();
 
   ParsedAttributes Attr(AttrFactory);
-  SourceLocation DeclLoc = Tok.getLocation();
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
@@ -1315,11 +1318,92 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-

[clang-tools-extra] 338d162 - [clang-tidy] Ignore all spaces in the list of checks

2021-03-24 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2021-03-24T06:43:13-07:00
New Revision: 338d16275571df4d841609d7e12bcb310b3a95e6

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

LOG: [clang-tidy] Ignore all spaces in the list of checks

This diff patch fixes issue with new line character after check name and before 
comma. Also ignores all other types of spaces like TAB.

Test Plan: ninja check-clang-tools

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

Added: 

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces

Modified: 
clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/GlobList.cpp 
b/clang-tools-extra/clang-tidy/GlobList.cpp
index 43945fcdc074..863bb4672852 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -15,7 +15,7 @@ using namespace tidy;
 // Returns true if GlobList starts with the negative indicator ('-'), removes 
it
 // from the GlobList.
 static bool consumeNegativeIndicator(StringRef &GlobList) {
-  GlobList = GlobList.trim(" \r\n");
+  GlobList = GlobList.trim();
   if (GlobList.startswith("-")) {
 GlobList = GlobList.substr(1);
 return true;
@@ -27,7 +27,7 @@ static bool consumeNegativeIndicator(StringRef &GlobList) {
 // removes it and the trailing comma from the GlobList.
 static llvm::Regex consumeGlob(StringRef &GlobList) {
   StringRef UntrimmedGlob = GlobList.substr(0, GlobList.find(','));
-  StringRef Glob = UntrimmedGlob.trim(' ');
+  StringRef Glob = UntrimmedGlob.trim();
   GlobList = GlobList.substr(UntrimmedGlob.size() + 1);
   SmallString<128> RegexText("^");
   StringRef MetaChars("()^$|*+?.[]\\{}");

diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces
 
b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces
new file mode 100644
index ..4aa1f846ade6
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file-spaces
@@ -0,0 +1,9 @@
+Checks: "
+  -*
+  ,
+  hicpp-uppercase-literal-suffix
+  ,hicpp-use-auto
+
+
+  ,  hicpp-use-emplace
+"

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
index 49028d198f75..16b216a1d4f6 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -1,2 +1,8 @@
 // RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file -dump-config 
-- | FileCheck %s -check-prefix=CHECK-BASE
 // CHECK-BASE: Checks: {{.*}}hicpp-uppercase-literal-suffix
+// RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file-spaces 
--list-checks -- | FileCheck %s -check-prefix=CHECK-SPACES
+// CHECK-SPACES: Enabled checks:
+// CHECK-SPACES-NEXT: hicpp-uppercase-literal-suffix
+// CHECK-SPACES-NEXT: hicpp-use-auto
+// CHECK-SPACES-NEXT: hicpp-use-emplace
+// CHECK-SPACES-EMPTY:



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


[PATCH] D12375: [PATCH] Relax parse ordering rules for attributes

2021-03-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Note to self: D95459  was a new attempt to fix 
this, which landed in 
https://reviews.llvm.org/rG9f2c7effd7f386e95aff3358500bc30974d35b0d

Thanks for that :)


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

https://reviews.llvm.org/D12375

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


[PATCH] D99262: [analyzer] Fix dead store checker false positive

2021-03-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, steakhal, xazax.hun, ASDenysPetrov.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is common to zero-initialize not only scalar variables,
but also structs.  This is also defensive programming and
we shouldn't complain about that.

rdar://34122265


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99262

Files:
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/test/Analysis/dead-stores.c


Index: clang/test/Analysis/dead-stores.c
===
--- clang/test/Analysis/dead-stores.c
+++ clang/test/Analysis/dead-stores.c
@@ -635,3 +635,21 @@
   volatile int v;
   v = 0; // no warning
 }
+
+struct Foo {
+  int x;
+  int y;
+};
+
+struct Foo rdar34122265_getFoo(void);
+
+int rdar34122265_test_struct(int input) {
+  // This is allowed for defensive programming.
+  struct Foo foo = {0, 0};
+  if (input > 0) {
+foo = rdar34122265_getFoo();
+  } else {
+return 0;
+  }
+  return foo.x + foo.y;
+}
Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -11,17 +11,18 @@
 //
 
//===--===//
 
-#include "clang/Lex/Lexer.h"
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/SaveAndRestore.h"
 
@@ -415,6 +416,14 @@
   if (E->isEvaluatable(Ctx))
 return;
 
+  // We should also allow defensive initialization of structs.
+  if (const auto *ILE =
+  dyn_cast(E->IgnoreParenCasts()))
+if (llvm::all_of(ILE->inits(), [this](const Expr *Init) {
+  return Init->isEvaluatable(Ctx);
+}))
+  return;
+
   if (const DeclRefExpr *DRE =
   dyn_cast(E->IgnoreParenCasts()))
 if (const VarDecl *VD = dyn_cast(DRE->getDecl())) {


Index: clang/test/Analysis/dead-stores.c
===
--- clang/test/Analysis/dead-stores.c
+++ clang/test/Analysis/dead-stores.c
@@ -635,3 +635,21 @@
   volatile int v;
   v = 0; // no warning
 }
+
+struct Foo {
+  int x;
+  int y;
+};
+
+struct Foo rdar34122265_getFoo(void);
+
+int rdar34122265_test_struct(int input) {
+  // This is allowed for defensive programming.
+  struct Foo foo = {0, 0};
+  if (input > 0) {
+foo = rdar34122265_getFoo();
+  } else {
+return 0;
+  }
+  return foo.x + foo.y;
+}
Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -11,17 +11,18 @@
 //
 //===--===//
 
-#include "clang/Lex/Lexer.h"
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/SaveAndRestore.h"
 
@@ -415,6 +416,14 @@
   if (E->isEvaluatable(Ctx))
 return;
 
+  // We should also allow defensive initialization of structs.
+  if (const auto *ILE =
+  dyn_cast(E->IgnoreParenCasts()))
+if (llvm::all_of(ILE->inits(), [this](const Expr *Init) {
+  return Init->isEval

[PATCH] D98724: Fix false negative in -Wthread-safety-attributes

2021-03-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping @aaron.ballman.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98724

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


[PATCH] D98747: Thread safety analysis: Don't warn about managed locks on join points

2021-03-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98747

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


[PATCH] D98286: [Driver] Enable kernel address and memory sanitizers on FreeBSD

2021-03-24 Thread Mark Johnston via Phabricator via cfe-commits
markj updated this revision to Diff 332974.
markj added a comment.

Enable the memory sanitizer too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98286

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


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -485,8 +485,11 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
-  if (IsX86_64)
+  if (IsX86_64) {
+Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelMemory;
 Res |= SanitizerKind::Memory;
+  }
   return Res;
 }
 


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -485,8 +485,11 @@
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
   }
-  if (IsX86_64)
+  if (IsX86_64) {
+Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelMemory;
 Res |= SanitizerKind::Memory;
+  }
   return Res;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98286: [Driver] Enable kernel address and memory sanitizers on FreeBSD

2021-03-24 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson accepted this revision.
arichardson added a comment.
This revision is now accepted and ready to land.

Does it also work on AArch64?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98286

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


[PATCH] D98286: [Driver] Enable kernel address and memory sanitizers on FreeBSD

2021-03-24 Thread Mark Johnston via Phabricator via cfe-commits
markj added a comment.

In D98286#2647606 , @arichardson wrote:

> Does it also work on AArch64?

Not yet, I haven't yet ported the sanitizer runtimes (though it's on my todo 
list). ASAN requires that we specify the relative offset of the shadow map to 
the kernel map (see D98285 ), which will be 
different on arm64. But, I guess there's no harm in declaring arm64 support in 
this commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98286

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


[PATCH] D99063: [clang-format] Fix ObjC method indent after f7f9f94b

2021-03-24 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99063

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-24 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.



> Front-end alloca <256 x i32> for the local variable tile. When the return 
> value of __builtin_ia32_tileloadd64_internal is assigned to tile. Front-end 
> bitcast x86_amx to <256 x i32>. The x86_amx is the type returned from 
> __builtin_ia32_tileloadd64_internal.

Can you share a more interesting example, where the result of the load is 
actually used by a different AMX builtin? For the store example, it seems like 
conversion intrinsic + regular IR store should work.

>> With respect to the `load` issue, it is not clear to me at the moment under 
>> which circumstances regular `load` instructions are generated & interact 
>> with AMX. If `load` is used to load `x` consecutive elements, than that's 
>> fine. But if the actual intended operation is a strided load, then `load` 
>> should not be used (this has also been discussed on llvm-dev).
>
> The `load` instructions are generated because it is a vector in C language. 
> See https://gcc.godbolt.org/z/qv5jnjK48. If we use -O0, there is load 
> instruction generated. If we use -O2, the load instruction is eliminated. The 
> -O2 version is what we want. There is no <256 x i32> in the generated code.

I can't see any `load <256 x i32>` in the linked example, just a store. Could 
you check the example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99181: [analyzer] Fix crash on spaceship operator (PR47511)

2021-03-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:331
 
   // Note: LAnd, LOr, Comma are handled specially by higher-level logic.
 

steakhal wrote:
> So, there are some corner cases already.
> I can't see any way of implementing this reasonably here, as you pointed out 
> the return value of the function is not a good fit.
> 
> Shouldn't put your mock 'implementation' to a different place?
> I'm just nitpicking though.
`evalAPSInt` is called in a lot of different contexts, I don't know how else to 
ensure that it won't crash on `BO_Cmp` in all of those contexts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99181

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


[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-24 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332991.
arnamoy10 added a comment.

Rebasing on top of main


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/std2018_wrong.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -487,7 +487,8 @@
   options.features.Enable(
   Fortran::common::LanguageFeature::BackslashEscapes, true);
 } else if (arg == "-Mstandard" || arg == "-std=f95" ||
-arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy") {
+arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy" ||
+arg == "-std=f2018" || arg == "-pedantic") {
   driver.warnOnNonstandardUsage = true;
 } else if (arg == "-fopenacc") {
   options.features.Enable(Fortran::common::LanguageFeature::OpenACC);
Index: flang/test/Driver/std2018_wrong.f90
===
--- /dev/null
+++ flang/test/Driver/std2018_wrong.f90
@@ -0,0 +1,12 @@
+! REQUIRES: new-flang-driver
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,28 @@
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -47,6 +47,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -96,6 +98,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -47,6 +47,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
 ! CHECK-NEXT: -Xflang   Pass  to the f

[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-24 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332997.
arnamoy10 added a comment.

rebasing on top of main


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

https://reviews.llvm.org/D98657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/werror.f90

Index: flang/test/Driver/werror.f90
===
--- /dev/null
+++ flang/test/Driver/werror.f90
@@ -0,0 +1,27 @@
+! Ensure argument -Werror work as expected.
+! TODO: Modify test cases in test/Semantics/ related to f18 when -std= is upstreamed
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -Werror %s  2>&1 | FileCheck %s --check-prefix=WITH
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+
+!-
+! EXPECTED OUTPUT WITH -Werror
+!-
+! WITH: Semantic errors in
+
+!-
+! EXPECTED OUTPUT WITHOUT -Werror
+!-
+! WITHOUT-NOT: Semantic errors in
+
+PROGRAM werror
+REAL, DIMENSION(20, 10) :: A
+FORALL (J=1:N)  A(I, I) = 1
+END PROGRAM werror
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -49,6 +49,7 @@
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
+! HELP-NEXT: -WEnable the specified warning
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
@@ -99,6 +100,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
 ! EXPECTED ERROR
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -49,6 +49,7 @@
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
+! CHECK-NEXT: -WEnable the specified warning
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -64,7 +64,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -97,7 +99,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -109,7 +113,9 @@
   // Parse. In case of failure, report and return.
   ci.parsing().Parse(llvm::outs());
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not parse %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -264,7 +270,9 @@
   // Parse. In case of failure, report and return.
   ci.parsing().Parse(llvm::outs());
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().w

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

Thank you for updating this @arnamoy10!

One thing worth pointing out - this patch adds `-pedantic` rather than 
`-fpendatic` as @richard.barton.arm suggested. That was clearly a typo, so 
everything is good.

IMO this is ready to land provided that:

- the test is updated to work with `f18`
- summary/commit message is updated to reflect the recent changes (i.e. that 
this patch adds `-std=f2018` AND `-pedantic`)

These are small changes and I'm happy for you to apply them when merging 
(rather than updating here first).




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:375
+
+  //-fpedantic
+  if (args.hasArg(clang::driver::options::OPT_pedantic)) {

[nit] `-pedantic` instead



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:535
+
+  // Set the standard
+  if (enableConformanceChecks()) {

[nit] Comment inconsistent with the code (no standard is set here)



Comment at: flang/test/Driver/std2018.f90:6-8
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN

`flang-new -fc1` (akin to `clang- cc1`), runs `-fsyntax-only` when no other 
action flag is specified. `f18` will go straight into code-generation. As such, 
this test fails for `f18`. Adding `-fsyntax-only` should fix it. It will also 
make the test a bit more clearer.


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

https://reviews.llvm.org/D97119

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


[PATCH] D99200: [SystemZ][z/OS] JSON file should be text files

2021-03-24 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth 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/D99200/new/

https://reviews.llvm.org/D99200

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Could you also update the switch statement in LLDB here: 
`llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:472` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96771

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-03-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Pushed the most minimal fix in 
https://github.com/llvm/llvm-project/commit/41454c30f6a38c3e107d857e63da0561610fd141,
 please double check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96771

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


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 333010.
sdesmalen added a comment.

Moved error reporting to llvm::reportInvalidSizeRequest in TypeSize.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TypeSize.cpp
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp

Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -180,7 +180,8 @@
   // Check convenience size scaling methods.
   EXPECT_EQ(v2i32.getSizeInBits() * 2, v4i32.getSizeInBits());
   EXPECT_EQ(2 * nxv2i32.getSizeInBits(), nxv4i32.getSizeInBits());
-  EXPECT_EQ(nxv2f64.getSizeInBits() / 2, nxv2i32.getSizeInBits());
+  EXPECT_EQ(nxv2f64.getSizeInBits().divideCoefficientBy(2),
+nxv2i32.getSizeInBits());
 }
 
 } // end anonymous namespace
Index: llvm/lib/Support/TypeSize.cpp
===
--- /dev/null
+++ llvm/lib/Support/TypeSize.cpp
@@ -0,0 +1,41 @@
+//===- TypeSize.cpp - Wrapper around type sizes--*- C++ -*-===//
+//
+// 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 "llvm/Support/TypeSize.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
+/// using the wrong interface on a scalable vector.
+cl::opt ScalableErrorAsWarning(
+"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
+cl::desc("Treat issues where a fixed-width property is requested from a "
+ "scalable type as a warning, instead of an error."),
+cl::ZeroOrMore);
+
+void llvm::reportInvalidSizeRequest(const char *Msg) {
+#ifndef STRICT_FIXED_SIZE_VECTORS
+  if (ScalableErrorAsWarning) {
+WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
+ << "\n";
+return;
+  }
+#endif
+  report_fatal_error("Invalid size request on a scalable vector.");
+}
+
+TypeSize::operator TypeSize::ScalarTy() const {
+  if (isScalable()) {
+reportInvalidSizeRequest(
+"Cannot implicitly convert a scalable size to a fixed-width size in "
+"`TypeSize::operator ScalarTy()`");
+return getKnownMinValue();
+  }
+  return getFixedValue();
+}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -185,6 +185,7 @@
   TrigramIndex.cpp
   Triple.cpp
   Twine.cpp
+  TypeSize.cpp
   Unicode.cpp
   UnicodeCaseFold.cpp
   VersionTuple.cpp
Index: llvm/lib/CodeGen/ValueTypes.cpp
===
--- llvm/lib/CodeGen/ValueTypes.cpp
+++ llvm/lib/CodeGen/ValueTypes.cpp
@@ -14,6 +14,18 @@
 #include "llvm/Support/TypeSize.h"
 using namespace llvm;
 
+unsigned EVT::getVectorNumElements() const {
+  assert(isVector() && "Invalid vector type!");
+
+  if (isScalableVector())
+llvm::reportInvalidSizeRequest(
+"Possible incorrect use of EVT::getVectorNumElements() for "
+"scalable vector. Scalable flag may be dropped, use "
+"EVT::getVectorElementCount() instead");
+
+  return isSimple() ? V.getVectorNumElements() : getExtendedVectorNumElements();
+}
+
 EVT EVT::changeExtendedTypeToInteger() const {
   assert(isExtended() && "Type is not extended!");
   LLVMContext &Context = LLVMTy->getContext();
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4847,8 +4847,8 @@
 assert(VT.isVector() && "This DAG node is restricted to vector types.");
 assert(Operand.getValueType().bitsLE(VT) &&
"The input must be the same size or smaller than the result.");
-assert(VT.getVectorNumElements() <
- Operand.getValueType().getVectorNumElements() &&
+assert(VT.getVectorMinNumElements() <
+   Operand.getValueType().getVectorMinNumElements() &&
"The destination vector type must have fewer lanes than the input.");
 break;
   case ISD::ABS:
Index: llvm/lib/Analysis/InstructionSimplify.cpp

[PATCH] D99227: [Coroutine][Clang] Force emit lifetime intrinsics for Coroutines

2021-03-24 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D99227#2646819 , @rjmccall wrote:

> Is it feasible to outline the initial segment that you don't want to be part 
> of the coroutine, and then have coroutine splitting force that outlined 
> function to be inlined into the ramp function?  IIUC, you were saying that 
> the splitting patch was difficult, but maybe thinking about it as outlining 
> simplifies things.  I know we had some nasty representational problems with 
> the async lowering that we solved with outlining and force-inlining.

That's a good idea. I will think about it. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99227

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


[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I see that `-Werror` changes the behavior of the driver in 5 different places. 
I would hope to see  5 new tests to verify each case.




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:353-354
 
+/// Parses all semantic related arguments and populates the variables
+/// options accordingly.
+static void parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args) {

Please update



Comment at: flang/lib/Frontend/FrontendActions.cpp:67-69
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {

Please add a test for this change.



Comment at: flang/lib/Frontend/FrontendActions.cpp:102-104
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {

Please add a test for this change.



Comment at: flang/lib/Frontend/FrontendActions.cpp:116-118
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {

Please add a test for this change.



Comment at: flang/lib/Frontend/FrontendActions.cpp:273-275
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {

Please add a test for this change.



Comment at: flang/test/Driver/werror.f90:11-12
+!-
+! RUN: not %flang_fc1 -Werror %s  2>&1 | FileCheck %s --check-prefix=WITH
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+

Does this work for `f18`?


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

https://reviews.llvm.org/D98657

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


[PATCH] D98505: [clangd] Propagate data in diagnostics

2021-03-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.h:58
+  /// If true, Clangd will populate the data field in LSP diagnostic
+  /// representation. This is used to prevent extra data transfer with old
+  /// clients that doesn't support data field.

sammccall wrote:
> Second sentence is confusing because of inverted sense. And really I don't 
> think the reason is that we don't want to send extra data, but rather the 
> fear that old clients will choke on it.
> 
> If we're *not* afraid of that, i.e. we think they'll just drop it on the 
> floor, then I don't think we should bother to feature-detect it just so *we* 
> can drop it on the floor.
> Not sure how you feel about this, but it's pretty tempting to me...
as discussed offline dropping this completely. since we don't really guard 
against adding "extra" properties to objects, and the worst that could happen 
is clangd won't surface a particular tweak on clients without support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98505

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


[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

jrtc27 wrote:
> khchen wrote:
> > nit: skip the temporary file and remove +experimental-zfh and 
> > -fallow-half-arguments-and-returns.
> Can we please stop putting ASM tests in Clang, and if they really are needed, 
> splitting them out into their own files separate from the IR tests?
For more background, this approach was copied from AArch64 SVE where they said 
this was beneficial to catch warnings from TypeSize's implicit conversion to 
uint64_t.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


[PATCH] D98724: Fix false negative in -Wthread-safety-attributes

2021-03-24 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, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98724

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


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5052-5055
+  if (isa(JA)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
+  }

paulwalker-arm wrote:
> Are there any concerns related to LTO here? Could we live with LTO triggering 
> errors for the invalid uses?  Part of me thinks this is reasonable given the 
> clang exception is more about ensuring we can continue active development 
> until we're ready to press the "it's supported" switch.
> Are there any concerns related to LTO here?
Yes, probably.

> Could we live with LTO triggering errors for the invalid uses? Part of me 
> thinks this is reasonable given the clang exception is more about ensuring we 
> can continue active development until we're ready to press the "it's 
> supported" switch.
Yes, that's my thinking about this as well. When the compiler is ready  to be 
used in production, then an actual runtime compiler error (the default) would 
be appropriate which would lead to a bug-report that'd we need to go off and 
fix. During development of scalable vector support, we just want to have some 
extra flexibility, because we know not all code-paths are covered. So while we 
use it for those purposes, the recommendation is not to use LTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

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


[PATCH] D99274: [analyzer] Fix crash when reasoning about C11 atomics (PR49422)

2021-03-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, steakhal, xazax.hun, ASDenysPetrov.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, jfb, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rdar://75020762


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99274

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/test/Analysis/atomics.c


Index: clang/test/Analysis/atomics.c
===
--- clang/test/Analysis/atomics.c
+++ clang/test/Analysis/atomics.c
@@ -93,3 +93,11 @@
   clang_analyzer_eval(s->refCount == 3); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(expected == 2); // expected-warning {{UNKNOWN}}
 }
+
+// PR49422
+void test_atomic_compare(int input) {
+  _Atomic(int) x = input;
+  if (x > 0) {
+// no crash
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -139,6 +139,12 @@
 
   /// Returns the type of the APSInt used to store values of the given 
QualType.
   APSIntType getAPSIntType(QualType T) const {
+// For the purposes of the analysis and constraints, we treat atomics
+// as their underlying types.
+if (const AtomicType *AT = T->getAs()) {
+  T = AT->getValueType();
+}
+
 assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T));
 return APSIntType(Ctx.getIntWidth(T),
   !T->isSignedIntegerOrEnumerationType());


Index: clang/test/Analysis/atomics.c
===
--- clang/test/Analysis/atomics.c
+++ clang/test/Analysis/atomics.c
@@ -93,3 +93,11 @@
   clang_analyzer_eval(s->refCount == 3); // expected-warning {{UNKNOWN}}
   clang_analyzer_eval(expected == 2); // expected-warning {{UNKNOWN}}
 }
+
+// PR49422
+void test_atomic_compare(int input) {
+  _Atomic(int) x = input;
+  if (x > 0) {
+// no crash
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -139,6 +139,12 @@
 
   /// Returns the type of the APSInt used to store values of the given QualType.
   APSIntType getAPSIntType(QualType T) const {
+// For the purposes of the analysis and constraints, we treat atomics
+// as their underlying types.
+if (const AtomicType *AT = T->getAs()) {
+  T = AT->getValueType();
+}
+
 assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T));
 return APSIntType(Ctx.getIntWidth(T),
   !T->isSignedIntegerOrEnumerationType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 333018.
sdesmalen marked 5 inline comments as done.
sdesmalen added a comment.

Moved implementation of EVT::getVectorNumElements back to header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TypeSize.cpp
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp

Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -180,7 +180,8 @@
   // Check convenience size scaling methods.
   EXPECT_EQ(v2i32.getSizeInBits() * 2, v4i32.getSizeInBits());
   EXPECT_EQ(2 * nxv2i32.getSizeInBits(), nxv4i32.getSizeInBits());
-  EXPECT_EQ(nxv2f64.getSizeInBits() / 2, nxv2i32.getSizeInBits());
+  EXPECT_EQ(nxv2f64.getSizeInBits().divideCoefficientBy(2),
+nxv2i32.getSizeInBits());
 }
 
 } // end anonymous namespace
Index: llvm/lib/Support/TypeSize.cpp
===
--- /dev/null
+++ llvm/lib/Support/TypeSize.cpp
@@ -0,0 +1,41 @@
+//===- TypeSize.cpp - Wrapper around type sizes--*- C++ -*-===//
+//
+// 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 "llvm/Support/TypeSize.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
+/// using the wrong interface on a scalable vector.
+cl::opt ScalableErrorAsWarning(
+"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
+cl::desc("Treat issues where a fixed-width property is requested from a "
+ "scalable type as a warning, instead of an error."),
+cl::ZeroOrMore);
+
+void llvm::reportInvalidSizeRequest(const char *Msg) {
+#ifndef STRICT_FIXED_SIZE_VECTORS
+  if (ScalableErrorAsWarning) {
+WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
+ << "\n";
+return;
+  }
+#endif
+  report_fatal_error("Invalid size request on a scalable vector.");
+}
+
+TypeSize::operator TypeSize::ScalarTy() const {
+  if (isScalable()) {
+reportInvalidSizeRequest(
+"Cannot implicitly convert a scalable size to a fixed-width size in "
+"`TypeSize::operator ScalarTy()`");
+return getKnownMinValue();
+  }
+  return getFixedValue();
+}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -185,6 +185,7 @@
   TrigramIndex.cpp
   Triple.cpp
   Twine.cpp
+  TypeSize.cpp
   Unicode.cpp
   UnicodeCaseFold.cpp
   VersionTuple.cpp
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4847,8 +4847,8 @@
 assert(VT.isVector() && "This DAG node is restricted to vector types.");
 assert(Operand.getValueType().bitsLE(VT) &&
"The input must be the same size or smaller than the result.");
-assert(VT.getVectorNumElements() <
- Operand.getValueType().getVectorNumElements() &&
+assert(VT.getVectorMinNumElements() <
+   Operand.getValueType().getVectorMinNumElements() &&
"The destination vector type must have fewer lanes than the input.");
 break;
   case ISD::ABS:
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4332,7 +4332,10 @@
   if (Q.isUndefValue(Ops[0]))
 return UndefValue::get(GEPTy);
 
-  bool IsScalableVec = isa(SrcTy);
+  bool IsScalableVec =
+  isa(SrcTy) || any_of(Ops, [](const Value *V) {
+return isa(V->getType());
+  });
 
   if (Ops.size() == 2) {
 // getelementptr P, 0 -> P.
Index: llvm/include/llvm/Support/TypeSize.h
===
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -27,6 +27,10 @@
 
 namespace llvm {
 
+/// Reports a diagnostic message to indicate a invalid size request has been
+/// done on a scalable vector. This function may not return.
+void reportI

[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/lib/CodeGen/ValueTypes.cpp:17
 
+unsigned EVT::getVectorNumElements() const {
+  auto Error = []() {

ctetreau wrote:
> Out of curiosity, what is the eventual plan for this function? Does it go 
> away, or will it just assert if this is a scalable vector?
The eventual plan is for this function to go away, so we just have a single 
getElementCount interface, although this hasn't really been discussed yet.
We could also end up renaming it to `getFixedVectorNumElements` for 
convenience, at which point it always asserts if it is scalable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

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


[PATCH] D98747: Thread safety analysis: Don't warn about managed locks on join points

2021-03-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'd really like to hear from @delesley about these changes, specifically 
because of this bit:

> the primary goal of the Thread safety analysis is not to find double locks 
> but race conditions.

I believe the primary goal of TSA is to find threading-related issues that can 
be caught at compile time which includes both double locks and race conditions, 
and I don't have a good feel for whether these changes have a larger impact on 
the overall design or not.

As far as the changes in the patch go, they look reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98747

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


[PATCH] D99235: [HIP] Change to code object v4

2021-03-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:116
+  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {

We do not do it for v2/v3. Could you elaborate on what makes v4 special that it 
needs its own offload kind? 

Will you need to target different object versions simultaneously?
If yes, how? AFAICT, the version specified is currently global and applies to 
all sub-compilations.
If not, then do we really need to encode the version in the offload target name?


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

https://reviews.llvm.org/D99235

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


[PATCH] D99278: [clang][parser] Allow GNU-style attributes in struct declarations

2021-03-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, rsmith, rjmccall.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Sorry for the title, I'm not 100% sure that's even correct here.

This call to `ProhibitAttributes()` is dead code in the case of GNU-style 
attributes. They are needed in e.g. 
`clang/test/Parser/objcbridge-related-attribute.m`.

However, adding a `&& !getLangOpts().ObjC` to the if statement just before is 
also not sufficient since clang expects to parse GNU-style attributes at this 
place without diagnosing them as well, for example in 
`clang/test/Sema/struct-decl.c:71`. This ends up diagnosing the wrongly-placed 
`noreturn` attribute at a later stage.

Once `ProhibitAttributes()` works with GNU-style attributes the cases mentioned 
above (and tons of other cases) are being diagnosed as incorrect.

This change depends on https://reviews.llvm.org/D97362 landing first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99278

Files:
  clang/lib/Parse/ParseDeclCXX.cpp


Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1933,7 +1933,7 @@
TemplateParams ? TemplateParams->size() : 0));
   } else {
 if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /* 
DiagnoseEmptyAttrs=*/true);
 
 if (TUK == Sema::TUK_Definition &&
 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {


Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1933,7 +1933,7 @@
TemplateParams ? TemplateParams->size() : 0));
   } else {
 if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /* DiagnoseEmptyAttrs=*/true);
 
 if (TUK == Sema::TUK_Definition &&
 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a6a1c30 - Fix false negative in -Wthread-safety-attributes

2021-03-24 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-03-24T17:45:25+01:00
New Revision: a6a1c3051dbd2cc5ccc70272890cf38d11dca9c7

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

LOG: Fix false negative in -Wthread-safety-attributes

The original implementation didn't fire on non-template classes when a
base class was an instantiation of a template with a dependent base.
In that case the base of the base is dependent as seen from the base,
but not from the class we're interested in, which isn't a template.

Also it simplifies the code a lot.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaCXX/warn-thread-safety-parsing.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c4901042c042..b39460d33214 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -513,16 +513,9 @@ static bool checkRecordDeclForAttr(const RecordDecl *RD) {
 
   // Else check if any base classes have the attribute.
   if (const auto *CRD = dyn_cast(RD)) {
-CXXBasePaths BPaths(false, false);
-if (CRD->lookupInBases(
-[](const CXXBaseSpecifier *BS, CXXBasePath &) {
-  const auto &Ty = *BS->getType();
-  // If it's type-dependent, we assume it could have the attribute.
-  if (Ty.isDependentType())
-return true;
-  return Ty.castAs()->getDecl()->hasAttr();
-},
-BPaths, true))
+if (!CRD->forallBases([](const CXXRecordDecl *Base) {
+  return !Base->hasAttr();
+}))
   return true;
   }
   return false;

diff  --git a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp 
b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
index 6ad0f877a11d..b6e9c052a241 100644
--- a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1295,6 +1295,11 @@ struct SLDerived2 : public SLTemplateClass {
 // expected-warning{{'unlock_function' attribute without capability 
arguments refers to 'this', but 'SLDerived2' isn't annotated with 'capability' 
or 'scoped_lockable' attribute}}
 };
 
+struct SLDerived3 : public SLTemplateDerived {
+  ~SLDerived3() UNLOCK_FUNCTION(); // \
+// expected-warning{{'unlock_function' attribute without capability 
arguments refers to 'this', but 'SLDerived3' isn't annotated with 'capability' 
or 'scoped_lockable' attribute}}
+};
+
 //-
 // Parsing of member variables and function parameters
 //--



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


[PATCH] D98724: Fix false negative in -Wthread-safety-attributes

2021-03-24 Thread Aaron Puchert 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 rGa6a1c3051dbd: Fix false negative in 
-Wthread-safety-attributes (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98724

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/warn-thread-safety-parsing.cpp


Index: clang/test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ clang/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1295,6 +1295,11 @@
 // expected-warning{{'unlock_function' attribute without capability 
arguments refers to 'this', but 'SLDerived2' isn't annotated with 'capability' 
or 'scoped_lockable' attribute}}
 };
 
+struct SLDerived3 : public SLTemplateDerived {
+  ~SLDerived3() UNLOCK_FUNCTION(); // \
+// expected-warning{{'unlock_function' attribute without capability 
arguments refers to 'this', but 'SLDerived3' isn't annotated with 'capability' 
or 'scoped_lockable' attribute}}
+};
+
 //-
 // Parsing of member variables and function parameters
 //--
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -513,16 +513,9 @@
 
   // Else check if any base classes have the attribute.
   if (const auto *CRD = dyn_cast(RD)) {
-CXXBasePaths BPaths(false, false);
-if (CRD->lookupInBases(
-[](const CXXBaseSpecifier *BS, CXXBasePath &) {
-  const auto &Ty = *BS->getType();
-  // If it's type-dependent, we assume it could have the attribute.
-  if (Ty.isDependentType())
-return true;
-  return Ty.castAs()->getDecl()->hasAttr();
-},
-BPaths, true))
+if (!CRD->forallBases([](const CXXRecordDecl *Base) {
+  return !Base->hasAttr();
+}))
   return true;
   }
   return false;


Index: clang/test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ clang/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1295,6 +1295,11 @@
 // expected-warning{{'unlock_function' attribute without capability arguments refers to 'this', but 'SLDerived2' isn't annotated with 'capability' or 'scoped_lockable' attribute}}
 };
 
+struct SLDerived3 : public SLTemplateDerived {
+  ~SLDerived3() UNLOCK_FUNCTION(); // \
+// expected-warning{{'unlock_function' attribute without capability arguments refers to 'this', but 'SLDerived3' isn't annotated with 'capability' or 'scoped_lockable' attribute}}
+};
+
 //-
 // Parsing of member variables and function parameters
 //--
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -513,16 +513,9 @@
 
   // Else check if any base classes have the attribute.
   if (const auto *CRD = dyn_cast(RD)) {
-CXXBasePaths BPaths(false, false);
-if (CRD->lookupInBases(
-[](const CXXBaseSpecifier *BS, CXXBasePath &) {
-  const auto &Ty = *BS->getType();
-  // If it's type-dependent, we assume it could have the attribute.
-  if (Ty.isDependentType())
-return true;
-  return Ty.castAs()->getDecl()->hasAttr();
-},
-BPaths, true))
+if (!CRD->forallBases([](const CXXRecordDecl *Base) {
+  return !Base->hasAttr();
+}))
   return true;
   }
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98505: [clangd] Propagate data in diagnostics

2021-03-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Diagnostics.h:77
+  // list.
+  std::vector OpaqueData;
 };

Hmm, you've replaced the json::Array with an array of objects :-)
Any reason we can't just use llvm::json::Object here?

We don't really handle conflicts anyway, and I don't think having one tweak 
read another one's data out of this field is a real concern.



Comment at: clang-tools-extra/clangd/Protocol.cpp:616
+  if (auto *Data = Params.getAsObject()->getObject("data"))
+R.data = std::move(*Data);
+  return O.map("range", R.range) && O.map("message", R.message) &&

std::move is a fancy way to spell copy here, since Params is const.

json::Value(*Data) (or can you just use mapOptOrNull?)



Comment at: clang-tools-extra/clangd/Protocol.h:413
+  /// textDocument.publishDiagnostics.dataSupport
+  bool DiagnosticDataSupport = false;
+

this is now unused



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:71
+/// Diagnostics related to this selection.
+llvm::ArrayRef Diags;
 // FIXME: provide a way to get sources and ASTs for other files.

unrelated?
(well not quite, but neither populated or used in this patch)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98505

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


[PATCH] D99280: [OPENMP]Fix PR48571: critical/master in outlined contexts cause crash.

2021-03-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

If emit inlined region for master/critical directives, no need to clear
lambda/block context data, otherwise the variables cannot be found and
it causes a crash at compile time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99280

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp

Index: clang/test/OpenMP/master_codegen.cpp
===
--- clang/test/OpenMP/master_codegen.cpp
+++ clang/test/OpenMP/master_codegen.cpp
@@ -55,6 +55,41 @@
   return a;
 }
 
+// ALL-LABEL:lambda_master
+// TERM_DEBUG-LABEL: lambda_master
+void lambda_master(int a, int b) {
+  auto l = [=]() {
+#pragma omp master
+{
+  // ALL: call i32 @__kmpc_master(
+  int c = a + b;
+}
+  };
+
+  l();
+
+  auto l1 = [=]() {
+#pragma omp parallel
+#pragma omp master
+{
+  // ALL: call i32 @__kmpc_master(
+  int c = a + b;
+}
+  };
+
+  l1();
+
+  auto l2 = [=]() {
+#pragma omp parallel master
+{
+  // ALL: call i32 @__kmpc_master(
+  int c = a + b;
+}
+  };
+
+  l2();
+}
+
 // ALL-LABEL:  parallel_master
 // TERM_DEBUG-LABEL: parallel_master
 void parallel_master() {
Index: clang/test/OpenMP/critical_codegen.cpp
===
--- clang/test/OpenMP/critical_codegen.cpp
+++ clang/test/OpenMP/critical_codegen.cpp
@@ -68,6 +68,31 @@
   return a;
 }
 
+// ALL-LABEL:lambda_critical
+// TERM_DEBUG-LABEL: lambda_critical
+void lambda_critical(int a, int b) {
+  auto l = [=]() {
+#pragma omp critical
+{
+  // ALL: call void @__kmpc_critical(
+  int c = a + b;
+}
+  };
+
+  l();
+
+  auto l1 = [=]() {
+#pragma omp parallel
+#pragma omp critical
+{
+  // ALL: call void @__kmpc_critical(
+  int c = a + b;
+}
+  };
+
+  l1();
+}
+
 struct S {
   int a;
 };
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -409,6 +409,7 @@
   llvm::DenseMap LambdaCaptureFields;
   FieldDecl *LambdaThisCaptureField = nullptr;
   const CodeGen::CGBlockInfo *BlockInfo = nullptr;
+  bool NoInheritance = false;
 
 public:
   /// Constructs region for combined constructs.
@@ -416,16 +417,19 @@
   /// a list of functions used for code generation of implicitly inlined
   /// regions.
   InlinedOpenMPRegionRAII(CodeGenFunction &CGF, const RegionCodeGenTy &CodeGen,
-  OpenMPDirectiveKind Kind, bool HasCancel)
-  : CGF(CGF) {
+  OpenMPDirectiveKind Kind, bool HasCancel,
+  bool NoInheritance = true)
+  : CGF(CGF), NoInheritance(NoInheritance) {
 // Start emission for the construct.
 CGF.CapturedStmtInfo = new CGOpenMPInlinedRegionInfo(
 CGF.CapturedStmtInfo, CodeGen, Kind, HasCancel);
-std::swap(CGF.LambdaCaptureFields, LambdaCaptureFields);
-LambdaThisCaptureField = CGF.LambdaThisCaptureField;
-CGF.LambdaThisCaptureField = nullptr;
-BlockInfo = CGF.BlockInfo;
-CGF.BlockInfo = nullptr;
+if (NoInheritance) {
+  std::swap(CGF.LambdaCaptureFields, LambdaCaptureFields);
+  LambdaThisCaptureField = CGF.LambdaThisCaptureField;
+  CGF.LambdaThisCaptureField = nullptr;
+  BlockInfo = CGF.BlockInfo;
+  CGF.BlockInfo = nullptr;
+}
   }
 
   ~InlinedOpenMPRegionRAII() {
@@ -434,9 +438,11 @@
 cast(CGF.CapturedStmtInfo)->getOldCSI();
 delete CGF.CapturedStmtInfo;
 CGF.CapturedStmtInfo = OldCSI;
-std::swap(CGF.LambdaCaptureFields, LambdaCaptureFields);
-CGF.LambdaThisCaptureField = LambdaThisCaptureField;
-CGF.BlockInfo = BlockInfo;
+if (NoInheritance) {
+  std::swap(CGF.LambdaCaptureFields, LambdaCaptureFields);
+  CGF.LambdaThisCaptureField = LambdaThisCaptureField;
+  CGF.BlockInfo = BlockInfo;
+}
   }
 };
 
@@ -3857,7 +3863,7 @@
   // Processing for implicitly captured variables.
   InlinedOpenMPRegionRAII Region(
   CGF, [](CodeGenFunction &, PrePostActionTy &) {}, OMPD_unknown,
-  /*HasCancel=*/false);
+  /*HasCancel=*/false, /*NoInheritance=*/true);
   SharedRefLValue = CGF.EmitLValue(Pair.second.OriginalRef);
 }
 if (Type->isArrayType()) {
@@ -6218,7 +6224,9 @@
bool HasCancel) {
   if (!CGF.HaveInsertPoint())
 return;
-  InlinedOpenMPRegionRAII Region(CGF, CodeGen, InnerKind, HasCancel);
+  InlinedOpenMPRegionRAII Region(CGF, CodeGen, InnerKind, HasCancel,
+ InnerKind != O

[PATCH] D98538: [clangd] Perform merging for stale symbols in MergeIndex

2021-03-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/Merge.cpp:59
+
+  bool DynamicIndexIsAuthoritative =
+  // We expect the definition to see the canonical declaration, so it

this bool seems complicated enough & duplicated that you could consider pulling 
out

static bool indexIsAuthoritative(const SymbolIndex::IndexedFiles&, const Symbol 
&S);

(The IndexedFiles typedef doesn't exist, but it should!)



Comment at: clang-tools-extra/clangd/index/Merge.cpp:67
+  // index is stale just drop the symbol.
+  if (DynamicIndexIsAuthoritative)
 return;

we could SPAN_ATTACH a counter for this too, e.g. static_dropped

(and possibly hoist ++StaticCount to the top, static_dropped can be a subset)



Comment at: clang-tools-extra/clangd/unittests/IndexTests.cpp:318
+  // Even though the definition is actually deleted in the newer version of the
+  // file, we still chose to merge with information coming from static index.
   LookupRequest LookupReq;

Bah, this is actually incorrect, for the given example, right? We point to a 
definition that doesn't exist, in a file where the index is up to date.
Can we at least hint why we do this?
("This seems wrong, but is generic behavior we want for e.g. include headers 
which are always missing from the dynamic index")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98538

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


[PATCH] D99274: [analyzer] Fix crash when reasoning about C11 atomics (PR49422)

2021-03-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal 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/D99274/new/

https://reviews.llvm.org/D99274

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


[PATCH] D99280: [OPENMP]Fix PR48571: critical/master in outlined contexts cause crash.

2021-03-24 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.

LG, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99280

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


[PATCH] D99151: [RISCV][Clang] Add RVV vleff intrinsic functions.

2021-03-24 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle16ff.c:9
+// RUN:   -target-feature +experimental-zfh -target-feature +m 
-fallow-half-arguments-and-returns -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+

craig.topper wrote:
> jrtc27 wrote:
> > khchen wrote:
> > > nit: skip the temporary file and remove +experimental-zfh and 
> > > -fallow-half-arguments-and-returns.
> > Can we please stop putting ASM tests in Clang, and if they really are 
> > needed, splitting them out into their own files separate from the IR tests?
> For more background, this approach was copied from AArch64 SVE where they 
> said this was beneficial to catch warnings from TypeSize's implicit 
> conversion to uint64_t.
You can have the ASM tests in a separate .test file though so you can still run 
the IR tests without the backend if there's value in having the end-to-end tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99151

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


  1   2   >