[PATCH] D95057: [clangd] Allow configuration database to be specified in config.

2021-01-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:140
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+}
+

maybe also try with an absolute path in `CompilationDatabase` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95057

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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-01-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for the thoughtful comments about the API surface and such! I think I've 
addressed or responded to most of them.

There are a few outstanding comments about how the HeuristicResolver object is 
stored and passed around (const, pointer, etc.), which I'll come back to once 
we come to a resolution on the nullability question.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[clang] 46ec025 - [clang][cli] NFC: Move prefix to the front of BoolOption

2021-01-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-25T09:15:33+01:00
New Revision: 46ec0254a97dcf35a0f9f023ea7632e7ee72a1ee

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

LOG: [clang][cli] NFC: Move prefix to the front of BoolOption

The prefix used to be the last (optional) argument to BoolOption. This decision 
was made with the expectation that only few command line options would need to 
pass it explicitly instead of using Bool{F,G}Option. It turns out that a 
considerable number of options don't conform to Bool{F,G}Option and need to 
provide the prefix anyways. This sometimes requires to explicitly pass 
`BothFlags<[]>`.

This patch makes prefix the first parameter, so it now directly precedes the 
spelling base string. Now 8 options dropped `BothFlags<[]>` and only two 
options (`pthread` and `emit_llvm_uselists`) need to pass an empty prefix.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7685d343ab96..2747ee27cb8d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -375,10 +375,10 @@ class BoolOptionFlag,
-  string prefix = ""> {
+  FlagDefSuffix flags_suffix = FlagDefSuffix<[], "">> {
   defvar flag1 = FlagDefExpanded.Result,
  prefix, NAME, spelling_base>;
 
@@ -436,29 +436,28 @@ class BothFlags option_flags = [], 
string help = ""> {
 /// Creates two command line flags that control the same boolean keypath.
 ///
 /// Example:
-///   defm my_boolean_option : BoolOption<"my-boolean-option",
+///   defm my_boolean_option : BoolOption<"f", "my-boolean-option",
 /// CodeGenOpts<"MyBooleanOption">, DefaultsToFalse,
 /// ChangedBy,
 /// ResetBy,
 /// BothFlags<[CoreOption], " my boolean option.">;
 ///
 ///   The Clang driver now knows two new command line flags: the "positive"
-///   -my-boolean-option and the "negative" -no-my-boolean-option. The positive
-///   flag is also available on the CC1 command line.
+///   -fmy-boolean-option and the "negative" -fno-my-boolean-option. The
+///   positive flag is also available on the CC1 command line.
 ///
 ///   * When the command line contains neither of the flags, the keypath value
 /// defaults to false.
 ///   * When the command line contains the positive -my-boolean-option, the
 /// keypath value changes to true.
-///   * When the command line contains the negative -no-my-bool-option, the
+///   * When the command line contains the negative -fno-my-bool-option, the
 /// keypath value resets to false.
 ///
 ///   The help text for -my-boolean-option is "Enable my boolean option." and
-///   "Disable my boolean option." for -no-my-boolean-option.
-multiclass BoolOption,
-  string name_prefix = ""> {
+  ResetBy reset_by, BothFlags both = BothFlags<[], "">> {
   defvar default = Default;
 
   defvar changed_by_flag = FlagDef;
 
-  defm NAME : BoolOptionBase;
+  defm NAME : BoolOptionBase;
 }
 
 /// Creates a BoolOption with the changing available on the CC1 command line.
-multiclass BoolCC1Option,
- string name_prefix = ""> {
+ ResetBy reset_by, BothFlags both = BothFlags<[], "">> 
{
   defvar changed_by_cc1
 = ChangedBy;
 
-  defm NAME : BoolOption;
+  defm NAME : BoolOption;
 }
 
 /// Creates a BoolOption where both of the flags are prefixed with "f", are in
@@ -494,8 +492,8 @@ multiclass BoolCC1Option> {
-  defm NAME : BoolCC1Option,
+  defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by,
+reset_by, both>,
   Group;
 }
 
@@ -505,8 +503,8 @@ multiclass BoolFOption> {
-  defm NAME : BoolCC1Option,
+  defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by,
+reset_by, both>,
   Group;
 }
 
@@ -1269,11 +1267,11 @@ def fcommon : Flag<["-"], "fcommon">, Group,
   Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global 
variables in a common block">,
   MarshallingInfoNegativeFlag>;
 def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group;
-defm complete_member_pointers : BoolOption<"complete-member-pointers",
+defm complete_member_pointers : BoolOption<"f", "complete-member-pointers",
   LangOpts<"CompleteMemberPointers">, DefaultsToFalse,
   ChangedBy, ResetBy,
   BothFlags<[CoreOption], " member pointer base types to be complete if they"
-" would be significant under the Microsoft ABI">, "f">,
+" would be significant under the Micros

[clang] 209f461 - [clang][cli] NFC: Pass CC1Option explicitly to BoolOption

2021-01-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-25T09:15:33+01:00
New Revision: 209f4618891365f5f655214581ab4edd27cacde4

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

LOG: [clang][cli] NFC: Pass CC1Option explicitly to BoolOption

When `Bool{F,G}Option` were introduced, they were designed after the existing 
`Opt{In,Out}FFlag` in that they implied `CC1Option` for the `ChangedBy` flag.

This means less typing, but can be misleading in situations when the `ResetBy` 
has explicit `CC1Option` and `ChangedBy` doesn't.

This patch stops implicitly putting `CC1Option` to `ChangedBy` flag.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2747ee27cb8d..dd7978435ff1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -473,38 +473,23 @@ multiclass BoolOption;
 }
 
-/// Creates a BoolOption with the changing available on the CC1 command line.
-multiclass BoolCC1Option> 
{
-  defvar changed_by_cc1
-= ChangedBy;
-
-  defm NAME : BoolOption;
-}
-
-/// Creates a BoolOption where both of the flags are prefixed with "f", are in
-/// the Group, and the changing flag is also available on the CC1
-/// command line.
+/// Creates a BoolOption where both of the flags are prefixed with "f" and have
+/// the Group.
 multiclass BoolFOption> {
-  defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by,
-reset_by, both>,
+  defm NAME : BoolOption<"f", flag_base, kpm, defaults_to, changed_by, 
reset_by,
+ both>,
   Group;
 }
 
-// Creates a BoolOption where both of the flags are prefixed with "g", are in
-// the Group, and the changing flag is also available on the CC1
-// command line.
+// Creates a BoolOption where both of the flags are prefixed with "g" and have
+// the Group.
 multiclass BoolGOption> {
-  defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by,
-reset_by, both>,
+  defm NAME : BoolOption<"g", flag_base, kpm, defaults_to, changed_by, 
reset_by,
+ both>,
   Group;
 }
 
@@ -951,7 +936,7 @@ defm cuda_approx_transcendentals : 
OptInFFlag<"cuda-approx-transcendentals", "Us
   " approximate transcendental functions">;
 defm gpu_rdc : BoolFOption<"gpu-rdc",
   LangOpts<"GPURelocatableDeviceCode">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
@@ -971,17 +956,17 @@ def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-scri
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
 defm hip_new_launch_api : BoolFOption<"hip-new-launch-api",
   LangOpts<"HIPUseNewLaunchAPI">, DefaultsToFalse,
-  ChangedBy, ResetBy,
+  ChangedBy, ResetBy,
   BothFlags<[], " new kernel launching API for HIP">>;
 defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init",
   "Allow", "Don't allow", " device side init function in HIP">;
 defm gpu_defer_diag : BoolFOption<"gpu-defer-diag",
   LangOpts<"GPUDeferDiag">, DefaultsToFalse,
-  ChangedBy, ResetBy,
+  ChangedBy, ResetBy,
   BothFlags<[], " host/device related diagnostic messages for CUDA/HIP">>;
 defm gpu_exclude_wrong_side_overloads : 
BoolFOption<"gpu-exclude-wrong-side-overloads",
   LangOpts<"GPUExcludeWrongSideOverloads">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy,
   BothFlags<[HelpHidden], " in overloading resolution for CUDA/HIP">>;
 def gpu_max_threads_per_block_EQ : Joined<["--"], 
"gpu-max-threads-per-block=">,
@@ -1043,14 +1028,14 @@ def fPIE : Flag<["-"], "fPIE">, Group;
 def fno_PIE : Flag<["-"], "fno-PIE">, Group;
 defm access_control : BoolFOption<"access-control",
   LangOpts<"AccessControl">, DefaultsToTrue,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def falign_functions : Flag<["-"], "falign-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
 def fno_align_functions: Flag<["-"], "fno-align-functions">, Group;
 defm allow_editor_placeholders : BoolFOption<"allow-editor-placeholders",
   LangOpts<"AllowEditorPlaceholders">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def fallow_unsupported : Flag<["-"], "fallow-unsupported">, Group;
 def fapple_kext : Flag<["-"], "fapple-kext">, Group, 
Flags<[CC1Option]>,
@@ -1058,7 +1043,7 @@ def fapple_kext : Flag<["-"], "fapple-kext">, 
Group, Flags<[CC1Option]>
   MarshallingInfoFlag>;
 defm apple_pragma_pack : BoolFOption<"apple-pragma-pack",
   LangOpts<"ApplePragmaPack">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;

[PATCH] D95221: [clang][cli] NFC: Move prefix to the front of BoolOption

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46ec0254a97d: [clang][cli] NFC: Move prefix to the front of 
BoolOption (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95221

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -375,10 +375,10 @@
 // BoolOption is the API that should be used most of the time. Use this only
 // when you need more control (e.g. to represent a marshalled option whose
 // keypath defaults to an arbitrarily complex boolean expression).
-multiclass BoolOptionBase,
-  string prefix = ""> {
+  FlagDefSuffix flags_suffix = FlagDefSuffix<[], "">> {
   defvar flag1 = FlagDefExpanded.Result,
  prefix, NAME, spelling_base>;
 
@@ -436,29 +436,28 @@
 /// Creates two command line flags that control the same boolean keypath.
 ///
 /// Example:
-///   defm my_boolean_option : BoolOption<"my-boolean-option",
+///   defm my_boolean_option : BoolOption<"f", "my-boolean-option",
 /// CodeGenOpts<"MyBooleanOption">, DefaultsToFalse,
 /// ChangedBy,
 /// ResetBy,
 /// BothFlags<[CoreOption], " my boolean option.">;
 ///
 ///   The Clang driver now knows two new command line flags: the "positive"
-///   -my-boolean-option and the "negative" -no-my-boolean-option. The positive
-///   flag is also available on the CC1 command line.
+///   -fmy-boolean-option and the "negative" -fno-my-boolean-option. The
+///   positive flag is also available on the CC1 command line.
 ///
 ///   * When the command line contains neither of the flags, the keypath value
 /// defaults to false.
 ///   * When the command line contains the positive -my-boolean-option, the
 /// keypath value changes to true.
-///   * When the command line contains the negative -no-my-bool-option, the
+///   * When the command line contains the negative -fno-my-bool-option, the
 /// keypath value resets to false.
 ///
 ///   The help text for -my-boolean-option is "Enable my boolean option." and
-///   "Disable my boolean option." for -no-my-boolean-option.
-multiclass BoolOption,
-  string name_prefix = ""> {
+  ResetBy reset_by, BothFlags both = BothFlags<[], "">> {
   defvar default = Default;
 
   defvar changed_by_flag = FlagDef;
 
-  defm NAME : BoolOptionBase;
+  defm NAME : BoolOptionBase;
 }
 
 /// Creates a BoolOption with the changing available on the CC1 command line.
-multiclass BoolCC1Option,
- string name_prefix = ""> {
+ ResetBy reset_by, BothFlags both = BothFlags<[], "">> {
   defvar changed_by_cc1
 = ChangedBy;
 
-  defm NAME : BoolOption;
+  defm NAME : BoolOption;
 }
 
 /// Creates a BoolOption where both of the flags are prefixed with "f", are in
@@ -494,8 +492,8 @@
 multiclass BoolFOption> {
-  defm NAME : BoolCC1Option,
+  defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by,
+reset_by, both>,
   Group;
 }
 
@@ -505,8 +503,8 @@
 multiclass BoolGOption> {
-  defm NAME : BoolCC1Option,
+  defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by,
+reset_by, both>,
   Group;
 }
 
@@ -1269,11 +1267,11 @@
   Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">,
   MarshallingInfoNegativeFlag>;
 def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group;
-defm complete_member_pointers : BoolOption<"complete-member-pointers",
+defm complete_member_pointers : BoolOption<"f", "complete-member-pointers",
   LangOpts<"CompleteMemberPointers">, DefaultsToFalse,
   ChangedBy, ResetBy,
   BothFlags<[CoreOption], " member pointer base types to be complete if they"
-" would be significant under the Microsoft ABI">, "f">,
+" would be significant under the Microsoft ABI">>,
   Group;
 def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group,
 Flags<[CC1Option]>, Values<"unspecified,standalone,objc,swift,swift-5.0,swift-4.2,swift-4.1">,
@@ -1495,33 +1493,33 @@
 Group,
 Flags<[CoreOption, NoXarchOption]>,
 HelpText<"Disable origins tracking in MemorySanitizer">;
-defm sanitize_memory_use_after_dtor : BoolOption<"sanitize-memory-use-after-dtor",
+defm sanitize_memory_use_after_dtor : BoolOption<"f", "sanitize-memory-use-after-dtor",
   CodeGenOpts<"SanitizeMemoryUseAfterDtor">, DefaultsToFalse,
   ChangedBy, ResetBy,
-  BothFlags<[], " use-after-destroy detection in MemorySanit

[PATCH] D95225: [clang][cli] NFC: Pass CC1Option explicitly to BoolOption

2021-01-25 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 rG209f46188913: [clang][cli] NFC: Pass CC1Option explicitly to 
BoolOption (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95225

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -473,38 +473,23 @@
  changed_by_flag, reset_by_flag, flag_suffix>;
 }
 
-/// Creates a BoolOption with the changing available on the CC1 command line.
-multiclass BoolCC1Option> {
-  defvar changed_by_cc1
-= ChangedBy;
-
-  defm NAME : BoolOption;
-}
-
-/// Creates a BoolOption where both of the flags are prefixed with "f", are in
-/// the Group, and the changing flag is also available on the CC1
-/// command line.
+/// Creates a BoolOption where both of the flags are prefixed with "f" and have
+/// the Group.
 multiclass BoolFOption> {
-  defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by,
-reset_by, both>,
+  defm NAME : BoolOption<"f", flag_base, kpm, defaults_to, changed_by, reset_by,
+ both>,
   Group;
 }
 
-// Creates a BoolOption where both of the flags are prefixed with "g", are in
-// the Group, and the changing flag is also available on the CC1
-// command line.
+// Creates a BoolOption where both of the flags are prefixed with "g" and have
+// the Group.
 multiclass BoolGOption> {
-  defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by,
-reset_by, both>,
+  defm NAME : BoolOption<"g", flag_base, kpm, defaults_to, changed_by, reset_by,
+ both>,
   Group;
 }
 
@@ -951,7 +936,7 @@
   " approximate transcendental functions">;
 defm gpu_rdc : BoolFOption<"gpu-rdc",
   LangOpts<"GPURelocatableDeviceCode">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
@@ -971,17 +956,17 @@
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
 defm hip_new_launch_api : BoolFOption<"hip-new-launch-api",
   LangOpts<"HIPUseNewLaunchAPI">, DefaultsToFalse,
-  ChangedBy, ResetBy,
+  ChangedBy, ResetBy,
   BothFlags<[], " new kernel launching API for HIP">>;
 defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init",
   "Allow", "Don't allow", " device side init function in HIP">;
 defm gpu_defer_diag : BoolFOption<"gpu-defer-diag",
   LangOpts<"GPUDeferDiag">, DefaultsToFalse,
-  ChangedBy, ResetBy,
+  ChangedBy, ResetBy,
   BothFlags<[], " host/device related diagnostic messages for CUDA/HIP">>;
 defm gpu_exclude_wrong_side_overloads : BoolFOption<"gpu-exclude-wrong-side-overloads",
   LangOpts<"GPUExcludeWrongSideOverloads">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy,
   BothFlags<[HelpHidden], " in overloading resolution for CUDA/HIP">>;
 def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">,
@@ -1043,14 +1028,14 @@
 def fno_PIE : Flag<["-"], "fno-PIE">, Group;
 defm access_control : BoolFOption<"access-control",
   LangOpts<"AccessControl">, DefaultsToTrue,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def falign_functions : Flag<["-"], "falign-functions">, Group;
 def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group;
 def fno_align_functions: Flag<["-"], "fno-align-functions">, Group;
 defm allow_editor_placeholders : BoolFOption<"allow-editor-placeholders",
   LangOpts<"AllowEditorPlaceholders">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def fallow_unsupported : Flag<["-"], "fallow-unsupported">, Group;
 def fapple_kext : Flag<["-"], "fapple-kext">, Group, Flags<[CC1Option]>,
@@ -1058,7 +1043,7 @@
   MarshallingInfoFlag>;
 defm apple_pragma_pack : BoolFOption<"apple-pragma-pack",
   LangOpts<"ApplePragmaPack">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def fxl_pragma_pack : Flag<["-"], "fxl-pragma-pack">, Group, Flags<[CC1Option]>,
   HelpText<"Enable IBM XL #pragma pack handling">;
@@ -1106,7 +1091,7 @@
   HelpText<"Embed placeholder LLVM IR data as a marker">;
 defm gnu_inline_asm : BoolFOption<"gnu-inline-asm",
   LangOpts<"GNUAsm">, DefaultsToTrue,
-  ChangedBy, ResetBy>;
+  ChangedBy, ResetBy>;
 
 def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
 Flags<[CoreOption]>;
@@ -1145,7 +1130,7 @@
 Alias;
 defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
   CodeGenOpts<"DebugInfoForProfiling">, DefaultsToFalse,
-  ChangedBy,
+  ChangedBy,
   ResetBy>;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
 Group, Flags<[CoreOption]>,
@@ -1166,7 +1151,7 @

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-25 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM. Thanks for being prompt at addressing the comments. I'll merge it today 
for you if @MyDeveloperDay has no more remarks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a subscriber: grimar.
jhenderson added a comment.

Sorry, could you revert this please. I don't think this is a good fix, as 
you've reduced coverage within the test, and some changes are completly 
redundant/add extra noise. I've commented inline with examples. Skimming D94239 
 suggests that has the same issue.

Could you also please explain the messages your system is actually producing so 
we can provide a better solution than this fix.

I'm also concerned that you are doing this to fix this test for a system, yet 
there are no build bots that report this error. A future contributor is likely 
to break them in the same way/add new tests with the same issue. If your system 
is a system that is supposed to be supported by LLVM, there needs to be a build 
bot. If it isn't supported, you should bring this up on llvm-dev (if you 
haven't already) to get buy-in for support.




Comment at: clang/test/Driver/clang-offload-bundler.c:75
 // RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | 
FileCheck %s -DFILE=%t.bundle.i.notexist --check-prefix CK-ERR5
-// CK-ERR5: error: '[[FILE]]': {{N|n}}o such file or directory
+// CK-ERR5: error: '[[FILE]]': {{.*}}{{N|n}}o such file or directory
 

Here and everywhere you've added the `{{.*}}`, the test will no longer pick up 
changes in the message that occur between the end of the literal match and the 
start of the "no such file..." part. For example, this will no longer fail if 
the message reported became "error: 'afile': fsdufbsdufbno such file or 
directory"

Even were adding `.*` desirable, it should be part of the following regex, i.e. 
`{{.*N|n}}` to reduce the noise of the `{{` and `}}`.



Comment at: llvm/test/Object/archive-extract-dir.test:11
 
-CHECK: foo: {{[Ii]}}s a directory
+CHECK: foo: {{.*}}{{[Ii]}}s a directory{{.*}}

`{{.*}}` at the end of a FileCheck line has literally no benefit - it is 
implicit unless `--match-full-lines` is specified to `FileCheck`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[clang] 01d9f13 - Revert "[clang][AVR] Improve avr-ld command line options"

2021-01-25 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2021-01-25T16:33:58+08:00
New Revision: 01d9f13c3a5914baf9739348ef666e348a7b2a2f

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

LOG: Revert "[clang][AVR] Improve avr-ld command line options"

This reverts commit 89a5147e5a0c2e886cdf7ffa34799c069d825940.

Added: 


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

Removed: 
clang/test/Driver/Inputs/basic_avr_tree/bin/avr-ld
clang/test/Driver/Inputs/basic_avr_tree/lib/avr/lib/libavr.a
clang/test/Driver/Inputs/basic_avr_tree/lib/gcc/avr/5.4.0/libgcc.a
clang/test/Driver/avr-ld.c



diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index c999c3b87f84..ae56b7b5249e 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -32,248 +32,247 @@ const struct {
   StringRef Name;
   std::string SubPath;
   StringRef Family;
-  unsigned DataAddr;
 } MCUInfo[] = {
-{"at90s1200", "", "avr1", 0},
-{"attiny11", "", "avr1", 0},
-{"attiny12", "", "avr1", 0},
-{"attiny15", "", "avr1", 0},
-{"attiny28", "", "avr1", 0},
-{"at90s2313", "tiny-stack", "avr2", 0x800060},
-{"at90s2323", "tiny-stack", "avr2", 0x800060},
-{"at90s2333", "tiny-stack", "avr2", 0x800060},
-{"at90s2343", "tiny-stack", "avr2", 0x800060},
-{"at90s4433", "tiny-stack", "avr2, 0x800060"},
-{"attiny22", "tiny-stack", "avr2", 0x800060},
-{"attiny26", "tiny-stack", "avr2", 0x800060},
-{"at90s4414", "", "avr2", 0x800060},
-{"at90s4434", "", "avr2", 0x800060},
-{"at90s8515", "", "avr2", 0x800060},
-{"at90c8534", "", "avr2", 0x800060},
-{"at90s8535", "", "avr2", 0x800060},
-{"attiny13", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny13a", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny2313", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny2313a", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny24", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny24a", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny25", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny261", "avr25/tiny-stack", "avr25", 0x800060},
-{"attiny261a", "avr25/tiny-stack", "avr25", 0x800060},
-{"at86rf401", "avr25", "avr25", 0x800060},
-{"ata5272", "avr25", "avr25", 0x800100},
-{"attiny4313", "avr25", "avr25", 0x800060},
-{"attiny44", "avr25", "avr25", 0x800060},
-{"attiny44a", "avr25", "avr25", 0x800060},
-{"attiny84", "avr25", "avr25", 0x800060},
-{"attiny84a", "avr25", "avr25", 0x800060},
-{"attiny45", "avr25", "avr25", 0x800060},
-{"attiny85", "avr25", "avr25", 0x800060},
-{"attiny441", "avr25", "avr25", 0x800100},
-{"attiny461", "avr25", "avr25", 0x800060},
-{"attiny461a", "avr25", "avr25", 0x800060},
-{"attiny841", "avr25", "avr25", 0x800100},
-{"attiny861", "avr25", "avr25", 0x800060},
-{"attiny861a", "avr25", "avr25", 0x800060},
-{"attiny87", "avr25", "avr25", 0x800100},
-{"attiny43u", "avr25", "avr25", 0x800060},
-{"attiny48", "avr25", "avr25", 0x800100},
-{"attiny88", "avr25", "avr25", 0x800100},
-{"attiny828", "avr25", "avr25", 0x800100},
-{"at43usb355", "avr3", "avr3", 0x800100},
-{"at76c711", "avr3", "avr3", 0x800060},
-{"atmega103", "avr31", "avr31", 0x800060},
-{"at43usb320", "avr31", "avr31", 0x800060},
-{"attiny167", "avr35", "avr35", 0x800100},
-{"at90usb82", "avr35", "avr35", 0x800100},
-{"at90usb162", "avr35", "avr35", 0x800100},
-{"ata5505", "avr35", "avr35", 0x800100},
-{"atmega8u2", "avr35", "avr35", 0x800100},
-{"atmega16u2", "avr35", "avr35", 0x800100},
-{"atmega32u2", "avr35", "avr35", 0x800100},
-{"attiny1634", "avr35", "avr35", 0x800100},
-{"atmega8", "avr4", "avr4", 0x800060},
-{"ata6289", "avr4", "avr4", 0x800100},
-{"atmega8a", "avr4", "avr4", 0x800060},
-{"ata6285", "avr4", "avr4", 0x800100},
-{"ata6286", "avr4", "avr4", 0x800100},
-{"atmega48", "avr4", "avr4", 0x800100},
-{"atmega48a", "avr4", "avr4", 0x800100},
-{"atmega48pa", "avr4", "avr4", 0x800100},
-{"atmega48pb", "avr4", "avr4", 0x800100},
-{"atmega48p", "avr4", "avr4", 0x800100},
-{"atmega88", "avr4", "avr4", 0x800100},
-{"atmega88a", "avr4", "avr4", 0x800100},
-{"atmega88p", "avr4", "avr4", 0x800100},
-{"atmega88pa", "avr4", "avr4", 0x800100},
-{"atmega88pb", "avr4", "avr4", 0x800100},
-{"atmega8515", "avr4", "avr4", 0x800060},
-{"atmega8535", "avr4", "avr4", 0x800060},
-{"atmega8hva", "avr4", "avr4", 0x800100},
-{"at90pwm1", "avr4", "avr4", 0x800100},
-{"at90pwm2", "avr4", "avr4", 0x800100},
-{"at90pwm2b", "avr4", "avr4", 0x800100},
-{"at90pwm3", "avr4", "avr4", 0x800100},
-{"at90pwm3b", "avr4", "avr4", 

[clang] f00a20e - [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-01-25T09:36:55+01:00
New Revision: f00a20e51c1d186e72844939aad10416e1cc99de

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

LOG: [clang-format] Add the possibility to align assignments spanning empty 
lines or comments

Currently, empty lines and comments break alignment of assignments on 
consecutive
lines. This makes the AlignConsecutiveAssignments option an enum that allows 
controlling
whether empty lines or empty lines and comments should be ignored when aligning
assignments.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, tinloaf

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/docs/tools/dump_format_style.py
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 27dcee83a538..6877cac28278 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -195,23 +195,84 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**AlignConsecutiveAssignments** (``bool``)
-  If ``true``, aligns consecutive assignments.
+**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``)
+  Style of aligning consecutive assignments.
 
-  This will align the assignment operators of consecutive lines. This
-  will result in formattings like
+  ``Consecutive`` will result in formattings like:
 
   .. code-block:: c++
 
-int  = 12;
-int b= 23;
-int ccc  = 23;
+int a= 1;
+int somelongname = 2;
+double c = 3;
 
-**AlignConsecutiveBitFields** (``bool``)
-  If ``true``, aligns consecutive bitfield members.
+  Possible values:
+
+  * ``ACS_None`` (in configuration: ``None``)
+ Do not align assignments on consecutive lines.
+
+  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
+ Align assignments on consecutive lines. This will result in
+ formattings like:
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d = 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
+ Same as ACS_Consecutive, but also spans over empty lines, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
+ Same as ACS_Consecutive, but also spans over lines only containing
+ comments, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossEmptyLinesAndComments``
+(in configuration: ``AcrossEmptyLinesAndComments``)
+
+ Same as ACS_Consecutive, but also spans over lines only containing
+ comments and empty lines, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``)
+  Style of aligning consecutive bit field.
 
-  This will align the bitfield separators of consecutive lines. This
-  will result in formattings like
+  ``Consecutive`` will align the bitfield separators of consecutive lines.
+  This will result in formattings like:
 
   .. code-block:: c++
 
@@ -219,23 +280,146 @@ the configuration (without a prefix: ``Auto``).
 int b: 12;
 int ccc  : 8;
 
-**AlignConsecutiveDeclarations** (``bool``)
-  If ``true``, aligns consecutive declarations.
+  Possible values:
+
+  * ``ACS_None`` (in configuration: ``None``)
+ Do not align bit fields on consecutive lines.
+
+  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
+ Align bit fields on consecutive lines. This will result in
+ formattings like:
+
+ .. code-block:: c++
+
+   int  : 1;
+   int b: 12;
+   int ccc  : 8;
+
+   int d : 2;
+   /* A comment. */
+   int ee : 3;
+
+  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
+ Same as ACS_Consecutive, but also spans over empty lines, e.g.
+
+ .. code-block:: c++
+
+   int  : 1;
+   int b: 12;
+   int ccc  : 8;
+
+   int d: 2;
+   /* A comment. */
+   int ee : 3;
+
+  * ``ACS_Acro

[PATCH] D93986: [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf00a20e51c1d: [clang-format] Add the possibility to align 
assignments spanning empty lines or… (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93986

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11395,8 +11395,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = true;
-  Tab.AlignConsecutiveDeclarations = true;
+  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -11634,8 +11634,8 @@
"*/\n"
"}",
Tab));
-  Tab.AlignConsecutiveAssignments = true;
-  Tab.AlignConsecutiveDeclarations = true;
+  Tab.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Tab.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
   verifyFormat("class Assign {\n"
@@ -12470,9 +12470,9 @@
 
 TEST_F(FormatTest, AlignConsecutiveMacros) {
   FormatStyle Style = getLLVMStyle();
-  Style.AlignConsecutiveAssignments = true;
-  Style.AlignConsecutiveDeclarations = true;
-  Style.AlignConsecutiveMacros = false;
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_None;
 
   verifyFormat("#define a 3\n"
"#define  4\n"
@@ -12496,7 +12496,7 @@
"#define (x, y) (x - y)",
Style);
 
-  Style.AlignConsecutiveMacros = true;
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
   verifyFormat("#define a3\n"
"#define  4\n"
"#define ccc  (5)",
@@ -12536,7 +12536,7 @@
"};",
Style);
 
-  Style.AlignConsecutiveMacros = false;
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_None;
   Style.ColumnLimit = 20;
 
   verifyFormat("#define a  \\\n"
@@ -12550,7 +12550,7 @@
"  \"\"\n",
Style);
 
-  Style.AlignConsecutiveMacros = true;
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
   verifyFormat("#define a  \\\n"
"  \"aa\"\n"
"#define D  \\\n"
@@ -12561,12 +12561,766 @@
"  \"F\"  \\\n"
"  \"\"\n",
Style);
+
+  // Test across comments
+  Style.MaxEmptyLinesToKeep = 10;
+  Style.ReflowComments = false;
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_AcrossComments;
+  EXPECT_EQ("#define a3\n"
+"// line comment\n"
+"#define  4\n"
+"#define ccc  (5)",
+format("#define a 3\n"
+   "// line comment\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style));
+
+  EXPECT_EQ("#define a3\n"
+"/* block comment */\n"
+"#define  4\n"
+"#define ccc  (5)",
+format("#define a  3\n"
+   "/* block comment */\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style));
+
+  EXPECT_EQ("#define a3\n"
+"/* multi-line *\n"
+" * block comment */\n"
+"#define  4\n"
+"#define ccc  (5)",
+format("#define a 3\n"
+   "/* multi-line *\n"
+   " * block comment */\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style));
+
+  EXPECT_EQ("#define a3\n"
+"// multi-line line comment\n"
+"//\n"
+"#define  4\n"
+"#define ccc  (5)",
+format("#define a  3\n"
+   "// multi-line line comment\n"
+   "//\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style));
+
+  EXPECT_EQ("#define a 3\n"
+"// empty lines still break.\n"
+"\n"
+"#define  4\n"
+"#define ccc  (5)",
+format("#define a 3\n"
+   "// empty lines still break.\n"
+   "\n"
+

[PATCH] D93986: [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I've committted it, but... something went wrong and you're not visible as the 
author. Sorry for that @tinloaf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93986

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


[PATCH] D93579: [clang][AVR] Improve avr-ld command line options

2021-01-25 Thread Ben Shi via Phabricator via cfe-commits
benshi001 reopened this revision.
benshi001 added a comment.
This revision is now accepted and ready to land.

It still cases many build failures, due to not enough test.

I will redo it with a full test.


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

https://reviews.llvm.org/D93579

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


[clang] 7b9d88a - Revert "[clang-format] Add the possibility to align assignments spanning empty lines or comments"

2021-01-25 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-01-25T09:40:46+01:00
New Revision: 7b9d88ab389e19d26432b1c1a6d57f554feb9a20

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

LOG: Revert "[clang-format] Add the possibility to align assignments spanning 
empty lines or comments"

This reverts commit f00a20e51c1d186e72844939aad10416e1cc99de.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/docs/tools/dump_format_style.py
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6877cac28278..27dcee83a538 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -195,84 +195,23 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``)
-  Style of aligning consecutive assignments.
+**AlignConsecutiveAssignments** (``bool``)
+  If ``true``, aligns consecutive assignments.
 
-  ``Consecutive`` will result in formattings like:
+  This will align the assignment operators of consecutive lines. This
+  will result in formattings like
 
   .. code-block:: c++
 
-int a= 1;
-int somelongname = 2;
-double c = 3;
+int  = 12;
+int b= 23;
+int ccc  = 23;
 
-  Possible values:
-
-  * ``ACS_None`` (in configuration: ``None``)
- Do not align assignments on consecutive lines.
-
-  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
- Align assignments on consecutive lines. This will result in
- formattings like:
-
- .. code-block:: c++
-
-   int a= 1;
-   int somelongname = 2;
-   double c = 3;
-
-   int d = 3;
-   /* A comment. */
-   double e = 4;
-
-  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
- Same as ACS_Consecutive, but also spans over empty lines, e.g.
-
- .. code-block:: c++
-
-   int a= 1;
-   int somelongname = 2;
-   double c = 3;
-
-   int d= 3;
-   /* A comment. */
-   double e = 4;
-
-  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
- Same as ACS_Consecutive, but also spans over lines only containing
- comments, e.g.
-
- .. code-block:: c++
-
-   int a= 1;
-   int somelongname = 2;
-   double c = 3;
-
-   int d= 3;
-   /* A comment. */
-   double e = 4;
-
-  * ``ACS_AcrossEmptyLinesAndComments``
-(in configuration: ``AcrossEmptyLinesAndComments``)
-
- Same as ACS_Consecutive, but also spans over lines only containing
- comments and empty lines, e.g.
-
- .. code-block:: c++
-
-   int a= 1;
-   int somelongname = 2;
-   double c = 3;
-
-   int d= 3;
-   /* A comment. */
-   double e = 4;
-
-**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``)
-  Style of aligning consecutive bit field.
+**AlignConsecutiveBitFields** (``bool``)
+  If ``true``, aligns consecutive bitfield members.
 
-  ``Consecutive`` will align the bitfield separators of consecutive lines.
-  This will result in formattings like:
+  This will align the bitfield separators of consecutive lines. This
+  will result in formattings like
 
   .. code-block:: c++
 
@@ -280,146 +219,23 @@ the configuration (without a prefix: ``Auto``).
 int b: 12;
 int ccc  : 8;
 
-  Possible values:
-
-  * ``ACS_None`` (in configuration: ``None``)
- Do not align bit fields on consecutive lines.
-
-  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
- Align bit fields on consecutive lines. This will result in
- formattings like:
-
- .. code-block:: c++
-
-   int  : 1;
-   int b: 12;
-   int ccc  : 8;
-
-   int d : 2;
-   /* A comment. */
-   int ee : 3;
-
-  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
- Same as ACS_Consecutive, but also spans over empty lines, e.g.
-
- .. code-block:: c++
-
-   int  : 1;
-   int b: 12;
-   int ccc  : 8;
-
-   int d: 2;
-   /* A comment. */
-   int ee : 3;
-
-  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
- Same as ACS_Consecutive, but also spans over lines only containing
- comments, e.g.
-
- .. code-block:: c++
-
-   int  : 1;
-   int b: 12;
-   int ccc  : 8;
-
-   int d  : 2;
-   /* A comment. */
-   int ee : 3;
-
-  * ``ACS_AcrossEmptyLinesAndComments``
-  (in configuration: ``AcrossEmptyLinesAndComment

[clang] 2563147 - [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Marek Kurdej via cfe-commits

Author: Lukas Barth
Date: 2021-01-25T09:41:50+01:00
New Revision: 256314711f3fa724bff1bb2d8b93c5252265b5c7

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

LOG: [clang-format] Add the possibility to align assignments spanning empty 
lines or comments

Currently, empty lines and comments break alignment of assignments on 
consecutive
lines. This makes the AlignConsecutiveAssignments option an enum that allows 
controlling
whether empty lines or empty lines and comments should be ignored when aligning
assignments.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, tinloaf

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/docs/tools/dump_format_style.py
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 27dcee83a538..6877cac28278 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -195,23 +195,84 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**AlignConsecutiveAssignments** (``bool``)
-  If ``true``, aligns consecutive assignments.
+**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``)
+  Style of aligning consecutive assignments.
 
-  This will align the assignment operators of consecutive lines. This
-  will result in formattings like
+  ``Consecutive`` will result in formattings like:
 
   .. code-block:: c++
 
-int  = 12;
-int b= 23;
-int ccc  = 23;
+int a= 1;
+int somelongname = 2;
+double c = 3;
 
-**AlignConsecutiveBitFields** (``bool``)
-  If ``true``, aligns consecutive bitfield members.
+  Possible values:
+
+  * ``ACS_None`` (in configuration: ``None``)
+ Do not align assignments on consecutive lines.
+
+  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
+ Align assignments on consecutive lines. This will result in
+ formattings like:
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d = 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
+ Same as ACS_Consecutive, but also spans over empty lines, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
+ Same as ACS_Consecutive, but also spans over lines only containing
+ comments, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+  * ``ACS_AcrossEmptyLinesAndComments``
+(in configuration: ``AcrossEmptyLinesAndComments``)
+
+ Same as ACS_Consecutive, but also spans over lines only containing
+ comments and empty lines, e.g.
+
+ .. code-block:: c++
+
+   int a= 1;
+   int somelongname = 2;
+   double c = 3;
+
+   int d= 3;
+   /* A comment. */
+   double e = 4;
+
+**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``)
+  Style of aligning consecutive bit field.
 
-  This will align the bitfield separators of consecutive lines. This
-  will result in formattings like
+  ``Consecutive`` will align the bitfield separators of consecutive lines.
+  This will result in formattings like:
 
   .. code-block:: c++
 
@@ -219,23 +280,146 @@ the configuration (without a prefix: ``Auto``).
 int b: 12;
 int ccc  : 8;
 
-**AlignConsecutiveDeclarations** (``bool``)
-  If ``true``, aligns consecutive declarations.
+  Possible values:
+
+  * ``ACS_None`` (in configuration: ``None``)
+ Do not align bit fields on consecutive lines.
+
+  * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
+ Align bit fields on consecutive lines. This will result in
+ formattings like:
+
+ .. code-block:: c++
+
+   int  : 1;
+   int b: 12;
+   int ccc  : 8;
+
+   int d : 2;
+   /* A comment. */
+   int ee : 3;
+
+  * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
+ Same as ACS_Consecutive, but also spans over empty lines, e.g.
+
+ .. code-block:: c++
+
+   int  : 1;
+   int b: 12;
+   int ccc  : 8;
+
+   int d: 2;
+   /* A comment. */
+   int ee : 3;
+
+  * ``ACS_Acros

[PATCH] D93986: [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Fixed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93986

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


[clang] c6bd660 - Fix a build-bot failure.

2021-01-25 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-01-25T09:46:29+01:00
New Revision: c6bd6607bf8abfe259fef6a41e695581a88c88f0

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

LOG: Fix a build-bot failure.

The test ms-lookup-template-base-classes.cpp added in 
d972d4c749048531953a16b815e07c67e8455a3b
is failing on some builtbot that don't include x86.

This patch should fix that (following the patterns in the test directory).

Added: 


Modified: 
clang/test/CodeGenCXX/ms-lookup-template-base-classes.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/ms-lookup-template-base-classes.cpp 
b/clang/test/CodeGenCXX/ms-lookup-template-base-classes.cpp
index fbc211aca17a..41a4ee8b5bb8 100644
--- a/clang/test/CodeGenCXX/ms-lookup-template-base-classes.cpp
+++ b/clang/test/CodeGenCXX/ms-lookup-template-base-classes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-obj -fms-compatibility %s 
-o -
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -fms-compatibility 
%s -o -
 // CHECK that we don't crash.
 
 struct Base {



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


[PATCH] D93940: [clang-tidy] Add a check for blocking types and functions.

2021-01-25 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon added a comment.

alexfh, hi! any comments on the patch?


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

https://reviews.llvm.org/D93940

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


[clang] 666815d - [RISCV] Implement new architecture extension macros

2021-01-25 Thread Simon Cook via cfe-commits

Author: Simon Cook
Date: 2021-01-25T08:58:46Z
New Revision: 666815d61bc2475aa7b3ecf8e3a91022d6ccce4b

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

LOG: [RISCV] Implement new architecture extension macros

This adds support for the new architecture extension test macros as
defined in the C-API Document:
https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md

Extension versions have been taken from what are used in
RISCVTargetStreamer for ratified extensions, and the -march parser
for experimental extensions.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 4436db904d59..7e6118af38e0 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -109,13 +109,18 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (ABIName == "ilp32e")
 Builder.defineMacro("__riscv_abi_rve");
 
+  Builder.defineMacro("__riscv_arch_test");
+  Builder.defineMacro("__riscv_i", "200");
+
   if (HasM) {
+Builder.defineMacro("__riscv_m", "200");
 Builder.defineMacro("__riscv_mul");
 Builder.defineMacro("__riscv_div");
 Builder.defineMacro("__riscv_muldiv");
   }
 
   if (HasA) {
+Builder.defineMacro("__riscv_a", "200");
 Builder.defineMacro("__riscv_atomic");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
@@ -125,22 +130,71 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   }
 
   if (HasF || HasD) {
+Builder.defineMacro("__riscv_f", "200");
 Builder.defineMacro("__riscv_flen", HasD ? "64" : "32");
 Builder.defineMacro("__riscv_fdiv");
 Builder.defineMacro("__riscv_fsqrt");
   }
 
-  if (HasC)
+  if (HasD)
+Builder.defineMacro("__riscv_d", "200");
+
+  if (HasC) {
+Builder.defineMacro("__riscv_c", "200");
 Builder.defineMacro("__riscv_compressed");
+  }
 
-  if (HasB)
+  if (HasB) {
+Builder.defineMacro("__riscv_b", "93000");
 Builder.defineMacro("__riscv_bitmanip");
+  }
 
-  if (HasV)
+  if (HasV) {
+Builder.defineMacro("__riscv_v", "9000");
 Builder.defineMacro("__riscv_vector");
+  }
+
+  if (HasZba)
+Builder.defineMacro("__riscv_zba", "93000");
+
+  if (HasZbb)
+Builder.defineMacro("__riscv_zbb", "93000");
+
+  if (HasZbc)
+Builder.defineMacro("__riscv_zbc", "93000");
+
+  if (HasZbe)
+Builder.defineMacro("__riscv_zbe", "93000");
+
+  if (HasZbf)
+Builder.defineMacro("__riscv_zbf", "93000");
+
+  if (HasZbm)
+Builder.defineMacro("__riscv_zbm", "93000");
+
+  if (HasZbp)
+Builder.defineMacro("__riscv_zbp", "93000");
+
+  if (HasZbproposedc)
+Builder.defineMacro("__riscv_zbproposedc", "93000");
+
+  if (HasZbr)
+Builder.defineMacro("__riscv_zbr", "93000");
+
+  if (HasZbs)
+Builder.defineMacro("__riscv_zbs", "93000");
+
+  if (HasZbt)
+Builder.defineMacro("__riscv_zbt", "93000");
 
   if (HasZfh)
-Builder.defineMacro("__riscv_zfh");
+Builder.defineMacro("__riscv_zfh", "1000");
+
+  if (HasZvamo)
+Builder.defineMacro("__riscv_zvamo", "9000");
+
+  if (HasZvlsseg)
+Builder.defineMacro("__riscv_zvlsseg", "9000");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -157,7 +211,20 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
   .Case("c", HasC)
   .Case("experimental-b", HasB)
   .Case("experimental-v", HasV)
+  .Case("experimental-zba", HasZba)
+  .Case("experimental-zbb", HasZbb)
+  .Case("experimental-zbc", HasZbc)
+  .Case("experimental-zbe", HasZbe)
+  .Case("experimental-zbf", HasZbf)
+  .Case("experimental-zbm", HasZbm)
+  .Case("experimental-zbp", HasZbp)
+  .Case("experimental-zbproposedc", HasZbproposedc)
+  .Case("experimental-zbr", HasZbr)
+  .Case("experimental-zbs", HasZbs)
+  .Case("experimental-zbt", HasZbt)
   .Case("experimental-zfh", HasZfh)
+  .Case("experimental-zvamo", HasZvamo)
+  .Case("experimental-zvlsseg", HasZvlsseg)
   .Default(false);
 }
 
@@ -179,8 +246,34 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   HasB = true;
 else if (Feature == "+experimental-v")
   HasV = true;
+else if (Feature == "+experimental-zba")
+  HasZba = true;
+else if (Feature == "+experimental-zbb")
+  HasZbb = true;
+else if (Feature == "+experimental-zbc")
+  HasZbc = true;
+else if (Feature == "+exper

[PATCH] D94403: [RISCV] Implement new architecture extension macros

2021-01-25 Thread Simon Cook via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG666815d61bc2: [RISCV] Implement new architecture extension 
macros (authored by simoncook).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94403

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -12,12 +12,27 @@
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
 // CHECK-NOT: __riscv_atomic
+// CHECK-NOT: __riscv_zba
+// CHECK-NOT: __riscv_zbb
+// CHECK-NOT: __riscv_zbc
+// CHECK-NOT: __riscv_zbe
+// CHECK-NOT: __riscv_zbf
+// CHECK-NOT: __riscv_zbm
+// CHECK-NOT: __riscv_zbp
+// CHECK-NOT: __riscv_zbproposedc
+// CHECK-NOT: __riscv_zbr
+// CHECK-NOT: __riscv_zbs
+// CHECK-NOT: __riscv_zbt
+// CHECK-NOT: __riscv_zfh
+// CHECK-NOT: __riscv_zvamo
+// CHECK-NOT: __riscv_zvlsseg
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
 // CHECK-M-EXT: __riscv_div 1
+// CHECK-M-EXT: __riscv_m 200
 // CHECK-M-EXT: __riscv_mul 1
 // CHECK-M-EXT: __riscv_muldiv 1
 
@@ -25,12 +40,14 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ia -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
+// CHECK-A-EXT: __riscv_a 200
 // CHECK-A-EXT: __riscv_atomic 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64if -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
+// CHECK-F-EXT: __riscv_f 200
 // CHECK-F-EXT: __riscv_fdiv 1
 // CHECK-F-EXT: __riscv_flen 32
 // CHECK-F-EXT: __riscv_fsqrt 1
@@ -39,6 +56,7 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
+// CHECK-D-EXT: __riscv_d 200
 // CHECK-D-EXT: __riscv_fdiv 1
 // CHECK-D-EXT: __riscv_flen 64
 // CHECK-D-EXT: __riscv_fsqrt 1
@@ -47,13 +65,25 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
+// CHECK-C-EXT: __riscv_c 200
 // CHECK-C-EXT: __riscv_compressed 1
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32ib0p93 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64ib0p93 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_b 93000
 // CHECK-B-EXT: __riscv_bitmanip 1
+// CHECK-B-EXT: __riscv_zba 93000
+// CHECK-B-EXT: __riscv_zbb 93000
+// CHECK-B-EXT: __riscv_zbc 93000
+// CHECK-B-EXT: __riscv_zbe 93000
+// CHECK-B-EXT: __riscv_zbf 93000
+// CHECK-B-EXT: __riscv_zbm 93000
+// CHECK-B-EXT: __riscv_zbp 93000
+// CHECK-B-EXT: __riscv_zbr 93000
+// CHECK-B-EXT: __riscv_zbs 93000
+// CHECK-B-EXT: __riscv_zbt 93000
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
@@ -85,10 +115,98 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
 // RUN:   -march=rv64iv0p9 -x c -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izvamo0p9 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv32izvamo0p9 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izvlsseg0p9 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv32izvlsseg0p9 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// CHECK-V-EXT: __riscv_v 9000
 // CHECK-V-EXT: __riscv_vector 1
-//
+// CHECK-V-EXT: __riscv_zvamo 9000
+// CHECK-V-EXT: __riscv_zvlsseg 9000
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable

[PATCH] D95270: [clangd][NFC] Simplify handing on methods with no params

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm not convinced this is clearer - these methods do in fact return `null`.
And it adds more duplicative code. Is it necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95270

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


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

2021-01-25 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:8943
+   Style);
+  Style = getLLVMStyle();
+  Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;

Redundant line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93846

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


[PATCH] D93986: [clang-format] Add the possibility to align assignments spanning empty lines or comments

2021-01-25 Thread Lukas Barth via Phabricator via cfe-commits
tinloaf added a comment.

In D93986#2519013 , @curdeius wrote:

> Fixed!

Thanks a lot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93986

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


[PATCH] D95270: [clangd][NFC] Simplify handing on methods with no params

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D95270#2519052 , @sammccall wrote:

> I'm not convinced this is clearer - these methods do in fact return `null`.
> And it adds more duplicative code. Is it necessary?

Doh, of course I misread - inputs rather than outputs.
Yes, this seems OK if we drop the NoParams variants.
(Though I'm still not sure it's worth the special case...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95270

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


[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:496
   }
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+auto N = DynTypedNode::create(X);

can we not use traverseNode here, rather than repeating?



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:272-283
+  R"cpp(
+struct Foo {};
+struct Bar : [[private Fo^o]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {

njames93 wrote:
> Is this good behaviour, or should Foo selection resolve as a RecordTypeLoc, 
> That is the behaviour previously observed for these 2 cases. And instead have 
> CXXBaseSpecifier as its parent selection?
Yes, this should be a typeloc with the CXXBaseSpecifier as its parent, unless 
there's a really compelling reason to make an exception.

Two main reasons:
 - it matches RecursiveASTVisitor's idea of the tree shape, which people mostly 
understand. If we diverge, it'll be a special case we need to remember and so 
potentially a source of bugs.
 - This allows code that handles types generically to work with fewer special 
cases.
  (I do like the FindTarget change though - it seems reasonable to allow 
go-to-def on e.g. the `public` keyword)
  It still preserves flexibility if we want to handle types as base-specifiers 
specially (we can examine the parent)



Comment at: clang/lib/AST/ASTTypeTraits.cpp:196
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();

nice, thanks!
We should probably have a test for this (in ASTTypeTraitsTest.cpp there's a 
simple pattern to follow for sourcerange)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

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


[PATCH] D94583: [RISCV] Update V extension to v1.0-draft 08a0b464.

2021-01-25 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Could you also update macros and attributes which implemented in 
https://reviews.llvm.org/D94403 and https://reviews.llvm.org/D94931


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94583

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread George Rimar via Phabricator via cfe-commits
grimar added a comment.

As far I understand, looking on the description of D94239 
, the message on z/OS looks like "EDC5129I No 
such file or directory.".
I guess the `EDC5129I` is a stable error code? So why not to check for a 
possible `EDC5129I` prefix word instead of `.*`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95336: [clang] NFC: Remove else if after return

2021-01-25 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added reviewers: kadircet, sammccall.
kbobyrev requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update the code to be compatible with LLVM Coding Guidelines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95336

Files:
  clang/lib/AST/DeclBase.cpp


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1171,10 +1171,8 @@
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-  else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
-return true;
 
-  return false;
+  return getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export;
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1171,10 +1171,8 @@
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-  else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
-return true;
 
-  return false;
+  return getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export;
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95336: [clang] NFC: Remove else if after return

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! (trivial changes like this can also be submitted without review)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95336

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


[clang] 7e5d41a - [clang] NFC: Remove else if after return

2021-01-25 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-01-25T10:58:22+01:00
New Revision: 7e5d41a68255d2a890977047be339091cc113e25

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

LOG: [clang] NFC: Remove else if after return

Update the code to be compatible with LLVM Coding Guidelines.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/AST/DeclBase.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index dc59f3dd1f15..1b59f217e3c1 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1171,10 +1171,8 @@ bool DeclContext::isDependentContext() const {
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-  else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
-return true;
 
-  return false;
+  return getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export;
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,



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


[PATCH] D95336: [clang] NFC: Remove else if after return

2021-01-25 Thread Kirill Bobyrev 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 rG7e5d41a68255: [clang] NFC: Remove else if after return 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95336

Files:
  clang/lib/AST/DeclBase.cpp


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1171,10 +1171,8 @@
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-  else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
-return true;
 
-  return false;
+  return getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export;
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,


Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1171,10 +1171,8 @@
 bool DeclContext::isTransparentContext() const {
   if (getDeclKind() == Decl::Enum)
 return !cast(this)->isScoped();
-  else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
-return true;
 
-  return false;
+  return getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export;
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 33a63a3 - [clang-format] [docs] Fix RST indentation.

2021-01-25 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-01-25T11:00:46+01:00
New Revision: 33a63a36d3cb0a59ef80054a02babe7a28a9842a

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

LOG: [clang-format] [docs] Fix RST indentation.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6877cac28278..3141dd5510fc 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -327,7 +327,7 @@ the configuration (without a prefix: ``Auto``).
int ee : 3;
 
   * ``ACS_AcrossEmptyLinesAndComments``
-  (in configuration: ``AcrossEmptyLinesAndComments``)
+(in configuration: ``AcrossEmptyLinesAndComments``)
 
  Same as ACS_Consecutive, but also spans over lines only containing
  comments and empty lines, e.g.
@@ -401,7 +401,7 @@ the configuration (without a prefix: ``Auto``).
bool c = false;
 
   * ``ACS_AcrossEmptyLinesAndComments``
-  (in configuration: ``AcrossEmptyLinesAndComments``)
+(in configuration: ``AcrossEmptyLinesAndComments``)
 
  Same as ACS_Consecutive, but also spans over lines only containing
  comments and empty lines, e.g.
@@ -476,7 +476,7 @@ the configuration (without a prefix: ``Auto``).
#define bar(y, z) (y + z)
 
   * ``ACS_AcrossEmptyLinesAndComments``
-  (in configuration: ``AcrossEmptyLinesAndComments``)
+(in configuration: ``AcrossEmptyLinesAndComments``)
 
  Same as ACS_Consecutive, but also spans over lines only containing
  comments and empty lines, e.g.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index a95689097b00..fcc38e25542f 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -153,7 +153,7 @@ struct FormatStyle {
   ///\endcode
   ///
   /// * ``ACS_AcrossEmptyLinesAndComments``
-  /// (in configuration: ``AcrossEmptyLinesAndComments``)
+  ///   (in configuration: ``AcrossEmptyLinesAndComments``)
   ///
   ///Same as ACS_Consecutive, but also spans over lines only containing
   ///comments and empty lines, e.g.
@@ -290,7 +290,7 @@ struct FormatStyle {
   ///\endcode
   ///
   /// * ``ACS_AcrossEmptyLinesAndComments``
-  /// (in configuration: ``AcrossEmptyLinesAndComments``)
+  ///   (in configuration: ``AcrossEmptyLinesAndComments``)
   ///
   ///Same as ACS_Consecutive, but also spans over lines only containing
   ///comments and empty lines, e.g.
@@ -359,7 +359,7 @@ struct FormatStyle {
   ///\endcode
   ///
   /// * ``ACS_AcrossEmptyLinesAndComments``
-  /// (in configuration: ``AcrossEmptyLinesAndComments``)
+  ///   (in configuration: ``AcrossEmptyLinesAndComments``)
   ///
   ///Same as ACS_Consecutive, but also spans over lines only containing
   ///comments and empty lines, e.g.



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


[clang] c8d2ae5 - [clang] NFC: Remove else-after-return pattern from some files

2021-01-25 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-01-25T11:14:17+01:00
New Revision: c8d2ae52c15b4c886e70587cbc3f61aaa7bd6692

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

LOG: [clang] NFC: Remove else-after-return pattern from some files

Follow-up on D95336. A bunch of these cases were found manually, the
rest made sense to be included to eliminate llvm-else-after-return
Clang-Tidy warnings.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/Expr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 0c5d82b3e9aa..bc86022d3743 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2401,12 +2401,10 @@ class ASTContext : public RefCountedBase {
 return (*SuperTnullability == NullabilityKind::NonNull &&
 *SubTnullability == NullabilityKind::Nullable);
   }
-  else {
-// For the return type, it's okay for the superclass method to specify
-// "nullable" and the subclass method specify "nonnull"
-return (*SuperTnullability == NullabilityKind::Nullable &&
-*SubTnullability == NullabilityKind::NonNull);
-  }
+  // For the return type, it's okay for the superclass method to specify
+  // "nullable" and the subclass method specify "nonnull"
+  return (*SuperTnullability == NullabilityKind::Nullable &&
+  *SubTnullability == NullabilityKind::NonNull);
 }
 return true;
   }

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 3cea3c23b527..feb9b0645ebc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1823,8 +1823,7 @@ template 
 static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl) {
   if (decl->getNumTemplateParameterLists() > 0)
 return decl->getTemplateParameterList(0)->getTemplateLoc();
-  else
-return decl->getInnerLocStart();
+  return decl->getInnerLocStart();
 }
 
 SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const {
@@ -2132,10 +2131,9 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) 
const {
 TSK_ExplicitSpecialization) ||
  isa(this)))
   return Definition;
-else if (!isOutOfLine() && isInline())
+if (!isOutOfLine() && isInline())
   return Definition;
-else
-  return DeclarationOnly;
+return DeclarationOnly;
   }
   // C99 6.7p5:
   //   A definition of an identifier is a declaration for that identifier that
@@ -2198,7 +2196,7 @@ VarDecl *VarDecl::getActingDefinition() {
 Kind = I->isThisDeclarationADefinition();
 if (Kind == Definition)
   return nullptr;
-else if (Kind == TentativeDefinition)
+if (Kind == TentativeDefinition)
   LastTentative = I;
   }
   return LastTentative;
@@ -2270,8 +2268,7 @@ VarDecl *VarDecl::getInitializingDeclaration() {
 if (I->isThisDeclarationADefinition()) {
   if (isStaticDataMember())
 return I;
-  else
-Def = I;
+  Def = I;
 }
   }
   return Def;
@@ -3595,8 +3592,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() 
const {
 OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
   if (getDeclName().getNameKind() == DeclarationName::CXXOperatorName)
 return getDeclName().getCXXOverloadedOperator();
-  else
-return OO_None;
+  return OO_None;
 }
 
 /// getLiteralIdentifier - The literal suffix identifier this function
@@ -3604,8 +3600,7 @@ OverloadedOperatorKind 
FunctionDecl::getOverloadedOperator() const {
 const IdentifierInfo *FunctionDecl::getLiteralIdentifier() const {
   if (getDeclName().getNameKind() == DeclarationName::CXXLiteralOperatorName)
 return getDeclName().getCXXLiteralIdentifier();
-  else
-return nullptr;
+  return nullptr;
 }
 
 FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const {
@@ -3938,8 +3933,8 @@ SourceLocation FunctionDecl::getPointOfInstantiation() 
const {
 = TemplateOrSpecialization.dyn_cast<
 FunctionTemplateSpecializationInfo*>())
 return FTSInfo->getPointOfInstantiation();
-  else if (MemberSpecializationInfo *MSInfo
- = TemplateOrSpecialization.dyn_cast())
+  if (MemberSpecializationInfo *MSInfo =
+  TemplateOrSpecialization.dyn_cast())
 return MSInfo->getPointOfInstantiation();
 
   return SourceLocation();
@@ -4053,29 +4048,29 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
 if (isExternC()) {
   if (FnInfo->isStr("memset"))
 return Builtin::BImemset;
-  else if (FnInfo->isStr("memcpy"))
+  if (FnInfo->isStr("memcpy"))
 return Builtin::BImemcpy;
-  else if (FnInfo->isS

[PATCH] D94583: [RISCV] Update V extension to v1.0-draft 08a0b464.

2021-01-25 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 318929.
HsiangKai added a comment.
Herald added subscribers: jdoerfert, hiraditya.
Herald added a project: LLVM.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94583

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,7 +40,7 @@
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v0p9"
+# CHECK: attribute  5, "rv32i2p0_v1p0"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
@@ -79,7 +79,7 @@
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1"
 
 .attribute arch, "rv32ivzvamo_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v0p9_zvamo0p9_zvlsseg0p9"
+# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
 
-.attribute arch, "rv32iv_zvamo0p9_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v0p9_zvamo0p9_zvlsseg0p9"
+.attribute arch, "rv32iv_zvamo1p0_zvlsseg"
+# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,7 +47,7 @@
 ; RV32D: .attribute 5, "rv32i2p0_f2p0_d2p0"
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32B: .attribute 5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
-; RV32V: .attribute 5, "rv32i2p0_v0p9_zvamo0p9_zvlsseg0p9"
+; RV32V: .attribute 5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
 ; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
 ; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
@@ -60,7 +60,7 @@
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
 ; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p9_zfh0p1_zbb0p93_zvamo0p9_zvlsseg0p9"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -80,8 +80,8 @@
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
 ; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
-; RV64V: .attribute 5, "rv64i2p0_v0p9_zvamo0p9_zvlsseg0p9"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p9_zfh0p1_zbb0p93_zvamo0p9_zvlsseg0p9"
+; RV64V: .attribute 5, "rv64i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -63,7 +63,7 @@
   if (STI.hasFeature(RISCV::FeatureStdExtB))
 Arch += "_b0p93";
   if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v0p9";
+Arch += "_v1p0";
   if (STI.hasFeature(RISCV::FeatureExtZfh))
 Arch += "_zfh0p1";
   if (STI.hasFeature(RISCV::FeatureExtZba))
@@ -89,9 +89,9 @@
   if (STI.hasFeature(RISCV::FeatureExtZbt))
 Arch += "_zbt0p93";
   if (STI.hasFeature(RISCV::FeatureExtZvamo))
-Arch += "_zvamo0p9";
+Arch += "_zvamo1p0";
   if (STI.hasFeature(RISCV::FeatureStdExtZvlsseg))
-Arch += "_zvlsseg0p9";
+Arch += "_zvlsseg1p0";
 
   emitTextAttribute(RISCVAttrs::ARCH, Arch);
 }
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2126,7 +2126,7 @@
   if (getFeatureBits(RISCV::FeatureStdExtB))
 formalArchStr = (Twine(formalArchStr) + "_b0p93").str();
   if (getFeatureBits(RISCV::FeatureStdExtV))
-formalArchStr = (Twine(formalArchStr) + "_v0p9").str();
+formalArchStr = (Twine(formalArchStr) + "_v1p0").str();
   if (getFeatureBits(RISCV::FeatureExtZfh))
 formalArchStr = (Twine(formalArchStr) + "_zfh0p1").str();
   if (getFeatureBits(RISCV::FeatureExtZba))
@@ -2152,9 +2152,9 @@
   if (getFeatureBits(RISCV::FeatureExtZbt))
 formalArchStr = (Twine(formalArchStr) + "_zbt0p93").str();
   if (getFeatureBit

[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:496
   }
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+auto N = DynTypedNode::create(X);

sammccall wrote:
> can we not use traverseNode here, rather than repeating?
Yeah, especially now I'm changing it to actually traverse :)



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:272-283
+  R"cpp(
+struct Foo {};
+struct Bar : [[private Fo^o]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {

sammccall wrote:
> njames93 wrote:
> > Is this good behaviour, or should Foo selection resolve as a RecordTypeLoc, 
> > That is the behaviour previously observed for these 2 cases. And instead 
> > have CXXBaseSpecifier as its parent selection?
> Yes, this should be a typeloc with the CXXBaseSpecifier as its parent, unless 
> there's a really compelling reason to make an exception.
> 
> Two main reasons:
>  - it matches RecursiveASTVisitor's idea of the tree shape, which people 
> mostly understand. If we diverge, it'll be a special case we need to remember 
> and so potentially a source of bugs.
>  - This allows code that handles types generically to work with fewer special 
> cases.
>   (I do like the FindTarget change though - it seems reasonable to allow 
> go-to-def on e.g. the `public` keyword)
>   It still preserves flexibility if we want to handle types as 
> base-specifiers specially (we can examine the parent)
OK, funnily enough that change to find target was to fix renaming when the 
recordtypeloc was removed from the selection. That change will be redundant if 
i fix that, but do you still want it in here? 



Comment at: clang/lib/AST/ASTTypeTraits.cpp:196
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();

sammccall wrote:
> nice, thanks!
> We should probably have a test for this (in ASTTypeTraitsTest.cpp there's a 
> simple pattern to follow for sourcerange)
Not really trivial as there is no matcher for `cxxBaseSpecifier`. Annoyingly 
its my fault there isn't one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

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


[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 318930.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Update behaviour to keep RecordTypeLoc seletion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang/lib/AST/ASTTypeTraits.cpp


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
 }
   )cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+  {R"cpp(// Ensure it doesn't associate base specifier with base name.
+struct A {};
+struct B : priv^ate A {};
+  )cpp",
+   "Cannot rename symbol: there is no symbol at the given location", false,
+   nullptr},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -493,6 +493,9 @@
 return traverseNode(
 X, [&] { return Base::TraverseConstructorInitializer(X); });
   }
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+return traverseNode(&X, [&] { return Base::TraverseCXXBaseSpecifier(X); });
+  }
   // Stmt is the same, but this form allows the data recursion optimization.
   bool dataTraverseStmtPre(Stmt *X) {
 if (!X || isImplicit(X))
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -710,7 +710,8 @@
 Finder.add(CCI, Flags);
   else if (const TemplateArgumentLoc *TAL = N.get())
 Finder.add(TAL->getArgument(), Flags);
-
+  else if (const CXXBaseSpecifier *CBS = N.get())
+Finder.add(CBS->getType(), Flags);
   return Finder.takeDecls();
 }
 


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameT

[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

(I don't see a new snapshot but LG with the traverseNode change)




Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:272-283
+  R"cpp(
+struct Foo {};
+struct Bar : [[private Fo^o]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {

njames93 wrote:
> sammccall wrote:
> > njames93 wrote:
> > > Is this good behaviour, or should Foo selection resolve as a 
> > > RecordTypeLoc, That is the behaviour previously observed for these 2 
> > > cases. And instead have CXXBaseSpecifier as its parent selection?
> > Yes, this should be a typeloc with the CXXBaseSpecifier as its parent, 
> > unless there's a really compelling reason to make an exception.
> > 
> > Two main reasons:
> >  - it matches RecursiveASTVisitor's idea of the tree shape, which people 
> > mostly understand. If we diverge, it'll be a special case we need to 
> > remember and so potentially a source of bugs.
> >  - This allows code that handles types generically to work with fewer 
> > special cases.
> >   (I do like the FindTarget change though - it seems reasonable to allow 
> > go-to-def on e.g. the `public` keyword)
> >   It still preserves flexibility if we want to handle types as 
> > base-specifiers specially (we can examine the parent)
> OK, funnily enough that change to find target was to fix renaming when the 
> recordtypeloc was removed from the selection. That change will be redundant 
> if i fix that, but do you still want it in here? 
Up to you, but I'd lean towards keeping it and adding a FindTarget test for 
`struct S : ^private T` or so, which is the visible change.



Comment at: clang/lib/AST/ASTTypeTraits.cpp:196
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();

njames93 wrote:
> sammccall wrote:
> > nice, thanks!
> > We should probably have a test for this (in ASTTypeTraitsTest.cpp there's a 
> > simple pattern to follow for sourcerange)
> Not really trivial as there is no matcher for `cxxBaseSpecifier`. Annoyingly 
> its my fault there isn't one.
Oh, I've been down this rabbithole recently... clangd support for attrs -> 
DynTypedNode support for Attr -> matchers for use in tests -> matchers get 
complicated...

Let's not block on this (and I need to revive my attr patch that got too big...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

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


[PATCH] D94355: [SimplifyCFG] Add relative switch lookup tables

2021-01-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/test/CodeGen/switch-to-lookup-table.c:2
+// Check switch to lookup optimization in fPIC and fno-PIC mode
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O2 -fno-PIC -S 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=FNOPIC
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O2 -fPIC -S -emit-llvm 
-o - | FileCheck %s --check-prefix=CHECK --check-prefix=FPIC

Clang codegen tests are not normally used to test LLVM optimizations. I think 
the tests for this should all live in LLVM, not Clang.

(Also aarch64 is not guaranteed to be included as a target in the LLVM build, 
so this test would not necessarily run.)



Comment at: clang/test/CodeGen/switch-to-lookup-table.c:6
+// Switch lookup table
+// FNOPIC: @switch.table.string_table = private unnamed_addr constant [9 x 
i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* 
getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* 
getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* 
getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* 
getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* 
getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0)], align 8
+

This table and the one below are very hard to read like this. Could you split 
it into multiple lines using FNOPIC-SAME?



Comment at: clang/test/CodeGen/switch-to-lookup-table.c:36
+
+  switch (cond) {
+  case 0:

I think the minimum number of cases for the switch-to-lookup table 
transformation is only 4 or 5. To make the test easier to read, I'd suggest 
using the minimum number of cases in the switch.



Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5658
+
+// If relative table is generated, initialize the array with the table.
+Constant *Initializer = ConstantArray::get(ArrayTy, TableContents);

This comment seems unnecessary, at this point we know we're generating the 
relative table.



Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5695
+if (auto *GlobalVal = dyn_cast(CaseRes))
+  if (!GlobalVal->isDSOLocal())
+return false;

I don't remember, will isDSOLocal() return true also if it's a private or 
internal symbol? Otherwise maybe this should check isLocalLinkage() also.



Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5709
+  return llvm::ConstantExpr::getTrunc(RelOffset,
+  Type::getInt32Ty(M.getContext()));
 }

I do worry about hard-coding this to 32 bits. As someone pointed out, it would 
not necessary hold in all code models for x86.

Similarly to the PIC check in ShouldBuildRelLookupTable(), is there some check 
we could do to make sure 32 bits is appropriate?



Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5712
 
-Value *SwitchLookupTable::BuildLookup(Value *Index, IRBuilder<> &Builder) {
+Value *SwitchLookupTable::BuildLookup(Module &M, Value *Index, Type *ValueType,
+  IRBuilder<> &Builder) {

The Builder points to a specific insertion point in a basic block for the 
lookup, so it knows the Module and adding the Module parameter is redundant.



Comment at: 
llvm/test/Transforms/SimplifyCFG/X86/switch_to_relative_lookup_table.ll:7
+
+@.str = private unnamed_addr constant [5 x i8] c"zero\00", align 1
+@.str.1 = private unnamed_addr constant [4 x i8] c"one\00", align 1

Same comment as I made for the test under clang/ above: I think fewer switch 
cases are probably enough to test this, and would make it easier to read. Also 
splitting the lookup tables over multiple lines would help too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 318932.
njames93 added a comment.

Update getSelectedRecord to work now that BaseSpecifier may contain nested 
Nodes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94942

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
@@ -0,0 +1,393 @@
+//===-- ImplementAbstractTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ImplementAbstract);
+
+TEST_F(ImplementAbstractTest, TestUnavailable) {
+
+  StringRef Cases[]{
+  // Not a pure virtual method.
+  R"cpp(
+  class A {
+virtual void Foo();
+  };
+  class ^B : public A {};
+)cpp",
+  // Pure virtual method overridden in class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class with virtual keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+virtual void Foo() override;
+  };
+)cpp",
+  // Pure virtual method overridden in class without override keyword
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class ^B : public A {
+void Foo();
+  };
+)cpp",
+  // Pure virtual method overriden in base class.
+  R"cpp(
+  class A {
+virtual void Foo() = 0;
+  };
+  class B : public A {
+void Foo() override;
+  };
+  class ^C : public B {
+  };
+)cpp"};
+  for (const auto &Case : Cases) {
+EXPECT_THAT(Case, Not(isAvailable()));
+  }
+}
+
+TEST_F(ImplementAbstractTest, NormalAvailable) {
+  struct Case {
+llvm::StringRef TestHeader;
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  };
+
+  Case Cases[]{
+  {
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};)cpp",
+  R"cpp(
+class B : public A {^};
+  )cpp",
+  R"cpp(
+class B : public A {
+void Foo() override;
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+  public:
+  virtual void Foo() = 0;
+};)cpp",
+  R"cpp(
+class ^B : public A {};
+  )cpp",
+  R"cpp(
+class B : public A {
+public:
+
+void Foo() override;
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+  virtual void Foo(int Param) = 0;
+};)cpp",
+  R"cpp(
+class ^B : public A {};
+  )cpp",
+  R"cpp(
+class B : public A {
+void Foo(int Param) override;
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+  virtual void Foo(int Param) = 0;
+};)cpp",
+  R"cpp(
+struct ^B : public A {};
+  )cpp",
+  R"cpp(
+struct B : public A {
+private:
+
+void Foo(int Param) override;
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+  virtual void Foo(int Param) const volatile = 0;
+  public:
+  virtual void Bar(int Param) = 0;
+};)cpp",
+  R"cpp(
+class ^B : public A {
+  void Foo(int Param) const volatile override;
+};
+  )cpp",
+  R"cpp(
+class B : public A {
+  void Foo(int Param) const volatile override;
+
+public:
+
+void Bar(int Param) override;
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+ class A {
+  virtual void Foo() = 0;
+  virtual void Bar() = 0;
+};
+class B : public A {
+  void Foo() override;
+};
+  )cpp",
+  R"cpp(
+class ^C : public B {
+  virtual void Baz();
+ 

[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:272-283
+  R"cpp(
+struct Foo {};
+struct Bar : [[private Fo^o]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {

sammccall wrote:
> njames93 wrote:
> > sammccall wrote:
> > > njames93 wrote:
> > > > Is this good behaviour, or should Foo selection resolve as a 
> > > > RecordTypeLoc, That is the behaviour previously observed for these 2 
> > > > cases. And instead have CXXBaseSpecifier as its parent selection?
> > > Yes, this should be a typeloc with the CXXBaseSpecifier as its parent, 
> > > unless there's a really compelling reason to make an exception.
> > > 
> > > Two main reasons:
> > >  - it matches RecursiveASTVisitor's idea of the tree shape, which people 
> > > mostly understand. If we diverge, it'll be a special case we need to 
> > > remember and so potentially a source of bugs.
> > >  - This allows code that handles types generically to work with fewer 
> > > special cases.
> > >   (I do like the FindTarget change though - it seems reasonable to allow 
> > > go-to-def on e.g. the `public` keyword)
> > >   It still preserves flexibility if we want to handle types as 
> > > base-specifiers specially (we can examine the parent)
> > OK, funnily enough that change to find target was to fix renaming when the 
> > recordtypeloc was removed from the selection. That change will be redundant 
> > if i fix that, but do you still want it in here? 
> Up to you, but I'd lean towards keeping it and adding a FindTarget test for 
> `struct S : ^private T` or so, which is the visible change.
I think I should remove it, then add it back in a follow up. It was needed to 
fix a issue in here that was then resolved in here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

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


[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 318933.
njames93 marked an inline comment as done.
njames93 added a comment.

Remove FindTarget to instead add in a follow up patch.
Side note, Think I'll wait til after tomorrow to land this, unsure if the 
changes will break anything elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95231

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang/lib/AST/ASTTypeTraits.cpp


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
 }
   )cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+  {R"cpp(// Ensure it doesn't associate base specifier with base name.
+struct A {};
+struct B : priv^ate A {};
+  )cpp",
+   "Cannot rename symbol: there is no symbol at the given location", false,
+   nullptr},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -493,6 +493,9 @@
 return traverseNode(
 X, [&] { return Base::TraverseConstructorInitializer(X); });
   }
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
+return traverseNode(&X, [&] { return Base::TraverseCXXBaseSpecifier(X); });
+  }
   // Stmt is the same, but this form allows the data recursion optimization.
   bool dataTraverseStmtPre(Stmt *X) {
 if (!X || isImplicit(X))


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -193,5 +193,7 @@
 return TAL->getSourceRange();
   if (const auto *C = get())
 return SourceRange(C->getBeginLoc(), C->getEndLoc());
+  if (const auto *CBS = get())
+return CBS->getSourceRange();
   return SourceRange();
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -261,6 +261,27 @@
   )cpp",
   "StringLiteral", // Not DeclRefExpr to operator()!
   },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[v^ir^tual private Foo]] {};
+  )cpp",
+  "CXXBaseSpecifier",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : private [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
+  {
+  R"cpp(
+struct Foo {};
+struct Bar : [[Fo^o]] {};
+  )cpp",
+  "RecordTypeLoc",
+  },
 
   // Point selections.
   {"void foo() { [[^foo]](); }", "DeclRefExpr"},
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1024,6 +1024,12 @@
 }
   )cpp",
"new name is the same", !HeaderFile, nullptr, "SameName"},
+  {R"cpp(// Ensure it doesn't associate base specifier with base name.
+struct A {};

[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D95307#2518592 , @NoQ wrote:

> This patch shoots the messenger but someone still needs to conduct a proper 
> investigation. The assertion is losing a lot more of its bug-finding power 
> than necessary to uncover the current cornercase; i really hope to preserve 
> it instead.

You mean the failing assertion from the tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D95338: [clangd] FindTarget resolves base specifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

FindTarget on the virtual keyword or access specifier of a base specifier will 
now resolve to type of the base specifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95338

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -230,6 +230,24 @@
{"void waldo()"});
 }
 
+TEST_F(TargetDeclTest, BaseSpecifier) {
+  Code = R"cpp(
+struct X {};
+struct Y : [[private]] X {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : [[private X]] {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : private [[X]] {};
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct X");
+}
+
 TEST_F(TargetDeclTest, ConstructorInitList) {
   Code = R"cpp(
 struct X {
@@ -1027,37 +1045,36 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {
-  // Simple expressions.
-  {R"cpp(
+  {// Simple expressions.
+   {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-   "0: targets = {global}\n"
-   "1: targets = {param}\n"
-   "2: targets = {func}\n"},
-  {R"cpp(
+"0: targets = {global}\n"
+"1: targets = {param}\n"
+"2: targets = {func}\n"},
+   {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-   "0: targets = {x}\n"
-   "1: targets = {X::a}\n"},
-  {R"cpp(
+"0: targets = {x}\n"
+"1: targets = {X::a}\n"},
+   {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-   "0: targets = {bar}\n"
-   "1: targets = {bar}\n"},
-  // Namespaces and aliases.
-  {R"cpp(
+"0: targets = {bar}\n"
+"1: targets = {bar}\n"},
+   // Namespaces and aliases.
+   {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -1065,19 +1082,19 @@
 using namespace $1^alias;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {alias}\n"},
-  // Using declarations.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {alias}\n"},
+   // Using declarations.
+   {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-   "0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
-  // Simple types.
-  {R"cpp(
+"0: targets = {ns}\n"
+"1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   // Simple types.
+   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -1086,13 +1103,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-   "0: targets = {Struct}\n"
-   "1: targets = {x}, decl\n"
-   "2: targets = {Typedef}\n"
-   "3: targets = {y}, decl\n"
-   "4: targets = {Struct}\n"},
-  // Name qualifiers.
-  {R"cpp(
+"0: targets = {Struct}\n"
+"1: targets = {x}, decl\n"
+"2: targets = {Typedef}\n"
+"3: targets = {y}, decl\n"
+"4: targets = {Struct}\n"},
+   // Name qualifiers.
+   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
$0^a::$1^b::$2^S $3^x;
@@ -1100,16 +1117,16 @@
$6^S::$7^type $8^y;
  }
 )cpp",
-   "0: targets = {a}\n"
-   "1: targets = {a::b}, qualifier = 'a::'\n"
-   "2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {x}, decl\n"
-   "4: targets = {a}\n"
-   "5: targets = {a::b}, qualifier = 'a::'\n"
-   "6: targets = {a::b::S}\n"
-   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
-   "8: targets = {y}, decl\n"},
-  {R"cpp(
+"0: targets = {a}\n"
+"1: targets = {a::b}, qualifier = 'a::'\n"
+"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
+"3: targets = {x}, decl\n"
+"4: targets 

[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D95307#2519283 , @vsavchenko wrote:

> In D95307#2518592 , @NoQ wrote:
>
>> This patch shoots the messenger but someone still needs to conduct a proper 
>> investigation. The assertion is losing a lot more of its bug-finding power 
>> than necessary to uncover the current cornercase; i really hope to preserve 
>> it instead.
>
> You mean the failing assertion from the tests?

Few hours before there was a message saying that there was some buggy commit to 
the build-bot. Are you referring to the build failure above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D95307#2519300 , @RedDocMD wrote:

> In D95307#2519283 , @vsavchenko 
> wrote:
>
>> In D95307#2518592 , @NoQ wrote:
>>
>>> This patch shoots the messenger but someone still needs to conduct a proper 
>>> investigation. The assertion is losing a lot more of its bug-finding power 
>>> than necessary to uncover the current cornercase; i really hope to preserve 
>>> it instead.
>>
>> You mean the failing assertion from the tests?
>
> Few hours before there was a message saying that there was some buggy commit 
> to the build-bot. Are you referring to the build failure above?

Yep. TBH I didn't take a good look at the failure, but judging even by the name 
of the failing test, it looks directly related to the subject of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[clang] 8fdd578 - [OpenCL][Docs] Describe tablegen BIFs declarations.

2021-01-25 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-01-25T11:17:03Z
New Revision: 8fdd5784f0d30b165602343a96a34611779b007b

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

LOG: [OpenCL][Docs] Describe tablegen BIFs declarations.

Added documentation for the fast builtin
function declarations with -fdeclare-opencl-builtins.

Tags: #clang

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

Added: 


Modified: 
clang/docs/OpenCLSupport.rst
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 5be7e91adcaf..0eaf0f300ee4 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -112,6 +112,28 @@ Feel free to contact us on `cfe-dev
 `_ or via `Bugzilla
 `__.
 
+Fast builtin function declarations
+--
+
+In addition to regular header includes with builtin types and functions using
+``-finclude-default-header`` explained in :doc:`UsersManual`, clang
+supports a fast mechanism to declare builtin functions with
+``-fdeclare-opencl-builtins``. This does not declare the builtin types and
+therefore it has to be used in combination with ``-finclude-default-header``
+if full functionality is required.
+
+**Example of Use**:
+
+.. code-block:: console
+ 
+  $ clang -Xclang -finclude-default-header test.cl
+
+Note that this is a frontend-only flag and therefore it requires the use of
+flags that forward options to the frontend, e.g. ``-cc1`` or ``-Xclang``.
+
+As this feature is still in experimental phase some changes might still occur
+on the command line interface side.
+
 C++ libraries for OpenCL
 
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index a7b698d77c47..fe944a0166b8 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3021,6 +3021,11 @@ To enable modules for OpenCL:
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path= test.cl
 
+Another way to circumvent long parsing latency for the OpenCL builtin
+declarations is to use mechanism enabled by ``-fdeclare-opencl-builtins`` flag
+that is available as an experimental feature (see more information in
+:doc:`OpenCLSupport`).
+
 OpenCL Extensions
 -
 



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


[PATCH] D95038: [OpenCL][Docs] Describe tablegen BIFs declaration

2021-01-25 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8fdd5784f0d3: [OpenCL][Docs] Describe tablegen BIFs 
declarations. (authored by Anastasia).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D95038?vs=318208&id=318938#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95038

Files:
  clang/docs/OpenCLSupport.rst
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3021,6 +3021,11 @@
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path= test.cl
 
+Another way to circumvent long parsing latency for the OpenCL builtin
+declarations is to use mechanism enabled by ``-fdeclare-opencl-builtins`` flag
+that is available as an experimental feature (see more information in
+:doc:`OpenCLSupport`).
+
 OpenCL Extensions
 -
 
Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -112,6 +112,28 @@
 `_ or via `Bugzilla
 `__.
 
+Fast builtin function declarations
+--
+
+In addition to regular header includes with builtin types and functions using
+``-finclude-default-header`` explained in :doc:`UsersManual`, clang
+supports a fast mechanism to declare builtin functions with
+``-fdeclare-opencl-builtins``. This does not declare the builtin types and
+therefore it has to be used in combination with ``-finclude-default-header``
+if full functionality is required.
+
+**Example of Use**:
+
+.. code-block:: console
+ 
+  $ clang -Xclang -finclude-default-header test.cl
+
+Note that this is a frontend-only flag and therefore it requires the use of
+flags that forward options to the frontend, e.g. ``-cc1`` or ``-Xclang``.
+
+As this feature is still in experimental phase some changes might still occur
+on the command line interface side.
+
 C++ libraries for OpenCL
 
 


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3021,6 +3021,11 @@
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path= test.cl
 
+Another way to circumvent long parsing latency for the OpenCL builtin
+declarations is to use mechanism enabled by ``-fdeclare-opencl-builtins`` flag
+that is available as an experimental feature (see more information in
+:doc:`OpenCLSupport`).
+
 OpenCL Extensions
 -
 
Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -112,6 +112,28 @@
 `_ or via `Bugzilla
 `__.
 
+Fast builtin function declarations
+--
+
+In addition to regular header includes with builtin types and functions using
+``-finclude-default-header`` explained in :doc:`UsersManual`, clang
+supports a fast mechanism to declare builtin functions with
+``-fdeclare-opencl-builtins``. This does not declare the builtin types and
+therefore it has to be used in combination with ``-finclude-default-header``
+if full functionality is required.
+
+**Example of Use**:
+
+.. code-block:: console
+ 
+  $ clang -Xclang -finclude-default-header test.cl
+
+Note that this is a frontend-only flag and therefore it requires the use of
+flags that forward options to the frontend, e.g. ``-cc1`` or ``-Xclang``.
+
+As this feature is still in experimental phase some changes might still occur
+on the command line interface side.
+
 C++ libraries for OpenCL
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

Funnily enough, when I run `ninja clang-check` I don't get any errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D95340: [clang][cli] NFC: Simplify BoolOption API

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
Herald added subscribers: dang, jfb.
jansvoboda11 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

The `Bool{,F,G}Option` TableGen classes were designed after `Opt{In,Out}FFlag`, 
which puts marshalling info on only one of the boolean options. To know which 
option is supposed to be visible on -cc1 command-line, we used `ChangedBy` and 
`ResetBy` classes to describe the flags. However, we now put marshalling info 
on both records (see D93008  for details), 
which means we don't really need `ChangedBy` and `ResetBy` anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95340

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -296,61 +296,75 @@
 }
 
 //===--===//
-// BoolOptionBase
+// BoolOption
 //===--===//
 
-// Default value of the keypath associated with a marshalled bool option.
+// The default value of a marshalled key path.
 class Default { code Value = value; }
 
-class FlagPolarity { bit Value = value; }
-def PosFlag : FlagPolarity {}
-def NegFlag : FlagPolarity {}
+// Convenience variables for boolean defaults.
+def DefaultTrue : Default<"true"> {}
+def DefaultFalse : Default<"false"> {}
+
+// The value set to the key path when the flag is present on the command line.
+class Set { bit Value = value; }
+def SetTrue : Set {}
+def SetFalse : Set {}
 
-// Definition of a single command line flag.
-class FlagDef option_flags,
+// Definition of single command line flag. This is an implementation detail, use
+// SetTrueBy or SetFalseBy instead.
+class FlagDef option_flags,
   string help, list implied_by_options = []> {
-  // Negative polarity (false) implies a command line spelling prefixed with
-  // "no-" and a TableGen record whose name is prefixed with "no_".
-  FlagPolarity Polarity = polarity;
+  // The polarity. Besides spelling, this also decides whether the TableGen
+  // record will be prefixed with "no_".
+  bit Polarity = polarity;
 
-  // The value assigned to keypath when the flag is present on the command line.
+  // The value assigned to key path when the flag is present on command line.
   bit Value = value;
 
-  // List of OptionFlag records that control the visibility of the flag in
-  // different scenarios.
+  // OptionFlags that control visibility of the flag in different tools.
   list OptionFlags = option_flags;
 
   // The help text associated with the flag.
   string Help = help;
 
-  // List of options that imply this flag when present on command line.
+  // Options that imply this flag when present on command line.
   list ImpliedBy = implied_by_options;
 }
 
-// Information extending a FlagDef.
-class FlagDefSuffix option_flags, string help> {
+// Additional information to be appended to both positive and negative flag.
+class BothFlags option_flags, string help = ""> {
   list OptionFlags = option_flags;
   string Help = help;
 }
 
-// Extend the flag definition with a suffix.
-class ApplySuffix {
+// Functor that appends the suffix to the base flag definition.
+class ApplySuffix {
   FlagDef Result
 = FlagDef;
+  !listconcat(flag.OptionFlags, suffix.OptionFlags),
+  !strconcat(flag.Help, suffix.Help), flag.ImpliedBy>;
 }
 
-// FlagDef extension. Convenient for creation of TableGen records.
+// Definition of the command line flag with positive spelling, e.g. "-ffoo".
+class PosFlag flags = [], string help = "",
+  list implied_by_options = []>
+  : FlagDef {}
+
+// Definition of the command line flag with negative spelling, e.g. "-fno-foo".
+class NegFlag flags = [], string help = "",
+  list implied_by_options = []>
+  : FlagDef {}
+
+// Expanded FlagDef that's convenient for creation of TableGen records.
 class FlagDefExpanded
   : FlagDef {
   // Name of the TableGen record.
-  string RecordName = prefix#!cond(flag.Polarity.Value : "", true : "no_")#name;
+  string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name;
 
   // Spelling of the flag.
-  string Spelling
-= prefix#!cond(flag.Polarity.Value : "", true : "no-")#spelling;
+  string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling;
 
   // Can the flag be implied by another flag?
   bit CanBeImplied = !not(!empty(flag.ImpliedBy));
@@ -359,9 +373,10 @@
   code ValueAsCode = !cond(flag.Value : "true", true: "false");
 }
 
-// Creates record with a marshalled flag.
-class BoolOptionFlag
+// TableGen record for a single marshalled flag.
+class Marsha

[PATCH] D95270: [clangd][NFC] Simplify handing on methods with no params

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 318942.
njames93 marked an inline comment as done.
njames93 added a comment.

Remove unnecessary specialization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95270

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

Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -265,8 +265,6 @@
   return true;
 }
 using InitializedParams = NoParams;
-using ShutdownParams = NoParams;
-using ExitParams = NoParams;
 
 /// Defines how the host (editor) should sync document changes to the language
 /// server.
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -93,8 +93,8 @@
   // Calls have signature void(const Params&, Callback).
   void onInitialize(const InitializeParams &, Callback);
   void onInitialized(const InitializedParams &);
-  void onShutdown(const ShutdownParams &, Callback);
-  void onSync(const NoParams &, Callback);
+  void onShutdown(Callback);
+  void onSync(Callback);
   void onDocumentDidOpen(const DidOpenTextDocumentParams &);
   void onDocumentDidChange(const DidChangeTextDocumentParams &);
   void onDocumentDidClose(const DidCloseTextDocumentParams &);
@@ -161,7 +161,7 @@
  Callback);
   /// This is a clangd extension. Provides a json tree representing memory usage
   /// hierarchy.
-  void onMemoryUsage(const NoParams &, Callback);
+  void onMemoryUsage(Callback);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic &D);
 
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -258,6 +258,15 @@
 };
   }
 
+  template 
+  void bind(const char *Method,
+void (ClangdLSPServer::*Handler)(Callback)) {
+Calls[Method] = [Handler, this](llvm::json::Value RawParams,
+ReplyOnce Reply) {
+  (Server.*Handler)(std::move(Reply));
+};
+  }
+
   // Bind a reply callback to a request. The callback will be invoked when
   // clangd receives the reply from the LSP client.
   // Return a call id of the request.
@@ -301,6 +310,20 @@
 };
   }
 
+  void bind(const char *Method, void (ClangdLSPServer::*Handler)()) {
+Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
+  (Server.*Handler)();
+};
+  }
+
+  template <>
+  void bind(const char *Method,
+  void (ClangdLSPServer::*Handler)(const NoParams &)) {
+Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
+  (Server.*Handler)(NoParams{});
+};
+  }
+
 private:
   // Function object to reply to an LSP call.
   // Each instance must be called exactly once, otherwise:
@@ -647,8 +670,7 @@
 
 void ClangdLSPServer::onInitialized(const InitializedParams &Params) {}
 
-void ClangdLSPServer::onShutdown(const ShutdownParams &Params,
- Callback Reply) {
+void ClangdLSPServer::onShutdown(Callback Reply) {
   // Do essentially nothing, just say we're ready to exit.
   ShutdownRequestReceived = true;
   Reply(nullptr);
@@ -656,8 +678,7 @@
 
 // sync is a clangd extension: it blocks until all background work completes.
 // It blocks the calling thread, so no messages are processed until it returns!
-void ClangdLSPServer::onSync(const NoParams &Params,
- Callback Reply) {
+void ClangdLSPServer::onSync(Callback Reply) {
   if (Server->blockUntilIdleForTest(/*TimeoutSeconds=*/60))
 Reply(nullptr);
   else
@@ -1445,8 +1466,7 @@
   });
 }
 
-void ClangdLSPServer::onMemoryUsage(const NoParams &,
-Callback Reply) {
+void ClangdLSPServer::onMemoryUsage(Callback Reply) {
   llvm::BumpPtrAllocator DetailAlloc;
   MemoryTree MT(&DetailAlloc);
   profile(MT);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95270: [clangd][NFC] Simplify handing on methods with no params

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:262
+  template 
+  void bind(const char *Method,
+void (ClangdLSPServer::*Handler)(const NoParams &,

kadircet wrote:
> why do we need this one ?
Good point, this one is never actually used now.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.h:93
   void onInitialize(const InitializeParams &, Callback);
   void onInitialized(const InitializedParams &);
+  void onShutdown(Callback);

kadircet wrote:
> any reasons for keeping `InitializedParams` ?
Although its empty, its defined in the protocol so we should be mirroring it.



Comment at: clang-tools-extra/clangd/Protocol.h:267
 }
 using InitializedParams = NoParams;
 

kadircet wrote:
> and drop this too.
See previous comment about mirroring the spec.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95270

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


[PATCH] D95342: [clang][cli] Store LangStandard::Kind in LangOptions

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `LangStandard::Kind` parsed from command line arguments is used to set up 
some `LangOption` defaults, but isn't stored anywhere.

To be able to generate `-std=` (in future patch), we need `CompilerInvocation` 
to not forget it.

This patch demonstrates another use-case: using `LangStd` to set up defaults of 
marshalled options.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95342

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

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -695,4 +695,49 @@
 
   ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-verify=xyz"), 1));
 }
+
+// Option default depends on language standard.
+
+TEST_F(CommandLineTest, DigraphsImplied) {
+  const char *Args[] = {""};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsDisabled) {
+  const char *Args[] = {"-fno-digraphs"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-digraphs")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsNotImplied) {
+  const char *Args[] = {"-std=c89"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsEnabled) {
+  const char *Args[] = {"-std=c89", "-fdigraphs"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs")));
+}
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1965,6 +1965,7 @@
   }
 
   const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
+  Opts.LangStd = LangStd;
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -14,7 +14,7 @@
 
 using namespace clang;
 
-LangOptions::LangOptions() {
+LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
 #define LANGOPT(Name, Bits, Default, Description) Name = Default;
 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
 #include "clang/Basic/LangOptions.def"
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -434,8 +434,11 @@
 AutoNormalizeEnum {}
 
 // Key paths that are constant during parsing of options with the same key path prefix.
+defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
 
+defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
+
 /
 // Options
 
@@ -1952,10 +1955,11 @@
 HelpText<"Compile common globals like normal definitions">;
 def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group,
   Flags<[NoXarchOption]>;
-def fdigraphs : Flag<["-"], "fdigraphs">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">;
-def fno_digraphs : Flag<["-"], "fno-digraphs">, Group, Flags<[CC1Option]>,
-  HelpText<"Disallow alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:'">;
+defm digraphs : BoolFOption<"digraphs",
+  LangOpts<"Digraphs">, Default,
+  PosFlag', '<%', '

[clang] 14947cd - [clang] Fix signedness in vector bitcast evaluation

2021-01-25 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-01-25T12:01:42Z
New Revision: 14947cd04701d923a57a0161fd1967b81e00ff5e

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

LOG: [clang] Fix signedness in vector bitcast evaluation

The included test case triggered a sign assertion on the result in
`Success()`.  This was caused by the APSInt created for a bitcast
having its signedness bit inverted.  The second APSInt constructor
argument is `isUnsigned`, so invert the result of
`isSignedIntegerType`.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenOpenCL/vector_literals.cl

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 56181bbe1166..c1973720e49a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr 
*E) {
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);

diff  --git a/clang/test/CodeGenOpenCL/vector_literals.cl 
b/clang/test/CodeGenOpenCL/vector_literals.cl
index af571714368e..3115aef2b50a 100644
--- a/clang/test/CodeGenOpenCL/vector_literals.cl
+++ b/clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,3 +63,10 @@ void vector_literals_valid() {
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
+
+void vector_literals_with_cast() {
+  // CHECK-LABEL: vector_literals_with_cast
+  // CHECK: store <2 x i32> , <2 x i32>*
+  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
+  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
+}



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


[PATCH] D95135: Fix signedness in vector bitcast evaluation

2021-01-25 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14947cd04701: [clang] Fix signedness in vector bitcast 
evaluation (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95135

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenOpenCL/vector_literals.cl


Index: clang/test/CodeGenOpenCL/vector_literals.cl
===
--- clang/test/CodeGenOpenCL/vector_literals.cl
+++ clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,3 +63,10 @@
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
+
+void vector_literals_with_cast() {
+  // CHECK-LABEL: vector_literals_with_cast
+  // CHECK: store <2 x i32> , <2 x i32>*
+  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
+  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);


Index: clang/test/CodeGenOpenCL/vector_literals.cl
===
--- clang/test/CodeGenOpenCL/vector_literals.cl
+++ clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,3 +63,10 @@
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
+
+void vector_literals_with_cast() {
+  // CHECK-LABEL: vector_literals_with_cast
+  // CHECK: store <2 x i32> , <2 x i32>*
+  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
+  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95342: [clang][cli] Store LangStandard::Kind in LangOptions

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 318951.
jansvoboda11 added a comment.

Remove Digraphs from CompilerInvocation.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95342

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

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -695,4 +695,49 @@
 
   ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-verify=xyz"), 1));
 }
+
+// Option default depends on language standard.
+
+TEST_F(CommandLineTest, DigraphsImplied) {
+  const char *Args[] = {""};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsDisabled) {
+  const char *Args[] = {"-fno-digraphs"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-digraphs")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsNotImplied) {
+  const char *Args[] = {"-std=c89"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fdigraphs";
+}
+
+TEST_F(CommandLineTest, DigraphsEnabled) {
+  const char *Args[] = {"-std=c89", "-fdigraphs"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+  ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs")));
+}
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1965,6 +1965,7 @@
   }
 
   const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
+  Opts.LangStd = LangStd;
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
@@ -1976,7 +1977,6 @@
   Opts.CPlusPlus17 = Std.isCPlusPlus17();
   Opts.CPlusPlus20 = Std.isCPlusPlus20();
   Opts.CPlusPlus2b = Std.isCPlusPlus2b();
-  Opts.Digraphs = Std.hasDigraphs();
   Opts.GNUMode = Std.isGNUMode();
   Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
   Opts.GNUCVersion = 0;
@@ -2256,8 +2256,6 @@
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);
 
-  Opts.Digraphs = Args.hasFlag(OPT_fdigraphs, OPT_fno_digraphs, Opts.Digraphs);
-
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -14,7 +14,7 @@
 
 using namespace clang;
 
-LangOptions::LangOptions() {
+LangOptions::LangOptions() : LangStd(LangStandard::lang_unspecified) {
 #define LANGOPT(Name, Bits, Default, Description) Name = Default;
 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
 #include "clang/Basic/LangOptions.def"
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -434,8 +434,11 @@
 AutoNormalizeEnum {}
 
 // Key paths that are constant during parsing of options with the same key path prefix.
+defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
 
+defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
+
 /
 // Options
 
@@ -1952,10 +1955,11 @@
 HelpText<"Compile common globals like normal definitions">;
 def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group,
   Flags<[NoXarchOption]>;
-def fdigraphs : Flag<["-"], "fdigraphs">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">;
-def fno_digraphs : Flag<["-"], "fno-d

[PATCH] D95343: [clang][cli] Port GNU language options to marshalling system

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Port some GNU-related language options to the marshalling system for automatic 
command line parsing and generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95343

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
@@ -400,9 +400,11 @@
 MERGER(KEYPATH, static_cast(*MaybeValue));  \
   }
 
+static const StringRef GetInputKindName(InputKind IK);
+
 static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags,
-const InputArgList &Args) {
+DiagnosticsEngine &Diags, const InputArgList &Args,
+InputKind IK) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -438,6 +440,10 @@
 LangOpts.NewAlignOverride = 0;
   }
 
+  if (Args.hasArg(OPT_fgnu89_inline) && LangOpts.CPlusPlus)
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+<< "-fgnu89-inline" << GetInputKindName(IK);
+
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
 auto DefaultCC = LangOpts.getDefaultCallingConv();
 
@@ -1978,7 +1984,6 @@
   Opts.CPlusPlus20 = Std.isCPlusPlus20();
   Opts.CPlusPlus2b = Std.isCPlusPlus2b();
   Opts.GNUMode = Std.isGNUMode();
-  Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
   Opts.GNUCVersion = 0;
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
@@ -2050,7 +2055,6 @@
   // C++ has wchar_t keyword.
   Opts.WChar = Opts.CPlusPlus;
 
-  Opts.GNUKeywords = Opts.GNUMode;
   Opts.CXXOperatorNames = Opts.CPlusPlus;
 
   Opts.AlignedAllocation = Opts.CPlusPlus17;
@@ -2248,14 +2252,6 @@
 << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
   }
 
-  // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
-  // keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
-  // while a subset (the non-C++ GNU keywords) is provided by GCC's
-  // '-fgnu-keywords'. Clang conflates the two for simplicity under the single
-  // name, as it doesn't seem a useful distinction.
-  Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
-  Opts.GNUKeywords);
-
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
@@ -2338,14 +2334,6 @@
 Opts.GNUCVersion = Major * 100 * 100 + Minor * 100 + Patch;
   }
 
-  if (Args.hasArg(OPT_fgnu89_inline)) {
-if (Opts.CPlusPlus)
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fgnu89-inline" << GetInputKindName(IK);
-else
-  Opts.GNUInline = 1;
-  }
-
   if (Args.hasArg(OPT_ftrapv)) {
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
 // Set the handler, if one is specified.
@@ -2988,7 +2976,7 @@
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
-  FixupInvocation(Res, Diags, Args);
+  FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -434,8 +434,11 @@
 AutoNormalizeEnum {}
 
 // Key paths that are constant during parsing of options with the same key path prefix.
+defvar cplusplus = LangOpts<"CPlusPlus">;
+defvar c99 = LangOpts<"C99">;
 defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
+defvar gnu_mode = LangOpts<"GNUMode">;
 
 defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
 
@@ -1619,9 +1622,19 @@
 def fgnuc_version_EQ : Joined<["-"], "fgnuc-version=">, Group,
   HelpText<"Sets various macros to claim compatibility with the given GCC version (default is 4.2.1)">,
   Flags<[CC1Option, CoreOption]>;
-def fgnu_keywords : Flag<["-"], "fgnu-keywords">, Group, Flags<[CC1Option]>,
-  HelpText<"Allow GNU-extension keywords regardless of language standard">;
-defm gnu89_inline : OptInFFlag<"gnu89-inline", "Use the gnu89 inline semantics">;
+// We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
+// keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
+// while a subset (the non-C++ GNU keywords) is provided by GCC's
+// '-fgnu-keywords'. Clang conflates the two for simplicity under the single
+// name, as it doesn't

[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-01-25 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:128
+  // after an underscore (_). It is instantiated like Prototype.
+  string MangledSuffix = managed_suffix;
+

mangled_suffix



Comment at: clang/include/clang/Basic/riscv_vector.td:147
+
+  // If HasMask, this flag states that this builtin has a merge operand. It is
+  // always the first operand.

"has a maskedoff operand"



Comment at: clang/include/clang/Basic/riscv_vector.td:149
+  // always the first operand.
+  bit HasMergeOperand = true;
+

Propose to use HasMaskedOffOperand.



Comment at: clang/include/clang/Basic/riscv_vector.td:161
+  // This builtin is valid for the given exponental LMULs.
+  list ELMUL = [0, 1, 2, 3, -1, -2, -3];
+

EMUL according to specification.



Comment at: clang/include/clang/Basic/riscv_vector.td:191
+multiclass GenRVVBuiltin {
+ if !or(!eq(gen_all, true), !eq(gen, true))  then {

mangled_suffix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

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


[PATCH] D95344: [clang][cli] Accept strings instead of options in ImpliedByAnyOf

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

To be able to use a constant keypaths (e.g. `defvar cplusplus = 
LangOpts<"CPlusPlus">`) inside `ImpliedByAnyOf`, let's accept strings instead 
of `Option` instances.

This somewhat weakens the guarantees that we're referring to an existing 
entity, but we can still use the option.KeyPath syntax to simulate this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95344

Files:
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/Opts.td

Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -51,10 +51,10 @@
   MarshallingInfoFlag>;
 def marshalled_flag_c : Flag<["-"], "marshalled-flag-c">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[marshalled_flag_d], "true">;
+  ImpliedByAnyOf<[marshalled_flag_d.KeyPath], "true">;
 def marshalled_flag_b : Flag<["-"], "marshalled-flag-b">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[marshalled_flag_d], "true">;
+  ImpliedByAnyOf<[marshalled_flag_d.KeyPath], "true">;
 def marshalled_flag_a : Flag<["-"], "marshalled-flag-a">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[marshalled_flag_c, marshalled_flag_b]>;
+  ImpliedByAnyOf<[marshalled_flag_c.KeyPath, marshalled_flag_b.KeyPath]>;
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -154,9 +154,9 @@
 
 def EmptyKPM : KeyPathAndMacro<"", "">;
 
-class ImpliedByAnyOf options, code value = "true"> {
-  code ImpliedCheck = !foldl("false", options, accumulator, option,
- !strconcat(accumulator, " || ", option.KeyPath));
+class ImpliedByAnyOf key_paths, code value = "true"> {
+  code ImpliedCheck = !foldl("false", key_paths, accumulator, key_path,
+ !strconcat(accumulator, " || ", key_path));
   code ImpliedValue = value;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -272,7 +272,7 @@
 multiclass OptInFFlag flags=[],
   KeyPathAndMacro kpm = EmptyKPM,
-  list enablers = []> {
+  list enablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText,
MarshallingInfoFlag,
@@ -286,7 +286,7 @@
 multiclass OptOutFFlag flags=[],
KeyPathAndMacro kpm = EmptyKPM,
-   list disablers = []> {
+   list disablers = []> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
@@ -314,7 +314,7 @@
 // Definition of single command line flag. This is an implementation detail, use
 // SetTrueBy or SetFalseBy instead.
 class FlagDef option_flags,
-  string help, list implied_by_options = []> {
+  string help, list implied_by_expressions = []> {
   // The polarity. Besides spelling, this also decides whether the TableGen
   // record will be prefixed with "no_".
   bit Polarity = polarity;
@@ -328,8 +328,8 @@
   // The help text associated with the flag.
   string Help = help;
 
-  // Options that imply this flag when present on command line.
-  list ImpliedBy = implied_by_options;
+  // List of expressions that, when true, imply this flag.
+  list ImpliedBy = implied_by_expressions;
 }
 
 // Additional information to be appended to both positive and negative flag.
@@ -348,13 +348,13 @@
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
 class PosFlag flags = [], string help = "",
-  list implied_by_options = []>
-  : FlagDef {}
+  list implied_by_expressions = []>
+  : FlagDef {}
 
 // Definition of the command line flag with negative spelling, e.g. "-fno-foo".
 class NegFlag flags = [], string help = "",
-  list implied_by_options = []>
-  : FlagDef {}
+  list implied_by_expressions = []>
+  : FlagDef {}
 
 // Expanded FlagDef that's convenient for creation of TableGen records.
 class FlagDefExpanded
@@ -790,7 +790,7 @@
 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>,
-  ImpliedByAnyOf<[cl_unsafe_math_optimizations, cl_fast_relaxed_math]>;
+  ImpliedByAnyOf<[cl_unsafe_math_optimizations.KeyPath, cl_fast_relaxed_math.KeyPath]>;
 def cl_no_signed_zeros : Flag<["-"], "c

[PATCH] D95345: [clang][cli] Port GPU-related language options to marshalling system

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Port some GPU-related language options to the marshalling system for automatic 
command line parsing and generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95345

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
@@ -444,6 +444,22 @@
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << "-fgnu89-inline" << GetInputKindName(IK);
 
+  if (Args.hasArg(OPT_fgpu_allow_device_init) && !LangOpts.HIP)
+Diags.Report(diag::warn_ignored_hip_only_option)
+<< Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
+
+  if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ) && !LangOpts.HIP)
+Diags.Report(diag::warn_ignored_hip_only_option)
+<< Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
+
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because
+  // this option was added for compatibility with OpenCL 1.0.
+  if (Args.getLastArg(OPT_cl_strict_aliasing) && LangOpts.OpenCLVersion > 100)
+Diags.Report(diag::warn_option_invalid_ocl_version)
+<< LangOpts.getOpenCLVersionTuple().getAsString()
+<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
+
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
 auto DefaultCC = LangOpts.getDefaultCallingConv();
 
@@ -2008,8 +2024,6 @@
 Opts.AltiVec = 0;
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FPM_On);
-Opts.NativeHalfType = 1;
-Opts.NativeHalfArgsAndReturns = 1;
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
 
 // Include default header file for OpenCL.
@@ -2041,10 +2055,6 @@
   }
 
   Opts.RenderScript = IK.getLanguage() == Language::RenderScript;
-  if (Opts.RenderScript) {
-Opts.NativeHalfType = 1;
-Opts.NativeHalfArgsAndReturns = 1;
-  }
 
   // OpenCL and C++ both have bool, true, false keywords.
   Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
@@ -2240,8 +2250,6 @@
 }
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
   // this option was added for compatibility with OpenCL 1.0.
@@ -2255,23 +2263,6 @@
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
-Opts.CUDADeviceApproxTranscendentals = 1;
-
-  if (Args.hasArg(OPT_fgpu_allow_device_init)) {
-if (Opts.HIP)
-  Opts.GPUAllowDeviceInit = 1;
-else
-  Diags.Report(diag::warn_ignored_hip_only_option)
-  << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
-  }
-  if (Opts.HIP)
-Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
-Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
-  else if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ))
-Diags.Report(diag::warn_ignored_hip_only_option)
-<< Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
@@ -2432,12 +2423,6 @@
 Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.XLPragmaPack = Args.hasArg(OPT_fxl_pragma_pack);
   llvm::sort(Opts.ModuleFeatures);
-  Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
-  Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
-  // Enable HalfArgsAndReturns if present in Args or if NativeHalfArgsAndReturns
-  // is enabled.
-  Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns)
-| Opts.NativeHalfArgsAndReturns;
 
   Opts.ArmSveVectorBits =
   getLastArgIntValue(Args, options::OPT_msve_vector_bits_EQ, 0, Diags);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -438,6 +438,8 @@
 defvar c99 = LangOpts<"C99">;
 defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
+defvar render_script = LangOpts<"RenderScript">;
+defvar hip = LangOpts<"HIP">;
 defvar gnu_mode = LangOpts<"GNUMode">;
 
 defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
@@ -870,8 +872,6 @@
 def fcuda_flush_denormals_to_ze

[PATCH] D95346: [clang][cli] Port LangOpts to marshalling system, pt.1

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Port some miscellaneous language options to the marshalling system for 
oautomatic command line parsing and generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95346

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
@@ -2004,6 +2004,8 @@
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
 
+  Opts.CPlusPlusModules = Opts.CPlusPlus20;
+
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();
   if (LangStd == LangStandard::lang_opencl10)
@@ -2065,14 +2067,7 @@
   // C++ has wchar_t keyword.
   Opts.WChar = Opts.CPlusPlus;
 
-  Opts.CXXOperatorNames = Opts.CPlusPlus;
-
   Opts.AlignedAllocation = Opts.CPlusPlus17;
-
-  Opts.DollarIdents = !Opts.AsmPreprocessor;
-
-  // Enable [[]] attributes in C++11 and C2x by default.
-  Opts.DoubleSquareBracketAttributes = Opts.CPlusPlus11 || Opts.C2x;
 }
 
 /// Check if input file kind and language standard are compatible.
@@ -2260,9 +2255,6 @@
 << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
   }
 
-  if (Args.hasArg(OPT_fno_operator_names))
-Opts.CXXOperatorNames = 0;
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
@@ -2334,8 +2326,6 @@
   else if (Args.hasArg(OPT_fwrapv))
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Defined);
 
-  Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
-  Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
   Opts.MSCompatibilityVersion = 0;
   if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
 VersionTuple VT;
@@ -2356,48 +2346,13 @@
   Opts.Trigraphs =
   Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
 
-  Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
-   OPT_fno_dollars_in_identifiers,
-   Opts.DollarIdents);
-
-  // -ffixed-point
-  Opts.FixedPoint =
-  Args.hasFlag(OPT_ffixed_point, OPT_fno_fixed_point, /*Default=*/false) &&
-  !Opts.CPlusPlus;
-  Opts.PaddingOnUnsignedFixedPoint =
-  Args.hasFlag(OPT_fpadding_on_unsigned_fixed_point,
-   OPT_fno_padding_on_unsigned_fixed_point,
-   /*Default=*/false) &&
-  Opts.FixedPoint;
-
-  Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
-  Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
 && Opts.OpenCLVersion == 200);
-  Opts.Coroutines = Opts.CPlusPlus20 || Args.hasArg(OPT_fcoroutines_ts);
 
   Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
  Opts.SYCLIsDevice ||
  Args.hasArg(OPT_fconvergent_functions);
 
-  Opts.DoubleSquareBracketAttributes =
-  Args.hasFlag(OPT_fdouble_square_bracket_attributes,
-   OPT_fno_double_square_bracket_attributes,
-   Opts.DoubleSquareBracketAttributes);
-
-  Opts.CPlusPlusModules = Opts.CPlusPlus20;
-  Opts.Modules =
-  Args.hasArg(OPT_fmodules) || Opts.ModulesTS || Opts.CPlusPlusModules;
-  Opts.ModulesDeclUse =
-  Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
-  // FIXME: We only need this in C++ modules / Modules TS if we might textually
-  // enter a different module (eg, when building a header unit).
-  Opts.ModulesLocalVisibility =
-  Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS ||
-  Opts.CPlusPlusModules;
-  Opts.ModulesSearchAll = Opts.Modules &&
-!Args.hasArg(OPT_fno_modules_search_all) &&
-Args.hasArg(OPT_fmodules_search_all);
   Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
   Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus20);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -435,12 +435,17 @@
 
 // Key paths that are constant during parsing of options with the same key path prefix.
 defvar cplusplus = LangOpts<"CPlusPlus">;
+defvar cpp11 = LangOpts<"CPlusPlus11">;
+defvar cpp20 = LangOpts<"CPlusPlus20">;
 defvar c99 = LangOpts<"C99">;
+defvar c2x = LangOpts<"C2x">;
 defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
 defvar render_

[PATCH] D95347: [clang][cli] Port LangOpts to marshalling system, pt. 2

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Port some miscellaneous language options to the marshalling system for 
oautomatic command line parsing and generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95347

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
@@ -432,6 +432,9 @@
   if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
 Diags.Report(diag::warn_c_kext);
 
+  if (Args.hasArg(OPT_fconcepts_ts))
+Diags.Report(diag::warn_fe_concepts_ts_flag);
+
   if (LangOpts.NewAlignOverride &&
   !llvm::isPowerOf2_32(LangOpts.NewAlignOverride)) {
 Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
@@ -2063,11 +2066,6 @@
 
   // OpenCL has half keyword
   Opts.Half = Opts.OpenCL;
-
-  // C++ has wchar_t keyword.
-  Opts.WChar = Opts.CPlusPlus;
-
-  Opts.AlignedAllocation = Opts.CPlusPlus17;
 }
 
 /// Check if input file kind and language standard are compatible.
@@ -2353,47 +2351,16 @@
  Opts.SYCLIsDevice ||
  Args.hasArg(OPT_fconvergent_functions);
 
-  Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
-  Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
-  Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus20);
   Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
   if (!Opts.NoBuiltin)
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
-  Opts.AlignedAllocation =
-  Args.hasFlag(OPT_faligned_allocation, OPT_fno_aligned_allocation,
-   Opts.AlignedAllocation);
-  Opts.AlignedAllocationUnavailable =
-  Opts.AlignedAllocation && Args.hasArg(OPT_aligned_alloc_unavailable);
-  if (Args.hasArg(OPT_fconcepts_ts))
-Diags.Report(diag::warn_fe_concepts_ts_flag);
-  Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
-  Opts.EnableAIXExtendedAltivecABI = Args.hasArg(OPT_mabi_EQ_vec_extabi);
-  Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
-  Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple
-|| Args.hasArg(OPT_fdump_record_layouts);
   if (Opts.FastRelaxedMath)
 Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
-  Opts.XLPragmaPack = Args.hasArg(OPT_fxl_pragma_pack);
   llvm::sort(Opts.ModuleFeatures);
 
-  Opts.ArmSveVectorBits =
-  getLastArgIntValue(Args, options::OPT_msve_vector_bits_EQ, 0, Diags);
-
-  // __declspec is enabled by default for the PS4 by the driver, and also
-  // enabled for Microsoft Extensions or Borland Extensions, here.
-  //
-  // FIXME: __declspec is also currently enabled for CUDA, but isn't really a
-  // CUDA extension. However, it is required for supporting
-  // __clang_cuda_builtin_vars.h, which uses __declspec(property). Once that has
-  // been rewritten in terms of something more generic, remove the Opts.CUDA
-  // term here.
-  Opts.DeclSpecKeyword =
-  Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
-   (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
-
   // -mrtd option
   if (Arg *A = Args.getLastArg(OPT_mrtd)) {
 if (Opts.getDefaultCallingConv() != LangOptions::DCC_None)
@@ -2516,11 +2483,6 @@
   Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) &&
   Args.hasArg(options::OPT_fopenmp_cuda_force_full_runtime);
 
-  // Record whether the __DEPRECATED define was requested.
-  Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
- OPT_fno_deprecated_macro,
- Opts.Deprecated);
-
   // FIXME: Eliminate this dependency.
   unsigned Opt = getOptimizationLevel(Args, IK, Diags),
OptSize = getOptimizationLevelSize(Args);
@@ -2551,20 +2513,6 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  LangOptions::FPExceptionModeKind FPEB = LangOptions::FPE_Ignore;
-  if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) {
-StringRef Val = A->getValue();
-if (Val.equals("ignore"))
-  FPEB = LangOptions::FPE_Ignore;
-else if (Val.equals("maytrap"))
-  FPEB = LangOptions::FPE_MayTrap;
-else if (Val.equals("strict"))
-  FPEB = LangOptions::FPE_Strict;
-else
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
-  }
-  Opts.setFPExceptionMode(FPEB);
-
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=

[PATCH] D95345: [clang][cli] Port GPU-related language options to marshalling system

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 318963.
jansvoboda11 added a comment.

Remove diagnostics from ParseLangArgs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95345

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
@@ -444,6 +444,22 @@
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << "-fgnu89-inline" << GetInputKindName(IK);
 
+  if (Args.hasArg(OPT_fgpu_allow_device_init) && !LangOpts.HIP)
+Diags.Report(diag::warn_ignored_hip_only_option)
+<< Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
+
+  if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ) && !LangOpts.HIP)
+Diags.Report(diag::warn_ignored_hip_only_option)
+<< Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
+
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because
+  // this option was added for compatibility with OpenCL 1.0.
+  if (Args.getLastArg(OPT_cl_strict_aliasing) && LangOpts.OpenCLVersion > 100)
+Diags.Report(diag::warn_option_invalid_ocl_version)
+<< LangOpts.getOpenCLVersionTuple().getAsString()
+<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
+
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
 auto DefaultCC = LangOpts.getDefaultCallingConv();
 
@@ -2008,8 +2024,6 @@
 Opts.AltiVec = 0;
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FPM_On);
-Opts.NativeHalfType = 1;
-Opts.NativeHalfArgsAndReturns = 1;
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
 
 // Include default header file for OpenCL.
@@ -2041,10 +2055,6 @@
   }
 
   Opts.RenderScript = IK.getLanguage() == Language::RenderScript;
-  if (Opts.RenderScript) {
-Opts.NativeHalfType = 1;
-Opts.NativeHalfArgsAndReturns = 1;
-  }
 
   // OpenCL and C++ both have bool, true, false keywords.
   Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
@@ -2240,38 +2250,9 @@
 }
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
-  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
-  // This option should be deprecated for CL > 1.0 because
-  // this option was added for compatibility with OpenCL 1.0.
-  if (Args.getLastArg(OPT_cl_strict_aliasing)
-   && Opts.OpenCLVersion > 100) {
-Diags.Report(diag::warn_option_invalid_ocl_version)
-<< Opts.getOpenCLVersionTuple().getAsString()
-<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
-  }
-
   if (Args.hasArg(OPT_fno_operator_names))
 Opts.CXXOperatorNames = 0;
 
-  if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
-Opts.CUDADeviceApproxTranscendentals = 1;
-
-  if (Args.hasArg(OPT_fgpu_allow_device_init)) {
-if (Opts.HIP)
-  Opts.GPUAllowDeviceInit = 1;
-else
-  Diags.Report(diag::warn_ignored_hip_only_option)
-  << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
-  }
-  if (Opts.HIP)
-Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
-Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
-  else if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ))
-Diags.Report(diag::warn_ignored_hip_only_option)
-<< Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
-
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
@@ -2432,12 +2413,6 @@
 Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.XLPragmaPack = Args.hasArg(OPT_fxl_pragma_pack);
   llvm::sort(Opts.ModuleFeatures);
-  Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
-  Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
-  // Enable HalfArgsAndReturns if present in Args or if NativeHalfArgsAndReturns
-  // is enabled.
-  Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns)
-| Opts.NativeHalfArgsAndReturns;
 
   Opts.ArmSveVectorBits =
   getLastArgIntValue(Args, options::OPT_msve_vector_bits_EQ, 0, Diags);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -438,6 +438,8 @@
 defvar c99 = LangOpts<"C99">;
 defvar lang_std = LangOpts<"LangStd">;
 defvar open_cl = LangOpts<"OpenCL">;
+defvar render_script = LangOpts<"RenderScript">;
+defvar hip = LangOpts<"HIP">;
 defvar gnu_mode = LangOpts<"GNUMode">;
 
 defvar std = !strconcat("LangStandard::getLangStandardForKi

[PATCH] D95348: [clang][cli] Port OpenMP-related LangOpts to marshalling system

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: dang, guansong, yaxunl.
jansvoboda11 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Port some OpenMP-related language options to the marshalling system for 
automatic command line parsing and generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95348

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
@@ -477,6 +477,12 @@
   << A->getSpelling() << T.getTriple();
   }
 
+  // Report if OpenMP host file does not exist.
+  if (!LangOpts.OMPHostIRFile.empty() &&
+  !llvm::sys::fs::exists(LangOpts.OMPHostIRFile))
+Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
+<< LangOpts.OMPHostIRFile;
+
   if (!CodeGenOpts.ProfileRemappingFile.empty() && 
CodeGenOpts.LegacyPassManager)
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
@@ -2369,13 +2375,6 @@
   bool IsSimdSpecified =
   Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
/*Default=*/false);
-  Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
-  Opts.OpenMPUseTLS =
-  Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
-  Opts.OpenMPIsDevice =
-  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
-  Opts.OpenMPIRBuilder =
-  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder);
   bool IsTargetSpecified =
   Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ);
 
@@ -2449,15 +2448,6 @@
 }
   }
 
-  // Get OpenMP host file path if any and report if a non existent file is
-  // found
-  if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
-Opts.OMPHostIRFile = A->getValue();
-if (!llvm::sys::fs::exists(Opts.OMPHostIRFile))
-  Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
-  << Opts.OMPHostIRFile;
-  }
-
   // Set CUDA mode for OpenMP target NVPTX/AMDGCN if specified in options
   Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2141,18 +2141,24 @@
 def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+  MarshallingInfoNegativeFlag, !strconcat("(bool)", 
fopenmp.KeyPath)>,
+  ShouldParseIf;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[NoXarchOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
+defm openmp_simd : BoolFOption<"openmp-simd",
+  LangOpts<"OpenMPSimd">, DefaultFalse,
+  PosFlag,
+  NegFlag, BothFlags<[CC1Option, NoArgumentUnused]>>,
+  ShouldParseIf;
 def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
-  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
-def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">,
+  MarshallingInfoFlag>,
+  ShouldParseIf;
 def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group,
@@ -5351,9 +5357,12 @@
 
//===--===//
 
 def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
-  HelpText<"Generate code only for an OpenMP target device.">;
+  HelpText<"Generate code only for an OpenMP target device.">,
+  MarshallingInfoFlag>,
+  ShouldParseIf;
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
- 

[clang] b16fb1f - Revert "[clang] Fix signedness in vector bitcast evaluation"

2021-01-25 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-01-25T12:43:30Z
New Revision: b16fb1ffc3ceebdff1f570668e73f257d7f7e499

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

LOG: Revert "[clang] Fix signedness in vector bitcast evaluation"

This reverts commit 14947cd04701d923a57a0161fd1967b81e00ff5e because
it broke clang-cmake-armv7-quick.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenOpenCL/vector_literals.cl

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c1973720e49a..56181bbe1166 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10193,7 +10193,7 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr 
*E) {
   Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
 else
   Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
-Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(;
+Elts.push_back(APValue(APSInt(Elt, EltTy->isSignedIntegerType(;
   }
 } else {
   return Error(E);

diff  --git a/clang/test/CodeGenOpenCL/vector_literals.cl 
b/clang/test/CodeGenOpenCL/vector_literals.cl
index 3115aef2b50a..af571714368e 100644
--- a/clang/test/CodeGenOpenCL/vector_literals.cl
+++ b/clang/test/CodeGenOpenCL/vector_literals.cl
@@ -63,10 +63,3 @@ void vector_literals_valid() {
   //CHECK: store <4 x float> , <4 x float>* %V2
   float4 V2 = (float4)(1);
 }
-
-void vector_literals_with_cast() {
-  // CHECK-LABEL: vector_literals_with_cast
-  // CHECK: store <2 x i32> , <2 x i32>*
-  // CHECK: extractelement <2 x i32> %{{[0-9]+}}, i64 0
-  unsigned int withCast = ((int2)((int2)(12, 34))).s0;
-}



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


[PATCH] D95338: [clangd] FindTarget resolves base specifier

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 318968.
njames93 added a comment.

Remove unintended formatting change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95338

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -230,6 +230,24 @@
{"void waldo()"});
 }
 
+TEST_F(TargetDeclTest, BaseSpecifier) {
+  Code = R"cpp(
+struct X {};
+struct Y : [[private]] X {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : [[private X]] {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : private [[X]] {};
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct X");
+}
+
 TEST_F(TargetDeclTest, ConstructorInitList) {
   Code = R"cpp(
 struct X {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -710,7 +710,8 @@
 Finder.add(CCI, Flags);
   else if (const TemplateArgumentLoc *TAL = N.get())
 Finder.add(TAL->getArgument(), Flags);
-
+  else if (const CXXBaseSpecifier *CBS = N.get())
+Finder.add(CBS->getTypeSourceInfo()->getType(), Flags);
   return Finder.takeDecls();
 }
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -230,6 +230,24 @@
{"void waldo()"});
 }
 
+TEST_F(TargetDeclTest, BaseSpecifier) {
+  Code = R"cpp(
+struct X {};
+struct Y : [[private]] X {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : [[private X]] {};
+  )cpp";
+  EXPECT_DECLS("CXXBaseSpecifier", "struct X");
+  Code = R"cpp(
+struct X {};
+struct Y : private [[X]] {};
+  )cpp";
+  EXPECT_DECLS("RecordTypeLoc", "struct X");
+}
+
 TEST_F(TargetDeclTest, ConstructorInitList) {
   Code = R"cpp(
 struct X {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -710,7 +710,8 @@
 Finder.add(CCI, Flags);
   else if (const TemplateArgumentLoc *TAL = N.get())
 Finder.add(TAL->getArgument(), Flags);
-
+  else if (const CXXBaseSpecifier *CBS = N.get())
+Finder.add(CBS->getTypeSourceInfo()->getType(), Flags);
   return Finder.takeDecls();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 318970.
jansvoboda11 added a comment.

Preserve pointer identity when round-tripping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -90,11 +90,22 @@
 }
 
 std::vector ArgList::getAllArgValues(OptSpecifier Id) const {
+  recordQueriedOpts(Id);
   SmallVector Values;
   AddAllArgValues(Values, Id);
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+   const DenseSet &ExcludeIds) const {
+  for (const Arg *Arg : *this) {
+if (!ExcludeIds.contains(Arg->getOption().getID())) {
+  Arg->claim();
+  Arg->render(*this, Output);
+}
+  }
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -137,6 +137,16 @@
   /// The first and last index of each different OptSpecifier ID.
   DenseMap OptRanges;
 
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+
+  /// Record the queried OptSpecifiers.
+  template 
+  void recordQueriedOpts(OptSpecifiers... Ids) const {
+SmallVector OptsSpecifiers({toOptSpecifier(Ids).getID()...});
+QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
+  }
+
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
   OptRange getRange(std::initializer_list Ids) const;
@@ -203,6 +213,7 @@
   template
   iterator_range>
   filtered(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.begin() + Range.first;
 auto E = Args.begin() + Range.second;
@@ -214,6 +225,7 @@
   template
   iterator_range>
   filtered_reverse(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.rend() - Range.second;
 auto E = Args.rend() - Range.first;
@@ -308,6 +320,10 @@
   A->render(*this, Output);
   }
 
+  /// AddAllArgsExcept - Render all arguments not matching any of the excluded
+  /// ids.
+  void AddAllArgsExcept(ArgStringList &Output,
+const DenseSet &ExcludeIds) const;
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
   void AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids,
@@ -342,6 +358,9 @@
   ///
   void ClaimAllArgs() const;
 
+  /// Return the OptSpecifiers queried from this argument list.
+  const DenseSet &getQueriedOpts() const { return QueriedOpts; }
+
   /// @}
   /// @name Arg Synthesis
   /// @{
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -48,10 +48,13 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -151,10 +154,10 @@
 /// unnecessary template instantiations and just ignore it with a variadic
 /// argument.
 static void denormalizeSimpleFlag(SmallVectorImpl &Args,
-  const char *Spelling,
-  CompilerInvocation::StringAllocator,
+  Twine Spelling,
+  CompilerInvocation::StringAllocator SA,
   Option::OptionClass, unsigned, /*T*/...) {
-  Args.push_back(Spelling);
+  Args.push_back(SA(Spelling));
 }
 
 template  static constexpr bool is_uint64_t_convertible() {
@@ -201,18 +204,18 @@
 }
 
 static void denormalizeStringImpl(SmallVectorImpl &Args,
-  const char *Spelling,
+  Twine Spelling,
   CompilerInvocation::StringAlloc

[PATCH] D95349: [clangd] Allow diagnostics to be suppressed with configuration

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

This has been specifically requested:

  https://github.com/clangd/vscode-clangd/issues/114

and various issues can be addressed with this as a workaround, e.g.:

  https://github.com/clangd/clangd/issues/662


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95349

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Config.h"
 #include "Diagnostics.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
@@ -16,6 +17,7 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "index/MemIndex.h"
+#include "support/Context.h"
 #include "support/Path.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticSema.h"
@@ -371,6 +373,28 @@
   DiagSource(Diag::ClangTidy), DiagName("modernize-loop-convert";
 }
 
+TEST(DiagnosticTest, RespectsDiagnosticConfig) {
+  Annotations Main(R"cpp(
+// error-ok
+void x() {
+  [[unknown]]();
+  $ret[[return]] 42;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Main.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(), "use of undeclared identifier 'unknown'"),
+  Diag(Main.range("ret"),
+   "void function 'x' should not return a value")));
+  Config Cfg;
+  Cfg.Diagnostics.Suppress.insert("return-type");
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(),
+   "use of undeclared identifier 'unknown'")));
+}
+
 TEST(DiagnosticTest, ClangTidySuppressionComment) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -98,7 +98,7 @@
 YAML.range());
 }
 
-TEST(ParseYAML, Diagnostics) {
+TEST(ParseYAML, ConfigDiagnostics) {
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
 If:
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -11,6 +11,7 @@
 #include "ConfigTesting.h"
 #include "Features.inc"
 #include "TestFS.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,7 @@
 using ::testing::IsEmpty;
 using ::testing::SizeIs;
 using ::testing::StartsWith;
+using ::testing::UnorderedElementsAre;
 
 class ConfigCompileTests : public ::testing::Test {
 protected:
@@ -183,6 +185,39 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticSuppression) {
+  Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
+  Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
+  Frag.Diagnostics.Suppress.emplace_back("-Wunused-variable");
+  Frag.Diagnostics.Suppress.emplace_back("typecheck_bool_condition");
+  Frag.Diagnostics.Suppress.emplace_back("err_unexpected_friend");
+  Frag.Diagnostics.Suppress.emplace_back("warn_alloca");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_THAT(Conf.Diagnostics.Suppress.keys(),
+  UnorderedElementsAre("bugprone-use-after-move",
+   "unreachable-code", "unused-variable",
+   "typecheck_bool_condition",
+   "unexpected_friend", "warn_alloca"));
+  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable,
+Conf.Diagnostics.Suppress));
+  // Subcategory not respected/suppressed.
+  EXPECT_FALSE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable_break,
+ Conf.Diagnostics.Suppress));
+  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::war

[clang-tools-extra] d6d36ba - Add a --use-color option to clang-query to allow forcing the behavior

2021-01-25 Thread Aaron Ballman via cfe-commits

Author: Tom Ritter
Date: 2021-01-25T08:06:54-05:00
New Revision: d6d36baa33e76ace11ac20c03de1097d48bd9246

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

LOG: Add a --use-color option to clang-query to allow forcing the behavior

D62056 makes the output color if clang auto-detects a tty, but if it
does not, there is no way to force it to use colors anyway.

This patch adjusts the command-lines given to ClangTool which will
force color on or off if --use-color is specified.

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index ca2a285e9eb7..e33612a2e16d 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -156,8 +156,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   const ASTContext &Ctx = AST->getASTContext();
-  const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
+  ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);
   Dumper.Visit(BI->second);
   OS << "\n";

diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 31c7f12251c9..45a355073945 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -49,6 +49,14 @@ using namespace llvm;
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 static cl::OptionCategory ClangQueryCategory("clang-query options");
 
+static cl::opt
+UseColor("use-color",
+ cl::desc(
+ R"(Use colors in detailed AST output. If not set, colors
+will be used if the terminal connected to
+standard output supports colors.)"),
+ cl::init(false), cl::cat(ClangQueryCategory));
+
 static cl::list Commands("c", cl::desc("Specify command to run"),
   cl::value_desc("command"),
   cl::cat(ClangQueryCategory));
@@ -109,6 +117,19 @@ int main(int argc, const char **argv) {
 
   ClangTool Tool(OptionsParser->getCompilations(),
  OptionsParser->getSourcePathList());
+
+  if (UseColor.getNumOccurrences() > 0) {
+ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, 
StringRef /*unused*/) {
+  CommandLineArguments AdjustedArgs = Args;
+  if (UseColor)
+AdjustedArgs.push_back("-fdiagnostics-color");
+  else
+AdjustedArgs.push_back("-fno-diagnostics-color");
+  return AdjustedArgs;
+};
+Tool.appendArgumentsAdjuster(colorAdjustor);
+  }
+
   std::vector> ASTs;
   int ASTStatus = 0;
   switch (Tool.buildASTs(ASTs)) {



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


[PATCH] D94624: PATCH] [clang-query] Add a --use-color option to clang-query to allow forcing the behavior

2021-01-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D94624#2516540 , @tomrittervg wrote:

> Try rebasing it...

Thanks, that was sufficient for me to apply it. I've commit on your behalf in 
d6d36baa33e76ace11ac20c03de1097d48bd9246 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94624

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 318975.
jansvoboda11 added a comment.

Undo changes to string allocation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -90,11 +90,22 @@
 }
 
 std::vector ArgList::getAllArgValues(OptSpecifier Id) const {
+  recordQueriedOpts(Id);
   SmallVector Values;
   AddAllArgValues(Values, Id);
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+   const DenseSet &ExcludeIds) const {
+  for (const Arg *Arg : *this) {
+if (!ExcludeIds.contains(Arg->getOption().getID())) {
+  Arg->claim();
+  Arg->render(*this, Output);
+}
+  }
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -137,6 +137,16 @@
   /// The first and last index of each different OptSpecifier ID.
   DenseMap OptRanges;
 
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+
+  /// Record the queried OptSpecifiers.
+  template 
+  void recordQueriedOpts(OptSpecifiers... Ids) const {
+SmallVector OptsSpecifiers({toOptSpecifier(Ids).getID()...});
+QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
+  }
+
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
   OptRange getRange(std::initializer_list Ids) const;
@@ -203,6 +213,7 @@
   template
   iterator_range>
   filtered(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.begin() + Range.first;
 auto E = Args.begin() + Range.second;
@@ -214,6 +225,7 @@
   template
   iterator_range>
   filtered_reverse(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.rend() - Range.second;
 auto E = Args.rend() - Range.first;
@@ -308,6 +320,10 @@
   A->render(*this, Output);
   }
 
+  /// AddAllArgsExcept - Render all arguments not matching any of the excluded
+  /// ids.
+  void AddAllArgsExcept(ArgStringList &Output,
+const DenseSet &ExcludeIds) const;
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
   void AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids,
@@ -342,6 +358,9 @@
   ///
   void ClaimAllArgs() const;
 
+  /// Return the OptSpecifiers queried from this argument list.
+  const DenseSet &getQueriedOpts() const { return QueriedOpts; }
+
   /// @}
   /// @name Arg Synthesis
   /// @{
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -48,10 +48,13 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -204,7 +207,7 @@
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
   Option::OptionClass OptClass, unsigned,
-  Twine Value) {
+  const Twine &Value) {
   switch (OptClass) {
   case Option::SeparateClass:
   case Option::JoinedOrSeparateClass:
@@ -523,9 +526,88 @@
   return 0;
 }
 
-static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
-  static const OptTable &OptTable = getDriverOptTable();
-  return OptTable.getOption(OptSpecifier).getPrefixedName();
+static void GenerateArg(SmallVectorImpl &Args,
+llvm::opt::OptSpecifier OptSpecifier,
+CompilerInvocation::StringAllocator SA) {
+  Option Opt = getDriverOptTable().getOption(OptSpecifier);
+  deno

[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D95307#2519309 , @RedDocMD wrote:

> Funnily enough, when I run `ninja clang-check` I don't get any errors.

I believe that `ninja check-clang` is the right command (clang-check is a tool) 
:-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D94986: Remove requirement for -maltivec to be used when using -mabi=vec-extabi or -mabi=vec-default when not using vector code

2021-01-25 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 318971.
ZarkoCA marked an inline comment as done.
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.

- Emit error message only when option is active
- Changed description of patch


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

https://reviews.llvm.org/D94986

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/altivec.c


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -2,23 +2,17 @@
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpcle-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang_cc1 -target-feature +altivec -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-LE
-// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
-// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple 
powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple 
powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
- 
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 2>&1 
| FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 
2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -mabi=vec-default -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target 
powerpc64-unknown-aix %s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc-unknown-aix %s 2>&1  | 
FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-default -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
-// RUN: not %clang -S -mabi=vec-extabi -target powerpc64-unknown-aix %s 2>&1  
| FileCheck  %s --check-prefix=AIX-ATVER
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 
-triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 
-triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
+// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+
+// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
+// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 
-triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
+// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 
-triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
 // Check initialization
 
 vector int test0 = (vector int)(1);   // CHECK: @test0 ={{.*}} global <4 x 
i32> 
@@ -63,4 +57,

[clang] 84851a2 - Revert "[SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued"

2021-01-25 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-01-25T08:29:38-05:00
New Revision: 84851a274e2beaa3cdafd6a70e6d1128cabf8b21

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

LOG: Revert "[SystemZ][z/OS] Fix No such file or directory expression error 
matching in lit tests - continued"

This reverts commit 520b5ecf856152f35ee38207eec39f5674dd2bd4.

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler.c
clang/test/Frontend/output-failures.c
llvm/test/Object/archive-extract-dir.test
llvm/test/Object/archive-extract.test
llvm/test/Object/directory.ll
llvm/test/tools/llvm-ar/error-opening-directory.test
llvm/test/tools/llvm-ar/move.test
llvm/test/tools/llvm-ar/print.test
llvm/test/tools/llvm-ar/quick-append.test
llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
llvm/test/tools/llvm-lipo/create-arch.test
llvm/test/tools/llvm-lipo/replace-invalid-input.test
llvm/test/tools/llvm-lto/error.ll
llvm/test/tools/llvm-objcopy/wasm/dump-section.test
llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index f7428d7f02f4..3e1fab25d754 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -72,7 +72,7 @@
 
 // RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2.notexist -outputs=%t.bundle.i 2>&1 | FileCheck %s 
-DFILE=%t.tgt2.notexist --check-prefix CK-ERR5
 // RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | 
FileCheck %s -DFILE=%t.bundle.i.notexist --check-prefix CK-ERR5
-// CK-ERR5: error: '[[FILE]]': {{.*}}{{N|n}}o such file or directory
+// CK-ERR5: error: '[[FILE]]': {{N|n}}o such file or directory
 
 // RUN: not clang-offload-bundler -type=invalid 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s 
-DTYPE=invalid --check-prefix CK-ERR6
 // CK-ERR6: error: '[[TYPE]]': invalid file type specified

diff  --git a/clang/test/Frontend/output-failures.c 
b/clang/test/Frontend/output-failures.c
index 26d25fdbef36..0e9ea63f8067 100644
--- a/clang/test/Frontend/output-failures.c
+++ b/clang/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
 // RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
-// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{.*}}{{[nN]}}o such file or 
directory{{.*}}'
+// OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'

diff  --git a/llvm/test/Object/archive-extract-dir.test 
b/llvm/test/Object/archive-extract-dir.test
index d6a721c090b3..5182a2f91411 100644
--- a/llvm/test/Object/archive-extract-dir.test
+++ b/llvm/test/Object/archive-extract-dir.test
@@ -8,4 +8,4 @@ RUN: rm foo
 RUN: mkdir foo
 RUN: not llvm-ar x test.a foo 2>&1 | FileCheck %s
 
-CHECK: foo: {{.*}}{{[Ii]}}s a directory{{.*}}
+CHECK: foo: {{[Ii]}}s a directory

diff  --git a/llvm/test/Object/archive-extract.test 
b/llvm/test/Object/archive-extract.test
index 589e8b8fe856..11ca12e3353b 100644
--- a/llvm/test/Object/archive-extract.test
+++ b/llvm/test/Object/archive-extract.test
@@ -58,4 +58,4 @@ RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s 
--check-prefix=EVENLEN
 EVENLEN: evenlen
 
 RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s 
--check-prefix=MISSING
-MISSING: error: {{.*}}{{N|n}}o such file or directory
+MISSING: error: {{N|n}}o such file or directory

diff  --git a/llvm/test/Object/directory.ll b/llvm/test/Object/directory.ll
index d9e340a587b1..3e9ac2ce202e 100644
--- a/llvm/test/Object/directory.ll
+++ b/llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
 ;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{.*}}{{I|i}}s a directory{{.*}}
+;CHECK: .: {{I|i}}s a directory
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name

diff  --git a/llvm/test/tools/llvm-ar/error-opening-directory.test 
b/llvm/test/tools/llvm-ar/error-opening-directory.test
index 5a6491bd29c8..c3068871230f 100644
--- a/llvm/test/tools/llvm-ar/error-opening-directory.test
+++ b/llvm/test/tools/llvm-ar/error-opening-directory.test
@@ -9,4 +9,4 @@
 # RUN: not llvm-ar p %t/tmpDir 2>&1 | \
 # RUN:FileCheck %s --check-prefix=IS-DIR -DARCHIVE=%t/tmpDir

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan reopened this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

In D95246#2518989 , @jhenderson wrote:

> Sorry, could you revert this please. I don't think this is a good fix, as 
> you've reduced coverage within the test, and some changes are completly 
> redundant/add extra noise. I've commented inline with examples. Skimming 
> D94239  suggests that has the same issue.
>
> Could you also please explain the messages your system is actually producing 
> so we can provide a better solution than this fix.
>
> I'm also concerned that you are doing this to fix this test for a system, yet 
> there are no build bots that report this error. A future contributor is 
> likely to break them in the same way/add new tests with the same issue. If 
> your system is a system that is supposed to be supported by LLVM, there needs 
> to be a build bot. If it isn't supported, you should bring this up on 
> llvm-dev (if you haven't already) to get buy-in for support.

Thanks for the feedback. I've reverted my changes from these two patches. We 
have indicated that we wish to add support for the z/OS platform but we have 
not set up a buildbot yet.

In D95246#2519086 , @grimar wrote:

> As far I understand, looking on the description of D94239 
> , the message on z/OS looks like "EDC5129I 
> No such file or directory.".
> I guess the `EDC5129I` is a stable error code? So why not to check for a 
> possible `EDC5129I` prefix word instead of `.*`?
> (The same applies for other possible errors)

As grimar noted, this is indeed the correct error message.  "EDC5129I No such 
file or directory." (Note the extra period at the end)
Based on your feedback, these are the better alternatives that were suggested:

  '{{.*N|n}}o such file or directory'

  {{EDC5129I N|N|n}}o such file or directory'

Some testcases fail because of the extra period at the end. For those 
testcases, this is a possible alternative.

  {{.*N|n}}o such file or directory{{\.?}}

Please let me know if there are better alternatives I could look into.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal

> Why don't you use the `SValVisitor` instead?

I simply didn't know of its exsistence. We can try to transform this patch 
using `SValVisitor` in the next revision to make the review easier and avoid 
additional complexity.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:105-126
+  SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(UndefinedVal V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(UnknownVal V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(Loc V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(NonLoc V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastSubKind(loc::ConcreteInt V, QualType CastTy,
+   QualType OriginalTy);

steakhal wrote:
> Why are all of these `public`?
> I would expect only the first overload to be public.
Great catch. I'll do it.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:647-650
+  // Array to pointer.
+  if (isa(OriginalTy))
+if (CastTy->isPointerType() || CastTy->isReferenceType())
   return UnknownVal();

steakhal wrote:
> Arrays decay to a pointer to the first element, but in this case, you return 
> `Unknown`.
> Why?
This is just how `evalCast` worked before the patch. I didn't think of why. 
I've just tried to replicate previous cast logic. If I'd change anything, you'd 
catch a bunch of differences in CodeChecker. That's what I didn't want the most.




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:680-681
+
+  // Try to cast to array
+  const auto *arrayT = dyn_cast(OriginalTy.getCanonicalType());
+

steakhal wrote:
> nit
Thanks! I'll check all for the naming rules.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:765-769
+  auto castedValue = [V, CastTy, this]() {
+llvm::APSInt value = V.getValue();
+BasicVals.getAPSIntType(CastTy).apply(value);
+return value;
+  };

steakhal wrote:
> Just call immediately that lambda and assign that value to a `const 
> llvm::APSInt CastedValue`.
I just wanted to make this lazy. Otherwise this set of calls will be invoked 
unnecessarily in some cases. I'd prefer to leave it as it is.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:844-847
+  // Symbol to bool.
+  if (CastTy->isBooleanType()) {
+// Non-float(presumably) to bool.
+if (Loc::isLocType(OriginalTy) ||

steakhal wrote:
> Presumably what?
We assume that this condition presents a type which is opposite to `float` (aka 
`non-float`). But it may happen that it is also opposite to some other types. 
So naming it `non-float` could be a bit incomplete and we are dealing with some 
other type. Yes, I feel this embarrassing. I'll remove `(presumably)`.


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

https://reviews.llvm.org/D90157

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


[PATCH] D95145: [clang] Fix a nullptr dereference bug on invalid code

2021-01-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks.




Comment at: clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp:2
+// RUN: %clang -fsyntax-only -std=c++17 %s -Xclang -verify
+#include 
+

adamcz wrote:
> adamcz wrote:
> > hokein wrote:
> > > A common practice is to avoid depending on STL in tests. I think we need 
> > > to pull out (even simplify?) std::result_of implementation if it is 
> > > needed for reproducing the crash.
> > I've noticed that pattern, but can't tell why this is. Is it documented 
> > somewhere?
> > 
> Anyway, I updated the change to not require type_traits. Turned out to be 
> simpler than expected ;-)
> I've noticed that pattern, but can't tell why this is. Is it documented 
> somewhere?

I did try to find some documentation about this before making the previous 
comment, but didn't find any.

Depending on the clang builtin includes is legitimate, but depending on the 
stand library is more complicated, it would hurt hermeticity of the test -- you 
may not always get the exact behavior you intend to test (as it may depend on 
the stand library versions, host environment etc).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95145

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


[PATCH] D95057: [clangd] Allow configuration database to be specified in config.

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 318980.
sammccall marked 4 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95057

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -8,6 +8,7 @@
 
 #include "GlobalCompilationDatabase.h"
 
+#include "Config.h"
 #include "Matchers.h"
 #include "TestFS.h"
 #include "support/Path.h"
@@ -205,10 +206,12 @@
   llvm::formatv(CDBOuter, llvm::sys::path::convert_to_slash(testRoot()));
   FS.Files[testPath("build/compile_commands.json")] =
   llvm::formatv(CDBInner, llvm::sys::path::convert_to_slash(testRoot()));
+  FS.Files[testPath("foo/compile_flags.txt")] = "-DFOO";
 
   // Note that gen2.cc goes missing with our following model, not sure this
   // happens in practice though.
   {
+SCOPED_TRACE("Default ancestor scanning");
 DirectoryBasedGlobalCompilationDatabase DB(FS);
 std::vector DiscoveredFiles;
 auto Sub =
@@ -227,8 +230,53 @@
 EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("gen.cc")));
   }
 
-  // With a custom compile commands dir.
   {
+SCOPED_TRACE("With config");
+DirectoryBasedGlobalCompilationDatabase::Options Opts(FS);
+Opts.ContextProvider = [&](llvm::StringRef Path) {
+  Config Cfg;
+  if (Path.endswith("a.cc")) {
+// a.cc uses another directory's CDB, so it won't be discovered.
+Cfg.CompileFlags.CDBSearch.Policy = Config::CDBSearchSpec::FixedDir;
+Cfg.CompileFlags.CDBSearch.FixedCDBPath = testPath("foo");
+  } else if (Path.endswith("gen.cc")) {
+// gen.cc has CDB search disabled, so it won't be discovered.
+Cfg.CompileFlags.CDBSearch.Policy = Config::CDBSearchSpec::NoCDBSearch;
+  } else if (Path.endswith("gen2.cc")) {
+// gen2.cc explicitly lists this directory, so it will be discovered.
+Cfg.CompileFlags.CDBSearch.Policy = Config::CDBSearchSpec::FixedDir;
+Cfg.CompileFlags.CDBSearch.FixedCDBPath = testRoot();
+  }
+  return Context::current().derive(Config::Key, std::move(Cfg));
+};
+DirectoryBasedGlobalCompilationDatabase DB(Opts);
+std::vector DiscoveredFiles;
+auto Sub =
+DB.watch([&DiscoveredFiles](const std::vector Changes) {
+  DiscoveredFiles = Changes;
+});
+
+// Does not use the root CDB, so no broadcast.
+auto Cmd = DB.getCompileCommand(testPath("build/../a.cc"));
+ASSERT_TRUE(Cmd.hasValue());
+EXPECT_THAT(Cmd->CommandLine, Contains("-DFOO")) << "a.cc uses foo/ CDB";
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
+EXPECT_THAT(DiscoveredFiles, IsEmpty()) << "Root CDB not discovered yet";
+
+// No special config for b.cc, so we trigger broadcast of the root CDB.
+DB.getCompileCommand(testPath("b.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
+EXPECT_THAT(DiscoveredFiles, ElementsAre(testPath("build/gen2.cc")));
+DiscoveredFiles.clear();
+
+// No CDB search so no discovery/broadcast triggered for build/ CDB.
+DB.getCompileCommand(testPath("build/gen.cc"));
+ASSERT_TRUE(DB.blockUntilIdle(timeoutSeconds(10)));
+EXPECT_THAT(DiscoveredFiles, IsEmpty());
+  }
+
+  {
+SCOPED_TRACE("With custom compile commands dir");
 DirectoryBasedGlobalCompilationDatabase::Options Opts(FS);
 Opts.CompileCommandsDir = testRoot();
 DirectoryBasedGlobalCompilationDatabase DB(Opts);
@@ -294,6 +342,58 @@
   EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
 }
 
+MATCHER_P(hasArg, Flag, "") {
+  if (!arg.hasValue()) {
+*result_listener << "command is null";
+return false;
+  }
+  if (!llvm::is_contained(arg->CommandLine, Flag)) {
+*result_listener << "flags are " << llvm::join(arg->CommandLine, " ");
+return false;
+  }
+  return true;
+}
+
+TEST(GlobalCompilationDatabaseTest, Config) {
+  MockFS FS;
+  FS.Files[testPath("x/compile_flags.txt")] = "-DX";
+  FS.Files[testPath("x/y/z/compile_flags.txt")] = "-DZ";
+
+  Config::CDBSearchSpec Spec;
+  DirectoryBasedGlobalCompilationDatabase::Options Opts(FS);
+  Opts.ContextProvider = [&](llvm::StringRef Path) {
+Config

[PATCH] D95057: [clangd] Allow configuration database to be specified in config.

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D95057#2518903 , @kadircet wrote:

> I believe we should log some warning at startup if user has provided 
> `--compile-commands-dir`. Saying that "CDB search customizations through 
> config is disabled".

So I considered this, but it depends on what we want the eventual interaction 
of flags and config to be.

A) if we're going to eliminate any flags that overlap with config, the message 
should say the flag is deprecated
B) if config is going to override flags, the message should say that the flag 
overrides config for now but this will change
C) if flags are going to override config, I don't think we should log a message 
when any such flag is used...

Personally I lean toward C and so don't want to log. I realize that there's 
legacy users of this flag that may not know the alternative, but equally there 
are future users of this flag that will be not-helped by such a log message.




Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:267
+  llvm::Optional Spec;
+  if (**F.CompilationDatabase == "Ancestors") {
+Spec.emplace();

kadircet wrote:
> i hope no one tries to put their CDBs in a directory named Ancestors/None :)))
> 
> (it is definitely better than breaking any project with a top-level directory 
> named Ancestors/None)
Haha, yes... you could always write ./Ancestors then, I suppose.

(Obviously we can work around this with a more complicated structure... but I'm 
not sure it's a good trade)



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:278
+  // Drop trailing slash to put the path in canonical form.
+  // Should makeAbsolute do this?
+  llvm::StringRef Rel = llvm::sys::path::relative_path(*Path);

kadircet wrote:
> +1 i think it should.
Right... the reason I didn't make the change in this patch is that it affected 
MountPoint of indexes, and there were tests of that, and code using starts_with 
in a way that suggested it might be important.

So we should clean this up somehow, but I didn't want to bite it off here.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:617
+Child->Parent = &Info;
+  // Keep walking, whether we inserted or not, if parent link is missing.
+  // (If it's present, parent links must be present up to the root, so 
stop)

kadircet wrote:
> missing a `Child = &Info;` ?
Nice catch, I guess I didn't have enough levels in my tests...



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:650
+  DirValues[I]->Cache = DirCaches[I];
+  if (DirCaches[I] == ThisCache)
+DirValues[I]->State = DirInfo::TargetCDB;

kadircet wrote:
> nit: `DirValues[I]->State = DirCaches[I] == ThisCache ? DirInfo::TargetCDB : 
> DirInfo::Unknown;`, to reduce branching.
This seems less clear to me, the branch is fairly predictable, and this 
function is pretty cold - I'd rather keep init as is for readability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95057

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2519642 , 
@abhina.sreeskantharajan wrote:

> In D95246#2518989 , @jhenderson 
> wrote:
>
>> Sorry, could you revert this please. I don't think this is a good fix, as 
>> you've reduced coverage within the test, and some changes are completly 
>> redundant/add extra noise. I've commented inline with examples. Skimming 
>> D94239  suggests that has the same issue.
>>
>> Could you also please explain the messages your system is actually producing 
>> so we can provide a better solution than this fix.
>>
>> I'm also concerned that you are doing this to fix this test for a system, 
>> yet there are no build bots that report this error. A future contributor is 
>> likely to break them in the same way/add new tests with the same issue. If 
>> your system is a system that is supposed to be supported by LLVM, there 
>> needs to be a build bot. If it isn't supported, you should bring this up on 
>> llvm-dev (if you haven't already) to get buy-in for support.
>
> Thanks for the feedback. I've reverted my changes from these two patches. We 
> have indicated that we wish to add support for the z/OS platform but we have 
> not set up a buildbot yet.
>
> In D95246#2519086 , @grimar wrote:
>
>> As far I understand, looking on the description of D94239 
>> , the message on z/OS looks like "EDC5129I 
>> No such file or directory.".
>> I guess the `EDC5129I` is a stable error code? So why not to check for a 
>> possible `EDC5129I` prefix word instead of `.*`?
>> (The same applies for other possible errors)
>
> As grimar noted, this is indeed the correct error message.  "EDC5129I No such 
> file or directory." (Note the extra period at the end)
> Based on your feedback, these are the better alternatives that were suggested:

Slightly off-the-wall idea: I'm assuming you don't control your system in such 
a way that you can change the error message to omit the error code?

>   '{{.*N|n}}o such file or directory'

>   {{EDC5129I N|N|n}}o such file or directory'
>
> Some testcases fail because of the extra period at the end. For those 
> testcases, this is a possible alternative.
>
>   {{.*N|n}}o such file or directory{{\.?}}
>
> Please let me know if there are better alternatives I could look into.

I think you can just omit the trailing full stop in those cases. If the test 
isn't using --match-full-lines, it should be fine. If it is, adding `{{.?}}` 
seems reasonable.

Having the error code explicitly in the pattern looks like the right solution 
for now, but a thought on that - it seems like tests will still have the 
fragility problem for when someone else writes a new test that checks the 
message due to the error code not being present on most systems. Is the error 
code different for each system error message (I'm guessing it is)? I wonder if 
we would be better off adding some sort of lit substitution or similar that 
expands to the right string for the given host OS, which could in turn be fed 
to FileCheck. It might look a bit like this in practice:

  # RUN: not do-a-thing %t 2>&1 | FileCheck %s -DMSG=%enoent -DFILE=%t
  
  # CHECK: error: '[[FILE]]': [[MSG]]

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95145: [clang] Fix a nullptr dereference bug on invalid code

2021-01-25 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd462aa5a619a: [clang] Fix a nullptr dereference bug on 
invalid code (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95145

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp


Index: clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -fsyntax-only -std=c++17 %s -Xclang -verify
+
+// The important part is that we do not crash.
+
+template T declval();
+
+template 
+auto Call(T x) -> decltype(declval()(0)) {} // expected-note{{candidate 
template ignored}}
+
+class Status {};
+
+void fun() {
+  // The Status() (instead of Status) here used to cause a crash.
+  Call([](auto x) -> Status() {}); // expected-error{{function cannot return 
function type 'Status ()}}
+  // expected-error@-1{{no matching function for call to 'Call'}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4189,6 +4189,9 @@
   for (unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
OldIdx != NumOldParams; ++OldIdx) {
 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
+if (!OldParam)
+  return nullptr;
+
 LocalInstantiationScope *Scope = SemaRef.CurrentInstantiationScope;
 
 Optional NumArgumentsInExpansion;


Index: clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -fsyntax-only -std=c++17 %s -Xclang -verify
+
+// The important part is that we do not crash.
+
+template T declval();
+
+template 
+auto Call(T x) -> decltype(declval()(0)) {} // expected-note{{candidate template ignored}}
+
+class Status {};
+
+void fun() {
+  // The Status() (instead of Status) here used to cause a crash.
+  Call([](auto x) -> Status() {}); // expected-error{{function cannot return function type 'Status ()}}
+  // expected-error@-1{{no matching function for call to 'Call'}}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4189,6 +4189,9 @@
   for (unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
OldIdx != NumOldParams; ++OldIdx) {
 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
+if (!OldParam)
+  return nullptr;
+
 LocalInstantiationScope *Scope = SemaRef.CurrentInstantiationScope;
 
 Optional NumArgumentsInExpansion;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d462aa5 - [clang] Fix a nullptr dereference bug on invalid code

2021-01-25 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-01-25T15:02:25+01:00
New Revision: d462aa5a619ab9fdf8b024e48c19bc8820fe8781

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

LOG: [clang] Fix a nullptr dereference bug on invalid code

When working with invalid code, we would try to dereference a nullptr
while deducing template arguments in some dependend code operating on a
lambda with invalid return type.

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

Added: 
clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp

Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d3d6df5e0064..dc1e0ef60cac 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4189,6 +4189,9 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl 
*D,
   for (unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
OldIdx != NumOldParams; ++OldIdx) {
 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
+if (!OldParam)
+  return nullptr;
+
 LocalInstantiationScope *Scope = SemaRef.CurrentInstantiationScope;
 
 Optional NumArgumentsInExpansion;

diff  --git a/clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp 
b/clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
new file mode 100644
index ..c783ff50
--- /dev/null
+++ b/clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -fsyntax-only -std=c++17 %s -Xclang -verify
+
+// The important part is that we do not crash.
+
+template T declval();
+
+template 
+auto Call(T x) -> decltype(declval()(0)) {} // expected-note{{candidate 
template ignored}}
+
+class Status {};
+
+void fun() {
+  // The Status() (instead of Status) here used to cause a crash.
+  Call([](auto x) -> Status() {}); // expected-error{{function cannot return 
function type 'Status ()}}
+  // expected-error@-1{{no matching function for call to 'Call'}}
+}



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


[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:647-650
+  // Array to pointer.
+  if (isa(OriginalTy))
+if (CastTy->isPointerType() || CastTy->isReferenceType())
   return UnknownVal();

ASDenysPetrov wrote:
> steakhal wrote:
> > Arrays decay to a pointer to the first element, but in this case, you 
> > return `Unknown`.
> > Why?
> This is just how `evalCast` worked before the patch. I didn't think of why. 
> I've just tried to replicate previous cast logic. If I'd change anything, 
> you'd catch a bunch of differences in CodeChecker. That's what I didn't want 
> the most.
> 
I agree, you should not change any behavior in this patch.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:765-769
+  auto castedValue = [V, CastTy, this]() {
+llvm::APSInt value = V.getValue();
+BasicVals.getAPSIntType(CastTy).apply(value);
+return value;
+  };

ASDenysPetrov wrote:
> steakhal wrote:
> > Just call immediately that lambda and assign that value to a `const 
> > llvm::APSInt CastedValue`.
> I just wanted to make this lazy. Otherwise this set of calls will be invoked 
> unnecessarily in some cases. I'd prefer to leave it as it is.
Maybe rename it then. What about `GetCastedValue(x)`?


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

https://reviews.llvm.org/D90157

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-25 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2519729 , @jhenderson wrote:

> In D95246#2519642 , 
> @abhina.sreeskantharajan wrote:
>
>> In D95246#2518989 , @jhenderson 
>> wrote:
>>
>>> Sorry, could you revert this please. I don't think this is a good fix, as 
>>> you've reduced coverage within the test, and some changes are completly 
>>> redundant/add extra noise. I've commented inline with examples. Skimming 
>>> D94239  suggests that has the same issue.
>>>
>>> Could you also please explain the messages your system is actually 
>>> producing so we can provide a better solution than this fix.
>>>
>>> I'm also concerned that you are doing this to fix this test for a system, 
>>> yet there are no build bots that report this error. A future contributor is 
>>> likely to break them in the same way/add new tests with the same issue. If 
>>> your system is a system that is supposed to be supported by LLVM, there 
>>> needs to be a build bot. If it isn't supported, you should bring this up on 
>>> llvm-dev (if you haven't already) to get buy-in for support.
>>
>> Thanks for the feedback. I've reverted my changes from these two patches. We 
>> have indicated that we wish to add support for the z/OS platform but we have 
>> not set up a buildbot yet.
>>
>> In D95246#2519086 , @grimar wrote:
>>
>>> As far I understand, looking on the description of D94239 
>>> , the message on z/OS looks like "EDC5129I 
>>> No such file or directory.".
>>> I guess the `EDC5129I` is a stable error code? So why not to check for a 
>>> possible `EDC5129I` prefix word instead of `.*`?
>>> (The same applies for other possible errors)
>>
>> As grimar noted, this is indeed the correct error message.  "EDC5129I No 
>> such file or directory." (Note the extra period at the end)
>> Based on your feedback, these are the better alternatives that were 
>> suggested:
>
> Slightly off-the-wall idea: I'm assuming you don't control your system in 
> such a way that you can change the error message to omit the error code?

Right, I'm not able to change the error message.

>>   '{{.*N|n}}o such file or directory'

>>   {{EDC5129I N|N|n}}o such file or directory'
>>
>> Some testcases fail because of the extra period at the end. For those 
>> testcases, this is a possible alternative.
>>
>>   {{.*N|n}}o such file or directory{{\.?}}
>>
>> Please let me know if there are better alternatives I could look into.
>
> I think you can just omit the trailing full stop in those cases. If the test 
> isn't using --match-full-lines, it should be fine. If it is, adding `{{.?}}` 
> seems reasonable.
>
> Having the error code explicitly in the pattern looks like the right solution 
> for now, but a thought on that - it seems like tests will still have the 
> fragility problem for when someone else writes a new test that checks the 
> message due to the error code not being present on most systems. Is the error 
> code different for each system error message (I'm guessing it is)? I wonder 
> if we would be better off adding some sort of lit substitution or similar 
> that expands to the right string for the given host OS, which could in turn 
> be fed to FileCheck. It might look a bit like this in practice:
>
>   # RUN: not do-a-thing %t 2>&1 | FileCheck %s -DMSG=%enoent -DFILE=%t
>   
>   # CHECK: error: '[[FILE]]': [[MSG]]
>
> What do you think?

I like the lit substitution solution, it will be a lot cleaner compared to a 
complicated regex. I've noticed there are already different regex for the same 
error message so this will help the error messages be uniform as well. I can 
look into implementing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-01-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 318991.
ASDenysPetrov added a comment.

Updated. Naming fixes. Member access changes.


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

https://reviews.llvm.org/D90157

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -530,108 +530,197 @@
   return evalCast(val, castTy, originalTy);
 }
 
-// FIXME: should rewrite according to the cast kind.
-SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
-  castTy = Context.getCanonicalType(castTy);
-  originalTy = Context.getCanonicalType(originalTy);
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-return val;
+//===--===//
+// Cast methods.
+// `evalCast` is the main method
+// `evalCastKind` and `evalCastSubKind` are helpers
+//===--===//
 
-  if (castTy->isBooleanType()) {
-if (val.isUnknownOrUndef())
-  return val;
-if (val.isConstant())
-  return makeTruthVal(!val.isZeroConstant(), castTy);
-if (!Loc::isLocType(originalTy) &&
-!originalTy->isIntegralOrEnumerationType() &&
-!originalTy->isMemberPointerType())
-  return UnknownVal();
-if (SymbolRef Sym = val.getAsSymbol(true)) {
-  BasicValueFactory &BVF = getBasicValueFactory();
-  // FIXME: If we had a state here, we could see if the symbol is known to
-  // be zero, but we don't.
-  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
-}
-// Loc values are not always true, they could be weakly linked functions.
-if (Optional L = val.getAs())
-  return evalCastFromLoc(*L, castTy);
+SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
+  CastTy = Context.getCanonicalType(CastTy);
+  OriginalTy = Context.getCanonicalType(OriginalTy);
+  if (CastTy == OriginalTy)
+return V;
 
-Loc L = val.castAs().getLoc();
-return evalCastFromLoc(L, castTy);
+  // FIXME: Move this check to the most appropriate evalCastKind/evalCastSubKind
+  // function.
+  // For const casts, casts to void, just propagate the value.
+  if (!CastTy->isVariableArrayType() && !OriginalTy->isVariableArrayType())
+if (shouldBeModeledWithNoOp(Context, Context.getPointerType(CastTy),
+Context.getPointerType(OriginalTy)))
+  return V;
+
+  // Cast SVal according to kinds.
+  switch (V.getBaseKind()) {
+  case SVal::UndefinedValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::UnknownValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::LocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::NonLocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // For const casts, casts to void, just propagate the value.
-  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
-if (shouldBeModeledWithNoOp(Context, Context.getPointerType(castTy),
- Context.getPointerType(originalTy)))
-  return val;
+SVal SValBuilder::evalCastKind(UndefinedVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
 
-  // Check for casts from pointers to integers.
-  if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy))
-return evalCastFromLoc(val.castAs(), castTy);
-
-  // Check for casts from integers to pointers.
-  if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) {
-if (Optional LV = val.getAs()) {
-  if (const MemRegion *R = LV->getLoc().getAsRegion()) {
-StoreManager &storeMgr = StateMgr.getStoreManager();
-R = storeMgr.castRegion(R, castTy);
-return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-  }
-  return LV->getLoc();
-}
-return dispatchCast(val, castTy);
+SVal SValBuilder::evalCastKind(UnknownVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
+
+SVal SValBuilder::evalCastKind(Loc V, QualType CastTy, QualType OriginalTy) {
+  switch (V.getSubKind()) {
+  case loc::ConcreteIntKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::GotoLabelKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::MemRegionValKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // Just pass through function and block pointers.
-  if (originalTy->isBlockPointerType() || original

[PATCH] D95349: [clangd] Allow diagnostics to be suppressed with configuration

2021-01-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:808
+llvm::StringRef Code(CodePtr);
+Code.consume_front("err_");
+if (Suppress.contains(Code))

nit: use `normalizeSuppressedCode(Code)`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95349

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


[PATCH] D95057: [clangd] Allow configuration database to be specified in config.

2021-01-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:278
+  // Drop trailing slash to put the path in canonical form.
+  // Should makeAbsolute do this?
+  llvm::StringRef Rel = llvm::sys::path::relative_path(*Path);

sammccall wrote:
> kadircet wrote:
> > +1 i think it should.
> Right... the reason I didn't make the change in this patch is that it 
> affected MountPoint of indexes, and there were tests of that, and code using 
> starts_with in a way that suggested it might be important.
> 
> So we should clean this up somehow, but I didn't want to bite it off here.
SG. As a note to future self, I don't remember the tests but in theory the 
startswith should be fine with and without the trailing slash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95057

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


[PATCH] D94472: [WIP][clang][cli] Command line round-trip for HeaderSearch options

2021-01-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D94472#2508018 , @dexonsmith wrote:

> I have three concerns with the approach:
>
> 1. Churn. This adds a lot of code that will eventually be removed / 
> refactored away. One example is that shifting the `NDEBUG` logic to the 
> driver requires threading a Boolean (or tristate/enum) for round-trip mode 
> through a few layers; once we're finished, we'll end up stripping that 
> argument back out. A second example is that this seems to require splitting 
> up `OPTIONS_WITH_MARSHALLING` for each option. Once this work is finished, 
> someone will need to clean them up / unify them, or maybe they'll 
> unnecessarily stay split / duplicated.

I think the driver command line options could be useful even after we're 
finished, so I'd consider not removing them. For example when working on new 
Clang feature that requires new command line option, one could implement the 
parsing first, temporarily disable round-tripping, implement the feature and 
worry about generation and round-tripping later. I can imagine a situation when 
downstream projects would prefer to prevent round-tripping from the driver 
rather than from within `CompilerInvocation`.

Yes, this requires splitting `OPTIONS_WITH_MARSHALLING`. I don't think it's a 
big deal, because we already do that for `DiagnosticOpts`, `LangOpts` and 
`CodegenOpts` anyway (D84673 , D94682 
). I think it makes more sense to have one 
parsing function per `*Opts`, rather than keeping it split up into `Parse*Opts` 
and `ParseSimpleOpts`.

> 2. Boilerplate. Somewhat related to churn; there's a fair bit of additional 
> boilerplate required in this approach. This makes it harder to read / 
> understand / modify the code.

Boilerplate was added mainly to `ArgList`, but we can delete that without even 
showing up in `git blame`. Another instance is the lambda setup in 
`ParseHeaderSearchArgs`, but I think that's pretty isolated as well. I agree 
the code may be confusing for people not familiar with this effort, but it will 
be me deleting the code few weeks from now, so I'm not sure how bad this is. Do 
you worry this will cause confusion during merge conflicts down stream?

> 3. Correctness. I'm not sure ResetHS is quite right. It'll probably work for 
> a normal command-line `-cc1` invocation, but perhaps not for all tooling 
> applications, since it's changing the pointer identity of 
> `HeaderSearchOptions`.

Nice catch! Some clients make changes to `AnalyzerOpts` before calling 
`CreateFromArgs`, and we would discard those changes. I've updated this patch 
with a solution: we save the original part of `CompilerInvocation`, run the 
first parse on a clean instance, generate arguments and use the original part 
for the second parse.

> On the other hand, one thing I really like about your approach, which I don't 
> see a way of getting with a top-level check, is the ability to turn on 
> "strict" mode for subsets of the command-line, which helps to hold the line 
> in the face of new options being added (I think this is the feature you're 
> (rightly) calling out). I'm not sure how important it is in practice, as long 
> as we still think getting them all is going to happen in a reasonable time 
> frame. There aren't that many new options being added: filtering out `[cli]` 
> (your patches), `[flang]`, `[[D]driver]`, reverts, and relandings, there are 
> 39 commits to Options.td in the last three months (3 / week). Some of those 
> are deleting options or changing values, and not important to catch. Even for 
> new options, I imagine most people copy/paste nearby options. I think it's 
> critical to hold the line once we have them all, but until then I'm not sure.

That's indeed not too many changes in the area we're working in. Though the 
biggest reason I'm inclined to stick with this solution is that we can verify 
the manual generation as soon as we finish one `Generate*Args`. When committing 
each `Generate*Args` separately, this ensures the code really works.

If we go only with the "relaxed" checks, we'd be committing code that might not 
work as expected and we'd find out only when enabling strict mode for the whole 
`-cc1` interface. Finding a bug in that situation might be harder than with the 
incremental approach.

> `strict` mode additionally uses the `GeneratedArgs1` to fill 
> CompilerInvocation, indirectly checking both directions by requiring tests to 
> pass both with and without this round-trip. However, during development 
> people generally only run the tests one way and the failure mode won't be 
> ideal.

So people build without assertions during development? In that case, I agree 
that erroring out on `GeneratedArgs1 != GeneratedArgs2` (in all kinds of 
builds) would improve the experience. I don't think there's anything preventing 
us to incorporate this into the current patch.


Repository:
  rG LLVM Git

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2021-01-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

What about this change? Did you make more measurements?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[clang] 0005438 - [clangd] Fix a crash when indexing invalid ObjC method declaration

2021-01-25 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-01-25T15:43:11+01:00
New Revision: 00054382b95a9d95e2df6457e7fe1fca2323d287

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

LOG: [clangd] Fix a crash when indexing invalid ObjC method declaration

This fix will make us not crash, but ideally we would handle this case
better.

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 7e36cff7afa6..924cfd03cba7 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1838,6 +1838,20 @@ TEST_F(SymbolCollectorTest, UndefOfModuleMacro) {
   EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
 }
 
+TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
+  auto TU = TestTU::withCode(R"objc(
+@interface Foo
+- (void)fun:(bool)foo, bool bar;
+@end
+  )objc");
+  TU.ExtraArgs.push_back("-xobjective-c++");
+
+  TU.build();
+  // We mostly care about not crashing.
+  EXPECT_THAT(TU.headerSymbols(),
+  UnorderedElementsAre(QName("Foo"), QName("Foo::fun:")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index d77c9e43a9bd..c2785fd60fc2 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -3529,9 +3529,11 @@ CodeCompletionString 
*CodeCompletionResult::createCodeCompletionStringForDecl(
 Result.AddTypedTextChunk("");
 }
 unsigned Idx = 0;
+// The extra Idx < Sel.getNumArgs() check is needed due to legacy C-style
+// method parameters.
 for (ObjCMethodDecl::param_const_iterator P = Method->param_begin(),
   PEnd = Method->param_end();
- P != PEnd; (void)++P, ++Idx) {
+ P != PEnd && Idx < Sel.getNumArgs(); (void)++P, ++Idx) {
   if (Idx > 0) {
 std::string Keyword;
 if (Idx > StartParameter)



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


[PATCH] D94919: [clangd] Fix a crash when indexing invalid ObjC method declaration

2021-01-25 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00054382b95a: [clangd] Fix a crash when indexing invalid 
ObjC method declaration (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94919

Files:
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3529,9 +3529,11 @@
 Result.AddTypedTextChunk("");
 }
 unsigned Idx = 0;
+// The extra Idx < Sel.getNumArgs() check is needed due to legacy C-style
+// method parameters.
 for (ObjCMethodDecl::param_const_iterator P = Method->param_begin(),
   PEnd = Method->param_end();
- P != PEnd; (void)++P, ++Idx) {
+ P != PEnd && Idx < Sel.getNumArgs(); (void)++P, ++Idx) {
   if (Idx > 0) {
 std::string Keyword;
 if (Idx > StartParameter)
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1838,6 +1838,20 @@
   EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
 }
 
+TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
+  auto TU = TestTU::withCode(R"objc(
+@interface Foo
+- (void)fun:(bool)foo, bool bar;
+@end
+  )objc");
+  TU.ExtraArgs.push_back("-xobjective-c++");
+
+  TU.build();
+  // We mostly care about not crashing.
+  EXPECT_THAT(TU.headerSymbols(),
+  UnorderedElementsAre(QName("Foo"), QName("Foo::fun:")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3529,9 +3529,11 @@
 Result.AddTypedTextChunk("");
 }
 unsigned Idx = 0;
+// The extra Idx < Sel.getNumArgs() check is needed due to legacy C-style
+// method parameters.
 for (ObjCMethodDecl::param_const_iterator P = Method->param_begin(),
   PEnd = Method->param_end();
- P != PEnd; (void)++P, ++Idx) {
+ P != PEnd && Idx < Sel.getNumArgs(); (void)++P, ++Idx) {
   if (Idx > 0) {
 std::string Keyword;
 if (Idx > StartParameter)
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1838,6 +1838,20 @@
   EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X";
 }
 
+TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
+  auto TU = TestTU::withCode(R"objc(
+@interface Foo
+- (void)fun:(bool)foo, bool bar;
+@end
+  )objc");
+  TU.ExtraArgs.push_back("-xobjective-c++");
+
+  TU.build();
+  // We mostly care about not crashing.
+  EXPECT_THAT(TU.headerSymbols(),
+  UnorderedElementsAre(QName("Foo"), QName("Foo::fun:")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 7e506b3 - [clangd] Allow diagnostics to be suppressed with configuration

2021-01-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-01-25T15:59:07+01:00
New Revision: 7e506b30a1e1500c3b0b54fba88ea664bc4232e5

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

LOG: [clangd] Allow diagnostics to be suppressed with configuration

This has been specifically requested:
  https://github.com/clangd/vscode-clangd/issues/114
and various issues can be addressed with this as a workaround, e.g.:
  https://github.com/clangd/clangd/issues/662

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 79e94ef6fe37..675e721c7e64 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FunctionExtras.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
@@ -77,6 +78,12 @@ struct Config {
 llvm::Optional External;
   } Index;
 
+  /// Controls warnings and errors when parsing code.
+  struct {
+bool SuppressAll = false;
+llvm::StringSet<> Suppress;
+  } Diagnostics;
+
   /// Style of the codebase.
   struct {
 // Namespaces that should always be fully qualified, meaning no "using"

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 2040ea4649fe..f2e6d544e6c9 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -27,6 +27,7 @@
 #include "Config.h"
 #include "ConfigFragment.h"
 #include "ConfigProvider.h"
+#include "Diagnostics.h"
 #include "Features.inc"
 #include "TidyProvider.h"
 #include "support/Logger.h"
@@ -187,6 +188,7 @@ struct FragmentCompiler {
 compile(std::move(F.If));
 compile(std::move(F.CompileFlags));
 compile(std::move(F.Index));
+compile(std::move(F.Diagnostics));
 compile(std::move(F.ClangTidy));
   }
 
@@ -328,6 +330,27 @@ struct FragmentCompiler {
 });
   }
 
+  void compile(Fragment::DiagnosticsBlock &&F) {
+std::vector Normalized;
+for (const auto &Suppressed : F.Suppress) {
+  if (*Suppressed == "*") {
+Out.Apply.push_back([&](const Params &, Config &C) {
+  C.Diagnostics.SuppressAll = true;
+  C.Diagnostics.Suppress.clear();
+});
+return;
+  }
+  Normalized.push_back(normalizeSuppressedCode(*Suppressed));
+}
+if (!Normalized.empty())
+  Out.Apply.push_back([Normalized](const Params &, Config &C) {
+if (C.Diagnostics.SuppressAll)
+  return;
+for (llvm::StringRef N : Normalized)
+  C.Diagnostics.Suppress.insert(N);
+  });
+  }
+
   void compile(Fragment::StyleBlock &&F) {
 if (!F.FullyQualifiedNamespaces.empty()) {
   std::vector FullyQualifiedNamespaces;

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 0e4ce638fc72..c491ec5ee68c 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -181,6 +181,24 @@ struct Fragment {
   };
   IndexBlock Index;
 
+  /// Controls behavior of diagnostics (errors and warnings).
+  struct DiagnosticsBlock {
+/// Diagnostic codes that should be suppressed.
+///
+/// Valid values are:
+/// - *, to disable all diagnostics
+/// - diagnostic codes exposed by clangd (e.g unknown_type, 
-Wunused-result)
+/// - clang internal diagnostic codes (e.g. err_unknown_type)
+/// - warning categories (e.g. unused-result)
+/// - clang-tidy check names (e.g. bugprone-narrowing-conversions)
+///
+/// This is a simple filter. Diagnostics can be controlled in other ways
+/// (e.g. by disabling a clang-tidy check, or the -Wunused compile flag).
+/// This often has other advantages, such as skipping some analysis.
+std::vector> Suppress;
+  };
+  DiagnosticsBlock Diagnostics;
+
   // Describes the style of the codebase, beyond formatting.
   struct StyleBlock {
 // Namespaces that should always be fully qualified, meaning no "using"
@@ -195,6 +213,7 @@ struct Fragment {
   ///
   /// The settings are merged with any settings found in .clang-tidy
   /// configiration files with these ones taking precedence.
+  // FIXME: move this to Diagnostics.Tidy.
   s

[PATCH] D95349: [clangd] Allow diagnostics to be suppressed with configuration

2021-01-25 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e506b30a1e1: [clangd] Allow diagnostics to be suppressed 
with configuration (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D95349?vs=318972&id=318997#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95349

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Config.h"
 #include "Diagnostics.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
@@ -16,6 +17,7 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "index/MemIndex.h"
+#include "support/Context.h"
 #include "support/Path.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticSema.h"
@@ -371,6 +373,28 @@
   DiagSource(Diag::ClangTidy), DiagName("modernize-loop-convert";
 }
 
+TEST(DiagnosticTest, RespectsDiagnosticConfig) {
+  Annotations Main(R"cpp(
+// error-ok
+void x() {
+  [[unknown]]();
+  $ret[[return]] 42;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Main.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(), "use of undeclared identifier 'unknown'"),
+  Diag(Main.range("ret"),
+   "void function 'x' should not return a value")));
+  Config Cfg;
+  Cfg.Diagnostics.Suppress.insert("return-type");
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  ElementsAre(Diag(Main.range(),
+   "use of undeclared identifier 'unknown'")));
+}
+
 TEST(DiagnosticTest, ClangTidySuppressionComment) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -98,7 +98,7 @@
 YAML.range());
 }
 
-TEST(ParseYAML, Diagnostics) {
+TEST(ParseYAML, ConfigDiagnostics) {
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
 If:
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -11,6 +11,7 @@
 #include "ConfigTesting.h"
 #include "Features.inc"
 #include "TestFS.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,7 @@
 using ::testing::IsEmpty;
 using ::testing::SizeIs;
 using ::testing::StartsWith;
+using ::testing::UnorderedElementsAre;
 
 class ConfigCompileTests : public ::testing::Test {
 protected:
@@ -183,6 +185,39 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticSuppression) {
+  Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
+  Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
+  Frag.Diagnostics.Suppress.emplace_back("-Wunused-variable");
+  Frag.Diagnostics.Suppress.emplace_back("typecheck_bool_condition");
+  Frag.Diagnostics.Suppress.emplace_back("err_unexpected_friend");
+  Frag.Diagnostics.Suppress.emplace_back("warn_alloca");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_THAT(Conf.Diagnostics.Suppress.keys(),
+  UnorderedElementsAre("bugprone-use-after-move",
+   "unreachable-code", "unused-variable",
+   "typecheck_bool_condition",
+   "unexpected_friend", "warn_alloca"));
+  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable,
+Conf.Diagnostics.Suppress));
+  // Subcategory not respected/suppressed.
+  EXPECT_FALSE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable_break,
+ Conf.Diagnostics.Suppress));
+  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unused_variable,
+Conf.Diagn

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-01-25 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/Expr.cpp:1402
 
   const FunctionType *FnType = CalleeType->castAs();
   return FnType->getReturnType();

Here occurs the problem: If `CalleeType` is of type `BuiltinType::Overload` it 
does not cast to `FunctionType`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D95362: [clangd] Parse Diagnostics block, and nest ClangTidy block under it.

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

(ClangTidy configuration block hasn't been in any release, so we should be OK
to move it around like this)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95362

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -60,10 +60,11 @@
 Index:
   Background: Skip
 ---
-ClangTidy: 
-  CheckOptions: 
-IgnoreMacros: true
-example-check.ExampleOption: 0
+Diagnostics:
+  ClangTidy: 
+CheckOptions: 
+  IgnoreMacros: true
+  example-check.ExampleOption: 0
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -77,7 +78,7 @@
 
   ASSERT_TRUE(Results[2].Index.Background);
   EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
-  EXPECT_THAT(Results[3].ClangTidy.CheckOptions,
+  EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
 }
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -219,32 +219,36 @@
 }
 
 TEST_F(ConfigCompileTests, Tidy) {
-  Frag.ClangTidy.Add.emplace_back("bugprone-use-after-move");
-  Frag.ClangTidy.Add.emplace_back("llvm-*");
-  Frag.ClangTidy.Remove.emplace_back("llvm-include-order");
-  Frag.ClangTidy.Remove.emplace_back("readability-*");
-  Frag.ClangTidy.CheckOptions.emplace_back(
+  auto &Tidy = Frag.Diagnostics.ClangTidy;
+  Tidy.Add.emplace_back("bugprone-use-after-move");
+  Tidy.Add.emplace_back("llvm-*");
+  Tidy.Remove.emplace_back("llvm-include-order");
+  Tidy.Remove.emplace_back("readability-*");
+  Tidy.CheckOptions.emplace_back(
   std::make_pair(std::string("StrictMode"), std::string("true")));
-  Frag.ClangTidy.CheckOptions.emplace_back(std::make_pair(
+  Tidy.CheckOptions.emplace_back(std::make_pair(
   std::string("example-check.ExampleOption"), std::string("0")));
   EXPECT_TRUE(compileAndApply());
   EXPECT_EQ(
-  Conf.ClangTidy.Checks,
+  Conf.Diagnostics.ClangTidy.Checks,
   "bugprone-use-after-move,llvm-*,-llvm-include-order,-readability-*");
-  EXPECT_EQ(Conf.ClangTidy.CheckOptions.size(), 2U);
-  EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("StrictMode"), "true");
-  EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("example-check.ExampleOption"),
+  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.size(), 2U);
+  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.lookup("StrictMode"),
+"true");
+  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.lookup(
+"example-check.ExampleOption"),
 "0");
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 }
 
 TEST_F(ConfigCompileTests, TidyBadChecks) {
-  Frag.ClangTidy.Add.emplace_back("unknown-check");
-  Frag.ClangTidy.Remove.emplace_back("*");
-  Frag.ClangTidy.Remove.emplace_back("llvm-includeorder");
+  auto &Tidy = Frag.Diagnostics.ClangTidy;
+  Tidy.Add.emplace_back("unknown-check");
+  Tidy.Remove.emplace_back("*");
+  Tidy.Remove.emplace_back("llvm-includeorder");
   EXPECT_TRUE(compileAndApply());
   // Ensure bad checks are stripped from the glob.
-  EXPECT_EQ(Conf.ClangTidy.Checks, "-*");
+  EXPECT_EQ(Conf.Diagnostics.ClangTidy.Checks, "-*");
   EXPECT_THAT(
   Diags.Diagnostics,
   ElementsAre(
Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -255,7 +255,7 @@
 
 TidyProviderRef provideClangdConfig() {
   return [](tidy::ClangTidyOptions &Opts, llvm::StringRef) {
-const auto &CurTidyConfig = Config::current().ClangTidy;
+const auto &CurTidyConfig = Config::current().Diagnostics.ClangTidy;
 if (!CurTidyConfig.Checks.empty())
   mergeCheckList(Opts.Checks, CurTidyConfig.Checks);
 
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAM

[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-25 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson marked 2 inline comments as done.
tmatheson added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

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


[PATCH] D82862: [ThinLTO] Always parse module level inline asm with At&t dialect

2021-01-25 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

In D82862#2513044 , @rnk wrote:

> In D82862#2512908 , @uweigand wrote:
>
>> So why do you want GNU inline asm for clang-cl anyway?   I thought the whole 
>> point of clang-cl was to be compatible with the Microsoft Visual Studio 
>> compiler, which I understand only supports the MS asm syntax?
>
> We have users, in this case, I think it's V8, who would prefer to use 
> gcc-style module level assembly if it is available. Their motivation is 
> somewhat arbitrary, but generally, clang-cl supports a variety of extensions, 
> some inherited from GCC, in all modes. Part of the point of switching 
> compilers from MSVC to clang is to get access to those extensions.

I might be mistaken here  but couldn't this be done by introducing an option 
and tying it to setting the AssemblerDialect field in the target's respective 
`MCAsmInfo` instance and then querying that? Wouldn't this remove the 
dependency on setting the dialect on the parser. Module level assembly are only 
going to be treated as GNU statements (from Uli's comment above), and if its 
just the case of using a different variant (within the gnu dialect), then this 
can be set in the respective (Target)MCAsmInfo instances appropriately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82862

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-01-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 319000.
khchen marked 7 inline comments as done.
khchen added a comment.

1. address @HsiangKai's comments
2. remove test generator to make td simpler.
3. remove MangledSuffix, it should be MangledName


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/riscv-rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/riscv-rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/riscv-rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/riscv-rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-01-25 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:161
+  // This builtin is valid for the given exponental LMULs.
+  list ELMUL = [0, 1, 2, 3, -1, -2, -3];
+

HsiangKai wrote:
> EMUL according to specification.
Here ELMUL means  exponental LMUL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

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


[PATCH] D95365: [clangd] Add include-fixer fixit for no_member_template diagnostic.

2021-01-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95365

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -855,11 +855,13 @@
 
   ::$global[[Global]] glob;
 }
+using Type = ns::$template[[Foo]];
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
-   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""},
+   SymbolWithHeader{"ns::Foo", "unittest:///foo.h", "\"foo.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -884,7 +886,12 @@
  "no type named 'Global' in the global namespace"),
 DiagName("typename_nested_not_found"),
 WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
-"Add include \"global.h\" for symbol Global");
+"Add include \"global.h\" for symbol Global"))),
+  AllOf(Diag(Test.range("template"),
+ "no template named 'Foo' in namespace 'ns'"),
+DiagName("no_member_template"),
+WithFix(Fix(Test.range("insert"), "#include \"foo.h\"\n",
+"Add include \"foo.h\" for symbol ns::Foo");
 }
 
 TEST(IncludeFixerTest, MultipleMatchedSymbols) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -100,6 +100,8 @@
   case diag::err_undeclared_var_use_suggest:
   case diag::err_no_member: // Could be no member in namespace.
   case diag::err_no_member_suggest:
+  case diag::err_no_member_template:
+  case diag::err_no_member_template_suggest:
 if (LastUnresolvedName) {
   // Try to fix unresolved name caused by missing declaration.
   // E.g.


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -855,11 +855,13 @@
 
   ::$global[[Global]] glob;
 }
+using Type = ns::$template[[Foo]];
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   auto Index = buildIndexWithSymbol(
   {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
-   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""},
+   SymbolWithHeader{"ns::Foo", "unittest:///foo.h", "\"foo.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -884,7 +886,12 @@
  "no type named 'Global' in the global namespace"),
 DiagName("typename_nested_not_found"),
 WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
-"Add include \"global.h\" for symbol Global");
+"Add include \"global.h\" for symbol Global"))),
+  AllOf(Diag(Test.range("template"),
+ "no template named 'Foo' in namespace 'ns'"),
+DiagName("no_member_template"),
+WithFix(Fix(Test.range("insert"), "#include \"foo.h\"\n",
+"Add include \"foo.h\" for symbol ns::Foo");
 }
 
 TEST(IncludeFixerTest, MultipleMatchedSymbols) {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -100,6 +100,8 @@
   case diag::err_undeclared_var_use_suggest:
   case diag::err_no_member: // Could be no member in namespace.
   case diag::err_no_member_suggest:
+  case diag::err_no_member_template:
+  case diag::err_no_member_template_suggest:
 if (LastUnresolvedName) {
   // Try to fix unresolved name caused by missing declaration.
   // E.g.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95362: [clangd] Parse Diagnostics block, and nest ClangTidy block under it.

2021-01-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

LG, Obviously we need to get this in before the branch or get it cherrypicked. 
Also documentation will need updating on https://github.com/llvm/clangd-www. Do 
you want to sort that out?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95362

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


  1   2   3   >