[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:6682
+  /// The outermost level of selector sets.
+  llvm::SmallVector Sets;
+

jdoerfert wrote:
> rnk wrote:
> > This is not a good data structure choice. You have three levels of small 
> > vector nesting, so sizeof OMPTraitInfo is 880 bytes, and then you are 
> > passing it by value in in some of the attribute classes. Are you sure you 
> > wanted to do that?
> I could make them all 0 elements long, reducing the size quite a bit for the 
> common case of very few trait sets/selectors/properties. I could also try to 
> dynamically allocate them once. WDYT?
One way of fixing this is D76173


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71830



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


[PATCH] D71179: [OpenMP][WIP] Initial support for `begin/end declare variant`

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

D75779  is the proper implementation of the 
OpenMP standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71179



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


[PATCH] D71241: [OpenMP][WIP] Use overload centric declare variants

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert abandoned this revision.
jdoerfert added a comment.

D75779  is the proper implementation of the 
OpenMP standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71241



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


[PATCH] D75001: [OpenMP][cmake] ignore warning on unknown CUDA version

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D75001#1891284 , @Hahnfeld wrote:

> In D75001#1887876 , @jdoerfert wrote:
>
> > I like this way better. I was hoping we could do it in our cmake only :)
> >
> > Give others a day or so to comment before your commit but I'm fine with 
> > this.
>
>
> Well, that doesn't really work if `openmp-commits` is only subscribed on 
> commit. That said, the solution is a bit ugly but I don't have an alternative 
> right now.


What is the problem with `openmp-commits` here? I got the emails, didn't you?

@kkwli0 Where are we with this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75001



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


[PATCH] D76173: [OpenMP][NFC] Minimize memory usage and copying of `OMPTraitInfo`s

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: rnk.
Herald added subscribers: guansong, bollu.
Herald added a project: clang.

See rational here: https://reviews.llvm.org/D71830#1922656


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76173

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Serialization/ASTRecordReader.h
  clang/include/clang/Serialization/ASTRecordWriter.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/AttrImpl.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -107,7 +107,7 @@
   .Case("IdentifierInfo *", "Record.readIdentifier()")
   .Case("StringRef", "Record.readString()")
   .Case("ParamIdx", "ParamIdx::deserialize(Record.readInt())")
-  .Case("OMPTraitInfo", "Record.readOMPTraitInfo()")
+  .Case("OMPTraitInfo *", "Record.readOMPTraitInfo()")
   .Default("Record.readInt()");
 }
 
@@ -131,7 +131,7 @@
  .Case("StringRef", "AddString(" + std::string(name) + ");\n")
  .Case("ParamIdx",
"push_back(" + std::string(name) + ".serialize());\n")
- .Case("OMPTraitInfo",
+ .Case("OMPTraitInfo *",
"writeOMPTraitInfo(" + std::string(name) + ");\n")
  .Default("push_back(" + std::string(name) + ");\n");
 }
@@ -363,7 +363,7 @@
   OS << "if (SA->get" << getUpperName() << "().isValid())\n  ";
 OS << "OS << \" \" << SA->get" << getUpperName()
<< "().getSourceIndex();\n";
-  } else if (type == "OMPTraitInfo") {
+  } else if (type == "OMPTraitInfo *") {
 OS << "OS << \" \" << SA->get" << getUpperName() << "();\n";
   } else {
 llvm_unreachable("Unknown SimpleArgument type!");
@@ -1331,7 +1331,7 @@
   else if (ArgName == "VersionArgument")
 Ptr = std::make_unique(Arg, Attr);
   else if (ArgName == "OMPTraitInfoArgument")
-Ptr = std::make_unique(Arg, Attr, "OMPTraitInfo");
+Ptr = std::make_unique(Arg, Attr, "OMPTraitInfo *");
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6592,9 +6592,9 @@
   Record.AddSourceLocation(C->getKindKwLoc());
 }
 
-void ASTRecordWriter::writeOMPTraitInfo(const OMPTraitInfo &TI) {
-  writeUInt32(TI.Sets.size());
-  for (const auto &Set : TI.Sets) {
+void ASTRecordWriter::writeOMPTraitInfo(const OMPTraitInfo *TI) {
+  writeUInt32(TI->Sets.size());
+  for (const auto &Set : TI->Sets) {
 writeEnum(Set.Kind);
 writeUInt32(Set.Selectors.size());
 for (const auto &Selector : Set.Selectors) {
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2744,7 +2744,7 @@
 return Reader.readVersionTuple();
   }
 
-  OMPTraitInfo readOMPTraitInfo() { return Reader.readOMPTraitInfo(); }
+  OMPTraitInfo *readOMPTraitInfo() { return Reader.readOMPTraitInfo(); }
 
   template  T *GetLocalDeclAs(uint32_t LocalID) {
 return Reader.GetLocalDeclAs(LocalID);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -12630,8 +12630,8 @@
   C->setKindKwLoc(Record.readSourceLocation());
 }
 
-OMPTraitInfo ASTRecordReader::readOMPTraitInfo() {
-  OMPTraitInfo TI;
+OMPTraitInfo *ASTRecordReader::readOMPTraitInfo() {
+  OMPTraitInfo &TI = getContext().getNewOMPTraitInfo();
   TI.Sets.resize(readUInt32());
   for (auto &Set : TI.Sets) {
 Set.Kind = readEnum();
@@ -12646,5 +12646,5 @@
 Property.Kind = readEnum();
 }
   }
-  return TI;
+  return &TI;
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -398,7 +398,8 @@
 
   // Copy the template version of the OMPTraitInfo and run substitute on all
   // score and condition expressiosn.
-  OMPTraitInfo TI = Attr.getTraitInfos();
+  OMPTraitInfo &TI = S.getASTContext().getNewOMP

[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2020-03-13 Thread Ilya Mirsky via Phabricator via cfe-commits
ilya added a comment.

One last kind ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


[clang] 810794c - PR44992 Don't crash when a defaulted <=> is in a class declared in a

2020-03-13 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-13T19:30:49-07:00
New Revision: 810794ce882850a11baca35aa4ef107ee8ee7f53

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

LOG: PR44992 Don't crash when a defaulted <=> is in a class declared in a
transparent context.

(The same crash would happen if a class template with a friend was
declared in an 'export' block, but there are more issues with that
case.)

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/compare-cxx2a.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 109b64921507..875eb2bfb940 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2039,7 +2039,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
 // Look only into the namespace where the friend would be declared to
 // find a previous declaration. This is the innermost enclosing namespace,
 // as described in ActOnFriendFunctionDecl.
-SemaRef.LookupQualifiedName(Previous, DC);
+SemaRef.LookupQualifiedName(Previous, DC->getRedeclContext());
 
 // In C++, the previous declaration we find might be a tag type
 // (class or enum). In this case, the new declaration will hide the

diff  --git a/clang/test/SemaCXX/compare-cxx2a.cpp 
b/clang/test/SemaCXX/compare-cxx2a.cpp
index 46e38f787db4..a45955418c44 100644
--- a/clang/test/SemaCXX/compare-cxx2a.cpp
+++ b/clang/test/SemaCXX/compare-cxx2a.cpp
@@ -426,3 +426,9 @@ namespace Vector {
 (void)(v1 <=> v2); // expected-error {{three-way comparison between 
vectors is not supported}}
   }
 }
+
+namespace PR44992 {
+  extern "C++" struct s {
+friend auto operator<=>(s const &, s const &) = default;
+  };
+}



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


[clang] 44c3a63 - PR45063: Fix crash on invalid processing an elaborated class template-id

2020-03-13 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-13T18:53:49-07:00
New Revision: 44c3a63c74dddeef17e424ec76bd90c8582d8a3c

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

LOG: PR45063: Fix crash on invalid processing an elaborated class template-id
with an invalid scope specifier.

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/Parser/cxx-template-decl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index f7568e3b62b7..4923d0a6dad2 100755
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3814,6 +3814,9 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
 SourceLocation LAngleLoc,
 ASTTemplateArgsPtr TemplateArgsIn,
 SourceLocation RAngleLoc) {
+  if (SS.isInvalid())
+return TypeResult(true);
+
   TemplateName Template = TemplateD.get();
 
   // Translate the parser's template argument list in our AST format.

diff  --git a/clang/test/Parser/cxx-template-decl.cpp 
b/clang/test/Parser/cxx-template-decl.cpp
index cb8a93fdecb1..3d7a3dc14f4c 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -269,3 +269,7 @@ namespace AnnotateAfterInvalidTemplateId {
 
   void f() { A<0, 0>::f(); } // expected-error {{ambiguous partial 
specializations}}
 }
+
+namespace PR45063 {
+  template> struct X {}; // expected-error 
{{undeclared identifier 'a'}}
+}



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-13 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

@jdoerfert To answer your question as to why it is being codegened as shared, 
codegen doesn't handle `default` clause- at least I didn't come across such a 
thing- and if you think about it, it shouldn't need to. You either have `none` 
or `shared`:

- `none` is largly to throw diag errors - so clang either never leaves sema 
because it threw an error, or there are no errors, which suggests that the 
programmer has already listed all captured variables as other clauses. - either 
way, codegen doesn't need to handle it.
- `shared` is the default anyway, and codegen already makes any captured 
variableby the outlined function not "claimed" by any other privatization 
clause, shared - it just passes it as an arg. to the outlined function.

and Since @atmnpatel didn't add any new codegen for the `default{firstprivate}` 
case, codegen defaulted to shared - at least that's what I think happened.

@atmnpatel  The way privatization works currently in codegen, you go over every 
clause, find the list of variables for that clause, find some relevant info 
about the variable along with the proper way to initialize the variable (i.e. 
what constructor to use), and add it to list of all variables to be privatized, 
once done with all privatization clauses, you do codegen for privatization for 
all of them in one go. The exception to this is `copyin`. 
So what you may want to do is to handle the `default` clause in codegen. if 
it's `none` or `shared`, you ignore it. if it is `firstprivate` or `private`, 
find the captured variables of the soon to be outlined function that have not 
been captured by any other privatization clause, then figure a way to pass it 
to `codegenfunction::emitOMPFirstprivateClause` or  
`codegenfunction::emitPrivateClause`. Alternatively, find this list while 
building the AST, and add them as default captured variables, which will make 
codegen much easier. You are already checking for them to throw the `none` diag 
error anyway.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7087
 
+/// Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
+///

fix comment: ... has ``firstprivate`` kind ...



Comment at: clang/lib/Sema/SemaOpenMP.cpp:4993
 
   // Check variables in the clauses if default(none) was specified.
+  if (DSAStack->getDefaultDSA() == DSA_none ||

fix the comments to say firstprivate as well (here and elsewhere)



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5102
   Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable)
   << P.first << P.second->getSourceRange();
   Diag(DSAStack->getDefaultDSALocation(), diag::note_omp_default_dsa_none);

Why is `firstprivate` throwing this error? isn't the purpose of specifying it 
as `default` is if a variable is not specified as anything, then it is 
automatically handled as `firstprivate`? or am I misunderstanding something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:6682
+  /// The outermost level of selector sets.
+  llvm::SmallVector Sets;
+

rnk wrote:
> This is not a good data structure choice. You have three levels of small 
> vector nesting, so sizeof OMPTraitInfo is 880 bytes, and then you are passing 
> it by value in in some of the attribute classes. Are you sure you wanted to 
> do that?
I could make them all 0 elements long, reducing the size quite a bit for the 
common case of very few trait sets/selectors/properties. I could also try to 
dynamically allocate them once. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71830



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


[PATCH] D76169: [WIP][AST] Allow ExprConstant to evaluate structs in C.

2020-03-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added a reviewer: nickdesaulniers.
Herald added a project: clang.

Just a proof of concept to show this works.  Handles all the examples from 
D76096 , as far as I can tell.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76169

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -2084,8 +2084,7 @@
   case APValue::Union:
 return ConstStructBuilder::BuildStruct(*this, Value, DestType);
   case APValue::Array: {
-const ConstantArrayType *CAT =
-CGM.getContext().getAsConstantArrayType(DestType);
+const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
 unsigned NumElements = Value.getArraySize();
 unsigned NumInitElts = Value.getArrayInitializedElts();
 
@@ -2093,7 +2092,7 @@
 llvm::Constant *Filler = nullptr;
 if (Value.hasArrayFiller()) {
   Filler = tryEmitAbstractForMemory(Value.getArrayFiller(),
-CAT->getElementType());
+AT->getElementType());
   if (!Filler)
 return nullptr;
 }
@@ -2108,7 +2107,7 @@
 llvm::Type *CommonElementType = nullptr;
 for (unsigned I = 0; I < NumInitElts; ++I) {
   llvm::Constant *C = tryEmitPrivateForMemory(
-  Value.getArrayInitializedElt(I), CAT->getElementType());
+  Value.getArrayInitializedElt(I), AT->getElementType());
   if (!C) return nullptr;
 
   if (I == 0)
@@ -2120,6 +2119,8 @@
 
 // This means that the array type is probably "IncompleteType" or some
 // type that is not ConstantArray.
+const ConstantArrayType *CAT =
+CGM.getContext().getAsConstantArrayType(DestType);
 if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
   const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
   CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13740,14 +13740,6 @@
 return true;
   }
 
-  // FIXME: Evaluating values of large array and record types can cause
-  // performance problems. Only do so in C++11 for now.
-  if (Exp->isRValue() && (Exp->getType()->isArrayType() ||
-  Exp->getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11) {
-IsConst = false;
-return true;
-  }
   return false;
 }
 
@@ -13913,12 +13905,6 @@
   assert(!isValueDependent() &&
  "Expression evaluator can't be called on a dependent expression.");
 
-  // FIXME: Evaluating initializers for large array and record types can cause
-  // performance problems. Only do so in C++11 for now.
-  if (isRValue() && (getType()->isArrayType() || getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11)
-return false;
-
   Expr::EvalStatus EStatus;
   EStatus.Diag = &Notes;
 


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -2084,8 +2084,7 @@
   case APValue::Union:
 return ConstStructBuilder::BuildStruct(*this, Value, DestType);
   case APValue::Array: {
-const ConstantArrayType *CAT =
-CGM.getContext().getAsConstantArrayType(DestType);
+const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
 unsigned NumElements = Value.getArraySize();
 unsigned NumInitElts = Value.getArrayInitializedElts();
 
@@ -2093,7 +2092,7 @@
 llvm::Constant *Filler = nullptr;
 if (Value.hasArrayFiller()) {
   Filler = tryEmitAbstractForMemory(Value.getArrayFiller(),
-CAT->getElementType());
+AT->getElementType());
   if (!Filler)
 return nullptr;
 }
@@ -2108,7 +2107,7 @@
 llvm::Type *CommonElementType = nullptr;
 for (unsigned I = 0; I < NumInitElts; ++I) {
   llvm::Constant *C = tryEmitPrivateForMemory(
-  Value.getArrayInitializedElt(I), CAT->getElementType());
+  Value.getArrayInitializedElt(I), AT->getElementType());
   if (!C) return nullptr;
 
   if (I == 0)
@@ -2120,6 +2119,8 @@
 
 // This means that the array type is probably "IncompleteType" or some
 // type that is not ConstantArray.
+const ConstantArrayType *CAT =
+CGM.getContext().getAsConstantArrayType(DestType);
 if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
   const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
   CommonElementType = CGM.getTypes().ConvertType(AT->getElemen

[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-03-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:6682
+  /// The outermost level of selector sets.
+  llvm::SmallVector Sets;
+

This is not a good data structure choice. You have three levels of small vector 
nesting, so sizeof OMPTraitInfo is 880 bytes, and then you are passing it by 
value in in some of the attribute classes. Are you sure you wanted to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71830



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

My questions are answered, as you have the clang people in the reviewer list 
and I was only added by my OpenMP hook, I would them to OK this. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-13 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added a comment.

Yep, it is still an open issue. I am actually unsure of how to do that, and I'd 
love some pointers.

As far as default(private) goes, I am also unsure of how to do it without 
retaining the prior values of the variables. I will take a look over this 
weekend and see if I can find a workaround. All I had so far was that maybe we 
could push it alongside the implicitly firstprivate variables but reassign it 
to a null/default value before/after doing so, but I'm not certain that it's an 
ideal solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Isn't that what my patch is doing? (Codegen walking the AST/InitListExpr, 
> generating Constants)?

Yes. The issue is we we don't really want to duplicate the logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 250319.
nickdesaulniers added a comment.

- add support for compile time arrays


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/const-init.c
  clang/test/Sema/array-init.c
  clang/test/Sema/const-eval.c
  clang/test/Sema/init.c

Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -160,3 +160,36 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // expected-error {{initializer element is not a compile-time constant}}
+
+// PR45157
+struct PR4517_foo {};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {};
+struct PR4517_bar my_bar = {
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar3 = {
+my_foo, // no-warning
+};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){
+my_foo // no-warning
+};
+extern const struct PR4517_foo my_foo2;
+struct PR4517_bar my_bar5 = {
+  .foo = my_foo2, // expected-error {{initializer element is not a compile-time constant}}
+};
+int PR4517_a[2] = {0, 1};
+const int PR4517_ca[2] = {0, 1};
+int PR4517_idx = 0;
+const int PR4517_idxc = 1;
+int PR4517_x1 = PR4517_a[PR4517_idx]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_x2 = PR4517_a[PR4517_idxc]; // should error
+int PR4517_x3 = PR4517_a[0]; // should error
+int PR4517_y1 = PR4517_ca[PR4517_idx]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_y2 = PR4517_ca[PR4517_idxc]; // no-warning
+int PR4517_y3 = PR4517_ca[0]; // no-warning
Index: clang/test/Sema/const-eval.c
===
--- clang/test/Sema/const-eval.c
+++ clang/test/Sema/const-eval.c
@@ -150,5 +150,5 @@
   int arr[];
 };
 int PR35214_x;
-int PR35214_y = ((struct PR35214_X *)&PR35214_x)->arr[1]; // expected-error {{not a compile-time constant}}
+int PR35214_y = ((struct PR35214_X *)&PR35214_x)->arr[1];
 int *PR35214_z = &((struct PR35214_X *)&PR35214_x)->arr[1]; // ok, &PR35214_x + 2
Index: clang/test/Sema/array-init.c
===
--- clang/test/Sema/array-init.c
+++ clang/test/Sema/array-init.c
@@ -268,7 +268,7 @@
   };
 }
 
-char badchararray[1] = { badchararray[0], "asdf" }; // expected-warning {{excess elements in array initializer}} expected-error {{initializer element is not a compile-time constant}}
+char badchararray[1] = { badchararray[0], "asdf" }; // expected-warning {{excess elements in array initializer}}
 
 // Test the GNU extension for initializing an array from an array
 // compound literal. PR9261.
Index: clang/test/CodeGen/const-init.c
===
--- clang/test/CodeGen/const-init.c
+++ clang/test/CodeGen/const-init.c
@@ -181,3 +181,28 @@
 #pragma pack()
   // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 -12312731, i16 -312 }, align 4
 }
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar2 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar3 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar4 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+const int PR4517_arrc[2] = {41, 42};
+int PR4517_x = PR4517_arrc[1];
+const int PR4517_idx = 1;
+int PR4517_x2 = PR4517_arrc[PR4517_idx];
+// CHECK: @PR4517_arrc = constant [2 x i32] [i32 41, i32 42], align 4
+// CHECK: @PR4517_x = global i32 42, align 4
+// CHECK: @PR4517_idx = constant i32 1, align 4
+// CHECK: @PR4517_x2 = global i32 42, align 4
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1007,6 +1007,40 @@
 return Visit(PE->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitDeclRefExpr(DeclRefExpr *DRE, QualType T) {
+if (VarDecl *V = dyn_cast(DRE->getDecl()))
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;
+  }
+
+  llvm::Constant *VisitIntegerLiteral(Int

[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D76096#1922239 , @rsmith wrote:

> it's substantially more efficient for CodeGen to walk the AST representation 
> (the `InitListExpr`) and directly generate an IR constant than it is to 
> create an `APValue` representation of the array. (`APValue` is not especially 
> space-efficient, and the extra copying and data shuffling can be quite slow.)


Isn't that what my patch is doing? (Codegen walking the AST/`InitListExpr`, 
generating `Constant`s)?

Uploading what I have; handling arrays is trickier than structs; the index and 
the base both end up having complex subtrees to fetch values from.  As much fun 
as it is to build a compile time evaluator, it sounds like I should stop 
pursing  `CGExprConstant` visitors in favor of `ExprConstant`? (I guess it's 
not clear to me whether @rsmith is in agreement with @eli.friedman on whether 
we want to be more aggressive in compile time evaluation or not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D73638: [AST] Move dependence computations into a separate file

2020-03-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

So this patch makes me pretty nervous - it moves a lot of logic, it necessarily 
changes the way it's structured, the domain is subtle. I wouldn't be terribly 
surprised if we were missing some tests here.
So this all points to resisting the urge to improve things in this patch, and 
doing it in followups instead.




Comment at: clang/include/clang/AST/Expr.h:4081
-: Expr(ConvertVectorExprClass, DstType, VK, OK,
-   DstType->isDependentType(),
-   DstType->isDependentType() || SrcExpr->isValueDependent(),

hokein wrote:
> !  behavior change change, now the `ConvertVectorExpr::TypeDependent = 
> DstType->isDependentType() | SrcExpr->isDependentType()`.
this looks incorrect to me. A conversion's type doesn't depend on the input 
type.



Comment at: clang/include/clang/AST/Expr.h:4139
- bool TypeDependent, bool ValueDependent)
-: Expr(ChooseExprClass, t, VK, OK, TypeDependent, ValueDependent,
-   (cond->isInstantiationDependent() ||

hokein wrote:
> ! this needs careful review, the ChooseExpr bits are from different sources:
> 
> - constructor here
> - 
> [`clang/lib/Sema/SemaPseudoObject.cpp`](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaPseudoObject.cpp#L170)
> - 
> [`clang/lib/AST/ASTImporter.cpp`](https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/ASTImporter.cpp#L6347)
> - 
> [`clang/lib/Sema/SemaExpr.cpp`](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaExpr.cpp#L14207)
> 
>  
LG



Comment at: clang/include/clang/AST/Expr.h:4250
 SourceLocation RPLoc, QualType t, bool IsMS)
-  : Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary, t->isDependentType(),
- false, (TInfo->getType()->isInstantiationDependentType() ||

hokein wrote:
> ! the implementation in the original patch doesn't seem to correct to me, I 
> rewrote it, need another review..
Are you saying the previous version of this patch didn't match the spec, or 
didn't match the old behavior, or both?

The new  one seems pretty different to head.
e.g. parameter packsand instantiation dependence are propagated from type, type 
dependence is propagated from the  subexpr and the writtentypeinfo's type.

Do these not make a difference for practical cases?
(If this is a bug fix, I'd prefer to land it separately)



Comment at: clang/include/clang/AST/Expr.h:5031
- CommonInit->isValueDependent() || ElementInit->isValueDependent(),
- T->isInstantiationDependentType(),
- CommonInit->containsUnexpandedParameterPack() ||

hokein wrote:
> ! behavior change here, now `ArrayInitLoopExpr::Instantiation =  
> T->isInstantiationDependentType() |  
> CommonInit->isInstantiationDependentType() |  
> ElementInit->isInstantiationDependentType()`.
Is this a bugfix? Consider leaving a FIXME instead?



Comment at: clang/include/clang/AST/Expr.h:5650
-: Expr(AsTypeExprClass, DstType, VK, OK,
-   DstType->isDependentType(),
-   DstType->isDependentType() || SrcExpr->isValueDependent(),

hokein wrote:
> ! behavior change here, now `Expr::TypeDependent = DstType->isDependentType() 
> | SrcExpr->isTypeDependent()`.
This seems incorrect to me. Like a new-expr, the type of the result doesn't 
depend on the type of the inputs.



Comment at: clang/include/clang/AST/Expr.h:152
 
   void setDependence(ExprDependence Deps) {
 ExprBits.Dependent = static_cast(Deps);

This should have some docs like "each concrete expr subclass is expected to 
compute its dependence and call this in the constructor".



Comment at: clang/include/clang/AST/ExprCXX.h:2742
-  : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
- false, queried->getType()->isDependentType(),
- (queried->getType()->isInstantiationDependentType() ||

hokein wrote:
> ! behavior change here, now we the `ValueDependent`, `UnexpandedPack` takes 
> `dimension` into account as well.
this seems like a reasonable/trivial bugfix



Comment at: clang/include/clang/AST/ExprCXX.h:4102
 std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
+setDependence(Length ? ExprDependence::None
+ : ExprDependence::ValueInstantiation);

Why not have a computeDependence function for this?
In particular we'll end up missing haserrors propagation without it, right?



Comment at: clang/include/clang/AST/TemplateBase.h:672
   TemplateArgumentLoc *OutArgArray);
+  // FIXME: cleanup the unsued Deps.
   void initializeFrom(SourceLocation TemplateKWLoc,

I don't understand this comment, can you expand it?



Comment at: clang/lib/AST/ComputeDepe

[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/utils/TableGen/SveEmitter.cpp:86
+  OS << "#ifndef  __cplusplus\n";
+  OS << "#include \n";
+  OS << "#endif\n\n";

sdesmalen wrote:
> efriedma wrote:
> > I'd prefer to avoid depending on stdbool if it isn't necessary.
> Section 3.3 of the ACLE actually mentions this explicitly:
> ```arm_sve.h includes stdint.h and so provides standard types such as 
> uint32_t. When included from C code the header also includes stdbool.h and so 
> provides the bool type.```
Oh, sorry, I was accidentally looking at an old version of the ACLE spec.


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

https://reviews.llvm.org/D75298



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


[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Looks like the latest build passed: 
https://ci.chromium.org/p/chromium/builders/ci/ToTLinux%20%28dbg%29/11585


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099



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


[clang-tools-extra] 42b7827 - [clangd] Add json::Object->Value conversion workaround for older compilers

2020-03-13 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-03-13T14:01:33-07:00
New Revision: 42b782747ed78d1fc68a2b47d1057713189c

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

LOG: [clangd] Add json::Object->Value conversion workaround for older compilers

The build was broken for clang-3.8 which we still support.

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 1975fc191aa1..56ddbfb446f7 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -407,7 +407,9 @@ llvm::json::Value toJSON(const WorkDoneProgressBegin &P) {
 Result["cancellable"] = true;
   if (P.percentage)
 Result["percentage"] = 0;
-  return Result;
+
+  // FIXME: workaround for older gcc/clang
+  return std::move(Result);
 }
 
 llvm::json::Value toJSON(const WorkDoneProgressReport &P) {
@@ -418,14 +420,16 @@ llvm::json::Value toJSON(const WorkDoneProgressReport &P) 
{
 Result["message"] = *P.message;
   if (P.percentage)
 Result["percentage"] = *P.percentage;
-  return Result;
+  // FIXME: workaround for older gcc/clang
+  return std::move(Result);
 }
 
 llvm::json::Value toJSON(const WorkDoneProgressEnd &P) {
   llvm::json::Object Result{{"kind", "end"}};
   if (P.message)
 Result["message"] = *P.message;
-  return Result;
+  // FIXME: workaround for older gcc/clang
+  return std::move(Result);
 }
 
 llvm::json::Value toJSON(const MessageType &R) {
@@ -530,6 +534,7 @@ llvm::json::Value toJSON(const Diagnostic &D) {
 Diag["source"] = D.source;
   if (D.relatedInformation)
 Diag["relatedInformation"] = *D.relatedInformation;
+  // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
 
@@ -648,8 +653,8 @@ llvm::json::Value toJSON(const SymbolDetails &P) {
   if (P.ID.hasValue())
 Result["id"] = P.ID.getValue().str();
 
-  // Older clang cannot compile 'return Result', even though it is legal.
-  return llvm::json::Value(std::move(Result));
+  // FIXME: workaround for older gcc/clang
+  return std::move(Result);
 }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
@@ -711,8 +716,8 @@ llvm::json::Value toJSON(const DocumentSymbol &S) {
 Result["children"] = S.children;
   if (S.deprecated)
 Result["deprecated"] = true;
-  // Older gcc cannot compile 'return Result', even though it is legal.
-  return llvm::json::Value(std::move(Result));
+  // FIXME: workaround for older gcc/clang
+  return std::move(Result);
 }
 
 llvm::json::Value toJSON(const WorkspaceEdit &WE) {



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Removing those two LangOpt checks isn't enough for the test cases to run.

Removing those two checks should unblock const-eval for structs in general.  I 
wasn't thinking about whether there something else for global variables 
specifically, though.  It looks like there's a relevant FIXME in 
findCompleteObject() in ExprConstant.cpp.

> APValue is not especially space-efficient

Yes.  We should probably do something similar to what we do for LLVM constants: 
add specialized representations for simple cases, like ConstantDataArray.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@thakis: Wasn't that issue fixed by rG18eae3312297cb197a3131f3ad9ca2bebb217415 
 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099



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


[PATCH] D76100: Debug Info: Store the SDK in the DICompileUnit.

2020-03-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl closed this revision.
aprantl added a comment.

842ea709e4ed881c2bc59155af5df910eccda9c6 



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

https://reviews.llvm.org/D76100



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


[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Do you think this could cause errors like in 
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8885934379148608192/+/steps/compile/0/stdout?format=raw
 ? (see also https://bugs.chromium.org/p/chromium/issues/detail?id=1061535)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D76096#1921842 , @nickdesaulniers 
wrote:

> > The performance implications of deleting those lines is the complicated 
> > part.
>
> Where does compile time performance suffer from this? I guess if we have 
> massive array initializers, or large struct definitions, or deeply nested 
> struct definitions, it might take time to recursively evaluate if all members 
> are constant expressions; but isn't that what I want as a developer, to 
> offload the calculations to compile time rather than runtime?  Or is the cost 
> way too significant?


It's exactly what you suspect: very large global arrays initialized from 
constant data. For those, it's substantially more efficient for CodeGen to walk 
the AST representation (the `InitListExpr`) and directly generate an IR 
constant than it is to create an `APValue` representation of the array. 
(`APValue` is not especially space-efficient, and the extra copying and data 
shuffling can be quite slow.) We saw a significant compile time regression on a 
couple of LNT benchmarks without these early bailouts for C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-03-13 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

In D69585#1922108 , @dblaikie wrote:

> Does this still have an OpenMP special case? The production code changes 
> don't seem to mention OpenMP anymore, but there's still a lot of test updates 
> for OpenMP - what are they for?


It's been handled by b841b9e96e605bed5a1f9b846a07aae88c65ce02 
 . The 
tests need updates because they test compilation both with and without PCH use, 
and this patch reorders templates in the output, without any functional change.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



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


[clang] 86bba6c - [Sema] Use the canonical type in function isVector

2020-03-13 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-03-13T13:08:48-07:00
New Revision: 86bba6c6410c31e669b10f182c6d1a03f704555a

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

LOG: [Sema] Use the canonical type in function isVector

This reapplies the following patch, which was reverted because it caused
neon CodeGen tests to fail:

https://reviews.llvm.org/rGa6150b48cea00ab31e9335cc73770327acc4cb3a

I've added checks to detect half precision neon vectors and avoid
promiting them to vectors of floats.

See the discussion here: https://reviews.llvm.org/rG825235c140e7

Original commit message:

This fixes an assertion in Sema::CreateBuiltinBinOp that fails when one
of the vector operand's element type is a typedef of __fp16.

rdar://problem/55983556

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp16-ops.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9ab6a16154d5..b9fe53f18891 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8272,7 +8272,7 @@ Sema::CheckAssignmentConstraints(SourceLocation Loc,
 /// type ElementType.
 static bool isVector(QualType QT, QualType ElementType) {
   if (const VectorType *VT = QT->getAs())
-return VT->getElementType() == ElementType;
+return VT->getElementType().getCanonicalType() == ElementType;
   return false;
 }
 
@@ -12920,10 +12920,27 @@ CorrectDelayedTyposInBinOp(Sema &S, 
BinaryOperatorKind Opc, Expr *LHSExpr,
 /// Returns true if conversion between vectors of halfs and vectors of floats
 /// is needed.
 static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext 
&Ctx,
- QualType SrcType) {
-  return OpRequiresConversion && !Ctx.getLangOpts().NativeHalfType &&
- !Ctx.getTargetInfo().useFP16ConversionIntrinsics() &&
- isVector(SrcType, Ctx.HalfTy);
+ Expr *E0, Expr *E1 = nullptr) {
+  if (!OpRequiresConversion || Ctx.getLangOpts().NativeHalfType ||
+  Ctx.getTargetInfo().useFP16ConversionIntrinsics())
+return false;
+
+  auto HasVectorOfHalfType = [&Ctx](Expr *E) {
+QualType Ty = E->IgnoreImplicit()->getType();
+
+// Don't promote half precision neon vectors like float16x4_t in arm_neon.h
+// to vectors of floats. Although the element type of the vectors is 
__fp16,
+// the vectors shouldn't be treated as storage-only types. See the
+// discussion here: https://reviews.llvm.org/rG825235c140e7
+if (const VectorType *VT = Ty->getAs()) {
+  if (VT->getVectorKind() == VectorType::NeonVector)
+return false;
+  return VT->getElementType().getCanonicalType() == Ctx.HalfTy;
+}
+return false;
+  };
+
+  return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
 }
 
 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
@@ -13158,8 +13175,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
   assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
  isVector(LHS.get()->getType(), Context.HalfTy) &&
  "both sides are half vectors or neither sides are");
-  ConvertHalfVec = needsConversionOfHalfVec(ConvertHalfVec, Context,
-LHS.get()->getType());
+  ConvertHalfVec =
+  needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 
   // Check for array bounds violations for both sides of the BinaryOperator
   CheckArrayAccess(LHS.get());
@@ -13651,8 +13668,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation 
OpLoc,
 // float vector and truncating the result back to a half vector. For now, 
we
 // do this only when HalfArgsAndReturns is set (that is, when the target is
 // arm or arm64).
-ConvertHalfVec =
-needsConversionOfHalfVec(true, Context, Input.get()->getType());
+ConvertHalfVec = needsConversionOfHalfVec(true, Context, Input.get());
 
 // If the operand is a half vector, promote it to a float vector.
 if (ConvertHalfVec)

diff  --git a/clang/test/CodeGen/fp16-ops.c b/clang/test/CodeGen/fp16-ops.c
index f74552b85921..6401dd125d2a 100644
--- a/clang/test/CodeGen/fp16-ops.c
+++ b/clang/test/CodeGen/fp16-ops.c
@@ -11,6 +11,7 @@
 // RUN: %clang_cc1 -emit-llvm -o - -x renderscript %s \
 // RUN:   | FileCheck %s --check-prefix=NATIVE-HALF
 typedef unsigned cond_t;
+typedef __fp16 float16_t;
 
 volatile cond_t test;
 volatile int i0;
@@ -541,3 +542,15 @@ void foo(void) {
   // NOTNATIVE: store volatile half [[TRUNC]], half* @h0
   h0 = s0;
 }
+
+// CHECK-LABEL: define void @testTypeDef(
+// CHECK: %[[CONV:.*]] = fpext <4 x half> %{{.*}} to <4 x float>
+// CHECK: %[[CONV1:.*]] = fpext <4 x half> %{{.*}} to <4 x float>
+// CHECK: %[[ADD:.*]] = fadd <4 x f

[PATCH] D76082: [Sema][SVE] Reject arrays of sizeless types

2020-03-13 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG994c071a1b7e: [Sema][SVE] Reject arrays of sizeless types 
(authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76082

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -61,6 +61,8 @@
 
 struct incomplete_struct *incomplete_ptr;
 
+typedef svint8_t sizeless_array[1]; // expected-error {{array has sizeless element type}}
+
 void func(int sel) {
   static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
 
@@ -107,6 +109,9 @@
   _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
 
+  svint8_t array_int8[1];  // expected-error {{array has sizeless element type}}
+  svint8_t array_int8_init[] = {}; // expected-error {{array has sizeless element type}}
+
   bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}}
 
   int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}}
@@ -283,6 +288,11 @@
   T *y;
 };
 
+template 
+struct s_array_template {
+  T y[1]; // expected-error {{array has sizeless element type}}
+};
+
 struct widget {
   widget(s_ptr_template);
   svint8_t operator[](int);
@@ -330,6 +340,13 @@
 void template_fn_rvalue_ref(T &&) {}
 #endif
 
+#if __cplusplus >= 201103L
+template 
+using array_alias = T[1]; // expected-error {{array has sizeless element type '__SVInt8_t'}}
+extern array_alias *array_alias_int_ptr;
+extern array_alias *array_alias_int8_ptr; // expected-note {{in instantiation of template type alias 'array_alias' requested here}}
+#endif
+
 void cxx_only(int sel) {
   svint8_t local_int8;
   svint16_t local_int16;
@@ -372,6 +389,9 @@
   widget w(1);
   local_int8 = w[1];
 
+  s_array_template st_array_int;
+  s_array_template st_array_svint8; // expected-note {{in instantiation}}
+
   local_int8 = static_cast(wrapper());
   local_int16 = static_cast(wrapper()); // expected-error {{assigning to 'svint16_t' (aka '__SVInt16_t') from incompatible type 'svint8_t'}}
 
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -51,6 +51,8 @@
 
 struct incomplete_struct *incomplete_ptr;
 
+typedef svint8_t sizeless_array[1]; // expected-error {{array has sizeless element type}}
+
 void func(int sel) {
   static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
 
@@ -93,6 +95,9 @@
   _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
 
+  svint8_t array_int8[1];  // expected-error {{array has sizeless element type}}
+  svint8_t array_int8_init[] = {}; // expected-error {{array has sizeless element type}}
+
   _Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with an expression of incompatible type 'svint8_t'}}
 
   int int_int8 = init_int8; // expected-error {{initializing 'int' with an expression of incompatible type 'svint8_t'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2214,7 +2214,7 @@
 }
 
 if (T->isVoidType() || T->isIncompleteArrayType()) {
-  Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
+  Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 << T;
   return QualType();
 }
 
@@ -2232,11 +2232,16 @@
   } else {
 // C99 6.7.5.2p1: If the element type is an incomplete or function type,
 // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
-if (RequireCompleteType(Loc, T,
-diag::err_illegal_decl_array_incomplete_type))
+if (RequireCompleteSizedType(Loc, T,
+ diag::err_array_incomplete_or_sizeless_type))
   return QualType();
   }
 
+  if (T->isSizelessType()) {
+Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 1 << T;
+return QualType();
+  }
+
   if (T->isFunctionType()) {
 Diag(Loc, diag::err_illegal_decl_array_of_functions)
   << getPrintableNameForEntity(Entity) << T;
Index: clang/lib/Se

[PATCH] D76090: [Sema][SVE] Don't allow sizeless types to be caught

2020-03-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D76090/new/

https://reviews.llvm.org/D76090



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


[PATCH] D75738: [Sema][SVE] Reject by-copy capture of sizeless types

2020-03-13 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c5c60a493ca: [Sema][SVE] Reject by-copy capture of sizeless 
types (authored by rsandifo-arm).

Changed prior to commit:
  https://reviews.llvm.org/D75738?vs=248702&id=250281#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75738

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -499,6 +499,7 @@
 #if __cplusplus >= 201703L
   auto fn3 = [a(return_int8())] {}; // expected-error {{field has sizeless 
type '__SVInt8_t'}}
 #endif
+  auto fn4 = [local_int8](svint8_t *ptr) { *ptr = local_int8; }; // 
expected-error {{by-copy capture of variable 'local_int8' with sizeless type 
'svint8_t'}}
 
   for (auto x : local_int8) { // expected-error {{no viable 'begin' function 
available}}
   }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16356,9 +16356,10 @@
 // Make sure that by-copy captures are of a complete and non-abstract type.
 if (!Invalid && BuildAndDiagnose) {
   if (!CaptureType->isDependentType() &&
-  S.RequireCompleteType(Loc, CaptureType,
-diag::err_capture_of_incomplete_type,
-Var->getDeclName()))
+  S.RequireCompleteSizedType(
+  Loc, CaptureType,
+  diag::err_capture_of_incomplete_or_sizeless_type,
+  Var->getDeclName()))
 Invalid = true;
   else if (S.RequireNonAbstractType(Loc, CaptureType,
 diag::err_capture_of_abstract_type))
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1476,8 +1476,8 @@
 def err_array_of_abstract_type : Error<"array of abstract class type %0">;
 def err_capture_of_abstract_type : Error<
   "by-copy capture of value of abstract type %0">;
-def err_capture_of_incomplete_type : Error<
-  "by-copy capture of variable %0 with incomplete type %1">;
+def err_capture_of_incomplete_or_sizeless_type : Error<
+  "by-copy capture of variable %0 with %select{incomplete|sizeless}1 type %2">;
 def err_capture_default_non_local : Error<
   "non-local lambda expression cannot have a capture-default">;
 


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -499,6 +499,7 @@
 #if __cplusplus >= 201703L
   auto fn3 = [a(return_int8())] {}; // expected-error {{field has sizeless type '__SVInt8_t'}}
 #endif
+  auto fn4 = [local_int8](svint8_t *ptr) { *ptr = local_int8; }; // expected-error {{by-copy capture of variable 'local_int8' with sizeless type 'svint8_t'}}
 
   for (auto x : local_int8) { // expected-error {{no viable 'begin' function available}}
   }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16356,9 +16356,10 @@
 // Make sure that by-copy captures are of a complete and non-abstract type.
 if (!Invalid && BuildAndDiagnose) {
   if (!CaptureType->isDependentType() &&
-  S.RequireCompleteType(Loc, CaptureType,
-diag::err_capture_of_incomplete_type,
-Var->getDeclName()))
+  S.RequireCompleteSizedType(
+  Loc, CaptureType,
+  diag::err_capture_of_incomplete_or_sizeless_type,
+  Var->getDeclName()))
 Invalid = true;
   else if (S.RequireNonAbstractType(Loc, CaptureType,
 diag::err_capture_of_abstract_type))
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1476,8 +1476,8 @@
 def err_array_of_abstract_type : Error<"array of abstract class type %0">;
 def err_capture_of_abstract_type : Error<
   "by-copy capture of value of abstract type %0">;
-def err_capture_of_incomplete_type : Error<
-  "by-copy capture of variable %0 with incomplete type %1">;
+def err_capture_of_incomplete_or_sizeless_type : Error<
+  "by-copy capture of variable %0 with %select{incomplete|sizeless}1 type %2">;
 def err_capture_default_non_local : Error<
   "non-local lambda expression cann

[PATCH] D73846: [PCH] make sure to not warn about unused macros from -D

2020-03-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks pretty reasonable to me - but I don't know enough about the macro and 
source location infrastructure. @rsmith - mind taking a quick look?


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

https://reviews.llvm.org/D73846



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


[clang] f82b32a - Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""

2020-03-13 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-03-13T15:37:44-04:00
New Revision: f82b32a51e22cc56d20f695772797127d3f9d85a

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

LOG: Revert "Reland "[DebugInfo] Enable the debug entry values feature by 
default""

This reverts commit 5aa5c943f7da155b95564058cd5d50a93eabfc89.
Causes clang to assert, see
https://bugs.chromium.org/p/chromium/issues/detail?id=1061533#c4
for a repro.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-locstats/locstats.ll

Removed: 
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index e047054447f3..3c8b0eeb47a5 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -63,6 +63,7 @@ CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the 
new, experimental
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index cc30893703df..b7a2826d8fcb 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -388,6 +388,8 @@ def flto_visibility_public_std:
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def 

[clang] 994c071 - [Sema][SVE] Reject arrays of sizeless types

2020-03-13 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-13T19:28:45Z
New Revision: 994c071a1b7eee8de132d78286c730da2be2c48f

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

LOG: [Sema][SVE] Reject arrays of sizeless types

The SVE ACLE doesn't allow arrays of sizeless types.  At the moment
clang accepts the TU:

  __SVInt8_t x[2];

but trying to code-generate it triggers the LLVM assertion:

  llvm/lib/IR/Type.cpp:588: static llvm::ArrayType* 
llvm::ArrayType::get(llvm::Type*, uint64_t): Assertion 
`isValidElementType(ElementType) && "Invalid type for array element!"' failed.

This patch reports an appropriate error instead.

The rules are slightly more restrictive than for general incomplete types.
For example:

  struct s;
  typedef struct s arr[2];

is valid as far as it goes, whereas arrays of sizeless types are
invalid in all contexts.  BuildArrayType therefore needs a specific
check for isSizelessType in addition to the usual handling of
incomplete types.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 936edf2d5ae0..4328e322b914 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5895,8 +5895,8 @@ def err_flexible_array_init_needs_braces : Error<
   "flexible array requires brace-enclosed initializer">;
 def err_illegal_decl_array_of_functions : Error<
   "'%0' declared as array of functions of type %1">;
-def err_illegal_decl_array_incomplete_type : Error<
-  "array has incomplete element type %0">;
+def err_array_incomplete_or_sizeless_type : Error<
+  "array has %select{incomplete|sizeless}0 element type %1">;
 def err_illegal_message_expr_incomplete_type : Error<
   "Objective-C message has incomplete result type %0">;
 def err_illegal_decl_array_of_references : Error<

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4ffac5eb5c70..a61ddbd290f8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12385,9 +12385,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
   if (!Var->isInvalidDecl()) {
 if (const IncompleteArrayType *ArrayT
 = Context.getAsIncompleteArrayType(Type)) {
-  if (RequireCompleteType(Var->getLocation(),
-  ArrayT->getElementType(),
-  
diag::err_illegal_decl_array_incomplete_type))
+  if (RequireCompleteSizedType(
+  Var->getLocation(), ArrayT->getElementType(),
+  diag::err_array_incomplete_or_sizeless_type))
 Var->setInvalidDecl();
 } else if (Var->getStorageClass() == SC_Static) {
   // C99 6.9.2p3: If the declaration of an identifier for an object is

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index eaf22fed3131..9ab6a16154d5 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6175,10 +6175,10 @@ Sema::BuildCompoundLiteralExpr(SourceLocation 
LParenLoc, TypeSourceInfo *TInfo,
   QualType literalType = TInfo->getType();
 
   if (literalType->isArrayType()) {
-if (RequireCompleteType(LParenLoc, Context.getBaseElementType(literalType),
-  diag::err_illegal_decl_array_incomplete_type,
-  SourceRange(LParenLoc,
-  LiteralExpr->getSourceRange().getEnd(
+if (RequireCompleteSizedType(
+LParenLoc, Context.getBaseElementType(literalType),
+diag::err_array_incomplete_or_sizeless_type,
+SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd(
   return ExprError();
 if (literalType->isVariableArrayType())
   return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 7f555ecdcc95..534178388048 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2214,7 +2214,7 @@ QualType Sema::BuildArrayType(QualType T, 
ArrayType::ArraySizeModifier ASM,
 }
 
 if (T->isVoidType() || T->isIncompleteArrayType()) {
-  Diag(Loc, diag::err_illegal_decl_array_incomplete_type) << T;
+  Diag(Loc, diag::err_array_incomplete_or_sizeless_type) << 0 << T;
   return QualType();
 }
 
@@ -2232,11 +2232,16 @@ QualType Sema::BuildArrayType(QualType T, 
ArrayType::ArraySizeModifier ASM,
   } else {
 // C99 6.7.5.2p1: If the 

[clang] 8c5c60a - [Sema][SVE] Reject by-copy capture of sizeless types

2020-03-13 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-13T19:27:31Z
New Revision: 8c5c60a493ca31c7e808ca48a99ed4bd5900b43d

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

LOG: [Sema][SVE] Reject by-copy capture of sizeless types

Since fields can't have sizeless type, it also doesn't make sense
to capture sizeless types by value in lambda expressions.  This patch
makes sure that we diagnose that and that we use "sizeless type" rather
"incomplete type" in the associated message.  (Both are correct, but
"sizeless type" is more specific and hopefully more user-friendly.)

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4966942e37e7..936edf2d5ae0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1476,8 +1476,8 @@ def err_throw_abstract_type : Error<
 def err_array_of_abstract_type : Error<"array of abstract class type %0">;
 def err_capture_of_abstract_type : Error<
   "by-copy capture of value of abstract type %0">;
-def err_capture_of_incomplete_type : Error<
-  "by-copy capture of variable %0 with incomplete type %1">;
+def err_capture_of_incomplete_or_sizeless_type : Error<
+  "by-copy capture of variable %0 with %select{incomplete|sizeless}1 type %2">;
 def err_capture_default_non_local : Error<
   "non-local lambda expression cannot have a capture-default">;
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8cc5ac267774..eaf22fed3131 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16356,9 +16356,10 @@ static bool captureInLambda(LambdaScopeInfo *LSI,
 // Make sure that by-copy captures are of a complete and non-abstract type.
 if (!Invalid && BuildAndDiagnose) {
   if (!CaptureType->isDependentType() &&
-  S.RequireCompleteType(Loc, CaptureType,
-diag::err_capture_of_incomplete_type,
-Var->getDeclName()))
+  S.RequireCompleteSizedType(
+  Loc, CaptureType,
+  diag::err_capture_of_incomplete_or_sizeless_type,
+  Var->getDeclName()))
 Invalid = true;
   else if (S.RequireNonAbstractType(Loc, CaptureType,
 diag::err_capture_of_abstract_type))

diff  --git a/clang/test/SemaCXX/sizeless-1.cpp 
b/clang/test/SemaCXX/sizeless-1.cpp
index 48453f594f18..f776c47ffc94 100644
--- a/clang/test/SemaCXX/sizeless-1.cpp
+++ b/clang/test/SemaCXX/sizeless-1.cpp
@@ -499,6 +499,7 @@ void cxx_only(int sel) {
 #if __cplusplus >= 201703L
   auto fn3 = [a(return_int8())] {}; // expected-error {{field has sizeless 
type '__SVInt8_t'}}
 #endif
+  auto fn4 = [local_int8](svint8_t *ptr) { *ptr = local_int8; }; // 
expected-error {{by-copy capture of variable 'local_int8' with sizeless type 
'svint8_t'}}
 
   for (auto x : local_int8) { // expected-error {{no viable 'begin' function 
available}}
   }



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


[PATCH] D75737: [Sema][SVE] Don't allow fields to have sizeless type

2020-03-13 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
rsandifo-arm marked an inline comment as done.
Closed by commit rGb50d80c1ee1f: [Sema][SVE] Don't allow fields to have 
sizeless type (authored by rsandifo-arm).

Changed prior to commit:
  https://reviews.llvm.org/D75737?vs=249990&id=250277#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75737

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -249,6 +249,20 @@
   return count;
 }
 
+struct sized_struct {
+  int f1;
+  svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t : 3;// expected-error {{field has sizeless type 'svint8_t'}}
+};
+
+union sized_union {
+  int f1;
+  svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t : 3;// expected-error {{field has sizeless type 'svint8_t'}}
+};
+
 void pass_int8_ref(svint8_t &); // expected-note {{not viable}}
 
 svint8_t &return_int8_ref();
@@ -257,6 +271,11 @@
 #endif
 
 template 
+struct s_template {
+  T y; // expected-error {{field has sizeless type '__SVInt8_t'}}
+};
+
+template 
 struct s_ptr_template {
   s_ptr_template();
   s_ptr_template(T, svint8_t = svint8_t());
@@ -344,6 +363,9 @@
   local_int8 = svint8_t();
   local_int8 = svint16_t(); // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
 
+  s_template st_int;
+  s_template st_svint8; // expected-note {{in instantiation}}
+
   s_ptr_template st_ptr_int;
   s_ptr_template st_ptr_svint8;
 
@@ -474,6 +496,9 @@
   local_int8 = ([]() -> svint8_t { return svint8_t(); })();
   auto fn1 = [&local_int8](svint8_t x) { local_int8 = x; };
   auto fn2 = [&local_int8](svint8_t *ptr) { *ptr = local_int8; };
+#if __cplusplus >= 201703L
+  auto fn3 = [a(return_int8())] {}; // expected-error {{field has sizeless type '__SVInt8_t'}}
+#endif
 
   for (auto x : local_int8) { // expected-error {{no viable 'begin' function available}}
   }
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -230,6 +230,20 @@
   return count;
 }
 
+struct sized_struct {
+  int f1;
+  svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t : 3;// expected-error {{field has sizeless type 'svint8_t'}}
+};
+
+union sized_union {
+  int f1;
+  svint8_t f2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t f3 : 2; // expected-error {{field has sizeless type 'svint8_t'}}
+  svint8_t : 3;// expected-error {{field has sizeless type 'svint8_t'}}
+};
+
 #if __STDC_VERSION__ >= 201112L
 void test_generic(void) {
   svint8_t local_int8;
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1629,7 +1629,8 @@
   // If the variable being captured has an invalid type, mark the class as
   // invalid as well.
   if (!FieldType->isDependentType()) {
-if (RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) {
+if (RequireCompleteSizedType(Loc, FieldType,
+ diag::err_field_incomplete_or_sizeless)) {
   RD->setInvalidDecl();
   Field->setInvalidDecl();
 } else {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5247,8 +5247,8 @@
   Chain.push_back(Anon);
 
   RecordDecl *RecordDef = Record->getDefinition();
-  if (RequireCompleteType(Anon->getLocation(), RecTy,
-  diag::err_field_incomplete) ||
+  if (RequireCompleteSizedType(Anon->getLocation(), RecTy,
+   diag::err_field_incomplete_or_sizeless) ||
   InjectAnonymousStructOrUnionMembers(*this, S, CurContext, RecordDef,
   AS_none, Chain)) {
 Anon->setInvalidDecl();
@@ -16103,8 +16103,9 @@
   // C99 6.7.2.1p4 - verify the field type.
   // C++ 9.6p3: A bit-field shall have integral or enumeration type.
   if (!FieldTy->isDependentType() && !FieldTy->isIntegralOrEnumerationType()) {
-// Handle incomplete types with specific error.
-if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete

[PATCH] D76090: [Sema][SVE] Don't allow sizeless types to be caught

2020-03-13 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 250273.
rsandifo-arm added a comment.

Allow pointers to sizeless types to be caught.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76090

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -398,6 +398,19 @@
   throw local_int8; // expected-error {{cannot throw object of sizeless type 
'svint8_t'}}
   throw global_int8_ptr;
 
+  try {
+  } catch (int) {
+  }
+  try {
+  } catch (svint8_t) { // expected-error {{cannot catch sizeless type 
'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t *) {
+  }
+  try {
+  } catch (svint8_t &) { // expected-error {{cannot catch reference to 
sizeless type 'svint8_t'}}
+  }
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of 
non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a 
pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15487,6 +15487,11 @@
   !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
 Invalid = true;
 
+  if (!Invalid && Mode != 1 && BaseType->isSizelessType()) {
+Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
+Invalid = true;
+  }
+
   if (!Invalid && !ExDeclType->isDependentType() &&
   RequireNonAbstractType(Loc, ExDeclType,
  diag::err_abstract_type_in_decl,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7012,6 +7012,8 @@
 def err_catch_incomplete_ref : Error<
   "cannot catch reference to incomplete type %0">;
 def err_catch_incomplete : Error<"cannot catch incomplete type %0">;
+def err_catch_sizeless : Error<
+  "cannot catch %select{|reference to }0sizeless type %1">;
 def err_catch_rvalue_ref : Error<"cannot catch exceptions by rvalue 
reference">;
 def err_catch_variably_modified : Error<
   "cannot catch variably modified type %0">;


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -398,6 +398,19 @@
   throw local_int8; // expected-error {{cannot throw object of sizeless type 'svint8_t'}}
   throw global_int8_ptr;
 
+  try {
+  } catch (int) {
+  }
+  try {
+  } catch (svint8_t) { // expected-error {{cannot catch sizeless type 'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t *) {
+  }
+  try {
+  } catch (svint8_t &) { // expected-error {{cannot catch reference to sizeless type 'svint8_t'}}
+  }
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15487,6 +15487,11 @@
   !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
 Invalid = true;
 
+  if (!Invalid && Mode != 1 && BaseType->isSizelessType()) {
+Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
+Invalid = true;
+  }
+
   if (!Invalid && !ExDeclType->isDependentType() &&
   RequireNonAbstractType(Loc, ExDeclType,
  diag::err_abstract_type_in_decl,
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7012,6 +7012,8 @@
 def err_catch_incomplete_ref : Error<
   "cannot catch reference to incomplete type %0">;
 def err_catch_incomplete : Error<"cannot catch incomplete type %0">;
+def err_catch_sizeless : Error<
+  "cannot catch %select{|reference to }0sizeless type %1">;
 def err_catch_rvalue_ref : Error<"cannot catch exceptions by rvalue reference">;
 def err_catch_variably_modified : Error<
   "cannot catch variably modified type %0">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b50d80c - [Sema][SVE] Don't allow fields to have sizeless type

2020-03-13 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-13T19:22:23Z
New Revision: b50d80c1ee1fc154c906f59a2ebedab2f85bacca

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

LOG: [Sema][SVE] Don't allow fields to have sizeless type

The SVE ACLE doesn't allow fields to have sizeless type.  At the moment
clang accepts things like:

  struct s { __SVInt8_t x; } y;

but trying to code-generate it leads to LLVM asserts like:

  llvm/include/llvm/Support/TypeSize.h:126: uint64_t 
llvm::TypeSize::getFixedSize() const: Assertion `!IsScalable && "Request for a 
fixed size on a scalable object"' failed.

This patch adds an associated clang diagnostic.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLambda.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 52bc4077bbc2..4966942e37e7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5602,7 +5602,8 @@ def err_func_returning_qualified_void : ExtWarn<
 def err_func_returning_array_function : Error<
   "function cannot return %select{array|function}0 type %1">;
 def err_field_declared_as_function : Error<"field %0 declared as a function">;
-def err_field_incomplete : Error<"field has incomplete type %0">;
+def err_field_incomplete_or_sizeless : Error<
+  "field has %select{incomplete|sizeless}0 type %1">;
 def ext_variable_sized_type_in_struct : ExtWarn<
   "field %0 with variable sized type %1 not at the end of a struct or class is"
   " a GNU extension">, InGroup;

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d31e2747f65c..4ffac5eb5c70 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5247,8 +5247,8 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, 
DeclSpec &DS,
   Chain.push_back(Anon);
 
   RecordDecl *RecordDef = Record->getDefinition();
-  if (RequireCompleteType(Anon->getLocation(), RecTy,
-  diag::err_field_incomplete) ||
+  if (RequireCompleteSizedType(Anon->getLocation(), RecTy,
+   diag::err_field_incomplete_or_sizeless) ||
   InjectAnonymousStructOrUnionMembers(*this, S, CurContext, RecordDef,
   AS_none, Chain)) {
 Anon->setInvalidDecl();
@@ -16103,8 +16103,9 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
   // C99 6.7.2.1p4 - verify the field type.
   // C++ 9.6p3: A bit-field shall have integral or enumeration type.
   if (!FieldTy->isDependentType() && !FieldTy->isIntegralOrEnumerationType()) {
-// Handle incomplete types with specific error.
-if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
+// Handle incomplete and sizeless types with a specific error.
+if (RequireCompleteSizedType(FieldLoc, FieldTy,
+ diag::err_field_incomplete_or_sizeless))
   return ExprError();
 if (FieldName)
   return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
@@ -16321,7 +16322,8 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, 
QualType T,
 
   QualType EltTy = Context.getBaseElementType(T);
   if (!EltTy->isDependentType()) {
-if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
+if (RequireCompleteSizedType(Loc, EltTy,
+ diag::err_field_incomplete_or_sizeless)) {
   // Fields of incomplete type force their record to be invalid.
   Record->setInvalidDecl();
   InvalidDecl = true;
@@ -16865,8 +16867,9 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, 
Decl *EnclosingDecl,
 // elsewhere, after synthesized ivars are known.
   }
 } else if (!FDTy->isDependentType() &&
-   RequireCompleteType(FD->getLocation(), FD->getType(),
-   diag::err_field_incomplete)) {
+   RequireCompleteSizedType(
+   FD->getLocation(), FD->getType(),
+   diag::err_field_incomplete_or_sizeless)) {
   // Incomplete type
   FD->setInvalidDecl();
   EnclosingDecl->setInvalidDecl();
@@ -16924,8 +16927,8 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, 
Decl *EnclosingDecl,
   Context, "", UnavailableAttr::IR_ARCFieldWithOwnership,
   FD->getLocation()));
 } else if (getLangOpts().ObjC &&
-   getLangOpts().getGC() != LangOptions::NonGC &&
-   Record && !Record->hasObjectMember()) {
+   getLangOpts().getGC() != L

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D76077#1921973 , @rjmccall wrote:

> In D76077#1921490 , @LukeGeeson 
> wrote:
>
> > In D76077#1919861 , @rjmccall 
> > wrote:
> >
> > > I don't understand why you wouldn't add a new IR type for this; doing so 
> > > should be totally mechanical.
> >
> >
> > We had a few reasons for doing it this way.
> >
> > By adding a new IR type we would need to consider calling conventions, and 
> > IR optimizations for what is essentially an opaque storage-only type.
>
>
> IR optimizations should just fall out; the code in `APFloat` should work for 
> arbitrary FP semantics.
>
> Calling something a "storage-only" type does not get you out of worrying 
> about calling conventions at the ABI level.  You can forbid passing your type 
> as an argument or result directly, but structs containing your type as a 
> field can still be passed around, and the behavior for that needs to be 
> defined.
>
> > Bfloat has no soft ABI, and all the supported operations can be handled 
> > through intrinsics (in a later patch, removed here due to bloat). If we 
> > were to add a new IR type, then we would need to handle many operations 
> > which would extend beyond what the type is supported for. For instance in 
> > GCC we had to add a new mode in RTL to handle inline memcopy.
>
> I don't know why having a soft ABI makes a difference.  If the type only 
> works on certain platforms, then it can't be used on other platforms.


Having an IR type sounds like the right thing to do here.


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

https://reviews.llvm.org/D76077



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-13 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 250272.
logan-5 marked 2 inline comments as done.
logan-5 added a comment.

Re-juggled and made `bool OnlyDependsOnFundamentalArraySizes(QualType QualTy)` 
recursive. Made `::` assert more useful. Thanks @Quuxplusone for both good 
ideas.


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

https://reviews.llvm.org/D72282

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-unintended-adl.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-generic-lambdas.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-operators.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
@@ -0,0 +1,332 @@
+// RUN: %check_clang_tidy %s bugprone-unintended-adl %t -- \
+// RUN: -config="{CheckOptions: [ \
+// RUN:   {key: bugprone-unintended-adl.AllowedNamespaces, value: 'ignore_me;also::ignore::me'}, \
+// RUN: ]}" --
+
+namespace aspace {
+struct A {};
+void func(const A &);
+} // namespace aspace
+
+namespace bspace {
+void func(int);
+void test() {
+  aspace::A a;
+  func(5);
+  func(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'aspace::func' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  aspace::func(a);{{$}}
+}
+} // namespace bspace
+
+namespace ops {
+
+struct Stream {
+} stream;
+Stream &operator<<(Stream &s, int) {
+  return s;
+}
+Stream &operator<<(Stream &s, aspace::A) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, int) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, aspace::A) {
+  return s;
+}
+void smooth_operator(Stream);
+
+} // namespace ops
+
+void ops_test() {
+  ops::stream << 5;
+  // no warning
+  operator<<(ops::stream, 5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator<<(ops::stream, 5);{{$}}
+  ops::stream << aspace::A();
+  // no warning
+  // CHECK-FIXES: {{^}}  ops::stream << aspace::A();{{$}}
+  operator<<(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator<<(ops::stream, aspace::A());{{$}}
+
+  ops::stream >> aspace::A();
+  // no warning
+  // CHECK-FIXES: {{^}}  ops::stream >> aspace::A();{{$}}
+  operator>>(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator>>' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator>>(ops::stream, aspace::A());{{$}}
+
+  smooth_operator(ops::stream);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::smooth_operator' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::smooth_operator(ops::stream);{{$}}
+}
+
+namespace std {
+// return types don't matter, returning 'void' everywhere for simplicity
+
+template 
+void swap(T &a, T &b);
+template 
+void make_error_code(T);
+template 
+void make_error_condition(T);
+template 
+void data(T);
+template 
+void begin(T);
+template 
+void end(T);
+template 
+void rbegin(T);
+template 
+void rend(T);
+template 
+void crbegin(T);
+template 
+void crend(T);
+template 
+void size(T);
+template 
+void ssize(T);
+template 
+void empty(T);
+
+template 
+void move(T &&);
+template 
+void forward(T &&);
+
+struct byte {};
+
+} // namespace std
+namespace ns {
+
+struct Swappable {};
+
+// whitelisted
+void swap(Swappable &a, Swappable &b);
+void make_error_code(Swappable);
+void make_error_condition(Swappable);
+void data(Swappable);
+void begin(Swappable);
+void end(Swappable);
+void rbegin(Swappable);
+void rend(Swappable);
+void crbegin(Swappable);
+void crend(Swappable);
+void size(Swappable);
+void ssize(Swappable);
+void empty(Swappable);
+
+// non-whitelisted
+void move(Swappable);
+void ref(Swappable);
+
+struct Swappable2 {};
+
+} // namespace ns
+struct {
+  template 
+  void operator()(T &&);
+} ref;
+
+void test2() {
+  // TODO add granularity for detecting functions that may always be called unqualified,
+  // versus those that can only be called through the 'using' 'two-step'
+  using namespace std;
+  ns::Swappable a, b;
+  swap(a, b);
+  make_error_code(a);
+  make_error_condition(a);
+  data(a);
+  begin(a);
+  end(a);
+  rbegin(a);
+  rend(a);
+  crbegin(a);
+  crend(a);
+  size(a);
+  ssize(a);
+  empty(a);
+
+  move(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: wa

[PATCH] D76086: [Sema][SVE] Reject arithmetic on pointers to sizeless types

2020-03-13 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D76086#1920558 , @efriedma wrote:

> People are going to want to iterate over arrays in memory to write simple 
> intrinsic loops.  If we don't allow `p + i` to work, people will be forced to 
> write `(__SVInt8_t*)((char*)p + i * svcntb())`.  Which is the same thing, 
> just a lot uglier.  And it wouldn't really be that crazy to support 
> `sizeof(__SVInt8_t)`.  I mean, it's effectively just a different way of 
> spelling `svcntb()`.  I guess we can always relax it later, though.


`__SVInt8_t` is only really supposed to be used for short-term working data 
rather than storage.  Sizelessness is one thing that makes it awkward to use as 
the target of a pointer iterator.  But another is that the underlying ABI type 
has an alignment of 16 bytes regardless of how big the vector actually is.  
Also, for length-agnostic code, it would be unusual to have two `__SVInt8_t`s 
side-by-side in memory, since the code doesn't know ahead of time how big each 
one is.

So for length-agnostic code the expectation is that loops would iterate on 
`int8_t *` instead of `__SVInt8_t *`.  It's then possible to operate on 
pointers that aren't 16-byte aligned.  The pointer can also be incremented by 
`svcntb()` without casting.  The same goes for other combinations, e.g. 
`int32_t *` and `svcntw()`.

For length-specific code we're working on another solution that allows SVE 
vector types to be treated like normal fixed-length types.  I hope we'll be 
able to share that soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76086



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 250267.
LukeGeeson added a comment.

Added a file from a downstream cleanup of the branch.


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

https://reviews.llvm.org/D76077

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-mangle-16bit-float.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -607,6 +607,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(Bfloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
+  fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
+  bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
+}
+
+#include 
+
+void test_vector(bfloat16x4_t a, bfloat16x4_t b, float16x4_t c) {
+  a + b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a - b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a * b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+  a / b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
+
+  a + 

[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-03-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Could you upload this with full context ( 
https://llvm.org/docs/Phabricator.html#id4 mentions how to do this)?

Does this still have an OpenMP special case? The production code changes don't 
seem to mention OpenMP anymore, but there's still a lot of test updates for 
OpenMP - what are they for?

@rsmith could you take a look at this - the pending instantiations stuff isn't 
something I'm sufficiently familiar with to feel comfortable signing off on 
this alone.


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

https://reviews.llvm.org/D69585



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


[clang] 842ea70 - Debug Info: Store the SDK in the DICompileUnit.

2020-03-13 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-03-13T11:21:30-07:00
New Revision: 842ea709e4ed881c2bc59155af5df910eccda9c6

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

LOG: Debug Info: Store the SDK in the DICompileUnit.

This is another intermediate step for PR44213
(https://bugs.llvm.org/show_bug.cgi?id=44213).

This stores the SDK *name* in the debug info, to make it possible to
`-fdebug-prefix-map`-replace the sysroot with a recognizable string
and allowing the debugger to find a fitting SDK relative to itself,
not the machine the executable was compiled on.

rdar://problem/51645582

Added: 
clang/test/CodeGen/debug-info-sysroot-sdk.c

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 
clang/test/CodeGen/debug-info-sysroot.c



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 551d4235a6f9..eeb1927177c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -611,9 +611,15 @@ void CGDebugInfo::CreateCompileUnit() {
   remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID()));
 
-  StringRef Sysroot;
-  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB)
+  StringRef Sysroot, SDK;
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
 Sysroot = CGM.getHeaderSearchOpts().Sysroot;
+auto B = llvm::sys::path::rbegin(Sysroot);
+auto E = llvm::sys::path::rend(Sysroot);
+auto It = std::find_if(B, E, [](auto SDK) { return SDK.endswith(".sdk"); 
});
+if (It != E)
+  SDK = *It;
+  }
 
   // Create new compile unit.
   TheCU = DBuilder.createCompileUnit(
@@ -625,7 +631,7 @@ void CGDebugInfo::CreateCompileUnit() {
   ? llvm::DICompileUnit::DebugNameTableKind::None
   : static_cast(
 CGOpts.DebugNameTable),
-  CGOpts.DebugRangesBaseAddress, Sysroot);
+  CGOpts.DebugRangesBaseAddress, Sysroot, SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

diff  --git a/clang/test/CodeGen/debug-info-sysroot-sdk.c 
b/clang/test/CodeGen/debug-info-sysroot-sdk.c
new file mode 100644
index ..5c4d201d6904
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-sysroot-sdk.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYSROOT/MacOSX.sdk -emit-llvm -o - \
+// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYSROOT/MacOSX.sdk -emit-llvm -o - \
+// RUN:   -debugger-tuning=gdb | FileCheck %s --check-prefix=GDB
+
+void foo() {}
+
+// The sysroot and sdk are LLDB-tuning-specific attributes.
+
+// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT/MacOSX.sdk",
+// LLDB-SAME:  sdk: "MacOSX.sdk"
+// GDB: distinct !DICompileUnit(
+// GDB-NOT: sysroot: "/CLANG_SYSROOT/MacOSX.sdk"
+// GDB-NOT: sdk: "MacOSX.sdk"

diff  --git a/clang/test/CodeGen/debug-info-sysroot.c 
b/clang/test/CodeGen/debug-info-sysroot.c
deleted file mode 100644
index bb3c0c820cee..
--- a/clang/test/CodeGen/debug-info-sysroot.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=gdb | FileCheck %s --check-prefix=GDB
-
-void foo() {}
-
-// The sysroot is an LLDB-tuning-specific attribute.
-
-// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT"
-// GDB: distinct !DICompileUnit(
-// GDB-NOT: sysroot: "/CLANG_SYSROOT"
-



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


[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-13 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 250264.
JonChesterfield marked an inline comment as done.
JonChesterfield added a comment.

- undo reformat of existing def


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclBase.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-loader-uninitialized.c
  clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-loader-uninitialized.c
  clang/test/Sema/attr-loader-uninitialized.cpp

Index: clang/test/Sema/attr-loader-uninitialized.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int still_cant_be_const __attribute__((loader_uninitialized));
+// expected-error@-1 {{default initialization of an object of const type}}
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}} 
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+void func() __attribute__((loader_uninitialized))
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+{
+  int local __attribute__((loader_uninitialized));
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static int sl __attribute__((loader_uninitialized));
+}
+
+struct s {
+  __attribute__((loader_uninitialized)) int field;
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static __attribute__((loader_uninitialized)) int sfield;
+
+} __attribute__((loader_uninitialized));
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+int redef_attr_first __attribute__((loader_uninitialized));
+int redef_attr_first;
+// expected-error@-1 {{redefinition of 'redef_attr_first'}}
+// expected-note@-3 {{previous definition is here}}
+
+int redef_attr_second; 
+int redef_attr_second __attribute__((loader_uninitialized)); 
+// expected-warning@-1 {{attribute declaration must precede definition}}
+// expected-note@-3 {{previous definition is here}}
+// expected-error@-3 {{redefinition of 'redef_attr_second'}}
+// expected-note@-5 {{previous definition is here}}
+
+struct trivial {};
+
+trivial default_ok __attribute__((loader_uninitialized));
+trivial value_rejected  __attribute__((loader_uninitialized)) {};
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+struct nontrivial
+{
+  nontrivial() {}
+};
+
+nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
Index: clang/test/Sema/attr-loader-uninitialized.c
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// See also attr-loader-uninitialized.cpp
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int can_still_be_const __attribute__((loader_uninitialized));
+
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+int declaration_then_uninit_ok;
+int declaration_then_uninit_ok __attribute__((loader_uninitialized));
+
+int definition_then_uninit_rejected = 0;
+int definition_then_uninit_rejected __attribute__((loader_uninitialized));
+//

[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-13 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 250263.
JonChesterfield added a comment.

- Amend diagnostic as suggested, clang-format new lines in SemaKinds.td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclBase.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-loader-uninitialized.c
  clang/test/CodeGenCXX/attr-loader-uninitialized.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-loader-uninitialized.c
  clang/test/Sema/attr-loader-uninitialized.cpp

Index: clang/test/Sema/attr-loader-uninitialized.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int still_cant_be_const __attribute__((loader_uninitialized));
+// expected-error@-1 {{default initialization of an object of const type}}
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}} 
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+void func() __attribute__((loader_uninitialized))
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+{
+  int local __attribute__((loader_uninitialized));
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static int sl __attribute__((loader_uninitialized));
+}
+
+struct s {
+  __attribute__((loader_uninitialized)) int field;
+  // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+  static __attribute__((loader_uninitialized)) int sfield;
+
+} __attribute__((loader_uninitialized));
+// expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
+
+int redef_attr_first __attribute__((loader_uninitialized));
+int redef_attr_first;
+// expected-error@-1 {{redefinition of 'redef_attr_first'}}
+// expected-note@-3 {{previous definition is here}}
+
+int redef_attr_second; 
+int redef_attr_second __attribute__((loader_uninitialized)); 
+// expected-warning@-1 {{attribute declaration must precede definition}}
+// expected-note@-3 {{previous definition is here}}
+// expected-error@-3 {{redefinition of 'redef_attr_second'}}
+// expected-note@-5 {{previous definition is here}}
+
+struct trivial {};
+
+trivial default_ok __attribute__((loader_uninitialized));
+trivial value_rejected  __attribute__((loader_uninitialized)) {};
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+struct nontrivial
+{
+  nontrivial() {}
+};
+
+nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
Index: clang/test/Sema/attr-loader-uninitialized.c
===
--- /dev/null
+++ clang/test/Sema/attr-loader-uninitialized.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// See also attr-loader-uninitialized.cpp
+
+int good __attribute__((loader_uninitialized));
+static int local_ok __attribute__((loader_uninitialized));
+int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
+
+const int can_still_be_const __attribute__((loader_uninitialized));
+
+extern int external_rejected __attribute__((loader_uninitialized));
+// expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
+
+int noargs __attribute__((loader_uninitialized(0)));
+// expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
+
+int init_rejected __attribute__((loader_uninitialized)) = 42;
+// expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
+
+int declaration_then_uninit_ok;
+int declaration_then_uninit_ok __attribute__((loader_uninitialized));
+
+int definition_then_uninit_rejected = 0;
+int definition_then_uninit_rejected __attribute__((loader_uninitialized));
+// expected-

[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-13 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D74361#1920329 , @aaron.ballman 
wrote:

> Aside from the diagnostic wording, I think this LG to me. However, I'd 
> appreciate if @rjmccall would also sign off.


Thanks! @rjmccall?




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5344
+def err_loader_uninitialized_extern_decl : Error<
+  "external declaration of variable cannot have the 'loader_uninitialized' 
attribute">;
 def err_block_extern_cant_init : Error<

aaron.ballman wrote:
> How would you feel about: `"variable %0 cannot be declared both 'extern' and 
> with the 'loader_uninitialized' attribute"` (or something along those lines) 
> to clarify "external declaration"?
Better, thanks. Also discovered clang-format has learned to do sensible things 
with tablegen so applied it to the new defs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-13 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.cpp:51
+  // Remove the '::' at the end.
+  assert(NNS.size() >= 2);
+  NNS.erase(NNS.end() - 2, NNS.end());

As long as you're asserting anyway, I think you should assert that the last two 
characters //are// `::`.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.cpp:159
+if (auto *Ty = dyn_cast(E->getType()))
+  return Ty->getElementType()->isFundamentalType();
+return false;

Never mind me if this becomes too ugly, but, I would have expected `bool 
OnlyDependsOnFundamentalArraySizes(const Expr *)` to be recursive, and I would 
have expected the `llvm::all_of`-over-a-parameter-list to happen in the caller. 
To properly handle corner cases like
```
template void test() {
char a[sizeof(T)][sizeof(T)]; foo(a);
}
```
Experimentally, it appears that Clang thinks that the type of `char 
b[sizeof(T)]; ... (b+1) ...` is dependent. (It's definitely `char*`, but it 
comes from applying `+` to an expression with dependent type.) I have no idea 
what the paper standard says about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D76096#1920685 , @efriedma wrote:

> I think the code that disables constant evaluation for C is just 
> https://github.com/llvm/llvm-project/blob/dcaf13a4048df3dad55f1a28cde7cefc99ccc057/clang/lib/AST/ExprConstant.cpp#L13918
>  and 
> https://github.com/llvm/llvm-project/blob/dcaf13a4048df3dad55f1a28cde7cefc99ccc057/clang/lib/AST/ExprConstant.cpp#L13744
>  .


Removing those two `LangOpt` checks isn't enough for the test cases to run.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

efriedma wrote:
> efriedma wrote:
> > nickdesaulniers wrote:
> > > efriedma wrote:
> > > > nickdesaulniers wrote:
> > > > > nickdesaulniers wrote:
> > > > > > Interesting, playing with this more in godbolt, it looks like the 
> > > > > > struct doesn't even have to be const qualified.
> > > > > Or, rather, behaves differently between C and C++ mode;
> > > > > 
> > > > > C -> const required
> > > > > C++ -> const not required
> > > > In C++, global variable initializers don't have to be constant 
> > > > expressions at all.
> > > > 
> > > > Do we really need to check GNUMode here? We try to avoid it except for 
> > > > cases where we would otherwise reject valid code.
> > > > 
> > > > Do we need to worry about arrays here?
> > > > In C++, global variable initializers don't have to be constant 
> > > > expressions at all.
> > > 
> > > It looks like my test cases are supported already in Clang today, in C++ 
> > > mode only and not C.  Maybe there's some alternative code path that I 
> > > should be looking to reuse?
> > > 
> > > > Do we really need to check GNUMode here?
> > > 
> > > Maybe a `-Wpedantic` diag would be more appropriate otherwise? (GCC does 
> > > not warn for these cases with `-Wpedantic`.  If the answer to your 
> > > question is `no`, then that means supporting these regardless of language 
> > > mode.  (I'm ok with that, was just being maybe overly cautious with 
> > > `GNUMode`, but maybe folks with better knowledge of the language 
> > > standards have better thoughts?)
> > > 
> > > > Do we need to worry about arrays here?
> > > 
> > > I don't think arrays are supported: https://godbolt.org/z/RiZPpM
> > Also, do we need to check that we actually have a definition for the 
> > variable?
> The C++ standard is substantially different from C.  C++ global initializers 
> can be evaluated at runtime.  So we don't call this code at all in C++.
> 
> Independent of that, we do have pretty complete support for constant 
> evaluation of structs in C++ to support constexpr, and we should be able to 
> leverage that.
> 
> 
> 
> For arrays, I was thinking of something like this:
> 
> ```
> const int foo[3] = { 0, 1, 2 };
> int bar = foo[0];
> ```
> 
> 
> 
> We generally don't generate pedantic warnings unless the user uses an 
> extension that's disallowed by the C standard.  (The idea is that clang with 
> -pedantic should generate a diagnostic every place the C standard requires a 
> diagnostic.  It's not a catch-all for extensions.)
> 
> We could separately generate some sort of portability warning, but not sure 
> anyone would care to enable it.
> Do we really need to check GNUMode here?

Will remove.

> Do we need to worry about arrays here?

Yep; as long as the base and index are `const` qualified, GCC allows them.  
Will add tests.

> Also, do we need to check that we actually have a definition for the variable?

Yep, will add tests.

> It's not a catch-all for extensions.

Ah, got it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[PATCH] D76100: Debug Info: Store the SDK in the DICompileUnit.

2020-03-13 Thread Davide Italiano via Phabricator via cfe-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D76100



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D76077#1921490 , @LukeGeeson wrote:

> In D76077#1919861 , @rjmccall wrote:
>
> > I don't understand why you wouldn't add a new IR type for this; doing so 
> > should be totally mechanical.
>
>
> We had a few reasons for doing it this way.
>
> By adding a new IR type we would need to consider calling conventions, and IR 
> optimizations for what is essentially an opaque storage-only type.


IR optimizations should just fall out; the code in `APFloat` should work for 
arbitrary FP semantics.

Calling something a "storage-only" type does not get you out of worrying about 
calling conventions at the ABI level.  You can forbid passing your type as an 
argument or result directly, but structs containing your type as a field can 
still be passed around, and the behavior for that needs to be defined.

> Bfloat has no soft ABI, and all the supported operations can be handled 
> through intrinsics (in a later patch, removed here due to bloat). If we were 
> to add a new IR type, then we would need to handle many operations which 
> would extend beyond what the type is supported for. For instance in GCC we 
> had to add a new mode in RTL to handle inline memcopy.

I don't know why having a soft ABI makes a difference.  If the type only works 
on certain platforms, then it can't be used on other platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-13 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked an inline comment as done.
vabridgers added a comment.

@Charusso -- I do not have commit access, but I will request. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D75558: [clang-tidy] Update abseil-duration-unnecessary-conversion check to find more cases.

2020-03-13 Thread Hyrum Wright via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3860b2a0bd09: [clang-tidy] Update Abseil Duration Conversion 
check to find more cases. (authored by hwright).

Changed prior to commit:
  https://reviews.llvm.org/D75558?vs=247988&id=250252#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75558

Files:
  clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
  
clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
  
clang-tools-extra/test/clang-tidy/checkers/abseil-duration-unnecessary-conversion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil-duration-unnecessary-conversion.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-duration-unnecessary-conversion.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-duration-unnecessary-conversion.cpp
@@ -100,6 +100,44 @@
   d2 = VALUE(d1);
 #undef VALUE
 
+  // Multiplication
+  d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Microseconds(absl::ToInt64Microseconds(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Seconds(absl::ToInt64Seconds(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Minutes(absl::ToDoubleMinutes(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Hours(absl::ToInt64Hours(d1) * 2);
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = d1 * 2
+  d2 = absl::Nanoseconds(2 * absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+  d2 = absl::Microseconds(2 * absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+  d2 = absl::Milliseconds(2 * absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+  d2 = absl::Seconds(2 * absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+  d2 = absl::Minutes(2 * absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+  d2 = absl::Hours(2 * absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
+  // CHECK-FIXES: d2 = 2 * d1
+
   // These should not match
   d2 = absl::Seconds(absl::ToDoubleMilliseconds(d1));
   d2 = absl::Seconds(4);
@@ -108,4 +146,6 @@
   d2 = absl::Seconds(d1 / absl::Seconds(30));
   d2 = absl::Hours(absl::FDivDuration(d1, absl::Minutes(1)));
   d2 = absl::Milliseconds(absl::FDivDuration(d1, absl::Milliseconds(20)));
+  d2 = absl::Seconds(absl::ToInt64Milliseconds(d1) * 2);
+  d2 = absl::Milliseconds(absl::ToDoubleSeconds(d1) * 2);
 }
Index: clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
+++ clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
@@ -40,6 +40,17 @@
   // Suggestion - Remove division and conversion
   absl::Duration d2 = d1;
 
+Unwrapping scalar operations:
+
+.. code-block:: c++
+
+  // Original - Multiplication by a scalar
+  absl::Duration d1;
+  absl::Duration d2 = absl::Seconds(absl::ToInt64Seconds(d1) * 2);
+
+  // Suggestion - Remove unnecessary conversion
+  absl::Duration d2 = d1 * 2;
+
 Note: Converting to an integer and back to an ``absl::Duration`` might be a
 truncating o

[PATCH] D72100: Allow matching "any file" in `VerifyDiagnosticConsumer`.

2020-03-13 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 250247.
arames added a comment.

Apply `clang-format`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72100

Files:
  clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/test/Frontend/verify-any-file.c
  clang/test/Frontend/verify-any-file.h

Index: clang/test/Frontend/verify-any-file.h
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.h
@@ -0,0 +1 @@
+unexpected var;
Index: clang/test/Frontend/verify-any-file.c
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.c
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -verify %s 2>&1 | FileCheck %s
+
+#include "verify-any-file.h"
+// expected-error@*:* {{unknown type name 'unexpected'}}
+
+// expected-error@*:* {{missing error}}
+
+// expected-error@*:123 {{invalid line : "*" required}}
+//
+//  CHECK: error: 'error' diagnostics expected but not seen:
+// CHECK-NEXT:   File * Line * (directive at {{.*}}verify-any-file.c:6): missing error
+// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT:   File {{.*}}verify-any-file.c Line 8: missing or invalid line number following '@' in expected '*'
+// CHECK-NEXT: 2 errors generated.
Index: clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -89,9 +89,10 @@
 class StandardDirective : public Directive {
 public:
   StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
-bool MatchAnyLine, StringRef Text, unsigned Min,
-unsigned Max)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max) {}
+bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+unsigned Min, unsigned Max)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max) {}
 
   bool isValid(std::string &Error) override {
 // all strings are considered valid; even empty ones
@@ -107,9 +108,10 @@
 class RegexDirective : public Directive {
 public:
   RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
- bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
- StringRef RegexStr)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max),
+ bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+ unsigned Min, unsigned Max, StringRef RegexStr)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max),
 Regex(RegexStr) {}
 
   bool isValid(std::string &Error) override {
@@ -294,11 +296,13 @@
 // Attach the specified directive to the line of code indicated by
 // \p ExpectedLoc.
 void attachDirective(DiagnosticsEngine &Diags, const UnattachedDirective &UD,
- SourceLocation ExpectedLoc, bool MatchAnyLine = false) {
+ SourceLocation ExpectedLoc,
+ bool MatchAnyFileAndLine = false,
+ bool MatchAnyLine = false) {
   // Construct new directive.
-  std::unique_ptr D =
-  Directive::create(UD.RegexKind, UD.DirectivePos, ExpectedLoc,
-MatchAnyLine, UD.Text, UD.Min, UD.Max);
+  std::unique_ptr D = Directive::create(
+  UD.RegexKind, UD.DirectivePos, ExpectedLoc, MatchAnyFileAndLine,
+  MatchAnyLine, UD.Text, UD.Min, UD.Max);
 
   std::string Error;
   if (!D->isValid(Error)) {
@@ -498,6 +502,7 @@
 // Next optional token: @
 SourceLocation ExpectedLoc;
 StringRef Marker;
+bool MatchAnyFileAndLine = false;
 bool MatchAnyLine = false;
 if (!PH.Next("@")) {
   ExpectedLoc = Pos;
@@ -526,26 +531,39 @@
 StringRef Filename(PH.C, PH.P-PH.C);
 PH.Advance();
 
-// Lookup file via Preprocessor, like a #include.
-const DirectoryLookup *CurDir;
-Optional File =
-PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
-   nullptr, nullptr, nullptr, nullptr, nullptr);
-if (!File) {
-  Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
-   diag::err_verify_missing_file) << Filename << KindStr;
-  continue;
-}
-
-const FileEntry *FE = &File->getFileEntry();
-if (SM.translateFile(FE).isInvalid())
-  SM.createFileID(FE, Pos, SrcMgr::C_User);
-
-if (PH.Next(Line) && Line > 0)
-  ExpectedLoc = SM.translateFileLineCol(FE, Line, 1);
-else if (PH.Next("*")) {
+if (Filename == "*") {
+ 

[PATCH] D75514: [Analyzer] Only add container note tags to the operations of the affected container

2020-03-13 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 250248.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

Updated according to the comments of D75677 .


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

https://reviews.llvm.org/D75514

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector &V) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector &V) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector &V) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector &V) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector &V) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector &V) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector &V) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector &V) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector &V) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector &V) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector &V) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begi

[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-13 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D75529#1920796 , @vabridgers wrote:

> I believe all comments have been addressed. Please let me know if there's 
> anything else required. Thanks


I think you have solved everything. Do you have commit access? May you would 
request it: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-13 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added a comment.

> The performance implications of deleting those lines is the complicated part.

Where does compile time performance suffer from this? I guess if we have 
massive array initializers, or large struct definitions, or deeply nested 
struct definitions, it might take time to recursively evaluate if all members 
are constant expressions; but isn't that what I want as a developer, to offload 
the calculations to compile time rather than runtime?  Or is the cost way too 
significant?  Looks like @rsmith added those comments/checks back in 2012 via 
commit dafff947599e ("constexpr irgen: Add irgen support for APValue::Struct, 
APValue::Union,").

Let me see if I comment out the code I've added, then modify those two spots in 
ExprConstant.cpp you pointed out, if that works as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096



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


[clang-tools-extra] 3860b2a - [clang-tidy] Update Abseil Duration Conversion check to find more cases.

2020-03-13 Thread Hyrum Wright via cfe-commits

Author: Hyrum Wright
Date: 2020-03-13T12:52:37-04:00
New Revision: 3860b2a0bd09291a276b0590939961dffe67fbb6

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

LOG: [clang-tidy] Update Abseil Duration Conversion check to find more cases.

This change improves the check to handle cases with internal scalar
multiplication.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp

clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst

clang-tools-extra/test/clang-tidy/checkers/abseil-duration-unnecessary-conversion.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
index 948feee3c504..28f970e17509 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
@@ -52,10 +52,22 @@ void 
DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
 callee(functionDecl(hasName("::absl::FDivDuration"))),
 hasArgument(0, expr().bind("arg")), hasArgument(1, factory_matcher));
 
+// Matcher which matches a duration argument being scaled,
+// e.g. `absl::ToDoubleSeconds(dur) * 2`
+auto scalar_matcher = ignoringImpCasts(
+binaryOperator(hasOperatorName("*"),
+   hasEitherOperand(expr(ignoringParenImpCasts(
+   callExpr(callee(functionDecl(hasAnyName(
+FloatConversion, IntegerConversion))),
+hasArgument(0, expr().bind("arg")))
+   .bind("inner_call")
+.bind("binop"));
+
 Finder->addMatcher(
 callExpr(callee(functionDecl(hasName(DurationFactory))),
  hasArgument(0, anyOf(inverse_function_matcher,
-  division_operator_matcher, 
fdiv_matcher)))
+  division_operator_matcher, fdiv_matcher,
+  scalar_matcher)))
 .bind("call"),
 this);
   }
@@ -64,16 +76,41 @@ void 
DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
 void DurationUnnecessaryConversionCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *OuterCall = Result.Nodes.getNodeAs("call");
-  const auto *Arg = Result.Nodes.getNodeAs("arg");
 
   if (isInMacro(Result, OuterCall))
 return;
 
+  FixItHint Hint;
+  if (const auto *Binop = Result.Nodes.getNodeAs("binop")) {
+const auto *Arg = Result.Nodes.getNodeAs("arg");
+const auto *InnerCall = Result.Nodes.getNodeAs("inner_call");
+const Expr *LHS = Binop->getLHS();
+const Expr *RHS = Binop->getRHS();
+
+if (LHS->IgnoreParenImpCasts() == InnerCall) {
+  Hint = FixItHint::CreateReplacement(
+  OuterCall->getSourceRange(),
+  (llvm::Twine(tooling::fixit::getText(*Arg, *Result.Context)) + " * " 
+
+   tooling::fixit::getText(*RHS, *Result.Context))
+  .str());
+} else {
+  assert(RHS->IgnoreParenImpCasts() == InnerCall &&
+ "Inner call should be find on the RHS");
+
+  Hint = FixItHint::CreateReplacement(
+  OuterCall->getSourceRange(),
+  (llvm::Twine(tooling::fixit::getText(*LHS, *Result.Context)) + " * " 
+
+   tooling::fixit::getText(*Arg, *Result.Context))
+  .str());
+}
+  } else if (const auto *Arg = Result.Nodes.getNodeAs("arg")) {
+Hint = FixItHint::CreateReplacement(
+OuterCall->getSourceRange(),
+tooling::fixit::getText(*Arg, *Result.Context));
+  }
   diag(OuterCall->getBeginLoc(),
"remove unnecessary absl::Duration conversions")
-  << FixItHint::CreateReplacement(
- OuterCall->getSourceRange(),
- tooling::fixit::getText(*Arg, *Result.Context));
+  << Hint;
 }
 
 } // namespace abseil

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
index 2f978f4d57c0..264c5d08b9d2 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/abseil-duration-unnecessary-conversion.rst
@@ -40,6 +40,17 @@ Integer examples:
   // Suggestion - Remove division and conversion
   absl::Duration d2 = d1;
 
+Unwrapping scalar operations:
+
+.. code-block:: c++
+
+  // Original - Multiplication by a scalar
+  absl::Duration d1;
+ 

[Diffusion] rG396b7253944e: [OpenMP][Opt] Combine `struct ident_t*` during deduplication

2020-03-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.

BRANCHES
  master

/clang/test/OpenMP/PR44893.c:3 > A test with no CHECK lines also passes if you 
symlink /bin/true to clang :-)
> It also doesn't indicate what is being relevant and when it comes to 
> maintaining / updating the test we won't know what is important to keep.

This is a common pattern, except the `%clang` part maybe. I'm fine with 
removing this test as the actual issue is covered explicitly, see below. This 
was added as the original reproducer, not the minimal one (which is IR).

> The fact that there was a crash that wasn't hit by the test suite indicates 
> that there was some behavior that wasn't tested before, so we should really 
> try to check that behavior.

> >  Can you add some sort of positive test, related to where the crash was?

> I did, in deduplication.ll.

I did, in deduplication.ll



Users:
  jdoerfert (Author)

https://reviews.llvm.org/rG396b7253944e



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2020-03-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo updated this revision to Diff 250232.
echristo added a comment.

Fix comments around full unroller.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687

Files:
  clang/test/Misc/loop-opt-setup.c
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -496,12 +496,13 @@
   LPM2.addPass(LoopDeletionPass());
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
-  // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
+  // inaccurate. The normal unroller doesn't pay attention to forced full 
unroll
+  // attributes so we need to make sure and allow the full unroll pass to pay
+  // attention to it.
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
 LPM2.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(),
-/*OnlyWhenForced=*/false,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto &C : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -1,5 +1,5 @@
-// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - 
%s -emit-llvm | FileCheck %s
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o 
- %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - 
%s -emit-llvm | FileCheck %s -check-prefix=CHECK-NEWPM
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o 
- %s -emit-llvm | FileCheck %s -check-prefix=CHECK-OLDPM
 extern int a[16];
 int b = 0;
 int foo(void) {
@@ -8,5 +8,34 @@
 a[i] = b += 2;
   return b;
 }
+// Check br i1 to make sure that the loop is fully unrolled
 // CHECK-NOT: br i1
 
+inline void Helper() {
+  const int* nodes[5];
+  int num_active = 5;
+
+  while (num_active) {
+#pragma clang loop unroll(full)
+for (int i = 0; i < 5; ++i) {
+  if (nodes[i]) {
+--num_active;
+  }
+}
+  }
+}
+
+void Run() {
+  Helper();
+}
+
+// Check br i1 to make sure the loop is gone, there will still be a label 
branch for the infinite loop.
+// CHECK-NEWPM-NOT: br i1
+
+// The old pass manager doesn't remove the loop so check for 5 load i32*.
+// CHECK-OLDPM: Helper
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -496,12 +496,13 @@
   LPM2.addPass(LoopDeletionPass());
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
-  // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
+  // inaccurate. The normal unroller doesn't pay attention to forced full unroll
+  // attributes so we need to make sure and allow the full unroll pass to pay
+  // attention to it.
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
 LPM2.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(),
-/*OnlyWhenForced=*/false,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto &C : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -1,5 +1,5 @@
-// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s -check-prefix=CHECK-NEWPM
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s -check-prefix=CHECK-OLDPM
 extern int a[16];
 int b = 0;
 int foo(void) {
@@ -8,5 +8,34 @@
 a[i] = b += 2;
   return b;
 }
+// Check br i1 to make sure that the loop is fully unrolled
 // CHECK-NOT: br i1
 
+inline void Helper

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:393-394
+
+  // Make the return value accordingly to the error.
+  State = State->assume(RetVal, (SS->*IsOfError)());
+  assert(State && "Return value should not be constrained already.");

Szelethus wrote:
> Is this correct? We set the `feof()` return value whether we know the state 
> of the stream to be EOF, but in this case we would incorrectly mark it as 
> non-EOF: 
> ```lang=bash
> $ cat a.txt # contains a single newline
> 
> $ cat test.cpp 
> ```
> ```lang=cpp
> #include 
> 
> void tryRead(FILE *F) {
>   char C = fgetc(F);
> 
>   if (feof(F))
> printf("The stream is EOF!\n");
>   else
> printf("The stream is good! Read '%c'\n", C);
> }
> 
> int main() {
>   FILE *F = fopen("a.txt", "r");
>   tryRead(F);
>   tryRead(F); // Incorrectly mark F to be non-EOF
> }
> ```
> ```lang=bash
> $ clang test.cpp -fsanitize=address && ./a.out 
> The stream is good! Read '
> '
> The stream is EOF!
> ```
> 
> Wouldn't it be safer to assume it to be `true` if we **know** its EOF and do 
> nothing otherwise? How about a state split?
> 
> (I know this functions also handler FError, but you see what my point is.)
The problem in this code seems to be that `fgetc` is not handled (yet) by the 
checker. The plan is to handle every possible file operation. The handler of 
`fgetc` would split the state to EOF and non-EOF case. In the current state 
this is a real "bug", it could be handled somehow by checking for escaped 
stream (the `fgetc` here should cause escape of the file pointer if not 
recognized as file operation). But this means again a new patch before this 
one. Or add every file operation to this patch with some simple implementation 
or with "forgetting" the stream?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2020-03-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo updated this revision to Diff 250229.
echristo added a comment.

Fixed the clang test.

Tried to get something that I could reduce down and duplicate with just opt but 
it's been... difficult. Even the small clang testcase in isolation won't 
duplicate via something like:

clang -O0 -fexperimental-new-pass-manager foo.cc -S -o -  -emit-llvm -mllvm 
-disable-llvm-optzns | opt -passes='defaulthttps://reviews.llvm.org/owners/package/1/>>' -transform-warning 
-pass-remarks-missed=transform-warning -S -o -

Might be holding it wrong, but this isn't very discoverable if so :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687

Files:
  clang/test/Misc/loop-opt-setup.c
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -497,11 +497,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
 LPM2.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(),
-/*OnlyWhenForced=*/false,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto &C : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -1,5 +1,5 @@
-// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - 
%s -emit-llvm | FileCheck %s
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o 
- %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - 
%s -emit-llvm | FileCheck %s -check-prefix=CHECK-NEWPM
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o 
- %s -emit-llvm | FileCheck %s -check-prefix=CHECK-OLDPM
 extern int a[16];
 int b = 0;
 int foo(void) {
@@ -8,5 +8,34 @@
 a[i] = b += 2;
   return b;
 }
+// Check br i1 to make sure that the loop is fully unrolled
 // CHECK-NOT: br i1
 
+inline void Helper() {
+  const int* nodes[5];
+  int num_active = 5;
+
+  while (num_active) {
+#pragma clang loop unroll(full)
+for (int i = 0; i < 5; ++i) {
+  if (nodes[i]) {
+--num_active;
+  }
+}
+  }
+}
+
+void Run() {
+  Helper();
+}
+
+// Check br i1 to make sure the loop is gone, there will still be a label 
branch for the infinite loop.
+// CHECK-NEWPM-NOT: br i1
+
+// The old pass manager doesn't remove the loop so check for 5 load i32*.
+// CHECK-OLDPM: Helper
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*
+// CHECK-OLDPM: load i32*


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -497,11 +497,10 @@
   // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
-   PGOOpt->Action != PGOOptions::SampleUse) &&
-  PTO.LoopUnrolling)
+  if (Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  PGOOpt->Action != PGOOptions::SampleUse)
 LPM2.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(),
-/*OnlyWhenForced=*/false,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));
 
   for (auto &C : LoopOptimizerEndEPCallbacks)
Index: clang/test/Misc/loop-opt-setup.c
===
--- clang/test/Misc/loop-opt-setup.c
+++ clang/test/Misc/loop-opt-setup.c
@@ -1,5 +1,5 @@
-// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s -check-prefix=CHECK-NEWPM
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s -check-prefix=CHECK-OLDPM
 extern int a[16];
 int b = 0;
 int foo(void) {
@@ -8,5 +8,34 @@
 a[i] = b += 2;
   return b;
 }
+// Check br i1 to make sure that the loop is fully unrolled
 // CHEC

[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D76099#1921571 , @aganea wrote:

> Looks like there's a memory corruption detected by ASAN, but I'm not sure 
> it's related to my change. Maybe someone with a more expert eye could tell?
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/26137/steps/check-asan%20in%20gcc%20build/logs/stdio


The error seems to have scalar evolution (SCEV) on the stack, and there was a 
patch related to that in the same buildbot run 
(https://reviews.llvm.org/D70097), so I'm guessing that's the cause -- not your 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX.

2020-03-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 250213.
ZarkoCA added a comment.

Clang formatted the patch and fixed typo in testcase.


Repository:
  rZORG LLVM Github Zorg

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

https://reviews.llvm.org/D76130

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-vararg.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll

Index: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
@@ -0,0 +1,316 @@
+; RUN: llc -O2 -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp -verify-machineinstrs < %s | \
+; RUN: FileCheck --check-prefixes=CHECK,64BIT %s
+
+; RUN: llc -O2 -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \
+; RUN:  -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefixes=CHECKASM,ASM64PWR4 %s
+
+
+  @a = local_unnamed_addr global i32 1, align 4
+  @b = local_unnamed_addr global i32 2, align 4
+  @c = local_unnamed_addr global i32 3, align 4
+  @d = local_unnamed_addr global i32 4, align 4
+  @e = local_unnamed_addr global i32 5, align 4
+  @f = local_unnamed_addr global i32 6, align 4
+  @g = local_unnamed_addr global i32 7, align 4
+  @h = local_unnamed_addr global i32 8, align 4
+  @i = local_unnamed_addr global i32 9, align 4
+  @j = local_unnamed_addr global i32 10, align 4
+
+define signext i32 @va_arg1(i32 signext %a, ...) local_unnamed_addr #0 {
+entry:
+  %arg = alloca i8*, align 8
+  %0 = bitcast i8** %arg to i8*
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0) #2
+  call void @llvm.va_start(i8* nonnull %0)
+  %cmp7 = icmp sgt i32 %a, 0
+  br i1 %cmp7, label %for.body.preheader, label %for.end
+
+for.body.preheader:   ; preds = %entry
+  %argp.cur.pre = load i8*, i8** %arg, align 8
+  %1 = add i32 %a, -1
+  %2 = zext i32 %1 to i64
+  %3 = add nuw nsw i64 %2, 1
+  %min.iters.check = icmp ult i32 %1, 8
+  br i1 %min.iters.check, label %for.body.preheader28, label %vector.memcheck
+
+vector.memcheck:  ; preds = %for.body.preheader
+  %uglygep = getelementptr inbounds i8, i8* %0, i64 1
+  %scevgep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %4 = shl nuw nsw i64 %2, 3
+  %5 = add nuw nsw i64 %4, 8
+  %scevgep11 = getelementptr i8, i8* %argp.cur.pre, i64 %5
+  %bound0 = icmp ugt i8* %scevgep11, %0
+  %bound1 = icmp ult i8* %scevgep, %uglygep
+  %found.conflict = and i1 %bound0, %bound1
+  br i1 %found.conflict, label %for.body.preheader28, label %vector.ph
+
+vector.ph:; preds = %vector.memcheck
+  %n.mod.vf = and i64 %3, 7
+  %6 = icmp eq i64 %n.mod.vf, 0
+  %7 = select i1 %6, i64 8, i64 %n.mod.vf
+  %n.vec = sub nsw i64 %3, %7
+  %8 = shl nsw i64 %n.vec, 3
+  %ind.end = getelementptr i8, i8* %argp.cur.pre, i64 %8
+  %ind.end13 = trunc i64 %n.vec to i32
+  %next.gep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep17 = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep20 = getelementptr i8, i8* %argp.cur.pre, i64 8
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, %vector.ph
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %vec.phi = phi <4 x i32> [ , %vector.ph ], [ %19, %vector.body ]
+  %vec.phi21 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
+  %9 = shl i64 %index, 3
+  %10 = shl i64 %index, 3
+  %11 = or i64 %10, 32
+  %12 = shl i64 %index, 3
+  %13 = or i64 %12, 56
+  %14 = getelementptr inbounds i8, i8* %next.gep20, i64 %13
+  %15 = getelementptr inbounds i8, i8* %next.gep, i64 %9
+  %16 = getelementptr inbounds i8, i8* %next.gep17, i64 %11
+  %17 = bitcast i8* %15 to <8 x i32>*
+  %18 = bitcast i8* %16 to <8 x i32>*
+  %wide.vec = load <8 x i32>, <8 x i32>* %17, align 4
+  %wide.vec23 = load <8 x i32>, <8 x i32>* %18, align 4
+  %strided.vec = shufflevector <8 x i32> %wide.vec, <8 x i32> undef, <4 x i32> 
+  %strided.vec24 = shufflevector <8 x i32> %wide.vec23, <8 x i32> undef, <4 x i32> 
+  %19 = add <4 x i32> %strided.vec, %vec.phi
+  %20 = add <4 x i32> %strided.vec24, %vec.phi21
+  %index.next = add i64 %index, 8
+  %21 = icmp eq i64 %index.next, %n.vec
+  br i1 %21, label %middle.block, label %vector.body
+
+middle.block: ; preds = %vector.body
+  store i8* %14, i8** %arg, align 8
+  %bin.rdx = add <4 x i32> %20, %19
+  %rdx.shuf = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> 
+  %bin.rdx25 = add <4 x i32> %bin.rdx, %rdx.shuf
+  %rdx.shuf26 = shufflevector <4 x i32> %bin.rdx25, <4 x i32> undef, <4 x i32> 
+  %bin.rdx27 = add <4 x i32> %bin.rdx25, %rdx.shuf26
+  %22 = extractelement <4 x i32> %bin.rdx27, i32 0
+  br label %for.body.preheader28
+
+for.bod

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Thanks for sticking this out! It just takes me a while to get to the mental 
space regarding this patch you are already in, sometimes through saying 
incorrect statements or stupid suggestions! :) If others could chip in in this 
discussion, it would be most appreciated, because I fear that otherwise this 
patch is a bit too exposed to my own wrongs.

In D75682#1918839 , @balazske wrote:

> In D75682#1917257 , @Szelethus wrote:
>
> > Could you please add the warning we discussed? That would be a great 
> > demonstration of this patch's capabilities, and wouldn't deserve its own 
> > patch.
>
>
> Was it this warning?
>
>   if (feof(F)) { // note: Assuming the condition is true
>  // note: Stream 'F' has the EOF flag set
> fgets(F); // warning: Illegal stream operation on a stream that has EOF 
> set
>   }
>
>
> The warning above should be get even if the `feof` call is missing because it 
> is still possible that the previous operation resulted in EOF state.


What I meant to demonstrate (but failed to describe) is that if the condition 
of the `if` statement is `!feof(F)`, we **shouldn't** get the warning.

> The checker does not work by "assuming feof is true" (this can be a later 
> feature, if the `F` is not tracked and a feof call is encountered). Value of 
> `feof` (more precisely: if any error happened) is fixed when the file 
> operation is called that causes the error. [...] And still that warning would 
> not be testable because `FEof` error state is never set in this patch.

I suspect that at this point you are 2 steps ahead of me, but this is how I 
would imagine such a patch to look like: we //evaluate// `feof()` by splitting 
the state (this should be worth the cost, because why would we ever call `feof` 
if the state couldn't be  EOF or non-EOF?), associate the state where its 
return value is true with the argument being marked as EOF, and the other as 
non-EOF.

This obviously wouldn't be sufficient -- values retrieved from stream reading 
operations may be EOF themselves, which should make us set the appropriate 
state for the originating stream, but that should indeed be the topic of a 
followup patch.

What is the goal here if not this? I have a suspicion I'm just not seeing the 
obvious here, but I don't get it just yet.

> By the way, a file read is not invalid if any error is there, it simply fails 
> again.

Oh, yea, silly me. You're totally right :)

> Probably it would be better to make a full working prototype first, because 
> the design decisions made now can turn out to be wrong later when the new 
> functionality would be added and we do "not see the full picture" now.

If you try to implement a warning just to see how this would turn out long 
term, that would indeed be a good idea. Feel free to upload them, if you 
prefer, as a WIP patch!




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:393-394
+
+  // Make the return value accordingly to the error.
+  State = State->assume(RetVal, (SS->*IsOfError)());
+  assert(State && "Return value should not be constrained already.");

Is this correct? We set the `feof()` return value whether we know the state of 
the stream to be EOF, but in this case we would incorrectly mark it as non-EOF: 
```lang=bash
$ cat a.txt # contains a single newline

$ cat test.cpp 
```
```lang=cpp
#include 

void tryRead(FILE *F) {
  char C = fgetc(F);

  if (feof(F))
printf("The stream is EOF!\n");
  else
printf("The stream is good! Read '%c'\n", C);
}

int main() {
  FILE *F = fopen("a.txt", "r");
  tryRead(F);
  tryRead(F); // Incorrectly mark F to be non-EOF
}
```
```lang=bash
$ clang test.cpp -fsanitize=address && ./a.out 
The stream is good! Read '
'
The stream is EOF!
```

Wouldn't it be safer to assume it to be `true` if we **know** its EOF and do 
nothing otherwise? How about a state split?

(I know this functions also handler FError, but you see what my point is.)



Comment at: clang/test/Analysis/stream-error.c:33-34
+  int ch = fputc('a', F);
+  if (ch == EOF) {
+// FIXME: fputc not handled by checker yet, should expect TRUE
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}

Sure, we don't, but the bigger issue here is that we wouldn't mark `F` to be in 
EOF even if we did handle it, we would also need to understand that `ch == EOF` 
is the telling sign. But that also ins't in the scope of this patch :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-13 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03993f3b6f46: [CMake] Explicitly specify paths to libc++abi 
in CrossWinToARMLinux.cmake (authored by broadwaylamb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -25,6 +25,14 @@
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
 
+# LLVM_PROJECT_DIR is the path to the llvm-project directory.
+# The right way to compute it would probably be to use 
"${CMAKE_SOURCE_DIR}/../",
+# but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
+# that we still need to support (for instance, 3.10.2).
+get_filename_component(LLVM_PROJECT_DIR
+   "${CMAKE_CURRENT_LIST_DIR}/../../../"
+   ABSOLUTE)
+
 if (NOT DEFINED DEFAULT_SYSROOT)
   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain 
build.")
 endif()
@@ -83,6 +91,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -25,6 +25,14 @@
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
 
+# LLVM_PROJECT_DIR is the path to the llvm-project directory.
+# The right way to compute it would probably be to use "${CMAKE_SOURCE_DIR}/../",
+# but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
+# that we still need to support (for instance, 3.10.2).
+get_filename_component(LLVM_PROJECT_DIR
+   "${CMAKE_CURRENT_LIST_DIR}/../../../"
+   ABSOLUTE)
+
 if (NOT DEFINED DEFAULT_SYSROOT)
   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
 endif()
@@ -83,6 +91,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75760: [clang-format] Do not indent C# array initialisers as continuations

2020-03-13 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked an inline comment as done.
jbcoe added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1443
+if (Style.isCSharp())
+  FormatTok->BlockKind = BK_BracedInit;
 nextToken();

krasimir wrote:
> A more general approach might be to adapt parseBracedList() itself to mark 
> the block kind `BK_BracedInit`:
> https://github.com/llvm/llvm-project/blob/7d2fdd3f6639731284dd8b6b274f01f04fd19215/clang/lib/Format/UnwrappedLineParser.cpp#L1628
> 
> Could you try to see if it will be easy/possible to get the same effect by 
> adapting that?
> If that's hard or has unintended side effects, we can reconsider.
Setting block kind inside parseBracedList() caused test failures outside of C# 
tests.

I was hoping to make this surgical for now, hence the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75760



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-13 Thread Louis Dionne via Phabricator via cfe-commits
ldionne requested changes to this revision.
ldionne added inline comments.
Herald added a subscriber: dexonsmith.



Comment at: libcxx/include/new:240
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif defined(_LIBCPP_CXX03_LANG)
+  return __align > alignment_of<__libcpp_max_align_t>::value;

joerg wrote:
> ldionne wrote:
> > So, IIUC what you're saying, `__STDCPP_DEFAULT_NEW_ALIGNMENT__` is provided 
> > by recent Clangs in C++03 mode? I tested it and it does seem to be correct. 
> > (side note: I tend to think we should be more aggressive to remove old 
> > compiler support, since most people don't upgrade their stdlib without 
> > upgrading their compiler anyway).
> > 
> > So if we don't care about supporting old compilers that don't provide that 
> > macro, we could just get rid of this `#elif`, and such compilers would 
> > error out when trying to use `max_align_t` in the `#else` below. That 
> > appears reasonable to me.
> > 
> > We'd still leave the `#if TEST_STD_VER >= 11` in the tests below, since in 
> > C++03 we wouldn't provide `std::max_align_t`, however testing that we use 
> > overaligned new in the same conditions in C++03 and C++11 becomes trivial, 
> > because it's the same code path.
> > 
> > Did I get what you meant correctly? If so, that sounds like a viable path 
> > forward to me, since we're simplifying the code. We're also improving on 
> > our C++03 conformance, which isn't considered good but is certainly not 
> > considered bad either.
> Correct, it has been provided since clang 4.0 at least it seems. For testing, 
> we have two cases, some that specifically check properties of max_align_t and 
> those should be restricted to C++11 and newer. I think we should grow a new 
> check that max_align_t <= __STDCPP_DEFAULT_NEW_ALIGNMENT__ as sanity check, 
> but that's slightly OT. Most of the existing cases to check for overalignment 
> already use __STDCPP_DEFAULT_NEW_ALIGNMENT__ anyway, so it would be a 
> case-by-case check for those.
I'm fine with that direction if you're willing to update the patch. I'll review 
it.


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

https://reviews.llvm.org/D73245



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


[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-03-13 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech updated this revision to Diff 250202.
jranieri-grammatech added a comment.

Adding context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76083

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -43,7 +43,91 @@
"::std::unique;"
"::std::unique_ptr::release;"
"::std::basic_string::empty;"
-   "::std::vector::empty")) {}
+   "::std::vector::empty;"
+   "::std::back_inserter;"
+   "::std::distance;"
+   "::std::find;"
+   "::std::find_if;"
+   "::std::inserter;"
+   "::std::lower_bound;"
+   "::std::make_pair;"
+   "::std::map::count;"
+   "::std::map::find;"
+   "::std::map::lower_bound;"
+   "::std::move;"
+   "::std::multimap::equal_range;"
+   "::std::multimap::upper_bound;"
+   "::std::set::count;"
+   "::std::set::find;"
+   "::std::setfill;"
+   "::std::setprecision;"
+   "::std::setw;"
+   "::std::upper_bound;"
+   "::std::vector::at;"
+   // C standard library
+   "::bsearch;"
+   "::ferror;"
+   "::feof;"
+   "::isalnum;"
+   "::isalpha;"
+   "::isblank;"
+   "::iscntrl;"
+   "::isdigit;"
+   "::isgraph;"
+   "::islower;"
+   "::isprint;"
+   "::ispunct;"
+   "::isspace;"
+   "::isupper;"
+   "::iswalnum;"
+   "::iswprint;"
+   "::iswspace;"
+   "::isxdigit;"
+   "::memchr;"
+   "::memcmp;"
+   "::strcmp;"
+   "::strcoll;"
+   "::strncmp;"
+   "::strpbrk;"
+   "::strrchr;"
+   "::strspn;"
+   "::strstr;"
+   "::wcscmp;"
+   // POSIX
+   "::access;"
+   "::bind;"
+   "::connect;"
+   "::difftime;"
+   "::dlsym;"
+   "::fnmatch;"
+   "::getaddrinfo;"
+   "::getopt;"
+   "::htonl;"
+   "::htons;"
+   "::iconv_open;"
+   "::inet_addr;"
+   "::isascii;"
+   "::isatty;"
+   "::mmap;"
+   "::newlocale;"
+   "::openat;"
+   "::pathconf;"
+   "::pthread_equal;"
+   "::pthread_getspecific;"
+   "::pthread_mutex_trylock;"
+   "::readdir;"
+   "::readlink;"
+   "::recvmsg;"
+   "::regexec;"
+   "::scandir;"
+   "::semget;"
+   "::setjmp;"
+   "::shm_open;"
+ 

[clang] 03993f3 - [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-13 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-03-13T17:58:02+03:00
New Revision: 03993f3b6f46ae533575ec057bb84c80d8218641

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

LOG: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

Summary:
D69169, which was necessary for running libc++ tests on remote host, got 
reverted. I couldn't think of a less invasive way to achieve this behavior but 
specify libc++abi paths in our cache file.

Reviewers: vvereschaka, aorlov, andreil99, EricWF

Reviewed By: vvereschaka

Subscribers: mgorny, kristof.beyls, ldionne, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 50957b153328..0d359a1609a5 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -25,6 +25,14 @@
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
 
+# LLVM_PROJECT_DIR is the path to the llvm-project directory.
+# The right way to compute it would probably be to use 
"${CMAKE_SOURCE_DIR}/../",
+# but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
+# that we still need to support (for instance, 3.10.2).
+get_filename_component(LLVM_PROJECT_DIR
+   "${CMAKE_CURRENT_LIST_DIR}/../../../"
+   ABSOLUTE)
+
 if (NOT DEFINED DEFAULT_SYSROOT)
   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain 
build.")
 endif()
@@ -83,6 +91,9 @@ set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


[clang] 172f146 - [OPENMP]Reduce number of captured global vars.

2020-03-13 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-13T10:47:54-04:00
New Revision: 172f1460ae05ab5c33c757142c8bdb10acfbdbe1

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

LOG: [OPENMP]Reduce number of captured global vars.

Try to reduce the number of global vars captured in the OpenMP regions
by capturing them only the regions, which mark them as not-shared.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ee02d3189816..ead15bf7da2d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9858,6 +9858,13 @@ class Sema final {
   bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,
   unsigned CaptureLevel) const;
 
+  /// Check if the specified global variable must be captured  by outer capture
+  /// regions.
+  /// \param Level Relative level of nested OpenMP construct for that
+  /// the check is performed.
+  bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level,
+  unsigned CaptureLevel) const;
+
   ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
 Expr *Op);
   /// Called on start of new data sharing attribute block.

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 55057c19df4f..83807f609e90 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -57,7 +57,8 @@ class OMPLexicalScope : public CodeGenFunction::LexicalScope {
   static bool isCapturedVar(CodeGenFunction &CGF, const VarDecl *VD) {
 return CGF.LambdaCaptureFields.lookup(VD) ||
(CGF.CapturedStmtInfo && CGF.CapturedStmtInfo->lookup(VD)) ||
-   (CGF.CurCodeDecl && isa(CGF.CurCodeDecl));
+   (CGF.CurCodeDecl && isa(CGF.CurCodeDecl) &&
+cast(CGF.CurCodeDecl)->capturesVariable(VD));
   }
 
 public:
@@ -5551,7 +5552,11 @@ void 
CodeGenFunction::EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S) {
   assert(isOpenMPTaskLoopDirective(S.getDirectiveKind()));
   // Emit outlined function for task construct.
   const CapturedStmt *CS = S.getCapturedStmt(OMPD_taskloop);
-  Address CapturedStruct = GenerateCapturedStmtArgument(*CS);
+  Address CapturedStruct = Address::invalid();
+  {
+OMPLexicalScope Scope(*this, S, OMPD_taskloop, /*EmitPreInitStmt=*/false);
+CapturedStruct = GenerateCapturedStmtArgument(*CS);
+  }
   QualType SharedsTy = getContext().getRecordType(CS->getCapturedRecordDecl());
   const Expr *IfCond = nullptr;
   for (const auto *C : S.getClausesOfKind()) {

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b2fe4fe2c588..8cc5ac267774 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16523,13 +16523,19 @@ bool Sema::tryCaptureVariable(
   !IsOpenMPPrivateDecl &&
   isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel,
  RSI->OpenMPCaptureLevel);
+  // Do not capture global if it is not privatized in outer regions.
+  bool IsGlobalCap =
+  IsGlobal && isOpenMPGlobalCapturedDecl(Var, RSI->OpenMPLevel,
+ RSI->OpenMPCaptureLevel);
+
   // When we detect target captures we are looking from inside the
   // target region, therefore we need to propagate the capture from the
   // enclosing region. Therefore, the capture is not initially nested.
   if (IsTargetCap)
 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, 
RSI->OpenMPLevel);
 
-  if (IsTargetCap || IsOpenMPPrivateDecl) {
+  if (IsTargetCap || IsOpenMPPrivateDecl ||
+  (IsGlobal && !IsGlobalCap)) {
 Nested = !IsTargetCap;
 DeclRefType = DeclRefType.getUnqualifiedType();
 CaptureType = Context.getLValueReferenceType(DeclRefType);

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 89b7c0b1cd0d..a3506bf046f7 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -498,6 +498,8 @@ class DSAStackTy {
   const DSAVarData getTopDSA(ValueDecl *D, bool FromParent);
   /// Returns data-sharing attrib

[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Looks like there's a memory corruption detected by ASAN, but I'm not sure it's 
related to my change. Maybe someone with a more expert eye could tell?

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/26137/steps/check-asan%20in%20gcc%20build/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

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

In D70265#1921013 , @vingeldal wrote:

> In D70265#1920379 , @aaron.ballman 
> wrote:
>
> > LGTM! Do you need someone to commit on your behalf?
>
>
> Yes please.


Happy to do so -- I've commit on your behalf in 
512767eb3fe9c34c655a480d034147c54f1d4f85 
. Thank 
you for the new check!

> Do I need to, or can I, do anything about the failing builds 
> (https://reviews.llvm.org/B49012) first? They seem unrelated to my change but 
> I'm not sure what caused that.

They're unrelated to your change, so there's nothing for you to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D75542: [Sema] Prevent UB for uninitialized `IsSurrogate`

2020-03-13 Thread Brian Gesiak via Phabricator via cfe-commits
modocache abandoned this revision.
modocache added a comment.

Awesome, thanks!

> Alternatively, I considered modifying the `clang::OverloadCandidate` 
> constructor to initialize `IsSurrogate` with a false value. I feel doing so 
> would be safer, but I stuck with what appears to be the convention: 
> initializing OverloadCandidate members are the site of use.

Looks like the patch does exactly this, which is nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75542



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


[clang-tools-extra] 512767e - Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-13 Thread Aaron Ballman via cfe-commits

Author: Kim Viggedal
Date: 2020-03-13T10:05:13-04:00
New Revision: 512767eb3fe9c34c655a480d034147c54f1d4f85

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

LOG: Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

Cpp Core Guideline I.2, a.k.a "Avoid non-const global variables"
For detailed documentation, see:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#i2-avoid-non-const-global-variables

Added: 

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
new file mode 100644
index ..da94ac03ae19
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -0,0 +1,67 @@
+//===--- AvoidNonConstGlobalVariablesCheck.cpp - clang-tidy 
---===//
+//
+// 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 "AvoidNonConstGlobalVariablesCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+void AvoidNonConstGlobalVariablesCheck::registerMatchers(MatchFinder *Finder) {
+  auto GlobalVariable = varDecl(
+  hasGlobalStorage(),
+  unless(anyOf(
+  isConstexpr(), hasType(isConstQualified()),
+  hasType(referenceType(); // References can't be changed, only the
+   // data they reference can be changed.
+
+  auto GlobalReferenceToNonConst =
+  varDecl(hasGlobalStorage(), hasType(referenceType()),
+  unless(hasType(references(qualType(isConstQualified());
+
+  auto GlobalPointerToNonConst =
+  varDecl(hasGlobalStorage(),
+  hasType(pointerType(pointee(unless(isConstQualified());
+
+  Finder->addMatcher(GlobalVariable.bind("non-const_variable"), this);
+  
Finder->addMatcher(GlobalReferenceToNonConst.bind("indirection_to_non-const"),
+ this);
+  Finder->addMatcher(GlobalPointerToNonConst.bind("indirection_to_non-const"),
+ this);
+}
+
+void AvoidNonConstGlobalVariablesCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  if (const auto *Variable =
+  Result.Nodes.getNodeAs("non-const_variable")) {
+diag(Variable->getLocation(), "variable %0 is non-const and globally "
+  "accessible, consider making it const")
+<< Variable; // FIXME: Add fix-it hint to Variable
+// Don't return early, a non-const variable may also be a pointer or
+// reference to non-const data.
+  }
+
+  if (const auto *VD =
+  Result.Nodes.getNodeAs("indirection_to_non-const")) {
+diag(VD->getLocation(),
+ "variable %0 provides global access to a non-const object; consider "
+ "making the %select{referenced|pointed-to}1 data 'const'")
+<< VD
+<< VD->getType()->isPointerType(); // FIXME: Add fix-it hint to 
Variable
+  }
+}
+
+} // namespace cppcoreguidelines
+} // namespace tidy
+} // namespace clang

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
new file mode 100644
index ..4f5a2a025033
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
@@ -0,0 +1,35 @@
+//===--- AvoidNonConstGlobalVariablesCheck.h - clang-tidy ---*- 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
+//
+//===--

[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX.

2020-03-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: cebowleratibm, sfertile.
Herald added subscribers: cfe-commits, kbarton, hiraditya, nemanjai.
Herald added a project: clang.

This patch adds support for handling of variadic functions for AIX. This 
includes ensuring that use and consume correct type of va_list (char *va_list) 
for AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76130

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-vararg.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-32.ll
  llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll

Index: llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-cc-abi-va_args-64.ll
@@ -0,0 +1,316 @@
+; RUN: llc -O2 -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp -verify-machineinstrs < %s | \
+; RUN: FileCheck --check-prefixes=CHECK,64BIT %s
+
+; RUN: llc -O2 -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \
+; RUN:  -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefixes=CHECKASM,ASM64PWR4 %s
+
+
+  @a = local_unnamed_addr global i32 1, align 4
+  @b = local_unnamed_addr global i32 2, align 4
+  @c = local_unnamed_addr global i32 3, align 4
+  @d = local_unnamed_addr global i32 4, align 4
+  @e = local_unnamed_addr global i32 5, align 4
+  @f = local_unnamed_addr global i32 6, align 4
+  @g = local_unnamed_addr global i32 7, align 4
+  @h = local_unnamed_addr global i32 8, align 4
+  @i = local_unnamed_addr global i32 9, align 4
+  @j = local_unnamed_addr global i32 10, align 4
+
+define signext i32 @va_arg1(i32 signext %a, ...) local_unnamed_addr #0 {
+entry:
+  %arg = alloca i8*, align 8
+  %0 = bitcast i8** %arg to i8*
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0) #2
+  call void @llvm.va_start(i8* nonnull %0)
+  %cmp7 = icmp sgt i32 %a, 0
+  br i1 %cmp7, label %for.body.preheader, label %for.end
+
+for.body.preheader:   ; preds = %entry
+  %argp.cur.pre = load i8*, i8** %arg, align 8
+  %1 = add i32 %a, -1
+  %2 = zext i32 %1 to i64
+  %3 = add nuw nsw i64 %2, 1
+  %min.iters.check = icmp ult i32 %1, 8
+  br i1 %min.iters.check, label %for.body.preheader28, label %vector.memcheck
+
+vector.memcheck:  ; preds = %for.body.preheader
+  %uglygep = getelementptr inbounds i8, i8* %0, i64 1
+  %scevgep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %4 = shl nuw nsw i64 %2, 3
+  %5 = add nuw nsw i64 %4, 8
+  %scevgep11 = getelementptr i8, i8* %argp.cur.pre, i64 %5
+  %bound0 = icmp ugt i8* %scevgep11, %0
+  %bound1 = icmp ult i8* %scevgep, %uglygep
+  %found.conflict = and i1 %bound0, %bound1
+  br i1 %found.conflict, label %for.body.preheader28, label %vector.ph
+
+vector.ph:; preds = %vector.memcheck
+  %n.mod.vf = and i64 %3, 7
+  %6 = icmp eq i64 %n.mod.vf, 0
+  %7 = select i1 %6, i64 8, i64 %n.mod.vf
+  %n.vec = sub nsw i64 %3, %7
+  %8 = shl nsw i64 %n.vec, 3
+  %ind.end = getelementptr i8, i8* %argp.cur.pre, i64 %8
+  %ind.end13 = trunc i64 %n.vec to i32
+  %next.gep = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep17 = getelementptr i8, i8* %argp.cur.pre, i64 4
+  %next.gep20 = getelementptr i8, i8* %argp.cur.pre, i64 8
+  br label %vector.body
+
+vector.body:  ; preds = %vector.body, %vector.ph
+  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
+  %vec.phi = phi <4 x i32> [ , %vector.ph ], [ %19, %vector.body ]
+  %vec.phi21 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
+  %9 = shl i64 %index, 3
+  %10 = shl i64 %index, 3
+  %11 = or i64 %10, 32
+  %12 = shl i64 %index, 3
+  %13 = or i64 %12, 56
+  %14 = getelementptr inbounds i8, i8* %next.gep20, i64 %13
+  %15 = getelementptr inbounds i8, i8* %next.gep, i64 %9
+  %16 = getelementptr inbounds i8, i8* %next.gep17, i64 %11
+  %17 = bitcast i8* %15 to <8 x i32>*
+  %18 = bitcast i8* %16 to <8 x i32>*
+  %wide.vec = load <8 x i32>, <8 x i32>* %17, align 4
+  %wide.vec23 = load <8 x i32>, <8 x i32>* %18, align 4
+  %strided.vec = shufflevector <8 x i32> %wide.vec, <8 x i32> undef, <4 x i32> 
+  %strided.vec24 = shufflevector <8 x i32> %wide.vec23, <8 x i32> undef, <4 x i32> 
+  %19 = add <4 x i32> %strided.vec, %vec.phi
+  %20 = add <4 x i32> %strided.vec24, %vec.phi21
+  %index.next = add i64 %index, 8
+  %21 = icmp eq i64 %index.next, %n.vec
+  br i1 %21, label %middle.block, label %vector.body
+
+middle.block: ; preds = %vector.body
+  store i8* %14, i8** %arg, align 8
+  %bin.rdx = add <4 x i32> %20, %19
+  %rdx.shuf = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> 
+  %bin.rdx25 = add <4 x i32> %bin.rdx, %rdx.shuf
+  %rdx.shuf26 = shufflevector <4 x i32> %bin.rdx25, <4 x i32> undef, <4 x i3

[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-03-13 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 250191.
danielkiss marked an inline comment as done.
danielkiss added a comment.

Patch is rebased, test is updated.


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

https://reviews.llvm.org/D75181

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGen/aarch64-sign-return-address.c
  clang/test/CodeGenCXX/aarch64-branch-target_clang_call_terminate.cpp
  clang/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64CallLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
  llvm/test/CodeGen/AArch64/branch-target-enforcement.mir
  llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
  llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
  llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll

Index: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
===
--- llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
+++ llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
@@ -1,6 +1,6 @@
 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
 
-define void @f0() "patchable-function-entry"="0" "branch-target-enforcement" {
+define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f0:
 ; CHECK-NEXT: .Lfunc_begin0:
 ; CHECK:  // %bb.0:
@@ -12,7 +12,7 @@
 
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, place the label .Lpatch0 after the initial BTI.
-define void @f1() "patchable-function-entry"="1" "branch-target-enforcement" {
+define void @f1() "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1:
 ; CHECK-NEXT: .Lfunc_begin1:
 ; CHECK-NEXT: .cfi_startproc
@@ -28,7 +28,7 @@
 }
 
 ;; -fpatchable-function-entry=2,1 -mbranch-protection=bti
-define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement" {
+define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: .type f2_1,@function
 ; CHECK-NEXT: .Ltmp0:
 ; CHECK-NEXT:  nop
@@ -50,7 +50,7 @@
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, don't create .Lpatch0 if the initial instruction is not BTI,
 ;; even if other basic blocks may have BTI.
-define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement" {
+define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1i:
 ; CHECK-NEXT: .Lfunc_begin3:
 ; CHECK:  // %bb.0:
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=aarch64-linux %s   -o - | \
+; RUN:   FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - | \
+; RUN:   llvm-readelf --notes | FileCheck %s --check-prefix=OBJ
+
+define dso_local i32 @f() #0 {
+entry:
+  ret i32 0
+}
+
+define dso_local i32 @g() {
+entry:
+  ret i32 0
+}
+
+attributes #0 = { "branch-target-enforcement"="true" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
+; Only the common atttribute (BTI)
+; ASM:	.word	3221225472
+; ASM-NEXT:	.word	4
+; ASM-NEXT	.word	1
+
+; OBJ: Properties: aarch64 feature: BTI
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
@@ -11,7 +11,11 @@
 
 declare dso_local i32 @g()
 
-attributes #0 = { "branch-target-enforcement" }
+attributes #0 = { "branch-target-enforcement"="true" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcemen

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-13 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D57497#1920870 , @shiva0217 wrote:

> In D57497#1920097 , @apazos wrote:
>
> > Thanks Shiva, I res-ynced and rebuilt the patch. It is working fine.
> >
> > I see there is a msmall-data-threshold flag used by Mips and Hexagon, and 
> > now we are adding a new flag msmall-data-limit. Should't we reuse the flag?
>
>
> Hi Ana, 
>  Thanks for trying the patch. msmall-data-limit is also a RISCV GCC flag, so 
> I would recommend using the same flag as GCC.


How hard would it be to use the `-msmall-data-threshold` flag work if a 
`-msmall-data-limit` flag is not provided?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

In D76077#1919861 , @rjmccall wrote:

> I don't understand why you wouldn't add a new IR type for this; doing so 
> should be totally mechanical.


We had a few reasons for doing it this way.

By adding a new IR type we would need to consider calling conventions, and IR 
optimizations for what is essentially an opaque storage-only type.

Bfloat has no soft ABI, and all the supported operations can be handled through 
intrinsics (in a later patch, removed here due to bloat). If we were to add a 
new IR type, then we would need to handle many operations which would extend 
beyond what the type is supported for. For instance in GCC we had to add a new 
mode in RTL to handle inline memcopy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D76128: [AST] Correct the CXXOperatorCallExpr source range.

2020-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, ilya-biryukov.
Herald added a project: clang.

Previously, the range for "->" CXXOperatorCallExpr is the range of the
class object (not including the operator!), e.g. "[[vector_ptr]]->size()".

This patch includes the range of the operator, which fixes the issue
where clangd doesn't go to the overloaded operator "->" definition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76128

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/AST/ExprCXX.cpp


Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -637,7 +637,7 @@
   // Postfix operator
   return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
   } else if (Kind == OO_Arrow) {
-return getArg(0)->getSourceRange();
+return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
   } else if (Kind == OO_Call) {
 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
   } else if (Kind == OO_Subscript) {
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -451,6 +451,14 @@
 }
   )cpp",
 
+  R"cpp(
+struct S1 { void f(); };
+struct S2 { S1 * $decl[[operator]]->(); };
+void test(S2 s2) {
+  s2-^>f();
+}
+  )cpp",
+
   R"cpp(// Declaration of explicit template specialization
 template 
 struct $decl[[Foo]] {};
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -380,6 +380,14 @@
   {"struct foo { [[^~foo()]]; };", "CXXDestructorDecl"},
   // FIXME: The following to should be class itself instead.
   {"struct foo { [[fo^o(){}]] };", "CXXConstructorDecl"},
+
+  {R"cpp(
+struct S1 { void f(); };
+struct S2 { S1 * operator->(); };
+void test(S2 s2) {
+  s2[[-^>]]f();
+}
+  )cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
   };
   for (const Case &C : Cases) {
 Annotations Test(C.Code);
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -649,9 +649,14 @@
const ForStmt *Loop,
const Expr *ContainerExpr) {
   StringRef ContainerString;
-  if (isa(ContainerExpr->IgnoreParenImpCasts())) {
+  ContainerExpr = ContainerExpr->IgnoreParenImpCasts();
+  if (isa(ContainerExpr)) {
 ContainerString = "this";
   } else {
+// For CXXOperatorCallExpr (e.g. vector_ptr->size()), its first argument is
+// the class object (vector_ptr) we are targeting.
+if (const auto* E = dyn_cast(ContainerExpr))
+  ContainerExpr = E->getArg(0);
 ContainerString =
 getStringFromRange(Context->getSourceManager(), Context->getLangOpts(),
ContainerExpr->getSourceRange());


Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -637,7 +637,7 @@
   // Postfix operator
   return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
   } else if (Kind == OO_Arrow) {
-return getArg(0)->getSourceRange();
+return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
   } else if (Kind == OO_Call) {
 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
   } else if (Kind == OO_Subscript) {
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -451,6 +451,14 @@
 }
   )cpp",
 
+  R"cpp(
+struct S1 { void f(); };
+struct S2 { S1 * $decl[[operator]]->(); };
+void test(S2 s2) {
+  s2-^>f();
+}
+  )cpp",
+
   R"cpp(// Declaration of explicit template specialization
 template 
 struct $decl[[Foo]] {};
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson marked an inline comment as done.
LukeGeeson added inline comments.



Comment at: clang/test/CodeGen/arm-mangle-16bit-float.cpp:4
+
+// CHECK64: define {{.*}}void @_Z3foou6__bf16(half %b)
+// CHECK32: define {{.*}}void @_Z3foou6__bf16(i32 %b.coerce)

craig.topper wrote:
> How can bfloat16 be passed as half? Don't they have a different format?
see the above comment about soft-abis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 250184.
hokein added a comment.

remove an accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/SemaTemplate/dependent-typos-recovery.cpp

Index: clang/test/SemaTemplate/dependent-typos-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/dependent-typos-recovery.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'template' keywords.
+struct B {
+  template 
+  int f(){};
+} builder;// expected-note 2{{'builder' declared here}}
+
+auto a = bilder.f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
+auto b = (*(&bilder+0)).f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1604,7 +1604,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus &&
-  ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return ANK_Error;
 
   if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
@@ -1840,8 +1840,7 @@
 //simple-template-id
 SourceLocation TypenameLoc = ConsumeToken();
 CXXScopeSpec SS;
-if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
-   /*EnteringContext=*/false, nullptr,
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext=*/false, nullptr,
/*IsTypename*/ true))
   return true;
 if (SS.isEmpty()) {
@@ -1913,7 +1912,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus)
-if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext*/ false))
   return true;
 
   return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
@@ -2042,7 +2041,7 @@
   assert(MightBeCXXScopeToken() && "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return true;
   if (SS.isEmpty())
 return false;
@@ -2151,8 +2150,7 @@
 
   // Parse nested-name-specifier.
   if (getLangOpts().CPlusPlus)
-ParseOptionalCXXScopeSpecifier(Result.SS, nullptr,
-   /*EnteringContext=*/false);
+ParseOptionalCXXScopeSpecifier(Result.SS, /*EnteringContext=*/false);
 
   // Check nested-name specifier.
   if (Result.SS.isInvalid()) {
@@ -2163,8 +2161,8 @@
   // Parse the unqualified-id.
   SourceLocation TemplateKWLoc; // FIXME: parsed, but unused.
   if (ParseUnqualifiedId(
-  Result.SS, /*EnteringContext*/false, /*AllowDestructorName*/true,
-  /*AllowConstructorName*/true, /*AllowDeductionGuide*/false, nullptr,
+  Result.SS, /*EnteringContext*/ false, /*AllowDestructorName*/ true,
+  /*AllowConstructorName*/ true, /*AllowDeductionGuide*/ false,
   &TemplateKWLoc, Result.Name)) {
 T.skipToEnd();
 return true;
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -363,9 +363,9 @@
   DiagnoseAndSkipCXX11Attributes();
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
-  /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
-  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
+  if (ParseOptionalCXXScopeSpecifier(
+  SS, /*EnteringContext=*/false, /*MayBePseudoDestructor=*/nullptr,
+  /*IsTypename=*/false, /*LastII=*/nullptr, /*OnlyNamespace=*/true) ||
   SS.isInvalid()) {
 SkipUntil(tok::semi);
 return nullptr;
@@ -380,8 +380,7 @@
  /*AllowDestructorName=*/false,
  /*AllowConstructorName=*/false,
  /*AllowDeductionGuide=*/false,
- /*ObjectType=*/ParsedType(), /*TemplateKWLoc=*/nullptr,
- Result)) {
+ /*TemplateKWLoc=*/nullptr, Result)) {
 SkipUntil(tok::semi);
 return nullptr;
   }
@@ -683,7 +682,7 @@
   CXXScopeSpec SS;
   bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope);
   if (ParseOptionalCXXScopeSpeci

[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28ad9fc20823: [Clang][Driver] In -fintegrated-cc1 mode, 
avoid crashing on exit after a… (authored by aganea).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76099

Files:
  clang/lib/Lex/Pragma.cpp
  clang/tools/driver/driver.cpp
  llvm/include/llvm/Support/ManagedStatic.h
  llvm/include/llvm/Support/Timer.h
  llvm/lib/Support/Timer.cpp

Index: llvm/lib/Support/Timer.cpp
===
--- llvm/lib/Support/Timer.cpp
+++ llvm/lib/Support/Timer.cpp
@@ -442,3 +442,7 @@
 void TimerGroup::ConstructTimerLists() {
   (void)*NamedGroupedTimers;
 }
+
+std::unique_ptr TimerGroup::aquireDefaultGroup() {
+  return std::unique_ptr(DefaultTimerGroup.claim());
+}
Index: llvm/include/llvm/Support/Timer.h
===
--- llvm/include/llvm/Support/Timer.h
+++ llvm/include/llvm/Support/Timer.h
@@ -230,6 +230,11 @@
   /// used by the Statistic code to influence the construction and destruction
   /// order of the global timer lists.
   static void ConstructTimerLists();
+
+  /// This makes the default group unmanaged, and lets the user manage the
+  /// group's lifetime.
+  static std::unique_ptr aquireDefaultGroup();
+
 private:
   friend class Timer;
   friend void PrintStatisticsJSON(raw_ostream &OS);
Index: llvm/include/llvm/Support/ManagedStatic.h
===
--- llvm/include/llvm/Support/ManagedStatic.h
+++ llvm/include/llvm/Support/ManagedStatic.h
@@ -102,6 +102,12 @@
   }
 
   const C *operator->() const { return &**this; }
+
+  // Extract the instance, leaving the ManagedStatic uninitialized. The
+  // user is then responsible for the lifetime of the returned instance.
+  C *claim() {
+return static_cast(Ptr.exchange(nullptr));
+  }
 };
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -491,6 +492,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 1;
+  bool IsCrash = false;
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
@@ -517,11 +519,11 @@
   // If result status is 70, then the driver command reported a fatal error.
   // On Windows, abort will return an exit code of 3.  In these cases,
   // generate additional diagnostic information if possible.
-  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+  IsCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef _WIN32
-  DiagnoseCrash |= CommandRes == 3;
+  IsCrash |= CommandRes == 3;
 #endif
-  if (DiagnoseCrash) {
+  if (IsCrash) {
 TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
 break;
   }
@@ -530,10 +532,16 @@
 
   Diags.getClient()->finish();
 
-  // If any timers were active but haven't been destroyed yet, print their
-  // results now.  This happens in -disable-free mode.
-  llvm::TimerGroup::printAll(llvm::errs());
-  llvm::TimerGroup::clearAll();
+  if (!UseNewCC1Process && IsCrash) {
+// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
+// the internal linked list might point to already released stack frames.
+llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
+  } else {
+// If any timers were active but haven't been destroyed yet, print their
+// results now.  This happens in -disable-free mode.
+llvm::TimerGroup::printAll(llvm::errs());
+llvm::TimerGroup::clearAll();
+  }
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -42,6 +42,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 #include 
@@ -1038,6 +1039,8 @@
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 llvm_unreachable("This is an assertion!");
 } else if (II->isStr("crash")) {
+  llvm::Timer T("crash", "pragma crash");
+  llvm::TimeRegion R(&T);
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 LLVM_BUILTIN_TRAP;
 } else if (II->isStr("parser_crash"))

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

In D76077#1919897 , @rjmccall wrote:

> Note that we have an IR type for the PPC double-double format, which isn't 
> even hardware-supported.  This is literally just an IEEE floating-point 
> format with non-standard parameters, right?


Indeed yeah, the details are laid out in a blog post here: 
https://community.arm.com/developer/ip-products/processors/b/ml-ip-blog/posts/bfloat16-processing-for-neural-networks-on-armv8_2d00_a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D65592: [Parser] Avoid spurious 'missing template' error in presence of typos

2020-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 250183.
hokein added a comment.

- rebase to master
- update some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65592

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/dependent-typos-recovery.cpp

Index: clang/test/SemaTemplate/dependent-typos-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/dependent-typos-recovery.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'template' keywords.
+struct B {
+  template 
+  int f(){};
+} builder;// expected-note 2{{'builder' declared here}}
+
+auto a = bilder.f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
+auto b = (*(&bilder+0)).f(); // expected-error{{undeclared identifier 'bilder'; did you mean}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -125,14 +125,11 @@
   return false;
 }
 
-TemplateNameKind Sema::isTemplateName(Scope *S,
-  CXXScopeSpec &SS,
-  bool hasTemplateKeyword,
-  const UnqualifiedId &Name,
-  ParsedType ObjectTypePtr,
-  bool EnteringContext,
-  TemplateTy &TemplateResult,
-  bool &MemberOfUnknownSpecialization) {
+TemplateNameKind
+Sema::isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword,
+ const UnqualifiedId &Name, ParsedType ObjectTypePtr,
+ bool EnteringContext, TemplateTy &TemplateResult,
+ bool &MemberOfUnknownSpecialization) {
   assert(getLangOpts().CPlusPlus && "No template names in C!");
 
   DeclarationName TName;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1604,7 +1604,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus &&
-  ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return ANK_Error;
 
   if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
@@ -1840,8 +1840,7 @@
 //simple-template-id
 SourceLocation TypenameLoc = ConsumeToken();
 CXXScopeSpec SS;
-if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
-   /*EnteringContext=*/false, nullptr,
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext=*/false, nullptr,
/*IsTypename*/ true))
   return true;
 if (SS.isEmpty()) {
@@ -1913,7 +1912,7 @@
 
   CXXScopeSpec SS;
   if (getLangOpts().CPlusPlus)
-if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
+if (ParseOptionalCXXScopeSpecifier(SS, /*EnteringContext*/ false))
   return true;
 
   return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
@@ -2042,7 +2041,7 @@
   assert(MightBeCXXScopeToken() && "Cannot be a type or scope token!");
 
   CXXScopeSpec SS;
-  if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+  if (ParseOptionalCXXScopeSpecifier(SS, EnteringContext))
 return true;
   if (SS.isEmpty())
 return false;
@@ -2151,8 +2150,7 @@
 
   // Parse nested-name-specifier.
   if (getLangOpts().CPlusPlus)
-ParseOptionalCXXScopeSpecifier(Result.SS, nullptr,
-   /*EnteringContext=*/false);
+ParseOptionalCXXScopeSpecifier(Result.SS, /*EnteringContext=*/false);
 
   // Check nested-name specifier.
   if (Result.SS.isInvalid()) {
@@ -2163,8 +2161,8 @@
   // Parse the unqualified-id.
   SourceLocation TemplateKWLoc; // FIXME: parsed, but unused.
   if (ParseUnqualifiedId(
-  Result.SS, /*EnteringContext*/false, /*AllowDestructorName*/true,
-  /*AllowConstructorName*/true, /*AllowDeductionGuide*/false, nullptr,
+  Result.SS, /*EnteringContext*/ false, /*AllowDestructorName*/ true,
+  /*AllowConstructorName*/ true, /*AllowDeductionGuide*/ false,
   &TemplateKWLoc, Result.Name)) {
 T.skipToEnd();
 return true;
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/l

[clang] 28ad9fc - [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-13 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-03-13T08:15:35-04:00
New Revision: 28ad9fc20823678881baa0d723834b88ea9e8e3a

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

LOG: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a 
compiler crash

After a crash catched by the CrashRecoveryContext, this patch prevents from 
accessing dangling pointers in TimerGroup structures before the clang tool 
exits. Previously, the default TimerGroup had internal linked lists which were 
still pointing to old Timer or TimerGroup instances, which lived in stack 
frames released by the CrashRecoveryContext.

Fixes PR45164.

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

Added: 


Modified: 
clang/lib/Lex/Pragma.cpp
clang/tools/driver/driver.cpp
llvm/include/llvm/Support/ManagedStatic.h
llvm/include/llvm/Support/Timer.h
llvm/lib/Support/Timer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index a8cd18b123b0..57a95815488e 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -42,6 +42,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 #include 
@@ -1038,6 +1039,8 @@ struct PragmaDebugHandler : public PragmaHandler {
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 llvm_unreachable("This is an assertion!");
 } else if (II->isStr("crash")) {
+  llvm::Timer T("crash", "pragma crash");
+  llvm::TimeRegion R(&T);
   if (!PP.getPreprocessorOpts().DisablePragmaDebugCrash)
 LLVM_BUILTIN_TRAP;
 } else if (II->isStr("parser_crash")) {

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 843fa4bdbca2..c59752178b66 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -491,6 +492,7 @@ int main(int argc_, const char **argv_) {
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 1;
+  bool IsCrash = false;
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
@@ -517,11 +519,11 @@ int main(int argc_, const char **argv_) {
   // If result status is 70, then the driver command reported a fatal 
error.
   // On Windows, abort will return an exit code of 3.  In these cases,
   // generate additional diagnostic information if possible.
-  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+  IsCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef _WIN32
-  DiagnoseCrash |= CommandRes == 3;
+  IsCrash |= CommandRes == 3;
 #endif
-  if (DiagnoseCrash) {
+  if (IsCrash) {
 TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
 break;
   }
@@ -530,10 +532,16 @@ int main(int argc_, const char **argv_) {
 
   Diags.getClient()->finish();
 
-  // If any timers were active but haven't been destroyed yet, print their
-  // results now.  This happens in -disable-free mode.
-  llvm::TimerGroup::printAll(llvm::errs());
-  llvm::TimerGroup::clearAll();
+  if (!UseNewCC1Process && IsCrash) {
+// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
+// the internal linked list might point to already released stack frames.
+llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
+  } else {
+// If any timers were active but haven't been destroyed yet, print their
+// results now.  This happens in -disable-free mode.
+llvm::TimerGroup::printAll(llvm::errs());
+llvm::TimerGroup::clearAll();
+  }
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.

diff  --git a/llvm/include/llvm/Support/ManagedStatic.h 
b/llvm/include/llvm/Support/ManagedStatic.h
index e65bb051f181..bbd0d04ed040 100644
--- a/llvm/include/llvm/Support/ManagedStatic.h
+++ b/llvm/include/llvm/Support/ManagedStatic.h
@@ -102,6 +102,12 @@ class ManagedStatic : public ManagedStaticBase {
   }
 
   const C *operator->() const { return &**this; }
+
+  // Extract the instance, leaving the ManagedStatic uninitialized. The
+  // user is then responsible for the lifetime of the returned instance.
+  C *claim() {
+return static_cast(Ptr.exchange(nullptr));
+  }
 };
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.

diff  --git a/llvm/include/llvm/Support/Timer.h 
b/llvm/include/llvm/Support/Time

[PATCH] D75677: [Analyzer] Only add iterator note tags to the operations of the affected iterators

2020-03-13 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 6 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp:91-111
   SVal V = C.getSVal(CE->getArg(0));
   const auto *Pos = getIteratorPosition(State, V);
+  SVal Field = Default;
+
   if (Pos) {
-State = State->BindExpr(CE, C.getLocationContext(), get(Pos));
-  } else {
-State = State->BindExpr(CE, C.getLocationContext(), Default);
+Field = get(Pos);
   }

Szelethus wrote:
> Now that we have multiple `SVal`s around, can we rename `V`? Also, I would 
> appreciate some comments. As I understand it, `ExprInspectionChecker` now 
> marks the arguments as interesting, so if we write this:
> ```lang=cpp
> clang_analyzer_express(clang_analyzer_iterator_position(i2));
> ```
> `clang_analyzer_iterator_position(i2)` will be interesting, and this function 
> propagates this interestingness to `i2`, correct?
Yes.



Comment at: clang/test/Analysis/iterator-modelling.cpp:169
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // 
expected-warning{{TRUE}}
 // 
expected-note@-1{{TRUE}}

Szelethus wrote:
> Interestingness won't be propagated here because 
> `clang_analyzer_iterator_container(i2) == &v` is interesting, not 
> `clang_analyzer_iterator_container(i2)`, correct?
Currently only `clang_analyzer_express()` marks its argument as interesting. 
This could be extended in the future, however the argument of 
`clang_analyzer_eval()` is usually the result of the comparison, not the 
symbolic comparison itself so the sides of the comparison are not reachable at 
that point.


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

https://reviews.llvm.org/D75677



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


[PATCH] D76076: [HIP] Mark kernels with uniform-work-group-size=true

2020-03-13 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ffb12ca67fd: [HIP] Mark kernels with 
uniform-work-group-size=true (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76076

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu


Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8091,6 +8091,10 @@
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
+  if (IsHIPKernel)
+F->addFnAttr("uniform-work-group-size", "true");
+
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = 0;


Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8091,6 +8091,10 @@
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
+  if (IsHIPKernel)
+F->addFnAttr("uniform-work-group-size", "true");
+
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0ffb12c - [HIP] Mark kernels with uniform-work-group-size=true

2020-03-13 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-03-13T06:56:56-04:00
New Revision: 0ffb12ca67fd813a8ae840399626dd5f8fea3178

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

LOG: [HIP] Mark kernels with uniform-work-group-size=true

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 21d5cd08c9fa..fb472d541160 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8091,6 +8091,10 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes(
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
+  if (IsHIPKernel)
+F->addFnAttr("uniform-work-group-size", "true");
+
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = 0;

diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
index ece8685932d2..5415bddffc89 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@ __global__ void num_vgpr_64() {
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"



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


[PATCH] D76122: [ARM,MVE] Add intrinsics and isel for MVE integer VMLA.

2020-03-13 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 250174.
simon_tatham added a comment.

Fix clang-format warnings.

(Is it //really// sensible to require even //test// input files, which are 
often autogenerated, to be fixed points of clang-format?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76122

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/ternary.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
@@ -101,6 +101,168 @@
   ret <4 x float> %1
 }
 
+define arm_aapcs_vfpcc <16 x i8> @test_vmlaq_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c) {
+; CHECK-LABEL: test_vmlaq_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <16 x i8> undef, i8 %c, i32 0
+  %.splat = shufflevector <16 x i8> %.splatinsert, <16 x i8> undef, <16 x i32> zeroinitializer
+  %0 = mul <16 x i8> %.splat, %b
+  %1 = add <16 x i8> %0, %a
+  ret <16 x i8> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmlaq_n_s16(<8 x i16> %a, <8 x i16> %b, i16 signext %c) {
+; CHECK-LABEL: test_vmlaq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %c, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %0 = mul <8 x i16> %.splat, %b
+  %1 = add <8 x i16> %0, %a
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmlaq_n_s32(<4 x i32> %a, <4 x i32> %b, i32 %c) {
+; CHECK-LABEL: test_vmlaq_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x i32> undef, i32 %c, i32 0
+  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
+  %0 = mul <4 x i32> %.splat, %b
+  %1 = add <4 x i32> %0, %a
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmlaq_n_u8(<16 x i8> %a, <16 x i8> %b, i8 zeroext %c) {
+; CHECK-LABEL: test_vmlaq_n_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <16 x i8> undef, i8 %c, i32 0
+  %.splat = shufflevector <16 x i8> %.splatinsert, <16 x i8> undef, <16 x i32> zeroinitializer
+  %0 = mul <16 x i8> %.splat, %b
+  %1 = add <16 x i8> %0, %a
+  ret <16 x i8> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmlaq_n_u16(<8 x i16> %a, <8 x i16> %b, i16 zeroext %c) {
+; CHECK-LABEL: test_vmlaq_n_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %c, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %0 = mul <8 x i16> %.splat, %b
+  %1 = add <8 x i16> %0, %a
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmlaq_n_u32(<4 x i32> %a, <4 x i32> %b, i32 %c) {
+; CHECK-LABEL: test_vmlaq_n_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmla.u32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x i32> undef, i32 %c, i32 0
+  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
+  %0 = mul <4 x i32> %.splat, %b
+  %1 = add <4 x i32> %0, %a
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmlasq_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c) {
+; CHECK-LABEL: test_vmlasq_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmlas.u8 q1, q0, r0
+; CHECK-NEXT:vmov q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = mul <16 x i8> %b, %a
+  %.splatinsert = insertelement <16 x i8> undef, i8 %c, i32 0
+  %.splat = shufflevector <16 x i8> %.splatinsert, <16 x i8> undef, <16 x i32> zeroinitializer
+  %1 = add <16 x i8> %.splat, %0
+  ret <16 x i8> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmlasq_n_s16(<8 x i16> %a, <8 x i16> %b, i16 signext %c) {
+; CHECK-LABEL: test_vmlasq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmlas.u16 q1, q0, r0
+; CHECK-NEXT:vmov q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = mul <8 x i16> %b, %a
+  %.splatinsert = insertelement <8 x i16> undef, i16 %c, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %1 = add <8 x i16> %.splat, %0
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmlasq_n_s32(<4 x i32> %a, <4 x i32> %b, i32 %c) {
+; CHECK-LABEL: test_vmlasq_

[PATCH] D76125: [clangd] Decouple preambleworker from astworker, NFCI

2020-03-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.

First step to enable deferred preamble builds. Not intending to land it
alone, will have follow-ups that will implement full deferred build
functionality and will land after all of them are ready.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76125

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp

Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -49,13 +49,16 @@
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
 #include "ParsedAST.h"
+#include "Path.h"
 #include "Preamble.h"
+#include "Threading.h"
 #include "Trace.h"
 #include "index/CanonicalIncludes.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Threading.h"
@@ -149,6 +152,182 @@
 };
 
 namespace {
+/// Responsible for building and providing access to the preamble of a TU. This
+/// worker doesn't guarantee that each preamble request will be built, in case
+/// of multiple preamble requests, it will only build the last one. Once stop is
+/// called it will build any remaining request and will exit the run loop.
+class PreambleWorker {
+public:
+  PreambleWorker(llvm::StringRef FileName, ParsingCallbacks &Callbacks,
+ bool StorePreambleInMemory, bool RunSync)
+  : FileName(FileName), Callbacks(Callbacks),
+StorePreambleInMemory(StorePreambleInMemory), RunSync(RunSync) {}
+
+  size_t getUsedBytes() const {
+auto Preamble = getLatestBuiltPreamble();
+return Preamble ? Preamble->Preamble.getSize() : 0;
+  }
+
+  void requestBuild(CompilerInvocation *CI, ParseInputs PI) {
+// If compiler invocation was broken, just fail out early.
+if (!CI) {
+  TUStatus::BuildDetails Details;
+  Details.BuildFailed = true;
+  std::string TaskName = llvm::formatv("Update ({0})", PI.Version);
+  emitTUStatus({TUAction::BuildingPreamble, std::move(TaskName)}, &Details);
+  // Make sure anyone waiting for the preamble gets notified it could not be
+  // built.
+  BuiltFirstPreamble.notify();
+  return;
+}
+// Make possibly expensive copy while not holding the lock.
+Request Req = {std::make_unique(*CI), std::move(PI)};
+if (RunSync) {
+  updateLatestBuiltPreamble(buildPreamble(std::move(Req)));
+  return;
+}
+{
+  std::lock_guard Lock(Mutex);
+  assert(!Done && "Build request to PreambleWorker after stop");
+  PreambleReq = std::move(Req);
+}
+// Let the worker thread know there's a request, notify_one is safe as there
+// should be a single worker thread waiting on it.
+PreambleRequested.notify_one();
+  }
+
+  /// Blocks until at least a single request has been processed. Note that it
+  /// will unblock even after an unsuccessful build.
+  void waitForFirstPreamble() const { BuiltFirstPreamble.wait(); }
+
+  /// Returns the latest built preamble, might be null if no preamble has been
+  /// built or latest attempt resulted in a failure.
+  std::shared_ptr getLatestBuiltPreamble() const {
+std::lock_guard Lock(Mutex);
+return LastBuiltPreamble;
+  }
+
+  void run() {
+dlog("Starting preamble worker for {0}", FileName);
+while (true) {
+  {
+std::unique_lock Lock(Mutex);
+assert(!CurrentReq && "Already processing a request?");
+// Wait until stop is called or there is a request.
+PreambleRequested.wait(Lock, [this] { return PreambleReq || Done; });
+// No request means we are done.
+if (!PreambleReq)
+  break;
+CurrentReq = std::move(*PreambleReq);
+// Reset it here, before we build the request to not overwrite any new
+// request that might arrive while we are still building this one.
+PreambleReq.reset();
+  }
+  // Build the preamble and let the waiters know about it.
+  updateLatestBuiltPreamble(buildPreamble(std::move(*CurrentReq)));
+}
+// We are no longer going to build any preambles, let the waiters know that.
+BuiltFirstPreamble.notify();
+dlog("Preamble worker for {0} finished", FileName);
+  }
+
+  void stop() {
+dlog("Stopping preamble worker for {0}", FileName);
+{
+  std::lock_guard Lock(Mutex);
+  Done = true;
+}
+// Let the worker thread know we've been stopped. notify_one is safe as
+// there should be only a single worker.
+PreambleRequested.notify_one();

[PATCH] D76123: [ARM,MVE] Add intrinsics for the VQDMLAH family.

2020-03-13 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki 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/D76123/new/

https://reviews.llvm.org/D76123



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


[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-03-13 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

Hi,

I like reading your code! But I'm concerned around the lack of tests here, 
specifically:

- CPSR liveness.
- LR liveness.
- All things PIC related.
- Linkage legality.
- A negative test for Thumb-1.
- Inline asm generally concerns me too.




Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5653
+
+  // Check if each of the unsafe registers are available...
+  bool R12AvailableInBlock = LRU.available(ARM::R12);

When you say 'available', do you mean 'dead'? I'm struggling to follow the 
logic here...



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5663
+  // Now, add the live outs to the set.
+  LRU.addLiveOuts(MBB);
+

Do you need to clear LRU first?



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5705
+  unsigned Opc = MI.getOpcode();
+  if (Opc == ARM::t2IT || Opc == ARM::tPICADD || Opc == ARM::PICADD ||
+  Opc == ARM::PICSTR || Opc == ARM::PICSTRB || Opc == ARM::PICSTRH ||

I'm surprised to see IT here?



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5761
+
+  // Don't touch the link register
+  if (MI.readsRegister(ARM::LR, &getRegisterInfo()) ||

Isn't this already handled in the loop above? I prefer this notation though.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5781
+if (Subtarget.isThumb())
+  if (Call->getOperand(2).isReg())
+BuildMI(MBB, MBB.end(), DebugLoc(), get(ARM::tTAILJMPr))

Looks like this MI building could be refactored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066



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


[clang] 2e77f0c - Added 'const' as suggested by ClangTidy llvm-qualified-auto

2020-03-13 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-03-13T11:49:23+01:00
New Revision: 2e77f0cf76be7c4b78784d6bb098e0c23d670ab0

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

LOG: Added 'const' as suggested by ClangTidy llvm-qualified-auto

Added: 


Modified: 
clang/unittests/AST/DeclTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/DeclTest.cpp 
b/clang/unittests/AST/DeclTest.cpp
index bd16df8a4fd2..08b1fbb5eb8a 100644
--- a/clang/unittests/AST/DeclTest.cpp
+++ b/clang/unittests/AST/DeclTest.cpp
@@ -79,7 +79,7 @@ TEST(Decl, AsmLabelAttr) {
  "Expected target to have a global prefix");
   DiagnosticsEngine &Diags = AST->getDiagnostics();
 
-  auto *DeclS =
+  const auto *DeclS =
   selectFirst("d", match(cxxRecordDecl().bind("d"), Ctx));
   NamedDecl *DeclF = *DeclS->method_begin();
   NamedDecl *DeclG = *(++DeclS->method_begin());



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-13 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:53-55
+ast_matchers::internal::Matcher
+hasAnyListedName(std::vector Names);
+

alexfh wrote:
> We could change all checks to use the other overload and drop this one (and 
> the utils::options::parseStringList() call in each check's constructor). WDYT?
I'm not sold on that, I'd like the conventions of all checks to be the same wrt 
option lists, however those option lists aren't only used for names of decls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911



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


[PATCH] D76120: Refactor SourceLocationTest to `using namespace`

2020-03-13 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8640737d476: Refactor SourceLocationTest to `using 
namespace` (authored by hlopko, committed by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D76120?vs=250163&id=250166#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76120

Files:
  clang/unittests/AST/SourceLocationTest.cpp


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -23,8 +23,10 @@
 #include "llvm/Testing/Support/Annotations.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace ast_matchers {
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace {
 
 // FIXME: Pull the *Verifier tests into their own test file.
 
@@ -643,10 +645,8 @@
 TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(1, 1, 1, 24);
-  EXPECT_TRUE(Verifier.match(
-  "void f() noexcept(false);\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", functionDecl(),
+ Lang_CXX11));
 }
 
 class FunctionDeclParametersRangeVerifier : public RangeVerifier 
{
@@ -768,12 +768,10 @@
 TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 2, 24);
-  EXPECT_TRUE(Verifier.match(
-  "class A {\n"
-  "void f() noexcept(false);\n"
-  "};\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("class A {\n"
+ "void f() noexcept(false);\n"
+ "};\n",
+ functionDecl(), Lang_CXX11));
 }
 
 class ExceptionSpecRangeVerifier : public RangeVerifier {
@@ -816,19 +814,19 @@
   std::vector Args;
   Args.push_back("-fms-extensions");
   EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
- Args, Language::Lang_CXX));
+ Args, Lang_CXX));
 
   Verifier.expectRange(1, 10, 1, 10);
-  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
- Language::Lang_CXX11));
+  EXPECT_TRUE(
+  Verifier.match("void f() noexcept;\n", loc(functionType()), Lang_CXX11));
 
   Verifier.expectRange(1, 10, 1, 24);
   EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", 
loc(functionType()),
- Language::Lang_CXX11));
+ Lang_CXX11));
 
   Verifier.expectRange(1, 10, 1, 32);
   EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
- loc(functionType()), Language::Lang_CXX11));
+ loc(functionType()), Lang_CXX11));
 
   ParmVarExceptionSpecRangeVerifier Verifier2;
   Verifier2.expectRange(1, 25, 1, 31);
@@ -840,7 +838,7 @@
   EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) noexcept(true));\n",
   parmVarDecl(hasType(pointerType(pointee(
   parenType(innerType(functionType())),
-  Language::Lang_CXX11));
+  Lang_CXX11));
 }
 
 TEST(Decl, MemberPointerStarLoc) {
@@ -861,5 +859,4 @@
   ASSERT_EQ(SM.getFileOffset(TL.getStarLoc()), Example.point("star"));
 }
 
-} // end namespace ast_matchers
-} // end namespace clang
+} // end namespace


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -23,8 +23,10 @@
 #include "llvm/Testing/Support/Annotations.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace ast_matchers {
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace {
 
 // FIXME: Pull the *Verifier tests into their own test file.
 
@@ -643,10 +645,8 @@
 TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(1, 1, 1, 24);
-  EXPECT_TRUE(Verifier.match(
-  "void f() noexcept(false);\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", functionDecl(),
+ Lang_CXX11));
 }
 
 class FunctionDeclParametersRangeVerifier : public RangeVerifier {
@@ -768,12 +768,10 @@
 TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 2, 24);
-  EXPECT_TRUE(Verifier.match(
-  "class A {\n"
-  "void f() noexcept(false);\n"
-  "};\n",
-  functionDecl(),
-  Lan

[PATCH] D76120: Refactor SourceLocationTest to `using namespace`

2020-03-13 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko updated this revision to Diff 250162.
hlopko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76120

Files:
  clang/unittests/AST/SourceLocationTest.cpp


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -22,8 +22,10 @@
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace ast_matchers {
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace {
 
 // FIXME: Pull the *Verifier tests into their own test file.
 
@@ -642,10 +644,8 @@
 TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(1, 1, 1, 24);
-  EXPECT_TRUE(Verifier.match(
-  "void f() noexcept(false);\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", functionDecl(),
+ Lang_CXX11));
 }
 
 class FunctionDeclParametersRangeVerifier : public RangeVerifier 
{
@@ -767,12 +767,10 @@
 TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 2, 24);
-  EXPECT_TRUE(Verifier.match(
-  "class A {\n"
-  "void f() noexcept(false);\n"
-  "};\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("class A {\n"
+ "void f() noexcept(false);\n"
+ "};\n",
+ functionDecl(), Lang_CXX11));
 }
 
 class ExceptionSpecRangeVerifier : public RangeVerifier {
@@ -815,19 +813,19 @@
   std::vector Args;
   Args.push_back("-fms-extensions");
   EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
- Args, Language::Lang_CXX));
+ Args, Lang_CXX));
 
   Verifier.expectRange(1, 10, 1, 10);
-  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
- Language::Lang_CXX11));
+  EXPECT_TRUE(
+  Verifier.match("void f() noexcept;\n", loc(functionType()), Lang_CXX11));
 
   Verifier.expectRange(1, 10, 1, 24);
   EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", 
loc(functionType()),
- Language::Lang_CXX11));
+ Lang_CXX11));
 
   Verifier.expectRange(1, 10, 1, 32);
   EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
- loc(functionType()), Language::Lang_CXX11));
+ loc(functionType()), Lang_CXX11));
 
   ParmVarExceptionSpecRangeVerifier Verifier2;
   Verifier2.expectRange(1, 25, 1, 31);
@@ -839,8 +837,8 @@
   EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) noexcept(true));\n",
   parmVarDecl(hasType(pointerType(pointee(
   parenType(innerType(functionType())),
-  Language::Lang_CXX11));
+  Lang_CXX11));
 }
 
-} // end namespace ast_matchers
-} // end namespace clang
+
+} // end namespace


Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -22,8 +22,10 @@
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace ast_matchers {
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace {
 
 // FIXME: Pull the *Verifier tests into their own test file.
 
@@ -642,10 +644,8 @@
 TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(1, 1, 1, 24);
-  EXPECT_TRUE(Verifier.match(
-  "void f() noexcept(false);\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", functionDecl(),
+ Lang_CXX11));
 }
 
 class FunctionDeclParametersRangeVerifier : public RangeVerifier {
@@ -767,12 +767,10 @@
 TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 2, 24);
-  EXPECT_TRUE(Verifier.match(
-  "class A {\n"
-  "void f() noexcept(false);\n"
-  "};\n",
-  functionDecl(),
-  Language::Lang_CXX11));
+  EXPECT_TRUE(Verifier.match("class A {\n"
+ "void f() noexcept(false);\n"
+ "};\n",
+ functionDecl(), Lang_CXX11));
 }
 
 class ExceptionSpecRangeVerifier : public RangeVerifier {
@@ -815,19 +813,19 @@
   std::vector Args;
   Args.push_back("-fms-extensions");
   EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),

[PATCH] D76061: [Sema] Fix location of star ('*') inside MemberPointerTypeLoc

2020-03-13 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce79c4246919: [Sema] Fix location of star ('*') 
inside MemberPointerTypeLoc (authored by hlopko, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76061

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/SourceLocationTest.cpp

Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -15,11 +15,12 @@
 //
 //===--===//
 
-#include "clang/AST/ASTContext.h"
 #include "MatchVerifier.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/Testing/Support/Annotations.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -842,5 +843,23 @@
   Language::Lang_CXX11));
 }
 
+TEST(Decl, MemberPointerStarLoc) {
+  llvm::Annotations Example(R"cpp(
+struct X {};
+int X::$star^* a;
+  )cpp");
+
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+  auto &Ctx = AST->getASTContext();
+
+  auto *VD = selectFirst("vd", match(varDecl().bind("vd"), Ctx));
+  ASSERT_TRUE(VD != nullptr);
+
+  auto TL =
+  VD->getTypeSourceInfo()->getTypeLoc().castAs();
+  ASSERT_EQ(SM.getFileOffset(TL.getStarLoc()), Example.point("star"));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -42,4 +42,5 @@
   clangFrontend
   clangSerialization
   clangTooling
+  LLVMTestingSupport
   )
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5840,7 +5840,7 @@
   }
 
   // Finally fill in MemberPointerLocInfo fields.
-  TL.setStarLoc(Chunk.Loc);
+  TL.setStarLoc(SourceLocation::getFromRawEncoding(Chunk.Mem.StarLoc));
   TL.setClassTInfo(ClsTInfo);
 }
 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5643,8 +5643,8 @@
 return;
   }
 
-  SourceLocation Loc = ConsumeToken();
-  D.SetRangeEnd(Loc);
+  SourceLocation StarLoc = ConsumeToken();
+  D.SetRangeEnd(StarLoc);
   DeclSpec DS(AttrFactory);
   ParseTypeQualifierListOpt(DS);
   D.ExtendWithDeclSpec(DS);
@@ -5655,7 +5655,7 @@
   // Sema will have to catch (syntactically invalid) pointers into global
   // scope. It has to catch pointers into namespace scope anyway.
   D.AddTypeInfo(DeclaratorChunk::getMemberPointer(
-SS, DS.getTypeQualifiers(), DS.getEndLoc()),
+SS, DS.getTypeQualifiers(), StarLoc, DS.getEndLoc()),
 std::move(DS.getAttributes()),
 /* Don't replace range end. */ SourceLocation());
   return;
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -1518,6 +1518,8 @@
   struct MemberPointerTypeInfo {
 /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
 unsigned TypeQuals : 5;
+/// Location of the '*' token.
+unsigned StarLoc;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
@@ -1660,11 +1662,13 @@
 
   static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS,
   unsigned TypeQuals,
-  SourceLocation Loc) {
+  SourceLocation StarLoc,
+  SourceLocation EndLoc) {
 DeclaratorChunk I;
 I.Kind  = MemberPointer;
 I.Loc   = SS.getBeginLoc();
-I.EndLoc= Loc;
+I.EndLoc = EndLoc;
+I.Mem.StarLoc = StarLoc.getRawEncoding();
 I.Mem.TypeQuals = TypeQuals;
 new (I.Mem.ScopeMem) CXXScopeSpec(SS);
 return I;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman

  1   2   >