[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Should we handle `#import` and `@import` for Object-C only so as to simply the 
regex for C++?




Comment at: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h:136
+/// #include 
+/// @include bar;
+/// #include "bar.h"

I think you meant `@import bar;`, which is valid in Objective-C only. So is 
`#import` btw.



Comment at: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h:139-147
+llvm::Regex GetCppIncludeRegex();
+
+/// \returns the last match in the list of matches that is not empty.
+llvm::StringRef GetIncludeNameFromMatches(
+const llvm::SmallVectorImpl &Matches);
+
+/// \returns the given include name and removes the following symbols from the

Function names should start with a lowercase letter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST

2022-04-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 423343.
nridge marked 5 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115187

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/co_await-ast.cpp

Index: clang/test/SemaCXX/co_await-ast.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/co_await-ast.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-dump -ast-dump-filter=foo %s | FileCheck %s --strict-whitespace
+
+namespace std {
+template  struct coroutine_traits;
+template  struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle &&) noexcept;
+  static coroutine_handle from_address(void *__addr) noexcept;
+};
+} // namespace std
+
+struct executor {};
+struct awaitable {};
+struct awaitable_frame {
+  awaitable get_return_object();
+  void return_void();
+  void unhandled_exception();
+  struct result_t {
+~result_t();
+bool await_ready() const noexcept;
+void await_suspend(std::coroutine_handle) noexcept;
+void await_resume() const noexcept;
+  };
+  result_t initial_suspend() noexcept;
+  result_t final_suspend() noexcept;
+  result_t await_transform(executor) noexcept;
+};
+
+namespace std {
+template <>
+struct coroutine_traits {
+  typedef awaitable_frame promise_type;
+};
+} // namespace std
+
+awaitable foo() {
+  co_await executor();
+}
+
+// Check that CoawaitExpr contains the correct subexpressions, including
+// the operand expression as written in the source.
+
+// CHECK-LABEL: Dumping foo:
+// CHECK: FunctionDecl {{.*}} foo 'awaitable ()'
+// CHECK: `-CoroutineBodyStmt {{.*}}
+// CHECK:   |-CompoundStmt {{.*}}
+// CHECK:   | `-ExprWithCleanups {{.*}} 'void'
+// CHECK:   |   `-CoawaitExpr {{.*}} 'void'
+// CHECK:   | |-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | | `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | |   `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | | |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | | | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame'
+// CHECK:   | | `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-ExprWithCleanups {{.*}} 'bool'
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'bool'
+// CHECK:   | |   `-MemberExpr {{.*}} '' .await_ready {{.*}}
+// CHECK:   | | `-ImplicitCastExpr {{.*}} 'const awaitable_frame::result_t' lvalue 
+// CHECK:   | |   `-OpaqueValueExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | | `-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | |   |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | |   | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame'
+// CHECK:   | |   `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |-ExprWithCleanups {{.*}} 'void'
+// CHECK:   | | `-CXXMemberCallExpr {{.*}} 'void'
+// CHECK:   | |   |-MemberExpr {{.*}} '' .await_suspend {{.*}}
+// CHECK:   | |   | `-OpaqueValueExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   |   `-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue
+// CHECK:   | |   | `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}})
+// CHECK:   | |   |   `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t'
+// CHECK:   | |   | |-MemberExpr {{.*}} '' .await_transform {{.*}}
+// CHECK:   | |   | | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame'
+// CHECK:   | |   | `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing
+// CHECK:   | |   `-ImplicitCastExpr {{.*}} 'std::coroutine_handle':'std::coroutine_handle' 
+// CHECK:   | | `-CXXConstructExpr {{.*}} 'std::coroutine_handle':'std::coroutine_handle' 'void (coroutine_handle &&) noexcept'
+//

[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST

2022-04-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:858
   }
   ExprResult Awaitable = buildOperatorCoawaitCall(*this, Loc, E, Lookup);
   if (Awaitable.isInvalid())

sammccall wrote:
> (aside, this variable name is really unfortunate: I think `E` here is the 
> awaitable, and `Awaitable` is the _awaiter_. If this is right, feel free to 
> change it or not...)
I believe you're right, changed it



Comment at: clang/lib/Sema/SemaCoroutine.cpp:865
 
-ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation Loc, Expr *E,
-  bool IsImplicit) {
+ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation Loc, Expr *Operand,
+  Expr *E, bool IsImplicit) {

sammccall wrote:
> Not really your fault, but having two Exprs `Operand` and `E` is terribly 
> confusing in isolation. I think `E` is `Awaiter` in standardese. Again feel 
> free to change or not.
Agreed, changed this as well



Comment at: clang/lib/Sema/TreeTransform.h:7959
+
+  // FIXME: getCurScope() should not be used during template instantiation.
+  // We should pick up the set of unqualified lookup results for operator

Note, I copied this comment from 
[here](https://searchfox.org/llvm/rev/34a68037ddb4dff972c5d8c599cf5edf08fadf6b/clang/lib/Sema/SemaStmt.cpp#2580).



Comment at: clang/lib/Sema/TreeTransform.h:7934
 TreeTransform::TransformCoawaitExpr(CoawaitExpr *E) {
-  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
-/*NotCopyInit*/false);
-  if (Result.isInvalid())
+  // XXX is transforming the operand and the common-expr separately the
+  // right thing to do?

sammccall wrote:
> Ah, this doesn't *sound* right - it's going to create duplicate subexprs I 
> think, and we should really try to have the operand still be a subexpr of the 
> commonexpr like in the non-instantiated case.
> 
> TransformInitListExpr() is a fairly similar case, and it just discards the 
> semantic form and rebuilds from the syntactic one. TransformPseudoObjectExpr 
> seems to be similar.
> 
> I suppose the analogous thing to do here would be to have RebuildCoawaitExpr 
> call Build**Un**resolvedCoawaitExpr with the operand only, but this is a 
> large change! (And suggests maybe we should stop building the semantic forms 
> of dependent coawaits entirely, though that probably would regress 
> diagnostics).
> Maybe worth giving this a spin anyway?
> 
> @rsmith, care to weight in here?
> I suppose the analogous thing to do here would be to have RebuildCoawaitExpr 
> call Build**Un**resolvedCoawaitExpr with the operand only,

I gave this a try.



Comment at: clang/lib/Sema/TreeTransform.h:7947
 
   // Always rebuild; we don't know if this needs to be injected into a new
   // context or if the promise type has changed.

sammccall wrote:
> (FWIW I don't know what "injected into a new context" means, but I don't 
> think the promise type can change since DependentCoawaitExpr was added in 
> 20f25cb6dfb3364847f4c570b1914fe51e585def.)
> 
Is the implication of this that there are some conditions under which we can 
reuse the original CoawaitExpr rather than rebuilding it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115187

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


[PATCH] D123924: [clang-apply-replacements] Added support for adjusting conflict offset.

2022-04-18 Thread gehry via Phabricator via cfe-commits
Sockke created this revision.
Sockke added reviewers: malcolm.parsons, hokein, alexfh.
Herald added a project: All.
Sockke requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

If two different texts are inserted at the same offset, 
clang-apply-replacements prints the conflict error and discard all fixes. This 
patch adds support for adjusting conflict offset and running to fix them 
continually.

https://godbolt.org/z/P938EGoxj doesn't have any fixes when I run 
run-clang-tidy.py to generate a YAML file with clang-tidy and fix them with 
clang-apply-replacements. The YAML file has two different header texts 
insertions at the same offset, unlike clang-tidy with '-fix', 
clang-apply-replacements does not adjust for this conflict.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123924

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/conflict-offset.cpp
  
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/file1.yaml
  clang-tools-extra/test/clang-apply-replacements/conflict-offset.cpp
  clang/include/clang/Tooling/Refactoring/AtomicChange.h


Index: clang/include/clang/Tooling/Refactoring/AtomicChange.h
===
--- clang/include/clang/Tooling/Refactoring/AtomicChange.h
+++ clang/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -116,6 +116,8 @@
   /// Returns a const reference to existing replacements.
   const Replacements &getReplacements() const { return Replaces; }
 
+  Replacements &getRefReplacements() { return Replaces; }
+
   llvm::ArrayRef getInsertedHeaders() const {
 return InsertedHeaders;
   }
Index: clang-tools-extra/test/clang-apply-replacements/conflict-offset.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/conflict-offset.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/Inputs/conflict-offset
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/conflict-offset/conflict-offset.cpp 
> %T/Inputs/conflict-offset/conflict-offset.cpp
+// RUN: sed "s#\$(path)#%/T/Inputs/conflict-offset#" 
%S/Inputs/conflict-offset/file1.yaml > %T/Inputs/conflict-offset/file1.yaml
+// RUN: clang-apply-replacements %T/Inputs/conflict-offset
+// RUN: FileCheck -input-file=%T/Inputs/conflict-offset/conflict-offset.cpp 
%S/Inputs/conflict-offset/conflict-offset.cpp
Index: 
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/file1.yaml
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/file1.yaml
@@ -0,0 +1,24 @@
+---
+MainSourceFile: conflict-offset.cpp
+Diagnostics:
+  - DiagnosticName: test-conflict-offset-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/conflict-offset.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/conflict-offset.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+  - DiagnosticName: test-conflict-offset-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/conflict-offset.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/conflict-offset.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+...
Index: 
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/conflict-offset.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-apply-replacements/Inputs/conflict-offset/conflict-offset.cpp
@@ -0,0 +1,4 @@
+class MyType {};
+// CHECK: #include 
+// CHECK-NEXT: #include 
+// CEHCK-NEXT: class MyType {};
Index: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -231,7 +231,19 @@
 // For now, printing directly the error reported by `AtomicChange` is
 // the easiest solution.
 errs() << llvm::toString(std::move(Err)) << "\n";
-ConflictDetected = true;
+tooling::Replacements &Replacements = FileChange.getRefReplacements();
+unsigned NewOffset = 
Replacements.getShiftedCodePosition(R.getOffset());
+unsigned NewLength =
+Replacements.getShiftedCodePosition(R.getOffset() + R.getLength()) 
-
+NewOffset;
+if (NewLength == R.getLength()) {
+  tooling::Replacement RR = tooling::Replacement(
+  R.getFilePath(), NewOffset, NewLength, R.getReplacementText());
+ 

[PATCH] D123926: [clang] Add a raw_ostream operator<< overload for QualType

2022-04-18 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: rsmith, dblaikie, aaron.ballman.
Herald added a subscriber: martong.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Under the hood this prints the same as `QualType::getAsString()` but cuts out 
the middle-man when that string is sent to another raw_ostream.

Also cleaned up all the call sites where this occurs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123926

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/unittests/AST/ASTTraverserTest.cpp

Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -60,7 +60,7 @@
 if (const auto *F = Init->getAnyMember()) {
   OS << " '" << F->getNameAsString() << "'";
 } else if (auto const *TSI = Init->getTypeSourceInfo()) {
-  OS << " '" << TSI->getType().getAsString() << "'";
+  OS << " '" << TSI->getType() << "'";
 }
   }
 
@@ -81,7 +81,7 @@
 OS << "TemplateArgument";
 switch (A.getKind()) {
 case TemplateArgument::Type: {
-  OS << " type " << A.getAsType().getAsString();
+  OS << " type " << A.getAsType();
   break;
 }
 default:
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -65,14 +65,13 @@
 }
 
 void SymbolCast::dumpToStream(raw_ostream &os) const {
-  os << '(' << ToTy.getAsString() << ") (";
+  os << '(' << ToTy << ") (";
   Operand->dumpToStream(os);
   os << ')';
 }
 
 void SymbolConjured::dumpToStream(raw_ostream &os) const {
-  os << getKindStr() << getSymbolID() << '{' << T.getAsString() << ", LC"
- << LCtx->getID();
+  os << getKindStr() << getSymbolID() << '{' << T << ", LC" << LCtx->getID();
   if (S)
 os << ", S" << S->getID(LCtx->getDecl()->getASTContext());
   else
@@ -90,15 +89,13 @@
 }
 
 void SymbolMetadata::dumpToStream(raw_ostream &os) const {
-  os << getKindStr() << getSymbolID() << '{' << getRegion() << ','
- << T.getAsString() << '}';
+  os << getKindStr() << getSymbolID() << '{' << getRegion() << ',' << T << '}';
 }
 
 void SymbolData::anchor() {}
 
 void SymbolRegionValue::dumpToStream(raw_ostream &os) const {
-  os << getKindStr() << getSymbolID() << '<' << getType().getAsString() << ' '
- << R << '>';
+  os << getKindStr() << getSymbolID() << '<' << getType() << ' ' << R << '>';
 }
 
 bool SymExpr::symbol_iterator::operator==(const symbol_iterator &X) const {
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -401,7 +401,7 @@
 else
   os << ", ";
 
-os << (*I).getType().getAsString();
+os << I->getType();
   }
 
   os << '}';
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -480,7 +480,7 @@
 }
 
 void CXXTempObjectRegion::dumpToStream(raw_ostream &os) const {
-  os << "temp_object{" << getValueType().getAsString() << ", "
+  os << "temp_object{" << getValueType() << ", "
  << "S" << Ex->getID(getContext()) << '}';
 }
 
@@ -497,8 +497,8 @@
 }
 
 void ElementRegion::dumpToStream(raw_ostream &

[PATCH] D123787: [clang][OpenMP][DebugInfo] Debug support for TLS variables when present in OpenMP consructs

2022-04-18 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D123787#3452970 , @aprantl wrote:

>> For an example, if thread local variable is present in copyin clause 
>> (testcase attached with the
>
> patch), parameter with same name is generated as parameter to artificial 
> function. When user
> inquires the thread Local variable, its debug info is hidden by the 
> parameter. The debug info
> for parameters (for thread local) must be suppressed.
>
> What does the dwarfdump output for the old behavior look like? Are the two in 
> the same scope?

The dwarfdump output looks like below. DIE (0x0023) is for actual user 
defined variable and artificial one DIE (0x00b1) is at local scope, the one 
at local scope gets precedence.

  0x000c: DW_TAG_compile_unit
DW_AT_producer("clang version 14.0.0")
DW_AT_language(DW_LANG_C99)
DW_AT_name("debug_threadprivate_copyin.c")
DW_AT_str_offsets_base(0x0008)
DW_AT_stmt_list   (0x)
DW_AT_comp_dir("/home/alok/amdllvm/build.llvm.d")
DW_AT_low_pc  (0x)
DW_AT_high_pc (0x029b)
DW_AT_addr_base   (0x0008)
  
  0x0023:   DW_TAG_variable
  DW_AT_name  ("gbl_dynamic_int")
  DW_AT_type  (0x0036 "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("debug_threadprivate_copyin.c")
  DW_AT_decl_line (22)
  DW_AT_location  (DW_OP_const8u 0x0, 
DW_OP_GNU_push_tls_address)
  
  0x0089:   DW_TAG_subprogram
  DW_AT_low_pc(0x0090)
  DW_AT_high_pc   (0x0260)
  DW_AT_frame_base(DW_OP_reg6 RBP)
  DW_AT_call_all_calls(true)
  DW_AT_name  (".omp_outlined._debug__")
  DW_AT_decl_file ("debug_threadprivate_copyin.c")
  DW_AT_decl_line (35)
  DW_AT_prototyped(true)
  
  0x00b1: DW_TAG_formal_parameter
DW_AT_location(DW_OP_fbreg -32)
DW_AT_name("gbl_dynamic_int")
DW_AT_decl_file   ("debug_threadprivate_copyin.c")
DW_AT_decl_line   (22)
DW_AT_type(0x0154 "int &")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123787

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


Re: [clang-tools-extra] 3eeca52 - Fix wrong signature for std::move and std::swap in test.

2022-04-18 Thread Aaron Ballman via cfe-commits
Thanks for fixing this one. It seems like there's a related bootstrap
failure that may be worth looking into as well:

https://lab.llvm.org/buildbot/#/builders/119/builds/8131
https://lab.llvm.org/buildbot/#/builders/168/builds/5806

~Aaron

On Sun, Apr 17, 2022 at 10:25 PM Richard Smith via cfe-commits
 wrote:
>
>
> Author: Richard Smith
> Date: 2022-04-17T19:25:20-07:00
> New Revision: 3eeca524569744d2927fd13304ab5abb7217e108
>
> URL: 
> https://github.com/llvm/llvm-project/commit/3eeca524569744d2927fd13304ab5abb7217e108
> DIFF: 
> https://github.com/llvm/llvm-project/commit/3eeca524569744d2927fd13304ab5abb7217e108.diff
>
> LOG: Fix wrong signature for std::move and std::swap in test.
>
> Added:
>
>
> Modified:
> 
> clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
>
> Removed:
>
>
>
> 
> diff  --git 
> a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
>  
> b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
> index fb7c089ae8cd6..14d27855d7c5a 100644
> --- 
> a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
> +++ 
> b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
> @@ -3,11 +3,11 @@
>  namespace std {
>
>  template 
> -void swap(T x, T y) {
> +void swap(T &x, T &y) {
>  }
>
>  template 
> -T &&move(T x) {
> +T &&move(T &x) {
>  }
>
>  template 
> @@ -403,7 +403,7 @@ class CopyAndMove1 {
>  class CopyAndMove2 {
>  public:
>CopyAndMove2 &operator=(const CopyAndMove2 &object) {
> -*this = std::move(CopyAndMove2(object));
> +*this = CopyAndMove2(object);
>  return *this;
>}
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123924: [clang-apply-replacements] Added support for adjusting conflict offset.

2022-04-18 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 423355.
Sockke retitled this revision from "[WIP][clang-apply-replacements] Added 
support for adjusting conflict offset." to "[clang-apply-replacements] Added 
support for adjusting conflict offset.".
Sockke added a comment.
Herald added a subscriber: carlosgalvezp.

Add an option to ignore insert conflict.


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

https://reviews.llvm.org/D123924

Files:
  
clang-tools-extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  
clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
  clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
  clang/include/clang/Tooling/Refactoring/AtomicChange.h

Index: clang/include/clang/Tooling/Refactoring/AtomicChange.h
===
--- clang/include/clang/Tooling/Refactoring/AtomicChange.h
+++ clang/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -116,6 +116,8 @@
   /// Returns a const reference to existing replacements.
   const Replacements &getReplacements() const { return Replaces; }
 
+  Replacements &getRefReplacements() { return Replaces; }
+
   llvm::ArrayRef getInsertedHeaders() const {
 return InsertedHeaders;
   }
Index: clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/Inputs/ignore-conflict
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/ignore-conflict/ignore-conflict.cpp > %T/Inputs/ignore-conflict/ignore-conflict.cpp
+// RUN: sed "s#\$(path)#%/T/Inputs/ignore-conflict#" %S/Inputs/ignore-conflict/file1.yaml > %T/Inputs/ignore-conflict/file1.yaml
+// RUN: clang-apply-replacements --ignore-insert-conflict %T/Inputs/ignore-conflict
+// RUN: FileCheck -input-file=%T/Inputs/ignore-conflict/ignore-conflict.cpp %S/Inputs/ignore-conflict/ignore-conflict.cpp
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
@@ -0,0 +1,4 @@
+class MyType {};
+// CHECK: #include 
+// CHECK-NEXT: #include 
+// CEHCK-NEXT: class MyType {};
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
@@ -0,0 +1,24 @@
+---
+MainSourceFile: ignore-conflict.cpp
+Diagnostics:
+  - DiagnosticName: test-ignore-conflict-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/ignore-conflict.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/ignore-conflict.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+  - DiagnosticName: test-ignore-conflict-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/ignore-conflict.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/ignore-conflict.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+...
Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -177,6 +177,7 @@
 def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
   """Calls clang-apply-fixes on a given directory."""
   invocation = [clang_apply_replacements_binary]
+  invocation.append('-ignore-insert-conflict')
   if args.format:
 invocation.append('-format')
   if args.style:
Index: clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
===
--- clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
+++ clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
@@ -42,6 +42,11 @@
  "merging/replacing."),
 cl::init(false), cl::cat(ReplacementCategory));
 
+static cl::opt IgnoreInsertConflict(
+"ignore-insert-conflict",
+cl::desc("Ignore insert conflict and keep running to fix."),
+cl::init(false), cl::cat(ReplacementCategory));
+
 static cl::opt DoFormat(
 "format",
 

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:5281
+  SourceLocation TemplateKwLoc,
+  bool HasTrailingLParen);
+

This parameter is always false, so it seems like it can be dropped.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:688-694
+/// ParseCXXMaybeMutableAgnosticExpression - Handle Expressions inside of
+/// sizeof, decltype, noexcepr
+/// - unqualified-id
+/// - expression
+/// This serves to silence errors about captured variable refered in lambda
+/// parameter list, if they aree used as the unqualified-id of a decltype,
+/// sizeof, or noexcept expression





Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

This feels surprisingly restrictive to me, but it's sufficient for getting 
libstdc++ working again.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:713-715
+}
+  }
+  return ParseExpression();

In the case we get an error from parsing the unqualified id, I don't think we 
want to immediately try to parse an expression, right? Seems like a case to 
return an `ExprError`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123924: [clang-apply-replacements] Added support for adjusting conflict offset.

2022-04-18 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

It stands to reason that there should be no insert conflicts in the YAML 
generated by clang-tidy except for the header insertion. The two checks that 
caused the conflict should be fixed in clang-tidy.


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

https://reviews.llvm.org/D123924

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


[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4889-4890
 return T->isArrayType();
+  case UTT_IsBoundedArray:
+return T->isArrayType() && !T->isIncompleteArrayType();
+  case UTT_IsUnboundedArray:

cjdb wrote:
> aaron.ballman wrote:
> > Is a VLA a bounded array? (We support those as an extension in C++, 
> > unfortunately.)
> `__is_bounded_array(T)` is true when "`T` is an array type of known bound". 
> Do VLAs meet this criteria?
Heh, that's just it -- I don't know what constitutes "known". A VLA that tracks 
its extent "knows" the extent at runtime but possibly not compile time. So it's 
known-ish.

I think there's a few ways we could go about it.

1) all VLAs are unbounded because some VLAs may not have their size known until 
runtime
2) check the VLA's size expression and if we can find any way to constant 
evaluate it to a known value, then it's a bounded array
3) make it an error to call this function with a VLA

My intuition is that #3 is the safest approach, but that #1 probably is 
sufficiently defensible as well. I worry a little bit that #2 will give 
surprising results without more investigation/effort (we sometimes fold VLAs 
into constant arrays, and I think users would expect this API to mirror that 
behavior).



Comment at: clang/test/SemaCXX/type-traits.cpp:764
+  int t30[F(__is_bounded_array(void*))];
+  int t31[F(__is_bounded_array(cvoid*))];
+}

cjdb wrote:
> aaron.ballman wrote:
> > Any reason there's not a test with something like `int[10]` and `int[]`? 
> > (Same below.)
> Those are `IntAr` and `IntArNB` at the very top. I can rename those if you'd 
> like.
Oh, yeah, I totally missed that, thank you!

Up to you on the rename, so long as we have the coverage, that's the crucial 
bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116280

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

aaron.ballman wrote:
> This feels surprisingly restrictive to me, but it's sufficient for getting 
> libstdc++ working again.
I've can't think of another kind of unqualified-id that could refer to a 
capturable entity here.
Do you know what would be missing?
Also, without being very restrictive, I'm not sure how this is implementable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123924: [clang-apply-replacements] Added an option to ignore insert conflict.

2022-04-18 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 423359.
Sockke retitled this revision from "[clang-apply-replacements] Added support 
for adjusting conflict offset." to "[clang-apply-replacements] Added an option 
to ignore insert conflict.".

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

https://reviews.llvm.org/D123924

Files:
  
clang-tools-extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  
clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
  clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
  clang/include/clang/Tooling/Refactoring/AtomicChange.h

Index: clang/include/clang/Tooling/Refactoring/AtomicChange.h
===
--- clang/include/clang/Tooling/Refactoring/AtomicChange.h
+++ clang/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -116,6 +116,8 @@
   /// Returns a const reference to existing replacements.
   const Replacements &getReplacements() const { return Replaces; }
 
+  Replacements &getRefReplacements() { return Replaces; }
+
   llvm::ArrayRef getInsertedHeaders() const {
 return InsertedHeaders;
   }
Index: clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/ignore-conflict.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/Inputs/ignore-conflict
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/ignore-conflict/ignore-conflict.cpp > %T/Inputs/ignore-conflict/ignore-conflict.cpp
+// RUN: sed "s#\$(path)#%/T/Inputs/ignore-conflict#" %S/Inputs/ignore-conflict/file1.yaml > %T/Inputs/ignore-conflict/file1.yaml
+// RUN: clang-apply-replacements --ignore-insert-conflict %T/Inputs/ignore-conflict
+// RUN: FileCheck -input-file=%T/Inputs/ignore-conflict/ignore-conflict.cpp %S/Inputs/ignore-conflict/ignore-conflict.cpp
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/ignore-conflict.cpp
@@ -0,0 +1,4 @@
+class MyType {};
+// CHECK: #include 
+// CHECK-NEXT: #include 
+// CEHCK-NEXT: class MyType {};
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/ignore-conflict/file1.yaml
@@ -0,0 +1,24 @@
+---
+MainSourceFile: ignore-conflict.cpp
+Diagnostics:
+  - DiagnosticName: test-ignore-conflict-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/ignore-conflict.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/ignore-conflict.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+  - DiagnosticName: test-ignore-conflict-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/ignore-conflict.cpp
+  FileOffset: 0
+  Replacements:
+- FilePath:$(path)/ignore-conflict.cpp
+  Offset:  0
+  Length:  0
+  ReplacementText: "#include \n"
+...
Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -177,6 +177,7 @@
 def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
   """Calls clang-apply-fixes on a given directory."""
   invocation = [clang_apply_replacements_binary]
+  invocation.append('-ignore-insert-conflict')
   if args.format:
 invocation.append('-format')
   if args.style:
Index: clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
===
--- clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
+++ clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
@@ -42,6 +42,11 @@
  "merging/replacing."),
 cl::init(false), cl::cat(ReplacementCategory));
 
+static cl::opt IgnoreInsertConflict(
+"ignore-insert-conflict",
+cl::desc("Ignore insert conflict and keep running to fix."),
+cl::init(false), cl::cat(ReplacementCategory));
+
 static cl::opt DoFormat(
 "format",
 cl::desc("Enable formatting of code changed by applying replacements.\n"
@@ -131,7 +136,7 @@
   SourceManager SM

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:5281
+  SourceLocation TemplateKwLoc,
+  bool HasTrailingLParen);
+

aaron.ballman wrote:
> This parameter is always false, so it seems like it can be dropped.
Not if we extend to `sizeof id` - I guess i can drop it for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123787: [clang][OpenMP][DebugInfo] Debug support for TLS variables when present in OpenMP consructs

2022-04-18 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok updated this revision to Diff 423362.
alok added a comment.

Re-based.


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

https://reviews.llvm.org/D123787

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c

Index: clang/test/OpenMP/debug_threadprivate_copyin.c
===
--- /dev/null
+++ clang/test/OpenMP/debug_threadprivate_copyin.c
@@ -0,0 +1,59 @@
+// This testcase checks emission of debug info for threadprivate variables
+// present in any clause of OpenMP construct.
+
+// REQUIRES: x86_64-linux
+
+// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: define internal void @.omp_outlined._debug__(
+// CHECK: call void @llvm.dbg.declare(metadata ptr %.global_tid..addr,
+// CHECK: call void @llvm.dbg.declare(metadata ptr %.bound_tid..addr,
+// CHECK: call void @llvm.dbg.declare(metadata ptr %nt.addr
+// CHECK: store ptr %gbl_dynamic_int, ptr %gbl_dynamic_int.addr, align 8
+// CHECK-NOT: call void @llvm.dbg.declare(metadata ptr %gbl_dynamic_int.addr
+// CHECK-NOT: call void @llvm.dbg.declare(metadata ptr %gbl_static_int.addr
+
+extern int printf(const char *, ...);
+extern void omp_set_num_threads(int);
+extern int omp_get_num_threads(void);
+extern int omp_get_thread_num(void);
+
+int gbl_dynamic_int;
+__thread int gbl_static_int;
+
+#pragma omp threadprivate(gbl_dynamic_int)
+
+int main() {
+  int nt = 0;
+  int offset = 10;
+  gbl_dynamic_int = 55;
+  gbl_static_int = 77;
+
+  omp_set_num_threads(4);
+#pragma omp parallel copyin(gbl_dynamic_int, gbl_static_int)
+  {
+int data;
+int tid;
+nt = omp_get_num_threads();
+tid = omp_get_thread_num();
+data = gbl_dynamic_int + gbl_static_int;
+gbl_dynamic_int += 10;
+gbl_static_int += 20;
+#pragma omp barrier
+if (tid == 0)
+  printf("In parallel region total threads = %d, thread id = %d data=%d gbl_dyn_addr = %p, gbl_static_addr = %p\n",
+ nt, tid, data, &gbl_dynamic_int, &gbl_static_int);
+if (tid == 1)
+  printf("In parallel region total threads = %d, thread id = %d data=%d gbl_dyn_addr = %p, gbl_static_addr = %p\n",
+ nt, tid, data, &gbl_dynamic_int, &gbl_static_int);
+if (tid == 2)
+  printf("In parallel region total threads = %d, thread id = %d data=%d gbl_dyn_addr = %p, gbl_static_addr = %p\n",
+ nt, tid, data, &gbl_dynamic_int, &gbl_static_int);
+if (tid == 3)
+  printf("In parallel region total threads = %d, thread id = %d data=%d gbl_dyn_addr = %p, gbl_static_addr = %p\n",
+ nt, tid, data, &gbl_dynamic_int, &gbl_static_int);
+  }
+
+  return 0;
+}
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -481,7 +481,11 @@
 if (ArgType->isVariablyModifiedType())
   ArgType = getCanonicalParamType(Ctx, ArgType);
 VarDecl *Arg;
-if (DebugFunctionDecl && (CapVar || I->capturesThis())) {
+if (CapVar && (CapVar->getTLSKind() != clang::VarDecl::TLS_None)) {
+  Arg = ImplicitParamDecl::Create(Ctx, /*DC=*/nullptr, FD->getLocation(),
+  II, ArgType,
+  ImplicitParamDecl::ThreadPrivateVar);
+} else if (DebugFunctionDecl && (CapVar || I->capturesThis())) {
   Arg = ParmVarDecl::Create(
   Ctx, DebugFunctionDecl,
   CapVar ? CapVar->getBeginLoc() : FD->getBeginLoc(),
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2442,6 +2442,7 @@
 /// for the specified parameter and set up LocalDeclMap.
 void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
unsigned ArgNo) {
+  bool NoDebugInfo = false;
   // FIXME: Why isn't ImplicitParamDecl a ParmVarDecl?
   assert((isa(D) || isa(D)) &&
  "Invalid argument to EmitParmDecl");
@@ -2461,6 +2462,10 @@
   setBlockContextParameter(IPD, ArgNo, V);
   return;
 }
+// Suppressing debug info for ThreadPrivateVar parameters, else it hides
+// debug info of TLS variables.
+NoDebugInfo =
+(IPD->getParameterKind() == ImplicitParamDecl::ThreadPrivateVar);
   }
 
   Address DeclPtr = Address::invalid();
@@ -2591,7 +2596,8 @@
 
   // Emit debug info for param declarations in non-thunk functions.
   if (CGDebugInfo *DI = getDebugInfo()) {
-if (CGM.getCodeGenOpts().hasReducedDebugInfo() && !CurFuncIsThunk) {
+if (CGM.getCodeGenOpts().hasReducedDebugInfo() && !CurFuncIsThunk &&
+!NoDebugInfo) {
   llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariab

[PATCH] D122008: [flang][driver] Add support for generating executables

2022-04-18 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Do you plan to discuss this again at during the next call? Note that today is a 
holiday in various country in Europe (maybe elsewhere too) so the one on 4/27 
is probably better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122008

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 423363.
cor3ntin marked an inline comment as done.
cor3ntin added a comment.

Address Aaron's feedback

- Typos
- Remove unused parameters
- return ExprError() if ParseUnqualifiedId fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,13 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,20 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  InMutableAgnosticContext = true;
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+ SourceLocation(), Id,
+ /*

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:5281
+  SourceLocation TemplateKwLoc,
+  bool HasTrailingLParen);
+

cor3ntin wrote:
> aaron.ballman wrote:
> > This parameter is always false, so it seems like it can be dropped.
> Not if we extend to `sizeof id` - I guess i can drop it for now?
I'd drop for now -- we can add it in later when we get around to doing the full 
core issue once it's settled.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

cor3ntin wrote:
> aaron.ballman wrote:
> > This feels surprisingly restrictive to me, but it's sufficient for getting 
> > libstdc++ working again.
> I've can't think of another kind of unqualified-id that could refer to a 
> capturable entity here.
> Do you know what would be missing?
> Also, without being very restrictive, I'm not sure how this is implementable
What I find restrictive is that it requires an unqualified-id *only* to kick in 
as being maybe mutable agnostic. e.g., `decltype(id)` and `decltype(+id)` 
(where the unary + may be an overloaded operator that depends on the mutability 
of the `this` object).

(I'm not seeing the principle that guides this restriction proposed in the core 
issue yet, but those can be hashed out later.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


Re: [PATCH] D123479: [clang-tidy] Support parenthesized literals in modernize-macro-to-enum

2022-04-18 Thread Jaime Venegas via cfe-commits

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


Re: [clang] 2121dc5 - [llvm-lto] Remove support for legacy pass manager

2022-04-18 Thread Jaime Venegas via cfe-commits

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

We should probably add a release note that says we partially implement CWG 2569 
(just the `decltype` portion) and that the core issue has not yet been approved 
by WG21 but the changes are needed to keep libstdc++ working.




Comment at: clang/lib/Parse/ParseExprCXX.cpp:710
+   /*TemplateKWLoc=*/nullptr, Name))
+  return ExprError();
+return Actions.ActOnMutableAgnosticIdExpression(getCurScope(), SS, Name);

Sorry, I forgot to mention this before, but there should be some test coverage 
for this case to make sure the behavior is still reasonable. Something like:
```
void whatever() {
  [=](){};
}
```
(I'd expect we get some sort of lookup error for `b`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

aaron.ballman wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > This feels surprisingly restrictive to me, but it's sufficient for 
> > > getting libstdc++ working again.
> > I've can't think of another kind of unqualified-id that could refer to a 
> > capturable entity here.
> > Do you know what would be missing?
> > Also, without being very restrictive, I'm not sure how this is implementable
> What I find restrictive is that it requires an unqualified-id *only* to kick 
> in as being maybe mutable agnostic. e.g., `decltype(id)` and `decltype(+id)` 
> (where the unary + may be an overloaded operator that depends on the 
> mutability of the `this` object).
> 
> (I'm not seeing the principle that guides this restriction proposed in the 
> core issue yet, but those can be hashed out later.)
I do not think there is a general answer to "given these captures and this 
arbitrarily complex expression", would the mutability of the lambda affect the 
declaration of the parameters.
In this case we know it doesn't and that happen  to fix existing code, which 
make the solution tractable.
If core was keen to add any more complexity here, I think they should consider 
mandating a look-ahead of the `mutable` keyword even if that sounds rather 
complex. I don't think it will come to that, the proposed resolution will be 
good enough to reduce the blast radius of the paper, and I don't see a strong 
motivation to add even more complexity here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D120290: [Clang][OpenMP] Add the codegen support for `atomic compare capture`

2022-04-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11663
   X = BO->getLHS();
-  D = BO->getRHS();
+  D = BO->getRHS()->IgnoreImpCasts();
 

Why do we need to use `IgnoreImpCasts()` here and in other places?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120290

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

cor3ntin wrote:
> aaron.ballman wrote:
> > cor3ntin wrote:
> > > aaron.ballman wrote:
> > > > This feels surprisingly restrictive to me, but it's sufficient for 
> > > > getting libstdc++ working again.
> > > I've can't think of another kind of unqualified-id that could refer to a 
> > > capturable entity here.
> > > Do you know what would be missing?
> > > Also, without being very restrictive, I'm not sure how this is 
> > > implementable
> > What I find restrictive is that it requires an unqualified-id *only* to 
> > kick in as being maybe mutable agnostic. e.g., `decltype(id)` and 
> > `decltype(+id)` (where the unary + may be an overloaded operator that 
> > depends on the mutability of the `this` object).
> > 
> > (I'm not seeing the principle that guides this restriction proposed in the 
> > core issue yet, but those can be hashed out later.)
> I do not think there is a general answer to "given these captures and this 
> arbitrarily complex expression", would the mutability of the lambda affect 
> the declaration of the parameters.
> In this case we know it doesn't and that happen  to fix existing code, which 
> make the solution tractable.
> If core was keen to add any more complexity here, I think they should 
> consider mandating a look-ahead of the `mutable` keyword even if that sounds 
> rather complex. I don't think it will come to that, the proposed resolution 
> will be good enough to reduce the blast radius of the paper, and I don't see 
> a strong motivation to add even more complexity here.
Eh, I'm less convinced. The changes in P2036R3 were a band-aid to fix mistakes. 
The core issue "fixing" it is another band-aid over the top of P2036R3. My 
experience is that band-aids over band-aids rarely leads to a good feature that 
users can make sense of. The fact that I can't make heads or tails of what the 
actual language design rule is here also means this is painful for us 
supporting our own extensions (like `alignof` on an object instead of a type, 
`__typeof__` instead of `decltype`, etc).

Personally, I'd prefer the core issue was resolved in a more clean fashion than 
carving out a few exceptions under the hope that it's "good enough". However, 
that's something for us to fight about in Core when this comes up. For the 
moment, I'm happy enough with this because it gets libstdc++ unstuck.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123313: [OpenMP] Make clang argument handling for the new driver more generic

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123313

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


[PATCH] D123325: [Clang] Make enabling the new driver more generic

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123325

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


[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-18 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

@DavidSpickett @chill @momchil.velikov May I get some comments on the 
`arm/aarch64` related code changes? Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:700
+
+  if (Tok.is(tok::identifier) && NextToken().is(tok::r_paren)) {
+SourceLocation TemplateKWLoc;

aaron.ballman wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > aaron.ballman wrote:
> > > > > This feels surprisingly restrictive to me, but it's sufficient for 
> > > > > getting libstdc++ working again.
> > > > I've can't think of another kind of unqualified-id that could refer to 
> > > > a capturable entity here.
> > > > Do you know what would be missing?
> > > > Also, without being very restrictive, I'm not sure how this is 
> > > > implementable
> > > What I find restrictive is that it requires an unqualified-id *only* to 
> > > kick in as being maybe mutable agnostic. e.g., `decltype(id)` and 
> > > `decltype(+id)` (where the unary + may be an overloaded operator that 
> > > depends on the mutability of the `this` object).
> > > 
> > > (I'm not seeing the principle that guides this restriction proposed in 
> > > the core issue yet, but those can be hashed out later.)
> > I do not think there is a general answer to "given these captures and this 
> > arbitrarily complex expression", would the mutability of the lambda affect 
> > the declaration of the parameters.
> > In this case we know it doesn't and that happen  to fix existing code, 
> > which make the solution tractable.
> > If core was keen to add any more complexity here, I think they should 
> > consider mandating a look-ahead of the `mutable` keyword even if that 
> > sounds rather complex. I don't think it will come to that, the proposed 
> > resolution will be good enough to reduce the blast radius of the paper, and 
> > I don't see a strong motivation to add even more complexity here.
> Eh, I'm less convinced. The changes in P2036R3 were a band-aid to fix 
> mistakes. The core issue "fixing" it is another band-aid over the top of 
> P2036R3. My experience is that band-aids over band-aids rarely leads to a 
> good feature that users can make sense of. The fact that I can't make heads 
> or tails of what the actual language design rule is here also means this is 
> painful for us supporting our own extensions (like `alignof` on an object 
> instead of a type, `__typeof__` instead of `decltype`, etc).
> 
> Personally, I'd prefer the core issue was resolved in a more clean fashion 
> than carving out a few exceptions under the hope that it's "good enough". 
> However, that's something for us to fight about in Core when this comes up. 
> For the moment, I'm happy enough with this because it gets libstdc++ unstuck.
> The changes in P2036R3 were a band-aid to fix mistakes. The core issue 
> "fixing" it is another band-aid over the top of P2036R3. 

Agreed, but, the question is how many people will run into scenario not covered 
by the band-aid in existing code?
And this is why I'm not a fan of generalizing to `sizeof`/`noexcept` because 
it' sounds arbitrary and unmotivated, and if we have more than one bandaid we 
should consider a general solution.

Basically either that or `mutable` look-ahead, i don't see an in-between 
solution as being viable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

1 nit, otherwise no comments.




Comment at: clang/lib/Sema/SemaExpr.cpp:2703
+  UnqualifiedId &Id) {
+  InMutableAgnosticContext = true;
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/

I would probably prefer a RAII object for this bool. It makes it easier later 
on if we decide this is something that needs to be enabled/disabled in a stack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 423365.
cor3ntin added a comment.

- Add a release note
- Add tests for lookup errors in decltype expressions in lambda parameters 
clause


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,15 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+
+  (void)[=](decltype(not_a_thing)){}; //expected-error 2{{use of undeclared identifier 'not_a_thing'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,20 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  InMutableAgnosticContext = true;
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+ 

[PATCH] D123612: [Driver] Support linking to compiler-rt on AVR

2022-04-18 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 423366.

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

https://reviews.llvm.org/D123612

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins-avr5.a
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -58,3 +58,12 @@
 // NOGCC-NOT: warning: {{.*}} microcontroller
 // NOGCC-NOT: warning: {{.*}} avr-libc
 // NOGCC-NOT: warning: {{.*}} data section address
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// LIBGCC: "-lgcc"
+// LIBGCC-NOT: libclang_rt
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// COMRT: libclang_rt.builtins-avr5.a
+// COMRT-NOT: "-lgcc"
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -34,11 +34,20 @@
   llvm::Optional findAVRLibcInstallation() const;
   StringRef getGCCInstallPath() const { return GCCInstallPath; }
 
+  std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args,
+  StringRef Component, FileType Type,
+  bool AddArch) const override;
+
+  std::string getCompilerRTPath() const override;
+
+  ToolChain::RuntimeLibType GetDefaultRuntimeLibType() const override;
+
 protected:
   Tool *buildLinker() const override;
 
 private:
   StringRef GCCInstallPath;
+  std::string MCU;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,14 +370,13 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  MCU = getCPUName(D, Args, Triple);
+  if (MCU.empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs) &&
-  GCCInstallation.isValid()) {
+  !Args.hasArg(options::OPT_nodefaultlibs) && GCCInstallation.isValid()) {
 GCCInstallPath = GCCInstallation.getInstallPath();
 std::string GCCParentPath(GCCInstallation.getParentLibPath());
 getProgramPaths().push_back(GCCParentPath + "/../bin");
@@ -415,6 +415,36 @@
 CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
+std::string
+AVRToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
+  StringRef Component, FileType Type,
+  bool AddArch) const {
+  // Each device family has its own compiler-rt build.
+  std::string Arch;
+  if (AddArch) {
+Optional FamilyName = GetMCUFamilyName(MCU);
+if (FamilyName)
+  Arch = "-" + (*FamilyName).str();
+  }
+  // libgcc distributed with avr-gcc always named 'libgcc.a' even on windows.
+  return (Twine("libclang_rt.") + Component + Arch + ".a").str();
+}
+
+std::string AVRToolChain::getCompilerRTPath() const {
+  // Return default path appended with "/avr", if it exists.
+  SmallString<128> Path(ToolChain::getCompilerRTPath());
+  llvm::sys::path::append(Path, "avr");
+  if (llvm::sys::fs::is_directory(Path))
+return std::string(Path.str());
+  // Fall back to default.
+  return ToolChain::getCompilerRTPath();
+}
+
+ToolChain::RuntimeLibType AVRToolChain::GetDefaultRuntimeLibType() const {
+  return GCCInstallation.isValid() ? ToolChain::RLT_Libgcc
+   : ToolChain::RLT_CompilerRT;
+}
+
 Tool *AVRToolChain::buildLinker() const {
   return new tools::AVR::Linker(getTriple(), *this);
 }
@@ -445,13 +475,19 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
+  // Get the runtime library, cur

[PATCH] D123182: [Concepts] Fix overload resolution bug with constrained candidates

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Pretty sure those OMP bugs are unrelated, we've been seeing those a ton lately 
on just about every patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123182

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


[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: beanz.
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3978
+"compute", "raygeneration", "intersection",
+"anyhit", "closestHit", "miss", "callable", "mesh",
+"amplification"],

`anyhit` vs `closestHit` in terms of capitalization seems a bit surprising to 
me -- is that intentional?



Comment at: clang/include/clang/Basic/AttrDocs.td:6386-6388
+The ``shader`` attribute applies to HLSL shader entry functions to identify the
+ shader stage for the entry function.
+  }];

Please add enough documentation that a user has a chance to use this feature 
properly (and it's fine to link to other documentation for more details if 
there's canonical documentation elsewhere that we don't want to duplicate).



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11598-11599
 def err_hlsl_attribute_param_mismatch : Error<"%0 attribute parameters do not 
match the previous declaration">;
+def err_hlsl_invalid_attribute_argument : Error<
+  "%0 attribute argument not supported: %1">;
 

Almost every other attribute warns on this situation and then ignores the 
attribute; why should this be a hard error? (A warning allows other 
implementations to support more enumeration values without breaking the user's 
code in Clang.)



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6944-6947
+  if (AL.getNumArgs() != 1) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }

Hmm, doesn't the common attribute handling logic already deal with this case? 
(It does for other attribute syntaxes, but we have almost no attributes using 
the Microsoft `[]` syntax, so I wouldn't be surprised if we need to add that 
logic.)



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6961
+
+  // TODO: check function match the shader stage.
+

Are you planning to do this TODO as part of this patch, or is this a FIXME 
someone needs to handle later?



Comment at: clang/test/SemaHLSL/shader_attr.hlsl:20
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("vertex")]
+static void oops() {}

Formatting looks off here.

Also, the diagnostic text leaves a bit to be desired (this is more of a general 
problem with the `HLSLEntry` subject, so don't worry about it for your patch) 
-- this is a global function.



Comment at: clang/test/SemaHLSL/shader_attr.hlsl:25
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("vertex")]
+static void oops() {}

Formatting looks off here as well. I'm guessing clang-format doesn't do 
anything good with Microsoft-style attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 423367.
cor3ntin added a comment.

- Use a RAII class to control InMutableAgnosticContext
- Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,15 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+
+  (void)[=](decltype(not_a_thing)){}; // expected-error 2{{use of undeclared identifier 'not_a_thing'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,20 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  MutableAgnosticContextRAII Ctx(*this);
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+ Sourc

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:2703
+  UnqualifiedId &Id) {
+  InMutableAgnosticContext = true;
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/

erichkeane wrote:
> I would probably prefer a RAII object for this bool. It makes it easier later 
> on if we decide this is something that needs to be enabled/disabled in a 
> stack.
Agreed, it's better


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision as: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a nit (forgot to remove a line covered by RAII).




Comment at: clang/lib/Sema/SemaExpr.cpp:2704-2712
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+ SourceLocation(), Id,
+ /*HasTrailingLParen*/ false,
+ /*IsAddressOfOperand*/ false,
+ /*CorrectionCandidateCallback*/ nullptr,
+ /*IsInlineAsmIdentifier*/ false,
+ /*KeywordReplacement*/ nullptr);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added subscribers: urnathan, erichkeane.
hvdijk added a comment.

ping. Apologies, I don't know who to add as a reviewer, there is no one 
specifically listed as code owner and it does not seem to be handled by anyone 
in particular. @urnathan, @erichkeane, you two appear to be the most recent 
people who pushed commits specifically for mangling issues, would either of you 
be able to review this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 423368.
cor3ntin added a comment.

Thanks Aaron, let's pretend this did not happen :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,15 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+
+  (void)[=](decltype(not_a_thing)){}; // expected-error 2{{use of undeclared identifier 'not_a_thing'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,19 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  MutableAgnosticContextRAII Ctx(*this);
+  ExprResult Res = ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+ SourceLocation(), Id,

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@rjmccall  is the expert on the Itanium ABI.

Code wise, I have no real comments, though he might.  As far as:

>> Question: does this need to be covered by -fclang-abi-compat= when the prior 
>> mangling resulted in names that even llvm-cxxfilt agreed made no sense? (If 
>> it is needed, it should be an easy change.)

I believe the answer here is 'yes'.  We also likely need release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 423370.
cor3ntin added a comment.

... and we don't need a local variable anymore either


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,15 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+
+  (void)[=](decltype(not_a_thing)){}; // expected-error 2{{use of undeclared identifier 'not_a_thing'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,18 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  MutableAgnosticContextRAII Ctx(*this);
+  return ActOnIdExpression(S, SS, /*TemplateKwLoc*/
+   SourceLocation(), Id,
+

[PATCH] D123837: [C++20] [Modules] Judge isInCurrentModule currently

2022-04-18 Thread Iain Sandoe via Phabricator via cfe-commits
iains added inline comments.



Comment at: clang/include/clang/Basic/Module.h:537-543
+  static StringRef getPrimaryModuleInterfaceName(StringRef Name) {
+return Name.split(':').first;
+  }
+
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
+return getPrimaryModuleInterfaceName(getTopLevelModuleName());

I do not understand the purpose of this change, we already iterated over making 
the function more efficient.

For C++20 modules there cannot be more than one parent - so that the nested 
call to getTopLevelModule(), via getTopLevelModuleName() is redundant.

Is there some other case that needs special handling?
(If so then I think we should guard this at a higher level)




Comment at: clang/lib/Sema/SemaLookup.cpp:1567-1568
+
+  return M->getPrimaryModuleInterfaceName() ==
+ Module::getPrimaryModuleInterfaceName(LangOpts.CurrentModule);
 }

... of course, "correctness before optimisation", but this test function seems 
like it would benefit from some refactoring as suggested below.

it seems a bit unfortunate that we are placing a string comparison in the 
"acceptable decl" lookup path, which might be made many times (the previous use 
of the string compare was in making the module decl - which only happens once 
in a TU).

* Sema has visibility of the import graph of modules (via DirectModuleImports 
and Exports).
* We also know what the module parse state is (FirstDecl, GMF etc)
* If were are not parsing a module (i.e. LangOpts.CurrentModule.empty()) the we 
could return false early?
* if ModuleScopes is empty we know we are not (yet) parsing a module
* Once we are parsing a module then we can test ModuleScopes.back() to find the 
current module 

there are only two users of isInCurrentModule() - so maybe we refactor could 
make more use of the higher level state information - and / or cache 
information on the parents of partitions  to  avoid the complexity of parsing 
strings each time.

what do you think?



Comment at: clang/test/Modules/cxx20-10-1-ex2.cpp:62-69
+// According to [module.import]p7:
+//   Additionally, when a module-import-declaration in a module unit of some
+//   module M imports another module unit U of M, it also imports all 
+//   translation units imported by non-exported module-import-declarations in
+//   the module unit purview of U.
+//
+// So B is imported in B:X3 due to B:X2 imported B. So n is visible here.

@rsmith 

so, I wonder if this is intended, it seems to defeat the mechanisms to avoid 
circular dependencies.

TU1:
module M : Impl; // this is said not to generate a circular dependency because 
M : Impl does not implicitly import M

import M;  // but now we've done it manually ... and if that module is 
implicitly exported to importers of the Impl. module interface


TU2:

export module M;
import : Impl; 

// ...  then boom! we have a circular dep.




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

https://reviews.llvm.org/D123837

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


[clang] daa6d7b - [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-04-18T15:58:25+02:00
New Revision: daa6d7b250edb81ffef7770a71049d7af211698b

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

LOG: [Clang] Use of decltype(capture) in parameter-declaration-clause

Partially implement the proposed resolution to CWG2569.

D119136 broke some libstdc++ code, as P2036R3, implemented as a DR to
C++11 made ill-formed some previously valid and innocuous code.

We resolve this issue to allow decltype(x) - but not decltype((x)
to appear in the parameter list of a lambda that capture x by copy.

Unlike CWG2569, we do not extend that special treatment to
sizeof/noexcept yet, as the resolution has not been approved yet
and keeping the review small allows a quicker fix of impacted code.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2aabeaf6d679f..fd4eac5458c0a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -261,6 +261,8 @@ C++2b Feature Support
 - Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_.
   This proposal modifies how variables captured in lambdas can appear in 
trailing return type
   expressions and how their types are deduced therein, in all C++ language 
versions.
+  `CWG2569 `_ is also 
partially implemented so that
+  `[x](decltype(x)){}` doesn't become ill-formed with the adoption of P2036R3.
 
 CUDA Language Changes in Clang
 --

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 3046962dddec4..e9b1fa0f27451 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1861,6 +1861,8 @@ class Parser : public CodeCompletionHandler {
  Token &Replacement);
   ExprResult ParseCXXIdExpression(bool isAddressOfOperand = false);
 
+  ExprResult ParseCXXMaybeMutableAgnosticExpression();
+
   bool areTokensAdjacent(const Token &A, const Token &B);
 
   void CheckForTemplateAndDigraph(Token &Next, ParsedType ObjectTypePtr,

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 95ce074fdccd3..e2ae02ea9f76f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -787,6 +787,23 @@ class Sema final {
   /// context.
   unsigned FunctionScopesStart = 0;
 
+  /// Whether we are currently in the context of a mutable agnostic identifier
+  /// as described by CWG2569.
+  /// We are handling the unqualified-id of a decltype or noexcept expression.
+  bool InMutableAgnosticContext = false;
+
+  /// RAII object used to change the value of \c InMutableAgnosticContext
+  /// within a \c Sema object.
+  class MutableAgnosticContextRAII {
+Sema &SemaRef;
+
+  public:
+MutableAgnosticContextRAII(Sema &S) : SemaRef(S) {
+  SemaRef.InMutableAgnosticContext = true;
+}
+~MutableAgnosticContextRAII() { SemaRef.InMutableAgnosticContext = false; }
+  };
+
   ArrayRef getFunctionScopes() const {
 return llvm::makeArrayRef(FunctionScopes.begin() + FunctionScopesStart,
   FunctionScopes.end());
@@ -5270,6 +5287,9 @@ class Sema final {
   CorrectionCandidateCallback *CCC = nullptr,
   bool IsInlineAsmIdentifier = false, Token *KeywordReplacement = nullptr);
 
+  ExprResult ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id);
+
   void DecomposeUnqualifiedId(const UnqualifiedId &Id,
   TemplateArgumentListInfo &Buffer,
   DeclarationNameInfo &NameInfo,

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 9cf9f7cc4c371..e367417410c86 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1054,7 +1054,7 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec 
&DS) {
   Actions, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
   Sema::ExpressionEvaluationContextRecord::EK_Decltype);
   Result = Actions.CorrectDelayedTyposInExpr(
-  ParseExpression(), /*InitDecl=*/nullptr,
+  ParseCXXMaybeMutableAgnosticExpression(), /*InitDecl=*/nullptr,
   /*RecoverUncorrectedTypos=*/false,
   [](Expr *E) { retur

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot 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 rGdaa6d7b250ed: [Clang] Use of decltype(capture) in 
parameter-declaration-clause (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- clang/test/SemaCXX/lambda-capture-type-deduction.cpp
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -87,23 +87,23 @@
   int y, z;// expected-note 2{{declared here}}
   auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
   decltype(
-  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+  [&] { return 0; }) y) { // expected-error{{captured variable 'y' cannot appear here}}
 return y;
   };
 
-  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init_tpl = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&] { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
   auto implicit = [=]( // expected-note {{variable 'z' is captured here}}
   decltype(
-  [&](decltype(z)) { return 0; }) z) { //expected-error{{captured variable 'z' cannot appear here}}
+  [&](decltype((z))) { return 0; }) z) { // expected-error{{captured variable 'z' cannot appear here}}
 return z;
   };
 
-  auto init = [x = 1](  // expected-note{{explicitly captured here}}
-  decltype([&](decltype(x)) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
+  auto init = [x = 1](// expected-note{{explicitly captured here}}
+  decltype([&](decltype((x))) { return 0; }) y) { // expected-error {{captured variable 'x' cannot appear here}}
 return x;
   };
 
@@ -141,20 +141,20 @@
   decltype([&](
decltype([=]( // expected-note {{variable 'x' is captured here}}
 decltype([&](
- decltype([&](decltype(x)) {}) // expected-error{{captured variable 'x' cannot appear here}}
+ decltype([&](decltype((x))) {}) // expected-error{{captured variable 'x' cannot appear here}}
  ) {})) {})) {})){};
 
   (void)[&](
   decltype([&](
decltype([&](
 decltype([&](
- decltype([&](decltype(y)) {})) {})) {})) {})){};
+ decltype([&](decltype((y))) {})) {})) {})) {})){};
 
   (void)[=](
   decltype([=](
decltype([=](
-decltype([=](  // expected-note {{variable 'z' is captured here}}
- decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
+decltype([=](// expected-note {{variable 'z' is captured here}}
+ decltype([&] {}) // expected-error{{captured variable 'z' cannot appear here}}
  ) {})) {})) {})){};
 }
 
@@ -171,3 +171,15 @@
   dependent(r);
   dependent(cr);
 }
+
+void test_CWG2569_tpl(auto a) {
+  (void)[=](decltype(a) b = decltype(a)()){};
+}
+
+void test_CWG2569() {
+  int a = 0;
+  (void)[=](decltype(a) b = decltype(a)()){};
+  test_CWG2569_tpl(0);
+
+  (void)[=](decltype(not_a_thing)){}; // expected-error 2{{use of undeclared identifier 'not_a_thing'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,6 +2698,18 @@
   return BuildDeclarationNameExpr(SS, R, ADL);
 }
 
+ExprResult Sema::ActOnMutableAgnosticIdExpression(Scope *S, CXXScopeSpec &SS,
+  UnqualifiedId &Id) {
+  MutableAgnosticContextRAII Ctx(*thi

[PATCH] D123909: [Clang] Use of decltype(capture) in parameter-declaration-clause

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman @erichkeane Thanks for the review - I've landed it. Hopefully 
the remediation should be enough so that libstdc++ is no longer affected but we 
should still keep an eye out for further issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123909

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

The remediation has landed, sorry again for the trouble this caused, I'll keep 
an eye out for further issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-18 Thread Noel Grandin via Phabricator via cfe-commits
grandinj added a comment.

thanks for the quick response


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D116203: [clang] adds unary type transformations as compiler built-ins

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Generally looking good to me, mostly just drive-by commentary at this point.




Comment at: clang/include/clang/Sema/DeclSpec.h:407
   static bool isTypeRep(TST T) {
-return (T == TST_typename || T == TST_typeofType ||
-T == TST_underlyingType || T == TST_atomic);
+static const llvm::SmallVector validTSTs = {
+TST_atomic,

Should we find a way we can drop the `19` here so that this doesn't become 
incorrect when someone adds anything to `TransformTypeTraits.def`?



Comment at: clang/lib/Parse/ParseDecl.cpp:3421-3422
 case tok::kw_decltype:
 case tok::identifier: {
+ParseIdentifier:
   // This identifier can only be a typedef name if we haven't already seen

I don't know why this offends my sensibilities, but it does. It seems like the 
label should be with the other (case) labels to my lizard brain, but the 
current way is also correct.



Comment at: clang/lib/Parse/ParseExpr.cpp:1044
// constant: enumeration-constant
+  ParseIdentifier:
 // Turn a potentially qualified name into a annot_typename or

Well, at least my sensibilities are consistent about pearl clutching, as this 
one also jumped out at me. :-D



Comment at: clang/lib/Parse/ParseExpr.cpp:1784
   default:
+  ExpectedExpression:
 NotCastExpr = true;

And yet this one didn't offend my sensibilities.  It's the curly braces that's 
doing it. :-D



Comment at: clang/lib/Parse/ParseStmt.cpp:186
   case tok::identifier: {
+  ParseIdentifier:
 Token Next = NextToken();

Gahh!

(Also, I'm a bit concerned that this feature requires so many `goto`s. Each one 
is reasonable in isolation, but we're adding a fair amount of total parsing 
complexity with those. That said, I don't have a better solution to suggest.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116203

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


[PATCH] D123946: [CUDA][HIP] Fix gpu.used.external

2022-04-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, jhuber6.
Herald added a subscriber: mattd.
Herald added a project: All.
yaxunl requested review of this revision.

Rename  gpu.used.external as __clang_gpu_used_external as ptxas does not
allow . in global variable name.

Fixes: https://github.com/llvm/llvm-project/issues/54934


https://reviews.llvm.org/D123946

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/host-used-extern.cu


Index: clang/test/CodeGenCUDA/host-used-extern.cu
===
--- clang/test/CodeGenCUDA/host-used-extern.cu
+++ clang/test/CodeGenCUDA/host-used-extern.cu
@@ -11,19 +11,19 @@
 
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @gpu.used.external = appending {{.*}}global
+// CHECK-LABEL: @__clang_gpu_used_external = appending {{.*}}global
 // CHECK-DAG: @_Z7kernel1v
 // CHECK-DAG: @_Z7kernel4v
 // CHECK-DAG: @var1
-// CHECK-LABEL: @llvm.compiler.used = {{.*}} @gpu.used.external
-
-// NEG-NOT: @gpu.used.external = {{.*}} @_Z7kernel2v
-// NEG-NOT: @gpu.used.external = {{.*}} @_Z7kernel3v
-// NEG-NOT: @gpu.used.external = {{.*}} @var2
-// NEG-NOT: @gpu.used.external = {{.*}} @var3
-// NORDC-NOT: @gpu.used.external = {{.*}} @_Z7kernel1v
-// NORDC-NOT: @gpu.used.external = {{.*}} @_Z7kernel4v
-// NORDC-NOT: @gpu.used.external = {{.*}} @var1
+// CHECK-LABEL: @llvm.compiler.used = {{.*}} @__clang_gpu_used_external
+
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel2v
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel3v
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @var2
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @var3
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel1v
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel4v
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @var1
 
 __global__ void kernel1();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -599,7 +599,7 @@
 
 auto *GV = new llvm::GlobalVariable(
 getModule(), ATy, false, llvm::GlobalValue::AppendingLinkage,
-llvm::ConstantArray::get(ATy, UsedArray), "gpu.used.external");
+llvm::ConstantArray::get(ATy, UsedArray), "__clang_gpu_used_external");
 addCompilerUsedGlobal(GV);
   }
 


Index: clang/test/CodeGenCUDA/host-used-extern.cu
===
--- clang/test/CodeGenCUDA/host-used-extern.cu
+++ clang/test/CodeGenCUDA/host-used-extern.cu
@@ -11,19 +11,19 @@
 
 #include "Inputs/cuda.h"
 
-// CHECK-LABEL: @gpu.used.external = appending {{.*}}global
+// CHECK-LABEL: @__clang_gpu_used_external = appending {{.*}}global
 // CHECK-DAG: @_Z7kernel1v
 // CHECK-DAG: @_Z7kernel4v
 // CHECK-DAG: @var1
-// CHECK-LABEL: @llvm.compiler.used = {{.*}} @gpu.used.external
-
-// NEG-NOT: @gpu.used.external = {{.*}} @_Z7kernel2v
-// NEG-NOT: @gpu.used.external = {{.*}} @_Z7kernel3v
-// NEG-NOT: @gpu.used.external = {{.*}} @var2
-// NEG-NOT: @gpu.used.external = {{.*}} @var3
-// NORDC-NOT: @gpu.used.external = {{.*}} @_Z7kernel1v
-// NORDC-NOT: @gpu.used.external = {{.*}} @_Z7kernel4v
-// NORDC-NOT: @gpu.used.external = {{.*}} @var1
+// CHECK-LABEL: @llvm.compiler.used = {{.*}} @__clang_gpu_used_external
+
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel2v
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel3v
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @var2
+// NEG-NOT: @__clang_gpu_used_external = {{.*}} @var3
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel1v
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @_Z7kernel4v
+// NORDC-NOT: @__clang_gpu_used_external = {{.*}} @var1
 
 __global__ void kernel1();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -599,7 +599,7 @@
 
 auto *GV = new llvm::GlobalVariable(
 getModule(), ATy, false, llvm::GlobalValue::AppendingLinkage,
-llvm::ConstantArray::get(ATy, UsedArray), "gpu.used.external");
+llvm::ConstantArray::get(ATy, UsedArray), "__clang_gpu_used_external");
 addCompilerUsedGlobal(GV);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123889: [clang-tidy] Improve macro handling in modernize-macro-to-enum

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Generally looks correct to me, but I did have some questions about the types 
used in the fix.




Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:235
   SmallVector Files;
+  std::vector ExpressionNames;
   FileState *CurrentFile = nullptr;

This smells expensive (compared to a `SmallVector` or somesuch).



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:303-305
+  if (Pos == ExpressionNames.end() || *Pos != Id) {
+ExpressionNames.insert(Pos, Id);
+  }

So you're manually keeping the vector sorted instead of using a set?

Any chance that we can store a `StringRef` rather than paying the expense of 
all these copies? And would it make sense to switch to using an ordered 
container rather than an unordered one?


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

https://reviews.llvm.org/D123889

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


[PATCH] D123946: [CUDA][HIP] Fix gpu.used.external

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D123946

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


[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-04-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/CodeGenCXX/no_auto_return_lambda.cpp:8
+
+// CHECK: !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK-NOT: !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto")

aprantl wrote:
> This test is very fragile. Instead of checking that no unspecified type 
> *follows* the first declaration of `int` and hoping that no other `int` is 
> emitted in this CU, it would be better to explictly check for the return type 
> of the `DISubprogram` for `g` using FileCheck variable substitutions.
I thought about that but there are a couple of steps to get there e.g.:

```
!10 = distinct !DISubprogram(name: "g", linkageName: "_Z1gv", scope: !8, file: 
!8, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: 
DISPFlagDefinition, unit: !7, retainedNodes: !14)
!11 = !DISubroutineType(types: !12)
!12 = !{!13}
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
```

I have to go from 11 to 12 to 13, is there a better way?


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

https://reviews.llvm.org/D123319

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


[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3978
+"compute", "raygeneration", "intersection",
+"anyhit", "closestHit", "miss", "callable", "mesh",
+"amplification"],

aaron.ballman wrote:
> `anyhit` vs `closestHit` in terms of capitalization seems a bit surprising to 
> me -- is that intentional?
Good catch. It is not intentional.



Comment at: clang/include/clang/Basic/AttrDocs.td:6386-6388
+The ``shader`` attribute applies to HLSL shader entry functions to identify the
+ shader stage for the entry function.
+  }];

aaron.ballman wrote:
> Please add enough documentation that a user has a chance to use this feature 
> properly (and it's fine to link to other documentation for more details if 
> there's canonical documentation elsewhere that we don't want to duplicate).
I'll fix this.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11598-11599
 def err_hlsl_attribute_param_mismatch : Error<"%0 attribute parameters do not 
match the previous declaration">;
+def err_hlsl_invalid_attribute_argument : Error<
+  "%0 attribute argument not supported: %1">;
 

aaron.ballman wrote:
> Almost every other attribute warns on this situation and then ignores the 
> attribute; why should this be a hard error? (A warning allows other 
> implementations to support more enumeration values without breaking the 
> user's code in Clang.)
I'll change it to warning.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6944-6947
+  if (AL.getNumArgs() != 1) {
+S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+return;
+  }

aaron.ballman wrote:
> Hmm, doesn't the common attribute handling logic already deal with this case? 
> (It does for other attribute syntaxes, but we have almost no attributes using 
> the Microsoft `[]` syntax, so I wouldn't be surprised if we need to add that 
> logic.)
I'll double check it I can remove this.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6961
+
+  // TODO: check function match the shader stage.
+

aaron.ballman wrote:
> Are you planning to do this TODO as part of this patch, or is this a FIXME 
> someone needs to handle later?
It is a FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

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


[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:6409-6411
+- The attribute will not cause any additional data to be output to LLVM IR,
+  object files or debug information. It is only intended to be consumed using
+  Clang APIs by source-level static analysis tools such as Clang-Tidy.

mboehme wrote:
> aaron.ballman wrote:
> > It seems to me that because we found reasons for `annotate` to be lowered 
> > to LLVM IR, we'll find reasons to lower `annotate_type` eventually. I worry 
> > that if we document this, we'll never be able to modify the attribute to 
> > output information to LLVM IR because people will rely on it not doing so 
> > and be broken by a change. Are we sure we want to commit to this as part of 
> > the design?
> Good point. I've done what I think you're implying, namely that we should 
> remove the comments saying that the attribute won't have any any effect on 
> the LLVM IR?
Heh, yes, you interpreted my concerns correctly, thank you!



Comment at: clang/lib/AST/TypePrinter.cpp:1686
+  // would require retrieving the attribute arguments, which we don't have 
here.
+  if (T->getAttrKind() == attr::AnnotateType)
+return;

mboehme wrote:
> aaron.ballman wrote:
> > mboehme wrote:
> > > xazax.hun wrote:
> > > > Would it make sense to print something without the arguments? I wonder 
> > > > which behavior would be less confusing.
> > > TBH I'm not sure. Is TypePrinter used only to produce debug output or is 
> > > it required that the output of TypePrinter will parse again correctly?
> > > 
> > > The reason I'm asking is because `annotate_type` has a mandatory first 
> > > argument; if we need the output to be parseable, we would have to print 
> > > some dummy string, e.g. `[[clang::annotate_type("arguments_omitted")]]`. 
> > > This seems a bit strange, but maybe it's still worth doing. OTOH, if the 
> > > output is used only for debugging, I guess we could print something like 
> > > `[[clang::annotate_type(...)]]`, which doesn't parse but by that very 
> > > nature makes it clear that we don't have all the information here.
> > > 
> > > I guess both of these options could have limited use -- they would at 
> > > least make it clear that there is an annotation on the type, though 
> > > without the arguments, we can't know what the actual annotation is.
> > > 
> > > Would appreciate some more input on the wider context here.
> > Yeah, the trouble is that you need a `TypeLoc` in order to get back to the 
> > actual attribute information that stores the arguments. But the type 
> > printer is printing types not specific instances of types at the location 
> > they're used.
> > 
> > The goal with the pretty printers is to print something back that the user 
> > actually wrote, but it's not always possible and so this is sort of a 
> > best-effort.
> So what's your position -- should I not print the attribute at all (which is 
> what I'm doing right now) or should I print it as something like 
> `[[clang::annotate_type(...)]]`?
I think we need to print *something* here because the type printer is used by 
`QualType::getAsStringInternal()` and `QualType::print()` which are used to 
produce diagnostics when giving a `QualType` argument. So I would  print 
`[[clang::annotate]]` as a stop-gap with a FIXME comment that it would be nice 
to print the arguments here some day.



Comment at: clang/lib/Parse/ParseDecl.cpp:3184
+continue;
+  // We reject AT_LifetimeBound and AT_AnyX86NoCfCheck, even though 
they
+  // are type attributes, because we historically haven't allowed these

I think this is a FIXME situation -- our policy is to diagnose attributes that 
are being ignored, and it seems pretty important to (someday, not part of this 
patch) diagnose these. Especially the lifetime bound attribute given that it's 
intended to help harden code.



Comment at: clang/lib/Sema/SemaAttr.cpp:396-408
+if (E->getType()->isArrayType())
+  E = ImpCastExprToType(E, Context.getPointerType(E->getType()),
+clang::CK_ArrayToPointerDecay)
+  .get();
+if (E->getType()->isFunctionType())
+  E = ImplicitCastExpr::Create(Context,
+   Context.getPointerType(E->getType()),

mboehme wrote:
> aaron.ballman wrote:
> > This seems an awful lot like doing `DefaultFunctionArrayLValueConversion()` 
> > here -- can you call that to do the heavy lifting?
> > 
> > Oh, I see we're just shuffling code around. Feel free to ignore or make as 
> > an NFC change if you'd prefer.
> By "NFC change", you mean I could submit this separately as an NFC change?
> 
> Since this change is already part of this patch, I think I'd prefer to just 
> keep it in here, if that's OK?
> By "NFC change", you mean I could submit this separately as an NFC change?

Yup!

>

[PATCH] D123325: [Clang] Make enabling the new driver more generic

2022-04-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3885-3888
+  bool UseNewOffloadingDriver =
+  C.isOffloadingHostKind(C.getActiveOffloadKinds()) &&
+  (Args.hasArg(options::OPT_foffload_new_driver) ||
+   Args.hasArg(options::OPT_fopenmp_new_driver));

If OPT_fopenmp_new_driver is on by default, then OPT_foffload_new_driver will 
have no effect. Is this intended? Should OPT_fopenmp_new_driver be conditioned 
for OpenMP offloading only?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123325

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


[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-04-18 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/test/Sema/annotate-type.c:6
+void foo(float * [[clang::annotate_type("foo")]] a) {
+  int [[clang::annotate_type("bar")]] x1;
+  int * [[clang::annotate_type("bar")]] x2;

Is it possible to typedef int [[clang::annotate_type("bar")]]  mymagicint_t ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111548

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


[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-18 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

It's broken again here https://lab.llvm.org/buildbot/#/builders/74/builds/10427


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123345

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-04-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Ping :)


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

https://reviews.llvm.org/D122335

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


[PATCH] D123325: [Clang] Make enabling the new driver more generic

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3885-3888
+  bool UseNewOffloadingDriver =
+  C.isOffloadingHostKind(C.getActiveOffloadKinds()) &&
+  (Args.hasArg(options::OPT_foffload_new_driver) ||
+   Args.hasArg(options::OPT_fopenmp_new_driver));

yaxunl wrote:
> If OPT_fopenmp_new_driver is on by default, then OPT_foffload_new_driver will 
> have no effect. Is this intended? Should OPT_fopenmp_new_driver be 
> conditioned for OpenMP offloading only?
Yeah, I need to rework the logic here once OpenMP moves to the new driver by 
default. I can probably require something like.
```
(C.isOffloadingHostKind(Action::OFK_OpenMP) && 
!Args.hasArg(options::OPT_fno_offload_new_driver) || 
Args.hasArg(options::OPT_fopenmp_new_driver);
```
Currently working on the patch to make this default for OpenMP so I'll be able 
to update this after that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123325

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


[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-18 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Hi, this is also breaking Fuchsia's clang CI builders 
(https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8816531831869640417/overview).
 If this will be hard to address, would you mind reverting until a patch is 
ready?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123345

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


[PATCH] D121959: [clang] Add missing diagnostics for invalid overloads of multiversion functions in C.

2022-04-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D121959#3454606 , @tahonermann 
wrote:

>> This might've caused a regression? 
>> (https://github.com/llvm/llvm-project/issues/54892)
>
> @dblaikie, it most definitely did. Note that I'm the author of the patch that 
> introduced the regression, the reporter of the regression, and the assignee 
> for fixing the regression ;)

Ah, sorry, didn't check the author/folks involved. It's not uncommon for 
non-contributors to file bugs for new breakages and for contributors not to be 
monitoring the bugs that closely - so usually a conversation on the 
commit/review is a better place for visibility - so was passing it along to 
make sure it didn't get lost :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121959

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


[PATCH] D122831: [OpenMP] Make the new offloading driver the default

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 423416.
jhuber6 added a comment.
Herald added a subscriber: mattd.

Splitting major changes into two files as per suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122831

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-system-arch.c
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/amdgpu-openmp-toolchain.c
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/OpenMP/driver-openmp-target.c
  openmp/libomptarget/CMakeLists.txt
  openmp/libomptarget/plugins/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/cuda/CMakeLists.txt
  openmp/libomptarget/test/lit.cfg
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/lambda_mapping.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug49334.cpp
  openmp/libomptarget/test/offloading/bug49779.cpp
  openmp/libomptarget/test/offloading/bug51781.c
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/offloading/memory_manager.cpp
  openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
  openmp/libomptarget/test/offloading/static_linking.c
  openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
  openmp/libomptarget/test/unified_shared_memory/api.c

Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -1,11 +1,11 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda
-// XFAIL: nvptx64-nvidia-cuda-newDriver
+// XFAIL: nvptx64-nvidia-cuda-oldDriver
 
 // Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newDriver
+// XFAIL: amdgcn-amd-amdhsa-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
===
--- openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
+++ openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/static_linking.c
===
--- openmp/libomptarget/test/offloading/static_linking.c
+++ openmp/libomptarget/test/offloading/static_linking.c
@@ -2,8 +2,8 @@
 // RUN: llvm-ar rcs %t.a %t.o
 // RUN: %libomptarget-compile-generic %t.a && %libomptarget-run-generic 2>&1 | %fcheck-generic
 
-// REQUIRES: nvptx64-nvidia-cuda-newDriver
-// REQUIRES: amdgcn-amd-amdhsa-newDriver
+// REQUIRES: nvptx64-nvidia-cuda-oldDriver
+// REQUIRES: amdgcn-amd-amdhsa-oldDriver
 
 #ifdef LIBRARY
 int x = 42;
Index: openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
===
--- openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
+++ openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/memory_manager.cpp
===
--- openmp/libomptarget/test/offloading/memory_manager.cpp
+++ openmp/libomptarget/test/offloading/memory_manager.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -9,7 +9,7 @@
 
 // amdgpu does not have a working printf definition
 // XFAIL: amdgcn-amd-amdhsa
-//

[PATCH] D123642: [clang codegen] Assume arguments of __atomic_* are aligned.

2022-04-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma abandoned this revision.
efriedma added a comment.

Opened https://github.com/llvm/llvm-project/issues/54963 to more specifically 
track the clang issue.

With b27430f 
, it 
should be easy enough to special-case calls to std::__addressof in 
CodeGenFunction::EmitPointerWithAlignment, so we can just do that, I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123642

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-18 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

This seems to be acting weird in template instantations.  Here's an example 
where the lambda only errors inside a template.

  template 
  int foo(int x = 0) {
  auto lambda = [x = x+1]() -> decltype(x) {
  return x;
  };
  return -1;
  }
  
  // no template
  int bar(int x = 0) {
  auto lambda = [x = x+1]() -> decltype(x) {
  return x;
  };
  return -1;
  }
  
  int a = foo();  // error
  int b = bar();  // no  error



  /tmp/lambda.cc:4:16: error: variable 'x' cannot be implicitly captured in a 
lambda with no capture-default specified
  return x;
 ^
  /tmp/lambda.cc:17:9: note: in instantiation of function template 
specialization 'foo' requested here
  int a = foo();  // error
  ^
  /tmp/lambda.cc:3:20: note: 'x' declared here
  auto lambda = [x = x+1]() -> decltype(x) {
 ^
  /tmp/lambda.cc:3:19: note: lambda expression begins here
  auto lambda = [x = x+1]() -> decltype(x) {
^
  /tmp/lambda.cc:3:27: note: capture 'x' by value
  auto lambda = [x = x+1]() -> decltype(x) {
^
, x
  /tmp/lambda.cc:3:27: note: capture 'x' by reference
  auto lambda = [x = x+1]() -> decltype(x) {
^
, &x
  /tmp/lambda.cc:3:20: note: default capture by value
  auto lambda = [x = x+1]() -> decltype(x) {
 ^
 =, 
  /tmp/lambda.cc:3:20: note: default capture by reference
  auto lambda = [x = x+1]() -> decltype(x) {
 ^
 &, 
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D122831: [OpenMP] Make the new offloading driver the default

2022-04-18 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! If it fails CI we might want to submit the tests and the code 
change separately, but I'm fine with trying it as one block in the first 
instance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122831

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


[PATCH] D123950: Look through calls to std::addressof to compute pointer alignment.

2022-04-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added reviewers: jyknight, rsmith, rjmccall.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: clang.

This is sort of a followup to D37310 ; that 
basically fixed the same issue, but then the libstdc++ implementation of 
 changed. Re-fix the the issue in essentially the same way: look 
through the addressof operation to find the alignment of the underlying object.

Fixes https://github.com/llvm/llvm-project/issues/54963 .  Alternative to 
D123642 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123950

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCXX/atomic-align.cpp


Index: clang/test/CodeGenCXX/atomic-align.cpp
===
--- clang/test/CodeGenCXX/atomic-align.cpp
+++ clang/test/CodeGenCXX/atomic-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 %s -std=c++14 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
 
 struct AM {
   int f1, f2;
@@ -28,3 +28,23 @@
   __atomic_load(&bm.f2, &am, 0);
   return am;
 }
+
+namespace std {
+  template 
+  inline constexpr
+  __attribute__ ((__visibility__("hidden"), __internal_linkage__))
+  _Tp* __addressof(_Tp& __x) noexcept
+  {
+  return __builtin_addressof(__x);
+  }
+}
+
+AM load3() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load3v
+  // CHECK: load atomic {{.*}} monotonic, align 8
+  __atomic_load(std::__addressof(m), &am, 0);
+  return am;
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1170,6 +1170,22 @@
 }
   }
 
+  // std::addressof and variants.
+  if (auto *Call = dyn_cast(E)) {
+switch (Call->getBuiltinCallee()) {
+default:
+  break;
+case Builtin::BIaddressof:
+case Builtin::BI__addressof:
+case Builtin::BI__builtin_addressof: {
+  LValue LV = EmitLValue(Call->getArg(0));
+  if (BaseInfo) *BaseInfo = LV.getBaseInfo();
+  if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo();
+  return LV.getAddress(*this);
+}
+}
+  }
+
   // TODO: conditional operators, comma.
 
   // Otherwise, use the alignment of the type.


Index: clang/test/CodeGenCXX/atomic-align.cpp
===
--- clang/test/CodeGenCXX/atomic-align.cpp
+++ clang/test/CodeGenCXX/atomic-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++14 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s
 
 struct AM {
   int f1, f2;
@@ -28,3 +28,23 @@
   __atomic_load(&bm.f2, &am, 0);
   return am;
 }
+
+namespace std {
+  template 
+  inline constexpr
+  __attribute__ ((__visibility__("hidden"), __internal_linkage__))
+  _Tp* __addressof(_Tp& __x) noexcept
+  {
+  return __builtin_addressof(__x);
+  }
+}
+
+AM load3() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load3v
+  // CHECK: load atomic {{.*}} monotonic, align 8
+  __atomic_load(std::__addressof(m), &am, 0);
+  return am;
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1170,6 +1170,22 @@
 }
   }
 
+  // std::addressof and variants.
+  if (auto *Call = dyn_cast(E)) {
+switch (Call->getBuiltinCallee()) {
+default:
+  break;
+case Builtin::BIaddressof:
+case Builtin::BI__addressof:
+case Builtin::BI__builtin_addressof: {
+  LValue LV = EmitLValue(Call->getArg(0));
+  if (BaseInfo) *BaseInfo = LV.getBaseInfo();
+  if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo();
+  return LV.getAddress(*this);
+}
+}
+  }
+
   // TODO: conditional operators, comma.
 
   // Otherwise, use the alignment of the type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123898: Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

2022-04-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D123898#3455933 , @theraven wrote:

> I'd like to.  The test case from the original bug report was very large but 
> I'm not sure how to trigger this with anything comprehensibly small.  You 
> need something where the callee is responsible for destroying the argument 
> and I'm not sure what combination of properties / ABIs results in that.  The 
> original test was `-(void)foo:(std::string)aString` on the MSVC ABI, but I 
> don't know how much of the Visual Studio `std::string` implementation is 
> necessary to trigger this behaviour.  Is it just a non-trivial destructor?

Yeah, a non-trivial destructor should be good enough.  Or a consumed ObjC 
pointer argument in ARC might also work, although I don't know if that takes 
the same path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123898

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


[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2022-04-18 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/test/SemaCXX/type-traits.cpp:764
+  int t30[F(__is_bounded_array(void*))];
+  int t31[F(__is_bounded_array(cvoid*))];
+}

aaron.ballman wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > Any reason there's not a test with something like `int[10]` and `int[]`? 
> > > (Same below.)
> > Those are `IntAr` and `IntArNB` at the very top. I can rename those if 
> > you'd like.
> Oh, yeah, I totally missed that, thank you!
> 
> Up to you on the rename, so long as we have the coverage, that's the crucial 
> bit.
Would you be against a patch where I found and replaced **all** `TypeAr` with 
`Type[2]` and `TypeArNB` with `Type[]`? I've done several double takes myself 
and question the readability of `TypeAr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116280

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


[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D123345#3456964 , @paulkirth wrote:

> Hi, this is also breaking Fuchsia's clang CI builders 
> (https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8816531831869640417/overview).
>  If this will be hard to address, would you mind reverting until a patch is 
> ready?

I'm working on a fix. I'll revert if it takes me more than a few minutes. If 
you'd prefer to not wait, please feel free to revert it yourself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123345

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


[PATCH] D123850: [Clang] Fix Unevaluated LambdasBackport to Clang 14.0.1

2022-04-18 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D123850#3453750 , @cor3ntin wrote:

> @tstellar I wasn't sure what the procedure was for backporting fixes, so I 
> made a PR. I think your suggestion of keeping the old signature works well.
> This also modifies the serialized AST, is that an issue for backports? (If it 
> is, I'm not sure i see a way to move forward with this!)

I don' t think we have a written policy about the serialized AST format like we 
do API/ABI.  What are the use cases where maintaining the AST format is 
important?  @rsmith  Do you have any opinion about changing the serialized AST 
in a bugfix release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123850

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


[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk updated this revision to Diff 423426.
hvdijk added a comment.
Herald added a subscriber: dexonsmith.

Allow the old mangling with suitable -fclang-abi-compat= value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/clang-abi-compat.cpp
  clang/test/CodeGenCXX/mangle.cpp

Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1155,3 +1155,15 @@
   // CHECK-LABEL: @_ZN6test601fIiEEvDTplL_ZNS_1aEEcvT__EE
   template void f(int);
 }
+
+namespace test61 {
+  struct X {
+struct Y {
+  using a = int;
+  using b = int;
+};
+  };
+  template  void f(typename T::Y::a, typename T::Y::b) {}
+  // CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE
+  template void f(int, int);
+}
Index: clang/test/CodeGenCXX/clang-abi-compat.cpp
===
--- clang/test/CodeGenCXX/clang-abi-compat.cpp
+++ clang/test/CodeGenCXX/clang-abi-compat.cpp
@@ -1,25 +1,27 @@
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.8 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.9 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=4.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=5 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20,PRE15 %s
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=14 %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,V15 %s
 
 typedef __attribute__((vector_size(8))) long long v1xi64;
 void clang39(v1xi64) {}
@@ -147,3 +149,14 @@
 inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0);

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D122663#3456507 , @erichkeane 
wrote:

> I believe the answer here is 'yes'.  We also likely need release notes.

Thanks for the feedback. -fclang-abi-compat= support added. Other mangling 
bugfixes appear to not have made it into release notes so I did not add it for 
this one either, but if that is something that's wanted I can add it; I'll wait 
for some more comments on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D122663#3457130 , @hvdijk wrote:

> In D122663#3456507 , @erichkeane 
> wrote:
>
>> I believe the answer here is 'yes'.  We also likely need release notes.
>
> Thanks for the feedback. -fclang-abi-compat= support added. Other mangling 
> bugfixes appear to not have made it into release notes so I did not add it 
> for this one either, but if that is something that's wanted I can add it; 
> I'll wait for some more comments on that.

Our most recent direction is to document any non-NFC patches in the release 
notes if at all sensible, so I think this meets those requirements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D123950: Look through calls to std::addressof to compute pointer alignment.

2022-04-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall 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/D123950/new/

https://reviews.llvm.org/D123950

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


[PATCH] D123952: [FPEnv] Allow CompoundStmt to keep FP options

2022-04-18 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, aaron.ballman, kpn.
Herald added subscribers: dexonsmith, martong.
Herald added a reviewer: shafik.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: clang.

AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn result in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keep
current set of them within it.

This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.

To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123952

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp

Index: clang/test/AST/ast-dump-fpfeatures.cpp
===
--- clang/test/AST/ast-dump-fpfeatures.cpp
+++ clang/test/AST/ast-dump-fpfeatures.cpp
@@ -141,3 +141,49 @@
 // CHECK:   CompoundStmt
 // CHECK-NEXT:ReturnStmt
 // CHECK-NEXT:  BinaryOperator {{.*}} 'float' '+' RoundingMode=towardzero
+
+float func_16(float x, float y) {
+#pragma STDC FENV_ROUND FE_TOWARDZERO
+  if (x < 0) {
+#pragma STDC FENV_ROUND FE_UPWARD
+return x - y;
+  }
+  return x + y;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} func_16 'float (float, float)'
+// CHECK: CompoundStmt {{.*}} RoundingMode=towardzero
+// CHECK:   IfStmt
+// CHECK: CompoundStmt {{.*}} RoundingMode=upward
+// CHECK:   ReturnStmt
+// CHECK: BinaryOperator {{.*}} RoundingMode=upward
+// CHECK:   ReturnStmt
+// CHECK: BinaryOperator {{.*}} RoundingMode=towardzero
+
+float func_17(float x, float y) {
+#pragma STDC FENV_ROUND FE_TOWARDZERO
+  if (x < 0) {
+#pragma STDC FENV_ROUND FE_TOWARDZERO
+return x - y;
+  }
+  return x + y;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} func_17 'float (float, float)'
+// CHECK: CompoundStmt {{.*}} RoundingMode=towardzero
+// CHECK:   IfStmt
+// CHECK: CompoundStmt {{.*}}
+// CHECK:   ReturnStmt
+// CHECK: BinaryOperator {{.*}} RoundingMode=towardzero
+// CHECK:   ReturnStmt
+// CHECK: BinaryOperator {{.*}} RoundingMode=towardzero
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
+float func_18(float x, float y) {
+  return x + y;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} func_18 'float (float, float)'
+// CHECK: CompoundStmt {{.*}} RoundingMode=downward
+// CHECK:   ReturnStmt
+// CHECK: BinaryOperator {{.*}} RoundingMode=downward
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -81,8 +81,11 @@
 void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
   VisitStmt(S);
   Record.push_back(S->size());
+  Record.push_back(S->hasStoredFPFeatures());
   for (auto *CS : S->body())
 Record.AddStmt(CS);
+  if (S->hasStoredFPFeatures())

[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 423428.
python3kgae added a comment.

Add more detail to the doc.
Update the attribute name according to the doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaHLSL/shader_type_attr.hlsl

Index: clang/test/SemaHLSL/shader_type_attr.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/shader_type_attr.hlsl
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -DFAIL -verify
+
+#ifdef FAIL
+
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("compute")]
+struct Fido {
+  // expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("pixel")]
+  void wag() {}
+  // expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("vertex")]
+  static void oops() {}
+};
+
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("vertex")]
+static void oops() {}
+
+namespace spec {
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("vertex")]
+static void oops() {}
+} // namespace spec
+
+// expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
+[shader("compute")]
+// expected-note@+1 {{conflicting attribute is here}}
+[shader("vertex")]
+int doubledUp() {
+  return 1;
+}
+
+// expected-note@+1 {{conflicting attribute is here}}
+[shader("vertex")]
+int forwardDecl();
+
+// expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
+[shader("compute")]
+int forwardDecl() {
+  return 1;
+}
+
+// expected-error@+1 {{'shader' attribute takes one argument}}
+[shader()]
+// expected-error@+1 {{'shader' attribute takes one argument}}
+[shader(1, 2)]
+// expected-error@+1 {{'shader' attribute requires a string}}
+[shader(1)]
+// expected-warning@+1 {{'shader' attribute argument not supported: cs}}
+[shader("cs")]
+
+#endif // END of FAIL
+
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+[shader("compute")]
+int entry() {
+  return 1;
+}
+
+// Because these two attributes match, they should both appear in the AST
+[shader("compute")]
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+int secondFn();
+
+[shader("compute")]
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+int secondFn() {
+  return 1;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6940,6 +6940,39 @@
   D->addAttr(::new (S.Context) HLSLSV_GroupIndexAttr(S.Context, AL));
 }
 
+static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  StringRef Str;
+  SourceLocation ArgLoc;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
+return;
+
+  HLSLShaderAttr::ShaderType ShaderType;
+  if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
+S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+<< AL << Str << ArgLoc;
+return;
+  }
+
+  // FIXME: check function match the shader stage.
+
+  HLSLShaderAttr *NewAttr = S.mergeHLSLShaderAttr(D, AL, ShaderType);
+  if (NewAttr)
+D->addAttr(NewAttr);
+}
+
+HLSLShaderAttr *
+Sema::mergeHLSLShaderAttr(Decl *D, const AttributeCommonInfo &AL,
+  HLSLShaderAttr::ShaderType ShaderType) {
+  if (HLSLShaderAttr *NT = D->getAttr()) {
+if (NT->getType() != ShaderType) {
+  Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
+  Diag(AL.getLoc(), diag::note_conflicting_attribute);
+}
+return nullptr;
+  }
+  return HLSLShaderAttr::Create(Context, ShaderType, AL);
+}
+
 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   if (!S.LangOpts.CPlusPlus) {
 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang)
@@ -8815,6 +8848,9 @@
   case ParsedAttr::AT_HLSLSV_GroupIndex:
 handleHLSLSVGroupIndexAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_HLSLShader:
+handleHLSLShaderAttr(S, D, AL);
+break;
 
   case ParsedAttr::AT_AbiTag:
 handleAbiTagAttr(S, D, AL);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2806,6 +2806,8 @@
   else if (const auto *NT = dyn_cast(Attr))
 NewAttr =
 S.mergeHLSLNumThreadsAttr(D, *NT, NT->getX(), NT->getY(), NT->getZ());
+  else if (const auto *SA = dyn_cast(Attr))
+NewAttr = S.mergeH

[clang] e43c93d - Don't treat 'T &forward(T&&)' as builtin.

2022-04-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-04-18T11:11:21-07:00
New Revision: e43c93dd63cca295ef26ab69cd305816a71d45fd

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

LOG: Don't treat 'T &forward(T&&)' as builtin.

This allows the standard library to diagnose it properly. Suppress
warning in libc++ testsuite for unused result of call to std::forward.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/builtin-std-move.cpp
libcxx/test/std/utilities/utility/forward/forward.fail.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 8b0147fc66c36..f11a1748e5c68 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -621,6 +621,20 @@ static bool isRelevantAttr(Sema &S, const Decl *D, const 
Attr *A) {
 return true;
   }
 
+  if (const auto *BA = dyn_cast(A)) {
+// Do not treat 'std::forward' as a builtin if it takes an rvalue reference
+// type and returns an lvalue reference type. The library implementation
+// will produce an error in this case; don't get in its way.
+if (BA->getID() == Builtin::BIforward) {
+  const FunctionDecl *FD = dyn_cast(D);
+  if (FD && FD->getNumParams() >= 1 &&
+  FD->getParamDecl(0)->getType()->isRValueReferenceType() &&
+  FD->getReturnType()->isLValueReferenceType()) {
+return false;
+  }
+}
+  }
+
   return true;
 }
 

diff  --git a/clang/test/SemaCXX/builtin-std-move.cpp 
b/clang/test/SemaCXX/builtin-std-move.cpp
index a53e57c86c14c..7f1b01e43d788 100644
--- a/clang/test/SemaCXX/builtin-std-move.cpp
+++ b/clang/test/SemaCXX/builtin-std-move.cpp
@@ -30,11 +30,18 @@ namespace std {
   template struct remove_reference { using type = T; };
   template struct remove_reference { using type = T; };
 
+  template struct is_lvalue_reference { static constexpr bool 
value = false; };
+  template struct is_lvalue_reference { static constexpr bool 
value = true; };
+
   template CONSTEXPR T &&forward(typename 
remove_reference::type &x) {
 static_assert(T::moveable, "instantiated forward"); // expected-error {{no 
member named 'moveable' in 'B'}}
 // expected-error@-1 
{{no member named 'moveable' in 'C'}}
 return static_cast(x);
   }
+  template CONSTEXPR T &&forward(typename 
remove_reference::type &&x) {
+static_assert(!is_lvalue_reference::value, "should not forward rval as 
lval"); // expected-error {{static_assert failed}}
+return static_cast(x);
+  }
 
   template CONSTEXPR const T &as_const(T &x) {
 static_assert(T::moveable, "instantiated as_const"); // expected-error 
{{no member named 'moveable' in 'B'}}
@@ -76,6 +83,11 @@ static_assert(f({}), "should be constexpr");
 // expected-note@#call {{}}
 #endif
 
+A &forward_rval_as_lval() {
+  std::forward(A()); // expected-warning {{const attribute}}
+  return std::forward(A()); // expected-note {{instantiation of}}
+}
+
 struct B {};
 B &&(*pMove)(B&) = std::move; // #1 expected-note {{instantiation of}}
 B &&(*pMoveIfNoexcept)(B&) = &std::move_if_noexcept; // #2 expected-note 
{{instantiation of}}

diff  --git a/libcxx/test/std/utilities/utility/forward/forward.fail.cpp 
b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
index 4d7790a751481..f913b835c2248 100644
--- a/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
+++ b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
@@ -22,7 +22,7 @@ const A csource() {return A();}
 int main(int, char**)
 {
 {
-std::forward(source());  // expected-note {{requested here}}
+(void)std::forward(source());  // expected-note {{requested here}}
 // expected-error-re@*:* 1 {{static_assert failed{{.*}} "cannot 
forward an rvalue as an lvalue"}}
 }
 {



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


[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D123345#3457109 , @rsmith wrote:

> I'm working on a fix. I'll revert if it takes me more than a few minutes. If 
> you'd prefer to not wait, please feel free to revert it yourself.

Thanks for your patience,  should be fixed in 
rGe43c93dd63cca295ef26ab69cd305816a71d45fd 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123345

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


[PATCH] D122831: [OpenMP] Make the new offloading driver the default

2022-04-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 423433.
jhuber6 added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122831

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-system-arch.c
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/amdgpu-openmp-toolchain.c
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/OpenMP/driver-openmp-target.c
  openmp/libomptarget/CMakeLists.txt
  openmp/libomptarget/plugins/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/cuda/CMakeLists.txt
  openmp/libomptarget/test/lit.cfg
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/lambda_mapping.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug49334.cpp
  openmp/libomptarget/test/offloading/bug49779.cpp
  openmp/libomptarget/test/offloading/bug51781.c
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/offloading/memory_manager.cpp
  openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
  openmp/libomptarget/test/offloading/static_linking.c
  openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
  openmp/libomptarget/test/unified_shared_memory/api.c

Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -1,11 +1,11 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda
-// XFAIL: nvptx64-nvidia-cuda-newDriver
+// XFAIL: nvptx64-nvidia-cuda-oldDriver
 
 // Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newDriver
+// XFAIL: amdgcn-amd-amdhsa-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
===
--- openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
+++ openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/static_linking.c
===
--- openmp/libomptarget/test/offloading/static_linking.c
+++ openmp/libomptarget/test/offloading/static_linking.c
@@ -2,8 +2,8 @@
 // RUN: llvm-ar rcs %t.a %t.o
 // RUN: %libomptarget-compile-generic %t.a && %libomptarget-run-generic 2>&1 | %fcheck-generic
 
-// REQUIRES: nvptx64-nvidia-cuda-newDriver
-// REQUIRES: amdgcn-amd-amdhsa-newDriver
+// REQUIRES: nvptx64-nvidia-cuda-oldDriver
+// REQUIRES: amdgcn-amd-amdhsa-oldDriver
 
 #ifdef LIBRARY
 int x = 42;
Index: openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
===
--- openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
+++ openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/memory_manager.cpp
===
--- openmp/libomptarget/test/offloading/memory_manager.cpp
+++ openmp/libomptarget/test/offloading/memory_manager.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -9,7 +9,7 @@
 
 // amdgpu does not have a working printf definition
 // XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newDriver
+// XFAIL: amdgcn-amd-amdhsa-oldDriver
 
 #incl

[PATCH] D122691: [clang][Sema] Add flag to LookupName to force C/ObjC codepath

2022-04-18 Thread Alex Langford via Phabricator via cfe-commits
bulbazord updated this revision to Diff 423437.
bulbazord edited the summary of this revision.
bulbazord added a comment.
Herald added a subscriber: mgorny.

Added a test


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

https://reviews.llvm.org/D122691

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaLookup.cpp
  clang/unittests/Sema/CMakeLists.txt
  clang/unittests/Sema/SemaLookupTest.cpp

Index: clang/unittests/Sema/SemaLookupTest.cpp
===
--- /dev/null
+++ clang/unittests/Sema/SemaLookupTest.cpp
@@ -0,0 +1,60 @@
+#include "clang/AST/DeclarationName.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Parse/ParseAST.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::tooling;
+
+namespace {
+
+class LookupAction : public ASTFrontendAction {
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef /*Unused*/) override {
+return std::make_unique();
+  }
+
+  void ExecuteAction() override {
+CompilerInstance &CI = getCompilerInstance();
+ASSERT_FALSE(CI.hasSema());
+CI.createSema(getTranslationUnitKind(), nullptr);
+ASSERT_TRUE(CI.hasSema());
+Sema &S = CI.getSema();
+ParseAST(S);
+
+ASTContext &Ctx = S.getASTContext();
+auto Name = &Ctx.Idents.get("Foo");
+LookupResult R_cpp(S, Name, SourceLocation(), Sema::LookupOrdinaryName);
+S.LookupName(R_cpp, S.TUScope, /*AllowBuiltinCreation=*/false,
+ /*ForceNoCPlusPlus=*/false);
+// By this point, parsing is done and S.TUScope is nullptr
+// CppLookupName will perform an early return with no results if the Scope
+// we pass in is nullptr. We expect to find nothing.
+ASSERT_TRUE(R_cpp.empty());
+
+// On the other hand, the non-C++ path doesn't care if the Scope passed in
+// is nullptr. We'll force the non-C++ path with a flag.
+LookupResult R_nocpp(S, Name, SourceLocation(), Sema::LookupOrdinaryName);
+S.LookupName(R_nocpp, S.TUScope, /*AllowBuiltinCreation=*/false,
+ /*ForceNoCPlusPlus=*/true);
+ASSERT_TRUE(!R_nocpp.empty());
+  }
+};
+
+TEST(SemaLookupTest, ForceNoCPlusPlusPath) {
+  const char *file_contents = R"objcxx(
+@protocol Foo
+@end
+@interface Foo 
+@end
+  )objcxx";
+  ASSERT_TRUE(runToolOnCodeWithArgs(std::make_unique(),
+file_contents, {"-x", "objective-c++"},
+"test.mm"));
+}
+} // namespace
Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -7,6 +7,7 @@
   ExternalSemaSourceTest.cpp
   CodeCompleteTest.cpp
   GslOwnerPointerInference.cpp
+  SemaLookupTest.cpp
   )
 
 clang_target_link_libraries(SemaTests
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1931,13 +1931,14 @@
 /// used to diagnose ambiguities.
 ///
 /// @returns \c true if lookup succeeded and false otherwise.
-bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) {
+bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation,
+  bool ForceNoCPlusPlus) {
   DeclarationName Name = R.getLookupName();
   if (!Name) return false;
 
   LookupNameKind NameKind = R.getLookupKind();
 
-  if (!getLangOpts().CPlusPlus) {
+  if (!getLangOpts().CPlusPlus || ForceNoCPlusPlus) {
 // Unqualified name lookup in C/Objective-C is purely lexical, so
 // search in the declarations attached to the name.
 if (NameKind == Sema::LookupRedeclarationWithLinkage) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -4252,8 +4252,8 @@
 = NotForRedeclaration);
   bool LookupBuiltin(LookupResult &R);
   void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
-  bool LookupName(LookupResult &R, Scope *S,
-  bool AllowBuiltinCreation = false);
+  bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
+  bool ForceNoCPlusPlus = false);
   bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
bool InUnqualifiedLookup = false);
   bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Mostly looks good, just some nits with the documentation.




Comment at: clang/include/clang/Basic/AttrDocs.td:6388
+identify the shader type for the entry function.
+The format is [shader("shadertype")].
+Normally the shader type is set by shader target with the -T option like





Comment at: clang/include/clang/Basic/AttrDocs.td:6389-6391
+Normally the shader type is set by shader target with the -T option like
+-Tps_6_1.
+When compiling to a library target like lib_6_3, the shader type attribute can




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

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


[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D122663#3457131 , @erichkeane 
wrote:

> Our most recent direction is to document any non-NFC patches in the release 
> notes if at all sensible, so I think this meets those requirements.

Thanks, I'm not finding documentation of any change in policy even after 
specifically looking for it, so I have opened 
https://github.com/llvm/llvm-project/issues/54965 for that. However, I have no 
issue with the policy and will add a release note for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/type-traits.cpp:764
+  int t30[F(__is_bounded_array(void*))];
+  int t31[F(__is_bounded_array(cvoid*))];
+}

cjdb wrote:
> aaron.ballman wrote:
> > cjdb wrote:
> > > aaron.ballman wrote:
> > > > Any reason there's not a test with something like `int[10]` and 
> > > > `int[]`? (Same below.)
> > > Those are `IntAr` and `IntArNB` at the very top. I can rename those if 
> > > you'd like.
> > Oh, yeah, I totally missed that, thank you!
> > 
> > Up to you on the rename, so long as we have the coverage, that's the 
> > crucial bit.
> Would you be against a patch where I found and replaced **all** `TypeAr` with 
> `Type[2]` and `TypeArNB` with `Type[]`? I've done several double takes myself 
> and question the readability of `TypeAr`.
I'd be fine with that -- it would be an easy NFC change after this lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116280

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


[clang] 9ec501d - [OpenMP] Refactor OMPScheduleType enum.

2022-04-18 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-04-18T14:03:17-05:00
New Revision: 9ec501da76fc1559cadd6d6dac32766bf4376a3d

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

LOG: [OpenMP] Refactor OMPScheduleType enum.

The OMPScheduleType enum stores the constants from libomp's internal sched_type 
in kmp.h and are used by several kmp API functions. The enum values have an 
internal structure, namely each scheduling algorithm (e.g.) exists in four 
variants: unordered, orderend, normerge unordered, and nomerge ordered.

This patch (basically a followup to D114940) splits the "ordered" and "nomerge" 
bits into separate flags, as was already done for the "monotonic" and 
"nonmonotonic", so we can apply bit flags operations on them. It also now 
contains all possible combinations according to kmp's sched_type. Deriving of 
the OMPScheduleType enum from clause parameters has been moved form MLIR's 
OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as 
well. Since the primary purpose of the flag is the binary interface to libomp, 
it has been made more private to LLVMFrontend. The primary interface for 
generating worksharing-loop using OpenMPIRBuilder code becomes 
`applyWorkshareLoop` which derives the OMPScheduleType automatically and calls 
the appropriate emitter function.

While this is mostly a NFC refactor, it still applies the following functional 
changes:
 * The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also 
applies to clang. Most notably, it now applies the nonmonotonic flag for 
non-static schedules by default.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously 
not applied if the simd modifier was used. I assume this was a bug, since the 
effect was due to `loop.schedule_modifier()` returning 
`mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if 
ordered was specified, in breach to what the comment before citing the OpenMP 
specification says. I assume this was an oversight.

The ordered flag with parameter was not considered in this patch. Changes will 
need to be made (e.g. adding/modifying function parameters) when support for it 
is added. The lengthy names of the enum values can be discussed, for the moment 
this is avoiding reusing previously existing enum value names such as 
`StaticChunked` to avoid confusion.

Reviewed By: peixin

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned_auto.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e85c702907fa0..a249ef9d58d97 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3760,9 +3760,11 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
-AllocaIP, NeedsBarrier, SchedKind,
-ChunkSize);
+  OMPBuilder.applyWorkshareLoop(
+  Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
+  SchedKind, ChunkSize, /*HasSimdModifier=*/false,
+  /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
+  /*HasOrderedClause=*/false);
   return;
 }
 

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
index f1dadc63a22a0..bf0383cdb956c 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i3

[PATCH] D123403: [OpenMP] Refactor OMPScheduleType enum.

2022-04-18 Thread Michael Kruse 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 rG9ec501da76fc: [OpenMP] Refactor OMPScheduleType enum. 
(authored by Meinersbur).

Changed prior to commit:
  https://reviews.llvm.org/D123403?vs=422862&id=423442#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123403

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/irbuilder_for_unsigned_auto.c
  clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
  clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
  clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/openmp-llvm.mlir

Index: mlir/test/Target/LLVMIR/openmp-llvm.mlir
===
--- mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -657,7 +657,7 @@
 llvm.func @test_omp_wsloop_runtime_simd(%lb : i64, %ub : i64, %step : i64) -> () {
   omp.wsloop schedule(runtime, simd)
   for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-// CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 47
+// CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741871
 // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
 // CHECK: %[[cond:.*]] = icmp ne i32 %[[continue]], 0
 // CHECK  br i1 %[[cond]], label %omp_loop.header{{.*}}, label %omp_loop.exit{{.*}}
@@ -674,7 +674,7 @@
 llvm.func @test_omp_wsloop_guided_simd(%lb : i64, %ub : i64, %step : i64) -> () {
   omp.wsloop schedule(guided, simd)
   for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-// CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 46
+// CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741870
 // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
 // CHECK: %[[cond:.*]] = icmp ne i32 %[[continue]], 0
 // CHECK  br i1 %[[cond]], label %omp_loop.header{{.*}}, label %omp_loop.exit{{.*}}
@@ -788,7 +788,7 @@
 llvm.func @test_omp_wsloop_dynamic_ordered(%lb : i64, %ub : i64, %step : i64) -> () {
  omp.wsloop schedule(dynamic) ordered(0)
  for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741891, i64 1, i64 %{{.*}}, i64 1, i64 1)
+  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 67, i64 1, i64 %{{.*}}, i64 1, i64 1)
   // CHECK: call void @__kmpc_dispatch_fini_8u
   // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
   // CHECK: %[[cond:.*]] = icmp ne i32 %[[continue]], 0
@@ -806,7 +806,7 @@
 llvm.func @test_omp_wsloop_auto_ordered(%lb : i64, %ub : i64, %step : i64) -> () {
  omp.wsloop schedule(auto) ordered(0)
  for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741894, i64 1, i64 %{{.*}}, i64 1, i64 1)
+  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 70, i64 1, i64 %{{.*}}, i64 1, i64 1)
   // CHECK: call void @__kmpc_dispatch_fini_8u
   // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
   // CHECK: %[[cond:.*]] = icmp ne i32 %[[continue]], 0
@@ -824,7 +824,7 @@
 llvm.func @test_omp_wsloop_runtime_ordered(%lb : i64, %ub : i64, %step : i64) -> () {
  omp.wsloop schedule(runtime) ordered(0)
  for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741893, i64 1, i64 %{{.*}}, i64 1, i64 1)
+  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 69, i64 1, i64 %{{.*}}, i64 1, i64 1)
   // CHECK: call void @__kmpc_dispatch_fini_8u
   // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
   // CHECK: %[[cond:.*]] = icmp ne i32 %[[continue]], 0
@@ -842,7 +842,7 @@
 llvm.func @test_omp_wsloop_guided_ordered(%lb : i64, %ub : i64, %step : i64) -> () {
  omp.wsloop schedule(guided) ordered(0)
  for (%iv) : i64 = (%lb) to (%ub) step (%step) {
-  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 1073741892, i64 1, i64 %{{.*}}, i64 1, i64 1)
+  // CHECK: call void @__kmpc_dispatch_init_8u(%struct.ident_t* @{{.*}}, i32 %{{.*}}, i32 68, i64 1, i64 %{{.*}}, i64 1, i64 1)
   // CHECK: call void @__kmpc_dispatch_fini_8u
   // CHECK: %[[continue:.*]] = call i32 @__kmpc_dispatch_next_8u
   // CHECK: %[[cond:.*]] = icm

[clang] ae23be8 - [OpenMP] Make the new offloading driver the default

2022-04-18 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-04-18T15:05:09-04:00
New Revision: ae23be84cb60357829078e832613660bfe98687f

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

LOG: [OpenMP] Make the new offloading driver the default

Previously an opt-in flag `-fopenmp-new-driver` was used to enable the
new offloading driver. After passing tests for a few months it should be
sufficiently mature to flip the switch and make it the default. The new
offloading driver is now enabled if there is OpenMP and OpenMP
offloading present and the new `-fno-openmp-new-driver` is not present.

The new offloading driver has three main benefits over the old method:
- Static library support
- Device-side LTO
- Unified clang driver stages

Depends on D122683

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

Added: 
clang/test/Driver/amdgpu-openmp-toolchain-new.c
clang/test/Driver/openmp-offload-gpu-new.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/amdgpu-openmp-system-arch.c
clang/test/Driver/amdgpu-openmp-toolchain.c
clang/test/Driver/fat_archive_amdgpu.cpp
clang/test/Driver/fat_archive_nvptx.cpp
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/openmp-offload.c
clang/test/OpenMP/driver-openmp-target.c
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/plugins/CMakeLists.txt
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
openmp/libomptarget/plugins/cuda/CMakeLists.txt
openmp/libomptarget/test/lit.cfg
openmp/libomptarget/test/mapping/data_member_ref.cpp
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
openmp/libomptarget/test/mapping/lambda_by_value.cpp
openmp/libomptarget/test/mapping/lambda_mapping.cpp
openmp/libomptarget/test/mapping/ompx_hold/struct.c
openmp/libomptarget/test/offloading/bug49021.cpp
openmp/libomptarget/test/offloading/bug49334.cpp
openmp/libomptarget/test/offloading/bug49779.cpp
openmp/libomptarget/test/offloading/bug51781.c
openmp/libomptarget/test/offloading/host_as_target.c
openmp/libomptarget/test/offloading/memory_manager.cpp
openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
openmp/libomptarget/test/offloading/static_linking.c
openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
openmp/libomptarget/test/unified_shared_memory/api.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f454bd038ecf8..a1f4075ad9590 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2521,6 +2521,8 @@ def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
 def fopenmp_new_driver : Flag<["-"], "fopenmp-new-driver">, 
Flags<[CC1Option]>, Group,
   HelpText<"Use the new driver for OpenMP offloading.">;
+def fno_openmp_new_driver : Flag<["-"], "fno-openmp-new-driver">, 
Flags<[CC1Option]>, Group,
+  HelpText<"Don't use the new driver for OpenMP offloading.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group, Flags<[CC1Option]>,
   HelpText<"Disable tail call optimization, keeping the call stack accurate">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0095e87b6ba00..c2f33f2970e1f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3897,6 +3897,10 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 
&Args,
   ActionList LinkerInputs;
   ActionList MergerInputs;
 
+  bool UseNewOffloadingDriver =
+  C.isOffloadingHostKind(Action::OFK_OpenMP) &&
+  !Args.hasArg(options::OPT_fno_openmp_new_driver);
+
   for (auto &I : Inputs) {
 types::ID InputType = I.first;
 const Arg *InputArg = I.second;
@@ -3912,14 +3916,14 @@ void Driver::BuildActions(Compilation &C, 
DerivedArgList &Args,
 
 // Use the current host action in any of the offloading actions, if
 // required.
-if (!Args.hasArg(options::OPT_fopenmp_new_driver))
+if (!UseNewOffloadingDriver)
   if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg))
 break;
 
 for (phases::ID Phase : PL) {
 
   // Add any offload action the host action depends on.
-  if (!Args.hasArg(options::OPT_fopenmp_new_driver))
+  if (!UseNewOffloadingDriver)
 Current = OffloadBuilder.addDeviceDependencesToHostAction(
 Current, InputArg, Phase, PL.back(), FullPL);
   if (!Current)
@@ -3962,7 +3966,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 

[clang] 15e6206 - [Clang][Docs] Update information on the new driver now that it's default

2022-04-18 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-04-18T15:05:09-04:00
New Revision: 15e62062c0c919ac1fa28d6f0c9f438063da2286

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

LOG: [Clang][Docs] Update information on the new driver now that it's default

Summary:
This patch updates some of the documentation on the new driver now that
it's the default. Also the ABI for embedding these images changed.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/OffloadingDesign.rst
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index b94b0473f7c2f..1a0e4805bc263 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -801,7 +801,7 @@ Generate Interface Stub Files, emit merged text not binary.
 
 Extract API information
 
-.. option:: -fopenmp-new-driver
+.. option:: -fopenmp-new-driver, fno-openmp-new-driver
 
 Use the new driver for OpenMP offloading.
 

diff  --git a/clang/docs/OffloadingDesign.rst b/clang/docs/OffloadingDesign.rst
index 30018098f5378..43a0c0d2c29f7 100644
--- a/clang/docs/OffloadingDesign.rst
+++ b/clang/docs/OffloadingDesign.rst
@@ -17,11 +17,6 @@ application using Clang.
 OpenMP Offloading
 =
 
-.. note::
-   This documentation describes Clang's behavior using the new offloading
-   driver. This currently must be enabled manually using
-   ``-fopenmp-new-driver``.
-
 Clang supports OpenMP target offloading to several 
diff erent architectures such
 as NVPTX, AMDGPU, X86_64, Arm, and PowerPC. Offloading code is generated by
 Clang and then executed using the ``libomptarget`` runtime and the associated
@@ -226,15 +221,15 @@ A fat binary is a binary file that contains information 
intended for another
 device. We create a fat object by embedding the output of the device 
compilation
 stage into the host as a named section. The output from the device compilation
 is passed to the host backend using the ``-fembed-offload-object`` flag. This
-inserts the object as a global in the host's IR. The section name contains the
-target triple and architecture that the data corresponds to for later use.
-Typically we will also add an extra string to the section name to prevent it
-from being merged with other sections if the user performs relocatable linking
-on the object.
+embeds the device image into the ``.llvm.offloading`` section using a special
+binary format that behaves like a string map. This binary format is used to
+bundle metadata about the image so the linker can associate the proper device
+linking action with the image. Each device image will start with the magic 
bytes
+``0x10FF10AD``.
 
 .. code-block:: llvm
 
-  @llvm.embedded.object = private constant [1 x i8] c"\00", section 
".llvm.offloading.nvptx64.sm_70."
+  @llvm.embedded.object = private constant [1 x i8] c"\00", section 
".llvm.offloading"
 
 The device code will then be placed in the corresponding section one the 
backend
 is run on the host, creating a fat object. Using fat objects allows us to treat
@@ -250,7 +245,7 @@ will use this information when :ref:`Device Linking`.
 
+==++
 | omp_offloading_entries   | Offloading entry information (see 
:ref:`table-tgt_offload_entry`)  |
 
+--++
-| .llvm.offloading.. | Embedded device object file for the 
target device and architecture |
+| .llvm.offloading | Embedded device object file for the 
target device and architecture |
 
+--++
 
 .. _Device Linking:
@@ -262,9 +257,10 @@ Objects containing :ref:`table-offloading_sections` 
require special handling to
 create an executable device image. This is done using a Clang tool, see
 :doc:`ClangLinkerWrapper` for more information. This tool works as a wrapper
 over the host linking job. It scans the input object files for the offloading
-sections and runs the appropriate device linking action. The linked device 
image
-is then :ref:`wrapped ` to create the symbols used to 
load the
-device image and link it with the host.
+section ``.llvm.offloading``. The device files stored in this section are then
+extracted and passed tot he appropriate linking job. The linked device image is
+then :ref:`wrapped ` to create the symbols used to load
+the device image and link it with the host.
 
 The linker wrapper tool supports linking bitcode files through link time
 optimization (LTO). This is used whenever the obj

[PATCH] D122831: [OpenMP] Make the new offloading driver the default

2022-04-18 Thread Joseph Huber 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 rGae23be84cb60: [OpenMP] Make the new offloading driver the 
default (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122831

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-system-arch.c
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/amdgpu-openmp-toolchain.c
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/OpenMP/driver-openmp-target.c
  openmp/libomptarget/CMakeLists.txt
  openmp/libomptarget/plugins/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
  openmp/libomptarget/plugins/cuda/CMakeLists.txt
  openmp/libomptarget/test/lit.cfg
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/lambda_mapping.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug49334.cpp
  openmp/libomptarget/test/offloading/bug49779.cpp
  openmp/libomptarget/test/offloading/bug51781.c
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/offloading/memory_manager.cpp
  openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
  openmp/libomptarget/test/offloading/static_linking.c
  openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
  openmp/libomptarget/test/unified_shared_memory/api.c

Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -1,11 +1,11 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda
-// XFAIL: nvptx64-nvidia-cuda-newDriver
+// XFAIL: nvptx64-nvidia-cuda-oldDriver
 
 // Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newDriver
+// XFAIL: amdgcn-amd-amdhsa-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
===
--- openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
+++ openmp/libomptarget/test/offloading/taskloop_offload_nowait.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/static_linking.c
===
--- openmp/libomptarget/test/offloading/static_linking.c
+++ openmp/libomptarget/test/offloading/static_linking.c
@@ -2,8 +2,8 @@
 // RUN: llvm-ar rcs %t.a %t.o
 // RUN: %libomptarget-compile-generic %t.a && %libomptarget-run-generic 2>&1 | %fcheck-generic
 
-// REQUIRES: nvptx64-nvidia-cuda-newDriver
-// REQUIRES: amdgcn-amd-amdhsa-newDriver
+// REQUIRES: nvptx64-nvidia-cuda-oldDriver
+// REQUIRES: amdgcn-amd-amdhsa-oldDriver
 
 #ifdef LIBRARY
 int x = 42;
Index: openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
===
--- openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
+++ openmp/libomptarget/test/offloading/parallel_offloading_map.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/memory_manager.cpp
===
--- openmp/libomptarget/test/offloading/memory_manager.cpp
+++ openmp/libomptarget/test/offloading/memory_manager.cpp
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
-// UNSUPPORTED: x86_64-pc-linux-gnu-newDriver
+// UNSUPPORTED: x86_64-pc-linux-gnu-oldDriver
 
 #include 
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -9,7 +9,7 @@
 
 // amdgpu 

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk updated this revision to Diff 423445.
hvdijk added a comment.

Add to release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/clang-abi-compat.cpp
  clang/test/CodeGenCXX/mangle.cpp

Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1155,3 +1155,15 @@
   // CHECK-LABEL: @_ZN6test601fIiEEvDTplL_ZNS_1aEEcvT__EE
   template void f(int);
 }
+
+namespace test61 {
+  struct X {
+struct Y {
+  using a = int;
+  using b = int;
+};
+  };
+  template  void f(typename T::Y::a, typename T::Y::b) {}
+  // CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE
+  template void f(int, int);
+}
Index: clang/test/CodeGenCXX/clang-abi-compat.cpp
===
--- clang/test/CodeGenCXX/clang-abi-compat.cpp
+++ clang/test/CodeGenCXX/clang-abi-compat.cpp
@@ -1,25 +1,27 @@
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.8 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,PRE39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=3.9 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=4.0 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,PRE5,PRE12,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=5 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20,PRE15 %s
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=14 %s -emit-llvm -o - \
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,PRE15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V15 %s
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \
-// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s
+// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20,V15 %s
 
 typedef __attribute__((vector_size(8))) long long v1xi64;
 void clang39(v1xi64) {}
@@ -147,3 +149,14 @@
 inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0);
 int use_inline_var_lambda() { return inline_var_l

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

LGTM!  I would like @rjmccall to take a pass if he ends up having time in the 
next day or two (perhaps tack on an extra day or two because of Easter), else 
I'll be willing to approve later in the week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D120290: [Clang][OpenMP] Add the codegen support for `atomic compare capture`

2022-04-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11663
   X = BO->getLHS();
-  D = BO->getRHS();
+  D = BO->getRHS()->IgnoreImpCasts();
 

ABataev wrote:
> Why do we need to use `IgnoreImpCasts()` here and in other places?
Clang usually inserts implicit casts. For example, if we have:
```
char a, b, c;
#pragma omp atomic compare capture
  { r = a; if (a > c) { a = b; } }
```
Clang inserts an implicit cast from `char` to `int` for all statements except 
`r = a`. In this case, what should be the right solution? I'm not quite sure 
actually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120290

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


[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: jyknight, eli.friedman, hubert.reinterpretcast, 
erichkeane, clang-language-wg.
Herald added subscribers: dexonsmith, jdoerfert, martong.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

WG14 has elected to remove support for K&R C functions in C2x. The feature was 
introduced into C89 already deprecated, so after this long of a deprecation 
period, the committee has made an empty parameter list mean the same thing in C 
as it means in C++: the function accepts no arguments exactly as if the 
function were written with `(void)` as the parameter list.

This patch implements WG14 N2841 No function declarators without prototypes 
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm)  and WG14 N2432 
Remove support for function definitions with identifier lists 
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123955

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/c2x-func-prototype.c
  clang/test/Sema/attr-c2x.c
  clang/test/Sema/c2x-func-prototype.c
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -725,7 +725,7 @@
 
   Remove support for function definitions with identifier lists
   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf";>N2432
-  No
+  Clang 15
 
 
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -181,6 +181,7 @@
   Inv->getLangOpts()->CPlusPlus = true;
   Inv->getLangOpts()->CPlusPlus11 = true;
   Inv->getHeaderSearchOpts().UseLibcxx = true;
+  Inv->getLangOpts()->StrictPrototypes = true;
 }
 if (isObjC(Id)) {
   Inv->getLangOpts()->ObjC = 1;
Index: clang/test/Sema/c2x-func-prototype.c
===
--- /dev/null
+++ clang/test/Sema/c2x-func-prototype.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c2x -std=c2x %s
+// RUN: %clang_cc1 -Wno-strict-prototypes -fsyntax-only -verify -std=c17 %s
+// expected-no-diagnostics
+
+void func(); // c2x-note {{'func' declared here}}
+typedef void (*fp)();
+
+void other_func(int i);
+
+void call(void) {
+  func(1, 2, 3); // c2x-error {{too many arguments to function call, expected 0, have 3}}
+  fp call_me = func;
+  call_me(1, 2, 3); // c2x-error {{too many arguments to function call, expected 0, have 3}}
+
+  fp nope = other_func; // c2x-warning {{incompatible function pointer types initializing 'fp' (aka 'void (*)(void)') with an expression of type 'void (int)'}}
+}
+
+// Ensure these function declarations do not merge in C2x.
+void redecl1();  // c2x-note {{previous declaration is here}}
+void redecl1(int i); // c2x-error {{conflicting types for 'redecl1'}}
+
+void redecl2(int i); // c2x-note {{previous declaration is here}}
+void redecl2();  // c2x-error {{conflicting types for 'redecl2'}}
Index: clang/test/Sema/attr-c2x.c
===
--- clang/test/Sema/attr-c2x.c
+++ clang/test/Sema/attr-c2x.c
@@ -20,7 +20,7 @@
 void context_async_okay2(void *context [[clang::swift_async_context]], void *selfType, char **selfWitnessTable) [[clang::swiftasynccall]];
 
 [[clang::ownership_returns(foo)]] void *f1(void);
-[[clang::ownership_returns(foo)]] void *f2(); // expected-warning {{'ownership_returns' attribute only applies to non-K&R-style functions}}
+[[clang::ownership_returns(foo)]] void *f2();
 
 [[clang::unavailable("not available - replaced")]] void foo2(void); // expected-note {{'foo2' has been explicitly marked unavailable here}}
 void bar(void) {
Index: clang/test/Parser/c2x-func-prototype.c
===
--- /dev/null
+++ clang/test/Parser/c2x-func-prototype.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c2x -std=c2x %s
+// RUN: %clang_cc1 -Wno-strict-prototypes -fsyntax-only -verify -std=c17 %s
+// expected-no-diagnostics
+
+// Functions with an identifier list are not supported in C2x.
+void ident_list(a) // c2x-error {{expected ';' after top level declarator}} \
+  c2x-warning {{type specifier missing, defaults to 'int'}}
+  int a;
+{} // c2x-error {{expected identifier or '('}}

[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 423448.
python3kgae added a comment.

Fix doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaHLSL/shader_type_attr.hlsl

Index: clang/test/SemaHLSL/shader_type_attr.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/shader_type_attr.hlsl
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -DFAIL -verify
+
+#ifdef FAIL
+
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("compute")]
+struct Fido {
+  // expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("pixel")]
+  void wag() {}
+  // expected-warning@+1 {{'shader' attribute only applies to global functions}}
+  [shader("vertex")]
+  static void oops() {}
+};
+
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("vertex")]
+static void oops() {}
+
+namespace spec {
+// expected-warning@+1 {{'shader' attribute only applies to global functions}}
+[shader("vertex")]
+static void oops() {}
+} // namespace spec
+
+// expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
+[shader("compute")]
+// expected-note@+1 {{conflicting attribute is here}}
+[shader("vertex")]
+int doubledUp() {
+  return 1;
+}
+
+// expected-note@+1 {{conflicting attribute is here}}
+[shader("vertex")]
+int forwardDecl();
+
+// expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}}
+[shader("compute")]
+int forwardDecl() {
+  return 1;
+}
+
+// expected-error@+1 {{'shader' attribute takes one argument}}
+[shader()]
+// expected-error@+1 {{'shader' attribute takes one argument}}
+[shader(1, 2)]
+// expected-error@+1 {{'shader' attribute requires a string}}
+[shader(1)]
+// expected-warning@+1 {{'shader' attribute argument not supported: cs}}
+[shader("cs")]
+
+#endif // END of FAIL
+
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+[shader("compute")]
+int entry() {
+  return 1;
+}
+
+// Because these two attributes match, they should both appear in the AST
+[shader("compute")]
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+int secondFn();
+
+[shader("compute")]
+// CHECK:HLSLShaderAttr 0x{{[0-9a-fA-F]+}}  Compute
+int secondFn() {
+  return 1;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6940,6 +6940,39 @@
   D->addAttr(::new (S.Context) HLSLSV_GroupIndexAttr(S.Context, AL));
 }
 
+static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  StringRef Str;
+  SourceLocation ArgLoc;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
+return;
+
+  HLSLShaderAttr::ShaderType ShaderType;
+  if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
+S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+<< AL << Str << ArgLoc;
+return;
+  }
+
+  // FIXME: check function match the shader stage.
+
+  HLSLShaderAttr *NewAttr = S.mergeHLSLShaderAttr(D, AL, ShaderType);
+  if (NewAttr)
+D->addAttr(NewAttr);
+}
+
+HLSLShaderAttr *
+Sema::mergeHLSLShaderAttr(Decl *D, const AttributeCommonInfo &AL,
+  HLSLShaderAttr::ShaderType ShaderType) {
+  if (HLSLShaderAttr *NT = D->getAttr()) {
+if (NT->getType() != ShaderType) {
+  Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
+  Diag(AL.getLoc(), diag::note_conflicting_attribute);
+}
+return nullptr;
+  }
+  return HLSLShaderAttr::Create(Context, ShaderType, AL);
+}
+
 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   if (!S.LangOpts.CPlusPlus) {
 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang)
@@ -8815,6 +8848,9 @@
   case ParsedAttr::AT_HLSLSV_GroupIndex:
 handleHLSLSVGroupIndexAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_HLSLShader:
+handleHLSLShaderAttr(S, D, AL);
+break;
 
   case ParsedAttr::AT_AbiTag:
 handleAbiTagAttr(S, D, AL);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2806,6 +2806,8 @@
   else if (const auto *NT = dyn_cast(Attr))
 NewAttr =
 S.mergeHLSLNumThreadsAttr(D, *NT, NT->getX(), NT->getY(), NT->getZ());
+  else if (const auto *SA = dyn_cast(Attr))
+NewAttr = S.mergeHLSLShaderAttr(D, *SA, SA->getType());
   else if (Attr->shouldInher

[PATCH] D123907: [HLSL] Add shader attribute

2022-04-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:6389-6391
+Normally the shader type is set by shader target with the -T option like
+-Tps_6_1.
+When compiling to a library target like lib_6_3, the shader type attribute can

aaron.ballman wrote:
> 
Thanks for the edit.
Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123907

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


[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:11243
 
   // We really shouldn't be making a no-proto type here.
+  if (ArgTypes.empty() && Variadic && !getLangOpts().StrictPrototypes)

How tough would it be to change this to represent always as a C++-esque 
`foo(...)` prototype, just always?



Comment at: clang/lib/Sema/SemaDecl.cpp:8821
 (!R->getAsAdjusted() && R->isFunctionProtoType());
+assert(SemaRef.getLangOpts().StrictPrototypes
+   ? HasPrototype

This assert is quite strange, particularly with the string part of it only in 
the 'else' of the conditional? It seems you're trying to ensure that:
"if strictProtoTypes, assert hasProtoType"?

In that case, I'd likely suggest:

`assert((HasProtoType || !SemeaRef.getLangOpts().StrictPrototypes) && "Strict 
prototypes are required");`





Comment at: clang/test/Parser/c2x-attributes.c:64
+  c2x-warning 2 {{type specifier missing, 
defaults to 'int'}} \
+  c2x-error {{expected ';' after top level 
declarator}} \
+  c2x-error {{expected identifier or '('}}

This is an unfortunate change in diagnostic quality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123955

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


[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:11243
 
   // We really shouldn't be making a no-proto type here.
+  if (ArgTypes.empty() && Variadic && !getLangOpts().StrictPrototypes)

erichkeane wrote:
> How tough would it be to change this to represent always as a C++-esque 
> `foo(...)` prototype, just always?
C doesn't allow that (but we do if the user specifies the `overloadable` 
attribute), so it could be a bit tricky.



Comment at: clang/lib/Sema/SemaDecl.cpp:8821
 (!R->getAsAdjusted() && R->isFunctionProtoType());
+assert(SemaRef.getLangOpts().StrictPrototypes
+   ? HasPrototype

erichkeane wrote:
> This assert is quite strange, particularly with the string part of it only in 
> the 'else' of the conditional? It seems you're trying to ensure that:
> "if strictProtoTypes, assert hasProtoType"?
> 
> In that case, I'd likely suggest:
> 
> `assert((HasProtoType || !SemeaRef.getLangOpts().StrictPrototypes) && "Strict 
> prototypes are required");`
> 
> 
You decoded what I was going for, but I like your approach better. Thanks!



Comment at: clang/test/Parser/c2x-attributes.c:64
+  c2x-warning 2 {{type specifier missing, 
defaults to 'int'}} \
+  c2x-error {{expected ';' after top level 
declarator}} \
+  c2x-error {{expected identifier or '('}}

erichkeane wrote:
> This is an unfortunate change in diagnostic quality.
Agreed, but thankfully this situation should be exceedingly rare (trying to put 
`[[]]` attributes after a function definition with an identifier list).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123955

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


[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 423451.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback


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

https://reviews.llvm.org/D123955

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/c2x-func-prototype.c
  clang/test/Sema/attr-c2x.c
  clang/test/Sema/c2x-func-prototype.c
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -725,7 +725,7 @@
 
   Remove support for function definitions with identifier lists
   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf";>N2432
-  No
+  Clang 15
 
 
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -181,6 +181,7 @@
   Inv->getLangOpts()->CPlusPlus = true;
   Inv->getLangOpts()->CPlusPlus11 = true;
   Inv->getHeaderSearchOpts().UseLibcxx = true;
+  Inv->getLangOpts()->StrictPrototypes = true;
 }
 if (isObjC(Id)) {
   Inv->getLangOpts()->ObjC = 1;
Index: clang/test/Sema/c2x-func-prototype.c
===
--- /dev/null
+++ clang/test/Sema/c2x-func-prototype.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c2x -std=c2x %s
+// RUN: %clang_cc1 -Wno-strict-prototypes -fsyntax-only -verify -std=c17 %s
+// expected-no-diagnostics
+
+void func(); // c2x-note {{'func' declared here}}
+typedef void (*fp)();
+
+void other_func(int i);
+
+void call(void) {
+  func(1, 2, 3); // c2x-error {{too many arguments to function call, expected 0, have 3}}
+  fp call_me = func;
+  call_me(1, 2, 3); // c2x-error {{too many arguments to function call, expected 0, have 3}}
+
+  fp nope = other_func; // c2x-warning {{incompatible function pointer types initializing 'fp' (aka 'void (*)(void)') with an expression of type 'void (int)'}}
+}
+
+// Ensure these function declarations do not merge in C2x.
+void redecl1();  // c2x-note {{previous declaration is here}}
+void redecl1(int i); // c2x-error {{conflicting types for 'redecl1'}}
+
+void redecl2(int i); // c2x-note {{previous declaration is here}}
+void redecl2();  // c2x-error {{conflicting types for 'redecl2'}}
Index: clang/test/Sema/attr-c2x.c
===
--- clang/test/Sema/attr-c2x.c
+++ clang/test/Sema/attr-c2x.c
@@ -20,7 +20,7 @@
 void context_async_okay2(void *context [[clang::swift_async_context]], void *selfType, char **selfWitnessTable) [[clang::swiftasynccall]];
 
 [[clang::ownership_returns(foo)]] void *f1(void);
-[[clang::ownership_returns(foo)]] void *f2(); // expected-warning {{'ownership_returns' attribute only applies to non-K&R-style functions}}
+[[clang::ownership_returns(foo)]] void *f2();
 
 [[clang::unavailable("not available - replaced")]] void foo2(void); // expected-note {{'foo2' has been explicitly marked unavailable here}}
 void bar(void) {
Index: clang/test/Parser/c2x-func-prototype.c
===
--- /dev/null
+++ clang/test/Parser/c2x-func-prototype.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c2x -std=c2x %s
+// RUN: %clang_cc1 -Wno-strict-prototypes -fsyntax-only -verify -std=c17 %s
+// expected-no-diagnostics
+
+// Functions with an identifier list are not supported in C2x.
+void ident_list(a) // c2x-error {{expected ';' after top level declarator}} \
+  c2x-warning {{type specifier missing, defaults to 'int'}}
+  int a;
+{} // c2x-error {{expected identifier or '('}}
+
+// Functions with an empty parameter list are supported as though the function
+// was declared with a parameter list of (void). Ensure they still parse.
+void no_param_decl();
+void no_param_defn() {}
+void (*var_of_type_with_no_param)();
+typedef void fn();
Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify -Wno-strict-prototypes %s
-// RUN: %clang_cc1 -fsyntax-only -std=gnu2x -verify -Wno-strict-prototypes %s
+// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify=expected,notc2x -Wno-strict-prototypes %s
+// 

[PATCH] D122663: Mark identifier prefixes as substitutable

2022-04-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:6031
+bool CXXNameMangler::mangleSubstitution(NestedNameSpecifier *NNS) {
+  NNS = Context.getASTContext().getCanonicalNestedNameSpecifier(NNS);
+  return mangleSubstitution(reinterpret_cast(NNS));

This seems a little error-prone to me: calling this on a type NNS would do the 
wrong thing (those are supposed to share a substitution number with the type, 
rather than have a substitution of their own).

We could handle the various cases here and dispatch to the right forms of 
`mangleSubstitution` depending on the kind of NNS, but that code would all be 
unreachable / untested. So maybe we should just make this assert that 
`NNS->getKind() == NestedNameSpecifier::Identifier`. (And optionally we could 
give this a more specific name, eg `mangleSubstitutionForIdentifierNNS`?)



Comment at: clang/test/CodeGenCXX/clang-abi-compat.cpp:160
+template  void test10(typename T::Y::a, typename T::Y::b) {}
+// PRE15: @_Z6test10I1XEvNT_1Y1aENS1_1Y1bE
+// V15:   @_Z6test10I1XEvNT_1Y1aENS2_1bE

I think this test does not capture an important property for which we should 
have test coverage: that we used to not register a substitution for `T::Y` (not 
only that we used to not *use* a substitution for it). For example, this test 
would capture that:

```
struct X {
  struct Y {
using a = int;
using b = int;
  };
};
template  void test10(typename T::Y::a, typename T::Y::b, float*, 
float*) {}
template void test10(int, int, float*, float*);
```
... where the numbering of `float*` depends on how many substitutions we 
created for the earlier types.

(Put another way, this test covers only one of the two `if (!Clang14Compat)` 
tests in ItaniumMangle.cpp, and we should cover both.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122663

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


[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:11243
 
   // We really shouldn't be making a no-proto type here.
+  if (ArgTypes.empty() && Variadic && !getLangOpts().StrictPrototypes)

aaron.ballman wrote:
> erichkeane wrote:
> > How tough would it be to change this to represent always as a C++-esque 
> > `foo(...)` prototype, just always?
> C doesn't allow that (but we do if the user specifies the `overloadable` 
> attribute), so it could be a bit tricky.
Hmm... I guess that is fair.  Thinking further, we likely 'assume' that cannot 
be the case else where :/



Comment at: clang/test/Parser/c2x-attributes.c:64
+  c2x-warning 2 {{type specifier missing, 
defaults to 'int'}} \
+  c2x-error {{expected ';' after top level 
declarator}} \
+  c2x-error {{expected identifier or '('}}

aaron.ballman wrote:
> erichkeane wrote:
> > This is an unfortunate change in diagnostic quality.
> Agreed, but thankfully this situation should be exceedingly rare (trying to 
> put `[[]]` attributes after a function definition with an identifier list).
Ah! less concerned then.


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

https://reviews.llvm.org/D123955

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


[clang] af02851 - Revert "[OpenMP] Refactor OMPScheduleType enum."

2022-04-18 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-04-18T14:38:31-05:00
New Revision: af0285122f306573d9bcc4c4ad7f904cfdd4d869

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

LOG: Revert "[OpenMP] Refactor OMPScheduleType enum."

This reverts commit 9ec501da76fc1559cadd6d6dac32766bf4376a3d.

It may have caused the openmp-gcc-x86_64-linux-debian buildbot to fail.
https://lab.llvm.org/buildbot/#/builders/4/builds/20377

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned_auto.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a249ef9d58d97..e85c702907fa0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3760,11 +3760,9 @@ void CodeGenFunction::EmitOMPForDirective(const 
OMPForDirective &S) {
   CGM.getOpenMPRuntime().getOMPBuilder();
   llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
   AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
-  OMPBuilder.applyWorkshareLoop(
-  Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
-  SchedKind, ChunkSize, /*HasSimdModifier=*/false,
-  /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
-  /*HasOrderedClause=*/false);
+  OMPBuilder.applyWorkshareLoop(Builder.getCurrentDebugLocation(), CLI,
+AllocaIP, NeedsBarrier, SchedKind,
+ChunkSize);
   return;
 }
 

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
index bf0383cdb956c..f1dadc63a22a0 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_auto.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741862, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 38, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
index 8a126c2ea440a..39321ff3b7af0 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 1)
+// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 35, i32 1, i32 %[[DOTCOUNT]], i32 1, i32 1)
 // CHECK-NEXT:br label %[[OMP_LOOP_PREHEADER_OUTER_COND:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[OMP_LOOP_HEADER:.*]]:

diff  --git a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c 
b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
index 09773a2bd6f17..fd932a4f82070 100644
--- a/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
+++ b/clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
@@ -38,7 +38,7 @@
 // CHECK-NEXT:store i32 %[[DOTCOUNT]], i32* %[[P_UPPERBOUND]], align 4
 // CHECK-NEXT:store i32 1, i32* %[[P_STRIDE]], align 4
 // CHECK-NEXT:%[[OMP_GLOBAL_THREAD_NUM:.+]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @1)
-// CHECK-NEXT:call void @__kmpc_dispatch_init_4u(%struct.ident_t* @1, i32 
%[[OMP_GLOBAL_THREAD_NUM]], i32 1073741859, i32 1, i32 %[[DOTCOUNT]], i32 1, 
i32 5)
+// CHECK-NEXT:  

[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

2022-04-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks for working on this, Just a few comments




Comment at: clang/lib/Basic/LangOptions.cpp:119
   Opts.Digraphs = Std.hasDigraphs();
+  Opts.StrictPrototypes = Std.isCPlusPlus() || Std.isC2x();
 

Stupid question, we probably don't want -fno-strict-prototype` to have an 
effect in  C++. is there something to deal with that? I'm not familiar with the 
option system



Comment at: clang/lib/Sema/SemaDecl.cpp:8821-8823
+assert(SemaRef.getLangOpts().StrictPrototypes
+   ? HasPrototype
+   : (true && "Strict prototypes are required"));

erichkeane wrote:
> This assert is quite strange, particularly with the string part of it only in 
> the 'else' of the conditional? It seems you're trying to ensure that:
> "if strictProtoTypes, assert hasProtoType"?
> 
> In that case, I'd likely suggest:
> 
> `assert((HasProtoType || !SemeaRef.getLangOpts().StrictPrototypes) && "Strict 
> prototypes are required");`
> 
> 
That would make more sense to me, not that it affects the logic
```
assert((SemaRef.getLangOpts().StrictPrototypes
   ? HasPrototype
   : true) && "Strict prototypes are required");
```



Comment at: clang/lib/Sema/SemaType.cpp:5299
+  ? Context.getFunctionNoProtoType(T, EI)
+ : Context.IntTy;
   break;

can you explain the `Context.IntTy` here ?


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

https://reviews.llvm.org/D123955

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


  1   2   >