[PATCH] D92041: [clangd] Add hover info for `this` expr

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

can you give me an email address to associate the commit with?


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

https://reviews.llvm.org/D92041

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I'm seeing build failures that might be triggered by this patch: 
http://lab.llvm.org:8011/#/builders/109/builds/3714


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[clang] 9738436 - [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

2020-12-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-01T09:24:04+01:00
New Revision: 973843681b9df4ba9303e98f7b4531ba31c2b1bf

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

LOG: [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

Reviewed By: Bigcheese, dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a2dec66692bb..35cd1a4f949e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4062,13 +4062,17 @@ std::string CompilerInvocation::getModuleHash() const {
 
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
+  // Capture the extracted value as a lambda argument to avoid potential issues
+  // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
-  if (((FLAGS) & options::CC1Option) &&
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)&options::CC1Option) {
\
+[&](const auto &Extracted) {   
\
+  if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE)) 
\
+DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);  
\
+}(EXTRACTOR(this->KEYPATH));   
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -4076,10 +4080,10 @@ void CompilerInvocation::generateCC1CommandLine(
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  
\
 NEG_SPELLING)  
\
-  if (((FLAGS)&options::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)&options::CC1Option) {
\
+bool Extracted = EXTRACTOR(this->KEYPATH); 
\
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"



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


[PATCH] D83211: [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG973843681b9d: [clang][cli] Factor out call to EXTRACTOR in 
generateCC1CommandLine (NFC) (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4062,13 +4062,17 @@
 
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
+  // Capture the extracted value as a lambda argument to avoid potential issues
+  // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
-  if (((FLAGS) & options::CC1Option) &&
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)&options::CC1Option) {
\
+[&](const auto &Extracted) {   
\
+  if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE)) 
\
+DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);  
\
+}(EXTRACTOR(this->KEYPATH));   
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -4076,10 +4080,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  
\
 NEG_SPELLING)  
\
-  if (((FLAGS)&options::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)&options::CC1Option) {
\
+bool Extracted = EXTRACTOR(this->KEYPATH); 
\
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4062,13 +4062,17 @@
 
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
+  // Capture the extracted value as a lambda argument to avoid potential issues
+  // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  if (((FLAGS) & options::CC1Option) &&\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  \
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)&options::CC1Option) {\
+[&](const auto &Extracted) {   \
+  if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE)) \
+DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);  \
+}(EXTRACTOR(this->KEYPATH));   \
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   \
@@ -4076,10 +4080,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  \
 NEG_SPELLING)  \
-  if (((FLAGS)&options::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, S

[PATCH] D92041: [clangd] Add hover info for `this` expr

2020-12-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

One last point, is it worth including cv qualifications in the hover info?


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

https://reviews.llvm.org/D92041

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


[clang] 88ab384 - [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

2020-12-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-01T09:50:11+01:00
New Revision: 88ab38449b49bf002ed7794d1b81d362aa9f9df2

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

LOG: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

This makes the options API composable, allows boolean flags to imply 
non-boolean values and makes the code more logical (IMO).

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 48d9607e734a..09c02989a6a8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -246,10 +246,11 @@ def clang_ignored_gcc_optimization_f_Group : OptionGroup<
 // This is useful if the option is usually disabled.
 multiclass OptInFFlag flags=[], code 
keypath="",
-  DefaultAnyOf defaults = DefaultAnyOf<[]>> {
+  list enablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag,
+   ImpliedByAnyOf;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText;
 }
@@ -258,12 +259,13 @@ multiclass OptInFFlag flags=[], code 
keypath="",
-   DefaultAnyOf defaults = DefaultAnyOf<[]>> {
+   list disablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag,
+   ImpliedByAnyOf;
 }
 
 multiclass BooleanMarshalledFFlag {
@@ -606,7 +608,8 @@ def cl_fast_relaxed_math : Flag<["-"], 
"cl-fast-relaxed-math">, GroupFastRelaxedMath">;
 def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise MAD computations in the 
generated binary.">,
-  MarshallingInfoFlag<"CodeGenOpts.LessPreciseFPMAD", 
DefaultAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>>;
+  MarshallingInfoFlag<"CodeGenOpts.LessPreciseFPMAD">,
+  ImpliedByAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>;
 def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">,
   MarshallingInfoFlag<"LangOpts->CLNoSignedZero">;
@@ -1048,10 +1051,11 @@ def ffp_model_EQ : Joined<["-"], "ffp-model=">, 
Group, Flags<[NoXarchOp
 def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Specifies the exception behavior of floating-point operations.">;
 defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy 
floating-point optimizations", "", "", [],
-  "LangOpts->FastMath", DefaultAnyOf<[cl_fast_relaxed_math]>>;
+  "LangOpts->FastMath", [cl_fast_relaxed_math]>;
 def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, 
Flags<[CC1Option]>,
   HelpText<"Allow unsafe floating-point math optimizations which may decrease 
precision">,
-  MarshallingInfoFlag<"LangOpts->UnsafeFPMath", 
DefaultAnyOf<[cl_unsafe_math_optimizations, ffast_math]>>;
+  MarshallingInfoFlag<"LangOpts->UnsafeFPMath">,
+  ImpliedByAnyOf<[cl_unsafe_math_optimizations, ffast_math]>;
 defm math_errno : OptInFFlag<"math-errno", "Require math functions to indicate 
errors by setting errno">;
 def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group, 
Flags<[CoreOption]>;
 def fsignaling_math : Flag<["-"], "fsignaling-math">, Group;
@@ -1265,13 +1269,13 @@ def fno_unsafe_math_optimizations : Flag<["-"], 
"fno-unsafe-math-optimizations">
 def fassociative_math : Flag<["-"], "fassociative-math">, Group;
 def fno_associative_math : Flag<["-"], "fno-associative-math">, Group;
 defm reciprocal_math : OptInFFlag<"reciprocal-math", "Allow division 
operations to be reassociated", "", "", [],
-  "LangOpts->AllowRecip", DefaultAnyOf<[menable_unsafe_fp_math]>>;
+  "LangOpts->AllowRecip", [menable_unsafe_fp_math]>;
 def fapprox_func : Flag<["-"], "fapprox-func">, Group, 
Flags<[CC1Option, NoDriverOption]>,
-  MarshallingInfoFlag<"LangOpts->ApproxFunc", 
DefaultAnyOf<[menable_unsafe_fp_math]>>;
+  MarshallingInfoFlag<"LangOpts->ApproxFunc">, 
ImpliedByAnyOf<[menable_unsafe_fp_mat

[PATCH] D91861: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88ab38449b49: [clang][cli] Split DefaultAnyOf into a default 
value and ImpliedByAnyOf (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D91861?vs=307028&id=308568#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91861

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -71,6 +71,8 @@
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
+  StringRef ImpliedCheck;
+  StringRef ImpliedValue;
   StringRef Normalizer;
   StringRef Denormalizer;
   StringRef ValueMerger;
@@ -113,6 +115,10 @@
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
 OS << ", ";
+OS << ImpliedCheck;
+OS << ", ";
+emitScopedNormalizedValue(OS, ImpliedValue);
+OS << ", ";
 OS << Normalizer;
 OS << ", ";
 OS << Denormalizer;
@@ -188,6 +194,9 @@
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
+  Ret->ImpliedCheck = R.getValueAsString("ImpliedCheck");
+  Ret->ImpliedValue =
+  R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret->DefaultValue);
 
   Ret->Normalizer = R.getValueAsString("Normalizer");
   Ret->Denormalizer = R.getValueAsString("Denormalizer");
Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -46,10 +46,13 @@
 def DashDash : Option<["--"], "", KIND_REMAINING_ARGS>;
 
 def marshalled_flag_d : Flag<["-"], "marshalled-flag-d">,
-  MarshallingInfoFlag<"MarshalledFlagD", DefaultAnyOf<[]>>;
+  MarshallingInfoFlag<"MarshalledFlagD">;
 def marshalled_flag_c : Flag<["-"], "marshalled-flag-c">,
-  MarshallingInfoFlag<"MarshalledFlagC", DefaultAnyOf<[marshalled_flag_d]>>;
+  MarshallingInfoFlag<"MarshalledFlagC">,
+  ImpliedByAnyOf<[marshalled_flag_d], "true">;
 def marshalled_flag_b : Flag<["-"], "marshalled-flag-b">,
-  MarshallingInfoFlag<"MarshalledFlagB", DefaultAnyOf<[marshalled_flag_d]>>;
+  MarshallingInfoFlag<"MarshalledFlagB">,
+  ImpliedByAnyOf<[marshalled_flag_d], "true">;
 def marshalled_flag_a : Flag<["-"], "marshalled-flag-a">,
-  MarshallingInfoFlag<"MarshalledFlagA", DefaultAnyOf<[marshalled_flag_c, marshalled_flag_b]>>;
+  MarshallingInfoFlag<"MarshalledFlagA">,
+  ImpliedByAnyOf<[marshalled_flag_c, marshalled_flag_b]>;
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -11,15 +11,17 @@
 struct OptionWithMarshallingInfo {
   const char *Name;
   const char *KeyPath;
-  const char *DefaultValue;
+  const char *ImpliedCheck;
+  const char *ImpliedValue;
 };
 
 static const OptionWithMarshallingInfo MarshallingTable[] = {
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  {NAME, #KEYPATH, #DEFAULT_VALUE},
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, \
+TABLE_INDEX)   \
+  {NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
 #include "Opts.inc"
 #undef OPTION_WITH_MARSHALLING
 };
@@ -38,10 +40,16 @@
   ASSERT_STREQ(MarshallingTable[3].KeyPath, "MarshalledFlagA");
 }
 
-TEST(OptionMarshalling, DefaultAnyOfConstructedDisjunctionOfKeypaths) {
-  ASSERT_STREQ(MarshallingTable[0].DefaultValue, "false");
-  ASSERT_STREQ(MarshallingTable[1].DefaultValue, "false || MarshalledFlagD");
-  ASSERT_STREQ(MarshallingTable[2].DefaultValue, "false || MarshalledFlagD");
-  ASSERT_STREQ(MarshallingTable[3].DefaultValue,
-"false || MarshalledFlagC || MarshalledFlagB");
+TEST(OptionMarshalling, ImpliedCheckContainsDisjunctionOfKeypaths) {
+  ASSERT_STREQ(MarshallingTable[0].ImpliedCheck, "false");
+
+  ASSERT_STREQ(MarshallingTable[1].ImpliedCheck, "false || MarshalledFlagD");
+  ASSERT_STREQ(MarshallingTable[1].Implie

[PATCH] D92370: [clang] Enable code completion of designated initializers in Compound Literal Expressions

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, hokein, adamcz.
Herald added subscribers: cfe-commits, usaxena95.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added a subscriber: ilya-biryukov.

PreferedType were not set when parsing compound literals, hence
designated initializers were not available as code completion suggestions.

This patch sets the preferedtype to parsed type for the following initializer
list.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92370

Files:
  clang/lib/Parse/ParseExpr.cpp
  clang/test/CodeCompletion/desig-init.cpp


Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:46:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -50,5 +52,5 @@
 template 
 void aux() {
   Test X{.x = T(2)};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:54:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
 }
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -3111,6 +3111,7 @@
   assert(Tok.is(tok::l_brace) && "Not a compound literal!");
   if (!getLangOpts().C99)   // Compound literals don't exist in C90.
 Diag(LParenLoc, diag::ext_c99_compound_literal);
+  PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());
   ExprResult Result = ParseInitializer();
   if (!Result.isInvalid() && Ty)
 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, 
Result.get());


Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completi

[PATCH] D83697: [clang][cli] Port Frontend option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b84efa00040: [clang][cli] Port Frontend option flags to new 
option parsing system (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83697

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -187,7 +187,7 @@
 // Mixins for additional marshalling attributes.
 
 class IsNegative {
-  // todo: create & apply a normalizer for negative flags
+  code Normalizer = "normalizeSimpleNegativeFlag";
 }
 class AlwaysEmit { bit ShouldAlwaysEmit = true; }
 class Normalizer { code Normalizer = normalizer; }
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -22,6 +22,13 @@
 using ::testing::StrNe;
 
 namespace {
+struct OptsPopulationTest : public ::testing::Test {
+  IntrusiveRefCntPtr Diags;
+  CompilerInvocation CInvok;
+
+  OptsPopulationTest()
+  : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
+};
 
 class CC1CommandLineGenerationTest : public ::testing::Test {
 public:
@@ -37,23 +44,36 @@
   : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
 };
 
-TEST(OptsPopulationTest, CanPopulateOptsWithImpliedFlags) {
-  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
+TEST_F(OptsPopulationTest, OptIsInitializedWithCustomDefaultValue) {
+  const char *Args[] = {"clang", "-xc++"};
 
-  auto Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions());
+  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+
+  ASSERT_TRUE(CInvok.getFrontendOpts().UseTemporary);
+}
+
+TEST_F(OptsPopulationTest, OptOfNegativeFlagIsPopulatedWithFalse) {
+  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+
+  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+
+  ASSERT_FALSE(CInvok.getFrontendOpts().UseTemporary);
+}
+
+TEST_F(OptsPopulationTest, OptsOfImpliedPositiveFlagArePopulatedWithTrue) {
+  const char *Args[] = {"clang", "-xc++", "-cl-unsafe-math-optimizations"};
 
-  CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
   // Explicitly provided flag.
-  ASSERT_EQ(CInvok.getLangOpts()->CLUnsafeMath, true);
+  ASSERT_TRUE(CInvok.getLangOpts()->CLUnsafeMath);
 
   // Flags directly implied by explicitly provided flag.
-  ASSERT_EQ(CInvok.getCodeGenOpts().LessPreciseFPMAD, true);
-  ASSERT_EQ(CInvok.getLangOpts()->UnsafeFPMath, true);
+  ASSERT_TRUE(CInvok.getCodeGenOpts().LessPreciseFPMAD);
+  ASSERT_TRUE(CInvok.getLangOpts()->UnsafeFPMath);
 
   // Flag transitively implied by explicitly provided flag.
-  ASSERT_EQ(CInvok.getLangOpts()->AllowRecip, true);
+  ASSERT_TRUE(CInvok.getLangOpts()->AllowRecip);
 }
 
 TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineFlag) {
@@ -134,6 +154,28 @@
   ASSERT_THAT(GeneratedArgs, Each(StrNe(RelocationModelCStr)));
 }
 
+TEST_F(CC1CommandLineGenerationTest, NotPresentNegativeFlagNotGenerated) {
+  const char *Args[] = {"clang", "-xc++"};
+
+  CompilerInvocation CInvok;
+  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+
+  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file";
+}
+
+TEST_F(CC1CommandLineGenerationTest, PresentNegativeFlagGenerated) {
+  const char *Args[] = {"clang", "-xc++", "-fno-temp-file"};
+
+  CompilerInvocation CInvok;
+  CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
+
+  CInvok.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
+}
+
 TEST_F(CC1CommandLineGenerationTest, NotPresentAndNotImpliedNotGenerated) {
   const char *Args[] = {"clang", "-xc++"};
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -136,6 +136,14 @@
   return None;
 }
 
+static Optional normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
+  const ArgList &Args,
+  DiagnosticsEngine &) {
+  if (Args.hasArg(Opt))
+return false;
+  return None;
+}
+
 void denormalizeSimpleFlag(SmallVectorImpl &Args,
const char *Spelling,
   

[clang] 2b84efa - [clang][cli] Port Frontend option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-01T10:02:08+01:00
New Revision: 2b84efa00040410d97aff403788ee5d96b1046e2

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

LOG: [clang][cli] Port Frontend option flags to new option parsing system

Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 09c02989a6a8..a8ab5cc2494c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -335,8 +335,8 @@ def ccc_arcmt_migrate : Separate<["-"], 
"ccc-arcmt-migrate">, InternalDriverOpt,
 def arcmt_migrate_report_output : Separate<["-"], 
"arcmt-migrate-report-output">,
   HelpText<"Output path for the plist report">,  Flags<[CC1Option]>;
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
-  HelpText<"Emit ARC errors even if the migrator can fix them">,
-  Flags<[CC1Option]>;
+  HelpText<"Emit ARC errors even if the migrator can fix them">, 
Flags<[CC1Option]>,
+  MarshallingInfoFlag<"FrontendOpts.ARCMTMigrateEmitARCErrors">;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
   HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, 
InternalDebugOpt,
@@ -1577,7 +1577,8 @@ def fmodule_name : Separate<["-"], "fmodule-name">, 
Alias;
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
   Flags<[CC1Option]>, Alias;
 def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,
-  HelpText<"Build this module as a system module. Only used with 
-emit-module">;
+  HelpText<"Build this module as a system module. Only used with 
-emit-module">,
+  MarshallingInfoFlag<"FrontendOpts.IsSystemModule">;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
   HelpText<"Load this module map file">;
@@ -1702,7 +1703,8 @@ def fno_strict_vtable_pointers: Flag<["-"], 
"fno-strict-vtable-pointers">,
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
 def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<
-  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">,
+  MarshallingInfoFlag<"FrontendOpts.UseTemporary", "true">, IsNegative;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,
@@ -1990,14 +1992,16 @@ def Wframe_larger_than_EQ : Joined<["-"], 
"Wframe-larger-than=">, Group
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
-def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>;
+def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>,
+  MarshallingInfoFlag<"FrontendOpts.ShowTimers">;
 def ftime_trace : Flag<["-"], "ftime-trace">, Group,
   HelpText<"Turn on time profiler. Generates JSON file based on output 
filename.">,
   DocBrief<[{
 Turn on time profiler. Generates JSON file based on output filename. Results
 can be analyzed with chrome://tracing or `Speedscope App
 `_ for flamegraph visualization.}]>,
-  Flags<[CC1Option, CoreOption]>;
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoFlag<"FrontendOpts.TimeTrace">;
 def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, 
Group,
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Flags<[CC1Option, CoreOption]>;
@@ -2210,7 +2214,8 @@ def gno_embed_source : Flag<["-"], "gno-embed-source">, 
Group,
 HelpText<"Restore the default behavior of not embedding source text in 
DWARF debug sections">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
 def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">;
+FlangOption]>, HelpText<"Display available options">,
+MarshallingInfoFlag<"FrontendOpts.ShowHelp">;
 def ibu

[PATCH] D92072: [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

2020-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Seems like a good idea to me.

From the change description:

> This allows us to use its value everywhere, rather than just llvm.

Do you mean rather than just clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92072

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


[PATCH] D83694: [clang][cli] Port DependencyOutput option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308573.
jansvoboda11 added a comment.

Remove unnecessary std namespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83694

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -170,7 +170,7 @@
 
 class MarshallingInfoBitfieldFlag
   : MarshallingInfoFlag {
-  code Normalizer = "(normalizeFlagToValue)";
+  code Normalizer = "makeFlagToValueNormalizer("#value#")";
   code ValueMerger = "mergeMaskValue";
   code ValueExtractor = "(extractMaskValue)";
 }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -144,20 +144,44 @@
   return None;
 }
 
-void denormalizeSimpleFlag(SmallVectorImpl &Args,
-   const char *Spelling,
-   CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
+/// The tblgen-erated code passes in a fifth parameter of an arbitrary type, but
+/// denormalizeSimpleFlags never looks at it. Avoid bloating compile-time with
+/// unnecessary template instantiations and just ignore it with a variadic
+/// argument.
+static void denormalizeSimpleFlag(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator, unsigned,
+  /*T*/...) {
   Args.push_back(Spelling);
 }
 
-template 
-static llvm::Optional
-normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  if (Args.hasArg(Opt))
-return Value;
-  return None;
+namespace {
+template  struct FlagToValueNormalizer {
+  T Value;
+
+  Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) {
+if (Args.hasArg(Opt))
+  return Value;
+return None;
+  }
+};
+} // namespace
+
+template  static constexpr bool is_int_convertible() {
+  return sizeof(T) <= sizeof(uint64_t) &&
+ std::is_trivially_constructible::value &&
+ std::is_trivially_constructible::value;
+}
+
+template (), bool> = false>
+static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
+  return FlagToValueNormalizer{Value};
+}
+
+template (), bool> = false>
+static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
+  return FlagToValueNormalizer{std::move(Value)};
 }
 
 static Optional normalizeBooleanFlag(OptSpecifier PosOpt,
@@ -1590,13 +1614,8 @@
   ArgList &Args) {
   Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
-  Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
-  Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
-  Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
   Opts.HeaderIncludeOutputFile =
   std::string(Args.getLastArgValue(OPT_header_include_file));
-  Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1611,8 +1630,6 @@
   Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
   Opts.ModuleDependencyOutputDir =
   std::string(Args.getLastArgValue(OPT_module_dependency_dir));
-  if (Args.hasArg(OPT_MV))
-Opts.OutputFormat = DependencyOutputFormat::NMake;
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -429,7 +429,8 @@
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, Alias;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
-HelpText<"Show header includes and nesting depth">;
+HelpText<"Show header includes and nesting depth">,
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -455,17 +456,21 @@
 HelpText<"Write depfile output f

[PATCH] D92201: [clangd] Make sure project-aware index is up-to-date for estimateMemoryUsage()

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D92201#2421520 , @sammccall wrote:

> In D92201#2419933 , @kbobyrev wrote:
>
>> I was trying to cause the index to load in the initialization stage for 
>> D92198  but couldn't figure out where 
>> exactly the config is loaded and what could be the best place for triggering 
>> index loading.
>
> Fair point, will have a look at that. Forcing an index load might be a nice 
> side-effect of this patch, but I think we can find a better way to do it.

I suppose the most natural place would be under `ClangdServer::addDocument`, 
but we don't have any nice way to trigger this warmup conceptually. All we can 
do is perform some other index operation that'll trigger index loading as a 
side-effect, which makes it quite weird to trigger in any "direct" place :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92201

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


[PATCH] D83694: [clang][cli] Port DependencyOutput option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e41a688a5b1: [clang][cli] Port DependencyOutput option 
flags to new option parsing system (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83694

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -170,7 +170,7 @@
 
 class MarshallingInfoBitfieldFlag
   : MarshallingInfoFlag {
-  code Normalizer = "(normalizeFlagToValue)";
+  code Normalizer = "makeFlagToValueNormalizer("#value#")";
   code ValueMerger = "mergeMaskValue";
   code ValueExtractor = "(extractMaskValue)";
 }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -144,20 +144,44 @@
   return None;
 }
 
-void denormalizeSimpleFlag(SmallVectorImpl &Args,
-   const char *Spelling,
-   CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
+/// The tblgen-erated code passes in a fifth parameter of an arbitrary type, but
+/// denormalizeSimpleFlags never looks at it. Avoid bloating compile-time with
+/// unnecessary template instantiations and just ignore it with a variadic
+/// argument.
+static void denormalizeSimpleFlag(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator, unsigned,
+  /*T*/...) {
   Args.push_back(Spelling);
 }
 
-template 
-static llvm::Optional
-normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  if (Args.hasArg(Opt))
-return Value;
-  return None;
+namespace {
+template  struct FlagToValueNormalizer {
+  T Value;
+
+  Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) {
+if (Args.hasArg(Opt))
+  return Value;
+return None;
+  }
+};
+} // namespace
+
+template  static constexpr bool is_int_convertible() {
+  return sizeof(T) <= sizeof(uint64_t) &&
+ std::is_trivially_constructible::value &&
+ std::is_trivially_constructible::value;
+}
+
+template (), bool> = false>
+static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
+  return FlagToValueNormalizer{Value};
+}
+
+template (), bool> = false>
+static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
+  return FlagToValueNormalizer{std::move(Value)};
 }
 
 static Optional normalizeBooleanFlag(OptSpecifier PosOpt,
@@ -1590,13 +1614,8 @@
   ArgList &Args) {
   Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
-  Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
-  Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
-  Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
   Opts.HeaderIncludeOutputFile =
   std::string(Args.getLastArgValue(OPT_header_include_file));
-  Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1611,8 +1630,6 @@
   Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
   Opts.ModuleDependencyOutputDir =
   std::string(Args.getLastArgValue(OPT_module_dependency_dir));
-  if (Args.hasArg(OPT_MV))
-Opts.OutputFormat = DependencyOutputFormat::NMake;
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -429,7 +429,8 @@
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, Alias;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
-HelpText<"Show header includes and nesting depth">;
+HelpText<"Show header includes and nesting depth">,
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags 

[clang] 8e41a68 - [clang][cli] Port DependencyOutput option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-01T10:36:12+01:00
New Revision: 8e41a688a5b1000b51c61b9d103545791c54af17

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

LOG: [clang][cli] Port DependencyOutput option flags to new option parsing 
system

Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a8ab5cc2494c..24662f15539d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -429,7 +429,8 @@ def G : JoinedOrSeparate<["-"], "G">, 
Flags<[NoXarchOption]>, Group,
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, 
Alias;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
-HelpText<"Show header includes and nesting depth">;
+HelpText<"Show header includes and nesting depth">,
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -455,17 +456,21 @@ def MF : JoinedOrSeparate<["-"], "MF">, Group,
 HelpText<"Write depfile output from -MMD, -MD, -MM, or -M to ">,
 MetaVarName<"">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
-HelpText<"Add missing headers to depfile">;
+HelpText<"Add missing headers to depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps">;
 def MJ : JoinedOrSeparate<["-"], "MJ">, Group,
 HelpText<"Write a compilation database entry per input">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
-HelpText<"Create phony target for each dependency (other than main file)">;
+HelpText<"Create phony target for each dependency (other than main file)">,
+MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets">;
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output to quote in depfile">;
 def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output in depfile">;
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
-HelpText<"Use NMake/Jom format for the depfile">;
+HelpText<"Use NMake/Jom format for the depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", 
"DependencyOutputFormat::Make">,
+Normalizer<"makeFlagToValueNormalizer(DependencyOutputFormat::NMake)">;
 def Mach : Flag<["-"], "Mach">, Group;
 def O0 : Flag<["-"], "O0">, Group, Flags<[CC1Option, HelpHidden]>;
 def O4 : Flag<["-"], "O4">, Group, Flags<[CC1Option, HelpHidden]>;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f23d1e398a4a..761f9ebd2381 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -144,20 +144,44 @@ static Optional 
normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
   return None;
 }
 
-void denormalizeSimpleFlag(SmallVectorImpl &Args,
-   const char *Spelling,
-   CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
+/// The tblgen-erated code passes in a fifth parameter of an arbitrary type, 
but
+/// denormalizeSimpleFlags never looks at it. Avoid bloating compile-time with
+/// unnecessary template instantiations and just ignore it with a variadic
+/// argument.
+static void denormalizeSimpleFlag(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator, 
unsigned,
+  /*T*/...) {
   Args.push_back(Spelling);
 }
 
-template 
-static llvm::Optional
-normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList 
&Args,
- DiagnosticsEngine &Diags) {
-  if (Args.hasArg(Opt))
-return Value;
-  return None;
+namespace {
+template  struct FlagToValueNormalizer {
+  T Value;
+
+  Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) {
+if (Args.hasArg(Opt))
+  return Value;
+return None;
+  }
+};
+} // namespace
+
+template  static constexpr bool is_int_convertible() {
+  return sizeof(T) <= sizeof(uint64_t) &&
+ std::is_trivially_constructible::value &&
+ std::is_trivially_constr

[PATCH] D91898: [attributes] Add a facility for defining and enforcing a Trusted Computing Base.

2020-12-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 16 inline comments as done.
NoQ added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:5497
+  called from a function with the enforce_tcb attribute. A function may be
+  a part of multiple TCBs. Invocations of function pointers and C++ methods
+  are not checked. Builtins are considered to a part of every TCB.

aaron.ballman wrote:
> Are there plans to support this on function pointers or other kinds of 
> callable things?
> 
> Also, it seems rather odd that C++ methods are not checked. I could somewhat 
> understand not checking virtual functions, but why not member functions where 
> the target is known? Why not static member functions?
Yup, sounds like there are plans for function pointers. We're likely to have a 
follow-up patch for that. I'll relax the statement to "currently".

With C++ we basically didn't make up our mind yet with respect to what we want. 
Like, it's kind of strange to isolate individual members of the class into a 
TCB, it sounds like it'd make a lot more sense on per-class basis but we'll 
have to see. Also as a matter of fact, the current implementation does check 
(and emit warnings for) C++ methods. I'll add a test and a TODO to figure out 
what exactly do we want and drop that part of the documentation.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1246
+
+def TCBEnforcement : DiagGroup<"tcb-enforcement">;

aaron.ballman wrote:
> Are you planning on adding more diagnostics under this group? If not, I'd 
> suggest defining it inline (see below).
Aha, ok, not yet but i guess we can always bring the group back if we need more 
diagnostics.



Comment at: clang/lib/Sema/SemaChecking.cpp:16079-16084
+  for (const auto *Attr : Callee->specific_attrs()) {
+CalleeTCBs.insert(Attr->getTCBName());
+  }
+  for (const auto *Attr : Callee->specific_attrs()) {
+CalleeTCBs.insert(Attr->getTCBName());
+  }

aaron.ballman wrote:
> Pretty sure you can remove the manual loops here with something like this.
`std::inserter` doesn't seem to work with `llvm::StringSet` but 
`llvm::for_each` works and seems to be more compact(?)



Comment at: clang/lib/Sema/SemaChecking.cpp:16086
+
+  // Go through the TCBs the caller is a part of and emit warnings if Caller 
is in a TCB that the Callee is not
+  for (const auto *Attr : Caller->specific_attrs()) {

aaron.ballman wrote:
> Can you be sure to run the patch through clang-format, this looks like it's 
> over the 80 col limit.
Umm yeah indeed thanks!



Comment at: clang/lib/Sema/SemaChecking.cpp:16090-16092
+if (CalleeTCBs.count(CallerTCB) == 0) {
+  Diag(TheCall->getExprLoc(), diag::warn_tcb_enforcement_violation) << 
CallerTCB << Callee->getName();
+}

aaron.ballman wrote:
> 
TIL that `<< Callee` adds quotes automatically. I should use clang diagnostic 
builders more often :)


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

https://reviews.llvm.org/D91898

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


[PATCH] D91898: [attributes] Add a facility for defining and enforcing a Trusted Computing Base.

2020-12-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 308581.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Fxd!


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

https://reviews.llvm.org/D91898

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-enforce-tcb-errors.cpp
  clang/test/Sema/attr-enforce-tcb.c
  clang/test/Sema/attr-enforce-tcb.cpp

Index: clang/test/Sema/attr-enforce-tcb.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-enforce-tcb.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define PLACE_IN_TCB(NAME) [[clang::enforce_tcb(NAME)]]
+#define PLACE_IN_TCB_LEAF(NAME) [[clang::enforce_tcb_leaf(NAME)]]
+
+PLACE_IN_TCB("foo") void in_tcb_foo();
+void not_in_tcb();
+
+// Test behavior on classes and methods.
+class C {
+  void bar();
+
+  PLACE_IN_TCB("foo")
+  void foo() {
+// TODO: Figure out if we want to support methods at all.
+// Does it even make sense to isolate individual methods into a TCB?
+// Maybe a per-class attribute would make more sense?
+bar(); // expected-warning{{calling 'bar' is a violation of trusted computing base 'foo'}}
+  }
+};
+
+// Test behavior on templates.
+template 
+PLACE_IN_TCB("foo")
+void foo_never_instantiated() {
+  not_in_tcb(); // expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
+  in_tcb_foo(); // no-warning
+}
+
+template 
+PLACE_IN_TCB("foo")
+void foo_specialized();
+
+template<>
+void foo_specialized() {
+  not_in_tcb(); // expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
+  in_tcb_foo(); // no-warning
+}
+
+PLACE_IN_TCB("foo")
+void call_template_good() {
+  foo_specialized(); // no-warning
+}
+PLACE_IN_TCB("bar")
+void call_template_bad() {
+  foo_specialized(); // expected-warning{{calling 'foo_specialized' is a violation of trusted computing base 'bar'}}
+}
+
+template
+void foo_specialization_in_tcb();
+
+template<>
+PLACE_IN_TCB("foo")
+void foo_specialization_in_tcb() {
+  not_in_tcb(); //expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
+  in_tcb_foo(); // no-warning
+}
+
+template<>
+void foo_specialization_in_tcb() {
+  not_in_tcb(); // no-warning
+  in_tcb_foo(); // no-warning
+}
+
+PLACE_IN_TCB("foo")
+void call_specialization_in_tcb() {
+  foo_specialization_in_tcb(); // no-warning
+  foo_specialization_in_tcb(); // expected-warning{{calling 'foo_specialization_in_tcb' is a violation of trusted computing base 'foo'}}
+  foo_specialization_in_tcb(); // expected-warning{{'foo_specialization_in_tcb' is a violation of trusted computing base 'foo'}}
+}
Index: clang/test/Sema/attr-enforce-tcb.c
===
--- /dev/null
+++ clang/test/Sema/attr-enforce-tcb.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define PLACE_IN_TCB(NAME) __attribute__ ((enforce_tcb(NAME)))
+#define PLACE_IN_TCB_LEAF(NAME) __attribute__ ((enforce_tcb_leaf(NAME)))
+
+void foo1 (void) PLACE_IN_TCB("bar");
+void foo2 (void) PLACE_IN_TCB("bar");
+void foo3 (void); // not in any TCB
+void foo4 (void) PLACE_IN_TCB("bar2");
+void foo5 (void) PLACE_IN_TCB_LEAF("bar");
+void foo6 (void) PLACE_IN_TCB("bar2") PLACE_IN_TCB("bar");
+void foo7 (void) PLACE_IN_TCB("bar3");
+void foo8 (void) PLACE_IN_TCB("bar") PLACE_IN_TCB("bar2");
+void foo9 (void);
+
+void foo1() {
+foo2(); // OK - function in same TCB
+foo3(); // expected-warning {{calling 'foo3' is a violation of trusted computing base 'bar'}}
+foo4(); // expected-warning {{calling 'foo4' is a violation of trusted computing base 'bar'}}
+foo5(); // OK - in leaf node
+foo6(); // OK - in multiple TCBs, one of which is the same
+foo7(); // expected-warning {{calling 'foo7' is a violation of trusted computing base 'bar'}}
+(void) __builtin_clz(5); // OK - builtins are excluded
+}
+
+// Normal use without any attributes works
+void foo3() {
+foo9(); // no-warning
+}
+
+void foo5() {
+// all calls should be okay, function in TCB leaf
+foo2(); // no-warning
+foo3(); // no-warning
+foo4(); // no-warning
+}
+
+void foo6() {
+foo1(); // expected-warning {{calling 'foo1' is a violation of trusted computing base 'bar2'}}
+foo4(); // expected-warning {{calling 'foo4' is a violation of trusted computing base 'bar'}}
+foo8(); // no-warning
+foo7(); // #1
+// expected-warning@#1 {{calling 'foo7' is a violation of trusted computing base 'bar2'}}
+// expected-warning@#1 {{calling 'foo7' is a violation of trusted computing base 'bar'}}
+}
+
+// Ensure that attribute merging works as expected across redeclarations.
+void foo10() PLACE_IN_TCB("bar");
+void foo10() PLACE_IN_TCB("bar2")

[PATCH] D91874: [GNU ObjC] Fix a regression listing methods twice.

2020-12-01 Thread David Chisnall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1ed67037de6: [GNU ObjC] Fix a regression listing methods 
twice. (authored by theraven).

Changed prior to commit:
  https://reviews.llvm.org/D91874?vs=306704&id=308583#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91874

Files:
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/test/CodeGenObjC/gnu-method-only-once.m


Index: clang/test/CodeGenObjC/gnu-method-only-once.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for declared properties.
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propertyImpl->getGetterMethodDecl());
-  addPropertyMethod(propertyImpl->getSetterMethodDecl());
-}
-
   llvm::Constant *Properties = GeneratePropertyList(OID, ClassDecl);
 
   // Collect the names of referenced protocols


Index: clang/test/CodeGenObjC/gnu-method-only-once.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm -fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for declared properties.
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propertyImpl->ge

[clang] 398b729 - [clang][cli] Port HeaderSearch option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-12-01T10:52:00+01:00
New Revision: 398b729243b12bdfbc7a75b46d39b547545cbd2d

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

LOG: [clang][cli] Port HeaderSearch option flags to new option parsing system

Depends on D83697.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24662f15539d..48d0e2d6235b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1501,11 +1501,9 @@ def fmodules_user_build_path : Separate<["-"], 
"fmodules-user-build-path">, Grou
 def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, 
Group,
   Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the prebuilt module path">;
-def fprebuilt_implicit_modules : Flag<["-"], "fprebuilt-implicit-modules">, 
Group,
-  Flags<[NoXarchOption, CC1Option]>,
-  HelpText<"Look up implicit modules in the prebuilt module path">;
-def fno_prebuilt_implicit_modules : Flag<["-"], 
"fno_prebuilt-implicit-modules">, Group,
-  Flags<[NoXarchOption, CC1Option]>;
+defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules",
+  "Look up implicit modules in the prebuilt module path", "", "",
+  [NoXarchOption, CC1Option], 
"HeaderSearchOpts->EnablePrebuiltImplicitModules">;
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the 
module cache">;
@@ -1524,13 +1522,17 @@ def fbuild_session_file : Joined<["-"], 
"fbuild-session-file=">,
 def fmodules_validate_once_per_build_session : Flag<["-"], 
"fmodules-validate-once-per-build-session">,
   Group, Flags<[CC1Option]>,
   HelpText<"Don't verify input files for the modules if the module has been "
-   "successfully validated or loaded during this build session">;
+   "successfully validated or loaded during this build session">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateOncePerBuildSession">;
 def fmodules_disable_diagnostic_validation : Flag<["-"], 
"fmodules-disable-diagnostic-validation">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Disable validation of the diagnostic options when loading the 
module">;
+  HelpText<"Disable validation of the diagnostic options when loading the 
module">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions", 
"true">, IsNegative;
+// todo: simplify these into a version of OptInFFlag that accepts 
diff erent flags for each record and does not imply group
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Validate the system headers that a module depends on when loading 
the module">;
+  HelpText<"Validate the system headers that a module depends on when loading 
the module">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateSystemHeaders">;
 def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
   Group, Flags<[NoXarchOption]>;
 
@@ -1539,7 +1541,8 @@ def fvalidate_ast_input_files_content:
   Group, Flags<[CC1Option]>,
   HelpText<"Compute and store the hash of input files used to build an AST."
" Files with mismatching mtime's are considered valid"
-   " if both contents is identical">;
+   " if both contents is identical">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ValidateASTInputFilesContent">;
 def fmodules_validate_input_files_content:
   Flag <["-"], "fmodules-validate-input-files-content">,
   Group, Flags<[NoXarchOption]>,
@@ -1571,7 +1574,8 @@ def fmodules : Flag <["-"], "fmodules">, Group,
   HelpText<"Enable the 'modules' language feature">;
 def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, 
Group,
   Flags<[NoXarchOption, CC1Option]>,
-  HelpText<"Implicitly search the file system for module map files.">;
+  HelpText<"Implicitly search the file system for module map files.">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ImplicitModuleMaps">;
 def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
   Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">;
 def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias;
@@ -2888,7 +2892,8 @@ def no_integrated_cpp : Flag<["-", "--"], 
"no-integrated-cpp">, Flags<[NoXarchOp
 def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group;
 def no__dead__strip__inits__and__terms : Flag<["-"], 
"no_dead_strip_inits_and_terms">;

[clang] d1ed670 - [GNU ObjC] Fix a regression listing methods twice.

2020-12-01 Thread David Chisnall via cfe-commits

Author: David Chisnall
Date: 2020-12-01T09:50:18Z
New Revision: d1ed67037de6f3f44dc446784f74f0e02adec9b5

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

LOG: [GNU ObjC] Fix a regression listing methods twice.

Methods synthesized from declared properties were being added to the
method lists twice.  This came from the change to list them in the
class's method list, which missed removing the place in CGObjCGNU that
added them again.

Reviewed By: lanza

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

Added: 
clang/test/CodeGenObjC/gnu-method-only-once.m

Modified: 
clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index c6500c0230c4..9825d7bca18c 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@ void CGObjCGNU::GenerateClass(const 
ObjCImplementationDecl *OID) {
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propertyImpl->getGetterMethodDecl());
-  addPropertyMethod(propertyImpl->getSetterMethodDecl());
-}
-
   llvm::Constant *Properties = GeneratePropertyList(OID, ClassDecl);
 
   // Collect the names of referenced protocols

diff  --git a/clang/test/CodeGenObjC/gnu-method-only-once.m 
b/clang/test/CodeGenObjC/gnu-method-only-once.m
new file mode 100644
index ..67d873ccc0aa
--- /dev/null
+++ b/clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for declared properties.
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x



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


[PATCH] D83940: [clang][cli] Port HeaderSearch option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG398b729243b1: [clang][cli] Port HeaderSearch option flags to 
new option parsing system (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D83940?vs=308074&id=308585#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83940

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2185,10 +2185,6 @@
 static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
   const std::string &WorkingDir) {
   Opts.Sysroot = std::string(Args.getLastArgValue(OPT_isysroot, "/"));
-  Opts.Verbose = Args.hasArg(OPT_v);
-  Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
-  Opts.UseStandardSystemIncludes = !Args.hasArg(OPT_nostdsysteminc);
-  Opts.UseStandardCXXIncludes = !Args.hasArg(OPT_nostdincxx);
   if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
 Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
   Opts.ResourceDir = std::string(Args.getLastArgValue(OPT_resource_dir));
@@ -2217,26 +2213,12 @@
   }
   for (const auto *A : Args.filtered(OPT_fprebuilt_module_path))
 Opts.AddPrebuiltModulePath(A->getValue());
-  Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
-  Opts.ModulesHashContent = Args.hasArg(OPT_fmodules_hash_content);
-  Opts.ModulesValidateDiagnosticOptions =
-  !Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
-  Opts.ImplicitModuleMaps = Args.hasArg(OPT_fimplicit_module_maps);
-  Opts.ModuleMapFileHomeIsCwd = Args.hasArg(OPT_fmodule_map_file_home_is_cwd);
-  Opts.EnablePrebuiltImplicitModules =
-  Args.hasArg(OPT_fprebuilt_implicit_modules);
   Opts.ModuleCachePruneInterval =
   getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
   Opts.ModuleCachePruneAfter =
   getLastArgIntValue(Args, OPT_fmodules_prune_after, 31 * 24 * 60 * 60);
-  Opts.ModulesValidateOncePerBuildSession =
-  Args.hasArg(OPT_fmodules_validate_once_per_build_session);
   Opts.BuildSessionTimestamp =
   getLastArgUInt64Value(Args, OPT_fbuild_session_timestamp, 0);
-  Opts.ModulesValidateSystemHeaders =
-  Args.hasArg(OPT_fmodules_validate_system_headers);
-  Opts.ValidateASTInputFilesContent =
-  Args.hasArg(OPT_fvalidate_ast_input_files_content);
   if (const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
 Opts.ModuleFormat = A->getValue();
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1501,11 +1501,9 @@
 def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group,
   Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the prebuilt module path">;
-def fprebuilt_implicit_modules : Flag<["-"], "fprebuilt-implicit-modules">, Group,
-  Flags<[NoXarchOption, CC1Option]>,
-  HelpText<"Look up implicit modules in the prebuilt module path">;
-def fno_prebuilt_implicit_modules : Flag<["-"], "fno_prebuilt-implicit-modules">, Group,
-  Flags<[NoXarchOption, CC1Option]>;
+defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules",
+  "Look up implicit modules in the prebuilt module path", "", "",
+  [NoXarchOption, CC1Option], "HeaderSearchOpts->EnablePrebuiltImplicitModules">;
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">;
@@ -1524,13 +1522,17 @@
 def fmodules_validate_once_per_build_session : Flag<["-"], "fmodules-validate-once-per-build-session">,
   Group, Flags<[CC1Option]>,
   HelpText<"Don't verify input files for the modules if the module has been "
-   "successfully validated or loaded during this build session">;
+   "successfully validated or loaded during this build session">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateOncePerBuildSession">;
 def fmodules_disable_diagnostic_validation : Flag<["-"], "fmodules-disable-diagnostic-validation">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Disable validation of the diagnostic options when loading the module">;
+  HelpText<"Disable validation of the diagnostic options when loading the module">,
+  MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions", "true">, IsNegative;
+// todo: simplify these into a version of OptInFFlag that accepts different flags for each record and does not imply group
 def fmodules_validate_system_head

[PATCH] D92109: [ASTImporter] Support import of CXXDeductionGuideDecl

2020-12-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3336
+if (Fun->getExplicitSpecifier().getExpr()) {
+  ExplicitExpr = importChecked(Err, Fun->getExplicitSpecifier().getExpr());
+  if (Err)

rnk wrote:
> GCC 5.3 complained about this, so I rewrote it a different way without 
> generic lambdas in rG43b5b485a203f190ee4d5d3cab19c44ca865d316.
> 
> Error spew:
> ```
> FAILED: tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o 
> /b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc530trusty/bin/g++ 
>  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/AST 
> -I/b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST 
> -I/b/s/w/ir/cache/builder/src/third_party/llvm/clang/include 
> -Itools/clang/include -Iinclude 
> -I/b/s/w/ir/cache/builder/src/third_party/llvm/llvm/include 
> -DLLVM_FORCE_HEAD_REVISION -fvisibility-inlines-hidden -Werror=date-time 
> -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment 
> -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> -Woverloaded-virtual -fno-strict-aliasing -O3 -fno-exceptions 
> -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -UNDEBUG 
> -std=c++14 -MD -MT 
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o -MF 
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o.d -o 
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTImporter.cpp.o -c 
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp: 
> In instantiation of 
> ‘clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*)::
>  [with auto:1 = clang::CXXConversionDecl; clang::ExpectedExpr = 
> llvm::Expected]’:
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3384:66:
>required from here
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3336:20:
>  error: cannot call member function ‘T 
> clang::ASTNodeImporter::importChecked(llvm::Error&, const T&) [with T = 
> clang::Expr*]’ without object
>ExplicitExpr = importChecked(Err, 
> Fun->getExplicitSpecifier().getExpr());
> ^
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp: 
> In instantiation of 
> ‘clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*)::
>  [with auto:1 = clang::CXXDeductionGuideDecl; clang::ExpectedExpr = 
> llvm::Expected]’:
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3402:57:
>required from here
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/lib/AST/ASTImporter.cpp:3336:20:
>  error: cannot call member function ‘T 
> clang::ASTNodeImporter::importChecked(llvm::Error&, const T&) [with T = 
> clang::Expr*]’ without object
> [3456/5141] Building CXX object 
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/InheritViz.cpp.o
> ```
Thanks, post-commit looks good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92109

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


[PATCH] D83979: [clang][cli] Port LangOpts option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308596.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83979

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -290,7 +290,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return Value;
+  return static_cast(Value);
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -306,7 +306,8 @@
   return KeyPath & Value;
 }
 
-static void FixupInvocation(CompilerInvocation &Invocation) {
+static void FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
@@ -316,9 +317,16 @@
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
   CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
+
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
+  LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
+  LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+
+  if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
+Diags.Report(diag::warn_c_kext);
 }
 
 //===--===//
@@ -2400,9 +2408,6 @@
 }
   }
 
-  if (Args.hasArg(OPT_fno_dllexport_inlines))
-Opts.DllExportInlines = false;
-
   if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
 StringRef Name = A->getValue();
 if (Name == "full" || Name == "branch") {
@@ -2431,7 +2436,6 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
   if (Opts.SYCL) {
 // -sycl-std applies to any SYCL source, not only those containing kernels,
@@ -2449,9 +2453,6 @@
 }
   }
 
-  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
-  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
-
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
 
@@ -2478,22 +2479,9 @@
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Args.hasArg(OPT_fcuda_is_device))
-Opts.CUDAIsDevice = 1;
-
-  if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
-Opts.CUDAAllowVariadicFunctions = 1;
-
-  if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
-Opts.CUDAHostDeviceConstexpr = 0;
-
-  if (Args.hasArg(OPT_fgpu_defer_diag))
-Opts.GPUDeferDiag = 1;
-
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
 Opts.CUDADeviceApproxTranscendentals = 1;
 
-  Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
   if (Args.hasArg(OPT_fgpu_allow_device_init)) {
 if (Opts.HIP)
   Opts.GPUAllowDeviceInit = 1;
@@ -2501,7 +2489,6 @@
   Diags.Report(diag::warn_ignored_hip_only_option)
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
-  Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
   if (Opts.HIP)
 Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
@@ -2521,7 +2508,6 @@
 else if (Args.hasArg(OPT_fobjc_gc))
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
-  Opts.ObjCAutoRefCount = 1;
   if (!Opts.ObjCRuntime.allowsARC())
 Diags.Report(diag::err_arc_unsupported_on_runtime);
 }
@@ -2551,9 +2537,6 @@
   Opts.ObjCWeak = Opts.ObjCWeakRuntime;
 }
 
-if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
-  Opts.ObjCInferRelatedResultType = 0;
-
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
@@ -2582,18 +2565,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (Args.hasArg(OPT_fapple_kext)) {
-if (!Opts.CPlusPlus)
-  Diags.Report(diag::warn_c_kext);
-else
-  Opts.AppleKext = 1;
-  }
-
-  if (Args.hasArg(OPT_print_ivar_layout))
-Opts.ObjCGCBitmapPrint = 1;
-
-  if (Args.hasArg(OPT_fno_constant_cfstrings))
-Opts.NoConstantCFStrings = 1;
   if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
 Opts.CFRuntime =
 llvm::StringSwitch(A->getValue())
@@ -

[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 308597.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -177,7 +177,6 @@
 
 class MarshallingInfoBooleanFlag
   : MarshallingInfoFlag {
-  bit ShouldAlwaysEmit = 1;
   string MarshallingInfoKind = "BooleanFlag";
   code Normalizer = "normalizeBooleanFlag";
   code Denormalizer = "denormalizeBooleanFlag";
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -76,6 +76,63 @@
   ASSERT_TRUE(CInvok.getLangOpts()->AllowRecip);
 }
 
+TEST_F(OptsPopulationTest, OptInFFlag) {
+  const char *ArgsEmpty[] = {"clang"};
+  CompilerInvocation InvocationEmpty;
+  CompilerInvocation::CreateFromArgs(InvocationEmpty, ArgsEmpty, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(InvocationEmpty.getCodeGenOpts().CoverageMapping);
+
+  const char *ArgsPosFlag[] = {"clang", "-fcoverage-mapping"};
+  CompilerInvocation InvocationPosFlag;
+  CompilerInvocation::CreateFromArgs(InvocationPosFlag, ArgsPosFlag, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(InvocationPosFlag.getCodeGenOpts().CoverageMapping);
+
+  const char *ArgsNegFlag[] = {"clang", "-fno-coverage-mapping"};
+  CompilerInvocation InvocationNegFlag;
+  CompilerInvocation::CreateFromArgs(InvocationNegFlag, ArgsNegFlag, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+}
+
+TEST_F(OptsPopulationTest, OptOutPositiveFFlag) {
+  const char *ArgsEmpty[] = {"clang"};
+  CompilerInvocation InvocationEmpty;
+  CompilerInvocation::CreateFromArgs(InvocationEmpty, ArgsEmpty, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(InvocationEmpty.getCodeGenOpts().Autolink);
+
+  const char *ArgsNegFlag[] = {"clang", "-fno-autolink"};
+  CompilerInvocation InvocationNegFlag;
+  CompilerInvocation::CreateFromArgs(InvocationNegFlag, ArgsNegFlag, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(InvocationNegFlag.getCodeGenOpts().Autolink);
+
+  const char *ArgsPosFlag[] = {"clang", "-fautolink"};
+  CompilerInvocation InvocationPosFlag;
+  CompilerInvocation::CreateFromArgs(InvocationPosFlag, ArgsPosFlag, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+}
+
+TEST_F(OptsPopulationTest, OptOutFFlag) {
+  const char *ArgsEmpty[] = {"clang"};
+  CompilerInvocation InvocationEmpty;
+  CompilerInvocation::CreateFromArgs(InvocationEmpty, ArgsEmpty, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_FALSE(InvocationEmpty.getCodeGenOpts().NoUseJumpTables);
+
+  const char *ArgsNegFlag[] = {"clang", "-fno-jump-tables"};
+  CompilerInvocation InvocationNegFlag;
+  CompilerInvocation::CreateFromArgs(InvocationNegFlag, ArgsNegFlag, *Diags);
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(InvocationNegFlag.getCodeGenOpts().NoUseJumpTables);
+
+  const char *ArgsPosFlag[] = {"clang", "-fjump-tables"};
+  CompilerInvocation InvocationPosFlag;
+  CompilerInvocation::CreateFromArgs(InvocationPosFlag, ArgsPosFlag, *Diags);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+}
+
 TEST_F(CC1CommandLineGenerationTest, CanGenerateCC1CommandLineFlag) {
   const char *Args[] = {"clang", "-xc++", "-fmodules-strict-context-hash", "-"};
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -311,9 +311,11 @@
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
+
   CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+  CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
@@ -852,10 +854,6 @@
 }
   }
 
-  Opts.DebugPassManager =
-  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
-   /* Default */ false);
-
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
 if (Name == "Accelerate")
@@ -907,23 +905,9

[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D85808#2424908 , @jansvoboda11 
wrote:

> I'm seeing build failures that might be triggered by this patch: 
> http://lab.llvm.org:8011/#/builders/109/builds/3714

It seems to affect a lot of the main bots (random example: 
http://lab.llvm.org:8011/#/builders/52/builds/1963)
And here's another one: http://45.33.8.238/linux/34102/step_12.txt
We also hit this in Chromium.

I think David just fixed it in 
https://github.com/llvm/llvm-project/commit/09d82fa95f4561a6a2ce80bce00209018ba70c24


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[clang] e98d3be - [clang] Enable code completion of designated initializers in Compound Literal Expressions

2020-12-01 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-12-01T12:06:48+01:00
New Revision: e98d3be11c2991c7d446d5c7c714d0384f3b7432

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

LOG: [clang] Enable code completion of designated initializers in Compound 
Literal Expressions

PreferedType were not set when parsing compound literals, hence
designated initializers were not available as code completion suggestions.

This patch sets the preferedtype to parsed type for the following initializer
list.

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

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

Added: 


Modified: 
clang/lib/Parse/ParseExpr.cpp
clang/test/CodeCompletion/desig-init.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index b3dae626fb0f..d993d9ce4bdb 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3111,6 +3111,7 @@ Parser::ParseCompoundLiteralExpression(ParsedType Ty,
   assert(Tok.is(tok::l_brace) && "Not a compound literal!");
   if (!getLangOpts().C99)   // Compound literals don't exist in C90.
 Diag(LParenLoc, diag::ext_c99_compound_literal);
+  PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());
   ExprResult Result = ParseInitializer();
   if (!Result.isInvalid() && Ty)
 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, 
Result.get());

diff  --git a/clang/test/CodeCompletion/desig-init.cpp 
b/clang/test/CodeCompletion/desig-init.cpp
index ebfd63266397..fbcaeb303e50 100644
--- a/clang/test/CodeCompletion/desig-init.cpp
+++ b/clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@ void foo() {
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@ struct Test {
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:46:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -50,5 +52,5 @@ void bar() {
 template 
 void aux() {
   Test X{.x = T(2)};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:54:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
 }



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


[PATCH] D92370: [clang] Enable code completion of designated initializers in Compound Literal Expressions

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe98d3be11c29: [clang] Enable code completion of designated 
initializers in Compound Literal… (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92370

Files:
  clang/lib/Parse/ParseExpr.cpp
  clang/test/CodeCompletion/desig-init.cpp


Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:46:16 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -50,5 +52,5 @@
 template 
 void aux() {
   Test X{.x = T(2)};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:54:14 %s -o - -std=c++2a | FileCheck 
-check-prefix=CHECK-CC3 %s
 }
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -3111,6 +3111,7 @@
   assert(Tok.is(tok::l_brace) && "Not a compound literal!");
   if (!getLangOpts().C99)   // Compound literals don't exist in C90.
 Diag(LParenLoc, diag::ext_c99_compound_literal);
+  PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());
   ExprResult Result = ParseInitializer();
   if (!Result.isInvalid() && Ty)
 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, 
Result.get());


Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -23,9 +23,11 @@
   auto z = [](Base B) {};
   z({.t = 1});
   z(Base{.t = 2});
+  z((Base){.t = 2});
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
 }
 
@@ -39,10 +41,10 @@
 };
 void bar() {
   Test T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:43:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:46:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -5

[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

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



Comment at: clang/docs/ClangFormatStyleOptions.rst:2710
 
+**SpacesInLineComments** (``SpacesInLineComment``)
+  How many spaces are allowed at the start of a line comment. To disable the

Is this change generated? with clang/doc/tools/dump_style.py or did you hand 
craft it?

ClangFormatStyleOptions.rst is always autogenerated from running dump_style.py, 
any text you want in the rst needs to be present in Format.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[clang] 523775f - [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-12-01 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-12-01T11:33:10Z
New Revision: 523775f96742e6f099b3498b6606b7250c0af841

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

LOG: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c282a73e0ed..2116b3f7b78e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8591,12 +8591,21 @@ static bool isOpenCLSizeDependentType(ASTContext &C, 
QualType Ty) {
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
-if (PointeeType->isPointerType())
-  return PtrPtrKernelParam;
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == LangAS::Default)
   return InvalidAddrSpacePtrKernelParam;
+
+if (PointeeType->isPointerType()) {
+  // This is a pointer to pointer parameter.
+  // Recursively check inner type.
+  OpenCLParamType ParamKind = getOpenCLKernelParameterType(S, PointeeType);
+  if (ParamKind == InvalidAddrSpacePtrKernelParam ||
+  ParamKind == InvalidKernelParam)
+return ParamKind;
+
+  return PtrPtrKernelParam;
+}
 return PtrKernelParam;
   }
 
@@ -8649,11 +8658,17 @@ static void checkIsValidOpenCLKernelParameter(
 
   switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to a pointer type.
-S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
-D.setInvalidType();
+// OpenCL v3.0 s6.11.a:
+// A kernel function argument cannot be declared as a pointer to a pointer
+// type. [...] This restriction only applies to OpenCL C 1.2 or below.
+if (S.getLangOpts().OpenCLVersion < 120 &&
+!S.getLangOpts().OpenCLCPlusPlus) {
+  S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
+  D.setInvalidType();
+  return;
+}
+
+ValidTypes.insert(PT.getTypePtr());
 return;
 
   case InvalidAddrSpacePtrKernelParam:

diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 26859ee62cae..9fce92dbd6c3 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@ kernel void half_arg(half x) { } // expected-error{{declaring 
function parameter
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#endif
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_lptrcptr(constant int * local *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_privateptr(__private int *i) { }
@@ -17,6 +23,15 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_ptr_private_ptr(private int * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_private_ptr_ptr(global int * private * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+#endif
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr

[PATCH] D92091: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-12-01 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG523775f96742: [OpenCL] Allow pointer-to-pointer kernel args 
beyond CL 1.2 (authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D92091?vs=308075&id=308607#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92091

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/invalid-kernel-parameters.cl


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#endif
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_lptrcptr(constant int * local *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_privateptr(__private int *i) { }
@@ -17,6 +23,15 @@
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_ptr_private_ptr(private int * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_private_ptr_ptr(global int * private * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+#endif
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8591,12 +8591,21 @@
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
-if (PointeeType->isPointerType())
-  return PtrPtrKernelParam;
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == LangAS::Default)
   return InvalidAddrSpacePtrKernelParam;
+
+if (PointeeType->isPointerType()) {
+  // This is a pointer to pointer parameter.
+  // Recursively check inner type.
+  OpenCLParamType ParamKind = getOpenCLKernelParameterType(S, PointeeType);
+  if (ParamKind == InvalidAddrSpacePtrKernelParam ||
+  ParamKind == InvalidKernelParam)
+return ParamKind;
+
+  return PtrPtrKernelParam;
+}
 return PtrKernelParam;
   }
 
@@ -8649,11 +8658,17 @@
 
   switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to a pointer type.
-S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
-D.setInvalidType();
+// OpenCL v3.0 s6.11.a:
+// A kernel function argument cannot be declared as a pointer to a pointer
+// type. [...] This restriction only applies to OpenCL C 1.2 or below.
+if (S.getLangOpts().OpenCLVersion < 120 &&
+!S.getLangOpts().OpenCLCPlusPlus) {
+  S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
+  D.setInvalidType();
+  return;
+}
+
+ValidTypes.insert(PT.getTypePtr());
 return;
 
   case InvalidAddrSpacePtrKernelParam:


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a pointer}}
+// e

[PATCH] D92231: [OpenCL] Implement extended subgroups fully in headers

2020-12-01 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D92231

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


[PATCH] D92342: [HIP] Fix HIP test on windows due to lld suffix

2020-12-01 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@ashi1 This is causing build failures - please can you take a look ? 
http://lab.llvm.org:8011/#/builders/14/builds/2514

  :17:66: note: possible intended match here
   "/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/bin/llvm-ar" "rcsD" 
"a.out" "/tmp/a-88f827.o" "/tmp/b-11b5fe.o" "/tmp/a-72b91c.o"
   ^
  Input file: 
  Check file: 
/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.src/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  -dump-input=help explains the following input dump.
  Input was:
  <<
  .
  .
  .
  9:  
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/bin/clang-12" "-cc1" 
"-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" 
"-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-main-file-name" "a.cu" 
"-mrelocation-model" "pic" "-pic-level" "1" "-mframe-pointer=all" 
"-fdenormal-fp-math-f32=preserve-sign,preserve-sign" "-fno-rounding-math" 
"-mconstructor-aliases" "-aux-target-cpu" "x86-64" "-fcuda-is-device" 
"-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden" 
"-fapply-global-visibility-to-externs" "-target-cpu" "gfx803" 
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0" 
"-internal-isystem" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0" 
"-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward" 
"-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward" 
"-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0/include"
 "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0/include"
 "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-std=c++11" "-fdeprecated-macro" "-fno-autolink" 
"-fdebug-compilation-dir" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/tools/clang/test/Driver"
 "-ferror-limit" "19" "-fhip-new-launch-api" "-fgnuc-version=4.2.1" 
"-fcxx-exceptions" "-fexceptions" "-fcuda-allow-variadic-functions" 
"-munsafe-fp-atomics" "-faddrsig" "-o" "/tmp/a-0292f9.bc" "-x" "hip" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.src/clang/test/Driver/Inputs/hip_multiple_inputs/a.cu"
 10:  
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/bin/clang-12" "-cc1" 
"-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" 
"-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-main-file-name" "b.hip" 
"-mrelocation-model" "pic" "-pic-level" "1" "-mframe-pointer=all" 
"-fdenormal-fp-math-f32=preserve-sign,preserve-sign" "-fno-rounding-math" 
"-mconstructor-aliases" "-aux-target-cpu" "x86-64" "-fcuda-is-device" 
"-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden" 
"-fapply-global-visibility-to-externs" "-target-cpu" "gfx803" 
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0" 
"-internal-isystem" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/lib/clang/12.0.0" 
"-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward" 
"-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward" 
"-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/l

[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This is a step towards making compile_commands.json reloadable.

The idea is:

- in addition to rare CDB loads we're soon going to have somewhat-rare CDB 
reloads and fairly-common stat() of files to validate the CDB
- so stop doing all our work under a big global lock, instead using it to 
acquire per-directory structures with their own locks
- each directory can be refreshed from disk every N seconds, like filecache
- avoid locking these at all in the most common case: directory has no CDB


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92381

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h

Index: clang-tools-extra/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.h
@@ -81,13 +81,15 @@
   llvm::Optional getProjectInfo(PathRef File) const override;
 
 private:
-  /// Caches compilation databases loaded from directories.
-  struct CachedCDB {
-std::string Path; // Not case-folded.
-std::unique_ptr CDB = nullptr;
-bool SentBroadcast = false;
-  };
-  CachedCDB &getCDBInDirLocked(PathRef File) const;
+  class DirectoryCache;
+  // Keyed by possibly-case-folded directory path.
+  // We can hand out pointers as they're stable and entries are never removed.
+  mutable llvm::StringMap DirCaches;
+  mutable std::mutex Mutex;
+  mutable std::unique_ptr OnlyDirCache;
+
+  std::vector
+  getDirectoryCaches(llvm::ArrayRef Dirs) const;
 
   struct CDBLookupRequest {
 PathRef FileName;
@@ -95,21 +97,13 @@
 bool ShouldBroadcast = false;
   };
   struct CDBLookupResult {
-tooling::CompilationDatabase *CDB = nullptr;
+std::shared_ptr CDB;
 ProjectInfo PI;
   };
   llvm::Optional lookupCDB(CDBLookupRequest Request) const;
 
   // Performs broadcast on governed files.
   void broadcastCDB(CDBLookupResult Res) const;
-
-  mutable std::mutex Mutex;
-  // Keyed by possibly-case-folded directory path.
-  mutable llvm::StringMap CompilationDatabases;
-
-  /// Used for command argument pointing to folder where compile_commands.json
-  /// is located.
-  llvm::Optional CompileCommandsDir;
 };
 
 /// Extracts system include search path from drivers matching QueryDriverGlobs
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -58,10 +60,112 @@
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool Dirty = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast

[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:89
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.

All these members feel pretty messy, there's definitely some redundancy (e.g. 
`CachePopulated` is equivalent to `CDB || FinalizedNoCDB` at the moment).

Basically this is an intermediate state: CachePopulated will become the 
validity time of the cached value (which *is* meaningful when CDB is set).

I can try to polish this code in its own right, or optimize for a smooth 
transition to cache/expiry, but probably not both at once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92381

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


[PATCH] D92231: [OpenCL] Implement extended subgroups fully in headers

2020-12-01 Thread Piotr Fusik via Phabricator via cfe-commits
PiotrFusik added a comment.

These specification for these extensions was edited by Ben Ashbaugh @Intel. 
I've asked him about this change.


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

https://reviews.llvm.org/D92231

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


[PATCH] D92231: [OpenCL] Implement extended subgroups fully in headers

2020-12-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D92231#2425305 , @PiotrFusik wrote:

> The specification for these extensions was edited by Ben Ashbaugh @Intel. 
> I've asked him about this change.

Sure. Thanks! Happy to hold off committing for a few days to see if Ben has any 
feedback.


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

https://reviews.llvm.org/D92231

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


[PATCH] D92384: [AST][NFC] Silence GCC warning about broken strict aliasing rules

2020-12-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: jdenny, aaron.ballman, hfinkel, llvm-commits.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
thopre requested review of this revision.

The deserialize() method would trigger the following warning on GCC <7:

  warning: dereferencing type-punned pointer will break
  strict-aliasing rules [-Wstrict-aliasing]
  
  ParamIdx P(*reinterpret_cast(&S));
 ^

&S was previously reinterpret_casted from a ParamIdx into a SerialType,
it is therefore safe to cast back into a ParamIdx. Similar to what was
done in D50608 , we replace it with two 
static_cast via void * which
silences the warning and presumably makes GCC understand that no
strict-aliasing violation is happening.

No functional change intended.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92384

Files:
  clang/include/clang/AST/Attr.h


Index: clang/include/clang/AST/Attr.h
===
--- clang/include/clang/AST/Attr.h
+++ clang/include/clang/AST/Attr.h
@@ -259,7 +259,10 @@
 
   /// Construct from a result from \c serialize.
   static ParamIdx deserialize(SerialType S) {
-ParamIdx P(*reinterpret_cast(&S));
+// Using this two-step static_cast via void * instead of reinterpret_cast
+// silences a -Wstrict-aliasing false positive from GCC7 and earlier.
+void *ParamIdxPtr = static_cast(&S);
+ParamIdx P(*static_cast(ParamIdxPtr));
 assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin");
 return P;
   }


Index: clang/include/clang/AST/Attr.h
===
--- clang/include/clang/AST/Attr.h
+++ clang/include/clang/AST/Attr.h
@@ -259,7 +259,10 @@
 
   /// Construct from a result from \c serialize.
   static ParamIdx deserialize(SerialType S) {
-ParamIdx P(*reinterpret_cast(&S));
+// Using this two-step static_cast via void * instead of reinterpret_cast
+// silences a -Wstrict-aliasing false positive from GCC7 and earlier.
+void *ParamIdxPtr = static_cast(&S);
+ParamIdx P(*static_cast(ParamIdxPtr));
 assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin");
 return P;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I wanted to defer the resolution of the todos after all existing patches 
(https://reviews.llvm.org/search/query/wPZcRaH7zHgu/#R) are upstreamed to avoid 
conflicts when rebasing and refactoring. Looking at the patches more closely, 
only two of them seem to be dealing with boolean flags, so we might as well 
come up with the right naming convention and put it in a prep patch. Below are 
my notes and though process.

The naming convention used upstream works like this:

  +---+-+
  |Keypath value with:| |
  +---+---+---+  Multiclass |
  | ''|  '-foo'   | '-no-foo' | |
  +---+---+---+-+
  |   false   |   false   |   true| OptOutFFlag |
  |   false   |   true|   false   | OptInFFlag  |
  |   true|   false   |   true| |
  |   true|   true|   false   | |
  +---+---+---+-+

To decide what multiclass to use, you ask:

- Both `Opt{Out,In}FFlag` multiclasses default the keypath to false. What 
command-line flag makes it possible to change the default value of the keypath?
  - `OptIn`  = `-ffoo`
  - `OptOut` = `-fno-foo`

This patch currently works like so:

  +---+-+
  |Keypath value with:| |
  +---+---+---+  Multiclass |
  | ''|  '-foo'   | '-no-foo' | |
  +---+---+---+-+
  |   false   |   false   |   true| OptInNegativeFFlag  |
  |   false   |   true|   false   | OptInPositiveFFlag  |
  |   true|   false   |   true| OptOutNegativeFFlag |
  |   true|   true|   false   | OptOutPositiveFFlag |
  +---+---+---+-+

To decide what multiclass to use, you'd ask two questions:

- What is the semantics of the keypath?
  - `Positive` = positive, e.g. `DoThis`
  - `Negative` = negative, e.g. `NoDoThis`

- What is the default value?
  - `OptIn`  = keypath defaults to false; it can be set to true  with `-ffoo`   
 if it has positive semantics, or with `-fno-foo` if it has negative semantics
  - `OptOut` = keypath defaults to true; it can be set to false with `-fno-foo` 
if it has positive semantics, or with `-ffoo`if it has negative semantics

I agree the axes and their naming is confusing. So how to make the behavior and 
usage clearer?

I think it's necessary to drop the assumption that exactly one of the flags is 
available in `-cc1`. Some of the record pairs I've marked with a todo don't 
conform to this scheme (e.g. `f[no_]sanitize_address_use_after_scope`) but it 
would still be nice to tie them together via a multiclass. I think it would now 
make sense to drop the `Opt{In,Out}` wording.

I think the simplest way to think about this is to encode these properties:

- What is the keypath default? Is it `true` or `false`?
- Which flag is used to invert the default keypath value? Is it `-ffoo` or 
`-fno-foo`?

How about something like this?

  
+---+-+
  |Keypath value with:| 
|
  +---+---+---+  Multiclass 
|
  | ''|  '-foo'   | '-no-foo' | 
|
  
+---+---+---+-+
  |   false   |   false   |   true| BoolOption |
  |   false   |   true|   false   | BoolOption |
  |   true|   false   |   true| BoolOption  |
  |   true|   true|   false   | BoolOption  |
  
+---+---+---+-+

I think it's really similar to the approach you outlined, but takes more 
keypath-centric approach.
To decide whether we can get away with one parametrized multiclass, I'd need to 
dig a bit deeper into TableGen.

Another problem to solve: how to declare a mixin that only applies to one of 
the two generated records?

Option 1:

Linear list of arguments with default values:

  multiclass BoolOption pos_flags = [], string pos_help = "", list 
neg_flags = [], string neg_help ="", list both_flags = [], string 
both_help_suffix = ""> { ... }

The downside here is that this gets hard to understand:

  defm inline_line_tables : BoolGOption;

This could be solved by named arguments, but I'm not sure TableGen supports 
them.

Option 2:

Group the `pos_*`, `neg_*`, `both_*` arguments into `PositiveFlag`, 
`NegativeFlag`, `BothFlags` bags:

  defm inline_line_tables : BoolGOption,
NegativeFlag<[CC1Option], "Don't emit inline line tables">, 
BothFlags<[CoreOption]>>;

@dexonsmith What do you think about

[PATCH] D92386: [VE] Add standard include path and library path for C++

2020-12-01 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: clang, VE.
Herald added subscribers: cfe-commits, ormris.
kaz7 requested review of this revision.

We have a plan to add libcxx and libcxxabi for VE.  In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup.  Add regression test for that, also.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92386

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- /dev/null
+++ clang/test/Driver/ve-toolchain.cpp
@@ -0,0 +1,120 @@
+/// Check the behavior of toolchain for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+///-
+/// Checking dwarf-version
+
+// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=4"
+
+///-
+/// Checking dynamic-linker
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DYNLINKER %s
+// DYNLINKER: nld{{.*}} "-dynamic-linker" "/opt/nec/ve/lib/ld-linux-ve.so.1"
+
+///-
+/// Checking VE specific option
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=VENLDOPT %s
+// VENLDOPT: nld{{.*}} "-z" "max-page-size=0x400"
+
+///-
+/// Checking include-path
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINC %s
+// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: "-nostdsysteminc"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdlibinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDLIBINC %s
+// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDLIBINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDLIBINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nobuiltininc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOBUILTININC %s
+// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTININC: "-nobuiltininc"
+// NOBUILTININC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOBUILTININC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOBUILTININC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINC %s
+// NOSTDINC: clang{{.*}} "-cc1"
+// NOSTDINC: "-nobuiltininc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc++ 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINCXX %s
+// NOSTDINCXX: clang{{.*}} "-cc1"
+// NOSTDINCXX: "-nostdinc++"
+// NOSTDINCXX-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINCXX: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINCXX: "-internal-isystem" "/opt/nec/ve/include"
+
+///-
+/// Checking -fuse-init-array
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINITARRAY %s
+// DEFINITARRAY: clang{{.*}} "-cc1"
+// DEFINITARRAY-NOT: "-fuse-init-array"
+
+// RUN: %clangxx -### -target ve %s -fno-use-init-array 2>&1 | \
+// RUN: FileCheck -check-prefix=NOTINITARRAY %s
+// NOTINITARRAY: clang{{.*}} "-cc1"
+// NOTINITARRAY: "-fno-use-init-array"
+
+///-
+/// Checking -faddrsig
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -fno-addrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=NOADDRSIG %s
+// NOADDRSIG: clang{{.*}} "-cc1"
+// NOADDRSIG-NOT: "-faddrsig"
+
+///-
+/// Checking exceptions
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFEXCEPTION %s
+// DEFEXCEPTION: clang{{.*}} "-cc1"
+// DEFEXCEPTI

[PATCH] D92041: [clangd] Add hover info for `this` expr

2020-12-01 Thread xndcn via Phabricator via cfe-commits
xndcn added a comment.

In D92041#2424869 , @kadircet wrote:

> can you give me an email address to associate the commit with?

xnd...@gmail.com, thank you.


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

https://reviews.llvm.org/D92041

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


[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:91
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool Dirty = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.

maybe rename this to `DidBroadcast` if we are not planning to add extra meaning 
to `Dirty` in the near future?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:119
+if (CachePopulated) {
+  ShouldBroadcast = Dirty;
+  Dirty = false;

what if caller is not willing to broadcast?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:253
+for (DirectoryCache *Candidate : getDirectoryCaches(SearchDirs)) {
+  if ((CDB = Candidate->get(ShouldBroadcast))) {
+DirCache = Candidate;

won't this overwrite `ShouldBroadcast` ?

for example if we get a query with `ShouldBroadcast` set to `true`, but first 
searchdir doesn't have a CDB underneath, for all the consecutive calls this 
will be `false`.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:263
 
-Result.CDB = Entry->CDB.get();
-Result.PI.SourceRoot = Entry->Path;
-  }
+  // Mark CDB as broadcasted to make sure discovery is performed once.
+  CDBLookupResult Result;

stale comment.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.h:88
+  mutable llvm::StringMap DirCaches;
+  mutable std::mutex Mutex;
+  mutable std::unique_ptr OnlyDirCache;

it is kind of hard to figure out if this mutex is also meant for OnlyDirCache. 
maybe separate it with a line or put some explicit `governed by` annotations?



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.h:89
+  mutable std::mutex Mutex;
+  mutable std::unique_ptr OnlyDirCache;
+

some comments about semantics of `OnlyDirCache` ? I suppose existing of it 
implies `DirCaches` won't be used at all ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92381

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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-12-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 308636.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCXX/mangle.cpp
  clang/test/Sema/invalid-bitwidth-expr.mm
  clang/test/SemaCXX/invalid-template-base-specifier.cpp
  clang/test/SemaTemplate/dependent-expr.cpp
  clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
@@ -121,4 +121,18 @@
   DeclRefExprVisitor::Lang_OBJCXX11));
 }
 
+TEST(RecursiveASTVisitor,
+ VisitInstantiationDependentDecltypeTypeUnderlyingExpr) {
+  DeclRefExprVisitor Visitor;
+  Visitor.ExpectMatch("x", 3, 57);
+  Visitor.ExpectMatch("x", 4, 57);
+  EXPECT_TRUE(Visitor.runOver(
+  R"cpp(
+  int x;
+  template void f(decltype(sizeof(T().f(x;
+  template void g(decltype(sizeof(T().f(x;
+)cpp",
+  DeclRefExprVisitor::Lang_CXX17));
+}
+
 } // end anonymous namespace
Index: clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
@@ -115,6 +115,6 @@
 
   int n;
   template struct SubstFailure;
-  TInt isf; // FIXME: this should be ill-formed
+  TInt isf; // expected-error {{template template argument has different template parameters than its corresponding template template parameter}}
   TIntPtr ipsf;
 }
Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -129,7 +129,7 @@
   template void f() {
 decltype(({})) x; // expected-error {{incomplete type}}
   }
-  template void f(); // expected-note {{instantiation of}}
+  template void f();
 
   template auto g() {
 auto c = [](auto, int) -> decltype(({})) {};
Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -12,11 +12,12 @@
 template 
 using Alias = decltype(Foo(T())); // expected-error {{no matching function for call to 'Foo'}}
 template 
-struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}}
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}} \
+  expected-error {{base specifier must name a class}}
   Crash2(){};
 };
 
-void test2() { Crash2(); } // expected-note {{in instantiation of template class 'Crash2' requested here}}
+void test2() { Crash2(); } // expected-note2 {{in instantiation of template class 'Crash2' requested here}}
 
 template 
 class Base {};
Index: clang/test/Sema/invalid-bitwidth-expr.mm
===
--- clang/test/Sema/invalid-bitwidth-expr.mm
+++ clang/test/Sema/invalid-bitwidth-expr.mm
@@ -25,7 +25,8 @@
 template 
 auto func() {
   // error-bit should be propagated from TemplateArgument to NestNameSpecifier.
-  class Base::type C; // expected-error {{no matching function for call to 'Foo'}}
+  class Base::type C; // expected-error {{no matching function for call to 'Foo'}} \
+ expected-error {{no class named 'type' in}}
   return C;
 }
 struct Z {
Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -805,6 +805,10 @@
   // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
   template void f(decltype(sizeof(1)));
 
+  template  void f(decltype(sizeof(T)), decltype(sizeof(T))) {}
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstT_ES2_
+  template void f(unsigned long, unsigned long);
+
   // Mangling for non-instantiation-dependent sizeof expressions.
   tem

[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-12-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

@rsmith I think it still makes sense to get this patch landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse updated this revision to Diff 308643.
ftynse added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix clang tests. The order of arguments is switched in the internal outlined 
function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

Files:
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -60,6 +60,25 @@
   DebugLoc DL;
 };
 
+// Returns the value stored in the given allocation. Returns null if the given
+// value is not a result of an allocation, if no value is stored or if there is
+// more than one store.
+static Value *findStoredValue(Value *AllocaValue) {
+  Instruction *Alloca = dyn_cast(AllocaValue);
+  if (!Alloca)
+return nullptr;
+  StoreInst *Store = nullptr;
+  for (Use &U : Alloca->uses()) {
+if (auto *CandidateStore = dyn_cast(U.getUser())) {
+  EXPECT_EQ(Store, nullptr);
+  Store = CandidateStore;
+}
+  }
+  if (!Store)
+return nullptr;
+  return Store->getValueOperand();
+};
+
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
@@ -401,7 +420,7 @@
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1U));
   EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  EXPECT_EQ(findStoredValue(ForkCI->getArgOperand(3)), F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelNested) {
@@ -708,13 +727,15 @@
   EXPECT_TRUE(isa(ForkCI->getArgOperand(0)));
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1));
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  Value *StoredForkArg = findStoredValue(ForkCI->getArgOperand(3));
+  EXPECT_EQ(StoredForkArg, F->arg_begin());
 
   EXPECT_EQ(DirectCI->getCalledFunction(), OutlinedFn);
   EXPECT_EQ(DirectCI->getNumArgOperands(), 3U);
   EXPECT_TRUE(isa(DirectCI->getArgOperand(0)));
   EXPECT_TRUE(isa(DirectCI->getArgOperand(1)));
-  EXPECT_EQ(DirectCI->getArgOperand(2), F->arg_begin());
+  Value *StoredDirectArg = findStoredValue(DirectCI->getArgOperand(2));
+  EXPECT_EQ(StoredDirectArg, F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelCancelBarrier) {
@@ -829,6 +850,85 @@
   }
 }
 
+TEST_F(OpenMPIRBuilderTest, ParallelForwardAsPointers) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+
+  Type *I32Ty = Type::getInt32Ty(M->getContext());
+  Type *I32PtrTy = Type::getInt32PtrTy(M->getContext());
+  Type *StructTy = StructType::get(I32Ty, I32PtrTy);
+  Type *StructPtrTy = StructTy->getPointerTo();
+  Type *VoidTy = Type::getVoidTy(M->getContext());
+  FunctionCallee RetI32Func = M->getOrInsertFunction("ret_i32", I32Ty);
+  FunctionCallee TakeI32Func =
+  M->getOrInsertFunction("take_i32", VoidTy, I32Ty);
+  FunctionCallee RetI32PtrFunc = M->getOrInsertFunction("ret_i32ptr", I32PtrTy);
+  FunctionCallee TakeI32PtrFunc =
+  M->getOrInsertFunction("take_i32ptr", VoidTy, I32PtrTy);
+  FunctionCallee RetStructFunc = M->getOrInsertFunction("ret_struct", StructTy);
+  FunctionCallee TakeStructFunc =
+  M->getOrInsertFunction("take_struct", VoidTy, StructTy);
+  FunctionCallee RetStructPtrFunc =
+  M->getOrInsertFunction("ret_structptr", StructPtrTy);
+  FunctionCallee TakeStructPtrFunc =
+  M->getOrInsertFunction("take_structPtr", VoidTy, StructPtrTy);
+  Value *I32Val = Builder.CreateCall(RetI32Func);
+  Value *I32PtrVal = Builder.CreateCall(RetI32PtrFunc);
+  Value *StructVal = Builder.CreateCall(RetStructFunc);
+  Value *StructPtrVal = Builder.CreateCall(RetStructPtrFunc);
+
+  Instruction *Internal;
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &ContinuationBB) {
+IRBuilder<>::InsertPointGuard Guard(Builder);
+Builder.restoreIP(CodeGenIP);
+Internal = Builder.CreateCall(TakeI32Func, I32Val);
+Builder.CreateCall(TakeI32PtrFunc, I32PtrVal);
+Builder.CreateCall(TakeStructFunc, StructVal);
+Builder.CreateCall(TakeStructPtrFunc, StructPtrVal);
+  };
+  auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+Value &VPtr, Value *&ReplacementValue) {
+ReplacementValue = &VPtr;
+return CodeGenIP;
+  };
+  auto FiniCB = [](InsertPointTy) {};
+
+  IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+F->getEntryBlock().getFirstInsertion

[PATCH] D92220: [clangd] Add support for static fields in rename

2020-12-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:630
   )cpp",
+  R"cpp(
+template  struct Foo { static T Variable; };

hmm, looks like these two tests are already working at head (without the patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92220

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


[PATCH] D87146: [analyzer] Implement shared semantics checks for XNU functions in PthreadLockChecker

2020-12-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Just a ping. Let me, please, do smth with this revision.


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

https://reviews.llvm.org/D87146

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse added inline comments.



Comment at: clang/test/OpenMP/parallel_codegen.cpp:139
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
-// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
+// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{64|32}}*, i8***)* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i{{64|32}}* %{{.+}}, i8*** 
[[ARGC_ADDR]])
 // ALL:  ret i32 0

The order of arguments changes here because we create a use of the 
promoted-to-pointer argument before any other uses in the body and the outliner 
finds it first. This should be fine because it's just an internal outlined 
function that the builder created and the calls to it are emitted accordingly 
and in the same builder. I can add a comment that explains this if desired.

If we go with Michael's suggestion not to turn into pointers the integer values 
whose size is equal to or smaller than pointer size, this change will not be 
necessary. I seem to remember seeing some documentation that says that trailing 
arguments to `fork_call` should be _pointers_, but I can't find it anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

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


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-12-01 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 308648.
Xiangling_L marked 3 inline comments as done.
Xiangling_L added a comment.

Split testcases;
Simplified code;
Don't need to respect attribute align within typedef when the alignment value 
is less than bitcontainer size;


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

https://reviews.llvm.org/D87029

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-bitfield-alignment.c
  clang/test/Layout/aix-bitfield-alignment.cpp

Index: clang/test/Layout/aix-bitfield-alignment.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-bitfield-alignment.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+struct A {
+  bool b : 3;
+};
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT:  0:0-2 |   _Bool b
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+enum class Bool : bool { False = 0,
+ True = 1 };
+
+struct B {
+  Bool b : 1;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct B
+// CHECK-NEXT:  0:0-0 |   enum Bool b
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+enum LL : unsigned long long { val = 1 };
Index: clang/test/Layout/aix-bitfield-alignment.c
===
--- /dev/null
+++ clang/test/Layout/aix-bitfield-alignment.c
@@ -0,0 +1,234 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+struct A {
+  unsigned char c : 2;
+} A;
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT:  0:0-1 |   unsigned char c
+// CHECK-NEXT:   sizeof=4, {{(dsize=4, )?}}align=4, preferredalign=4
+
+struct B {
+  char c;
+  int : 0;
+} B;
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct B
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:   sizeof=4, {{(dsize=4, )?}}align=4, preferredalign=4
+
+struct C {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+} C;
+
+int c = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK32: 4:0-7 |   unsigned long a7
+// CHECK32:  sizeof=8, {{(dsize=8, )?}}align=4, preferredalign=4
+// CHECK64: 3:1-8 |   unsigned long a7
+// CHECK64:  sizeof=8, {{(dsize=8, )?}}align=8, preferredalign=8
+
+#pragma align(packed)
+struct C1 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+} C1;
+#pragma align(reset)
+
+int c1 = sizeof(C1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C1
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK-NEXT:  3:1-8 |   unsigned long a7
+// CHECK-NEXT:   sizeof=5, {{(dsize=5, )?}}align=1, preferredalign=1
+
+#pragma pack(4)
+struct C2 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 

[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-12-01 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/test/Layout/aix-bitfield-alignment.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \

sfertile wrote:
> I suggest we split the test cases which are C++ only into a sperate file, and 
> run the cases that are valid in both C and C++ as both to ensure there are no 
> differences between C and C++ layout fir bit fields.
Good idea. I split the testcase as you suggested. But since C and C++ layout 
dumping are slightly different in format, the `CHECK`s are adjusted accordingly 
to avoid making testcase too messy. 


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

https://reviews.llvm.org/D87029

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


[PATCH] D92140: Fix noderef for array member of deref expr

2020-12-01 Thread Jann Horn via Phabricator via cfe-commits
thejh added a comment.

@leonardchan  I don't have commit access; can you land this change and D92141 
 for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92140

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


[PATCH] D92103: [ASTImporter] Import the default argument of TemplateTypeParmDecl

2020-12-01 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

@gamesh411 I recreated the setup you listed (thanks for that btw) but for me 
this works just fine. I assume the crash happens in a class template from one 
of the external libraries. It probably works for me because I don't have the 
same library version as you have, but just from the backtrace it's hard to know 
where the error could come from.

I'm not sure if the XTU analyzer has a way to create reproducers (maybe 
@martong knows), but if you could apply the patch below, recompile/run the 
analyzer and post the output that would help a lot with figuring out what code 
on your system is causing the crash:

  diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
  index 67ee8c0956d6..a471501aa71e 100644
  --- a/clang/lib/AST/ASTContext.cpp
  +++ b/clang/lib/AST/ASTContext.cpp
  @@ -4408,6 +4408,9 @@ static bool NeedsInjectedClassNameType(const RecordDecl 
*D) {
   /// injected class name type for the specified templated declaration.
   QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl,
 QualType TST) const {
  +  if (!NeedsInjectedClassNameType(Decl)) {
  +Decl->dumpColor();
  +  }
 assert(NeedsInjectedClassNameType(Decl));
 if (Decl->TypeForDecl) {
   assert(isa(Decl->TypeForDecl));

The output from this code is probably colorized in your terminal and looks a 
bit like this:

  |-ClassTemplateDecl 0x7ff94c04a0a0  line:1:36 A
  | |-TemplateTypeParmDecl 0x7ff94c049f50  col:26 referenced 
typename depth 0 index 0 T
  | |-CXXRecordDecl 0x7ff94c04a010  line:1:36 struct A 
definition
  | | |-DefinitionData empty standard_layout trivially_copyable 
has_user_declared_ctor can_const_default_init
  | | | |-DefaultConstructor defaulted_is_constexpr
  | | | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | | | |-MoveConstructor exists simple trivial needs_implicit
  [...]

FWIW, I don't think the patch itself introduces this regression, but it just 
causes more of the AST to be imported (and the import of these AST nodes then 
runs into an unsupported use case). This would most likely already crash if the 
analysed source code referenced that class template in some other way.




Comment at: 
lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py:25
 
-deque_type = "std::deque >"
 size_type = deque_type + "::size_type"

shafik wrote:
> Why do the default arguments not show up in the results anymore?
Because we don't show args that match the default arg in the display type 
(which is identical to what Clang does). See also rdar://59292534


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92103

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

While only partially related, can you leave a FIXME saying that more than 15 
arguments need to be packed in a structure?




Comment at: clang/test/OpenMP/parallel_codegen.cpp:139
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
-// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
+// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i{{64|32}}*, i8***)* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i{{64|32}}* %{{.+}}, i8*** 
[[ARGC_ADDR]])
 // ALL:  ret i32 0

ftynse wrote:
> The order of arguments changes here because we create a use of the 
> promoted-to-pointer argument before any other uses in the body and the 
> outliner finds it first. This should be fine because it's just an internal 
> outlined function that the builder created and the calls to it are emitted 
> accordingly and in the same builder. I can add a comment that explains this 
> if desired.
> 
> If we go with Michael's suggestion not to turn into pointers the integer 
> values whose size is equal to or smaller than pointer size, this change will 
> not be necessary. I seem to remember seeing some documentation that says that 
> trailing arguments to `fork_call` should be _pointers_, but I can't find it 
> anymore.
>  I seem to remember seeing some documentation that says that trailing 
> arguments to fork_call should be _pointers_, but I can't find it anymore.

Technically, anything that is passed in the same register as a `void *` is 
fine. The documentation on this is thin at best. As I mentioned in my response 
to @Meinersbur, I think turning everything into pointers is a reasonable way to 
handle this. I gave some rational there 
(https://reviews.llvm.org/D92189#2424690)



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:736
  "Expected copy/create callback to set replacement value!");
-  if (ReplacementValue == &V)
-return;
 }
 

ftynse wrote:
> jdoerfert wrote:
> > jdoerfert wrote:
> > > I was expecting the above logic to be placed here, after the `PrivCB` 
> > > callback as I assumed we would privatize in the sequential part. Clang 
> > > does not and we do not either (for now), which is unfortunate. It does 
> > > duplicate the privatization and makes this patch more complicated than I 
> > > anticipated. I though we can simply replace `ReplacementValue` by 
> > > `Reloaded` if `ReplacementValue` wasn't a pointer and therefor put in an 
> > > alloca. The fact that we need to reload `V` and then "replace twice" 
> > > seems really unfortunate. 
> > > 
> > > What would happen if you do not have `Reloaded` at all but instead make 
> > > it `V = createlodoad(alloca)`? After all, `Reloaded` is equivalent to `V` 
> > > in all aspects, right? Would this work? Would we still need the code 
> > > below? I feel like there must be a minimal solution as we only want to 
> > > replace the value once on the other side of the call edge.
> > -"duplicate privatization" +"duplicate replace all uses with"
> I am not sure I fully follow what you suggest, so I will elaborate on the two 
> versions I had considered.
> 
> 1. Move the code that loads back the value (currently lines 709-725) after 
> this line.  This will not remove the need for two separate "replace all uses 
> with": there uses of the original `V` in the body that need to be replaced 
> with `ReplacementValue`, and there are uses of `V` that could have been 
> introduced by `PrivCB` for the purpose of //defining// `ReplacementValue` 
> which should be replaced with `Reloaded` instead. This doesn't look like it 
> would address your concern about having double replacement.
> 
> 2. I can keep the code that loads back the value in its current place and 
> pass either `V` or `*Reloaded` to `PrivCB`. This will make sure any 
> instructions created in `PrivCB` use the `Reloaded` and don't need to be 
> update via "replace all uses with" pattern. However, this exposes the pointer 
> mechanism to the caller of `CreateParallel`. The `Value &` that `PrivCB` 
> receives is not necessarily a value that exists in the user code, it can be 
> the alloca we constructed in builder. So the implementation of `PrivCB` needs 
> to be aware of it and can no longer rely on, e.g., keeping a list of 
> values/instructions that nee

[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu updated this revision to Diff 308653.
jasonliu added a comment.

Address comment.


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

https://reviews.llvm.org/D91455

Files:
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGenCXX/personality.cpp
  llvm/include/llvm/Analysis/EHPersonalities.h
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/lib/Analysis/EHPersonalities.cpp
  llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
  llvm/lib/CodeGen/AsmPrinter/DwarfException.h
  llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/CodeGen/PowerPC/aix-exception.ll

Index: llvm/test/CodeGen/PowerPC/aix-exception.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-exception.ll
@@ -0,0 +1,152 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefixes=ASM,ASM32 %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | \
+; RUN:   FileCheck --check-prefixes=ASM,ASM64 %s
+
+@_ZTIi = external constant i8*
+
+define void @_Z9throwFuncv() {
+entry:
+  %exception = call i8* @__cxa_allocate_exception(i32 4) #2
+  %0 = bitcast i8* %exception to i32*
+  store i32 1, i32* %0, align 16
+  call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3
+  unreachable
+}
+
+; ASM:._Z9throwFuncv:
+; ASM:  bl .__cxa_allocate_exception[PR]
+; ASM:  nop
+; ASM32:lwz 4, L..C0(2)
+; ASM64:ld 4, L..C0(2)
+; ASM:  bl .__cxa_throw[PR]
+; ASM:  nop
+
+define i32 @_Z9catchFuncv() personality i8* bitcast (i32 (...)* @__xlcxx_personality_v1 to i8*) {
+entry:
+  %retval = alloca i32, align 4
+  %exn.slot = alloca i8*, align 4
+  %ehselector.slot = alloca i32, align 4
+  %0 = alloca i32, align 4
+  invoke void @_Z9throwFuncv()
+  to label %invoke.cont unwind label %lpad
+
+invoke.cont:  ; preds = %entry
+  br label %try.cont
+
+lpad: ; preds = %entry
+  %1 = landingpad { i8*, i32 }
+  catch i8* bitcast (i8** @_ZTIi to i8*)
+  %2 = extractvalue { i8*, i32 } %1, 0
+  store i8* %2, i8** %exn.slot, align 4
+  %3 = extractvalue { i8*, i32 } %1, 1
+  store i32 %3, i32* %ehselector.slot, align 4
+  br label %catch.dispatch
+
+catch.dispatch:   ; preds = %lpad
+  %sel = load i32, i32* %ehselector.slot, align 4
+  %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+  %matches = icmp eq i32 %sel, %4
+  br i1 %matches, label %catch, label %eh.resume
+
+catch:; preds = %catch.dispatch
+  %exn = load i8*, i8** %exn.slot, align 4
+  %5 = call i8* @__cxa_begin_catch(i8* %exn) #2
+  %6 = bitcast i8* %5 to i32*
+  %7 = load i32, i32* %6, align 4
+  store i32 %7, i32* %0, align 4
+  store i32 2, i32* %retval, align 4
+  call void @__cxa_end_catch() #2
+  br label %return
+
+try.cont: ; preds = %invoke.cont
+  store i32 1, i32* %retval, align 4
+  br label %return
+
+return:   ; preds = %try.cont, %catch
+  %8 = load i32, i32* %retval, align 4
+  ret i32 %8
+
+eh.resume:; preds = %catch.dispatch
+  %exn1 = load i8*, i8** %exn.slot, align 4
+  %sel2 = load i32, i32* %ehselector.slot, align 4
+  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0
+  %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1
+  resume { i8*, i32 } %lpad.val3
+}
+
+; ASM:  ._Z9catchFuncv:
+; ASM:  L..func_begin0:
+; ASM:  # %bb.0:# %entry
+; ASM:  	mflr 0
+; ASM:  L..tmp0:
+; ASM:  	bl ._Z9throwFuncv
+; ASM:  	nop
+; ASM:  L..tmp1:
+; ASM:  # %bb.1:# %invoke.cont
+; ASM:  	li 3, 1
+; ASM:  L..BB1_2:   # %return
+; ASM:  	mtlr 0
+; ASM:  	blr
+; ASM:  L..BB1_3:   # %lpad
+; ASM:  L..tmp2:
+; ASM:  	bl .__cxa_begin_catch[PR]
+; ASM:  	nop
+; ASM:  	bl .__cxa_end_catch[PR]
+; ASM:  	nop
+; ASM:  	b L..BB1_2
+; ASM:  L..func_end0:
+
+; ASM:  	.csect .gcc_except_table[RO],2
+; ASM:  	.align	2
+; ASM:  GCC_except_table1:
+; ASM:  L..exception0:
+; ASM:  	.byte	255 # @LPStart Encoding = omit
+; ASM32:	.byte	187 # @TType Encoding = 
+; ASM64:  .b

[PATCH] D92386: [VE] Add standard include path and library path for C++

2020-12-01 Thread Simon Moll via Phabricator via cfe-commits
simoll added inline comments.



Comment at: clang/lib/Driver/ToolChains/VEToolchain.cpp:109
+return;
+  if (const char *cl_include_dir = getenv("NCC_CPLUS_INCLUDE_PATH")) {
+SmallVector Dirs;

Do we want a test for this code path? Ie, checking system includes with the 
environment variable set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92386

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


[PATCH] D92342: [HIP] Fix HIP test on windows due to lld suffix

2020-12-01 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

In D92342#2425271 , @RKSimon wrote:

> @ashi1 This is causing build failures - please can you take a look ? 
> http://lab.llvm.org:8011/#/builders/14/builds/2514
>
>   :17:66: note: possible intended match here
>"/b/1/clang-x86_64-debian-new-pass-manager-fast/llvm.obj/bin/llvm-ar" 
> "rcsD" "a.out" "/tmp/a-88f827.o" "/tmp/b-11b5fe.o" "/tmp/a-72b91c.o"

Thank you, I'm working on pushing a patch ASAP, otherwise I will revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92342

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


[clang] cd5897d - [HIP] Fix static-lib test CHECK bug

2020-12-01 Thread Aaron En Ye Shi via cfe-commits

Author: Aaron En Ye Shi
Date: 2020-12-01T15:49:39Z
New Revision: cd5897d55908827faf3e16c505bd79732a8f6eb6

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

LOG: [HIP] Fix static-lib test CHECK bug

Fix hip test failures that were introduced by
previous changes to hip-toolchain-rdc-static-lib.hip
test. The .*lld.* is matching a longer string than
expected.

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

Added: 


Modified: 
clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Removed: 




diff  --git a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip 
b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
index 533d3457d5b4..b698ec763249 100644
--- a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -47,7 +47,9 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] 
[[B_BC1]]
+// CHECK: [[LLD: ".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx803"
+// CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -71,7 +73,9 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: [[LLD]] {{.*}} "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx900"
+// CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"



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


[PATCH] D90887: ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D90887

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


[PATCH] D90733: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D90733

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


[PATCH] D90889: Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D90889

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


[PATCH] D90888: Frontend: Remove redundant call to CompilerInstance::setFileManager, NFC

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D90888

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


[PATCH] D91296: Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D91296

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


[PATCH] D91297: Frontend: Take VFS and MainFileBuffer by reference in PrecompiledPreamble::CanReuse, NFC

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/include/clang/Frontend/PrecompiledPreamble.h:108
   bool CanReuse(const CompilerInvocation &Invocation,
-const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds 
Bounds,
-llvm::vfs::FileSystem *VFS) const;
+const llvm::MemoryBufferRef &MainFileBuffer,
+PreambleBounds Bounds, llvm::vfs::FileSystem &VFS) const;

dexonsmith wrote:
> kadircet wrote:
> > why not accept a value directly here? (i.e. drop const and ref)
> Ah, yes, I've done this a few times, and it still seems not quite right. But 
> the alternative also doesn't feel right when it's not necessary:
> ```
> #include "llvm/Basic/MemoryBufferRef.h"
> ```
> I'm happy either way since that file is fairly careful to avoid bloating 
> includes.
I agree this looks a bit odd, but avoiding an unnecessary include seems like a 
good excuse.


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

https://reviews.llvm.org/D91297

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


[PATCH] D92072: [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

2020-12-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: llvm/include/llvm/Config/llvm-config.h.cmake:92
 /* Define to 1 if you have the  header file. */
 #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H}
 

This is unrelated, but appears to be in the wrong header, it should be in 
config.h. It isn't namespaced, and could conflict with another project's config 
header.



Comment at: llvm/include/llvm/Config/llvm-config.h.cmake:95
+/* Define to 1 to enable the experimental new pass manager by default */
+#cmakedefine01 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
+

This should be namespaced in LLVM_*.

Can we drop "experimental" now to shorten it? LLVM_ENABLE_NEW_PASS_MANAGER?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92072

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AIXException.cpp:68
+Per = dyn_cast(F.getPersonalityFn()->stripPointerCasts());
+  bool EmitEHBlock =
+  HasLandingPads || (F.hasPersonalityFn() &&

This logic seems very similar to the base class. 

The pattern there and in other instance of EHStreamer seems to be to make these 
queries in beginFunction, store the results in a member and just early exit if 
we have nothing to emit in endFunction, etc. Is that something we should be 
doing here? (e.g. presumably the traceback emission will want to know if we 
plan to emit anything so it can emit the appropriate info)


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

https://reviews.llvm.org/D91455

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


[PATCH] D92245: -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-12-01 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

> How do things go wrong on Darwin? I was under the impression that this was 
> implemented in LLVM as strictly inline code, no runtime support required.

That is my impression as well (although it seems that an earlier version might 
have emitted calls to a stack probe routine?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92245

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


[PATCH] D92399: clang/darwin: Use response files with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis requested review of this revision.

The new MachO lld just grew support for response files in D92149 
, so let
the clang driver use it.


https://reviews.llvm.org/D92399

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8()
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8()
+  } else {
 // For older versions of the linker, use the legacy filelist method instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Extracted the darwinnew bits to D92399 . Will 
rebase this once that's in.


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

https://reviews.llvm.org/D92357

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


[PATCH] D92399: clang/darwin: Use response files with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 308675.
thakis added a comment.

fewer build errors


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

https://reviews.llvm.org/D92399

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse planned changes to this revision.
ftynse added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:736
  "Expected copy/create callback to set replacement value!");
-  if (ReplacementValue == &V)
-return;
 }
 

jdoerfert wrote:
> ftynse wrote:
> > jdoerfert wrote:
> > > jdoerfert wrote:
> > > > I was expecting the above logic to be placed here, after the `PrivCB` 
> > > > callback as I assumed we would privatize in the sequential part. Clang 
> > > > does not and we do not either (for now), which is unfortunate. It does 
> > > > duplicate the privatization and makes this patch more complicated than 
> > > > I anticipated. I though we can simply replace `ReplacementValue` by 
> > > > `Reloaded` if `ReplacementValue` wasn't a pointer and therefor put in 
> > > > an alloca. The fact that we need to reload `V` and then "replace twice" 
> > > > seems really unfortunate. 
> > > > 
> > > > What would happen if you do not have `Reloaded` at all but instead make 
> > > > it `V = createlodoad(alloca)`? After all, `Reloaded` is equivalent to 
> > > > `V` in all aspects, right? Would this work? Would we still need the 
> > > > code below? I feel like there must be a minimal solution as we only 
> > > > want to replace the value once on the other side of the call edge.
> > > -"duplicate privatization" +"duplicate replace all uses with"
> > I am not sure I fully follow what you suggest, so I will elaborate on the 
> > two versions I had considered.
> > 
> > 1. Move the code that loads back the value (currently lines 709-725) after 
> > this line.  This will not remove the need for two separate "replace all 
> > uses with": there uses of the original `V` in the body that need to be 
> > replaced with `ReplacementValue`, and there are uses of `V` that could have 
> > been introduced by `PrivCB` for the purpose of //defining// 
> > `ReplacementValue` which should be replaced with `Reloaded` instead. This 
> > doesn't look like it would address your concern about having double 
> > replacement.
> > 
> > 2. I can keep the code that loads back the value in its current place and 
> > pass either `V` or `*Reloaded` to `PrivCB`. This will make sure any 
> > instructions created in `PrivCB` use the `Reloaded` and don't need to be 
> > update via "replace all uses with" pattern. However, this exposes the 
> > pointer mechanism to the caller of `CreateParallel`. The `Value &` that 
> > `PrivCB` receives is not necessarily a value that exists in the user code, 
> > it can be the alloca we constructed in builder. So the implementation of 
> > `PrivCB` needs to be aware of it and can no longer rely on, e.g., keeping a 
> > list of values/instructions that need privatization or directly rely on 
> > types since the type would change. I decided that I did not want to change 
> > the contract that `PrivCB` has with `CreateParallel` because I was not 
> > aware of all its use cases (and have a preference for more "isolated" APIs) 
> > . However, if you think it is acceptable for the builder in order to reduce 
> > the complexity/overhead of the code, I can adapt.
> > 
> > There is a flavor of (2) that changes `PrivCB` to take both `V` and 
> > `Replacement` so that the implementation of `PrivCB` can easily detect when 
> > the pointer mechanism is active.
> Appreciate the detailed explanations!
> 
> > There is a flavor of (2) that changes PrivCB to take both V and Replacement 
> > so that the implementation of PrivCB can easily detect when the pointer 
> > mechanism is active.
> 
> This looks like a sweet-spot. We can avoid adding more replacement logic but 
> the `PrivCB` is aware of what is going on. If you are OK with this solution 
> as well I'd prefer it.
> 
Great, will do this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-12-01 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

Ah, I am sorry. Thanks for fixing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[clang] b99e2b8 - clang/darwin: Use response files with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-12-01T12:07:56-05:00
New Revision: b99e2b8b14f4ba50f9eb80bd5a2c1824099a7f96

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

LOG: clang/darwin: Use response files with ld64.lld.darwinnew

The new MachO lld just grew support for response files in D92149, so let
the clang driver use it.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index db3d57a48098..f1846a573914 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};



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


[PATCH] D92399: clang/darwin: Use response files with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb99e2b8b14f4: clang/darwin: Use response files with 
ld64.lld.darwinnew (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92399

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method 
instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -697,8 +697,10 @@
 }
   }
 
-  ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8();
-  if (Version[0] < 607) {
+  ResponseFileSupport ResponseSupport;
+  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+ResponseSupport = ResponseFileSupport::AtFileUTF8();
+  } else {
 // For older versions of the linker, use the legacy filelist method instead.
 ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8,
"-filelist"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91055: [clang-tidy] Introduce misc No Integer To Pointer Cast check

2020-12-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 308683.
lebedev.ri marked 6 inline comments as done.
lebedev.ri added a comment.
Herald added a subscriber: phosek.

@aaron.ballman @aqjune thank you for taking a look!

Rebased, mostly addressed review notes:

- Moved into `performance` module
- Don't diagnose casts of integer literals


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91055

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp
  clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-no-inttoptr.rst
  clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.c
  clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s performance-no-inttoptr %t
+
+// can't implicitly cast int to a pointer.
+// can't use static_cast<>() to cast integer to a pointer.
+// can't use dynamic_cast<>() to cast integer to a pointer.
+// can't use const_cast<>() to cast integer to a pointer.
+
+void *t0(long long int x) {
+  return (void *)x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+void *t1(int x) {
+  return reinterpret_cast(x);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+// Don't diagnose casts from integer literals.
+// It's a widely-used technique in embedded/microcontroller/hardware interfacing.
+void *t3(long long int x) {
+  return (void *)0xFEEDFACE;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-no-inttoptr.c
@@ -0,0 +1,66 @@
+// RUN: %check_clang_tidy %s performance-no-inttoptr %t
+
+void *t0(char x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t1(signed char x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t2(unsigned char x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+void *t3(short x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t4(unsigned short x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t5(signed short x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+void *t6(int x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t7(unsigned int x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t8(signed int x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+void *t9(long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t10(unsigned long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t11(signed long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+
+void *t12(long long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t13(unsigned long long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
+void *t14(signed long long x) {
+  return x;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid integer to pointer casts [performance-no-inttoptr]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/performance-no-inttoptr.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/performance-no-inttoptr.rst
@@ -0,0 +1,45 @@
+.. title:: clang-tidy - performance-no-inttoptr
+
+performance-no-inttoptr
+===
+
+Diagnoses every integer to pointer cast.
+
+Whi

[PATCH] D92357: clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 308684.
thakis edited the summary of this revision.
thakis added a comment.

rebase


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

https://reviews.llvm.org/D92357

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -698,7 +698,10 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method 
instead.


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -698,7 +698,10 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method instead.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Lubomir Litchev via Phabricator via cfe-commits
llitchev added a comment.

In D92189#2425639 , @jdoerfert wrote:

> While only partially related, can you leave a FIXME saying that more than 15 
> arguments need to be packed in a structure?

Yes, the number of varargs that is guarantee to work is 15, if more are needed, 
there is a need to wrap the parameters in a struct.
As we discussed (bring it here too) the issue here is how parameters are passed 
following the calling convention. The varargs assumes that parameters are 
passed in GPR (INTEGER classifications based on the calling conventions). The 
varargs approach works fine for the INTEGER classified args. It breaks for the 
SSE(UP) and vector clarified parameters. If we pass the pointers to the SSE 
params (floats for example) everything will work - pointers are INTEGER 
classification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

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


[clang-tools-extra] ae7ec47 - [NFC][clang-tidy] Port rename_check.py to Python3

2020-12-01 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-12-01T20:10:19+03:00
New Revision: ae7ec47fc655537ce82c0bfee0b587921663eaff

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

LOG: [NFC][clang-tidy] Port rename_check.py to Python3

Added: 


Modified: 
clang-tools-extra/clang-tidy/rename_check.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/rename_check.py 
b/clang-tools-extra/clang-tidy/rename_check.py
index 4d5311c9a293..2410041fd5d2 100755
--- a/clang-tools-extra/clang-tidy/rename_check.py
+++ b/clang-tools-extra/clang-tidy/rename_check.py
@@ -120,16 +120,15 @@ def adapt_cmake(module_path, check_name_camel):
   if (not file_added) and (cpp_line or cpp_found):
 cpp_found = True
 if (line.strip() > cpp_file) or (not cpp_line):
-  f.write('  ' + cpp_file + '\n')
+  f.write(('  ' + cpp_file + '\n').encode())
   file_added = True
-  f.write(line)
+  f.write(line.encode())
 
   return True
 
 # Modifies the module to include the new check.
 def adapt_module(module_path, module, check_name, check_name_camel):
-  modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
- os.listdir(module_path))[0]
+  modulecpp = next(filter(lambda p: p.lower() == module.lower() + 
'tidymodule.cpp', os.listdir(module_path)))
   filename = os.path.join(module_path, modulecpp)
   with open(filename, 'r') as f:
 lines = f.readlines()
@@ -149,21 +148,21 @@ def adapt_module(module_path, module, check_name, 
check_name_camel):
   header_found = True
   if match.group(1) > check_name_camel:
 header_added = True
-f.write('#include "' + check_name_camel + '.h"\n')
+f.write(('#include "' + check_name_camel + '.h"\n').encode())
 elif header_found:
   header_added = True
-  f.write('#include "' + check_name_camel + '.h"\n')
+  f.write(('#include "' + check_name_camel + '.h"\n').encode())
 
   if not check_added:
 if line.strip() == '}':
   check_added = True
-  f.write(check_decl)
+  f.write(check_decl.encode())
 else:
   match = re.search('registerCheck<(.*)>', line)
   if match and match.group(1) > check_name_camel:
 check_added = True
-f.write(check_decl)
-  f.write(line)
+f.write(check_decl.encode())
+  f.write(line.encode())
 
 
 # Adds a release notes entry.
@@ -198,22 +197,22 @@ def add_release_notes(clang_tidy_path, old_check_name, 
new_check_name):
 
 if match:
   header_found = True
-  f.write(line)
+  f.write(line.encode())
   continue
 
 if line.startswith(''):
-  f.write(line)
+  f.write(line.encode())
   continue
 
 if header_found and add_note_here:
   if not line.startswith(''):
-f.write("""- The '%s' check was renamed to :doc:`%s
+f.write(("""- The '%s' check was renamed to :doc:`%s
   `
 
-""" % (old_check_name, new_check_name, new_check_name))
+""" % (old_check_name, new_check_name, new_check_name)).encode())
 note_added = True
 
-  f.write(line)
+  f.write(line.encode())
 
 def main():
   parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
@@ -259,9 +258,9 @@ def main():
 (check_name_camel, cmake_lists))
   return 1
 
-modulecpp = filter(
+modulecpp = next(filter(
 lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
-os.listdir(old_module_path))[0]
+os.listdir(old_module_path)))
 deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_name)
 



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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AIXException.cpp:68
+Per = dyn_cast(F.getPersonalityFn()->stripPointerCasts());
+  bool EmitEHBlock =
+  HasLandingPads || (F.hasPersonalityFn() &&

daltenty wrote:
> This logic seems very similar to the base class. 
> 
> The pattern there and in other instance of EHStreamer seems to be to make 
> these queries in beginFunction, store the results in a member and just early 
> exit if we have nothing to emit in endFunction, etc. Is that something we 
> should be doing here? (e.g. presumably the traceback emission will want to 
> know if we plan to emit anything so it can emit the appropriate info)
I agree that this is a query that we want to share with the traceback table 
emission. 
Presumably, we need to do the traceback table emission somewhere in 
PPCAIXAsmPrinter.
So that means we would need to have a query that could accessible from 
PPCAIXAsmPrinter and here. 
And there are other EHStreamer that have similar queries (but not all of them), 
so this makes it trickier to get it right if we want to do it for all 
platforms. 
I was hoping to address this issue when we actually do the traceback table 
emission for EH info so that we could keep the scope of the patch reasonable.


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

https://reviews.llvm.org/D91455

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


[PATCH] D92041: [clangd] Add hover info for `this` expr

2020-12-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet requested changes to this revision.
kadircet added a comment.
This revision now requires changes to proceed.

In D92041#2424928 , @njames93 wrote:

> One last point, is it worth including cv qualifications in the hover info?

Yes, I think we should (and I thought we already did!). Sorry for messing this 
up, I am not sure what made me change my mind in the middle but we should 
definitely be using `QualType` printing rather than `NamedDecl` printing, 
similar to how we generate hover for `auto`s.

It produces an output like:

  namespace ns {
  template  struct Foo {};
  tempate <> struct Foo { void bar() { thi^s; } };
  }

-> `const ns::Foo*`

which contains both the namespaces and template parameters, including 
cv-qualifier and is pretty concise. The only downside to Decl printing is we 
will lose `Documentation` support, I am not sure how important it is but we can 
easily augment the output to contain that if it turns out to be important.


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

https://reviews.llvm.org/D92041

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


[PATCH] D83892: [clang][cli] Port CodeGen option flags to new option parsing system

2020-12-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

@Bigcheese brought up that if you wanted to mimic the current logic in 
`OptInFFlag` that automatically creates the `-cc1` option with my current 
proposal, you'd need to remember to pass it to the right `Flags` (e.g.: use 
`NegativeFlag<[CC1Option]>` when using `InvertedByNegativeFlag`). My hope is 
that this could be handled automatically by a thin wrapper around `BoolOption`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83892

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6416
+  if (D->hasAttr())
+return true;
+

rjmccall wrote:
> I don't think we can just unconditionally check for the attribute.  The rule 
> for `trivial_abi` is that it overrides direct sources of non-triviality, but 
> if there's a subobject which can't be safely passed in registers, we'll still 
> pass aggregates indirectly.  This means we can safely add the attribute 
> whenever a class's own special members don't rely on non-triviality without 
> having to recursively check the component types.
If there's a non-trivial field (or base) then the attribute won't be applied 
and a warning will be emitted. See the below tests (though, it would probably 
be good to add some more).



Comment at: clang/test/SemaCXX/attr-trivial-abi.cpp:30
 
 // Diagnose invalid trivial_abi even when the type is templated because it has 
a non-trivial field.
 template 

Here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64

2020-12-01 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: asb, lenary, vitalybuka, eugenis, EccoTheDolphin.
Herald added subscribers: Sanitizers, cfe-commits, NickHung, evandro, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, PkmX, rogfer01, shiva0217, 
kito-cheng, simoncook, fedor.sergeev, mgorny.
Herald added projects: clang, Sanitizers.
luismarques requested review of this revision.

Fixes the broken RISCV64 implementation of `internal_clone` and adds RISCV64 
support for LSan.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92403

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
  compiler-rt/test/asan/lit.cfg.py
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/lit.common.cfg.py
  compiler-rt/test/sanitizer_common/print_address.h

Index: compiler-rt/test/sanitizer_common/print_address.h
===
--- compiler-rt/test/sanitizer_common/print_address.h
+++ compiler-rt/test/sanitizer_common/print_address.h
@@ -8,7 +8,7 @@
   while (n--) {
 void *p = va_arg(ap, void *);
 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-defined(__s390x__)
+defined(__s390x__) || (defined(__riscv) && (__riscv_xlen == 64))
 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
 // match to the format used in the diagnotic message.
 fprintf(stderr, "0x%012lx ", (unsigned long) p);
Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -76,7 +76,7 @@
 # LeakSanitizer tests are currently supported on
 # Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
-supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x']
+supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
 if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
Index: compiler-rt/test/lsan/TestCases/use_registers.cpp
===
--- compiler-rt/test/lsan/TestCases/use_registers.cpp
+++ compiler-rt/test/lsan/TestCases/use_registers.cpp
@@ -50,6 +50,10 @@
   asm("lgr %%r10, %0"
   :
   : "r"(p));
+#elif defined(__riscv)
+  asm("mv s11, %0"
+  :
+  : "r"(p));
 #else
 #error "Test is not supported on this architecture."
 #endif
Index: compiler-rt/test/asan/lit.cfg.py
===
--- compiler-rt/test/asan/lit.cfg.py
+++ compiler-rt/test/asan/lit.cfg.py
@@ -210,7 +210,7 @@
 
 # Turn on leak detection on 64-bit Linux.
 leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64'])
-leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386'])
+leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64'])
 leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64')
 leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386'])
 if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd:
Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
===
--- compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -492,7 +492,7 @@
!SI_SOLARIS)  // NOLINT
 #define SANITIZER_INTERCEPT_CFREE\
   (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \
-   !SI_SOLARIS && !SANITIZER_ANDROID)  // NOLINT
+   !SI_SOLARIS && !SANITIZER_ANDROID && !SANITIZER_RISCV64)  // NOLINT
 #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX
 #define SANITIZER_INTERCEPT_A

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6416
+  if (D->hasAttr())
+return true;
+

zoecarver wrote:
> rjmccall wrote:
> > I don't think we can just unconditionally check for the attribute.  The 
> > rule for `trivial_abi` is that it overrides direct sources of 
> > non-triviality, but if there's a subobject which can't be safely passed in 
> > registers, we'll still pass aggregates indirectly.  This means we can 
> > safely add the attribute whenever a class's own special members don't rely 
> > on non-triviality without having to recursively check the component types.
> If there's a non-trivial field (or base) then the attribute won't be applied 
> and a warning will be emitted. See the below tests (though, it would probably 
> be good to add some more).
Do we just remove it without a warning in template instantiation?  At any rate, 
if we're relying on the attribute not being present when it isn't 
authoritative, we should say that here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: llvm/lib/CodeGen/AsmPrinter/AIXException.cpp:68
+Per = dyn_cast(F.getPersonalityFn()->stripPointerCasts());
+  bool EmitEHBlock =
+  HasLandingPads || (F.hasPersonalityFn() &&

jasonliu wrote:
> daltenty wrote:
> > This logic seems very similar to the base class. 
> > 
> > The pattern there and in other instance of EHStreamer seems to be to make 
> > these queries in beginFunction, store the results in a member and just 
> > early exit if we have nothing to emit in endFunction, etc. Is that 
> > something we should be doing here? (e.g. presumably the traceback emission 
> > will want to know if we plan to emit anything so it can emit the 
> > appropriate info)
> I agree that this is a query that we want to share with the traceback table 
> emission. 
> Presumably, we need to do the traceback table emission somewhere in 
> PPCAIXAsmPrinter.
> So that means we would need to have a query that could accessible from 
> PPCAIXAsmPrinter and here. 
> And there are other EHStreamer that have similar queries (but not all of 
> them), so this makes it trickier to get it right if we want to do it for all 
> platforms. 
> I was hoping to address this issue when we actually do the traceback table 
> emission for EH info so that we could keep the scope of the patch reasonable.
Thanks, I think that helps explain the structure here. This should be amenable 
to later refactoring, so that sounds good for now.


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

https://reviews.llvm.org/D91455

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6416
+  if (D->hasAttr())
+return true;
+

rjmccall wrote:
> zoecarver wrote:
> > rjmccall wrote:
> > > I don't think we can just unconditionally check for the attribute.  The 
> > > rule for `trivial_abi` is that it overrides direct sources of 
> > > non-triviality, but if there's a subobject which can't be safely passed 
> > > in registers, we'll still pass aggregates indirectly.  This means we can 
> > > safely add the attribute whenever a class's own special members don't 
> > > rely on non-triviality without having to recursively check the component 
> > > types.
> > If there's a non-trivial field (or base) then the attribute won't be 
> > applied and a warning will be emitted. See the below tests (though, it 
> > would probably be good to add some more).
> Do we just remove it without a warning in template instantiation?  At any 
> rate, if we're relying on the attribute not being present when it isn't 
> authoritative, we should say that here.
Alright. I'll put a comment. 

> Do we just remove it without a warning in template instantiation?

[[ https://godbolt.org/z/8Ex936 | That would appear to be what happens. ]]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92357: clang/darwin: Don't use response files with ld64

2020-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D92357

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


[PATCH] D92357: clang/darwin: Don't use response files with ld64

2020-12-01 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

I'm a bit worried that without a repro case (outside of the missing newline) 
Apple won't get around to fixing this, and in the meantime I'm wondering if 
outside of the chromium build system folks will experience this. I wonder if 
there's an acceptable alternative here such as adding a (ideally temporary) 
flag to force the old behavior?


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

https://reviews.llvm.org/D92357

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


[PATCH] D92357: clang/darwin: Don't use response files with ld64

2020-12-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D92357#2426042 , @keith wrote:

> I'm a bit worried that without a repro case (outside of the missing newline) 
> Apple won't get around to fixing this, and in the meantime I'm wondering if 
> outside of the chromium build system folks will experience this. I wonder if 
> there's an acceptable alternative here such as adding a (ideally temporary) 
> flag to force the old behavior?

Chromium just lets ninja write the rsp file, like many projects.


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

https://reviews.llvm.org/D92357

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


[PATCH] D92189: [OpenMPIRBuilder] forward arguments as pointers to outlined function

2020-12-01 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse updated this revision to Diff 308698.
ftynse added a comment.

Simplify the code by adapting the PrivatizationCallback signature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92189

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -60,6 +60,25 @@
   DebugLoc DL;
 };
 
+// Returns the value stored in the given allocation. Returns null if the given
+// value is not a result of an allocation, if no value is stored or if there is
+// more than one store.
+static Value *findStoredValue(Value *AllocaValue) {
+  Instruction *Alloca = dyn_cast(AllocaValue);
+  if (!Alloca)
+return nullptr;
+  StoreInst *Store = nullptr;
+  for (Use &U : Alloca->uses()) {
+if (auto *CandidateStore = dyn_cast(U.getUser())) {
+  EXPECT_EQ(Store, nullptr);
+  Store = CandidateStore;
+}
+  }
+  if (!Store)
+return nullptr;
+  return Store->getValueOperand();
+};
+
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
@@ -341,20 +360,25 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 ++NumPrivatizedVars;
 
-if (!isa(VPtr)) {
-  EXPECT_EQ(&VPtr, F->arg_begin());
-  ReplacementValue = &VPtr;
+if (!isa(Orig)) {
+  EXPECT_EQ(&Orig, F->arg_begin());
+  ReplacementValue = &Inner;
   return CodeGenIP;
 }
 
+// Since the original value is an allocation, it has a pointer type and
+// therefore no additional wrapping should happen.
+EXPECT_EQ(&Orig, &Inner);
+
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -401,7 +425,7 @@
   EXPECT_EQ(ForkCI->getArgOperand(1),
 ConstantInt::get(Type::getInt32Ty(Ctx), 1U));
   EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
-  EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
+  EXPECT_EQ(findStoredValue(ForkCI->getArgOperand(3)), F->arg_begin());
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelNested) {
@@ -423,12 +447,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -515,12 +540,13 @@
   };
 
   auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
-Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+Value &Orig, Value &Inner,
+Value *&ReplacementValue) -> InsertPointTy {
 // Trivial copy (=firstprivate).
 Builder.restoreIP(AllocaIP);
-Type *VTy = VPtr.getType()->getPointerElementType();
-Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
-ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Type *VTy = Inner.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &Inner, Orig.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, Orig.getName() + ".copy");
 Builder.restoreIP(CodeGenIP);
 Builder.CreateStore(V, ReplacementValue);
 return CodeGenIP;
@@ -6

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 308699.
zoecarver added a comment.

- Add comment in SemaDeclCXX.
- Add tests for non-trivial bases/members.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -101,34 +101,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted a;
-  };
-
-  struct __attribute__((trivial_abi)) CopyDeleted {
-CopyDeleted(const CopyDeleted &) = delete;
-CopyDeleted(CopyDeleted &&) = default;
-  };
-
-  struct __attribute__((trivial_abi)) MoveDeleted {
-MoveDeleted(const MoveDeleted &) = default;
-MoveDeleted(MoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyDeleted a;
-MoveDeleted b;
-  };
-
-  // This is fine since the move constructor isn't deleted.
-  struct __attribute__((trivial_abi)) S20 {
-int &&a; // a member of rvalue reference type deletes the copy constructor.
-  };
-}
Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -34,6 +34,21 @@
   S3_2 s32;
 };
 
+struct NonTrivial {
+NonTrivial(const NonTrivial&) { }
+~NonTrivial() {}
+};
+
+struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{has a field of a non-trivial class type}}
+NonTrivial n;
+~S18() { }
+};
+
+struct __attribute__((trivial_abi)) S19: NonTrivial { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{'trivial_abi' is disallowed on 'S19' because it has a base of a non-trivial class type}}
+int n;
+~S19() { }
+};
+
 struct S4 {
   int a;
 };
@@ -79,34 +94,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted a;
-};
-
-struct __attribute__((trivial_abi)) CopyDeleted {
-  CopyDeleted(const CopyDeleted &) = delete;
-  CopyDeleted(CopyDeleted &&) = default;
-};
-
-struct __attribute__((trivial_abi)) MoveDeleted {
-  MoveDeleted(const MoveDeleted &) = default;
-  MoveDeleted(MoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyDeleted a;
-  MoveDeleted b;
-};
-
-// This is fine since the move constructor isn't deleted.
-struct __attribute__((trivial_abi)) S20 {
-  int &&a; // a member of rvalue reference type deletes the copy constructor.
-};
-} // namespace deletedCopyMoveConstructor
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -5,6 +5,12 @@
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
 // CHECK: %[[STRUCT_TRIVIAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_NONTRIVIAL:.*]] = type { i32 }
+// CHECK: [[STRUCT_COPY_MOVE_DELETED:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_1:%.*]] = type { i8 }
+// CHECK: [[STRUCT_MOVE_LIKE_2:%.*]] = type { i8 }
+// CHECK: [[STRUCT_HAS_MEMBER_COPY_MOVE_DELETED:%.*]] = type { [[STRUCT_COPY_MOVE_DELETED]] }
+// CHECK: [[STRUCT_TEMPLATED_NON_TRIVIAL:%.*]] = type { %[[STRUCT_NONTRIVIAL]] }
+// CHECK:

[PATCH] D92072: [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

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

In D92072#2425025 , @hans wrote:

> Seems like a good idea to me.
>
> From the change description:
>
>> This allows us to use its value everywhere, rather than just llvm.
>
> Do you mean rather than just clang?

Whoops, yup.




Comment at: llvm/include/llvm/Config/llvm-config.h.cmake:95
+/* Define to 1 to enable the experimental new pass manager by default */
+#cmakedefine01 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
+

rnk wrote:
> This should be namespaced in LLVM_*.
> 
> Can we drop "experimental" now to shorten it? LLVM_ENABLE_NEW_PASS_MANAGER?
That would mean changing the CMake variable name which would break everybody 
using the flag. I can add a #define alias if you want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92072

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


[PATCH] D92406: [OpenCL] Add some more kernel argument tests

2020-12-01 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added a subscriber: yaxunl.
Herald added a project: clang.
svenvh requested review of this revision.

These cases weren't in any of the SemaOpenCL tests yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92406

Files:
  clang/test/SemaOpenCL/invalid-kernel-parameters.cl


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@
 // expected-error@+1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@
 // expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/aix-exception.ll:108-109
+; ASM: .byte   255 # @LPStart Encoding = 
omit
+; ASM32:   .byte   187 # @TType Encoding = 

+; ASM64:  .byte188 # @TType Encoding = 

+; ASM: .uleb128 L..ttbase0-L..ttbaseref0

Is there a plan to update the annotation output here?


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

https://reviews.llvm.org/D91455

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


[PATCH] D92408: [clangd] ExtractFunction: disable on regions that sometimes, but not always return.

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

apply() will fail in those cases, so it's better to detect it in
prepare() already and hide code action from the user.

This was especially annoying on code bases that use a lot of
RETURN_IF_ERROR-like macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92408

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -607,7 +607,11 @@
   // Extract certain return
   EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
   // Don't extract uncertain return
-  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "), StartsWith("fail"));
+  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "),
+  StartsWith("unavailable"));
+  EXPECT_THAT(
+  apply("#define RETURN_IF_ERROR(x) if (x) return\nRETU^RN_IF_ERROR(4);"),
+  StartsWith("unavailable"));
 
   FileName = "a.c";
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("unavailable"));
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -708,6 +708,27 @@
   return tooling::Replacement(SM, ExtractedFunc.InsertionPoint, 0, 
FunctionDef);
 }
 
+// Returns true if ExtZone contains any ReturnStms.
+bool hasReturnStmt(const ExtractionZone &ExtZone) {
+  class ReturnStmtVisitor
+  : public clang::RecursiveASTVisitor {
+  public:
+bool VisitReturnStmt(ReturnStmt *Return) {
+  Found = true;
+  return false; // We found the answer, abort the scan.
+}
+bool Found = false;
+  };
+
+  ReturnStmtVisitor V;
+  for (const auto *RootStmt : ExtZone.RootStmts) {
+V.TraverseStmt(const_cast(RootStmt));
+if (V.Found)
+  break;
+  }
+  return V.Found;
+}
+
 bool ExtractFunction::prepare(const Selection &Inputs) {
   const LangOptions &LangOpts = Inputs.AST->getLangOpts();
   if (!LangOpts.CPlusPlus)
@@ -715,8 +736,12 @@
   const Node *CommonAnc = Inputs.ASTSelection.commonAncestor();
   const SourceManager &SM = Inputs.AST->getSourceManager();
   auto MaybeExtZone = findExtractionZone(CommonAnc, SM, LangOpts);
+  if (!MaybeExtZone ||
+  (hasReturnStmt(*MaybeExtZone) && !alwaysReturns(*MaybeExtZone)))
+return false;
+
   // FIXME: Get rid of this check once we support hoisting.
-  if (!MaybeExtZone || MaybeExtZone->requiresHoisting(SM))
+  if (MaybeExtZone->requiresHoisting(SM))
 return false;
 
   ExtZone = std::move(*MaybeExtZone);


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -607,7 +607,11 @@
   // Extract certain return
   EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
   // Don't extract uncertain return
-  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "), StartsWith("fail"));
+  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "),
+  StartsWith("unavailable"));
+  EXPECT_THAT(
+  apply("#define RETURN_IF_ERROR(x) if (x) return\nRETU^RN_IF_ERROR(4);"),
+  StartsWith("unavailable"));
 
   FileName = "a.c";
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("unavailable"));
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -708,6 +708,27 @@
   return tooling::Replacement(SM, ExtractedFunc.InsertionPoint, 0, FunctionDef);
 }
 
+// Returns true if ExtZone contains any ReturnStms.
+bool hasReturnStmt(const ExtractionZone &ExtZone) {
+  class ReturnStmtVisitor
+  : public clang::RecursiveASTVisitor {
+  public:
+bool VisitReturnStmt(ReturnStmt *Return) {
+  Found = true;
+  return false; // We found the answer, abort the scan.
+}
+bool Found = false;
+  };
+
+  ReturnStmtVisitor V;
+  for (const auto *RootStmt : ExtZone.RootStmts) {
+V.TraverseStmt(const_cast(RootStmt));
+if (V.Found)
+  break;
+  }
+  return V.Found;
+}
+
 bool ExtractFunction::prepare(const Selection &Inputs) {
   const LangOptions &LangOpts = Inputs.AST->getLangOpts();
   if (!LangOpts.CPlusPlus)
@@ -715,8 +736,12 @@
   const Node *CommonAnc = Inputs.ASTSelection.common

[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2020-12-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: ABataev, rjmccall, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
thopre requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

GCC's -Wcomment warning is emitted on OMPDeclareReductionDecl heading
comment due to the continuation mark in the code example. This commit
changes the comment style to javadoc to avoid the warning and allow
building with -Werror.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92409

Files:
  clang/include/clang/AST/DeclOpenMP.h


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -158,16 +158,18 @@
   static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
 };
 
-/// This represents '#pragma omp declare reduction ...' directive.
-/// For example, in the following, declared reduction 'foo' for types 'int' and
-/// 'float':
-///
-/// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
-/// initializer (omp_priv = 0)
-/// \endcode
-///
-/// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an 
initializer.
+/**
+ * This represents '#pragma omp declare reduction ...' directive.
+ * For example, in the following, declared reduction 'foo' for types 'int' and
+ * 'float':
+ *
+ * \code
+ * #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+ * initializer (omp_priv = 0)
+ * \endcode
+ *
+ * Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an initializer.
+ */
 class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext {
   // This class stores some data in DeclContext::OMPDeclareReductionDeclBits
   // to save some space. Use the provided accessors to access it.


Index: clang/include/clang/AST/DeclOpenMP.h
===
--- clang/include/clang/AST/DeclOpenMP.h
+++ clang/include/clang/AST/DeclOpenMP.h
@@ -158,16 +158,18 @@
   static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
 };
 
-/// This represents '#pragma omp declare reduction ...' directive.
-/// For example, in the following, declared reduction 'foo' for types 'int' and
-/// 'float':
-///
-/// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
-/// initializer (omp_priv = 0)
-/// \endcode
-///
-/// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an initializer.
+/**
+ * This represents '#pragma omp declare reduction ...' directive.
+ * For example, in the following, declared reduction 'foo' for types 'int' and
+ * 'float':
+ *
+ * \code
+ * #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+ * initializer (omp_priv = 0)
+ * \endcode
+ *
+ * Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an initializer.
+ */
 class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext {
   // This class stores some data in DeclContext::OMPDeclareReductionDeclBits
   // to save some space. Use the provided accessors to access it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92072: [CMake][NewPM] Move ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER into llvm/

2020-12-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: llvm/include/llvm/Config/llvm-config.h.cmake:95
+/* Define to 1 to enable the experimental new pass manager by default */
+#cmakedefine01 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
+

aeubanks wrote:
> rnk wrote:
> > This should be namespaced in LLVM_*.
> > 
> > Can we drop "experimental" now to shorten it? LLVM_ENABLE_NEW_PASS_MANAGER?
> That would mean changing the CMake variable name which would break everybody 
> using the flag. I can add a #define alias if you want.
You can leave the cmake option as it is, and make a new variable with the right 
name before the call to configure_file:
  set(LLVM_ENABLE_NEW_PASS_MANAGER ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92072

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


[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2020-12-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

I would just remove this extra symbol.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92409

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


[PATCH] D91455: [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX

2020-12-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AIXException.cpp:35
+  //   unsigned long lsda; /* Pointer to LSDA */
+  //   unsigned long personality;  /* Pointerto the personality routine */
+  //   }

Typo: missing space.


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

https://reviews.llvm.org/D91455

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


[PATCH] D92406: [OpenCL] Add some more kernel argument tests

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

LGTM! Thanks




Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:40
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+

Btw this is tested in C, C++, and C++ for OpenCL. But I think it's good to test 
here as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92406

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


[PATCH] D92409: [AST][NFC] Silence GCC warning about multiline comments

2020-12-01 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D92409#2426160 , @ABataev wrote:

> I would just remove this extra symbol.

But then the example code is no longer copy/pastable. Note that I expect people 
to copy/paste but it's nice if it looks authentic. Note that I don't mind 
either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92409

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


[clang] 3734079 - Argument dependent lookup with class argument is recursing into base

2020-12-01 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2020-12-01T10:33:12-08:00
New Revision: 37340798ccb00b9c3a53e8a5f1b6430e85870338

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

LOG: Argument dependent lookup with class argument is recursing into base
classes that haven't been instantiated. This is generating an assertion
in DeclTemplate.h. Fix for Bug25668.

Added: 
clang/test/OpenMP/template-specialization.cpp

Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 16dd8f510596..34065a5a212a 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2576,6 +2576,8 @@ namespace {
 
 bool addClassTransitive(CXXRecordDecl *RD) {
   Classes.insert(RD);
+  if (InstantiationLoc.isInvalid())
+InstantiationLoc = RD->getLocation();
   return ClassesTransitive.insert(RD);
 }
 

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 63ea297493ff..dece57bb060a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17549,6 +17549,7 @@ static void checkMappableExpressionList(
 auto &DeclNames = SemaRef.getASTContext().DeclarationNames;
 MapperId.setName(DeclNames.getIdentifier(
 &SemaRef.getASTContext().Idents.get("default")));
+MapperId.setLoc(StartLoc);
   }
 
   // Iterators to find the current unresolved mapper expression.

diff  --git a/clang/test/OpenMP/template-specialization.cpp 
b/clang/test/OpenMP/template-specialization.cpp
new file mode 100644
index ..714fbf4a2011
--- /dev/null
+++ b/clang/test/OpenMP/template-specialization.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify -fopenmp -fsyntax-only %s
+
+// expected-no-diagnostics
+
+template 
+struct z {
+  static void aj() {
+T f;
+#pragma omp target map(f)
+;
+  }
+};
+
+template  class ar {};
+template  struct as {};
+template class z>>;



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


  1   2   >