[PATCH] D99031: [clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set

2021-03-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D99031#2640425 , @aybassiouny wrote:

>> How about verifyFormat? Would that fail without your patch?
>
> @HazardyKnusperkeks sorry, but not sure that I understand your point. Are you 
> suggesting to use verifyFormat in my UT instead of EXPECT_EQ?

I'm pretty sure @MyDeveloperDay would ask for that. I would maybe use both. But 
what it really interesting for me if verifyFormat would fail, i.e. would 
clang-format misformat something previously correctly formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99031

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


[clang] f263418 - [Driver] Gnu.cpp: remove obsoleted i386 triple detection from end-of-life distribution versions

2021-03-22 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-22T00:23:55-07:00
New Revision: f26341840253e15ab07c9e765733803fd3e4

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

LOG: [Driver] Gnu.cpp: remove obsoleted i386 triple detection from end-of-life 
distribution versions

This saves 16 openat syscalls for `clang a.cc` on x86_64.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 972044fb615e..a046e8e7eed8 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2109,12 +2109,10 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
-  "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
-  "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
-  "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
-  "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu",
-  "i686-linux-android",   "i386-gnu",  "i486-gnu",
-  "i586-gnu", "i686-gnu"};
+  "i686-linux-gnu","i686-pc-linux-gnu",  "i386-redhat-linux6E",
+  "i686-redhat-linux", "i386-redhat-linux",  "i586-suse-linux",
+  "i686-montavista-linux", "i686-linux-android", "i386-gnu",
+  };
 
   static const char *const M68kLibDirs[] = {"/lib"};
   static const char *const M68kTriples[] = {



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


[PATCH] D98548: [clang][Sema] Don't try to initialize implicit variable of invalid anonymous union/struct

2021-03-22 Thread Ta-Wei Tu via Phabricator via cfe-commits
TaWeiTu added a comment.

In D98548#2625593 , @tmatheson wrote:

> This seems quite an early point to bail out, so it will prevent some 
> errors/warnings associated with initialization from being emitted. For 
> example, this warning is currently emitted but would be suppressed by this 
> patch:
>
>   union {
> virtual int a();
> int b = 'c'; // expected-warning {{in-class initialization of non-static 
> data member is a C++11 extension [-Wc++11-extensions]}}
>   }
>
> I don't know how much that matters seeing as the union is invalid by this 
> point.

Hi,

Thanks for the comment!
I understand the problem, but the warning you mentioned is not suppressed in 
this patch from what I've seen.
After poking around, I saw that diagnostics related to anonymous unions are all 
emitted in another call to `ActOnUninitializedDecl` in the parser, which takes 
place before this check.
If I completely remove this call to `ActOnUninitializedDecl` (on line 5215 to 
be specific), all the failed testcases seem to be related to CodeGen, so I 
suspect that removing this call for invalid unions will not suppress further 
warnings/errors.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98548

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


[PATCH] D98948: [analyzer][solver] Fix infeasible constraints (PR49642)

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 332211.
vsavchenko added a comment.

Re-write the test using %clang_analyze_cc1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98948

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49642.c

Index: clang/test/Analysis/PR49642.c
===
--- /dev/null
+++ clang/test/Analysis/PR49642.c
@@ -0,0 +1,24 @@
+// RUN: %clang_analyze_cc1 -w -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions
+
+// expected-no-diagnostics
+
+typedef ssize_t;
+b;
+
+unsigned c;
+int write(int, const void *, unsigned long);
+
+a() {
+  d();
+  while (c > 0) {
+b = write(0, d, c);
+if (b)
+  c -= b;
+b < 1;
+  }
+  if (c && c) {
+// ^ no-crash
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -448,12 +448,12 @@
   EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
-  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State);
+  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
   /// Return true if the current class is trivial in the given state.
-  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State);
+  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State) const;
   /// Return true if the current class is trivial and its only member is dead.
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
- SymbolReaper &Reaper);
+ SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
   markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
@@ -521,7 +521,7 @@
ProgramStateRef State, SymbolSet Members,
EquivalenceClass Other,
SymbolSet OtherMembers);
-  static inline void
+  static inline bool
   addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
BasicValueFactory &BV, RangeSet::Factory &F,
ProgramStateRef State, EquivalenceClass First,
@@ -535,6 +535,15 @@
 // Constraint functions
 //===--===//
 
+LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
+areFeasible(ConstraintRangeTy Constraints) {
+  return llvm::none_of(
+  Constraints,
+  [](const std::pair &ClassConstraint) {
+return ClassConstraint.second.isEmpty();
+  });
+}
+
 LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,
 EquivalenceClass Class) {
   return State->get(Class);
@@ -1397,15 +1406,6 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
-  areFeasible(ConstraintRangeTy Constraints) {
-return llvm::none_of(
-Constraints,
-[](const std::pair &ClassConstraint) {
-  return ClassConstraint.second.isEmpty();
-});
-  }
-
   LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
EquivalenceClass Class,
RangeSet Constraint) {
@@ -1428,7 +1428,7 @@
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
 
 // If we end up with at least one of the disequal classes to be
-// constrainted with an empty range-set, the state is infeasible.
+// constrained with an empty range-set, the state is infeasible.
 if (UpdatedConstraint.isEmpty())
   return nullptr;
 
@@ -1574,6 +1574,9 @@
 // Assign new constraints for this class.
 Constraints = CRF.add(Constraints, *this, *NewClassConstraint);
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 State = State->set(Constraints);
   }
 
@@ -1644,7 +1647,7 @@
   return State->get_context();
 }
 
-SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef State) {
+SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef State) const {
   if (const SymbolSet *Members = State->get(*this))
 return *Members;
 
@@ -1654,12 +1657,12 @@
   return F.add(F.getEmptySet(), getRepresentativeSymbol());
 }
 
-bool EquivalenceClass::isTrivial(ProgramStateRef State) {
+bool EquivalenceClass::isTrivial(ProgramStateRef State

[clang] 3085bda - [analyzer][solver] Fix infeasible constraints (PR49642)

2021-03-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-22T11:02:02+03:00
New Revision: 3085bda2b348f6a8b4e0bd1d230af4e9c900c9c4

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

LOG: [analyzer][solver] Fix infeasible constraints (PR49642)

Additionally, this patch puts an assertion checking for feasible
constraints in every place where constraints are assigned to states.

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

Added: 
clang/test/Analysis/PR49642.c

Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 95e61f9c8c61..6ae80b3ae773 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -448,12 +448,12 @@ class EquivalenceClass : public llvm::FoldingSetNode {
   EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
-  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State);
+  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
   /// Return true if the current class is trivial in the given state.
-  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State);
+  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State) const;
   /// Return true if the current class is trivial and its only member is dead.
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
- SymbolReaper &Reaper);
+ SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
   markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
@@ -521,7 +521,7 @@ class EquivalenceClass : public llvm::FoldingSetNode {
ProgramStateRef State, SymbolSet Members,
EquivalenceClass Other,
SymbolSet OtherMembers);
-  static inline void
+  static inline bool
   addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
BasicValueFactory &BV, RangeSet::Factory &F,
ProgramStateRef State, EquivalenceClass First,
@@ -535,6 +535,15 @@ class EquivalenceClass : public llvm::FoldingSetNode {
 // Constraint functions
 
//===--===//
 
+LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
+areFeasible(ConstraintRangeTy Constraints) {
+  return llvm::none_of(
+  Constraints,
+  [](const std::pair &ClassConstraint) {
+return ClassConstraint.second.isEmpty();
+  });
+}
+
 LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,
 EquivalenceClass Class) {
   return State->get(Class);
@@ -1397,15 +1406,6 @@ class RangeConstraintManager : public 
RangedConstraintManager {
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
-  areFeasible(ConstraintRangeTy Constraints) {
-return llvm::none_of(
-Constraints,
-[](const std::pair &ClassConstraint) {
-  return ClassConstraint.second.isEmpty();
-});
-  }
-
   LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
EquivalenceClass Class,
RangeSet Constraint) {
@@ -1428,7 +1428,7 @@ class RangeConstraintManager : public 
RangedConstraintManager {
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
 
 // If we end up with at least one of the disequal classes to be
-// constrainted with an empty range-set, the state is infeasible.
+// constrained with an empty range-set, the state is infeasible.
 if (UpdatedConstraint.isEmpty())
   return nullptr;
 
@@ -1574,6 +1574,9 @@ EquivalenceClass::mergeImpl(BasicValueFactory 
&ValueFactory,
 // Assign new constraints for this class.
 Constraints = CRF.add(Constraints, *this, *NewClassConstraint);
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 State = State->set(Constraints);
   }
 
@@ -1644,7 +1647,7 @@ EquivalenceClass::getMembersFactory(ProgramStateRef 
State) {
   return State->get_context();
 }
 
-SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef State) {
+SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef St

[PATCH] D98948: [analyzer][solver] Fix infeasible constraints (PR49642)

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3085bda2b348: [analyzer][solver] Fix infeasible constraints 
(PR49642) (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98948

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49642.c

Index: clang/test/Analysis/PR49642.c
===
--- /dev/null
+++ clang/test/Analysis/PR49642.c
@@ -0,0 +1,24 @@
+// RUN: %clang_analyze_cc1 -w -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions
+
+// expected-no-diagnostics
+
+typedef ssize_t;
+b;
+
+unsigned c;
+int write(int, const void *, unsigned long);
+
+a() {
+  d();
+  while (c > 0) {
+b = write(0, d, c);
+if (b)
+  c -= b;
+b < 1;
+  }
+  if (c && c) {
+// ^ no-crash
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -448,12 +448,12 @@
   EquivalenceClass Other);
 
   /// Return a set of class members for the given state.
-  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State);
+  LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
   /// Return true if the current class is trivial in the given state.
-  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State);
+  LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State) const;
   /// Return true if the current class is trivial and its only member is dead.
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
- SymbolReaper &Reaper);
+ SymbolReaper &Reaper) const;
 
   LLVM_NODISCARD static inline ProgramStateRef
   markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
@@ -521,7 +521,7 @@
ProgramStateRef State, SymbolSet Members,
EquivalenceClass Other,
SymbolSet OtherMembers);
-  static inline void
+  static inline bool
   addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
BasicValueFactory &BV, RangeSet::Factory &F,
ProgramStateRef State, EquivalenceClass First,
@@ -535,6 +535,15 @@
 // Constraint functions
 //===--===//
 
+LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
+areFeasible(ConstraintRangeTy Constraints) {
+  return llvm::none_of(
+  Constraints,
+  [](const std::pair &ClassConstraint) {
+return ClassConstraint.second.isEmpty();
+  });
+}
+
 LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,
 EquivalenceClass Class) {
   return State->get(Class);
@@ -1397,15 +1406,6 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
-  areFeasible(ConstraintRangeTy Constraints) {
-return llvm::none_of(
-Constraints,
-[](const std::pair &ClassConstraint) {
-  return ClassConstraint.second.isEmpty();
-});
-  }
-
   LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
EquivalenceClass Class,
RangeSet Constraint) {
@@ -1428,7 +1428,7 @@
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
 
 // If we end up with at least one of the disequal classes to be
-// constrainted with an empty range-set, the state is infeasible.
+// constrained with an empty range-set, the state is infeasible.
 if (UpdatedConstraint.isEmpty())
   return nullptr;
 
@@ -1574,6 +1574,9 @@
 // Assign new constraints for this class.
 Constraints = CRF.add(Constraints, *this, *NewClassConstraint);
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 State = State->set(Constraints);
   }
 
@@ -1644,7 +1647,7 @@
   return State->get_context();
 }
 
-SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef State) {
+SymbolSet EquivalenceClass::getClassMembers(ProgramStateRef State) const {
   if (const SymbolSet *Members = State->get(*this))
 return *Members;
 
@@ -1654,12 +1657,12 @@
   return F.add(F.getEmptySet(), getRepresentativeSymbol

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Given that it did not change any reports in our testbench it seems to be safe 
to land it.

It clearly improves the API significantly, so I'm not opposing.
Really good work @vsavchenko.

PS: If should support `_ExtInt`s as well, even if they are not too common.
Please try to fill this gap, before you push your changes.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:495-507
+void RangeSet::dump(raw_ostream &OS) const {
   bool isFirst = true;
-  os << "{ ";
-  for (iterator i = begin(), e = end(); i != e; ++i) {
+  OS << "{ ";
+  for (const Range &R : *this) {
 if (isFirst)
   isFirst = false;
 else

vsavchenko wrote:
> steakhal wrote:
> > Hmm, we could simplify this further, assuming `Range::operator<<` is 
> > defined.
> I think it looks a bit clearer with `llvm::interleaveComma`
Awesome!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D98128: [clang][clangd] Avoid inconsistent target creation

2021-03-22 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT added a comment.

ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98128

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


[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!

one final nit: `getInsertArgumentAdjuster` defaults the position to 
`ArgumentInsertPosition::END` when there's a single argument to insert. so you 
can drop those.


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

https://reviews.llvm.org/D98824

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


[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

(also please let me know if I should land this for you, preferably with an 
email address to attribute the commit to)


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

https://reviews.llvm.org/D98824

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

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

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

https://reviews.llvm.org/D97371

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/CodeGenObjC/attr-nomerge.m


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+@class C;
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(C *c) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+@class C;
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(C *c) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 82f6e0d - [Driver] -m32: Add /usr/include/i386-linux-gnu for Debian

2021-03-22 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-22T01:27:06-07:00
New Revision: 82f6e0dde29e6c6da27f64db5992eb539a57d21b

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

LOG: [Driver] -m32: Add /usr/include/i386-linux-gnu for Debian

Added: 

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep

Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-cross.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index e889791d19b2..0df2d3793819 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -604,13 +604,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 return;
   }
 
-  // On Android and Debian, add /usr/include/$triple if exists. On Debian, we
-  // can assume a GCC installation is available.
-  std::string MultiarchIncludeDir;
-  if (getTriple().isAndroid())
-MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), SysRoot);
-  else if (GCCInstallation.isValid())
-MultiarchIncludeDir = GCCInstallation.getTriple().str();
+  // On Android and Debian, add /usr/include/$triple if exists.
+  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), 
SysRoot);
   if (!MultiarchIncludeDir.empty() &&
   D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
 addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include/" + 
MultiarchIncludeDir);

diff  --git 
a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
 
b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/linux-cross.cpp 
b/clang/test/Driver/linux-cross.cpp
index fa07d615f4fc..6fdd9193fa2f 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -34,6 +34,8 @@
 // DEBIAN_X86_64_M32-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 // DEBIAN_X86_64_M32-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+// DEBIAN_X86_64_M32:  "-internal-externc-isystem"
+// DEBIAN_X86_64_M32-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-linux-gnu"
 // DEBIAN_X86_64_M32:  "-L
 // DEBIAN_X86_64_M32-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/32"
 // DEBIAN_X86_64_M32-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib32"



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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2637186 , @steakhal wrote:

> Ah, I wanted to give it a go, but the bots caught an assertion failure for 
> the parent revision of this. See the details at the Bugzilla ticket 
> .
>
> What is more concerning is that this patch resolves that assertion failure. I 
> guess it implies it can not be NFC?
> Regardless, I'm gonna wait to get that issue fixed before I have a deeper 
> look.

Hmm, I tried it on that test without the fix, and the assertion failure is 
there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2640687 , @steakhal wrote:

> Given that it did not change any reports in our testbench it seems to be safe 
> to land it.
>
> It clearly improves the API significantly, so I'm not opposing.
> Really good work @vsavchenko.

Thanks 😊

> PS: If should support `_ExtInt`s as well, even if they are not too common.
> Please try to fill this gap, before you push your changes.

I do have a bit of a struggle here.  This is a unit-test and thus should be 
compiled for all supported architecture by all of the supported compilers.
Is there a `__has_feature` or something for me to check if `_ExtInt` can be 
used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[clang-tools-extra] f51ab18 - Make clangd CompletionModel usable even with non-standard (but supported) layout

2021-03-22 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-03-22T10:05:25+01:00
New Revision: f51ab1871655a9a96134c2636c37dcb5a6b01ac3

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

LOG: Make clangd CompletionModel usable even with non-standard (but supported) 
layout

llvm supports specifying a non-standard layout where each project lies in its
own place. Do not assume a fixed layout and use the appropriate cmake variable
instead.

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

Added: 


Modified: 
clang-tools-extra/clangd/quality/CompletionModel.cmake

Removed: 




diff  --git a/clang-tools-extra/clangd/quality/CompletionModel.cmake 
b/clang-tools-extra/clangd/quality/CompletionModel.cmake
index 60c6d2aa8433..41bc2ed1890b 100644
--- a/clang-tools-extra/clangd/quality/CompletionModel.cmake
+++ b/clang-tools-extra/clangd/quality/CompletionModel.cmake
@@ -5,8 +5,8 @@
 # will define a C++ class called ${cpp_class} - which may be a
 # namespace-qualified class name.
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler 
${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py)
-  
+  set(model_compiler 
${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+
   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
   set(header_file ${output_dir}/${filename}.h)
   set(cpp_file ${output_dir}/${filename}.cpp)



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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

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

In D86465#2640765 , @vsavchenko wrote:

> I do have a bit of a struggle here.  This is a unit-test and thus should be 
> compiled for all of the supported architectures by all of the supported 
> compilers.
> Is there a `__has_feature` or something for me to check if `_ExtInt` can be 
> used?

Aa, I get it. It is actually a clang specific extension. By checking git blame 
,
 it seems to be a quite new feature, clang-11+.
What about something like this?

  using IntTypes = ::Types= 11
   , __int128_t, __uint128_t
   , signed _ExtInt(200)
   , unsigned _ExtInt(200)
  #endif
  >;

https://godbolt.org/z/GfMfWEz88 Seems to work for a number of compilers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


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

2021-03-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I'll fix the formatting with the next update.




Comment at: clang/lib/Parse/ParseExprCXX.cpp:1445-1461
+  unsigned TokKind = 0;
+  switch (Tok.getKind()) {
+  case tok::kw_mutable: TokKind = 0; break;
+  case tok::arrow: TokKind = 1; break;
+  case tok::kw___attribute:
+  case tok::kw___private:
+  case tok::kw___global:

Is this really needed? May I simplify remove this switch and just have a 
generic warning message?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[clang] 20d9326 - [OpenCL] Use -fdeclare-opencl-builtins for some tests

2021-03-22 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-03-22T09:46:28Z
New Revision: 20d93267e18463292d54791f3c19211a85b27227

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

LOG: [OpenCL] Use -fdeclare-opencl-builtins for some tests

This speeds up the test running times, as the large `opencl-c.h`
header no longer needs to be parsed.

Added: 


Modified: 
clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
clang/test/CodeGenOpenCL/builtins.cl
clang/test/CodeGenOpenCL/size_t.cl
clang/test/SemaOpenCL/fp-options.cl
clang/test/SemaOpenCL/printf-format-string-warnings.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl 
b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
index d1ab6aceac5c..a4d28c7e6cf8 100644
--- a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
+++ b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header 
-cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header 
-fdeclare-opencl-builtins -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
 void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) {

diff  --git a/clang/test/CodeGenOpenCL/builtins.cl 
b/clang/test/CodeGenOpenCL/builtins.cl
index 2ab6f12a9f4b..1d566698d045 100644
--- a/clang/test/CodeGenOpenCL/builtins.cl
+++ b/clang/test/CodeGenOpenCL/builtins.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -finclude-default-header -cl-std=clc++ -fblocks -O0 
-emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s
+// RUN: %clang_cc1 %s -finclude-default-header -fdeclare-opencl-builtins 
-cl-std=clc++ -fblocks -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | 
FileCheck %s
 
 void testBranchingOnEnqueueKernel(queue_t default_queue, unsigned flags, 
ndrange_t ndrange) {
 // Ensure `enqueue_kernel` can be branched upon.

diff  --git a/clang/test/CodeGenOpenCL/size_t.cl 
b/clang/test/CodeGenOpenCL/size_t.cl
index 63a062268da3..b9bb72ac45a0 100644
--- a/clang/test/CodeGenOpenCL/size_t.cl
+++ b/clang/test/CodeGenOpenCL/size_t.cl
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 
-triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 
-triple spir64-unknown-unknown -o - | FileCheck --check-prefix=SZ64 
--check-prefix=SZ64ONLY %s
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 
-triple amdgcn -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 
-triple amdgcn---opencl -o - | FileCheck --check-prefix=SZ64 
--check-prefix=AMDGCN %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header 
-fdeclare-opencl-builtins -emit-llvm -O0 -triple spir-unknown-unknown -o - | 
FileCheck --check-prefix=SZ32 %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header 
-fdeclare-opencl-builtins -emit-llvm -O0 -triple spir64-unknown-unknown -o - | 
FileCheck --check-prefix=SZ64 --check-prefix=SZ64ONLY %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header 
-fdeclare-opencl-builtins -emit-llvm -O0 -triple amdgcn -o - | FileCheck 
--check-prefix=SZ64 --check-prefix=AMDGCN %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header 
-fdeclare-opencl-builtins -emit-llvm -O0 -triple amdgcn---opencl -o - | 
FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s
 
 //SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
 //SZ32: ptrtoint i8* %{{.*}} to i32

diff  --git a/clang/test/SemaOpenCL/fp-options.cl 
b/clang/test/SemaOpenCL/fp-options.cl
index 413afd61819d..3b7cb89cf41b 100644
--- a/clang/test/SemaOpenCL/fp-options.cl
+++ b/clang/test/SemaOpenCL/fp-options.cl
@@ -1,4 +1,3 @@
-// RUN: %clang_cc1 %s -finclude-default-header -triple spir-unknown-unknown 
-emit-pch -o %t.pch
-// RUN: %clang_cc1 %s -finclude-default-header -cl-no-signed-zeros -triple 
spir-unknown-unknown -include-pch %t.pch -fsyntax-only -verify
+// RUN: %clang_cc1 %s -finclude-default-header -fdeclare-opencl-builtins 
-triple spir-unknown-unknown -emit-pch -o %t.pch
+// RUN: %clang_cc1 %s -finclude-default-header -fdeclare-opencl-builtins 
-cl-no-signed-zeros -triple spir-unknown-unknown -include-pch %t.pch 
-fsyntax-only -verify
 // expected-no-diagnostics
-

diff  --git a/clang/test/SemaOpenCL/printf-format-string-warnings.cl 
b/clang/test/SemaOpenCL/printf-format-string-warnings.cl
index d08c95b6d8ab..af4905108557 100644
--- a/clang/test/SemaOpenCL/printf-format-string-warnings.cl
+++ b/clang/test/SemaOpenCL/printf-format-string-warnings.

[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, 
dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update ASTImporter to import value of FieldDecl::getCapturedVLAType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99062

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6208,6 +6208,24 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  const auto *Code =
+  R"(void declToImport(int N) {
+  int VLA[N];
+  [&VLA] {}; // FieldDecl inside the lambda.
+  })";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX14, "input.cpp");
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3631,6 +3631,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3644,6 +3648,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6208,6 +6208,24 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  const auto *Code =
+  R"(void declToImport(int N) {
+  int VLA[N];
+  [&VLA] {}; // FieldDecl inside the lambda.
+  })";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX14, "input.cpp");
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3631,6 +3631,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3644,6 +3648,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98951: [clang][ASTImporter] Add import API for 'const Type *' (NFC).

2021-03-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

In D98951#2637807 , @shafik wrote:

> Can we add a test for the `getCapturedVLAType` case?

The test is added here: D99062 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98951

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


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

2021-03-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Commit
https://github.com/llvm/llvm-project/commit/f7f9f94b2e2b4c714bac9036f6b73a3df42daaff
changed the indent of ObjC method arguments from +4 to +2, if the method
occurs after a block statement.  I believe this was unintentional and there
was insufficient ObjC test coverage to catch this.

Example: `clang-format -style=google test.mm`

before:

  void a(int c) {
if (c) {
  f();
}
[
e:^(fff ) {
  f(S, c);
}];
  }

after:

  void a(int c) {
if (c) {
  f();
}
[
  e:^(fff ) {
f(S, c);
  }];
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99063

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -977,6 +977,19 @@
   "performSelectorOnMainThread:@selector(loadAccessories)\n"
   " withObject:nil\n"
   "  waitUntilDone:false];");
+
+  // The appropriate indentation is used after a block statement.
+  Style.ContinuationIndentWidth = 4;
+  verifyFormat(
+  "void a(int c) {\n"
+  "  if (c) {\n"
+  "f();\n"
+  "  }\n"
+  "  [\n"
+  "  e:^(fff ) {\n"
+  "f(S, c);\n"
+  "  }];\n"
+  "}");
 }
 
 TEST_F(FormatTestObjC, ObjCAt) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -649,7 +649,6 @@
 nextToken();
 
   Line->Level = InitialLevel;
-  FormatTok->setBlockKind(BK_Block);
 
   if (PPStartHash == PPEndHash) {
 Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -977,6 +977,19 @@
   "performSelectorOnMainThread:@selector(loadAccessories)\n"
   " withObject:nil\n"
   "  waitUntilDone:false];");
+
+  // The appropriate indentation is used after a block statement.
+  Style.ContinuationIndentWidth = 4;
+  verifyFormat(
+  "void a(int c) {\n"
+  "  if (c) {\n"
+  "f();\n"
+  "  }\n"
+  "  [\n"
+  "  e:^(fff ) {\n"
+  "f(S, c);\n"
+  "  }];\n"
+  "}");
 }
 
 TEST_F(FormatTestObjC, ObjCAt) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -649,7 +649,6 @@
 nextToken();
 
   Line->Level = InitialLevel;
-  FormatTok->setBlockKind(BK_Block);
 
   if (PPStartHash == PPEndHash) {
 Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2637186 , @steakhal wrote:

> Ah, I wanted to give it a go, but the bots caught an assertion failure for 
> the parent revision of this. See the details at the Bugzilla ticket 
> .
>
> What is more concerning is that this patch resolves that assertion failure. I 
> guess it implies it can not be NFC?
> Regardless, I'm gonna wait to get that issue fixed before I have a deeper 
> look.

Hmm, I tried it on that test without the fix, and the assertion failure is 
there.

In D86465#2640842 , @steakhal wrote:

> In D86465#2640765 , @vsavchenko 
> wrote:
>
>> I do have a bit of a struggle here.  This is a unit-test and thus should be 
>> compiled for all of the supported architectures by all of the supported 
>> compilers.
>> Is there a `__has_feature` or something for me to check if `_ExtInt` can be 
>> used?
>
> Aa, I get it. It is actually a clang specific extension. By checking git 
> blame 
> ,
>  it seems to be a quite new feature, clang-11+.
> What about something like this?
>
>   using IntTypes = ::Typesuint32_t, int64_t, uint64_t
>   #if defined(__clang__) && __clang_major__ >= 11
>, __int128_t, __uint128_t
>, signed _ExtInt(200)
>, unsigned _ExtInt(200)
>   #endif
>   >;
>
> https://godbolt.org/z/GfMfWEz88 Seems to work for a number of compilers.

This is not only a compiler feature, it also should be supported by the target 
architecture:
https://godbolt.org/z/ddjYYx9x6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D98951: [clang][ASTImporter] Add import API for 'const Type *' (NFC).

2021-03-22 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
Herald added a subscriber: rnkovacs.

LG! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98951

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-22 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S updated this revision to Diff 332236.
Max_S added a comment.

Fixed interaction between Before and After configurations options. Before 
handles the case
of two access modifiers specification following each other.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9179,6 +9179,296 @@
Style);
 }
 
+TEST_F(FormatTest, FormatsAfterAccessModifiers) {
+  char const *const NL_After_Never = "struct foo {\n"
+ "private:\n"
+ "  void f() {}\n"
+ "\n"
+ "private:\n"
+ "  int i;\n"
+ "\n"
+ "protected:\n"
+ "  int j;\n"
+ "};\n";
+  char const *const NL_After_Always = "struct foo {\n"
+  "private:\n"
+  "\n"
+  "  void f() {}\n"
+  "\n"
+  "private:\n"
+  "\n"
+  "  int i;\n"
+  "\n"
+  "protected:\n"
+  "\n"
+  "  int j;\n"
+  "};\n";
+
+  char const *const NL_After_Always3Times = "struct foo {\n"
+"private:\n"
+"\n\n\n"
+"  void f() {}\n"
+"\n"
+"private:\n"
+"\n\n\n"
+"  int i;\n"
+"\n"
+"protected:\n"
+"\n\n\n"
+"  int j;\n"
+"};\n";
+
+  char const *const NL_After_Never_Before_Never = "struct foo {\n"
+  "private:\n"
+  "  void f() {}\n"
+  "private:\n"
+  "  int i;\n"
+  "protected:\n"
+  "  int j;\n"
+  "};\n";
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.EmptyLineAfterAccessModifier, FormatStyle::ELAAMS_Never);
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Never, format(NL_After_Always, Style));
+
+  Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
+  EXPECT_EQ(NL_After_Always, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+
+  Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
+  Style.MaxEmptyLinesToKeep = 0u;
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Always3Times, Style));
+
+  Style.MaxEmptyLinesToKeep = 1u;
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always3Times, Style));
+
+  Style.MaxEmptyLinesToKeep = 10u;
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Always3Times, format(NL_After_Always3Times, Style));
+
+  // Test with comments
+  char const *const NL_Com_After_Never = "struct foo {\n"
+ "private:\n"
+ "  // comment\n"
+ "  void f() {}\n"
+ "\n"
+ "private: /* comment */\n"
+ "  int i;\n"
+ "

[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-22 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: rnkovacs.

LGTM! Thanks!




Comment at: clang/unittests/AST/ASTImporterTest.cpp:6213-6216
+  R"(void declToImport(int N) {
+  int VLA[N];
+  [&VLA] {}; // FieldDecl inside the lambda.
+  })";

Very minor, but please clang-format the code inside the raw-string-literal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99062

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-22 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S marked 4 inline comments as done.
Max_S added a comment.

> The tests in line 9462 and 9466 require some additional implementation. 
> EmptyLineAfterAccessModifier is adding the three lines since it is configured 
> to do so, but EmptyLineBeforeAccessModifier would remove these lines. Since 
> EmptyLineBeforeAccessModifier can only access the old file and not the new 
> one. It does not know that three lines have been written and probably could 
> not remove them.
>
> I would like to implement it in such a way, that EmptyLineAfterAccessModifier 
> looks ahead and skips its logic if the next token is a also an access 
> modifier such that the logic of EmptyLineBeforeAccessModifier takes 
> precedence. I could not find a way to get the next line. Is this possible 
> somehow? Does there exist some helper functionality?

I fixed this in the  newest change set. EmptyLineBeforeAccessModifier handles 
the case when two access modifiers follow each other. I updated the 
documentation accordingly.

> Four of the new tests fail, two of them are probably bugs in the 
> implementation of EmptyLineBeforeAccessModifier.
>
> The test in line 9354 is set to:
>
>   Style.MaxEmptyLinesToKeep = 0u; // Both force one new line
>   Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Always;
>   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
>   EXPECT_EQ(NL_B_1_A_1_I_1, format(NL_B_3_A_3_I_3, Style));
>
> So both options should force here the newline, that are removed by 
> MaxEmptyLinesToKeep. EmptyLineBeforeAccessModifier removes all lines, so it 
> seems that MaxEmptyLinesToKeep has the higher rank here. Is that correct 
> behavior?
>
> The test in line 9368 is set to:
>
>   Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Leave;
>   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
>   Style.MaxEmptyLinesToKeep = 1u; 
>   EXPECT_EQ(NL_B_1_A_1_I_1, format(NL_B_3_A_3_I_3, Style));
>
> So both options should leave the new lines in place but should adhere to 
> MaxEmptyLinesToKeep. EmptyLineBeforeAccessModifier keeps all three lines, so 
> it seems that MaxEmptyLinesToKeep has the lower rank here. Is that correct 
> behavior?

I still need some advice on how to handle this. Should I fix the test so that 
it captures the current behavior. Should I fix the logic or should I open a bug 
report?

In D98237#2637832 , @MyDeveloperDay 
wrote:

> could you please mark your comments done when they are done.

I usually try to do this. How can I see which ones are still open?




Comment at: clang/docs/ClangFormatStyleOptions.rst:2159
+Always add empty line after access modifiers if there are none.
+MaxEmptyLinesToKeep is applied also.
+

MyDeveloperDay wrote:
> if MaxEmptyLineToKeep is 0 then surely ELAAMS_Always should win, as this is 
> the lesser i.e. if people never uses extra lines except after access 
> modifiers this is what they would set? did I missunderstand?
> 
> otherwise doesn't MaxEmptyLinesToKeep just nullify the whole option? meaning 
> its useless for anyone using it?
> 
> I agree in the ELAAMS_Leave  case that MaxEmptyLinesToKeep  should win.
> if MaxEmptyLineToKeep is 0 then surely ELAAMS_Always should win, as this is 
> the lesser i.e. if people never uses extra lines except after access 
> modifiers this is what they would set? did I missunderstand?

You understood correctly and that is the way it is implemented.

> I agree in the ELAAMS_Leave case that MaxEmptyLinesToKeep should win.

That is also the way it is implemented.

I fixed the problem with two access modifiers in a row. 



Comment at: clang/unittests/Format/FormatTest.cpp:9392
+ "};\n";
+  EXPECT_EQ(NL_B_3_A_1_I_3, format(NL_B_3_A_3_I_3, Style));
+

MyDeveloperDay wrote:
> I can't read this, I can't tell if you've fat fingered a test, I feel these 
> are better done systematically one by one with the text in the 
> verifyFormat("...") it makes it easier when they fail to understand what is 
> going on.
> 
> Also its ok to have more than one TEST_F if you want to handle the different 
> states in small batches
> 
> I think you undetersand what NL_B_3_A_0_I_0 means and how it differs form 
> NL_B_0_A_3_I_0  but others won't
> I can't read this, 
I may have missed here a comment. The convention is:
```
NewLines_Before_Access_Modifier_3_After_Access_Modifier_3_Inbetween_Access_Modifier_3
N L_   B_   3_A_
3_I_   3
NL_B_3_A_3_I_3
```

> I can't tell if you've fat fingered a test
What do you mean by that?

> I feel these are better done systematically
Thats what I have actually done. First tests only concerning 
EmptyLineAfterAccessModifier afterwards the combinations with 
EmptyLineAfterAccessModifier and EmptyLineBeforeAccessModifier.
You h

[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

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

Hmm, the new test seems to cause an assertion failure in llvm code generation 
in Windows. Is anything known about that? Is the test case wrong in some way?


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

https://reviews.llvm.org/D97371

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

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

In D86465#2640875 , @vsavchenko wrote:

> This is not only a compiler feature, it also should be supported by the 
> target architecture:
> https://godbolt.org/z/ddjYYx9x6

It's getting complicated then xD. I guess we should complement unittests with 
LIT tests?
You can know there that clang is recent enough and pinning the target triple 
would also solve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2640954 , @steakhal wrote:

> In D86465#2640875 , @vsavchenko 
> wrote:
>
>> This is not only a compiler feature, it also should be supported by the 
>> target architecture:
>> https://godbolt.org/z/ddjYYx9x6
>
> It's getting complicated then xD. I guess we should complement unittests with 
> LIT tests?
> You can know there that clang is recent enough and pinning the target triple 
> would also solve this.

My suggestion would be to check these separately with a possible fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

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

In D86465#2640958 , @vsavchenko wrote:

> In D86465#2640954 , @steakhal wrote:
>
>> It's getting complicated then xD. I guess we should complement unittests 
>> with LIT tests?
>> You can know there that clang is recent enough and pinning the target triple 
>> would also solve this.
>
> My suggestion would be to check these separately with a possible fix.

Feel free to push this as-is. But try to cover these cases later if you can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[clang] 02b51e5 - [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-22T13:52:35+03:00
New Revision: 02b51e5316cd501ede547d0223e0f5416ebd9845

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

LOG: [analyzer][solver] Redesign constraint ranges data structure

ImmutableSet doesn't seem like the perfect fit for the RangeSet
data structure.  It is good for saving memory in a persistent
setting, but not for the case when the population of the container
is tiny.  This commit replaces RangeSet implementation and
redesigns the most common operations to be more efficient.

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

Added: 


Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index bc5d5f57cd68..4a118074463d 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -16,6 +16,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/Allocator.h"
 
 namespace clang {
 
@@ -24,21 +26,19 @@ namespace ento {
 /// A Range represents the closed range [from, to].  The caller must
 /// guarantee that from <= to.  Note that Range is immutable, so as not
 /// to subvert RangeSet's immutability.
-class Range : public std::pair {
+class Range {
 public:
-  Range(const llvm::APSInt &from, const llvm::APSInt &to)
-  : std::pair(&from, &to) {
-assert(from <= to);
+  Range(const llvm::APSInt &From, const llvm::APSInt &To) : Impl(&From, &To) {
+assert(From <= To);
   }
 
-  Range(const llvm::APSInt &point)
-  : std::pair(&point, &point) 
{}
+  Range(const llvm::APSInt &Point) : Range(Point, Point) {}
 
-  bool Includes(const llvm::APSInt &v) const {
-return *first <= v && v <= *second;
+  bool Includes(const llvm::APSInt &Point) const {
+return From() <= Point && Point <= To();
   }
-  const llvm::APSInt &From() const { return *first; }
-  const llvm::APSInt &To() const { return *second; }
+  const llvm::APSInt &From() const { return *Impl.first; }
+  const llvm::APSInt &To() const { return *Impl.second; }
   const llvm::APSInt *getConcreteValue() const {
 return &From() == &To() ? &From() : nullptr;
   }
@@ -47,93 +47,264 @@ class Range : public std::pair {
 ID.AddPointer(&From());
 ID.AddPointer(&To());
   }
-};
+  void dump(raw_ostream &OS) const;
 
-class RangeTrait : public llvm::ImutContainerInfo {
-public:
-  // When comparing if one Range is less than another, we should compare
-  // the actual APSInt values instead of their pointers.  This keeps the order
-  // consistent (instead of comparing by pointer values) and can potentially
-  // be used to speed up some of the operations in RangeSet.
-  static inline bool isLess(key_type_ref lhs, key_type_ref rhs) {
-return *lhs.first < *rhs.first ||
-   (!(*rhs.first < *lhs.first) && *lhs.second < *rhs.second);
-  }
+  // In order to keep non-overlapping ranges sorted, we can compare only From
+  // points.
+  bool operator<(const Range &RHS) const { return From() < RHS.From(); }
+
+  bool operator==(const Range &RHS) const { return Impl == RHS.Impl; }
+  bool operator!=(const Range &RHS) const { return !operator==(RHS); }
+
+private:
+  std::pair Impl;
 };
 
-/// RangeSet contains a set of ranges. If the set is empty, then
-///  there the value of a symbol is overly constrained and there are no
-///  possible values for that symbol.
+/// @class RangeSet is a persistent set of non-overlapping ranges.
+///
+/// New RangeSet objects can be ONLY produced by RangeSet::Factory object, 
which
+/// also supports the most common operations performed on range sets.
+///
+/// Empty set corresponds to an overly constrained symbol meaning that there
+/// are no possible values for that symbol.
 class RangeSet {
-  typedef llvm::ImmutableSet PrimRangeSet;
-  PrimRangeSet ranges; // no need to make const, since it is an
-   // ImmutableSet - this allows default operator=
-   // to work.
 public:
-  typedef PrimRangeSet::Factory Factory;
-  typedef PrimRangeSet::iterator iterator;
-
-  RangeSet(PrimRangeSet RS) : ranges(RS) {}
-
-  /// Create a new set with 

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-03-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02b51e5316cd: [analyzer][solver] Redesign constraint ranges 
data structure (authored by vsavchenko).

Changed prior to commit:
  https://reviews.llvm.org/D86465?vs=331008&id=332240#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -11,120 +11,340 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
+using namespace clang;
+using namespace ento;
+
 namespace clang {
 namespace ento {
-namespace {
 
-// TestCase contains to lists of ranges.
-// Original one has to be negated.
-// Expected one has to be compared to negated original range.
-template  struct TestCase {
-  RangeSet original;
-  RangeSet expected;
-
-  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
-   const std::initializer_list &originalList,
-   const std::initializer_list &expectedList)
-  : original(createRangeSetFromList(BVF, F, originalList)),
-expected(createRangeSetFromList(BVF, F, expectedList)) {}
-
-private:
-  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
-  const std::initializer_list rangeList) {
-llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
-llvm::APSInt to = from;
-RangeSet rangeSet = F.getEmptySet();
-for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
-  from = *it;
-  to = *(it + 1);
-  rangeSet = rangeSet.addRange(
-  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
-}
-return rangeSet;
-  }
+template  static std::string toString(const RangeOrSet &Obj) {
+  std::string ObjRepresentation;
+  llvm::raw_string_ostream SS(ObjRepresentation);
+  Obj.dump(SS);
+  return SS.str();
+}
+LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
+  return Point.toString(10);
+}
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
+  const RangeSet &Set) {
+  return OS << toString(Set);
+}
 
-  void printNegate(const TestCase &TestCase) {
-TestCase.original.print(llvm::dbgs());
-llvm::dbgs() << " => ";
-TestCase.expected.print(llvm::dbgs());
-  }
-};
+} // namespace ento
+} // namespace clang
 
-class RangeSetTest : public testing::Test {
-protected:
+namespace {
+
+template  class RangeSetTest : public testing::Test {
+public:
   // Init block
   std::unique_ptr AST = tooling::buildASTFromCode("struct foo;");
-  ASTContext &context = AST->getASTContext();
-  llvm::BumpPtrAllocator alloc;
-  BasicValueFactory BVF{context, alloc};
-  RangeSet::Factory F;
+  ASTContext &Context = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+  RangeSet::Factory F{BVF};
   // End init block
 
-  template  void checkNegate() {
-using type = T;
-
-// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-// MID is a value in the middle of the range
-// which unary minus does not affect on,
-// e.g. int8/int32(0), uint8(128), uint32(2147483648).
-
-constexpr type MIN = std::numeric_limits::min();
-constexpr type MAX = std::numeric_limits::max();
-constexpr type MID = std::is_signed::value
- ? 0
- : ~(static_cast(-1) / static_cast(2));
-constexpr type A = MID - static_cast(42 + 42);
-constexpr type B = MID - static_cast(42);
-constexpr type C = -B;
-constexpr type D = -A;
-
-static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-  "Values shall be in an ascending order");
-
-// Left {[x, y], [x, y]} is what shall be negated.
-// Right {[x, y], [x, y]} is what shall be compared to a negation result.
-TestCase cases[] = {
-{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
-{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
-{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
-{BVF, F, {MIN, MAX}, {MIN, MAX}},
-{BVF, F, {A, D}, {A, D}},
-{BVF, F

[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-03-22 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko added a comment.

In D91949#2503646 , @MyDeveloperDay 
wrote:

> I think the revision whilst it does what is needed to structs doesn't address 
> the many other times this forms appear. I think we need something a little 
> more extensive. It can't just be when a line starts with struct

I did it in the same way as existing options made in MustBreakBefore function 
(here we can see that we check only //Line.startsWith(tok::kw_struct)//, no 
more extensive conditions):

  if (isAllmanBrace(Left) || isAllmanBrace(Right))
return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
   (Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
Style.BraceWrapping.AfterEnum) ||
   (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) ||
   (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct);


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

https://reviews.llvm.org/D91949

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


[PATCH] D99018: [clang][flang] Moke the definition of `-module-dir` restricted to Flang

2021-03-22 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3b002b12f2d: [clang][flang] Moke the definition of 
`-module-dir` restricted to Flang (authored by awarzynski).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99018

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -986,11 +986,6 @@
 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
   Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">,
   MarshallingInfoString>;
-def module_dir : Separate<["-"], "module-dir">, 
Flags<[FlangOption,FC1Option]>, MetaVarName<"">,
-  HelpText<"Put MODULE files in ">,
-  DocBrief<[{This option specifies where to put .mod files for compiled 
modules.
-It is also added to the list of directories to be searched by an USE statement.
-The default is the current directory.}]>;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
   Flags<[NoXarchOption, RenderAsInput]>,
   HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
@@ -4220,7 +4215,6 @@
 
 // Generic gfortran options.
 def A_DASH : Joined<["-"], "A-">, Group;
-def J : JoinedOrSeparate<["-"], "J">, 
Flags<[RenderJoined,FlangOption,FC1Option]>, Group, 
Alias;
 def cpp : Flag<["-"], "cpp">, Group;
 def nocpp : Flag<["-"], "nocpp">, Group;
 def static_libgfortran : Flag<["-"], "static-libgfortran">, 
Group;
@@ -4303,6 +4297,12 @@
 
//===--===//
 let Flags = [FC1Option, FlangOption, FlangOnlyOption] in {
 
+def module_dir : Separate<["-"], "module-dir">, MetaVarName<"">,
+  HelpText<"Put MODULE files in ">,
+  DocBrief<[{This option specifies where to put .mod files for compiled 
modules.
+It is also added to the list of directories to be searched by an USE statement.
+The default is the current directory.}]>;
+
 def ffixed_form : Flag<["-"], "ffixed-form">, Group,
   HelpText<"Process source files in fixed form">;
 def ffree_form : Flag<["-"], "ffree-form">, Group,
@@ -4340,6 +4340,11 @@
   HelpText<"Enable the old style PARAMETER statement">;
 }
 
+def J : JoinedOrSeparate<["-"], "J">,
+  Flags<[RenderJoined, FlangOption, FC1Option, FlangOnlyOption]>,
+  Group,
+  Alias;
+
 
//===--===//
 // FC1 Options
 
//===--===//


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -986,11 +986,6 @@
 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
   Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">,
   MarshallingInfoString>;
-def module_dir : Separate<["-"], "module-dir">, Flags<[FlangOption,FC1Option]>, MetaVarName<"">,
-  HelpText<"Put MODULE files in ">,
-  DocBrief<[{This option specifies where to put .mod files for compiled modules.
-It is also added to the list of directories to be searched by an USE statement.
-The default is the current directory.}]>;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
   Flags<[NoXarchOption, RenderAsInput]>,
   HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
@@ -4220,7 +4215,6 @@
 
 // Generic gfortran options.
 def A_DASH : Joined<["-"], "A-">, Group;
-def J : JoinedOrSeparate<["-"], "J">, Flags<[RenderJoined,FlangOption,FC1Option]>, Group, Alias;
 def cpp : Flag<["-"], "cpp">, Group;
 def nocpp : Flag<["-"], "nocpp">, Group;
 def static_libgfortran : Flag<["-"], "static-libgfortran">, Group;
@@ -4303,6 +4297,12 @@
 //===--===//
 let Flags = [FC1Option, FlangOption, FlangOnlyOption] in {
 
+def module_dir : Separate<["-"], "module-dir">, MetaVarName<"">,
+  HelpText<"Put MODULE files in ">,
+  DocBrief<[{This option specifies where to put .mod files for compiled modules.
+It is also added to the list of directories to be searched by an USE statement.
+The default is the current directory.}]>;
+
 def ffixed_form : Flag<["-"], "ffixed-form">, Group,
   HelpText<"Process source files in fixed form">;
 def ffree_form : Flag<["-"], "ffree-form">, Group,
@@ -4340,6 +4340,11 @@
   HelpText<"Enable the old style PARAMETER statement">;
 }
 
+def J : JoinedOrSeparate<["-"], "J">,
+  Flags<[RenderJoined, FlangOption, FC1Option, FlangOnlyOption]>,
+  Group,
+  Alias;
+
 //===--===//
 // FC1 Options
 //===--===//
___
cfe-

[clang] b3b002b - [clang][flang] Moke the definition of `-module-dir` restricted to Flang

2021-03-22 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-03-22T11:06:50Z
New Revision: b3b002b12f2d6ebdb80b678dec0d14786cbef15a

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

LOG: [clang][flang] Moke the definition of `-module-dir` restricted to Flang

`-module-dir` is a Flang specific option and should not be visible in
Clang. This patch adds `FlangOnlyOption` flag to its definition. This
way Clang will know that it should reject it and skip it when generating
output for `clang -help`.

The definition of `-module-dir` is moved next to other Flang options.
As `-J` is an alias for `-module-dir`, it has to be moved as well (the
alias cannot be defined before the original option). As `gfortran` mode
is effectively no longer supported (*), `-J` is claimed as Flang only
option.

This is a follow-up of a post-commit review for
https://reviews.llvm.org/D95448.

* https://reviews.llvm.org/rG6a75496836ea14bcfd2f4b59d35a1cad4ac58cee

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6e22bd01bea3..2e9d0f53f9a3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -986,11 +986,6 @@ def dependency_dot : Separate<["-"], "dependency-dot">, 
Flags<[CC1Option]>,
 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
   Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">,
   MarshallingInfoString>;
-def module_dir : Separate<["-"], "module-dir">, 
Flags<[FlangOption,FC1Option]>, MetaVarName<"">,
-  HelpText<"Put MODULE files in ">,
-  DocBrief<[{This option specifies where to put .mod files for compiled 
modules.
-It is also added to the list of directories to be searched by an USE statement.
-The default is the current directory.}]>;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
   Flags<[NoXarchOption, RenderAsInput]>,
   HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
@@ -4220,7 +4215,6 @@ defm devirtualize_speculatively : 
BooleanFFlag<"devirtualize-speculatively">,
 
 // Generic gfortran options.
 def A_DASH : Joined<["-"], "A-">, Group;
-def J : JoinedOrSeparate<["-"], "J">, 
Flags<[RenderJoined,FlangOption,FC1Option]>, Group, 
Alias;
 def cpp : Flag<["-"], "cpp">, Group;
 def nocpp : Flag<["-"], "nocpp">, Group;
 def static_libgfortran : Flag<["-"], "static-libgfortran">, 
Group;
@@ -4303,6 +4297,12 @@ def Xflang : Separate<["-"], "Xflang">,
 
//===--===//
 let Flags = [FC1Option, FlangOption, FlangOnlyOption] in {
 
+def module_dir : Separate<["-"], "module-dir">, MetaVarName<"">,
+  HelpText<"Put MODULE files in ">,
+  DocBrief<[{This option specifies where to put .mod files for compiled 
modules.
+It is also added to the list of directories to be searched by an USE statement.
+The default is the current directory.}]>;
+
 def ffixed_form : Flag<["-"], "ffixed-form">, Group,
   HelpText<"Process source files in fixed form">;
 def ffree_form : Flag<["-"], "ffree-form">, Group,
@@ -4340,6 +4340,11 @@ def falternative_parameter_statement : Flag<["-"], 
"falternative-parameter-state
   HelpText<"Enable the old style PARAMETER statement">;
 }
 
+def J : JoinedOrSeparate<["-"], "J">,
+  Flags<[RenderJoined, FlangOption, FC1Option, FlangOnlyOption]>,
+  Group,
+  Alias;
+
 
//===--===//
 // FC1 Options
 
//===--===//



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


[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-03-22 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:5075
+   "};",
+   Style);
+}

MyDeveloperDay wrote:
> I wonder if there should be other options
> 
> i.e.
> 
> ```
> struct new_struct struct_name = {
> a = 1
> };
> ```
> ```
> struct new_struct struct_name = { a = 1 };
> ```
> 
> ```
> struct new_struct struct_name = 
> { 
> a = 1,
> };
> ```
> 
> Again I don't want to discourage you, but this is very much related to one of 
> the key problem areas of clang-format that it really doesn't do well, so its 
> one of the places users ALWAY have to add //clang-format off
> 
> e.g.
> 
> ```
> Status GradForBinaryCwise(FunctionDef* g, std::vector body) {
>   // clang-format off
>   std::vector nodes = {
> {{"sx"}, "Shape", {"x"}},
> {{"sy"}, "Shape", {"y"}},
>   };
>   // clang-format on
> ```
> 
> If we are going to fix this to some extent we should fix it for all those 
> cases too. I understand that that might be beyond what you are trying to 
> achieve, but I think its important that we explore what might be needed to 
> satisfy being able to get rid of all these //clang-format off cases as some 
> point and you've woken the beast in this area ;-)
> 
> To be honest fixing this is one of biggest things (and very commendable if 
> you want to focus on it) and whilst your fix is along the right lines, it 
> only addresses the struct cases (and not the class case example (as above) 
> and it perhaps doesn't cover where there might be something before the struct 
> as in 
> 
> ```
> static struct X Y = {
> }
> ```
> 
> If your interested in pursuing this still, I'm happy to try and help you walk 
> through it, where I can. However you'll have to bare with me as it might be 
> beyond my skill set.
> 
> 
I understand what you mean, but at the moment options such as "AfterStruct" are 
also implemented with checking the first word in a line (not considering cases 
with "static" word). It seems to me that the option that I add should only 
concern structures, and new configurations  should be created for the class, 
etc. (BreakBeforeClassInit, BreakBeforeEnumInit), so that the formatting would 
be more flexible.


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

https://reviews.llvm.org/D91949

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


[clang-tools-extra] f71404c - [clangd] Replace usages of dummy with more descriptive words

2021-03-22 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-22T12:49:24+01:00
New Revision: f71404c37c32902b66cf802bc18984be184d583e

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

LOG: [clangd] Replace usages of dummy with more descriptive words

Dummy is a word with inappropriate associations. This patch updates the
references to it in clangd code base with more precise ones.

The only user-visible change is the default variable name used when extracting a
variable. It will be named as `placeholder` from now on.

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

Added: 
clang-tools-extra/clangd/fuzzer/FuzzerClangdMain.cpp

Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/Format.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Trace.cpp
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp

Removed: 
clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp



diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index f9516a1537a0..557689774b14 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -497,7 +497,7 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
 // prepareRename is latency-sensitive: we don't query the index, as we
 // only need main-file references
 auto Results =
-clangd::rename({Pos, NewName.getValueOr("__clangd_rename_dummy"),
+clangd::rename({Pos, NewName.getValueOr("__clangd_rename_placeholder"),
 InpAST->AST, File, /*FS=*/nullptr,
 /*Index=*/nullptr, RenameOpts});
 if (!Results) {

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index b55d1b03dee6..7966b7dfa8a3 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -96,9 +96,9 @@ std::string detectClangPath() {
 if (auto PathCC = llvm::sys::findProgramByName(Name))
   return resolve(std::move(*PathCC));
   // Fallback: a nonexistent 'clang' binary next to clangd.
-  static int Dummy;
+  static int StaticForMainAddr;
   std::string ClangdExecutable =
-  llvm::sys::fs::getMainExecutable("clangd", (void *)&Dummy);
+  llvm::sys::fs::getMainExecutable("clangd", (void *)&StaticForMainAddr);
   SmallString<128> ClangPath;
   ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
   llvm::sys::path::append(ClangPath, "clang");
@@ -120,8 +120,9 @@ const llvm::Optional detectSysroot() {
 }
 
 std::string detectStandardResourceDir() {
-  static int Dummy; // Just an address in this process.
-  return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
+  static int StaticForMainAddr; // Just an address in this process.
+  return CompilerInvocation::GetResourcesPath("clangd",
+  (void *)&StaticForMainAddr);
 }
 
 // The path passed to argv[0] is important:

diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index bda5dcadf12e..e4846ac7a59d 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -376,10 +376,10 @@ class DocumentOutline {
 
   /// Builds the document outline for the generated AST.
   std::vector build() {
-SymBuilder DummyRoot;
+SymBuilder Root;
 for (auto &TopLevel : AST.getLocalTopLevelDecls())
-  traverseDecl(TopLevel, DummyRoot);
-return std::move(std::move(DummyRoot).build().children);
+  traverseDecl(TopLevel, Root);
+return std::move(std::move(Root).build().children);
   }
 
 private:

diff  --git a/clang-tools-extra/clangd/Format.cpp 
b/clang-tools-extra/clangd/Format.cpp
index d68a5bc672d0..3963bc21d403 100644
--- a/clang-tools-extra/clangd/Format.cpp
+++ b/clang-tools-extra/clangd/Format.cpp
@@ -23,7 +23,7 @@ namespace {
 /// as it isn't sure where the errors are and so can't correct.
 /// When editing, it's reasonable to assume code before the cursor is complete.
 void closeBrackets(std::string &Code, const format::FormatStyle &Styl

[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 332250.
balazske added a comment.

Add regular expression to test, removed space characters from line endings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock_state.c

Index: clang/test/Analysis/pthreadlock_state.c
===
--- /dev/null
+++ clang/test/Analysis/pthreadlock_state.c
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
+
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
+
+#define NULL 0
+
+void clang_analyzer_printState();
+
+pthread_mutex_t mtx;
+
+void test(pthread_mutex_t *mtx1) {
+  clang_analyzer_printState();
+  // CHECK:"checker_messages": null
+
+  pthread_mutex_init(&mtx, NULL);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_lock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: locked",
+  // CHECK-NEXT:  "Mutex lock order:",
+  // CHECK-NEXT:  "mtx",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_unlock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  int ret = pthread_mutex_destroy(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked, possibly destroyed",
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:",
+  // CHECK-NEXT:  "mtx: conj_${{[0-9]+}}{{.+}}",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  if (ret)
+return;
+
+  ret = pthread_mutex_destroy(mtx1);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: destroyed",
+  // CHECK-NEXT:  "SymRegion{reg_$12}: not tracked, possibly destroyed",
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:",
+  // CHECK-NEXT:  "SymRegion{reg_$12}: conj_${{[0-9]+}}{{.+}}",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+  if (ret)
+return;
+  pthread_mutex_init(mtx1, NULL);
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -339,7 +339,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutexes in unresolved possibly destroyed state:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69218: [ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)

2021-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3812-3821
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
 hasType,
 AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl,
-ValueDecl),
+ValueDecl, CXXBaseSpecifier),
 internal::Matcher, InnerMatcher, 0) {
   QualType QT = internal::getUnderlyingType(Node);
   if (!QT.isNull())

nick wrote:
> njames93 wrote:
> > I don't think the change to this matcher is warranted.
> > The `hasType` matcher that accepts a DeclarationMatcher already has support 
> > for cxxBaseSpecifier.
> > However overloading the matcher that takes a QualType matcher doesn't make 
> > sense as base specifiers have no qualifications.
> What should I use in D69000 then? It is been a very long time since I 
> developed and published these patches, but D69000 definitely requires this 
> matcher, without it I get:
> 
> ```
> llvm-project\clang\include\clang\ASTMatchers\ASTMatchersInternal.h(1569): 
> error C2338: right polymorphic conversion
> llvm-project\clang-tools-extra\clang-tidy\modernize\DeprecatedIteratorBaseCheck.cpp(200):
>  note: see reference to function template instantiation 
> 'clang::ast_matchers::internal::PolymorphicMatcher  
> (clang::ast_matchers::internal::TypeList),clang::ast_matchers::internal::Matcher>::operator
>  clang::ast_matchers::internal::Matcher(void) 
> const' being compiled
> llvm-project\clang-tools-extra\clang-tidy\modernize\DeprecatedIteratorBaseCheck.cpp(192):
>  note: see reference to function template instantiation 
> 'clang::ast_matchers::internal::PolymorphicMatcher  
> (clang::ast_matchers::internal::TypeList),clang::ast_matchers::internal::Matcher>::operator
>  clang::ast_matchers::internal::Matcher(void) 
> const' being compiled
> ```
> 
> However overloading the matcher that takes a QualType matcher doesn't make 
> sense as base specifiers have no qualifications.

`QualType` is a convenience wrapper around a `Type` and so I think it's 
reasonable based on that convenience alone. We have some matchers that return a 
`QualType`, like `asString()`, which I could imagine a user wanting to use with 
`cxxBaseSpecifier()`. e.g., `cxxBaseSpecifier(asString("SomeClass"))`


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

https://reviews.llvm.org/D69218

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


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

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



Comment at: clang/test/Analysis/pthreadlock_state.c:55
+  // CHECK-NEXT:  "mtx: conj_$11{int, LC1, S1874, #1}", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}

steakhal wrote:
> Out of curiosity, what is the purpose of this 'empty' line? I've seen it many 
> times in other tests but I still don't know.
This is an issue with the state dump, the checker does not print the empty line 
but the state dump shows it always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

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


[clang] 2bbc9bc - [OpenCL] Support template parameters for as_type

2021-03-22 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-03-22T11:59:05Z
New Revision: 2bbc9bccf095b92b3ed1ab9669fab8a7dc96ee6d

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

LOG: [OpenCL] Support template parameters for as_type

Implement the TreeTransform for AsTypeExpr.  Split `BuildAsTypeExpr`
out of `ActOnAsTypeExpr`, such that we can call the Build method from
the TreeTransform.

Fixes PR47979.

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

Added: 
clang/test/SemaOpenCLCXX/template-astype.cl

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6fae208f74e7..650b2061e314 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5581,6 +5581,9 @@ class Sema final {
   ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc);
+  ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc);
 
   //=== C++ Features 
--===//
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 81eec3db162b..6b3da7ca5a4d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6497,24 +6497,30 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
ExecConfig, IsExecConfig);
 }
 
-/// ActOnAsTypeExpr - create a new asType (bitcast) from the arguments.
+/// Parse a __builtin_astype expression.
 ///
 /// __builtin_astype( value, dst type )
 ///
 ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc) {
+  QualType DstTy = GetTypeFromParser(ParsedDestTy);
+  return BuildAsTypeExpr(E, DstTy, BuiltinLoc, RParenLoc);
+}
+
+/// Create a new AsTypeExpr node (bitcast) from the arguments.
+ExprResult Sema::BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc) {
   ExprValueKind VK = VK_RValue;
   ExprObjectKind OK = OK_Ordinary;
-  QualType DstTy = GetTypeFromParser(ParsedDestTy);
   QualType SrcTy = E->getType();
-  if (Context.getTypeSize(DstTy) != Context.getTypeSize(SrcTy))
-return ExprError(Diag(BuiltinLoc,
-  diag::err_invalid_astype_of_
diff erent_size)
- << DstTy
- << SrcTy
- << E->getSourceRange());
-  return new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
+  if (!SrcTy->isDependentType() &&
+  Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy))
+return ExprError(
+Diag(BuiltinLoc, diag::err_invalid_astype_of_
diff erent_size)
+<< DestTy << SrcTy << E->getSourceRange());
+  return new (Context) AsTypeExpr(E, DestTy, VK, OK, BuiltinLoc, RParenLoc);
 }
 
 /// ActOnConvertVectorExpr - create a new convert-vector expression from the

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 5fb2bfa85352..6fa91035a0c4 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13971,7 +13971,14 @@ TreeTransform::TransformBlockExpr(BlockExpr 
*E) {
 template
 ExprResult
 TreeTransform::TransformAsTypeExpr(AsTypeExpr *E) {
-  llvm_unreachable("Cannot transform asType expressions yet");
+  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
+  if (SrcExpr.isInvalid())
+return ExprError();
+
+  QualType Type = getDerived().TransformType(E->getType());
+
+  return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
+ E->getRParenLoc());
 }
 
 template

diff  --git a/clang/test/SemaOpenCLCXX/template-astype.cl 
b/clang/test/SemaOpenCLCXX/template-astype.cl
new file mode 100644
index ..efb93412cb20
--- /dev/null
+++ b/clang/test/SemaOpenCLCXX/template-astype.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header %s 
-cl-std=clc++ -verify
+
+// Test as_type, which is defined in terms of __builtin_astype.
+template 
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretation: sizes of 'int2' (vector of 2 
'int' values) and '__private int' must match}}
+}
+
+auto test_long(long x) { return templated_astype(x); }
+
+auto neg_test_int(int x) { return templated_astype(x); }
+// expected

[PATCH] D98855: [OpenCL] Support template parameters for as_type

2021-03-22 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bbc9bccf095: [OpenCL] Support template parameters for 
as_type (authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D98855?vs=331517&id=332251#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98855

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaOpenCLCXX/template-astype.cl

Index: clang/test/SemaOpenCLCXX/template-astype.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-astype.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header %s -cl-std=clc++ -verify
+
+// Test as_type, which is defined in terms of __builtin_astype.
+template 
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretation: sizes of 'int2' (vector of 2 'int' values) and '__private int' must match}}
+}
+
+auto test_long(long x) { return templated_astype(x); }
+
+auto neg_test_int(int x) { return templated_astype(x); }
+// expected-note@-1{{in instantiation of function template specialization 'templated_astype' requested here}}
+
+auto test_short4(short4 x) { return templated_astype(x); }
+
+// Test __builtin_astype.
+template 
+auto templated_builtin_astype(T x) {
+  return __builtin_astype(x, int2);
+}
+
+auto test_builtin(char8 x) { return templated_builtin_astype(x); }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -13971,7 +13971,14 @@
 template
 ExprResult
 TreeTransform::TransformAsTypeExpr(AsTypeExpr *E) {
-  llvm_unreachable("Cannot transform asType expressions yet");
+  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
+  if (SrcExpr.isInvalid())
+return ExprError();
+
+  QualType Type = getDerived().TransformType(E->getType());
+
+  return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
+ E->getRParenLoc());
 }
 
 template
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6497,24 +6497,30 @@
ExecConfig, IsExecConfig);
 }
 
-/// ActOnAsTypeExpr - create a new asType (bitcast) from the arguments.
+/// Parse a __builtin_astype expression.
 ///
 /// __builtin_astype( value, dst type )
 ///
 ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc) {
+  QualType DstTy = GetTypeFromParser(ParsedDestTy);
+  return BuildAsTypeExpr(E, DstTy, BuiltinLoc, RParenLoc);
+}
+
+/// Create a new AsTypeExpr node (bitcast) from the arguments.
+ExprResult Sema::BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc) {
   ExprValueKind VK = VK_RValue;
   ExprObjectKind OK = OK_Ordinary;
-  QualType DstTy = GetTypeFromParser(ParsedDestTy);
   QualType SrcTy = E->getType();
-  if (Context.getTypeSize(DstTy) != Context.getTypeSize(SrcTy))
-return ExprError(Diag(BuiltinLoc,
-  diag::err_invalid_astype_of_different_size)
- << DstTy
- << SrcTy
- << E->getSourceRange());
-  return new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
+  if (!SrcTy->isDependentType() &&
+  Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy))
+return ExprError(
+Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
+<< DestTy << SrcTy << E->getSourceRange());
+  return new (Context) AsTypeExpr(E, DestTy, VK, OK, BuiltinLoc, RParenLoc);
 }
 
 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -5581,6 +5581,9 @@
   ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc);
+  ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc);
 
   //=== C++ Features --===//
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/pthreadlock_state.c:70
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:", 
+  // CHECK-NEXT:  "SymRegion{reg_$12}: 
conj_$15{int, LC1, S1921, #1}", 
+  // CHECK-NEXT:  ""

steakhal wrote:
> I recommend not hardcoding symbol identifier numbers. `reg$NN`, `conj_$NN`, 
> `LCNN`, `S`
> It would result in a less fragile test.
> I'm pretty sure you can use some regexp to achieve this.
AFAIK only the line prefix is checked.
So you could use simply `"SymRegion{reg_${{[0-9]+}}}: 
conj_$"`

Make sure you mask the number out of the `reg_$12` as well, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

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


[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-22 Thread Bradley Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG48f5a392cb73: [IR] Add vscale_range IR function attribute 
(authored by bsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Verifier/vscale_range.ll

Index: llvm/test/Verifier/vscale_range.ll
===
--- /dev/null
+++ llvm/test/Verifier/vscale_range.ll
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: 'vscale_range' minimum cannot be greater than maximum
+declare i8* @b(i32*) vscale_range(8, 1)
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -422,6 +422,31 @@
   ret void
 }
 
+; CHECK: define void @f72() #45
+define void @f72() vscale_range(8)
+{
+  ret void
+}
+
+; CHECK: define void @f73() #46
+define void @f73() vscale_range(1,8)
+{
+  ret void
+}
+
+; CHECK: define void @f74() #47
+define void @f74() vscale_range(1,0)
+{
+  ret void
+}
+
+; CHECK: define void @f75()
+; CHECK-NOT: define void @f75() #
+define void @f75() vscale_range(0,0)
+{
+  ret void
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -467,4 +492,7 @@
 ; CHECK: attributes #42 = { nocallback }
 ; CHECK: attributes #43 = { cold }
 ; CHECK: attributes #44 = { hot }
+; CHECK: attributes #45 = { vscale_range(8,8) }
+; CHECK: attributes #46 = { vscale_range(1,8) }
+; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -970,6 +970,7 @@
   case Attribute::StackProtectStrong:
   case Attribute::StrictFP:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
   case Attribute::NoProfile:
Index: llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
@@ -73,6 +73,7 @@
   .Case("sspstrong", Attribute::StackProtectStrong)
   .Case("strictfp", Attribute::StrictFP)
   .Case("uwtable", Attribute::UWTable)
+  .Case("vscale_range", Attribute::VScaleRange)
   .Default(Attribute::None);
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1629,6 +1629,7 @@
   case Attribute::InlineHint:
   case Attribute::StackAlignment:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NonLazyBind:
   case Attribute::ReturnsTwice:
   case Attribute::SanitizeAddress:
@@ -1987,6 +1988,14 @@
   return;
   }
 
+  if (Attrs.hasFnAttribute(Attribute::VScaleRange)) {
+std::pair Args =
+Attrs.getVScaleRangeArgs(AttributeList::FunctionIndex);
+
+if (Args.first > Args.second && Args.second != 0)
+  CheckFailed("'vscale_range' minimum cannot be greater than maximum", V);
+  }
+
   if (Attrs.hasFnAttribute("frame-pointer")) {
 StringRef FP = Attrs.getAttribute(AttributeList::FunctionIndex,
   "frame-pointer").getValueAsString();
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -78,6 +78,17 @@
   return std::make_pair(ElemSizeArg, NumElemsArg);
 }
 
+static uint64_t packVScaleRangeArgs(unsigned MinValue, unsigned MaxValue) {
+  return uint64_t(MinValue) << 32 | MaxValue;
+}
+
+static std::pair unpackVScaleRangeArgs(uint64_t Value) {
+  unsigned MaxValue = Value & std::numeric_limits::max();
+  unsigned MinValue = Value >> 32;
+
+  return std::make_pair(MinValue, MaxValue);
+}
+
 Attribute Att

[clang] 48f5a39 - [IR] Add vscale_range IR function attribute

2021-03-22 Thread Bradley Smith via cfe-commits

Author: Bradley Smith
Date: 2021-03-22T12:05:06Z
New Revision: 48f5a392cb73d99a58f01448926f6964ab5b0d0a

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

LOG: [IR] Add vscale_range IR function attribute

This attribute represents the minimum and maximum values vscale can
take. For now this attribute is not hooked up to anything during
codegen, this will be added in the future when such codegen is
considered stable.

Additionally hook up the -msve-vector-bits= clang option to emit this
attribute.

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

Added: 
clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
llvm/test/Verifier/vscale_range.ll

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp
llvm/docs/BitCodeFormat.rst
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Bitcode/attributes.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index fd708849e609..e3fdf54716ab 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -496,6 +496,13 @@ void CodeGenFunction::FinishFunction(SourceLocation 
EndLoc) {
   if (LargestVectorWidth)
 CurFn->addFnAttr("min-legal-vector-width", 
llvm::utostr(LargestVectorWidth));
 
+  // Add vscale attribute if appropriate.
+  if (getLangOpts().ArmSveVectorBits) {
+unsigned VScale = getLangOpts().ArmSveVectorBits / 128;
+CurFn->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs(getLLVMContext(),
+ VScale, VScale));
+  }
+
   // If we generated an unreachable return block, delete it now.
   if (ReturnBlock.isValid() && ReturnBlock.getBlock()->use_empty()) {
 Builder.ClearInsertionPoint();

diff  --git a/clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c 
b/clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
new file mode 100644
index ..84541f9cb12d
--- /dev/null
+++ b/clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=128 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=128
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=256 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=256
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=512 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=512
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=1024 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=1024
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=2048 -S -emit-llvm -o - %s | FileCheck %s -D#VBITS=2048
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=scalable -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-NONE
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -S 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-NONE
+
+// CHECK-LABEL: @func() #0
+// CHECK: attributes #0 = { {{.*}} 
vscale_range([[#div(VBITS,128)]],[[#div(VBITS,128)]]) {{.*}} }
+// CHECK-NONE-NOT: vscale_range
+void func() {}

diff  --git a/llvm/docs/BitCodeFormat.rst b/llvm/docs/BitCodeFormat.rst
index df0e195c6809..eff9d2866a8f 100644
--- a/llvm/docs/BitCodeFormat.rst
+++ b/llvm/docs/BitCodeFormat.rst
@@ -1070,6 +1070,7 @@ The integer codes are mapped to well-known attributes as 
follows.
 * code 68: ``noundef``
 * code 69: ``byref``
 * code 70: ``mustprogress``
+* code 74: ``vscale_range([, ])``
 
 .. note::
   The ``allocsize`` attribute has a special encoding for its arguments. Its two
@@ -1077,6 +1078,12 @@ The integer codes are mapped to well-known attributes as 
follows.
   (i.e. ``(EltSizeParam << 32) | NumEltsParam``), with ``NumEltsParam`` taking 
on
   the sentinel value -1 if it is not specified.
 
+.. note::
+  The ``vscale_range`` attribute has a special encoding for its arguments. Its 
two
+  arguments, which are 32-bit integers, are packed into one 64-bit integer 
value
+  (i.e. ``(Min << 32) | Max``), with ``Max`` taking on the value of ``Min`` if
+  it is not specified.
+
 .. _TYPE_BLOCK:
 
 TYPE_BLOCK Contents

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Just a ping for you, guys, to let me move in this direction.


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

https://reviews.llvm.org/D96090

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


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

2021-03-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.

LGTM; just one minor comment, which you can address as part of your commit.




Comment at: clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp:2
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -O0 -o - | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CLC++ -emit-llvm 
-O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS
 

Nitpick: this `-cl-std` can be removed too.


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

https://reviews.llvm.org/D96771

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


[PATCH] D98738: [clang-tidy] performance-* checks: Match AllowedTypes against qualified type names when they contain "::".

2021-03-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:60
+ return RegexAndScope{
+ .Regex = llvm::Regex(Name),
+ .MatchQualifiedName = Name.contains("::"),

I don't think that the clang style-guide accepts designated initializers yet.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:79
+llvm::Regex Regex;
+bool MatchQualifiedName = false;
+  };

Worth a comment i think.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:86
+// Returns a matcher that matches NamedDecls against a list of provided regular
+// expressions. If a regular expression contains '::' the NamedDecls qualified
+// name will be used for matching, otherwise its name will be used.

nit: s/NamedDecls/`NamedDecl`'s/



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:55
   return llvm::any_of(NameList, [&Node](const std::string &Name) {
-  return llvm::Regex(Name).match(Node.getName());
-});
+if (Name.find("::") != std::string::npos) {
+  return llvm::Regex(Name).match(Node.getQualifiedNameAsString());

flx wrote:
> hokein wrote:
> > hokein wrote:
> > > If we pass the name as a `llvm::StringRef`, we can use `if 
> > > (Name.contains("::"))` which seems a bit clearer to me.
> > there is a tricky case where the `::` is a prefix of the Name, e.g.  a 
> > global symbol x, the Name is `::x`, and `getQualifiedNameAsString` of 
> > symbol x is `x` (without the `::` prefix), then the matcher will not find a 
> > match, but we expect this is a match right?
> > 
> I agree that's a tricky case.
> 
> We could prepend "::" to getQualifiedNameAsString() and always match against 
> it. Would this work?
> 
> Or we could do this only for regex names that have a leading "::".  This 
> would avoid extra string operations, and users could still match using 
> "^foo::Bar$" to match ::foo::Bar.
>Or we could do this only for regex names that have a leading "::". This would 
>avoid extra string operations, and users could still match using "^foo::Bar$" 
>to match ::foo::Bar.

This should work most of the time. There could still be mistakes, like if a 
user spells the "::" in some odd way, like "[:][:]", but that seems quite 
unlikely in practice.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98738

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


[clang] 9cd7c41 - [analyzer] Don't include private gtest headers

2021-03-22 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2021-03-22T13:31:38+01:00
New Revision: 9cd7c4130635a6f0c94046f529fb1ee19118bbfb

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

LOG: [analyzer] Don't include private gtest headers

Added: 


Modified: 
clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp 
b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
index aeeff47a9af9..5be2ee3fc520 100644
--- a/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -13,7 +13,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/Support/raw_ostream.h"
-#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
 using namespace clang;



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


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

2021-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1445-1461
+  unsigned TokKind = 0;
+  switch (Tok.getKind()) {
+  case tok::kw_mutable: TokKind = 0; break;
+  case tok::arrow: TokKind = 1; break;
+  case tok::kw___attribute:
+  case tok::kw___private:
+  case tok::kw___global:

curdeius wrote:
> Is this really needed? May I simplify remove this switch and just have a 
> generic warning message?
I think a generic diagnostic would be reasonable. I think `lambda without a 
parameter clause is a C++2b extension` would be sufficiently clear.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D99072: [NFC] Formatting changes

2021-03-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: thopre, hiraditya.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch addresses some formatting changes from the comments in 
https://reviews.llvm.org/D97785.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99072

Files:
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +845,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,9 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,8 +139,9 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
+if (auto ExistingOrErr = MemoryBuffer::getFile(
+OutputFilename, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+/*IsVolatile=*/false, /*IsText=*/true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
Index: llvm/lib/IRReader/IRReader.cpp
===
--- llvm/lib/IRReader/IRReader.cpp
+++ llvm/lib/IRReader/IRReader.cpp
@@ -92,9 +92,9 @@
 llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
   DataLayoutCallbackTy DataLayoutCallback) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError()) {
 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + EC.message());
Index: clang/tools/arcmt-test/arcmt-test.cpp
===
--- clang/tools/arcmt-test/arcmt-test.cpp
+++ clang/tools/arcmt-test/arcmt-test.cpp
@@ -208,14 +208,14 @@
   using namespace llvm;
 
   ErrorOr> file1 = MemoryBuffer::getFile(
-  fname1, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname1, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+  /*IsVolatile=*/false, /*IsText=*/true);
   if (!file1)
 return false;
 
   ErrorOr> file2 = MemoryBuffer::getFile(
-  fname2, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname2, /*FileSize=*/-1, /*RequiresNullTerm

[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

2021-03-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed to the release branch in 
https://github.com/llvm/llvm-project/commit/00441b8f4e5b7daa39ac6cbeb45ebfe54662b08d


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

https://reviews.llvm.org/D98076

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


[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-22 Thread Janusz Nykiel via Phabricator via cfe-commits
jnykiel updated this revision to Diff 332268.
jnykiel added a comment.

Thanks. About committing/attribution, I'm not sure how it's supposed to work - 
I've asked a co-worker (@aganea) to commit this, but if he can't do it, please 
do it instead. I'm Janusz Nykiel, email address janusz.nykiel at ubisoft.com


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

https://reviews.llvm.org/D98824

Files:
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -725,14 +725,14 @@
 protected:
   // Look up the command from a relative path, and return it in string form.
   // The input file is not included in the returned command.
-  std::string getCommand(llvm::StringRef F) {
+  std::string getCommand(llvm::StringRef F, bool MakeNative = true) {
 auto Results =
 inferMissingCompileCommands(std::make_unique(Entries))
-->getCompileCommands(path(F));
+->getCompileCommands(MakeNative ? path(F) : F);
 if (Results.empty())
   return "none";
 // drop the input file argument, so tests don't have to deal with path().
-EXPECT_EQ(Results[0].CommandLine.back(), path(F))
+EXPECT_EQ(Results[0].CommandLine.back(), MakeNative ? path(F) : F)
 << "Last arg should be the file";
 Results[0].CommandLine.pop_back();
 return llvm::join(Results[0].CommandLine, " ");
@@ -812,6 +812,28 @@
   EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall");
 }
 
+TEST_F(InterpolateTest, StripDoubleDash) {
+  add("dir/foo.cpp", "-o foo.o -std=c++14 -Wall -- dir/foo.cpp");
+  // input file and output option are removed
+  // -Wall flag isn't
+  // -std option gets re-added as the last argument before the input file
+  // -- is removed as it's not necessary - the new input file doesn't start with
+  // a dash
+  EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall -std=c++14");
+}
+
+TEST_F(InterpolateTest, InsertDoubleDash) {
+  add("dir/foo.cpp", "-o foo.o -std=c++14 -Wall");
+  EXPECT_EQ(getCommand("-dir/bar.cpp", false),
+"clang -D dir/foo.cpp -Wall -std=c++14 --");
+}
+
+TEST_F(InterpolateTest, InsertDoubleDashForClangCL) {
+  add("dir/foo.cpp", "clang-cl", "/std:c++14 /W4");
+  EXPECT_EQ(getCommand("/dir/bar.cpp", false),
+"clang-cl -D dir/foo.cpp /W4 /std:c++14 --");
+}
+
 TEST_F(InterpolateTest, Case) {
   add("FOO/BAR/BAZ/SHOUT.cc");
   add("foo/bar/baz/quiet.cc");
@@ -831,7 +853,7 @@
   add("foo.cpp", "clang-cl", "/W4");
 
   // Language flags should be added with CL syntax.
-  EXPECT_EQ(getCommand("foo.h"), "clang-cl -D foo.cpp /W4 /TP");
+  EXPECT_EQ(getCommand("foo.h", false), "clang-cl -D foo.cpp /W4 /TP");
 }
 
 TEST_F(InterpolateTest, DriverModes) {
@@ -839,8 +861,10 @@
   add("bar.cpp", "clang", "--driver-mode=cl");
 
   // --driver-mode overrides should be respected.
-  EXPECT_EQ(getCommand("foo.h"), "clang-cl -D foo.cpp --driver-mode=gcc -x c++-header");
-  EXPECT_EQ(getCommand("bar.h"), "clang -D bar.cpp --driver-mode=cl /TP");
+  EXPECT_EQ(getCommand("foo.h"),
+"clang-cl -D foo.cpp --driver-mode=gcc -x c++-header");
+  EXPECT_EQ(getCommand("bar.h", false),
+"clang -D bar.cpp --driver-mode=cl /TP");
 }
 
 TEST(TransferCompileCommandTest, Smoke) {
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -440,8 +440,9 @@
   return;
 
   // If there's no override in place add our resource dir.
-  Args.push_back("-resource-dir=" +
- CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+  Args = getInsertArgumentAdjuster(
+  ("-resource-dir=" + CompilerInvocation::GetResourcesPath(Argv0, MainAddr))
+  .c_str())(Args, "");
 }
 
 int ClangTool::run(ToolAction *Action) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -177,6 +177,10 @@
Opt.matches(OPT__SLASH_Fo
 continue;
 
+  // ...including when the inputs are passed after --.
+  if (Opt.matches(OPT__DASH_DASH))
+break;
+
   // Strip -x, but record the overridden language.
   if (const auto GivenType = tryParseTypeArg(*Arg)) {
 Type = *GivenType;
@@ -235,6 +239,8 @@
   llvm::Twine(ClangCLMode ? "/std:" : "-std=") +
   LangStandard::getLangStandardForKind(Std).getName()).str());
 }
+if (Filename.startswith("-") || (ClangCLMod

[clang] ce9bade - [clang][ASTImporter] Add import API for 'const Type *' (NFC).

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

Author: Balázs Kéri
Date: 2021-03-22T14:38:49+01:00
New Revision: ce9bade1f2c6249cf4179842aeb5e7e3bb34ceec

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

LOG: [clang][ASTImporter] Add import API for 'const Type *' (NFC).

There was only an `Import` function for `QualType` but not for `Type`.
For correct import of some AST nodes where not `QualType` is used
an import of `Type *` is needed. (It is the case with
`FieldDecl::getCapturedVLAType`.)

Reviewed By: shafik, teemperor, martong

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

Added: 


Modified: 
clang/include/clang/AST/ASTImporter.h
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTImporter.h 
b/clang/include/clang/AST/ASTImporter.h
index 630d220deff7..17e673a8471a 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/AST/ASTImporter.h
@@ -344,6 +344,12 @@ class TypeSourceInfo;
 Import(ExprWithCleanups::CleanupObject From);
 
 /// Import the given type from the "from" context into the "to"
+/// context.
+///
+/// \returns The equivalent type in the "to" context, or the import error.
+llvm::Expected Import(const Type *FromT);
+
+/// Import the given qualified type from the "from" context into the "to"
 /// context. A null type is imported as a null type (no error).
 ///
 /// \returns The equivalent type in the "to" context, or the import error.

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index bf3cb4c42873..182a57c16aba 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8168,28 +8168,37 @@ ASTImporter::Import(ExprWithCleanups::CleanupObject 
From) {
   return make_error(ImportError::UnsupportedConstruct);
 }
 
-Expected ASTImporter::Import(QualType FromT) {
-  if (FromT.isNull())
-return QualType{};
-
-  const Type *FromTy = FromT.getTypePtr();
+Expected ASTImporter::Import(const Type *FromT) {
+  if (!FromT)
+return FromT;
 
   // Check whether we've already imported this type.
-  llvm::DenseMap::iterator Pos
-= ImportedTypes.find(FromTy);
+  llvm::DenseMap::iterator Pos =
+  ImportedTypes.find(FromT);
   if (Pos != ImportedTypes.end())
-return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
+return Pos->second;
 
   // Import the type
   ASTNodeImporter Importer(*this);
-  ExpectedType ToTOrErr = Importer.Visit(FromTy);
+  ExpectedType ToTOrErr = Importer.Visit(FromT);
   if (!ToTOrErr)
 return ToTOrErr.takeError();
 
   // Record the imported type.
-  ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
+  ImportedTypes[FromT] = ToTOrErr->getTypePtr();
+
+  return ToTOrErr->getTypePtr();
+}
+
+Expected ASTImporter::Import(QualType FromT) {
+  if (FromT.isNull())
+return QualType{};
+
+  Expected ToTyOrErr = Import(FromT.getTypePtr());
+  if (!ToTyOrErr)
+return ToTyOrErr.takeError();
 
-  return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
+  return ToContext.getQualifiedType(*ToTyOrErr, FromT.getLocalQualifiers());
 }
 
 Expected ASTImporter::Import(TypeSourceInfo *FromTSI) {



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


[PATCH] D98951: [clang][ASTImporter] Add import API for 'const Type *' (NFC).

2021-03-22 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce9bade1f2c6: [clang][ASTImporter] Add import API for 
'const Type *' (NFC). (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98951

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8168,28 +8168,37 @@
   return make_error(ImportError::UnsupportedConstruct);
 }
 
-Expected ASTImporter::Import(QualType FromT) {
-  if (FromT.isNull())
-return QualType{};
-
-  const Type *FromTy = FromT.getTypePtr();
+Expected ASTImporter::Import(const Type *FromT) {
+  if (!FromT)
+return FromT;
 
   // Check whether we've already imported this type.
-  llvm::DenseMap::iterator Pos
-= ImportedTypes.find(FromTy);
+  llvm::DenseMap::iterator Pos =
+  ImportedTypes.find(FromT);
   if (Pos != ImportedTypes.end())
-return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
+return Pos->second;
 
   // Import the type
   ASTNodeImporter Importer(*this);
-  ExpectedType ToTOrErr = Importer.Visit(FromTy);
+  ExpectedType ToTOrErr = Importer.Visit(FromT);
   if (!ToTOrErr)
 return ToTOrErr.takeError();
 
   // Record the imported type.
-  ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
+  ImportedTypes[FromT] = ToTOrErr->getTypePtr();
+
+  return ToTOrErr->getTypePtr();
+}
+
+Expected ASTImporter::Import(QualType FromT) {
+  if (FromT.isNull())
+return QualType{};
+
+  Expected ToTyOrErr = Import(FromT.getTypePtr());
+  if (!ToTyOrErr)
+return ToTyOrErr.takeError();
 
-  return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
+  return ToContext.getQualifiedType(*ToTyOrErr, FromT.getLocalQualifiers());
 }
 
 Expected ASTImporter::Import(TypeSourceInfo *FromTSI) {
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -344,6 +344,12 @@
 Import(ExprWithCleanups::CleanupObject From);
 
 /// Import the given type from the "from" context into the "to"
+/// context.
+///
+/// \returns The equivalent type in the "to" context, or the import error.
+llvm::Expected Import(const Type *FromT);
+
+/// Import the given qualified type from the "from" context into the "to"
 /// context. A null type is imported as a null type (no error).
 ///
 /// \returns The equivalent type in the "to" context, or the import error.


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8168,28 +8168,37 @@
   return make_error(ImportError::UnsupportedConstruct);
 }
 
-Expected ASTImporter::Import(QualType FromT) {
-  if (FromT.isNull())
-return QualType{};
-
-  const Type *FromTy = FromT.getTypePtr();
+Expected ASTImporter::Import(const Type *FromT) {
+  if (!FromT)
+return FromT;
 
   // Check whether we've already imported this type.
-  llvm::DenseMap::iterator Pos
-= ImportedTypes.find(FromTy);
+  llvm::DenseMap::iterator Pos =
+  ImportedTypes.find(FromT);
   if (Pos != ImportedTypes.end())
-return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
+return Pos->second;
 
   // Import the type
   ASTNodeImporter Importer(*this);
-  ExpectedType ToTOrErr = Importer.Visit(FromTy);
+  ExpectedType ToTOrErr = Importer.Visit(FromT);
   if (!ToTOrErr)
 return ToTOrErr.takeError();
 
   // Record the imported type.
-  ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
+  ImportedTypes[FromT] = ToTOrErr->getTypePtr();
+
+  return ToTOrErr->getTypePtr();
+}
+
+Expected ASTImporter::Import(QualType FromT) {
+  if (FromT.isNull())
+return QualType{};
+
+  Expected ToTyOrErr = Import(FromT.getTypePtr());
+  if (!ToTyOrErr)
+return ToTyOrErr.takeError();
 
-  return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
+  return ToContext.getQualifiedType(*ToTyOrErr, FromT.getLocalQualifiers());
 }
 
 Expected ASTImporter::Import(TypeSourceInfo *FromTSI) {
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -344,6 +344,12 @@
 Import(ExprWithCleanups::CleanupObject From);
 
 /// Import the given type from the "from" context into the "to"
+/// context.
+///
+/// \returns The equivalent type in the "to" context, or the import error.
+llvm::Expected Import(const Type *FromT);
+
+/// Import the given qualified type from the "from" context into the "to"
 /// contex

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D97785#2638824 , @MaskRay wrote:

> The recommended named parameter form is probably `/*Param=*/something`. It is 
> liked by both 
> https://clang.llvm.org/extra/clang-tidy/checks/bugprone-argument-comment.html 
> and clang-format.
> Another form look to me as well, if both the two tools like it.

Thanks, I've created the following patch https://reviews.llvm.org/D99072 to fix 
the parameter formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D55212: Handle alloc_size attribute on function pointers

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

In D55212#2640260 , @arichardson wrote:

> I completely forgot about this patch. @aaron.ballman are you still happy for 
> me to commit this?

I think where we left off is that this causes a slight regression in behavior 
because it shrinks the list of attributes that can use `#pragma clang 
attribute`. From earlier:

> I'm also adding Erik and Duncan to the review because they may have some more 
> insights into whether alloc_size is being used with #pragma clang attribute 
> in the wild. My feeling is: if we can't spot any uses of that feature being 
> used to apply alloc_size with a reasonable amount of looking for it, then we 
> can go ahead with this patch even if it removes support for alloc_size from 
> the pragma. If we get push back from the community, we can fix or revert at 
> that time. However, given that this is plausibly a breaking change, I'd 
> rather not commit to trunk until after we branch to give folks more time to 
> react. WDYT?

I think folks will have a chance to react if we apply it to trunk now, but I am 
wondering if anyone's had a chance to investigate usage in the wild. 
@erik.pilkington or @dexonsmith, do either of you have a gut feeling?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55212

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


[PATCH] D99072: [NFC] Formatting changes

2021-03-22 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp accepted this revision.
anirudhp 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/D99072/new/

https://reviews.llvm.org/D99072

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

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

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

https://reviews.llvm.org/D97371

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/CodeGenObjC/attr-nomerge.m


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(...) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+
+  return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(...) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+
+  return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55212: Handle alloc_size attribute on function pointers

2021-03-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.

In D55212#2641301 , @aaron.ballman 
wrote:

> I think folks will have a chance to react if we apply it to trunk now, but I 
> am wondering if anyone's had a chance to investigate usage in the wild. 
> @erik.pilkington or @dexonsmith, do either of you have a gut feeling?

I don't see any uses of #pca with alloc_size in our internal codebase. IMO I'd 
be really quite surprised if anyone actually used these two features together.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55212

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-03-22 Thread David Candler via Phabricator via cfe-commits
dcandler created this revision.
dcandler added reviewers: t.p.northover, rsanthir.quic, SjoerdMeijer, efriedma, 
peter.smith, labrinea.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
dcandler requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch changes the AArch32 crypto instructions (sha2 and aes) to
require the specific sha2 or aes features. These features have
already been implemented and can be controlled through the command
line, but do not have the expected result (i.e. `+noaes` will not
disable aes instructions). The crypto feature retains its existing
meaning of both sha2 and aes.

Several small changes are included due to the knock-on effect this has:

- The AArch32 driver has been modified to ensure sha2/aes is correctly set 
based on arch/cpu/fpu selection and feature ordering.
- Crypto extensions are permitted for AArch32 v8-R profile, but not enabled by 
default.
- ACLE feature macros have been updated with the fine grained crypto 
algorithms. These are also used by AArch64.
- Various tests updated due to the change in feature lists and macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99079

Files:
  clang/include/clang/Basic/arm_neon.td
  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/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm-target-features.c
  clang/test/CodeGen/arm64_crypto.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Driver/arm-features.c
  clang/test/Driver/arm-mfpu.c
  clang/test/Driver/armv8.1m.main.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/test/Bindings/llvm-c/ARM/disassemble.test
  llvm/test/MC/ARM/directive-arch_extension-aes-sha2.s
  llvm/test/MC/ARM/directive-arch_extension-crypto.s
  llvm/test/MC/ARM/neon-crypto.s

Index: llvm/test/MC/ARM/neon-crypto.s
===
--- llvm/test/MC/ARM/neon-crypto.s
+++ llvm/test/MC/ARM/neon-crypto.s
@@ -9,10 +9,10 @@
 @ CHECK: aese.8 q0, q1  @ encoding: [0x02,0x03,0xb0,0xf3]
 @ CHECK: aesimc.8 q0, q1@ encoding: [0xc2,0x03,0xb0,0xf3]
 @ CHECK: aesmc.8 q0, q1 @ encoding: [0x82,0x03,0xb0,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
+@ CHECK-V7: instruction requires: aes armv8
 
 sha1h.32  q0, q1
 sha1su1.32  q0, q1
@@ -20,9 +20,9 @@
 @ CHECK: sha1h.32  q0, q1   @ encoding: [0xc2,0x02,0xb9,0xf3]
 @ CHECK: sha1su1.32 q0, q1  @ encoding: [0x82,0x03,0xba,0xf3]
 @ CHECK: sha256su0.32 q0, q1@ encoding: [0xc2,0x03,0xba,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 sha1c.32  q0, q1, q2
 sha1m.32  q0, q1, q2
@@ -38,14 +38,14 @@
 @ CHECK: sha256h.32  q0, q1, q2  @ encoding: [0x44,0x0c,0x02,0xf3]
 @ CHECK: sha256h2.32 q0, q1, q2  @ encoding: [0x44,0x0c,0x12,0xf3]
 @ CHECK: sha256su1.32 q0, q1, q2 @ encoding: [0x44,0x0c,0x22,0xf3]
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
+@ CHECK-V7: instruction requires: sha2 armv8
 
 vmull.p64 q8, d16, d17
 @ CHECK: vmull.p64  q8, d16, d17@ encoding: [0xa1,0x0e,0xe0,0xf2]
-@ CHECK-V7: instruction requires: crypto armv8
+@ CHECK-V7: instruction requires: aes armv8
Index: llvm/test/MC/ARM/directive-arch_extension-crypto.s
===
--- llvm/test/MC/ARM/directive-arch_extension-crypto.s
+++ llvm/test/

[PATCH] D55212: Handle alloc_size attribute on function pointers

2021-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In D55212#2641402 , @erik.pilkington 
wrote:

> In D55212#2641301 , @aaron.ballman 
> wrote:
>
>> I think folks will have a chance to react if we apply it to trunk now, but I 
>> am wondering if anyone's had a chance to investigate usage in the wild. 
>> @erik.pilkington or @dexonsmith, do either of you have a gut feeling?
>
> I don't see any uses of #pca with alloc_size in our internal codebase. IMO 
> I'd be really quite surprised if anyone actually used these two features 
> together.

Thank you for the feedback! Then I think this continues to LGTM -- if there is 
breakage in the wild, we can hopefully react to it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55212

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


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 332293.
balazske added a comment.

Simplified the test somewhat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock_state.c


Index: clang/test/Analysis/pthreadlock_state.c
===
--- /dev/null
+++ clang/test/Analysis/pthreadlock_state.c
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | 
FileCheck %s
+
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
+
+#define NULL 0
+
+void clang_analyzer_printState();
+
+pthread_mutex_t mtx;
+
+void test(pthread_mutex_t *mtx1) {
+  clang_analyzer_printState();
+  // CHECK:"checker_messages": null
+
+  pthread_mutex_init(&mtx, NULL);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  pthread_mutex_lock(&mtx);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: locked",
+  // CHECK-NEXT:  "Mutex lock order:",
+  // CHECK-NEXT:  "mtx",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  pthread_mutex_unlock(&mtx);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  int ret = pthread_mutex_destroy(&mtx);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked, possibly destroyed",
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:",
+  // CHECK-NEXT:  "mtx: conj_$
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  if (ret)
+return;
+
+  ret = pthread_mutex_destroy(mtx1);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: destroyed",
+  // CHECK-NEXT:  "SymRegion{reg_$[[REG:[0-9]+]]}: 
not tracked, possibly destroyed",
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:",
+  // CHECK-NEXT:  "SymRegion{reg_$[[REG]]}: conj_$
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  if (ret)
+return;
+  pthread_mutex_init(mtx1, NULL);
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -339,7 +339,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutexes in unresolved possibly destroyed state:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,


Index: clang/test/Analysis/pthreadlock_state.c
===
--- /dev/null
+++ clang/test/Analysis/pthreadlock_state.c
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
+
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
+
+#define NULL 0
+
+void clang_analyzer_printState();
+
+pthread_mutex_t mtx;
+
+void test(pthread_mutex_t *mtx1) {
+  clang_analyzer_printState();
+  // CHECK:"checker_messages": null
+
+  pthread_mutex_init(&mtx, NULL);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  pthread_mutex_lock(&mtx);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: locked",
+  // CHECK-NEXT:  "Mutex lock order:",
+  // CHECK-NEXT:  "mtx",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  pthread_mutex_unlock(&mtx);
+  clang_analyzer_printState();
+  // CHECK:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:",
+  // CHECK-NEXT:  "mtx: unlocked",
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+
+  int ret = pthread_mutex_destroy(&mtx);
+  clang_analyzer_printState();
+  // CH

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

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

Thank you for adding this  @arnamoy10 !

I think that in order to match the semantics of `-Werror` from `f18`, this 
patch needs to be extended a bit. In the following two cases, `f18` will exit 
immediately, whereas `flang-new -fc1` will happily carry-on:

- 
https://github.com/llvm/llvm-project/blob/main/flang/tools/f18/f18.cpp#L212-L213
- 
https://github.com/llvm/llvm-project/blob/main/flang/tools/f18/f18.cpp#L241-L242

Could you try implementing similar semantics here?

I've left a few more comments inline.




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:331-334
+  // -Werror option
+  if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
+res.SetWarnAsErr(true);
+  }

1. This will capture almost anything that matches `-W`. Could you 
verify that it's indeed `-Werror`?
2. This is a diagnostics rather than `Sema` option. We are likely to introduce 
much more with time. Could you move it to a separate method?



Comment at: flang/test/Semantics/dosemantics03.f90:1-2
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 

Rather than adding the 2nd line, could you update the first line to use 
`%flang_fc1` instead of `%f18`?


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

https://reviews.llvm.org/D98657

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


[PATCH] D98812: [OPENMP]Map data field with l-value reference types.

2021-03-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 332296.
ABataev added a comment.

Rebase + fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98812

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  openmp/libomptarget/test/mapping/data_member_ref.cpp

Index: openmp/libomptarget/test/mapping/data_member_ref.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/data_member_ref.cpp
@@ -0,0 +1,69 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include 
+
+struct View {
+  int Data;
+};
+
+struct ViewPtr {
+  int *Data;
+};
+
+template  struct Foo {
+  Foo(T &V) : VRef(V) {}
+  T &VRef;
+};
+
+int main() {
+  View V;
+  V.Data = 123456;
+  Foo Bar(V);
+  ViewPtr V1;
+  int Data = 123456;
+  V1.Data = &Data;
+  Foo Baz(V1);
+
+  // CHECK: Host 123456.
+  printf("Host %d.\n", Bar.VRef.Data);
+#pragma omp target map(Bar.VRef)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", Bar.VRef.Data);
+V.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", Bar.VRef.Data);
+  }
+  // CHECK: Host 654321 654321.
+  printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
+  V.Data = 123456;
+  // CHECK: Host 123456.
+  printf("Host %d.\n", Bar.VRef.Data);
+#pragma omp target map(Bar) map(Bar.VRef)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", Bar.VRef.Data);
+V.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", Bar.VRef.Data);
+  }
+  // CHECK: Host 654321 654321.
+  printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
+  // CHECK: Host 123456.
+  printf("Host %d.\n", *Baz.VRef.Data);
+#pragma omp target map(*Baz.VRef.Data)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", *Baz.VRef.Data);
+*V1.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", *Baz.VRef.Data);
+  }
+  // CHECK: Host 654321 654321 654321.
+  printf("Host %d %d %d.\n", *Baz.VRef.Data, *V1.Data, Data);
+  return 0;
+}
Index: clang/test/OpenMP/target_map_codegen_35.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_map_codegen_35.cpp
@@ -0,0 +1,182 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK35 --check-prefix CK35-64
+// RUN: %clang_cc1 -DCK35 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-64
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-32
+// RUN: %clang_cc1 -DCK35 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-32
+
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -fopenmp-simd -fopenmp-version=50 -fopenmp

[PATCH] D99082: [RISCV][NFC] Fix RVV intrinsic tests.

2021-03-22 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, HsiangKai, evandro, liaolucy.
Herald added subscribers: vkmr, frasercrmck, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

1. Skip the temporary file
2. Test cc1 with -S to verify codegen work well. Add '-target-feature +m' 
because the backend requires it to calculate the vscaled size/offset.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99082

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c
@@ -4,8 +4,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -emit-llvm -o - %s \
 // RUN:   | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -Werror -Wall -o - \
-// RUN:   %s > /dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
@@ -4,8 +4,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -emit-llvm -o - %s \
 // RUN:   | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -Werror -Wall -o - \
-// RUN:   %s > /dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
@@ -3,8 +3,8 @@
 // RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
 // RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
-// RUN:   -Werror -Wall -o - %s >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature +f -target-feature +d -target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
@@ -3,8 +3,8 @@
 // RUN:   -disable-O0-optnone  -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
 // RUN:   -disable-O0-optnone  -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
-// RUN:   -Werror -Wall -o - %s >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature +f -target-feature +d -target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck --check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
===

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

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

Ping.


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

https://reviews.llvm.org/D82547

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-22 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 332303.
ffrankies added a comment.

Implemented changes requested by @aaron.ballman


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,516 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+
+#ifdef MULT
+// For loops with *= and /= increments.
+void for_loop_mult_div_increments(int *A) {
+// *=
+#pragma unroll
+  for (int i = 2; i <= 32; i *= 2)
+A[i]++; // OK
+
+#pragma unroll
+  for (int i = 2; i <= 64; i *= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++; // Not OK
+
+// /=
+#pragma unroll
+  for (int i = 32; i >= 2; i /= 2)
+A[i]++; // OK
+
+#pragma unroll
+  for (int i = 64; i >= 2; i /= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++; // Not OK
+}
+#else
+// Cannot determine loop bounds for while loops.
+void while_loops(int *A) {
+  // Recommend unrolling loops that aren't already unrolled.
+  int j = 0;
+  while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[1] += j;
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[2] += j;
+j++;
+  } while (j < 2000);
+
+// If a while loop is fully unrolled, add a note recommending partial
+// unrolling.
+#pragma unroll
+  while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+  }
+
+#pragma unroll
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+  } while (j < 2000);
+
+// While loop is partially unrolled, no action needed.
+#pragma unroll 4
+  while (j < 2000) {
+A[j]++;
+  }
+
+#pragma unroll 4
+  do {
+A[j]++;
+  } while (j < 2000);
+}
+
+// Range-based for loops.
+void cxx_for_loops(int *A, int vectorSize) {
+  // Loop with known array size should be unrolled.
+  int a[] = {0, 1, 2, 3, 4, 5};
+  for (int k : a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[k]++;
+  }
+
+// Loop with known size correctly unrolled.
+#pragma unroll
+  for (int k : a) {
+A[k]++;
+  }
+
+  // Loop with unknown size should be partially unrolled.
+  int b[vectorSize];
+#pragma unroll
+  for (int k : b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: full unrolling requested, but loop bounds are not known; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+k++;
+  }
+
+// Loop with unknown size correctly unrolled.
+#pragma unroll 5
+  for (int k : b) {
+k++;
+  }
+
+  // Loop with large size should be partially unrolled.
+  int c[51];
+#pragma unroll
+  for (int k : c) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[k]++;
+  }
+
+// Loop with large size correctly unrolled.
+#pragma unroll 5
+  for (int k : c) {
+A[k]++;
+  }
+}
+
+// Simple for loops.
+void for_loops(int *A, int size) {
+  // Recommend unrolling loops that aren't already unrolled.
+  for (int i = 0; i < 2000; ++i) {
+ 

[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-22 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies marked 7 inline comments as done.
ffrankies added a comment.

@aaron.ballman If there are no more changes, can you please commit this on my 
behalf? My github username is ffrankies .


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

https://reviews.llvm.org/D72235

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-22 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 332307.
khchen added a comment.

Remove half type in TypeList.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

SG, will wait for Alexandre to land this then!


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

https://reviews.llvm.org/D98824

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


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz updated this revision to Diff 332312.
glaubitz retitled this revision from "[Sparc] Define the same macros for 
-mcpu=v9 as GCC on Linux" to "[Sparc] Define the same macros for -mcpu=v9 as 
GCC on Linux  and the BSDs".
glaubitz edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

Files:
  clang/lib/Basic/Targets/Sparc.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
   Builder.defineMacro("__sparcv8__");
   break;
 case CG_V9:
-  Builder.defineMacro("__sparcv9");
-  Builder.defineMacro("__sparcv9__");
   Builder.defineMacro("__sparc_v9__");
   break;
 }
@@ -239,13 +237,17 @@
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
-  // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
-Builder.defineMacro("__sparc64__");
+  if (getTriple().getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__sparc_v9__");
-Builder.defineMacro("__sparcv9__");
+  } else {
+Builder.defineMacro("__sparcv9");
+// Solaris doesn't need these variants, but the BSDs do.
+if (getTriple().getOS() != llvm::Triple::Solaris) {
+  Builder.defineMacro("__sparc64__");
+  Builder.defineMacro("__sparc_v9__");
+  Builder.defineMacro("__sparcv9__");
+}
   }
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===

Re: [clang] c2f9086 - [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot

2021-03-22 Thread Matt Morehouse via cfe-commits
Hi Fangrui,

This change seems to have broken the link on Android:
https://lab.llvm.org/buildbot/#/builders/77/builds/4777
Could you please take a look?

ld.lld: error: 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../lib64/libc++.so
is incompatible with aarch64linux



On Sat, Mar 20, 2021 at 9:38 PM Fangrui Song via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Fangrui Song
> Date: 2021-03-20T21:37:49-07:00
> New Revision: c2f9086b6184a132ec8cac7edeb620813796e1e8
>
> URL:
> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8
> DIFF:
> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8.diff
>
> LOG: [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot
>
> Added:
>
>
> Modified:
> clang/lib/Driver/ToolChains/Gnu.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
> b/clang/lib/Driver/ToolChains/Gnu.cpp
> index 39be77463544..078579669634 100644
> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
> @@ -2853,8 +2853,6 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
>Paths);
>  }
>
> -// See comments above on the multilib variant for details of why this
> is
> -// included even from outside the sysroot.
>  const std::string &LibPath =
>  std::string(GCCInstallation.getParentLibPath());
>  const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
> @@ -2862,11 +2860,7 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
>  addPathIfExists(
>  D, LibPath + "/../" + GCCTriple.str() + "/lib" +
> Multilib.osSuffix(),
>  Paths);
> -
> -// See comments above on the multilib variant for details of why this
> is
> -// only included from within the sysroot.
> -if (StringRef(LibPath).startswith(SysRoot))
> -  addPathIfExists(D, LibPath, Paths);
> +addPathIfExists(D, LibPath, Paths);
>}
>  }
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-03-22 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added inline comments.



Comment at: llvm/include/llvm/Support/TypeSize.h:31-35
+namespace TypeSizeClOpt {
+/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
+/// using the wrong interface.
+extern cl::opt ScalableErrorAsWarning;
+} // namespace TypeSizeClOpt

paulwalker-arm wrote:
> Why is this need here? Can it just be externs where it's accessed?
It could, but that would be annoying. It would be nice if you could just 
include the header and have this symbol in scope.

Whether or not it should be convenient to use this option is a valid question 
though. I'm fine either way.



Comment at: llvm/lib/CodeGen/ValueTypes.cpp:28
+  if (isScalableVector()) {
+if (llvm::TypeSizeClOpt::ScalableErrorAsWarning)
+  WithColor::warning()

paulwalker-arm wrote:
> I guess related to my comment for TypeSize.h but I'm wondering if it's better 
> to move all error reporting into TypeSize.cpp. For example:
> ```
> if (isScalableVector())
>   reportInvalidSizeRequest("EVT::getVectorNumElements()", 
> "EVT::getVectorElementCount()")
> 
> reportInvalidSizeRequest(string bad_func, string good_fun) {
> #ifndef STRICT_FIXED_SIZE_VECTORS
>   if (ScalableErrorAsWarning)
> warning(don't use badfunc, use good_fun instead)
>   else
> #endif
> Error()
> }
> ```
I guess if we did this, then the definitions for EVT::getVectorNumElements and 
the TypeSize cast to unsigned to stay in the header. Then, if 
STRICT_FIXED_SIZE_VECTORS is defined, it would be easy to inline the function 
body as it's all in the header, resulting in a real "pro" to defining 
STRICT_FIXED_SIZE_VECTORS and having your code work with it. I'm fine either 
way.

It's only two functions, and unlikely to increase to more, so you could make 
the case that it's not worth bothering over.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

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


[PATCH] D81285: [builtins] Change si_int to int in some helper declarations

2021-03-22 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Hi!

My users have found problems with miscompiles that seem to originate from this 
patch.

As a background, my target has 16-bit int, and 32-bit long. And the calling 
convention is not that an i16 is passed as the low bits in a 32-bit register 
that would be used for an i32 argument.
Thus, when the bultins are built for my target, and the signature doesn't 
specify the exact bit-width using `si_int`, but rather using `int`, then the 
lib function will expect to get a 16-bit input.

The problem is that opt/llc does not know about the size of `int` etc. But opt 
(SimplifyLibCalls) and llc (LegalizeDAG) can rewrite things into using libcalls 
to for example `__powisf2`. But when it generate those calls it will use a 
function signature with `int` being mapped to `i32`.

Afaict the change that made sure the size of si_int was respected (`typedef  
int32_t si_int;`) was a nice change.
But I don't really understand why some types where changed to C-types instead 
of the Machine Mode types. Specially since you also quote that `int` only is 
used as an illustration but the real implementation should use the Machine 
Modes.

The miscompile found was when using `pow(x, (double)2u)` together with 
`-ffast-math`. opt rewrites it into calling `@llvm.powi.f64(double, i32)`, and 
later LegalizeDAG will rewrite that into a libcall to `__powidf2(double , 
i32)`, although that call is wrong if the lib function is compiler as 
`__powidf2(double , i16)`.

Btw, I've found similar problems in for example SimplifyLibCall, that for 
example could rewrite `powf(2.0, itofp(x))` to `ldexpf(1.0, x)`. The second 
argument of ldexpf is an `int` according to math.h, but LLVM does not really 
consider that when doing the transform so it will use i32 in the call (while 
the lib in our case expect to receive an i16).

So it is kind of a mess. But I figure at least these "GCC low-level runtime 
library" kind of calls should use the Machine Modes? Or do we need to match up 
with the types in 
https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=libgcc/libgcc2.h;hb=HEAD ? If 
so, then this patch that made changes to compiler-rt (which is what we use for 
those builtins) isn't enough and we need to teach opt/llc to take the size of 
int into account when generating certain lib calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81285

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


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz updated this revision to Diff 332320.
glaubitz edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

Files:
  clang/lib/Basic/Targets/Sparc.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
   Builder.defineMacro("__sparcv8__");
   break;
 case CG_V9:
-  Builder.defineMacro("__sparcv9");
-  Builder.defineMacro("__sparcv9__");
   Builder.defineMacro("__sparc_v9__");
   break;
 }
@@ -239,13 +237,17 @@
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
-  // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
-Builder.defineMacro("__sparc64__");
+  if (getTriple().getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__sparc_v9__");
-Builder.defineMacro("__sparcv9__");
+  } else {
+Builder.defineMacro("__sparcv9");
+// Solaris doesn't need these variants, but the BSDs do.
+if (getTriple().getOS() != llvm::Triple::Solaris) {
+  Builder.defineMacro("__sparc64__");
+  Builder.defineMacro("__sparc_v9__");
+  Builder.defineMacro("__sparcv9__");
+}
   }
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
   Builder.defin

[PATCH] D99086: [clang][Syntax] Optimize expandedTokens for token ranges.

2021-03-22 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added reviewers: kadircet, sammccall.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

`expandedTokens(SourceRange)` used to do a binary search to get the
expanded tokens belonging to a source range. Each binary search uses
`isBeforeInTranslationUnit` to order two source locations. This is
inherently very slow.
By profiling clangd we found out that users like clangd::SelectionTree
spend 95% of time in `isBeforeInTranslationUnit`. Also it is worth
noting that users of `expandedTokens(SourceRange)` majorly use ranges
provided by AST to query this funciton. The ranges provided by AST are
token ranges (starting at the beginning of a token and ending at the
beginning of another token).

Therefore we can avoid the binary search in majority of the cases by
maintaining an index of ExpandedToken by their SourceLocations. We still
do binary search for ranges which are not token ranges but such
instances are quite low.

Performance:
`~/build/bin/clangd --check=clang/lib/Serialization/ASTReader.cpp`
Before: Took 2:10s to complete.
Now: Took 1:13s to complete.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99086

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp


Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -184,6 +184,18 @@
 }
 
 llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const 
{
+  // Quick lookup if `R` is a token range.
+  // This is a huge win since majority of the users use ranges provided by an
+  // AST. Ranges in AST are token ranges from expanded token stream.
+  const auto Begin = ExpandedTokIndex.find(R.getBegin());
+  const auto End = ExpandedTokIndex.find(R.getEnd());
+  if (Begin != ExpandedTokIndex.end() && End != ExpandedTokIndex.end()) {
+// Add 1 to End to make a half-open range.
+return {ExpandedTokens.data() + Begin->getSecond(),
+ExpandedTokens.data() + End->getSecond() + 1};
+  }
+  // Slow case. Use `isBeforeInTranslationUnit` to binary search for the
+  // required range.
   return getTokensCovering(expandedTokens(), R, *SourceMgr);
 }
 
@@ -638,6 +650,11 @@
 assert(!Result.ExpandedTokens.empty());
 assert(Result.ExpandedTokens.back().kind() == tok::eof);
 
+// Index ExpandedTokens for faster lookups by SourceLocation.
+unsigned ExpandedIndex = 0;
+for (const Token &Tok : Result.ExpandedTokens)
+  Result.ExpandedTokIndex[Tok.location()] = ExpandedIndex++;
+
 // Tokenize every file that contributed tokens to the expanded stream.
 buildSpelledTokens();
 
Index: clang/include/clang/Tooling/Syntax/Tokens.h
===
--- clang/include/clang/Tooling/Syntax/Tokens.h
+++ clang/include/clang/Tooling/Syntax/Tokens.h
@@ -34,6 +34,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
@@ -366,6 +367,9 @@
   /// same stream as 'clang -E' (excluding the preprocessor directives like
   /// #file, etc.).
   std::vector ExpandedTokens;
+  // Index of ExpandedTokens for faster lookups by SourceLocation. This is
+  // useful while finding expanded tokens in a 'token range'.
+  llvm::DenseMap ExpandedTokIndex;
   llvm::DenseMap Files;
   // The value is never null, pointer instead of reference to avoid disabling
   // implicit assignment operator.


Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -184,6 +184,18 @@
 }
 
 llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const {
+  // Quick lookup if `R` is a token range.
+  // This is a huge win since majority of the users use ranges provided by an
+  // AST. Ranges in AST are token ranges from expanded token stream.
+  const auto Begin = ExpandedTokIndex.find(R.getBegin());
+  const auto End = ExpandedTokIndex.find(R.getEnd());
+  if (Begin != ExpandedTokIndex.end() && End != ExpandedTokIndex.end()) {
+// Add 1 to End to make a half-open range.
+return {ExpandedTokens.data() + Begin->getSecond(),
+ExpandedTokens.data() + End->getSecond() + 1};
+  }
+  // Slow case. Use `isBeforeInTranslationUnit` to binary search for the
+  // required range.
   return getTokensCovering(expandedTokens(), R, *SourceMgr);
 }
 
@@ -638,6 +650,11 @@
 assert(!Result.ExpandedTokens.empty());
 assert(Result.ExpandedTokens.back().kind() == tok::eof);
 
+// Index ExpandedTokens for faster lookups by SourceLocation.
+unsigned ExpandedIndex = 0;
+for (const Token &Tok :

[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

For reference, here is what GCC defines on Linux with regards to SPARC:

  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m32 - |grep arch
  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m32 - |grep LP
  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m32 - |grep v9
  #define __sparc_v9__ 1
  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m64 - |grep arch
  #define __arch64__ 1
  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m64 - |grep LP
  #define __LP64__ 1
  #define _LP64 1
  glaubitz@gcc202:~$ echo | gcc -E -dM -mcpu=v9 -m64 - |grep v9
  #define __sparc_v9__ 1
  glaubitz@gcc202:~$

And here is what it defines on OpenBSD:

  openbsd# echo | gcc -E -dM -mcpu=v9 -m64 - |grep arch 
  #define __arch64__ 1
  openbsd# echo | gcc -E -dM -mcpu=v9 -m64 - |grep LP   
  #define __LP64__ 1
  #define _LP64 1
  openbsd# echo | gcc -E -dM -mcpu=v9 -m64 - |grep sparc
  #define sparc 1
  #define __sparc__ 1
  #define __sparc 1
  #define __sparc64__ 1
  #define __sparcv9__ 1
  #define __sparc_v9__ 1
  openbsd#



  -m32``` is not supported on OpenBSD at all:

openbsd# echo | gcc -E -dM -m32 -
:0: error: -m32 is not supported by this configuration
openbsd#

  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

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



Comment at: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c:5
+
+#include 
+

I don't think this include is needed. You're calling the __builtin names 
directly.



Comment at: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c:5
+
+#include 
+

Same here



Comment at: clang/test/Headers/rvintrin.c:7
+
+#include 

This should be in the D99008 patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D98959: [OpenCL] Add as_size/ptrdiff/intptr/uintptr_t operators

2021-03-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTH! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98959

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


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

In D98574#2641697 , @glaubitz wrote:

> `-m32` is not supported on OpenBSD at all:
>
>   openbsd# echo | gcc -E -dM -m32 -
>   :0: error: -m32 is not supported by this configuration
>   openbsd#

Yes. OpenBSD has no 32-bit support for sparc64 (nor does FreeBSD).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


[PATCH] D99008: [RISCV] [2/2] Add intrinsic for Zbr extension

2021-03-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Please note I asked that this patch be separate from D99009 
 because the rvintrin.h file name may not be 
the final filename we want to use. This 
https://github.com/riscv/riscv-c-api-doc/pull/14 suggests it should be 
riscv_intrinsic.h. So I wanted to separate any discussion about how it should 
be exposed to the user from the implementation of the IR intrinsics and clang 
builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99008

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


Re: [clang] c2f9086 - [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot

2021-03-22 Thread Arthur Eubanks via cfe-commits
Same error on the Android Chrome bots, although I didn't check if this
commit was the issue.
https://ci.chromium.org/ui/p/chromium/builders/ci/ToTAndroid/16087/overview

On Mon, Mar 22, 2021 at 9:11 AM Matt Morehouse via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Fangrui,
>
> This change seems to have broken the link on Android:
> https://lab.llvm.org/buildbot/#/builders/77/builds/4777
> Could you please take a look?
>
> ld.lld: error: 
> /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../lib64/libc++.so
>  is incompatible with aarch64linux
>
>
>
> On Sat, Mar 20, 2021 at 9:38 PM Fangrui Song via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Fangrui Song
>> Date: 2021-03-20T21:37:49-07:00
>> New Revision: c2f9086b6184a132ec8cac7edeb620813796e1e8
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8.diff
>>
>> LOG: [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/Driver/ToolChains/Gnu.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
>> b/clang/lib/Driver/ToolChains/Gnu.cpp
>> index 39be77463544..078579669634 100644
>> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
>> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
>> @@ -2853,8 +2853,6 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
>>Paths);
>>  }
>>
>> -// See comments above on the multilib variant for details of why
>> this is
>> -// included even from outside the sysroot.
>>  const std::string &LibPath =
>>  std::string(GCCInstallation.getParentLibPath());
>>  const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
>> @@ -2862,11 +2860,7 @@ void Generic_GCC::AddMultiarchPaths(const Driver
>> &D,
>>  addPathIfExists(
>>  D, LibPath + "/../" + GCCTriple.str() + "/lib" +
>> Multilib.osSuffix(),
>>  Paths);
>> -
>> -// See comments above on the multilib variant for details of why
>> this is
>> -// only included from within the sysroot.
>> -if (StringRef(LibPath).startswith(SysRoot))
>> -  addPathIfExists(D, LibPath, Paths);
>> +addPathIfExists(D, LibPath, Paths);
>>}
>>  }
>>
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz updated this revision to Diff 332339.
glaubitz edited the summary of this revision.
Herald added a subscriber: krytarowski.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

Files:
  clang/lib/Basic/Targets/Sparc.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
   Builder.defineMacro("__sparcv8__");
   break;
 case CG_V9:
-  Builder.defineMacro("__sparcv9");
-  Builder.defineMacro("__sparcv9__");
   Builder.defineMacro("__sparc_v9__");
   break;
 }
@@ -239,13 +237,24 @@
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
-  // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
+  switch (getTriple().getOS()) {
+  case llvm::Triple::Linux:
+Builder.defineMacro("__sparc_v9__");
+break;
+  case llvm::Triple::NetBSD:
+Builder.defineMacro("__sparcv9");
 Builder.defineMacro("__sparc64__");
 Builder.defineMacro("__sparc_v9__");
+break;
+  case llvm::Triple::OpenBSD:
+Builder.defineMacro("__sparc64__");
 Builder.defineMacro("__sparcv9__");
+Builder.defineMacro("__sparc_v9__");
+break;
+  case llvm::Triple::Solaris:
+Builder.defineMacro("__sparcv9");
+break;
   }
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3558,11 +3553,9 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sp

[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-22 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

I have updated the patch now with the result that clang should behave as GCC 
now on Linux, NetBSD and OpenBSD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


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

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

- Use a generic message.
- Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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

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

[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-22 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 332341.
khchen added a comment.

update tests, remove target-feature zfh.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

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

Windows exceptions code-generation is quite different; I don't know whether 
Clang supports ObjC on Windows in general.  It'd be fine if you add a `-triple` 
argument to this test.


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

https://reviews.llvm.org/D97371

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

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

In D97371#2641800 , @rjmccall wrote:

> Windows exceptions code-generation is quite different; I don't know whether 
> Clang supports ObjC on Windows in general.  It'd be fine if you add a 
> `-triple` argument to this test.

I'd have no issue with that either.


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

https://reviews.llvm.org/D97371

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


[clang] e421a74 - [ASTImporter] Fix import of ObjCPropertyDecl that share the same name

2021-03-22 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2021-03-22T18:05:50+01:00
New Revision: e421a74108ee86afec133c77258470d3ed7dcc90

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

LOG: [ASTImporter] Fix import of ObjCPropertyDecl that share the same name

Objective-C apparently allows name conflicts between instance and class
properties, so this is valid code:

```
@protocol DupProp
@property (class, readonly) int prop;
@property (readonly) int prop;
@end
```

The ASTImporter however isn't aware of this and will consider the two properties
as if they are the same property because it just compares their name and types.
This causes that when importing both properties we only end up with one property
(whatever is imported first from what I can see).

Beside generating a different AST this also leads to a bunch of asserts and
crashes as we still correctly import the two different getters for both
properties (the import code for methods does the correct check where it
differentiated between instance and class methods). As one of the setters will
not have its associated ObjCPropertyDecl imported, any call to
`ObjCMethodDecl::findPropertyDecl` will just lead to an assert or crash.

Fixes rdar://74322659

Reviewed By: shafik, kastiglione

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 182a57c16abaf..f9b1910552ee0 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -5066,6 +5066,11 @@ ExpectedDecl 
ASTNodeImporter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
   auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
   for (auto *FoundDecl : FoundDecls) {
 if (auto *FoundProp = dyn_cast(FoundDecl)) {
+  // Instance and class properties can share the same name but are 
diff erent
+  // declarations.
+  if (FoundProp->isInstanceProperty() != D->isInstanceProperty())
+continue;
+
   // Check property types.
   if (!Importer.IsStructurallyEquivalent(D->getType(),
  FoundProp->getType())) {

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 8c4b982ec6d50..9458fc2265800 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5639,6 +5639,35 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImplicitlyDeclareSelf) {
   EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ObjPropertyNameConflict) {
+  // Tests that properties that share the same name are correctly imported.
+  // This is only possible with one instance and one class property.
+  Decl *FromTU = getTuDecl(R"(
+   @interface DupProp{}
+   @property (class) int prop;
+   @property int prop;
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, namedDecl(hasName("DupProp")));
+  auto ToClass = Import(FromClass, Lang_OBJCXX);
+  ASSERT_TRUE(ToClass);
+  // We should have one class and one instance property.
+  ASSERT_EQ(
+  1, std::distance(ToClass->classprop_begin(), ToClass->classprop_end()));
+  ASSERT_EQ(1,
+std::distance(ToClass->instprop_begin(), ToClass->instprop_end()));
+  for (clang::ObjCPropertyDecl *prop : ToClass->properties()) {
+// All properties should have a getter and a setter.
+ASSERT_TRUE(prop->getGetterMethodDecl());
+ASSERT_TRUE(prop->getSetterMethodDecl());
+// The getters/setters should be able to find the right associated 
property.
+ASSERT_EQ(prop->getGetterMethodDecl()->findPropertyDecl(), prop);
+ASSERT_EQ(prop->getSetterMethodDecl()->findPropertyDecl(), prop);
+  }
+}
+
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {



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


[PATCH] D99077: [ASTImporter] Fix import of ObjCPropertyDecl that share the same name

2021-03-22 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe421a74108ee: [ASTImporter] Fix import of ObjCPropertyDecl 
that share the same name (authored by teemperor).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99077

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5639,6 +5639,35 @@
   EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ObjPropertyNameConflict) {
+  // Tests that properties that share the same name are correctly imported.
+  // This is only possible with one instance and one class property.
+  Decl *FromTU = getTuDecl(R"(
+   @interface DupProp{}
+   @property (class) int prop;
+   @property int prop;
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, namedDecl(hasName("DupProp")));
+  auto ToClass = Import(FromClass, Lang_OBJCXX);
+  ASSERT_TRUE(ToClass);
+  // We should have one class and one instance property.
+  ASSERT_EQ(
+  1, std::distance(ToClass->classprop_begin(), ToClass->classprop_end()));
+  ASSERT_EQ(1,
+std::distance(ToClass->instprop_begin(), ToClass->instprop_end()));
+  for (clang::ObjCPropertyDecl *prop : ToClass->properties()) {
+// All properties should have a getter and a setter.
+ASSERT_TRUE(prop->getGetterMethodDecl());
+ASSERT_TRUE(prop->getSetterMethodDecl());
+// The getters/setters should be able to find the right associated 
property.
+ASSERT_EQ(prop->getGetterMethodDecl()->findPropertyDecl(), prop);
+ASSERT_EQ(prop->getSetterMethodDecl()->findPropertyDecl(), prop);
+  }
+}
+
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5066,6 +5066,11 @@
   auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
   for (auto *FoundDecl : FoundDecls) {
 if (auto *FoundProp = dyn_cast(FoundDecl)) {
+  // Instance and class properties can share the same name but are 
different
+  // declarations.
+  if (FoundProp->isInstanceProperty() != D->isInstanceProperty())
+continue;
+
   // Check property types.
   if (!Importer.IsStructurallyEquivalent(D->getType(),
  FoundProp->getType())) {


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5639,6 +5639,35 @@
   EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ObjPropertyNameConflict) {
+  // Tests that properties that share the same name are correctly imported.
+  // This is only possible with one instance and one class property.
+  Decl *FromTU = getTuDecl(R"(
+   @interface DupProp{}
+   @property (class) int prop;
+   @property int prop;
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, namedDecl(hasName("DupProp")));
+  auto ToClass = Import(FromClass, Lang_OBJCXX);
+  ASSERT_TRUE(ToClass);
+  // We should have one class and one instance property.
+  ASSERT_EQ(
+  1, std::distance(ToClass->classprop_begin(), ToClass->classprop_end()));
+  ASSERT_EQ(1,
+std::distance(ToClass->instprop_begin(), ToClass->instprop_end()));
+  for (clang::ObjCPropertyDecl *prop : ToClass->properties()) {
+// All properties should have a getter and a setter.
+ASSERT_TRUE(prop->getGetterMethodDecl());
+ASSERT_TRUE(prop->getSetterMethodDecl());
+// The getters/setters should be able to find the right associated property.
+ASSERT_EQ(prop->getGetterMethodDecl()->findPropertyDecl(), prop);
+ASSERT_EQ(prop->getSetterMethodDecl()->findPropertyDecl(), prop);
+  }
+}
+
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AS

[clang-tools-extra] 5a87f81 - new altera unroll loops check

2021-03-22 Thread Aaron Ballman via cfe-commits

Author: Frank Derry Wanye
Date: 2021-03-22T13:09:53-04:00
New Revision: 5a87f81fe9aee996dfe3a84dd833f0a48e093e7f

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

LOG: new altera unroll loops check

This lint check is a part of the FLOCL (FPGA Linters for OpenCL)
project out of the Synergy Lab at Virginia Tech.

FLOCL is a set of lint checks aimed at FPGA developers who write code
in OpenCL.

The altera unroll loops check finds inner loops that have not been
unrolled, as well as fully-unrolled loops that should be partially
unrolled due to unknown loop bounds or a large number of loop
iterations.

Based on the Altera SDK for OpenCL: Best Practices Guide.

Added: 
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Modified: 
clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
clang-tools-extra/clang-tidy/altera/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp 
b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
index a328f05da5d0..a6c29e03f7aa 100644
--- a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
@@ -12,6 +12,7 @@
 #include "KernelNameRestrictionCheck.h"
 #include "SingleWorkItemBarrierCheck.h"
 #include "StructPackAlignCheck.h"
+#include "UnrollLoopsCheck.h"
 
 using namespace clang::ast_matchers;
 
@@ -28,6 +29,7 @@ class AlteraModule : public ClangTidyModule {
 "altera-single-work-item-barrier");
 CheckFactories.registerCheck(
 "altera-struct-pack-align");
+CheckFactories.registerCheck("altera-unroll-loops");
   }
 };
 

diff  --git a/clang-tools-extra/clang-tidy/altera/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/altera/CMakeLists.txt
index 0765b9735cf9..c8a883d0750c 100644
--- a/clang-tools-extra/clang-tidy/altera/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/altera/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_library(clangTidyAlteraModule
   KernelNameRestrictionCheck.cpp
   SingleWorkItemBarrierCheck.cpp
   StructPackAlignCheck.cpp
+  UnrollLoopsCheck.cpp
 
   LINK_LIBS
   clangTidy

diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
new file mode 100644
index ..40ba3913467f
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -0,0 +1,277 @@
+//===--- UnrollLoopsCheck.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 "UnrollLoopsCheck.h"
+#include "clang/AST/APValue.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/OperationKinds.h"
+#include "clang/AST/ParentMapContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace altera {
+
+UnrollLoopsCheck::UnrollLoopsCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  MaxLoopIterations(Options.get("MaxLoopIterations", 100U)) {}
+
+void UnrollLoopsCheck::registerMatchers(MatchFinder *Finder) {
+  const auto HasLoopBound = hasDescendant(
+  varDecl(allOf(matchesName("__end*"),
+hasDescendant(integerLiteral().bind("cxx_loop_bound");
+  const auto CXXForRangeLoop =
+  cxxForRangeStmt(anyOf(HasLoopBound, unless(HasLoopBound)));
+  const auto AnyLoop = anyOf(forStmt(), whileStmt(), doStmt(), 
CXXForRangeLoop);
+  Finder->addMatcher(
+  stmt(allOf(AnyLoop, unless(hasDescendant(stmt(AnyLoop).bind("loop"),
+  this);
+}
+
+void UnrollLoopsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *Loop = Result.Nodes.getNodeAs("loop");
+  const auto *CXXLoopBound =
+  Result.Nodes.getNodeAs("cxx_loop_bound");
+  const ASTContext *Context = Result.Context;
+  switch (unrollType(Loop, Result.Context)) {
+  case NotUnrolled:
+diag(Loop->getBeginLoc(),
+ "kernel performance could be improved by unrolling this loop with a "
+ "'#pragma unroll' directive");
+break;
+  case PartiallyUnrolled:
+// Loop already partially unrolled, do nothing.
+break;
+  case FullyUnrolled:
+if (

[PATCH] D72235: [clang-tidy] new altera unroll loops check

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

Thanks! I've commit on your behalf in 5a87f81fe9aee996dfe3a84dd833f0a48e093e7f 



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

https://reviews.llvm.org/D72235

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


[clang] 5184f69 - Revert "[Driver] Gnu.cpp: drop an unneeded special rule related to sysroot"

2021-03-22 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-03-22T10:16:19-07:00
New Revision: 5184f69041166257e4c6a15e572d12c676cd0c31

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

LOG: Revert "[Driver] Gnu.cpp: drop an unneeded special rule related to sysroot"

This reverts commits 56700e937903969a4a95f68c59e38e35d1ea and 
c2f9086b6184a132ec8cac7edeb620813796e1e8.

Breaks multiple Android bots, e.g. 
https://lab.llvm.org/buildbot/#/builders/77/builds/4777.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index a046e8e7eed8..193c944e7392 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2832,7 +2832,17 @@ void Generic_GCC::AddMultilibPaths(const Driver &D,
 SelectedMultilib.osSuffix(),
 Paths);
 
-addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
+// If the GCC installation we found is inside of the sysroot, we want to
+// prefer libraries installed in the parent prefix of the GCC installation.
+// It is important to *not* use these paths when the GCC installation is
+// outside of the system root as that can pick up unintended libraries.
+// This usually happens when there is an external cross compiler on the
+// host system, and a more minimal sysroot available that is the target of
+// the cross. Note that GCC does include some of these directories in some
+// configurations but this seems somewhere between questionable and simply
+// a bug.
+if (StringRef(LibPath).startswith(SysRoot))
+  addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
   }
 }
 
@@ -2851,6 +2861,8 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
   Paths);
 }
 
+// See comments above on the multilib variant for details of why this is
+// included even from outside the sysroot.
 const std::string &LibPath =
 std::string(GCCInstallation.getParentLibPath());
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
@@ -2858,7 +2870,11 @@ void Generic_GCC::AddMultiarchPaths(const Driver &D,
 addPathIfExists(
 D, LibPath + "/../" + GCCTriple.str() + "/lib" + Multilib.osSuffix(),
 Paths);
-addPathIfExists(D, LibPath, Paths);
+
+// See comments above on the multilib variant for details of why this is
+// only included from within the sysroot.
+if (StringRef(LibPath).startswith(SysRoot))
+  addPathIfExists(D, LibPath, Paths);
   }
 }
 



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


Re: [clang] c2f9086 - [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot

2021-03-22 Thread Arthur Eubanks via cfe-commits
I reverted this and the related change in 625fd7e54205077. The regression
range did point to this and the related change.

On Mon, Mar 22, 2021 at 9:42 AM Arthur Eubanks  wrote:

> Same error on the Android Chrome bots, although I didn't check if this
> commit was the issue.
> https://ci.chromium.org/ui/p/chromium/builders/ci/ToTAndroid/16087/overview
>
> On Mon, Mar 22, 2021 at 9:11 AM Matt Morehouse via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi Fangrui,
>>
>> This change seems to have broken the link on Android:
>> https://lab.llvm.org/buildbot/#/builders/77/builds/4777
>> Could you please take a look?
>>
>> ld.lld: error: 
>> /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../lib64/libc++.so
>>  is incompatible with aarch64linux
>>
>>
>>
>> On Sat, Mar 20, 2021 at 9:38 PM Fangrui Song via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Fangrui Song
>>> Date: 2021-03-20T21:37:49-07:00
>>> New Revision: c2f9086b6184a132ec8cac7edeb620813796e1e8
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/c2f9086b6184a132ec8cac7edeb620813796e1e8.diff
>>>
>>> LOG: [Driver] Gnu.cpp: drop an unneeded special rule related to sysroot
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/Driver/ToolChains/Gnu.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp
>>> b/clang/lib/Driver/ToolChains/Gnu.cpp
>>> index 39be77463544..078579669634 100644
>>> --- a/clang/lib/Driver/ToolChains/Gnu.cpp
>>> +++ b/clang/lib/Driver/ToolChains/Gnu.cpp
>>> @@ -2853,8 +2853,6 @@ void Generic_GCC::AddMultiarchPaths(const Driver
>>> &D,
>>>Paths);
>>>  }
>>>
>>> -// See comments above on the multilib variant for details of why
>>> this is
>>> -// included even from outside the sysroot.
>>>  const std::string &LibPath =
>>>  std::string(GCCInstallation.getParentLibPath());
>>>  const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
>>> @@ -2862,11 +2860,7 @@ void Generic_GCC::AddMultiarchPaths(const Driver
>>> &D,
>>>  addPathIfExists(
>>>  D, LibPath + "/../" + GCCTriple.str() + "/lib" +
>>> Multilib.osSuffix(),
>>>  Paths);
>>> -
>>> -// See comments above on the multilib variant for details of why
>>> this is
>>> -// only included from within the sysroot.
>>> -if (StringRef(LibPath).startswith(SysRoot))
>>> -  addPathIfExists(D, LibPath, Paths);
>>> +addPathIfExists(D, LibPath, Paths);
>>>}
>>>  }
>>>
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-03-22 Thread Stephen Tozer via Phabricator via cfe-commits
StephenTozer added a comment.

Apart from the one comment, LGTM.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1644-1650
+  Opts.EnableDIPreservationVerify = 
Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }

Any particular behaviour if the user specifies a file for 
`-fverify-debuginfo-preserve-export` but doesn't set 
`-fverify-debuginfo-preserve`? It seems like it would be worth emitting a 
warning in this case, though I'm not sure if that's an established precedent.


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

https://reviews.llvm.org/D82547

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


[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-22 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99062

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


[PATCH] D98951: [clang][ASTImporter] Add import API for 'const Type *' (NFC).

2021-03-22 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank you for adding the test!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98951

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-22 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies added a comment.

Thank you very much!


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

https://reviews.llvm.org/D72235

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


[PATCH] D98902: [Clang][OpenMP][NVPTX] Fixed failure in openmp-offload-gpu.c if the system has CUDA

2021-03-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D98902#2640477 , @tianshilei1992 
wrote:

> In D98902#2636308 , @jdoerfert wrote:
>
>> @tra, so you think we should not do this? The user will see a link error 
>> late I assume, might be better.
>
> I think @tra 's point is we should not do that for CUDA code. This change 
> only affects OpenMP.

Correct. We do want to ling with libdevice during CUDA compilation, even with 
-S. I don't have a strong opinion on what OpenMP does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98902

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


  1   2   >