[PATCH] D115573: [Clang][OpenMP] Return error ahead of time if there are multiple mutex clauses in atomic directive

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Currently if there are multiple mutex clauses used in `atomic` directive,
it emits an error but proceeds execution. This patch simply makes it return 
ahead
of time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115573

Files:
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10942,6 +10942,7 @@
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
 Diag(AtomicKindLoc, diag::note_omp_previous_mem_order_clause)
 << getOpenMPClauseName(AtomicKind);
+return StmtError();
   } else {
 AtomicKind = C->getClauseKind();
 AtomicKindLoc = C->getBeginLoc();


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10942,6 +10942,7 @@
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
 Diag(AtomicKindLoc, diag::note_omp_previous_mem_order_clause)
 << getOpenMPClauseName(AtomicKind);
+return StmtError();
   } else {
 AtomicKind = C->getClauseKind();
 AtomicKindLoc = C->getBeginLoc();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 393656.
tianshilei1992 added a comment.

rebase and remove unnecessary changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2273,6 +2273,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6248,6 +6248,8 @@
 
 void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11761,6 +11761,9 @@
   case llvm::omp::OMPC_capture:
 C = new (Context) OMPCaptureClause();
 break;
+  case llvm::omp::OMPC_compare:
+C = new (Context) OMPCompareClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12119,6 +12122,8 @@
 
 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9429,6 +9429,13 @@
   return C;
 }
 
+template 
+OMPClause *
+TreeTransform::TransformOMPCompareClause(OMPCompareClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6353,6 +6353,7 @@
   case OMPC_write:
   case OMPC_update:
   case OMPC_capture:
+  case OMPC_compare:
   case OMPC_seq_cst:
   case OMPC_acq_rel:
   case OMPC_acquire:
@@ -10936,7 +10937,8 @@
   for (const OMPClause *C : Clauses) {
 if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
 C->getClauseKind() == OMPC_update ||
-C->getClauseKind() == OMPC_capture) {
+C->getClauseKind() == OMPC_capture ||
+C->getClauseKind() == OMPC_compare) {
   if (AtomicKind != OMPC_unknown) {
 Diag(C->getBeginLoc(), diag::err_omp_atomic_several_clauses)
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
@@ -11372,15 +11374,19 @@
 SourceRange(Body->getBeginLoc(), 

[PATCH] D115441: [X86][MS] Add 80bit long double support for Windows

2021-12-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: mstorsjo.
rnk added a comment.

I seem to recall assuming that Windows `long double` was 64-bits in many, many 
places. Unfortunately, I have no idea where that could've happened. Something 
that comes to mind immediately is the MSVC name mangler. I don't think that's a 
blocking issue, but it's something you should be aware of if you want to 
promote this flag's usage.

@mstorsjo, can you advise what GCC does here? I've forgotten how this is 
supposed to work.




Comment at: clang/lib/Basic/Targets/X86.h:537
 resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
 "64-i64:64-f80:32-n8:16:32-a:0:32-S32"
   : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"

If GCC aligns f80 to 16 bytes, we might as well make the change here and share 
it with the mingw target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115441

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-12-10 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added inline comments.



Comment at: llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp:132
+  // Place new instruction sequence after GEP.
+  Builder.SetInsertPoint(GEP);
+  Value *Index = GEP->getOperand(2);

jrtc27 wrote:
> This line causes the bug seen in bind. In that case, the GEP has been 
> hoisted, but the load has not. In general the GEP could be in a different 
> basic block, or even in the same basic block with an instruction that may not 
> return (intrinsic, real function call, well-defined language-level exception, 
> etc). You can insert the reltable.shift where the GEP is, and that probably 
> makes sense given it serves (part of) the same purpose, but you *must* insert 
> the actual reltable.intrinsic where the original load is, unless you've gone 
> to great lengths to prove it's safe not to (which seems best left to the 
> usual culprits like LICM).
> 
> IR test cases: https://godbolt.org/z/YMdaMrobE (bind is characterised by the 
> first of the two functions)
@dim and @jrtc27 thank you for reporting it.
I see what's going wrong, and I uploaded a patch that fixes the issue by 
ensuring that the call to load.relative.intrinsic is inserted before the load, 
but not gep.
Please see https://reviews.llvm.org/D115571. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[clang] cdd5fb6 - [NFC][Clang] clang-format -i clang/lib/Sema/SemaOpenMP.cpp

2021-12-10 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-12-10T22:05:25-05:00
New Revision: cdd5fb6e19c81c1a9c1eac22e7ac48d5b33abc3d

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

LOG: [NFC][Clang] clang-format -i clang/lib/Sema/SemaOpenMP.cpp

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 581b7c8841d33..9672b0ac60a84 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -255,14 +255,14 @@ class DSAStackTy {
 return ().first[Size - 1];
   }
   const SharingMapTy *getTopOfStackOrNull() const {
-return const_cast(*this).getTopOfStackOrNull();
+return const_cast(*this).getTopOfStackOrNull();
   }
   SharingMapTy () {
 assert(!isStackEmpty() && "no current directive");
 return *getTopOfStackOrNull();
   }
   const SharingMapTy () const {
-return const_cast(*this).getTopOfStack();
+return const_cast(*this).getTopOfStack();
   }
 
   SharingMapTy *getSecondOnStackOrNull() {
@@ -272,7 +272,7 @@ class DSAStackTy {
 return ().first[Size - 2];
   }
   const SharingMapTy *getSecondOnStackOrNull() const {
-return const_cast(*this).getSecondOnStackOrNull();
+return const_cast(*this).getSecondOnStackOrNull();
   }
 
   /// Get the stack element at a certain level (previously returned by
@@ -286,7 +286,7 @@ class DSAStackTy {
 return Stack.back().first[Level];
   }
   const SharingMapTy (unsigned Level) const {
-return const_cast(*this).getStackElemAtLevel(Level);
+return const_cast(*this).getStackElemAtLevel(Level);
   }
 
   DSAVarData getDSA(const_iterator , ValueDecl *D) const;
@@ -354,9 +354,7 @@ class DSAStackTy {
 const SharingMapTy *Top = getTopOfStackOrNull();
 return Top && Top->BodyComplete;
   }
-  void setBodyComplete() {
-getTopOfStack().BodyComplete = true;
-  }
+  void setBodyComplete() { getTopOfStack().BodyComplete = true; }
 
   bool isForceVarCapturing() const { return ForceCapturing; }
   void setForceVarCapturing(bool V) { ForceCapturing = V; }
@@ -392,6 +390,7 @@ class DSAStackTy {
   class ParentDirectiveScope {
 DSAStackTy 
 bool Active;
+
   public:
 ParentDirectiveScope(DSAStackTy , bool Activate)
 : Self(Self), Active(false) {
@@ -433,8 +432,7 @@ class DSAStackTy {
   }
   /// Marks (or clears) declaration as possibly loop counter.
   void resetPossibleLoopCounter(const Decl *D = nullptr) {
-getTopOfStack().PossiblyLoopCounter =
-D ? D->getCanonicalDecl() : D;
+getTopOfStack().PossiblyLoopCounter = D ? D->getCanonicalDecl() : D;
   }
   /// Gets the possible loop counter decl.
   const Decl *getPossiblyLoopCunter() const {
@@ -631,13 +629,10 @@ class DSAStackTy {
   }
 
   /// Add requires decl to internal vector
-  void addRequiresDecl(OMPRequiresDecl *RD) {
-RequiresDecls.push_back(RD);
-  }
+  void addRequiresDecl(OMPRequiresDecl *RD) { RequiresDecls.push_back(RD); }
 
   /// Checks if the defined 'requires' directive has specified type of clause.
-  template 
-  bool hasRequiresDeclWithClause() const {
+  template  bool hasRequiresDeclWithClause() const {
 return llvm::any_of(RequiresDecls, [](const OMPRequiresDecl *D) {
   return llvm::any_of(D->clauselists(), [](const OMPClause *C) {
 return isa(C);
@@ -680,9 +675,7 @@ class DSAStackTy {
 
   /// Returns the location of the first encountered atomic directive in the
   /// module.
-  SourceLocation getAtomicDirectiveLoc() const {
-return AtomicLocation;
-  }
+  SourceLocation getAtomicDirectiveLoc() const { return AtomicLocation; }
 
   // Return previously encountered target region locations.
   ArrayRef getEncounteredTargetLocs() const {
@@ -706,8 +699,7 @@ class DSAStackTy {
   }
   /// Set default data mapping attribute to Modifier:Kind
   void setDefaultDMAAttr(OpenMPDefaultmapClauseModifier M,
- OpenMPDefaultmapClauseKind Kind,
- SourceLocation Loc) {
+ OpenMPDefaultmapClauseKind Kind, SourceLocation Loc) {
 DefaultmapInfo  = getTopOfStack().DefaultmapMap[Kind];
 DMI.ImplicitBehavior = M;
 DMI.SLoc = Loc;
@@ -749,12 +741,10 @@ class DSAStackTy {
: getStackElemAtLevel(Level).DefaultAttr;
   }
   DefaultDataSharingAttributes getDefaultDSA() const {
-return isStackEmpty() ? DSA_unspecified
-  : getTopOfStack().DefaultAttr;
+return isStackEmpty() ? DSA_unspecified : getTopOfStack().DefaultAttr;
   }
   SourceLocation getDefaultDSALocation() const {
-return isStackEmpty() ? SourceLocation()
-  : getTopOfStack().DefaultAttrLoc;
+return isStackEmpty() ? SourceLocation() : getTopOfStack().DefaultAttrLoc;

[PATCH] D115567: [Sema] Add FixIt when a C++ out-of-line method has extra/missing const

2021-12-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115567

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/FixIt/member-mismatch.cpp


Index: clang/test/FixIt/member-mismatch.cpp
===
--- /dev/null
+++ clang/test/FixIt/member-mismatch.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+class Foo {
+  int get() const; // expected-note {{because it is const qualified}}
+  void set(int); // expected-note {{because it is not const qualified}}
+};
+
+// CHECK: fix-it:"{{.*}}":{10:15-10:15}:" const"
+int Foo::get() {} // expected-error {{does not match any declaration}}
+// CHECK: fix-it:"{{.*}}":{12:20-12:26}:""
+void Foo::set(int) const {} // expected-error {{does not match any 
declaration}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8504,7 +8504,14 @@
 << NewFD->getParamDecl(Idx - 1)->getType();
 } else if (FDisConst != NewFDisConst) {
   SemaRef.Diag(FD->getLocation(), diag::note_member_def_close_const_match)
-  << NewFDisConst << FD->getSourceRange().getEnd();
+  << NewFDisConst << FD->getSourceRange().getEnd()
+  << (NewFDisConst
+  ? FixItHint::CreateRemoval(ExtraArgs.D.getFunctionTypeInfo()
+ .getConstQualifierLoc())
+  : 
FixItHint::CreateInsertion(ExtraArgs.D.getFunctionTypeInfo()
+   .getRParenLoc()
+   .getLocWithOffset(1),
+   " const"));
 } else
   SemaRef.Diag(FD->getLocation(),
IsMember ? diag::note_member_def_close_match


Index: clang/test/FixIt/member-mismatch.cpp
===
--- /dev/null
+++ clang/test/FixIt/member-mismatch.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+class Foo {
+  int get() const; // expected-note {{because it is const qualified}}
+  void set(int); // expected-note {{because it is not const qualified}}
+};
+
+// CHECK: fix-it:"{{.*}}":{10:15-10:15}:" const"
+int Foo::get() {} // expected-error {{does not match any declaration}}
+// CHECK: fix-it:"{{.*}}":{12:20-12:26}:""
+void Foo::set(int) const {} // expected-error {{does not match any declaration}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8504,7 +8504,14 @@
 << NewFD->getParamDecl(Idx - 1)->getType();
 } else if (FDisConst != NewFDisConst) {
   SemaRef.Diag(FD->getLocation(), diag::note_member_def_close_const_match)
-  << NewFDisConst << FD->getSourceRange().getEnd();
+  << NewFDisConst << FD->getSourceRange().getEnd()
+  << (NewFDisConst
+  ? FixItHint::CreateRemoval(ExtraArgs.D.getFunctionTypeInfo()
+ .getConstQualifierLoc())
+  : FixItHint::CreateInsertion(ExtraArgs.D.getFunctionTypeInfo()
+   .getRParenLoc()
+   .getLocWithOffset(1),
+   " const"));
 } else
   SemaRef.Diag(FD->getLocation(),
IsMember ? diag::note_member_def_close_match
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115320: Avoid setting tbaa information on store of return type of call to inline assember

2021-12-10 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 393642.
schittir marked an inline comment as done.
schittir added a comment.

1. Removed returnNullTBAA() method
2. Add NO-TBAA check-prefix to the test


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

https://reviews.llvm.org/D115320

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/avoidTBAAonASMstore.cpp


Index: clang/test/CodeGen/avoidTBAAonASMstore.cpp
===
--- /dev/null
+++ clang/test/CodeGen/avoidTBAAonASMstore.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -disable-llvm-passes 
-fasm-blocks %s -emit-llvm -o - | FileCheck --check-prefix=NO-TBAA %s
+// NO-TBAA-NOT: !tbaa
+double foo(double z) {
+// CHECK-LABEL: define{{.*}} double @_Z3food
+   unsigned short ControlWord;
+   __asm { fnstcw word ptr[ControlWord] };
+// CHECK: call i64 asm sideeffect inteldialect
+// NO-TBAA: store i64 %{{.*}}, i64* %{{.*}}, align 4
+   return z;
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2504,6 +2504,13 @@
 BaseInfo, TBAAInfo);
   }
 
+  LValue
+  MakeAddrLValueWithoutTBAA(Address Addr, QualType T,
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
+TBAAAccessInfo());
+  }
+
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
 
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2454,7 +2454,7 @@
 const ABIArgInfo  = CurFnInfo->getReturnInfo();
 if (RetAI.isDirect() || RetAI.isExtend()) {
   // Make a fake lvalue for the return value slot.
-  LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy);
+  LValue ReturnSlot = MakeAddrLValueWithoutTBAA(ReturnValue, FnRetTy);
   CGM.getTargetCodeGenInfo().addReturnRegisterOutputs(
   *this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes,
   ResultRegDests, AsmString, S.getNumOutputs());


Index: clang/test/CodeGen/avoidTBAAonASMstore.cpp
===
--- /dev/null
+++ clang/test/CodeGen/avoidTBAAonASMstore.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -disable-llvm-passes -fasm-blocks %s -emit-llvm -o - | FileCheck --check-prefix=NO-TBAA %s
+// NO-TBAA-NOT: !tbaa
+double foo(double z) {
+// CHECK-LABEL: define{{.*}} double @_Z3food
+	unsigned short ControlWord;
+	__asm { fnstcw word ptr[ControlWord] };
+// CHECK: call i64 asm sideeffect inteldialect
+// NO-TBAA: store i64 %{{.*}}, i64* %{{.*}}, align 4
+	return z;
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2504,6 +2504,13 @@
 BaseInfo, TBAAInfo);
   }
 
+  LValue
+  MakeAddrLValueWithoutTBAA(Address Addr, QualType T,
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
+TBAAAccessInfo());
+  }
+
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
 
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2454,7 +2454,7 @@
 const ABIArgInfo  = CurFnInfo->getReturnInfo();
 if (RetAI.isDirect() || RetAI.isExtend()) {
   // Make a fake lvalue for the return value slot.
-  LValue ReturnSlot = MakeAddrLValue(ReturnValue, FnRetTy);
+  LValue ReturnSlot = MakeAddrLValueWithoutTBAA(ReturnValue, FnRetTy);
   CGM.getTargetCodeGenInfo().addReturnRegisterOutputs(
   *this, ReturnSlot, Constraints, ResultRegTypes, ResultTruncRegTypes,
   ResultRegDests, AsmString, S.getNumOutputs());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] ac431fc - [clangd] ... and mark a new test as -fno-ms-compatibility too

2021-12-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-12-11T02:41:39+01:00
New Revision: ac431fc2cdf1457a286d86be57c0771ce42c0965

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

LOG: [clangd] ... and mark a new test as -fno-ms-compatibility too

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 02d572ed926f..b3872ab0bc59 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -892,6 +892,7 @@ TEST(IncludeFixerTest, IncompleteEnum) {
   TestTU TU;
   TU.ExternalIndex = Index.get();
   TU.ExtraArgs.push_back("-std=c++20");
+  TU.ExtraArgs.push_back("-fno-ms-compatibility"); // else incomplete enum is 
OK
 
   std::vector> Tests{
   {"incomplete_enum", "enum class X : int; using enum [[X]];"},



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


[clang] 30fc88b - Revert "Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"""

2021-12-10 Thread Med Ismail Bennani via cfe-commits

Author: Med Ismail Bennani
Date: 2021-12-10T17:33:54-08:00
New Revision: 30fc88bf1dc15a72e2d9809d28019d386b7a7cc0

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

LOG: Revert "Revert "Revert "Use `GNUInstallDirs` to support custom 
installation dirs. -- LLVM"""

This reverts commit 492de35df443d5f31480173d5f1274c7835cd3d8.

I tried to apply John's changes in 8d897ec91528 that were expected to
fix his patch but that didn't work unfortunately.

Reverting this again to fix the macOS bots and leave him more time to
investigate the issue.

Added: 


Modified: 
clang/tools/scan-build/CMakeLists.txt
libclc/CMakeLists.txt
lldb/cmake/modules/FindLibEdit.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/AddSphinxTarget.cmake
llvm/cmake/modules/CMakeLists.txt
llvm/cmake/modules/LLVMInstallSymlink.cmake
llvm/docs/CMake.rst
llvm/examples/Bye/CMakeLists.txt
llvm/include/llvm/CMakeLists.txt
llvm/tools/llvm-config/BuildVariables.inc.in
llvm/tools/llvm-config/llvm-config.cpp
llvm/tools/lto/CMakeLists.txt
llvm/tools/opt-viewer/CMakeLists.txt
llvm/tools/remarks-shlib/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/scan-build/CMakeLists.txt 
b/clang/tools/scan-build/CMakeLists.txt
index 74334e53c9b18..ec0702d76f184 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
+add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
COMMAND ${CMAKE_COMMAND} -E make_directory
- "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
COMMAND ${CMAKE_COMMAND} -E copy
- "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
- "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
+ ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
+ ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
+list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
 install(PROGRAMS man/${ManPage}
-DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
 COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index e90e0fd852012..ec39ea63f2d02 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
-install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
${CMAKE_INSTALL_DATADIR}/pkgconfig )
+install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 
)
 
 if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_disable STATIC
generic/lib/subnormal_disable.ll )
install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-   DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+   DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
 endif()
 
 find_package( Python3 REQUIRED COMPONENTS Interpreter )
@@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
add_custom_target( "prepare-${spv_suffix}" ALL
   DEPENDS "${spv_suffix}" )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
-DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
else()
 
# Add prepare target
@@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
PROPERTIES ENVIRONMENT 
"LLVM_CONFIG=${LLVM_CONFIG}" )
endif()
 
-   install( FILES 
${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION 
"${CMAKE_INSTALL_DATADIR}/clc" )
+   install( FILES 

[clang-tools-extra] 1a68c14 - [clangd] Restore -fno-ms-compatibility to tests

2021-12-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-12-11T02:31:26+01:00
New Revision: 1a68c14b577fd1b1ebfd6a064dd5faeda07042aa

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

LOG: [clangd] Restore -fno-ms-compatibility to tests

Turns out these weren't obsolete after all...
http://45.33.8.238/win/50653/step_9.txt

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index c28efdf014e5..02d572ed926f 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1084,6 +1084,8 @@ void g() {  ns::$[[scope]]::X_Y();  }
   )cpp");
   TestTU TU;
   TU.Code = std::string(Test.code());
+  // FIXME: Figure out why this is needed and remove it, PR43662.
+  TU.ExtraArgs.push_back("-fno-ms-compatibility");
   auto Index = buildIndexWithSymbol(
   SymbolWithHeader{"ns::scope::X_Y", "unittest:///x.h", "\"x.h\""});
   TU.ExternalIndex = Index.get();
@@ -1109,6 +,8 @@ void f() {
   )cpp");
   TestTU TU;
   TU.Code = std::string(Test.code());
+  // FIXME: Figure out why this is needed and remove it, PR43662.
+  TU.ExtraArgs.push_back("-fno-ms-compatibility");
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"clang::clangd::X", "unittest:///x.h", "\"x.h\""},
SymbolWithHeader{"clang::clangd::ns::Y", "unittest:///y.h", 
"\"y.h\""}});



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


[PATCH] D114095: [clang][lex] Include tracking: simplify and move to preprocessor

2021-12-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for measuring the .pcm impact! And I appreciate including the trunk 
baseline.

The results aren't exactly the same I've seen before, so please forgive me my 
suspiciousness. When you mention

> current trunk with this patch

do you mean "just this D114095  patch"? Or 
were you testing with D112915  applied? 
Because I was testing with per-submodule tracking applied. I am going to check 
again but it would be useful to know if you were comparing with per-submodule 
tracking (D112915 ) or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114095

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


[PATCH] D115484: [clangd] Include-fixer: handle more "incomplete type" diags, clean up tests

2021-12-10 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.
Closed by commit rGc25ea488a39a: [clangd] Include-fixer: handle more 
incomplete type diags. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D115484?vs=393343=393638#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115484

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/TestIndex.cpp
  clang-tools-extra/clangd/unittests/TestIndex.h

Index: clang-tools-extra/clangd/unittests/TestIndex.h
===
--- clang-tools-extra/clangd/unittests/TestIndex.h
+++ clang-tools-extra/clangd/unittests/TestIndex.h
@@ -10,7 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTINDEX_H
 
 #include "index/Index.h"
-#include "index/Merge.h"
 
 namespace clang {
 namespace clangd {
@@ -26,6 +25,8 @@
 Symbol func(llvm::StringRef Name);
 // Creates a class symbol.
 Symbol cls(llvm::StringRef Name);
+// Creates an enum symbol.
+Symbol enm(llvm::StringRef Name);
 // Creates a variable symbol.
 Symbol var(llvm::StringRef Name);
 // Creates a namespace symbol.
Index: clang-tools-extra/clangd/unittests/TestIndex.cpp
===
--- clang-tools-extra/clangd/unittests/TestIndex.cpp
+++ clang-tools-extra/clangd/unittests/TestIndex.cpp
@@ -65,6 +65,10 @@
   return sym(Name, index::SymbolKind::Class, "@S@\\0");
 }
 
+Symbol enm(llvm::StringRef Name) {
+  return sym(Name, index::SymbolKind::Enum, "@E@\\0");
+}
+
 Symbol var(llvm::StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
 }
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -843,14 +843,29 @@
   {"incomplete_base_class", "class Y : [[ns::X]] {};"},
   {"incomplete_member_access", "auto i = x[[->]]f();"},
   {"incomplete_type", "auto& [[[]]m] = *x;"},
+  {"init_incomplete_type",
+   "struct C { static int f(ns::X&); }; int i = C::f([[{]]});"},
+  {"bad_cast_incomplete", "auto a = [[static_cast]](0);"},
+  {"template_nontype_parm_incomplete", "template  int a;"},
   {"typecheck_decl_incomplete_type", "ns::X [[var]];"},
   {"typecheck_incomplete_tag", "auto i = [[(*x)]]->f();"},
+  {"typecheck_nonviable_condition_incomplete",
+   "struct A { operator ns::X(); } a; const ns::X &[[b]] = a;"},
   {"invalid_incomplete_type_use", "auto var = [[ns::X()]];"},
   {"sizeof_alignof_incomplete_or_sizeless_type",
"auto s = [[sizeof]](ns::X);"},
   {"for_range_incomplete_type", "void foo() { for (auto i : [[*]]x ) {} }"},
   {"func_def_incomplete_result", "ns::X [[func]] () {}"},
   {"field_incomplete_or_sizeless", "class M { ns::X [[member]]; };"},
+  {"array_incomplete_or_sizeless_type", "auto s = [[(ns::X[]){}]];"},
+  {"call_incomplete_return", "ns::X f(); auto fp =  auto z = [[fp()]];"},
+  {"call_function_incomplete_return", "ns::X foo(); auto a = [[foo()]];"},
+  {"call_incomplete_argument", "int m(ns::X); int i = m([[*x]]);"},
+  {"switch_incomplete_class_type", "void a() { [[switch]](*x) {} }"},
+  {"delete_incomplete_class_type", "void f() { [[delete]] *x; }"},
+  {"-Wdelete-incomplete", "void f() { [[delete]] x; }"},
+  {"dereference_incomplete_type",
+   R"cpp(void f() { asm("" : "=r"([[*]]x)::); })cpp"},
   };
   for (auto Case : Tests) {
 Annotations Main(Case.second);
@@ -864,6 +879,36 @@
   }
 }
 
+TEST(IncludeFixerTest, IncompleteEnum) {
+  Symbol Sym = enm("X");
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.CanonicalDeclaration.FileURI = Sym.Definition.FileURI = "unittest:///x.h";
+  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
+  SymbolSlab::Builder Slab;
+  Slab.insert(Sym);
+  auto Index =
+  MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
+
+  TestTU TU;
+  TU.ExternalIndex = Index.get();
+  TU.ExtraArgs.push_back("-std=c++20");
+
+  std::vector> Tests{
+  {"incomplete_enum", "enum class X : int; using enum [[X]];"},
+  {"underlying_type_of_incomplete_enum",
+   "[[__underlying_type]](enum X) i;"},
+  };
+  for (auto Case : Tests) {
+Annotations Main(Case.second);
+TU.Code = Main.code().str() + "\n // error-ok";
+EXPECT_THAT(*TU.build().getDiagnostics(),
+Contains(AllOf(DiagName(Case.first), HasRange(Main.range()),
+   WithFix(Fix(Range{}, "#include \"x.h\"\n",
+   "Include \"x.h\" for symbol 

[clang-tools-extra] c25ea48 - [clangd] Include-fixer: handle more "incomplete type" diags.

2021-12-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-12-11T01:46:35+01:00
New Revision: c25ea488a39a090d43c0fd6dd68fdc26dc563708

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

LOG: [clangd] Include-fixer: handle more "incomplete type" diags.

I started adding tests for all diags but found there were just too many cases.

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang-tools-extra/clangd/unittests/TestIndex.h

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeFixer.cpp 
b/clang-tools-extra/clangd/IncludeFixer.cpp
index 24d9b4918543..8c020f2486f0 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -71,28 +71,115 @@ std::vector only(llvm::Optional F) {
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic ) const {
   switch (Info.getID()) {
-  case diag::err_incomplete_nested_name_spec:
+  /*
+   There are many "incomplete type" diagnostics!
+   They are almost all Sema diagnostics with "incomplete" in the name.
+
+   sed -n '/CLASS_NOTE/! s/DIAG(\\([^,]*\\).*)/  case diag::\\1:/p' \
+ tools/clang/include/clang/Basic/DiagnosticSemaKinds.inc | grep incomplete
+  */
+  // clang-format off
+  //case diag::err_alignof_member_of_incomplete_type:
+  case diag::err_array_incomplete_or_sizeless_type:
+  case diag::err_array_size_incomplete_type:
+  case diag::err_asm_incomplete_type:
+  case diag::err_assoc_type_incomplete:
+  case diag::err_bad_cast_incomplete:
+  case diag::err_call_function_incomplete_return:
+  case diag::err_call_incomplete_argument:
+  case diag::err_call_incomplete_return:
+  case diag::err_capture_of_incomplete_or_sizeless_type:
+  case diag::err_catch_incomplete:
+  case diag::err_catch_incomplete_ptr:
+  case diag::err_catch_incomplete_ref:
+  case diag::err_cconv_incomplete_param_type:
+  case diag::err_coroutine_promise_type_incomplete:
+  case diag::err_covariant_return_incomplete:
+  //case diag::err_deduced_class_template_incomplete:
+  case diag::err_delete_incomplete_class_type:
+  case diag::err_dereference_incomplete_type:
+  case diag::err_exception_spec_incomplete_type:
+  case diag::err_field_incomplete_or_sizeless:
+  case diag::err_for_range_incomplete_type:
+  case diag::err_func_def_incomplete_result:
+  case diag::err_ice_incomplete_type:
+  case diag::err_illegal_message_expr_incomplete_type:
   case diag::err_incomplete_base_class:
+  case diag::err_incomplete_enum:
+  case diag::err_incomplete_in_exception_spec:
   case diag::err_incomplete_member_access:
+  case diag::err_incomplete_nested_name_spec:
+  case diag::err_incomplete_object_call:
+  case diag::err_incomplete_receiver_type:
+  case diag::err_incomplete_synthesized_property:
   case diag::err_incomplete_type:
-  case diag::err_typecheck_decl_incomplete_type:
-  case diag::err_typecheck_incomplete_tag:
+  case diag::err_incomplete_type_objc_at_encode:
+  case diag::err_incomplete_type_used_in_type_trait_expr:
+  case diag::err_incomplete_typeid:
+  case diag::err_init_incomplete_type:
   case diag::err_invalid_incomplete_type_use:
+  case diag::err_lambda_incomplete_result:
+  //case diag::err_matrix_incomplete_index:
+  //case diag::err_matrix_separate_incomplete_index:
+  case diag::err_memptr_incomplete:
+  case diag::err_new_incomplete_or_sizeless_type:
+  case diag::err_objc_incomplete_boxed_expression_type:
+  case diag::err_objc_index_incomplete_class_type:
+  case diag::err_offsetof_incomplete_type:
+  case diag::err_omp_firstprivate_incomplete_type:
+  case diag::err_omp_incomplete_type:
+  case diag::err_omp_lastprivate_incomplete_type:
+  case diag::err_omp_linear_incomplete_type:
+  case diag::err_omp_private_incomplete_type:
+  case diag::err_omp_reduction_incomplete_type:
+  case diag::err_omp_section_incomplete_type:
+  case diag::err_omp_threadprivate_incomplete_type:
+  case diag::err_second_parameter_to_va_arg_incomplete:
   case diag::err_sizeof_alignof_incomplete_or_sizeless_type:
-  case diag::err_for_range_incomplete_type:
-  case diag::err_func_def_incomplete_result:
-  case diag::err_field_incomplete_or_sizeless:
+  case diag::err_subscript_incomplete_or_sizeless_type:
+  case diag::err_switch_incomplete_class_type:
+  case diag::err_temp_copy_incomplete:
+  //case diag::err_template_arg_deduced_incomplete_pack:
+  case diag::err_template_nontype_parm_incomplete:
+  //case diag::err_tentative_def_incomplete_type:
+  case diag::err_throw_incomplete:
+  case diag::err_throw_incomplete_ptr:
+  case 

[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 393634.
tianshilei1992 added a comment.

continue to remove more unrelated code changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2273,6 +2273,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6248,6 +6248,8 @@
 
 void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11761,6 +11761,9 @@
   case llvm::omp::OMPC_capture:
 C = new (Context) OMPCaptureClause();
 break;
+  case llvm::omp::OMPC_compare:
+C = new (Context) OMPCompareClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12119,6 +12122,8 @@
 
 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9429,6 +9429,13 @@
   return C;
 }
 
+template 
+OMPClause *
+TreeTransform::TransformOMPCompareClause(OMPCompareClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6371,6 +6371,7 @@
   case OMPC_write:
   case OMPC_update:
   case OMPC_capture:
+  case OMPC_compare:
   case OMPC_seq_cst:
   case OMPC_acq_rel:
   case OMPC_acquire:
@@ -10952,7 +10953,8 @@
   for (const OMPClause *C : Clauses) {
 if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
 C->getClauseKind() == OMPC_update ||
-C->getClauseKind() == OMPC_capture) {
+C->getClauseKind() == OMPC_capture ||
+C->getClauseKind() == OMPC_compare) {
   if (AtomicKind != OMPC_unknown) {
 Diag(C->getBeginLoc(), diag::err_omp_atomic_several_clauses)
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
@@ -11387,15 +11389,19 @@
 

[clang-tools-extra] a8bf389 - [clangd] Clean up some include-fixer tests. NFC

2021-12-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-12-11T01:31:03+01:00
New Revision: a8bf389f41465415fa9088609956dfd3e153e9cf

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

LOG: [clangd] Clean up some include-fixer tests. NFC

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 2c4a9aec1d3f1..c46f084c4ebc0 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -13,7 +13,6 @@
 #include "FeatureModule.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
-#include "SourceCode.h"
 #include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
@@ -70,6 +69,8 @@ WithTag(::testing::Matcher TagMatcher) {
   return Field(::Tags, Contains(TagMatcher));
 }
 
+MATCHER_P(HasRange, Range, "") { return arg.Range == Range; }
+
 MATCHER_P2(Diag, Range, Message,
"Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
   return arg.Range == Range && arg.Message == Message;
@@ -831,95 +832,36 @@ buildIndexWithSymbol(llvm::ArrayRef 
Syms) {
 }
 
 TEST(IncludeFixerTest, IncompleteType) {
-  Annotations Test(R"cpp(// error-ok
-$insert[[]]namespace ns {
-  class X;
-  $nested[[X::]]Nested n;
-}
-class Y : $base[[public ns::X]] {};
-void test(ns::X *x, ns::X& ref_x) {
-  x$access[[->]]f();
-  auto& $type[[[]]a] = *x;
-
-  ns::X $incomplete[[var]];
-  $tag[[ref_x]]->f();
-  $use[[ns::X()]];
-  $sizeof[[sizeof]](ns::X);
-  for (auto it : $for[[ref_x]]);
-}
-
-ns::X $return[[func]]() {}
-
-class T {
-  ns::X $field[[x]];
-};
-  )cpp");
-  auto TU = TestTU::withCode(Test.code());
-  TU.ExtraArgs.push_back("-std=c++17");
+  auto TU = TestTU::withHeaderCode("namespace ns { class X; } ns::X *x;");
+  TU.ExtraArgs.push_back("-std=c++20");
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
 
-  EXPECT_THAT(
-  *TU.build().getDiagnostics(),
-  UnorderedElementsAreArray(
-  {AllOf(Diag(Test.range("nested"),
-  "incomplete type 'ns::X' named in nested name 
specifier"),
- DiagName("incomplete_nested_name_spec"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("base"), "base class has incomplete type"),
- DiagName("incomplete_base_class"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("access"),
-  "member access into incomplete type 'ns::X'"),
- DiagName("incomplete_member_access"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(
-   Diag(
-   Test.range("type"),
-   "incomplete type 'ns::X' where a complete type is 
required"),
-   DiagName("incomplete_type"),
-   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-   "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("incomplete"),
-  "variable has incomplete type 'ns::X'"),
- DiagName("typecheck_decl_incomplete_type"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(
-   Diag(Test.range("tag"), "incomplete definition of type 
'ns::X'"),
-   DiagName("typecheck_incomplete_tag"),
-   WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-   "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("use"),
-  "invalid use of incomplete type 'ns::X'"),
- DiagName("invalid_incomplete_type_use"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("sizeof"),
-  "invalid application of 'sizeof' to "
-  "an incomplete type 'ns::X'"),
- DiagName("sizeof_alignof_incomplete_or_sizeless_type"),
- WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
- "Include \"x.h\" for symbol ns::X"))),
-   AllOf(Diag(Test.range("for"),
-  "cannot use 

[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 393633.
tianshilei1992 added a comment.

further remove code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2273,6 +2273,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6248,6 +6248,8 @@
 
 void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11761,6 +11761,9 @@
   case llvm::omp::OMPC_capture:
 C = new (Context) OMPCaptureClause();
 break;
+  case llvm::omp::OMPC_compare:
+C = new (Context) OMPCompareClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12119,6 +12122,8 @@
 
 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9429,6 +9429,13 @@
   return C;
 }
 
+template 
+OMPClause *
+TreeTransform::TransformOMPCompareClause(OMPCompareClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6371,6 +6371,7 @@
   case OMPC_write:
   case OMPC_update:
   case OMPC_capture:
+  case OMPC_compare:
   case OMPC_seq_cst:
   case OMPC_acq_rel:
   case OMPC_acquire:
@@ -10952,7 +10953,8 @@
   for (const OMPClause *C : Clauses) {
 if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
 C->getClauseKind() == OMPC_update ||
-C->getClauseKind() == OMPC_capture) {
+C->getClauseKind() == OMPC_capture ||
+C->getClauseKind() == OMPC_compare) {
   if (AtomicKind != OMPC_unknown) {
 Diag(C->getBeginLoc(), diag::err_omp_atomic_several_clauses)
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
@@ -11007,9 +11009,13 @@
   if (auto *EWC = dyn_cast(Body))
 

Re: [clang] 9791b58 - [C++20 Modules] Don't create global module fragment for extern linkage declaration in GMF already

2021-12-10 Thread Richard Smith via cfe-commits
On Wed, 8 Dec 2021 at 21:56, Chuanqi Xu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Chuanqi Xu
> Date: 2021-12-09T13:55:15+08:00
> New Revision: 9791b589516b644a6273607b46a9c6661993d667
>
> URL:
> https://github.com/llvm/llvm-project/commit/9791b589516b644a6273607b46a9c6661993d667
> DIFF:
> https://github.com/llvm/llvm-project/commit/9791b589516b644a6273607b46a9c6661993d667.diff
>
> LOG: [C++20 Modules] Don't create global module fragment for extern
> linkage declaration in GMF already
>
> Previously we would create global module fragment for extern linkage
> declaration which is alreday in global module fragment. However, it is
> clearly redundant to do so. This patch would check if the extern linkage
> declaration are already in GMF before we create a GMF for it.
>

I'm still seeing some problems even after this patch -- linkage spec
declarations within the purview of the module still create new global
module fragments, and then the serialization code seems to sometimes get
confused because we have multiple submodules with the same name "".
Perhaps we should reuse an existing global module fragment if there is one,
even when inside the purview of the module?

Here's an example end-to-end testcase for which I'm seeing an assertion
failure; I've not got a reduced testcase yet:

$ cat say_hello.cppm
module;
#include 
#include 
export module Hello;
export void SayHello
  (std::string_view const )
{
  std::cout << "Hello " << name << "!\n";
}

$ cat hello.cpp
#include 
import Hello;
int main() {
  SayHello("world");
  return 0;
}

$ ./build/bin/clang++ say_hello.cppm --precompile -o say_hello.pcm
-std=c++20
$ ./build/bin/clang++ say_hello.cppm hello.cpp -fmodule-file=say_hello.pcm
-std=c++20

Added:
> clang/test/CXX/module/module.unit/p7/Inputs/h7.h
> clang/test/CXX/module/module.unit/p7/t7.cpp
>
> Modified:
> clang/include/clang/Sema/Sema.h
> clang/lib/Sema/SemaDeclCXX.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Sema/Sema.h
> b/clang/include/clang/Sema/Sema.h
> index a12dd4db66c13..73c5ad1dd7acf 100644
> --- a/clang/include/clang/Sema/Sema.h
> +++ b/clang/include/clang/Sema/Sema.h
> @@ -,6 +,12 @@ class Sema final {
>  return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
>}
>
> +  /// Helper function to judge if we are in module purview.
> +  /// Return false if we are not in a module.
> +  bool isCurrentModulePurview() const {
> +return getCurrentModule() ? getCurrentModule()->isModulePurview() :
> false;
> +  }
> +
>/// Enter the scope of the global module.
>Module *PushGlobalModuleFragment(SourceLocation BeginLoc, bool
> IsImplicit);
>/// Leave the scope of the global module.
>
> diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp
> b/clang/lib/Sema/SemaDeclCXX.cpp
> index 4a0eda2a700fe..3f6bde1b9ed6a 100644
> --- a/clang/lib/Sema/SemaDeclCXX.cpp
> +++ b/clang/lib/Sema/SemaDeclCXX.cpp
> @@ -16153,7 +16153,10 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope
> *S, SourceLocation ExternLoc,
>///   - ...
>///   - appears within a linkage-specification,
>///   it is attached to the global module.
> -  if (getLangOpts().CPlusPlusModules && getCurrentModule()) {
> +  ///
> +  /// If the declaration is already in global module fragment, we don't
> +  /// need to attach it again.
> +  if (getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
>  Module *GlobalModule =
>  PushGlobalModuleFragment(ExternLoc, /*IsImplicit=*/true);
>  D->setModuleOwnershipKind(Decl::ModuleOwnershipKind::ModulePrivate);
> @@ -16177,7 +16180,11 @@ Decl *Sema::ActOnFinishLinkageSpecification(Scope
> *S,
>  LSDecl->setRBraceLoc(RBraceLoc);
>}
>
> -  if (getLangOpts().CPlusPlusModules && getCurrentModule())
> +  // If the current module doesn't has Parent, it implies that the
> +  // LinkageSpec isn't in the module created by itself. So we don't
> +  // need to pop it.
> +  if (getLangOpts().CPlusPlusModules && getCurrentModule() &&
> +  getCurrentModule()->isGlobalModule() && getCurrentModule()->Parent)
>  PopGlobalModuleFragment();
>
>PopDeclContext();
>
> diff  --git a/clang/test/CXX/module/module.unit/p7/Inputs/h7.h
> b/clang/test/CXX/module/module.unit/p7/Inputs/h7.h
> new file mode 100644
> index 0..cd3b6706d561c
> --- /dev/null
> +++ b/clang/test/CXX/module/module.unit/p7/Inputs/h7.h
> @@ -0,0 +1,10 @@
> +#ifndef H7_H
> +#define H7_H
> +
> +extern "C++" {
> +class A {};
> +}
> +
> +class B : public A {};
> +
> +#endif
>
> diff  --git a/clang/test/CXX/module/module.unit/p7/t7.cpp
> b/clang/test/CXX/module/module.unit/p7/t7.cpp
> new file mode 100644
> index 0..7ce0cbb964131
> --- /dev/null
> +++ b/clang/test/CXX/module/module.unit/p7/t7.cpp
> @@ -0,0 +1,7 @@
> +// RUN: rm -fr %t
> +// RUN: mkdir %t
> +// RUN: %clang_cc1 -std=c++20 -I%S/Inputs/ %s -verify
> +// 

[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 393630.
nickdesaulniers added a comment.

- fix typo in release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115471

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/Stmt.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/asm-goto.c

Index: clang/test/CodeGen/asm-goto.c
===
--- clang/test/CodeGen/asm-goto.c
+++ clang/test/CodeGen/asm-goto.c
@@ -55,14 +55,14 @@
 
 int test4(int out1, int out2) {
   // CHECK-LABEL: define{{.*}} i32 @test4(
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${3:l}", "={si},={di},r,i,i,0,1
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,0,1,i,i
   // CHECK: to label %asm.fallthrough [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough:
   if (out1 < out2)
-asm volatile goto("jne %l3" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
+asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
   else
-asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,r,i,i,0,1
+asm volatile goto("jne %l7" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${7:l}", "={si},={di},r,r,0,1,i,i
   // CHECK: to label %asm.fallthrough2 [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough2:
   return out1 + out2;
@@ -74,7 +74,7 @@
 
 int test5(int addr, int size, int limit) {
   // CHECK-LABEL: define{{.*}} i32 @test5(
-  // CHECK: callbr i32 asm "add $1,$0 ; jc ${3:l} ; cmp $2,$0 ; ja ${3:l} ; ", "=r,imr,imr,i,0
+  // CHECK: callbr i32 asm "add $1,$0 ; jc ${4:l} ; cmp $2,$0 ; ja ${4:l} ; ", "=r,imr,imr,0,i
   // CHECK: to label %asm.fallthrough [label %t_err]
   // CHECK-LABEL: asm.fallthrough:
   asm goto(
@@ -92,14 +92,40 @@
 
 int test6(int out1) {
   // CHECK-LABEL: define{{.*}} i32 @test6(
-  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${2:l}", "={si},r,i,i,0,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
+  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${3:l}", "={si},r,0,i,i,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
   // CHECK: to label %asm.fallthrough [label %label_true, label %landing]
   // CHECK-LABEL: asm.fallthrough:
   // CHECK-LABEL: landing:
   int out2 = 42;
-  asm volatile goto("testl %0, %0; testl %1, %1; jne %l2" : "+S"(out2) : "r"(out1) :: label_true, landing);
+  asm volatile goto("testl %0, %0; testl %1, %1; jne %l3" : "+S"(out2) : "r"(out1) :: label_true, landing);
 landing:
   return out1 + out2;
 label_true:
   return -2;
 }
+
+// test7 - For the output templates in the asm string (%0, %l2), GCC places
+// hidden inputs tied to outputs ("+r" constraint) BEFORE labels. Test that foo
+// is $2 (or rather ${2:l} because of the l output template) in the emitted asm
+// string, not $1.
+void *test7(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test7(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test7, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &
+  asm goto ("# %0\n\t# %l2":"+r"(p):::foo);
+foo:
+  return p;
+}
+
+// test8 - the same as test7, but this time we use symbolic names rather than
+// numbered outputs.
+void *test8(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test8(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test8, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &
+  asm goto ("# %0\n\t# %l[foo]":"+r"(p):::foo);
+foo:
+  return p;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2532,6 +2532,13 @@
 Constraints += InputConstraint;
   }
 
+  // Append the "input" part of inout constraints.
+  for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
+ArgTypes.push_back(InOutArgTypes[i]);
+Args.push_back(InOutArgs[i]);
+  }
+  Constraints += InOutConstraints;
+
   // Labels
   SmallVector Transfer;
   llvm::BasicBlock *Fallthrough = nullptr;
@@ -2554,13 +2561,6 @@
 }
   }
 
-  // Append the "input" part of inout constraints last.
-  for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
-ArgTypes.push_back(InOutArgTypes[i]);
-Args.push_back(InOutArgs[i]);
-  }
-  Constraints += InOutConstraints;
-
   bool HasUnwindClobber = false;
 
   // Clobbers
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ 

[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 393629.
tianshilei1992 added a comment.

remove useless code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2273,6 +2273,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6248,6 +6248,8 @@
 
 void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11761,6 +11761,9 @@
   case llvm::omp::OMPC_capture:
 C = new (Context) OMPCaptureClause();
 break;
+  case llvm::omp::OMPC_compare:
+C = new (Context) OMPCompareClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12119,6 +12122,8 @@
 
 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9429,6 +9429,13 @@
   return C;
 }
 
+template 
+OMPClause *
+TreeTransform::TransformOMPCompareClause(OMPCompareClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6371,6 +6371,7 @@
   case OMPC_write:
   case OMPC_update:
   case OMPC_capture:
+  case OMPC_compare:
   case OMPC_seq_cst:
   case OMPC_acq_rel:
   case OMPC_acquire:
@@ -10952,7 +10953,8 @@
   for (const OMPClause *C : Clauses) {
 if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
 C->getClauseKind() == OMPC_update ||
-C->getClauseKind() == OMPC_capture) {
+C->getClauseKind() == OMPC_capture ||
+C->getClauseKind() == OMPC_compare) {
   if (AtomicKind != OMPC_unknown) {
 Diag(C->getBeginLoc(), diag::err_omp_atomic_several_clauses)
 << SourceRange(C->getBeginLoc(), C->getEndLoc());
@@ -11007,9 +11009,13 @@
   

[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

I created a patch D115561  for parser.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-10 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev, carlo.bertolli.
Herald added subscribers: arphaman, guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

This patch adds the support for `atomic compare` in parser. The support
in Sema and CodeGen will come soon. For now, it simply eimits an error when it
is encountered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2273,6 +2273,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6248,6 +6248,8 @@
 
 void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11761,6 +11761,9 @@
   case llvm::omp::OMPC_capture:
 C = new (Context) OMPCaptureClause();
 break;
+  case llvm::omp::OMPC_compare:
+C = new (Context) OMPCompareClause();
+break;
   case llvm::omp::OMPC_seq_cst:
 C = new (Context) OMPSeqCstClause();
 break;
@@ -12119,6 +12122,8 @@
 
 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
 
+void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}
+
 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
 
 void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9429,6 +9429,13 @@
   return C;
 }
 
+template 
+OMPClause *
+TreeTransform::TransformOMPCompareClause(OMPCompareClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template 
 OMPClause *
 TreeTransform::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6371,6 +6371,7 @@
   case OMPC_write:
   case OMPC_update:
   case OMPC_capture:
+  case OMPC_compare:
   case OMPC_seq_cst:
   case OMPC_acq_rel:
   case OMPC_acquire:
@@ -10950,24 +10951,30 @@
   OpenMPClauseKind MemOrderKind = OMPC_unknown;
   SourceLocation MemOrderLoc;
   for (const OMPClause *C : Clauses) {
-if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
-

[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-12-10 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:395
+/// in 64-bit achitectures where 32-bit offsets might not be enough.
+if (TM.getCodeModel() == CodeModel::Medium ||
+TM.getCodeModel() == CodeModel::Large)

The meanings of code models isn't really portable across targets... e.g. 
RISC-V's medium (underlying LLVM name for -mcmodel=medany) assumes 32-bit 
PC-relative offsets, and thus using a 32-bit table-relative offset is safe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D113146: [Sema] Fix the assertion in Sema::ActOnDependentMemberExpr

2021-12-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113146

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-12-10 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp:132
+  // Place new instruction sequence after GEP.
+  Builder.SetInsertPoint(GEP);
+  Value *Index = GEP->getOperand(2);

This line causes the bug seen in bind. In that case, the GEP has been hoisted, 
but the load has not. In general the GEP could be in a different basic block, 
or even in the same basic block with an instruction that may not return 
(intrinsic, real function call, well-defined language-level exception, etc). 
You can insert the reltable.shift where the GEP is, and that probably makes 
sense given it serves (part of) the same purpose, but you *must* insert the 
actual reltable.intrinsic where the original load is, unless you've gone to 
great lengths to prove it's safe not to (which seems best left to the usual 
culprits like LICM).

IR test cases: https://godbolt.org/z/YMdaMrobE (bind is characterised by the 
first of the two functions)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[clang] 7c004c2 - Revert "[asan] Add support for disable_sanitizer_instrumentation attribute"

2021-12-10 Thread Andrew Browne via cfe-commits

Author: Andrew Browne
Date: 2021-12-10T14:33:38-08:00
New Revision: 7c004c2bc999186884a343989b523dacef02cda9

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

LOG: Revert "[asan] Add support for disable_sanitizer_instrumentation attribute"

This reverts commit 2b554920f11c8b763cd9ed9003f4e19b919b8e1f.

This change causes tsan test timeout on x86_64-linux-autoconf.

The timeout can be reproduced by:
  git clone https://github.com/llvm/llvm-zorg.git
  BUILDBOT_CLOBBER= BUILDBOT_REVISION=eef8f3f85679c5b1ae725bade1c23ab7bb6b924f 
llvm-zorg/zorg/buildbot/builders/sanitizers/buildbot_standard.sh

Added: 


Modified: 
clang/docs/AddressSanitizer.rst
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/test/CodeGen/address-safety-attr-flavors.cpp
clang/test/CodeGen/asan-globals.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 

llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll



diff  --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index fe5f683580a46..06b53e2e5da0b 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -229,12 +229,6 @@ compilers, so we suggest to use it together with
 The same attribute used on a global variable prevents AddressSanitizer
 from adding redzones around it and detecting out of bounds accesses.
 
-
-AddressSanitizer also supports
-``__attribute__((disable_sanitizer_instrumentation))``. This attribute
-works similar to ``__attribute__((no_sanitize("address")))``, but it also
-prevents instrumentation performed by other sanitizers.
-
 Suppressing Errors in Recompiled Code (Ignorelist)
 --
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index f3b53c4859b2c..ed43adfab9545 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -382,6 +382,9 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) 
{
"__cyg_profile_func_exit");
   }
 
+  if (ShouldSkipSanitizerInstrumentation())
+CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
+
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
 DI->EmitFunctionEnd(Builder, CurFn);
@@ -763,22 +766,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   Fn->addFnAttr(llvm::Attribute::NoSanitizeCoverage);
   }
 
-  if (ShouldSkipSanitizerInstrumentation()) {
-CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
-  } else {
-// Apply sanitizer attributes to the function.
-if (SanOpts.hasOneOf(SanitizerKind::Address | 
SanitizerKind::KernelAddress))
-  Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
-if (SanOpts.hasOneOf(SanitizerKind::HWAddress |
- SanitizerKind::KernelHWAddress))
-  Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
-if (SanOpts.has(SanitizerKind::MemTag))
-  Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
-if (SanOpts.has(SanitizerKind::Thread))
-  Fn->addFnAttr(llvm::Attribute::SanitizeThread);
-if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
-  Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
-  }
+  // Apply sanitizer attributes to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
+Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
+  if (SanOpts.hasOneOf(SanitizerKind::HWAddress | 
SanitizerKind::KernelHWAddress))
+Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
+  if (SanOpts.has(SanitizerKind::MemTag))
+Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
+  if (SanOpts.has(SanitizerKind::Thread))
+Fn->addFnAttr(llvm::Attribute::SanitizeThread);
+  if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
+Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
   if (SanOpts.has(SanitizerKind::ShadowCallStack))

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 9e26d242d3a7e..009965a36c396 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -73,8 +73,6 @@ void 
SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
   for (auto Attr : D.specific_attrs())
 if (Attr->getMask() & SanitizerKind::Address)
   IsExcluded = true;
-  if (D.hasAttr())
-IsExcluded = true;
   reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit,
  IsExcluded);
 }

diff  --git 

[PATCH] D115544: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

Sorry for this new build failure. I think I found the culprit and fixed it with 
https://reviews.llvm.org/D115553


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115544

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


[PATCH] D115049: Fall back on Android triple w/o API level for runtimes search

2021-12-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.
This revision is now accepted and ready to land.

LGTM once the comments are addressed. (I'd also approve the alternative 
approach discussed in the thread of searching each older API level directory, 
but have no preference one way or the other)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115049

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


[PATCH] D115544: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

I see a build failure in 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/ and think I know how 
to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115544

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


[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-12-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:14583
 
   if (Second && Second->getObjectKind() == OK_ObjCProperty) {
 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);

rnk wrote:
> This is also pseudo object handling code
Hmm.  Am I wrong to be concerned about folding overload placeholders too early 
in these clauses?  Surely overloads can be resolved by the operator call in 
some cases.

I agree with Reid that it would be really nice if we could make this share the 
normal paths for C++ operator resolution instead of duplicating so much of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-12-10 Thread Dimitry Andric via Phabricator via cfe-commits
dim added subscribers: emaste, jrtc27, dim.
dim added a comment.

FWIW, this commit turned out to break the FreeBSD dns/bind916 port, see 
https://bugs.freebsd.org/259921.

The short story is that the bind9 code on and after this line: 
https://gitlab.isc.org/isc-projects/bind9/-/blob/main/lib/isc/log.c#L1525 gets 
changed from something like:

  .Ltmp661:
  #DEBUG_VALUE: isc_log_doit:category_channels <- $r12
  .loc3 0 58  # log.c:0:58
  xorl%eax, %eax
  testl   %r15d, %r15d
  setg%al
  movl%r15d, %ecx
  negl%ecx
  movq%rcx, -840(%rbp)# 8-byte Spill
  leaq8328(%r13), %rcx
  #DEBUG_VALUE: isc_log_doit:matched <- 0
  movq%rcx, -808(%rbp)# 8-byte Spill
  .Ltmp662:
  .loc3 1552 25 is_stmt 1 # log.c:1552:25

to using a relative lookup table:

  .Ltmp661:
  #DEBUG_VALUE: isc_log_doit:category_channels <- $r12
  .loc3 0 58  # log.c:0:58
  xorl%eax, %eax
  testl   %r15d, %r15d
  setg%al
  movl%r15d, %edx
  negl%edx
  leaqreltable.isc_log_doit(%rip), %rcx
  movq%rdx, -848(%rbp)# 8-byte Spill
  movslq  (%rcx,%rdx,4), %rdx
  addq%rcx, %rdx
  movq%rdx, -840(%rbp)# 8-byte Spill
  leaq8328(%r13), %rcx
  #DEBUG_VALUE: isc_log_doit:matched <- 0
  movq%rcx, -808(%rbp)# 8-byte Spill
  .Ltmp662:
  .loc3 1552 25 is_stmt 1 # log.c:1552:25

However, the value of `%rcx` at the `movslq (%rcx,%rdx,4), %rdx` statement 
becomes -2, so it attempts to access data before `reltable.isc_log_doit`. As 
that is in `.rodata`, this leads to a segfault.

The current working theory is that some code is hoisted out of the do-while 
loop starting at 
https://gitlab.isc.org/isc-projects/bind9/-/blob/main/lib/isc/log.c#L1531, in 
particular the `[-level]` accesses on lines 1613 and 1843:

  snprintf(level_string, sizeof(level_string),
   "%s: ", log_level_strings[-level]);
  ...
  } else {
  syslog_level = syslog_map[-level];
  }

but maybe these negative offsets confuse the lookup table converter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D115471: [clang] number labels in asm goto strings after tied inputs

2021-12-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 393577.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.

- note this semantic change in the release notes, add links to GCC docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115471

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/Stmt.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/asm-goto.c

Index: clang/test/CodeGen/asm-goto.c
===
--- clang/test/CodeGen/asm-goto.c
+++ clang/test/CodeGen/asm-goto.c
@@ -55,14 +55,14 @@
 
 int test4(int out1, int out2) {
   // CHECK-LABEL: define{{.*}} i32 @test4(
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${3:l}", "={si},={di},r,i,i,0,1
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,0,1,i,i
   // CHECK: to label %asm.fallthrough [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough:
   if (out1 < out2)
-asm volatile goto("jne %l3" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
+asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1) :: label_true, loop);
   else
-asm volatile goto("jne %l5" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
-  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${5:l}", "={si},={di},r,r,i,i,0,1
+asm volatile goto("jne %l7" : "+S"(out1), "+D"(out2) : "r"(out1), "r"(out2) :: label_true, loop);
+  // CHECK: callbr { i32, i32 } asm sideeffect "jne ${7:l}", "={si},={di},r,r,0,1,i,i
   // CHECK: to label %asm.fallthrough2 [label %label_true, label %loop]
   // CHECK-LABEL: asm.fallthrough2:
   return out1 + out2;
@@ -74,7 +74,7 @@
 
 int test5(int addr, int size, int limit) {
   // CHECK-LABEL: define{{.*}} i32 @test5(
-  // CHECK: callbr i32 asm "add $1,$0 ; jc ${3:l} ; cmp $2,$0 ; ja ${3:l} ; ", "=r,imr,imr,i,0
+  // CHECK: callbr i32 asm "add $1,$0 ; jc ${4:l} ; cmp $2,$0 ; ja ${4:l} ; ", "=r,imr,imr,0,i
   // CHECK: to label %asm.fallthrough [label %t_err]
   // CHECK-LABEL: asm.fallthrough:
   asm goto(
@@ -92,14 +92,40 @@
 
 int test6(int out1) {
   // CHECK-LABEL: define{{.*}} i32 @test6(
-  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${2:l}", "={si},r,i,i,0,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
+  // CHECK: callbr i32 asm sideeffect "testl $0, $0; testl $1, $1; jne ${3:l}", "={si},r,0,i,i,{{.*}} i8* blockaddress(@test6, %label_true), i8* blockaddress(@test6, %landing)
   // CHECK: to label %asm.fallthrough [label %label_true, label %landing]
   // CHECK-LABEL: asm.fallthrough:
   // CHECK-LABEL: landing:
   int out2 = 42;
-  asm volatile goto("testl %0, %0; testl %1, %1; jne %l2" : "+S"(out2) : "r"(out1) :: label_true, landing);
+  asm volatile goto("testl %0, %0; testl %1, %1; jne %l3" : "+S"(out2) : "r"(out1) :: label_true, landing);
 landing:
   return out1 + out2;
 label_true:
   return -2;
 }
+
+// test7 - For the output templates in the asm string (%0, %l2), GCC places
+// hidden inputs tied to outputs ("+r" constraint) BEFORE labels. Test that foo
+// is $2 (or rather ${2:l} because of the l output template) in the emitted asm
+// string, not $1.
+void *test7(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test7(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test7, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &
+  asm goto ("# %0\n\t# %l2":"+r"(p):::foo);
+foo:
+  return p;
+}
+
+// test8 - the same as test7, but this time we use symbolic names rather than
+// numbered outputs.
+void *test8(void) {
+  // CHECK-LABEL: define{{.*}} i8* @test8(
+  // CHECK: %1 = callbr i8* asm "# $0\0A\09# ${2:l}", "=r,0,i,~{dirflag},~{fpsr},~{flags}"(i8* %0, i8* blockaddress(@test8, %foo))
+  // CHECK-NEXT: to label %asm.fallthrough [label %foo]
+  void *p = &
+  asm goto ("# %0\n\t# %l[foo]":"+r"(p):::foo);
+foo:
+  return p;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2532,6 +2532,13 @@
 Constraints += InputConstraint;
   }
 
+  // Append the "input" part of inout constraints.
+  for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
+ArgTypes.push_back(InOutArgTypes[i]);
+Args.push_back(InOutArgs[i]);
+  }
+  Constraints += InOutConstraints;
+
   // Labels
   SmallVector Transfer;
   llvm::BasicBlock *Fallthrough = nullptr;
@@ -2554,13 +2561,6 @@
 }
   }
 
-  // Append the "input" part of inout constraints last.
-  for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
-ArgTypes.push_back(InOutArgTypes[i]);
-Args.push_back(InOutArgs[i]);
-  }
-  Constraints += InOutConstraints;
-
   bool HasUnwindClobber = false;
 
   // Clobbers
Index: clang/lib/AST/Stmt.cpp

[PATCH] D115544: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson 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 rG492de35df443: Revert Revert Use `GNUInstallDirs` 
to support custom installation dirs. (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115544

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -360,7 +360,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -372,7 +372,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(LLVM_TOOLS_INSTALL_DIR);
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(LLVM_INSTALL_BINDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define 

[clang] 492de35 - Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2021-12-10T20:59:43Z
New Revision: 492de35df443d5f31480173d5f1274c7835cd3d8

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

LOG: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. 
-- LLVM""

This reverts commit 797b50d4be873b4662983413a06806fca544c276.

See the original D99484. @mib who noticed the original problem could not longer
reproduce it, after I tried and also failed. We are threfore hoping it went
away on its own!

Reviewed By: mib

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

Added: 


Modified: 
clang/tools/scan-build/CMakeLists.txt
libclc/CMakeLists.txt
lldb/cmake/modules/FindLibEdit.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/AddSphinxTarget.cmake
llvm/cmake/modules/CMakeLists.txt
llvm/cmake/modules/LLVMInstallSymlink.cmake
llvm/docs/CMake.rst
llvm/examples/Bye/CMakeLists.txt
llvm/include/llvm/CMakeLists.txt
llvm/tools/llvm-config/BuildVariables.inc.in
llvm/tools/llvm-config/llvm-config.cpp
llvm/tools/lto/CMakeLists.txt
llvm/tools/opt-viewer/CMakeLists.txt
llvm/tools/remarks-shlib/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/scan-build/CMakeLists.txt 
b/clang/tools/scan-build/CMakeLists.txt
index ec0702d76f184..74334e53c9b18 100644
--- a/clang/tools/scan-build/CMakeLists.txt
+++ b/clang/tools/scan-build/CMakeLists.txt
@@ -66,16 +66,16 @@ if(CLANG_INSTALL_SCANBUILD)
   endforeach()
 
   foreach(ManPage ${ManPages})
-add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
+add_custom_command(OUTPUT 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"
COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
- ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
+ "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
-list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
+list(APPEND Depends 
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")
 install(PROGRAMS man/${ManPage}
-DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
 COMPONENT scan-build)
   endforeach()
 

diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index ec39ea63f2d02..e90e0fd852012 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -183,8 +183,8 @@ endif()
 
 # pkg-config file
 configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
${CMAKE_INSTALL_DATADIR}/pkgconfig )
-install( DIRECTORY generic/include/clc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 
)
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
 
 if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_use_default STATIC
@@ -192,7 +192,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
add_library( subnormal_disable STATIC
generic/lib/subnormal_disable.ll )
install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-   DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+   DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 endif()
 
 find_package( Python3 REQUIRED COMPONENTS Interpreter )
@@ -343,7 +343,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
add_custom_target( "prepare-${spv_suffix}" ALL
   DEPENDS "${spv_suffix}" )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
-DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
+DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
else()
 
# Add prepare target
@@ -366,7 +366,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
PROPERTIES ENVIRONMENT 
"LLVM_CONFIG=${LLVM_CONFIG}" )
endif()
 
-   install( FILES 
${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION 
${CMAKE_INSTALL_DATADIR}/clc )
+   install( FILES 

[PATCH] D115544: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

This pre-merge build failure is in the ASAN tests and thus seems entirely 
unrelated, so I cam going to land this is and watch careful as instructed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115544

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


[PATCH] D112761: cfi-icall: Add -fsanitize-cfi-promotion-aliases

2021-12-10 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen abandoned this revision.
samitolvanen added a comment.

See https://reviews.llvm.org/D113613.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112761

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


[clang] 17414b6 - Fix shared build of unittests.

2021-12-10 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2021-12-10T15:33:56-05:00
New Revision: 17414b61245dcd3ae96c447762e8f776856a733c

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

LOG: Fix shared build of unittests.

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index d6f38c9404abc..f651cdeff1b55 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
   Support
   )
 



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


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-12-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D110549#3185409 , @linjamaki wrote:

> Assuming this patch is ready to land. @yaxunl, Could you please commit this 
> patch to the LLVM for us. Thanks.

I will test it with our internal CI, then commit it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D115503: [DebugInfo] emit DW_AT_accessibility attribute for class/struct/union types.

2021-12-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Generally sounds OK to me - this should be submitted as two separate patches. 
The LLVM part first, followed by the Clang part (since they can be separated 
they should be, and I guess the order doesn't matter too much (since the new IR 
that Clang's generating won't be invalid/break LLVM, it'll just be unused until 
the LLVM part is submitted).

I probably wouldn't bother adding the helper functions for "getParentDecl" to 
DeclCXX.h since there's only one use - if they provide a bunch of cleanup to 
existing callers, then maybe - otherwise just inlining the logic into the one 
call site is probably the right thing to do at the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115503

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


[PATCH] D115544: Revert "Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM""

2021-12-10 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Herald added subscribers: ormris, jvesely, steven_wu, hiraditya, mgorny.
Ericson2314 requested review of this revision.
Herald added projects: clang, LLDB, OpenMP, LLVM.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits, 
cfe-commits.

This reverts commit 797b50d4be873b4662983413a06806fca544c276 
.

See the original D99484 . @mib who noticed the 
original problem could not longer
reproduce it, after I tried and also failed. We are threfore hoping it went
away on its own!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115544

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -360,7 +360,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -372,7 +372,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(LLVM_TOOLS_INSTALL_DIR);
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(LLVM_INSTALL_BINDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ 

[PATCH] D112410: [SPIR-V] Add a toolchain for SPIR-V in clang

2021-12-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/UsersManual.rst:3559
+by the OpenCL driver that support SPIR-V consumption or it can be compiled 
further
+by offline SPIR-V consumer tools.
+

Btw do we want to say anything about the limitations of translating IR when 
optimizations are enabled?



Comment at: clang/test/Driver/spirv-toolchain.cl:10
+// SPV64-SAME: "-o" [[BC:".*bc"]]
+// SPV64: {{".*llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
+

svenvh wrote:
> Any reason to not just check for `llvm-spirv{{.*}}`, for consistency with the 
> clang check above?
Good question, apparently some tools get some target prefixes like if you look 
at `Driver::generatePrefixedToolNames`:
https://clang.llvm.org/doxygen/Driver_8cpp_source.html#l05169

But perhaps it doesn't happen for `llvm-spirv` and we can safely omit the 
prefix?


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

https://reviews.llvm.org/D112410

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


[PATCH] D114483: [SYCL] Add support for sycl_special_class attribute

2021-12-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 393532.

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

https://reviews.llvm.org/D114483

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/special-class-attribute.cpp

Index: clang/test/SemaSYCL/special-class-attribute.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/special-class-attribute.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+
+// No diagnostics
+class [[clang::sycl_special_class]] class1 {
+  void __init(){};
+};
+class __attribute__((sycl_special_class)) class2 {
+  void __init(){};
+};
+
+class class3;
+class [[clang::sycl_special_class]] class3 {
+  void __init(){};
+};
+
+class class4;
+class __attribute__((sycl_special_class)) class4 {
+  void __init(){};
+};
+
+class [[clang::sycl_special_class]] struct1 {
+  void __init(){};
+};
+struct __attribute__((sycl_special_class)) struct2 {
+  void __init(){};
+};
+
+class [[clang::sycl_special_class]] class5 {
+  void __init(){};
+};
+class special5 {};
+
+class __attribute__((sycl_special_class)) class6;
+class class6 {
+  void __init(){};
+};
+
+// Must have __init method defined
+class __attribute__((sycl_special_class)) class7 { // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+  class7() {}
+};
+class [[clang::sycl_special_class]] class8 { // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+  void __init();
+};
+
+struct __attribute__((sycl_special_class)) struct3;
+struct struct3 {}; // expected-error {{types with 'sycl_special_class' attribute must have an '__init' method defined}}
+
+// Only classes
+[[clang::sycl_special_class]] int var1 = 0;   // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+__attribute__((sycl_special_class)) int var2 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+
+[[clang::sycl_special_class]] void foo1();   // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+__attribute__((sycl_special_class)) void foo2(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
+
+// Attribute takes no arguments
+class [[clang::sycl_special_class(1)]] class9{}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
+class __attribute__((sycl_special_class(1))) class10 {}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
Index: clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/special-class-attribute-on-non-sycl.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+#ifndef __SYCL_DEVICE_ONLY__
+// expected-warning@+5 {{'sycl_special_class' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+class __attribute__((sycl_special_class)) special_class {
+  void __init(){};
+};
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -154,6 +154,7 @@
 // CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLSpecialClass (SubjectMatchRule_record)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7757,6 +7757,13 @@
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handleSYCLSpecialClassAttr(Sema , Decl *D, const ParsedAttr ) {
+  // The 'sycl_special_class' attribute applies only to records.
+  const auto *RD = cast(D);
+  assert(RD && "Record type is expected");
+  handleSimpleAttribute(S, D, AL);
+}
+
 static void 

[PATCH] D115492: [LTO] Ignore unreachable virtual functions in WPD in hybrid LTO

2021-12-10 Thread Mingming Liu via Phabricator via cfe-commits
luna updated this revision to Diff 393531.
luna added a comment.

Remove verbose attributes from test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115492

Files:
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGen/thinlto-distributed-cfi.ll
  clang/test/CodeGen/thinlto-funcattr-prop.ll
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Assembler/thinlto-summary.ll
  llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
  llvm/test/Bitcode/thinlto-type-vcalls.ll
  llvm/test/ThinLTO/X86/Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll
  llvm/test/ThinLTO/X86/devirt_hybrid_after_filtering_unreachable.ll
  llvm/test/ThinLTO/X86/dot-dumper.ll
  llvm/test/ThinLTO/X86/dot-dumper2.ll
  llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
  llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll

Index: llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
===
--- llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
+++ llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
@@ -23,4 +23,4 @@
 }
 
 attributes #0 = { alwaysinline nounwind uwtable }
-; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0
+; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0
Index: llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
===
--- llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
+++ llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
@@ -48,9 +48,9 @@
 ; CHECK-DAG: attributes [[ATTR_NOUNWIND]] = { norecurse nounwind }
 ; CHECK-DAG: attributes [[ATTR_MAYTHROW]] = { norecurse }
 
-; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, 

[PATCH] D112915: [clang][modules] Track included files per submodule

2021-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D112915#3141417 , @vsapsai wrote:

> I think AST format for `IncludedFiles` was discussed here, so I'll continue 
> here though the bulk of implementation is in D114095 
>  now. Have you compared the size of 
> resulting .pcm files when you are using a bitvector compared to a list of 
> included headers? In my quick check (which is not a perfect comparison, to be 
> honest) bitvector approach takes more space. For example, Darwin.pcm is 7320 
> bytes bigger, UIKit.pcm is 2388 bytes bigger, and entire modules cache is 
> 14KB bigger. I haven't checked the details of the discrepancies, so curious 
> if you have some insights already. For the record, I was testing with
>
>   echo '#import ' | path/to/built/bin/clang -fsyntax-only 
> -isysroot "$(xcrun --sdk iphoneos --show-sdk-path)" -target arm64-apple-ios 
> -fmodules -fmodules-cache-path=modules.noindex -x objective-c -

Replied in D114095 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

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


[PATCH] D114095: [clang][lex] Include tracking: simplify and move to preprocessor

2021-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D114095#3160103 , @vsapsai wrote:

> I've mentioned it in D112915  as we've 
> discussed the stored data format there. But my concern was that bitvector 
> packing might be not the most space-efficient encoding. I haven't done proper 
> testing, just off-the-cuff comparison and it looks like for the most of 
> frameworks in iOS SDK storing included headers per submodule takes less space 
> than encoding them as a bitvector. I have an idea why that might be happening 
> but I haven't checked it in debugger, so'll keep it to myself to avoid 
> derailing the discussion.

Let's bring the conversation over here. I ran the same UIKit test you did and 
compared the following:

- current trunk
- current trunk with this patch
- current trunk with this patch, with bitvector replaced by vector of IDs 
(32-bit integers).

The following table shows sizes of .pcm files in bytes and their delta compared 
to trunk:

  +--+-+-+
  |   trunk  |bit vector   |ID vector|
  +--+-+-+
  |   281932 |   281944+12 |   281988+56 |
  |   989840 |   989784-56 |   989968   +128 |
  |   837116 |   837084-32 |   837212+96 |
  |   899924 |   899912-12 |   94+80 |
  |   710296 |   710296 +0 |   710376+80 |
  |   273140 |   273144 +4 |   273196+56 |
  |  3649856 |  3649024   -832 |  3650804   +948 |
  |   207676 |   207692+16 |   207740+64 |
  |   342792 |   342804+12 |   342860+68 |
  |  4137660 |  4137460   -200 |  4137940   +280 |
  |   173536 |   173564+28 |   173580+44 |
  |   787120 |   787144+24 |   787180+60 |
  |  1260652 |  1260596-56 |  1260804   +152 |
  |   255072 |   255092+20 |   255128+56 |
  |   973204 |   973228+24 |   973268+64 |
  |   398952 |   398940-12 |   399036+84 |
  |   631516 |   631516 +0 |   631588+72 |
  |  5252932 |  5252348   -584 |  5253612   +680 |
  |   230160 |   230168 +8 |   230228+68 |
  |24460 |24500+40 |24500+40 |
  |53244 |53280+36 |53288+44 |
  |75932 |75952+20 |75972+40 |
  |32840 |32876+36 |32884+44 |
  +--+-+-+
  | 22479852 | 22478348  -1504 | 22483156  +3304 |
  +--+-+-+

Used command:

  echo '#import ' | ./bin/clang -fsyntax-only -isysroot "$(xcrun 
--sdk iphoneos --show-sdk-path)" -target arm64-apple-ios -fmodules 
-fmodules-cache-path=modules.noindex -x objective-c -

Patch that I applied on top of the one under review to get vector of IDs:

F20979504: bitvector-to-id-vector.diff 

I see how the bitvector could explode for large fine-grained modules. They have 
lots of input files (-> large bitvectors in each submodule), but each submodule 
only includes a handful files (-> bitvectors are sparse). It seems like this 
doesn't actually happen, at least in our SDK.

@vsapsai Do you think this warrants more thorough investigation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114095

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


[PATCH] D115355: Fix build failure with GCC 11 in C++20 mode

2021-12-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.

LGTM too.




Comment at: clang/lib/AST/ASTImporter.cpp:8400-8403
+  AttrArgImporter(const AttrArgImporter &) = delete;
+  AttrArgImporter(AttrArgImporter &&) = default;
   AttrArgImporter =(const AttrArgImporter &) = delete;
   AttrArgImporter =(AttrArgImporter &&) = default;

Might be nice to remove the implied ``s in the parameters/returns (here and 
elsewhere) as a follow up; a bit noisy to read those, even if it doesn't cause 
a build failure (probably separately from this patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115355

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


[PATCH] D105555: [RISCV][Clang] Compute the default target-abi if it's empty.

2021-12-10 Thread Zakk Chen 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 rG57b5f4b2ecc6: [RISCV][Clang] Compute the default target-abi 
if its empty. (authored by khchen).

Changed prior to commit:
  https://reviews.llvm.org/D10?vs=384981=393522#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D10

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-metadata.c
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -331,6 +331,21 @@
   return true;
 }
 
+StringRef computeDefaultABIFromArch(const llvm::RISCVISAInfo ) {
+  if (ISAInfo.getXLen() == 32) {
+if (ISAInfo.hasExtension("d"))
+  return "ilp32d";
+if (ISAInfo.hasExtension("e"))
+  return "ilp32e";
+return "ilp32";
+  } else if (ISAInfo.getXLen() == 64) {
+if (ISAInfo.hasExtension("d"))
+  return "lp64d";
+return "lp64";
+  }
+  llvm_unreachable("Invalid XLEN");
+}
+
 } // namespace RISCV
 } // namespace llvm
 
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -17,8 +17,9 @@
 // FIXME: vector is used because that's what clang uses for subtarget feature
 // lists, but SmallVector would probably be better
 #include "llvm/ADT/Triple.h"
-#include "llvm/Support/ARMTargetParser.h"
 #include "llvm/Support/AArch64TargetParser.h"
+#include "llvm/Support/ARMTargetParser.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include 
 
 namespace llvm {
@@ -174,6 +175,7 @@
 void fillValidTuneCPUArchList(SmallVectorImpl , bool IsRV64);
 bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector );
 StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64);
+StringRef computeDefaultABIFromArch(const llvm::RISCVISAInfo );
 
 } // namespace RISCV
 
Index: clang/test/CodeGen/RISCV/riscv-metadata.c
===
--- clang/test/CodeGen/RISCV/riscv-metadata.c
+++ clang/test/CodeGen/RISCV/riscv-metadata.c
@@ -1,14 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck -check-prefix=EMPTY-ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -target-feature +f -target-feature +d -o - %s | FileCheck -check-prefix=EMPTY-ILP32D %s
 // RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | FileCheck -check-prefix=ILP32 %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f -target-abi ilp32d -emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck -check-prefix=EMPTY-LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -emit-llvm -o - %s | FileCheck -check-prefix=EMPTY-LP64D %s
 // RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | FileCheck -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-feature +f -target-abi lp64d -emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
 
+// Test expected behavior when giving -target-cpu
+// This cc1 test is similar to clang with -march=rv32ifd -mcpu=sifive-e31, default abi is ilp32d
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -target-feature +f -target-feature +d -target-cpu sifive-e31 -o - %s | FileCheck -check-prefix=EMPTY-ILP32D %s
+// This cc1 test is similar to clang with -march=rv64i -mcpu=sifive-u74, default abi is lp64
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -target-cpu sifive-u74 %s | FileCheck -check-prefix=EMPTY-LP64 %s
+
+// EMPTY-ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// EMPTY-ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 // ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
 // ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
 // ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 
+// EMPTY-LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// EMPTY-LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
 // LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
 // LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
 // LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- 

[clang] 57b5f4b - [RISCV][Clang] Compute the default target-abi if it's empty.

2021-12-10 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2021-12-10T08:54:23-08:00
New Revision: 57b5f4b2ecc6aeed5328086aa533d706adb008d1

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

LOG: [RISCV][Clang] Compute the default target-abi if it's empty.

Every generated IR has a corresponding target-abi value, so
encoding a non-empty value would improve the robustness and
correctness.

Reviewed By: asb, jrtc27, arichardson

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/CodeGen/RISCV/riscv-metadata.c
llvm/include/llvm/Support/TargetParser.h
llvm/lib/Support/TargetParser.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 93562dde2f544..770d37a1c1bea 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -246,6 +246,9 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector ,
 ISAInfo = std::move(*ParseResult);
   }
 
+  if (ABI.empty())
+ABI = llvm::RISCV::computeDefaultABIFromArch(*ISAInfo).str();
+
   return true;
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 323f588c8269c..7ad8ca69bed5d 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -194,27 +194,11 @@ StringRef riscv::getRISCVABI(const ArgList , const 
llvm::Triple ) {
 
   auto ParseResult = llvm::RISCVISAInfo::parseArchString(
   Arch, /* EnableExperimentalExtension */ true);
-  if (!ParseResult) {
+  if (!ParseResult)
 // Ignore parsing error, just go 3rd step.
 consumeError(ParseResult.takeError());
-  } else {
-auto  = *ParseResult;
-bool HasD = ISAInfo->hasExtension("d");
-unsigned XLen = ISAInfo->getXLen();
-if (XLen == 32) {
-  bool HasE = ISAInfo->hasExtension("e");
-  if (HasD)
-return "ilp32d";
-  if (HasE)
-return "ilp32e";
-  return "ilp32";
-} else if (XLen == 64) {
-  if (HasD)
-return "lp64d";
-  return "lp64";
-}
-llvm_unreachable("unhandled XLen");
-  }
+  else
+return llvm::RISCV::computeDefaultABIFromArch(**ParseResult);
 
   // 3. Choose a default based on the triple
   //

diff  --git a/clang/test/CodeGen/RISCV/riscv-metadata.c 
b/clang/test/CodeGen/RISCV/riscv-metadata.c
index 3e5b2b855bf5c..93b836e1f26cf 100644
--- a/clang/test/CodeGen/RISCV/riscv-metadata.c
+++ b/clang/test/CodeGen/RISCV/riscv-metadata.c
@@ -1,14 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck 
-check-prefix=EMPTY-ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -target-feature +f 
-target-feature +d -o - %s | FileCheck -check-prefix=EMPTY-ILP32D %s
 // RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-feature +f 
-target-abi ilp32d -emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck 
-check-prefix=EMPTY-LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-emit-llvm -o - %s | FileCheck -check-prefix=EMPTY-LP64D %s
 // RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-feature +f 
-target-abi lp64d -emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
 
+// Test expected behavior when giving -target-cpu
+// This cc1 test is similar to clang with -march=rv32ifd -mcpu=sifive-e31, 
default abi is ilp32d
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -target-feature +f 
-target-feature +d -target-cpu sifive-e31 -o - %s | FileCheck 
-check-prefix=EMPTY-ILP32D %s
+// This cc1 test is similar to clang with -march=rv64i -mcpu=sifive-u74, 
default abi is lp64
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -target-cpu sifive-u74 %s | 
FileCheck -check-prefix=EMPTY-LP64 %s
+
+// EMPTY-ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// EMPTY-ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 // ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
 // ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
 // ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 
+// EMPTY-LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// EMPTY-LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", 

Re: [PATCH] D108560: [clang-tidy] Add support for `NOLINTBEGIN` ... `NOLINTEND` comments

2021-12-10 Thread Yitzhak Mandelbaum via cfe-commits
Sounds good to me. Thanks for pushing on this!

On Wed, Dec 8, 2021 at 4:47 AM Salman Javed via Phabricator <
revi...@reviews.llvm.org> wrote:

> salman-javed-nz added a comment.
>
> Hi, just giving a progress update. This is just a early heads-up - no
> action needed from you at this stage.
>
> I have a rough prototype that seems promising. The big-O/time complexity
> is no longer dependent on the number of headers being included and the
> number of diagnostics being raised. I need to tidy up and refactor the code
> before sharing with you but to give an early indication of the path I'm
> taking, it's essentially:
>
>   struct NolintBlock {
> SourceLocation BeginLoc;
> SourceLocation EndLoc;
> std::string Checks;
>   };
>
>   // Need to keep a cache of every NOLINT block seen, not only in the
> current file
>   // but in any other file seen during this run of the program. We may be
> context
>   // switching between files (if there is a check violation in a macro in
> an
>   // #included file, for instance), and we don't want to be starting from
> scratch
>   // each time.
>   some_kind_of_map> NolintBlocks;
>   // Performance of each type of map class is still to be evaluated...
>
>   bool lineIsMarkedWithNOLINT(/* ... */) {
> // These two `if` statements will more or less be the same as they are
> now:
> //   If NOLINT statement found on this line, return true
> //   If NOLINTNEXTLINE statement found on previous line, return true
>
> // If no cache for the file exists, generate it (warning: heavy
> operation)
>
> // For NolintBlock in NolintBlocks[FileID]:
> //   if NolintBlock.StartLoc < Loc < NolintBlock.EndLoc:
> //  return true
> // Return false
>   }
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D108560/new/
>
> https://reviews.llvm.org/D108560
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 393513.
ymandel added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

renames the `testing` namespace to `test`

cleans up the code the implementation of `operator<<` for dataflow state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn

Index: llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
+++ llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
@@ -9,9 +9,15 @@
 "//clang/lib/Analysis/FlowSensitive",
 "//clang/lib/Basic",
 "//clang/lib/Frontend",
+"//clang/lib/Lex",
 "//clang/lib/Testing",
 "//clang/lib/Tooling",
 "//llvm/lib/Support",
+"//llvm/lib/Testing/Support",
+  ]
+  sources = [
+"TestingSupport.cpp",
+"TestingSupportTest.cpp",
+"TypeErasedDataflowAnalysisTest.cpp",
   ]
-  sources = [ "TypeErasedDataflowAnalysisTest.cpp" ]
 }
Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,178 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+std::ostream <<(std::ostream , const NoopLattice ) {
+  OS << "noop";
+  return OS;
+}
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext , T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto  : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto  = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+test::buildStatementToAnnotationMapping(Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap ) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  test::checkDataflow(
+  Code, Target,
+  [](ASTContext , Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  

[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. Great!


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

https://reviews.llvm.org/D115168

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


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-12-10 Thread Denys Petrov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a399bf4b3aa: [analyzer] Implemented 
RangeSet::Factory::unite function to handle… (authored by ASDenysPetrov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -35,12 +35,34 @@
   const RangeSet ) {
   return OS << toString(Set);
 }
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream <<(std::ostream ,
+  const Range ) {
+  return OS << toString(R);
+}
 
 } // namespace ento
 } // namespace clang
 
 namespace {
 
+template  struct TestValues {
+  static constexpr T MIN = std::numeric_limits::min();
+  static constexpr T MAX = std::numeric_limits::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).
+  static constexpr T MID =
+  std::is_signed::value ? 0 : ~(static_cast(-1) / static_cast(2));
+  static constexpr T A = MID - (MAX - MID) / 3 * 2;
+  static constexpr T B = MID - (MAX - MID) / 3;
+  static constexpr T C = -B;
+  static constexpr T D = -A;
+
+  static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
+"Values shall be in an ascending order");
+};
+
 template  class RangeSetTest : public testing::Test {
 public:
   // Init block
@@ -55,24 +77,11 @@
   using RawRange = std::pair;
   using RawRangeSet = std::initializer_list;
 
-  static constexpr BaseType getMin() {
-return std::numeric_limits::min();
-  }
-  static constexpr BaseType getMax() {
-return std::numeric_limits::max();
-  }
-  static constexpr BaseType getMid() {
-return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
-  }
-
-  static constexpr bool isSigned() { return std::is_signed::value; }
-  static constexpr BaseType fromInt(int X) { return static_cast(X); }
-
-  static llvm::APSInt Base;
   const llvm::APSInt (BaseType X) {
-llvm::APSInt Dummy = Base;
-Dummy = X;
-return BVF.getValue(Dummy);
+static llvm::APSInt Base{sizeof(BaseType) * CHAR_BIT,
+ std::is_unsigned::value};
+Base = X;
+return BVF.getValue(Base);
   }
 
   Range from(const RawRange ) {
@@ -160,7 +169,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -168,6 +177,29 @@
  RawExpected);
   }
 
+  template 
+  void checkUniteImpl(RangeSet LHS, RHSType RHS, RangeSet Expected) {
+RangeSet Result = F.unite(LHS, RHS);
+EXPECT_EQ(Result, Expected)
+<< "while uniting " << toString(LHS) << " and " << toString(RHS);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRange RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRangeSet RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, BaseType RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS,
+ RawExpected);
+  }
+
   void checkDeleteImpl(const llvm::APSInt , RangeSet From,
RangeSet Expected) {
 RangeSet Result = F.deletePoint(From, Point);
@@ -183,29 +215,19 @@
 
 } // namespace
 
-template 
-llvm::APSInt RangeSetTest::Base{sizeof(BaseType) * 8, !isSigned()};
-
 using IntTypes = ::testing::Types;
 TYPED_TEST_SUITE(RangeSetTest, IntTypes, );
 
 TYPED_TEST(RangeSetTest, RangeSetNegateTest) {
-  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-  constexpr TypeParam MIN = TestFixture::getMin();
-  constexpr TypeParam MAX = TestFixture::getMax();
-  // 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 TypeParam MID = TestFixture::getMid();
-  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
-  constexpr TypeParam B = MID - 

[clang] 6a399bf - [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-12-10 Thread Denys Petrov via cfe-commits

Author: Denys Petrov
Date: 2021-12-10T18:48:02+02:00
New Revision: 6a399bf4b3aa32a87fb04dd1deb05f0066810a05

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

LOG: [analyzer] Implemented RangeSet::Factory::unite function to handle 
intersections and adjacency

Summary: Handle intersected and adjacent ranges uniting them into a single one.
Example:
intersection [0, 10] U [5, 20] = [0, 20]
adjacency [0, 10] U [11, 20] = [0, 20]

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

Added: 


Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.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 a80484610131b..3a0bec9d04e57 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -140,6 +140,30 @@ class RangeSet {
 /// Complexity: O(N)
 /// where N = size(Original)
 RangeSet add(RangeSet Original, const llvm::APSInt );
+/// Create a new set which is a union of two given ranges.
+/// Possible intersections are not checked here.
+///
+/// Complexity: O(N + M)
+/// where N = size(LHS), M = size(RHS)
+RangeSet unite(RangeSet LHS, RangeSet RHS);
+/// Create a new set by uniting given range set with the given range.
+/// All intersections and adjacent ranges are handled here.
+///
+/// Complexity: O(N)
+/// where N = size(Original)
+RangeSet unite(RangeSet Original, Range Element);
+/// Create a new set by uniting given range set with the given point.
+/// All intersections and adjacent ranges are handled here.
+///
+/// Complexity: O(N)
+/// where N = size(Original)
+RangeSet unite(RangeSet Original, llvm::APSInt Point);
+/// Create a new set by uniting given range set with the given range
+/// between points. All intersections and adjacent ranges are handled here.
+///
+/// Complexity: O(N)
+/// where N = size(Original)
+RangeSet unite(RangeSet Original, llvm::APSInt From, llvm::APSInt To);
 
 RangeSet getEmptySet() { return  }
 
@@ -224,6 +248,9 @@ class RangeSet {
 ContainerType *construct(ContainerType &);
 
 RangeSet intersect(const ContainerType , const ContainerType );
+/// NOTE: This function relies on the fact that all values in the
+/// containers are persistent (created via BasicValueFactory::getValue).
+ContainerType unite(const ContainerType , const ContainerType );
 
 // Many operations include producing new APSInt values and that's why
 // we need this factory.

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 74403a160b8e0..4b0d4942e5287 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -110,6 +110,14 @@ class OperatorRelationsTable {
 
 RangeSet::ContainerType RangeSet::Factory::EmptySet{};
 
+RangeSet RangeSet::Factory::add(RangeSet LHS, RangeSet RHS) {
+  ContainerType Result;
+  Result.reserve(LHS.size() + RHS.size());
+  std::merge(LHS.begin(), LHS.end(), RHS.begin(), RHS.end(),
+ std::back_inserter(Result));
+  return makePersistent(std::move(Result));
+}
+
 RangeSet RangeSet::Factory::add(RangeSet Original, Range Element) {
   ContainerType Result;
   Result.reserve(Original.size() + 1);
@@ -126,6 +134,186 @@ RangeSet RangeSet::Factory::add(RangeSet Original, const 
llvm::APSInt ) {
   return add(Original, Range(Point));
 }
 
+RangeSet RangeSet::Factory::unite(RangeSet LHS, RangeSet RHS) {
+  ContainerType Result = unite(*LHS.Impl, *RHS.Impl);
+  return makePersistent(std::move(Result));
+}
+
+RangeSet RangeSet::Factory::unite(RangeSet Original, Range R) {
+  ContainerType Result;
+  Result.push_back(R);
+  Result = unite(*Original.Impl, Result);
+  return makePersistent(std::move(Result));
+}
+
+RangeSet RangeSet::Factory::unite(RangeSet Original, llvm::APSInt Point) {
+  return unite(Original, Range(ValueFactory.getValue(Point)));
+}
+
+RangeSet RangeSet::Factory::unite(RangeSet Original, llvm::APSInt From,
+  llvm::APSInt To) {
+  return unite(Original,
+   Range(ValueFactory.getValue(From), ValueFactory.getValue(To)));
+}
+
+template 
+void swapIterators(T , T , T , T ) {
+  std::swap(First, Second);
+  

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-12-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 393509.
ASDenysPetrov added a comment.

Fixed code formatting in the unit test file according to remarks. Ready to load.


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

https://reviews.llvm.org/D99797

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

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -35,12 +35,34 @@
   const RangeSet ) {
   return OS << toString(Set);
 }
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream <<(std::ostream ,
+  const Range ) {
+  return OS << toString(R);
+}
 
 } // namespace ento
 } // namespace clang
 
 namespace {
 
+template  struct TestValues {
+  static constexpr T MIN = std::numeric_limits::min();
+  static constexpr T MAX = std::numeric_limits::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).
+  static constexpr T MID =
+  std::is_signed::value ? 0 : ~(static_cast(-1) / static_cast(2));
+  static constexpr T A = MID - (MAX - MID) / 3 * 2;
+  static constexpr T B = MID - (MAX - MID) / 3;
+  static constexpr T C = -B;
+  static constexpr T D = -A;
+
+  static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
+"Values shall be in an ascending order");
+};
+
 template  class RangeSetTest : public testing::Test {
 public:
   // Init block
@@ -55,24 +77,11 @@
   using RawRange = std::pair;
   using RawRangeSet = std::initializer_list;
 
-  static constexpr BaseType getMin() {
-return std::numeric_limits::min();
-  }
-  static constexpr BaseType getMax() {
-return std::numeric_limits::max();
-  }
-  static constexpr BaseType getMid() {
-return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
-  }
-
-  static constexpr bool isSigned() { return std::is_signed::value; }
-  static constexpr BaseType fromInt(int X) { return static_cast(X); }
-
-  static llvm::APSInt Base;
   const llvm::APSInt (BaseType X) {
-llvm::APSInt Dummy = Base;
-Dummy = X;
-return BVF.getValue(Dummy);
+static llvm::APSInt Base{sizeof(BaseType) * CHAR_BIT,
+ std::is_unsigned::value};
+Base = X;
+return BVF.getValue(Base);
   }
 
   Range from(const RawRange ) {
@@ -160,7 +169,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -168,6 +177,29 @@
  RawExpected);
   }
 
+  template 
+  void checkUniteImpl(RangeSet LHS, RHSType RHS, RangeSet Expected) {
+RangeSet Result = F.unite(LHS, RHS);
+EXPECT_EQ(Result, Expected)
+<< "while uniting " << toString(LHS) << " and " << toString(RHS);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRange RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, RawRangeSet RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS, RawExpected);
+  }
+
+  void checkUnite(RawRangeSet RawLHS, BaseType RawRHS,
+  RawRangeSet RawExpected) {
+wrap(::checkUniteImpl, RawLHS, RawRHS,
+ RawExpected);
+  }
+
   void checkDeleteImpl(const llvm::APSInt , RangeSet From,
RangeSet Expected) {
 RangeSet Result = F.deletePoint(From, Point);
@@ -183,29 +215,19 @@
 
 } // namespace
 
-template 
-llvm::APSInt RangeSetTest::Base{sizeof(BaseType) * 8, !isSigned()};
-
 using IntTypes = ::testing::Types;
 TYPED_TEST_SUITE(RangeSetTest, IntTypes, );
 
 TYPED_TEST(RangeSetTest, RangeSetNegateTest) {
-  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-  constexpr TypeParam MIN = TestFixture::getMin();
-  constexpr TypeParam MAX = TestFixture::getMax();
-  // 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 TypeParam MID = TestFixture::getMid();
-  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
-  constexpr TypeParam B = MID - TestFixture::fromInt(42);
-  constexpr TypeParam C = -B;
-  constexpr TypeParam D = -A;
-
-  static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-"Values shall be in an ascending order");
+  using 

[PATCH] D115484: [clangd] Include-fixer: handle more "incomplete type" diags, clean up tests

2021-12-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeFixer.cpp:75
+  /*
+   There are many "incomplete type" diagnostics!
+   They are almost all Sema diagnostics with "incomplete" in the name.

have you considered updating these diagnostics to have "incomplete" as 
diagnostic category and do the filtering here based on that?



Comment at: clang-tools-extra/clangd/IncludeFixer.cpp:176
+  if (auto * ET = llvm::dyn_cast(T))
+if (ET->getDecl()->getDefinition() == nullptr)
+  return fixIncompleteType(*T);

nit: `if (!ET->...)`



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:842
 
-  ns::X $incomplete[[var]];
-  $tag[[ref_x]]->f();
-  $use[[ns::X()]];
-  $sizeof[[sizeof]](ns::X);
-  for (auto it : $for[[ref_x]]);
+  std::vector> Tests{
+  {"incomplete_nested_name_spec", "[[ns::X::]]Nested n;"},

thanks this one looks a lot better!

I just wonder if we should send it as a separate patch though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115484

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


[clang] 78ff12d - Revert "[clang][dataflow] Add framework for testing analyses."

2021-12-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-12-10T11:06:40-05:00
New Revision: 78ff12da1115abcaf4cbf50b605a197011505646

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

LOG: Revert "[clang][dataflow] Add framework for testing analyses."

Doesn't build on Windows.

This reverts commit 5a40df6381819b38df66e4b6eaa02e7140e07a0c
and commit db494bd4e815bc5546ee0986cb738da1a54bf6ab.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn

Removed: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp



diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 6193b9860d33a..55fae246da795 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -78,8 +78,7 @@ struct TypeErasedDataflowAnalysisState {
 
 /// Transfers the state of a basic block by evaluating each of its statements 
in
 /// the context of `Analysis` and the states of its predecessors that are
-/// available in `BlockStates`. `HandleTransferredStmt` (if provided) will be
-/// applied to each statement in the block, after it is evaluated.
+/// available in `BlockStates`.
 ///
 /// Requirements:
 ///
@@ -89,10 +88,7 @@ struct TypeErasedDataflowAnalysisState {
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ,
-std::function
-HandleTransferredStmt = nullptr);
+TypeErasedDataflowAnalysis );
 
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 413e8d14bf0a9..45afd59728e14 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -66,10 +66,7 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ,
-std::function
-HandleTransferredStmt) {
+TypeErasedDataflowAnalysis ) {
   TypeErasedDataflowAnalysisState State =
   computeBlockInputState(BlockStates, Block, InitEnv, Analysis);
   for (const CFGElement  : Block) {
@@ -82,8 +79,6 @@ TypeErasedDataflowAnalysisState transferBlock(
 
 State.Lattice = Analysis.transferTypeErased(Stmt.getValue().getStmt(),
 State.Lattice, State.Env);
-if (HandleTransferredStmt != nullptr)
-  HandleTransferredStmt(Stmt.getValue(), State);
   }
   return State;
 }

diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index 1388a224b3807..d6f38c9404abc 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -3,8 +3,6 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_unittest(ClangAnalysisFlowSensitiveTests
-  TestingSupport.cpp
-  TestingSupportTest.cpp
   TypeErasedDataflowAnalysisTest.cpp
   )
 
@@ -16,13 +14,8 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangASTMatchers
   clangBasic
   clangFrontend
-  clangLex
   clangSerialization
   clangTesting
   clangTooling
   )
 
-target_link_libraries(ClangAnalysisFlowSensitiveTests
-  PRIVATE
-  LLVMTestingSupport
-  )

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
deleted file mode 100644
index 2b08d949c1fa6..0
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-#include "TestingSupport.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Analysis/CFG.h"
-#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
-#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Basic/LLVM.h"
-#include "clang/Basic/LangOptions.h"
-#include 

[PATCH] D115523: [OpenCL] Set external linkage for block enqueue kernels

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

LGTM! I agree according to the OpenCL programming model attributes `internal 
spir_kernel` together on the same function create a contradiction because 
kernel functions are expected to have global visibility.

Adding @AlexeySachkov who has reported the same issue earlier elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115523

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


[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks building on Windows: 
http://45.33.8.238/win/50614/step_4.txt

Please take a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

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


[PATCH] D115346: [clang][deps] Squash caches for original and minimized files

2021-12-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked 3 inline comments as done.
jansvoboda11 added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:106-108
+  std::unique_ptr OriginalContents;
+  std::unique_ptr MinimizedContents;
   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;

dexonsmith wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > I'm finding it a bit subtle detecting if there are races on access / 
> > > setting of these, but I think it's correct.
> > > - I think I verified that they are "set once".
> > > - All the setters are guarded by locks.
> > > - The first getter per "local" cache is guarded by a lock.
> > > - Subsequent getters are not.
> > > 
> > > The key question: are the subsequent getters ONLY used when the first 
> > > getter was successful?
> > > 
> > > One way to make it more obvious:
> > > ```
> > > lang=c++
> > >   struct ContentWithPPRanges {
> > > std::unique_ptr Content;
> > > PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
> > >   };
> > > 
> > > private:
> > >   // Always accessed,mutated under a lock. Not mutated after they escape.
> > >   std::unique_ptr Original;
> > >   std::unique_ptr Minimized;
> > >   PreprocessorSkippedRangeMapping PPSkippedRangeMapping;
> > > 
> > >   // Used in getters. Pointed-at memory immutable after these are set.
> > >   std::atomic OriginalAccess;
> > >   std::atomic MinimizedAccess;
> > >   std::atomic PPRangesAccess;
> > > ```
> > > I don't think this is the only approach though.
> > > 
> > I think there are no races on the original contents. The pointer is 
> > unconditionally set on creation of `CachedFileSystemEntry` under a lock 
> > that no threads get past without having set the pointer (or failing and 
> > never accessing the pointer).
> > 
> > For minimized contents, the latest revision adds check at the beginning of 
> > the main function (`needsMinimization`) outside the critical section. There 
> > are three paths I can think of:
> > * The check returns `true` in thread A (pointer is `null`), thread A enters 
> > critical section, minimizes the contents and initializes the pointer.
> > * The check returns `true` in thread A, but thread B entered the critical 
> > section, minimized contents and initialized the pointer. When thread A 
> > enters the critical section, it performs the check again, figures that out 
> > and skips minimization.
> > * The check returns `false` and the local cache entry is returned.
> > 
> > So there definitely is a race here, but I believe it's benign. Do you 
> > agree? Do you think it's worth addressing?
> I don't trust myself to evaluate whether it's benign, but if there's no 
> atomic mutation, then I think it's possible that when the setter changes a 
> value from "x" to "y" then the racing reader can see a third value "z". You 
> might gain some confidence by using `-fsanitize=thread` on a workload that's 
> going to include this sort of thing -- probably hard to exercise: PCH already 
> exists, try minimizing something that uses the PCH, and then try minimizing 
> something that doesn't.
> 
> I'd rather just avoid the race entirely so we don't need to guess though.
Interesting...

After reading up on this a bit, my understanding is that reads of 
`MinimizedContents` cannot be torn, because it's pointers-sized and aligned. So 
we should never see a third value "z". Am I wrong?

The potential data race is IMO somewhat independent from the read tearing 
aspect and is avoided by defensively checking `MinimizedContents` again under 
lock.

To confirm, I ran the following test case with and without thread sanitizer, 
never seeing data races or incorrect results.

{F20978137}

I'm happy to use the `std::atomic` pattern you suggested, but I want to be sure 
I understand why that's necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115346

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


[PATCH] D115523: [OpenCL] Set external linkage for block enqueue kernels

2021-12-10 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, yaxunl.
svenvh added a project: clang.
Herald added a subscriber: ldrumm.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

All kernels can be called from the host as per the SPIR_KERNEL calling
convention.  As such, all kernels should have external linkage, but
block enqueue kernels were created with internal linkage.

Reported-by: Pedro Olsen Ferreira


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115523

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl


Index: clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -402,28 +402,28 @@
   size = get_kernel_sub_group_count_for_ndrange(ndrange, ^(){});
 }
 
-// COMMON: define internal spir_kernel void [[INVLK1]](i8 addrspace(4)* %0) 
#{{[0-9]+}} {
+// COMMON: define spir_kernel void [[INVLK1]](i8 addrspace(4)* %0) #{{[0-9]+}} 
{
 // COMMON: entry:
 // COMMON:  call spir_func void @__device_side_enqueue_block_invoke(i8 
addrspace(4)* %0)
 // COMMON:  ret void
 // COMMON: }
-// COMMON: define internal spir_kernel void [[INVLK2]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK1]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK2]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK3]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK4]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK5]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK6]](i8 addrspace(4)* %0, i8 
addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) #{{[0-9]+}} {
+// COMMON: define spir_kernel void [[INVLK2]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK1]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK2]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK3]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK4]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK5]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK6]](i8 addrspace(4)* %0, i8 
addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3) #{{[0-9]+}} {
 // COMMON: entry:
 // COMMON:  call spir_func void @__device_side_enqueue_block_invoke_9(i8 
addrspace(4)* %0, i8 addrspace(3)* %1, i8 addrspace(3)* %2, i8 addrspace(3)* %3)
 // COMMON:  ret void
 // COMMON: }
-// COMMON: define internal spir_kernel void [[INVGK7]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK7]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
 // COMMON: define internal spir_func void [[INVG8]](i8 addrspace(4)*{{.*}})
 // COMMON: define internal spir_func void [[INVG9]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)* %{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK8]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INV_G_K]](i8 
addrspace(4)*{{.*}}, i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVLK3]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK9]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK10]](i8 addrspace(4)*{{.*}})
-// COMMON: define internal spir_kernel void [[INVGK11]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK8]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INV_G_K]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVLK3]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK9]](i8 addrspace(4)*{{.*}}, i8 
addrspace(3)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK10]](i8 addrspace(4)*{{.*}})
+// COMMON: define spir_kernel void [[INVGK11]](i8 addrspace(4)*{{.*}})
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -11351,7 +11351,7 @@
   auto  = CGF.getLLVMContext();
   std::string Name = Invoke->getName().str() + "_kernel";
   auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);
-  auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, 
Name,
+  auto *F = llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, 
Name,
());
   auto IP = CGF.Builder.saveIP();
   auto *BB = 

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum 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 rG5a40df638181: [clang][dataflow] Add framework for testing 
analyses. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,179 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+std::ostream <<(std::ostream , const NoopLattice ) {
+  OS << "noop";
+  return OS;
+}
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext , T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto  : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto  = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap ) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext , Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+ 

[clang] 5a40df6 - [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2021-12-10T15:24:12Z
New Revision: 5a40df6381819b38df66e4b6eaa02e7140e07a0c

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

LOG: [clang][dataflow] Add framework for testing analyses.

Adds a general-purpose framework to support testing of dataflow analyses.

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

Added: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Modified: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 55fae246da795..6193b9860d33a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -78,7 +78,8 @@ struct TypeErasedDataflowAnalysisState {
 
 /// Transfers the state of a basic block by evaluating each of its statements 
in
 /// the context of `Analysis` and the states of its predecessors that are
-/// available in `BlockStates`.
+/// available in `BlockStates`. `HandleTransferredStmt` (if provided) will be
+/// applied to each statement in the block, after it is evaluated.
 ///
 /// Requirements:
 ///
@@ -88,7 +89,10 @@ struct TypeErasedDataflowAnalysisState {
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis );
+TypeErasedDataflowAnalysis ,
+std::function
+HandleTransferredStmt = nullptr);
 
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 45afd59728e14..413e8d14bf0a9 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -66,7 +66,10 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ) {
+TypeErasedDataflowAnalysis ,
+std::function
+HandleTransferredStmt) {
   TypeErasedDataflowAnalysisState State =
   computeBlockInputState(BlockStates, Block, InitEnv, Analysis);
   for (const CFGElement  : Block) {
@@ -79,6 +82,8 @@ TypeErasedDataflowAnalysisState transferBlock(
 
 State.Lattice = Analysis.transferTypeErased(Stmt.getValue().getStmt(),
 State.Lattice, State.Env);
+if (HandleTransferredStmt != nullptr)
+  HandleTransferredStmt(Stmt.getValue(), State);
   }
   return State;
 }

diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index d6f38c9404abc..1388a224b3807 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -3,6 +3,8 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_unittest(ClangAnalysisFlowSensitiveTests
+  TestingSupport.cpp
+  TestingSupportTest.cpp
   TypeErasedDataflowAnalysisTest.cpp
   )
 
@@ -14,8 +16,13 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangASTMatchers
   clangBasic
   clangFrontend
+  clangLex
   clangSerialization
   clangTesting
   clangTooling
   )
 
+target_link_libraries(ClangAnalysisFlowSensitiveTests
+  PRIVATE
+  LLVMTestingSupport
+  )

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
new file mode 100644
index 0..2b08d949c1fa6
--- /dev/null
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
@@ -0,0 +1,170 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Lexer.h"

[PATCH] D114703: [AArch64] Use Feature for A53 Erratum 835769 Fix

2021-12-10 Thread Sam Elliott via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52faad83c9f8: [AArch64] Use Feature for A53 Erratum 835769 
Fix (authored by lenary).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114703

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-fix-cortex-a53-835769.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/CodeGen/AArch64/O0-pipeline.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769.ll

Index: llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769.ll
===
--- llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769.ll
+++ llvm/test/CodeGen/AArch64/aarch64-fix-cortex-a53-835769.ll
@@ -3,9 +3,9 @@
 ; therefore, the tests are a bit fragile/reliant on instruction scheduling. The
 ; test cases have been minimized as much as possible, but still most of the test
 ; cases could break if instruction scheduling heuristics for cortex-a53 change
-; RUN: llc < %s -mcpu=cortex-a53 -aarch64-fix-cortex-a53-835769=1 -frame-pointer=non-leaf -stats 2>&1 \
+; RUN: llc < %s -mcpu=cortex-a53 -mattr=+fix-cortex-a53-835769 -frame-pointer=non-leaf -stats 2>&1 \
 ; RUN:  | FileCheck %s
-; RUN: llc < %s -mcpu=cortex-a53 -aarch64-fix-cortex-a53-835769=0 -frame-pointer=non-leaf -stats 2>&1 \
+; RUN: llc < %s -mcpu=cortex-a53 -mattr=-fix-cortex-a53-835769 -frame-pointer=non-leaf -stats 2>&1 \
 ; RUN:  | FileCheck %s --check-prefix CHECK-NOWORKAROUND
 ; The following run lines are just to verify whether or not this pass runs by
 ; default for given CPUs. Given the fragility of the tests, this is only run on
Index: llvm/test/CodeGen/AArch64/O3-pipeline.ll
===
--- llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -195,6 +195,7 @@
 ; CHECK-NEXT:   Insert XRay ops
 ; CHECK-NEXT:   Implement the 'patchable-function' attribute
 ; CHECK-NEXT:   AArch64 load / store optimization pass
+; CHECK-NEXT:   Workaround A53 erratum 835769 pass
 ; CHECK-NEXT:   AArch64 Branch Targets
 ; CHECK-NEXT:   Branch relaxation pass
 ; CHECK-NEXT:   AArch64 Compress Jump Tables
Index: llvm/test/CodeGen/AArch64/O0-pipeline.ll
===
--- llvm/test/CodeGen/AArch64/O0-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O0-pipeline.ll
@@ -60,6 +60,7 @@
 ; CHECK-NEXT:   Insert fentry calls
 ; CHECK-NEXT:   Insert XRay ops
 ; CHECK-NEXT:   Implement the 'patchable-function' attribute
+; CHECK-NEXT:   Workaround A53 erratum 835769 pass
 ; CHECK-NEXT:   AArch64 Branch Targets
 ; CHECK-NEXT:   Branch relaxation pass
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -116,11 +116,6 @@
   cl::desc("Enable the condition optimizer pass"),
   cl::init(true), cl::Hidden);
 
-static cl::opt
-EnableA53Fix835769("aarch64-fix-cortex-a53-835769", cl::Hidden,
-cl::desc("Work around Cortex-A53 erratum 835769"),
-cl::init(false));
-
 static cl::opt
 EnableGEPOpt("aarch64-enable-gep-opt", cl::Hidden,
  cl::desc("Enable optimizations on complex GEPs"),
@@ -764,8 +759,7 @@
   if (TM->getOptLevel() >= CodeGenOpt::Aggressive && EnableLoadStoreOpt)
 addPass(createAArch64LoadStoreOptimizationPass());
 
-  if (EnableA53Fix835769)
-addPass(createAArch64A53Fix835769());
+  addPass(createAArch64A53Fix835769());
 
   if (EnableBranchTargets)
 addPass(createAArch64BranchTargetsPass());
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -116,6 +116,8 @@
   bool HasFP16FML = false;
   bool HasSPE = false;
 
+  bool FixCortexA53_835769 = false;
+
   // ARMv8.1 extensions
   bool HasVH = false;
   bool HasPAN = false;
@@ -571,6 +573,8 @@
   bool hasEL2VMSA() const { return HasEL2VMSA; }
   bool hasEL3() const { return HasEL3; }
 
+  bool fixCortexA53_835769() const { return FixCortexA53_835769; }
+
   bool addrSinkUsingGEPs() const override {
 // Keeping GEPs inbounds is important for exploiting AArch64
 // addressing-modes in ILP32 mode.
Index: llvm/lib/Target/AArch64/AArch64A53Fix835769.cpp

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 393477.
ymandel added a comment.

Remove the SFINAE guard and add `operator<<` for `NoopLattice`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,179 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+std::ostream <<(std::ostream , const NoopLattice ) {
+  OS << "noop";
+  return OS;
+}
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext , T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto  : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto  = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap ) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext , Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+"target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, 

[PATCH] D115521: [Templight] Don't return string for name for unnamed template parameters

2021-12-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: sabel83, xazax.hun, rsmith, whisperity, martong, 
mikael-s-persson, mclow.lists.
Szelethus added a project: clang.
Herald added subscribers: steakhal, gamesh411, dkrupp, rnkovacs.
Szelethus requested review of this revision.
Herald added a subscriber: cfe-commits.

Patch by oktal3000 : 
https://github.com/mikael-s-persson/templight/pull/40

When a template parameter is unnamed, the `name` of `-templight-dump` might 
return an empty string. This is fine, they are unnamed after all, but it might 
be more user friendly to at least describe what entity is unnamed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115521

Files:
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Templight/templight-empty-entries-fix.cpp

Index: clang/test/Templight/templight-empty-entries-fix.cpp
===
--- /dev/null
+++ clang/test/Templight/templight-empty-entries-fix.cpp
@@ -0,0 +1,333 @@
+// RUN: %clang_cc1 -templight-dump -Wno-unused-value %s 2>&1 | FileCheck %s
+
+void a() {
+  [] {};
+}
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'lambda at .*templight-empty-entries-fix.cpp:4:3'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:4:3'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:4:3'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'lambda at .*templight-empty-entries-fix.cpp:4:3'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:4:3'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:4:3'$}}
+
+template  void a() { a(); }
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+a$}}
+// CHECK: {{^kind:[ ]+DeducedTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:31'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+unnamed template non-type parameter 0 of a$}}
+// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:15'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+unnamed template non-type parameter 0 of a$}}
+// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:15'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+a$}}
+// CHECK: {{^kind:[ ]+DeducedTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:31'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'a<0>'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:31'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'a<0>'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:20:25'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:20:31'$}}
+
+template  struct b { typedef int c; };
+template ::c> void a() { a(); }
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+a$}}
+// CHECK: {{^kind:[ ]+DeducedTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:60:57'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:60:63'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+d$}}
+// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:60:16'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:60:57'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+d$}}
+// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:60:16'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:60:57'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+unnamed template type parameter 1 of a$}}
+// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ ]+'.*templight-empty-entries-fix.cpp:60:32'$}}
+// CHECK: {{^poi:[ ]+'.*templight-empty-entries-fix.cpp:60:57'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'b<1>'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^orig:[ 

[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 393474.
MyDeveloperDay added a comment.

Thank @HazardyKnusperkeks  you got me over the line, I was able to escape the 
`[` but not the `]` so I used your trick there

  "R\"(([\\[A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]|])*)\\("

Add unit tests to cover those cases too


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

https://reviews.llvm.org/D115168

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -1045,6 +1045,153 @@
   EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
 }
 
+TEST_F(SortIncludesTest, DisableRawStringLiteralSorting) {
+
+  EXPECT_EQ("const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";",
+sort("const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";",
+sort("const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";",
+sort("const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";\n"
+"#include \n"
+"#include ",
+sort("#include \n"
+ "#include \n"
+ "const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";\n"
+ "#include \n"
+ "#include ",
+ "test.cc", 4));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz\";",
+sort("const char *t = R\"AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"-AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")-AMZ029amz\";",
+sort("const char *t = R\"-AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")-AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz-(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz-\";",
+sort("const char *t = R\"AMZ029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz-\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AM|029amz-(\n"
+"#include \n"
+"#include \n"
+")AM|029amz-\";",
+sort("const char *t = R\"AM|029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AM|029amz-\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AM[029amz-(\n"
+"#include \n"
+"#include \n"
+")AM[029amz-\";",
+sort("const char *t = R\"AM[029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AM[029amz-\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AM]029amz-(\n"
+"#include \n"
+"#include \n"
+")AM]029amz-\";",
+sort("const char *t = R\"AM]029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AM]029amz-\";",
+ "test.cxx", 0));
+
+#define X "AMZ029amz{}+!%*=_:;',.<>|/?#~-$"
+
+  EXPECT_EQ("const char *t 

[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-12-10 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Assuming this patch is ready to land. @yaxunl, Could you please commit this 
patch to the LLVM for us. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D115243: [clangd] Extend SymbolOrigin, stop serializing it

2021-12-10 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!

---

> The problem is these methods yield SymbolSlabs, and the symbols within them 
> are frozen/const. There's no provision to "just tweak some bitfield" - we'd 
> have to copy the whole slab.

Yes and no. As mentioned SymbolSlabs are frozen once created and I totally 
agree with the reasons there. But AFAICT in none of the indexes (apart from 
monolithic FileIndex) we ever have a single SymbolSlab.
We always have multiple of those and periodically build a single slab out of 
them, by copying/merging each symbol so that we can build a SymbolIndex on top 
of the final merged SymbolSlab. I was suggesting to perform ultimate Origin 
tweaking there (we can even respect the Origins of each individual slabs too).

Couple reasons:

- Definitely less plumbing, we just let FileSymbol now what it should be called 
during construction. Background/RemoteIndex already has this knowledge hard 
coded.
- In theory those indexes that operate on top of a multiple SymbolSlabs should 
be inserting their own "origin" into the final merged slab as it contains some 
extra logic, just like MergeIndex.

Downside is the possible discrepancy between the invocation of SymbolCollector 
and the serving of the SymbolSlab acquired from it.
The discrepancy is only possible when we serialize/deserialize the slab between 
collection and serving, I'd say in those cases the symbol origin should just be 
Static (and the server should add any extra semantics).

No matter where we do the "overriding" this discrepancy will become an issue 
today anyways, the consumer of the serialized slabs needs to overwrite them.
I just feel like keeping that semantic to `FileSymbol`/`Background/RemoteIndex` 
isolates the logic better.

---

I don't feel too strongly about it though, feel free to roll with this version 
if you don't think that isolation is worth the changes.




Comment at: clang-tools-extra/clangd/index/SymbolOrigin.h:26
+  Static = 1 << 2, // From a static, externally-built index.
   Merge = 1 << 3,  // A non-trivial index merge was performed.
   Identifier = 1 << 4, // Raw identifiers in file.

sammccall wrote:
> kadircet wrote:
> > do we think this still provides a meaningful signal ?
> > It only provides value only when multiple indices of same type was involved 
> > in providing the result (and only that single type of indices). I suppose 
> > after this patch it can only happen for `SM` (as there are certain 
> > remote-index implementations that mark themselves as static) or `RM` (well 
> > this is not possible today, but some day we might have a stack of 
> > remote-indices).
> > As soon as there's a different type of index is involved `M` no longer has 
> > any meanings, as it's clear that there was some sort of merge happening (or 
> > am I missing something obvious?)
> > 
> > ---
> > 
> > Before this patch situation is a little bit different since `FileIndex` 
> > just said `D` for both main file and preamble, but that's changing.
> Hmm, we can also get M when merging happens at indexing time due to multiple 
> visits of the same symbol (`DuplicateHandling::Merge`, which is used by 
> background indexing).
> 
> I don't have a strong opinion on its usefulness though. IIRC we added it (and 
> origins) when trying to understand the paths various symbols took through 
> indexes. As a debugging tool some redundancy maybe has some sanity-check 
> value, but we could also drop it.
> 
> I don't think it has so much to do with this patch (unless you think we 
> should reuse the bit instead of expanding to 16)...
> 
> > Before this patch situation is a little bit different since FileIndex just 
> > said D for both main file and preamble
> 
> ...it makes sense that this could have been a reason for the flag, but I 
> don't think it actually was :-)
> I don't think it has so much to do with this patch (unless you think we 
> should reuse the bit instead of expanding to 16)...

Nope it isn't directly related to this patch (also, we soon plan to introduce 
the stdlib kind here, so doesn't really let us get back to 8).
Mostly checking if we can get rid of it and some code governing it.

> Hmm, we can also get M when merging happens at indexing time due to multiple 
> visits of the same symbol (DuplicateHandling::Merge, which is used by 
> background indexing).
> I don't have a strong opinion on its usefulness though. IIRC we added it (and 
> origins) when trying to understand the paths various symbols took through 
> indexes. As a debugging tool some redundancy maybe has some sanity-check 
> value, but we could also drop it.

I see, yeah I am not sure about its usefulness either, sounds like there might 
still be rare cases this provides value (like debugging some behaviour in 
background index).
Thanks for the thoughts, definitely no action needed here.


Repository:
  rG LLVM Github 

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:47-48
+template ()
+  << std::declval())>
+std::ostream <<(std::ostream ,

This SFINAE guard doesn't work on some platforms, as evidenced by the many 
buildbot failures after commit.

Any suggestions for 
1) what's wrong
2) how to configure my local build to replicate the breakage
would be appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

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


[clang] 28d3976 - Revert "[clang][dataflow] Add framework for testing analyses."

2021-12-10 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2021-12-10T14:27:15Z
New Revision: 28d3976819c9d0921c6118c3f8fee9297380ddae

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

LOG: Revert "[clang][dataflow] Add framework for testing analyses."

This reverts commit 47d526d67e3cc66771eed1d0b607226a4fb9a5b5.

The commit is failing to build on some platforms. Rolling back while we 
investigate.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Removed: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp



diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 6193b9860d33a..55fae246da795 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -78,8 +78,7 @@ struct TypeErasedDataflowAnalysisState {
 
 /// Transfers the state of a basic block by evaluating each of its statements 
in
 /// the context of `Analysis` and the states of its predecessors that are
-/// available in `BlockStates`. `HandleTransferredStmt` (if provided) will be
-/// applied to each statement in the block, after it is evaluated.
+/// available in `BlockStates`.
 ///
 /// Requirements:
 ///
@@ -89,10 +88,7 @@ struct TypeErasedDataflowAnalysisState {
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ,
-std::function
-HandleTransferredStmt = nullptr);
+TypeErasedDataflowAnalysis );
 
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 413e8d14bf0a9..45afd59728e14 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -66,10 +66,7 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ,
-std::function
-HandleTransferredStmt) {
+TypeErasedDataflowAnalysis ) {
   TypeErasedDataflowAnalysisState State =
   computeBlockInputState(BlockStates, Block, InitEnv, Analysis);
   for (const CFGElement  : Block) {
@@ -82,8 +79,6 @@ TypeErasedDataflowAnalysisState transferBlock(
 
 State.Lattice = Analysis.transferTypeErased(Stmt.getValue().getStmt(),
 State.Lattice, State.Env);
-if (HandleTransferredStmt != nullptr)
-  HandleTransferredStmt(Stmt.getValue(), State);
   }
   return State;
 }

diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index 1388a224b3807..d6f38c9404abc 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -3,8 +3,6 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_unittest(ClangAnalysisFlowSensitiveTests
-  TestingSupport.cpp
-  TestingSupportTest.cpp
   TypeErasedDataflowAnalysisTest.cpp
   )
 
@@ -16,13 +14,8 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangASTMatchers
   clangBasic
   clangFrontend
-  clangLex
   clangSerialization
   clangTesting
   clangTooling
   )
 
-target_link_libraries(ClangAnalysisFlowSensitiveTests
-  PRIVATE
-  LLVMTestingSupport
-  )

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
deleted file mode 100644
index 2b08d949c1fa6..0
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-#include "TestingSupport.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Analysis/CFG.h"
-#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
-#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Basic/LLVM.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TokenKinds.h"

[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2021-12-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D114639#3183244 , @Meinersbur 
wrote:

> ping?
>
> @erichkeane Since you are pushing for upgrade the gcc/clang requirement as 
> well, would you take care of that?

I was looking into the patch to do so, but I don't have a good idea what I 
should update the GCC/Clang/AppleClang requirements TO.  I thought I saw 
someone at one point suggest GCC6/clang6, but I can't find that anymore, did I 
just imagine it?

I presume any such patch would have similar issues with buildbots unfortunately.

That said;
My understanding is that updating the GCC/Clang minimum versions requires 
altering our 'minimum platform' significantly (since you cannot ship a 
dynamically linked version of clang to a system with an older stdlibc++ version 
than you built it with), and thus would be more controversial than this patch 
(where updating the C++ runtime version on a system is a much lower barrier to 
run).

Because of that, and because my concern on the RFC seems to be mine alone, I 
see no reason to have my concerns 'block' this patch as it is. Additionally, 
since the RFC to move us to C++17 didn't seem to gain any traction, I'd presume 
the appetite for changing the linux/apple toolchain doesn't seem to be there.

TL;DR: Don't block this on my concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

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

In D115168#3185199 , @MyDeveloperDay 
wrote:

> Add support for | but still can't get [] to work in the regex (checked the 
> unit tests for Support/Regex and its not clear if its supported)

How about `"R\"(([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]|]|\[)*)\\("`, not 
putting the [] symbols within the [].

Does it work with std::regex which should also be available?


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

https://reviews.llvm.org/D115168

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


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-12-10 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 393465.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/lib/Driver/ToolChains/HIPUtility.cpp
  clang/lib/Driver/ToolChains/HIPUtility.h

Index: clang/lib/Driver/ToolChains/HIPUtility.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPUtility.h
@@ -0,0 +1,35 @@
+//===--- HIPUtility.h - Common HIP Tool Chain Utilities -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
+
+#include "clang/Driver/Tool.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace HIP {
+
+// Construct command for creating HIP fatbin.
+void constructHIPFatbinCommand(Compilation , const JobAction ,
+   StringRef OutputFileName,
+   const InputInfoList ,
+   const llvm::opt::ArgList , const Tool );
+
+// Construct command for creating Object from HIP fatbin.
+void constructGenerateObjFileFromHIPFatBinary(
+Compilation , const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList , const JobAction , const Tool );
+
+} // namespace HIP
+} // namespace tools
+} // namespace driver
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
Index: clang/lib/Driver/ToolChains/HIPUtility.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -0,0 +1,166 @@
+//===--- HIPUtility.cpp - Common HIP Tool Chain Utilities ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "HIPUtility.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver;
+using namespace clang::driver::tools;
+using namespace llvm::opt;
+
+#if defined(_WIN32) || defined(_WIN64)
+#define NULL_FILE "nul"
+#else
+#define NULL_FILE "/dev/null"
+#endif
+
+namespace {
+const unsigned HIPCodeObjectAlign = 4096;
+} // namespace
+
+// Constructs a triple string for clang offload bundler.
+static std::string normalizeForBundler(const llvm::Triple ,
+   bool HasTargetID) {
+  return HasTargetID ? (T.getArchName() + "-" + T.getVendorName() + "-" +
+T.getOSName() + "-" + T.getEnvironmentName())
+   .str()
+ : T.normalize();
+}
+
+// Construct a clang-offload-bundler command to bundle code objects for
+// different devices into a HIP fat binary.
+void HIP::constructHIPFatbinCommand(Compilation , const JobAction ,
+StringRef OutputFileName,
+const InputInfoList ,
+const llvm::opt::ArgList ,
+const Tool ) {
+  // Construct clang-offload-bundler command to bundle object files for
+  // for different GPU archs.
+  ArgStringList BundlerArgs;
+  BundlerArgs.push_back(Args.MakeArgString("-type=o"));
+  BundlerArgs.push_back(
+  Args.MakeArgString("-bundle-align=" + Twine(HIPCodeObjectAlign)));
+
+  // ToDo: Remove the dummy host binary entry which is required by
+  // clang-offload-bundler.
+  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
+  std::string BundlerInputArg = "-inputs=" NULL_FILE;
+
+  // AMDGCN:
+  // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
+  // for backward compatibility. For code object version 4 and greater, the
+  // offload kind in bundle ID is 'hipv4'.
+  std::string OffloadKind = "hip";
+  auto  = T.getToolChain().getTriple();
+  if (TT.isAMDGCN() && getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+OffloadKind = OffloadKind + "v4";
+  for (const auto  : Inputs) {
+const auto *A = II.getAction();
+auto ArchStr = StringRef(A->getOffloadingArch());
+

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum 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 rG47d526d67e3c: [clang][dataflow] Add framework for testing 
analyses. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,174 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext , T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto  : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto  = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap ) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext , Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+"target", Expectations.AsStdFunction());
+}
+

[clang] 47d526d - [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2021-12-10T14:00:36Z
New Revision: 47d526d67e3cc66771eed1d0b607226a4fb9a5b5

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

LOG: [clang][dataflow] Add framework for testing analyses.

Adds a general-purpose framework to support testing of dataflow analyses.

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

Added: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Modified: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 55fae246da795..6193b9860d33a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -78,7 +78,8 @@ struct TypeErasedDataflowAnalysisState {
 
 /// Transfers the state of a basic block by evaluating each of its statements 
in
 /// the context of `Analysis` and the states of its predecessors that are
-/// available in `BlockStates`.
+/// available in `BlockStates`. `HandleTransferredStmt` (if provided) will be
+/// applied to each statement in the block, after it is evaluated.
 ///
 /// Requirements:
 ///
@@ -88,7 +89,10 @@ struct TypeErasedDataflowAnalysisState {
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis );
+TypeErasedDataflowAnalysis ,
+std::function
+HandleTransferredStmt = nullptr);
 
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 45afd59728e14..413e8d14bf0a9 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -66,7 +66,10 @@ static TypeErasedDataflowAnalysisState 
computeBlockInputState(
 TypeErasedDataflowAnalysisState transferBlock(
 std::vector> ,
 const CFGBlock , const Environment ,
-TypeErasedDataflowAnalysis ) {
+TypeErasedDataflowAnalysis ,
+std::function
+HandleTransferredStmt) {
   TypeErasedDataflowAnalysisState State =
   computeBlockInputState(BlockStates, Block, InitEnv, Analysis);
   for (const CFGElement  : Block) {
@@ -79,6 +82,8 @@ TypeErasedDataflowAnalysisState transferBlock(
 
 State.Lattice = Analysis.transferTypeErased(Stmt.getValue().getStmt(),
 State.Lattice, State.Env);
+if (HandleTransferredStmt != nullptr)
+  HandleTransferredStmt(Stmt.getValue(), State);
   }
   return State;
 }

diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index d6f38c9404abc..1388a224b3807 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -3,6 +3,8 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_clang_unittest(ClangAnalysisFlowSensitiveTests
+  TestingSupport.cpp
+  TestingSupportTest.cpp
   TypeErasedDataflowAnalysisTest.cpp
   )
 
@@ -14,8 +16,13 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangASTMatchers
   clangBasic
   clangFrontend
+  clangLex
   clangSerialization
   clangTesting
   clangTooling
   )
 
+target_link_libraries(ClangAnalysisFlowSensitiveTests
+  PRIVATE
+  LLVMTestingSupport
+  )

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
new file mode 100644
index 0..2b08d949c1fa6
--- /dev/null
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
@@ -0,0 +1,170 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Lexer.h"

[PATCH] D115341: [clang][dataflow] Add framework for testing analyses.

2021-12-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 393460.
ymandel added a comment.

add missing build dependency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115341

Files:
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -0,0 +1,174 @@
+#include "TestingSupport.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace dataflow;
+
+namespace {
+
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::isDefinition;
+using ::testing::_;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+template 
+const FunctionDecl *findTargetFunc(ASTContext , T FunctionMatcher) {
+  auto TargetMatcher =
+  functionDecl(FunctionMatcher, isDefinition()).bind("target");
+  for (const auto  : ast_matchers::match(TargetMatcher, Context)) {
+const auto *Func = Node.template getNodeAs("target");
+if (Func == nullptr)
+  continue;
+if (Func->isTemplated())
+  continue;
+return Func;
+  }
+  return nullptr;
+}
+
+class BuildStatementToAnnotationMappingTest : public ::testing::Test {
+public:
+  void
+  runTest(llvm::StringRef Code, llvm::StringRef TargetName,
+  std::function &)>
+  RunChecks) {
+llvm::Annotations AnnotatedCode(Code);
+auto Unit = tooling::buildASTFromCodeWithArgs(
+AnnotatedCode.code(), {"-fsyntax-only", "-std=c++17"});
+auto  = Unit->getASTContext();
+const FunctionDecl *Func = findTargetFunc(Context, hasName(TargetName));
+ASSERT_NE(Func, nullptr);
+
+llvm::Expected> Mapping =
+clang::dataflow::testing::buildStatementToAnnotationMapping(
+Func, AnnotatedCode);
+ASSERT_TRUE(static_cast(Mapping));
+
+RunChecks(Mapping.get());
+  }
+};
+
+TEST_F(BuildStatementToAnnotationMappingTest, ReturnStmt) {
+  runTest(R"(
+int target() {
+  return 42;
+  /*[[ok]]*/
+}
+  )",
+  "target",
+  [](const llvm::DenseMap ) {
+ASSERT_EQ(Annotations.size(), static_cast(1));
+EXPECT_TRUE(isa(Annotations.begin()->first));
+EXPECT_EQ(Annotations.begin()->second, "ok");
+  });
+}
+
+void checkDataflow(
+llvm::StringRef Code, llvm::StringRef Target,
+std::function>>,
+   ASTContext &)>
+Expectations) {
+  clang::dataflow::testing::checkDataflow(
+  Code, Target,
+  [](ASTContext , Environment &) { return NoopAnalysis(Context); },
+  std::move(Expectations), {"-fsyntax-only", "-std=c++17"});
+}
+
+TEST(ProgramPointAnnotations, NoAnnotations) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void target() {}", "target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, NoAnnotationsDifferentTarget) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations, Call(IsEmpty(), _)).Times(1);
+
+  checkDataflow("void fun() {}", "fun", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, WithCodepoint) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  Call(UnorderedElementsAre(Pair("program-point", _)), _))
+  .Times(1);
+
+  checkDataflow(R"cc(void target() {
+ int n;
+ // [[program-point]]
+   })cc",
+"target", Expectations.AsStdFunction());
+}
+
+TEST(ProgramPointAnnotations, MultipleCodepoints) {
+  ::testing::MockFunction>>,
+  ASTContext &)>
+  Expectations;
+
+  EXPECT_CALL(Expectations,
+  

[PATCH] D115355: Fix build failure with GCC 11 in C++20 mode

2021-12-10 Thread Evgeny Mandrikov via Phabricator via cfe-commits
Godin added a comment.

Thank you for the review @shafik !

As a note: this change is similar to the 
https://reviews.llvm.org/rG95d0d8e9e9d10da3cfa503fbba405e740aea3cc1 by @rsmith


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115355

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


[PATCH] D115501: [clang][ARM] Emit warnings when PACBTI-M is used with unsupported architectures

2021-12-10 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added inline comments.



Comment at: clang/lib/Basic/Targets/ARM.cpp:372
+  if (Arch.empty())
+return true;
+

I'd play safe and return false here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115501

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


[clang] 77e9d36 - [clang][dataflow] Fix build breakage from commit 8dcaf3aa0bf25508700a7452ed963c1487221dfd

2021-12-10 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2021-12-10T12:55:48Z
New Revision: 77e9d36a785ab12f3840c522fd357575929df92c

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

LOG: [clang][dataflow] Fix build breakage from commit 
8dcaf3aa0bf25508700a7452ed963c1487221dfd

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
index d463e31bea3b..d6f38c9404ab 100644
--- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
@@ -14,6 +14,7 @@ clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
   clangASTMatchers
   clangBasic
   clangFrontend
+  clangSerialization
   clangTesting
   clangTooling
   )



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


[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-12-10 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

@mib Can you help me reproduce? I ran

  cmake -G Ninja .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
-DCMAKE_INSTALL_PREFIX="$HOME/tmp/out" 
-DLLDB_TEST_USER_ARGS="--arch;x86_64;--build-dir;$HOME/tmp/out/lldb-test-build.noindex;-t;--env;TERM=vt100"
 '-DLLDB_ENABLE_PYTHON=On' '-DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE' 
'-DLLVM_ENABLE_MODULES=On' 
'-DLLVM_ENABLE_PROJECTS=clang;libcxx;libcxxabi;compiler-rt;lld;lldb;cross-project-tests'
 "-DLLVM_LIT_ARGS=-v --time-tests --shuffle 
--xunit-xml-output=$HOME/tmp/test/results.xml" '-DLLVM_VERSION_PATCH=99' 
'-DCMAKE_C_FLAGS=-Wdocumentation' '-DCMAKE_CXX_FLAGS=-Wdocumentation'

on ssh'd to a macOS machine with perhaps fewer SDKs installed, and where the 
failure occurred I got:

  -- Clang version: 14.0.99
  -- Host linker version: 530
  # (error was here)
  -- Not building amdgpu-arch: hsa-runtime64 not found
  -- LLD version: 14.0.99
  -- Enable editline support in LLDB: TRUE
  -- Enable curses support in LLDB: TRUE


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 393448.
MyDeveloperDay added a comment.

Add support for | but still can't get [] to work in the regex (checked the unit 
tests for Support/Regex and its not clear if its supported)


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

https://reviews.llvm.org/D115168

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -1045,6 +1045,133 @@
   EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
 }
 
+TEST_F(SortIncludesTest, DisableRawStringLiteralSorting) {
+
+  EXPECT_EQ("const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";",
+sort("const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";",
+sort("const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";",
+ "test.cxx", 0));
+  EXPECT_EQ("const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";",
+sort("const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"x(\n"
+"#include \n"
+"#include \n"
+")x\";\n"
+"#include \n"
+"#include \n"
+"const char *t = R\"xyz(\n"
+"#include \n"
+"#include \n"
+")xyz\";\n"
+"#include \n"
+"#include ",
+sort("#include \n"
+ "#include \n"
+ "const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"x(\n"
+ "#include \n"
+ "#include \n"
+ ")x\";\n"
+ "#include \n"
+ "#include \n"
+ "const char *t = R\"xyz(\n"
+ "#include \n"
+ "#include \n"
+ ")xyz\";\n"
+ "#include \n"
+ "#include ",
+ "test.cc", 4));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz\";",
+sort("const char *t = R\"AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"-AMZ029amz(\n"
+"#include \n"
+"#include \n"
+")-AMZ029amz\";",
+sort("const char *t = R\"-AMZ029amz(\n"
+ "#include \n"
+ "#include \n"
+ ")-AMZ029amz\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AMZ029amz-(\n"
+"#include \n"
+"#include \n"
+")AMZ029amz-\";",
+sort("const char *t = R\"AMZ029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AMZ029amz-\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("const char *t = R\"AM|029amz-(\n"
+"#include \n"
+"#include \n"
+")AM|029amz-\";",
+sort("const char *t = R\"AM|029amz-(\n"
+ "#include \n"
+ "#include \n"
+ ")AM|029amz-\";",
+ "test.cxx", 0));
+
+#define X "AMZ029amz{}+!%*=_:;',.<>|/?#~-$"
+
+  EXPECT_EQ("const char *t = R\"" X "(\n"
+"#include \n"
+"#include \n"
+")" X "\";",
+sort("const char *t = R\"" X "(\n"
+ "#include \n"
+ "#include \n"
+ ")" X "\";",
+ "test.cxx", 0));
+
+#undef X
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2586,12 +2586,31 @@
   bool MainIncludeFound = false;
   bool FormattingOff = false;
 
+  llvm::Regex RawStringRegex(
+  "R\"([A-Za-z0-9_{}#<>%:;.?*+/^&\\$|~!=,'\\-]*)\\(");
+  SmallVector 

[PATCH] D115235: [clang][dataflow] Implement a basic algorithm for dataflow analysis

2021-12-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/CMakeLists.txt:1
+set(LLVM_LINK_COMPONENTS
+  Support

sgatev wrote:
> ymandel wrote:
> > Why create a new sub directory? From what I've seen elsewhere, it seems 
> > uncommon. I'm fine either way, but want to be sure we have a good reason 
> > for differing.
> I created the directory to match the structure in 
> llvm-project/clang/include/clang/Analysis/FlowSensitive and 
> llvm-project/clang/lib/Analysis/FlowSensitive. In general, I think it'd be 
> easier to find related code if it's structured similarly. If this doesn't 
> follow the established practices for the project I'd be happy to change it.
I'm also confused by this.

Would this work:

```
% git diff
diff --git a/clang/lib/Analysis/CMakeLists.txt 
b/clang/lib/Analysis/CMakeLists.txt
index 16e3f474060c..eec02b31a9a8 100644
--- a/clang/lib/Analysis/CMakeLists.txt
+++ b/clang/lib/Analysis/CMakeLists.txt
@@ -18,6 +18,7 @@ add_clang_library(clangAnalysis
   CodeInjector.cpp
   Dominators.cpp
   ExprMutationAnalyzer.cpp
+  FlowSensitive/TypeErasedDataflowAnalysis.cpp
   IssueHash.cpp
   LiveVariables.cpp
   MacroExpansionContext.cpp
@@ -44,4 +45,3 @@ add_clang_library(clangAnalysis
   )

 add_subdirectory(plugins)
-add_subdirectory(FlowSensitive)
diff --git a/clang/unittests/Analysis/CMakeLists.txt 
b/clang/unittests/Analysis/CMakeLists.txt
index 7e2a00b96057..f1cb402268c0 100644
--- a/clang/unittests/Analysis/CMakeLists.txt
+++ b/clang/unittests/Analysis/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_unittest(ClangAnalysisTests
   CFGTest.cpp
   CloneDetectionTest.cpp
   ExprMutationAnalyzerTest.cpp
+  FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
   MacroExpansionContextTest.cpp
   )
```

Or do the flow-sensitive analyses have different library dependencies and there 
are places that want to depend on analysis without the flow sensitive bits or 
the other way round?

(Why are these files in a subdirectory at all?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115235

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


[PATCH] D115510: [clang][OpenMP][DebugInfo] Debug support for variables in shared clause of OpenMP task construct

2021-12-10 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok created this revision.
alok added reviewers: aprantl, djtodoro, jdoerfert, jini.susan.george.
alok added a project: debug-info.
Herald added subscribers: guansong, yaxunl.
alok requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Currently variables appearing inside shared clause of OpenMP task construct are 
not visible inside lldb debugger.
This is because compiler does not generate debug info for it.

  * thread #1, name = 'a.out', stop reason = breakpoint 1.1
  frame #0: 0x00400934 a.out`.omp_task_entry. [inlined] 
.omp_outlined.(.global_tid.=0, .part_id.=0x0071f0d0, 
.privates.=0x0071f0e8, .copy_fn.=(a.out`.omp_task_privates_map. at 
testshared.cxx:8), .task_t.=0x0071f0c0, __context=0x0071f0f0) 
at testshared.cxx:10:34
 7  else {
 8#pragma omp task shared(svar) firstprivate(n)
 9{
  -> 10 printf("Task svar = %d\n", svar);
 11 printf("Task n = %d\n", n);
 12 svar = fib(n - 1);
 13   }
  (lldb) p svar
  error: :1:1: use of undeclared identifier 'svar'
  svar
  ^
  (lldb)

After the current patch, lldb is able to show the variable

  * thread #1, name = 'a.out', stop reason = breakpoint 1.1
  frame #0: 0x00400934 a.out`.omp_task_entry. [inlined] 
.omp_outlined.(.global_tid.=0, .part_id.=0x0071f0d0, 
.privates.=0x0071f0e8, .copy_fn.=(a.out`.omp_task_privates_map. at 
testshared.cxx:8), .task_t.=0x0071f0c0, __context=0x0071f0f0) 
at testshared.cxx:10:34
 7  else {
 8#pragma omp task shared(svar) firstprivate(n)
 9{
  -> 10 printf("Task svar = %d\n", svar);
 11 printf("Task n = %d\n", n);
 12 svar = fib(n - 1);
 13   }
  (lldb) p svar
  (int) $0 = 9
  (lldb)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115510

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/debug_task_shared.c

Index: clang/test/OpenMP/debug_task_shared.c
===
--- /dev/null
+++ clang/test/OpenMP/debug_task_shared.c
@@ -0,0 +1,55 @@
+// This testcase checks emission of debug info for variables
+// inside shared clause of task construct.
+
+// REQUIRES: x86_64-linux
+
+// RUN: %clang_cc1 -debug-info-kind=constructor -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
+// expected-no-diagnostics
+
+// CHECK-LABEL: define internal i32 @.omp_task_entry.
+
+// CHECK-DAG:  [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE2:![0-9]+]], metadata !DIExpression(DW_OP_deref))
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE3:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref))
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE1:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_deref))
+
+// CHECK-DAG: [[SHARE2]] = !DILocalVariable(name: "share2"
+// CHECK-DAG: [[SHARE3]] = !DILocalVariable(name: "share3"
+// CHECK-DAG: [[SHARE1]] = !DILocalVariable(name: "share1"
+
+// NEG-LABEL: define internal i32 @.omp_task_entry.
+// NEG:  [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8
+// NEG-NOT: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata {{![0-9]+}}, metadata !DIExpression(DW_OP_deref))
+
+extern int printf(const char *, ...);
+
+int foo(int n) {
+  int share1 = 9, share2 = 11, share3 = 13, priv1, priv2, fpriv;
+  fpriv = n + 4;
+
+  if (n < 2)
+return n;
+  else {
+#if SHARED
+#pragma omp task shared(share1, share2) private(priv1, priv2) firstprivate(fpriv) shared(share3)
+#else
+#pragma omp task private(priv1, priv2) firstprivate(fpriv)
+#endif
+{
+  priv1 = n;
+  priv2 = n + 2;
+  share2 += share3;
+  printf("share1 = %d, share2 = %d, share3 = %d\n", share1, share2, share3);
+  share1 = priv1 + priv2 + fpriv + foo(n - 1) + share2 + share3;
+}
+#pragma omp taskwait
+return share1 + share2 + share3;
+  }
+}
+
+int main() {
+  int n = 10;
+  printf("foo(%d) = %d\n", n, foo(n));
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -459,6 +459,11 @@
 /// Get the name of the capture helper.
 virtual StringRef getHelperName() const { return "__captured_stmt"; }
 
+/// Get the CaptureFields
+llvm::SmallDenseMap 

[PATCH] D115442: [clangd] Provide documentation as MarkupContent in signaturehelp

2021-12-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3606a3375d2: [clangd] Provide documentation as 
MarkupContent in signaturehelp (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115442

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/signature-help.test
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_SYNCAPI_H
 
 #include "ClangdServer.h"
+#include "Protocol.h"
 #include "index/Index.h"
 
 namespace clang {
@@ -32,7 +33,8 @@
 clangd::CodeCompleteOptions Opts);
 
 llvm::Expected runSignatureHelp(ClangdServer ,
-   PathRef File, Position Pos);
+   PathRef File, Position Pos,
+   MarkupKind DocumentationFormat);
 
 llvm::Expected>
 runLocateSymbolAt(ClangdServer , PathRef File, Position Pos);
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "SyncAPI.h"
+#include "Protocol.h"
 #include "index/Index.h"
 
 namespace clang {
@@ -77,9 +78,10 @@
 }
 
 llvm::Expected runSignatureHelp(ClangdServer ,
-   PathRef File, Position Pos) {
+   PathRef File, Position Pos,
+   MarkupKind DocumentationFormat) {
   llvm::Optional> Result;
-  Server.signatureHelp(File, Pos, capture(Result));
+  Server.signatureHelp(File, Pos, DocumentationFormat, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -24,6 +24,7 @@
 #include "support/Threading.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Testing/Support/Annotations.h"
@@ -1171,8 +1172,10 @@
 MainFileRefs(0u), ScopeRefs(3u;
 }
 
-SignatureHelp signatures(llvm::StringRef Text, Position Point,
- std::vector IndexSymbols = {}) {
+SignatureHelp
+signatures(llvm::StringRef Text, Position Point,
+   std::vector IndexSymbols = {},
+   MarkupKind DocumentationFormat = MarkupKind::PlainText) {
   std::unique_ptr Index;
   if (!IndexSymbols.empty())
 Index = memIndex(IndexSymbols);
@@ -1193,13 +1196,16 @@
 ADD_FAILURE() << "Couldn't build Preamble";
 return {};
   }
-  return signatureHelp(testPath(TU.Filename), Point, *Preamble, Inputs);
+  return signatureHelp(testPath(TU.Filename), Point, *Preamble, Inputs,
+   DocumentationFormat);
 }
 
-SignatureHelp signatures(llvm::StringRef Text,
- std::vector IndexSymbols = {}) {
+SignatureHelp
+signatures(llvm::StringRef Text, std::vector IndexSymbols = {},
+   MarkupKind DocumentationFormat = MarkupKind::PlainText) {
   Annotations Test(Text);
-  return signatures(Test.code(), Test.point(), std::move(IndexSymbols));
+  return signatures(Test.code(), Test.point(), std::move(IndexSymbols),
+DocumentationFormat);
 }
 
 struct ExpectedParameter {
@@ -1216,7 +1222,7 @@
   }
   return true;
 }
-MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
+MATCHER_P(SigDoc, Doc, "") { return arg.documentation.value == Doc; }
 
 /// \p AnnotatedLabel is a signature label with ranges marking parameters, e.g.
 ///foo([[int p1]], [[double p2]]) -> void
@@ -1388,8 +1394,9 @@
 #include "a.h"
 void bar() { foo(^2); })cpp");
   TU.Code = Test.code().str();
-  

[clang-tools-extra] d3606a3 - [clangd] Provide documentation as MarkupContent in signaturehelp

2021-12-10 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-12-10T12:58:08+01:00
New Revision: d3606a3375d258c67c061a97901faca53c4032da

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

LOG: [clangd] Provide documentation as MarkupContent in signaturehelp

This unifies the behaviour we have in code completion item
documentations and signaturehelp. Providing better line wrapping and detection
of inline code blocks in comments to be renedered appropriately in markdown.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/signature-help.test
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 762ca1aa213a4..3f0bff6e00032 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -500,6 +500,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
 Opts.CodeComplete.BundleOverloads = Params.capabilities.HasSignatureHelp;
   Opts.CodeComplete.DocumentationFormat =
   Params.capabilities.CompletionDocumentationFormat;
+  Opts.SignatureHelpDocumentationFormat =
+  Params.capabilities.SignatureHelpDocumentationFormat;
   DiagOpts.EmbedFixesInDiagnostics = Params.capabilities.DiagnosticFixes;
   DiagOpts.SendDiagnosticCategory = Params.capabilities.DiagnosticCategory;
   DiagOpts.EmitRelatedLocations =
@@ -1058,6 +1060,7 @@ void ClangdLSPServer::onCompletion(const CompletionParams 
,
 void ClangdLSPServer::onSignatureHelp(const TextDocumentPositionParams ,
   Callback Reply) {
   Server->signatureHelp(Params.textDocument.uri.file(), Params.position,
+Opts.SignatureHelpDocumentationFormat,
 [Reply = std::move(Reply), this](
 llvm::Expected Signature) mutable {
   if (!Signature)

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 4c195df6f893c..bd7c1a05b0e22 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -56,6 +56,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
 /// Per-feature options. Generally ClangdServer lets these vary
 /// per-request, but LSP allows limited/no customizations.
 clangd::CodeCompleteOptions CodeComplete;
+MarkupKind SignatureHelpDocumentationFormat = MarkupKind::PlainText;
 clangd::RenameOptions Rename;
 /// Returns true if the tweak should be enabled.
 std::function TweakFilter = [](const Tweak ) {

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 1e722086e2e04..ae486d176ba91 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -403,9 +403,11 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
 }
 
 void ClangdServer::signatureHelp(PathRef File, Position Pos,
+ MarkupKind DocumentationFormat,
  Callback CB) {
 
   auto Action = [Pos, File = File.str(), CB = std::move(CB),
+ DocumentationFormat,
  this](llvm::Expected IP) mutable {
 if (!IP)
   return CB(IP.takeError());
@@ -416,7 +418,8 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
 
 ParseInputs ParseInput{IP->Command, , IP->Contents.str()};
 ParseInput.Index = Index;
-CB(clangd::signatureHelp(File, Pos, *PreambleData, ParseInput));
+CB(clangd::signatureHelp(File, Pos, *PreambleData, ParseInput,
+ DocumentationFormat));
   };
 
   // Unlike code completion, we wait for a preamble here.

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 7d98977a70567..0589f4fc4214c 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -225,7 +225,8 @@ class ClangdServer {
 
   /// Provide signature help for \p File at \p Pos.  This method should only be
   /// called for tracked files.
-  void signatureHelp(PathRef 

[PATCH] D115507: Add PACBTI-M support to LLVM release notes.

2021-12-10 Thread Ties Stuij 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 rGfbf489cd1b4b: Add PACBTI-M support to LLVM release notes. 
(authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115507

Files:
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115442: [clangd] Provide documentation as MarkupContent in signaturehelp

2021-12-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 393438.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Drop extra tests
- Move capability closer to others


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115442

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/signature-help.test
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_SYNCAPI_H
 
 #include "ClangdServer.h"
+#include "Protocol.h"
 #include "index/Index.h"
 
 namespace clang {
@@ -32,7 +33,8 @@
 clangd::CodeCompleteOptions Opts);
 
 llvm::Expected runSignatureHelp(ClangdServer ,
-   PathRef File, Position Pos);
+   PathRef File, Position Pos,
+   MarkupKind DocumentationFormat);
 
 llvm::Expected>
 runLocateSymbolAt(ClangdServer , PathRef File, Position Pos);
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "SyncAPI.h"
+#include "Protocol.h"
 #include "index/Index.h"
 
 namespace clang {
@@ -77,9 +78,10 @@
 }
 
 llvm::Expected runSignatureHelp(ClangdServer ,
-   PathRef File, Position Pos) {
+   PathRef File, Position Pos,
+   MarkupKind DocumentationFormat) {
   llvm::Optional> Result;
-  Server.signatureHelp(File, Pos, capture(Result));
+  Server.signatureHelp(File, Pos, DocumentationFormat, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -24,6 +24,7 @@
 #include "support/Threading.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Testing/Support/Annotations.h"
@@ -1171,8 +1172,10 @@
 MainFileRefs(0u), ScopeRefs(3u;
 }
 
-SignatureHelp signatures(llvm::StringRef Text, Position Point,
- std::vector IndexSymbols = {}) {
+SignatureHelp
+signatures(llvm::StringRef Text, Position Point,
+   std::vector IndexSymbols = {},
+   MarkupKind DocumentationFormat = MarkupKind::PlainText) {
   std::unique_ptr Index;
   if (!IndexSymbols.empty())
 Index = memIndex(IndexSymbols);
@@ -1193,13 +1196,16 @@
 ADD_FAILURE() << "Couldn't build Preamble";
 return {};
   }
-  return signatureHelp(testPath(TU.Filename), Point, *Preamble, Inputs);
+  return signatureHelp(testPath(TU.Filename), Point, *Preamble, Inputs,
+   DocumentationFormat);
 }
 
-SignatureHelp signatures(llvm::StringRef Text,
- std::vector IndexSymbols = {}) {
+SignatureHelp
+signatures(llvm::StringRef Text, std::vector IndexSymbols = {},
+   MarkupKind DocumentationFormat = MarkupKind::PlainText) {
   Annotations Test(Text);
-  return signatures(Test.code(), Test.point(), std::move(IndexSymbols));
+  return signatures(Test.code(), Test.point(), std::move(IndexSymbols),
+DocumentationFormat);
 }
 
 struct ExpectedParameter {
@@ -1216,7 +1222,7 @@
   }
   return true;
 }
-MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
+MATCHER_P(SigDoc, Doc, "") { return arg.documentation.value == Doc; }
 
 /// \p AnnotatedLabel is a signature label with ranges marking parameters, e.g.
 ///foo([[int p1]], [[double p2]]) -> void
@@ -1388,8 +1394,9 @@
 #include "a.h"
 void bar() { foo(^2); })cpp");
   TU.Code = Test.code().str();
-  auto Results = signatureHelp(testPath(TU.Filename), Test.point(),
-

[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-12-10 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodf requested review of this revision.
brunodf added a comment.

A stage2 build (outside of the buildloops) is now working correctly. Pinging 
for new review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111639

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


[PATCH] D115507: Add PACBTI-M support to LLVM release notes.

2021-12-10 Thread Victor Campos via Phabricator via cfe-commits
vhscampos accepted this revision.
vhscampos 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/D115507/new/

https://reviews.llvm.org/D115507

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


[PATCH] D115507: Add PACBTI-M support to LLVM release notes.

2021-12-10 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 393434.
stuij added a comment.

removed accidentally included Clang release notes draft


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115507

Files:
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115507: Add PACBTI-M support to LLVM release notes.

2021-12-10 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
stuij requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Clang release note changes will be added once the last PACBTI-M command line
patch lands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115507

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -69,6 +69,9 @@
 
 - Clang plugin arguments can now be passed through the compiler driver via
   ``-fplugin-arg-pluginname-arg``, similar to GCC's ``-fplugin-arg``.
+- The ``-mbranch-protection`` flag will now also work for the ARM backend
+- The ``-mno-bti-at-return-twice`` flag will make sure a BTI instruction won't
+  be added after a setjmp or other return-twice construct (ARM backend only).
 
 Deprecated Compiler Flags
 -
@@ -226,6 +229,8 @@
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
+Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm
+only)
 
 Floating Point Support in Clang
 ---


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -83,6 +83,7 @@
 --
 
 * Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
+* Added support for the Armv8.1-M PACBTI-M extension.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -69,6 +69,9 @@
 
 - Clang plugin arguments can now be passed through the compiler driver via
   ``-fplugin-arg-pluginname-arg``, similar to GCC's ``-fplugin-arg``.
+- The ``-mbranch-protection`` flag will now also work for the ARM backend
+- The ``-mno-bti-at-return-twice`` flag will make sure a BTI instruction won't
+  be added after a setjmp or other return-twice construct (ARM backend only).
 
 Deprecated Compiler Flags
 -
@@ -226,6 +229,8 @@
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
+Do not add a BTI instruction after a setjmp or other return-twice construct (Arm
+only)
 
 Floating Point Support in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114421: [asan] Add support for disable_sanitizer_instrumentation attribute

2021-12-10 Thread Alexander Potapenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b554920f11c: [asan] Add support for 
disable_sanitizer_instrumentation attribute (authored by glider).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114421

Files:
  clang/docs/AddressSanitizer.rst
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/asan-globals.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll

Index: llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll
@@ -0,0 +1,47 @@
+; This test checks that we are not instrumenting sanitizer code.
+; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function with sanitize_address is instrumented.
+; Function Attrs: nounwind uwtable
+define void @instr_sa(i32* %a) sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @instr_sa
+; CHECK: call void @__asan_report_load
+
+
+; Function with disable_sanitizer_instrumentation is not instrumented.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi(i32* %a) disable_sanitizer_instrumentation {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi
+; CHECK-NOT: call void @__asan_report_load
+
+
+; disable_sanitizer_instrumentation takes precedence over sanitize_address.
+; Function Attrs: nounwind uwtable
+define void @noinstr_dsi_sa(i32* %a) disable_sanitizer_instrumentation sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  %tmp2 = add i32 %tmp1,  1
+  store i32 %tmp2, i32* %a, align 4
+  ret void
+}
+
+; CHECK-LABEL: @noinstr_dsi_sa
+; CHECK-NOT: call void @__asan_report_load
+
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2890,6 +2890,9 @@
   // Leave if the function doesn't need instrumentation.
   if (!F.hasFnAttribute(Attribute::SanitizeAddress)) return FunctionModified;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return FunctionModified;
+
   LLVM_DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
 
   initializeCallbacks(*F.getParent());
Index: clang/test/CodeGen/asan-globals.cpp
===
--- clang/test/CodeGen/asan-globals.cpp
+++ clang/test/CodeGen/asan-globals.cpp
@@ -10,6 +10,7 @@
 int global;
 int dyn_init_global = global;
 int __attribute__((no_sanitize("address"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
 
 int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - ignore globals in a section
@@ -50,31 +51,33 @@
 // UWTABLE: attributes #[[#ATTR]] = { nounwind uwtable }
 // UWTABLE: ![[#]] = !{i32 7, !"uwtable", i32 1}
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
 // CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 10, i32 5}
 // CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], !"dyn_init_global", i1 true, i1 false}
 // CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 11, i32 5}
-// CHECK: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
-// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
+// CHECK: 

[clang] 2b55492 - [asan] Add support for disable_sanitizer_instrumentation attribute

2021-12-10 Thread Alexander Potapenko via cfe-commits

Author: Alexander Potapenko
Date: 2021-12-10T12:17:26+01:00
New Revision: 2b554920f11c8b763cd9ed9003f4e19b919b8e1f

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

LOG: [asan] Add support for disable_sanitizer_instrumentation attribute

For ASan this will effectively serve as a synonym for
__attribute__((no_sanitize("address")))

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

Added: 

llvm/test/Instrumentation/AddressSanitizer/asan-disable-sanitizer-instrumentation.ll

Modified: 
clang/docs/AddressSanitizer.rst
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/test/CodeGen/address-safety-attr-flavors.cpp
clang/test/CodeGen/asan-globals.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 




diff  --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index 06b53e2e5da0b..fe5f683580a46 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -229,6 +229,12 @@ compilers, so we suggest to use it together with
 The same attribute used on a global variable prevents AddressSanitizer
 from adding redzones around it and detecting out of bounds accesses.
 
+
+AddressSanitizer also supports
+``__attribute__((disable_sanitizer_instrumentation))``. This attribute
+works similar to ``__attribute__((no_sanitize("address")))``, but it also
+prevents instrumentation performed by other sanitizers.
+
 Suppressing Errors in Recompiled Code (Ignorelist)
 --
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index ed43adfab9545..f3b53c4859b2c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -382,9 +382,6 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) 
{
"__cyg_profile_func_exit");
   }
 
-  if (ShouldSkipSanitizerInstrumentation())
-CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
-
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
 DI->EmitFunctionEnd(Builder, CurFn);
@@ -766,17 +763,22 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   Fn->addFnAttr(llvm::Attribute::NoSanitizeCoverage);
   }
 
-  // Apply sanitizer attributes to the function.
-  if (SanOpts.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
-Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
-  if (SanOpts.hasOneOf(SanitizerKind::HWAddress | 
SanitizerKind::KernelHWAddress))
-Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
-  if (SanOpts.has(SanitizerKind::MemTag))
-Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
-  if (SanOpts.has(SanitizerKind::Thread))
-Fn->addFnAttr(llvm::Attribute::SanitizeThread);
-  if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
-Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
+  if (ShouldSkipSanitizerInstrumentation()) {
+CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
+  } else {
+// Apply sanitizer attributes to the function.
+if (SanOpts.hasOneOf(SanitizerKind::Address | 
SanitizerKind::KernelAddress))
+  Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
+if (SanOpts.hasOneOf(SanitizerKind::HWAddress |
+ SanitizerKind::KernelHWAddress))
+  Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
+if (SanOpts.has(SanitizerKind::MemTag))
+  Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
+if (SanOpts.has(SanitizerKind::Thread))
+  Fn->addFnAttr(llvm::Attribute::SanitizeThread);
+if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
+  Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
+  }
   if (SanOpts.has(SanitizerKind::SafeStack))
 Fn->addFnAttr(llvm::Attribute::SafeStack);
   if (SanOpts.has(SanitizerKind::ShadowCallStack))

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 009965a36c396..9e26d242d3a7e 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -73,6 +73,8 @@ void 
SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
   for (auto Attr : D.specific_attrs())
 if (Attr->getMask() & SanitizerKind::Address)
   IsExcluded = true;
+  if (D.hasAttr())
+IsExcluded = true;
   reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit,
  IsExcluded);
 }

diff  --git a/clang/test/CodeGen/address-safety-attr-flavors.cpp 
b/clang/test/CodeGen/address-safety-attr-flavors.cpp
index e6d17ed2da340..ef81059db 100644
--- a/clang/test/CodeGen/address-safety-attr-flavors.cpp
+++ 

[PATCH] D115503: [DebugInfo] emit DW_AT_accessibility attribute for class/struct/union types.

2021-12-10 Thread Esme Yi via Phabricator via cfe-commits
Esme created this revision.
Esme added reviewers: shchenz, probinson, dblaikie, jhenderson, aprantl, 
PowerPC.
Herald added a subscriber: hiraditya.
Esme requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch emits DW_AT_accessibility attribute for class/struct/union types.

Sample program :

  class A {
public:
  struct B {
  };
public:
  B b;
  };
  
  struct C {
private:
  union D {
  };
public:
  D d;
  };
  
  union E {
private:
  class F {
  };
  class G {
  };
public:
  F f;
  G g;
  };

Debug info without this patch:

  0x013d:   DW_TAG_class_type
  DW_AT_name  ("A")
  
  0x0143: DW_TAG_member
DW_AT_name("b")
DW_AT_accessibility   (DW_ACCESS_public)
  
  0x014e: DW_TAG_structure_type
DW_AT_name("B") // no accessibility attribute is 
present, private access is assumed for B.
  
  0x0155:   DW_TAG_structure_type
  DW_AT_name  ("C")
  
  0x015b: DW_TAG_member
DW_AT_name("d")
  
  0x0165: DW_TAG_union_type
DW_AT_name("D") // no accessibility attribute is 
present, public access is assumed for D.
  
  0x016c:   DW_TAG_union_type
  DW_AT_name  ("E")
  
  0x0172: DW_TAG_member
DW_AT_name("f")
  
  0x017c: DW_TAG_class_type
DW_AT_name("F") // no accessibility attribute is 
present, public access is assumed for F.
  
  0x0182: DW_TAG_member
DW_AT_name("g")
  
  0x018c: DW_TAG_class_type
DW_AT_name("G") // no accessibility attribute is 
present, public access is assumed for G.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115503

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/X86/debug-info-access.ll

Index: llvm/test/DebugInfo/X86/debug-info-access.ll
===
--- llvm/test/DebugInfo/X86/debug-info-access.ll
+++ llvm/test/DebugInfo/X86/debug-info-access.ll
@@ -1,9 +1,8 @@
 ; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
-;
+
 ; Test the DW_AT_accessibility DWARF attribute.
-;
-;
+
 ; Regenerate me:
 ; clang++ -g tools/clang/test/CodeGenCXX/debug-info-access.cpp -S -emit-llvm -o -
 ;
@@ -22,6 +21,34 @@
 ; void priv_default();
 ;   };
 ;
+;   class C {
+;   public:
+; struct D {
+; };
+;   protected:
+; union E {
+; };
+;   public:
+; D d;
+; E e;
+;   };
+;
+;   struct F {
+;   private:
+; union G {
+; };
+;   public:
+; G g;
+;   };
+;
+;   union H {
+;   private:
+; class I {
+; };
+;   public:
+; I i;
+;   };
+;
 ;   union U {
 ; void union_pub_default();
 ;   private:
@@ -33,119 +60,164 @@
 ;   A a;
 ;   B b;
 ;   U u;
-;
+;   C c;
+;   F f;
+;   H h;
+
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"free")
 ; CHECK-NOT: DW_AT_accessibility
 
+; CHECK: DW_TAG_member
+; CHECK: DW_AT_name {{.*}}"union_priv")
+; CHECK-NOT: DW_TAG
+; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_private)
+
+; CHECK: DW_TAG_subprogram
+; CHECK: DW_AT_name {{.*}}"union_pub_default")
+; CHECK-NOT: DW_AT_accessibility
+
 ; CHECK: DW_TAG_member
 ; CHECK: DW_AT_name {{.*}}"pub_default_static")
 ; CHECK-NOT: DW_AT_accessibility
 ; CHECK-NOT: DW_TAG
-;
+
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"pub_default")
 ; CHECK-NOT: DW_AT_accessibility
 ; CHECK: DW_TAG
-;
+
 ; CHECK: DW_TAG_inheritance
 ; CHECK-NOT: DW_TAG
 ; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
-;
+
 ; CHECK: DW_TAG_member
 ; CHECK: DW_AT_name {{.*}}"public_static")
 ; CHECK-NOT: DW_TAG
 ; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
-;
+
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"pub")
 ; CHECK-NOT: DW_TAG
 ; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
-;
+
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"prot")
 ; CHECK-NOT: DW_TAG
 ; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_protected)
-;
+
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"priv_default")
 ; CHECK-NOT: DW_AT_accessibility
 ; CHECK: DW_TAG
-;
-; CHECK: DW_TAG_member
-; CHECK: DW_AT_name {{.*}}"union_priv")
-; CHECK-NOT: DW_TAG
-; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_private)
-;
-; CHECK: DW_TAG_subprogram
-; CHECK: DW_AT_name {{.*}}"union_pub_default")
-; CHECK-NOT: DW_AT_accessibility
-;
-; ModuleID = '/llvm/tools/clang/test/CodeGenCXX/debug-info-access.cpp'
-source_filename = "test/DebugInfo/X86/debug-info-access.ll"

[PATCH] D115501: [clang][ARM] Emit warnings when PACBTI-M is used with unsupported architectures

2021-12-10 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra created this revision.
amilendra added reviewers: chill, vhscampos.
Herald added a subscriber: kristof.beyls.
Herald added a reviewer: aaron.ballman.
amilendra requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Branch protection in M-class is supported by

- Armv8.1-M.Main
- Armv8-M.Main
- Armv7-M

Attempting to enable this for other architectures, either by
command-line (e.g -mbranch-protection=bti) or by target attribute
in source code (e.g.  __attribute__((target("branch-protection=..."))) )
will generate a warning.

In both cases function attributes related to branch protection will not
be emitted. Regardless of the warning, module level attributes related to
branch protection will be emitted when it is enabled via the command-line.

The following people also contributed to this patch:

- Victor Campos


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115501

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/arm-branch-protection-attr-2.c
  clang/test/CodeGen/arm_acle.c
  clang/test/Driver/arm-security-options.c
  clang/test/Frontend/arm-branch-protection-default-arch.c
  clang/test/Frontend/arm-ignore-branch-protection-option.c
  clang/test/Frontend/arm-invalid-branch-protection.c
  clang/test/Sema/arm-branch-protection-attr-warn.c
  clang/test/Sema/arm-branch-protection.c

Index: clang/test/Sema/arm-branch-protection.c
===
--- /dev/null
+++ clang/test/Sema/arm-branch-protection.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple thumbv6m -verify -fsyntax-only %s
+
+// expected-no-diagnostics
+// Armv8.1-M.Main
+__attribute__((target("arch=cortex-m55,branch-protection=bti"))) void f1() {}
+__attribute__((target("arch=cortex-m55,branch-protection=pac-ret"))) void f2() {}
+__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret"))) void f3() {}
+__attribute__((target("arch=cortex-m55,branch-protection=bti+pac-ret+leaf"))) void f4() {}
+// Armv8-M.Main
+__attribute__((target("arch=cortex-m33,branch-protection=bti"))) void f5() {}
+__attribute__((target("arch=cortex-m33,branch-protection=pac-ret"))) void f6() {}
+__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret"))) void f7() {}
+__attribute__((target("arch=cortex-m33,branch-protection=bti+pac-ret+leaf"))) void f8() {}
+// Armv7-M
+__attribute__((target("arch=cortex-m3,branch-protection=bti"))) void f9() {}
+__attribute__((target("arch=cortex-m3,branch-protection=pac-ret"))) void f10() {}
+__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret"))) void f11() {}
+__attribute__((target("arch=cortex-m3,branch-protection=bti+pac-ret+leaf"))) void f12() {}
+// Armv7E-M
+__attribute__((target("arch=cortex-m4,branch-protection=bti"))) void f13() {}
+__attribute__((target("arch=cortex-m4,branch-protection=pac-ret"))) void f14() {}
+__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret"))) void f15() {}
+__attribute__((target("arch=cortex-m4,branch-protection=bti+pac-ret+leaf"))) void f16() {}
Index: clang/test/Sema/arm-branch-protection-attr-warn.c
===
--- /dev/null
+++ clang/test/Sema/arm-branch-protection-attr-warn.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple thumbv6m -verify -fsyntax-only %s
+
+// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
+__attribute__((target("arch=cortex-m0,branch-protection=bti"))) void f1() {}
+
+// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
+__attribute__((target("arch=cortex-m0,branch-protection=pac-ret"))) void f2() {}
+
+// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
+__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret"))) void f3() {}
+
+// expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
+__attribute__((target("arch=cortex-m0,branch-protection=bti+pac-ret+leaf"))) void f4() {}
Index: clang/test/Frontend/arm-invalid-branch-protection.c
===
--- clang/test/Frontend/arm-invalid-branch-protection.c
+++ clang/test/Frontend/arm-invalid-branch-protection.c
@@ -1,7 +1,7 @@
 // REQUIRES: arm-registered-target
-// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c %s -o /dev/null 2>&1 | FileCheck %s
-// RUN: %clang -target arm-arm-none-eabi 

[PATCH] D114382: [clang] Fix wrong -Wunused-local-typedef warning within a template function

2021-12-10 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

@rtrieu, thank you for looking at this! Do you have any comments about the rest 
of the patch? Do you think it makes sense?




Comment at: clang/test/Modules/odr_hash.cpp:4288
 S s;
+// expected-error@first.h:* {{'ParameterTest::S::Foo' has different 
definitions in different modules; definition in module 'FirstModule' first 
difference is 1st parameter with name ''}}
+// expected-note@second.h:* {{but in 'SecondModule' found 1st parameter with 
name 'asdf'}}

rtrieu wrote:
> krisb wrote:
> > I'm not sure what was the original intent of this test (i.e. whether it 
> > intentionally tests the fact that there is no error on an uninstantiated 
> > static member function). As well as it doesn't clear to me what is the role 
> > of the unused typedef here, but it starts triggering the error because of 
> > redecls() call on isReferenced() added by this patch.
> I've checked out the ODR Hashing versus the other cases.   The new error is 
> in line with the other behavior.  Having this new error is okay.
Thank you for checking this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114382

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


[PATCH] D115235: [clang][dataflow] Implement a basic algorithm for dataflow analysis

2021-12-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dcaf3aa0bf2: [clang][dataflow] Implement a basic algorithm 
for dataflow analysis (authored by sgatev, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115235

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -0,0 +1,148 @@
+//===- unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace dataflow;
+
+template 
+class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
+public:
+  void run(const ast_matchers::MatchFinder::MatchResult ) override {
+assert(BlockStates.empty());
+
+const auto *Func = Result.Nodes.getNodeAs("func");
+assert(Func != nullptr);
+
+Stmt *Body = Func->getBody();
+assert(Body != nullptr);
+
+// FIXME: Consider providing a utility that returns a `CFG::BuildOptions`
+// which is a good default for most clients or a utility that directly
+// builds the `CFG` using default `CFG::BuildOptions`.
+CFG::BuildOptions Options;
+Options.AddImplicitDtors = true;
+Options.AddTemporaryDtors = true;
+Options.setAllAlwaysAdd();
+
+std::unique_ptr Cfg =
+CFG::buildCFG(nullptr, Body, Result.Context, Options);
+assert(Cfg != nullptr);
+
+AnalysisT Analysis(*Result.Context);
+Environment Env;
+BlockStates = runDataflowAnalysis(*Cfg, Analysis, Env);
+  }
+
+  std::vector<
+  llvm::Optional>>
+  BlockStates;
+};
+
+template 
+std::vector>>
+runAnalysis(llvm::StringRef Code) {
+  std::unique_ptr AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
+
+  AnalysisCallback Callback;
+  ast_matchers::MatchFinder Finder;
+  Finder.addMatcher(
+  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
+  );
+  Finder.matchAST(AST->getASTContext());
+
+  return Callback.BlockStates;
+}
+
+class NoopLattice {
+public:
+  bool operator==(const NoopLattice &) const { return true; }
+
+  LatticeJoinEffect join(const NoopLattice &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
+
+class NoopAnalysis : public DataflowAnalysis {
+public:
+  NoopAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {}
+
+  static NoopLattice initialElement() { return {}; }
+
+  NoopLattice transfer(const Stmt *S, const NoopLattice , Environment ) {
+return {};
+  }
+};
+
+TEST(DataflowAnalysisTest, NoopAnalysis) {
+  auto BlockStates = runAnalysis(R"(
+void target() {}
+  )");
+  EXPECT_EQ(BlockStates.size(), 2u);
+  EXPECT_TRUE(BlockStates[0].hasValue());
+  EXPECT_TRUE(BlockStates[1].hasValue());
+}
+
+struct NonConvergingLattice {
+  int State;
+
+  bool operator==(const NonConvergingLattice ) const {
+return State == Other.State;
+  }
+
+  LatticeJoinEffect join(const NonConvergingLattice ) {
+if (Other.State == 0)
+  return LatticeJoinEffect::Unchanged;
+State += Other.State;
+return LatticeJoinEffect::Changed;
+  }
+};
+
+class NonConvergingAnalysis
+: public DataflowAnalysis {
+public:
+  explicit NonConvergingAnalysis(ASTContext )
+  : DataflowAnalysis(Context) {
+  }
+
+  static NonConvergingLattice initialElement() { return {0}; }
+
+  NonConvergingLattice transfer(const Stmt *S, const NonConvergingLattice ,
+Environment ) {
+return {E.State + 1};
+  }
+};
+
+TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
+  auto BlockStates = 

[clang] 8dcaf3a - [clang][dataflow] Implement a basic algorithm for dataflow analysis

2021-12-10 Thread Dmitri Gribenko via cfe-commits

Author: Stanislav Gatev
Date: 2021-12-10T11:44:49+01:00
New Revision: 8dcaf3aa0bf25508700a7452ed963c1487221dfd

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

LOG: [clang][dataflow] Implement a basic algorithm for dataflow analysis

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed By: xazax.hun, gribozavr2

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

Added: 
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 69a5c2e47b66d..4a3c0239f8e12 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -15,11 +15,20 @@
 #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H
 #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H
 
+#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+
 namespace clang {
 namespace dataflow {
 
 /// Holds the state of the program (store and heap) at a given program point.
-class Environment {};
+class Environment {
+public:
+  bool operator==(const Environment &) const { return true; }
+
+  LatticeJoinEffect join(const Environment &) {
+return LatticeJoinEffect::Unchanged;
+  }
+};
 
 } // namespace dataflow
 } // namespace clang

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
index 90095735ad3d5..52d84eb13c568 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h
@@ -61,11 +61,12 @@ struct ReversePostOrderCompare {
 /// the same block multiple times at once.
 struct ForwardDataflowWorklist
 : DataflowWorklistBase {
+  ForwardDataflowWorklist(const CFG , PostOrderCFGView *POV)
+  : DataflowWorklistBase(Cfg, POV,
+ ReversePostOrderCompare{POV->getComparator()}) {}
+
   ForwardDataflowWorklist(const CFG , AnalysisDeclContext )
-  : DataflowWorklistBase(
-Cfg, Ctx.getAnalysis(),
-ReversePostOrderCompare{
-Ctx.getAnalysis()->getComparator()}) {}
+  : ForwardDataflowWorklist(Cfg, Ctx.getAnalysis()) {}
 
   void enqueueSuccessors(const CFGBlock *Block) {
 for (auto B : Block->succs())

diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
index 9448b911f4718..55fae246da795 100644
--- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -76,6 +76,20 @@ struct TypeErasedDataflowAnalysisState {
   Environment Env;
 };
 
+/// Transfers the state of a basic block by evaluating each of its statements 
in
+/// the context of `Analysis` and the states of its predecessors that are
+/// available in `BlockStates`.
+///
+/// Requirements:
+///
+///   All predecessors of `Block` except those with loop back edges must have
+///   already been transferred. States in `BlockStates` that are set to
+///   `llvm::None` represent basic blocks that are not evaluated yet.
+TypeErasedDataflowAnalysisState transferBlock(
+std::vector> ,
+const CFGBlock , const Environment ,
+TypeErasedDataflowAnalysis );
+
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices
 /// of the returned vector correspond to basic block IDs.

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index bb7eb99710681..45afd59728e14 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -11,15 +11,77 @@
 //
 
//===--===//
 
+#include 
 #include 
 
+#include "clang/Analysis/Analyses/PostOrderCFGView.h"
 #include "clang/Analysis/CFG.h"
 #include 

[PATCH] D115320: Avoid setting tbaa information on store of return type of call to inline assember

2021-12-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:2511
+return LValue::MakeAddr(Addr, T, getContext(), LValueBaseInfo(Source),
+CGM.returnNullTBAA());
+  }

Looking at how a 'null tbaa'is produced in other places (grep for 
'TBAAAccessInfo()', I would just do a 'TBAAAccessInfo()' here and omit the new 
''returnNullTBAA' method.





Comment at: clang/test/CodeGen/avoidTBAAonASMstore.cpp:6
+   __asm { fnstcw word ptr[ControlWord] };
+// CHECK: store i64 %2, i64* %1, align 4
+// CHECK-NOT: !tbaa

Will this also work in release mode ? Maybe abstract away the %2 and %1.



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

https://reviews.llvm.org/D115320

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


[PATCH] D115492: [LTO] Ignore unreachable virtual functions in WPD in hybrid LTO

2021-12-10 Thread Mingming Liu via Phabricator via cfe-commits
luna updated this revision to Diff 393392.
luna added a comment.

Revert unit test that shouldn't be affected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115492

Files:
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGen/thinlto-distributed-cfi.ll
  clang/test/CodeGen/thinlto-funcattr-prop.ll
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Assembler/thinlto-summary.ll
  llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
  llvm/test/Bitcode/thinlto-type-vcalls.ll
  llvm/test/ThinLTO/X86/Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll
  llvm/test/ThinLTO/X86/devirt_hybrid_after_filtering_unreachable.ll
  llvm/test/ThinLTO/X86/dot-dumper.ll
  llvm/test/ThinLTO/X86/dot-dumper2.ll
  llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
  llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll

Index: llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
===
--- llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
+++ llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
@@ -23,4 +23,4 @@
 }
 
 attributes #0 = { alwaysinline nounwind uwtable }
-; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0
+; CHECK2: ^2 = gv: (guid: {{.*}}, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 1, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0
Index: llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
===
--- llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
+++ llvm/test/ThinLTO/X86/funcattrs-prop-maythrow.ll
@@ -48,9 +48,9 @@
 ; CHECK-DAG: attributes [[ATTR_NOUNWIND]] = { norecurse nounwind }
 ; CHECK-DAG: attributes [[ATTR_MAYTHROW]] = { norecurse }
 
-; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
-; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}
+; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, 

[PATCH] D114569: [PowerPC] Require htm feature for HTM builtins

2021-12-10 Thread Qiu Chaofan 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 rGd3cd0635e15a: [PowerPC] Require htm feature for HTM builtins 
(authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114569

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-htm.c

Index: clang/test/CodeGen/builtins-ppc-htm.c
===
--- clang/test/CodeGen/builtins-ppc-htm.c
+++ clang/test/CodeGen/builtins-ppc-htm.c
@@ -1,62 +1,88 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +htm -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature -htm -triple powerpc64-unknown-unknown -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=ERROR
 
 void test1(long int *r, int code, long int *a, long int *b) {
 // CHECK-LABEL: define{{.*}} void @test1
 
   r[0] = __builtin_tbegin (0);
 // CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
   r[1] = __builtin_tbegin (1);
 // CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
   r[2] = __builtin_tend (0);
 // CHECK: @llvm.ppc.tend
+// ERROR: error: this builtin requires HTM to be enabled
   r[3] = __builtin_tendall ();
 // CHECK: @llvm.ppc.tendall
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[4] = __builtin_tabort (code);
 // CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
   r[5] = __builtin_tabort (0x1);
 // CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
   r[6] = __builtin_tabortdc (0xf, a[0], b[0]);
 // CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
   r[7] = __builtin_tabortdci (0xf, a[1], 0x1);
 // CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
   r[8] = __builtin_tabortwc (0xf, a[2], b[2]);
 // CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
   r[9] = __builtin_tabortwci (0xf, a[3], 0x1);
 // CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[10] = __builtin_tcheck ();
 // CHECK: @llvm.ppc.tcheck
+// ERROR: error: this builtin requires HTM to be enabled
   r[11] = __builtin_trechkpt ();
 // CHECK: @llvm.ppc.trechkpt
+// ERROR: error: this builtin requires HTM to be enabled
   r[12] = __builtin_treclaim (0);
 // CHECK: @llvm.ppc.treclaim
+// ERROR: error: this builtin requires HTM to be enabled
   r[13] = __builtin_tresume ();
 // CHECK: @llvm.ppc.tresume
+// ERROR: error: this builtin requires HTM to be enabled
   r[14] = __builtin_tsuspend ();
 // CHECK: @llvm.ppc.tsuspend
+// ERROR: error: this builtin requires HTM to be enabled
   r[15] = __builtin_tsr (0);
 // CHECK: @llvm.ppc.tsr
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[16] = __builtin_ttest ();
 // CHECK: @llvm.ppc.ttest
+// ERROR: error: this builtin requires HTM to be enabled
 
   r[17] = __builtin_get_texasr ();
 // CHECK: @llvm.ppc.get.texasr
+// ERROR: error: this builtin requires HTM to be enabled
   r[18] = __builtin_get_texasru ();
 // CHECK: @llvm.ppc.get.texasru
+// ERROR: error: this builtin requires HTM to be enabled
   r[19] = __builtin_get_tfhar ();
 // CHECK: @llvm.ppc.get.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
   r[20] = __builtin_get_tfiar ();
 // CHECK: @llvm.ppc.get.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
 
   __builtin_set_texasr (a[21]);
 // CHECK: @llvm.ppc.set.texasr
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_texasru (a[22]);
 // CHECK: @llvm.ppc.set.texasru
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_tfhar (a[23]);
 // CHECK: @llvm.ppc.set.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
   __builtin_set_tfiar (a[24]);
 // CHECK: @llvm.ppc.set.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3533,14 +3533,43 @@
   case PPC::BI__builtin_altivec_dss:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
   case PPC::BI__builtin_tbegin:
-  case PPC::BI__builtin_tend: i = 0; l = 0; u = 1; break;
-  case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7; break;
+  case PPC::BI__builtin_tend:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 1) ||
+   SemaFeatureCheck(*this, TheCall, "htm",
+diag::err_ppc_builtin_requires_htm);
+  case PPC::BI__builtin_tsr:
+return SemaBuiltinConstantArgRange(TheCall, 0, 

  1   2   >