[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2020-08-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp:27-31
+  createHTMLDiagnosticConsumer(
+  DiagOpts, C, std::string(llvm::sys::path::parent_path(Prefix)), PP, CTU);
+  createPlistMultiFileDiagnosticConsumer(DiagOpts, C, Prefix, PP, CTU);
+  createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, Prefix, PP,
+  CTU);

I just realized that this code creates 5 consumers: 1 html consumer, 1 plist 
consumer, 3 text consumers. This isn't a regression due to this patch... but 
damn!


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

https://reviews.llvm.org/D67422

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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-08-13 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

The regression here seems to be because operations on an empty GraphDiff don't 
optimize out. Not going through GraphDiff but using the same basic logic 
(https://github.com/llvm/llvm-project/commit/4c6a5de8131183ff88f52cc3dda67180e31501a1
 -- going through a separate method seems to be necessary for NRVO) we get back 
at least part of it: 
https://llvm-compile-time-tracker.com/compare.php?from=38537307e502c1ac9a09e6f75f9208db1327a0bf&to=4c6a5de8131183ff88f52cc3dda67180e31501a1&stat=instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713

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


[PATCH] D85819: [SyntaxTree] Split tests

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 285273.
eduucaldas marked 11 inline comments as done.
eduucaldas added a comment.

Answer review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85819

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1145,6 +1145,72 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, QualifiedId_DecltypeSpecifier) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct S {
+  static void f(){}
+};
+void test(S s) {
+  decltype(s)::f();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-S
+| |-{
+| |-SimpleDeclaration
+| | |-static
+| | |-void
+| | |-SimpleDeclarator
+| | | |-f
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-CompoundStatement
+| |   |-{
+| |   `-}
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-S
+  |   | `-SimpleDeclarator
+  |   |   `-s
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-DecltypeNameSpecifier
+| | | | | |-decltype
+| | | | | |-(
+| | | | | |-IdExpression
+| | | | | | `-UnqualifiedId
+| | | | | |   `-s
+| | | | | `-)
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, QualifiedId_OptionalTemplateKw) {
   if (!GetParam().isCXX()) {
 return;
@@ -1235,11 +1301,11 @@
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 namespace n {
-template
-struct ST {
-  template
-  static U f();
-};
+  template
+  struct ST {
+template
+static U f();
+  };
 }
 void test() {
   ::n::template ST::template f();
@@ -1409,72 +1475,6 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedId_Decltype) {
-  if (!GetParam().isCXX11OrLater()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-struct S {
-  static void f(){}
-};
-void test(S s) {
-  decltype(s)::f();
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-S
-| |-{
-| |-SimpleDeclaration
-| | |-static
-| | |-void
-| | |-SimpleDeclarator
-| | | |-f
-| | | `-ParametersAndQualifiers
-| | |   |-(
-| | |   `-)
-| | `-CompoundStatement
-| |   |-{
-| |   `-}
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-S
-  |   | `-SimpleDeclarator
-  |   |   `-s
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | |-NestedNameSpecifier
-| | | | |-DecltypeNameSpecifier
-| | | | | |-decltype
-| | | | | |-(
-| | | | | |-IdExpression
-| | | | | | `-UnqualifiedId
-| | | | | |   `-s
-| | | | | `-)
-| | | | `-::
-| | | `-UnqualifiedId
-| | |   `-f
-| | |-(
-| | `-)
-| `-;
-`-}
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, ParenExpr) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
@@ -2643,7 +2643,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, NestedBinaryOperator_Parenthesis) {
+TEST_P(SyntaxTreeTest, BinaryOperator_NestedWithParenthesis) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
@@ -2687,7 +2687,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, NestedBinaryOperator_Associativity) {
+TEST_P(SyntaxTreeTest, BinaryOperator_Associativity) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test(int a, int b) {
@@ -2747,7 +2747,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, NestedBinaryOperator_Precedence) {
+TEST_P(SyntaxTreeTest, BinaryOperator_Precedence) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
@@ -2802,7 +2802,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UserDefinedOperator_Assignment) {
+TEST_P(SyntaxTreeTest, OverloadedOperator_Assignment) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2870,7 +2870,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UserDefinedOperator_Plus) {
+TEST_P(SyntaxTreeTest, OverloadedOperator_Plus) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2943,7 +2943,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UserDefinedOperator_Less) {
+TEST_P(SyntaxTreeTest, OverloadedOperator_Less) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -3018,7 +3018,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UserDefinedOperator_Shift) {
+TEST_P(SyntaxTreeTest, OverloadedOperator_LeftShift) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -3092,7 +3092,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UserDefinedOperator_Comma) {
+TEST_P(SyntaxTreeTest, Overloaded

[PATCH] D85819: [SyntaxTree] Split tests

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2805
 
-TEST_P(SyntaxTreeTest, UserDefinedBinaryOperator) {
+TEST_P(SyntaxTreeTest, UserDefinedOperator_Assignment) {
   if (!GetParam().isCXX()) {

gribozavr2 wrote:
> UserDefinedOperator => OverloadedOperator?
> 
> "user-defined" seems to suggest that the operator was previously not a thing 
> in C++.
Actually it is a very good point! Thanks!



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:3393
 
-TEST_P(SyntaxTreeTest, UserDefinedUnaryPostfixOperator) {
+TEST_P(SyntaxTreeTest, UserDefinedOperator_PostfixIncr) {
   if (!GetParam().isCXX()) {

gribozavr2 wrote:
> PostfixIncrement
> 
> Also, group it right after prefix increment?
I'm grouping together Prefix operators. But you're right it makes sense to put 
them close to each other. I've put PrefixIncrement as the last Prefix operator 
to achieve that 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85819

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


[PATCH] D84844: [OpenMP] Ensure testing for versions 4.5 and default - Part 1

2020-08-13 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Time for check-clang has increased from ~51 sec to ~107 sec after this patch.
Putting it here before committing/closing the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84844

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


[clang] eaa341f - [OpenMP] Ensure testing for versions 4.5 and default - Part 1

2020-08-13 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2020-08-13T07:37:10Z
New Revision: eaa341fbea961894759355256d25d785509002ef

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

LOG: [OpenMP] Ensure testing for versions 4.5 and default - Part 1

Many OpenMP Clang tests do not RUN for version 4.5 and the default
version. This first patch in the series only handles test cases
which do not require any modifications in the CHECK lines after
adding RUN lines for default version.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/test/OpenMP/cancel_ast_print.cpp
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/cancel_codegen_cleanup.cpp
clang/test/OpenMP/cancel_if_messages.cpp
clang/test/OpenMP/capturing_in_templates.cpp
clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_if_messages.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
clang/test/OpenMP/parallel_default_messages.cpp
clang/test/OpenMP/parallel_for_if_messages.cpp
clang/test/OpenMP/parallel_if_codegen.cpp
clang/test/OpenMP/parallel_if_messages.cpp
clang/test/OpenMP/parallel_master_if_messages.cpp
clang/test/OpenMP/parallel_sections_if_messages.cpp
clang/test/OpenMP/report_default_DSA.cpp
clang/test/OpenMP/target_ast_print.cpp
clang/test/OpenMP/target_enter_data_ast_print.cpp
clang/test/OpenMP/target_enter_data_if_messages.cpp
clang/test/OpenMP/target_exit_data_ast_print.cpp
clang/test/OpenMP/target_exit_data_if_messages.cpp
clang/test/OpenMP/target_if_messages.cpp
clang/test/OpenMP/target_parallel_codegen.cpp
clang/test/OpenMP/target_parallel_for_codegen.cpp
clang/test/OpenMP/target_parallel_if_messages.cpp
clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
clang/test/OpenMP/target_teams_distribute_codegen.cpp
clang/test/OpenMP/target_teams_distribute_if_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp
clang/test/OpenMP/target_teams_if_messages.cpp
clang/test/OpenMP/target_teams_num_teams_codegen.cpp
clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
clang/test/OpenMP/target_update_if_messages.cpp
clang/test/OpenMP/task_if_codegen.cpp
clang/test/OpenMP/task_if_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/cancel_ast_print.cpp 
b/clang/test/OpenMP/cancel_ast_print.cpp
index b376d4ec2807..f5173ed4ca51 100644
--- a/clang/test/OpenMP/cancel_ast_print.cpp
+++ b/clang/test/OpenMP/cancel_ast_print.cpp
@@ -5,6 +5,15 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | 
FileCheck %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 
-emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch 
%t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+
 // expected-no-diagnostics
 
 #ifndef HEADER

diff  --git a/clang/test/OpenMP/cancel_codegen.cpp 
b/clang/test/OpenMP/cancel_codegen.cpp
index 0942c7cf4236..80e2e294a60c 100644
--- a/clang/test/OpenMP/cancel_codegen.cpp
+++ b/clang/test/OpenMP/cancel_codegen.cpp
@@ -10,6 +10,20 @@
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple 
x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch 
%t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | 
FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin13.4.0 
-emit-llvm -o - %s | FileCheck %s --check-pr

[PATCH] D84844: [OpenMP] Ensure testing for versions 4.5 and default - Part 1

2020-08-13 Thread Saiyedul Islam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeaa341fbea96: [OpenMP] Ensure testing for versions 4.5 and 
default - Part 1 (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84844

Files:
  clang/test/OpenMP/cancel_ast_print.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancel_codegen_cleanup.cpp
  clang/test/OpenMP/cancel_if_messages.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_if_messages.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_if_messages.cpp
  clang/test/OpenMP/parallel_master_if_messages.cpp
  clang/test/OpenMP/parallel_sections_if_messages.cpp
  clang/test/OpenMP/report_default_DSA.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_enter_data_ast_print.cpp
  clang/test/OpenMP/target_enter_data_if_messages.cpp
  clang/test/OpenMP/target_exit_data_ast_print.cpp
  clang/test/OpenMP/target_exit_data_if_messages.cpp
  clang/test/OpenMP/target_if_messages.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_if_messages.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_if_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp
  clang/test/OpenMP/target_teams_if_messages.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/target_update_if_messages.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  clang/test/OpenMP/task_if_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp

Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
@@ -6,6 +6,16 @@
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-ibm-linux-gnu -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-ibm-linux-gnu -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
Index: clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
+++ 

[clang] c286d6f - [Parser] Suppress -Wempty-translation-unit if this is a header file

2020-08-13 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-08-13T09:43:27+02:00
New Revision: c286d6fdeeb2b103777d3ae8c9de84937cb51efe

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

LOG: [Parser] Suppress -Wempty-translation-unit if this is a header file

This is motivated by tooling (clangd, libclang etc) - headers without
declarations are legitimate even if they're not valid TUs.

The other use -x c-header cases (PCH/modules) are nonstandard anyway and this
warning doesn't seem necessary there either.

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

Added: 


Modified: 
clang/lib/Parse/Parser.cpp
clang/test/Parser/empty-translation-unit.c

Removed: 




diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 45cf855cf8c9..5e485eda831c 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -552,9 +552,10 @@ bool Parser::ParseFirstTopLevelDecl(DeclGroupPtrTy 
&Result) {
   // declaration. C++ doesn't have this restriction. We also don't want to
   // complain if we have a precompiled header, although technically if the PCH
   // is empty we should still emit the (pedantic) diagnostic.
+  // If the main file is a header, we're only pretending it's a TU; don't warn.
   bool NoTopLevelDecls = ParseTopLevelDecl(Result, true);
   if (NoTopLevelDecls && !Actions.getASTContext().getExternalSource() &&
-  !getLangOpts().CPlusPlus)
+  !getLangOpts().CPlusPlus && !getLangOpts().IsHeaderFile)
 Diag(diag::ext_empty_translation_unit);
 
   return NoTopLevelDecls;

diff  --git a/clang/test/Parser/empty-translation-unit.c 
b/clang/test/Parser/empty-translation-unit.c
index 04e57f69ce87..991d98eb52fa 100644
--- a/clang/test/Parser/empty-translation-unit.c
+++ b/clang/test/Parser/empty-translation-unit.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -W -verify %s
+// RUN: %clang_cc1 -fsyntax-only -x c-header -std=c99 -pedantic-errors -W %s
 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++03 -pedantic-errors -W %s
 
 #include "completely-empty-header-file.h"
@@ -6,5 +7,5 @@
 
 #define A_MACRO_IS_NOT_GOOD_ENOUGH 1
 
-// In C we should get this warning, but in C++ we shouldn't.
+// In C we should get this warning, but in C++ (or a header) we shouldn't.
 // expected-warning{{ISO C requires a translation unit to contain at least one 
declaration}}



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


[PATCH] D85789: [Parser] Suppress -Wempty-translation-unit if this is a header file

2020-08-13 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc286d6fdeeb2: [Parser] Suppress -Wempty-translation-unit if 
this is a header file (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85789

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/empty-translation-unit.c


Index: clang/test/Parser/empty-translation-unit.c
===
--- clang/test/Parser/empty-translation-unit.c
+++ clang/test/Parser/empty-translation-unit.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -W -verify %s
+// RUN: %clang_cc1 -fsyntax-only -x c-header -std=c99 -pedantic-errors -W %s
 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++03 -pedantic-errors -W %s
 
 #include "completely-empty-header-file.h"
@@ -6,5 +7,5 @@
 
 #define A_MACRO_IS_NOT_GOOD_ENOUGH 1
 
-// In C we should get this warning, but in C++ we shouldn't.
+// In C we should get this warning, but in C++ (or a header) we shouldn't.
 // expected-warning{{ISO C requires a translation unit to contain at least one 
declaration}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -552,9 +552,10 @@
   // declaration. C++ doesn't have this restriction. We also don't want to
   // complain if we have a precompiled header, although technically if the PCH
   // is empty we should still emit the (pedantic) diagnostic.
+  // If the main file is a header, we're only pretending it's a TU; don't warn.
   bool NoTopLevelDecls = ParseTopLevelDecl(Result, true);
   if (NoTopLevelDecls && !Actions.getASTContext().getExternalSource() &&
-  !getLangOpts().CPlusPlus)
+  !getLangOpts().CPlusPlus && !getLangOpts().IsHeaderFile)
 Diag(diag::ext_empty_translation_unit);
 
   return NoTopLevelDecls;


Index: clang/test/Parser/empty-translation-unit.c
===
--- clang/test/Parser/empty-translation-unit.c
+++ clang/test/Parser/empty-translation-unit.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -W -verify %s
+// RUN: %clang_cc1 -fsyntax-only -x c-header -std=c99 -pedantic-errors -W %s
 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++03 -pedantic-errors -W %s
 
 #include "completely-empty-header-file.h"
@@ -6,5 +7,5 @@
 
 #define A_MACRO_IS_NOT_GOOD_ENOUGH 1
 
-// In C we should get this warning, but in C++ we shouldn't.
+// In C we should get this warning, but in C++ (or a header) we shouldn't.
 // expected-warning{{ISO C requires a translation unit to contain at least one declaration}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -552,9 +552,10 @@
   // declaration. C++ doesn't have this restriction. We also don't want to
   // complain if we have a precompiled header, although technically if the PCH
   // is empty we should still emit the (pedantic) diagnostic.
+  // If the main file is a header, we're only pretending it's a TU; don't warn.
   bool NoTopLevelDecls = ParseTopLevelDecl(Result, true);
   if (NoTopLevelDecls && !Actions.getASTContext().getExternalSource() &&
-  !getLangOpts().CPlusPlus)
+  !getLangOpts().CPlusPlus && !getLangOpts().IsHeaderFile)
 Diag(diag::ext_empty_translation_unit);
 
   return NoTopLevelDecls;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85819: [SyntaxTree] Split tests

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1546-1548
+unsigned operator "" _r(const char*);
+template 
+unsigned operator "" _t();

eduucaldas wrote:
> Same setup for `FloatUserDefinedLiteral`. I think it is justified with the 
> Annotations we can constraint the dump just to the expressions being tested
Taking account the Annotations change. Duplicating two lines of code between 
tests should be ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85819

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


[PATCH] D85819: [SyntaxTree] Split tests

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

We'll split this file in a future change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85819

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


[PATCH] D84029: [clang][Driver] Default to /usr/bin/ld on Solaris

2020-08-13 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Ping^2?  It's been two weeks now and with having to specify 
`-DCLANG_DEFAULT_LINKER=/usr/bin/ld ` as a workaround, many tests `FAIL` on 
Solaris.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84029

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


[PATCH] D85819: [SyntaxTree] Split tests

2020-08-13 Thread Eduardo Caldas 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 rGd1211fd1ec03: [SyntaxTree] Split tests for expressions 
(authored by eduucaldas).

Changed prior to commit:
  https://reviews.llvm.org/D85819?vs=285273&id=285278#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85819

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -632,26 +632,48 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedId) {
+TEST_P(SyntaxTreeTest, UnqualifiedIdIdentifier) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test(int a) {
+  a;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-a
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdOperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 struct X {
-  // TODO: Expose `id-expression` from `Declarator`
   friend X operator+(const X&, const X&);
-  operator int();
 };
-template
-void f(T&);
 void test(X x) {
-  x;  // identifier
-  operator+(x, x);// operator-function-id
-  f(x);// template-id
-  // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();   // conversion-funtion-id
-  x.~X(); // ~type-name
+  operator+(x, x);
 }
 )cpp",
   R"txt(
@@ -682,35 +704,8 @@
 | |   |   |   `-&
 | |   |   `-)
 | |   `-;
-| |-SimpleDeclaration
-| | |-SimpleDeclarator
-| | | |-operator
-| | | |-int
-| | | `-ParametersAndQualifiers
-| | |   |-(
-| | |   `-)
-| | `-;
 | |-}
 | `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-typename
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-void
-|   |-SimpleDeclarator
-|   | |-f
-|   | `-ParametersAndQualifiers
-|   |   |-(
-|   |   |-SimpleDeclaration
-|   |   | |-T
-|   |   | `-SimpleDeclarator
-|   |   |   `-&
-|   |   `-)
-|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -725,11 +720,6 @@
   `-CompoundStatement
 |-{
 |-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-x
-| `-;
-|-ExpressionStatement
 | |-UnknownExpression
 | | |-IdExpression
 | | | `-UnqualifiedId
@@ -745,20 +735,53 @@
 | | |   `-x
 | | `-)
 | `-;
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-f
-| | |   |-<
-| | |   |-X
-| | |   `->
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdConversionFunctionId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct X {
+  operator int();
+};
+void test(X x) {
+  // TODO: Expose `id-expression` from `MemberExpr`
+  x.operator int();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-SimpleDeclaration
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-int
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+|-{
 |-ExpressionStatement
 | |-UnknownExpression
 | | |-UnknownExpression
@@ -771,6 +794,93 @@
 | | |-(
 | | `-)
 | `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdLiteralOperatorId) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+unsigned operator "" _w(char);
+void test() {
+  operator "" _w('1');
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_w
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | `-char
+| |   `-)
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   |-operator
+| | |   |-""
+| | |   `-_w
+| | |-(
+| | |-CharacterLiteralExpression
+| | | `-'1'
+| | `-)

[clang] d1211fd - [SyntaxTree] Split tests for expressions

2020-08-13 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-13T08:18:14Z
New Revision: d1211fd1ec037f88c2cc855bc850200948c76940

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

LOG: [SyntaxTree] Split tests for expressions

We do that because:
* Big tests generated big tree dumps that could hardly serve as documentation.
* In most cases the tests didn't share setup, thus there was not much addition 
in lines of code.

We split tests for:
* `UserDefinedLiteral`
* `NestedBinaryOperator`
* `UserDefinedBinaryOperator`
* `UserDefinedPrefixOperator`
* `QualifiedId`

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index a5d1a4bfcacf..834496ce0082 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -632,26 +632,48 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedId) {
+TEST_P(SyntaxTreeTest, UnqualifiedIdIdentifier) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test(int a) {
+  a;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-a
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdOperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 struct X {
-  // TODO: Expose `id-expression` from `Declarator`
   friend X operator+(const X&, const X&);
-  operator int();
 };
-template
-void f(T&);
 void test(X x) {
-  x;  // identifier
-  operator+(x, x);// operator-function-id
-  f(x);// template-id
-  // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();   // conversion-funtion-id
-  x.~X(); // ~type-name
+  operator+(x, x);
 }
 )cpp",
   R"txt(
@@ -682,35 +704,8 @@ void test(X x) {
 | |   |   |   `-&
 | |   |   `-)
 | |   `-;
-| |-SimpleDeclaration
-| | |-SimpleDeclarator
-| | | |-operator
-| | | |-int
-| | | `-ParametersAndQualifiers
-| | |   |-(
-| | |   `-)
-| | `-;
 | |-}
 | `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-typename
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-void
-|   |-SimpleDeclarator
-|   | |-f
-|   | `-ParametersAndQualifiers
-|   |   |-(
-|   |   |-SimpleDeclaration
-|   |   | |-T
-|   |   | `-SimpleDeclarator
-|   |   |   `-&
-|   |   `-)
-|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -725,11 +720,6 @@ void test(X x) {
   `-CompoundStatement
 |-{
 |-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-x
-| `-;
-|-ExpressionStatement
 | |-UnknownExpression
 | | |-IdExpression
 | | | `-UnqualifiedId
@@ -745,20 +735,53 @@ void test(X x) {
 | | |   `-x
 | | `-)
 | `-;
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-f
-| | |   |-<
-| | |   |-X
-| | |   `->
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdConversionFunctionId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct X {
+  operator int();
+};
+void test(X x) {
+  // TODO: Expose `id-expression` from `MemberExpr`
+  x.operator int();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-SimpleDeclaration
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-int
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+|-{
 |-ExpressionStatement
 | |-UnknownExpression
 | | |-UnknownExpression
@@ -771,6 +794,93 @@ void test(X x) {
 | | |-(
 | | `-)
 | `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdLiteralOperatorId) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+unsigned operator "" _w(char);
+void test() {
+  operator "" _w('1');
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+

[clang] 833c2b6 - [SyntaxTree] Rename tests following `TestSuite_TestCase` + nits

2020-08-13 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-13T08:18:14Z
New Revision: 833c2b6be26bcdf90aac2f6de6e345bcd858149e

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

LOG: [SyntaxTree] Rename tests following `TestSuite_TestCase` + nits

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 834496ce0082..e266ef3f5870 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -632,7 +632,7 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdIdentifier) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test(int a) {
@@ -663,7 +663,7 @@ void test(int a) {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdOperatorFunctionId) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -739,7 +739,7 @@ void test(X x) {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdConversionFunctionId) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -798,7 +798,7 @@ void test(X x) {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdLiteralOperatorId) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_LiteralOperatorId) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
@@ -848,7 +848,7 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdDestructor) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_Destructor) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -897,7 +897,7 @@ void test(X x) {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdDecltypeDestructor) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_DecltypeDestructor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
@@ -949,7 +949,7 @@ void test(X x) {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UnqualifiedIdTemplateId) {
+TEST_P(SyntaxTreeTest, UnqualifiedId_TemplateId) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -1002,7 +1002,7 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdWithNamespace) {
+TEST_P(SyntaxTreeTest, QualifiedId_NamespaceSpecifier) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -1065,7 +1065,7 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdWithTemplateSpecifier) {
+TEST_P(SyntaxTreeTest, QualifiedId_TemplateSpecifier) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -1145,7 +1145,73 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdWithOptionalTemplateKw) {
+TEST_P(SyntaxTreeTest, QualifiedId_DecltypeSpecifier) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct S {
+  static void f(){}
+};
+void test(S s) {
+  decltype(s)::f();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-S
+| |-{
+| |-SimpleDeclaration
+| | |-static
+| | |-void
+| | |-SimpleDeclarator
+| | | |-f
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-CompoundStatement
+| |   |-{
+| |   `-}
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-S
+  |   | `-SimpleDeclarator
+  |   |   `-s
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-DecltypeNameSpecifier
+| | | | | |-decltype
+| | | | | |-(
+| | | | | |-IdExpression
+| | | | | | `-UnqualifiedId
+| | | | | |   `-s
+| | | | | `-)
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, QualifiedId_OptionalTemplateKw) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -1228,18 +1294,18 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdComplex) {
+TEST_P(SyntaxTreeTest, QualifiedId_Complex) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 namespace n {
-template
-struct ST {
-  template
-  static U f();
-};
+  template
+  struct ST {
+template
+static U f();
+  };
 }
 void test() {
   ::n::template ST::template f();
@@ -1318,7 +1384,7 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdWithDependentType) {
+TEST_P(SyntaxTreeTest, QualifiedId_DependentType) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -1409,72 +1475,6 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, QualifiedIdDecltype) {
-  if (!GetParam().isCXX11OrLater()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-struct S {
-  

[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-13 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 285282.
simoll added a comment.

- Fixed type printing & added type printing test.
- Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-print-vector-size-bool.c
  clang/test/CodeGen/debug-info-vector-bool.c
  clang/test/SemaCXX/constexpr-vectors.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int &reference_to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   const TemplateVectorType::type Works2 = {};
-  // expected-error@#1 {{invalid vector element type 'bool'}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool = {};
+  const TemplateVectorType::type BoolWorks = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
   const TemplateVectorType::type NoComplex = {};
Index: clang/test/SemaCXX/constexpr-vectors.cpp
===
--- clang/test/SemaCXX/constexpr-vectors.cpp
+++ clang/test/SemaCXX/constexpr-vectors.cpp
@@ -204,35 +204,35 @@
 
   constexpr auto w = FourCharsVecSize{1, 2, 3, 4} <
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto x = FourCharsVecSize{1, 2, 3, 4} >
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto y = FourCharsVecSize{1, 2, 3, 4} <=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto z = FourCharsVecSize{1, 2, 3, 4} >=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto A = FourCharsVecSize{1, 2, 3, 4} ==
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto B = FourCharsVecSize{1, 2, 3, 4} !=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto C = FourCharsVecSize{1, 2, 3, 4} < 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto D = FourCharsVecSize{1, 2, 3, 4} > 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto E = FourCharsVecSize{1, 2, 3, 4} <= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto F = FourCharsVecSize{1, 2, 3, 4} >= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto G = FourCharsVecSize{1, 2, 3, 4} == 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto H = FourCharsVecSize{1, 2, 3, 4} != 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto I = FourCharsVecSize{1, 2, 3, 4} &
  FourCharsVecSize{4, 3, 2, 1};
@@ -252,15 +252,15 @@
 
   constexpr auto O = FourCharsVecSize{5, 0, 6, 0} &&
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto P = FourCharsVecSize{5, 0, 6, 0} ||
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto Q = FourCharsVecSize{5, 0, 6, 0} && 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto R = FourCharsVecSize{5, 0, 6, 0} || 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcas

[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-08-13 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Aside  from infrastructural questions which I am not qualified ( nor 
particularly knowledgeable :3 ) to address, this looks good to me.




Comment at: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp:77
 
+  unsigned ArgNum = 999;
+

999 seems a bit arbitrary here, consider using 
std::numeric_limits::max(), or llvm::Optional.


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

https://reviews.llvm.org/D77229

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


[PATCH] D85787: [InstCombine] Aggregate reconstruction simplification (PR47060)

2020-08-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 285283.
lebedev.ri added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix (overstepping) clang test being affected by this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85787

Files:
  clang/test/CodeGenCXX/nrvo.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
  llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll

Index: llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
===
--- llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
+++ llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
@@ -17,21 +17,14 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]
 ; CHECK:   left:
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0
-; CHECK-NEXT:[[I2:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT]], 1
 ; CHECK-NEXT:call void @foo()
 ; CHECK-NEXT:br label [[END:%.*]]
 ; CHECK:   right:
-; CHECK-NEXT:[[I3:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 0
-; CHECK-NEXT:[[I4:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT]], 1
 ; CHECK-NEXT:call void @bar()
 ; CHECK-NEXT:br label [[END]]
 ; CHECK:   end:
-; CHECK-NEXT:[[I5:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I3]], [[RIGHT]] ]
-; CHECK-NEXT:[[I6:%.*]] = phi i32 [ [[I2]], [[LEFT]] ], [ [[I4]], [[RIGHT]] ]
+; CHECK-NEXT:[[I8:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]
 ; CHECK-NEXT:call void @baz()
-; CHECK-NEXT:[[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0
-; CHECK-NEXT:[[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1
 ; CHECK-NEXT:ret { i32, i32 } [[I8]]
 ;
 entry:
@@ -278,24 +271,17 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:br i1 [[C0:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]
 ; CHECK:   left:
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0
-; CHECK-NEXT:[[I2:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT]], 1
 ; CHECK-NEXT:call void @foo()
 ; CHECK-NEXT:br label [[MIDDLE:%.*]]
 ; CHECK:   right:
-; CHECK-NEXT:[[I3:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 0
-; CHECK-NEXT:[[I4:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT]], 1
 ; CHECK-NEXT:call void @bar()
 ; CHECK-NEXT:br label [[MIDDLE]]
 ; CHECK:   middle:
-; CHECK-NEXT:[[I5:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I3]], [[RIGHT]] ], [ [[I5]], [[MIDDLE]] ]
-; CHECK-NEXT:[[I6:%.*]] = phi i32 [ [[I2]], [[LEFT]] ], [ [[I4]], [[RIGHT]] ], [ [[I6]], [[MIDDLE]] ]
+; CHECK-NEXT:[[I8:%.*]] = phi { i32, i32 } [ [[I8]], [[MIDDLE]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]
 ; CHECK-NEXT:call void @baz()
 ; CHECK-NEXT:[[C1:%.*]] = call i1 @geni1()
 ; CHECK-NEXT:br i1 [[C1]], label [[END:%.*]], label [[MIDDLE]]
 ; CHECK:   end:
-; CHECK-NEXT:[[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0
-; CHECK-NEXT:[[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1
 ; CHECK-NEXT:ret { i32, i32 } [[I8]]
 ;
 entry:
Index: llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
===
--- llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
+++ llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
@@ -13,11 +13,7 @@
 ; We should just return the source aggregate.
 define { i32, i32 } @test0({ i32, i32 } %srcagg) {
 ; CHECK-LABEL: @test0(
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[SRCAGG:%.*]], 0
-; CHECK-NEXT:[[I1:%.*]] = extractvalue { i32, i32 } [[SRCAGG]], 1
-; CHECK-NEXT:[[I2:%.*]] = insertvalue { i32, i32 } undef, i32 [[I0]], 0
-; CHECK-NEXT:[[I3:%.*]] = insertvalue { i32, i32 } [[I2]], i32 [[I1]], 1
-; CHECK-NEXT:ret { i32, i32 } [[I3]]
+; CHECK-NEXT:ret { i32, i32 } [[SRCAGG:%.*]]
 ;
   %i0 = extractvalue { i32, i32 } %srcagg, 0
   %i1 = extractvalue { i32, i32 } %srcagg, 1
@@ -29,11 +25,7 @@
 ; Arrays are still aggregates
 define [2 x i32] @test1([2 x i32] %srcagg) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[I0:%.*]] = extractvalue [2 x i32] [[SRCAGG:%.*]], 0
-; CHECK-NEXT:[[I1:%.*]] = extractvalue [2 x i32] [[SRCAGG]], 1
-; CHECK-NEXT:[[I2:%.*]] = insertvalue [2 x i32] undef, i32 [[I0]], 0
-; CHECK-NEXT:[[I3:%.*]] = insertvalue [2 x i32] [[I2]], i32 [[I1]], 1
-; CHECK-NEXT:ret [2 x i32] [[I3]]
+; CHECK-NEXT:ret [2 x i32] [[SRCAGG:%.*]]
 ;
   %i0 = extractvalue [2 x i32] %srcagg, 0
   %i1 = extractvalue [2 x i32] %srcagg,

[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

aaron.ballman wrote:
> I suspect there are more checks that should be added here. For instance, much 
> of `modernize-` is purely stylistic so it's easy to view as being false 
> positives (like `modernize-use-trailing-return-types` or whatever it's 
> called).
I don't think that's what this list is for. This seems to be purely for checks 
that don't run properly or crash inside clangd. 
`modernize-use-trailing-return-types` is a very noisy check but that's how it 
is when ran as normal clang-tidy. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83224

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


[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

2020-08-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: adamcz, kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This lets basic AST-consuming actions be defined outside clangdserver.
(it essentially exposes TUScheduler::runWithAST).

Two use cases for now:

- replace ClangdServer::dumpAST, which doesn't really belong in the public 
interface (a followup patch will do this)
- allow embedders to add/experiment with extra features (e.g. I know some who 
want to try crazy AST+ML code completion...)

Maybe in the future we should use this sort of mechanism to make ClangdServer
less of a monolith, but that's not in scope for now.
This would probably require a richer and more carefully-thought-out API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85883

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -60,6 +60,9 @@
 llvm::Expected>
 runSwitchHeaderSource(ClangdServer &Server, PathRef File);
 
+llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
+llvm::function_ref);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -154,5 +154,20 @@
   return std::move(*Result);
 }
 
+llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
+llvm::function_ref Action) {
+  llvm::Error Result = llvm::Error::success();
+  Notification Done;
+  Server.customAction(File, "Custom", [&](llvm::Expected AST) {
+if (!AST)
+  Result = AST.takeError();
+else
+  Action(*AST);
+Done.notify();
+  });
+  Done.wait();
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -15,6 +15,7 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "URI.h"
 #include "support/Path.h"
 #include "support/Threading.h"
@@ -28,6 +29,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -1141,6 +1143,21 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST(ClangdServerTest, CustomAction) {
+  OverlayCDB CDB(/*Base=*/nullptr);
+  MockFS FS;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
+
+  Server.addDocument(testPath("foo.cc"), "void x();");
+  Decl::Kind XKind = Decl::TranslationUnit;
+  EXPECT_THAT_ERROR(runCustomAction(Server, testPath("foo.cc"),
+[&](ParsedAST *AST) {
+  XKind = findDecl(*AST, "x").getKind();
+}),
+llvm::Succeeded());
+  EXPECT_EQ(XKind, Decl::Function);
+}
+
 // Tests fails when built with asan due to stack overflow. So skip running the
 // test as a workaround.
 #if !defined(__has_feature) || !__has_feature(address_sanitizer)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -317,6 +317,13 @@
   void semanticHighlights(PathRef File,
   Callback>);
 
+  /// Runs an arbitrary action that has access to the AST of the specified file.
+  /// The action will execute on one of ClangdServer's internal threads.
+  /// The AST is only valid for the duration of the callback.
+  /// As with other actions, the file must have been opened.
+  void customAction(PathRef File, llvm::StringRef Name,
+Callback Action);
+
   /// Returns estimated memory usage and other statistics for each of the
   /// currently open files.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -754,6 +754,17 @@
 

[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-13 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 285285.
c-rhodes marked an inline comment as not done.
c-rhodes added a comment.

Address @rsandifo-arm comments.


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

https://reviews.llvm.org/D85736

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// expected-no-diagnostics
+
+#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+
+typedef __SVInt8_t svint8_t;
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+
+template struct S { T var; };
+
+S s;
+
+svint8_t to_svint8_t(fixed_int8_t x) { return x; }
+fixed_int8_t from_svint8_t(svint8_t x) { return x; }
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -102,8 +102,11 @@
   svint8_t ss8;
 
   void *sel __attribute__((unused));
-  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
-  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+  sel = c ? ss8 : fs8; // expected-error {{cannot convert between fixed-length and sizeless vector}}
+  sel = c ? fs8 : ss8; // expected-error {{cannot convert between fixed-length and sizeless vector}}
+
+  sel = fs8 + ss8; // expected-error {{cannot convert between fixed-length and sizeless vector}}
+  sel = ss8 + fs8; // expected-error {{cannot convert between fixed-length and sizeless vector}}
 }
 
 // --//
@@ -192,14 +195,18 @@
 TEST_CAST(bool)
 
 // Test the implicit conversion only applies to valid types
-fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (aka '__SVInt8_t')}}
-fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (aka '__SVBool_t')}}
+fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (vector of {{[0-9]+}} 'signed char' values)}}
+fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
+
+// Test conversion between predicate and uint8 is invalid, both have the same
+// memory representation.
+fixed_bool_t to_fixed_bool_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
 // Test the implicit conversion only applies to fixed-length types
 typedef signed int vSInt32 __attribute__((__vector_size__(16)));
-svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error {{returning 'vSInt32' (vector of 4 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
+svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error-re {{returning 'vSInt32' (vector of {{[0-9]+}} 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
 
-vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'vSInt32' (vector of 4 'int' values)}}
+vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible 

[PATCH] D84248: [analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions

2020-08-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 285289.
martong marked 2 inline comments as done.
martong added a comment.

- Handle minimum buffer sizes
- Fix copy paste error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84248

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -149,6 +149,7 @@
   // bugpath-note{{TRUE}} \
   // bugpath-note{{'s' is <= 2}}
 }
+
 int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
 void test_buf_size_concrete_with_multiplication() {
   short buf[3]; // bugpath-note{{'buf' initialized here}}
@@ -173,3 +174,13 @@
   // bugpath-warning{{TRUE}} \
   // bugpath-note{{TRUE}}
 }
+
+// The minimum buffer size for this function is set to 10.
+int __buf_size_arg_constraint_concrete(const void *);
+void test_min_buf_size() {
+  char buf[9];// bugpath-note{{'buf' initialized here}}
+  __buf_size_arg_constraint_concrete(buf); // \
+  // report-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -95,6 +95,19 @@
 // CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
 // CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
 // CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
+// CHECK: Loaded summary for: int utime(const char *filename, struct utimbuf *buf)
+// CHECK: Loaded summary for: int futimens(int fd, const struct timespec times[2])
+// CHECK: Loaded summary for: int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags)
+// CHECK: Loaded summary for: int utimes(const char *filename, const struct timeval times[2])
+// CHECK: Loaded summary for: int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
+// CHECK: Loaded summary for: struct tm *localtime(const time_t *tp)
+// CHECK: Loaded summary for: struct tm *localtime_r(const time_t *restrict timer, struct tm *restrict result)
+// CHECK: Loaded summary for: char *asctime_r(const struct tm *restrict tm, char *restrict buf)
+// CHECK: Loaded summary for: char *ctime_r(const time_t *timep, char *buf)
+// CHECK: Loaded summary for: struct tm *gmtime_r(const time_t *restrict timer, struct tm *restrict result)
+// CHECK: Loaded summary for: struct tm *gmtime(const time_t *tp)
+// CHECK: Loaded summary for: int clock_gettime(clockid_t clock_id, struct timespec *tp)
+// CHECK: Loaded summary for: int getitimer(int which, struct itimerval *curr_value)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -226,6 +239,25 @@
 ssize_t send(int sockfd, const void *buf, size_t len, int flags);
 int socketpair(int domain, int type, int protocol, int sv[2]);
 int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags);
+struct utimbuf;
+struct timespec { int x; };
+struct timeval { int x; };
+int utime(const char *filename, struct utimbuf *buf);
+int futimens(int fd, const struct timespec times[2]);
+int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags);
+int utimes(const char *filename, const struct timeval times[2]);
+int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
+typedef unsigned long time_t;
+struct tm *localtime(const time_t *tp);
+struct tm *localtime_r(const time_t *restrict timer, struct tm *restrict result);
+char *asctime_r(const struct tm *restrict tm, char *restrict buf);
+char *ctime_r(const time_t *timep, char *buf);
+struct tm *gmtime_r(const time_t *restrict timer, struct tm *restrict result);
+struct tm *gmtime(const time_t *tp);
+typedef unsigned long clockid_t;
+int clock_gettime(clockid_t clock_id, struct timespec *tp);
+struct itimerval;
+int getitimer(int which, struct itimerval *curr_value);
 
 // Must have at least one call expression to initialize the summary map.
 int bar(void);
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
=

[PATCH] D84248: [analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions

2020-08-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2040
+
+if (ConstStructTimevalPtrTy && StructTimespecPtrTy)
+  // int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);

balazske wrote:
> Should be `ConstStructTimespecPtrTy`.
Thanks!



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2092
+  .ArgConstraint(NotNull(ArgNo(0)))
+  .ArgConstraint(NotNull(ArgNo(1;
+

balazske wrote:
> Is it possible to check for the size of the passed buffer? The man page says 
> that `buf` should have room for 26 bytes (for `ctime_r` too).
Yes, absolutely, this is a very good observation. I extended the BufferSize 
constraint to handle concrete values as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84248

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


[PATCH] D85728: [Analyzer] Support for the new variadic isa<> and isa_and_not_null<> in CastValueChecker

2020-08-13 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:289
+  for (QualType CastToTy: CastToTyVec) {
+if (CastFromTy->isPointerType())
+  CastToTy = C.getASTContext().getPointerType(CastToTy);

NoQ wrote:
> Hmm, is this phabricator's way of displaying tabs?
I believe it is not displaying tabs, but rather just indicating that the 
current line changed in a way that //only// the indentation has changed... 
instead of marking the old side of the diff red. The HTML element is 
`span.depth-in`. A `span.depth-out` is red, and the arrow points the other way.

But I agree this is a new thing since the version update.


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

https://reviews.llvm.org/D85728

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


[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-13 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes marked 4 inline comments as done.
c-rhodes added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:1941
+// Adjust the alignment for fixed-length SVE predicates.
+if (VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
+  Align = 16;

rsandifo-arm wrote:
> The alignment of the SVE data vectors should be 128 too (see the alignof 
> stuff in the ACLE doc).  FWIW, there were two reasons for defining it like 
> that:
>   - the fixed-length types map to the same ABI machine type as the 
> variable-length types
>   - the length isn't required to be a power of 2: an implementation that 
> supports fixed-length 384-bit vectors could define `__ARM_FEATURE_SVE_BITS` 
> to 384.
> 
> 
> 
> The alignment of the SVE data vectors should be 128 too (see the alignof 
> stuff in the ACLE doc).

Ah, good point. This would've bitten us when when we come to supporting 
non-power-of-2 vector lengths.



Comment at: clang/lib/AST/Type.cpp:2338
+  case BuiltinType::SveUint32:
+return Ctx.UnsignedIntTy;
+  case BuiltinType::SveInt64:

rsandifo-arm wrote:
> This is just a note, not sure what can be done about it, but:
> 
> The element types are defined in terms of the stdint.h types.  One snag is 
> that ILP32 newlib defines `int32_t` to be UnsignedLongTy instead of 
> UnsignedIntTy, and defines `uint64_t` to UnsignedLongLongTy.
> 
> In GCC we got away with this because GCC already has hard-coded knowledge 
> about the target C library's choices.  I don't think that information is 
> available here though.
> 
> Like I say, there's nothing that necessarily needs to be “fixed”/dealt-with 
> now, just thought it was worth mentioning.
Thanks for the heads up! I'm not familiar with ILP32 so that's good to know. So 
if `-mabi=ilp32` is passed then I guess we should handle that here. I'll make a 
note of this and address it in a later patch.



Comment at: clang/lib/Sema/SemaExpr.cpp:8934
+  ASTContext &Context) {
+  auto IsValidCast = [](QualType LHSType, QualType RHSType,
+ASTContext &Context) {

rsandifo-arm wrote:
> I guess this is personal preference, but it seems more natural to use `[&]` 
> and not pass the context.  Maybe different names from LHSType and RHSType 
> would be better for the nested function, since it's called with both orders.
> I guess this is personal preference, but it seems more natural to use [&] and 
> not pass the context.

Agreed, that's nicer.

> Maybe different names from LHSType and RHSType would be better for the nested 
> function, since it's called with both orders.

I've renamed them to first/second.




Comment at: clang/lib/Sema/SemaExpr.cpp:8942
+VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector &&
+isVector(RHSType, LHSType->getFixedLengthSveEltType(Context)))
+  return true;

rsandifo-arm wrote:
> Is the isVector just being defensive?  I'd have expected it to be redundant, 
> since we shouldn't create SveFixedLengthPredicateVectors with invalid element 
> types.
> Is the isVector just being defensive? I'd have expected it to be redundant, 
> since we shouldn't create SveFixedLengthPredicateVectors with invalid element 
> types.

Yeah although as you say it's not really necessary, fixed.



Comment at: clang/lib/Sema/SemaExpr.cpp:8945
+
+if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector &&
+isVector(RHSType, LHSType->getFixedLengthSveEltType(Context)))

rsandifo-arm wrote:
> It looks like this could still trigger for SveBools.  Maybe it would be 
> better to have:
> 
>   if (BT->getKind() == BuiltinType::SveBool) {
> …
>   } else {
> …
>   }
> 
> instead.  Perhaps it'd also be worth having an assert to show that we've 
> already checked that any builtin type is an SVE type.
I've simplified this somewhat although I'm not sure if it's what you meant. If 
it's a predicate vector kind then it's compatible if the builtin is an SVE 
bool, otherwise it compares the types. Worth noting I've moved this to 
ASTContext also since it's used for the C++ conversions.


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

https://reviews.llvm.org/D85736

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


[PATCH] D84248: [analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions

2020-08-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske accepted this revision.
balazske added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84248

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


[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

2020-08-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

mostly looks good to me, as discussed offline I would rather expose AST within 
a thread, both to keep the API changes to a minimum in the future and possibly 
indicating the "view-ness" of the exposed structs like AST more explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85883

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-13 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-13 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

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


[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 285309.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D81272

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp
  clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-redundant-condition.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp
@@ -0,0 +1,1153 @@
+// RUN: %check_clang_tidy %s misc-redundant-condition %t
+
+extern unsigned peopleInTheBuilding;
+extern unsigned fireFighters;
+
+bool isBurning();
+bool isReallyBurning();
+bool isCollapsing();
+void tryToExtinguish(bool&);
+void tryPutFireOut();
+bool callTheFD();
+void scream();
+
+bool someOtherCondition();
+
+//===--- Basic Positives --===//
+
+void positive_direct() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+}
+  }
+}
+
+void positive_direct_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire && peopleInTheBuilding > 0) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: if ( peopleInTheBuilding > 0) {
+  scream();
+}
+  }
+}
+
+void positive_indirect_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire && peopleInTheBuilding > 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: if ( peopleInTheBuilding > 0) {
+scream();
+  }
+}
+  }
+}
+
+void positive_direct_inner_and_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (peopleInTheBuilding > 0 && onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: if (peopleInTheBuilding > 0 ) {
+  scream();
+}
+  }
+}
+
+void positive_indirect_inner_and_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (peopleInTheBuilding > 0 && onFire) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: if (peopleInTheBuilding > 0 ) {
+scream();
+  }
+}
+  }
+}
+
+void positive_direct_inner_or_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire || isCollapsing()) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect_inner_or_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire || isCollapsing()) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+  }
+  // CHECK-FIXES: {{^\ *$}}
+}
+  }
+}
+
+void positive_direct_inner_or_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (isCollapsing() || onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [misc-redundant-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect_inner_or_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (isCollapsing() || onFire) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [misc-redundant-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+  }
+  // CHECK-FIXES: {{^\ *$}}
+}
+  }
+}
+
+void positive_direct_outer_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire && fireFighters < 10) {
+if (onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant 

[clang-tools-extra] 32626bc - [clangd] Add ClangdServer::customAction() extension point

2020-08-13 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-08-13T12:26:32+02:00
New Revision: 32626bcc0b9b1180db7eebc46c45faff7905bd05

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

LOG: [clangd] Add ClangdServer::customAction() extension point

This lets basic AST-consuming actions be defined outside clangdserver.
(it essentially exposes TUScheduler::runWithAST).

Two use cases for now:
 - replace ClangdServer::dumpAST, which doesn't really belong in the public
   interface (a followup patch will do this)
 - allow embedders to add/experiment with extra features
   (e.g. I know some who want to try crazy AST+ML code completion...)

Maybe in the future we should use this sort of mechanism to make ClangdServer
less of a monolith, but that's not in scope for now.
This would probably require a richer and more carefully-thought-out API.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index ec4855659501..919d59ab09d0 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -754,6 +754,11 @@ void ClangdServer::semanticHighlights(
TUScheduler::InvalidateOnUpdate);
 }
 
+void ClangdServer::customAction(PathRef File, llvm::StringRef Name,
+Callback Action) {
+  WorkScheduler.runWithAST(Name, File, std::move(Action));
+}
+
 llvm::StringMap ClangdServer::fileStats() const {
   return WorkScheduler.fileStats();
 }

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 3529e5050aa3..7aed7d4f3d85 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -317,6 +317,13 @@ class ClangdServer {
   void semanticHighlights(PathRef File,
   Callback>);
 
+  /// Runs an arbitrary action that has access to the AST of the specified 
file.
+  /// The action will execute on one of ClangdServer's internal threads.
+  /// The AST is only valid for the duration of the callback.
+  /// As with other actions, the file must have been opened.
+  void customAction(PathRef File, llvm::StringRef Name,
+Callback Action);
+
   /// Returns estimated memory usage and other statistics for each of the
   /// currently open files.
   /// Overall memory usage of clangd may be significantly more than reported

diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index c21719d58bd6..585fabe60ab7 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -15,6 +15,7 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "URI.h"
 #include "support/Path.h"
 #include "support/Threading.h"
@@ -28,6 +29,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -1141,6 +1143,21 @@ TEST_F(ClangdVFSTest, 
FallbackWhenWaitingForCompileCommand) {
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST(ClangdServerTest, CustomAction) {
+  OverlayCDB CDB(/*Base=*/nullptr);
+  MockFS FS;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
+
+  Server.addDocument(testPath("foo.cc"), "void x();");
+  Decl::Kind XKind = Decl::TranslationUnit;
+  EXPECT_THAT_ERROR(runCustomAction(Server, testPath("foo.cc"),
+[&](InputsAndAST AST) {
+  XKind = findDecl(AST.AST, "x").getKind();
+}),
+llvm::Succeeded());
+  EXPECT_EQ(XKind, Decl::Function);
+}
+
 // Tests fails when built with asan due to stack overflow. So skip running the
 // test as a workaround.
 #if !defined(__has_feature) || !__has_feature(address_sanitizer)

diff  --git a/clang-tools-extra/clangd/unittests/SyncAPI.cpp 
b/clang-tools-extra/clangd/unittests/SyncAPI.cpp
index 36b028bd4d87..c356fb08d5dd 100644
--- a/clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ b/clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -154,5 +154,20 @@ runSwitchHeaderSource(ClangdServer &Server, PathRef File) {
   return std::move(*Result);
 }
 
+llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
+ 

[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

2020-08-13 Thread Sam McCall 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 rG32626bcc0b9b: [clangd] Add ClangdServer::customAction() 
extension point (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D85883?vs=285286&id=285310#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85883

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -60,6 +60,9 @@
 llvm::Expected>
 runSwitchHeaderSource(ClangdServer &Server, PathRef File);
 
+llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
+llvm::function_ref);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -154,5 +154,20 @@
   return std::move(*Result);
 }
 
+llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
+llvm::function_ref Action) {
+  llvm::Error Result = llvm::Error::success();
+  Notification Done;
+  Server.customAction(File, "Custom", [&](llvm::Expected AST) {
+if (!AST)
+  Result = AST.takeError();
+else
+  Action(*AST);
+Done.notify();
+  });
+  Done.wait();
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -15,6 +15,7 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "URI.h"
 #include "support/Path.h"
 #include "support/Threading.h"
@@ -28,6 +29,7 @@
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -1141,6 +1143,21 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST(ClangdServerTest, CustomAction) {
+  OverlayCDB CDB(/*Base=*/nullptr);
+  MockFS FS;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
+
+  Server.addDocument(testPath("foo.cc"), "void x();");
+  Decl::Kind XKind = Decl::TranslationUnit;
+  EXPECT_THAT_ERROR(runCustomAction(Server, testPath("foo.cc"),
+[&](InputsAndAST AST) {
+  XKind = findDecl(AST.AST, "x").getKind();
+}),
+llvm::Succeeded());
+  EXPECT_EQ(XKind, Decl::Function);
+}
+
 // Tests fails when built with asan due to stack overflow. So skip running the
 // test as a workaround.
 #if !defined(__has_feature) || !__has_feature(address_sanitizer)
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -317,6 +317,13 @@
   void semanticHighlights(PathRef File,
   Callback>);
 
+  /// Runs an arbitrary action that has access to the AST of the specified file.
+  /// The action will execute on one of ClangdServer's internal threads.
+  /// The AST is only valid for the duration of the callback.
+  /// As with other actions, the file must have been opened.
+  void customAction(PathRef File, llvm::StringRef Name,
+Callback Action);
+
   /// Returns estimated memory usage and other statistics for each of the
   /// currently open files.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -754,6 +754,11 @@
TUScheduler::InvalidateOnUpdate);
 }
 
+void ClangdServer::customAction(PathRef File, llvm::StringRef Name,
+Callback Action) {
+  WorkScheduler.runWithAST(Name, File, std::move(Action));
+}
+
 llvm::StringMap ClangdServer::fileStats() const {
   return WorkScheduler.fileStats();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://list

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

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



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46
+CheckFactories.registerCheck(
+"misc-redundant-condition");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> I think this check should probably live in the `bugprone` module, WDYT?
Based on my experience, `bugpronbe` is for checks whose findings are bugs that 
lead to undefined illegal memory access, behavior etc. This one is somewhere 
between that and readability. For example, `redundant-expression` is also in 
`misc`. But if you wish, I can move this checker into `bugprone`.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp:1097
+  }
+}

aaron.ballman wrote:
> baloghadamsoftware wrote:
> > aaron.ballman wrote:
> > > Can you add some tests that exercise GNU expression statements, just to 
> > > make sure we get the behavior correct?
> > > ```
> > > if (({foo;})) {
> > > } else if (({foo;})) {
> > > }
> > > 
> > > if (foo) ({bar;});
> > > else if (foo) ({bar;});
> > > ```
> > > Another thing that's interesting to test is whether the redundant 
> > > expression is in a subexpression which doesn't contribute to the value of 
> > > the control expression:
> > > ```
> > > if (foo(), val) {
> > > } else if (foo(), other_val) {
> > > }
> > > ```
> > > (Similar can be tested with GNU statement expressions.)
> > Do you mean that I should handle these cases as well? (Detect a bug, 
> > provide a fix.)
> If the check misses these cases, I think that's reasonable (just comment that 
> the tests aren't currently handled). If the check diagnoses these cases but 
> the fixit causes an issue, then I think that should be corrected in this 
> patch. If it's trivial to support these cases (diagnosing or fixing), it's 
> your call on whether you want to do so. I mostly just want the test coverage 
> so I can know what to expect.
The check currently misses these cases completely, so I left a `FIXME` there. I 
can do it in the near future, but first I would like to commit a first version 
so I can tell the user who requested it that his request is fulfilled.


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

https://reviews.llvm.org/D81272

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


[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 285326.
baloghadamsoftware added a comment.

Updated according to the latest comment.


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

https://reviews.llvm.org/D77229

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1990,6 +1990,55 @@
 ++i0;
 }
 
+template 
+struct delegated_ctor_iterator {
+  delegated_ctor_iterator(const T&, int);
+  delegated_ctor_iterator(const T& t) : delegated_ctor_iterator(t, 0) {}
+  delegated_ctor_iterator operator++();
+  delegated_ctor_iterator operator++(int);
+  T& operator*();
+};
+
+template 
+struct container_with_delegated_ctor_iterator {
+  typedef delegated_ctor_iterator iterator;
+  iterator begin() const { return delegated_ctor_iterator(T()); }
+};
+
+void
+test_delegated_ctor_iterator(
+const container_with_delegated_ctor_iterator &c) {
+  auto i = c.begin(); // no-crash
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.begin()}}
+}
+
+template 
+struct base_ctor_iterator {
+  base_ctor_iterator(const T&);
+  base_ctor_iterator operator++();
+  base_ctor_iterator operator++(int);
+  T& operator*();
+};
+
+template 
+struct derived_ctor_iterator: public base_ctor_iterator {
+  derived_ctor_iterator(const T& t) : base_ctor_iterator(t) {}
+};
+
+template 
+struct container_with_derived_ctor_iterator {
+  typedef derived_ctor_iterator iterator;
+  iterator begin() const { return derived_ctor_iterator(T()); }
+};
+
+void
+test_derived_ctor_iterator(const container_with_derived_ctor_iterator &c) {
+  auto i = c.begin();
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.begin()}}
+}
+
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
Index: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
@@ -24,12 +24,12 @@
 namespace {
 
 class STLAlgorithmModeling : public Checker {
-  bool evalFind(CheckerContext &C, const CallExpr *CE) const;
+  void evalFind(CheckerContext &C, const CallExpr *CE, SVal Begin,
+SVal End) const;
 
-  void Find(CheckerContext &C, const CallExpr *CE, unsigned paramNum) const;
-
-  using FnCheck = bool (STLAlgorithmModeling::*)(CheckerContext &,
-const CallExpr *) const;
+  using FnCheck = void (STLAlgorithmModeling::*)(CheckerContext &,
+ const CallExpr *, SVal Begin,
+ SVal End) const;
 
   const CallDescriptionMap Callbacks = {
 {{{"std", "find"}, 3}, &STLAlgorithmModeling::evalFind},
@@ -67,51 +67,45 @@
 
 bool STLAlgorithmModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
-  const auto *CE = dyn_cast_or_null(Call.getOriginExpr());
-  if (!CE)
-return false;
-
-  const FnCheck *Handler = Callbacks.lookup(Call);
-  if (!Handler)
-return false;
-
-  return (this->**Handler)(C, CE);
-}
-
-bool STLAlgorithmModeling::evalFind(CheckerContext &C,
-const CallExpr *CE) const {
   // std::find()-like functions either take their primary range in the first
   // two parameters, or if the first parameter is "execution policy" then in
   // the second and third. This means that the second parameter must always be
   // an iterator.
-  if (!isIteratorType(CE->getArg(1)->getType()))
+  if (Call.getNumArgs() < 2 || !isIteratorType(Call.getArgExpr(1)->getType()))
 return false;
 
   // If no "execution policy" parameter is used then the first argument is the
-  // beginning of the range.
-  if (isIteratorType(CE->getArg(0)->getType())) {
-Find(C, CE, 0);
-return true;
+  // beginning of the range. If "execution policy" parmeter is used then the
+  // third argument is the end of the range.
+  unsigned ArgNum = 0;
+  if (!isIteratorType(Call.getArgExpr(0)->getType())) {
+if (Call.getNumArgs() < 3 || !isIterator

[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

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



Comment at: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp:77
 
+  unsigned ArgNum = 999;
+

gamesh411 wrote:
> 999 seems a bit arbitrary here, consider using 
> std::numeric_limits::max(), or llvm::Optional.
I refactored this part. The earlier approach was very ugly and non-standard. I 
just intended to make it work as quickly as possible, but I forgot to refactor 
after that. Thank you for noticing it!


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

https://reviews.llvm.org/D77229

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


[PATCH] D85728: [Analyzer] Support for the new variadic isa<> and isa_and_not_null<> in CastValueChecker

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added a comment.

@NoQ Thank you for the review. Please also review D85752 
 after my update and tell me what I have to 
change there if it is not acceptable yet. This patch depends on that one.


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

https://reviews.llvm.org/D85728

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


[PATCH] D85351: [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

@NoQ Could you please take a look on this one? It is a fix of my earlier work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85351

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-08-13 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 285329.
MForster added a comment.

Rebase before submission


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-print-attr.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -329,6 +329,8 @@
 // empty string but are then recorded as a nullptr.
 OS << "\" << (get" << getUpperName() << "() ? get" << getUpperName()
<< "()->getName() : \"\") << \"";
+  else if (type == "VarDecl *")
+OS << "\" << get" << getUpperName() << "()->getName() << \"";
   else if (type == "TypeSourceInfo *")
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/test/AST/ast-print-attr.c
===
--- clang/test/AST/ast-print-attr.c
+++ clang/test/AST/ast-print-attr.c
@@ -15,3 +15,14 @@
 int fun_asm() asm("test");
 // CHECK: int var_asm asm("test");
 int var_asm asm("test");
+
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+// CHECK: enum __attribute__((ns_error_domain(MyErrorDomain))) MyErrorEnum {
+enum __attribu

[PATCH] D62574: Add support for target-configurable address spaces.

2020-08-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D62574#2210503 , @ebevhan wrote:

> I think this works now. It should probably be given a few more reviewers to 
> have a look. Do you have some suggestions, @Anastasia ?

Great! I will look at this again within a week or so. I think it would be good 
to get some feedback from John @rjmccall too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62574

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


[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-08-13 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 285332.
danielkiss added a comment.

Always emit xpac* instructions as discussed in D84502 
.


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

https://reviews.llvm.org/D75044

Files:
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll

Index: llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
@@ -0,0 +1,49 @@
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.2a | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.3a | FileCheck %s --check-prefix=CHECKV83
+
+; Armv8.3-A Pointer Authetication requires a special intsruction to strip the
+; pointer authentication code from the pointer.
+; The XPACLRI instruction assembles to a hint-space instruction before Armv8.3-A
+; therefore this instruction can be safely used for any pre Armv8.3-A architectures.
+; On Armv8.3-A and onwards XPACI is available so use that instead.
+
+define i8* @ra0() nounwind readnone {
+entry:
+; CHECK-LABEL: ra0:
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: ret
+; CHECKV83:   str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  ret
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+define i8* @ra1() nounwind readnone #0 {
+entry:
+; CHECK-LABEL: ra1:
+; CHECK:  hint#25
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: hint#29
+; CHECK-NEXT: ret
+; CHECKV83:   paciasp
+; CHECKV83-NEXT:  str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  retaa
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+attributes #0 = { "sign-return-address"="all" }
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -6388,17 +6388,34 @@
   EVT VT = Op.getValueType();
   SDLoc DL(Op);
   unsigned Depth = cast(Op.getOperand(0))->getZExtValue();
+  SDValue ReturnAddress;
   if (Depth) {
 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
 SDValue Offset = DAG.getConstant(8, DL, getPointerTy(DAG.getDataLayout()));
-return DAG.getLoad(VT, DL, DAG.getEntryNode(),
-   DAG.getNode(ISD::ADD, DL, VT, FrameAddr, Offset),
-   MachinePointerInfo());
+ReturnAddress = DAG.getLoad(
+VT, DL, DAG.getEntryNode(),
+DAG.getNode(ISD::ADD, DL, VT, FrameAddr, Offset), MachinePointerInfo());
+  } else {
+// Return LR, which contains the return address. Mark it an implicit
+// live-in.
+unsigned Reg = MF.addLiveIn(AArch64::LR, &AArch64::GPR64RegClass);
+ReturnAddress = DAG.getCopyFromReg(DAG.getEntryNode(), DL, Reg, VT);
+  }
+
+  // The XPACLRI instruction assembles to a hint-space instruction before
+  // Armv8.3-A therefore this instruction can be safely used for any pre
+  // Armv8.3-A architectures. On Armv8.3-A and onwards XPACI is available so use
+  // that instead.
+  SDNode *St;
+  if (Subtarget->hasV8_3aOps()) {
+St = DAG.getMachineNode(AArch64::XPACI, DL, VT, ReturnAddress);
+  } else {
+// XPACLRI operates on LR therefore we must move the operand accordingly.
+SDValue Chain =
+DAG.getCopyToReg(DAG.getEntryNode(), DL, AArch64::LR, ReturnAddress);
+St = DAG.getMachineNode(AArch64::XPACLRI, DL, VT, Chain);
   }
-
-  // Return LR, which contains the return address. Mark it an implicit live-in.
-  unsigned Reg = MF.addLiveIn(AArch64::LR, &AArch64::GPR64RegClass);
-  return DAG.getCopyFromReg(DAG.getEntryNode(), DL, Reg, VT);
+  return SDValue(St, 0);
 }
 
 /// LowerShiftRightParts - Lower SRA_PARTS, which returns two
Index: llvm/include/llvm/CodeGen/ISDOpcodes.h
===
--- llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -86,7 +86,16 @@
   /// the parent's frame or return address, and so on.
   FRAMEADDR,
   RETURNADDR,
+
+  /// ADDROFRETURNADDR - Represents the llvm.addressofreturnaddress intrinsic.
+  /// This node takes no operand, returns a target-specific pointer to the
+  /// place in the stack frame where the return address of the current
+  /// function is stored.
   

[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

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

The patch looks great. I guess the only remaining discussion remains as to 
whether this should be in `libAnalysis`, or somewhere else. Here is my take: 
Since clang-tidy, CSA, and some other parts of the compiler (like uninitialized 
variable warnings) are static analyzers within the same infrastructure, it 
makes sense for them to have a common library. I see that diagnostics aren't 
really analyses. `libFrontend` or `libDriver`, which, as I understand it 
contains most the diagnostics machinery for clang aren't viable alternatives 
because of the library dependencies. So, I think if `libAnalysis` was called 
`libStaticAnalysisCommon`, we would be golden, but that would screw over 
downstream developers for negligible gain. While I'm not terribly experiences 
in library layout design, for the time being, the move to `libAnalysis` seems 
appropriate.

I see that we're still heavily tied to StaticAnalyzer headers. Doesn't that 
violate the module system, as `libAnalysis` is a dependency of 
`libStaticAnalyzerCore`? `AnalyzerOptions` and `AnalysisConsumer` (that last 
one in particular) seem deeply integrated into these consumers.




Comment at: clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp:27-31
+  createHTMLDiagnosticConsumer(
+  DiagOpts, C, std::string(llvm::sys::path::parent_path(Prefix)), PP, CTU);
+  createPlistMultiFileDiagnosticConsumer(DiagOpts, C, Prefix, PP, CTU);
+  createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, Prefix, PP,
+  CTU);

NoQ wrote:
> I just realized that this code creates 5 consumers: 1 html consumer, 1 plist 
> consumer, 3 text consumers. This isn't a regression due to this patch... but 
> damn!
Oh wow. That is definitely my mistake. The issue is that detailed diagnostics 
(`-analyzer-output=text`) and the minimal one (`analyzer-output=text-minimal`) 
should be mutually exclusive. I'll try to think about a solution. Maybe some 
`Profile` thing might work.


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

https://reviews.llvm.org/D67422

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


[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

2020-08-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

Tests c:

I'm still not a huge fan of the warning message. Now it describes //what kind// 
of constraint was violated, but not //how// (too large? too small?). Also, 
while I respect that you didn't prefer my suggestion, I think the warning 
message there is still a lot more welcoming, even if it doesn't convey more 
information. But, I don't necessarily insist on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D71767: [POC][SVE] Allow code generation for fixed length vectorised loops [Patch 2/2].

2020-08-13 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm updated this revision to Diff 285336.
paulwalker-arm added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71767

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h

Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -878,6 +878,7 @@
   SDValue LowerVectorSRA_SRL_SHL(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
+  SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerF128Call(SDValue Op, SelectionDAG &DAG,
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1110,13 +1110,24 @@
   setOperationAction(ISD::SHL, VT, Custom);
   setOperationAction(ISD::SIGN_EXTEND, VT, Custom);
   setOperationAction(ISD::SIGN_EXTEND_INREG, VT, Custom);
+  setOperationAction(ISD::SMAX, VT, Custom);
+  setOperationAction(ISD::SMIN, VT, Custom);
   setOperationAction(ISD::SRA, VT, Custom);
   setOperationAction(ISD::SRL, VT, Custom);
   setOperationAction(ISD::STORE, VT, Custom);
   setOperationAction(ISD::SUB, VT, Custom);
   setOperationAction(ISD::TRUNCATE, VT, Custom);
+  setOperationAction(ISD::UMAX, VT, Custom);
+  setOperationAction(ISD::UMIN, VT, Custom);
+  setOperationAction(ISD::VSELECT, VT, Custom);
   setOperationAction(ISD::XOR, VT, Custom);
   setOperationAction(ISD::ZERO_EXTEND, VT, Custom);
+
+  if (VT.getVectorElementType() == MVT::i32 ||
+  VT.getVectorElementType() == MVT::i64) {
+setOperationAction(ISD::SDIV, VT, Custom);
+setOperationAction(ISD::UDIV, VT, Custom);
+  }
 }
 
 void AArch64TargetLowering::addDRTypeForNEON(MVT VT) {
@@ -3710,6 +3721,8 @@
 return LowerToPredicatedOp(Op, DAG, AArch64ISD::FMAXNM_PRED);
   case ISD::FMINNUM:
 return LowerToPredicatedOp(Op, DAG, AArch64ISD::FMINNM_PRED);
+  case ISD::VSELECT:
+return LowerVSELECT(Op, DAG);
   }
 }
 
@@ -15491,3 +15504,24 @@
   auto Promote = DAG.getBoolExtOrTrunc(Cmp, DL, PromoteVT, InVT);
   return convertFromScalableVector(DAG, Op.getValueType(), Promote);
 }
+
+SDValue AArch64TargetLowering::LowerVSELECT(SDValue Op,
+SelectionDAG &DAG) const {
+  SDLoc DL(Op);
+
+  EVT InVT = Op.getOperand(1).getValueType();
+  EVT ContainerVT = getContainerForFixedLengthVector(DAG, InVT);
+  auto Op1 = convertToScalableVector(DAG, ContainerVT, Op.getOperand(1));
+  auto Op2 = convertToScalableVector(DAG, ContainerVT, Op.getOperand(2));
+
+  // Convert the mask to a predicated (NOTE: We don't need to worry about
+  // inactive lanes since VSELECT is safe when given undefined elements).
+  EVT MaskVT = Op.getOperand(0).getValueType();
+  EVT MaskContainerVT = getContainerForFixedLengthVector(DAG, MaskVT);
+  auto Mask = convertToScalableVector(DAG, MaskContainerVT, Op.getOperand(0));
+  Mask = DAG.getNode(ISD::TRUNCATE, DL,
+ MaskContainerVT.changeVectorElementType(MVT::i1), Mask);
+
+  auto VSel = DAG.getNode(ISD::VSELECT, DL, ContainerVT, Mask, Op1, Op2);
+  return convertFromScalableVector(DAG, InVT, VSel);
+}
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20577,7 +20577,8 @@
 EVT N0SrcSVT = N0Src.getValueType().getScalarType();
 EVT N1SrcSVT = N1Src.getValueType().getScalarType();
 if ((N0.isUndef() || N0SrcSVT == N1SrcSVT) &&
-N0Src.getValueType().isVector() && N1Src.getValueType().isVector()) {
+N0Src.getValueType().isFixedLengthVector() &&
+N1Src.getValueType().isFixedLengthVector()) {
   EVT NewVT;
   SDLoc DL(N);
   SDValue NewIdx;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1724,9 +1724,17 @@
 StringRef Val = A->getValue();
 const Driver &D = getToolChain().getDriver();
 if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
-Val.equals("1024") || Val.equals("2048"))
+Val.equals("1024") || Val.equals("2048")) {
   CmdArgs.push_back(
   Args.MakeArgString(llvm::Twine("-msve-

[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

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

Oops sorry, misread "mostly lgtm" and committed.

Changed to use the "InputsAndAST" struct to provide the rest of the info.
Happy to address any further comments...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85883

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


[clang-tools-extra] 41d0edd - [clangd] Express dumpAST in tests as a customAction()

2020-08-13 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-08-13T14:27:32+02:00
New Revision: 41d0edd54e29e994fa7d40961a38e8fca27addac

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

LOG: [clangd] Express dumpAST in tests as a customAction()

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/ParsedAST.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 919d59ab09d0..cd6cba8c2ed3 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -525,26 +525,6 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, 
StringRef TweakID,
   WorkScheduler.runWithAST("ApplyTweak", File, std::move(Action));
 }
 
-void ClangdServer::dumpAST(PathRef File,
-   llvm::unique_function Callback) {
-  auto Action = [Callback = std::move(Callback)](
-llvm::Expected InpAST) mutable {
-if (!InpAST) {
-  llvm::consumeError(InpAST.takeError());
-  return Callback("");
-}
-std::string Result;
-
-llvm::raw_string_ostream ResultOS(Result);
-clangd::dumpAST(InpAST->AST, ResultOS);
-ResultOS.flush();
-
-Callback(Result);
-  };
-
-  WorkScheduler.runWithAST("DumpAST", File, std::move(Action));
-}
-
 void ClangdServer::locateSymbolAt(PathRef File, Position Pos,
   Callback> CB) {
   auto Action = [Pos, CB = std::move(CB),

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 7aed7d4f3d85..1bc7d70eebad 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -295,10 +295,6 @@ class ClangdServer {
   void applyTweak(PathRef File, Range Sel, StringRef ID,
   Callback CB);
 
-  /// Only for testing purposes.
-  /// Waits until all requests to worker thread are finished and dumps AST for
-  /// \p File. \p File must be in the list of added documents.
-  void dumpAST(PathRef File, llvm::unique_function 
Callback);
   /// Called when an event occurs for a watched file in the workspace.
   void onFileEvent(const DidChangeWatchedFilesParams &Params);
 

diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index 7a7853a6245c..35e7fd72c3c5 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -238,10 +238,6 @@ class ReplayPreamble : private PPCallbacks {
 
 } // namespace
 
-void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS) {
-  AST.getASTContext().getTranslationUnitDecl()->dump(OS, true);
-}
-
 llvm::Optional
 ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
  std::unique_ptr CI,

diff  --git a/clang-tools-extra/clangd/ParsedAST.h 
b/clang-tools-extra/clangd/ParsedAST.h
index 361b20aeff4c..05818b9dba80 100644
--- a/clang-tools-extra/clangd/ParsedAST.h
+++ b/clang-tools-extra/clangd/ParsedAST.h
@@ -146,10 +146,6 @@ class ParsedAST {
   CanonicalIncludes CanonIncludes;
 };
 
-/// For testing/debugging purposes. Note that this method deserializes all
-/// unserialized Decls, so use with care.
-void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS);
-
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index 585fabe60ab7..a7c25683e9c1 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -139,9 +139,25 @@ std::string replacePtrsInDump(std::string const &Dump) {
   return Result;
 }
 
+std::string dumpAST(ClangdServer &Server, PathRef File) {
+  std::string Result;
+  Notification Done;
+  Server.customAction(File, "DumpAST", [&](llvm::Expected AST) {
+if (AST) {
+  llvm::raw_string_ostream ResultOS(Result);
+  AST->AST.getASTContext().getTranslationUnitDecl()->dump(ResultOS, true);
+} else {
+  llvm::consumeError(AST.takeError());
+  Result = "";
+}
+Done.notify();
+  });
+  Done.wait();
+  return Result;
+}
+
 std::string dumpASTWithoutMemoryLocs(ClangdServer &Server, PathRef File) {
-  auto DumpWithMemLocs = runDumpAST(Server, File);
-  return replacePtrsInDump(DumpWithMemLocs);
+  return replacePtrsInDump(dumpAST(Server, File));
 }
 
 class ClangdVFSTest : public ::testing::Test {
@@ -607,7 +623,7 @@ TEST_F(ClangdVFSTest, InvalidCompileCommand) {
   // Clang can't parse command args in that case, bu

[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

2020-08-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

no I am totally fine with the change. I just wanted to give Adam some time to 
take a look too :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85883

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


[PATCH] D85883: [clangd] Add ClangdServer::customAction() extension point

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

Yup sorry @adamcz, I was just confused. Likewise, happy to change to a 
different structure or revert entirely if you have concerns.

41d0edd54e29e994fa7d40961a38e8fca27addac 
 
eliminates dumpAST based on this, but is easy to revert too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85883

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


[PATCH] D85896: [SyntaxTree] Split `TreeTest.cpp`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
eduucaldas requested review of this revision.

We extract the test infrastructure into `TreeTestBase.h` and split the
tests into `MutationsTest.cpp` and `BuildTreeTest.cpp`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85896

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -0,0 +1,218 @@
+//===- TreeTestBase.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides the test infrastructure for syntax trees.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Testing/TestClangConfig.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Mutations.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace syntax_test {
+static ArrayRef tokens(syntax::Node *N) {
+  assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
+  if (auto *L = dyn_cast(N))
+return llvm::makeArrayRef(L->token(), 1);
+  auto *T = cast(N);
+  return llvm::makeArrayRef(T->firstLeaf()->token(),
+T->lastLeaf()->token() + 1);
+}
+
+class SyntaxTreeTest : public ::testing::Test,
+   public ::testing::WithParamInterface {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(StringRef Code,
+ const TestClangConfig &ClangConfig) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &TB,
+  std::unique_ptr &Arena,
+  std::unique_ptr Tokens)
+  : Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+TB =
+std::make_unique(std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Arena = std::make_unique(Ctx.getSourceManager(),
+Ctx.getLangOpts(), *TB);
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
+  std::unique_ptr &Arena;
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &TB,
+std::unique_ptr &Arena)
+  : Root(Root), TB(TB), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+std::make_unique(CI.getPreprocessor());
+return std::make_unique(Root, TB, Arena,
+ std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
+  std::unique_ptr &Arena;
+};
+
+constexpr const char *FileName = "./input.cpp";
+ 

[PATCH] D85897: [SyntaxTree] Split `TreeTest.cpp`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
eduucaldas requested review of this revision.

We extract the test infrastructure into `TreeTestBase.h` and split the
tests into `MutationsTest.cpp` and `BuildTreeTest.cpp`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85897

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -0,0 +1,218 @@
+//===- TreeTestBase.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides the test infrastructure for syntax trees.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Testing/TestClangConfig.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Mutations.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace syntax_test {
+static ArrayRef tokens(syntax::Node *N) {
+  assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
+  if (auto *L = dyn_cast(N))
+return llvm::makeArrayRef(L->token(), 1);
+  auto *T = cast(N);
+  return llvm::makeArrayRef(T->firstLeaf()->token(),
+T->lastLeaf()->token() + 1);
+}
+
+class SyntaxTreeTest : public ::testing::Test,
+   public ::testing::WithParamInterface {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(StringRef Code,
+ const TestClangConfig &ClangConfig) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &TB,
+  std::unique_ptr &Arena,
+  std::unique_ptr Tokens)
+  : Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+TB =
+std::make_unique(std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Arena = std::make_unique(Ctx.getSourceManager(),
+Ctx.getLangOpts(), *TB);
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
+  std::unique_ptr &Arena;
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &TB,
+std::unique_ptr &Arena)
+  : Root(Root), TB(TB), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+std::make_unique(CI.getPreprocessor());
+return std::make_unique(Root, TB, Arena,
+ std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &TB;
+  std::unique_ptr &Arena;
+};
+
+constexpr const char *FileName = "./input.cpp";
+ 

[PATCH] D85898: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85898

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 
//===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax_test {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -19,7 +19,7 @@
 TEST_P(SyntaxTreeTest, Simple) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int main() {}
+void main() {}
 void foo() {}
 )cpp",
   R"txt(


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 //===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax_test {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -19,7 +19,7 @@
 TEST_P(SyntaxTreeTest, Simple) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int main() {}
+void main() {}
 void foo() {}
 )cpp",
   R"txt(
___
cfe-commits mailing list
cfe-commits@lis

[PATCH] D85898: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 285342.
eduucaldas added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85898

Files:
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 
//===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax_test {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 //===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax_test {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46
+CheckFactories.registerCheck(
+"misc-redundant-condition");
 CheckFactories.registerCheck(

baloghadamsoftware wrote:
> aaron.ballman wrote:
> > I think this check should probably live in the `bugprone` module, WDYT?
> Based on my experience, `bugpronbe` is for checks whose findings are bugs 
> that lead to undefined illegal memory access, behavior etc. This one is 
> somewhere between that and readability. For example, `redundant-expression` 
> is also in `misc`. But if you wish, I can move this checker into `bugprone`.
The `bugprone` module has less to do with memory access or undefined behavior 
specifically and more to do with checks that should expose bugs in your code 
but don't belong to other categories. We try to keep checks out of `misc` as 
much as possible these days and this code pattern is attempting to find cases 
where the user potentially has a bug, so I think `bugprone` is the correct home 
for it.

However, `bugprone` has a similar check and I sort of wonder whether we should 
be extending that check rather than adding a separate one. See 
`bugprone-branch-clone` which catches the highly related situation where you 
have a chain of conditionals and one of the conditions is repeated. e.g.,
```
if (foo) {
  if (foo) { // Caught by misc-redundant-condition
  }
} else if (foo) { // Caught by bugprone-branch-clone
}
```
Even if we don't combine the checks, we should ensure their behaviors work well 
together (catch the same scenarios, don't repeat diagnostics, etc).



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-redundant-condition.cpp:1097
+  }
+}

baloghadamsoftware wrote:
> aaron.ballman wrote:
> > baloghadamsoftware wrote:
> > > aaron.ballman wrote:
> > > > Can you add some tests that exercise GNU expression statements, just to 
> > > > make sure we get the behavior correct?
> > > > ```
> > > > if (({foo;})) {
> > > > } else if (({foo;})) {
> > > > }
> > > > 
> > > > if (foo) ({bar;});
> > > > else if (foo) ({bar;});
> > > > ```
> > > > Another thing that's interesting to test is whether the redundant 
> > > > expression is in a subexpression which doesn't contribute to the value 
> > > > of the control expression:
> > > > ```
> > > > if (foo(), val) {
> > > > } else if (foo(), other_val) {
> > > > }
> > > > ```
> > > > (Similar can be tested with GNU statement expressions.)
> > > Do you mean that I should handle these cases as well? (Detect a bug, 
> > > provide a fix.)
> > If the check misses these cases, I think that's reasonable (just comment 
> > that the tests aren't currently handled). If the check diagnoses these 
> > cases but the fixit causes an issue, then I think that should be corrected 
> > in this patch. If it's trivial to support these cases (diagnosing or 
> > fixing), it's your call on whether you want to do so. I mostly just want 
> > the test coverage so I can know what to expect.
> The check currently misses these cases completely, so I left a `FIXME` there. 
> I can do it in the near future, but first I would like to commit a first 
> version so I can tell the user who requested it that his request is fulfilled.
Sounds great to me, thanks!


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

https://reviews.llvm.org/D81272

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


[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

njames93 wrote:
> aaron.ballman wrote:
> > I suspect there are more checks that should be added here. For instance, 
> > much of `modernize-` is purely stylistic so it's easy to view as being 
> > false positives (like `modernize-use-trailing-return-types` or whatever 
> > it's called).
> I don't think that's what this list is for. This seems to be purely for 
> checks that don't run properly or crash inside clangd. 
> `modernize-use-trailing-return-types` is a very noisy check but that's how it 
> is when ran as normal clang-tidy. 
Ah, thank you for the explanation. Then how about `UnusableWithinClangd` or 
something other than `FalsePositives` for the name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83224

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


[PATCH] D85897: [SyntaxTree] Split `TreeTest.cpp`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

We can further split `BuildTreeTest.cpp` for instance in 
`BuildStatementTest.cpp` and `BuildDeclTest.cpp`, I can't see many arguments 
towards that though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85897

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Jesper Antonsson via Phabricator via cfe-commits
JesperAntonsson added a comment.

Hi,

In our local Jenkins machinery, the UndefOfModuleMacro test fails on master 
when built with gcc. Pasting the crash dump below. Any ideas?

BR  /Jesper

12:24:39 FAIL: Clangd Unit Tests :: 
./ClangdTests/SymbolCollectorTest.UndefOfModuleMacro (31492 of 65755)
12:24:39  TEST 'Clangd Unit Tests :: 
./ClangdTests/SymbolCollectorTest.UndefOfModuleMacro' FAILED 

12:24:39 Note: Google Test filter = SymbolCollectorTest.UndefOfModuleMacro
12:24:39 [==] Running 1 test from 1 test case.
12:24:39 [--] Global test environment set-up.
12:24:39 [--] 1 test from SymbolCollectorTest
12:24:39 [ RUN  ] SymbolCollectorTest.UndefOfModuleMacro
12:24:39 VFS: failed to set CWD to /clangd-test: No such file or directory
12:24:39 VFS: failed to set CWD to /clangd-test: No such file or directory
12:24:39 Built preamble of size 214456 for file /clangd-test/TestTU.cpp version 
null
12:24:39 VFS: failed to set CWD to /clangd-test: No such file or directory
12:24:39   #0 0x009e175a llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x9e175a)
12:24:39   #1 0x009df764 llvm::sys::RunSignalHandlers() 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x9df764)
12:24:39   #2 0x009df8a3 SignalHandler(int) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x9df8a3)
12:24:39   #3 0x7f4051202630 __restore_rt (/lib64/libpthread.so.0+0xf630)
12:24:39   #4 0x00eb291c llvm::SimpleBitstreamCursor::Read(unsigned 
int) ([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xeb291c)
12:24:39   #5 0x0233a2fc llvm::SimpleBitstreamCursor::ReadVBR(unsigned 
int) [clone .constprop.173] 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x233a2fc)
12:24:39   #6 0x0233b9f3 llvm::BitstreamCursor::readRecord(unsigned 
int, llvm::SmallVectorImpl&, llvm::StringRef*) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x233b9f3)
12:24:39   #7 0x01797360 
clang::ASTReader::ReadSLocEntry(int)::{lambda(llvm::BitstreamCursor&, 
llvm::StringRef)#1}::operator()(llvm::BitstreamCursor&, llvm::StringRef) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x1797360)
12:24:39   #8 0x017c2511 clang::ASTReader::ReadSLocEntry(int) [clone 
.part.2799] 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x17c2511)
12:24:39   #9 0x00dd752d clang::SourceManager::loadSLocEntry(unsigned 
int, bool*) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xdd752d)
12:24:39  #10 0x00dab66c 
clang::DiagnosticsEngine::DiagStateMap::lookup(clang::SourceManager&, 
clang::SourceLocation) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xdab66c)
12:24:39  #11 0x00dae275 
clang::DiagnosticIDs::getDiagnosticSeverity(unsigned int, 
clang::SourceLocation, clang::DiagnosticsEngine const&) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xdae275)
12:24:39  #12 0x00dae725 
clang::DiagnosticIDs::getDiagnosticLevel(unsigned int, clang::SourceLocation, 
clang::DiagnosticsEngine const&) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xdae725)
12:24:39  #13 0x00daf181 
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xdaf181)
12:24:39  #14 0x00da50ab 
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda50ab)
12:24:39  #15 0x00da546c clang::DiagnosticsEngine::ReportDelayed() 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda546c)
12:24:39  #16 0x00da50cb 
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda50cb)
12:24:39  #17 0x00da546c clang::DiagnosticsEngine::ReportDelayed() 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda546c)
12:24:39  #18 0x00da50cb 
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda50cb)
12:24:39  #19 0x00da546c clang::DiagnosticsEngine::ReportDelayed() 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda546c)
12:24:39  #20 0x00da50cb 
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda50cb)
12:24:39  #21 0x00da546c clang::DiagnosticsEngine::ReportDelayed() 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda546c)
[...]
12:24:39 #252 0x00da50cb 
clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
([...]/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xda50cb)
12:24:39 #253 0x00da546c clang::DiagnosticsEngine::ReportDelayed() 
([...]/tools/clan

[PATCH] D85898: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.h:14
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Frontend/CompilerInstance.h"

We can either remove this or
```
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
```

I imagine that we'd rather leave the direct includes, in this case should we 
remove `clang/Basic/LLVM.h`?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85898

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


[PATCH] D85450: Support the standards-based dates for __has_c_attribute

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

I'm accepting these changes on my own authority as code owner; if there are 
issues, I'll deal with them post-commit.


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

https://reviews.llvm.org/D85450

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


[clang] 9936b96 - Support the standards-based dates for __has_c_attribute

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

Author: Aaron Ballman
Date: 2020-08-13T08:47:40-04:00
New Revision: 9936b96d5333af4e6dff55025943366bb5f07272

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

LOG: Support the standards-based dates for __has_c_attribute

WG14 N2481 was adopted with minor modifications at the latest WG14 meetings.
The only modification to the paper was to correct the date for the deprecated
attribute to be 201904L (the corrected date value will be present in WG14
N2553 when it gets published).

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/test/Preprocessor/has_c_attribute.c
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index f9bf3f0acd553..3d8ad705f91fc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -267,8 +267,10 @@ class CXX11
   string Namespace = namespace;
   int Version = version;
 }
-class C2x : Spelling {
+class C2x
+: Spelling {
   string Namespace = namespace;
+  int Version = version;
 }
 
 class Keyword : Spelling;
@@ -1221,7 +1223,8 @@ def RenderScriptKernel : Attr {
 
 def Deprecated : InheritableAttr {
   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
-   CXX11<"","deprecated", 201309>, C2x<"", "deprecated">];
+   CXX11<"","deprecated", 201309>,
+   C2x<"", "deprecated", 201904>];
   let Args = [StringArgument<"Message", 1>,
   // An optional string argument that enables us to provide a
   // Fix-It.
@@ -1278,7 +1281,8 @@ def ExtVectorType : Attr {
 }
 
 def FallThrough : StmtAttr {
-  let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
+  let Spellings = [CXX11<"", "fallthrough", 201603>,
+   C2x<"", "fallthrough", 201904>,
CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
 //  let Subjects = [NullStmt];
   let Documentation = [FallthroughDocs];
@@ -2442,7 +2446,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
-   C2x<"", "maybe_unused">];
+   C2x<"", "maybe_unused", 201904>];
   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
@@ -2528,7 +2532,8 @@ def WarnUnused : InheritableAttr {
 }
 
 def WarnUnusedResult : InheritableAttr {
-  let Spellings = [CXX11<"", "nodiscard", 201907>, C2x<"", "nodiscard">,
+  let Spellings = [CXX11<"", "nodiscard", 201907>,
+   C2x<"", "nodiscard", 201904>,
CXX11<"clang", "warn_unused_result">,
GCC<"warn_unused_result">];
   let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;

diff  --git a/clang/test/Preprocessor/has_c_attribute.c 
b/clang/test/Preprocessor/has_c_attribute.c
index f8b0b364faa5f..670e42a97926e 100644
--- a/clang/test/Preprocessor/has_c_attribute.c
+++ b/clang/test/Preprocessor/has_c_attribute.c
@@ -1,22 +1,44 @@
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -std=c2x -E %s -o - | FileCheck %s
-
-// CHECK: has_fallthrough
-#if __has_c_attribute(fallthrough)
-  int has_fallthrough();
-#endif
-
-// CHECK: does_not_have_selectany
-#if !__has_c_attribute(selectany)
-  int does_not_have_selectany();
-#endif
-
-// CHECK: has_nodiscard_underscore
-#if __has_c_attribute(__nodiscard__)
-  int has_nodiscard_underscore();
-#endif
-
-// CHECK: has_clang_annotate
-#if __has_c_attribute(clang::annotate)
-  int has_clang_annotate();
-#endif
+// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E -P %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
+
+#define C2x(x) x: __has_c_attribute(x)
+
+// CHECK: fallthrough: 201904L
+C2x(fallthrough)
+
+// CHECK: __nodiscard__: 201904L
+C2x(__nodiscard__)
+
+// CHECK: selectany: 0
+C2x(selectany); // Known attribute not supported in C mode
+
+// CHECK: frobble: 0
+C2x(frobble) // Unknown attribute
+
+// CHECK: frobble::frobble: 0
+C2x(frobble::frobble) // Unknown vendor namespace
+
+// CHECK: clang::annotate: 1
+C2x(clang::annotate)
+
+// CHECK: deprecated: 201904L
+C2x(deprecated)
+
+// CHECK: maybe_unused: 201904L
+C2x(maybe_unused)
+
+// CHECK: __gnu__::warn_unused_result: 201904L
+C2x(__gnu__::warn_unused_result)
+
+// CHECK: gnu::__warn_unused_result__: 201904L
+C2x(gnu::__warn_unused_result__)
+
+// We do somewhat support the __clang__ vendor namespace, but it is a
+// predefined macro and thus we encourage users to use _Clang instead.
+// Becau

[PATCH] D85450: Support the standards-based dates for __has_c_attribute

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

Changes committed in 9936b96d5333af4e6dff55025943366bb5f07272 



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

https://reviews.llvm.org/D85450

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


[PATCH] D85898: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.h:14
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Frontend/CompilerInstance.h"

eduucaldas wrote:
> We can either remove this or
> ```
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/StringRef.h"
> #include "llvm/Support/Casting.h"
> #include "llvm/Support/Error.h"
> ```
> 
> I imagine that we'd rather leave the direct includes, in this case should we 
> remove `clang/Basic/LLVM.h`?
> 
clang/Basic/LLVM.h only adds "using" declarations, it does not define the types 
themselves. So we need to keep both clang/Basic/LLVM.h and ArrayRef.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85898

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


[PATCH] D85897: [SyntaxTree] Split `TreeTest.cpp`

2020-08-13 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:16
+namespace clang {
+namespace syntax_test {
 namespace {

Ditto, please use namespace clang::syntax.



Comment at: clang/unittests/Tooling/Syntax/TreeTestBase.h:44
+namespace clang {
+namespace syntax_test {
+static ArrayRef tokens(syntax::Node *N) {

Please use the same namespace that the non-test code is using.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85897

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


[PATCH] D84248: [analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions

2020-08-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added reviewers: NoQ, vsavchenko.
Szelethus accepted this revision.
Szelethus added a comment.

Lets make sure we invite the wider community to see whats going on. Otherwise, 
LGTM!

It seems like this patch adds two new additions at once -- infrastructure for 
when the arg constraint size is concrete with an appropriate test, and another 
round of adding mass function modeling. While this isn't the largest amount of 
new functions you're adding, it would still be nice that such changes were void 
of any other functional changes, imo. However, I don't think its worth 
splitting up at this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84248

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


[PATCH] D85351: [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

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

Shouldn't we create a new test care for this, instead of expanding an existing 
one? Btw, this looks great, but I lack the confidence to accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85351

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


[clang] a5b8757 - Introduce ns_error_domain attribute.

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

Author: Michael Forster
Date: 2020-08-13T15:05:12+02:00
New Revision: a5b8757506b07e3091fe243b6c1e004220d3cba3

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

LOG: Introduce ns_error_domain attribute.

ns_error_domain can be used by, e.g. NS_ERROR_ENUM, in order to
identify a global declaration representing the domain constant.

Introduces the attribute, Sema handling, diagnostics, and test case.

This is cherry-picked from 
https://github.com/llvm/llvm-project-staging/commit/a14779f504b02ad0e4dbc39d6d10cadc7ed4cfd0
and adapted to updated Clang APIs.

Reviewed By: gribozavr2, aaron.ballman

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

Added: 
clang/test/Sema/ns_error_enum.m

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/AST/ast-print-attr.c
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3d8ad705f91f..f525d3566dbb 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1878,6 +1878,13 @@ def ObjCBridgeRelated : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def NSErrorDomain : InheritableAttr {
+  let Spellings = [GNU<"ns_error_domain">];
+  let Subjects = SubjectList<[Enum], ErrorDiag>;
+  let Args = [DeclArgument];
+  let Documentation = [NSErrorDomainDocs];
+}
+
 def NSReturnsRetained : DeclOrTypeAttr {
   let Spellings = [Clang<"ns_returns_retained">];
 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 83990721d7f7..29ad179e46e9 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3339,6 +3339,38 @@ arguments, with arbitrary offsets.
   }];
 }
 
+def NSErrorDomainDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+In Cocoa frameworks in Objective-C, one can group related error codes in enums
+and categorize these enums with error domains.
+
+The ``ns_error_domain`` attribute indicates a global ``NSString`` constant
+representing the error domain that an error code belongs to. For pointer
+uniqueness and code size this is a constant symbol, not a literal.
+
+The domain and error code need to be used together. The ``ns_error_domain``
+attribute links error codes to their domain at the source level.
+
+This metadata is useful for documentation purposes, for static analysis, and 
for
+improving interoperability between Objective-C and Swift. It is not used for
+code generation in Objective-C.
+
+For example:
+
+  .. code-block:: objc
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) 
_name : _type
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+  MyErrFirst,
+  MyErrSecond,
+};
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f2e939da3050..e3edddf6a3f2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9476,6 +9476,11 @@ def err_nsconsumed_attribute_mismatch : Error<
 def err_nsreturns_retained_attribute_mismatch : Error<
   "overriding method has mismatched ns_returns_%select{not_retained|retained}0"
   " attributes">;
+def err_nserrordomain_invalid_decl : Error<
+  "domain argument %select{|%1 }0does not refer to global constant">;
+def err_nserrordomain_wrong_type : Error<
+  "domain argument %0 does not point to an NSString constant">;
+
 def warn_nsconsumed_attribute_mismatch : Warning<
   err_nsconsumed_attribute_mismatch.Text>, InGroup;
 def warn_nsreturns_retained_attribute_mismatch : Warning<

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index d46c791b0e3a..bb19bd097564 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Loo

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-08-13 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5b8757506b0: Introduce ns_error_domain attribute. (authored 
by MForster, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-print-attr.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -329,6 +329,8 @@
 // empty string but are then recorded as a nullptr.
 OS << "\" << (get" << getUpperName() << "() ? get" << getUpperName()
<< "()->getName() : \"\") << \"";
+  else if (type == "VarDecl *")
+OS << "\" << get" << getUpperName() << "()->getName() << \"";
   else if (type == "TypeSourceInfo *")
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/test/AST/ast-print-attr.c
===
--- clang/test/AST/ast-print-attr.c
+++ clang/test/AST/ast-print-attr.c
@@ -15,3 +15,14 @@
 int fun_asm() asm("test");
 // CHECK: int var_asm asm("test");
 int var_asm asm("test");
+
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;

[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

2020-08-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

There is a TODO comment at the error message, it needs improvement. The current 
form is still something for developers, not for end users. For final version I 
would accept textual descriptions (as mentioned above), not names like 
"BufferSize" and words like "ArgN" inside it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46
+CheckFactories.registerCheck(
+"misc-redundant-condition");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> baloghadamsoftware wrote:
> > aaron.ballman wrote:
> > > I think this check should probably live in the `bugprone` module, WDYT?
> > Based on my experience, `bugpronbe` is for checks whose findings are bugs 
> > that lead to undefined illegal memory access, behavior etc. This one is 
> > somewhere between that and readability. For example, `redundant-expression` 
> > is also in `misc`. But if you wish, I can move this checker into `bugprone`.
> The `bugprone` module has less to do with memory access or undefined behavior 
> specifically and more to do with checks that should expose bugs in your code 
> but don't belong to other categories. We try to keep checks out of `misc` as 
> much as possible these days and this code pattern is attempting to find cases 
> where the user potentially has a bug, so I think `bugprone` is the correct 
> home for it.
> 
> However, `bugprone` has a similar check and I sort of wonder whether we 
> should be extending that check rather than adding a separate one. See 
> `bugprone-branch-clone` which catches the highly related situation where you 
> have a chain of conditionals and one of the conditions is repeated. e.g.,
> ```
> if (foo) {
>   if (foo) { // Caught by misc-redundant-condition
>   }
> } else if (foo) { // Caught by bugprone-branch-clone
> }
> ```
> Even if we don't combine the checks, we should ensure their behaviors work 
> well together (catch the same scenarios, don't repeat diagnostics, etc).
OK, I will put this into `bugprone`. The two checks may look similar, but this 
one is more complex because it does not check for the same condition in 
multiple branches of the same branch statement but checks whether the condition 
expression could be mutated between the two branch statements. Therefore the 
the whole logic is totally different, I see no point in merging the two. Should 
I create a test case then, where both are enabled?


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

https://reviews.llvm.org/D81272

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


[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

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

Ah, okay, silly me. Didn't catch that. Then the message is OK for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[clang] d17437d - [SyntaxTree] Split `TreeTest.cpp`

2020-08-13 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-13T13:30:57Z
New Revision: d17437d2bd8e83baee96f2860276d615d216dfbc

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

LOG: [SyntaxTree] Split `TreeTest.cpp`

We extract the test infrastructure into `TreeTestBase.h` and split the
tests into `MutationsTest.cpp` and `BuildTreeTest.cpp`

Added: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
clang/unittests/Tooling/Syntax/MutationsTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.h

Modified: 
clang/unittests/Tooling/Syntax/CMakeLists.txt

Removed: 
clang/unittests/Tooling/Syntax/TreeTest.cpp



diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
similarity index 88%
rename from clang/unittests/Tooling/Syntax/TreeTest.cpp
rename to clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index e266ef3f5870..deffd48da085 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1,217 +1,20 @@
-//===- TreeTest.cpp 
---===//
+//===- BuildTreeTest.cpp 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
+//
+// This file tests the syntax tree generation from the ClangAST.
+//
+//===--===//
 
-#include "clang/Tooling/Syntax/Tree.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
-#include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/CompilerInvocation.h"
-#include "clang/Frontend/FrontendAction.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/PreprocessorOptions.h"
-#include "clang/Testing/CommandLineArgs.h"
-#include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
-#include "clang/Tooling/Syntax/Nodes.h"
-#include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-#include 
-#include 
-
-using namespace clang;
+#include "TreeTestBase.h"
 
+namespace clang {
+namespace syntax {
 namespace {
-static ArrayRef tokens(syntax::Node *N) {
-  assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
-  if (auto *L = dyn_cast(N))
-return llvm::makeArrayRef(L->token(), 1);
-  auto *T = cast(N);
-  return llvm::makeArrayRef(T->firstLeaf()->token(),
-T->lastLeaf()->token() + 1);
-}
-
-class SyntaxTreeTest : public ::testing::Test,
-   public ::testing::WithParamInterface {
-protected:
-  // Build a syntax tree for the code.
-  syntax::TranslationUnit *buildTree(StringRef Code,
- const TestClangConfig &ClangConfig) {
-// FIXME: this code is almost the identical to the one in TokensTest. Share
-//it.
-class BuildSyntaxTree : public ASTConsumer {
-public:
-  BuildSyntaxTree(syntax::TranslationUnit *&Root,
-  std::unique_ptr &TB,
-  std::unique_ptr &Arena,
-  std::unique_ptr Tokens)
-  : Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
-assert(this->Tokens);
-  }
-
-  void HandleTranslationUnit(ASTContext &Ctx) override {
-TB =
-
std::make_unique(std::move(*Tokens).consume());
-Tokens = nullptr; // make sure we fail if this gets called twice.
-Arena = std::make_unique(Ctx.getSourceManager(),
-Ctx.getLangOpts(), *TB);
-Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
-  }
-
-private:
-  syntax::TranslationUnit *&Root;
-  std::unique_ptr &TB;
-  std::unique_ptr &Arena;
-  std::unique_ptr Tokens;
-};
-
-class BuildSyntaxTreeAction : public ASTFrontendAction {
-public:
-  BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
-std::unique_ptr &TB,
-std::unique_ptr &Arena)

[clang] 9c2e708 - [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-13T13:30:57Z
New Revision: 9c2e708f0dc547d386ea528450a33ef4bd2a750b

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

LOG: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/MutationsTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.h

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/MutationsTest.cpp 
b/clang/unittests/Tooling/Syntax/MutationsTest.cpp
index 30f8d523b781..088dbe3afbdc 100644
--- a/clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ b/clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {

diff  --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h 
b/clang/unittests/Tooling/Syntax/TreeTestBase.h
index 0e66a320d812..37b604dd5cd5 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 
//===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax {



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


[PATCH] D85898: [SyntaxTree] Clean `#includes` in `TreeTestBase.h`

2020-08-13 Thread Eduardo Caldas 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 rG9c2e708f0dc5: [SyntaxTree] Clean `#includes` in 
`TreeTestBase.h` (authored by eduucaldas).

Changed prior to commit:
  https://reviews.llvm.org/D85898?vs=285342&id=285354#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85898

Files:
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 
//===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {


Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -11,10 +11,7 @@
 //===--===//
 
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -22,23 +19,16 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
 #include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
-#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Annotations.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
-#include 
 
 namespace clang {
 namespace syntax {
Index: clang/unittests/Tooling/Syntax/MutationsTest.cpp
===
--- clang/unittests/Tooling/Syntax/MutationsTest.cpp
+++ clang/unittests/Tooling/Syntax/MutationsTest.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "TreeTestBase.h"
 
 namespace clang {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng requested changes to this revision.
fanbo-meng added a comment.
This revision now requires changes to proceed.

Can you modify `clang/test/Frontend/trigraphs.cpp` and 
`clang/test/Lexer/cxx1z-trigraphs.cpp` ? These tests are assuming trigraphs are 
disabled by `-std=gnu++11 -fms-compatibility -std=c++1z`, and it won't be the 
case here because on z/OS trigraphs are still enabled when these options are 
present.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

This is quite strange. I can't reproduce this with gcc 7.5.0, 9.3.0 or 10.0.1. 
Which version are you using?

There are bugs around clangd + modules + diagnostics. I'm fixing one in 
https://reviews.llvm.org/D85753 (not in it's final form yet), but it doesn't 
seem to be the same issue (can't be sure, but I think this is using the right 
SourceManager). This test is not supposed to generate any diagnostics, so 
that's the really surprising bit. Are you building from clean HEAD, or do you 
have any local modifications that could generate a extra diagnostics in this 
test?

The other option is that the failure is caused by module_cache_path. This test, 
unlike other clangd tests, needs real file system (to write the .pcm file and 
then read it back) and perhaps that doesn't work in your jenkins setup.

Are there any special options or things unique to your setup I could try out to 
reproduce this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525

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


[PATCH] D85817: [analyzer] Fix crash with pointer to members values

2020-08-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 285358.
vsavchenko added a comment.

Simplify the main test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85817

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/PR46264.cpp
  clang/test/Analysis/pointer-to-member.cpp

Index: clang/test/Analysis/pointer-to-member.cpp
===
--- clang/test/Analysis/pointer-to-member.cpp
+++ clang/test/Analysis/pointer-to-member.cpp
@@ -233,39 +233,57 @@
 
 namespace testAnonymousMember {
 struct A {
+  int a;
   struct {
-int x;
+int b;
+int c;
   };
   struct {
 struct {
-  int y;
+  int d;
+  int e;
 };
   };
   struct {
 union {
-  int z;
+  int f;
 };
   };
 };
 
 void test() {
-  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::a); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::b); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::c); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::e); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::f); // expected-warning{{TRUE}}
+
+  int A::*ap = &A::a,
+  A::*bp = &A::b,
+  A::*cp = &A::c,
+  A::*dp = &A::d,
+  A::*ep = &A::e,
+  A::*fp = &A::f;
+
+  clang_analyzer_eval(ap); // expected-warning{{TRUE}}
+  clang_analyzer_eval(bp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(cp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(dp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ep); // expected-warning{{TRUE}}
+  clang_analyzer_eval(fp); // expected-warning{{TRUE}}
 
-  // FIXME: These should be true.
-  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
-  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
-
-  // FIXME: These should be true as well.
   A a;
-  a.x = 1;
-  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
-  a.y = 2;
-  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
-  a.z = 3;
-  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+  a.a = 1;
+  a.b = 2;
+  a.c = 3;
+  a.d = 4;
+  a.e = 5;
+
+  clang_analyzer_eval(a.*ap == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*bp == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*cp == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*dp == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*ep == 5); // expected-warning{{TRUE}}
 }
-} // end of testAnonymousMember namespace
+} // namespace testAnonymousMember
Index: clang/test/Analysis/PR46264.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR46264.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// rdar://problem/64202361
+
+struct A {
+  int a;
+  struct {
+struct {
+  int b;
+  union {
+int c;
+  };
+};
+  };
+};
+
+int testCrash() {
+  int *x = 0;
+  int A::*ap = &A::a;
+
+  if (ap)
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
+
+int testIndirectCrash() {
+  int *x = 0;
+  int A::*cp = &A::c;
+
+  if (cp)
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1106,19 +1106,28 @@
 }
 
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
-  BinaryOperator::Opcode op,
-  Loc lhs, NonLoc rhs, QualType resultTy) {
+BinaryOperator::Opcode op, Loc lhs,
+NonLoc rhs, QualType resultTy) {
   if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
 if (auto PTMSV = rhs.getAs()) {
   if (PTMSV->isNullMemberPointer())
 return UndefinedVal();
-  if (const FieldDecl *FD = PTMSV->getDeclAs()) {
+
+  auto getFieldLValue = [&](const auto

[PATCH] D85817: [analyzer] Fix crash with pointer to members values

2020-08-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 285360.
vsavchenko added a comment.

Add "no crash" comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85817

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/PR46264.cpp
  clang/test/Analysis/pointer-to-member.cpp

Index: clang/test/Analysis/pointer-to-member.cpp
===
--- clang/test/Analysis/pointer-to-member.cpp
+++ clang/test/Analysis/pointer-to-member.cpp
@@ -233,39 +233,57 @@
 
 namespace testAnonymousMember {
 struct A {
+  int a;
   struct {
-int x;
+int b;
+int c;
   };
   struct {
 struct {
-  int y;
+  int d;
+  int e;
 };
   };
   struct {
 union {
-  int z;
+  int f;
 };
   };
 };
 
 void test() {
-  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::a); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::b); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::c); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::e); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::f); // expected-warning{{TRUE}}
+
+  int A::*ap = &A::a,
+  A::*bp = &A::b,
+  A::*cp = &A::c,
+  A::*dp = &A::d,
+  A::*ep = &A::e,
+  A::*fp = &A::f;
+
+  clang_analyzer_eval(ap); // expected-warning{{TRUE}}
+  clang_analyzer_eval(bp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(cp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(dp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ep); // expected-warning{{TRUE}}
+  clang_analyzer_eval(fp); // expected-warning{{TRUE}}
 
-  // FIXME: These should be true.
-  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
-  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
-
-  // FIXME: These should be true as well.
   A a;
-  a.x = 1;
-  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
-  a.y = 2;
-  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
-  a.z = 3;
-  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+  a.a = 1;
+  a.b = 2;
+  a.c = 3;
+  a.d = 4;
+  a.e = 5;
+
+  clang_analyzer_eval(a.*ap == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*bp == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*cp == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*dp == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*ep == 5); // expected-warning{{TRUE}}
 }
-} // end of testAnonymousMember namespace
+} // namespace testAnonymousMember
Index: clang/test/Analysis/PR46264.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR46264.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// rdar://problem/64202361
+
+struct A {
+  int a;
+  struct {
+struct {
+  int b;
+  union {
+int c;
+  };
+};
+  };
+};
+
+int testCrash() {
+  int *x = 0;
+  int A::*ap = &A::a;
+
+  if (ap)  // no crash
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
+
+int testIndirectCrash() {
+  int *x = 0;
+  int A::*cp = &A::c;
+
+  if (cp)  // no crash
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1106,19 +1106,28 @@
 }
 
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
-  BinaryOperator::Opcode op,
-  Loc lhs, NonLoc rhs, QualType resultTy) {
+BinaryOperator::Opcode op, Loc lhs,
+NonLoc rhs, QualType resultTy) {
   if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
 if (auto PTMSV = rhs.getAs()) {
   if (PTMSV->isNullMemberPointer())
 return UndefinedVal();
-  if (const FieldDecl *FD = PTMSV->getDeclAs()) {
+
+  a

[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 285362.
abhina.sreeskantharajan added a comment.

Thanks Hubert and Fanbo for reviewing. I updated the comment to Hubert's 
suggestion, and updated both testcases as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/trigraphs.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,25 @@
-// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck 
--check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify=notri
+// RUN: %clang_cc1 -std=c++1z %s -verify=tri -ftrigraphs
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} 
expected-warning {{trigraph ignored}}
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-error {{}}
+error here;
+
+#ifndef __MVS__
+// notri-error@4 {{}} notri-warning@4 {{trigraph ignored}} tri-warning@4 
{{trigraph converted}}
+// notri-error@6 {{failed}} notri-warning@6 {{trigraph ignored}} tri-warning@6 
{{trigraph converted}}
+// notri-error@9 {{}}
+// tri-warning@12 {{backslash and newline separated by space}}
+// notri-error@13 {{}}
+#else
+// notri-warning@4 {{trigraph converted}} tri-warning@4 {{trigraph converted}}
+// notri-warning@6 {{trigraph converted}} tri-warning@6 {{trigraph converted}}
+// notri-warning@12 {{backslash and newline separated by space}} 
tri-warning@12 {{backslash and newline separated by space}}
+#endif
Index: clang/test/Frontend/trigraphs.cpp
===
--- clang/test/Frontend/trigraphs.cpp
+++ clang/test/Frontend/trigraphs.cpp
@@ -4,12 +4,14 @@
 // RUN: %clang_cc1 -DSTDCPP17 -std=c++1z -verify -fsyntax-only %s
 // RUN: %clang_cc1 -DSTDCPP17TRI -ftrigraphs -std=c++1z -verify -fsyntax-only 
%s
 // RUN: %clang_cc1 -DMSCOMPAT -fms-compatibility -std=c++11 -verify 
-fsyntax-only %s
+// RUN: %clang_cc1 -DNOTRI -fno-trigraphs -verify -fsyntax-only %s
 
 void foo() {
 #if defined(NOFLAGS) || defined(STDCPP11) || defined(STDGNU11TRI) || \
-defined(STDCPP17TRI)
+defined(STDCPP17TRI) || (defined(__MVS__) && !defined(NOTRI))
   const char c[] = "??/n"; // expected-warning{{trigraph converted to '\' 
character}}
-#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT)
+#elif defined(STDGNU11) || defined(STDCPP17) || defined(MSCOMPAT) || \
+defined(NOTRI)
   const char c[] = "??/n"; // expected-warning{{trigraph ignored}}
 #else
 #error Not handled.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2787,7 +2787,9 @@
   // Mimicking gcc's behavior, trigraphs are only enabled if -trigraphs
   // is specified, or -std is set to a conforming mode.
   // Trigraphs are disabled by default in c++1z onwards.
-  Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
+  // For z/OS, trigraphs are enabled by default (without regard to the above).
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 


Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -1,14 +1,25 @@
-// RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck --check-prefix=TRIGRAPHS %s
+// RUN: %clang_cc1 -std=c++1z %s -verify=notri
+// RUN: %clang_cc1 -std=c++1z %s -verify=tri -ftrigraphs
 
-??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
+??= define foo ;
 
-static_assert("??="[0] == '#', ""); // expected-error {{failed}} expected-warning {{trigraph ignored}}
+static_assert("??="[0] == '#', "");
 
 // ??/
-error here; // expected-error {{}}
+error here;
 
-// Note, there is intentionally trailing whitespace two lines below.
-// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// Note, there is intentionally trailing whitespace one line below.
 // ??/  
-error here; // expected-e

[PATCH] D84005: Introduce ns_error_domain attribute.

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

Looks like this breaks check-clangd on Windows: 
http://45.33.8.238/win/21943/step_9.txt

Please take a look, and revert while you investigate if the fix takes a while.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

2020-08-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added reviewers: NoQ, vsavchenko.
martong added subscribers: vsavchenko, NoQ.
martong added a comment.

@NoQ, @vsavchenko My apologies, somehow I forgot to add you as reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

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


[PATCH] D84248: [analyzer][StdLibraryFunctionsChecker] Add POSIX time handling functions

2020-08-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@NoQ, @vsavchenko My apologies, somehow I forgot to add you as reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84248

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


[clang] 82057e3 - clang: Fix minor grammar-o in diag added in c354b2e3b

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

Author: Nico Weber
Date: 2020-08-13T10:06:40-04:00
New Revision: 82057e3f39e624dbaa5bbd7497c359f704347f6f

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

LOG: clang: Fix minor grammar-o in diag added in c354b2e3b

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Modules/namespaces.cpp
clang/test/SemaCXX/elaborated-type-specifier.cpp
clang/test/SemaCXX/pointer-forward-declared-class-conversion.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e3edddf6a3f2..fd21285b1f79 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2006,7 +2006,7 @@ def err_init_conversion_failed : Error<
   "|: 
diff erent qualifiers (%5 vs %6)"
   "|: 
diff erent exception specifications}4">;
 def note_forward_class_conversion : Note<"%0 is not defined, but forward "
-  "declared here; conversion would be valid if it's derived from %1">;
+  "declared here; conversion would be valid if it was derived from %1">;
 
 def err_lvalue_to_rvalue_ref : Error<"rvalue reference %
diff {to type $ cannot "
   "bind to lvalue of type $|cannot bind to incompatible lvalue}0,1">;

diff  --git a/clang/test/Modules/namespaces.cpp 
b/clang/test/Modules/namespaces.cpp
index 315b1cdeda0a..7e3ce820491e 100644
--- a/clang/test/Modules/namespaces.cpp
+++ b/clang/test/Modules/namespaces.cpp
@@ -78,8 +78,8 @@ void testAnonymousNotMerged() {
 
 // expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter 
here}}
 // expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter 
here}}
-// expected-note@Inputs/namespaces-left.h:63 {{'N11::(anonymous 
namespace)::Foo' is not defined, but forward declared here; conversion would be 
valid if it's derived from 'N11::(anonymous namespace)::Foo'}}
-// expected-note@Inputs/namespaces-left.h:70 {{'N12::(anonymous 
namespace)::Foo' is not defined, but forward declared here; conversion would be 
valid if it's derived from 'N12::(anonymous namespace)::Foo'}}
+// expected-note@Inputs/namespaces-left.h:63 {{'N11::(anonymous 
namespace)::Foo' is not defined, but forward declared here; conversion would be 
valid if it was derived from 'N11::(anonymous namespace)::Foo'}}
+// expected-note@Inputs/namespaces-left.h:70 {{'N12::(anonymous 
namespace)::Foo' is not defined, but forward declared here; conversion would be 
valid if it was derived from 'N12::(anonymous namespace)::Foo'}}
 // Test that bringing in one name from an overload set does not hide the rest.
 void testPartialImportOfOverloadSet() {
   void (*p)() = N13::p;

diff  --git a/clang/test/SemaCXX/elaborated-type-specifier.cpp 
b/clang/test/SemaCXX/elaborated-type-specifier.cpp
index 06037d865d26..66693ec3d118 100644
--- a/clang/test/SemaCXX/elaborated-type-specifier.cpp
+++ b/clang/test/SemaCXX/elaborated-type-specifier.cpp
@@ -26,7 +26,7 @@ namespace NS {
 }
 
 void test_X_elab(NS::X x) {
-  struct S4 *s4 = 0; // expected-note{{'S4' is not defined, but forward 
declared here; conversion would be valid if it's derived from 'NS::S4'}}
+  struct S4 *s4 = 0; // expected-note{{'S4' is not defined, but forward 
declared here; conversion would be valid if it was derived from 'NS::S4'}}
   x.test_elab2(s4); // expected-error{{cannot initialize a parameter of type 
'NS::S4 *' with an lvalue of type 'struct S4 *'}}
 }
 

diff  --git a/clang/test/SemaCXX/pointer-forward-declared-class-conversion.cpp 
b/clang/test/SemaCXX/pointer-forward-declared-class-conversion.cpp
index 606517b51aac..e4fda5118061 100644
--- a/clang/test/SemaCXX/pointer-forward-declared-class-conversion.cpp
+++ b/clang/test/SemaCXX/pointer-forward-declared-class-conversion.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 class A1 {};
-class B1; // expected-note{{'B1' is not defined, but forward declared here; 
conversion would be valid if it's derived from 'A1'}}
+class B1; // expected-note{{'B1' is not defined, but forward declared here; 
conversion would be valid if it was derived from 'A1'}}
 B1 *b1;
 A1 *a1 = b1; // expected-error{{cannot initialize a variable of type 'A1 *' 
with an lvalue of type 'B1 *'}}
 



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


[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 3 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2791
+  Opts.Trigraphs =
+  (!Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17) || T.isOSzOS();
   Opts.Trigraphs =

hubert.reinterpretcast wrote:
> I would like to point out that processing trigraphs when most platforms don't 
> would be a portability concern. Clang appears to mitigate this somewhat with 
> warnings.
Unfortunately we can't move away from this because the system headers currently 
use trigraphs. But we will definitely look into whether we can update these 
headers to not be dependent on trigraphs and improve portability.



Comment at: clang/test/Frontend/trigraphs.cpp:8
+// RUN: %clang_cc1 -DZOS -triple=s390x-none-zos -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DZOSNOTRI -triple=s390x-none-zos -fno-trigraphs -verify 
-fsyntax-only %s
 

hubert.reinterpretcast wrote:
> Do we know if `-fno-trigraphs` is meaningfully functional on z/OS? I believe 
> trigraph usage might need to be replaced to use digraphs in the system 
> headers before using `-fno-trigraphs` can be expected to work in a real user 
> application.
With the current system headers, compiling with -fno-trigraphs would not work 
in a user application. As mentioned above, we will look into whether we can 
remove this dependency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

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


[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46
+CheckFactories.registerCheck(
+"misc-redundant-condition");
 CheckFactories.registerCheck(

baloghadamsoftware wrote:
> aaron.ballman wrote:
> > baloghadamsoftware wrote:
> > > aaron.ballman wrote:
> > > > I think this check should probably live in the `bugprone` module, WDYT?
> > > Based on my experience, `bugpronbe` is for checks whose findings are bugs 
> > > that lead to undefined illegal memory access, behavior etc. This one is 
> > > somewhere between that and readability. For example, 
> > > `redundant-expression` is also in `misc`. But if you wish, I can move 
> > > this checker into `bugprone`.
> > The `bugprone` module has less to do with memory access or undefined 
> > behavior specifically and more to do with checks that should expose bugs in 
> > your code but don't belong to other categories. We try to keep checks out 
> > of `misc` as much as possible these days and this code pattern is 
> > attempting to find cases where the user potentially has a bug, so I think 
> > `bugprone` is the correct home for it.
> > 
> > However, `bugprone` has a similar check and I sort of wonder whether we 
> > should be extending that check rather than adding a separate one. See 
> > `bugprone-branch-clone` which catches the highly related situation where 
> > you have a chain of conditionals and one of the conditions is repeated. 
> > e.g.,
> > ```
> > if (foo) {
> >   if (foo) { // Caught by misc-redundant-condition
> >   }
> > } else if (foo) { // Caught by bugprone-branch-clone
> > }
> > ```
> > Even if we don't combine the checks, we should ensure their behaviors work 
> > well together (catch the same scenarios, don't repeat diagnostics, etc).
> OK, I will put this into `bugprone`. The two checks may look similar, but 
> this one is more complex because it does not check for the same condition in 
> multiple branches of the same branch statement but checks whether the 
> condition expression could be mutated between the two branch statements. 
> Therefore the the whole logic is totally different, I see no point in merging 
> the two. Should I create a test case then, where both are enabled?
> Therefore the the whole logic is totally different, I see no point in merging 
> the two. 

I'm approaching the question from the perspective of the user, not a check 
author. These two checks do the same thing (find redundant conditions in flow 
control which look like they could be a logical mistake), so why should they be 
two separate checks? "Because the code looks different" isn't super compelling 
from that perspective, so I'm trying to figure out what the underlying 
principles are for the checks. If they're the same principle, they should be 
the same check. If they're fundamentally different principles, we should be 
able to explain when to use each check as part of their documentation without 
it sounding contrived. (Note, I'm not saying the checks have to be combined, 
but I am pushing back on adding an entirely new check that seems to be 
redundant from a user perspective.)

As a litmus test: can you think of a situation where you'd want only one of 
these two checks enabled? I can't think of a case where I'd care about 
redundancy in nested conditionals but not in chained conditionals (or vice 
versa) unless one of the checks had a really high false positive rate (which 
isn't much of a reason to split the checks anyway).

> Should I create a test case then, where both are enabled?

If we wind up keeping the checks separate, then probably yes (also, the 
documentation for the checks should be updated to explain how they're different 
and why that's useful).


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

https://reviews.llvm.org/D81272

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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 285366.
baloghadamsoftware added a comment.

Since no better idea cam to my mind, in this version I check whether 
`modernize-use-default-member-init` is enabled. If it is, then we issue a 
warning and suggest a fix that uses default member initializer. We also take 
into account the option for that checker whether we should use brackets or 
assignment. This checker has no options now. If the other checker is not 
enabled, we always warn and suggest fix to use constructor member initializer.


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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,454 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  double x;
+
+public:
+  Simple1() {
+// CHECK-FIXES: Simple1() : n(0), x(0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+
+public:
+  Simple2() : n(0) {
+// CHECK-FIXES: Simple2() : n(0), x(0.0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  double x;
+
+public:
+  Simple3() : x(0.0) {
+// CHECK-FIXES: Simple3() : n(0), x(0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  ~Complex2() = default;
+};
+
+class Complex3 {
+  int

[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:113
+
+// Set of clang-tidy checks that are not suitable to be run through clangd,
+// either due to crashes or false positives.

nit: "returns a clang-tidy filter string: -check1,-check2"



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:115
+// either due to crashes or false positives.
+const char *getClangTidyBlacklist() {
+  static const std::string FalsePositives =

aaron.ballman wrote:
> kadircet wrote:
> > aaron.ballman wrote:
> > > njames93 wrote:
> > > > Return by StringRef?
> > > How about `getDisabledClangTidyChecks()` (or literally any other name 
> > > than blacklist)?
> > thanks for bringing this to my attention, i will try to be more conscious 
> > next time.
> > 
> > I would prefer allow/deny as `disabled` might also be offensive in some 
> > contexts. Do you know if we already have some settlements around this one 
> > in the wider community?
> > thanks for bringing this to my attention, i will try to be more conscious 
> > next time.
> 
> No worries!
> 
> > I would prefer allow/deny as disabled might also be offensive in some 
> > contexts. Do you know if we already have some settlements around this one 
> > in the wider community?
> 
> I don't believe there's any consensus around avoiding use of "disabled" (we 
> use the term in a lot of places, especially when paired with "enabled"), but 
> I'd also be fine with allow/deny terminology instead.
> 
> As a minor drive-by comment, the function should also be marked `static` and 
> placed outside of the anonymous namespace (per our usual coding style).
I dislike "disabled" because it's vague: every check that's not enabled is 
disabled, but only a few of them are mentioned here.

I'd suggest BadlyBehavedTidyChecks or UnusableTidyChecks...



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > I suspect there are more checks that should be added here. For instance, 
> > > much of `modernize-` is purely stylistic so it's easy to view as being 
> > > false positives (like `modernize-use-trailing-return-types` or whatever 
> > > it's called).
> > I don't think that's what this list is for. This seems to be purely for 
> > checks that don't run properly or crash inside clangd. 
> > `modernize-use-trailing-return-types` is a very noisy check but that's how 
> > it is when ran as normal clang-tidy. 
> Ah, thank you for the explanation. Then how about `UnusableWithinClangd` or 
> something other than `FalsePositives` for the name?
The whole list is of checks that aren't usable in clangd, FalsePositives is the 
specific reason. What's the problem with the name?



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:210
 GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File);
+  if (!Opts.ClangTidyOpts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including

kadircet wrote:
> njames93 wrote:
> > Should the `!` be removed the branches be swapped? Just looks cleaner imo, 
> > WDYT? 
> SGTM, will address once we've settled on the idea with Sam.
> 
> (and let this be a ping to him :D @sammccall )
I'd actually write this explicitly as hasValue() since the nullopt vs empty 
distinction is critical here



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:213
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//

this comment no longer belongs here, it's to do with the structure of the 
various ClangTidyOptionsProvider implementations, which aren't visible here. 
Fine to just drop it.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:219
+//  - being reasonably efficient
+Opts.ClangTidyOpts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",

if you're going to do this on every request, might as well pull out the default 
set of checks into a function getDefaultTidyChecks() or so.

(So it's just joined once, but more importantly so we're consistent in how we 
separate the mechanism vs policy)



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:227
+  } else {
+// If user has enabled some checks, make sure clangd incompatible ones are
+// disabled.

nit: they haven't necessarily enabled checks (e.g. they could have specified 
`-checks=""` on the command line).

If the set of checks was configured?

(This is kind of a nit but did confuse me.

[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

sammccall wrote:
> aaron.ballman wrote:
> > njames93 wrote:
> > > aaron.ballman wrote:
> > > > I suspect there are more checks that should be added here. For 
> > > > instance, much of `modernize-` is purely stylistic so it's easy to view 
> > > > as being false positives (like `modernize-use-trailing-return-types` or 
> > > > whatever it's called).
> > > I don't think that's what this list is for. This seems to be purely for 
> > > checks that don't run properly or crash inside clangd. 
> > > `modernize-use-trailing-return-types` is a very noisy check but that's 
> > > how it is when ran as normal clang-tidy. 
> > Ah, thank you for the explanation. Then how about `UnusableWithinClangd` or 
> > something other than `FalsePositives` for the name?
> The whole list is of checks that aren't usable in clangd, FalsePositives is 
> the specific reason. What's the problem with the name?
> What's the problem with the name?

If this is a list of checks that should be disabled because they have a ton of 
false positives, I think the name is fine and the list is incomplete. If this 
is a list of checks that should be disabled because they're not well-supported 
in clangd specifically, I think the name is misleading and the list is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83224

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


[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

aaron.ballman wrote:
> sammccall wrote:
> > aaron.ballman wrote:
> > > njames93 wrote:
> > > > aaron.ballman wrote:
> > > > > I suspect there are more checks that should be added here. For 
> > > > > instance, much of `modernize-` is purely stylistic so it's easy to 
> > > > > view as being false positives (like 
> > > > > `modernize-use-trailing-return-types` or whatever it's called).
> > > > I don't think that's what this list is for. This seems to be purely for 
> > > > checks that don't run properly or crash inside clangd. 
> > > > `modernize-use-trailing-return-types` is a very noisy check but that's 
> > > > how it is when ran as normal clang-tidy. 
> > > Ah, thank you for the explanation. Then how about `UnusableWithinClangd` 
> > > or something other than `FalsePositives` for the name?
> > The whole list is of checks that aren't usable in clangd, FalsePositives is 
> > the specific reason. What's the problem with the name?
> > What's the problem with the name?
> 
> If this is a list of checks that should be disabled because they have a ton 
> of false positives, I think the name is fine and the list is incomplete. If 
> this is a list of checks that should be disabled because they're not 
> well-supported in clangd specifically, I think the name is misleading and the 
> list is fine.
> If this is a list of checks that should be disabled because they're not 
> well-supported in clangd specifically, I think the name is misleading and the 
> list is fine.

Fair enough - I think there's enough context to not need to repeat "in clangd" 
here though. This code is in clangd, in a function with a comment indicating 
that it's for checks that don't work well specifically in clangd. (Maybe s/not 
suitable to be run through clangd/don't work well in clangd/ though).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83224

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In D80525#2215641 , @adamcz wrote:

> This is quite strange. I can't reproduce this with gcc 7.5.0, 9.3.0 or 
> 10.0.1. Which version are you using?
>
> There are bugs around clangd + modules + diagnostics. I'm fixing one in 
> https://reviews.llvm.org/D85753 (not in it's final form yet), but it doesn't 
> seem to be the same issue (can't be sure, but I think this is using the right 
> SourceManager). This test is not supposed to generate any diagnostics, so 
> that's the really surprising bit. Are you building from clean HEAD, or do you 
> have any local modifications that could generate a extra diagnostics in this 
> test?
>
> The other option is that the failure is caused by module_cache_path. This 
> test, unlike other clangd tests, needs real file system (to write the .pcm 
> file and then read it back) and perhaps that doesn't work in your jenkins 
> setup.
>
> Are there any special options or things unique to your setup I could try out 
> to reproduce this?

We actually have had problems reproducing it outside jenkins ourselves as well. 
That is kind of why we were a bit clueless about what to do and what might be 
causing it.

Are those `VFS: failed to set CWD to /clangd-test: No such file or directory` 
outputs expected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525

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


[PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:120
+   // clangd doesn't replay those when using a preamble.
+   "-llvm-header-guard");
+  static const std::string CrashingChecks =

sammccall wrote:
> aaron.ballman wrote:
> > sammccall wrote:
> > > aaron.ballman wrote:
> > > > njames93 wrote:
> > > > > aaron.ballman wrote:
> > > > > > I suspect there are more checks that should be added here. For 
> > > > > > instance, much of `modernize-` is purely stylistic so it's easy to 
> > > > > > view as being false positives (like 
> > > > > > `modernize-use-trailing-return-types` or whatever it's called).
> > > > > I don't think that's what this list is for. This seems to be purely 
> > > > > for checks that don't run properly or crash inside clangd. 
> > > > > `modernize-use-trailing-return-types` is a very noisy check but 
> > > > > that's how it is when ran as normal clang-tidy. 
> > > > Ah, thank you for the explanation. Then how about 
> > > > `UnusableWithinClangd` or something other than `FalsePositives` for the 
> > > > name?
> > > The whole list is of checks that aren't usable in clangd, FalsePositives 
> > > is the specific reason. What's the problem with the name?
> > > What's the problem with the name?
> > 
> > If this is a list of checks that should be disabled because they have a ton 
> > of false positives, I think the name is fine and the list is incomplete. If 
> > this is a list of checks that should be disabled because they're not 
> > well-supported in clangd specifically, I think the name is misleading and 
> > the list is fine.
> > If this is a list of checks that should be disabled because they're not 
> > well-supported in clangd specifically, I think the name is misleading and 
> > the list is fine.
> 
> Fair enough - I think there's enough context to not need to repeat "in 
> clangd" here though. This code is in clangd, in a function with a comment 
> indicating that it's for checks that don't work well specifically in clangd. 
> (Maybe s/not suitable to be run through clangd/don't work well in clangd/ 
> though).
> Fair enough - I think there's enough context to not need to repeat "in 
> clangd" here though. This code is in clangd, in a function with a comment 
> indicating that it's for checks that don't work well specifically in clangd. 
> (Maybe s/not suitable to be run through clangd/don't work well in clangd/ 
> though).

That makes sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83224

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Might be that it is some other commit that cause the problem. Looking a bit 
closer at the jenkins history it seems like the tests passed once after this 
patch was added. But the next time it failed.

That second time the "[Diagnoostics] Reworked -Wstring-concatenation" commit 
had been pushed as well (commit b9af72bffe 
). And I 
see that there are some string concatenation going on in the test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

In D80525#2215755 , @bjope wrote:

> In D80525#2215641 , @adamcz wrote:
>
>> This is quite strange. I can't reproduce this with gcc 7.5.0, 9.3.0 or 
>> 10.0.1. Which version are you using?
>>
>> There are bugs around clangd + modules + diagnostics. I'm fixing one in 
>> https://reviews.llvm.org/D85753 (not in it's final form yet), but it doesn't 
>> seem to be the same issue (can't be sure, but I think this is using the 
>> right SourceManager). This test is not supposed to generate any diagnostics, 
>> so that's the really surprising bit. Are you building from clean HEAD, or do 
>> you have any local modifications that could generate a extra diagnostics in 
>> this test?
>>
>> The other option is that the failure is caused by module_cache_path. This 
>> test, unlike other clangd tests, needs real file system (to write the .pcm 
>> file and then read it back) and perhaps that doesn't work in your jenkins 
>> setup.
>>
>> Are there any special options or things unique to your setup I could try out 
>> to reproduce this?
>
> We actually have had problems reproducing it outside jenkins ourselves as 
> well. That is kind of why we were a bit clueless about what to do and what 
> might be causing it.
>
> Are those `VFS: failed to set CWD to /clangd-test: No such file or directory` 
> outputs expected?

Yes, they are harmless. InMemoryFS uses fake paths like /clangd-test, but the 
real file system can't follow that. The real file system is supposed to be used 
for module cache only.

If you can't reproduce this locally, but can on Jenkins that makes me think 
it's definitely something with filesystem. I suppose running strace on jenkins 
to log all FS access is not easy?

Maybe try to figure out what the effective ModuleCachePath is and whether that 
makes sense (i.e. is accessible) in your Jenkins setup? I can't think of a way 
to make clangd test log it, but you can just:

  llvm::errs() << ModuleCachePath << "\n"; llvm::errs().flush();

as last line of setModuleCachePath() in clang/lib/clang/Lex/HeaderSearch.h 
(around line 325) to see what path it's using.  There's probably a much smarter 
way to do this, but I don't know it.

This is still a random guess that it's something to do with file system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525

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


[PATCH] D85787: [InstCombine] Aggregate reconstruction simplification (PR47060)

2020-08-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 285371.
lebedev.ri added a comment.

Drop unneeded header include.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85787

Files:
  clang/test/CodeGenCXX/nrvo.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
  llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll

Index: llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
===
--- llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
+++ llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
@@ -17,21 +17,14 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:br i1 [[C:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]
 ; CHECK:   left:
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0
-; CHECK-NEXT:[[I2:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT]], 1
 ; CHECK-NEXT:call void @foo()
 ; CHECK-NEXT:br label [[END:%.*]]
 ; CHECK:   right:
-; CHECK-NEXT:[[I3:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 0
-; CHECK-NEXT:[[I4:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT]], 1
 ; CHECK-NEXT:call void @bar()
 ; CHECK-NEXT:br label [[END]]
 ; CHECK:   end:
-; CHECK-NEXT:[[I5:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I3]], [[RIGHT]] ]
-; CHECK-NEXT:[[I6:%.*]] = phi i32 [ [[I2]], [[LEFT]] ], [ [[I4]], [[RIGHT]] ]
+; CHECK-NEXT:[[I8:%.*]] = phi { i32, i32 } [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]
 ; CHECK-NEXT:call void @baz()
-; CHECK-NEXT:[[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0
-; CHECK-NEXT:[[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1
 ; CHECK-NEXT:ret { i32, i32 } [[I8]]
 ;
 entry:
@@ -278,24 +271,17 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:br i1 [[C0:%.*]], label [[LEFT:%.*]], label [[RIGHT:%.*]]
 ; CHECK:   left:
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT:%.*]], 0
-; CHECK-NEXT:[[I2:%.*]] = extractvalue { i32, i32 } [[AGG_LEFT]], 1
 ; CHECK-NEXT:call void @foo()
 ; CHECK-NEXT:br label [[MIDDLE:%.*]]
 ; CHECK:   right:
-; CHECK-NEXT:[[I3:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT:%.*]], 0
-; CHECK-NEXT:[[I4:%.*]] = extractvalue { i32, i32 } [[AGG_RIGHT]], 1
 ; CHECK-NEXT:call void @bar()
 ; CHECK-NEXT:br label [[MIDDLE]]
 ; CHECK:   middle:
-; CHECK-NEXT:[[I5:%.*]] = phi i32 [ [[I0]], [[LEFT]] ], [ [[I3]], [[RIGHT]] ], [ [[I5]], [[MIDDLE]] ]
-; CHECK-NEXT:[[I6:%.*]] = phi i32 [ [[I2]], [[LEFT]] ], [ [[I4]], [[RIGHT]] ], [ [[I6]], [[MIDDLE]] ]
+; CHECK-NEXT:[[I8:%.*]] = phi { i32, i32 } [ [[I8]], [[MIDDLE]] ], [ [[AGG_RIGHT:%.*]], [[RIGHT]] ], [ [[AGG_LEFT:%.*]], [[LEFT]] ]
 ; CHECK-NEXT:call void @baz()
 ; CHECK-NEXT:[[C1:%.*]] = call i1 @geni1()
 ; CHECK-NEXT:br i1 [[C1]], label [[END:%.*]], label [[MIDDLE]]
 ; CHECK:   end:
-; CHECK-NEXT:[[I7:%.*]] = insertvalue { i32, i32 } undef, i32 [[I5]], 0
-; CHECK-NEXT:[[I8:%.*]] = insertvalue { i32, i32 } [[I7]], i32 [[I6]], 1
 ; CHECK-NEXT:ret { i32, i32 } [[I8]]
 ;
 entry:
Index: llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
===
--- llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
+++ llvm/test/Transforms/InstCombine/aggregate-reconstruction.ll
@@ -13,11 +13,7 @@
 ; We should just return the source aggregate.
 define { i32, i32 } @test0({ i32, i32 } %srcagg) {
 ; CHECK-LABEL: @test0(
-; CHECK-NEXT:[[I0:%.*]] = extractvalue { i32, i32 } [[SRCAGG:%.*]], 0
-; CHECK-NEXT:[[I1:%.*]] = extractvalue { i32, i32 } [[SRCAGG]], 1
-; CHECK-NEXT:[[I2:%.*]] = insertvalue { i32, i32 } undef, i32 [[I0]], 0
-; CHECK-NEXT:[[I3:%.*]] = insertvalue { i32, i32 } [[I2]], i32 [[I1]], 1
-; CHECK-NEXT:ret { i32, i32 } [[I3]]
+; CHECK-NEXT:ret { i32, i32 } [[SRCAGG:%.*]]
 ;
   %i0 = extractvalue { i32, i32 } %srcagg, 0
   %i1 = extractvalue { i32, i32 } %srcagg, 1
@@ -29,11 +25,7 @@
 ; Arrays are still aggregates
 define [2 x i32] @test1([2 x i32] %srcagg) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[I0:%.*]] = extractvalue [2 x i32] [[SRCAGG:%.*]], 0
-; CHECK-NEXT:[[I1:%.*]] = extractvalue [2 x i32] [[SRCAGG]], 1
-; CHECK-NEXT:[[I2:%.*]] = insertvalue [2 x i32] undef, i32 [[I0]], 0
-; CHECK-NEXT:[[I3:%.*]] = insertvalue [2 x i32] [[I2]], i32 [[I1]], 1
-; CHECK-NEXT:ret [2 x i32] [[I3]]
+; CHECK-NEXT:ret [2 x i32] [[SRCAGG:%.*]]
 ;
   %i0 = extractvalue [2 x i32] %srcagg, 0
   %i1 = extractvalue [2 x i32] %srcagg, 1
@@ -83,11 +75,7 @@
 ; This is fine, however, all elements are on the same level
 define { i32, { i3

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46
+CheckFactories.registerCheck(
+"misc-redundant-condition");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> baloghadamsoftware wrote:
> > aaron.ballman wrote:
> > > baloghadamsoftware wrote:
> > > > aaron.ballman wrote:
> > > > > I think this check should probably live in the `bugprone` module, 
> > > > > WDYT?
> > > > Based on my experience, `bugpronbe` is for checks whose findings are 
> > > > bugs that lead to undefined illegal memory access, behavior etc. This 
> > > > one is somewhere between that and readability. For example, 
> > > > `redundant-expression` is also in `misc`. But if you wish, I can move 
> > > > this checker into `bugprone`.
> > > The `bugprone` module has less to do with memory access or undefined 
> > > behavior specifically and more to do with checks that should expose bugs 
> > > in your code but don't belong to other categories. We try to keep checks 
> > > out of `misc` as much as possible these days and this code pattern is 
> > > attempting to find cases where the user potentially has a bug, so I think 
> > > `bugprone` is the correct home for it.
> > > 
> > > However, `bugprone` has a similar check and I sort of wonder whether we 
> > > should be extending that check rather than adding a separate one. See 
> > > `bugprone-branch-clone` which catches the highly related situation where 
> > > you have a chain of conditionals and one of the conditions is repeated. 
> > > e.g.,
> > > ```
> > > if (foo) {
> > >   if (foo) { // Caught by misc-redundant-condition
> > >   }
> > > } else if (foo) { // Caught by bugprone-branch-clone
> > > }
> > > ```
> > > Even if we don't combine the checks, we should ensure their behaviors 
> > > work well together (catch the same scenarios, don't repeat diagnostics, 
> > > etc).
> > OK, I will put this into `bugprone`. The two checks may look similar, but 
> > this one is more complex because it does not check for the same condition 
> > in multiple branches of the same branch statement but checks whether the 
> > condition expression could be mutated between the two branch statements. 
> > Therefore the the whole logic is totally different, I see no point in 
> > merging the two. Should I create a test case then, where both are enabled?
> > Therefore the the whole logic is totally different, I see no point in 
> > merging the two. 
> 
> I'm approaching the question from the perspective of the user, not a check 
> author. These two checks do the same thing (find redundant conditions in flow 
> control which look like they could be a logical mistake), so why should they 
> be two separate checks? "Because the code looks different" isn't super 
> compelling from that perspective, so I'm trying to figure out what the 
> underlying principles are for the checks. If they're the same principle, they 
> should be the same check. If they're fundamentally different principles, we 
> should be able to explain when to use each check as part of their 
> documentation without it sounding contrived. (Note, I'm not saying the checks 
> have to be combined, but I am pushing back on adding an entirely new check 
> that seems to be redundant from a user perspective.)
> 
> As a litmus test: can you think of a situation where you'd want only one of 
> these two checks enabled? I can't think of a case where I'd care about 
> redundancy in nested conditionals but not in chained conditionals (or vice 
> versa) unless one of the checks had a really high false positive rate (which 
> isn't much of a reason to split the checks anyway).
> 
> > Should I create a test case then, where both are enabled?
> 
> If we wind up keeping the checks separate, then probably yes (also, the 
> documentation for the checks should be updated to explain how they're 
> different and why that's useful).
There are many checks that users almost always keep enabled together, but they 
are still separate checks. Now I looked into the branch clone check, combining 
them means simply copying them together because the logic is so much different.

Even from the user's perspective I see that branches with identical conditions 
are different from redundant checks. While the first one is a more serious bug 
(the second branch with the same condition is never executed) this one is 
slightly more than a readability error.


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

https://reviews.llvm.org/D81272

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


[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

2020-08-13 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

Looks like it's an issue with not clearing the module cache. I'll revert this 
change to fix the build, then re-submit with proper fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525

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


[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

2020-08-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Off-topic: I really think that we should have some sort of DSL for that kind of 
stuff.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2013
+if (Pthread_tTy) {
+  Pthread_tPtrTy = ACtx.getPointerType(*Pthread_tTy);
+  Pthread_tPtrRestrictTy = getRestrictTy(*Pthread_tPtrTy);

It feels like the readability of the code here can be drastically improved by 
introducing functions `getPointerType`, `getRestrictType`, and similar 
accepting `Optional` arguments. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

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


[PATCH] D85722: [SystemZ][z/OS] enable trigraphs by default on z/OS

2020-08-13 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Lexer/cxx1z-trigraphs.cpp:24
+// notri-warning@6 {{trigraph converted}} tri-warning@6 {{trigraph converted}}
+// notri-warning@12 {{backslash and newline separated by space}} 
tri-warning@12 {{backslash and newline separated by space}}
+#endif

This strategy duplicates the trigraphs-enabled behaviour checks three times.

Plain `-verify` can be used along with a macro instead (without such 
duplication). This also allows the explicit `-fno-trigraphs` case to be added 
with little cost.

Pseudo-code:
```
// RUN: ...
// RUN: ... -ftrigraphs -DENABLED_TRIGRAPHS=1
// RUN: ... -fno-trigraphs -DENABLED_TRIGRAPHS=0

#ifdef __MVS__
#ifndef ENABLED_TRIGRAPHS
#define ENABLED_TRIGRAPHS 1
#endif
#endif

#if !ENABLED_TRIGRAPHS
// ...
#else
// ...
#endif
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85722

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-08-13 Thread Michael Forster via Phabricator via cfe-commits
MForster added a comment.

In D84005#2215685 , @thakis wrote:

> Looks like this breaks check-clangd on Windows: 
> http://45.33.8.238/win/21943/step_9.txt

Update from an offline conversation: This may actually be rather an issue with 
the test, which was introduced just today: https://reviews.llvm.org/D80525. 
We're looking into reverting that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D85312: [ADT] Move FixedPoint.h from Clang to LLVM.

2020-08-13 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Thanks for reviewing! I'm not really sure who to add as reviewers for D85314 
, though, and no one has replied to the RFC on 
the mailing list yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85312

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


[clang] 9cbfdde - [analyzer] Fix crash with pointer to members values

2020-08-13 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-08-13T18:03:59+03:00
New Revision: 9cbfdde2ea060d7e51fd2637f63eaa74b8d92848

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

LOG: [analyzer] Fix crash with pointer to members values

This fix unifies all of the different ways we handled pointer to
members into one.  The crash was caused by the fact that the type
of pointer-to-member values was `void *`, and while this works
for the vast majority of cases it breaks when we actually need
to explain the path for the report.

rdar://problem/64202361

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

Added: 
clang/test/Analysis/PR46264.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/StaticAnalyzer/Core/SVals.cpp
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
clang/test/Analysis/pointer-to-member.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
index a001c0dc7030..142b1ab11750 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -79,11 +79,11 @@ class LazyCompoundValData : public llvm::FoldingSetNode {
 };
 
 class PointerToMemberData : public llvm::FoldingSetNode {
-  const DeclaratorDecl *D;
+  const NamedDecl *D;
   llvm::ImmutableList L;
 
 public:
-  PointerToMemberData(const DeclaratorDecl *D,
+  PointerToMemberData(const NamedDecl *D,
   llvm::ImmutableList L)
   : D(D), L(L) {}
 
@@ -92,11 +92,11 @@ class PointerToMemberData : public llvm::FoldingSetNode {
   iterator begin() const { return L.begin(); }
   iterator end() const { return L.end(); }
 
-  static void Profile(llvm::FoldingSetNodeID& ID, const DeclaratorDecl *D,
+  static void Profile(llvm::FoldingSetNodeID &ID, const NamedDecl *D,
   llvm::ImmutableList L);
 
-  void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, D, L); }
-  const DeclaratorDecl *getDeclaratorDecl() const {return D;}
+  void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, D, L); }
+  const NamedDecl *getDeclaratorDecl() const { return D; }
 
   llvm::ImmutableList getCXXBaseList() const {
 return L;
@@ -236,9 +236,9 @@ class BasicValueFactory {
   const LazyCompoundValData *getLazyCompoundValData(const StoreRef &store,
 const TypedValueRegion *region);
 
-  const PointerToMemberData *getPointerToMemberData(
-  const DeclaratorDecl *DD,
-  llvm::ImmutableList L);
+  const PointerToMemberData *
+  getPointerToMemberData(const NamedDecl *ND,
+ llvm::ImmutableList L);
 
   llvm::ImmutableList getEmptySValList() {
 return SValListFactory.getEmptyList();

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index 35ebefdc00d6..4ea85f9730bb 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -233,7 +233,7 @@ class SValBuilder {
const LocationContext *LCtx,
unsigned count);
 
-  DefinedSVal getMemberPointer(const DeclaratorDecl *DD);
+  DefinedSVal getMemberPointer(const NamedDecl *ND);
 
   DefinedSVal getFunctionPointer(const FunctionDecl *func);
 

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index a561ac67bf78..bb295ab591d4 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -520,7 +520,7 @@ class PointerToMember : public NonLoc {
 
 public:
   using PTMDataType =
-  llvm::PointerUnion;
+  llvm::PointerUnion;
 
   const PTMDataType getPTMData() const {
 return PTMDataType::getFromOpaqueValue(const_cast(Data));
@@ -528,7 +528,7 @@ class PointerToMember : public NonLoc {
 
   bool isNullMemberPointer() const;
 
-  const DeclaratorDecl *getDecl() const;
+  const NamedDecl *getDecl() const;
 
   template
   const AdjustedDecl *getDeclAs() const {

diff  --git a/clang/lib/StaticAnalyzer/Core/BasicValueFactory

[PATCH] D85817: [analyzer] Fix crash with pointer to members values

2020-08-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cbfdde2ea06: [analyzer] Fix crash with pointer to members 
values (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85817

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/PR46264.cpp
  clang/test/Analysis/pointer-to-member.cpp

Index: clang/test/Analysis/pointer-to-member.cpp
===
--- clang/test/Analysis/pointer-to-member.cpp
+++ clang/test/Analysis/pointer-to-member.cpp
@@ -233,39 +233,57 @@
 
 namespace testAnonymousMember {
 struct A {
+  int a;
   struct {
-int x;
+int b;
+int c;
   };
   struct {
 struct {
-  int y;
+  int d;
+  int e;
 };
   };
   struct {
 union {
-  int z;
+  int f;
 };
   };
 };
 
 void test() {
-  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
-  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::a); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::b); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::c); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::e); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::f); // expected-warning{{TRUE}}
+
+  int A::*ap = &A::a,
+  A::*bp = &A::b,
+  A::*cp = &A::c,
+  A::*dp = &A::d,
+  A::*ep = &A::e,
+  A::*fp = &A::f;
+
+  clang_analyzer_eval(ap); // expected-warning{{TRUE}}
+  clang_analyzer_eval(bp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(cp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(dp); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ep); // expected-warning{{TRUE}}
+  clang_analyzer_eval(fp); // expected-warning{{TRUE}}
 
-  // FIXME: These should be true.
-  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
-  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
-
-  // FIXME: These should be true as well.
   A a;
-  a.x = 1;
-  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
-  a.y = 2;
-  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
-  a.z = 3;
-  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+  a.a = 1;
+  a.b = 2;
+  a.c = 3;
+  a.d = 4;
+  a.e = 5;
+
+  clang_analyzer_eval(a.*ap == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*bp == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*cp == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*dp == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a.*ep == 5); // expected-warning{{TRUE}}
 }
-} // end of testAnonymousMember namespace
+} // namespace testAnonymousMember
Index: clang/test/Analysis/PR46264.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR46264.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// rdar://problem/64202361
+
+struct A {
+  int a;
+  struct {
+struct {
+  int b;
+  union {
+int c;
+  };
+};
+  };
+};
+
+int testCrash() {
+  int *x = 0;
+  int A::*ap = &A::a;
+
+  if (ap)  // no crash
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
+
+int testIndirectCrash() {
+  int *x = 0;
+  int A::*cp = &A::c;
+
+  if (cp)  // no crash
+return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+
+  return 10;
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1106,19 +1106,28 @@
 }
 
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
-  BinaryOperator::Opcode op,
-  Loc lhs, NonLoc rhs, QualType resultTy) {
+BinaryOperator::Opcode op, Loc lhs,
+NonLoc rhs, QualType resultTy) {
   if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
 if (auto PTMSV = rhs.getAs()) {
   if (PTMSV->isNullMemberPointer())
 retur

[PATCH] D85907: [clangd] Revert "[clangd] Fix crash-bug in preamble indexing when using modules."

2020-08-13 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This reverts commit 4061d9e42cff621462931ac7df9666806c77a237 
.
Tests are failing in some configuration, likely due to not cleaning up
module cache path before running the test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85907

Files:
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang/lib/Index/IndexingAction.cpp

Index: clang/lib/Index/IndexingAction.cpp
===
--- clang/lib/Index/IndexingAction.cpp
+++ clang/lib/Index/IndexingAction.cpp
@@ -165,20 +165,11 @@
 static void indexPreprocessorMacros(const Preprocessor &PP,
 IndexDataConsumer &DataConsumer) {
   for (const auto &M : PP.macros())
-if (MacroDirective *MD = M.second.getLatest()) {
-  auto *MI = MD->getMacroInfo();
-  // When using modules, it may happen that we find #undef of a macro that
-  // was defined in another module. In such case, MI may be nullptr, since
-  // we only look for macro definitions in the current TU. In that case,
-  // there is nothing to index.
-  if (!MI)
-continue;
-
+if (MacroDirective *MD = M.second.getLatest())
   DataConsumer.handleMacroOccurrence(
   M.first, MD->getMacroInfo(),
   static_cast(index::SymbolRole::Definition),
   MD->getLocation());
-}
 }
 
 void index::indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -66,16 +66,6 @@
   // Simulate a header guard of the header (using an #import directive).
   bool ImplicitHeaderGuard = true;
 
-  // Whether to use overlay the TestFS over the real filesystem. This is
-  // required for use of implicit modules.where the module file is written to
-  // disk and later read back.
-  // FIXME: Change the way reading/writing modules work to allow us to keep them
-  // in memory across multiple clang invocations, at least in tests, to
-  // eliminate the need for real file system here.
-  // Please avoid using this for things other than implicit modules. The plan is
-  // to eliminate this option some day.
-  bool OverlayRealFileSystemForModules = false;
-
   // By default, build() will report Error diagnostics as GTest errors.
   // Suppress this behavior by adding an 'error-ok' comment to the code.
   ParsedAST build() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -54,8 +54,6 @@
   Inputs.CompileCommand.Filename = FullFilename;
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  if (OverlayRealFileSystemForModules)
-FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = &FS;
   Inputs.Opts = ParseOptions();
   Inputs.Opts.BuildRecoveryAST = true;
Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -34,21 +34,12 @@
 class MockFS : public ThreadsafeFS {
 public:
   IntrusiveRefCntPtr viewImpl() const override {
-auto MemFS = buildTestFS(Files, Timestamps);
-if (!OverlayRealFileSystemForModules)
-  return MemFS;
-llvm::IntrusiveRefCntPtr OverlayFileSystem =
-new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem());
-OverlayFileSystem->pushOverlay(MemFS);
-return OverlayFileSystem;
+return buildTestFS(Files, Timestamps);
   }
 
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
   llvm::StringMap Timestamps;
-  // If true, real file system will be used as fallback for the in-memory one.
-  // This is useful for testing module support.
-  bool OverlayRealFileSystemForModules = false;
 };
 
 // A Compilation database that returns a fixed set of compile flags.
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1610,31 +1610,6 @@
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(QName("X

  1   2   3   >