[clang-tools-extra] b7d6640 - [NFC][clang-tidy] Move recently newly-added tests into checkers/ subdir

2020-02-14 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-02-14T11:25:05+03:00
New Revision: b7d6640ba9812ec74a0f86ae7bc9850332f5fd2b

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

LOG: [NFC][clang-tidy] Move recently newly-added tests into checkers/ subdir

That's where nowadays those tests reside, those outliers were created
before the migration but committed after,
so they just awkwardly reside in the old place.

Added: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h

clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-in-initialization-strlen.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-before-safe.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-cxx.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-other.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-strlen.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-wcslen.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-userliteral.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-make-member-function-const.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-access-specifiers-check-first-declaration.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-access-specifiers.cpp

Modified: 


Removed: 

clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h

clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h
clang-tools-extra/test/clang-tidy/bugprone-bad-signal-to-kill-thread.cpp

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-in-initialization-strlen.c

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-before-safe.c

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-cxx.cpp

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe-other.c

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-memcpy-safe.c

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-strlen.c

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wcslen.cpp

clang-tools-extra/test/clang-tidy/bugprone-not-null-terminated-result-wmemcpy-safe-cxx.cpp

clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
clang-tools-extra/test/clang-tidy/readability-magic-numbers-userliteral.cpp
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp

clang-tools-extra/test/clang-tidy/readability-redundant-access-specifiers-check-first-declaration.cpp

clang-tools-extra/test/clang-tidy/readability-redundant-access-specifiers.cpp



diff  --git 
a/clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h
similarity index 100%
rename from 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h
rename to 
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-c.h

diff  --git 
a/clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h
similarity index 100%
rename from 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h
rename to 
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-not-null-terminated-result/not-null-terminated-result-cxx.h

diff  --git 
a/clang-tools-extra/test/clang-tidy/bugprone-bad-signal-to-kill-thread.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread.cpp
similarity index 

[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:98
+  case SK::TemplateTypeParm:
+  case SK::TemplateTemplateParm:
 return CompletionItemKind::Class;

I think these two should belong to `CompletionItemKind::TypeParameter`?



Comment at: clang/lib/Index/IndexSymbol.cpp:360
   break;
+case Decl::TemplateTypeParm:
+  Info.Kind = SymbolKind::TemplateTypeParm;

nit: could we move these newly-added lines above the `case 
Decl::ClassTemplatePartialSpecialization:`. I think we usually put the 
`llvm_unreachable` cases at the end of switch statement..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696



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


[PATCH] D74554: [ASTImporter] Added visibility check for scoped enums.

2020-02-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 244582.
balazske added a comment.

Added to the generic tests (and removed one redundant test).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74554

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -69,6 +69,8 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+const auto *ExternEC = "enum class E;";
+const auto *AnonEC = "namespace { enum class E; }";
 // TypedefNameDecl:
 const auto *ExternTypedef = "typedef int T;";
 const auto *AnonTypedef = "namespace { typedef int T; }";
@@ -125,6 +127,7 @@
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
 using ImportClassesVisibilityChain = ImportVisibilityChain;
+using ImportScopedEnumsVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
 using ImportClassTemplatesVisibilityChain =
@@ -142,6 +145,10 @@
 TEST_P(ImportClassesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for scoped enums.
+TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 // Value-parameterized test for function templates.
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -173,6 +180,11 @@
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
 ::testing::Values(ExternC, AnonC)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(ExternEC, AnonEC)), );
 INSTANTIATE_TEST_CASE_P(ParameterizedTests,
 ImportFunctionTemplatesVisibilityChain,
 ::testing::Combine(DefaultTestValuesForRunOptions,
@@ -291,6 +303,7 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportScopedEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
 using ImportClassTemplatesVisibility = ImportVisibility;
@@ -323,6 +336,12 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 // TypedefNameDecl.
 TEST_P(ImportTypedefNameVisibility, ImportAfter) {
   TypedTest_ImportAfterWithMerge();
@@ -392,6 +411,15 @@
 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
+std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportTypedefNameVisibility,
 ::testing::Combine(
Index: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
===
--- clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
+++ clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
@@ -64,6 +64,14 @@
   Language getLang() { return Lang_CXX; }
 };
 
+struct EnumClass {
+  using DeclTy = EnumDecl;
+  static constexpr auto *Definition = "enum class X { a, b };";
+  static constexpr auto *ConflictingDefinition = "enum class X { a, b, c };";
+  BindableMatcher getPattern() { return enumDecl(hasName("X")); }
+  Language getLang() { return Lang_CXX11; }
+};
+
 struct EnumConstant {
   using DeclTy = EnumConstantDecl;
   static constexpr auto *Definition = "enum E { X = 0 };";
@@ -396,6 +404,9 @@
 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_CASE(
 Enum, Liberal, ,
 ImportConflictingDefAfterDef)
+ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_CASE(
+EnumClass, Liberal, ,
+ImportConflictingDefAfterDef)
 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_CASE(
 EnumConsta

[PATCH] D74554: [ASTImporter] Added visibility check for scoped enums.

2020-02-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2600
+  EnumDecl *FoundDef = FoundEnum->getDefinition();
+  if (D->isThisDeclarationADefinition() && FoundDef)
+return Importer.MapImported(D, FoundDef);

martong wrote:
> shafik wrote:
> > Can you explain why we need to check `D->isThisDeclarationADefinition()` 
> > 
> > Does the test added hit all the combination of cases?
> By the time of this check, we already know that D and the existing (found) 
> decl are structurally equivalent. If they are both definitions then they must 
> be the same, so we keep on with the existing. Actually, this is not 
> unorthodox with enums, this is the pattern that we follow with all kind of 
> declarations. 
Good observation: The `enum class` case could be added to the generic redecl 
and ODR tests. This makes the single test in **ASTImporterTest.cpp** 
unnecessary, this case should be covered by the tests in 
**ASTImporterGenericRedeclTest.cpp**.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74554



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added a comment.

I'd still like to see the nits addressed and comments on the tests addressed 
before approving.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto added a comment.

@richard.barton.arm  A new patch will land today with the changes asked by you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[clang] a82f35e - [OpenMP] Lower taskwait using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via cfe-commits

Author: Roger Ferrer Ibanez
Date: 2020-02-14T09:53:02Z
New Revision: a82f35e17621a036cb726244ee5cb9708545fb93

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

LOG: [OpenMP] Lower taskwait using OpenMP IR Builder

The code generation is exactly the same as it was.

But not that the special handling of untied tasks is still handled by
emitUntiedSwitch in clang.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/task_codegen.cpp
clang/test/OpenMP/taskwait_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index fe672f346128..554d95a256ec 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6340,11 +6340,18 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF,
SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
-  // global_tid);
-  llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-  // Ignore return result until untied tasks are supported.
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), Args);
+
+  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+  if (OMPBuilder) {
+OMPBuilder->CreateTaskwait(CGF.Builder);
+  } else {
+// Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
+// global_tid);
+llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, 
Loc)};
+// Ignore return result until untied tasks are supported.
+CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), 
Args);
+  }
+
   if (auto *Region = 
dyn_cast_or_null(CGF.CapturedStmtInfo))
 Region->emitUntiedSwitch(CGF);
 }

diff  --git a/clang/test/OpenMP/task_codegen.cpp 
b/clang/test/OpenMP/task_codegen.cpp
index cf9f03082563..47c31fb217ad 100644
--- a/clang/test/OpenMP/task_codegen.cpp
+++ b/clang/test/OpenMP/task_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s

diff  --git a/clang/test/OpenMP/taskwait_codegen.cpp 
b/clang/test/OpenMP/taskwait_codegen.cpp
index 22f381b35199..20c332b3732b 100644
--- a/clang/test/OpenMP/taskwait_codegen.cpp
+++ b/clang/test/OpenMP/taskwait_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index a1470bc04958..c1ec28abd34c 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -176,6 +176,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location where the fl

[PATCH] D69828: [OpenMP] Lower taskwait using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa82f35e17621: [OpenMP] Lower taskwait using OpenMP IR 
Builder (authored by rogfer01).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69828

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/taskwait_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -691,3 +691,21 @@
return;
   emitFlush(Loc);
 }
+
+void OpenMPIRBuilder::emitTaskwaitImpl(const LocationDescription &Loc) {
+  // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
+  // global_tid);
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *Args[] = {Ident, getOrCreateThreadID(Ident)};
+
+  // Ignore return result until untied tasks are supported.
+  Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_omp_taskwait),
+ Args);
+}
+
+void OpenMPIRBuilder::CreateTaskwait(const LocationDescription &Loc) {
+  if (!updateToLocation(Loc))
+return;
+  emitTaskwaitImpl(Loc);
+}
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -169,6 +169,7 @@
 __OMP_RTL(__kmpc_flush, false, Void, IdentPtr)
 __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
 __OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
+__OMP_RTL(__kmpc_omp_taskwait, false, Int32, IdentPtr, Int32)
 __OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32,
   /* Int */ Int32)
 __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -176,6 +176,11 @@
   /// \param Loc The location where the flush directive was encountered
   void CreateFlush(const LocationDescription &Loc);
 
+  /// Generator for '#omp taskwait'
+  ///
+  /// \param Loc The location where the taskwait directive was encountered.
+  void CreateTaskwait(const LocationDescription& Loc);
+
   ///}
 
 
@@ -241,6 +246,11 @@
FinalizationStack.back().DK == DK;
   }
 
+  /// Generate a taskwait runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskwaitImpl(const LocationDescription &Loc);
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
Index: clang/test/OpenMP/taskwait_codegen.cpp
===
--- clang/test/OpenMP/taskwait_codegen.cpp
+++ clang/test/OpenMP/taskwait_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
Index: clang/test/OpenMP/task_codegen.cpp
===
--- clang/test/OpenMP/task_codegen.cpp
+++ clang/test/OpenMP/task_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D74051#1872856 , @MaskRay wrote:

> @rsmith Does `clang/test/utils/` (a new directory) look appropriate to you?


That seems fine to me. Following that pattern, I think we should also move:

- `test/clang-rename` -> `test/tools/clang-rename`
- `test/ClangScanDeps` -> `test/tools/clang-scan-deps`
- `test/TableGen` -> `test/utils/TableGen`

(We might want to move part of `test/Index` to `test/tools/libclang` and parts 
to `test/tools/c-index-test`, but we'd need to decide for each test whether 
it's a test for Clang's behavior, a test for libclang's wrapping behavior, or a 
test for the c-index-test tool itself. Let's leave that alone for now.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-14 Thread Christof Douma via Phabricator via cfe-commits
christof added a comment.

In D73904#1874303 , @thakis wrote:

> I fixed windows tests in a41550cff91b7fb2b56bf0e19ccb341bfd3e37b4 
>  . 
> Please watch bots after landing patches next time.


Thanks for fixing my broken tests @thakis. I always relied on bots to send me 
email. I just realized that my github privacy settings means that there is a 
noreply email-address in the git commit which I assume stops buildbot from 
sending emails to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73904



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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-14 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr added a comment.

@aaron.ballman I just noticed this in 
https://mlir.llvm.org/getting_started/Contributing/

> Note: if you haven’t used Arcanist to send your patch for review, committers 
> don’t have access to your preferred identity for commit messages. Make sure 
> to communicate it to them through available channels or use the git sign-off 
> functionality to make your identity visible in the commit message.

Can you please make sure the email is listed as `romanov.alex...@huawei.com` 
when committing?


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

https://reviews.llvm.org/D73775



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-02-14 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 244601.
njames93 added a comment.

- Small refactor of code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -1,7 +1,9 @@
 // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, \
-// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase} \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.MethodCase, value: camelBack}, \
+// RUN: {key: readability-identifier-naming.AggressiveDependentMemberLookup, value: 1} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -63,32 +65,23 @@
   // CHECK-FIXES: {{^}}  int getBar2() const { return this->BarBaz; } // comment-9
 };
 
-TempTest x; //force an instantiation
-
-int blah() {
-  return x.getBar2(); // gotta have a reference to the getBar2 so that the
-  // compiler will generate the function and resolve
-  // the DependantScopeMemberExpr
-}
-
 namespace Bug41122 {
 namespace std {
 
 // for this example we aren't bothered about how std::vector is treated
-template  //NOLINT
-class vector { //NOLINT
-public:
-  void push_back(bool); //NOLINT
-  void pop_back(); //NOLINT
-}; //NOLINT
-}; // namespace std
+template// NOLINT
+struct vector { // NOLINT
+  void push_back(bool); // NOLINT
+  void pop_back();  // NOLINT
+};  // NOLINT
+};  // namespace std
 
-class Foo { 
+class Foo {
   std::vector &stack;
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for member 'stack' [readability-identifier-naming]
 public:
   Foo(std::vector &stack)
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
   // CHECK-FIXES: {{^}}  Foo(std::vector &Stack)
   : stack(stack) {
 // CHECK-FIXES: {{^}}  : Stack(Stack) {
@@ -134,4 +127,92 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 &operator=(const A0 &Other) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value; // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A1
+  int GetValue() const { return value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for method 'GetValue'
+  // CHECK-FIXES {{^}}  int getValue() const { return Value; } // A1
+  void SetValue(int Value) { this->value = Value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for method 'SetValue'
+  // CHECK-FIXES {{^}}  void setValue(int Value) { this->Value = Value; } // A1
+  A1 &operator=(const A1 &Other) {
+this->SetValue(Other.GetValue()); // A1
+this->value = Other.value;// A1
+// CHECK-FIXES:  {{^}}this->setValue(Other.getValue()); // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value;// A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES

[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

2020-02-14 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:345
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));

hokein wrote:
> kbobyrev wrote:
> > A tracer message here would be helpful!
> the message now would be the  and under the 
> `FindOccurrencesOutsideFile` span, I think it is clear enough?
Okay, sounds good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74395



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-14 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll:35
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -14, i64 
15)
+  ret  %out

Is there a reason you're not testing for -16, 15 for all of these intrinsics? 
Probably better to test the edge-cases. It's also worth adding some "negative" 
tests for these, where the value should use the reg form instead if the 
immediate is not within the range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74550



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


[PATCH] D74298: Honor -finline-functions and -finline-hint-functions at -O0

2020-02-14 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki abandoned this revision.
davezarzycki added a comment.

I'm abandoning this due to lack of time and the problem being more involved 
than I thought.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74298



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


[PATCH] D74602: Fix standalone build interaction with compiler extension

2020-02-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: Keruspe, hans, Meinersbur.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.

As suggested in https://github.com/llvm/llvm-project/issues/120, don't try to 
generate the extension file from clang, only do the linking step.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74602

Files:
  clang/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -883,26 +883,28 @@
 
 endfunction(add_llvm_pass_plugin)
 
-# Generate X Macro file for extension handling. It provides a
-# HANDLE_EXTENSION(extension_namespace, ExtensionProject) call for each 
extension
-# allowing client code to define HANDLE_EXTENSION to have a specific code be 
run for
-# each extension.
+# process_llvm_pass_plugins([NO_GEN])
+#
+# Correctly set lib dependencies between plugins and tools, based on tools
+# registered with the ENABLE_PLUGINS option.
+#
+# Unless NO_GEN option is set, also generate X Macro file for extension
+# handling. It provides a HANDLE_EXTENSION(extension_namespace, 
ExtensionProject)
+# call for each extension allowing client code to define
+# HANDLE_EXTENSION to have a specific code be run for each extension.
 #
-# Also correctly set lib dependencies between plugins and tools.
 function(process_llvm_pass_plugins)
+  cmake_parse_arguments(ARG
+  "NO_GEN" "" ""
+${ARGN})
+
+  # Add static plugins to each plugin target.
   get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
-  file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"//extension handlers\n")
   foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
 string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(SUBSTRING ${llvm_extension_upper} 0 1 llvm_extension_upper_first)
-string(SUBSTRING ${llvm_extension_lower} 1 -1 llvm_extension_lower_tail)
-string(CONCAT llvm_extension_project ${llvm_extension_upper_first} 
${llvm_extension_lower_tail})
+string(TOLOWER ${llvm_extension} llvm_extension_lower)
 
 if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"HANDLE_EXTENSION(${llvm_extension_project})\n")
-
   get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
   foreach(llvm_plugin_target ${llvm_plugin_targets})
 set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY 
LINK_LIBRARIES ${llvm_extension})
@@ -911,15 +913,32 @@
 else()
   add_llvm_library(${llvm_extension_lower} MODULE 
obj.${llvm_extension_lower})
 endif()
-
   endforeach()
-  file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"#undef HANDLE_EXTENSION\n")
 
-  # only replace if there's an actual change
-  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
-"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp"
-"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
-  file(REMOVE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
+  # Eventually generate the extension header.
+  if(NOT ARG_NO_GEN)
+  file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"//extension handlers\n")
+  foreach(llvm_extension ${LLVM_EXTENSIONS})
+string(TOLOWER ${llvm_extension} llvm_extension_lower)
+
+string(TOUPPER ${llvm_extension} llvm_extension_upper)
+string(SUBSTRING ${llvm_extension_upper} 0 1 
llvm_extension_upper_first)
+string(SUBSTRING ${llvm_extension_lower} 1 -1 
llvm_extension_lower_tail)
+string(CONCAT llvm_extension_project ${llvm_extension_upper_first} 
${llvm_extension_lower_tail})
+
+if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
+  file(APPEND 
"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"HANDLE_EXTENSION(${llvm_extension_project})\n")
+endif()
+
+  endforeach()
+  file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" 
"#undef HANDLE_EXTENSION\n")
+
+  # only replace if there's an actual change
+  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp"
+"${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
+  file(REMOVE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp")
+  endif()
 endfunction()
 
 function(export_executable_symbols target)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -864,7 +864,7 @@
 
 if(CLANG_BUILT_STANDALONE)
   llvm_distribution_add_targets()
-  process_llvm_pass_plugins()
+  process_llvm_pass_plugins(NO_GEN)
 endif()
 

[clang] 2bef1c0 - [OpenMP] Lower taskyield using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via cfe-commits

Author: Roger Ferrer Ibanez
Date: 2020-02-14T11:35:17Z
New Revision: 2bef1c0e5645639bda1807f7df970da97792b0c8

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

LOG: [OpenMP] Lower taskyield using OpenMP IR Builder

This is similar to D69828.

Special codegen for enclosing untied tasks is still done in clang.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/taskyield_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 554d95a256ec..7440434df508 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3295,11 +3295,18 @@ void CGOpenMPRuntime::emitTaskyieldCall(CodeGenFunction 
&CGF,
 SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
-  llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-  llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskyield), Args);
+  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+  if (OMPBuilder) {
+OMPBuilder->CreateTaskyield(CGF.Builder);
+  } else {
+// Build call __kmpc_omp_taskyield(loc, thread_id, 0);
+llvm::Value *Args[] = {
+emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
+CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskyield),
+Args);
+  }
+
   if (auto *Region = 
dyn_cast_or_null(CGF.CapturedStmtInfo))
 Region->emitUntiedSwitch(CGF);
 }

diff  --git a/clang/test/OpenMP/taskyield_codegen.cpp 
b/clang/test/OpenMP/taskyield_codegen.cpp
index d57071f48aa8..ce8a729771d7 100644
--- a/clang/test/OpenMP/taskyield_codegen.cpp
+++ b/clang/test/OpenMP/taskyield_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 
-triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index c1ec28abd34c..d0e9e40370bb 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -171,6 +171,7 @@ class OpenMPIRBuilder {
  Value *IfCondition, Value *NumThreads,
  omp::ProcBindKind ProcBind, bool IsCancellable);
 
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
@@ -181,6 +182,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location where the taskwait directive was encountered.
   void CreateTaskwait(const LocationDescription& Loc);
 
+  /// Generator for '#omp taskyield'
+  ///
+  /// \param Loc The location where the taskyield directive was encountered.
+  void CreateTaskyield(const LocationDescription& Loc);
+
   ///}
 
 
@@ -251,6 +257,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location at which the request originated and is fulfilled.
   void emitTaskwaitImpl(const LocationDescription &Loc);
 
+  /// Generate a taskyield runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskyieldImpl(const LocationDescription &Loc);
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 7d6f29ba2633..e0318ab3c551 1

[PATCH] D70799: [OpenMP] Lower taskyield using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 244611.
rogfer01 added a comment.

ChangeLog:

- Rebase


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

https://reviews.llvm.org/D70799

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/taskyield_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -709,3 +709,20 @@
 return;
   emitTaskwaitImpl(Loc);
 }
+
+void OpenMPIRBuilder::emitTaskyieldImpl(const LocationDescription &Loc) {
+  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Constant *I32Null = ConstantInt::getNullValue(Int32);
+  Value *Args[] = {Ident, getOrCreateThreadID(Ident), I32Null};
+
+  Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_omp_taskyield),
+ Args);
+}
+
+void OpenMPIRBuilder::CreateTaskyield(const LocationDescription &Loc) {
+  if (!updateToLocation(Loc))
+return;
+  emitTaskyieldImpl(Loc);
+}
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -170,6 +170,7 @@
 __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
 __OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
 __OMP_RTL(__kmpc_omp_taskwait, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_omp_taskyield, false, Int32, IdentPtr, Int32, Int32)
 __OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32,
   /* Int */ Int32)
 __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -171,6 +171,7 @@
  Value *IfCondition, Value *NumThreads,
  omp::ProcBindKind ProcBind, bool IsCancellable);
 
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
@@ -181,6 +182,11 @@
   /// \param Loc The location where the taskwait directive was encountered.
   void CreateTaskwait(const LocationDescription& Loc);
 
+  /// Generator for '#omp taskyield'
+  ///
+  /// \param Loc The location where the taskyield directive was encountered.
+  void CreateTaskyield(const LocationDescription& Loc);
+
   ///}
 
 
@@ -251,6 +257,11 @@
   /// \param Loc The location at which the request originated and is fulfilled.
   void emitTaskwaitImpl(const LocationDescription &Loc);
 
+  /// Generate a taskyield runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskyieldImpl(const LocationDescription &Loc);
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
Index: clang/test/OpenMP/taskyield_codegen.cpp
===
--- clang/test/OpenMP/taskyield_codegen.cpp
+++ clang/test/OpenMP/taskyield_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3295,11 +3295,18 @@
 SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
-  llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), g

[PATCH] D70799: [OpenMP] Lower taskyield using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bef1c0e5645: [OpenMP] Lower taskyield using OpenMP IR 
Builder (authored by rogfer01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70799

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/taskyield_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -709,3 +709,20 @@
 return;
   emitTaskwaitImpl(Loc);
 }
+
+void OpenMPIRBuilder::emitTaskyieldImpl(const LocationDescription &Loc) {
+  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Constant *I32Null = ConstantInt::getNullValue(Int32);
+  Value *Args[] = {Ident, getOrCreateThreadID(Ident), I32Null};
+
+  Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_omp_taskyield),
+ Args);
+}
+
+void OpenMPIRBuilder::CreateTaskyield(const LocationDescription &Loc) {
+  if (!updateToLocation(Loc))
+return;
+  emitTaskyieldImpl(Loc);
+}
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -170,6 +170,7 @@
 __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
 __OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
 __OMP_RTL(__kmpc_omp_taskwait, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_omp_taskyield, false, Int32, IdentPtr, Int32, Int32)
 __OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32,
   /* Int */ Int32)
 __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -171,6 +171,7 @@
  Value *IfCondition, Value *NumThreads,
  omp::ProcBindKind ProcBind, bool IsCancellable);
 
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
@@ -181,6 +182,11 @@
   /// \param Loc The location where the taskwait directive was encountered.
   void CreateTaskwait(const LocationDescription& Loc);
 
+  /// Generator for '#omp taskyield'
+  ///
+  /// \param Loc The location where the taskyield directive was encountered.
+  void CreateTaskyield(const LocationDescription& Loc);
+
   ///}
 
 
@@ -251,6 +257,11 @@
   /// \param Loc The location at which the request originated and is fulfilled.
   void emitTaskwaitImpl(const LocationDescription &Loc);
 
+  /// Generate a taskyield runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskyieldImpl(const LocationDescription &Loc);
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
Index: clang/test/OpenMP/taskyield_codegen.cpp
===
--- clang/test/OpenMP/taskyield_codegen.cpp
+++ clang/test/OpenMP/taskyield_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3295,11 +3295,18 @@
 SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;

[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-14 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 244610.
kmclaughlin added a comment.

- Changed 'dl' to 'DL' as suggested by @andwar
- Updated tests to address @sdesmalen's comment (changed all tests to check min 
& max immediate values, plus added some tests where the immediate is out of 
range)


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

https://reviews.llvm.org/D74550

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
@@ -0,0 +1,178 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; INDEX (IMMEDIATES)
+;
+
+define  @index_ii_i8() {
+; CHECK-LABEL: index_ii_i8:
+; CHECK: index z0.b, #-16, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 -16, i8 15)
+  ret  %out
+}
+
+define  @index_ii_i16() {
+; CHECK-LABEL: index_ii_i16:
+; CHECK: index z0.h, #15, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 15, i16 -16)
+  ret  %out
+}
+
+define  @index_ii_i32() {
+; CHECK-LABEL: index_ii_i32:
+; CHECK: index z0.s, #-16, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -16, i32 15)
+  ret  %out
+}
+
+define  @index_ii_i64() {
+; CHECK-LABEL: index_ii_i64:
+; CHECK: index z0.d, #15, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 15, i64 -16)
+  ret  %out
+}
+
+define  @index_ii_range() {
+; CHECK-LABEL: index_ii_range:
+; CHECK: mov w8, #16
+; CHECK-NEXT: mov x9, #-17
+; CHECK-NEXT: index z0.d, x9, x8
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -17, i64 16)
+  ret  %out
+}
+
+;
+; INDEX (IMMEDIATE, SCALAR)
+;
+
+define  @index_ir_i8(i8 %a) {
+; CHECK-LABEL: index_ir_i8:
+; CHECK: index z0.b, #15, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 15, i8 %a)
+  ret  %out
+}
+
+define  @index_ir_i16(i16 %a) {
+; CHECK-LABEL: index_ir_i16:
+; CHECK: index z0.h, #-16, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 -16, i16 %a)
+  ret  %out
+}
+
+define  @index_ir_i32(i32 %a) {
+; CHECK-LABEL: index_ir_i32:
+; CHECK: index z0.s, #15, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 15, i32 %a)
+  ret  %out
+}
+
+define  @index_ir_i64(i64 %a) {
+; CHECK-LABEL: index_ir_i64:
+; CHECK: index z0.d, #-16, x0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -16, i64 %a)
+  ret  %out
+}
+
+define  @index_ir_range(i32 %a) {
+; CHECK-LABEL: index_ir_range:
+; CHECK: mov w8, #-17
+; CHECK: index z0.s, w8, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -17, i32 %a)
+  ret  %out
+}
+
+;
+; INDEX (SCALAR, IMMEDIATE)
+;
+
+define  @index_ri_i8(i8 %a) {
+; CHECK-LABEL: index_ri_i8:
+; CHECK: index z0.b, w0, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 -16)
+  ret  %out
+}
+
+define  @index_ri_i16(i16 %a) {
+; CHECK-LABEL: index_ri_i16:
+; CHECK: index z0.h, w0, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 15)
+  ret  %out
+}
+
+define  @index_ri_i32(i32 %a) {
+; CHECK-LABEL: index_ri_i32:
+; CHECK: index z0.s, w0, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 -16)
+  ret  %out
+}
+
+define  @index_ri_i64(i64 %a) {
+; CHECK-LABEL: index_ri_i64:
+; CHECK: index z0.d, x0, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 15)
+  ret  %out
+}
+
+define  @index_ri_range(i16 %a) {
+; CHECK-LABEL: index_ri_range:
+; CHECK: mov w8, #16
+; CHECK: index z0.h, w0, w8
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 16)
+  ret  %out
+}
+
+;
+; INDEX (SCALARS)
+;
+
+define  @index_rr_i8(i8 %a, i8 %b) {
+; CHECK-LABEL: index_rr_i8:
+; CHECK: index z0.b, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 %b)
+  ret  %out
+}
+
+define  @index_rr_i16(i16 %a, i16 %b) {
+; CHECK-LABEL: index_rr_i16:
+; CHECK: index z0.h, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 %b)
+  ret  %out
+}
+
+define  @index_rr_i32(i32 %a, i32 %b) {
+; CHECK-LABEL: index_rr_i32:
+; CHECK: index z0.s, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 %b)
+  ret  %out
+}
+
+define  @index_rr_i64(i64 %a, i64 %b) {
+; CHECK-LABEL: index_rr_i64:
+; CHECK: index z0.d, x0, x1
+; CHECK-NEXT: ret
+  %out = c

[clang-tools-extra] c45fb35 - [clang][DeclPrinter] Implement visitors for {TemplateType,NonTypeTemplate}Parms

2020-02-14 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-14T13:20:34+01:00
New Revision: c45fb35b5e0b45357a9bfae500ec5403545dbc77

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

LOG: [clang][DeclPrinter] Implement visitors for 
{TemplateType,NonTypeTemplate}Parms

Reviewers: sammccall, hokein

Subscribers: kristof.beyls, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang/lib/AST/DeclPrinter.cpp
clang/unittests/AST/DeclPrinterTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index be4b37c8f453..fa091b2a2503 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -215,8 +215,7 @@ TEST_F(TargetDeclTest, NestedNameSpecifier) {
 template 
 int x = [[T::]]y;
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("NestedNameSpecifierLoc", "");
+  EXPECT_DECLS("NestedNameSpecifierLoc", "typename T");
 
   Code = R"cpp(
 namespace a { int x; }
@@ -256,8 +255,7 @@ TEST_F(TargetDeclTest, Types) {
 template
 void foo() { [[T]] x; }
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("TemplateTypeParmTypeLoc", "");
+  EXPECT_DECLS("TemplateTypeParmTypeLoc", "class T");
   Flags.clear();
 
   // FIXME: Auto-completion in a template requires disabling delayed template
@@ -290,8 +288,7 @@ TEST_F(TargetDeclTest, Types) {
   static const int size = sizeof...([[E]]);
 };
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("SizeOfPackExpr", "");
+  EXPECT_DECLS("SizeOfPackExpr", "typename ...E");
 
   Code = R"cpp(
 template 

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 4cedcbed0644..23dc9e562d4f 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -105,6 +105,8 @@ namespace {
 void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
 void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
 void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
+void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP);
+void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *NTTP);
 
 void printTemplateParameters(const TemplateParameterList *Params,
  bool OmitTemplateKW = false);
@@ -1051,37 +1053,10 @@ void DeclPrinter::printTemplateParameters(const 
TemplateParameterList *Params,
 else
   NeedComma = true;
 
-if (auto TTP = dyn_cast(Param)) {
-
-  if (const TypeConstraint *TC = TTP->getTypeConstraint())
-TC->print(Out, Policy);
-  else if (TTP->wasDeclaredWithTypename())
-Out << "typename";
-  else
-Out << "class";
-
-  if (TTP->isParameterPack())
-Out << " ...";
-  else if (!TTP->getName().empty())
-Out << ' ';
-
-  Out << *TTP;
-
-  if (TTP->hasDefaultArgument()) {
-Out << " = ";
-Out << TTP->getDefaultArgument().getAsString(Policy);
-  };
+if (const auto *TTP = dyn_cast(Param)) {
+  VisitTemplateTypeParmDecl(TTP);
 } else if (auto NTTP = dyn_cast(Param)) {
-  StringRef Name;
-  if (IdentifierInfo *II = NTTP->getIdentifier())
-Name = II->getName();
-  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
-
-  if (NTTP->hasDefaultArgument()) {
-Out << " = ";
-NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy,
-Indentation);
-  }
+  VisitNonTypeTemplateParmDecl(NTTP);
 } else if (auto TTPD = dyn_cast(Param)) {
   VisitTemplateDecl(TTPD);
   // FIXME: print the default argument, if present.
@@ -1705,3 +1680,36 @@ void 
DeclPrinter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
   D->getInit()->printPretty(Out, nullptr, Policy, Indentation);
 }
 
+void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) {
+  if (const TypeConstraint *TC = TTP->getTypeConstraint())
+TC->print(Out, Policy);
+  else if (TTP->wasDeclaredWithTypename())
+Out << "typename";
+  else
+Out << "class";
+
+  if (TTP->isParameterPack())
+Out << " ...";
+  else if (!TTP->getName().empty())
+Out << ' ';
+
+  Out << *TTP;
+
+  if (TTP->hasDefaultArgument()) {
+Out << " = ";
+Out << TTP->getDefaultArgument().getAsString(Policy);
+  }
+}
+
+void DeclPrinter::VisitNonTypeTemplateParmDecl(
+const NonTypeTemplateParmDecl 

[clang-tools-extra] 84240e0 - [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-14 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-14T13:20:34+01:00
New Revision: 84240e0db8ab85b56df11e6cee8fef5ac7ee8c33

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

LOG: [clang][Index] Introduce a TemplateParm SymbolKind

Summary:
Currently template parameters has symbolkind `Unknown`. This patch
introduces a new kind `TemplateParm` for templatetemplate, templatetype and
nontypetemplate parameters.

Also adds tests in clangd hover feature.

Reviewers: sammccall

Subscribers: kristof.beyls, ilya-biryukov, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang/include/clang/Index/IndexSymbol.h
clang/lib/Index/IndexSymbol.cpp
clang/tools/libclang/CXIndexDataConsumer.cpp
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 52c1ceef7425..f7c6f105cb9a 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -108,6 +108,7 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind 
Kind) {
 return CompletionItemKind::Function;
   case SK::Variable:
   case SK::Parameter:
+  case SK::NonTypeTemplateParm:
 return CompletionItemKind::Variable;
   case SK::Field:
 return CompletionItemKind::Field;
@@ -125,6 +126,9 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind 
Kind) {
 return CompletionItemKind::Property;
   case SK::Constructor:
 return CompletionItemKind::Constructor;
+  case SK::TemplateTypeParm:
+  case SK::TemplateTemplateParm:
+return CompletionItemKind::TypeParameter;
   }
   llvm_unreachable("Unhandled clang::index::SymbolKind.");
 }

diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index ae4c441a73b5..750df50c4777 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -115,15 +115,6 @@ std::string printDefinition(const Decl *D) {
   return Definition;
 }
 
-void printParams(llvm::raw_ostream &OS,
- const std::vector &Params) {
-  for (size_t I = 0, E = Params.size(); I != E; ++I) {
-if (I)
-  OS << ", ";
-OS << Params.at(I);
-  }
-}
-
 std::string printType(QualType QT, const PrintingPolicy &Policy) {
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in 
them.
@@ -133,6 +124,43 @@ std::string printType(QualType QT, const PrintingPolicy 
&Policy) {
   return QT.getAsString(Policy);
 }
 
+std::string printType(const TemplateTypeParmDecl *TTP) {
+  std::string Res = TTP->wasDeclaredWithTypename() ? "typename" : "class";
+  if (TTP->isParameterPack())
+Res += "...";
+  return Res;
+}
+
+std::string printType(const NonTypeTemplateParmDecl *NTTP,
+  const PrintingPolicy &PP) {
+  std::string Res = printType(NTTP->getType(), PP);
+  if (NTTP->isParameterPack())
+Res += "...";
+  return Res;
+}
+
+std::string printType(const TemplateTemplateParmDecl *TTP,
+  const PrintingPolicy &PP) {
+  std::string Res;
+  llvm::raw_string_ostream OS(Res);
+  OS << "template <";
+  llvm::StringRef Sep = "";
+  for (const Decl *Param : *TTP->getTemplateParameters()) {
+OS << Sep;
+Sep = ", ";
+if (const auto *TTP = dyn_cast(Param))
+  OS << printType(TTP);
+else if (const auto *NTTP = dyn_cast(Param))
+  OS << printType(NTTP, PP);
+else if (const auto *TTPD = dyn_cast(Param))
+  OS << printType(TTPD, PP);
+  }
+  // FIXME: TemplateTemplateParameter doesn't store the info on whether this
+  // param was a "typename" or "class".
+  OS << "> class";
+  return OS.str();
+}
+
 std::vector
 fetchTemplateParameters(const TemplateParameterList *Params,
 const PrintingPolicy &PP) {
@@ -142,38 +170,30 @@ fetchTemplateParameters(const TemplateParameterList 
*Params,
   for (const Decl *Param : *Params) {
 HoverInfo::Param P;
 if (const auto *TTP = dyn_cast(Param)) {
-  P.Type = TTP->wasDeclaredWithTypename() ? "typename" : "class";
-  if (TTP->isParameterPack())
-*P.Type += "...";
+  P.Type = printType(TTP);
 
   if (!TTP->getName().empty())
 P.Name = TTP->getNameAsString();
+
   if (TTP->hasDefaultArgument())
 P.Default = TTP->getDefaultArgument().getAsString(PP);
 } else if (const auto *NTTP = dyn_cast(Param)) {
+  P.Type = printType(NTTP, PP);
+
   if (Ide

[PATCH] D73693: [clang][DeclPrinter] Implement visitors for {TemplateType,NonTypeTemplate}Parms

2020-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc45fb35b5e0b: [clang][DeclPrinter] Implement visitors for 
{TemplateType,NonTypeTemplate}Parms (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73693

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/unittests/AST/DeclPrinterTest.cpp

Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -22,6 +22,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -1273,6 +1274,15 @@
 // Should be: with semicolon
 }
 
+TEST(DeclPrinter, TestTemplateArgumentList16) {
+  llvm::StringLiteral Code = "template struct Z {};";
+  ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "T1", "typename T1"));
+  ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "T2", "typename T2 = bool"));
+  ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "NT1", "int NT1"));
+  ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "NT2", "int NT2 = 5"));
+}
+
 TEST(DeclPrinter, TestStaticAssert1) {
   ASSERT_TRUE(PrintedDeclCXX1ZMatches(
 "static_assert(true);",
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -105,6 +105,8 @@
 void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
 void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
 void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
+void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP);
+void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *NTTP);
 
 void printTemplateParameters(const TemplateParameterList *Params,
  bool OmitTemplateKW = false);
@@ -1051,37 +1053,10 @@
 else
   NeedComma = true;
 
-if (auto TTP = dyn_cast(Param)) {
-
-  if (const TypeConstraint *TC = TTP->getTypeConstraint())
-TC->print(Out, Policy);
-  else if (TTP->wasDeclaredWithTypename())
-Out << "typename";
-  else
-Out << "class";
-
-  if (TTP->isParameterPack())
-Out << " ...";
-  else if (!TTP->getName().empty())
-Out << ' ';
-
-  Out << *TTP;
-
-  if (TTP->hasDefaultArgument()) {
-Out << " = ";
-Out << TTP->getDefaultArgument().getAsString(Policy);
-  };
+if (const auto *TTP = dyn_cast(Param)) {
+  VisitTemplateTypeParmDecl(TTP);
 } else if (auto NTTP = dyn_cast(Param)) {
-  StringRef Name;
-  if (IdentifierInfo *II = NTTP->getIdentifier())
-Name = II->getName();
-  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
-
-  if (NTTP->hasDefaultArgument()) {
-Out << " = ";
-NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy,
-Indentation);
-  }
+  VisitNonTypeTemplateParmDecl(NTTP);
 } else if (auto TTPD = dyn_cast(Param)) {
   VisitTemplateDecl(TTPD);
   // FIXME: print the default argument, if present.
@@ -1705,3 +1680,36 @@
   D->getInit()->printPretty(Out, nullptr, Policy, Indentation);
 }
 
+void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) {
+  if (const TypeConstraint *TC = TTP->getTypeConstraint())
+TC->print(Out, Policy);
+  else if (TTP->wasDeclaredWithTypename())
+Out << "typename";
+  else
+Out << "class";
+
+  if (TTP->isParameterPack())
+Out << " ...";
+  else if (!TTP->getName().empty())
+Out << ' ';
+
+  Out << *TTP;
+
+  if (TTP->hasDefaultArgument()) {
+Out << " = ";
+Out << TTP->getDefaultArgument().getAsString(Policy);
+  }
+}
+
+void DeclPrinter::VisitNonTypeTemplateParmDecl(
+const NonTypeTemplateParmDecl *NTTP) {
+  StringRef Name;
+  if (IdentifierInfo *II = NTTP->getIdentifier())
+Name = II->getName();
+  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
+
+  if (NTTP->hasDefaultArgument()) {
+Out << " = ";
+NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy, Indentation);
+  }
+}
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -215,8 +215,7 @@
 template 
 int x = [[T::]]y;
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("NestedNameSpecifierLoc", "");
+  EXPECT_DECLS("NestedNameSpecifierLoc", "typename T");
 
   Code = R"cpp(
 namespace a { int x; }
@@ -256

[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 244619.
kadircet marked an inline comment as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/Index/IndexSymbol.h
  clang/lib/Index/IndexSymbol.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -249,8 +249,13 @@
   Index->Symbols.clear();
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
   EXPECT_THAT(Index->Symbols,
-  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I")),
-Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
+  AllOf(Contains(AllOf(QName("Foo::T"),
+   Kind(SymbolKind::TemplateTypeParm))),
+Contains(AllOf(QName("Foo::I"),
+   Kind(SymbolKind::NonTypeTemplateParm))),
+Contains(AllOf(QName("Foo::C"),
+   Kind(SymbolKind::TemplateTemplateParm))),
+Contains(QName("Foo::NoRef";
 }
 
 TEST(IndexTest, UsingDecls) {
Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -1245,6 +1245,9 @@
   case SymbolKind::Macro:
   case SymbolKind::ClassProperty:
   case SymbolKind::Using:
+  case SymbolKind::TemplateTypeParm:
+  case SymbolKind::TemplateTemplateParm:
+  case SymbolKind::NonTypeTemplateParm:
 return CXIdxEntity_Unexposed;
 
   case SymbolKind::Enum: return CXIdxEntity_Enum;
Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -357,6 +357,15 @@
 case Decl::VarTemplate:
   llvm_unreachable("variables handled before");
   break;
+case Decl::TemplateTypeParm:
+  Info.Kind = SymbolKind::TemplateTypeParm;
+  break;
+case Decl::TemplateTemplateParm:
+  Info.Kind = SymbolKind::TemplateTemplateParm;
+  break;
+case Decl::NonTypeTemplateParm:
+  Info.Kind = SymbolKind::NonTypeTemplateParm;
+  break;
 // Other decls get the 'unknown' kind.
 default:
   break;
@@ -517,6 +526,9 @@
   case SymbolKind::ConversionFunction: return "conversion-func";
   case SymbolKind::Parameter: return "param";
   case SymbolKind::Using: return "using";
+  case SymbolKind::TemplateTypeParm: return "template-type-param";
+  case SymbolKind::TemplateTemplateParm: return "template-template-param";
+  case SymbolKind::NonTypeTemplateParm: return "non-type-template-param";
   }
   llvm_unreachable("invalid symbol kind");
 }
Index: clang/include/clang/Index/IndexSymbol.h
===
--- clang/include/clang/Index/IndexSymbol.h
+++ clang/include/clang/Index/IndexSymbol.h
@@ -54,6 +54,9 @@
 
   Parameter,
   Using,
+  TemplateTypeParm,
+  TemplateTemplateParm,
+  NonTypeTemplateParm,
 };
 
 enum class SymbolLanguage : uint8_t {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -573,6 +573,42 @@
  // pattern.
  HI.Documentation = "comment from primary";
}},
+  {// Template Type Parameter
+   R"cpp(
+  template  void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::SymbolKind::TemplateTypeParm;
+ HI.NamespaceScope = "";
+ HI.Definition = "typename T = int";
+ HI.LocalScope = "foo::";
+ HI.Type = "typename";
+   }},
+  {// TemplateTemplate Type Parameter
+   R"cpp(
+  template  class [[^T]]> void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::SymbolKind::TemplateTemplateParm;
+ HI.NamespaceScope = "";
+ HI.Definition = "template  class T";
+ HI.LocalScope = "foo::";
+ HI.Type = "template  class";
+   }},
+  {// NonType Template Parameter
+   R"cpp(
+  template  void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::SymbolKind::NonTypeTemplateParm;
+ HI.Names

[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 3 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:98
+  case SK::TemplateTypeParm:
+  case SK::TemplateTemplateParm:
 return CompletionItemKind::Class;

hokein wrote:
> I think these two should belong to `CompletionItemKind::TypeParameter`?
right, moved the ones below but forgot to move these :D thanks!



Comment at: clang/lib/Index/IndexSymbol.cpp:360
   break;
+case Decl::TemplateTypeParm:
+  Info.Kind = SymbolKind::TemplateTypeParm;

hokein wrote:
> nit: could we move these newly-added lines above the `case 
> Decl::ClassTemplatePartialSpecialization:`. I think we usually put the 
> `llvm_unreachable` cases at the end of switch statement..
yes but this one is specially, there's also a default label below.

Also the unreachable ones are for making sure certain `valid` types don't 
arrive in here rather than checking for `invalid` types are passed.
We usually put the unreachable to the end if it is protecting against invalid 
usages, I believe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696



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


[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84240e0db8ab: [clang][Index] Introduce a TemplateParm 
SymbolKind (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/Index/IndexSymbol.h
  clang/lib/Index/IndexSymbol.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -249,8 +249,13 @@
   Index->Symbols.clear();
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
   EXPECT_THAT(Index->Symbols,
-  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I")),
-Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
+  AllOf(Contains(AllOf(QName("Foo::T"),
+   Kind(SymbolKind::TemplateTypeParm))),
+Contains(AllOf(QName("Foo::I"),
+   Kind(SymbolKind::NonTypeTemplateParm))),
+Contains(AllOf(QName("Foo::C"),
+   Kind(SymbolKind::TemplateTemplateParm))),
+Contains(QName("Foo::NoRef";
 }
 
 TEST(IndexTest, UsingDecls) {
Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -1245,6 +1245,9 @@
   case SymbolKind::Macro:
   case SymbolKind::ClassProperty:
   case SymbolKind::Using:
+  case SymbolKind::TemplateTypeParm:
+  case SymbolKind::TemplateTemplateParm:
+  case SymbolKind::NonTypeTemplateParm:
 return CXIdxEntity_Unexposed;
 
   case SymbolKind::Enum: return CXIdxEntity_Enum;
Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -357,6 +357,15 @@
 case Decl::VarTemplate:
   llvm_unreachable("variables handled before");
   break;
+case Decl::TemplateTypeParm:
+  Info.Kind = SymbolKind::TemplateTypeParm;
+  break;
+case Decl::TemplateTemplateParm:
+  Info.Kind = SymbolKind::TemplateTemplateParm;
+  break;
+case Decl::NonTypeTemplateParm:
+  Info.Kind = SymbolKind::NonTypeTemplateParm;
+  break;
 // Other decls get the 'unknown' kind.
 default:
   break;
@@ -517,6 +526,9 @@
   case SymbolKind::ConversionFunction: return "conversion-func";
   case SymbolKind::Parameter: return "param";
   case SymbolKind::Using: return "using";
+  case SymbolKind::TemplateTypeParm: return "template-type-param";
+  case SymbolKind::TemplateTemplateParm: return "template-template-param";
+  case SymbolKind::NonTypeTemplateParm: return "non-type-template-param";
   }
   llvm_unreachable("invalid symbol kind");
 }
Index: clang/include/clang/Index/IndexSymbol.h
===
--- clang/include/clang/Index/IndexSymbol.h
+++ clang/include/clang/Index/IndexSymbol.h
@@ -54,6 +54,9 @@
 
   Parameter,
   Using,
+  TemplateTypeParm,
+  TemplateTemplateParm,
+  NonTypeTemplateParm,
 };
 
 enum class SymbolLanguage : uint8_t {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -573,6 +573,42 @@
  // pattern.
  HI.Documentation = "comment from primary";
}},
+  {// Template Type Parameter
+   R"cpp(
+  template  void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::SymbolKind::TemplateTypeParm;
+ HI.NamespaceScope = "";
+ HI.Definition = "typename T = int";
+ HI.LocalScope = "foo::";
+ HI.Type = "typename";
+   }},
+  {// TemplateTemplate Type Parameter
+   R"cpp(
+  template  class [[^T]]> void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::SymbolKind::TemplateTemplateParm;
+ HI.NamespaceScope = "";
+ HI.Definition = "template  class T";
+ HI.LocalScope = "foo::";
+ HI.Type = "template  class";
+   }},
+  {// NonType Template Parameter
+   R"cpp(
+  template  void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T";
+ HI.Kind = index::Symbo

[PATCH] D74555: [clangd] Add a flag for setting isIncomplete flag true in all responses

2020-02-14 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 244618.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Address the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74555

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/always-incomplete.test

Index: clang-tools-extra/clangd/test/always-incomplete.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/always-incomplete.test
@@ -0,0 +1,39 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"initializationOptions":{"alwaysIncomplete": true},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct S { int a; };\nint main() {\nS().\n}"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":4}}}
+#  CHECK:  "id": 1
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": true,
+# CHECK-NEXT:"items": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "a",
+# CHECK-NEXT:  "insertText": "a",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 5,
+# CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
+# CHECK-NEXT:  "sortText": "{{.*}}a"
+# CHECK-NEXT:  "textEdit": {
+# CHECK-NEXT:"newText": "a",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 2
+# CHECK-NEXT:  }
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 2
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -474,6 +474,10 @@
 
   /// Clients supports show file status for textDocument/clangd.fileStatus.
   bool FileStatus = false;
+
+  /// Always sets code completion list's isIncomplete to true. This helps to
+  /// utilize Clangd code completion ranking to a higher degree.
+  bool AlwaysIncomplete = false;
 };
 bool fromJSON(const llvm::json::Value &, InitializationOptions &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -993,6 +993,7 @@
   O.map("compilationDatabasePath", Opts.compilationDatabasePath);
   O.map("fallbackFlags", Opts.fallbackFlags);
   O.map("clangdFileStatus", Opts.FileStatus);
+  O.map("alwaysIncomplete", Opts.AlwaysIncomplete);
   return true;
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -145,6 +145,9 @@
 /// Enable cross-file rename feature.
 bool CrossFileRename = false;
 
+/// Always set isIncomplete to true when returning CompletionList.
+bool AlwaysIncomplete = false;
+
 /// Returns true if the tweak should be enabled.
 std::function TweakFilter = [](const Tweak &T) {
   return !T.hidden(); // only enable non-hidden tweaks.
@@ -295,7 +298,7 @@
 
   /// Get all document links in a file.
   void documentLinks(PathRef File, Callback> CB);
- 
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -506,6 +506,9 @@
   }
   applyConfiguration(Params.initializationOptions.ConfigSettings);
 
+  ClangdServerOpts.AlwaysIncomplete =
+  Params.initializationOptions.AlwaysIncomplete;
+
   CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets;
   CCOpts.IncludeFixIts = Params.capabilities.CompletionFixes;
   if (!CCOpts.BundleOverloads.hasValue())
@@ -976,7 +979,11 @@
  if (!List)
return Reply(List.takeError());
 

[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-14 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Make it more convinient for the clients to select completion items by
providing a set of default characters (punctuation).

Related issue: https://github.com/clangd/clangd/issues/284


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74606

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\""},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\""},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 244635.
CarolineConcatto added a comment.

- [Clang]Rename flag and update the tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/clang-driver-2-frontend01.f90
  clang/test/Driver/flang/flang-driver-2-frontend01.f90
  clang/test/Driver/flang/flang-driver-2-frontend02.f90

Index: clang/test/Driver/flang/flang-driver-2-frontend02.f90
===
--- /dev/null
+++ clang/test/Driver/flang/flang-driver-2-frontend02.f90
@@ -0,0 +1,14 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! The flag -fortran-fe is passed by the driver.
+! The flag has preference over the predefined frontend "flang".
+! Therefore the driver invokes the FE given by the flag.
+
+! Copy clang to two temporary file.
+! t1 is the driver name. t2 is the frontend name
+! RUN: cp %clang %t1
+! RUN: cp %clang %t2
+! RUN: %t1 --driver-mode=flang -fortran-fe %basename_t.tmp2 -### %s 2>&1 | FileCheck --check-prefixes=ALL %s
+
+! The invocations should begin with .tmp2 -fc1.
+! ALL-LABEL: "{{[^"]*}}flang-driver-2-frontend02.f90.tmp2" "-fc1"
Index: clang/test/Driver/flang/flang-driver-2-frontend01.f90
===
--- /dev/null
+++ clang/test/Driver/flang/flang-driver-2-frontend01.f90
@@ -0,0 +1,11 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! The flag -fortran-fe is NOT passed by the driver.
+! Therefore, it uses the predefined frontend "flang".
+
+! Copy clang to a temporary file to be the driver name
+! RUN: cp %clang %t1
+! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL %s
+
+! The invocations should begin with .tmp1 -fc1.
+! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
Index: clang/test/Driver/flang/clang-driver-2-frontend01.f90
===
--- /dev/null
+++ clang/test/Driver/flang/clang-driver-2-frontend01.f90
@@ -0,0 +1,13 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! The flag -fortran-fe is passed by the driver.
+! The flag has preference over "flang" frontend.
+! Therefore the driver invokes the FE given by the flag.
+
+! Copy clang to two temporary file
+! t1 is the new frontend name.
+! RUN: cp %clang %t1
+! RUN: %clang --driver-mode=flang -fortran-fe %basename_t.tmp1 -### %s 2>&1 | FileCheck --check-prefixes=ALL %s
+
+! The invocations should begin with .tmp1 -fc1.
+! ALL-LABEL: "{{[^"]*}}clang-driver-2-frontend01.f90.tmp1" "-fc1"
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -11,7 +11,6 @@
 #include "CommonArgs.h"
 
 #include "clang/Driver/Options.h"
-
 #include 
 
 using namespace clang::driver;
@@ -69,7 +68,13 @@
   CmdArgs.push_back(Input.getFilename());
 
   const auto& D = C.getDriver();
-  const char* Exec = Args.MakeArgString(D.GetProgramPath("flang", TC));
+  const std::string &customFortranName = D.getGenericFortranFE();
+  const char *FortranName;
+  if (!customFortranName.empty())
+FortranName = customFortranName.c_str();
+  else FortranName = "flang";
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(FortranName));
   C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -128,8 +128,8 @@
   CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
   CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false),
   CCLogDiagnostics(false), CCGenDiagnostics(false),
-  TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), GenReproducer(false),
+  TargetTriple(TargetTriple), CCCGenericGCCName(""), GenericFortranFE(""),
+  Saver(Alloc), CheckInputsExist(true), GenReproducer(false),
   SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -1088,6 +1088,10 @@
 .Default(SaveTempsCwd);
   }
 
+  // Extract -ffc args.
+  if (const Arg *A = Args.getLastArg(options::OPT_fortran_fe))
+GenericFortranFE = A->getValue();
+
   setLTOMode(Args);
 
   // Process -fembed-bitcode= flags.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -264,6 +264,8 @@
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">,

[clang] 9816e72 - [Driver][RISCV] Add RedHat Linux RISC-V triple

2020-02-14 Thread Luís Marques via cfe-commits

Author: Luís Marques
Date: 2020-02-14T13:46:26Z
New Revision: 9816e726e747d72e0c5ac92aa20e652031a10448

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

LOG: [Driver][RISCV] Add RedHat Linux RISC-V triple

Summary: Adds the RedHat Linux triple to the list of 64-bit RISC-V triples.
Without this the gcc libraries wouldn't be found by clang on a redhat/fedora
system, as the search list included `/usr/lib/gcc/riscv64-redhat-linux-gnu`
but the correct path didn't include the `-gnu` suffix.

Reviewers: lenary, asb, dlj
Reviewed By: lenary
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74399

Added: 

clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtbegin.o

clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtend.o

clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crti.o

clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtn.o
clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib64/crt1.o

Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index bc67a7e0cdf9..dadbfa288a03 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2090,6 +2090,7 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
"riscv64-unknown-elf",
+   "riscv64-redhat-linux",
"riscv64-suse-linux"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};

diff  --git 
a/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtbegin.o
 
b/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtbegin.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtend.o
 
b/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtend.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crti.o
 
b/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crti.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtn.o
 
b/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtn.o
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib64/crt1.o 
b/clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib64/crt1.o
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 51227550b528..ec539522c25d 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -769,6 +769,21 @@
 // CHECK-FEDORA-21-AARCH64: 
"{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0{{/|}}crtend.o"
 // CHECK-FEDORA-21-AARCH64: 
"{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0/../../../../lib64{{/|}}crtn.o"
 //
+// Check Fedora 31 on riscv64.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=riscv64-redhat-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/fedora_31_riscv64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FEDORA-31-RISCV64 %s
+// CHECK-FEDORA-31-RISCV64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64{{/|}}crt1.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crti.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtbegin.o"
+// CHECK-FEDORA-31-RISCV64: "-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9"
+// CHECK-FEDORA-31-RISCV64: 
"-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtend.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtn.o"
+//
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-unknown-linux-gnueabi -rtlib=platform \
 // RUN: --gcc-toolchain="" \



_

[PATCH] D74399: [Driver][RISCV] Add RedHat Linux RISC-V triple

2020-02-14 Thread Luís Marques via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9816e726e747: [Driver][RISCV] Add RedHat Linux RISC-V triple 
(authored by luismarques).
Herald added a subscriber: jrtc27.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74399

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  
clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtbegin.o
  
clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtend.o
  
clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crti.o
  
clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib/gcc/riscv64-redhat-linux/9/crtn.o
  clang/test/Driver/Inputs/fedora_31_riscv64_tree/usr/lib64/crt1.o
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -769,6 +769,21 @@
 // CHECK-FEDORA-21-AARCH64: 
"{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0{{/|}}crtend.o"
 // CHECK-FEDORA-21-AARCH64: 
"{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0/../../../../lib64{{/|}}crtn.o"
 //
+// Check Fedora 31 on riscv64.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=riscv64-redhat-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/fedora_31_riscv64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FEDORA-31-RISCV64 %s
+// CHECK-FEDORA-31-RISCV64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64{{/|}}crt1.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crti.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtbegin.o"
+// CHECK-FEDORA-31-RISCV64: "-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9"
+// CHECK-FEDORA-31-RISCV64: 
"-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtend.o"
+// CHECK-FEDORA-31-RISCV64: 
"{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtn.o"
+//
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-unknown-linux-gnueabi -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2090,6 +2090,7 @@
   static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
"riscv64-unknown-elf",
+   "riscv64-redhat-linux",
"riscv64-suse-linux"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -769,6 +769,21 @@
 // CHECK-FEDORA-21-AARCH64: "{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0{{/|}}crtend.o"
 // CHECK-FEDORA-21-AARCH64: "{{.*}}/usr/lib/gcc/aarch64-redhat-linux/4.9.0/../../../../lib64{{/|}}crtn.o"
 //
+// Check Fedora 31 on riscv64.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=riscv64-redhat-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/fedora_31_riscv64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FEDORA-31-RISCV64 %s
+// CHECK-FEDORA-31-RISCV64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64{{/|}}crt1.o"
+// CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crti.o"
+// CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtbegin.o"
+// CHECK-FEDORA-31-RISCV64: "-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9"
+// CHECK-FEDORA-31-RISCV64: "-L[[SYSROOT]]/usr/lib/gcc/riscv64-redhat-linux/9/../../../../lib64"
+// CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtend.o"
+// CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|}}crtn.o"
+//
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-unknown-linux-gnueabi -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2090,6 +2090,7 @@
   static const char *const RISCV64Triple

[PATCH] D74609: [clangd] Update the CompletionItemKind.

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fix some FIXMEs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74609

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), 
Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,19 +101,17 @@
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // FIXME(ioeric): this should probably be an operator. This should be fixed
-  // when `Operator` is support type in the protocol.
-  case SK::ConversionFunction:
 return CompletionItemKind::Function;
+  case SK::ConversionFunction:
+return CompletionItemKind::Operator;
   case SK::Variable:
   case SK::Parameter:
   case SK::NonTypeTemplateParm:
 return CompletionItemKind::Variable;
   case SK::Field:
 return CompletionItemKind::Field;
-  // FIXME(ioeric): use LSP enum constant when it is supported in the protocol.
   case SK::EnumConstant:
-return CompletionItemKind::Value;
+return CompletionItemKind::EnumMember;
   case SK::InstanceMethod:
   case SK::ClassMethod:
   case SK::StaticMethod:


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,19 +101,17 @@
   case SK::Using

[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, ilya-biryukov, 
kristof.beyls.
Herald added a project: clang.

We are missing the default parmeter arguments when IndexFunctionLocals
is true.

Fixes https://github.com/clangd/clangd/issues/285.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultTemplateArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,9 +90,16 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
+IndexDefaultParmeterArgument(Parm, Parent);
 if (auto *FD = dyn_cast(DC)) {
   if (IndexCtx.shouldIndexParametersInDeclarations() ||
   FD->isThisDeclarationADefinition())
@@ -106,7 +113,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +124,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultTemplateArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,9 +90,16 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNes

[PATCH] D74609: [clangd] Update the CompletionItemKind.

2020-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:106
+  case SK::ConversionFunction:
+return CompletionItemKind::Operator;
   case SK::Variable:

I believe `function` still captures the intend better here, as you can only see 
the completion if you are literally completing for `Foo.operator X()` (btw, I 
am not even sure if we show completions for those, we might have another bug 
around this one).

So I would keep it the same, but up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74609



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


[PATCH] D69869: [clang-tools-extra] fix the check for if '-latomic' is necessary

2020-02-14 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

Whether or not GCC behaves the way it should behave regarding atomics, this 
seems like a sensible patch to make things work given the current situation.
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69869



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


[clang-tools-extra] 1d40c41 - [clang-tools-extra] fix the check for if '-latomic' is necessary

2020-02-14 Thread Luís Marques via cfe-commits

Author: Gokturk Yuksek
Date: 2020-02-14T14:16:10Z
New Revision: 1d40c4150630729a9c1ce5119a8027dac93a5b2d

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

LOG: [clang-tools-extra] fix the check for if '-latomic' is necessary

Summary:
The CheckAtomic module performs two tests to determine if passing
'-latomic' to the linker is required: one for 64-bit atomics, and
another for non-64-bit atomics. clangd only uses the result from
HAVE_CXX_ATOMICS64_WITHOUT_LIB. This is incomplete because there are
uses of non-64-bit atomics in the code, such as the ReplyOnce::Replied
of type std::atomic defined in clangd/ClangdLSPServer.cpp.

Fix by also checking for the result of HAVE_CXX_ATOMICS_WITHOUT_LIB.

See also: https://reviews.llvm.org/D68964

Reviewers: ilya-biryukov, nridge, kadircet, beanz, compnerd, luismarques
Reviewed By: luismarques
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69869

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index e3eccb50a496..fc5a07e69e9d 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CLANG_BUILT_STANDALONE)
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 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.

Thanks for your patience while I thought about this more. I think the direction 
makes sense, so this LGTM with some extra test cases.




Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.

I'd like a few more test cases:
```
// Test that a non-prototyped definition with no preceding prototype whines 
about lacking a preceding prototype
void fooN() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}

// Test that an existing declaration with no prototype still warns that a 
corresponding definition with a type list is still not preceded by a prototype.
void fooN1(); // expected-warning {{this function declaration is not a 
prototype}}
void fooN1(void) {} // expected-warning {{this old-style function definition is 
not preceded by a prototype}}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[PATCH] D69869: [clang-tools-extra] fix the check for if '-latomic' is necessary

2020-02-14 Thread Luís Marques via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d40c4150630: [clang-tools-extra] fix the check for if 
'-latomic' is necessary (authored by gokturk, committed by 
luismarques).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69869

Files:
  clang-tools-extra/clangd/CMakeLists.txt


Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 


Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74591: [Driver] Rename AddGoldPlugin to addLTOOptions. NFC

2020-02-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74591



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


[PATCH] D74609: [clangd] Update the CompletionItemKind.

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244646.
hokein marked 2 inline comments as done.
hokein added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74609

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), 
Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,8 +101,6 @@
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // FIXME(ioeric): this should probably be an operator. This should be fixed
-  // when `Operator` is support type in the protocol.
   case SK::ConversionFunction:
 return CompletionItemKind::Function;
   case SK::Variable:
@@ -112,9 +109,8 @@
 return CompletionItemKind::Variable;
   case SK::Field:
 return CompletionItemKind::Field;
-  // FIXME(ioeric): use LSP enum constant when it is supported in the protocol.
   case SK::EnumConstant:
-return CompletionItemKind::Value;
+return CompletionItemKind::EnumMember;
   case SK::InstanceMethod:
   case SK::ClassMethod:
   case SK::StaticMethod:


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,8 +101,6 @@
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // FIXME(ioeric): this should probably be an 

[clang] 61dd060 - Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-02-14T14:39:55Z
New Revision: 61dd0603bd8afeaa0d467d19c1522b5fbcf0104c

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

LOG: Move update_cc_test_checks.py tests to clang

Having tests that depend on clang inside llvm/ are not a good idea since
it can break incremental `ninja check-llvm`.

Fixes https://llvm.org/PR44798

Reviewed By: lebedev.ri, MaskRay, rsmith
Differential Revision: https://reviews.llvm.org/D74051

Added: 
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected

clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
clang/test/utils/update_cc_test_checks/def-and-decl.test
clang/test/utils/update_cc_test_checks/lit.local.cfg
clang/test/utils/update_cc_test_checks/mangled_names.test

Modified: 
llvm/test/tools/UpdateTestChecks/lit.local.cfg

Removed: 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c

llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected

llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c

llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.expected

llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test



diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c 
b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
rename to clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
 b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
rename to clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c
rename to clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.expected
 b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.expected
rename to clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
rename to 
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test 
b/clang/test/utils/update_cc_test_checks/def-and-decl.test
similarity index 100%
rename from 
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
rename to clang/test/utils/update_cc_test_checks/def-and-decl.test

diff  --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg 
b/clang/test/utils/update_cc_test_checks/lit.local.cfg
new file mode 100644
index ..0250446423cb
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -0,0 +1,25 @@
+import os
+
+import lit.util
+
+# python 2.7 backwards compatibility
+try:
+from shlex import quote as shell_quote
+except ImportError:
+from pipes import quote as shell_quote
+
+
+config.test_format = lit.formats.ShTest(execute_external=False)
+config.suffixes = ['.test']
+
+clang_path = os.path.join(config.clang_tools_dir, 'clang')
+extra_args = '--clang ' + shell_quote(clang_path)
+opt_path = os.path.join(config.llvm_tools_dir, 'opt')
+extra_args += ' --opt ' + shell_quote(opt_path)
+script_path = os.path.join(config.llvm_src_root, 'utils',
+  

[clang-tools-extra] 74c97ca - [clangd] Add tracer to the rename workflow, NFC

2020-02-14 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-14T15:39:29+01:00
New Revision: 74c97ca1b4b7d1a7497cebc0c9c91d2764a6f4b4

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

LOG: [clangd] Add tracer to the rename workflow, NFC

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 8b9b1d0033a5..c5dd09b99508 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -13,6 +13,7 @@
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
+#include "Trace.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -124,6 +125,7 @@ llvm::Optional renameable(const NamedDecl 
&RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
+  trace::Span Tracer("Renameable");
   // Filter out symbols that are unsupported in both rename modes.
   if (llvm::isa(&RenameDecl))
 return ReasonToReject::UnsupportedSymbol;
@@ -225,6 +227,7 @@ llvm::Error makeError(ReasonToReject Reason) {
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
+  trace::Span Tracer("FindOccurrenceeWithinFile");
   // If the cursor is at the underlying CXXRecordDecl of the
   // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
   // get the primary template maunally.
@@ -260,6 +263,7 @@ std::vector 
findOccurrencesWithinFile(ParsedAST &AST,
 llvm::Expected
 renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
  llvm::StringRef NewName) {
+  trace::Span Tracer("RenameWithinFile");
   const SourceManager &SM = AST.getSourceManager();
 
   tooling::Replacements FilteredChanges;
@@ -319,6 +323,7 @@ std::vector 
getConstructors(const NamedDecl *ND) {
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFile, const SymbolIndex &Index) 
{
+  trace::Span Tracer("FindOccurrencesOutsideFile");
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
   // Classes and their constructors are 
diff erent symbols, and have 
diff erent
@@ -361,6 +366,9 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 auto &Ranges = FileAndOccurrences.getValue();
 llvm::sort(Ranges);
 Ranges.erase(std::unique(Ranges.begin(), Ranges.end()), Ranges.end());
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));
   }
   return AffectedFiles;
 }
@@ -381,6 +389,7 @@ llvm::Expected renameOutsideFile(
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
 llvm::function_ref(PathRef)> GetFileContent) {
+  trace::Span Tracer("RenameOutsideFile");
   auto AffectedFiles =
   findOccurrencesOutsideFile(RenameDecl, MainFilePath, Index);
   if (!AffectedFiles)
@@ -463,6 +472,7 @@ void findNearMiss(
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
+  trace::Span Tracer("Rename flow");
   ParsedAST &AST = RInputs.AST;
   const SourceManager &SM = AST.getSourceManager();
   llvm::StringRef MainFileCode = SM.getBufferData(SM.getMainFileID());
@@ -555,6 +565,11 @@ llvm::Expected buildRenameEdit(llvm::StringRef 
AbsFilePath,
  llvm::StringRef InitialCode,
  std::vector Occurrences,
  llvm::StringRef NewName) {
+  trace::Span Tracer("BuildRenameEdit");
+  SPAN_ATTACH(Tracer, "file_path", AbsFilePath);
+  SPAN_ATTACH(Tracer, "rename_occurrences",
+  static_cast(Occurrences.size()));
+
   assert(std::is_sorted(Occurrences.begin(), Occurrences.end()));
   assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
  Occurrences.end() &&
@@ -618,6 +633,7 @@ llvm::Expected buildRenameEdit(llvm::StringRef 
AbsFilePath,
 llvm::Optional>
 adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier,
std::vector Indexed, const LangOptions &LangOpts) {
+  trace::Span Tracer("AdjustRenameRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   std::vector Lexed =
@@ -628,12 +644,16 @@

[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74c97ca1b4b7: [clangd] Add tracer to the rename workflow, 
NFC (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74395

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -13,6 +13,7 @@
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
+#include "Trace.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -124,6 +125,7 @@
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
+  trace::Span Tracer("Renameable");
   // Filter out symbols that are unsupported in both rename modes.
   if (llvm::isa(&RenameDecl))
 return ReasonToReject::UnsupportedSymbol;
@@ -225,6 +227,7 @@
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
+  trace::Span Tracer("FindOccurrenceeWithinFile");
   // If the cursor is at the underlying CXXRecordDecl of the
   // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
   // get the primary template maunally.
@@ -260,6 +263,7 @@
 llvm::Expected
 renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
  llvm::StringRef NewName) {
+  trace::Span Tracer("RenameWithinFile");
   const SourceManager &SM = AST.getSourceManager();
 
   tooling::Replacements FilteredChanges;
@@ -319,6 +323,7 @@
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFile, const SymbolIndex &Index) {
+  trace::Span Tracer("FindOccurrencesOutsideFile");
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
   // Classes and their constructors are different symbols, and have different
@@ -361,6 +366,9 @@
 auto &Ranges = FileAndOccurrences.getValue();
 llvm::sort(Ranges);
 Ranges.erase(std::unique(Ranges.begin(), Ranges.end()), Ranges.end());
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));
   }
   return AffectedFiles;
 }
@@ -381,6 +389,7 @@
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
 llvm::function_ref(PathRef)> GetFileContent) {
+  trace::Span Tracer("RenameOutsideFile");
   auto AffectedFiles =
   findOccurrencesOutsideFile(RenameDecl, MainFilePath, Index);
   if (!AffectedFiles)
@@ -463,6 +472,7 @@
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
+  trace::Span Tracer("Rename flow");
   ParsedAST &AST = RInputs.AST;
   const SourceManager &SM = AST.getSourceManager();
   llvm::StringRef MainFileCode = SM.getBufferData(SM.getMainFileID());
@@ -555,6 +565,11 @@
  llvm::StringRef InitialCode,
  std::vector Occurrences,
  llvm::StringRef NewName) {
+  trace::Span Tracer("BuildRenameEdit");
+  SPAN_ATTACH(Tracer, "file_path", AbsFilePath);
+  SPAN_ATTACH(Tracer, "rename_occurrences",
+  static_cast(Occurrences.size()));
+
   assert(std::is_sorted(Occurrences.begin(), Occurrences.end()));
   assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
  Occurrences.end() &&
@@ -618,6 +633,7 @@
 llvm::Optional>
 adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier,
std::vector Indexed, const LangOptions &LangOpts) {
+  trace::Span Tracer("AdjustRenameRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   std::vector Lexed =
@@ -628,12 +644,16 @@
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed) {
+  trace::Span Tracer("GetMappedRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
 
   if (Indexed.size() > Lexed.size()) {
 vlog("The number of lexed occurrences is less than indexed occurrences");
+SPAN_ATTACH(
+Tracer, "error",
+"The number of lexed occurrences is less than indexed occurrences");
 return llvm::None;
   }
   // Fast check for the special subset case.
@@ -660,15 +680,18 @@
});
   if (HasMultiple) {
 vlog("The best near miss is not unique.");
+SPAN_ATTACH(Tracer, "error", "The best near miss is not unique");
 

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61dd0603bd8a: Move update_cc_test_checks.py tests to clang 
(authored by arichardson).

Changed prior to commit:
  https://reviews.llvm.org/D74051?vs=243859&id=244650#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051

Files:
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/def-and-decl.test
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  clang/test/utils/update_cc_test_checks/mangled_names.test
  llvm/test/tools/UpdateTestChecks/lit.local.cfg
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.expected
  
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
  llvm/test/tools/UpdateTestChecks/update_cc_test_checks/mangled_names.test


Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# These tests require clang.
-if 'clang-binary' not in config.available_features:
-config.unsupported = True
Index: llvm/test/tools/UpdateTestChecks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/lit.local.cfg
+++ llvm/test/tools/UpdateTestChecks/lit.local.cfg
@@ -42,11 +42,3 @@
 config.available_features.add('llvm-mca-binary')
 mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path)
 add_update_script_substition('%update_test_checks', extra_args=mca_arg)
-
-clang_path = os.path.join(config.llvm_tools_dir, 'clang')
-if os.path.isfile(clang_path):
-config.available_features.add('clang-binary')
-extra_args = '--clang ' + shell_quote(clang_path)
-if os.path.isfile(opt_path):
-extra_args += ' --opt ' + shell_quote(opt_path)
-add_update_script_substition('%update_cc_test_checks', 
extra_args=extra_args)
Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -0,0 +1,25 @@
+import os
+
+import lit.util
+
+# python 2.7 backwards compatibility
+try:
+from shlex import quote as shell_quote
+except ImportError:
+from pipes import quote as shell_quote
+
+
+config.test_format = lit.formats.ShTest(execute_external=False)
+config.suffixes = ['.test']
+
+clang_path = os.path.join(config.clang_tools_dir, 'clang')
+extra_args = '--clang ' + shell_quote(clang_path)
+opt_path = os.path.join(config.llvm_tools_dir, 'opt')
+extra_args += ' --opt ' + shell_quote(opt_path)
+script_path = os.path.join(config.llvm_src_root, 'utils',
+   'update_cc_test_checks.py')
+assert os.path.isfile(script_path)
+config.substitutions.append(
+('%update_cc_test_checks', "%s %s %s" % (
+shell_quote(config.python_executable), shell_quote(script_path),
+extra_args)))


Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/update_cc_test_checks/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# These tests require clang.
-if 'clang-binary' not in config.available_features:
-config.unsupported = True
Index: llvm/test/tools/UpdateTestChecks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/lit.local.cfg
+++ llvm/test/tools/UpdateTestChecks/lit.local.cfg
@@ -42,11 +42,3 @@
 config.available_features.add('llvm-mca-binary')
 mca_arg = '--llvm-mca-binary ' + shell_quote(llvm_mca_path)
 add_update_script_substition('%update_test_checks', extra_args=mca_arg)
-
-clang_path = os.path.join(config.llvm_tools_dir, 'clang')
-if os.path.isfile(clang_path):
-config.available_features.add('clang-binary')
-extra_args = '--clang ' + shell_quote(clang_path)
-if os.path.isfile(opt_path):
-extra_args += ' --opt ' + shell_quote(opt_path)
-add_update_script_substition('%update_cc_

[PATCH] D74609: [clangd] Update the CompletionItemKind.

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:106
+  case SK::ConversionFunction:
+return CompletionItemKind::Operator;
   case SK::Variable:

kadircet wrote:
> I believe `function` still captures the intend better here, as you can only 
> see the completion if you are literally completing for `Foo.operator X()` 
> (btw, I am not even sure if we show completions for those, we might have 
> another bug around this one).
> 
> So I would keep it the same, but up to you.
hmm, I'm not sure we will actually encounter this case in practice, the 
completion didn't show up on `Foo.^` or `Foo.operat^or`,   `Foo.opeator ^` 
shows completion results, but seems not running into this code path. 

Reverted back, and removed the fixme.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74609



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


[clang-tools-extra] 5dc2314 - [clangd] Update the CompletionItemKind.

2020-02-14 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-14T15:48:30+01:00
New Revision: 5dc2314d5ecf3fe246ee0134f519183844287456

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

LOG: [clangd] Update the CompletionItemKind.

Summary: Fix some FIXMEs.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index f7c6f105cb9a..3fbf98970cce 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind 
Kind) {
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,8 +101,6 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind 
Kind) {
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // FIXME(ioeric): this should probably be an operator. This should be fixed
-  // when `Operator` is support type in the protocol.
   case SK::ConversionFunction:
 return CompletionItemKind::Function;
   case SK::Variable:
@@ -112,9 +109,8 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind 
Kind) {
 return CompletionItemKind::Variable;
   case SK::Field:
 return CompletionItemKind::Field;
-  // FIXME(ioeric): use LSP enum constant when it is supported in the protocol.
   case SK::EnumConstant:
-return CompletionItemKind::Value;
+return CompletionItemKind::EnumMember;
   case SK::InstanceMethod:
   case SK::ClassMethod:
   case SK::StaticMethod:

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index a39c7431044f..f9ffe1167338 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@ TEST(CompletionTest, Kinds) {
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@ TEST(CompletionTest, Kinds) {
   AllOf(Named("complete_variable"), 
Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {



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


[PATCH] D74609: [clangd] Update the CompletionItemKind.

2020-02-14 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dc2314d5ecf: [clangd] Update the CompletionItemKind. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74609

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), 
Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,8 +101,6 @@
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // FIXME(ioeric): this should probably be an operator. This should be fixed
-  // when `Operator` is support type in the protocol.
   case SK::ConversionFunction:
 return CompletionItemKind::Function;
   case SK::Variable:
@@ -112,9 +109,8 @@
 return CompletionItemKind::Variable;
   case SK::Field:
 return CompletionItemKind::Field;
-  // FIXME(ioeric): use LSP enum constant when it is supported in the protocol.
   case SK::EnumConstant:
-return CompletionItemKind::Value;
+return CompletionItemKind::EnumMember;
   case SK::InstanceMethod:
   case SK::ClassMethod:
   case SK::StaticMethod:


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -481,7 +481,7 @@
   AllOf(Has("function", CompletionItemKind::Function),
 Has("variable", CompletionItemKind::Variable),
 Has("int", CompletionItemKind::Keyword),
-Has("Struct", CompletionItemKind::Class),
+Has("Struct", CompletionItemKind::Struct),
 Has("MACRO", CompletionItemKind::Text),
 Has("indexFunction", CompletionItemKind::Function),
 Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@
   AllOf(Named("complete_variable"), Kind(CompletionItemKind::Variable)),
   AllOf(Named("complete_static_member"),
 Kind(CompletionItemKind::Property;
+
+   Results = completions(
+  R"cpp(
+enum Color {
+  Red
+};
+Color u = ^
+  )cpp");
+   EXPECT_THAT(Results.Completions,
+   Contains(
+   AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember;
 }
 
 TEST(CompletionTest, NoDuplicates) {
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -87,9 +87,8 @@
 return CompletionItemKind::Text;
   case SK::Enum:
 return CompletionItemKind::Enum;
-  // FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
-  // protocol.
   case SK::Struct:
+return CompletionItemKind::Struct;
   case SK::Class:
   case SK::Protocol:
   case SK::Extension:
@@ -102,8 +101,6 @@
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
-  // 

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Fails on windows, looks like line endings: 
http://45.33.8.238/win/8350/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[clang-tools-extra] 13700c3 - Revert "[clang-tools-extra] fix the check for if '-latomic' is necessary"

2020-02-14 Thread Luís Marques via cfe-commits

Author: Luís Marques
Date: 2020-02-14T15:01:52Z
New Revision: 13700c383fdbb172fac281bff6738a62989631c5

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

LOG: Revert "[clang-tools-extra] fix the check for if '-latomic' is necessary"

This reverts commit 1d40c4150630729a9c1ce5119a8027dac93a5b2d.
This seemed to have caused build failures on ARM/AArch64.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index fc5a07e69e9d..e3eccb50a496 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CLANG_BUILT_STANDALONE)
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 



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


[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I think this was addressed by https://reviews.llvm.org/D71997.


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

https://reviews.llvm.org/D73138



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


[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D74051#1876291 , @thakis wrote:

> Fails on windows, looks like line endings: 
> http://45.33.8.238/win/8350/step_7.txt


Are the other update_test_checks.py and update_llc_test_checks.py tests running 
on that bot? I would expect them to fail in the same way otherwise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[clang] d9049e8 - [clang-scan-deps] Switch to using a ThreadPool

2020-02-14 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-14T10:24:22-05:00
New Revision: d9049e871f309199a3d8fd7d3c0f76c86af9db91

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

LOG: [clang-scan-deps] Switch to using a ThreadPool

Use a ThreadPool instead of plain std::threads in clang-scan-deps.
This is needed to further support https://reviews.llvm.org/D71775.

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

Added: 


Modified: 
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 50788cb7cf8b..c499048fdb52 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@ int main(int argc, const char **argv) {
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@ int main(int argc, const char **argv) {
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@ int main(int argc, const char **argv) {
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@ int main(int argc, const char **argv) {
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());



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


[clang-tools-extra] 8404aeb - [Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and all NUMA groups

2020-02-14 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-02-14T10:24:22-05:00
New Revision: 8404aeb56a73ab24f9b295111de3b37a37f0b841

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

LOG: [Support] On Windows, ensure hardware_concurrency() extends to all CPU 
sockets and all NUMA groups

The goal of this patch is to maximize CPU utilization on multi-socket or high 
core count systems, so that parallel computations such as LLD/ThinLTO can use 
all hardware threads in the system. Before this patch, on Windows, a maximum of 
64 hardware threads could be used at most, in some cases dispatched only on one 
CPU socket.

== Background ==
Windows doesn't have a flat cpu_set_t like Linux. Instead, it projects hardware 
CPUs (or NUMA nodes) to applications through a concept of "processor groups". A 
"processor" is the smallest unit of execution on a CPU, that is, an 
hyper-thread if SMT is active; a core otherwise. There's a limit of 32-bit 
processors on older 32-bit versions of Windows, which later was raised to 
64-processors with 64-bit versions of Windows. This limit comes from the 
affinity mask, which historically is represented by the sizeof(void*). 
Consequently, the concept of "processor groups" was introduced for dealing with 
systems with more than 64 hyper-threads.

By default, the Windows OS assigns only one "processor group" to each starting 
application, in a round-robin manner. If the application wants to use more 
processors, it needs to programmatically enable it, by assigning threads to 
other "processor groups". This also means that affinity cannot cross "processor 
group" boundaries; one can only specify a "preferred" group on start-up, but 
the application is free to allocate more groups if it wants to.

This creates a peculiar situation, where newer CPUs like the AMD EPYC 7702P 
(64-cores, 128-hyperthreads) are projected by the OS as two (2) "processor 
groups". This means that by default, an application can only use half of the 
cores. This situation could only get worse in the years to come, as dies with 
more cores will appear on the market.

== The problem ==
The heavyweight_hardware_concurrency() API was introduced so that only *one 
hardware thread per core* was used. Once that API returns, that original 
intention is lost, only the number of threads is retained. Consider a 
situation, on Windows, where the system has 2 CPU sockets, 18 cores each, each 
core having 2 hyper-threads, for a total of 72 hyper-threads. Both 
heavyweight_hardware_concurrency() and hardware_concurrency() currently return 
36, because on Windows they are simply wrappers over 
std::thread::hardware_concurrency() -- which can only return processors from 
the current "processor group".

== The changes in this patch ==
To solve this situation, we capture (and retain) the initial intention until 
the point of usage, through a new ThreadPoolStrategy class. The number of 
threads to use is deferred as late as possible, until the moment where the 
std::threads are created (ThreadPool in the case of ThinLTO).

When using hardware_concurrency(), setting ThreadCount to 0 now means to use 
all the possible hardware CPU (SMT) threads. Providing a ThreadCount above to 
the maximum number of threads will have no effect, the maximum will be used 
instead.
The heavyweight_hardware_concurrency() is similar to hardware_concurrency(), 
except that only one thread per hardware *core* will be used.

When LLVM_ENABLE_THREADS is OFF, the threading APIs will always return 1, to 
ensure any caller loops will be exercised at least once.

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

Added: 


Modified: 
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/BackgroundRebuild.h
clang/lib/Tooling/AllTUsExecution.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
lld/ELF/SyntheticSections.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Support/ThreadPool.h
llvm/include/llvm/Support/Threading.h
llvm/lib/CodeGen/ParallelCG.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Support/Host.cpp
llvm/lib/Support/Parallel.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cov/CoverageExporterJson.cpp
llvm/

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

Turns out those scripts use different code to write the updated file. The 
failure should hopefully be fixed in rGc29310707e9a85e70a226277657cd9d9182a5d04 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D74569: [clang-scan-deps] Switch to using a ThreadPool

2020-02-14 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9049e871f30: [clang-scan-deps] Switch to using a ThreadPool 
(authored by aganea).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74569

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2020-02-14 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8404aeb56a73: [Support] On Windows, ensure 
hardware_concurrency() extends to all CPU sockets… (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D71775?vs=237197&id=244664#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775

Files:
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundRebuild.h
  clang/lib/Tooling/AllTUsExecution.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  lld/ELF/SyntheticSections.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Support/ThreadPool.h
  llvm/include/llvm/Support/Threading.h
  llvm/lib/CodeGen/ParallelCG.cpp
  llvm/lib/DWARFLinker/DWARFLinker.cpp
  llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
  llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/Parallel.cpp
  llvm/lib/Support/ThreadPool.cpp
  llvm/lib/Support/Threading.cpp
  llvm/lib/Support/Unix/Threading.inc
  llvm/lib/Support/Windows/Threading.inc
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-cov/CodeCoverage.cpp
  llvm/tools/llvm-cov/CoverageExporterJson.cpp
  llvm/tools/llvm-cov/CoverageReport.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/unittests/Support/Host.cpp
  llvm/unittests/Support/TaskQueueTest.cpp
  llvm/unittests/Support/ThreadPool.cpp
  llvm/unittests/Support/Threading.cpp
  mlir/lib/Pass/Pass.cpp

Index: mlir/lib/Pass/Pass.cpp
===
--- mlir/lib/Pass/Pass.cpp
+++ mlir/lib/Pass/Pass.cpp
@@ -411,7 +411,8 @@
   // Create the async executors if they haven't been created, or if the main
   // pipeline has changed.
   if (asyncExecutors.empty() || hasSizeMismatch(asyncExecutors.front(), mgrs))
-asyncExecutors.assign(llvm::hardware_concurrency(), mgrs);
+asyncExecutors.assign(llvm::hardware_concurrency().compute_thread_count(),
+  mgrs);
 
   // Run a prepass over the module to collect the operations to execute over.
   // This ensures that an analysis manager exists for each operation, as well as
Index: llvm/unittests/Support/Threading.cpp
===
--- llvm/unittests/Support/Threading.cpp
+++ llvm/unittests/Support/Threading.cpp
@@ -21,7 +21,8 @@
   auto Num = heavyweight_hardware_concurrency();
   // Since Num is unsigned this will also catch us trying to
   // return -1.
-  ASSERT_LE(Num, thread::hardware_concurrency());
+  ASSERT_LE(Num.compute_thread_count(),
+hardware_concurrency().compute_thread_count());
 }
 
 #if LLVM_ENABLE_THREADS
Index: llvm/unittests/Support/ThreadPool.cpp
===
--- llvm/unittests/Support/ThreadPool.cpp
+++ llvm/unittests/Support/ThreadPool.cpp
@@ -8,11 +8,13 @@
 
 #include "llvm/Support/ThreadPool.h"
 
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/Threading.h"
 
 #include "gtest/gtest.h"
 
@@ -69,6 +71,8 @@
 
   void SetUp() override { MainThreadReady = false; }
 
+  void TestAllThreads(ThreadPoolStrategy S);
+
   std::condition_variable WaitMainThread;
   std::mutex WaitMainThreadMutex;
   bool MainThreadReady = false;
@@ -131,7 +135,7 @@
 
 TEST_F(ThreadPoolTest, GetFuture) {
   CHECK_UNSUPPORTED();
-  ThreadPool Pool{2};
+  ThreadPool Pool(hardware_concurrency(2));
   std::atomic_int i{0};
   Pool.async([this, &i] {
 waitForMainThread();
@@ -162,3 +166,45 @@
   }
   ASSERT_EQ(5, checked_in);
 }
+
+#if LLVM_ENABLE_THREADS == 1
+
+void ThreadPoolTest::TestAllThreads(ThreadPoolStrategy S) {
+  // FIXME: Skip these tests on non-Windows because multi-socket system were not
+  // tested on Unix yet, and llvm::get_thread_affinity_mask() isn't implemented
+  // for Unix.
+  Triple Host(Triple::normalize(sys::getProcessTriple()));
+  if (!Host.isOSWindows())
+return;
+
+  llvm::DenseSet ThreadsUsed;
+  std::mutex Lock;
+  unsigned Threads = 0;
+  {
+ThreadPool Pool(S);
+Threads = Pool.getThreadCount();
+for (size_t I = 0; I < 1; ++I) {
+  Pool.async([&] {
+waitForMainThread();
+std::lock_guard Guard(Lock);
+auto Mask = llvm::get_thread_affinity_mask();
+ThreadsUsed.insert(Mask);
+  });
+}
+ASSERT_EQ(true, ThreadsUsed.empty());
+setMainThrea

[clang] 9122b92 - Revert "Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-02-14 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-14T07:32:09-08:00
New Revision: 9122b92f8e046bfeabdc503d978cf098c86f6e49

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

LOG: Revert "Reland D74436 "Change clang option -ffp-model=precise to select 
ffp-contract=on""

This reverts commit 0a1123eb43f945593b26dd037490e0c909fa3c4f.
Want to revert this because it's causing trouble for PowerPC
I also fixed test fp-model.c which was looking for an incorrect error message

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 6c8c9f802082..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1190,50 +1190,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1427,7 +1385,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d1197556aeef..2585a5fa05da 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,9 +2525,10 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
+
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 CmdArgs.push_back(A->getValue());
@@ -2550,6 +2551,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcont

RE: [PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-14 Thread Blower, Melanie I via cfe-commits
I reverted MaskRay's "reland" since the original patch is causing trouble on 
PowerPC, check-all is passing on my box.  Sorry for the trouble. 

> -Original Message-
> From: Andy Kaylor via Phabricator 
> Sent: Thursday, February 13, 2020 9:20 PM
> To: Blower, Melanie I ; lebedev...@gmail.com;
> rjmcc...@gmail.com; sepavl...@gmail.com
> Cc: mask...@google.com; j...@us.ibm.com; david.bolvan...@gmail.com;
> mar...@martin.st; Wang, Pengfei ;
> wuz...@cn.ibm.com; nemanja.i@gmail.com; kit.bar...@gmail.com; cfe-
> comm...@lists.llvm.org; mlek...@skidmore.edu; blitzrak...@gmail.com;
> shen...@google.com; peter.wal...@arm.com
> Subject: [PATCH] D74436: Change clang option -ffp-model=precise to select ffp-
> contract=on
> 
> andrew.w.kaylor added a subscriber: MaskRay.
> andrew.w.kaylor added a comment.
> 
> In D74436#1875386 , @thakis
> wrote:
> 
> > The revert of this breaks tests everywhere, as far as I can tell.
> 
> 
> It looks like something strange happened with the revert:
> 
> > clang-11: warning: overriding '-ffp-model=strict' option with '-ffp-
> model=strict' [-Woverriding-t-option]
> 
> I believe the problem is that the original change that was being reverted
> contained this:
> 
>   clang/lib/Driver/ToolChains/Clang.cpp
>   @@ -2768,7 +2766,7 @@ static void RenderFloatingPointOptions(const
> ToolChain &TC, const Driver &D,
>   !AssociativeMath && !ReciprocalMath &&
>   SignedZeros && TrappingMath && RoundingFPMath &&
>   DenormalFPMath != llvm::DenormalMode::getIEEE() &&
>   +FPContract.empty())
>   -(FPContract.equals("off") || FPContract.empty()))
> 
> But sometime in the land-revert-land-revert cycle the line above that changed,
> causing the merge to miss this change in the most recent revert. I see that
> @MaskRay has since re-landed this change set, but it's going to cause problems
> for PowerPC. If someone needs to revert this yet again, I think it can be 
> safely
> done by recovering the change above.
> 
> Apologies for the mess!
> 
> 
> Repository:
>   rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D74436/new/
> 
> https://reviews.llvm.org/D74436
> 
> 

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


[PATCH] D74615: [Analyzer] Add visitor to track iterator invalidation

2020-02-14 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: steakhal, Charusso, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, xazax.hun.

To understand the bug report issued by the `InvalidatedIterator` checker it is 
essential to see the point where the iterator was invalidated and also to track 
the assignemnts of the already invalidated iterator up to its errorneous 
access. Since iterator invalidation is neither "done" by `InvalidatedIterator` 
checker nor by `IteratorModeling` but "happens" upon container modifications 
(modeled by `ContainerModeling`) the proper solution here seems to be a 
`BugReporterVisitor` instead of `NoteTag`s.


Repository:
  rC Clang

https://reviews.llvm.org/D74615

Files:
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/test/Analysis/invalidated-iterator.cpp

Index: clang/test/Analysis/invalidated-iterator.cpp
===
--- clang/test/Analysis/invalidated-iterator.cpp
+++ clang/test/Analysis/invalidated-iterator.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -12,8 +12,9 @@
 
 void invalidated_dereference(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   *i; // expected-warning{{Invalidated iterator accessed}}
+  // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_prefix_increment(std::vector &V) {
@@ -23,8 +24,9 @@
 
 void invalidated_prefix_increment(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   ++i; // expected-warning{{Invalidated iterator accessed}}
+   // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_prefix_decrement(std::vector &V) {
@@ -34,8 +36,9 @@
 
 void invalidated_prefix_decrement(std::vector &V) {
   auto i = ++V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   --i; // expected-warning{{Invalidated iterator accessed}}
+   // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_postfix_increment(std::vector &V) {
@@ -45,8 +48,9 @@
 
 void invalidated_postfix_increment(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   i++; // expected-warning{{Invalidated iterator accessed}}
+   // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_postfix_decrement(std::vector &V) {
@@ -56,8 +60,9 @@
 
 void invalidated_postfix_decrement(std::vector &V) {
   auto i = ++V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   i--; // expected-warning{{Invalidated iterator accessed}}
+   // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_increment_by_2(std::vector &V) {
@@ -67,8 +72,9 @@
 
 void invalidated_increment_by_2(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   i += 2; // expected-warning{{Invalidated iterator accessed}}
+  // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_increment_by_2_copy(std::vector &V) {
@@ -78,8 +84,9 @@
 
 void invalidated_increment_by_2_copy(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   auto j = i + 2; // expected-warning{{Invalidated iterator accessed}}
+  // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_decrement_by_2(std::vector &V) {
@@ -89,8 +96,9 @@
 
 void invalidated_decrement_by_2(std::vector &V) {
   auto i = V.cbegin();
-  V.erase(i);
+  V.erase(i); // expected-note{{Iterator 'i' invalidated}}
   i -= 2; // expected-warning{{Invalidated iterator accessed}}
+  // expected-note@-1{{Invalidated iterator accessed}}
 }
 
 void normal_decrement

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-14 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 244667.
baloghadamsoftware added a comment.

Minor update: ignore parentheses and casts when taking the name of the 
expression.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector &V) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector &V) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector &V) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector &V) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector &V) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector &V) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector &V) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector &V) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector &V) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector &V) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector &V) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin_by_2(const std::vector &V) {
@@ -246,11 +257,13 @@
 void decr_by_2_copy_begin(const std::vector &V) {
   aut

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-14 Thread David Stenberg via Phabricator via cfe-commits
dstenb added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:870
 if (MI->isCandidateForCallSiteEntry() &&
-DAG->getTarget().Options.EnableDebugEntryValues)
+DAG->getTarget().Options.SupportsDebugEntryValues)
   MF.addCallArgsForwardingRegs(MI, DAG->getSDCallSiteInfo(Node));

djtodoro wrote:
> dstenb wrote:
> > I'm sorry for commenting on this so late, but when now adapting this patch 
> > for our downstream target, for which we will not enable call site info by 
> > default yet, I noticed that the call site information wasn't added. I think 
> > that this should be `ShouldEmitDebugEntryValues()`.
> I thought to restrict the production of the call site info here and only to 
> allow a hand-made testing, but I think you are right, we should use the 
> `ShouldEmitDebugEntryValues()`. I'll update the patch, thanks!
Thanks! It is perhaps a bit of a corner case, and we're moving towards enabling 
call site info by default, but I guess this might be useful when experimenting 
with adding call site info for other targets in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73534



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:403
+return;
+  case nonloc::ConcreteIntKind: {
+

This check works now with concrete int values. We have a known value and a list 
of ranges with known limits, so testing for //in any of the ranges// does work 
the same way as testing for //out of all ranges//. And testing if the value is 
inside one of the ranges is more simple code.

But I think the symbolic evaluation with "eval" and "assume" functions would be 
more generic here (and more simple code). Then the way of cutting-of the bad 
ranges is usable (probably still there is other solution).



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:464
+}
+
 void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,

If `evalCall` is used it could be more simple to test and apply the constraints 
for arguments and return value in a "single step".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

2020-02-14 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware abandoned this revision.
baloghadamsoftware added a comment.

Superseded by [[ https://reviews.llvm.org/D73720 | [Analyzer] Use note tags to 
track container begin and and changes ]], [[ https://reviews.llvm.org/D74541 | 
[Analyzer] Use note tags to track iterator increments and decrements ]] and [[ 
https://reviews.llvm.org/D74615 | [Analyzer] Add visitor to track iterator 
invalidation ]].


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

https://reviews.llvm.org/D62525



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


[clang] 597dfb3 - [Driver] Rename AddGoldPlugin to addLTOOptions. NFC

2020-02-14 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-02-14T08:06:37-08:00
New Revision: 597dfb3bd56cdb65a89c67775ce348f10af36aa0

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

LOG: [Driver] Rename AddGoldPlugin to addLTOOptions. NFC

AddGoldPlugin does more than adding `-plugin path/to/LLVMgold.so`.
It works with lld and GNU ld, and adds other LTO options.
So AddGoldPlugin is no longer a suitable name.

Reviewed By: tejohnson

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Ananas.cpp
clang/lib/Driver/ToolChains/CloudABI.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Ananas.cpp 
b/clang/lib/Driver/ToolChains/Ananas.cpp
index 2f11c9739a0e..10e4ea70db41 100644
--- a/clang/lib/Driver/ToolChains/Ananas.cpp
+++ b/clang/lib/Driver/ToolChains/Ananas.cpp
@@ -103,7 +103,7 @@ void ananas::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 

diff  --git a/clang/lib/Driver/ToolChains/CloudABI.cpp 
b/clang/lib/Driver/ToolChains/CloudABI.cpp
index 77672a99d989..0602e4f6d0b3 100644
--- a/clang/lib/Driver/ToolChains/CloudABI.cpp
+++ b/clang/lib/Driver/ToolChains/CloudABI.cpp
@@ -75,7 +75,7 @@ void cloudabi::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 0b2f8ce455f6..51b2e5f3c34d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -353,7 +353,7 @@ bool tools::isUseSeparateSections(const llvm::Triple 
&Triple) {
   return Triple.getOS() == llvm::Triple::CloudABI;
 }
 
-void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
+void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
   ArgStringList &CmdArgs, const InputInfo &Output,
   const InputInfo &Input, bool IsThinLTO) {
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index bf1ab8153de7..984f3ee98af1 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -58,7 +58,7 @@ void SplitDebugInfo(const ToolChain &TC, Compilation &C, 
const Tool &T,
 const JobAction &JA, const llvm::opt::ArgList &Args,
 const InputInfo &Output, const char *OutFile);
 
-void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
+void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
const InputInfo &Input, bool IsThinLTO);
 

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index c5c6f530f48c..3f3d6e7c72eb 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -275,7 +275,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 1e1f003daf83..6114829ac8e1 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -111,7 +111,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 

diff  --git a/clang/lib/Driver/ToolChai

[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-02-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Yep, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D74618: [ARM] Creating 'call_mangled' for Neon intrinsics definitions

2020-02-14 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

As multiple versions ofthe same Neon intrinsic can be created through
the same TableGen definition with the same argument types, the existing
'call' operator is not always able to properly perform overload
resolutions.

As these different intrinsic versions are diferentiated later on by the
NeonEmitter through name mangling, this patch introduces a new
'call_mangled' operator to the TableGen definitions, which allows a call
for an otherwise ambiguous intrinsic by matching its mangled name with
the mangled variation of the caller.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74618

Files:
  clang/include/clang/Basic/arm_neon_incl.td
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
@@ -523,7 +524,7 @@
 std::pair emitDagDupTyped(DagInit *DI);
 std::pair emitDagShuffle(DagInit *DI);
 std::pair emitDagCast(DagInit *DI, bool IsBitCast);
-std::pair emitDagCall(DagInit *DI);
+std::pair emitDagCall(DagInit *DI, bool MatchMangledName);
 std::pair emitDagNameReplace(DagInit *DI);
 std::pair emitDagLiteral(DagInit *DI);
 std::pair emitDagOp(DagInit *DI);
@@ -551,7 +552,8 @@
 public:
   /// Called by Intrinsic - this attempts to get an intrinsic that takes
   /// the given types as arguments.
-  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types);
+  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types,
+  Optional MangledName);
 
   /// Called by Intrinsic - returns a globally-unique number.
   unsigned getUniqueNumber() { return UniqueNumber++; }
@@ -1388,8 +1390,8 @@
 return emitDagSaveTemp(DI);
   if (Op == "op")
 return emitDagOp(DI);
-  if (Op == "call")
-return emitDagCall(DI);
+  if (Op == "call" || Op == "call_mangled")
+return emitDagCall(DI, Op == "call_mangled");
   if (Op == "name_replace")
 return emitDagNameReplace(DI);
   if (Op == "literal")
@@ -1416,7 +1418,8 @@
   }
 }
 
-std::pair Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
+std::pair Intrinsic::DagEmitter::emitDagCall(DagInit *DI,
+bool MatchMangledName) {
   std::vector Types;
   std::vector Values;
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
@@ -1432,7 +1435,12 @@
 N = SI->getAsUnquotedString();
   else
 N = emitDagArg(DI->getArg(0), "").second;
-  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types);
+  Optional MangledName;
+  if (MatchMangledName) {
+if (Intr.getRecord()->getValueAsBit("isLaneQ")) N += "q";
+MangledName = Intr.mangleName(N, ClassS);
+  }
+  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types, MangledName);
 
   // Make sure the callee is known as an early def.
   Callee.setNeededEarly();
@@ -1839,7 +1847,8 @@
 // NeonEmitter implementation
 //===--===//
 
-Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types) {
+Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types,
+ Optional MangledName) {
   // First, look up the name in the intrinsic map.
   assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
   ("Intrinsic '" + Name + "' not found!").str());
@@ -1878,6 +1887,9 @@
 break;
   }
 }
+if (MangledName)
+  Good &= I.getMangledName(true) == MangledName;
+
 if (Good)
   GoodVec.push_back(&I);
   }
Index: clang/include/clang/Basic/arm_neon_incl.td
===
--- clang/include/clang/Basic/arm_neon_incl.td
+++ clang/include/clang/Basic/arm_neon_incl.td
@@ -60,6 +60,11 @@
 // example: (call "vget_high", $p0) -> "vgetq_high_s16(__p0)"
 //(assuming $p0 has type int16x8_t).
 def call;
+// call_mangled - Invoke another intrinsic matching the mangled name variation
+//of the caller's base type. If there is no intrinsic defined
+//that has the variation and takes the given types, an error
+//is generated at tblgen time.
+def call_mangled;
 // cast - Perform a cast to a different type. This gets emitted as a static
 //C-style cast. For a pure reinterpret cast (T x = *(T*)&y), use
 //"bitcast".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74616: [ARM] Setting missing isLaneQ attribute on Neon Intrisics definitions

2020-02-14 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

Some of the '*_laneq' intrinsics defined in arm_neon.td were missing the
setting of the 'isLaneQ' attribute. This patch sets the attribute on the
re lated definitions, as they will be required to properly perform range
checks on their lane arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74616

Files:
  clang/include/clang/Basic/arm_neon.td

Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -881,16 +881,22 @@
 def COPYQ_LANE : IOpInst<"vcopy_lane", "..IqI",
 "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
 def COPY_LANEQ : IOpInst<"vcopy_laneq", "..IQI",
- "csilPcPsPlUcUsUiUlfd", OP_COPY_LN>;
+ "csilPcPsPlUcUsUiUlfd", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 def COPYQ_LANEQ : IOpInst<"vcopy_laneq", "..I.I",
- "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN>;
+ "QcQsQiQlQUcQUsQUiQUlQPcQPsQfQdQPl", OP_COPY_LN> {
+  let isLaneQ = 1;
+}
 
 
 // Set all lanes to same value
 def VDUP_LANE1: WOpInst<"vdup_lane", ".qI", "hdQhQdPlQPl", OP_DUP_LN>;
 def VDUP_LANE2: WOpInst<"vdup_laneq", ".QI",
   "csilUcUsUiUlPcPshfdQcQsQiQlQPcQPsQUcQUsQUiQUlQhQfQdPlQPl",
-OP_DUP_LN>;
+OP_DUP_LN> {
+  let isLaneQ = 1;
+}
 def DUP_N   : WOpInst<"vdup_n", ".1", "dQdPlQPl", OP_DUP>;
 def MOV_N   : WOpInst<"vmov_n", ".1", "dQdPlQPl", OP_DUP>;
 
@@ -906,38 +912,60 @@
 
 
 def VMLA_LANEQ   : IOpInst<"vmla_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLA_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLA_LN> {
+  let isLaneQ = 1;
+}
 def VMLS_LANEQ   : IOpInst<"vmls_laneq", "...QI",
-   "siUsUifQsQiQUsQUiQf", OP_MLS_LN>;
+   "siUsUifQsQiQUsQUiQf", OP_MLS_LN> {
+  let isLaneQ = 1;
+}
 
 def VFMA_LANE: IInst<"vfma_lane", "...qI", "fdQfQd">;
 def VFMA_LANEQ   : IInst<"vfma_laneq", "...QI", "fdQfQd"> {
   let isLaneQ = 1;
 }
 def VFMS_LANE: IOpInst<"vfms_lane", "...qI", "fdQfQd", OP_FMS_LN>;
-def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ>;
+def VFMS_LANEQ   : IOpInst<"vfms_laneq", "...QI", "fdQfQd", OP_FMS_LNQ> {
+  let isLaneQ = 1;
+}
 
-def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN>;
+def VMLAL_LANEQ  : SOpInst<"vmlal_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLAL_LN> {
+  let isLaneQ = 1;
+}
 def VMLAL_HIGH_LANE   : SOpInst<"vmlal_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLALHi_LN>;
 def VMLAL_HIGH_LANEQ  : SOpInst<"vmlal_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLALHi_LN>;
-def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN>;
+OP_MLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VMLSL_LANEQ  : SOpInst<"vmlsl_laneq", "(>Q)(>Q).QI", "siUsUi", OP_MLSL_LN> {
+  let isLaneQ = 1;
+}
 def VMLSL_HIGH_LANE   : SOpInst<"vmlsl_high_lane", "(>Q)(>Q)Q.I", "siUsUi",
 OP_MLSLHi_LN>;
 def VMLSL_HIGH_LANEQ  : SOpInst<"vmlsl_high_laneq", "(>Q)(>Q)QQI", "siUsUi",
-OP_MLSLHi_LN>;
+OP_MLSLHi_LN> {
+  let isLaneQ = 1;
+}
 
-def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", OP_QDMLAL_LN>;
+def VQDMLAL_LANEQ  : SOpInst<"vqdmlal_laneq", "(>Q)(>Q).QI", "si", OP_QDMLAL_LN> {
+  let isLaneQ = 1;
+}
 def VQDMLAL_HIGH_LANE   : SOpInst<"vqdmlal_high_lane", "(>Q)(>Q)Q.I", "si",
 OP_QDMLALHi_LN>;
 def VQDMLAL_HIGH_LANEQ  : SOpInst<"vqdmlal_high_laneq", "(>Q)(>Q)QQI", "si",
-OP_QDMLALHi_LN>;
-def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_laneq", "(>Q)(>Q).QI", "si", OP_QDMLSL_LN>;
+OP_QDMLALHi_LN> {
+  let isLaneQ = 1;
+}
+def VQDMLSL_LANEQ  : SOpInst<"vqdmlsl_laneq", "(>Q)(>Q).QI", "si", OP_QDMLSL_LN> {
+  let isLaneQ = 1;
+}
 def VQDMLSL_HIGH_LANE   : SOpInst<"vqdmlsl_high_lane", "(>Q)(>Q)Q.I", "si",
 OP_QDMLSLHi_LN>;
 def VQDMLSL_HIGH_LANEQ  : SOpInst<"vqdmlsl_high_laneq", "(>Q)(>Q)QQI", "si",
-OP_QDMLSLHi_LN>;
+OP_QDMLSLHi_LN> {
+  let isLaneQ = 1;
+}
 
 // Newly add double parameter for vmul_lane in aarch64
 // Note: d type is handled by SCALAR_VMUL_LANE
@@ -945,32 +973,48 @@
 
 // Note: d type is handled by SCALAR_VMUL_LANEQ
 def VMUL_LANEQ   : IOpInst<"vmul_laneq", "..QI",
-   "sifUs

[PATCH] D74617: [ARM] Keeping sign information on bitcasts for Neon vdot_lane intrinsics

2020-02-14 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

Sign information was being lost on Neon's vdot_lane intrinsics arguments
when bitcasting explicitly to uint32 vector types. This patch introduces
a new cast option to allow casting the operand to the equivalent vector
type of 32-bit integers, keeping the sign information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74617

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -238,6 +238,11 @@
 NumVectors = 1;
   }
 
+  void make32BitElement() {
+assert_with_loc(Bitwidth > 32, "Not enough bits to make it 32!");
+ElementBitwidth = 32;
+  }
+
   void doubleLanes() {
 assert_with_loc(Bitwidth != 128, "Can't get bigger than 128!");
 Bitwidth = 128;
@@ -1486,6 +1491,8 @@
 castToType.doubleLanes();
   } else if (SI->getAsUnquotedString() == "8") {
 castToType.makeInteger(8, true);
+  } else if (SI->getAsUnquotedString() == "32") {
+castToType.make32BitElement();
   } else {
 castToType = Type::fromTypedefName(SI->getAsUnquotedString());
 assert_with_loc(!castToType.isVoid(), "Unknown typedef");
Index: clang/include/clang/Basic/arm_neon_incl.td
===
--- clang/include/clang/Basic/arm_neon_incl.td
+++ clang/include/clang/Basic/arm_neon_incl.td
@@ -79,6 +79,7 @@
 //  - "D" - Double the number of lanes in the type.
 //  - "8" - Convert type to an equivalent vector of 8-bit signed
 //  integers.
+//  - "32" - Convert type to an equivalent vector of 32-bit integers.
 // example: (cast "R", "U", $p0) -> "(uint32x4_t)__p0" (assuming the return
 //   value is of type "int32x4_t".
 //  (cast $p0, "D", "8", $p1) -> "(int8x16_t)__p1" (assuming __p0
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -207,10 +207,10 @@
 
 def OP_DOT_LN
 : Op<(call "vdot", $p0, $p1,
-  (bitcast $p1, (splat(bitcast "uint32x2_t", $p2), $p3)))>;
+  (bitcast $p1, (splat(bitcast "32", $p2), $p3)))>;
 def OP_DOT_LNQ
 : Op<(call "vdot", $p0, $p1,
-  (bitcast $p1, (splat(bitcast "uint32x4_t", $p2), $p3)))>;
+  (bitcast $p1, (splat(bitcast "32", $p2), $p3)))>;
 
 def OP_FMLAL_LN : Op<(call "vfmlal_low", $p0, $p1,
(dup_typed $p1, (call "vget_lane", $p2, $p3)))>;


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -238,6 +238,11 @@
 NumVectors = 1;
   }
 
+  void make32BitElement() {
+assert_with_loc(Bitwidth > 32, "Not enough bits to make it 32!");
+ElementBitwidth = 32;
+  }
+
   void doubleLanes() {
 assert_with_loc(Bitwidth != 128, "Can't get bigger than 128!");
 Bitwidth = 128;
@@ -1486,6 +1491,8 @@
 castToType.doubleLanes();
   } else if (SI->getAsUnquotedString() == "8") {
 castToType.makeInteger(8, true);
+  } else if (SI->getAsUnquotedString() == "32") {
+castToType.make32BitElement();
   } else {
 castToType = Type::fromTypedefName(SI->getAsUnquotedString());
 assert_with_loc(!castToType.isVoid(), "Unknown typedef");
Index: clang/include/clang/Basic/arm_neon_incl.td
===
--- clang/include/clang/Basic/arm_neon_incl.td
+++ clang/include/clang/Basic/arm_neon_incl.td
@@ -79,6 +79,7 @@
 //  - "D" - Double the number of lanes in the type.
 //  - "8" - Convert type to an equivalent vector of 8-bit signed
 //  integers.
+//  - "32" - Convert type to an equivalent vector of 32-bit integers.
 // example: (cast "R", "U", $p0) -> "(uint32x4_t)__p0" (assuming the return
 //   value is of type "int32x4_t".
 //  (cast $p0, "D", "8", $p1) -> "(int8x16_t)__p1" (assuming __p0
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -207,10 +207,10 @@
 
 def OP_DOT_LN
 : Op<(call "vdot", $p0, $p1,
-  (bitcast $p1, (splat(bitcast "uint32x2_t", $p2), $p3)))>;
+  (bitcast $p1, (splat(bitcast "32", $p2), $p3)))>;
 def OP_DOT_LNQ
 : Op<(call "vdot", $p0, $p1,
-  (bitcast $p1, (splat(bitcast "uint32x4_t", $p2), $p3)))>;
+  (bitcast $p1, (splat(bi

[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

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

Probably a better solution can be:
For every "case" build a single `SVal` that contains all argument constraints 
for that case. It is possible using multiple `evalBinOp` calls (with <=, >=, 
logical or) to build such a condition (or repeated calls to other assume 
functions to cut off outer ranges). If the condition can be satisfied (by 
assume) add the new state, the condition for return value can be added here 
too. Repeat this for every different case. If no applicable case is found none 
of the conditions can be assumed, this means argument constraint error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D74591: [Driver] Rename AddGoldPlugin to addLTOOptions. NFC

2020-02-14 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG597dfb3bd56c: [Driver] Rename AddGoldPlugin to 
addLTOOptions. NFC (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74591

Files:
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -512,7 +512,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -111,7 +111,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -275,7 +275,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -58,7 +58,7 @@
 const JobAction &JA, const llvm::opt::ArgList &Args,
 const InputInfo &Output, const char *OutFile);
 
-void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
+void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
const InputInfo &Input, bool IsThinLTO);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -353,7 +353,7 @@
   return Triple.getOS() == llvm::Triple::CloudABI;
 }
 
-void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
+void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
   ArgStringList &CmdArgs, const InputInfo &Output,
   const InputInfo &Input, bool IsThinLTO) {
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/Driver/ToolChains/CloudABI.cpp
===
--- clang/lib/Driver/ToolChains/CloudABI.cpp
+++ clang/lib/Driver/ToolChains/CloudABI.cpp
@@ -75,7 +75,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 
Index: clang/lib/Driver/ToolChains/Ananas.cpp
===
--- clang/lib/Driver/ToolChains/Ananas.cpp
+++ clang/lib/Driver/ToolChains/Ananas.cpp
@@ -103,7 +103,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -512,7 +512,7 @@
 
   if (D.isUsingLTO()) {
 assert(!Inputs.empty() && "Must have at least one input.");
-AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
   }
 
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
=

[PATCH] D74555: [clangd] Add a flag for setting isIncomplete flag true in all responses

2020-02-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

The idea is this is an easy option for the user to work-around editors that do 
client-side filtering badly (everyone lets you add flags).
But as mentioned offline, I don't think we actually have an example of an 
editor this fixes (I think it fixes neither vscode nor coc.nvim). So in that 
case we shouldn't land it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74555



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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-14 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D74436#1875320 , @mibintc wrote:

> @jsji Will your backend tolerate -ffp-contract=on if optimizations are not 
> disabled, e.g. -O2?  We are proposing that the default floating point model 
> be -ffp-model=precise, and with precise model, the ffp-contract=on. However 
> you are right we don't want the frontend to create FMA when optimizations are 
> disabled -O0


We normally default to `-ffp-contract=on ` only for -O3 and above (for legacy 
compilers XL/gcc on PowerPC).
But yes, I think we are OK to accept  `-ffp-contract=on` (not 
`-ffp-contract=fast`)  at -O2 if there are strong justifications to do so on 
clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added a comment.

Still not sure why all the tests are needed here. The first one looks fine, 
i.e. we test that --fortran-fe= 
calls to that copy. The second one appears to test the default behaviour with 
no option, but why does it do it via a different name for clang, why would that 
make a difference? The second uses a different name for both driver and 
frontend. Why is that test relevant to the change you have made? As far as I 
can see, the name of the driver binary has no bearing on its behaviour wrt. 
calling a frontend binary. What am I missing?




Comment at: clang/include/clang/Driver/Options.td:268
+def fortran_fe : Separate<["-"], "fortran-fe">, InternalDriverOpt,
+  HelpText<"Name for native Fortran compiler">;
 

This is not right. I think the option points the driver at the name of the 
Fortran frontend to call. I don't think that has to be native or otherwise. 
Suggest changing this string to "Name for Fortran frontend"



Comment at: clang/test/Driver/flang/clang-driver-2-frontend01.f90:10
+! RUN: cp %clang %t1
+! RUN: %clang --driver-mode=flang -fortran-fe %basename_t.tmp1 -### %s 2>&1 | 
FileCheck --check-prefixes=ALL %s
+

Does %t1 not work again on this line?



Comment at: clang/test/Driver/flang/flang-driver-2-frontend01.f90:10
+
+! The invocations should begin with .tmp1 -fc1.
+! ALL-LABEL: "{{[^"]*}}flang" "-fc1"

No they shouldn't ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added inline comments.



Comment at: clang/include/clang/Driver/Options.td:268
+def fortran_fe : Separate<["-"], "fortran-fe">, InternalDriverOpt,
+  HelpText<"Name for native Fortran compiler">;
 

richard.barton.arm wrote:
> This is not right. I think the option points the driver at the name of the 
> Fortran frontend to call. I don't think that has to be native or otherwise. 
> Suggest changing this string to "Name for Fortran frontend"
I prefer the new option name though - thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-14 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto marked an inline comment as done.
CarolineConcatto added inline comments.



Comment at: clang/test/Driver/flang/clang-driver-2-frontend01.f90:10
+! RUN: cp %clang %t1
+! RUN: %clang --driver-mode=flang -fortran-fe %basename_t.tmp1 -### %s 2>&1 | 
FileCheck --check-prefixes=ALL %s
+

richard.barton.arm wrote:
> Does %t1 not work again on this line?
If I don't create the fake link getProgramPath will only return the name, not 
the entire path.
t1 here is the path for the frontend.  
For instance:
clang --driver-mode=flang -fortran-fe %test
the frontend name is test, but when running it should print:
 /test -fc1
 without the link it will only print:
test -fc1
Like I said before it is more a preference that actually a requisite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D74571: [OpenMP][CUDA] Add CUDA 10.2 support

2020-02-14 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added a comment.

Thanks for all the comments.  It makes sense to keep the warning there before 
any ptx65 features are added.  The warning should also apply to both the CUDA 
and OpenMP compile paths.  As a result, I will pursue to ignore the warning in 
the build of libomp (i.e. libomp_check_linker_flag function in 
LibompCheckLinkerFlag.cmake).  I think it is less pervasive and also can avoid 
similar occurrence when a new version of CUDA toolkit is available.

Comments?


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

https://reviews.llvm.org/D74571



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


[PATCH] D74620: [ARM,MVE] Add vector-scalar intrinsics

2020-02-14 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

I would prefer not to format the Clang test cases to avoid code churn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74620



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


[PATCH] D74571: [OpenMP][CUDA] Add CUDA 10.2 support

2020-02-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D74571#1876617 , @kkwli0 wrote:

> Thanks for all the comments.  It makes sense to keep the warning there before 
> any ptx65 features are added.  The warning should also apply to both the CUDA 
> and OpenMP compile paths.  As a result, I will pursue to ignore the warning 
> in the build of libomp (i.e. libomp_check_linker_flag function in 
> LibompCheckLinkerFlag.cmake).  I think it is less pervasive and also can 
> avoid similar occurrence when a new version of CUDA toolkit is available.
>
> If users are annoyed by many many warning messages in the build, as @tra 
> suggested, users can just use -Wno-unknown-cuda-version to suppress it.
>
> Comments?


That sounds like the right approach for OpenMP. We require a minimal CUDA 
version, based on what we use internally, but no maximal version if possible 
since we don't use new features anyway.


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

https://reviews.llvm.org/D74571



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


[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from some small nits.




Comment at: clang/include/clang/Basic/Attr.td:186-192
+// an OMPTraitInfo object. The structure of an OMPTraitInfo object is a
+// tree as defined below:
+//
+//   OMPTraitInfo := {list}
+//   OMPTraitSet  := {Kind, list}
+//   OMPTraitSelector := {Kind, Expr, list}
+//   OMPTraitProperty := {Kind}

Rather than describing the internal data structure form, I am hoping for 
comments that show the format of the user-facing pragma arguments. e.g., what 
information is in what position. Basically, something so I can mentally map 
from "OMPTraitsInfoArgument" to "oh, that's right, the arguments are specified 
in this order with these types" (roughly -- a general idea of the argument is 
all I'm looking for).



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1379
   // Parse inner context selectors.
-  SmallVector Data;
-  if (!parseOpenMPContextSelectors(Loc, Data)) {
-// Parse ')'.
-(void)T.consumeClose();
-// Need to check for extra tokens.
-if (Tok.isNot(tok::annot_pragma_openmp_end)) {
-  Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
-  << getOpenMPDirectiveName(OMPD_declare_variant);
-}
-  }
+  OMPTraitInfo *TI = new OMPTraitInfo();
+  parseOMPContextSelectors(Loc, *TI);

jdoerfert wrote:
> jdoerfert wrote:
> > aaron.ballman wrote:
> > > What is responsible for freeing this memory?
> > Will check and fix if needed.
> I made sure all OMPTraitInfo are freed, I think. If an 
> `OMPDeclareVariantAttr` is build its taking owenership and calls delete in 
> the destructor.
That is reasonable enough -- any chance we can easily turn it into a 
`std::unique_ptr<>` and then get rid of the destructor entirely? I don't 
insist, but it would be cleaner, to my thinking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71830



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


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 244691.
Anastasia added a comment.
Herald added a reviewer: jdoerfert.

- Switched to using `CheckAssignmentConstraints`
- Duplicated all extensions and warnings as errors for C++ mode
- Added `IncompatibleFunctionPointer`


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

https://reviews.llvm.org/D74116

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/conv/conv.fctptr/p1.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/except/except.handle/p16.cpp
  clang/test/CXX/expr/p13.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
  clang/test/OpenMP/allocate_allocator_messages.cpp
  clang/test/SemaCXX/addr-of-overloaded-function.cpp
  clang/test/SemaCXX/decl-microsoft-call-conv.cpp
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/ms-property-error.cpp
  clang/test/SemaObjCXX/arc-type-conversion.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instantiate-expr.mm
  clang/test/SemaObjCXX/instantiate-stmt.mm
  clang/test/SemaObjCXX/noescape.mm
  clang/test/SemaObjCXX/nullability-pragmas.mm
  clang/test/SemaObjCXX/objc-container-subscripting.mm
  clang/test/SemaObjCXX/parameterized_classes_subst.mm
  clang/test/SemaObjCXX/property-invalid-type.mm
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaTemplate/extern-templates.cpp
  clang/test/SemaTemplate/instantiate-member-class.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -194,7 +194,7 @@
   template
   struct Y {
 static void f(T x) { 
-  x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+  x = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
 }
   };
 
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -156,7 +156,7 @@
 void get(B **ptr) {
   // It's okay if at some point we figure out how to diagnose this
   // at instantiation time.
-  *ptr = field; // expected-error {{assigning to 'test6::B *' from incompatible type 'test6::A *}}
+  *ptr = field; // expected-error {{incompatible pointer types assigning to 'test6::B *' from 'test6::A *'}}
 }
   };
 }
Index: clang/test/SemaTemplate/instantiate-member-class.cpp
===
--- clang/test/SemaTemplate/instantiate-member-class.cpp
+++ clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -43,8 +43,8 @@
 X::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
 
 void test_naming() {
-  c1 = c2; // expected-error{{assigning to 'X::C *' from incompatible type 'X::C *'}}
-  xi = xf;  // expected-error{{assigning to 'X::X *' from incompatible type 'X::X *'}}
+  c1 = c2; // expected-error{{incompatible pointer types assigning to 'X::C *' from 'X::C *'}}
+  xi = xf;  // expected-error{{incompatible pointer types assigning to 'X::X *' from 'X::X *'}}
 // FIXME: error above doesn't print the type X::X cleanly!
 }
 
Index: clang/test/SemaTemplate/extern-templates.cpp
===
--- clang/test/SemaTemplate/extern-templates.cpp
+++ clang/test/SemaTemplate/extern-templates.cpp
@@ -23,9 +23,9 @@
 template
 void X0::Inner::g(T t) {
 #ifdef MS
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}} expected-error{{assigning to 'int *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}} expected-error{{incompatible integer to pointer conversion assigning to 'int *'}}
 #else
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}}
 #endif
 }
 
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -20,7 +20,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-error@-2 {{assigning '__constant int *' to '__generic int *__private' changes address space of pointer}}
 #else
-// expected-error@-4 {{assigning to '__generic int *' f

[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> It looks like there's already some type analysis in 
> `DiagnoseAssignmentResult` to get a specialized diagnostic for certain cases 
> of function-pointer assignment.  That could probably be easily moved into 
> `CheckAssignmentConstraints` by just adding a few more cases to 
> `AssignConvertResult`.

One interesting effect I get after modifying this that some extra tests in C 
mode started to report function pointer instead of generic pointer warning. I 
feel this is because in `checkPointerTypesForAssignment`  we use canonical 
types and in `DiagnoseAssignmentResult` we don't.

Perhaps this way is better? I can update the test if so and then finalize some 
other bits.

  FAIL: Clang :: Sema/block-return.c (9341 of 16808)
   TEST 'Clang :: Sema/block-return.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -Wno-int-to-pointer-cast 
-pedantic -fsyntax-only <...>clang/test/Sema/block-return.c -verify -fblocks
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/block-return.c Line 82: incompatible pointer 
types initializing 'int (*)(const char *)' with an expression of type 'int 
(char *)'
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/block-return.c Line 82: incompatible function 
pointer types initializing 'int (*)(const char *)' with an expression of type 
'int (char *)'
  2 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv-ms_abi.c (9396 of 16808)
   TEST 'Clang :: Sema/callingconv-ms_abi.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
-triple x86_64-pc-win32 <...>clang/test/Sema/callingconv-ms_abi.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv-ms_abi.c Line 7: incompatible pointer 
types
File <...>clang/test/Sema/callingconv-ms_abi.c Line 9: incompatible pointer 
types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv-ms_abi.c Line 7: incompatible 
function pointer types initializing 'void (*)(void)' with an expression of type 
'void (void) __attribute__((sysv_abi))'
File <...>clang/test/Sema/callingconv-ms_abi.c Line 9: incompatible 
function pointer types initializing 'void (*)(void) __attribute__((sysv_abi))' 
with an expression of type 'void (void) __attribute__((ms_abi))'
  4 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv-sysv_abi.c (9397 of 16808)
   TEST 'Clang :: Sema/callingconv-sysv_abi.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
-triple x86_64-pc-linux-gnu <...>clang/test/Sema/callingconv-sysv_abi.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 4: incompatible 
pointer types
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 9: incompatible 
pointer types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 4: incompatible 
function pointer types initializing 'void (*)(void)' with an expression of type 
'void (void) __attribute__((ms_abi))'
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 9: incompatible 
function pointer types initializing 'void (*)(void) __attribute__((ms_abi))' 
with an expression of type 'void (void) __attribute__((sysv_abi))'
  4 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv.c (9398 of 16808)
   TEST 'Clang :: Sema/callingconv.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc 
<...>clang/test/Sema/callingconv.c -fsyntax-only -triple i386-unknown-unknown 
-verify
  : 'RUN: at line 2';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc 
<...>clang/test/Sema/callingconv.c -fsyntax-only -triple i386-unknown-unknown 
-fms-compatibility -DWIN -verify
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv.c Line 34: incompatible pointer types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv.c Line 34: incompatible function 
pointer types initializing 'void (*)(void) __attr

[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The C diagnostic changes seem like improvements, yeah.  The virtue of re-using 
the same infrastructure across language modes.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

This assertion seems important; can we make it work?


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

https://reviews.llvm.org/D74116



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.

aaron.ballman wrote:
> I'd like a few more test cases:
> ```
> // Test that a non-prototyped definition with no preceding prototype whines 
> about lacking a preceding prototype
> void fooN() {} // expected-warning {{this old-style function definition is 
> not preceded by a prototype}}
> 
> // Test that an existing declaration with no prototype still warns that a 
> corresponding definition with a type list is still not preceded by a 
> prototype.
> void fooN1(); // expected-warning {{this function declaration is not a 
> prototype}}
> void fooN1(void) {} // expected-warning {{this old-style function definition 
> is not preceded by a prototype}}
> ```
I guess we want the warning only on the declaration of `fooN1`, not the 
definition? Because that's not an old-style function definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.

aaronpuchert wrote:
> aaron.ballman wrote:
> > I'd like a few more test cases:
> > ```
> > // Test that a non-prototyped definition with no preceding prototype whines 
> > about lacking a preceding prototype
> > void fooN() {} // expected-warning {{this old-style function definition is 
> > not preceded by a prototype}}
> > 
> > // Test that an existing declaration with no prototype still warns that a 
> > corresponding definition with a type list is still not preceded by a 
> > prototype.
> > void fooN1(); // expected-warning {{this function declaration is not a 
> > prototype}}
> > void fooN1(void) {} // expected-warning {{this old-style function 
> > definition is not preceded by a prototype}}
> > ```
> I guess we want the warning only on the declaration of `fooN1`, not the 
> definition? Because that's not an old-style function definition.
Yeah, I'm not sure about `fooN1`. We can't emit the warning on the definition 
(and I think we also don't need to, as we diagnose that before), and the 
warning on the declaration is kind of tested already. (Note that there is also 
`-Wmissing-prototypes`.)

But `fooN` definitely makes sense, I'll add that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.

aaronpuchert wrote:
> aaronpuchert wrote:
> > aaron.ballman wrote:
> > > I'd like a few more test cases:
> > > ```
> > > // Test that a non-prototyped definition with no preceding prototype 
> > > whines about lacking a preceding prototype
> > > void fooN() {} // expected-warning {{this old-style function definition 
> > > is not preceded by a prototype}}
> > > 
> > > // Test that an existing declaration with no prototype still warns that a 
> > > corresponding definition with a type list is still not preceded by a 
> > > prototype.
> > > void fooN1(); // expected-warning {{this function declaration is not a 
> > > prototype}}
> > > void fooN1(void) {} // expected-warning {{this old-style function 
> > > definition is not preceded by a prototype}}
> > > ```
> > I guess we want the warning only on the declaration of `fooN1`, not the 
> > definition? Because that's not an old-style function definition.
> Yeah, I'm not sure about `fooN1`. We can't emit the warning on the definition 
> (and I think we also don't need to, as we diagnose that before), and the 
> warning on the declaration is kind of tested already. (Note that there is 
> also `-Wmissing-prototypes`.)
> 
> But `fooN` definitely makes sense, I'll add that.
I think you're right about the `fooN1` definition not needing a warning -- I 
was thinking we wanted to warn because there was no preceding prototype, but 
it's not an old-style declaration at that definition. You can ignore that 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-14 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a subscriber: scanon.
andrew.w.kaylor added a comment.

In D74436#1875320 , @mibintc wrote:

> However you are right we don't want the frontend to create FMA when 
> optimizations are disabled -O0


I've been discussing this with @scanon on the cfe-dev mailing list, and he has 
convinced me that we should create FMA options at -O0 if the fp-contract 
setting is "on" -- including when it is on by default. The reasoning that 
persuaded me was, "preserving FMA formation at O0 _helps_ debuggability, 
because it means that numerical behavior is more likely to match what a user 
observed at Os, allowing them to debug the problem."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 5 inline comments as done.
aaronpuchert added a comment.

Thanks!




Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.

aaron.ballman wrote:
> aaronpuchert wrote:
> > aaronpuchert wrote:
> > > aaron.ballman wrote:
> > > > I'd like a few more test cases:
> > > > ```
> > > > // Test that a non-prototyped definition with no preceding prototype 
> > > > whines about lacking a preceding prototype
> > > > void fooN() {} // expected-warning {{this old-style function definition 
> > > > is not preceded by a prototype}}
> > > > 
> > > > // Test that an existing declaration with no prototype still warns that 
> > > > a corresponding definition with a type list is still not preceded by a 
> > > > prototype.
> > > > void fooN1(); // expected-warning {{this function declaration is not a 
> > > > prototype}}
> > > > void fooN1(void) {} // expected-warning {{this old-style function 
> > > > definition is not preceded by a prototype}}
> > > > ```
> > > I guess we want the warning only on the declaration of `fooN1`, not the 
> > > definition? Because that's not an old-style function definition.
> > Yeah, I'm not sure about `fooN1`. We can't emit the warning on the 
> > definition (and I think we also don't need to, as we diagnose that before), 
> > and the warning on the declaration is kind of tested already. (Note that 
> > there is also `-Wmissing-prototypes`.)
> > 
> > But `fooN` definitely makes sense, I'll add that.
> I think you're right about the `fooN1` definition not needing a warning -- I 
> was thinking we wanted to warn because there was no preceding prototype, but 
> it's not an old-style declaration at that definition. You can ignore that 
> suggestion.
Ok, then I'll submit this with `fooN`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


[clang] 2f26bc5 - Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-02-14T19:25:02+01:00
New Revision: 2f26bc5542705c390bf17af2fdfc31e056147ea9

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

LOG: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

Summary:
Zero-parameter K&R definitions specify that the function has no
parameters, but they are still not prototypes, so calling the function
with the wrong number of parameters is just a warning, not an error.

The C11 standard doesn't seem to directly define what a prototype is,
but it can be inferred from 6.9.1p7: "If the declarator includes a
parameter type list, the list also specifies the types of all the
parameters; such a declarator also serves as a function prototype
for later calls to the same function in the same translation unit."
This refers to 6.7.6.3p5: "If, in the declaration “T D1”, D1 has
the form
D(parameter-type-list)
or
D(identifier-list_opt)
[...]". Later in 6.11.7 it also refers only to the parameter-type-list
variant as prototype: "The use of function definitions with separate
parameter identifier and declaration lists (not prototype-format
parameter type and identifier declarators) is an obsolescent feature."

We already correctly treat an empty parameter list as non-prototype
declaration, so we can just take that information.

GCC also warns about this with -Wstrict-prototypes.

This shouldn't affect C++, because there all FunctionType's are
FunctionProtoTypes. I added a simple test for that.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Sema/warn-strict-prototypes.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/warn-strict-prototypes.c
clang/test/Sema/warn-strict-prototypes.m

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ff0bd939613c..4c088aa47f55 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14154,11 +14154,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
   //   Warn if K&R function is defined without a previous declaration.
   //   This warning is issued only if the definition itself does not 
provide
   //   a prototype. Only K&R definitions do not provide a prototype.
-  //   An empty list in a function declarator that is part of a definition
-  //   of that function specifies that the function has no parameters
-  //   (C99 6.7.5.3p14)
-  if (!FD->hasWrittenPrototype() && FD->getNumParams() > 0 &&
-  !LangOpts.CPlusPlus) {
+  if (!FD->hasWrittenPrototype()) {
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
 FunctionTypeLoc FTL = TL.getAsAdjusted();

diff  --git a/clang/test/Sema/warn-strict-prototypes.c 
b/clang/test/Sema/warn-strict-prototypes.c
index 5565a09060fc..50b0f7d060f2 100644
--- a/clang/test/Sema/warn-strict-prototypes.c
+++ b/clang/test/Sema/warn-strict-prototypes.c
@@ -1,15 +1,18 @@
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes 
-Wno-implicit-function-declaration -verify %s
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
+// function definition with 0 params, no prototype, no preceding declaration.
+void foo0() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+
 // function declaration with unspecified params
 void foo1(); // expected-warning {{this function declaration is not a 
prototype}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:"void"
 // function declaration with 0 params
 void foo2(void);
 
-// function definition with 0 params(for both cases),
-// valid according to 6.7.5.3/14
-void foo1() {}
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.
 void foo2(void) {}
 
 // function type typedef unspecified params

diff  --git a/clang/test/Sema/warn-strict-prototypes.cpp 
b/clang/test/Sema/warn-strict-prototypes.cpp
new file mode 100644
index ..6a3839ff9367
--- /dev/null
+++ b/clang/test/Sema/warn-strict-prototypes.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wstrict-prototypes %s
+// expected-no-diagnostics
+
+void decl();
+void decl_void(void);
+
+void def() {}
+void def_void(void) {}

diff  --git a/clang/test/Sema/warn-strict-prototypes.m 
b/clang/test/Sema/warn-strict-prototypes.m
index 66d574f75f80..e2fde8ee38fc 100644
--- a/clang/test/Sema/warn-strict-prototypes.m
+++ b/clang/test/Sema/warn-strict-prototypes.m
@@ -10,7 +10,7 @@ @interface Foo
 
 @end

[PATCH] D74555: [clangd] Add a flag for setting isIncomplete flag true in all responses

2020-02-14 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev abandoned this revision.
kbobyrev added a comment.

Okay, makes sense!


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

https://reviews.llvm.org/D74555



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rG2f26bc554270: Warn about zero-parameter K&R definitions 
in -Wstrict-prototypes (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D66919?vs=217751&id=244705#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-strict-prototypes.c
  clang/test/Sema/warn-strict-prototypes.cpp
  clang/test/Sema/warn-strict-prototypes.m


Index: clang/test/Sema/warn-strict-prototypes.m
===
--- clang/test/Sema/warn-strict-prototypes.m
+++ clang/test/Sema/warn-strict-prototypes.m
@@ -10,7 +10,7 @@
 
 @end
 
-void foo() {
+void foo() { // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
   void (^block)() = // expected-warning {{this block declaration is not a 
prototype}}
 ^void(int arg) { // no warning
   };
Index: clang/test/Sema/warn-strict-prototypes.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-strict-prototypes.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wstrict-prototypes %s
+// expected-no-diagnostics
+
+void decl();
+void decl_void(void);
+
+void def() {}
+void def_void(void) {}
Index: clang/test/Sema/warn-strict-prototypes.c
===
--- clang/test/Sema/warn-strict-prototypes.c
+++ clang/test/Sema/warn-strict-prototypes.c
@@ -1,15 +1,18 @@
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes 
-Wno-implicit-function-declaration -verify %s
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
+// function definition with 0 params, no prototype, no preceding declaration.
+void foo0() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+
 // function declaration with unspecified params
 void foo1(); // expected-warning {{this function declaration is not a 
prototype}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:"void"
 // function declaration with 0 params
 void foo2(void);
 
-// function definition with 0 params(for both cases),
-// valid according to 6.7.5.3/14
-void foo1() {}
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not 
preceded by a prototype}}
+// function definition with 0 params, prototype.
 void foo2(void) {}
 
 // function type typedef unspecified params
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14154,11 +14154,7 @@
   //   Warn if K&R function is defined without a previous declaration.
   //   This warning is issued only if the definition itself does not 
provide
   //   a prototype. Only K&R definitions do not provide a prototype.
-  //   An empty list in a function declarator that is part of a definition
-  //   of that function specifies that the function has no parameters
-  //   (C99 6.7.5.3p14)
-  if (!FD->hasWrittenPrototype() && FD->getNumParams() > 0 &&
-  !LangOpts.CPlusPlus) {
+  if (!FD->hasWrittenPrototype()) {
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
 FunctionTypeLoc FTL = TL.getAsAdjusted();


Index: clang/test/Sema/warn-strict-prototypes.m
===
--- clang/test/Sema/warn-strict-prototypes.m
+++ clang/test/Sema/warn-strict-prototypes.m
@@ -10,7 +10,7 @@
 
 @end
 
-void foo() {
+void foo() { // expected-warning {{this old-style function definition is not preceded by a prototype}}
   void (^block)() = // expected-warning {{this block declaration is not a prototype}}
 ^void(int arg) { // no warning
   };
Index: clang/test/Sema/warn-strict-prototypes.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-strict-prototypes.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wstrict-prototypes %s
+// expected-no-diagnostics
+
+void decl();
+void decl_void(void);
+
+void def() {}
+void def_void(void) {}
Index: clang/test/Sema/warn-strict-prototypes.c
===
--- clang/test/Sema/warn-strict-prototypes.c
+++ clang/test/Sema/warn-strict-prototypes.c
@@ -1,15 +1,18 @@
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-o

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, I agree with Steve here.  The great virtue of `-ffp-contract=on` over the 
more aggressive modes is that FMA formation is purely local to a single source 
expression, which means there's really no obstacle to treating it as 
implementation-guaranteed semantics.  Such behavior should be done consistently 
across compiler settings rather than potentially making the numeric result of 
an expression subject to optimizer settings and choices; the latter is fine for 
"fast" modes but not really acceptable as the default compiler behavior.  If a 
backend needs to legalize the intrinsic back to separate multiply + add 
instructions, that's okay, but it should do so consistently rather than only 
under a specific optimization level.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436



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


[PATCH] D74631: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-14 Thread David Tenty via Phabricator via cfe-commits
daltenty created this revision.
daltenty added reviewers: stevewan, sfertile, Xiangling_L.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.
daltenty updated this revision to Diff 244708.
daltenty added a comment.

- Add missing newline


XCOFF doesn't support COMDATs, so clang shouldn't emit them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74631

Files:
  clang/test/CodeGen/xcoff-comdat.cpp
  llvm/include/llvm/ADT/Triple.h


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74631: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-14 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 244708.
daltenty added a comment.

- Add missing newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74631

Files:
  clang/test/CodeGen/xcoff-comdat.cpp
  llvm/include/llvm/ADT/Triple.h


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7053065 - Fix tests after previous commit

2020-02-14 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2020-02-14T19:41:01+01:00
New Revision: 705306526b5ca7eed2fa28ebf832873cbb5085ec

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

LOG: Fix tests after previous commit

We don't want to test for this warning, so we just fix it.

Added: 


Modified: 
clang/test/Preprocessor/Weverything_pragma.c
clang/test/Preprocessor/pragma_diagnostic.c
clang/test/Preprocessor/pushable-diagnostics.c
clang/test/Sema/warn-unused-parameters.c

Removed: 




diff  --git a/clang/test/Preprocessor/Weverything_pragma.c 
b/clang/test/Preprocessor/Weverything_pragma.c
index 1815f554fffd..f2cf97ed4a1c 100644
--- a/clang/test/Preprocessor/Weverything_pragma.c
+++ b/clang/test/Preprocessor/Weverything_pragma.c
@@ -6,7 +6,7 @@
 // but -Weverything forces it
 #define UNUSED_MACRO1 1 // expected-warning{{macro is not used}}
 
-void foo() // expected-warning {{no previous prototype for function}}
+void foo(void) // expected-warning {{no previous prototype for function}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 {
  // A diagnostic without DefaultIgnore, and not part of a group.

diff  --git a/clang/test/Preprocessor/pragma_diagnostic.c 
b/clang/test/Preprocessor/pragma_diagnostic.c
index 99724623207f..75d2bbc7190f 100644
--- a/clang/test/Preprocessor/pragma_diagnostic.c
+++ b/clang/test/Preprocessor/pragma_diagnostic.c
@@ -35,19 +35,19 @@
 #endif
 
 // Testing pragma clang diagnostic with -Weverything
-void ppo(){} // First test that we do not diagnose on this.
+void ppo(void){} // First test that we do not diagnose on this.
 
 #pragma clang diagnostic warning "-Weverything"
-void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
+void ppp(void){} // expected-warning {{no previous prototype for function 
'ppp'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic ignored "-Weverything" // Reset it.
-void ppq(){}
+void ppq(void){}
 
 #pragma clang diagnostic error "-Weverything" // Now set to error
-void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
+void ppr(void){} // expected-error {{no previous prototype for function 'ppr'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic warning "-Weverything" // This should not be effective
-void pps(){} // expected-error {{no previous prototype for function 'pps'}}
+void pps(void){} // expected-error {{no previous prototype for function 'pps'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}

diff  --git a/clang/test/Preprocessor/pushable-diagnostics.c 
b/clang/test/Preprocessor/pushable-diagnostics.c
index 4a0dd895a78e..9eaf87d58f82 100644
--- a/clang/test/Preprocessor/pushable-diagnostics.c
+++ b/clang/test/Preprocessor/pushable-diagnostics.c
@@ -18,28 +18,28 @@ int c = 'df';  // expected-warning{{multi-character 
character constant}}
 
 // Test -Weverything
 
-void ppo0(){} // first verify that we do not give anything on this
+void ppo0(void){} // first verify that we do not give anything on this
 #pragma clang diagnostic push // now push
 
 #pragma clang diagnostic warning "-Weverything" 
-void ppr1(){} // expected-warning {{no previous prototype for function 'ppr1'}}
+void ppr1(void){} // expected-warning {{no previous prototype for function 
'ppr1'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic push // push again
 #pragma clang diagnostic ignored "-Weverything"  // Set to ignore in this 
level.
-void pps2(){}
+void pps2(void){}
 #pragma clang diagnostic warning "-Weverything"  // Set to warning in this 
level.
-void ppt2(){} // expected-warning {{no previous prototype for function 'ppt2'}}
+void ppt2(void){} // expected-warning {{no previous prototype for function 
'ppt2'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 #pragma clang diagnostic error "-Weverything"  // Set to error in this level.
-void ppt3(){} // expected-error {{no previous prototype for function 'ppt3'}}
+void ppt3(void){} // expected-error {{no previous prototype for function 
'ppt3'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 #pragma clang diagnostic pop // pop should go back to warning level
 
-void pps1(){} // expected-warning {{no previous prototype for function 'pps1'}}
+void pps1(void){} // expected-warning {{no previous pro

[PATCH] D74572: [WIP][BPF] implement intrinsic function __builtin__btf_type_id()

2020-02-14 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 244709.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

Addressing some Alexei's comments:

  Change comments in clang CGBuiltin.cpp to make it easier to understand.
  Remove BPFMIPreserveDIType.cpp and fold into existing 
BPFMISimplifyPatchable.cpp.
  Other Simplifications.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74572

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  llvm/include/llvm/IR/IntrinsicsBPF.td
  llvm/lib/Target/BPF/BPF.h
  llvm/lib/Target/BPF/BPFCORE.h
  llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
  llvm/lib/Target/BPF/BPFPreserveDIType.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/lib/Target/BPF/BTFDebug.h
  llvm/lib/Target/BPF/CMakeLists.txt
  llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll

Index: llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
@@ -0,0 +1,147 @@
+; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfel -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+;
+; Source code:
+;   static int (*bpf_log)(unsigned tid, void *data, int data_size) = (void *)999;
+;   struct {
+; char f1[100];
+; typeof(3) f2;
+;   } tmp__abc = {1, 3};
+;   void prog1() {
+; bpf_log(__builtin_btf_type_id(tmp__abc), &tmp__abc, sizeof(tmp__abc));
+;   }
+;   void prog2() {
+; bpf_log(__builtin_btf_type_id(&tmp__abc), &tmp__abc, sizeof(tmp__abc));
+;   }
+;   void prog3() {
+; bpf_log(__builtin_btf_type_id(tmp__abc.f1[3]), &tmp__abc, sizeof(tmp__abc));
+;   }
+; Compilation flag:
+;   clang -target bpf -O2 -g -S -emit-llvm test.c
+
+%struct.anon = type { [100 x i8], i32 }
+
+@tmp__abc = dso_local global { <{ i8, i8, [98 x i8] }>, i32 } { <{ i8, i8, [98 x i8] }> <{ i8 1, i8 3, [98 x i8] zeroinitializer }>, i32 0 }, align 4, !dbg !0
+
+; Function Attrs: nounwind
+define dso_local void @prog1() local_unnamed_addr #0 !dbg !28 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon* bitcast ({ <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc to %struct.anon*), i32 1), !dbg !31, !llvm.preserve.access.index !7
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !32
+  ret void, !dbg !33
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon*, i32) #1
+
+; Function Attrs: nounwind
+define dso_local void @prog2() local_unnamed_addr #0 !dbg !34 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon* bitcast ({ <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc to %struct.anon*), i32 0), !dbg !35, !llvm.preserve.access.index !6
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !36
+  ret void, !dbg !37
+}
+
+; Function Attrs: nounwind
+define dso_local void @prog3() local_unnamed_addr #0 !dbg !38 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0i8.i32(i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 2, i64 1), i32 1), !dbg !39, !llvm.preserve.access.index !11
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !40
+  ret void, !dbg !41
+}
+
+; CHECK-LABEL:   prog1
+; CHECK: r1 = 3
+; CHECK-LABEL:   prog2
+; CHECK: r1 = 10
+; CHECK-LABEL:   prog3
+; CHECK: r1 = 4
+;
+; CHECK: .long   0   # BTF_KIND_STRUCT(id = 3)
+; CHECK-NEXT:.long   67108866# 0x402
+; CHECK-NEXT:.long   104
+; CHECK-NEXT:.long   13
+; CHECK-NEXT:.long   5
+; CHECK-NEXT:.long   0   # 0x0
+; CHECK-NEXT:.long   16
+; CHECK-NEXT:.long   7
+; CHECK-NEXT:.long   800 # 0x320
+; CHECK-NEXT:.long   19  # BTF_KIND_INT(id = 4)
+; CHECK-NEXT:.long   16777216# 0x100
+; CHECK-NEXT:.long   1
+; CHECK-NEXT:.long   16777224# 0x108
+; CHECK: .long   0 

[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-14 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 3 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:520
+
+class XLCXXABI final : public ItaniumCXXABI {
+public:

sfertile wrote:
> Xiangling_L wrote:
> > sfertile wrote:
> > > Here would be a good place to add a comment to indicate that XL has 
> > > several C++ ABIs, but this represents the one used in 'xlClang++'.
> > You mean we have legacy XLC and XLClang++ ABI? But for static init, they 
> > have same implementation. So it's not a must to point it out. 
> > 
> > And also AFAIK, `static init` is the only thing we will differ from Generic 
> > Itanium ABI in the frontend, so basically it's the only thing we will add 
> > in this ABI.
> > 
> > I am okay with either way with a little concern that legacy XLC user may 
> > wonder is there any difference of static init implementation between XLC 
> > and XLClang++ ABI if we add the comment.
> Sorry, I had a matching comment on the 'XL' enum, but I must have deleted it 
> accidentally before submitting. I said I agreed with using just 'XL' since 
> there is only one XL C++ ABI implemented in Clang we don't have to worry 
> about differentiating between the 'legacy' XL and the C++11 XL ABIs. If you 
> did want to clarify then adding a comment here would be the only thing I 
> suggest.
I see. Thank you for your clarification.


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

https://reviews.llvm.org/D74015



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


[PATCH] D74571: [OpenMP][CUDA] Add CUDA 10.2 support

2020-02-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D74571#1876647 , @jdoerfert wrote:

> That sounds like the right approach for OpenMP. We require a minimal CUDA 
> version, based on what we use internally, but no maximal version if possible 
> since we don't use new features anyway.


SGTM, with a caveat.

Word of caution -- it's not just the features. New CUDA versions also come with 
sometimes substantially different header files. Clang pre-includes a lot of 
them, so if the new headers have something funky, clang may need extra changes 
before it can compile anything, even if you don't use the new features.

If you silence compiler with the option set during build config, it may be 
prudent to tell the user that CUDA compilation *may* fail if the CUDA version 
if not one of the known "not quite supported, but usable on par with the oldest 
supported version."


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

https://reviews.llvm.org/D74571



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


[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-14 Thread George Rokos via Phabricator via cfe-commits
grokos marked 2 inline comments as done.
grokos added a comment.

In D74262#1867245 , @ABataev wrote:

> Partial linking may lead to some incorrect results with global constructors. 
> How are you going to handle this?


Can you give me an example of what can break? I remember reading a conversation 
about some linker patch some time ago but I cannot recall the details.




Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:84
"  o   - object\n"
+   "  oo  - object; output file is a list of unbundled 
objects\n"
"  gch - precompiled-header\n"

jdoerfert wrote:
> ABataev wrote:
> > Hmm, are you going to introduce a new kind of output? It really requires 
> > RFC.
> This is the offload-bundler tool, right? Who is using that except OpenMP (and 
> SYCL)?
> 
> Is there a reason for `oo`? `uo` (=unboundled object), or `do` (=device 
> object)?
No one else (at least for now). But I can send out an RFC regarding the new 
output anyway.

`oo` is related to the fact that under this scheme we can have multiple `.o` 
files as output (many `o`'s). But if you think some of the other abbreviations 
makes more sense, I'm happy to change it.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:160
+  }
+
   /// Write the header of the bundled file to \a OS based on the information

jdoerfert wrote:
> I don't understand the comment. If \p FileName is a list of outputs, how does 
> this work?
The scheme is described in the attached pdf. In short, when the host liner 
fetches dependencies from a static library, alongside the host bundle it also 
fetches the device bundle. Now, if we have multiple dependencies from multiple 
objects inside a static library (or multiple static libraries) the host linker 
will perform a partial linking between all fetched bundles for the targets we 
are interested in. The result is a fat object in which each target bundle is 
the result of concatenating the individual bundles for that target we fetched 
from each static library. We also keep track of the size of each fetched bundle 
(we use a new sizes section per target inside the fat object for this purpose) 
so that the unbundler can separate the partially-linked bundle into the 
original object files it was assembled from. Usually, we don't know a priori 
how many dependencies will be brought in, so we don't know how many objects 
we're going to have at outputs. Therefore, in `oo` unbundling mode, the user 
specifies a single output file per target (just like in any other unbundling 
mode) which the unbundler populates with the paths to the actual output device 
objects. Then the driver reads those paths and passes them on to the device 
linker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

2020-02-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Just FYI, I had to fix some tests after this in 
rG705306526b5ca7eed2fa28ebf832873cbb5085ec 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919



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


LLVM buildmaster will be updated and restarted tonight

2020-02-14 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 5PM Pacific time today.

Thanks

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


  1   2   >