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

2021-01-26 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 rG2154cffdc2a6: [clang][cli] Store LangStandard::Kind in 
LangOptions (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D95342?vs=318951&id=319225#toc

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
@@ -1971,6 +1971,7 @@
   }
 
   const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
+  Opts.LangStd = LangStd;
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
@@ -1982,7 +1983,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;
@@ -2262,8 +2262,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 fdigr

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

2021-01-26 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 rG956d8e02e8a5: [clang][cli] Port GNU language options to 
marshalling system (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

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();
 
@@ -1984,7 +1990,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();
@@ -2056,7 +2061,6 @@
   // C++ has wchar_t keyword.
   Opts.WChar = Opts.CPlusPlus;
 
-  Opts.GNUKeywords = Opts.GNUMode;
   Opts.CXXOperatorNames = Opts.CPlusPlus;
 
   Opts.AlignedAllocation = Opts.CPlusPlus17;
@@ -2254,14 +2258,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;
 
@@ -2344,14 +2340,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.
@@ -2994,7 +2982,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 seem a useful distinction.
+defm gnu_key

[PATCH] D95419: [clangd] Fix filename completion at the end of file

2021-01-26 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 for puzzling this one out, i thought it would be in lexer...




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1127
+  // If preamble doesn't end on a new line, include the following byte in
+  // preamble to enable include completion on a new file. e.g: #include "^
+  bool CompletingInPreamble =

"include the following byte" doesn't match my mental model, which is that we're 
on the boundary, and are choosing whether to resolve left out right, i.e 
*guessing* whether inserted text will become part of the preamble or the main 
file.

(Of course everyone has their own mental model - but if that seems clearer to 
you too, maybe reword)

 clearer might be:

```
if (Offset < Size || (!EndsInNewline && Offset == Size))
```

May not even need the comment in this case, up to you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95419

___
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-26 Thread George Rimar via Phabricator via cfe-commits
grimar added a comment.

I like this approach.


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] D95344: [clang][cli] Accept strings instead of options in ImpliedByAnyOf

2021-01-26 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 rG9338f3a586bc: [clang][cli] Accept strings instead of options 
in ImpliedByAnyOf (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

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<["-"], "cl-no-signed-zeros">, Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">,
   MarshallingInfoFlag>;
@@ -1331,11 +1331,11 @@
 def ffp_exception_behavior_EQ : Joined<["-"], 

[PATCH] D94952: [clangd] Take into account what is in the index (symbols, references, etc.) at indexes merge

2021-01-26 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:433
 PreambleSymbols.update(
-Uri, std::make_unique(std::move(*IF->Symbols)),
+FilePath ? *FilePath : (consumeError(FilePath.takeError()), Uri),
+std::make_unique(std::move(*IF->Symbols)),

ArcsinX wrote:
> sammccall wrote:
> > ArcsinX wrote:
> > > sammccall wrote:
> > > > Is this change related? It changes the key scheme for the preamble 
> > > > index from URIs to paths, but I'm not sure why.
> > > > 
> > > > Do we have multiple URIs pointing to the same path? What are they 
> > > > concretely?
> > > This is the main thing in this patch. I will try to explain.
> > > We use these keys to create the file list, which is used by 
> > > `indexedFiles()`.
> > > Currently, the preamble index contains URI's instead of paths (as a file 
> > > list), that leads to the function returned by 
> > > `PreambleIndex::indexedFiles()` always return `false` (because we pass to 
> > > this function paths, not URI's). So, we always take data from the 
> > > preamble index (but maybe we should not in some cases).
> > > 
> > Oooh... I'm not sure how I misunderstood the original so much :-( And I 
> > missed it in this patch description as well, apologies.
> > 
> > My impression was that the file list was derived from the index data, 
> > rather than from the keys, which were always intended to be 
> > opaque/arbitrary.
> > (At various times, these have been filenames, URIs, and other things IIRC. 
> > And until relatively recently, the preamble index keys were the file the 
> > preamble was built from, not the file containing the symbol!)
> > 
> > It feels like using URIs extracted from symbols might not be *completely* 
> > robust. Because having CanonicalDeclaration etc set to a file might not 
> > line up exactly with the idea that we indexed the file. But we do use this 
> > partitioning for FileShardedIndex, so it has to work well enough.
> > 
> > The advantage of using the extracted URIs would be: also works for 
> > non-file-sharded indexes like --index-file, avoid a bunch of conversion 
> > between URI and path, and we get to keep the simpler/flexible design for 
> > FileSymbols where the key is opaque.
> > 
> > Does this seem feasible to you?
> > that leads to the function returned by `PreambleIndex::indexedFiles()` 
> > always return `false` (because we pass to this function paths, not URI's)
> 
> This is a bit incorrect.
> We pass to this function URI, but this URI is converted to path. i.e. 
> `MemIndex::indexedFiles()`, `Dex::indexedFiles()` expect that `Files` are 
> paths, but they are URI's for the preamble index. That's why 
> `PreambleIndex::indexedFiles()` always return `false`.
I also do not like these path <=> URI conversions. But what about empty files?, 
e.g.:
- open a file
- remove everything from this file
- the dynamic index has no symbols with definition/declaration from this file, 
so we do not have this file in the dynamic index file list.
- the static index has symbols with definition/declaration from this file, so 
we have this file in the static index file list.
- we will show stale results from the static index for this file.


Unsure, maybe it's ok to ignore the problem with empty files, seems this is the 
only case when the file was indexed, but we have no symbols located there.

Overall, I like the idea to use URI's instead of paths. I think we could 
implement it first as a separate patch and after that return to this one.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94952

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


[PATCH] D95419: [clangd] Fix filename completion at the end of file

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 319229.
kadircet marked an inline comment as done.
kadircet added a comment.

- Rewrite the condition as suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95419

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


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2573,7 +2573,7 @@
 }
 
 TEST(CompletionTest, IncludedCompletionKinds) {
-  Annotations Test(R"cpp(#include "^")cpp");
+  Annotations Test(R"cpp(#include "^)cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.AdditionalFiles["sub/bar.h"] = "";
   TU.ExtraArgs.push_back("-I" + testPath("sub"));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1123,7 +1123,9 @@
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
   ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
-  bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
+  bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
+  (!PreambleRegion.PreambleEndsAtStartOfLine &&
+   Input.Offset == PreambleRegion.Size);
   if (Input.Patch)
 Input.Patch->apply(*CI);
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. 
Otherwise


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2573,7 +2573,7 @@
 }
 
 TEST(CompletionTest, IncludedCompletionKinds) {
-  Annotations Test(R"cpp(#include "^")cpp");
+  Annotations Test(R"cpp(#include "^)cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.AdditionalFiles["sub/bar.h"] = "";
   TU.ExtraArgs.push_back("-I" + testPath("sub"));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1123,7 +1123,9 @@
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
   ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
-  bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
+  bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
+  (!PreambleRegion.PreambleEndsAtStartOfLine &&
+   Input.Offset == PreambleRegion.Size);
   if (Input.Patch)
 Input.Patch->apply(*CI);
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95419: [clangd] Fix filename completion at the end of file

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64cdba65bbfa: [clangd] Fix filename completion at the end of 
file (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95419

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


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2573,7 +2573,7 @@
 }
 
 TEST(CompletionTest, IncludedCompletionKinds) {
-  Annotations Test(R"cpp(#include "^")cpp");
+  Annotations Test(R"cpp(#include "^)cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.AdditionalFiles["sub/bar.h"] = "";
   TU.ExtraArgs.push_back("-I" + testPath("sub"));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1123,7 +1123,9 @@
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
   ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
-  bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
+  bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
+  (!PreambleRegion.PreambleEndsAtStartOfLine &&
+   Input.Offset == PreambleRegion.Size);
   if (Input.Patch)
 Input.Patch->apply(*CI);
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. 
Otherwise


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2573,7 +2573,7 @@
 }
 
 TEST(CompletionTest, IncludedCompletionKinds) {
-  Annotations Test(R"cpp(#include "^")cpp");
+  Annotations Test(R"cpp(#include "^)cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.AdditionalFiles["sub/bar.h"] = "";
   TU.ExtraArgs.push_back("-I" + testPath("sub"));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1123,7 +1123,9 @@
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
   ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
-  bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
+  bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
+  (!PreambleRegion.PreambleEndsAtStartOfLine &&
+   Input.Offset == PreambleRegion.Size);
   if (Input.Patch)
 Input.Patch->apply(*CI);
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95421: [NFC] Refine some uninitialized used variables.

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3b0acdc6fb5: [NFC] Refine some uninitialized used 
variables. (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95421

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  llvm/lib/CodeGen/RegisterCoalescer.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp

Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -13830,7 +13830,7 @@
   assert(V2.getSimpleValueType() == MVT::v4f32 && "Bad operand type!");
 
   // Attempt to match the insertps pattern.
-  unsigned InsertPSMask;
+  unsigned InsertPSMask = 0;
   if (!matchShuffleAsInsertPS(V1, V2, InsertPSMask, Zeroable, Mask, DAG))
 return SDValue();
 
Index: llvm/lib/CodeGen/RegisterCoalescer.cpp
===
--- llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -442,7 +442,7 @@
   Flipped = CrossClass = false;
 
   Register Src, Dst;
-  unsigned SrcSub, DstSub;
+  unsigned SrcSub = 0, DstSub = 0;
   if (!isMoveInstr(TRI, MI, Src, Dst, SrcSub, DstSub))
 return false;
   Partial = SrcSub || DstSub;
@@ -537,7 +537,7 @@
   if (!MI)
 return false;
   Register Src, Dst;
-  unsigned SrcSub, DstSub;
+  unsigned SrcSub = 0, DstSub = 0;
   if (!isMoveInstr(TRI, MI, Src, Dst, SrcSub, DstSub))
 return false;
 
@@ -1590,7 +1590,7 @@
   // CoalescerPair may have a new register class with adjusted subreg indices
   // at this point.
   Register SrcReg, DstReg;
-  unsigned SrcSubIdx, DstSubIdx;
+  unsigned SrcSubIdx = 0, DstSubIdx = 0;
   if(!isMoveInstr(*TRI, CopyMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
 return nullptr;
 
@@ -1966,7 +1966,7 @@
 if (!canJoinPhys(CP)) {
   // Before giving up coalescing, if definition of source is defined by
   // trivial computation, try rematerializing it.
-  bool IsDefCopy;
+  bool IsDefCopy = false;
   if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
 return true;
   if (IsDefCopy)
@@ -2005,7 +2005,7 @@
 
 // If definition of source is defined by trivial computation, try
 // rematerializing it.
-bool IsDefCopy;
+bool IsDefCopy = false;
 if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
   return true;
 
@@ -3798,7 +3798,7 @@
   if (!UseTerminalRule)
 return false;
   Register SrcReg, DstReg;
-  unsigned SrcSubReg, DstSubReg;
+  unsigned SrcSubReg = 0, DstSubReg = 0;
   if (!isMoveInstr(*TRI, &Copy, SrcReg, DstReg, SrcSubReg, DstSubReg))
 return false;
   // Check if the destination of this copy has any other affinity.
@@ -3823,7 +3823,7 @@
 if (&MI == &Copy || !MI.isCopyLike() || MI.getParent() != OrigBB)
   continue;
 Register OtherSrcReg, OtherReg;
-unsigned OtherSrcSubReg, OtherSubReg;
+unsigned OtherSrcSubReg = 0, OtherSubReg = 0;
 if (!isMoveInstr(*TRI, &Copy, OtherSrcReg, OtherReg, OtherSrcSubReg,
 OtherSubReg))
   return false;
Index: clang/lib/CodeGen/CGBlocks.cpp
===
--- clang/lib/CodeGen/CGBlocks.cpp
+++ clang/lib/CodeGen/CGBlocks.cpp
@@ -2697,7 +2697,7 @@
   }
 
   bool HasByrefExtendedLayout = false;
-  Qualifiers::ObjCLifetime Lifetime;
+  Qualifiers::ObjCLifetime Lifetime = Qualifiers::OCL_None;
   if (getContext().getByrefLifetime(Ty, Lifetime, HasByrefExtendedLayout) &&
   HasByrefExtendedLayout) {
 /// void *__byref_variable_layout;
@@ -2767,8 +2767,8 @@
   const VarDecl &D = *emission.Variable;
   QualType type = D.getType();
 
-  bool HasByrefExtendedLayout;
-  Qualifiers::ObjCLifetime ByrefLifetime;
+  bool HasByrefExtendedLayout = false;
+  Qualifiers::ObjCLifetime ByrefLifetime = Qualifiers::OCL_None;
   bool ByRefHasLifetime =
 getContext().getByrefLifetime(type, ByrefLifetime, HasByrefExtendedLayout);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.
This revision is now accepted and ready to land.

Basically LGTM - (I'm happy for this to land either with or without my comments 
being addressed). Would be nice to get a second reviewer to confirm they're 
happy.




Comment at: clang/test/Driver/fbinutils-version.c:1
+// RUN: %clang -### -c -target x86_64-linux %s -fbinutils-version=none 2>&1 | 
FileCheck %s --check-prefix=NONE
+

Maybe also add a case for `-fbinutils-version=2` (i.e. no minor version at all).



Comment at: llvm/lib/CodeGen/LLVMTargetMachine.cpp:64
 
+  if (Options.BinutilsVersion.first > 0)
+TmpAsmInfo->setBinutilsVersion(Options.BinutilsVersion);

Is it possible somebody might do something weird like `-fbinutils-version=0.1` 
and get behaviour different to what might be expected? Should we explicitly 
forbid major versions of 0?



Comment at: llvm/lib/Target/TargetMachine.cpp:239
+  if (Version == "none")
+return {INT_MAX, 0}; // Make binutilsIsAtLeast() return true.
+  std::pair Ret;

Maybe `{INT_MAX, INT_MAX}`? Doesn't really matter in practice, but `{INT_MAX, 
INT_MAX} > {INT_MAX, 0}` in the versioning scheme.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

___
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-26 Thread Haojian Wu 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 rG68dbd1aefe5a: [clangd] Add include-fixer fixit for 
no_member_template diagnostic. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

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
@@ -879,11 +879,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(
@@ -908,7 +910,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
@@ -879,11 +879,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(
@@ -908,7 +910,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] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

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

I did briefly consider one alternative, which was to build these directly into 
FileCheck, but it doesn't quite feel like the right approach for FileCheck to 
need to know system level details. In practice, I think the lit substitution 
may be the best way forward overall. In the future, it should be easy to expand 
with more error messages.

You should add the new substitution to the lit command guide, so that it's 
documented. It might also be worth a heads up on llvm-dev to get feedback from 
those not directly on this review, to see if there are other ideas.




Comment at: llvm/utils/lit/lit/llvm/config.py:349-354
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))

These lines are quite long, so probably want reflowing.

I wonder if `%errc_...` might be a better name? That way, it ties to the 
`std::errc` values these match up with.



Comment at: llvm/utils/lit/lit/llvm/config.py:369-370
 
+if hasattr(self.config, 'host_triple'):
+   self.add_err_msg_substitutions(self.config.host_triple) 
+

Under what conditions can there not be a `host_triple`? In those cases, what 
happens to the tests that use the new substitution?



Comment at: llvm/utils/lit/lit/llvm/config.py:372
+
+
 def use_llvm_tool(self, name, search_env=None, required=False, 
quiet=False):

Nit: too many blank lines (compared to what was there before)


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] D95345: [clang][cli] Port GPU-related language options to marshalling system

2021-01-26 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 rG7025fef3f653: [clang][cli] Port GPU-related language options 
to marshalling system (authored by jansvoboda11).

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();
 
@@ -2014,8 +2030,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.
@@ -2047,10 +2061,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;
@@ -2246,38 +2256,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();
@@ -2438,12 +2419,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<"RenderScr

[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-01-26 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous marked an inline comment as done.
nomanous added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10111-10124
+// Check the static member's type given in the explicit instantiation
+// definition against the one in the class template. This won't happen in
+// explicit instantiation declaration because the instantiated code won't
+// be generated in that case.
+if (IsStaticDataMemberInstantiation &&
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {

rsmith wrote:
> Can we combine this with the previous `if`? This is really checking the same 
> thing that the `hasSameType` check above checked.
It seems difficult to combine this with the previous one.

  # The two `if` blocks are small and both only contain two statements, but the 
two statements contained by the posterior one are all different from statements 
contained by the previous one (they use different diagnostics);
  # The conditions are different. The previous one uses `PrevTemplate` to make 
sure that it's in a variable template declaration and the posterior one uses 
`IsStaticDataMemberInstantiation` to make sure that it's in a static data 
member instantiation of a template class.

So, if we want to combine the two blocks, we must write two sub-`if`-blocks in 
the combined block, which, I think, has no advantage over the current code (if 
not more confusing).









Comment at: clang/lib/Sema/SemaTemplate.cpp:10117
+TSK == TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameTypeIgnoreLifetime(Prev->getType(), R)) {
+  Diag(T->getTypeLoc().getBeginLoc(),

rsmith wrote:
> Please can you point us at an example that needs this "ignore lifetime" 
> nuance? We should check with Apple folks what they want to happen here, and 
> we should presumably have the same rule for all explicit instantiations of 
> templated variables -- both in the static data member case here and the 
> variable template case a few lines above.
> 
> My expectation is that we want one of these two rules:
> 1) the declared lifetime should match exactly between the declaration and the 
> explicit instantiation, or
> 2) there cannot be a declared lifetime on the explicit instantiation, and a 
> lifetime on the template declaration is ignored by the check
> (or a combination of these rules where we accept either option). I don't 
> think that matches what you're doing here -- in particular, I think a wrong 
> declared lifetime on the explicit instantiation should result in an error.
I'll do some test and give you a code snippet to trigger the lifetime mismatch 
when lifetime specifiers are not ignored. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90448

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


[PATCH] D91913: Suppress non-conforming GNU paste extension in all standard-conforming modes

2021-01-26 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

Restoring the old behaviour for LLVM 12 may or may not help the Chrome/Chromium 
people: if they also regularly build with clang from git, they would need to 
handle this change anyway. However, if it does help, then it sounds like a good 
idea to me.

> So we should be working towards removing the `getNumParams() < 2` check in at 
> least the C++20 case.

Right, and the same change has also been accepted for C, has it not? If it has, 
then also the C2x case.

It would be good to align with GCC here. I would imagine that they will want 
the same thing for GCC you are proposing for clang, but it would be good to 
make sure. Specifically: it would be good to confirm that there are no 
objections from GCC's side to supporting `#ifdef __VA_OPT__` as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91913

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


[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM

2021-01-26 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:2490
+  continue;
+std::string::size_type position1 = Constraints.find("={eax}");
+if (position1 != std::string::npos) {

If `Clobber` is `edx` only, we shouldn't change `"={eax}"` to `"=&{eax}"`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

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


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: llvm/include/llvm/Analysis/ObjCARCRVAttr.h:28
+
+static inline const char *getRVAttrValStr(bool Retain) {
+  return Retain ? "retain" : "claim";

Is there a place the attributes could be documented?



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

rjmccall wrote:
> nikic wrote:
> > This change looks pretty fishy. Objective C shouldn't be hijacking LLVMs 
> > core instruction model in this way. If it writes to memory, this should 
> > either be reflected in the attributes, or modeled using operand bundles.
> > 
> > @fhahn Did you review these changes? If not, I'd suggest to revert this 
> > patch and get a review on the LLVM changes.
> This could definitely be an operand bundle, and I suppose the presence of a 
> bundle does force a conservative assumption on passes.
> @fhahn Did you review these changes? 

Nope I didn't have time to look at this so far.



Can functions marked as `readonly`/`readnone` be called with the objc 
attributes? 

I'm not very familiar with ObjC, but even for a function that just returns a 
passed in object id, don't we need to retain & release the object in the 
function? Which means the function cannot be `readonly` because we need to call 
`@llvm.objc*` functions? If that's the case, could we just check in the 
verifier that the attributes are never used with `readonly` functions?

If there are indeed cases where we can call `readonly` functions, operand 
bundles would probably be safest. It would probably also good to have at least 
a few alias-analysis tests, to make sure things work as expected.



Comment at: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:576
+// Don't change the return type of the function if it has retainRV/claimRV.
+if (objcarc::hasRetainRVOrClaimRVAttr(CB)) {
+  NumLiveRetVals = RetCount;

This seems fragile. IIUC this workaround is needed because the return value of 
a `retainRV/claimRV` function always has one implicit use. This aspect could 
get missed in other places as well.

As an alternative, could the frontend insert 'dummy' uses (e.g. 
`llvm.objc.arc.use`) to make this assumption transparent? Those could be 
removed sufficiently late. Their placement doesn't really matter and neither 
does if any instructions are moved between the original call and the dummy use, 
but the fact that the returned value is used is now explicit. IICU they could 
be marked as accessing inaccessible memory only, so they should be too much 
trouble for other optimizations (at least not more than the previous explicit 
release calls). Or perhaps there's a different way to mark the return value as 
used explicitly.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


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

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

Ok, reverted. If there's a doubt, then I guess it's the best solution.


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] D95017: [clang-format] add case aware include sorting

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



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

kentsommer wrote:
> MyDeveloperDay wrote:
> > Are you sure `IncludeSortAlphabetically` expresses what you mean? Once 
> > these things get released they cannot be changed easily.
> > 
> > If you were not sure of a new option, in my view we should slow down and 
> > make sure we have the correct design, for example you could have used a 
> > enum and it might have given you more possibility for greater flexibility
> > 
> > ```
> > enum IncludeSort
> > {
> >CaseInsensitive
> >CaseSensitive
> > }
> > ```
> > 
> > Please give people time to re-review your changes before we commit, 
> > especially if they've taken the time to look at your review in the first 
> > place. Just saying.
> > 
> Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> through the review. I was simply trying to follow the process outlined in 
> https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which mentions 
> giving sufficient information to allow for a commit on your behalf when you 
> don't have access after an LGTM (which is all that I did). As you can see 
> from the lack of additional comments from my end, I was happy to let this sit 
> and be reviewed. 
> 
> Per the discussion about the option itself, I do believe 
> `IncludeSortAlphabetically` currently expresses what I mean as the behavior 
> with this off is indeed not an alphabetical sort as case takes precedence 
> over the alphabetical ordering. However, looking at the enum and realizing 
> that others probably will have additional styles they prefer (maybe they want 
> alphabetical but lower case first, etc.) I do believe it might have been a 
> better way to go as it leaves more flexibility and room for additional 
> ordering styles. Given that this just landed, I would be happy to open a 
> patch to turn this into an `enum` as I do see benefits to doing so. What do 
> you think?
Hmmm, and how about using the existing option `SortIncludes` and change its 
type from `bool` to some `enum`?
We could then, for backward-compatibility, map `false` to (tentative) `Never` 
and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.

This will have the advantage of not adding additional style options.
... and it will prove once again that using `bool`s for style options is not a 
good idea.


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] D95017: [clang-format] add case aware include sorting

2021-01-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added a comment.
This revision now requires changes to proceed.

Requesting changes so that it appears correctly in the review queue.


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] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-01-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 319261.
balazske added a comment.

Adding a test, fixing other problems revealed by the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

Files:
  clang/lib/AST/Expr.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,37 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+struct A {
+  void f(int);
+  void f(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+f_overload(p);
+A a;
+a.f(p);
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1382,6 +1382,14 @@
 QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
   const Expr *Callee = getCallee();
   QualType CalleeType = Callee->getType();
+
+  auto CreateDependentType = [&Ctx]() {
+ASTContext::GetBuiltinTypeError Error;
+QualType RetTy = Ctx.GetBuiltinType(BuiltinType::Dependent, Error);
+assert(Error == ASTContext::GE_None);
+return RetTy;
+  };
+
   if (const auto *FnTypePtr = CalleeType->getAs()) {
 CalleeType = FnTypePtr->getPointeeType();
   } else if (const auto *BPT = CalleeType->getAs()) {
@@ -1390,8 +1398,13 @@
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
-// This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+if (CalleeType.isNull())
+  return CreateDependentType();
+
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return CreateDependentType();
   }
 
   const FunctionType *FnType = CalleeType->castAs();


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,37 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+struct A {
+  void f(int);
+  void f(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+f_overload(p);
+A a;
+a.f(p);
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1382,6 +1382,14 @@
 QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
   const Expr *Callee = getCallee();
   QualType CalleeType = Callee->getType();
+
+  auto CreateDependentType = [&Ctx]() {
+ASTContext::GetBuiltinTypeError Error;
+QualType RetTy = Ctx.GetBuiltinType(BuiltinType::Dependent, Error);
+assert(Error == ASTContext::GE_None);
+return RetTy;
+  };
+
   if (const auto *FnTypePtr = CalleeType->getAs()) {
 CalleeType = FnTypePtr->getPointeeType();
   } else if (const auto *BPT = CalleeType->getAs()) {
@@ -1390,8 +1398,13 @@
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
-// This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+if (CalleeType.isNull())
+  return CreateDependentType();
+
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return CreateDependentType();
   }
 
   const FunctionType *FnType = CalleeType->castAs();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:2490
+  continue;
+std::string::size_type position1 = Constraints.find("={eax}");
+if (position1 != std::string::npos) {

pengfei wrote:
> If `Clobber` is `edx` only, we shouldn't change `"={eax}"` to `"=&{eax}"`.
Yes! I'll update and add a test. THX for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

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


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

2021-01-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I could add a test in ToolingTests, lit test is much more difficult to add 
because the function is normally not called on "bad" code.




Comment at: clang/lib/AST/Expr.cpp:1403
+if (CalleeType.isNull())
+  return CreateDependentType();
+

I am not sure if dependent type is here (and later) the correct value to 
return. But only a null type is another possibility.


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] D95435: [clang][aarch64][WOA64][docs] Release note for longjmp crash with /guard:cf

2021-01-26 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm created this revision.
peterwaller-arm added a reviewer: richard.townsend.arm.
Herald added subscribers: danielkiss, kristof.beyls.
peterwaller-arm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a release note workaround for PR47463.

Bug: https://bugs.llvm.org/show_bug.cgi?id=47463


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95435

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -146,6 +146,11 @@
 Windows Support
 ---
 
+- Windows on Arm64: programs using the C standard library's setjmp and longjmp
+  functions may crash with a "Security check failure or stack buffer overrun"
+  exception. To workaround (with reduced security), compile with
+  /guard:cf,nolongjmp.
+
 C Language Changes in Clang
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -146,6 +146,11 @@
 Windows Support
 ---
 
+- Windows on Arm64: programs using the C standard library's setjmp and longjmp
+  functions may crash with a "Security check failure or stack buffer overrun"
+  exception. To workaround (with reduced security), compile with
+  /guard:cf,nolongjmp.
+
 C Language Changes in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94952: [clangd] Take into account what is in the index (symbols, references, etc.) at indexes merge

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



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:433
 PreambleSymbols.update(
-Uri, std::make_unique(std::move(*IF->Symbols)),
+FilePath ? *FilePath : (consumeError(FilePath.takeError()), Uri),
+std::make_unique(std::move(*IF->Symbols)),

ArcsinX wrote:
> ArcsinX wrote:
> > sammccall wrote:
> > > ArcsinX wrote:
> > > > sammccall wrote:
> > > > > Is this change related? It changes the key scheme for the preamble 
> > > > > index from URIs to paths, but I'm not sure why.
> > > > > 
> > > > > Do we have multiple URIs pointing to the same path? What are they 
> > > > > concretely?
> > > > This is the main thing in this patch. I will try to explain.
> > > > We use these keys to create the file list, which is used by 
> > > > `indexedFiles()`.
> > > > Currently, the preamble index contains URI's instead of paths (as a 
> > > > file list), that leads to the function returned by 
> > > > `PreambleIndex::indexedFiles()` always return `false` (because we pass 
> > > > to this function paths, not URI's). So, we always take data from the 
> > > > preamble index (but maybe we should not in some cases).
> > > > 
> > > Oooh... I'm not sure how I misunderstood the original so much :-( And I 
> > > missed it in this patch description as well, apologies.
> > > 
> > > My impression was that the file list was derived from the index data, 
> > > rather than from the keys, which were always intended to be 
> > > opaque/arbitrary.
> > > (At various times, these have been filenames, URIs, and other things 
> > > IIRC. And until relatively recently, the preamble index keys were the 
> > > file the preamble was built from, not the file containing the symbol!)
> > > 
> > > It feels like using URIs extracted from symbols might not be *completely* 
> > > robust. Because having CanonicalDeclaration etc set to a file might not 
> > > line up exactly with the idea that we indexed the file. But we do use 
> > > this partitioning for FileShardedIndex, so it has to work well enough.
> > > 
> > > The advantage of using the extracted URIs would be: also works for 
> > > non-file-sharded indexes like --index-file, avoid a bunch of conversion 
> > > between URI and path, and we get to keep the simpler/flexible design for 
> > > FileSymbols where the key is opaque.
> > > 
> > > Does this seem feasible to you?
> > > that leads to the function returned by `PreambleIndex::indexedFiles()` 
> > > always return `false` (because we pass to this function paths, not URI's)
> > 
> > This is a bit incorrect.
> > We pass to this function URI, but this URI is converted to path. i.e. 
> > `MemIndex::indexedFiles()`, `Dex::indexedFiles()` expect that `Files` are 
> > paths, but they are URI's for the preamble index. That's why 
> > `PreambleIndex::indexedFiles()` always return `false`.
> I also do not like these path <=> URI conversions. But what about empty 
> files?, e.g.:
> - open a file
> - remove everything from this file
> - the dynamic index has no symbols with definition/declaration from this 
> file, so we do not have this file in the dynamic index file list.
> - the static index has symbols with definition/declaration from this file, so 
> we have this file in the static index file list.
> - we will show stale results from the static index for this file.
> 
> 
> Unsure, maybe it's ok to ignore the problem with empty files, seems this is 
> the only case when the file was indexed, but we have no symbols located there.
> 
> Overall, I like the idea to use URI's instead of paths. I think we could 
> implement it first as a separate patch and after that return to this one.
> 
> What do you think?
Right, completely empty files are going to be mishandled., in the same way that 
before your changes we mishandled files that had no results from the query.

I do still think this is the way to go though, because:
 - completely empty files are much rarer
 - again this is a peer to an FileShardedIndex issue where empty files get no 
shards. Therefore *within* the dynamic index, we'll never clear out the symbols 
for a file while the file is emptied
 - having SymbolCollector explicitly the files indexed is the principled 
solution to both problems, and that seems feasible for us to do at some point.

> Overall, I like the idea to use URI's instead of paths. I think we could 
> implement it first as a separate patch and after that return to this one.

That sounds great if you don't mind!
(Is there a reason we can't land the rest of this patch as-is already?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94952

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


[PATCH] D95423: [clangd] Add std::size_t to StdSymbol mapping

2021-01-26 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.

This might annoy people occasionally, but so does the current behavior.
I guess inserting *nothing* might be better, we could have a list of symbols 
known to have no insertable header. But we don't have that today, and this is 
an improvement we can land before the 12 release.

stddef seems like the best choice among the headers that provide size_t.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95423

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


[PATCH] D95439: [clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.

2021-01-26 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/D95439

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
@@ -770,6 +770,10 @@
 }
 
 ns::X $return[[func]]() {}
+
+class T {
+  ns::X $field[[x]];
+};
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.ExtraArgs.push_back("-std=c++17");
@@ -779,57 +783,64 @@
 
   EXPECT_THAT(
   TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  AllOf(Diag(Test.range("nested"),
- "incomplete type 'ns::X' named in nested name specifier"),
-DiagName("incomplete_nested_name_spec"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("base"), "base class has incomplete type"),
-DiagName("incomplete_base_class"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("access"),
- "member access into incomplete type 'ns::X'"),
-DiagName("incomplete_member_access"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(
-  Diag(Test.range("type"),
+  testing::UnorderedElementsAreArray(
+  {AllOf(Diag(Test.range("nested"),
+  "incomplete type 'ns::X' named in nested name specifier"),
+ DiagName("incomplete_nested_name_spec"),
+ WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ "Add include \"x.h\" for symbol ns::X"))),
+   AllOf(Diag(Test.range("base"), "base class has incomplete type"),
+ DiagName("incomplete_base_class"),
+ WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ "Add include \"x.h\" for symbol ns::X"))),
+   AllOf(Diag(Test.range("access"),
+  "member access into incomplete type 'ns::X'"),
+ DiagName("incomplete_member_access"),
+ WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ "Add include \"x.h\" for symbol ns::X"))),
+   AllOf(
+   Diag(
+   Test.range("type"),
"incomplete type 'ns::X' where a complete type is required"),
-  DiagName("incomplete_type"),
-  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-  "Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("incomplete"),
- "variable has incomplete type 'ns::X'"),
-DiagName("typecheck_decl_incomplete_type"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(
-  Diag(Test.range("tag"), "incomplete definition of type 'ns::X'"),
-  DiagName("typecheck_incomplete_tag"),
-  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-  "Add include \"x.h\" for symbol ns::X"))),
-  AllOf(
-  Diag(Test.range("use"), "invalid use of incomplete type 'ns::X'"),
-  DiagName("invalid_incomplete_type_use"),
-  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-  "Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("sizeof"), "invalid application of 'sizeof' to "
-   "an incomplete type 'ns::X'"),
-DiagName("sizeof_alignof_incomplete_or_sizeless_type"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("for"),
- "cannot use incomplete type 'ns::X' as a range"),
-DiagName("for_range_incomplete_type"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("return"),
- "incomplete result type 'ns::X' in function definition"),
-DiagNa

[PATCH] D94614: [FPEnv][X86] Platform builtins edition: clang should get from the AST the metadata for constrained FP builtins

2021-01-26 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks


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

https://reviews.llvm.org/D94614

___
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-26 Thread Zarko Todorovski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ZarkoCA marked an inline comment as done.
Closed by commit rG028d7a36681f: Remove requirement for -maltivec to be used 
when using -mabi=vec-extabi or… (authored by ZarkoCA).

Repository:
  rG LLVM Github Monorepo

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

[PATCH] D95408: [Sema][C] members of anonymous struct inherit QualType

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I know we don't have to deal with `restrict` because that qualifies a pointer 
(so there's no way to use it with an anonymous struct), but are there others? 
There's `DeclSpec::TQ_unaligned` (which has no corresponding qualifier in 
`Qualifiers::TQ` despite the comment about keeping them in sync). Similarly, 
what about:

  struct S {
_Atomic struct {
  int i;
};
  }
  
  void foo(void) {
struct S s;
s.i = 12; // Is this an atomic assignment?
  }

Further, do we have to worry about things which are not type specifiers but 
still impact the declaration, like various type attributes?




Comment at: clang/test/AST/ast-dump-decl.c:132
 
+// CHECK: IndirectFieldDecl{{.*}} Test48755Const 'int'
+// CHECK-NEXT: Field{{.*}} 'const struct testIndirectFieldDecl::{{.*}}'

This looks wrong to me -- I would have assumed the type would be `const int` 
and not `int`, which would match the behavior if the type was directly 
qualified: https://godbolt.org/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95408

___
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-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319276.
abhina.sreeskantharajan added a comment.
Herald added subscribers: mgorny, emaste.

This patch makes the following changes:

- Define LLVM_HOST_TRIPLE for lld tests. (This was the project that didn't have 
host defined.)
- Change %err_no_such_file_or_directory to %errc_ENOENT as suggested by 
jhenderson

I've also created a post on llvm-dev about this patch: 
https://lists.llvm.org/pipermail/llvm-dev/2021-January/148089.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/test/Object/archive-extract.test
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,14 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self, triple):
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +366,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions(self.config.host_triple)
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 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
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
 config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -111,6 +111,10 @@
 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
 set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+if (LLD_BUILT_STANDALONE)
+  set(LLVM_HOST_TRIPLE ${TARGET_TRIPLE})
+endif()
+
 set(LLD_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with ve

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

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan requested review of this revision.
abhina.sreeskantharajan marked 4 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-354
+if (re.match(r's390x-.*-zos', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'EDC5129I 
No such file or directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'no such 
file or directory\''))
+else:
+
self.config.substitutions.append(('%err_no_such_file_or_directory', '\'No such 
file or directory\''))

jhenderson wrote:
> These lines are quite long, so probably want reflowing.
> 
> I wonder if `%errc_...` might be a better name? That way, it ties to the 
> `std::errc` values these match up with.
Thanks, I've changed the error messages to your suggestion.



Comment at: llvm/utils/lit/lit/llvm/config.py:369-370
 
+if hasattr(self.config, 'host_triple'):
+   self.add_err_msg_substitutions(self.config.host_triple) 
+

jhenderson wrote:
> Under what conditions can there not be a `host_triple`? In those cases, what 
> happens to the tests that use the new substitution?
This was not defined for lld. I added changes to define this for lld and 
removed the check. I think this is defined in all the other projects.


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] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Pinging the reviewers to help with the naming questions.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2867
+extern const internal::MapAnyOfMatcher
+callOrConstruct;
+

steveire wrote:
> aaron.ballman wrote:
> > steveire wrote:
> > > aaron.ballman wrote:
> > > > I'm not super keen on this name. It's certainly descriptive, but I do 
> > > > wonder if it's a bit too specific and should perhaps be something more 
> > > > like `callableExpr()`, `callLikeExpr()`, or something more generic. For 
> > > > instance, I could imagine wanting this to match on something like:
> > > > ```
> > > > struct S {
> > > >   void setter(int val) {}
> > > >   __declspec(property(put = setter)) int x;
> > > > };
> > > > 
> > > > int main() {
> > > >   S s;
> > > >   s.x = 12; // Match here
> > > >   // Because the above code actually does this:
> > > >   // s.setter(12);
> > > > }
> > > > ```
> > > > because this also has an expression that isn't really a call (as far as 
> > > > our AST is concerned) but is a call as far as program semantics are 
> > > > concerned. I'm not suggesting to make the matcher support that right 
> > > > now (unless you felt like doing it), but thinking about the future and 
> > > > avoiding a name that may paint us into a corner.
> > > > 
> > > > WDYT about using a more generic name?
> > > I haven't seen code like that before (ms extension?) 
> > > https://godbolt.org/z/anvd43 but I think that should be matched by 
> > > `binaryOperator` instead. That already matches based on what the code 
> > > looks like, rather than what it is in the AST.
> > > 
> > > This `callOrConstruct` is really for using `hasArgument` and related 
> > > submatchers with nodes which support it. As such I think the name is 
> > > fine. I don't like `callableExpr` or `callLikeExpr` because they don't 
> > > bring to mind the possibility that construction is also supported.
> > > I haven't seen code like that before (ms extension?)
> > 
> > Yes, it's an MS extension.
> > 
> > > That already matches based on what the code looks like, rather than what 
> > > it is in the AST.
> > 
> > Yes, but these are AST matchers, so it's reasonable to match on what's in 
> > the AST (as well as what the code looks like, of course). I'm not arguing 
> > it needs to be supported so much as pointing out that there are other AST 
> > nodes this notionally applies to where the name is a bit too specific.
> > 
> > > This callOrConstruct is really for using hasArgument and related 
> > > submatchers with nodes which support it. As such I think the name is 
> > > fine. I don't like callableExpr or callLikeExpr because they don't bring 
> > > to mind the possibility that construction is also supported.
> > 
> > I'm pretty sure we've extended what `hasArgument` can be applied to in the 
> > past (but I've not verified), so the part that worries me is specifically 
> > naming the nodes as part of the identifier. This effectively means that if 
> > we ever find another AST node for `hasArgument`, we either need a different 
> > API like `callConstructOrWhatever` or we're stuck with a poor name.
> > 
> > Another (smaller) concern with the name is that `callOrConstruct` can 
> > describe declarations as well as expressions, to some degree as you can 
> > declare calls and constructors. It's a smaller concern because those at 
> > least share a common base class. `callOrConstructExpr` would clarify this 
> > easily enough.
> > 
> > I see you added `ObjCMessageExpr` as well, thank you for that! It's a 
> > perhaps better example of why this name feels awkward to me. In ObjC, you 
> > don't call an `ObjCMessageExpr`, you "send" it to the given object or 
> > class. That suggests to me that `callableExpr` or `callLikeExpr` is also 
> > not a great name either.
> > 
> > Perhaps `executableExpr` because you're executing some code?
> > Perhaps `executableExpr` because you're executing some code?
> 
> The thing that this really does is make it possible to use `hasArgument` and 
> related matchers with the nodes that that matcher supports. So, something 
> with `argument` in the name probably makes sense. Like `argumentExpr`. 
> 
> The thing that this really does is make it possible to use hasArgument and 
> related matchers with the nodes that that matcher supports. So, something 
> with argument in the name probably makes sense. Like argumentExpr.

A name like `argumentExpr()` would make me think we're trying to match the `42` 
in an expression like `foo(42)` (e.g., it makes me think we're going to match 
on expressions that are arguments to a call).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865

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


[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 319282.
FreddyYe added a comment.

If Clobber is edx only, don't change "={eax}" to "=&{eax}".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGenCXX/ms-inline-asm-return.cpp

Index: clang/test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- clang/test/CodeGenCXX/ms-inline-asm-return.cpp
+++ clang/test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -13,7 +13,17 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_i64()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&A,{{.*}}"
+// CHECK: ret i64 %[[r]]
+
+long long f_i64_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i64 @f_i64_reverse()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&A,{{.*}}"
 // CHECK: ret i64 %[[r]]
 
 int f_i32() {
@@ -23,7 +33,26 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_i32()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_reverse()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_edx() {
+  __asm {
+mov edx, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_edx()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1", "={eax},~{edx},{{.*}}"
 // CHECK: ret i32 %[[r]]
 
 short f_i16() {
@@ -33,7 +62,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i16 @f_i16()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
 // CHECK: ret i16 %[[r_i16]]
 
@@ -44,7 +73,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i8 @f_i8()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: ret i8 %[[r_i8]]
 
@@ -55,7 +84,7 @@
   }
 }
 // CHECK-LABEL: define dso_local zeroext i1 @f_i1()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: store i8 %[[r_i8]], i8* %{{.*}}
 // CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}}
@@ -70,7 +99,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_s4()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "=&{eax},{{.*}}"
 // CHECK: store i32 %[[r]], i32* %{{.*}}
 // CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}}
 // CHECK: ret i32 %[[r_i32]]
@@ -85,7 +114,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_s8()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=&A,{{.*}}"
 // CHECK: store i64 %[[r]], i64* %{{.*}}
 // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}}
 // CHECK: ret i64 %[[r_i64]]
@@ -96,5 +125,5 @@
   __asm xor eax, eax
 }
 // CHECK-LABEL: define dso_local i32 @main()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "=&{eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
Index: clang/test/CodeGen/ms-inline-asm.c
===
--- clang/test/CodeGen/ms-inline-asm.c
+++ clang/test/CodeGen/ms-inline-asm.c
@@ -114,7 +114,7 @@
 // CHECK: call i32 asm sideeffect inteldialect
 // CHECK-SAME: mov eax, $2
 // CHECK-SAME: mov $0, eax
-// CHECK-SAME: "=*m,={eax},*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
+// CHECK-SAME: "=*m,=&{eax},*m,~{dirflag},~{fpsr

[PATCH] D94466: [X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM

2021-01-26 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 319284.
FreddyYe added a comment.

refine clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94466

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGenCXX/ms-inline-asm-return.cpp

Index: clang/test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- clang/test/CodeGenCXX/ms-inline-asm-return.cpp
+++ clang/test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -13,7 +13,17 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_i64()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&A,{{.*}}"
+// CHECK: ret i64 %[[r]]
+
+long long f_i64_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i64 @f_i64_reverse()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&A,{{.*}}"
 // CHECK: ret i64 %[[r]]
 
 int f_i32() {
@@ -23,7 +33,26 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_i32()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_reverse() {
+  __asm {
+mov edx, 1
+mov eax, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_reverse()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1\0A\09mov eax, $$1", "=&{eax},~{edx},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+int f_i32_edx() {
+  __asm {
+mov edx, 1
+  }
+}
+// CHECK-LABEL: define dso_local i32 @f_i32_edx()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov edx, $$1", "={eax},~{edx},{{.*}}"
 // CHECK: ret i32 %[[r]]
 
 short f_i16() {
@@ -33,7 +62,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i16 @f_i16()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
 // CHECK: ret i16 %[[r_i16]]
 
@@ -44,7 +73,7 @@
   }
 }
 // CHECK-LABEL: define dso_local signext i8 @f_i8()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: ret i8 %[[r_i8]]
 
@@ -55,7 +84,7 @@
   }
 }
 // CHECK-LABEL: define dso_local zeroext i1 @f_i1()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=&{eax},~{edx},{{.*}}"
 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
 // CHECK: store i8 %[[r_i8]], i8* %{{.*}}
 // CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}}
@@ -70,7 +99,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i32 @f_s4()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$16843009", "=&{eax},{{.*}}"
 // CHECK: store i32 %[[r]], i32* %{{.*}}
 // CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}}
 // CHECK: ret i32 %[[r_i32]]
@@ -85,7 +114,7 @@
   }
 }
 // CHECK-LABEL: define dso_local i64 @f_s8()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$85", "=&A,{{.*}}"
 // CHECK: store i64 %[[r]], i64* %{{.*}}
 // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}}
 // CHECK: ret i64 %[[r_i64]]
@@ -96,5 +125,5 @@
   __asm xor eax, eax
 }
 // CHECK-LABEL: define dso_local i32 @main()
-// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "=&{eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
Index: clang/test/CodeGen/ms-inline-asm.c
===
--- clang/test/CodeGen/ms-inline-asm.c
+++ clang/test/CodeGen/ms-inline-asm.c
@@ -114,7 +114,7 @@
 // CHECK: call i32 asm sideeffect inteldialect
 // CHECK-SAME: mov eax, $2
 // CHECK-SAME: mov $0, eax
-// CHECK-SAME: "=*m,={eax},*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
+// CHECK-SAME: "=*m,=&{eax},*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})

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

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

On further digging as to how pointer-to-members are handled in StaticAnalyzer, 
I discovered that in `BasicValueFactory::accumCXXBase() for the example given 
in my test produces the two `CXXBaseSpecifier` for the pointer-to-member. At 
line 195, one base specifier is added while the other is added in the loop in 
201. The loop accounts for the static_cast while line 195 adds a base specifier 
from the expression being cast. 
This causes the duplication. I will try to update this patch to handle the 
duplication.


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] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: mantognini.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

References to functions are less permissive than pointers to functions and 
therefore some use cases could be allowed for example:

- For local variables
- For non-extern static and global variables
- For template parameters that are not used as function parameters or class 
members
- In constexpr

However, more language work is needed to analyze the invalid/valid cases. This 
can be done in the future language versions if there is enough interest in the 
feature from the application developers. Even if we had  a request for allowing 
some function pointer functionality (PR44788), OpenCL has never adopted the 
feature as a part of the standard and therefore many applications have been 
written successfully without it. On the other hand C++ provides other related 
features - lambdas and function objects that are allowed in OpenCL and can be 
used to express some sort of the indirect function call logic. For now it seems 
reasonable to just disallow the references to functions just like we disallow 
function pointers. This prevents erroneous programs from being compiled 
silently.

Note that for the advanced users there is the following extension available 
`__cl_clang_function_pointers` that can be used if there is knowledge about the 
application sources or compilation options to make sure the non-conformant 
functionality is safe (more details are in 
https://clang.llvm.org/docs/LanguageExtensions.html#opencl-features).


https://reviews.llvm.org/D95442

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/references.cl


Index: clang/test/SemaOpenCLCXX/references.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/references.cl
@@ -0,0 +1,43 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only -DFPTREXT
+
+#ifdef FPTREXT
+#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
+#endif // FPTREXT
+
+// References to functions are not allowed.
+struct myclass {
+  void (&mem)();
+//FIXME: Here we provide incorrect diagnostic.
+#ifndef FPTREXT
+//expected-error@-3{{reference to function type cannot have '__generic' 
qualifier}}
+#endif // FPTREXT
+};
+
+void (&glob)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'glob' requires an 
initializer}}
+#endif // FPTREXT
+template 
+void templ() {
+  // FIXME: We miss to diagnose the reference to function.
+  T loc; //expected-error{{declaration of reference variable 'loc' requires an 
initializer}}
+}
+
+void foo();
+void test(void (&par)()) {
+  void (&loc)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'loc' requires an 
initializer}}
+#endif // FPTREXT
+
+  void (*&ref2fptr)();
+#ifndef FPTREXT
+//expected-error@-2{{pointers to functions are not allowed}}
+//expected-error@-3{{declaration of reference variable 'ref2fptr' requires an 
initializer}}
+#endif // FPTREXT
+
+  templ(); //expected-note{{in instantiation of function template 
specialization}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2091,7 +2091,7 @@
 
   if (T->isFunctionType() && getLangOpts().OpenCL &&
   !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-Diag(Loc, diag::err_opencl_function_pointer);
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
 return QualType();
   }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6752,9 +6752,12 @@
   // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
   if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
 QualType NR = R;
-while (NR->isPointerType() || NR->isMemberFunctionPointerType()) {
-  if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType()) {
-Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer);
+while (NR->isPointerType() || NR->isMemberFunctionPointerType() ||
+   NR->isReferenceType()) {
+  if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType() ||
+  NR->isFunctionReferenceType()) {
+Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer)
+<< NR->isReferenceType();
 D.setInvalidType();
 return false;
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===

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

2021-01-26 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand 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 see, thanks.   I think what would make sense to preserve existing behavior 
while still allowing other platforms to use different dialects for GNU inline 
asm would be to move the decision which dialect to use for inline asm to the 
back-end.  I've posted a patch along those lines as 
https://reviews.llvm.org/D95444 - I hope we can continue the discussion there.


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] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

fhahn wrote:
> rjmccall wrote:
> > nikic wrote:
> > > This change looks pretty fishy. Objective C shouldn't be hijacking LLVMs 
> > > core instruction model in this way. If it writes to memory, this should 
> > > either be reflected in the attributes, or modeled using operand bundles.
> > > 
> > > @fhahn Did you review these changes? If not, I'd suggest to revert this 
> > > patch and get a review on the LLVM changes.
> > This could definitely be an operand bundle, and I suppose the presence of a 
> > bundle does force a conservative assumption on passes.
> > @fhahn Did you review these changes? 
> 
> Nope I didn't have time to look at this so far.
> 
> 
> 
> Can functions marked as `readonly`/`readnone` be called with the objc 
> attributes? 
> 
> I'm not very familiar with ObjC, but even for a function that just returns a 
> passed in object id, don't we need to retain & release the object in the 
> function? Which means the function cannot be `readonly` because we need to 
> call `@llvm.objc*` functions? If that's the case, could we just check in the 
> verifier that the attributes are never used with `readonly` functions?
> 
> If there are indeed cases where we can call `readonly` functions, operand 
> bundles would probably be safest. It would probably also good to have at 
> least a few alias-analysis tests, to make sure things work as expected.
A function compiled using ARC can call a function compiled using MRR, which can 
be readonly/readnone. Also, a function compiled using ARC can be marked as 
readonly/readnone (if an optimization pass wants to do so) after ARC optimizer 
removes the retainRV/autoreleaseRV pair.

```
define i8* @foo() {
  %1 = tail call i8* @readonlyMRRFunc()
  ; This function can be readonly if ARC optimizer removes the following two 
instructions.
  %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
  %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
  ret i8* 
}
```



Comment at: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:576
+// Don't change the return type of the function if it has retainRV/claimRV.
+if (objcarc::hasRetainRVOrClaimRVAttr(CB)) {
+  NumLiveRetVals = RetCount;

fhahn wrote:
> This seems fragile. IIUC this workaround is needed because the return value 
> of a `retainRV/claimRV` function always has one implicit use. This aspect 
> could get missed in other places as well.
> 
> As an alternative, could the frontend insert 'dummy' uses (e.g. 
> `llvm.objc.arc.use`) to make this assumption transparent? Those could be 
> removed sufficiently late. Their placement doesn't really matter and neither 
> does if any instructions are moved between the original call and the dummy 
> use, but the fact that the returned value is used is now explicit. IICU they 
> could be marked as accessing inaccessible memory only, so they should be too 
> much trouble for other optimizations (at least not more than the previous 
> explicit release calls). Or perhaps there's a different way to mark the 
> return value as used explicitly.
> 
I think we can make the front-end insert a dummy use instruction. The front-end 
currently emits `@llvm.objc.clang.arc.use` in some cases to make sure the 
object doesn't get released too early, but we can't use that in this case since 
ARC optimizer treats a call to `@llvm.objc.clang.arc.use` as a real use, so we 
probably need a new intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

ahatanak wrote:
> fhahn wrote:
> > rjmccall wrote:
> > > nikic wrote:
> > > > This change looks pretty fishy. Objective C shouldn't be hijacking 
> > > > LLVMs core instruction model in this way. If it writes to memory, this 
> > > > should either be reflected in the attributes, or modeled using operand 
> > > > bundles.
> > > > 
> > > > @fhahn Did you review these changes? If not, I'd suggest to revert this 
> > > > patch and get a review on the LLVM changes.
> > > This could definitely be an operand bundle, and I suppose the presence of 
> > > a bundle does force a conservative assumption on passes.
> > > @fhahn Did you review these changes? 
> > 
> > Nope I didn't have time to look at this so far.
> > 
> > 
> > 
> > Can functions marked as `readonly`/`readnone` be called with the objc 
> > attributes? 
> > 
> > I'm not very familiar with ObjC, but even for a function that just returns 
> > a passed in object id, don't we need to retain & release the object in the 
> > function? Which means the function cannot be `readonly` because we need to 
> > call `@llvm.objc*` functions? If that's the case, could we just check in 
> > the verifier that the attributes are never used with `readonly` functions?
> > 
> > If there are indeed cases where we can call `readonly` functions, operand 
> > bundles would probably be safest. It would probably also good to have at 
> > least a few alias-analysis tests, to make sure things work as expected.
> A function compiled using ARC can call a function compiled using MRR, which 
> can be readonly/readnone. Also, a function compiled using ARC can be marked 
> as readonly/readnone (if an optimization pass wants to do so) after ARC 
> optimizer removes the retainRV/autoreleaseRV pair.
> 
> ```
> define i8* @foo() {
>   %1 = tail call i8* @readonlyMRRFunc()
>   ; This function can be readonly if ARC optimizer removes the following two 
> instructions.
>   %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
>   %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
>   ret i8* 
> }
> ```
> A function compiled using ARC can call a function compiled using MRR, which 
> can be readonly/readnone

Ok, sounds like a bundle would be a good option then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-26 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: awarzynski, sscalpone, sameeranjoshi, SouraVX, 
tskeith, kiranktp, AMDChirag.
Herald added a subscriber: dang.
Herald added a reviewer: jansvoboda11.
arnamoy10 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for option -J/-module-dir in the new Flang driver.
This will allow for including module files in other directories, as the default 
search path is currently the working folder.  This also provides an option of 
storing the output module in the specified folder.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95448

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/include/flang/Parser/parsing.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- flang/test/Flang-Driver/include-module.f90
+++ flang/test/Flang-Driver/include-module.f90
@@ -1,4 +1,4 @@
-! Ensure argument -I works as expected with module files.
+! Ensure argument -I, -J and -module-dir works as expected with module files.
 ! The module files for this test are not real module files.
 
 ! REQUIRES: new-flang-driver
@@ -8,12 +8,20 @@
 !--
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
 
 !-
 ! FRONTEND FLANG DRIVER (flang-new -fc1)
 !-
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
 
 !-
 ! EXPECTED OUTPUT FOR MISSING MODULE FILE
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -26,6 +26,7 @@
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-NEXT: -module-dir  Add to the list of directories to be searched by an USE statement
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
@@ -41,6 +42,7 @@
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-FC1-NEXT: -module-dir  Add to the list of directories to be searched by an USE statement
 ! HELP-FC1-NEXT: -o   Write output to 
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -26,6 +26,7 @@
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
+! CHECK-NEXT: -module-dir  Add to the list of directories to be s

[PATCH] D95417: [NFC] Disallow unused prefixes under clang/test/CodeGen

2021-01-26 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c0d009a88f2: [NFC] Disallow unused prefixes under 
clang/test/CodeGen (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95417

Files:
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-overflow-volatile.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/CodeGen/cmse-clear-return.c
  clang/test/CodeGen/lit.local.cfg

Index: clang/test/CodeGen/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGen/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGen/cmse-clear-return.c
===
--- clang/test/CodeGen/cmse-clear-return.c
+++ clang/test/CodeGen/cmse-clear-return.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple thumbv8m.main   -O0 -mcmse -S -emit-llvm %s -o - | \
 // RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-NOPT,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbebv8m.main -O0 -mcmse -S -emit-llvm %s -o - | \
-// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-BE-NOPT,CHECK-SOFT
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbv8m.main   -O2 -mcmse -S -emit-llvm %s -o - | \
 // RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-OPT,CHECK-SOFT
 // RUN: %clang_cc1 -triple thumbebv8m.main -O2 -mcmse -S -emit-llvm %s -o - | \
Index: clang/test/CodeGen/catch-pointer-overflow.c
===
--- clang/test/CodeGen/catch-pointer-overflow.c
+++ clang/test/CodeGen/catch-pointer-overflow.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fsanitize-trap=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-C,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
 
-// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-CPP,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c++ -fsanitize=point

[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/references.cl:24
+void templ() {
+  // FIXME: We miss to diagnose the reference to function.
+  T loc; //expected-error{{declaration of reference variable 'loc' requires an 
initializer}}

I have created PR48887 for this because we also miss other diagnotics.



Comment at: clang/test/SemaOpenCLCXX/references.cl:29
+void foo();
+void test(void (&par)()) {
+  void (&loc)();

oops, I thought this was covered in my patch. I will see if there is a quick 
fix and if not I will create another PR.


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

https://reviews.llvm.org/D95442

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


[PATCH] D95450: [clangd] Respect ReferencesParams.context.includeDeclarations

2021-01-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
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.

Unfortunately this treats overrides declarations as declarations, not as
references. I don't plan to land this until I have a fix for that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95450

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/references.test
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -37,6 +37,7 @@
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
@@ -290,7 +291,8 @@
 
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
-MATCHER_P(RangeIs, R, "") { return arg.range == R; }
+MATCHER_P(RangeIs, R, "") { return arg.Loc.range == R; }
+MATCHER_P(AttrsAre, A, "") { return arg.Attributes == A; }
 
 TEST(LocateSymbol, WithIndex) {
   Annotations SymbolHeader(R"cpp(
@@ -1688,11 +1690,35 @@
   << Test;
 }
 
+void checkFindRefs(llvm::StringRef Test, bool UseIndex = false) {
+  Annotations T(Test);
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  std::vector> ExpectedLocations;
+  for (const auto &R : T.ranges())
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Plain)));
+  // $def is actually shorthand for both definition and declaration.
+  // If we have cases that are definition-only, we should change this.
+  for (const auto &R : T.ranges("def"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Definition |
+   ReferencesResult::Declaration)));
+  for (const auto &R : T.ranges("decl"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Declaration)));
+  EXPECT_THAT(
+  findReferences(AST, T.point(), 0, UseIndex ? TU.index().get() : nullptr)
+  .References,
+  UnorderedElementsAreArray(ExpectedLocations))
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
-  int [[foo]];
+  int $def[[foo]];
   [[^foo]] = 2;
   int test1 = [[foo]];
 }
@@ -1700,7 +1726,7 @@
 
   R"cpp(// Struct
 namespace ns1 {
-struct [[Foo]] {};
+struct $def[[Foo]] {};
 } // namespace ns1
 int main() {
   ns1::[[Fo^o]]* Params;
@@ -1708,15 +1734,15 @@
   )cpp",
 
   R"cpp(// Forward declaration
-class [[Foo]];
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 int main() {
   [[Fo^o]] foo;
 }
   )cpp",
 
   R"cpp(// Function
-int [[foo]](int) {}
+int $def[[foo]](int) {}
 int main() {
   auto *X = &[[^foo]];
   [[foo]](42);
@@ -1725,7 +1751,7 @@
 
   R"cpp(// Field
 struct Foo {
-  int [[foo]];
+  int $def[[foo]];
   Foo() : [[foo]](0) {}
 };
 int main() {
@@ -1735,8 +1761,8 @@
   )cpp",
 
   R"cpp(// Method call
-struct Foo { int [[foo]](); };
-int Foo::[[foo]]() {}
+struct Foo { int $decl[[foo]](); };
+int Foo::$def[[foo]]() {}
 int main() {
   Foo f;
   f.[[^foo]]();
@@ -1745,7 +1771,7 @@
 
   R"cpp(// Constructor
 struct Foo {
-  [[F^oo]](int);
+  $decl[[F^oo]](int);
 };
 void foo() {
   Foo f = [[Foo]](42);
@@ -1753,14 +1779,14 @@
   )cpp",
 
   R"cpp(// Typedef
-typedef int [[Foo]];
+typedef int $def[[Foo]];
 int main() {
   [[^Foo]] bar;
 }
   )cpp",
 
   R"cpp(// Namespace
-namespace [[ns]] {
+namespace $decl[[ns]] { // FIXME: def?
 struct Foo {};
 } // namespace ns
 int main() { [[^ns]]::Foo foo; }
@@ -1770,7 +1796,7 @@
 #define TYPE(X) X
 #define FOO Foo
 #define CAT(X, Y) X##Y
-class [[Fo^o]] {};
+class $def[[Fo^o]] {};
 void test() {
   TYPE([[Foo]]) foo;
   [[FOO]] foo2;
@@ -1780,7 +1806,7 @@
   )cpp",
 
   R"cpp(// Macros
-#define [[MA^CRO]](X) (X+1)
+#define $def[[MA^CRO]](X) (X+1)
 void test() {
   int x = [[MACRO]

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

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319309.
abhina.sreeskantharajan added a comment.

Fix CI: Other projects like flang also do not specify LLVM_HOST_TRIPLE. If this 
is not specified, set the triple to an empty string.

I also added one more error code %errc_EISDIR and updated the TestingGuide. 
Please let me know if there are other guides I will need to update that I'm not 
aware of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-failures.c
  clang/test/Frontend/stats-file.c
  lld/CMakeLists.txt
  lld/test/ELF/basic.s
  lld/test/lit.site.cfg.py.in
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,21 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple
+
+if (re.match(r's390x-.*-zos', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (re.match(r'.*windows.*', triple)):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +373,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ 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
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 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
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,14 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   Example (%errc_ENOENT): ``No such file or directory``
+
+   Example (%errc_ENOENT): ``no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/lit.site.cfg.py.in
===
--- lld/test/lit.site.cfg.py.in
+++ lld/test/lit.site.cfg.py.in
@@ -11,6 +11,7 @@
 config.lld_obj_root = "@LLD

[PATCH] D95439: [clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.

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



Comment at: clang-tools-extra/clangd/IncludeFixer.cpp:81
   case diag::err_func_def_incomplete_result:
+  case diag::err_field_incomplete_or_sizeless:
 // Incomplete type diagnostics should have a QualType argument for the

what about the `sizless` case ? we'll attach a fixit, but it is not going to 
fix the issue :(



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:786
   TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  AllOf(Diag(Test.range("nested"),
- "incomplete type 'ns::X' named in nested name specifier"),
-DiagName("incomplete_nested_name_spec"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("base"), "base class has incomplete type"),
-DiagName("incomplete_base_class"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("access"),
- "member access into incomplete type 'ns::X'"),
-DiagName("incomplete_member_access"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
-  AllOf(
-  Diag(Test.range("type"),
+  testing::UnorderedElementsAreArray(
+  {AllOf(Diag(Test.range("nested"),

nit: add a `using` decl instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95439

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


[PATCH] D95423: [clangd] Add std::size_t to StdSymbol mapping

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9190f17a7cc5: [clangd] Add std::size_t to StdSymbol mapping 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95423

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -92,6 +92,8 @@
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, std::, )
 #undef SYMBOL
 });
 StdSymbolMapping = Symbols;
@@ -99,6 +101,8 @@
 static const auto *CSymbols = new llvm::StringMap({
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, None, )
 #undef SYMBOL
 });
 StdSymbolMapping = CSymbols;


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -92,6 +92,8 @@
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, std::, )
 #undef SYMBOL
 });
 StdSymbolMapping = Symbols;
@@ -99,6 +101,8 @@
 static const auto *CSymbols = new llvm::StringMap({
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
+// There are multiple headers for size_t, pick one.
+SYMBOL(size_t, None, )
 #undef SYMBOL
 });
 StdSymbolMapping = CSymbols;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-01-26 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 319315.
whisperity added a comment.

  - Added a fallback case to also diagnose when Clang parsed the two types to 
be canonically the same (we will elaborate a few cases of such equivalences 
later, such as `typedef`s)
- Fixed Clang-Format and Clang-Tidy warnings in the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 3}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.
+
+int magic(int Left, int Right, int X, int Y) { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 4 adjacent parameters of 'magic' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in the range is 'Left'
+// CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'Y'
+
+void multipleDistinctTypes(int I, int J, int K,
+   long L, long M,
+   double D, double E, double F) {}
+// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:32: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-5]]:46: note: the last parameter in the range is 'K'
+// NO-WARN: The [long, long] range is length of 2.
+// CHECK-MESSAGES: :[[@LINE-5]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('double')
+// CHECK-MESSAGES: :[[@LINE-6]]:35: note: the first parameter in the range is 'D'
+// CHECK-MESSAGES: :[[@LINE-7]]:55: note: the last parameter in the range is 'F'
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -0,0 +1,141 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+#define assert(X)
+
+void declaration(int Param, int Other); // NO-WARN: No chance to change this function.
+
+struct S {};
+
+S *allocate() { return nullptr; }   // NO-WARN: 1 parameter.
+void allocate(S **Out) {}   // NO-WARN: 1 parameter.
+bool operator<(const S &LHS, const S &RHS) { return true; } // NO-WARN: Operator.
+
+void redeclChain(int, int, int);
+void redeclChain(int I, int, int);
+void redeclChain(int, int J, int);
+void redeclChain(int I, int J, int K) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 3 adjacent parameters of 'redeclChain' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:36: note: the last parameter in the range is 'K'
+
+void copyMany(S *Src, S *Dst, unsigned Num) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'copyMany' of similar type ('S *')
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'Src'
+// CHECK-MESSAGES: :[[@LINE-3]]:26: 

[PATCH] D95451: [clangd] references: decls of overrides of x are refs to x, not decls

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

This requires a second index query for refs to overrides, as the refs
call doesn't tell you which ref points at which symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95451

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1872,7 +1872,7 @@
 };
 class Derived : public Base {
 public:
-  void $decl[[func]]() override; // FIXME: ref, not decl
+  void [[func]]() override;
 };
 void test(Derived* D) {
   D->[[func]]();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -872,6 +872,7 @@
   struct Reference {
 syntax::Token SpelledTok;
 index::SymbolRoleSet Role;
+SymbolID Target;
 
 Range range(const SourceManager &SM) const {
   return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
@@ -906,13 +907,15 @@
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
 const SourceManager &SM = AST.getSourceManager();
-if (!isInsideMainFile(Loc, SM) ||
-TargetIDs.find(getSymbolID(D)) == TargetIDs.end())
+if (!isInsideMainFile(Loc, SM))
+  return true;
+SymbolID ID = getSymbolID(D);
+if (!TargetIDs.contains(ID))
   return true;
 const auto &TB = AST.getTokens();
 Loc = SM.getFileLoc(Loc);
 if (const auto *Tok = TB.spelledTokenAt(Loc))
-  References.push_back({*Tok, Roles});
+  References.push_back({*Tok, Roles, ID});
 return true;
   }
 
@@ -1298,6 +1301,7 @@
   }
 
   RefsRequest Req;
+  llvm::DenseSet Overrides;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
@@ -1336,7 +1340,6 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
 if (Index) {
   RelationsRequest FindOverrides;
   FindOverrides.Predicate = RelationKind::OverriddenBy;
@@ -1374,16 +1377,18 @@
   ReferencesResult::Reference Result;
   Result.Loc.range = Ref.range(SM);
   Result.Loc.uri = URIMainFile;
-  if (Ref.Role & static_cast(index::SymbolRole::Declaration))
-Result.Attributes |= ReferencesResult::Declaration;
-  // clang-index doesn't report definitions as declarations, but they are.
-  if (Ref.Role & static_cast(index::SymbolRole::Definition))
-Result.Attributes |=
-ReferencesResult::Definition | ReferencesResult::Declaration;
+  // Overrides are always considered references, not defs/decls.
+  if (!Overrides.contains(Ref.Target)) {
+if (Ref.Role & static_cast(index::SymbolRole::Declaration))
+  Result.Attributes |= ReferencesResult::Declaration;
+// clang-index doesn't report definitions as declarations, but they are.
+if (Ref.Role & static_cast(index::SymbolRole::Definition))
+  Result.Attributes |=
+  ReferencesResult::Definition | ReferencesResult::Declaration;
+  }
   Results.References.push_back(std::move(Result));
 }
 if (Index && Results.References.size() <= Limit) {
-  Req.IDs = std::move(Overrides);
   for (const Decl *D : Decls) {
 // Not all symbols can be referenced from outside (e.g.
 // function-locals).
@@ -1397,8 +1402,10 @@
 }
   }
   // Now query the index for references from other files.
-  if (!Req.IDs.empty() && Index && Results.References.size() <= Limit) {
-Req.Limit = Limit;
+  Req.Limit = Limit;
+  auto QueryIndex = [&](bool AllowAttributes) {
+if (Req.IDs.empty() || !Index || Results.References.size() > Limit)
+  return;
 Results.HasMore |= Index->refs(Req, [&](const Ref &R) {
   // No need to continue process if we reach the limit.
   if (Results.References.size() > Limit)
@@ -1409,15 +1416,22 @@
 return;
   ReferencesResult::Reference Result;
   Result.Loc = std::move(*LSPLoc);
-  if ((R.Kind & RefKind::Declaration) == RefKind::Declaration)
-Result.Attributes |= ReferencesResult::Declaration;
-  // FIXME: our index should definitely store def | decl separately!
-  if ((R.Kind & RefKind::Definition) == RefKind::Definition)
-Result.Attributes |=
-ReferencesResult::Declaration | ReferencesResult::Definition;
+  if (AllowAttributes) {
+if ((R.Kind 

[PATCH] D95229: [clangd] Treat optional field type mismatches as soft failures

2021-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 319321.
kadircet marked 4 inline comments as done.
kadircet added a comment.

As discussed offline, only treat "null" fields as missing, rather than allowing
type mismatches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95229

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

Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -27,6 +27,21 @@
 
 namespace clang {
 namespace clangd {
+namespace {
+
+// Helper that doesn't treat `null` and absent fields as failures.
+template 
+bool tryMap(const llvm::json::Value &Params, llvm::StringLiteral Prop, T &Out,
+llvm::json::Path P) {
+  auto *O = Params.getAsObject();
+  assert(O);
+  auto *V = O->get(Prop);
+  // Field is missing or null.
+  if (!V || V->getAsNull().hasValue())
+return true;
+  return fromJSON(*V, Out, P.field(Prop));
+}
+} // namespace
 
 char LSPError::ID;
 
@@ -490,7 +505,7 @@
   return O && O.map("textDocument", R.textDocument) &&
  O.map("contentChanges", R.contentChanges) &&
  O.map("wantDiagnostics", R.wantDiagnostics) &&
- O.mapOptional("forceRebuild", R.forceRebuild);
+ tryMap(Params, "forceRebuild", R.forceRebuild, P);
 }
 
 bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
@@ -580,10 +595,10 @@
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
   return O && O.map("range", R.range) && O.map("message", R.message) &&
- O.mapOptional("severity", R.severity) &&
- O.mapOptional("category", R.category) &&
- O.mapOptional("code", R.code) && O.mapOptional("source", R.source);
-  return true;
+ tryMap(Params, "severity", R.severity, P) &&
+ tryMap(Params, "category", R.category, P) &&
+ tryMap(Params, "code", R.code, P) &&
+ tryMap(Params, "source", R.source, P);
 }
 
 llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
@@ -817,9 +832,9 @@
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
   int TriggerKind;
-  if (!O || !O.map("triggerKind", TriggerKind) ||
-  !O.mapOptional("triggerCharacter", R.triggerCharacter))
+  if (!O || !O.map("triggerKind", TriggerKind))
 return false;
+  tryMap(Params, "triggerCharacter", R.triggerCharacter, P);
   R.triggerKind = static_cast(TriggerKind);
   return true;
 }
@@ -1121,8 +1136,8 @@
   llvm::json::ObjectMapper O(Params, P);
   if (!O)
 return true; // 'any' type in LSP.
-  return O.mapOptional("compilationDatabaseChanges",
-   S.compilationDatabaseChanges);
+  tryMap(Params, "compilationDatabaseChanges", S.compilationDatabaseChanges, P);
+  return true;
 }
 
 bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts,
@@ -1133,8 +1148,8 @@
 
   return fromJSON(Params, Opts.ConfigSettings, P) &&
  O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
- O.mapOptional("fallbackFlags", Opts.fallbackFlags) &&
- O.mapOptional("clangdFileStatus", Opts.FileStatus);
+ tryMap(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
+ tryMap(Params, "clangdFileStatus", Opts.FileStatus, P);
 }
 
 bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
@@ -1190,10 +1205,11 @@
   return O && O.map("name", I.name) && O.map("kind", I.kind) &&
  O.map("uri", I.uri) && O.map("range", I.range) &&
  O.map("selectionRange", I.selectionRange) &&
- O.mapOptional("detail", I.detail) &&
- O.mapOptional("deprecated", I.deprecated) &&
- O.mapOptional("parents", I.parents) &&
- O.mapOptional("children", I.children) && O.mapOptional("data", I.data);
+ tryMap(Params, "detail", I.detail, P) &&
+ tryMap(Params, "deprecated", I.deprecated, P) &&
+ tryMap(Params, "parents", I.parents, P) &&
+ tryMap(Params, "children", I.children, P) &&
+ tryMap(Params, "data", I.data, P);
 }
 
 bool fromJSON(const llvm::json::Value &Params,
@@ -1238,7 +1254,7 @@
   return O && O.map("name", I.name) && O.map("kind", I.kind) &&
  O.map("uri", I.uri) && O.map("range", I.range) &&
  O.map("selectionRange", I.selectionRange) &&
- O.mapOptional("data", I.data);
+ tryMap(Params, "data", I.data, P);
 }
 
 bool fromJSON(const llvm::json::Value &Params,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94806: [OpenMP] Add support for mapping names in mapper API

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message has just `Reviewers:`. The `Reviewers:` list does 
not necessarily mean all the people on the list have acknowledged the patch so 
`Reviewers:` is mostly useless. Many people agree that both `Reviewed:` & 
`Differential Revision:` should be present.

`arc amend` can fetch the Phabricator summary and amend the local description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94806

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


[PATCH] D95075: [hip] Fix `` compilation on Windows with VS2019.

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message does not include `Reviewed by:`. Many people agree 
that both `Reviewed by:` & `Differential Revision:` should be present. The 
`Reviewed by:` list indicates people who acknowledged the patch. (The 
`Reviewers:` list does not necessarily mean all the people on the list have 
acknowledged the patch so `Reviewers:` is mostly useless.)

`arc amend` can fetch the Phabricator summary and amend the local description.

You can install `llvm/.git/hooks/pre-push` to prevent accidental `Summary:`, 
`Reviewers:`, `Subscribers:` and `Tags:`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95075

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


[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In your commit the message does not include `Reviewed by:`. Many people agree 
that both `Reviewed by:` & `Differential Revision:` should be present. The 
`Reviewed by:` list indicates people who acknowledged the patch. (The 
`Reviewers:` list does not necessarily mean all the people on the list have 
acknowledged the patch so `Reviewers:` is mostly useless.)

`arc amend` can fetch the Phabricator summary and amend the local description.

You can install `llvm/.git/hooks/pre-push` to prevent accidental `Summary:`, 
`Reviewers:`, `Subscribers:` and `Tags:`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

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


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

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



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

curdeius wrote:
> kentsommer wrote:
> > MyDeveloperDay wrote:
> > > Are you sure `IncludeSortAlphabetically` expresses what you mean? Once 
> > > these things get released they cannot be changed easily.
> > > 
> > > If you were not sure of a new option, in my view we should slow down and 
> > > make sure we have the correct design, for example you could have used a 
> > > enum and it might have given you more possibility for greater flexibility
> > > 
> > > ```
> > > enum IncludeSort
> > > {
> > >CaseInsensitive
> > >CaseSensitive
> > > }
> > > ```
> > > 
> > > Please give people time to re-review your changes before we commit, 
> > > especially if they've taken the time to look at your review in the first 
> > > place. Just saying.
> > > 
> > Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> > through the review. I was simply trying to follow the process outlined in 
> > https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > mentions giving sufficient information to allow for a commit on your behalf 
> > when you don't have access after an LGTM (which is all that I did). As you 
> > can see from the lack of additional comments from my end, I was happy to 
> > let this sit and be reviewed. 
> > 
> > Per the discussion about the option itself, I do believe 
> > `IncludeSortAlphabetically` currently expresses what I mean as the behavior 
> > with this off is indeed not an alphabetical sort as case takes precedence 
> > over the alphabetical ordering. However, looking at the enum and realizing 
> > that others probably will have additional styles they prefer (maybe they 
> > want alphabetical but lower case first, etc.) I do believe it might have 
> > been a better way to go as it leaves more flexibility and room for 
> > additional ordering styles. Given that this just landed, I would be happy 
> > to open a patch to turn this into an `enum` as I do see benefits to doing 
> > so. What do you think?
> Hmmm, and how about using the existing option `SortIncludes` and change its 
> type from `bool` to some `enum`?
> We could then, for backward-compatibility, map `false` to (tentative) `Never` 
> and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.
> 
> This will have the advantage of not adding additional style options.
> ... and it will prove once again that using `bool`s for style options is not 
> a good idea.
I think that is an excellent idea @curdeius 


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] D94745: [OpenMP][deviceRTLs] Build the deviceRTLs with OpenMP instead of target dependent language

2021-01-26 Thread Shilei Tian 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 rG7c03f7d7d04c: [OpenMP][deviceRTLs] Build the deviceRTLs with 
OpenMP instead of target… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94745

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_80-sm_20.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  clang/test/Driver/openmp-offload-gpu.c
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/allocator.h
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/common/src/reduction.cu
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -13,18 +13,16 @@
 #define _TARGET_IMPL_H_
 
 #include 
-#include 
 #include 
 #include 
 #include 
 
 #include "nvptx_interface.h"
 
-#define DEVICE __device__
-#define INLINE __forceinline__ DEVICE
-#define NOINLINE __noinline__ DEVICE
-#define SHARED __shared__
-#define ALIGN(N) __align__(N)
+#define DEVICE
+#define INLINE inline __attribute__((always_inline))
+#define NOINLINE __attribute__((noinline))
+#define ALIGN(N) __attribute__((aligned(N)))
 
 
 // Kernel options
@@ -96,10 +94,6 @@
 INLINE uint32_t __kmpc_impl_ffs(uint32_t x) { return __builtin_ffs(x); }
 INLINE uint32_t __kmpc_impl_popc(uint32_t x) { return __builtin_popcount(x); }
 
-#ifndef CUDA_VERSION
-#error CUDA_VERSION macro is undefined, something wrong with cuda.
-#endif
-
 DEVICE __kmpc_impl_lanemask_t __kmpc_impl_activemask();
 
 DEVICE int32_t __kmpc_impl_shfl_sync(__kmpc_impl_lanemask_t Mask, int32_t Var,
Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -14,8 +14,6 @@
 #include "target_impl.h"
 #include "common/debug.h"
 
-#include 
-
 DEVICE void __kmpc_impl_unpack(uint64_t val, uint32_t &lo, uint32_t &hi) {
   asm volatile("mov.b64 {%0,%1}, %2;" : "=r"(lo), "=r"(hi) : "l"(val));
 }
Index: openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
@@ -11,7 +11,8 @@
 
 #include 
 
-#define EXTERN extern "C" __device__
+#define EXTERN extern "C"
+
 typedef uint32_t __kmpc_impl_lanemask_t;
 typedef uint32_t omp_lock_t; /* arbitrary type of the right length */
 
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -10,6 +10,21 @@
 #
 ##===--===##
 
+# TODO: This part needs to be refined when libomptarget is going to support
+# Windows!
+# TODO: This part can also be removed if we can change the clang driver to make
+# it support device only compilation.
+if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
+  set(aux_triple x86_64-unknown-linux-gnu)
+elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ppc64le")
+  set(aux_triple powerpc64le-unknown-linux-gnu)
+elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
+  set(aux_triple aarch64-unknown-linux-gnu)
+else()
+  libomptarget_say("Not building CUDA offloading device RTL: unknown host arch: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
+  return()
+endif()
+
 get_filename_component(devicertl_base_directory
   ${CMAKE_CURRENT_SOURCE_DIR}
   DIRECTORY)
@@ -79,61 +94,91 @@
 )
 
 # Set flags for LLVM Bitcode compilation.
-set(bc_flags ${LIBOMPTARGET_NVPTX_SELECTED_CUDA_COMPILER_FLAGS}
+set(bc_flags -S -x c++
+ -target nvptx64
+ -Xclang -emit-llvm-bc
+ -Xclang -aux-triple -Xclang ${aux_triple}
+ -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device
+ -D__CUDACC__
  -I${devicertl_base_directory}
  -I${devicertl_nvptx_directory}/src)
 
 if(${LIBOMPTARGET_NVPTX_DEBUG})
-  set(bc_flags ${bc_f

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

2021-01-26 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

In D94472#2519838 , @jansvoboda11 
wrote:

> In D94472#2508018 , @dexonsmith 
> wrote:
>
>> `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.

The only issue I have with this if always parsing twice has a noticeable 
performance impact for any users of Clang. Can we measure the impact? If it's 
small (< 100ms ?) then that's fine. I'm also concerned about users like cling 
and clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-01-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

@hliao -- Can you take a look at  https://bugs.llvm.org/show_bug.cgi?id=48866. 
This patch may be relevant there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D95451: [clangd] references: decls of overrides of x are refs to x, not decls

2021-01-26 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/XRefs.cpp:1406
+  Req.Limit = Limit;
+  auto QueryIndex = [&](bool AllowAttributes) {
+if (Req.IDs.empty() || !Index || Results.References.size() > Limit)

it might be nicer to make `IDs` a parameter too.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1409
+  return;
 Results.HasMore |= Index->refs(Req, [&](const Ref &R) {
   // No need to continue process if we reach the limit.

just thinking out loud, i wonder why we don't just provide a symbolid in this 
callback too. the interface currently says refs will be returned in any order, 
and i am not sure about all the index implementations we have, but i think they 
should be able to provide that for each reference. that way we could get rid of 
multiple index queries (not that it matters too much currently, but it might 
one day..)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95451

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 319337.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -430,6 +439,8 @@
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple &TheTriple) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with entry-size=0 but was placed in section '.debug_str' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_2' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_4' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 
+;; For GNU as before 2.35,
 ;; Don't create mergeable sections for globals with an explicit section name.
 ; RUN: echo '@explicit = unnamed_addr constant [2 x i16] [i16 1, i16 1], section ".explicit"' > %t.no_i_as.ll
-; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as 2>&1 \
-; RUN: | FileCheck %s --check-prefix=NO-I-AS
-; NO-I-AS: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-OLD
+; NO-I-AS-OLD: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.35 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-NEW
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=none 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-NEW
+; NO-I-AS-NEW: .section .explicit,"aM",@progbits,4,unique,1
Index: llvm/lib/Target/TargetMachine.cpp
===
--- llvm/lib/Target/TargetMachi

[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM I think, it would be good to get input from other reviewers




Comment at: clang/unittests/Format/FormatTest.cpp:13696
"  }\n"
-   "break;\n"
+   "  break;\n"
"}\n"

whilst I don't really like changing the indentation I don't think there was 
anything that says it was correct before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D95458: [PowerPC] Exploit xxsplti32dx (constant materialization) for scalars

2021-01-26 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: nemanjai, saghir, PowerPC.
Conanap added projects: LLVM, clang, PowerPC.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.

Previously related differential (exploit xxsplti32dx for vectors) here: 
https://reviews.llvm.org/D90173

This patch exploits the xxsplti32dx instruction available on Power10 in place 
of constant pool loads where xxspltidp would not be able to, usually because 
the immediate cannot fit into 32 bits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95458

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/constant-pool.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
  llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
  llvm/test/CodeGen/PowerPC/pcrel.ll

Index: llvm/test/CodeGen/PowerPC/pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel.ll
+++ llvm/test/CodeGen/PowerPC/pcrel.ll
@@ -8,13 +8,14 @@
 
 ; Constant Pool Index.
 ; CHECK-S-LABEL: ConstPool
-; CHECK-S:   plfd f1, .LCPI0_0@PCREL(0), 1
+; CHECK-S:   xxsplti32dx vs1, 0, 1081002676
+; CHECK-S-NEXT:   xxsplti32dx vs1, 1, 962072674
 ; CHECK-S:   blr
 
 ; CHECK-O-LABEL: ConstPool
-; CHECK-O:   plfd 1, 0(0), 1
-; CHECK-O-NEXT:  R_PPC64_PCREL34  .rodata.cst8
-; CHECK-O:   blr
+; CHECK-O:   xxsplti32dx 1, 0, 1081002676
+; CHECK-O-NEXT:  xxsplti32dx 1, 1, 962072674
+; CHECK-O-NEXT:  blr
 define dso_local double @ConstPool() local_unnamed_addr {
   entry:
 ret double 0x406ECAB439581062
Index: llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
+++ llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
@@ -35,6 +35,9 @@
 @FuncPtrOut = external local_unnamed_addr global void (...)*, align 8
 
 define dso_local void @ReadWrite8() local_unnamed_addr #0 {
+; In this test the stb r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lbz r3, 0(r3)
+; which is defined between the pld and the stb.
 ; CHECK-LABEL: ReadWrite8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input8@got@pcrel(0), 1
@@ -42,9 +45,6 @@
 ; CHECK-NEXT:pld r4, output8@got@pcrel(0), 1
 ; CHECK-NEXT:.reloc .Lpcrel0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel0-8)
 ; CHECK-NEXT:lbz r3, 0(r3)
-; In this test the stb r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lbz r3, 0(r3)
-; which is defined between the pld and the stb.
 ; CHECK-NEXT:stb r3, 0(r4)
 ; CHECK-NEXT:blr
 entry:
@@ -54,6 +54,9 @@
 }
 
 define dso_local void @ReadWrite16() local_unnamed_addr #0 {
+; In this test the sth r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lhz r3, 0(r3)
+; which is defined between the pld and the sth.
 ; CHECK-LABEL: ReadWrite16:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input16@got@pcrel(0), 1
@@ -61,9 +64,6 @@
 ; CHECK-NEXT:pld r4, output16@got@pcrel(0), 1
 ; CHECK-NEXT:.reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
 ; CHECK-NEXT:lhz r3, 0(r3)
-; In this test the sth r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lhz r3, 0(r3)
-; which is defined between the pld and the sth.
 ; CHECK-NEXT:sth r3, 0(r4)
 ; CHECK-NEXT:blr
 entry:
@@ -144,7 +144,8 @@
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, inputf64@got@pcrel(0), 1
 ; CHECK-NEXT:  .Lpcrel5:
-; CHECK-NEXT:plfd f1, .LCPI6_0@PCREL(0), 1
+; CHECK-NEXT:xxsplti32dx vs1, 0, 1075524403
+; CHECK-NEXT:xxsplti32dx vs1, 1, 858993459
 ; CHECK-NEXT:.reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
 ; CHECK-NEXT:lfd f0, 0(r3)
 ; CHECK-NEXT:pld r3, outputf64@got@pcrel(0), 1
@@ -286,8 +287,7 @@
 
 define dso_local void @FuncPtrCall() local_unnamed_addr #0 {
 ; CHECK-LABEL: FuncPtrCall:
-; CHECK: .localentry FuncPtrCall, 1
-; CHECK-NEXT:  # %bb.0: # %entry
+; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, FuncPtrIn@got@pcrel(0), 1
 ; CHECK-NEXT:  .Lpcrel10:
 ; CHECK-NEXT:.reloc .Lpcrel10-8,R_PPC64_PCREL_OPT,.-(.Lpcrel10-8)
@@ -317,8 +317,7 @@
 
 define dso_local signext i32 @VecMultiUse() local_unnamed_addr #0 {
 ; CHECK-LABEL: VecMultiUse:
-; CHECK: .localentry VecMultiUse, 1
-; CHECK-NEXT:  # %bb.0: # %entry
+; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:mflr r0
 ; CHECK-NEXT:std r29, -24(r1) # 8-byte Folded Spill
 ; CHECK-NEXT:std r30, -16(r1) # 8-byte Folded Spill
@@ -355,8 +354,7 @@
 
 define dso_local signext i32 @UseAddr(i32 signext %a) local_unnamed_addr #0 {
 ; CHECK-LABEL: UseAddr:
-; CHECK: .loc

[PATCH] D95459: Add helper functionality for parsing different attribute syntaxes in arbitrary order

2021-01-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie, jyknight, rjmccall.
aaron.ballman requested review of this revision.

In Clang today, we parse the different attribute syntaxes (`__attribute__`, 
`__declspec`, and `[[]]`) in a fairly rigid order. This leads to confusion for 
users when they guess the order incorrectly, and leads to bug reports like 
PR24559 or necessitates changes like D94788 .

This patch adds a helper function to allow us to more easily parse attributes 
in arbitrary order, and then updates all of the places where we would parse two 
or more different syntaxes in a rigid order to use the helper method. The patch 
does not attempt to handle Microsoft attributes (`[]`) because those are 
ambiguous with other code constructs and we don't have any attributes that use 
the syntax.

There may be other places that could be modified to start accepting attributes 
with more arbitrary orders (such as in lambda expressions), but I think that 
effort is best left to follow-up work as we notice a need.


https://reviews.llvm.org/D95459

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/test/Parser/attr-order.cpp
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -256,7 +256,8 @@
 
 void func_multiple_addr2(void) {
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}}
+  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}} \
+   // expected-error {{function scope variable cannot be declared in global address space}}
   __private __attribute__((opencl_global)) int *var2;  // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t *var4;  // expected-error {{multiple address spaces specified for type}}
Index: clang/test/Parser/attr-order.cpp
===
--- /dev/null
+++ clang/test/Parser/attr-order.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+
+struct [[]] __attribute__((lockable)) __declspec(dllexport) A {}; // ok
+struct [[]] __declspec(dllexport) __attribute__((lockable)) B {}; // ok
+struct [[]] [[]] __declspec(dllexport) __attribute__((lockable)) C {}; // ok
+struct __declspec(dllexport) [[]] __attribute__((lockable)) D {}; // ok
+struct __declspec(dllexport) __attribute__((lockable)) [[]] E {}; // ok
+struct __attribute__((lockable)) __declspec(dllexport) [[]] F {}; // ok
+struct __attribute__((lockable)) [[]] __declspec(dllexport) G {}; // ok
+struct [[]] __attribute__((lockable)) [[]] __declspec(dllexport) H {}; // ok
+
+[[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void a(); // ok
+[[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
+[[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
+
+// [[]] attributes before a declaration must be at the start of the line.
+__declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // expected-error {{an attribute list cannot appear here}}
+__declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // expected-error {{an attribute list cannot appear here}}
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // expected-error {{an attribute list cannot appear here}}
+
+[[noreturn]] __attribute__((cdecl))
+[[]] // expected-error {{an attribute list cannot appear here}}
+__declspec(dllexport) void h();
Index: clang/lib/Parse/ParseObjc.cpp
===
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -1350,9 +1350,8 @@
 
   // If attributes exist before the method, parse them.
   ParsedAttributes methodAttrs(AttrFactory);
-  if (getLangOpts().ObjC)
-MaybeParseGNUAttributes(methodAttrs);
-  MaybeParseCXX11Attributes(methodAttrs);
+  MaybeParseAttributes(PAKM_CXX11 | (getLangOpts().ObjC ? PAKM_GNU : 0),
+   methodAttrs);
 
   if (Tok.is(tok::code_completion)) {
 Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
@@ -1377,9 +1376,8 @@
   SmallVector CParamInfo;
   if (Tok.isNot(tok::colon)) {
 // If attributes exist after the method, par

[PATCH] D94987: DR39: Perform ambiguous subobject checks for class member access as part of object argument conversion, not as part of name lookup.

2021-01-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/CXXInheritance.h:77
 
-  CXXBasePath() = default;
+  /// Additional data stashed on the base path by its consumers.
+  union {

rsmith wrote:
> rjmccall wrote:
> > rsmith wrote:
> > > rjmccall wrote:
> > > > Is there a way to know which case we're in, or do different consumers 
> > > > do different things?
> > > We could use a discriminated union here. Ultimately, I think what we 
> > > really want is to provide some opaque storage for the consumer to use, 
> > > rather than to have some hard-coded list here. I haven't thought of a 
> > > good way to expose that; I don't think it's worth templating the entire 
> > > base path finding mechanism to add such storage, and a single pointer 
> > > isn't large enough for a `DeclContext::lookup_result`.
> > > 
> > > Vassil's https://reviews.llvm.org/D91524 will make the `lookup_result` 
> > > case fit into a single pointer; once we adopt that, perhaps we can switch 
> > > to holding an opaque `void*` here?
> > Yeah, that might be cleaner, assuming we really need this.  What are the 
> > clients that need to store something specifically in the `CXXBasePath` 
> > object and can't just keep it separate?
> The main users of this are in name lookup proper (where we store the lookup 
> results on the path to avoid redoing the class scope hash table lookup) and 
> now in access checking (where we store the most-accessible declaration). I 
> think there's a couple of other name-lookup-like clients that also store a 
> lookup result here.
> 
> In all cases the side storage is just a convenience. But it's probably an 
> important convenience; it's awkward for a client to maintain a mapping on the 
> side, because the key for that map would end up being the entire base path. 
> 
> We could just number the paths as we find them, and let the consumers build a 
> `SmallVector` on the side rather than storing data in the `CXXBasePath`s. 
> We'd need to be careful about the post-processing pass in `lookupInBases` 
> that removes virtual base paths that are shadowed by non-virtual inheritance 
> from the vbase, but that seems feasible. Worthwhile?
I see what you're saying.  We have places that compute all the base paths in an 
array, and it's convenient to be able to stash things into the elements of that 
array instead of having a second data structure that's parallel to it.  I guess 
there are three options:

- Tell clients to just make a parallel structure.

- Have this sort of intrusive storage and just accept that clients that want to 
use it will have some awkward casting to do.

- Get rid of the initial array dependence by making it a callback API instead 
of an array-building API, and then clients that want to build an array can 
build an array with the type they actually want.

I guess the third might be awkward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94987

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


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi. Up until this point, we've noticed that this patch can produce different 
formatted files depending on amount of whitespace. For example, given (A):

  #include 
  namespace fuzzing {}

`clang-format` with this patch would produced (B):

  #include 
  namespace fuzzing {
  }

but given (C):

  #include 
  namespace fuzzing {
  
  
  }

would be formatted to (D):

  #include 
  namespace fuzzing {
  
  }

The invocation specifically is `clang-format --style=google file`. Prior to 
this patch, both inputs (A/C) would give the same output:

  #include 
  namespace fuzzing {}

Is this unintended behavior and worth looking into? We have tests for generated 
code that use `clang-format` to attempt to "unify" expected and generated 
output for easy comparison. We would expect that extra whitespace not produce 
different formatted outputs. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 319348.
akhuang marked an inline comment as done.
akhuang added a comment.

change to function returning a number, fill in ItaniumMangle function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -6,10 +6,15 @@
 namespace NS {
 struct C {
   void m() {}
+  // Test externally visible lambda.
+  void lambda2() { []() {}(); }
 };
 void f() {}
 }
 
+// Test non- externally visible lambda.
+auto lambda1 = []() { return 1; };
+
 NS::C c;
 
 void test() {
@@ -27,4 +32,16 @@
   // CHECK-NOT: identifier
   // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]]
+  // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  lambda1();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA2:[0-9]+]]
+  // CHECK: ![[LAMBDA2]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  c.lambda2();
 }
Index: clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
@@ -100,7 +100,7 @@
   // MSVC-SAME:  )
   // MSVC:   [[TYPE_OF_FOUR]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_class_type
-  // MSVC-NOT:   name:
+  // MSVC-SAME:  name: ""
   // MSVC-SAME:  identifier: ".?AV@?0??main@@9@"
   // MSVC-SAME:  )
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -317,8 +317,9 @@
   if (const IdentifierInfo *II = RD->getIdentifier())
 return II->getName();
 
-  // The CodeView printer in LLVM wants to see the names of unnamed types: it is
-  // used to reconstruct the fully qualified type names.
+  // The CodeView printer in LLVM wants to see the names of unnamed types
+  // because they need to have a unique identifier.
+  // These names are used to reconstruct the fully qualified type names.
   if (CGM.getCodeGenOpts().EmitCodeView) {
 if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
   assert(RD->getDeclContext() == D->getDeclContext() &&
@@ -342,6 +343,18 @@
 // associate typedef mangled in if they have one.
 Name = TND->getName();
 
+  // Give lambdas a display name based on their name mangling.
+  if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
+if (CXXRD->isLambda()) {
+  unsigned LambdaNumber =
+  CGM.getCXXABI().getMangleContext().getLambdaNumber(CXXRD);
+
+  SmallString<256> LambdaName(" UnnamedType("getLambdaManglingNumber();
+if (LambdaManglingNumber)
+  return LambdaManglingNumber;
+else
+  return getLambdaId(Lambda);
+  }
+
   unsigned getLambdaId(const CXXRecordDecl *RD) {
 assert(RD->isLambda() && "RD must be a lambda!");
 assert(!RD->isExternallyVisible() && "RD must not be visible!");
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -203,6 +203,14 @@
 disc = discriminator-2;
 return true;
   }
+
+  unsigned getLambdaNumber(const CXXRecordDecl *Lambda) override {
+unsigned Number = Lambda->getLambdaManglingNumber();
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;
+  }
+
   /// @}
 };
 
Index: clang/include/clang/AST/Mangle.h
===
--- clang/include/clang/AST/Mangle.h
+++ clang/include/clang/AST/Mangle.h
@@ -89,6 +89,8 @@
 return Result.first->second;
   }
 
+  virtual unsigned getLambdaNumber(const CXXRecordDecl *Lambda) = 0;
+
   /// @name Mangler Entry Points
   /// @{
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-26 Thread Faris via Phabricator via cfe-commits
FarisRehman created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
Herald added a reviewer: awarzynski.
Herald added a reviewer: jansvoboda11.
FarisRehman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for the following layout options:

- -ffree-form
- -ffixed-form
- -ffixed-line-length-n

The default fixed line length is 72, based off the current default.

This patch does not add `-ffree-line-length-n` as Fortran::parser::Options does 
not have a variable for free form columns.
Whilst `fixedFormColumns` variable is used in f18 for `-ffree-line-length-n`, 
f18 only allows `-ffree-line-length-none`/`-ffree-line-length-0` and not a 
user-specified value. `fixedFormcolumns` cannot be used in the new driver as it 
is ignored in the frontend when dealing with free form files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95460

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/fixed-form-test.f
  flang/test/Flang-Driver/Inputs/fixed-line-length-test.f
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/fixed-free-flag.f90
  flang/test/Flang-Driver/fixed-line-length.f90

Index: flang/test/Flang-Driver/fixed-line-length.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-line-length.f90
@@ -0,0 +1,43 @@
+! Ensure argument -ffixed-line-length-n works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: %flang-new -fc1 -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!-
+! EXPECTED OUTPUT WITH DEFAULT LENGTH
+!-
+! The line should be trimmed to 72 characters when reading based on the default value of fixed line length.
+! DEFAULTLENGTH: programaa
+
+!-
+! EXPECTED OUTPUT WITH LENGTH LESS THAN 7
+!-
+! INVALIDLENGTH: invalid value '{{(-)?[0-9]+}}'
+
+!---
+! EXPECTED OUTPUT WITH UNLIMITED LENGTH
+!---
+! The line should not be trimmed and so 73 characters (including spaces) should be read.
+! UNLIMITEDLENGTH: programaaa
+
+!
+! EXPECTED OUTPUT WITH LENGTH 13
+!
+! LENGTH13: program
Index: flang/test/Flang-Driver/fixed-free-flag.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-free-flag.f90
@@ -0,0 +1,25 @@
+! Ensure arguments -ffree-form and -ffixed-form work as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -ffree-form %S/Inputs/fixed-form-test.f %S/Inputs/free-form-test.f90  2>&1 | FileCheck %s --check-prefix=FREEFORM
+! RUN: %flang-new -fsyntax-only -ffixed-form %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FIXEDFORM
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!---

[PATCH] D95231: [clangd] Selection handles CXXBaseSpecifier

2021-01-26 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd92413a45e20: [clangd] Selection handles CXXBaseSpecifier 
(authored by njames93).

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 {};
+struct B : priv^ate A {};
+  )cpp",
+   "Cannot rename symbol: there is no symbol at the given

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

2021-01-26 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7730599c4164: [clangd] FindTarget resolves base specifier 
(authored by njames93).

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] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4edf35f11a9e: Support for instrumenting only selected files 
or functions (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D94820?vs=318257&id=319359#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SourceBasedCodeCoverage.rst
  clang/docs/UsersManual.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/ProfileList.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/ProfileList.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/profile-filter.c
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/PGOProfile/noprofile.ll

Index: llvm/test/Transforms/PGOProfile/noprofile.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/noprofile.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@i = dso_local global i32 0, align 4
+
+define i32 @test1() {
+entry:
+; CHECK: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %add = add i32 %0, 1
+  ret i32 %add
+}
+
+define i32 @test2() #0 {
+entry:
+; CHECK-NOT: call void @llvm.instrprof.increment
+  %0 = load i32, i32* @i, align 4
+  %sub = sub i32 %0, 1
+  ret i32 %sub
+}
+
+attributes #0 = { noprofile }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -973,6 +973,7 @@
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 break;
   }
 
Index: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1591,6 +1591,8 @@
   for (auto &F : M) {
 if (F.isDeclaration())
   continue;
+if (F.hasFnAttribute(llvm::Attribute::NoProfile))
+  continue;
 auto &TLI = LookupTLI(F);
 auto *BPI = LookupBPI(F);
 auto *BFI = LookupBFI(F);
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1655,6 +1655,7 @@
   case Attribute::StrictFP:
   case Attribute::NullPointerIsValid:
   case Attribute::MustProgress:
+  case Attribute::NoProfile:
 return true;
   default:
 break;
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -403,6 +403,8 @@
 return "nocf_check";
   if (hasAttribute(Attribute::NoRecurse))
 return "norecurse";
+  if (hasAttribute(Attribute::NoProfile))
+return "noprofile";
   if (hasAttribute(Attribute::NoUnwind))
 return "nounwind";
   if (hasAttribute(Attribute::OptForFuzzing))
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -680,6 +680,8 @@
 return bitc::ATTR_KIND_NOSYNC;
   case Attribute::NoCfCheck:
 return bitc::ATTR_KIND_NOCF_CHECK;
+  case Attribute::NoProfile:
+return bitc::ATTR_KIND_NO_PROFILE;
   case Attribute::NoUnwind:
 return bitc::ATTR_KIND_NO_UNWIND;
   case Attribute::NullPointerIsValid:
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -210,6 +210,7 @@
   kw_nonlazybind,
   kw_nomerge,
   kw_nonnull,
+  kw_noprofile,
   kw_noredzone,
   kw_noreturn,
   kw_nosync,
Index: llvm/lib/AsmParser/LLParser.cpp
===

[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see a potential issue, but I think this looks good otherwise.




Comment at: clang/lib/AST/ItaniumMangle.cpp:210
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;

This has the potential to create a situation where enabling debug info changes 
the internal mangled names that clang uses. To be *extra* safe, you could add a 
method like `getAnonymousStructIdForDebugInfo` that does .find instead of 
.insert, and use it here.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:236
+else
+  return getLambdaId(Lambda);
+  }

This has a similar concern, this isn't a readonly operation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2021-01-26 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

This seems to have broken compilation for me on 10.15.

The stdio.h from the 10.15 SDK there's the following usage:

  #if TARGET_OS_EMBEDDED
  #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
  #else
  #define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83250

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


[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2021-01-26 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

Actually, this may just be a local configuration issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83250

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


[PATCH] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 319369.
Anastasia added a comment.

Improved diagnostics to cover more cases.

NOTE that this now also contains similar improvements for the pointers to 
member functions.


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

https://reviews.llvm.org/D95442

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/members.cl
  clang/test/SemaOpenCLCXX/references.cl

Index: clang/test/SemaOpenCLCXX/references.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/references.cl
@@ -0,0 +1,46 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -verify -fsyntax-only -DFPTREXT
+
+#ifdef FPTREXT
+#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
+#endif // FPTREXT
+
+// References to functions are not allowed.
+struct myclass {
+//FIXME: Here we provide incorrect diagnostic.
+  void (&mem)(); //expected-error{{reference to function type cannot have '__generic' qualifier}}
+};
+
+void (&glob)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#else
+//expected-error@-4{{declaration of reference variable 'glob' requires an initializer}}
+#endif // FPTREXT
+
+using ref2fct_t = void (&)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+typedef void (&ref2fct_t)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+
+void test(void (&par)()) {
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#endif // FPTREXT
+  void (&loc)();
+#ifndef FPTREXT
+//expected-error@-2{{references to functions are not allowed}}
+#else
+//expected-error@-4{{declaration of reference variable 'loc' requires an initializer}}
+#endif // FPTREXT
+
+  void (*&ref2fptr)();
+#ifndef FPTREXT
+//expected-error@-2{{pointers to functions are not allowed}}
+#endif // FPTREXT
+//expected-error@-4{{declaration of reference variable 'ref2fptr' requires an initializer}}
+}
Index: clang/test/SemaOpenCLCXX/members.cl
===
--- clang/test/SemaOpenCLCXX/members.cl
+++ clang/test/SemaOpenCLCXX/members.cl
@@ -13,31 +13,13 @@
 };
 
 typedef void (C::*p_t)(int);
-
-template  struct remove_reference { typedef T type; };
-template  struct remove_reference { typedef T type; };
-
-template 
-void templ_test() {
-  typename remove_reference::type *ptr;
 #ifndef FUNCPTREXT
-  //expected-error@-2{{pointers to functions are not allowed}}
+//expected-error@-2{{pointers to functions are not allowed}}
 #endif
-}
 
 void test() {
   void (C::*p)(int);
 #ifndef FUNCPTREXT
 //expected-error@-2{{pointers to functions are not allowed}}
-#endif
-
-  p_t p1;
-#ifndef FUNCPTREXT
-//expected-error@-2{{pointers to functions are not allowed}}
-#endif
-
-  templ_test();
-#ifndef FUNCPTREXT
-//expected-note@-2{{in instantiation of function template specialization}}
 #endif
 }
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2091,7 +2091,7 @@
 
   if (T->isFunctionType() && getLangOpts().OpenCL &&
   !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-Diag(Loc, diag::err_opencl_function_pointer);
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
 return QualType();
   }
 
@@ -2163,6 +2163,12 @@
   if (checkQualifiedFunction(*this, T, Loc, QFK_Reference))
 return QualType();
 
+  if (T->isFunctionType() && getLangOpts().OpenCL &&
+  !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+Diag(Loc, diag::err_opencl_function_pointer) << /*reference*/ 1;
+return QualType();
+  }
+
   // In ARC, it is forbidden to build references to unqualified pointers.
   if (getLangOpts().ObjCAutoRefCount)
 T = inferARCLifetimeForPointee(*this, T, Loc, /*reference*/ true);
@@ -2889,6 +2895,12 @@
 return QualType();
   }
 
+  if (T->isFunctionType() && getLangOpts().OpenCL &&
+  !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
+Diag(Loc, diag::err_opencl_function_pointer) << /*pointer*/ 0;
+return QualType();
+  }
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6751,10 +6751,13 @@
 
   // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
   if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) {
-QualType NR = R;
-while (NR->isPointerType() || NR->isMemberFunctionPointerType()) {
-  if (NR->isFunctionPointerType()

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

2021-01-26 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

MyDeveloperDay wrote:
> curdeius wrote:
> > kentsommer wrote:
> > > MyDeveloperDay wrote:
> > > > Are you sure `IncludeSortAlphabetically` expresses what you mean? Once 
> > > > these things get released they cannot be changed easily.
> > > > 
> > > > If you were not sure of a new option, in my view we should slow down 
> > > > and make sure we have the correct design, for example you could have 
> > > > used a enum and it might have given you more possibility for greater 
> > > > flexibility
> > > > 
> > > > ```
> > > > enum IncludeSort
> > > > {
> > > >CaseInsensitive
> > > >CaseSensitive
> > > > }
> > > > ```
> > > > 
> > > > Please give people time to re-review your changes before we commit, 
> > > > especially if they've taken the time to look at your review in the 
> > > > first place. Just saying.
> > > > 
> > > Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> > > through the review. I was simply trying to follow the process outlined in 
> > > https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > > mentions giving sufficient information to allow for a commit on your 
> > > behalf when you don't have access after an LGTM (which is all that I 
> > > did). As you can see from the lack of additional comments from my end, I 
> > > was happy to let this sit and be reviewed. 
> > > 
> > > Per the discussion about the option itself, I do believe 
> > > `IncludeSortAlphabetically` currently expresses what I mean as the 
> > > behavior with this off is indeed not an alphabetical sort as case takes 
> > > precedence over the alphabetical ordering. However, looking at the enum 
> > > and realizing that others probably will have additional styles they 
> > > prefer (maybe they want alphabetical but lower case first, etc.) I do 
> > > believe it might have been a better way to go as it leaves more 
> > > flexibility and room for additional ordering styles. Given that this just 
> > > landed, I would be happy to open a patch to turn this into an `enum` as I 
> > > do see benefits to doing so. What do you think?
> > Hmmm, and how about using the existing option `SortIncludes` and change its 
> > type from `bool` to some `enum`?
> > We could then, for backward-compatibility, map `false` to (tentative) 
> > `Never` and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.
> > 
> > This will have the advantage of not adding additional style options.
> > ... and it will prove once again that using `bool`s for style options is 
> > not a good idea.
> I think that is an excellent idea @curdeius 
I also fully support that! (Although I would not say a bool is per se bad.)


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] D95442: [OpenCL] Add diagnostics for references to functions

2021-01-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/references.cl:29
+void foo();
+void test(void (&par)()) {
+  void (&loc)();

Anastasia wrote:
> oops, I thought this was covered in my patch. I will see if there is a quick 
> fix and if not I will create another PR.
Ok, I have addressed that. I realized that my original patch was not doing what 
I said in the description as it was still allowing the references to functions 
in type aliases or template arguments. While I think such functionality might 
be useful we should first start from the language definition side of it. For 
now let's just go with the conservative approach and disallow this.


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

https://reviews.llvm.org/D95442

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


[PATCH] D94391: CGDebugInfo: Drop Loc.isInvalid() special case from getLineNumber

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31d375f178c2: CGDebugInfo: Drop Loc.isInvalid() special case 
from getLineNumber (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94391

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -481,11 +481,10 @@
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
-  if (Loc.isInvalid() && CurLoc.isInvalid())
+  if (Loc.isInvalid())
 return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
-  PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.isValid() ? PLoc.getLine() : 0;
+  return SM.getPresumedLoc(Loc).getLine();
 }
 
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -1025,7 +1024,8 @@
   if (llvm::DIType *T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
 return cast(T);
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   uint64_t Size = 0;
@@ -1349,7 +1349,7 @@
 
   // Get the location for the field.
   llvm::DIFile *file = getOrCreateFile(loc);
-  unsigned line = getLineNumber(loc);
+  const unsigned line = getLineNumber(loc.isValid() ? loc : CurLoc);
 
   uint64_t SizeInBits = 0;
   auto Align = AlignInBits;
@@ -,7 +,8 @@
 
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
@@ -3869,7 +3870,7 @@
   llvm::DISubprogram::DISPFlags SPFlagsForDef =
   SPFlags | llvm::DISubprogram::SPFlagDefinition;
 
-  unsigned LineNo = getLineNumber(Loc);
+  const unsigned LineNo = getLineNumber(Loc.isValid() ? Loc : CurLoc);
   unsigned ScopeLine = getLineNumber(ScopeLoc);
   llvm::DISubroutineType *DIFnType = getOrCreateFunctionType(D, FnType, Unit);
   llvm::DISubprogram *Decl = nullptr;
@@ -4372,7 +4373,8 @@
   Ty = CreateSelfType(VD->getType(), Ty);
 
   // Get location information.
-  unsigned Line = getLineNumber(VD->getLocation());
+  const unsigned Line =
+  getLineNumber(VD->getLocation().isValid() ? VD->getLocation() : CurLoc);
   unsigned Column = getColumnNumber(VD->getLocation());
 
   const llvm::DataLayout &target = CGM.getDataLayout();
@@ -4832,6 +4834,8 @@
   if (!NSDecl->isAnonymousNamespace() ||
   CGM.getCodeGenOpts().DebugExplicitImport) {
 auto Loc = UD.getLocation();
+if (!Loc.isValid())
+  Loc = CurLoc;
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNamespace(NSDecl), getOrCreateFile(Loc), 
getLineNumber(Loc));


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -481,11 +481,10 @@
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
-  if (Loc.isInvalid() && CurLoc.isInvalid())
+  if (Loc.isInvalid())
 return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
-  PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
-  return PLoc.isValid() ? PLoc.getLine() : 0;
+  return SM.getPresumedLoc(Loc).getLine();
 }
 
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -1025,7 +1024,8 @@
   if (llvm::DIType *T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
 return cast(T);
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
   uint64_t Size = 0;
@@ -1349,7 +1349,7 @@
 
   // Get the location for the field.
   llvm::DIFile *file = getOrCreateFile(loc);
-  unsigned line = getLineNumber(loc);
+  const unsigned line = getLineNumber(loc.isValid() ? loc : CurLoc);
 
   uint64_t SizeInBits = 0;
   auto Align = AlignInBits;
@@ -,7 +,8 @@
 
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  unsigned Line = getLineNumber(RD->getLocation());
+  const unsigned Line =
+  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
 
 

[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Clang side looks good to me.

On the LLVM side, is it intended that invalid `-binutils-version` values are 
silently accepted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D94735: CGDebugInfo CreatedLimitedType: Drop file/line for RecordType with invalid location

2021-01-26 Thread Fangrui Song 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 rG189f311130da: CGDebugInfo CreatedLimitedType: Drop file/line 
for RecordType with invalid… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94735

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/X86/x86_64-arguments.c


Index: clang/test/CodeGen/X86/x86_64-arguments.c
===
--- clang/test/CodeGen/X86/x86_64-arguments.c
+++ clang/test/CodeGen/X86/x86_64-arguments.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=SSE 
-check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s 
-target-feature +avx | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s -target-feature +avx | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX 
-check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s 
-target-feature +avx512f | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-debug-info-kind=limited -o - %s -target-feature +avx512f | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX 
-check-prefix=AVX512
 #include 
 
@@ -545,3 +545,9 @@
 // AVX: @f65(<8 x float> %{{[^,)]+}})
 void f65(struct t65 a0) {
 }
+
+/// The synthesized __va_list_tag does not have file/line fields.
+// CHECK:  = distinct !DICompositeType(tag: DW_TAG_structure_type, name: 
"__va_list_tag",
+// CHECK-NOT:  file:
+// CHECK-NOT:  line:
+// CHECK-SAME: size:
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3332,10 +3332,14 @@
   RecordDecl *RD = Ty->getDecl();
 
   // Get overall information about the record type for the debug info.
-  llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  const unsigned Line =
-  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = nullptr;
+  unsigned Line = 0;
+  if (Loc.isValid()) {
+DefUnit = getOrCreateFile(Loc);
+Line = getLineNumber(Loc);
+  }
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 


Index: clang/test/CodeGen/X86/x86_64-arguments.c
===
--- clang/test/CodeGen/X86/x86_64-arguments.c
+++ clang/test/CodeGen/X86/x86_64-arguments.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s -target-feature +avx | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=NO-AVX512
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx512f | \
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -debug-info-kind=limited -o - %s -target-feature +avx512f | \
 // RUN:   FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX512
 #include 
 
@@ -545,3 +545,9 @@
 // AVX: @f65(<8 x float> %{{[^,)]+}})
 void f65(struct t65 a0) {
 }
+
+/// The synthesized __va_list_tag does not have file/line fields.
+// CHECK:  = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__va_list_tag",
+// CHECK-NOT:  file:
+// CHECK-NOT:  line:
+// CHECK-SAME: size:
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3332,10 +3332,14 @@
   RecordDecl *RD = Ty->getDecl();
 
   // Get overall information about the record type for the debug info.
-  llvm::DIFile *DefUnit = getOrCreateFile(RD->getLocation());
-  const unsigned Line =
-  getLineNumber(RD->getLocation().isValid() ? RD->getLocation() : CurLoc);
   StringRef RDName = getClassName(RD);
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = nullptr;
+  unsigned Line = 0;
+  if (Loc.isValid()) {
+DefUnit = getOrCreateFile(Loc);
+Line = getLineNumber(Loc);
+  }
 
   llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 
___
cfe-commits m

[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on windows: http://45.33.8.238/win/32075/step_7.txt

Please take a look, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D85474#2523439 , @rsmith wrote:

> Clang side looks good to me.
>
> On the LLVM side, is it intended that invalid `-binutils-version` values are 
> silently accepted?

Yes. In `llvm/tools/llc/llc.cpp`, there is no validity check. For these 
non-user-facing utilities (opt/llc/llvm-mc/...), validity check for options 
tends to be scarce.

I can add some tests to `llvm/test/tools/llc` (which hardly has any test 
currently).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

___
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-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D94472#2523053 , @Bigcheese wrote:

> In D94472#2519838 , @jansvoboda11 
> wrote:
>
>> In D94472#2508018 , @dexonsmith 
>> wrote:
>>
>>> `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.
>
> The only issue I have with this if always parsing twice has a noticeable 
> performance impact for any users of Clang. Can we measure the impact? If it's 
> small (< 100ms ?) then that's fine. I'm also concerned about users like cling 
> and clangd.

I think the idea is only to parse twice when `-round-trip-args` is on, which 
the driver will only set by default in asserts mode. Good to measure the impact 
nevertheless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D93031: Enable fexec-charset option

2021-01-26 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.
Herald added a reviewer: jansvoboda11.

ping :)
Is there any more feedback on the implementation inside ProcessCharEscape()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 319378.
MaskRay added a comment.

Add llc validity check and tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/test/tools/llc/binutils-version.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -427,9 +436,24 @@
   case '3': OLvl = CodeGenOpt::Aggressive; break;
   }
 
+  // Parse 'none' or '$major.$minor'. Disallow -binutils-version=0 because we
+  // use that to indicate the MC default.
+  if (!BinutilsVersion.empty() && BinutilsVersion != "none") {
+StringRef V = BinutilsVersion.getValue();
+unsigned Num;
+if (V.consumeInteger(10, Num) || Num == 0 ||
+!(V.empty() ||
+  (V.consume_front(".") && !V.consumeInteger(10, Num) && V.empty( {
+  WithColor::error(errs(), argv[0])
+  << "invalid -binutils-version, accepting 'none' or major.minor\n";
+  return 1;
+}
+  }
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple &TheTriple) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/tools/llc/binutils-version.ll
===
--- /dev/null
+++ llvm/test/tools/llc/binutils-version.ll
@@ -0,0 +1,13 @@
+;; Test valid and invalid -binutils-version values.
+; RUN: llc %s -filetype=null -binutils-version=none
+; RUN: llc %s -filetype=null -binutils-version=2
+; RUN: llc %s -filetype=null -binutils-version=2.35
+
+;; Disallow -binutils-version=0 because we use $major==0 to indicate the MC
+;; default.
+; RUN: not llc %s -filetype=null -binutils-version=0 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=nan 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=2. 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=3.-14 2>&1 | FileCheck %s --check-prefix=ERR
+
+; ERR: error: invalid -binutils-version, accepting 'none' or major.minor
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with entry-size=0 but was placed in section '.debug_str' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; N

[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:92
 
+  virtual StringRef getLambdaString(const CXXRecordDecl *Lambda) = 0;
+

rnk wrote:
> I think I would prefer to have this return a number. I think CGDebugInfo 
> should be responsible for the formatting of the display names, not the 
> mangler. Both the MS and Itanium manglers have private methods for numbering 
> internal linkage lambdas, and I think it would be reasonable to hook those up 
> to a public virtual method.
I used a string because we mangle some lambdas like  (when they're 
used as function parameters). 
Maybe we don't need to differentiate between these lambdas though? 



Comment at: clang/lib/AST/ItaniumMangle.cpp:210
+if (Number == 0)
+  return getAnonymousStructId(Lambda);
+return Number;

rnk wrote:
> This has the potential to create a situation where enabling debug info 
> changes the internal mangled names that clang uses. To be *extra* safe, you 
> could add a method like `getAnonymousStructIdForDebugInfo` that does .find 
> instead of .insert, and use it here.
Oh, right, yeah. I guess I'll just let it return 0 if it's not found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

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


[PATCH] D95187: [DebugInfo][CodeView] Use as the display name for lambdas.

2021-01-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 319379.
akhuang added a comment.

Avoid using getLambdaId function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95187

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -6,10 +6,15 @@
 namespace NS {
 struct C {
   void m() {}
+  // Test externally visible lambda.
+  void lambda2() { []() {}(); }
 };
 void f() {}
 }
 
+// Test non- externally visible lambda.
+auto lambda1 = []() { return 1; };
+
 NS::C c;
 
 void test() {
@@ -27,4 +32,16 @@
   // CHECK-NOT: identifier
   // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]]
+  // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  lambda1();
+
+  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA2:[0-9]+]]
+  // CHECK: ![[LAMBDA2]] = !DICompositeType(tag: DW_TAG_class_type,
+  // CHECK-SAME:name: ""
+  // CHECK-SAME:flags: DIFlagFwdDecl
+  c.lambda2();
 }
Index: clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
@@ -100,7 +100,7 @@
   // MSVC-SAME:  )
   // MSVC:   [[TYPE_OF_FOUR]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_class_type
-  // MSVC-NOT:   name:
+  // MSVC-SAME:  name: ""
   // MSVC-SAME:  identifier: ".?AV@?0??main@@9@"
   // MSVC-SAME:  )
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -317,8 +317,9 @@
   if (const IdentifierInfo *II = RD->getIdentifier())
 return II->getName();
 
-  // The CodeView printer in LLVM wants to see the names of unnamed types: it is
-  // used to reconstruct the fully qualified type names.
+  // The CodeView printer in LLVM wants to see the names of unnamed types
+  // because they need to have a unique identifier.
+  // These names are used to reconstruct the fully qualified type names.
   if (CGM.getCodeGenOpts().EmitCodeView) {
 if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
   assert(RD->getDeclContext() == D->getDeclContext() &&
@@ -342,6 +343,18 @@
 // associate typedef mangled in if they have one.
 Name = TND->getName();
 
+  // Give lambdas a display name based on their name mangling.
+  if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
+if (CXXRD->isLambda()) {
+  unsigned LambdaNumber =
+  CGM.getCXXABI().getMangleContext().getLambdaNumber(CXXRD);
+
+  SmallString<256> LambdaName(" UnnamedType("getLambdaManglingNumber();
+if (LambdaManglingNumber)
+  return LambdaManglingNumber;
+return getLambdaIdForDebugInfo(Lambda);
+  }
+
   unsigned getLambdaId(const CXXRecordDecl *RD) {
 assert(RD->isLambda() && "RD must be a lambda!");
 assert(!RD->isExternallyVisible() && "RD must not be visible!");
@@ -238,6 +245,19 @@
 return Result.first->second;
   }
 
+  unsigned getLambdaIdForDebugInfo(const CXXRecordDecl *RD) {
+assert(RD->isLambda() && "RD must be a lambda!");
+assert(!RD->isExternallyVisible() && "RD must not be visible!");
+assert(RD->getLambdaManglingNumber() == 0 &&
+   "RD must not have a mangling number!");
+llvm::DenseMap::iterator Result =
+LambdaIds.find(RD);
+// The lambda should exist, but return 0 in case it doesn't.
+if (Result == LambdaIds.end())
+  return 0;
+return Result->second;
+  }
+
   /// Return a character sequence that is (somewhat) unique to the TU suitable
   /// for mangling anonymous namespaces.
   StringRef getAnonymousNamespaceHash() const {
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -203,6 +203,14 @@
 disc = discriminator-2;
 return true;
   }
+
+  unsigned getLambdaNumber(const CXXRecordDecl *Lambda) override {
+unsigned Number = Lambda->getLambdaManglingNumber();
+if (Number == 0)
+  return getAnon

[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D94820#2523461 , @thakis wrote:

> Looks like this breaks tests on windows: 
> http://45.33.8.238/win/32075/step_7.txt
>
> Please take a look, and revert for now if it takes a while to fix.

Thanks for the heads up, I suspect it might be because of the Windows paths in 
the list file. I've reverted the change so I can test the fix on Windows before 
relanding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2021-01-26 Thread Fangrui Song 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 rG34b60d8a5684: Add -fbinutils-version= to gate ELF features 
on the specified binutils version (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/test/tools/llc/binutils-version.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -82,6 +82,15 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt
+BinutilsVersion("binutils-version", cl::Hidden,
+cl::desc("Produced object files can use all ELF features "
+ "supported by this binutils version and newer."
+ "If -no-integrated-as is specified, the generated "
+ "assembly will consider GNU as support."
+ "'none' means that all ELF features can be used, "
+ "regardless of binutils support"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -427,9 +436,24 @@
   case '3': OLvl = CodeGenOpt::Aggressive; break;
   }
 
+  // Parse 'none' or '$major.$minor'. Disallow -binutils-version=0 because we
+  // use that to indicate the MC default.
+  if (!BinutilsVersion.empty() && BinutilsVersion != "none") {
+StringRef V = BinutilsVersion.getValue();
+unsigned Num;
+if (V.consumeInteger(10, Num) || Num == 0 ||
+!(V.empty() ||
+  (V.consume_front(".") && !V.consumeInteger(10, Num) && V.empty( {
+  WithColor::error(errs(), argv[0])
+  << "invalid -binutils-version, accepting 'none' or major.minor\n";
+  return 1;
+}
+  }
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple &TheTriple) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/tools/llc/binutils-version.ll
===
--- /dev/null
+++ llvm/test/tools/llc/binutils-version.ll
@@ -0,0 +1,13 @@
+;; Test valid and invalid -binutils-version values.
+; RUN: llc %s -filetype=null -binutils-version=none
+; RUN: llc %s -filetype=null -binutils-version=2
+; RUN: llc %s -filetype=null -binutils-version=2.35
+
+;; Disallow -binutils-version=0 because we use $major==0 to indicate the MC
+;; default.
+; RUN: not llc %s -filetype=null -binutils-version=0 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=nan 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=2. 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not llc %s -filetype=null -binutils-version=3.-14 2>&1 | FileCheck %s --check-prefix=ERR
+
+; ERR: error: invalid -binutils-version, accepting 'none' or major.minor
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,21 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with e

[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/UsersManual.rst:2271
 
+.. option:: -fprofile-list=
+

This can be added below `-fprofile-exclude-files=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

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

That's definitely an unintended behaviour. Please file a bug and possibly mark 
it as release blocker for LLVM 12. Either a fix will be there soon, or we'll 
revert.

FYI, simple reproduce:

  verifyFormat("#include \n"
   "namespace rep {}",
   Style);

The problem doesn't happen with `#include "stdint.h"`.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:374-375
+if (Previous) {
+  if (Previous->is(tok::greater))
+return 0;
+  if (Previous->is(tok::identifier)) {

@leonardchan, it seems this is the culprit. the closing `>` in the `#include 
<...>` is treated as if it were a template closer and so it inhibits line 
merging.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D93839: [clang-format] PR48594 BraceWrapping: SplitEmptyRecord ignored for templates

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D93839#2523703 , @curdeius wrote:

> That's definitely an unintended behaviour. Please file a bug and possibly 
> mark it as release blocker for LLVM 12. Either a fix will be there soon, or 
> we'll revert.
>
> FYI, simple reproduce:
>
>   verifyFormat("#include \n"
>"namespace rep {}",
>Style);
>
> The problem doesn't happen with `#include "stdint.h"`.

Thanks for looking into this. I filed 
https://bugs.llvm.org/show_bug.cgi?id=48891.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93839

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


[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, leonardchan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a bug introduced in D93839  where:

  #include 
  namespace rep {}

got formatted as

  #include 
  namespace rep {
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95479

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10248,6 +10248,21 @@
"{\n"
"};",
Style);
+
+  verifyFormat("#include \"stdint.h\"\n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   "#include \n"
+   "namespace rep {\n"
+   "\n"
+   "\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, SplitEmptyStruct) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -371,7 +371,7 @@
 if (Previous->is(tok::comment))
   Previous = Previous->getPreviousNonComment();
 if (Previous) {
-  if (Previous->is(tok::greater))
+  if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
 return 0;
   if (Previous->is(tok::identifier)) {
 const FormatToken *PreviousPrevious =


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10248,6 +10248,21 @@
"{\n"
"};",
Style);
+
+  verifyFormat("#include \"stdint.h\"\n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   Style);
+  verifyFormat("#include \n"
+   "namespace rep {}",
+   "#include \n"
+   "namespace rep {\n"
+   "\n"
+   "\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, SplitEmptyStruct) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -371,7 +371,7 @@
 if (Previous->is(tok::comment))
   Previous = Previous->getPreviousNonComment();
 if (Previous) {
-  if (Previous->is(tok::greater))
+  if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
 return 0;
   if (Previous->is(tok::identifier)) {
 const FormatToken *PreviousPrevious =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95409: [clang] implicitly delete space ship operator with function pointers

2021-01-26 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 319400.
mizvekov added a comment.

added tests

adds test that will catch original bug
also adds some tests on default equality/relational operators

this last one would have caught the issue of not accepting equality
operator for function pointers, had I not remembered about it :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95409

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p4.cpp


Index: clang/test/CXX/class/class.compare/class.spaceship/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.compare/class.spaceship/p4.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+namespace std {
+class partial_ordering {
+  int n;
+  constexpr partial_ordering(int n) : n(n) {}
+
+public:
+  static const partial_ordering less, equivalent, greater, unordered;
+  bool operator!=(int) { return n != 0; }
+};
+constexpr partial_ordering partial_ordering::less{-1},
+partial_ordering::equivalent{0}, partial_ordering::greater{1},
+partial_ordering::unordered{2};
+} // namespace std
+
+struct A {
+  auto operator<=>(A const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  const int &a = 0;// expected-note {{defaulted 
'operator<=>' is implicitly deleted because class 'A' has a reference member}}
+};
+
+struct B {
+  auto operator<=>(B const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  void (*a)(); // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
+
+struct C {
+  auto operator<=>(C const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  void (C::*a)();  // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
+
+struct D {
+  auto operator<=>(D const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  int D::*a;   // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};
Index: clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.compare/class.compare.default/p6.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+struct A {
+  bool operator==(A const &) const = default; // expected-warning {{explicitly 
defaulted equality comparison operator is implicitly deleted}}
+  bool operator<(A const &) const = default;  // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  const int &a = 0; // expected-note {{defaulted 'operator==' is implicitly 
deleted because class 'A' has a reference member}}
+};
+
+struct B {
+  bool operator==(B const &) const = default;
+  bool operator<(B const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  void (*a)();
+};
+
+struct C {
+  bool operator==(C const &) const = default;
+  bool operator<(C const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  void (C::*a)();
+};
+
+struct D {
+  bool operator==(D const &) const = default;
+  bool operator<(D const &) const = default; // expected-warning {{explicitly 
defaulted relational comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator<' is implicitly deleted because 
there is no viable comparison function}}
+  int D::*a;
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7677,7 +7677,8 @@
 
 if (Args[0]->getType()->isOverloadableType())
   S.LookupOverloadedBinOp(CandidateSet, OO, Fns, Args);
-else {
+else if (OO == OO_EqualEqual ||
+ !Args[0]->getType()->isFunctionPointerType()) {
   // FIXME: We determine whether this i

[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM. Confirmed on our end this fixes our issue. Thanks for addressing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95479

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


[PATCH] D92808: [ObjC][ARC] Annotate calls with attributes instead of emitting retainRV or claimRV calls in the IR

2021-01-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: llvm/lib/IR/Instruction.cpp:580
+if (auto *CB = dyn_cast(this))
+  return objcarc::hasRetainRVOrClaimRVAttr(CB);
+return false;

fhahn wrote:
> ahatanak wrote:
> > fhahn wrote:
> > > rjmccall wrote:
> > > > nikic wrote:
> > > > > This change looks pretty fishy. Objective C shouldn't be hijacking 
> > > > > LLVMs core instruction model in this way. If it writes to memory, 
> > > > > this should either be reflected in the attributes, or modeled using 
> > > > > operand bundles.
> > > > > 
> > > > > @fhahn Did you review these changes? If not, I'd suggest to revert 
> > > > > this patch and get a review on the LLVM changes.
> > > > This could definitely be an operand bundle, and I suppose the presence 
> > > > of a bundle does force a conservative assumption on passes.
> > > > @fhahn Did you review these changes? 
> > > 
> > > Nope I didn't have time to look at this so far.
> > > 
> > > 
> > > 
> > > Can functions marked as `readonly`/`readnone` be called with the objc 
> > > attributes? 
> > > 
> > > I'm not very familiar with ObjC, but even for a function that just 
> > > returns a passed in object id, don't we need to retain & release the 
> > > object in the function? Which means the function cannot be `readonly` 
> > > because we need to call `@llvm.objc*` functions? If that's the case, 
> > > could we just check in the verifier that the attributes are never used 
> > > with `readonly` functions?
> > > 
> > > If there are indeed cases where we can call `readonly` functions, operand 
> > > bundles would probably be safest. It would probably also good to have at 
> > > least a few alias-analysis tests, to make sure things work as expected.
> > A function compiled using ARC can call a function compiled using MRR, which 
> > can be readonly/readnone. Also, a function compiled using ARC can be marked 
> > as readonly/readnone (if an optimization pass wants to do so) after ARC 
> > optimizer removes the retainRV/autoreleaseRV pair.
> > 
> > ```
> > define i8* @foo() {
> >   %1 = tail call i8* @readonlyMRRFunc()
> >   ; This function can be readonly if ARC optimizer removes the following 
> > two instructions.
> >   %2 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
> >   %3 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %2)
> >   ret i8* 
> > }
> > ```
> > A function compiled using ARC can call a function compiled using MRR, which 
> > can be readonly/readnone
> 
> Ok, sounds like a bundle would be a good option then?
Yes. I think bundle should be used here.

I'm considering passing an integer flag, which distinguishes between retain and 
claim (e.g., 0 for retain and 1 for claim), to the bundles:

```
call i8* @foo() [ "clang.arc.rv"(i64 0) ]
```

Do you see any problems with this approach? Alternatively, we could pass the 
pointer to the runtime function (e.g., pointer to 
`@llvm.objc.retainAutoreleasedReturnValue`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D95482: [PATCH] [clang] Fix bug 48848 by removing assertion related to recoverFromMSUnqualifiedLookup

2021-01-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: erichkeane, rnk.
mibintc requested review of this revision.
Herald added a project: clang.

Fix https://bugs.llvm.org/show_bug.cgi?id=48848 by removing assertion


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95482

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT &sp, ET &ep) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can 
recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value -fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT &sp, ET &ep) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95479: [clang-format] Avoid considering include directive as a template closer.

2021-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95479

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


[PATCH] D93248: Frontend: Fix layering between create{,Default}OutputFile, NFC

2021-01-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93248

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


[PATCH] D94820: Support for instrumenting only selected files or functions

2021-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/docs/UsersManual.rst:2271
 
+.. option:: -fprofile-list=
+

MaskRay wrote:
> This can be added below `-fprofile-exclude-files=`
I considered it but that's in the GCOV section and this flag only applies to 
the LLVM instrumentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94820

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


[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream

2021-01-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93249

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


[PATCH] D95459: Add helper functionality for parsing different attribute syntaxes in arbitrary order

2021-01-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me! (welcome to wait for more eyes, if you like)


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

https://reviews.llvm.org/D95459

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


  1   2   >