[PATCH] D92936: [Sema] Fix deleted function problem in implicitly movable test

2021-01-01 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Thanks, and checking other compilers with godbolt is a good idea (I had tried 
gcc locally but it was likely too old)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92936

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


[clang-tools-extra] b4c5e19 - Temporarily disable to clang-tidy tests on Windows

2021-01-01 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-01-01T23:19:48-05:00
New Revision: b4c5e19da74773b86662cbe5a7437f72116f3615

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

LOG: Temporarily disable to clang-tidy tests on Windows

They fail at least on my Win bot after switching it to Py3.
See PR48646 for details.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-custom.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-custom.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-custom.cpp
index e25eae323094..b3075324efdb 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-custom.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-custom.cpp
@@ -1,3 +1,6 @@
+// FIXME: PR48646
+// UNSUPPORTED: system-windows
+
 // RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \
 // RUN: -config='{CheckOptions: \
 // RUN:  [{key: cppcoreguidelines-macro-usage.AllowedRegexp, value: 
"DEBUG_*|TEST_*"}]}' --

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
index e99edff5cc21..625b7dc9134a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
@@ -1,3 +1,6 @@
+// FIXME: PR48646
+// UNSUPPORTED: system-windows
+
 // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: readability-identifier-naming.ParameterCase, value: 
CamelCase}, \



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


[PATCH] D92936: [Sema] Fix deleted function problem in implicitly movable test

2021-01-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D92936#2476091 , @aeubanks wrote:

> This broke [ https://godbolt.org/z/9EG7ev ]
> is this intentional?

Yes, intentional. This brings Clang's C++14 conformance into line with 
GCC/EDG/MSVC, who all already (correctly) reject that code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92936

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


[PATCH] D92936: [Sema] Fix deleted function problem in implicitly movable test

2021-01-01 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

This broke

  struct A {
A();
A(A&&)=delete;
   private:
A(const A&);
   friend class B;
  };
  
  struct B {
A foo() {
  A a;
  return a;
}
  };

with

  /tmp/a.cc:12:12: error: call to deleted constructor of 'A'
  return a;
 ^
  /tmp/a.cc:3:3: note: 'A' has been explicitly marked deleted here
A(A&&)=delete;
^
  1 error generated.

is this intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92936

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-01-01 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added a comment.

@MyDeveloperDay Would you mind explaining what changes you're wanting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-01 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu updated this revision to Diff 314229.
alokmishra.besu added a comment.

Rebased with current branch to avoid patch failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -60,6 +60,7 @@
   let clangClass = "OMPCollapseClause";
   let flangClassValue = "ScalarIntConstantExpr";
 }
+def OMPC_When: Clause<"when"> {}
 def OMPC_Default : Clause<"default"> {
   let clangClass = "OMPDefaultClause";
   let flangClassValue = "OmpDefaultClause";
@@ -319,6 +320,14 @@
 // Definition of OpenMP directives
 //===--===//
 
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+  let allowedOnceClauses = [
+VersionedClause
+  ];
+}
 def OMP_ThreadPrivate : Directive<"threadprivate"> {}
 def OMP_Parallel : Directive<"parallel"> {
   let allowedClauses = [
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -639,6 +639,9 @@
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5526,6 +5526,8 @@
 return cxstring::createRef("CXXAccessSpecifier");
   case CXCursor_ModuleImportDecl:
 return cxstring::createRef("ModuleImport");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'isa' 'arch'}} expected-note {{the ignored selector spans until here}}
+  ;
+#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expec

[clang] ec9f2c3 - test/OpenMP/parallel_codegen.cpp: Allow multiple result attributes

2021-01-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-01-01T10:46:34-08:00
New Revision: ec9f2c3be070ec2fc4d45f13c70e68c8c0deafc2

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

LOG: test/OpenMP/parallel_codegen.cpp: Allow multiple result attributes

On many targets the matched line is `define dso_local i32 @main` while
on ppc64 it is `define dso_local signext i32 @main`.

Added: 


Modified: 
clang/test/OpenMP/parallel_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/test/OpenMP/parallel_codegen.cpp
index f61e6867b280..b32f6c3b91c7 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -59,7 +59,7 @@ int main (int argc, char **argv) {
   return tmain(argv);
 }
 
-// ALL-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}} %argc, i8** 
%argv)
+// ALL-LABEL: define{{[ _a-z]*}} i32 @main({{i32[ ]?[a-z]*}} %argc, i8** %argv)
 // ALL: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
 // ALL: [[VLA:%.+]] = alloca i32, i{{[0-9]+}} [[VLA_SIZE:%[^,]+]],
 // CHECK:  call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, 
...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, 
...)* bitcast (void (i32*, i32*, i{{[0-9]+}}, i32*)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i{{[0-9]+}} [[VLA_SIZE]], i32* [[VLA]])



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


[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

2021-01-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1221
+if (Style.EmptyLineBeforeAccessModifier &&
+PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
+RootToken.NewlinesBefore == 1)

maybe I don't understand the logic but why is this `r_brace` and shouldn't we 
be looking at the "Last Non Comment" token?


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

https://reviews.llvm.org/D93846

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


[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

2021-01-01 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki reclaimed this revision.
danielmarjamaki added a comment.

ok.. thanks for the reviews. I will see if I can make some new check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92634

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-01 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu added a comment.

Emitting error instead of instantiation in clang/lib/Sema/TreeTransform.h. 
Added a TODO for future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-01-01 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu updated this revision to Diff 314224.
alokmishra.besu marked an inline comment as done.
alokmishra.besu added a comment.

All clang test and clang-tidy pass. Ran clang-format on all code, except 
clang/include/clang/Serialization/ASTBitCodes.h which was formatting unrelated 
code as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_ast_print.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -115,6 +115,7 @@
 __OMP_CLAUSE_NO_CLASS(uniform)
 __OMP_CLAUSE_NO_CLASS(device_type)
 __OMP_CLAUSE_NO_CLASS(match)
+__OMP_CLAUSE_NO_CLASS(when)
 
 __OMP_IMPLICIT_CLAUSE_CLASS(depobj, "depobj", OMPDepobjClause)
 __OMP_IMPLICIT_CLAUSE_CLASS(flush, "flush", OMPFlushClause)
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -59,6 +59,7 @@
   let clangClass = "OMPCollapseClause";
   let flangClassValue = "ScalarIntConstantExpr";
 }
+def OMPC_When: Clause<"when"> {}
 def OMPC_Default : Clause<"default"> {
   let clangClass = "OMPDefaultClause";
   let flangClass = "OmpDefaultClause";
@@ -295,6 +296,14 @@
 // Definition of OpenMP directives
 //===--===//
 
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+  let allowedOnceClauses = [
+VersionedClause
+  ];
+}
 def OMP_ThreadPrivate : Directive<"threadprivate"> {}
 def OMP_Parallel : Directive<"parallel"> {
   let allowedClauses = [
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -639,6 +639,9 @@
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5525,6 +5525,8 @@
 return cxstring::createRef("CXXAccessSpecifier");
   case CXCursor_ModuleImportDecl:
 return cxstring::createRef("ModuleImport");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal des

[PATCH] D93955: [Sema] Add support for reporting multiple errors during initialization

2021-01-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/test/SemaCXX/diagnostic-initialization.cpp:7
+template 
+class initializer_list {
+  const _E *__begin_;

Looking at other places like 
`clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp`, I think you don't need 
quite so much code here. However, also, I'm amazed that people are 
cutting-and-pasting `class initializer_list` between test cases; shouldn't it 
just be in a support header somewhere? (My second sentence is likely out of 
scope for this PR, I know.)
Anyway, my next comment shows that you don't need `initializer_list` at all, so 
both parts of this comment are moot.



Comment at: clang/test/SemaCXX/diagnostic-initialization.cpp:43
+// expected-error@-1 {{call to deleted constructor of 'A'}}
+// expected-error@-2 {{chosen constructor is explicit in copy-initialization}}

https://godbolt.org/z/aMa4e6 (showing the old behavior, and also showing that 
you don't need `class initializer_list` to trigger it)

IIUC, the changed behavior here is that old-Clang complained only that the 
chosen ctor was deleted; new-Clang complains that the chosen ctor is deleted 
//and// that the chosen ctor is explicit?
IMHO this is not actually an improvement, at least not in this particular case. 
However, it's not //significantly worse//, and also it brings Clang (back) into 
line with GCC and ICC in terms of outputting multiple complaints about the same 
problem, so I wouldn't say that this patch is //wrong//...
Still, could you find an example where this patch clearly //improves// Clang's 
behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93955

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


[PATCH] D93962: [Sema] Fix the program state in reference initialization

2021-01-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

This could use some tests. (What's observably bad about the old code's 
behavior? does this patch fix that behavior?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93962

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


[PATCH] D93955: [Sema] Add support for reporting multiple errors during initialization

2021-01-01 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 314214.
nullptr.cpp edited the summary of this revision.
nullptr.cpp added a comment.

Separate out D93962 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93955

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/diagnostic-initialization.cpp

Index: clang/test/SemaCXX/diagnostic-initialization.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/diagnostic-initialization.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify=expected %s
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E &reference;
+  typedef const _E &const_reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+} // namespace std
+
+// C++11 [over.match.list]p1:
+//   In copy-list-initialization, if an explicit constructor is chosen, the
+//   initializer is ill-formed.
+struct A {
+  explicit A(std::initializer_list) = delete;
+  // expected-note@-1 {{'A' has been explicitly marked deleted here}}
+  // expected-note@-2 {{explicit constructor declared here}}
+};
+
+A a = {1, 2, 3};
+// expected-error@-1 {{call to deleted constructor of 'A'}}
+// expected-error@-2 {{chosen constructor is explicit in copy-initialization}}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -526,48 +526,52 @@
   // stlport does so too. Look for std::__debug for libstdc++, and for
   // std:: for stlport.  This is effectively a compiler-side implementation of
   // LWG2193.
-  if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
-  InitializationSequence::FK_ExplicitConstructor) {
-OverloadCandidateSet::iterator Best;
-OverloadingResult O =
-InitSeq.getFailedCandidateSet()
-.BestViableFunction(SemaRef, Kind.getLocation(), Best);
-(void)O;
-assert(O == OR_Success && "Inconsistent overload resolution");
-CXXConstructorDecl *CtorDecl = cast(Best->Function);
-CXXRecordDecl *R = CtorDecl->getParent();
-
-if (CtorDecl->getMinRequiredArguments() == 0 &&
-CtorDecl->isExplicit() && R->getDeclName() &&
-SemaRef.SourceMgr.isInSystemHeader(CtorDecl->getLocation())) {
-  bool IsInStd = false;
-  for (NamespaceDecl *ND = dyn_cast(R->getDeclContext());
-   ND && !IsInStd; ND = dyn_cast(ND->getParent())) {
-if (SemaRef.getStdNamespace()->InEnclosingNamespaceSetOf(ND))
-  IsInStd = true;
-  }
+  if (!InitSeq && EmptyInitList) {
+auto Failures = InitSeq.getFailureKind();
+if (Failures.end() !=
+std::find(Failures.begin(), Failures.end(),
+  InitializationSequence::FK_ExplicitConstructor)) {
+  OverloadCandidateSet::iterator Best;
+  OverloadingResult O = InitSeq.getFailedCandidateSet().BestViableFunction(
+  SemaRef, Kind.getLocation(), Best);
+  (void)O;
+  assert(O == OR_Success && "Inconsistent overload resolution");
+  CXXConstructorDecl *CtorDecl = cast(Best->Function);
+  CXXRecordDecl *R = CtorDecl->getParent();
+
+  if (CtorDecl->getMinRequiredArguments() == 0 && CtorDecl->isExplicit() &&
+  R->getDeclName() &&
+  SemaRef.SourceMgr.isInSystemHeader(CtorDecl->getLocation())) {
+bool IsInStd = false;
+for (NamespaceDecl *ND = dyn_cast(R->getDeclContext());
+ ND && !IsInStd; ND = dyn_cast(ND->getParent())) {
+  if (SemaRef.getStdNamespace()->InEnclosingNamespaceSetOf(ND))
+IsInStd = true;
+}
 
-  if (IsInStd && llvm::StringSwitch(R->getName())
-  .Cases("basic_string", "deque", "forward_list", true)
-  .Cases("list", "map", "multimap", "multiset", true)
-  .Cases("priority_queue", "queue", "set", "stack", true)
-  .Cases("unordered_map", "unordered_set", "vector", true)
-  .Default(false)) {
-InitSeq.InitializeFrom(
-SemaRef, Entity,
-InitializationKind::CreateValue(Loc, Loc, Loc, true),
-MultiExprArg(), /*TopLevelOfInitList=*/false,
-TreatUnavailableAsInvalid);
-// Emit a warning for this.  System header warnings aren't shown
-// by default, but people

[PATCH] D93962: [Sema] Fix the program state in reference initialization

2021-01-01 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp created this revision.
nullptr.cpp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to [dcl.init.ref]p5:

> A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2”
>  as follows:
>
>   — If the reference is an lvalue reference and the initializer expression
> — is an lvalue (but is not a bit-field), and “cv1 T1” is
>   reference-compatible with “cv2 T2”, or
> — has a class type (i.e., T2 is a class type), where T1 is not
>   reference-related to T2, and can be converted to an lvalue of type
>   “cv3 T3”, where “cv1 T1” is reference-compatible with “cv3 T3” (this
>   conversion is selected by enumerating the applicable conversion 
> functions
>   and choosing the best one through overload resolution),
> then the reference is bound to the initializer expression lvalue in the
> first case and to the lvalue result of the conversion in the second case
> (or, in either case, to the appropriate base class subobject of the 
> object).
>   
>   — Otherwise, [...]

If the overload resolution fails in the second case, the program should continue
to check other conditions and the program is NOT ill-formed at this point. But
the code here sets the program to ill-formed state.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93962

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4811,10 +4811,6 @@
 /*IsLValueRef*/ isLValueRef, Sequence);
 if (ConvOvlResult == OR_Success)
   return;
-if (ConvOvlResult != OR_No_Viable_Function)
-  Sequence.SetOverloadFailure(
-  InitializationSequence::FK_ReferenceInitOverloadFailed,
-  ConvOvlResult);
   } else {
 ConvOvlResult = OR_No_Viable_Function;
   }


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4811,10 +4811,6 @@
 /*IsLValueRef*/ isLValueRef, Sequence);
 if (ConvOvlResult == OR_Success)
   return;
-if (ConvOvlResult != OR_No_Viable_Function)
-  Sequence.SetOverloadFailure(
-  InitializationSequence::FK_ReferenceInitOverloadFailed,
-  ConvOvlResult);
   } else {
 ConvOvlResult = OR_No_Viable_Function;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

2021-01-01 Thread Albertas Vyšniauskas via Phabricator via cfe-commits
thezbyg added a comment.

When access modifier is in the same line with previous tokens, 
**UnwrappedLineFormatter::formatFirstToken** is called with 
**RootToken.NewlinesBefore** == 0, but empty line is only inserted if 
**RootToken.NewlinesBefore** == 1. The following change fixes this and passes 
all tests except the ones with comment:

 if (PreviousLine && RootToken.isAccessSpecifier()) {
   if (Style.EmptyLineBeforeAccessModifier &&
   PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
  -RootToken.NewlinesBefore == 1)
  -  ++Newlines;
  +RootToken.NewlinesBefore <= 1)
  +  Newlines = 2;
   else if (!Style.EmptyLineBeforeAccessModifier &&
RootToken.NewlinesBefore > 1)
 Newlines = 1;
 }


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

https://reviews.llvm.org/D93846

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


[PATCH] D93961: [clang-tidy][NFC] Fix a build warning due to an extra semicolon

2021-01-01 Thread Yang Fan via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5324c052b21: [clang-tidy][NFC] Fix a build warning due to 
an extra semicolon (authored by nullptr.cpp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93961

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -392,7 +392,7 @@
 
 static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
   (*reinterpret_cast(Ctx))(Diag);
-};
+}
 
 llvm::ErrorOr
 parseConfigurationWithDiags(llvm::MemoryBufferRef Config,


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -392,7 +392,7 @@
 
 static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
   (*reinterpret_cast(Ctx))(Diag);
-};
+}
 
 llvm::ErrorOr
 parseConfigurationWithDiags(llvm::MemoryBufferRef Config,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d5324c0 - [clang-tidy][NFC] Fix a build warning due to an extra semicolon

2021-01-01 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-01-01T16:00:20+08:00
New Revision: d5324c052b21741d8d9f980d796604589b85c97a

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

LOG: [clang-tidy][NFC] Fix a build warning due to an extra semicolon

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 472123f8b306..be068aa8da4a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -392,7 +392,7 @@ parseConfiguration(llvm::MemoryBufferRef Config) {
 
 static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
   (*reinterpret_cast(Ctx))(Diag);
-};
+}
 
 llvm::ErrorOr
 parseConfigurationWithDiags(llvm::MemoryBufferRef Config,



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