[clang] c495dfe - [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

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

Author: Jan Svoboda
Date: 2021-01-15T08:41:50+01:00
New Revision: c495dfe0268bc2be8737725d657411baa1399e9d

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

LOG: [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

Instead of passing the whole `TargetOptions` and `PreprocessorOptions` to 
`ParseLangArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups 
easier.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index c723fc084c85..9f16c5077154 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -176,11 +176,12 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// \param Opts - The LangOptions object to set up.
   /// \param IK - The input language.
   /// \param T - The target triple.
-  /// \param PPOpts - The PreprocessorOptions affected.
+  /// \param Includes - The affected list of included files.
   /// \param LangStd - The input language standard.
-  static void setLangDefaults(LangOptions &Opts, InputKind IK,
-   const llvm::Triple &T, PreprocessorOptions &PPOpts,
-   LangStandard::Kind LangStd = 
LangStandard::lang_unspecified);
+  static void
+  setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T,
+  std::vector &Includes,
+  LangStandard::Kind LangStd = LangStandard::lang_unspecified);
 
   /// Retrieve a module hash string that is suitable for uniquely
   /// identifying the conditions under which the module was built.

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 6327723699d2..d80d1f79c692 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1889,7 +1889,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions 
&Opts, ArgList &Args,
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
- PreprocessorOptions &PPOpts,
+ std::vector &Includes,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be 
nice
   // to move these to the language standard, and have the driver resolve the
@@ -2000,9 +2000,9 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
 if (Opts.IncludeDefaultHeader) {
   if (Opts.DeclareOpenCLBuiltins) {
 // Only include base header file for builtin types and constants.
-PPOpts.Includes.push_back("opencl-c-base.h");
+Includes.push_back("opencl-c-base.h");
   } else {
-PPOpts.Includes.push_back("opencl-c.h");
+Includes.push_back("opencl-c.h");
   }
 }
   }
@@ -2138,8 +2138,8 @@ static const StringRef GetInputKindName(InputKind IK) {
 }
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
-  const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts,
+  const llvm::Triple &T,
+  std::vector &Includes,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -2212,8 +2212,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
-  llvm::Triple T(TargetOpts.Triple);
-  CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
+  CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
@@ -2490,7 +2489,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getSpelling() << "-fdefault-calling-conv";
 else {
-  llvm::Triple T(TargetOpts.Triple);
   if (T.getArch() != llvm::Triple::x86)
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << A->getSpelling() << T.getTriple();
@@ -2527,8 +2525,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, Input

[PATCH] D94674: [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters

2021-01-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc495dfe0268b: [clang][cli] NFC: Decrease the scope of 
ParseLangArgs parameters (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94674

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1889,7 +1889,7 @@
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
- PreprocessorOptions &PPOpts,
+ std::vector &Includes,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be 
nice
   // to move these to the language standard, and have the driver resolve the
@@ -2000,9 +2000,9 @@
 if (Opts.IncludeDefaultHeader) {
   if (Opts.DeclareOpenCLBuiltins) {
 // Only include base header file for builtin types and constants.
-PPOpts.Includes.push_back("opencl-c-base.h");
+Includes.push_back("opencl-c-base.h");
   } else {
-PPOpts.Includes.push_back("opencl-c.h");
+Includes.push_back("opencl-c.h");
   }
 }
   }
@@ -2138,8 +2138,8 @@
 }
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
-  const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts,
+  const llvm::Triple &T,
+  std::vector &Includes,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -2212,8 +2212,7 @@
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
-  llvm::Triple T(TargetOpts.Triple);
-  CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
+  CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
@@ -2490,7 +2489,6 @@
   Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getSpelling() << "-fdefault-calling-conv";
 else {
-  llvm::Triple T(TargetOpts.Triple);
   if (T.getArch() != llvm::Triple::x86)
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << A->getSpelling() << T.getTriple();
@@ -2527,8 +2525,7 @@
   // Add unsupported host targets here:
   case llvm::Triple::nvptx:
   case llvm::Triple::nvptx64:
-Diags.Report(diag::err_drv_omp_host_target_not_supported)
-<< TargetOpts.Triple;
+Diags.Report(diag::err_drv_omp_host_target_not_supported) << T.str();
 break;
   }
 }
@@ -2960,8 +2957,8 @@
   } else {
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
-ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-  Res.getPreprocessorOpts(), Diags);
+ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes,
+  Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
 if (T.isOSDarwin() && DashX.isPreprocessed()) {
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -176,11 +176,12 @@
   /// \param Opts - The LangOptions object to set up.
   /// \param IK - The input language.
   /// \param T - The target triple.
-  /// \param PPOpts - The PreprocessorOptions affected.
+  /// \param Includes - The affected list of included files.
   /// \param LangStd - The input language standard.
-  static void setLangDefaults(LangOptions &Opts, InputKind IK,
-   const llvm::Triple &T, PreprocessorOptions &PPOpts,
-   LangStandard::Kind LangStd = 
LangStandard::lang_unspecified);
+  static void
+  setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T,
+  std::vector &Includes,
+  LangStandard::Kind LangStd = LangStandard::lang_unspecified);
 
   /// Retrieve a module hash string that is suitable for uniquely
   /// identifying the conditions under which the module was built.


Index: clang/lib/Frontend/CompilerInvocation.cpp
=

[clang] 1a49944 - [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

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

Author: Jan Svoboda
Date: 2021-01-15T08:42:30+01:00
New Revision: 1a49944b59dbbfd62bd860b564919087f274a5bf

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

LOG: [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

Instead of passing the whole `TargetOptions` and `FrontendOptions` to 
`ParseCodeGenArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups 
easier.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d80d1f79c692..6d5b4a84c233 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -405,6 +405,8 @@ static void FixupInvocation(CompilerInvocation &Invocation,
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
+  CodeGenOpts.CodeModel = TargetOpts.CodeModel;
+
   if (LangOpts.getExceptionHandling() != llvm::ExceptionHandling::None &&
   T.isWindowsMSVCEnvironment())
 Diags.Report(diag::err_fe_invalid_exception_model)
@@ -901,11 +903,9 @@ static void setPGOUseInstrumentor(CodeGenOptions &Opts,
 }
 
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags,
- const TargetOptions &TargetOpts,
- const FrontendOptions &FrontendOpts) {
+ DiagnosticsEngine &Diags, const llvm::Triple &T,
+ const std::string &OutputFile) {
   bool Success = true;
-  llvm::Triple Triple = llvm::Triple(TargetOpts.Triple);
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
   // TODO: This could be done in Driver
@@ -964,7 +964,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList 
&Args, InputKind IK,
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  llvm::Triple T(TargetOpts.Triple);
   if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
@@ -990,8 +989,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList 
&Args, InputKind IK,
   if (!Opts.ProfileInstrumentUsePath.empty())
 setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
 
-  Opts.CodeModel = TargetOpts.CodeModel;
-
   if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
 Opts.TimePasses = true;
 
@@ -1036,8 +1033,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, 
ArgList &Args, InputKind IK,
   if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
 Opts.SaveTempsFilePrefix =
 llvm::StringSwitch(A->getValue())
-.Case("obj", FrontendOpts.OutputFile)
-.Default(llvm::sys::path::filename(FrontendOpts.OutputFile).str());
+.Case("obj", OutputFile)
+.Default(llvm::sys::path::filename(OutputFile).str());
 
   // The memory profile runtime appends the pid to make this name more unique.
   const char *MemProfileBasename = "memprof.profraw";
@@ -2937,11 +2934,11 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
-  Res.getTargetOpts(), Res.getFrontendOpts());
+  llvm::Triple T(Res.getTargetOpts().Triple);
+  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags, T,
+  Res.getFrontendOpts().OutputFile);
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
-  llvm::Triple T(Res.getTargetOpts().Triple);
   if (DashX.getFormat() == InputKind::Precompiled ||
   DashX.getLanguage() == Language::LLVM_IR) {
 // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the



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


[PATCH] D94675: [clang][cli] NFC: Decrease the scope of ParseCodeGenArgs parameters

2021-01-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a49944b59db: [clang][cli] NFC: Decrease the scope of 
ParseCodeGenArgs parameters (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94675

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -405,6 +405,8 @@
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
+  CodeGenOpts.CodeModel = TargetOpts.CodeModel;
+
   if (LangOpts.getExceptionHandling() != llvm::ExceptionHandling::None &&
   T.isWindowsMSVCEnvironment())
 Diags.Report(diag::err_fe_invalid_exception_model)
@@ -901,11 +903,9 @@
 }
 
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags,
- const TargetOptions &TargetOpts,
- const FrontendOptions &FrontendOpts) {
+ DiagnosticsEngine &Diags, const llvm::Triple &T,
+ const std::string &OutputFile) {
   bool Success = true;
-  llvm::Triple Triple = llvm::Triple(TargetOpts.Triple);
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
   // TODO: This could be done in Driver
@@ -964,7 +964,6 @@
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  llvm::Triple T(TargetOpts.Triple);
   if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
@@ -990,8 +989,6 @@
   if (!Opts.ProfileInstrumentUsePath.empty())
 setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
 
-  Opts.CodeModel = TargetOpts.CodeModel;
-
   if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
 Opts.TimePasses = true;
 
@@ -1036,8 +1033,8 @@
   if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
 Opts.SaveTempsFilePrefix =
 llvm::StringSwitch(A->getValue())
-.Case("obj", FrontendOpts.OutputFile)
-.Default(llvm::sys::path::filename(FrontendOpts.OutputFile).str());
+.Case("obj", OutputFile)
+.Default(llvm::sys::path::filename(OutputFile).str());
 
   // The memory profile runtime appends the pid to make this name more unique.
   const char *MemProfileBasename = "memprof.profraw";
@@ -2937,11 +2934,11 @@
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
-  Res.getTargetOpts(), Res.getFrontendOpts());
+  llvm::Triple T(Res.getTargetOpts().Triple);
+  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags, T,
+  Res.getFrontendOpts().OutputFile);
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
-  llvm::Triple T(Res.getTargetOpts().Triple);
   if (DashX.getFormat() == InputKind::Precompiled ||
   DashX.getLanguage() == Language::LLVM_IR) {
 // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -405,6 +405,8 @@
   llvm::Triple T(TargetOpts.Triple);
   llvm::Triple::ArchType Arch = T.getArch();
 
+  CodeGenOpts.CodeModel = TargetOpts.CodeModel;
+
   if (LangOpts.getExceptionHandling() != llvm::ExceptionHandling::None &&
   T.isWindowsMSVCEnvironment())
 Diags.Report(diag::err_fe_invalid_exception_model)
@@ -901,11 +903,9 @@
 }
 
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags,
- const TargetOptions &TargetOpts,
- const FrontendOptions &FrontendOpts) {
+ DiagnosticsEngine &Diags, const llvm::Triple &T,
+ const std::string &OutputFile) {
   bool Success = true;
-  llvm::Triple Triple = llvm::Triple(TargetOpts.Triple);
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
   // TODO: This could be done in Driver
@@ -964,7 +964,6 @@
   llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
-  llvm::Triple T(TargetOp

[PATCH] D94724: [clangd] Remove the recovery-ast options.

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

Thanks, this looks good to me.

I have left an explicit setting in our internal client (so this will break the 
build during the integration), I'll remove them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94724

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


[PATCH] D94727: [clangd] Retire some flags for uncontroversial, stable features.

2021-01-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

the code looks good to me, but we need to be a bit careful on landing this -- 
as we have an internal client setting this flag.




Comment at: clang-tools-extra/clangd/ClangdServer.h:147
 
-bool SuggestMissingIncludes = false;
-

our internal client explicitly set this to `true`, so we need a migration plan 
for this, otherwise this would break our build of internal client during the 
integration, a possible plan is

1. set this flag to true by default in upstream, wait for the integration
2. remove the explicit setting internally
3. remove this flag (this patch) in upstream

Or just remove the flag internally, then land this patch in upstream (but 
internal release has to pick-up these two together)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94727

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


[clang] 168be42 - [Clang] Mutate long-double math builtins into f128 under IEEE-quad

2021-01-15 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2021-01-15T16:56:20+08:00
New Revision: 168be4208304e36d3bb156b5c413b340a391383e

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

LOG: [Clang] Mutate long-double math builtins into f128 under IEEE-quad

Under -mabi=ieeelongdouble on PowerPC, IEEE-quad floating point semantic
is used for long double. This patch mutates call to related builtins
into f128 version on PowerPC. And in theory, this should be applied to
other targets when their backend supports IEEE 128-bit style libcalls.

GCC already has these mutations except nansl, which is not available on
PowerPC along with other variants (nans, nansf).

Reviewed By: RKSimon, nemanjai

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/math-builtins-long.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7fa4e4d270ad..25ebb67c2ab6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2107,6 +2107,78 @@ RValue CodeGenFunction::emitRotate(const CallExpr *E, 
bool IsRotateRight) {
   return RValue::get(Builder.CreateCall(F, { Src, Src, ShiftAmt }));
 }
 
+// Map math builtins for long-double to f128 version.
+static unsigned mutateLongDoubleBuiltin(unsigned BuiltinID) {
+  switch (BuiltinID) {
+#define MUTATE_LDBL(func) \
+  case Builtin::BI__builtin_##func##l: \
+return Builtin::BI__builtin_##func##f128;
+  MUTATE_LDBL(sqrt)
+  MUTATE_LDBL(cbrt)
+  MUTATE_LDBL(fabs)
+  MUTATE_LDBL(log)
+  MUTATE_LDBL(log2)
+  MUTATE_LDBL(log10)
+  MUTATE_LDBL(log1p)
+  MUTATE_LDBL(logb)
+  MUTATE_LDBL(exp)
+  MUTATE_LDBL(exp2)
+  MUTATE_LDBL(expm1)
+  MUTATE_LDBL(fdim)
+  MUTATE_LDBL(hypot)
+  MUTATE_LDBL(ilogb)
+  MUTATE_LDBL(pow)
+  MUTATE_LDBL(fmin)
+  MUTATE_LDBL(fmax)
+  MUTATE_LDBL(ceil)
+  MUTATE_LDBL(trunc)
+  MUTATE_LDBL(rint)
+  MUTATE_LDBL(nearbyint)
+  MUTATE_LDBL(round)
+  MUTATE_LDBL(floor)
+  MUTATE_LDBL(lround)
+  MUTATE_LDBL(llround)
+  MUTATE_LDBL(lrint)
+  MUTATE_LDBL(llrint)
+  MUTATE_LDBL(fmod)
+  MUTATE_LDBL(modf)
+  MUTATE_LDBL(nan)
+  MUTATE_LDBL(nans)
+  MUTATE_LDBL(inf)
+  MUTATE_LDBL(fma)
+  MUTATE_LDBL(sin)
+  MUTATE_LDBL(cos)
+  MUTATE_LDBL(tan)
+  MUTATE_LDBL(sinh)
+  MUTATE_LDBL(cosh)
+  MUTATE_LDBL(tanh)
+  MUTATE_LDBL(asin)
+  MUTATE_LDBL(acos)
+  MUTATE_LDBL(atan)
+  MUTATE_LDBL(asinh)
+  MUTATE_LDBL(acosh)
+  MUTATE_LDBL(atanh)
+  MUTATE_LDBL(atan2)
+  MUTATE_LDBL(erf)
+  MUTATE_LDBL(erfc)
+  MUTATE_LDBL(ldexp)
+  MUTATE_LDBL(frexp)
+  MUTATE_LDBL(huge_val)
+  MUTATE_LDBL(copysign)
+  MUTATE_LDBL(nextafter)
+  MUTATE_LDBL(nexttoward)
+  MUTATE_LDBL(remainder)
+  MUTATE_LDBL(remquo)
+  MUTATE_LDBL(scalbln)
+  MUTATE_LDBL(scalbn)
+  MUTATE_LDBL(tgamma)
+  MUTATE_LDBL(lgamma)
+#undef MUTATE_LDBL
+  default:
+return BuiltinID;
+  }
+}
+
 RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned 
BuiltinID,
 const CallExpr *E,
 ReturnValueSlot ReturnValue) {
@@ -2123,6 +2195,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Result.Val.getFloat()));
   }
 
+  // If current long-double semantics is IEEE 128-bit, replace math builtins
+  // of long-double with f128 equivalent.
+  // TODO: This mutation should also be applied to other targets other than 
PPC,
+  // after backend supports IEEE 128-bit style libcalls.
+  if (getTarget().getTriple().isPPC64() &&
+  &getTarget().getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
+BuiltinID = mutateLongDoubleBuiltin(BuiltinID);
+
   // If the builtin has been declared explicitly with an assembler label,
   // disable the specialized emitting below. Ideally we should communicate the
   // rename in IR, or at least avoid generating the intrinsic calls that are

diff  --git a/clang/test/CodeGen/math-builtins-long.c 
b/clang/test/CodeGen/math-builtins-long.c
index bf7ebd31..f5cee75acad6 100644
--- a/clang/test/CodeGen/math-builtins-long.c
+++ b/clang/test/CodeGen/math-builtins-long.c
@@ -13,13 +13,13 @@ void foo(long double f, long double *l, int *i, const char 
*c) {
   // F80: call x86_fp80 @fmodl(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @fmodl(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
-  // PPCF128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
+  // PPCF128: call fp128 @fmodf128(fp128 %{{.+}}, fp128 %{{.+}})
   __builtin_fmodl(f,f);
 
   // F80: call x86_fp80 @atan2l(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @atan2l(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @atan2l(fp128

[PATCH] D92080: [Clang] Mutate long-double math builtins into f128 under IEEE-quad

2021-01-15 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG168be4208304: [Clang] Mutate long-double math builtins into 
f128 under IEEE-quad (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92080

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/math-builtins-long.c

Index: clang/test/CodeGen/math-builtins-long.c
===
--- clang/test/CodeGen/math-builtins-long.c
+++ clang/test/CodeGen/math-builtins-long.c
@@ -13,13 +13,13 @@
   // F80: call x86_fp80 @fmodl(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @fmodl(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
-  // PPCF128: call fp128 @fmodl(fp128 %{{.+}}, fp128 %{{.+}})
+  // PPCF128: call fp128 @fmodf128(fp128 %{{.+}}, fp128 %{{.+}})
   __builtin_fmodl(f,f);
 
   // F80: call x86_fp80 @atan2l(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @atan2l(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @atan2l(fp128 %{{.+}}, fp128 %{{.+}})
-  // PPCF128: call fp128 @atan2l(fp128 %{{.+}}, fp128 %{{.+}})
+  // PPCF128: call fp128 @atan2f128(fp128 %{{.+}}, fp128 %{{.+}})
   __builtin_atan2l(f,f);
 
   // F80: call x86_fp80 @llvm.copysign.f80(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
@@ -37,7 +37,7 @@
   // F80: call x86_fp80 @frexpl(x86_fp80 %{{.+}}, i32* %{{.+}})
   // PPC: call ppc_fp128 @frexpl(ppc_fp128 %{{.+}}, i32* %{{.+}})
   // X86F128: call fp128 @frexpl(fp128 %{{.+}}, i32* %{{.+}})
-  // PPCF128: call fp128 @frexpl(fp128 %{{.+}}, i32* %{{.+}})
+  // PPCF128: call fp128 @frexpf128(fp128 %{{.+}}, i32* %{{.+}})
   __builtin_frexpl(f,i);
 
   // F80: store x86_fp80 0xK7FFF8000, x86_fp80*
@@ -55,73 +55,73 @@
   // F80: call x86_fp80 @ldexpl(x86_fp80 %{{.+}}, i32 %{{.+}})
   // PPC: call ppc_fp128 @ldexpl(ppc_fp128 %{{.+}}, {{(signext)?.+}})
   // X86F128: call fp128 @ldexpl(fp128 %{{.+}}, {{(signext)?.+}})
-  // PPCF128: call fp128 @ldexpl(fp128 %{{.+}}, {{(signext)?.+}})
+  // PPCF128: call fp128 @ldexpf128(fp128 %{{.+}}, {{(signext)?.+}})
   __builtin_ldexpl(f,f);
 
   // F80: call x86_fp80 @modfl(x86_fp80 %{{.+}}, x86_fp80* %{{.+}})
   // PPC: call ppc_fp128 @modfl(ppc_fp128 %{{.+}}, ppc_fp128* %{{.+}})
   // X86F128: call fp128 @modfl(fp128 %{{.+}}, fp128* %{{.+}})
-  // PPCF128: call fp128 @modfl(fp128 %{{.+}}, fp128* %{{.+}})
+  // PPCF128: call fp128 @modff128(fp128 %{{.+}}, fp128* %{{.+}})
   __builtin_modfl(f,l);
 
   // F80: call x86_fp80 @nanl(i8* %{{.+}})
   // PPC: call ppc_fp128 @nanl(i8* %{{.+}})
   // X86F128: call fp128 @nanl(i8* %{{.+}})
-  // PPCF128: call fp128 @nanl(i8* %{{.+}})
+  // PPCF128: call fp128 @nanf128(i8* %{{.+}})
   __builtin_nanl(c);
 
   // F80: call x86_fp80 @nansl(i8* %{{.+}})
   // PPC: call ppc_fp128 @nansl(i8* %{{.+}})
   // X86F128: call fp128 @nansl(i8* %{{.+}})
-  // PPCF128: call fp128 @nansl(i8* %{{.+}})
+  // PPCF128: call fp128 @nansf128(i8* %{{.+}})
   __builtin_nansl(c);
 
   // F80: call x86_fp80 @powl(x86_fp80 %{{.+}}, x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @powl(ppc_fp128 %{{.+}}, ppc_fp128 %{{.+}})
   // X86F128: call fp128 @powl(fp128 %{{.+}}, fp128 %{{.+}})
-  // PPCF128: call fp128 @powl(fp128 %{{.+}}, fp128 %{{.+}})
+  // PPCF128: call fp128 @powf128(fp128 %{{.+}}, fp128 %{{.+}})
   __builtin_powl(f,f);
 
   // F80: call x86_fp80 @acosl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @acosl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @acosl(fp128 %{{.+}})
-  // PPCF128: call fp128 @acosl(fp128 %{{.+}})
+  // PPCF128: call fp128 @acosf128(fp128 %{{.+}})
   __builtin_acosl(f);
 
   // F80: call x86_fp80 @acoshl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @acoshl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @acoshl(fp128 %{{.+}})
-  // PPCF128: call fp128 @acoshl(fp128 %{{.+}})
+  // PPCF128: call fp128 @acoshf128(fp128 %{{.+}})
   __builtin_acoshl(f);
 
   // F80: call x86_fp80 @asinl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @asinl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @asinl(fp128 %{{.+}})
-  // PPCF128: call fp128 @asinl(fp128 %{{.+}})
+  // PPCF128: call fp128 @asinf128(fp128 %{{.+}})
   __builtin_asinl(f);
 
   // F80: call x86_fp80 @asinhl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @asinhl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @asinhl(fp128 %{{.+}})
-  // PPCF128: call fp128 @asinhl(fp128 %{{.+}})
+  // PPCF128: call fp128 @asinhf128(fp128 %{{.+}})
   __builtin_asinhl(f);
 
   // F80: call x86_fp80 @atanl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @atanl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @atanl(fp128 %{{.+}})
-  // PPCF128: call fp128 @atanl(fp128 %{{.+}})
+  // PPCF128: call fp128 @atanf128(fp128 %{{.+}})
   __builtin_atanl(f);
 
   // F80: call x86_fp80 @atanhl(x86_fp80 %{{.+}})
   // PPC: call ppc_fp128 @atanhl(ppc_fp128 %{{.+}})
   // X86F128: call fp128 @a

[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-01-15 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 316861.
steakhal edited the summary of this revision.
steakhal set the repository for this revision to rG LLVM Github Monorepo.
steakhal added a comment.
Herald added a reviewer: shafik.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update: resolve @balazske's comment D94673#2498165 
.

- remove `ASTImporter::FileIDImportHandler` etc.
- updates the revision's summary accordingly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94673

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/test/Analysis/plist-macros-with-expansion-ctu.c
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -91,26 +91,6 @@
   *Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
 
   if (NewFD) {
-// Check GetImportedFromSourceLocation.
-llvm::Optional> SLocResult =
-CTU.getImportedFromSourceLocation(NewFD->getLocation());
-EXPECT_TRUE(SLocResult);
-if (SLocResult) {
-  SourceLocation OrigSLoc = (*SLocResult).first;
-  ASTUnit *OrigUnit = (*SLocResult).second;
-  // OrigUnit is created internally by CTU (is not the
-  // ASTWithDefinition).
-  TranslationUnitDecl *OrigTU =
-  OrigUnit->getASTContext().getTranslationUnitDecl();
-  const FunctionDecl *FDWithDefinition = FindFInTU(OrigTU);
-  EXPECT_TRUE(FDWithDefinition);
-  if (FDWithDefinition) {
-EXPECT_EQ(FDWithDefinition->getName(), "f");
-EXPECT_TRUE(FDWithDefinition->isThisDeclarationADefinition());
-EXPECT_EQ(OrigSLoc, FDWithDefinition->getLocation());
-  }
-}
-
 // Check parent map.
 const DynTypedNodeList ParentsAfterImport =
 Ctx.getParentMapContext().getParents(*FD);
Index: clang/test/Analysis/plist-macros-with-expansion-ctu.c
===
--- clang/test/Analysis/plist-macros-with-expansion-ctu.c
+++ clang/test/Analysis/plist-macros-with-expansion-ctu.c
@@ -2,13 +2,13 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -emit-pch -o %t/ctudir/plist-macros-ctu.c.ast %S/Inputs/plist-macros-ctu.c
 // RUN: cp %S/Inputs/plist-macros-with-expansion-ctu.c.externalDefMap.txt %t/ctudir/externalDefMap.txt
-
+//
 // RUN: %clang_analyze_cc1 -analyzer-checker=core \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=%t/ctudir \
 // RUN:   -analyzer-config expand-macros=true \
 // RUN:   -analyzer-output=plist-multi-file -o %t.plist -verify %s
-// XFAIL: *
+//
 // Check the macro expansions from the plist output here, to make the test more
 // understandable.
 //   RUN: FileCheck --input-file=%t.plist %s
@@ -23,25 +23,30 @@
   F3(&X);
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM1
-// CHECK-NEXT: expansion*Z = (int *)0
-
+// FIXME: Macro expansion for other TUs should also work.
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 void test1() {
   int *X;
   F1(&X);
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansion*X = (int *)0
+
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 void test2() {
   int *X;
   F2(&X);
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansion*Y = (int *)0
+
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 #define M F1(&X)
 
@@ -50,10 +55,20 @@
   M;
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansionF1(&X)
-// CHECK: nameM
-// CHECK-NEXT: expansion*X = (int *)0
+// Macro expansions for the main TU still works, even in CTU mode.
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:line55
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   nameM
+// CHECK-NEXT:   expansionF1 (&X )
+// CHECK-NEXT:  
+// CHECK-NEXT: 
 
 #undef M
 #define M F2(&X)
@@ -64,10 +79,19 @@
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
 
-// CHECK: nameM
-// CHECK-NEXT: expansionF2(&X)
-// CHECK: nameM
-// CHECK-NEXT: expansion*Y = (int *)0
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:   

[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-01-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:186
 
-  /// Determine the original source location in the original TU for an
-  /// imported source location.
+  /// Returns the MacroExpansionContext for the imported TU to which the given
+  /// corresponds.

I think it's missing "location" here



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:189-190
   /// \p ToLoc Source location in the imported-to AST.
-  /// \return Source location in the imported-from AST and the corresponding
-  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
-  /// object that is returned here).
-  /// If any error happens (ToLoc is a non-imported source location) empty is
+  /// If any error happens (\p ToLoc is a non-imported source location or macro
+  /// expansion tracking for imported TUs are not implemented yet) empty is
   /// returned.

I don't think that this piece of information should be here, it took me a bit 
to get it.  Maybe it can be a separate \note?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94673

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


[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 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 for the fix, a small comment about testing though.




Comment at: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp:532
 
 TEST(DocumentSymbols, InHeaderFile) {
   TestTU TU;

we already have a test case for this but it was passing erroneously, as the 
include was part of the preamble and never subject to documentoutline traversal.

can you rather update this test to look like:

```
int DeclarationToFinishPreamble;
#inclube "bar.h"
int test() {}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

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


[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

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



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:191
+  ///   source-location, empty is returned.
+  /// \note Macro expansion tracking for imported TUs are not implemented yet.
+  ///   It returns empty unconditionally.

`is`


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

https://reviews.llvm.org/D94673

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


[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2021-01-15 Thread Sam Elliott via Phabricator via cfe-commits
lenary marked 3 inline comments as done.
lenary added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp:104
+  // so that we don't insert `fp` manipulation code into functions that do not
+  // require it.
+  const MachineFrameInfo &MFI = MF.getFrameInfo();

jrtc27 wrote:
> Shouldn't this all be done by the generic stack realignment code like any 
> other allocation? Or is the issue because it's _register spills_ not explicit 
> allocas?
Yeah the issue is because it’s register spills. I have a nice long commit 
message I wrote that I should update the summary with.

Comment updated nonetheless



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.h:40
 
+  bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override {
+return true;

I forgot this was left in after some experimentation I did. Will remove it in 
the next update. 



Comment at: llvm/test/CodeGen/RISCV/callee-saved-fpr32s.ll:26
 define void @callee() nounwind {
+; ILP32-ILP32E-LP64-LABEL: callee:
+; ILP32-ILP32E-LP64:   # %bb.0:

These check lines are left over from before. will remove



Comment at: llvm/test/CodeGen/RISCV/stack-realignment.ll:3
 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
-; RUN:   | FileCheck %s -check-prefix=RV32I
+; RUN:   | FileCheck %s -check-prefixes=RV32I,RV32-ILP32
+; RUN: llc -mtriple=riscv32 -target-abi ilp32e -verify-machineinstrs < %s \

jrtc27 wrote:
> Multiple prefixes is a bad idea with update_llc_test_checks.py, and why is 
> this one done differently from the rest?
It also doesn’t help to avoid duplication here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D93401: [flang][driver] Add support for `-D`, `-U`

2021-01-15 Thread Faris via Phabricator via cfe-commits
FarisRehman marked an inline comment as done.
FarisRehman added inline comments.



Comment at: flang/test/Flang-Driver/driver-help.f90:22
 ! HELP-NEXT: -###   Print (but do not run) the commands to run 
for this compilation
+! HELP-NEXT: -D = Define  to  (or 1 if  
omitted)
 ! HELP-NEXT: -E Only run the preprocessor

FarisRehman wrote:
> sameeranjoshi wrote:
> > I see below crash report, when omitting the  but not omitting the 
> > `=` symbol.
> > Not sure if that's correct way of running hence instead of filing bug 
> > reporting here.
> > 
> > ```
> > ./bin/flang-new -E -DX= test.f90
> > ```
> > 
> > ```
> > PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
> > backtrace.
> > Stack dump:
> > 0.  Program arguments: 
> > /home/amd/f18_git/final_test/driver_build/bin/flang-new -fc1 -E -D X= -o - 
> > test.f90
> >  #0 0x7f26185d0bc1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libLLVMSupport.so.12git+0x1a4bc1)
> >  #1 0x7f26185ce9a4 llvm::sys::RunSignalHandlers() 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libLLVMSupport.so.12git+0x1a29a4)
> >  #2 0x7f26185ceb10 SignalHandler(int) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libLLVMSupport.so.12git+0x1a2b10)
> >  #3 0x7f2617749470 (/lib/x86_64-linux-gnu/libc.so.6+0x46470)
> >  #4 0x7f2617443498 
> > Fortran::parser::OffsetToProvenanceMappings::Map(unsigned long) const 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x571498)
> >  #5 0x7f261744adf2 Fortran::parser::TokenSequence::GetProvenanceRange() 
> > const 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x578df2)
> >  #6 0x7f26173dd334 
> > Fortran::parser::Preprocessor::MacroReplacement(Fortran::parser::TokenSequence
> >  const&, Fortran::parser::Prescanner&) (.localalias) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x50b334)
> >  #7 0x7f26173e9dc1 Fortran::parser::Prescanner::Statement() 
> > (.localalias) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x517dc1)
> >  #8 0x7f26173ea888 
> > Fortran::parser::Prescanner::Prescan(Fortran::common::Interval)
> >  (.localalias) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x51)
> >  #9 0x7f26173d480b 
> > Fortran::parser::Parsing::Prescan(std::__cxx11::basic_string > std::char_traits, std::allocator > const&, 
> > Fortran::parser::Options) 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/../lib/libFortranParser.so.12git+0x50280b)
> > #10 0x7f2618424ddd Fortran::frontend::FrontendAction::Execute() 
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libflangFrontend.so.12git+0x)
> > #11 0x7f261841fa5e 
> > Fortran::frontend::CompilerInstance::ExecuteAction(Fortran::frontend::FrontendAction&)
> >  
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libflangFrontend.so.12git+0x8a5e)
> > #12 0x7f26184132fc 
> > Fortran::frontend::ExecuteCompilerInvocation(Fortran::frontend::CompilerInstance*)
> >  
> > (/home/amd/f18_git/final_test/driver_build/bin/../lib/libflangFrontendTool.so.12git+0x12fc)
> > #13 0x55bad4081c20 fc1_main(llvm::ArrayRef, char const*) 
> > (/home/amd/f18_git/final_test/driver_build/bin/flang-new+0x3c20)
> > #14 0x55bad4080e59 main 
> > (/home/amd/f18_git/final_test/driver_build/bin/flang-new+0x2e59)
> > #15 0x7f261772a1e3 __libc_start_main 
> > /build/glibc-5mDdLG/glibc-2.30/csu/../csu/libc-start.c:342:3
> > #16 0x55bad4080eae _start 
> > (/home/amd/f18_git/final_test/driver_build/bin/flang-new+0x2eae)
> > flang-new: error: unable to execute command: Segmentation fault (core 
> > dumped)
> > flang-new: error: flang frontend command failed due to signal (use -v to 
> > see invocation)
> > flang-new version 12.0.0 (https://github.com/llvm/llvm-project.git 
> > 2f9cb090cc6db1be5bf524eb0a32537503b3e786)
> > Target: x86_64-unknown-linux-gnu
> > Thread model: posix
> > InstalledDir: /home/amd/f18_git/final_test/driver_build/bin
> > flang-new: note: diagnostic msg: Error generating preprocessed source(s) - 
> > no preprocessable inputs.
> > 
> > ```
> > 
> Thanks for reporting this!
> I was able to reproduce this error running:
>   - flang-new -DX= file.f
>   - flang-new -E -DX= file.f
>   - flang-new -fc1 -E -DX= file.f
>   - f18 -E -DX= file.f
> However I did not receive an error when running: `flang-new -fc1 -DX= file.f`
> I suspect this may be an issue in the frontend and I will look into this 
> further.
The bug seems to occur in the frontend and a bug report has been filed: 
https://bugs.llvm.org/show_bug.cgi?id=48747


Repository:
  rG LLVM Github Monorepo

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

https://

[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 316877.
ilya-golovenko added a comment.

Update existing test and remove redundant one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

@kadircet  Thank you for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

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


[PATCH] D94755: [clangd] Fix division by zero when computing scores

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

NameMatch could be a float close to zero, in such cases we were
dividing by zero and moreover propogating a "NaN" to clients, which is invalid
per JSON.

This fixes the issue by only using Quality scores whenever the NameMatch is low,
as we do in CodeCompletion ranking.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94755

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/FindSymbols.cpp


Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "FindSymbols"
@@ -146,8 +147,9 @@
   return;
 }
 Relevance.merge(Sym);
-auto Score = evaluateSymbolAndRelevance(Quality.evaluateHeuristics(),
-Relevance.evaluateHeuristics());
+auto QualScore = Quality.evaluateHeuristics();
+auto RelScore = Relevance.evaluateHeuristics();
+auto Score = evaluateSymbolAndRelevance(QualScore, RelScore);
 dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
  Quality, Relevance);
 
@@ -159,7 +161,9 @@
 Info.containerName = Scope.str();
 
 // Exposed score excludes fuzzy-match component, for client-side 
re-ranking.
-Info.score = Score / Relevance.NameMatch;
+Info.score = Relevance.NameMatch > std::numeric_limits::epsilon()
+ ? Score / Relevance.NameMatch
+ : QualScore;
 Top.push({Score, std::move(Info)});
   });
   for (auto &R : std::move(Top).items())
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -70,6 +70,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include 
 #include 
+#include 
 
 // We log detailed candidate here if you run with -debug-only=codecomplete.
 #define DEBUG_TYPE "CodeComplete"
@@ -1655,9 +1656,10 @@
   evaluateSymbolAndRelevance(Scores.Quality, Scores.Relevance);
   // NameMatch is in fact a multiplier on total score, so rescoring is
   // sound.
-  Scores.ExcludingName = Relevance.NameMatch
- ? Scores.Total / Relevance.NameMatch
- : Scores.Quality;
+  Scores.ExcludingName =
+  Relevance.NameMatch > std::numeric_limits::epsilon()
+  ? Scores.Total / Relevance.NameMatch
+  : Scores.Quality;
   return Scores;
 
 case RM::DecisionForest:


Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "FindSymbols"
@@ -146,8 +147,9 @@
   return;
 }
 Relevance.merge(Sym);
-auto Score = evaluateSymbolAndRelevance(Quality.evaluateHeuristics(),
-Relevance.evaluateHeuristics());
+auto QualScore = Quality.evaluateHeuristics();
+auto RelScore = Relevance.evaluateHeuristics();
+auto Score = evaluateSymbolAndRelevance(QualScore, RelScore);
 dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
  Quality, Relevance);
 
@@ -159,7 +161,9 @@
 Info.containerName = Scope.str();
 
 // Exposed score excludes fuzzy-match component, for client-side re-ranking.
-Info.score = Score / Relevance.NameMatch;
+Info.score = Relevance.NameMatch > std::numeric_limits::epsilon()
+ ? Score / Relevance.NameMatch
+ : QualScore;
 Top.push({Score, std::move(Info)});
   });
   for (auto &R : std::move(Top).items())
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -70,6 +70,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include 
 #include 
+#include 
 
 // We log detailed candidate here if you run with -debug-only=codecomplete.
 #define DEBUG_TYPE "CodeComplete"
@@ -1655,9 +1656,10 @@
   evaluateSymbolAndRelevance(Scores.Quality, Scores.Relevance);
   // NameMatch is in fact a multiplier on t

[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

btw, do you have commit access or should i land this for you ? (if so please 
provide your email)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

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


[PATCH] D94621: [clang-tidy] add concurrency-async-fs

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

Eugene.Zelenko, thanks for the review! fixed


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

https://reviews.llvm.org/D94621

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


[PATCH] D94622: [clang-tidy] add concurrency-async-no-new-threads

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

Eugene.Zelenko, thanks for the review! fixed


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

https://reviews.llvm.org/D94622

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


[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

In D94753#2500535 , @kadircet wrote:

> btw, do you have commit access or should i land this for you ? (if so please 
> provide your email)

I've got commit access some time ago. Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

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


[clang-tools-extra] 9cc221b - [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via cfe-commits

Author: Ilya Golovenko
Date: 2021-01-15T13:23:12+03:00
New Revision: 9cc221b99becf20397d935981eeb48cba5be7faf

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

LOG: [clangd] exclude symbols from document outline which do not originate from 
the main file

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index d6908f7ab5fb..0a10e3efb05c 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@ class DocumentOutline {
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index 43658284937e..e594ade4295e 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@ TEST(DocumentSymbols, InHeaderFile) {
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {



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


[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file

2021-01-15 Thread Ilya Golovenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cc221b99bec: [clangd] exclude symbols from document outline 
which do not originate from the… (authored by ilya-golovenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94753

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@
   }
   )cpp";
   TU.Code = R"cpp(
+  int i; // declaration to finish preamble
   #include "bar.h"
   int test() {
   }
   )cpp";
-  EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("i"), WithName("test")));
 }
 
 TEST(DocumentSymbols, Template) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@
   enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
+// Skip symbols which do not originate from the main file.
+if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+  return;
+
 if (auto *Templ = llvm::dyn_cast(D)) {
   // TemplatedDecl might be null, e.g. concepts.
   if (auto *TD = Templ->getTemplatedDecl())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94606: [clangd] Move DirBasedCDB broadcasting onto its own thread.

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



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:496
+  std::condition_variable CV;
+  std::atomic ShouldStop = {false}; // Must notify CV after writing.
+  std::deque Queue;

nit: we already hold the lock within the loop while reading. it is nice that we 
no longer need to acquire the lock during destructor, but is it worth the extra 
mental load that comes with memory orderings? (also IIRC, default load/store 
behaviors are already acquire-release)



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:541
+  });
+  Queue.push_back(std::move(Task));
+}

don't we need some context propagation here? previously broadcasting was 
running with the context of the astworker that discovered the cdb. i suppose it 
is not needed at the moment, as most of the stuff we do in ::process isn't 
context-aware, but I can't be sure if we don't have any users that make use of 
some context-aware FS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94606

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


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

2021-01-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D82862#2500038 , @pengfei wrote:

>> What is the reason for treating this differently in LLVM?
>
> I'm not sure if it is related to this. I think one difference is that LLVM is 
> supporting MS inline assembly. Although it uses Intel dialect, it has 
> different representation in input, output, clobber etc. with GCC'.

That is indeed another complication.  On the one hand, we have two different 
inline asm formats, GNU assembly and MS assembly.  These differ completely in 
how asm arguments (passed in from surrounding C/C++ code) are handled and 
therefore need to be parsed quite differently.  On the other hand, we have the 
different assembler dialects (AT&T vs. Intel on x86), which affect how the 
single asm instructions are to be parsed.

Unfortunately, the distinction between the two seems to be somewhat muddled in 
LLVM at this point.  In particular, MS assembly statements are represented at 
the LLVM IR level via the "inteldialect" token.  This is a bit confusing 
because while MS asm indeed always uses the Intel dialect, we can also have GNU 
asm with the Intel dialect -- at least this is the case in GCC when using 
-masm=intel.

What I think we should have is:

- the LLVM IR level distinction between GNU and MS asm statements; and in 
addition
- for GNU asm statements, a target-specific selection of assembler variants, 
which may depend on the target triple and/or command line options like -masm=

If you look at AsmPrinter::emitInlineAsm, this is actually **partially** 
implemented already:

  // The variant of the current asmprinter.
  int AsmPrinterVariant = MAI->getAssemblerDialect();
  AsmPrinter *AP = const_cast(this);
  if (MI->getInlineAsmDialect() == InlineAsm::AD_ATT)
EmitGCCInlineAsmStr(AsmStr, MI, MMI, AsmPrinterVariant, AP, LocCookie, OS);
  else
EmitMSInlineAsmStr(AsmStr, MI, MMI, AP, LocCookie, OS);

So here the LLVM IR marker is used to select between GCC and MS inline asm 
instructions, and for the GCC inline asm statements, the target is queried as 
to the proper asm dialect variant to use.

However, later on we have a

  Parser->setAssemblerDialect(Dialect);

call, where the Dialect is again taken from the LLVM IR setting -- so for GNU 
asm, this gets now always set back to AT&T.   It seems to me that this is 
simply wrong.

Then, we finally have **module** level inline asm statements, which are always 
treated as GNU style (although this may not really make any difference since 
module level statements do not have arguments anyway).  Again because of the 
above setAssemblerDialect call they would therefore be also treated as AT&T 
dialect, which I guess is what @hans originally noticed.

In D82862#2498785 , @hans wrote:

> The motivation for my change was really just to make ThinLTO compiles work 
> the same as non-ThinLTO ones.
>
> Maybe the fact that -x86-asm-syntax=intel doesn't affect inline asm is a bug. 
> I wasn't aware that Clang and GCC's -masm= flags behaved differently in that 
> way, but that certainly suggests there's a problem here.

So I'm wondering, if I remove the above setAssemblerDialect line **and** revert 
this commit, we should have inline asm (both module-level and GNU 
function-leve) respect the target-selected asm dialect variant both for ThinLTO 
and non-ThinLTO, so they should match again.   Would that also solve the 
problem you were originally tracking?


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] D75594: [AArch64] Add support for Fujitsu A64FX

2021-01-15 Thread KAWASHIMA Takahiro via Phabricator via cfe-commits
kawashima-fj closed this revision.
kawashima-fj added a comment.
Herald added subscribers: dexonsmith, danielkiss.

In D75594#1927988 , @ikitayama wrote:

> In D75594#1927959 , @kawashima-fj 
> wrote:
>
>> Yes, https://github.com/fujitsu/A64FX contains the official 
>> microarchitecture information of A64FX. I wanted to include the URL in the 
>> Git commit message but the disclosure was not ready for it at the time.
>
> Can you do it at the next commit opportunity as this reference manual should 
> be broadly read by the Arm developer community?

Done in b54337070b198cf66356a4ee3e420666151a2023 
 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75594

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


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

2021-01-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: rnk.
hans added a comment.

> In D82862#2498785 , @hans wrote:
>
>> The motivation for my change was really just to make ThinLTO compiles work 
>> the same as non-ThinLTO ones.
>>
>> Maybe the fact that -x86-asm-syntax=intel doesn't affect inline asm is a 
>> bug. I wasn't aware that Clang and GCC's -masm= flags behaved differently in 
>> that way, but that certainly suggests there's a problem here.
>
> So I'm wondering, if I remove the above setAssemblerDialect line **and** 
> revert this commit, we should have inline asm (both module-level and GNU 
> function-leve) respect the target-selected asm dialect variant both for 
> ThinLTO and non-ThinLTO, so they should match again.   Would that also solve 
> the problem you were originally tracking?

Not completely, because clang-cl sets -x86-asm-syntax=intel to enable 
intel-style asm in assembly listing output. We'd have to find another way of 
doing that without affecting the inline asm dialect.


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] D94697: [clangd] Update CC Ranking model with better sampling.

2021-01-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Quality.cpp:515
+  E.setFractionNameInContext(
+  Relevance.ContextWords ? NumMatch * 1.0 / Relevance.ContextWords->size()
+ : 0);

Please add a guard for division by zero


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94697

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


[PATCH] D94127: [ASTMatchers] Add mapAnyOf matcher

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94127

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


[PATCH] D94128: [ASTMatchers] Make cxxOperatorCallExpr matchers API-compatible with n-ary operators

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

LGTM




Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1994
+  return None;
+return FD->getNumParams() > 0 ? UO_PostInc : UO_PreInc;
+  }

steveire wrote:
> aaron.ballman wrote:
> > Not certain how much we want to care about it, but I think we need to check 
> > whether there's exactly one parameter of type `int` to meet the language 
> > rules for these to be replacement APIs: http://eel.is/c++draft/over.inc#1
> > 
> > e.g., the user could do something rather unlikely like: `int 
> > operator++(float);` for their overload and we're report it as being 
> > equivalent when it really isn't.
> It doesn't compile with the big three at least: https://godbolt.org/z/Kns8We
> 
> So, we can't write a test for it.
> 
> So, we shouldn't add a condition for it.
I had a think-o there and realize now that such a declaration is illegal per 
http://eel.is/c++draft/over.oper#over.inc-1

So agreed that we shouldn't handle it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94128

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


[PATCH] D94129: [ASTMatchers] Add binaryOperation matcher

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

LGTM aside from some minor NFC improvements.




Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:957
+
+  void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
+   std::vector &Kinds) const override {





Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:964-968
+for (auto const &F : Funcs) {
+  if (F.isConvertibleTo(Kind, Specificity, LeastDerivedKind))
+return true;
+}
+return false;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94129

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


[PATCH] D93453: [flang][driver] Add support for `-I`

2021-01-15 Thread Faris via Phabricator via cfe-commits
FarisRehman marked 2 inline comments as done.
FarisRehman added inline comments.



Comment at: flang/test/Flang-Driver/include-header.f90:38
+!-
+! EXPECTED OUTPUT FOR /Inputs/ FOLDER SPECIFIED FIRST
+!-

sameeranjoshi wrote:
> Nit - Shouldn't this be `Inputs/` starting with a `/` changes the meaning(at 
> least on Linux systems) ?
I've fixed this, thanks.



Comment at: flang/test/Flang-Driver/include-header.f90:59
+#endif
+end

tskeith wrote:
> `-I` also is supposed to affect INCLUDE lines so it would be good to have a 
> test for that too. They are handled during preprocessing and so can be tested 
> the same way.
> 
> It also affects searching for .mod files but I think to test that requires 
> semantics (i.e. to report an error if the module can't be found). It would be 
> good to test that somewhere too.
Thanks, I've updated the test to check INCLUDE lines and added a new test for 
module files.
I've added some `.mod` files to the Inputs directory, however these files are 
not real module files and are just there for the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93453

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


[PATCH] D93453: [flang][driver] Add support for `-I`

2021-01-15 Thread Faris via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 316908.
FarisRehman marked 2 inline comments as done.
FarisRehman added a comment.

Add include-module test

Update the regression test to check the behaviour of -I with an INCLUDE line in 
the source code.
Also add a regression test to check the behaviour of -I with module files.

Summary of changes:

- Update include-header.f90 to check INCLUDE
- Add include-module.f90 to check the behaviour with module files
- Rename SecondaryInputs directory to header-dir and create a module-dir 
directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93453

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/basic-header-one.h
  flang/test/Flang-Driver/Inputs/basic-header-two.h
  flang/test/Flang-Driver/Inputs/basictestmoduleone.mod
  flang/test/Flang-Driver/Inputs/header-dir/basic-header-one.h
  flang/test/Flang-Driver/Inputs/header-dir/basic-header-two.h
  flang/test/Flang-Driver/Inputs/module-dir/basictestmoduletwo.mod
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-header.f90
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/include-module.f90
@@ -0,0 +1,32 @@
+! Ensure argument -I works as expected with module files.
+! The module files for this test are not real module files.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! 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
+
+!-
+! 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
+
+!-
+! EXPECTED OUTPUT FOR MISSING MODULE FILE
+!-
+! SINGLEINCLUDE:No such file or directory
+! SINGLEINCLUDE-NOT:Error reading module file for module 'basictestmoduletwo'
+
+!---
+! EXPECTED OUTPUT FOR ALL MODULES FOUND
+!---
+! INCLUDED-NOT:No such file or directory
+
+program test_dash_I_with_mod_files
+USE basictestmoduleone
+USE basictestmoduletwo
+end
\ No newline at end of file
Index: flang/test/Flang-Driver/include-header.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/include-header.f90
@@ -0,0 +1,77 @@
+! Ensure argument -I works as expected with an included header.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: %flang-new -E -I %S/Inputs -I %S/Inputs/header-dir %s  2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
+! RUN: %flang-new -E -I %S/Inputs/header-dir -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: not %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=UNINCLUDED
+! RUN: %flang-new -fc1 -E -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: %flang-new -fc1 -E -I %S/Inputs -I %S/Inputs/header-dir %s  2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
+! RUN: %flang-new -fc1 -E -I %S/Inputs/header-dir -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
+
+!
+! EXPECTED OUTPUT FOR MISSING INCLUDED FILE
+!
+! UNINCLUDED:No such file or directory
+! UNINCLUDED-NOT:program b
+! UNINCLUDED-NOT:program c
+
+!-
+! EXPECTED OUTPUT FOR A SINGLE INCLUDED FOLDER
+!
+! SINGLEINCLUDE:program maindirectoryone
+! SINGLEINCLUDE-NOT:program x
+! SINGLEINCLUDE-NOT:program b
+! SINGLEINCLUDE-NEXT:end
+! SINGLEINCLUDE-NEXT:program maindirectorytwo
+! SINGLEINCLUDE-NOT:program y
+! SINGLEINCLUDE-NOT:program c
+
+!---
+! EXPECTED OUTPUT FOR Inputs/ DIR

[PATCH] D94130: [ASTMatchers] Add support for CXXRewrittenBinaryOperator

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

LGTM aside from the `auto` usage.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:5346
+AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,
+CXXRewrittenBinaryOperator)) {
   return Node.isAssignmentOp();

steveire wrote:
> aaron.ballman wrote:
> > This change surprises me -- aren't rewritten binary operators *always* 
> > comparison operations? I don't know of a time when they'd ever be an 
> > assignment operator.
> Yes, which is why the new method in this patch on that class returns `true`.
> 
> This makes it possible to write
> 
> ```
> binaryOperation(isComparisonOperator())
> binaryOperation(isAssignmentOperator())
> ```
> 
> (possibly with `unless`).
Ohhh, I see what the intent is now. Thank you for clarifying!



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:260
+
+auto DCF = Node->getDecomposedForm();
+if (!match(*DCF.LHS) || !match(*DCF.RHS))

steveire wrote:
> aaron.ballman wrote:
> > Please spell out this use of `auto`.
> Please specify what to replace auto with when the replacement is a condition 
> of acceptance.
> 
> Type noise makes code less readable, especially if the type contains `<`, `>` 
> `,`, spaces or `::` or a combination of all of them. There is also ambiguity 
> about what part of the type is a namespace, and what is an enclosing class 
> etc. Very confusing,
> 
> In C++98 typedefs were often used to make that problem less bad. 
> 
> The C++11 solution is `auto`.
> 
> So, you require that an `auto` must be replaced with something less optimal, 
> please be specific about what you require it replaced with. I don't know what 
> you want here, but my guess is it is a long type which makes the code less 
> readable.
> Please specify what to replace auto with when the replacement is a condition 
> of acceptance.

If I knew that information, I would likely have not had to make the suggestion 
in the first place (or I would have suggested it as an edit). FWIW, I think 
it's a bit unreasonable to expect your code reviewers to hunt down the 
information you have at your fingertips as the code author (you presumably know 
what types your code edits are using). 

From 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable:

"Don’t “almost always” use auto, but do use auto with initializers like 
cast(...) or other places where the type is already obvious from the 
context."

There's nothing about this context that makes the type obvious to me. That 
said, I did the work and found the type should be spelled 
`CXXRewriteBinaryOperator::DecomposedForm`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94130

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


[PATCH] D94473: [clangd] Use AST-based signals in CodeCompletion.

2021-01-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/Quality.cpp:349
+  };
+  DeriveASTSignals();
   // Declarations are scoped, others (like macros) are assumed global.

Maybe it's just me, but using a lambda like this seems quite confusing. I don't 
think it improves readability. Maybe just make it a separate method? Or inline 
here, but without lambda?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94473

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


[clang-tools-extra] aeaeb9e - [clangd] Make ExpandAutoType not available on template params.

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

Author: Adam Czachorowski
Date: 2021-01-15T14:19:05+01:00
New Revision: aeaeb9e6bdc90d9c4b839ac0e4edc6255021cced

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

LOG: [clangd] Make ExpandAutoType not available on template params.

We cannot expand auto when used inside a template param (C++17 feature),
so do not offer it there.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
index cb87cc764bc3..3776e1c3505d 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -82,6 +82,15 @@ bool isDeducedAsLambda(const SelectionTree::Node *Node, 
SourceLocation Loc) {
   return false;
 }
 
+// Returns true iff "auto" in Node is really part of the template parameter,
+// which we cannot expand.
+bool isTemplateParam(const SelectionTree::Node *Node) {
+  if (Node->Parent)
+if (Node->Parent->ASTNode.get())
+  return true;
+  return false;
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
@@ -90,7 +99,8 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
 // Code in apply() does handle 'decltype(auto)' yet.
 if (!Result.getTypePtr()->isDecltypeAuto() &&
 !isStructuredBindingType(Node) &&
-!isDeducedAsLambda(Node, Result.getBeginLoc()))
+!isDeducedAsLambda(Node, Result.getBeginLoc()) &&
+!isTemplateParam(Node))
   CachedLocation = Result;
   }
 }

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
index 6c96ecc2332f..5554b68b31c7 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
@@ -80,6 +80,9 @@ TEST_F(ExpandAutoTypeTest, Test) {
   // unknown types in a template should not be replaced
   EXPECT_THAT(apply("template  void x() { ^auto y = T::z(); }"),
   StartsWith("fail: Could not deduce type for 'auto' type"));
+
+  ExtraArgs.push_back("-std=c++17");
+  EXPECT_UNAVAILABLE("template  class Y;");
 }
 
 } // namespace



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


[PATCH] D94719: [clangd] Make ExpandAutoType not available on template params.

2021-01-15 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaeaeb9e6bdc9: [clangd] Make ExpandAutoType not available on 
template params. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94719

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
@@ -80,6 +80,9 @@
   // unknown types in a template should not be replaced
   EXPECT_THAT(apply("template  void x() { ^auto y = T::z(); }"),
   StartsWith("fail: Could not deduce type for 'auto' type"));
+
+  ExtraArgs.push_back("-std=c++17");
+  EXPECT_UNAVAILABLE("template  class Y;");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -82,6 +82,15 @@
   return false;
 }
 
+// Returns true iff "auto" in Node is really part of the template parameter,
+// which we cannot expand.
+bool isTemplateParam(const SelectionTree::Node *Node) {
+  if (Node->Parent)
+if (Node->Parent->ASTNode.get())
+  return true;
+  return false;
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
@@ -90,7 +99,8 @@
 // Code in apply() does handle 'decltype(auto)' yet.
 if (!Result.getTypePtr()->isDecltypeAuto() &&
 !isStructuredBindingType(Node) &&
-!isDeducedAsLambda(Node, Result.getBeginLoc()))
+!isDeducedAsLambda(Node, Result.getBeginLoc()) &&
+!isTemplateParam(Node))
   CachedLocation = Result;
   }
 }


Index: clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
@@ -80,6 +80,9 @@
   // unknown types in a template should not be replaced
   EXPECT_THAT(apply("template  void x() { ^auto y = T::z(); }"),
   StartsWith("fail: Could not deduce type for 'auto' type"));
+
+  ExtraArgs.push_back("-std=c++17");
+  EXPECT_UNAVAILABLE("template  class Y;");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -82,6 +82,15 @@
   return false;
 }
 
+// Returns true iff "auto" in Node is really part of the template parameter,
+// which we cannot expand.
+bool isTemplateParam(const SelectionTree::Node *Node) {
+  if (Node->Parent)
+if (Node->Parent->ASTNode.get())
+  return true;
+  return false;
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
@@ -90,7 +99,8 @@
 // Code in apply() does handle 'decltype(auto)' yet.
 if (!Result.getTypePtr()->isDecltypeAuto() &&
 !isStructuredBindingType(Node) &&
-!isDeducedAsLambda(Node, Result.getBeginLoc()))
+!isDeducedAsLambda(Node, Result.getBeginLoc()) &&
+!isTemplateParam(Node))
   CachedLocation = Result;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Thanks for this, I think it's looking more promising! I'd still like to see 
some test coverage for the changes so long as it doesn't turn into a slog. 
Tests like `clang\test\AST\ast-dump-color.cpp` show roughly how it's done in 
the frontend. If it turns out that the tests are too much of a pain to write 
for clang-query, it won't be a blocker.




Comment at: clang-tools-extra/clang-query/Query.cpp:159
   const ASTContext &Ctx = AST->getASTContext();
-  const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
+  ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);

Semi-idle curiosity, does the source manager have a different diagnostics 
object than the AST? I guess I'm a bit surprised this change is needed (or is 
the change just a minor simplification to the code?).



Comment at: clang-tools-extra/clang-query/tool/ClangQuery.cpp:124-128
+  if (UseColor) {
+AdjustedArgs.push_back("-fdiagnostics-color");
+  } else {
+AdjustedArgs.push_back("-fno-diagnostics-color");
+  }

Our coding style typically has us elide braces around single-line constructs 
like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94624

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


[clang-tools-extra] c77c3d1 - [clangd] Set correct CWD when using compile_flags.txt

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

Author: Adam Czachorowski
Date: 2021-01-15T14:26:24+01:00
New Revision: c77c3d1d18cdd58989f9d35bbf6c31f5fda0a125

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

LOG: [clangd] Set correct CWD when using compile_flags.txt

This fixes a bug where clangd would attempt to set CWD to the
compile_flags.txt file itself.

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d983f76e227f..fde4e56ac72d 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -271,7 +271,8 @@ parseJSON(PathRef Path, llvm::StringRef Data, std::string 
&Error) {
 }
 static std::unique_ptr
 parseFixed(PathRef Path, llvm::StringRef Data, std::string &Error) {
-  return tooling::FixedCompilationDatabase::loadFromBuffer(Path, Data, Error);
+  return tooling::FixedCompilationDatabase::loadFromBuffer(
+  llvm::sys::path::parent_path(Path), Data, Error);
 }
 
 bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(

diff  --git 
a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp 
b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
index 63b1b731656a..fbb85684af5f 100644
--- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -279,6 +279,17 @@ TEST(GlobalCompilationDatabaseTest, BuildDir) {
   << "x/build/compile_flags.json only applicable to x/";
 }
 
+TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
+  MockFS FS;
+  FS.Files[testPath("x/compile_flags.txt")] = "-DFOO";
+  DirectoryBasedGlobalCompilationDatabase CDB(FS);
+  auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
+  ASSERT_TRUE(Commands.hasValue());
+  EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
+  // Make sure we pick the right working directory.
+  EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
+}
+
 TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
   OverlayCDB DB(nullptr);
   std::vector DiscoveredFiles;



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


[PATCH] D94699: [clangd] Set correct CWD when using compile_flags.txt

2021-01-15 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc77c3d1d18cd: [clangd] Set correct CWD when using 
compile_flags.txt (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94699

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp


Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -279,6 +279,17 @@
   << "x/build/compile_flags.json only applicable to x/";
 }
 
+TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
+  MockFS FS;
+  FS.Files[testPath("x/compile_flags.txt")] = "-DFOO";
+  DirectoryBasedGlobalCompilationDatabase CDB(FS);
+  auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
+  ASSERT_TRUE(Commands.hasValue());
+  EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
+  // Make sure we pick the right working directory.
+  EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
+}
+
 TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
   OverlayCDB DB(nullptr);
   std::vector DiscoveredFiles;
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -271,7 +271,8 @@
 }
 static std::unique_ptr
 parseFixed(PathRef Path, llvm::StringRef Data, std::string &Error) {
-  return tooling::FixedCompilationDatabase::loadFromBuffer(Path, Data, Error);
+  return tooling::FixedCompilationDatabase::loadFromBuffer(
+  llvm::sys::path::parent_path(Path), Data, Error);
 }
 
 bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(


Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -279,6 +279,17 @@
   << "x/build/compile_flags.json only applicable to x/";
 }
 
+TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) {
+  MockFS FS;
+  FS.Files[testPath("x/compile_flags.txt")] = "-DFOO";
+  DirectoryBasedGlobalCompilationDatabase CDB(FS);
+  auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
+  ASSERT_TRUE(Commands.hasValue());
+  EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO"));
+  // Make sure we pick the right working directory.
+  EXPECT_EQ(testPath("x"), Commands.getValue().Directory);
+}
+
 TEST(GlobalCompilationDatabaseTest, NonCanonicalFilenames) {
   OverlayCDB DB(nullptr);
   std::vector DiscoveredFiles;
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -271,7 +271,8 @@
 }
 static std::unique_ptr
 parseFixed(PathRef Path, llvm::StringRef Data, std::string &Error) {
-  return tooling::FixedCompilationDatabase::loadFromBuffer(Path, Data, Error);
+  return tooling::FixedCompilationDatabase::loadFromBuffer(
+  llvm::sys::path::parent_path(Path), Data, Error);
 }
 
 bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-01-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests missing


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] D90448: [clang] Add type check for explicit instantiation of static data members

2021-01-15 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous added a comment.

In D90448#2500829 , @lebedev.ri wrote:

> Tests missing

I mistakenly missed that file in the last commit. I'll add it soon.


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] D92277: [OpenCL] Refactor of targets OpenCL option settings

2021-01-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

This patch contains very useful improvements to the design along with the 
behavioral fixes. I see that it opens more opportunities to bring the 
implementation in line with the conventional flow and therefore simplify the 
further development of new functionality. More improvements can be easily built 
on top of this work. I, therefore, suggest we drive towards finalizing this 
patch asap and I have made a couple of small comments that should hopefully be 
quick enough to address.




Comment at: clang/include/clang/Basic/OpenCLExtensions.def:17
 // If the extensions are to be enumerated without the supported OpenCL version,
-// define OPENCLEXT(ext) where ext is the name of the extension.
+// define OPENCLEXTNAME(ext) where ext is the name of the extension.
 //

I guess you mean that this extension is not against a specific version i.e. 
applies to all versions?



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:65
+OPENCL_EXTENSION(cl_khr_int64_extended_atomics, 100)
+OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, 100, OCL_C_20, OCL_C_30)
 

FYI not saying this should be changed now because it is sufficient for the 
current needs but perhaps we could do something like 

OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, 100, {OCL_C_20, OCL_C_31}, 
{OCL_C_30})

if we start having non-continuous set of versions where a feature is optional 
or core.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:79
+OPENCL_EXTENSION(cl_khr_subgroups, 200)
+OPENCL_EXTENSION(cl_khr_subgroup_extended_types, 200)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, 200)

Is this code accidental? The following extensions `cl_khr_subgroup_*` were 
recently removed from this file.

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLExtensions.def



Comment at: clang/include/clang/Basic/OpenCLOptions.h:25
+// optional core feature.
+enum OpenCLVersionID : unsigned int {
+  OCL_C_10 = 0x1,

I suggest putting this in an anonymous namespace along with 
`encodeOpenCLVersion` and `OpenCLVersionIsContainedInMask`, as they are only to 
be used locally.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:55
+// OpenCL C version mask
+static inline bool OpenCLVersionIsContainedInMask(const LangOptions &LO,
+  unsigned Mask) {

A small renaming
`OpenCLVersionIsContainedInMask` -> `isOpenCLVersionContainedInMask`



Comment at: clang/include/clang/Basic/OpenCLOptions.h:62
 
-  /// Check if \c Ext is supported as an (optional) OpenCL core features for
-  /// the given OpenCL version.
-  ///
-  /// \param Ext - Extension to look up.
-  /// \param LO - \c LangOptions specifying the OpenCL version.
-  /// \returns \c true if \c Ext is known and supported, \c false otherwise.
-  bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
-auto E = OptMap.find(Ext);
-if (E == OptMap.end()) {
-  return false;
-}
-// In C++ mode all extensions should work at least as in v2.0.
-auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = E->getValue();
-return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
-  }
+struct OpenCLOptionInfo {
+  // Option starts to be available in this OpenCL version

I think it would be better to keep it in `OpenCLOptions`, as we don't intend 
this to be used stand-alone also considering that it's a `struct`? I understand 
that this is now being used in Targets too but that use should hopefully be 
eliminated in the future.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:106
 
-  void addSupport(const OpenCLOptions &Opts) {
-for (auto &I:Opts.OptMap)
-  if (I.second.Supported)
-OptMap[I.getKey()].Supported = true;
-  }
+  llvm::StringMap OptMap;
 

I think this map deserves type alias since it's used in quite many places.



Comment at: clang/lib/Basic/OpenCLOptions.cpp:96
+void OpenCLOptions::disableAll() {
+  for (llvm::StringMap::iterator I = OptMap.begin(),
+   E = OptMap.end();

Maybe this could also be switched to a range based loop along with the one 
below.



Comment at: clang/lib/Basic/TargetInfo.cpp:360
+// Set core features based on OpenCL version
+for (auto CoreExt : clang::getCoreFeatures(Opts))
+  getTargetOpts().OpenCLFeaturesMap[CoreExt] = true;

I still think the target map should be immutable and especially we should not 
change it silently based on the language compiled even if we have done it 
before but that caused incorrect behavior i.e. successfully compiling for the 
architectures that didn't support the features.

If I look 

[clang] d1862a1 - [OpenCL][Docs] Fixed malformed table in OpenCLSupport

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

Author: Anastasia Stulova
Date: 2021-01-15T14:27:26Z
New Revision: d1862a16310379179a40b309a9721318ae7e3254

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

LOG: [OpenCL][Docs] Fixed malformed table in OpenCLSupport

 Tags: #clang

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 9c17bd8f2692..7e5bb41f7dbc 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -67,40 +67,39 @@ OpenCL 3.0 Implementation Status
 The following table provides an overview of features in OpenCL C 3.0 and their
 implementation status. 
 
-+--+--+--+---
+
-| Category | Feature   
   | Status   | Reviews 
  |
-+==+==+==+===
+
-| Command line interface   | New value for ``-cl-std`` flag
   | :good:`done` | https://reviews.llvm.org/D88300 
  |
-+--+--+--+---
+
-| Predefined macros| New version macro 
   | :good:`done` | https://reviews.llvm.org/D88300 
  |
-+--+--+--+---
+
-| Predefined macros| Feature macros
   | :part:`worked on`| https://reviews.llvm.org/D89869 
  |
-+--+--+--+---
+
-| Feature optionality  | Generic address space 
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | Builtin function overloads with generic 
address space| :part:`worked on`| https://reviews.llvm.o
rg/D92004   |
-
-+--+--+--+---
+
-| Feature optionality  | Program scope variables in global memory  
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | 3D image writes including builtin functions   
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | read_write images including builtin functions 
   | :none:`unclaimed`| 
  |
-+--+--+--+---
+
-| Feature optionality  | C11 atomics memory scopes, ordering and 
builtin function | :part:`worked on`| https://reviews.llvm.o
rg/D92004 (functions only)  |
-+--+---

[clang] 791634b - [clang][cli] Parse & generate options necessary for LangOptions defaults manually

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

Author: Jan Svoboda
Date: 2021-01-15T15:38:43+01:00
New Revision: 791634b999e33e029aeeda91eeb5fae13757dcdc

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

LOG: [clang][cli] Parse & generate options necessary for LangOptions defaults 
manually

It turns out we need to handle `LangOptions` separately from the rest of the 
options. `LangOptions` used to be conditionally parsed only when 
`!(DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == 
Language::LLVM_IR)` and we need to restore this order (for more info, see 
D94682).

D94682 moves the parsing of marshalled `LangOpts` from `parseSimpleArgs` back 
to `ParseLangArgs`.

We need to parse marshalled `LangOpts` **after** `ParseLangArgs` calls 
`setLangDefaults`. This will enable future patches, where values of some 
`LangOpts` depend on the defaults.

However, two language options (`-finclude-default-header` and 
`-fdeclare-opencl-builtins`) need to be parsed **before** `ParseLangArgs` calls 
`setLangDefaults`, because they are necessary for setting up OpenCL defaults 
correctly.
This patch implements this by removing their marshalling info and manually 
parsing (and generating) them exactly where necessary.

Reviewed By: Bigcheese

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2f7bd9e552e1..3722192c7eee 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5207,12 +5207,13 @@ def fdefault_calling_conv_EQ : Joined<["-"], 
"fdefault-calling-conv=">,
   NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", 
"DCC_VectorCall", "DCC_RegCall"]>,
   MarshallingInfoString, "DCC_None">, 
AutoNormalizeEnum;
+
+// These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL">,
-  MarshallingInfoFlag>;
+  HelpText<"Include default header file for OpenCL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
-  HelpText<"Add OpenCL builtin function declarations (experimental)">,
-  MarshallingInfoFlag>;
+  HelpText<"Add OpenCL builtin function declarations (experimental)">;
+
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
   HelpText<"Preserve 3-component vector type">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 37d7f6f3f0fa..c85b0f9d65cf 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -491,6 +491,11 @@ static unsigned getOptimizationLevelSize(ArgList &Args) {
   return 0;
 }
 
+static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
+  static const OptTable &OptTable = getDriverOptTable();
+  return OptTable.getOption(OptSpecifier).getPrefixedName();
+}
+
 static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
   OptSpecifier GroupWithValue,
   std::vector &Diagnostics) {
@@ -2137,6 +2142,15 @@ static const StringRef GetInputKindName(InputKind IK) {
   llvm_unreachable("unknown input language");
 }
 
+static void GenerateLangArgs(const LangOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  if (Opts.IncludeDefaultHeader)
+Args.push_back(SA(GetOptName(OPT_finclude_default_header)));
+  if (Opts.DeclareOpenCLBuiltins)
+Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
+}
+
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const llvm::Triple &T,
   std::vector &Includes,
@@ -2212,6 +2226,10 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
+  // These need to be parsed now. They are used to set OpenCL defaults.
+  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
+  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
+
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
@@ -3163,6 +3181,8 @@ void CompilerInvocation::generateCC1CommandLine(
 #undef DIAG_OPTION_WITH_MARSHALLING
 #undef OPTION_WITH_MARSHALLING
 #undef GENERATE_OPTION_WITH_MARSHALLING
+
+  GenerateLan

[PATCH] D94678: [clang][cli] Parse & generate options necessary for LangOptions defaults manually

2021-01-15 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 rG791634b999e3: [clang][cli] Parse & generate options 
necessary for LangOptions defaults… (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D94678?vs=316628&id=316932#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94678

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
@@ -491,6 +491,11 @@
   return 0;
 }
 
+static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
+  static const OptTable &OptTable = getDriverOptTable();
+  return OptTable.getOption(OptSpecifier).getPrefixedName();
+}
+
 static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
   OptSpecifier GroupWithValue,
   std::vector &Diagnostics) {
@@ -2137,6 +2142,15 @@
   llvm_unreachable("unknown input language");
 }
 
+static void GenerateLangArgs(const LangOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  if (Opts.IncludeDefaultHeader)
+Args.push_back(SA(GetOptName(OPT_finclude_default_header)));
+  if (Opts.DeclareOpenCLBuiltins)
+Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
+}
+
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const llvm::Triple &T,
   std::vector &Includes,
@@ -2212,6 +2226,10 @@
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
 
+  // These need to be parsed now. They are used to set OpenCL defaults.
+  Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
+  Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
+
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
@@ -3163,6 +3181,8 @@
 #undef DIAG_OPTION_WITH_MARSHALLING
 #undef OPTION_WITH_MARSHALLING
 #undef GENERATE_OPTION_WITH_MARSHALLING
+
+  GenerateLangArgs(*LangOpts, Args, SA);
 }
 
 IntrusiveRefCntPtr
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5207,12 +5207,13 @@
   NormalizedValuesScope<"LangOptions">,
   NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", 
"DCC_VectorCall", "DCC_RegCall"]>,
   MarshallingInfoString, "DCC_None">, 
AutoNormalizeEnum;
+
+// These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL">,
-  MarshallingInfoFlag>;
+  HelpText<"Include default header file for OpenCL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
-  HelpText<"Add OpenCL builtin function declarations (experimental)">,
-  MarshallingInfoFlag>;
+  HelpText<"Add OpenCL builtin function declarations (experimental)">;
+
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
   HelpText<"Preserve 3-component vector type">,
   MarshallingInfoFlag>;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -491,6 +491,11 @@
   return 0;
 }
 
+static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
+  static const OptTable &OptTable = getDriverOptTable();
+  return OptTable.getOption(OptSpecifier).getPrefixedName();
+}
+
 static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
   OptSpecifier GroupWithValue,
   std::vector &Diagnostics) {
@@ -2137,6 +2142,15 @@
   llvm_unreachable("unknown input language");
 }
 
+static void GenerateLangArgs(const LangOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  if (Opts.IncludeDefaultHeader)
+Args.push_back(SA(GetOptName(OPT_finclude_default_header)));
+  if (Opts.DeclareOpenCLBuiltins)
+Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
+}
+
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const llvm::Triple &T,
   std::vector &Includes,
@@ -2212,6 +2226,10 @@
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsyc

[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-15 Thread Malhar via Phabricator via cfe-commits
malharJ created this revision.
Herald added a subscriber: rogfer01.
malharJ requested review of this revision.
Herald added subscribers: cfe-commits, vkmr.
Herald added a project: clang.

This ensures that the Clang loop pragma vectorize_predicate([enable|disable]) 
is ignored
when vectorize_width(1) is also used, since that effectively disables 
vectorization.
For all other non-zero vectorization widths, the pragma is not ignored unless 
vectorization
is explicitly disabled using vectorize(disable)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94779

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp


Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp
===
--- clang/test/CodeGenCXX/pragma-loop-predicate.cpp
+++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp
@@ -58,6 +58,28 @@
 List[i] = i * 2;
 }
 
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test6(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test6{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test7(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test7{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
 // CHECK:  ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], 
[[GEN3:![0-9]+]]}
 // CHECK:  [[MP]] = !{!"llvm.loop.mustprogress"}
 // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true}
@@ -74,3 +96,8 @@
 // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1}
 
 // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], 
[[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}
Index: clang/lib/CodeGen/CGLoopInfo.cpp
===
--- clang/lib/CodeGen/CGLoopInfo.cpp
+++ clang/lib/CodeGen/CGLoopInfo.cpp
@@ -249,11 +249,12 @@
   Args.push_back(nullptr);
   Args.append(LoopProperties.begin(), LoopProperties.end());
 
-  // Setting vectorize.predicate
+  // Setting vectorize.predicate when it has been specified and vectorization
+  // has not been disabled.
   bool IsVectorPredicateEnabled = false;
   if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
   Attrs.VectorizeEnable != LoopAttributes::Disable &&
-  Attrs.VectorizeWidth < 1) {
+  Attrs.VectorizeWidth != 1) {
 
 IsVectorPredicateEnabled =
 (Attrs.VectorizePredicateEnable == LoopAttributes::Enable);


Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp
===
--- clang/test/CodeGenCXX/pragma-loop-predicate.cpp
+++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp
@@ -58,6 +58,28 @@
 List[i] = i * 2;
 }
 
+// Check that vectorize_predicate is ignored when vectorization width is 1
+void test6(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test6{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(1)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
+// Check that vectorize_width(!=1) does not affect vectorize_predicate.
+void test7(int *List, int Length) {
+// CHECK-LABEL: @{{.*}}test7{{.*}}(
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]]
+
+#pragma clang loop vectorize_predicate(disable) vectorize_width(4)
+  for (int i = 0; i < Length; i++)
+List[i] = i * 2;
+}
+
+
 // CHECK:  ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], [[GEN3:![0-9]+]]}
 // CHECK:  [[MP]] = !{!"llvm.loop.mustprogress"}
 // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true}
@@ -74,3 +96,8 @@
 // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1}
 
 // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN10]]}
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}
Index: clang/lib/CodeGen/CGLoopInfo.cpp
===
--- clang/lib/CodeGen/CGLoopInfo.cpp
+++ clang/lib/CodeGen/CGLoopInfo.cpp
@@ -249,11 +249,12 @@
   Args.push_back(nullptr);
   Args.append(LoopProperties.begin(), LoopProperties.end());
 
-  // Setting vectorize.predicate
+  // Setting vectorize.predicate when it has been specified and vectorization
+  // has not been d

[PATCH] D84846: [MC] Add support for generating missing GNU build notes

2021-01-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 316944.
Herald added a subscriber: martong.

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

https://reviews.llvm.org/D84846

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -331,7 +331,6 @@
   case Stmt::SourceLocExprClass:
   case Stmt::ConvertVectorExprClass:
   case Stmt::VAArgExprClass:
-  case Stmt::VAArgPackExprClass:
   case Stmt::ObjCArrayLiteralClass:
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1382,7 +1382,6 @@
 case Stmt::ShuffleVectorExprClass:
 case Stmt::ConvertVectorExprClass:
 case Stmt::VAArgExprClass:
-case Stmt::VAArgPackExprClass:
 case Stmt::CUDAKernelCallExprClass:
 case Stmt::OpaqueValueExprClass:
 case Stmt::AsTypeExprClass:
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1144,13 +1144,6 @@
   Code = serialization::EXPR_VA_ARG;
 }
 
-void ASTStmtWriter::VisitVAArgPackExpr(VAArgPackExpr *E) {
-  VisitExpr(E);
-  Record.AddSourceLocation(E->getBuiltinLoc());
-  Record.AddSourceLocation(E->getRParenLoc());
-  Code = serialization::EXPR_VA_ARG_PACK;
-}
-
 void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr *E) {
   VisitExpr(E);
   Record.AddDeclRef(cast_or_null(E->getParentContext()));
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1284,12 +1284,6 @@
   E->setIsMicrosoftABI(Record.readInt());
 }
 
-void ASTStmtReader::VisitVAArgPackExpr(VAArgPackExpr *E) {
-  VisitExpr(E);
-  E->setBuiltinLoc(readSourceLocation());
-  E->setRParenLoc(readSourceLocation());
-}
-
 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
   VisitExpr(E);
   E->ParentContext = readDeclAs();
@@ -2960,10 +2954,6 @@
   S = new (Context) VAArgExpr(Empty);
   break;
 
-case EXPR_VA_ARG_PACK:
-  S = new (Context) VAArgPackExpr(Empty);
-  break;
-
 case EXPR_SOURCE_LOC:
   S = new (Context) SourceLocExpr(Empty);
   break;
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3248,11 +3248,6 @@
 return getSema().BuildSourceLocExpr(Kind, BuiltinLoc, RPLoc, ParentContext);
   }
 
-  ExprResult RebuildVAArgPackExpr(SourceLocation BuiltinLoc,
-  SourceLocation RPLoc) {
-return getSema().BuildVAArgPackExpr (BuiltinLoc, RPLoc);
-  }
-
   /// Build a new Objective-C boxed expression.
   ///
   /// By default, performs semantic analysis to build the new expression.
@@ -11184,14 +11179,6 @@
getSema().CurContext);
 }
 
-template 
-ExprResult TreeTransform::TransformVAArgPackExpr(VAArgPackExpr *E) {
-  if (!getDerived().AlwaysRebuild())
-return E;
-
-  return getDerived().RebuildVAArgPackExpr(E->getBeginLoc(), E->getEndLoc());
-}
-
 template
 ExprResult
 TreeTransform::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15621,17 +15621,6 @@
   return new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
 }
 
-ExprResult Sema::ActOnVAArgPack(SourceLocation BuiltinLoc, SourceLocation RPLoc) {
-  return BuildVAArgPackExpr(BuiltinLoc, RPLoc);
-}
-
-ExprResult Sema::BuildVAArgPackExpr(SourceLocation BuiltinLoc, SourceLocation RPLoc) {
-  QualType VaListType = Context.get

[PATCH] D84846: [MC] Add support for generating missing GNU build notes

2021-01-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 316945.
tbaeder added a comment.

Sorry about the last change, that was the wrong patch.


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

https://reviews.llvm.org/D84846

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Misc/generate-missing-build-notes.c
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCTargetOptions.cpp
  llvm/test/MC/ELF/build-notes.s
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -176,6 +176,9 @@
 static cl::opt NoExecStack("no-exec-stack",
  cl::desc("File doesn't need an exec stack"));
 
+static cl::opt GenerateMissingBuildNotes("generate-missing-build-notes",
+   cl::desc("FOo"));
+
 enum ActionType {
   AC_AsLex,
   AC_Assemble,
@@ -383,6 +386,9 @@
   if (SaveTempLabels)
 Ctx.setAllowTemporaryLabels(false);
 
+  if (GenerateMissingBuildNotes)
+Ctx.setGenerateMissingBuildNotes(true);
+
   Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
   // Default to 4 for dwarf version.
   unsigned DwarfVersion = MCOptions.DwarfVersion ? MCOptions.DwarfVersion : 4;
Index: llvm/test/MC/ELF/build-notes.s
===
--- /dev/null
+++ llvm/test/MC/ELF/build-notes.s
@@ -0,0 +1,55 @@
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple i386-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s --check-prefix=i386
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple armeb-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s --check-prefix=armbe32
+
+.text
+.dc.l 1
+
+.section .text.unused,"ax"
+.space 1025
+
+.section .data,"0x3"
+.dc.l 3
+
+// CHECK:  Relocations [
+// CHECK-NEXT:   Section {{.*}} .rela.gnu.build.attributes {
+// CHECK-NEXT: 0x14 R_X86_64_64 .text 0x0
+// CHECK-NEXT: 0x1C R_X86_64_64 .text 0x4
+// CHECK-NEXT: 0x38 R_X86_64_64 .text.unused 0x0
+// CHECK-NEXT: 0x40 R_X86_64_64 .text.unused 0x401
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+// CHECK: Hex dump of section '.gnu.build.attributes':
+// CHECK-NEXT: 0x 0800 1000 0001 47412401 GA$.
+// CHECK-NEXT: 0x0010 33613200    3a2.
+// CHECK-NEXT: 0x0020  0800 1000 0001 
+// CHECK-NEXT: 0x0030 47412401 33613200   GA$.3a2.
+// CHECK-NEXT: 0x0040     
+
+// i386:  Relocations [
+// i386-NEXT:   Section {{.*}} .rel.gnu.build.attributes {
+// i386-NEXT: 0x14 R_386_32 .text
+// i386-NEXT: 0x18 R_386_32 .text
+// i386-NEXT: 0x30 R_386_32 .text.unused
+// i386-NEXT: 0x34 R_386_32 .text.unused
+// i386-NEXT:   }
+// i386-NEXT: ]
+// i386: Hex dump of section '.gnu.build.attributes':
+// i386-NEXT: 0x 0800 0800 0001 47412401 GA$.
+// i386-NEXT: 0x0010 33613200  0400 0800 3a2.
+// i386-NEXT: 0x0020 0800 0001 47412401 33613200 GA$.3a2.
+// i386-NEXT: 0x0030  0104   
+
+// armbe32:  Relocations [
+// armbe32-NEXT:   Section {{.*}} .rel.gnu.build.attributes {
+// armbe32-NEXT: 0x14 R_ARM_ABS32 .text
+// armbe32-NEXT: 0x18 R_ARM_ABS32 .text
+// armbe32-NEXT: 0x30 R_ARM_ABS32 .text.unused
+// armbe32-NEXT: 0x34 R_ARM_ABS32 .text.unused
+// armbe32-NEXT:   }
+// armbe32-NEXT: ]
+// armbe32: Hex dump of section '.gnu.build.attributes':
+// armbe32-NEXT: 0x 0008 0008 0100 47412401 GA$.
+// armbe32-NEXT: 0x0010 33613200  0004 0008 3a2.
+// armbe32-NEXT: 0x0020 0008 0100 47412401 33613200 GA$.3a2.
+// armbe32-NEXT: 0x0030  0401   
Index: llvm/lib/MC/MCTargetOptions.cpp
===
--- llvm/lib/MC/MCTargetOptions.cpp
+++ llvm/lib/MC/MCTargetOptions.cpp
@@ -15,8 +15,9 @@
 : MCRelaxAll(false), MCNoExecStack(false), MCFatalWarnings(false),
   MCNoWarn(false), MCNoDeprecatedWarn(f

[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/CodeGenCXX/pragma-loop-predicate.cpp:102
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], 
[[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}

Do we also expect:

   !{!"llvm.loop.vectorize.predicate.enable", i1 false}

here since the test sets:

  vectorize_predicate(disable) vectorize_width(4)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D94779: [Clang] Ensure vector predication pragma is ignored only when vectorization width is 1.

2021-01-15 Thread Malhar via Phabricator via cfe-commits
malharJ added inline comments.



Comment at: clang/test/CodeGenCXX/pragma-loop-predicate.cpp:102
+
+// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], 
[[GEN11:![0-9]+]], [[GEN3]]}
+// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4}

SjoerdMeijer wrote:
> Do we also expect:
> 
>!{!"llvm.loop.vectorize.predicate.enable", i1 false}
> 
> here since the test sets:
> 
>   vectorize_predicate(disable) vectorize_width(4)
GEN8 covers checking for that ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[clang] 3832629 - [clang][cli] NFC: Add PIE parsing for precompiled input and IR

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

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: 383262933045e1c138362105be4ee4d1b62ab4cc

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

LOG: [clang][cli] NFC: Add PIE parsing for precompiled input and IR

This patch effectively reverts a small part of D83979.

When we stop parsing `LangOpts` unconditionally in `parseSimpleArgs` (above the 
diff) and move them back to `ParseLangArgs` (called in `else` branch) in 
D94682, `LangOpts.PIE` would never get parsed in this `if` branch. This patch 
ensures this doesn't happen.

Right now, this causes `LangOpts.PIE` to be parsed twice, but that will be 
immediately corrected in D94682.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c85b0f9d65cf..d261eb7f45cd 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2970,6 +2970,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 // PIClevel and PIELevel are needed during code generation and this should 
be
 // set regardless of the input type.
 LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
   } else {



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


[clang] a7dcd3a - [clang][cli] NFC: Parse some LangOpts after the defaults are set

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

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa

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

LOG: [clang][cli] NFC: Parse some LangOpts after the defaults are set

This patch ensures we only parse the necessary options before calling 
`setLangDefaults` (explained in D94678).

Because neither `LangOpts.CFProtectionBranch` nor `LangOpts.SYCLIsDevice` are 
used in `setLangDefaults`, this is a NFC.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d261eb7f45cd..c672834a7970 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2196,12 +2196,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 }
   }
 
-  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
-StringRef Name = A->getValue();
-if (Name == "full" || Name == "branch") {
-  Opts.CFProtectionBranch = 1;
-}
-  }
   // -cl-std only applies for OpenCL language standards.
   // Override the -std option in this case.
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
@@ -2224,14 +2218,21 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
   // These need to be parsed now. They are used to set OpenCL defaults.
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
+  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
+StringRef Name = A->getValue();
+if (Name == "full" || Name == "branch") {
+  Opts.CFProtectionBranch = 1;
+}
+  }
+
+  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.



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


[clang] 1744f4c - [clang][cli] NFC: Promote ParseLangArgs and ParseCodeGenArgs to members

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

Author: Jan Svoboda
Date: 2021-01-15T16:41:34+01:00
New Revision: 1744f4c676411ebd2e38afd5a6b56e5dd533c6ac

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

LOG: [clang][cli] NFC: Promote ParseLangArgs and ParseCodeGenArgs to members

This patch promotes `ParseLangArgs` and `ParseCodeGenArgs` to members of 
`CompilerInvocation`. That will be useful in the following patch D94682, where 
we need to access protected members of `LangOptions` and `CodeGenOptions`. Both 
of those classes already have `friend CompilerInvocation`.

This is cleaner than keeping those functions freestanding and having to specify 
the exact signature of both in extra `friend` declarations.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 9f16c5077154..b65b087510ce 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -247,6 +247,18 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// \returns - True if parsing was successful, false otherwise
   bool parseSimpleArgs(const llvm::opt::ArgList &Args,
DiagnosticsEngine &Diags);
+
+  /// Parse command line options that map to LangOptions.
+  static void ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
+InputKind IK, const llvm::Triple &T,
+std::vector &Includes,
+DiagnosticsEngine &Diags);
+
+  /// Parse command line options that map to CodeGenOptions.
+  static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
+   InputKind IK, DiagnosticsEngine &Diags,
+   const llvm::Triple &T,
+   const std::string &OutputFile);
 };
 
 IntrusiveRefCntPtr

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c672834a7970..25b3610e50db 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -907,9 +907,11 @@ static void setPGOUseInstrumentor(CodeGenOptions &Opts,
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 }
 
-static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags, const llvm::Triple &T,
- const std::string &OutputFile) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
+  InputKind IK,
+  DiagnosticsEngine &Diags,
+  const llvm::Triple &T,
+  const std::string &OutputFile) {
   bool Success = true;
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
@@ -2151,10 +2153,10 @@ static void GenerateLangArgs(const LangOptions &Opts,
 Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
 }
 
-static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
-  const llvm::Triple &T,
-  std::vector &Includes,
-  DiagnosticsEngine &Diags) {
+void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
+   InputKind IK, const llvm::Triple &T,
+   std::vector &Includes,
+   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
   if (const Arg *A = Args.getLastArg(OPT_std_EQ)) {



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


[PATCH] D94679: [clang][cli] NFC: Add PIE parsing for precompiled input and IR

2021-01-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG383262933045: [clang][cli] NFC: Add PIE parsing for 
precompiled input and IR (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94679

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2970,6 +2970,7 @@
 // PIClevel and PIELevel are needed during code generation and this should 
be
 // set regardless of the input type.
 LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
   } else {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2970,6 +2970,7 @@
 // PIClevel and PIELevel are needed during code generation and this should be
 // set regardless of the input type.
 LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94680: [clang][cli] NFC: Parse some LangOpts after the defaults are set

2021-01-15 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 rGa7dcd3aeb0fb: [clang][cli] NFC: Parse some LangOpts after 
the defaults are set (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94680

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2196,12 +2196,6 @@
 }
   }
 
-  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
-StringRef Name = A->getValue();
-if (Name == "full" || Name == "branch") {
-  Opts.CFProtectionBranch = 1;
-}
-  }
   // -cl-std only applies for OpenCL language standards.
   // Override the -std option in this case.
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
@@ -2224,14 +2218,21 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
   // These need to be parsed now. They are used to set OpenCL defaults.
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
+  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
+StringRef Name = A->getValue();
+if (Name == "full" || Name == "branch") {
+  Opts.CFProtectionBranch = 1;
+}
+  }
+
+  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.


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2196,12 +2196,6 @@
 }
   }
 
-  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
-StringRef Name = A->getValue();
-if (Name == "full" || Name == "branch") {
-  Opts.CFProtectionBranch = 1;
-}
-  }
   // -cl-std only applies for OpenCL language standards.
   // Override the -std option in this case.
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
@@ -2224,14 +2218,21 @@
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-
   // These need to be parsed now. They are used to set OpenCL defaults.
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
   CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
 
+  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
+StringRef Name = A->getValue();
+if (Name == "full" || Name == "branch") {
+  Opts.CFProtectionBranch = 1;
+}
+  }
+
+  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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94681: [clang][cli] NFC: Promote ParseLangArgs and ParseCodeGenArgs to members

2021-01-15 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 rG1744f4c67641: [clang][cli] NFC: Promote ParseLangArgs and 
ParseCodeGenArgs to members (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94681

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -907,9 +907,11 @@
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 }
 
-static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags, const llvm::Triple &T,
- const std::string &OutputFile) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
+  InputKind IK,
+  DiagnosticsEngine &Diags,
+  const llvm::Triple &T,
+  const std::string &OutputFile) {
   bool Success = true;
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
@@ -2151,10 +2153,10 @@
 Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
 }
 
-static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
-  const llvm::Triple &T,
-  std::vector &Includes,
-  DiagnosticsEngine &Diags) {
+void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
+   InputKind IK, const llvm::Triple &T,
+   std::vector &Includes,
+   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
   if (const Arg *A = Args.getLastArg(OPT_std_EQ)) {
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -247,6 +247,18 @@
   /// \returns - True if parsing was successful, false otherwise
   bool parseSimpleArgs(const llvm::opt::ArgList &Args,
DiagnosticsEngine &Diags);
+
+  /// Parse command line options that map to LangOptions.
+  static void ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
+InputKind IK, const llvm::Triple &T,
+std::vector &Includes,
+DiagnosticsEngine &Diags);
+
+  /// Parse command line options that map to CodeGenOptions.
+  static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
+   InputKind IK, DiagnosticsEngine &Diags,
+   const llvm::Triple &T,
+   const std::string &OutputFile);
 };
 
 IntrusiveRefCntPtr


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -907,9 +907,11 @@
 Opts.setProfileUse(CodeGenOptions::ProfileClangInstr);
 }
 
-static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
- DiagnosticsEngine &Diags, const llvm::Triple &T,
- const std::string &OutputFile) {
+bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
+  InputKind IK,
+  DiagnosticsEngine &Diags,
+  const llvm::Triple &T,
+  const std::string &OutputFile) {
   bool Success = true;
 
   unsigned OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
@@ -2151,10 +2153,10 @@
 Args.push_back(SA(GetOptName(OPT_fdeclare_opencl_builtins)));
 }
 
-static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
-  const llvm::Triple &T,
-  std::vector &Includes,
-  DiagnosticsEngine &Diags) {
+void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
+   InputKind IK, const llvm::Triple &T,
+   std::vector &Includes,
+   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::l

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

2021-01-15 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

> This doesn't add metadata to llvm intrinsics that are not constrained.

Oh, right. I misunderstood what's doing in these patches and thought we can add 
metadata to any intrinsics by CGFPOptionsRAII now. :-)

> If a relevant #pragma is used then without this change the metadata ...

Yeah, I understand it now. Thank you! But why we still have the wrong `maytrap` 
with this patch?

> It's true that the middle-end optimizers know nothing about the constrained 
> intrinsics. Today. I plan on changing that in the near future.

Brilliant!

> If use of the constrained intrinsics will cause breakage of the 
> target-specific clang builtins then that's important to know and to fix.

I had a look at these changes and didn't find anything will cause breakage for 
now. I'm still not sure if we need to teach target-specific clang builtins to 
respect strict FP or not. But it has nothing to do with this patch.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:12268
+  case X86::BI__builtin_ia32_cvtqq2pd512_mask: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 return EmitX86ConvertIntToFp(*this, Ops, /*IsSigned*/true);

Maybe better to move it into these Emit* functions?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14093
   // exception behavior under strict FP.
+  // NOTE: If strict FP does ever go through here a CGFPOptionsRAII
+  // object will be required.

It can't go here because of line 14037. But the comment seems good here.


Repository:
  rG LLVM Github Monorepo

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] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: kadircet, arphaman.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Previously we did not record local class declarations. Now with features like
findImplementation and typeHierarchy, we have a need to index such local
classes to accurately report subclasses and implementations of methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.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
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto &Point : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -138,6 +138,13 @@
 namespace nx {
 class X{};
 auto f() { int Local; } // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
 struct { int x; } var;
 }
   )",
@@ -154,6 +161,11 @@
   EXPECT_TRUE(shouldCollect("InAnonymous", /*Qualified=*/false));
   EXPECT_TRUE(shouldCollect("g"));
 
+  // Locals.
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -72,7 +72,7 @@
 struct LocalClass {};
 int local_var;
   })cpp";
-  EXPECT_THAT(getSymbols(TU, "l"), IsEmpty());
+  EXPECT_THAT(getSymbols(TU, "l"), ElementsAre(QName("LocalClass")));
   EXPECT_THAT(getSymbols(TU, "p"), IsEmpty());
 }
 
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -223,6 +223,13 @@
   if (!IsMainFileOnly && ND.isInAnonymousNamespace())
 return false;
 
+  // Index all virtual and overridding methods.
+  if (const auto *CXXMD = llvm::dyn_cast(&ND))
+if (CXXMD->isVirtual() || !CXXMD->overridden_methods().empty())
+  return true;
+  // For function local symbols, index only classes.
+  if (ND.getParentFunctionOrMethod())
+return isa(ND);
   // We want most things but not "local" symbols such as symbols inside
   // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
   // FIXME: Need a matcher for ExportDecl in order to include symbols declared
Index: clang-tools-extra/clangd/index/IndexAction.cpp
===
--- clang-tools-extra/clangd/index/IndexAction.cpp
+++ clang-tools-extra/clangd/index/IndexAction.cpp
@@ -212,6 +212,7 @@
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::All;
+  IndexOpts.IndexFunctionLocals = true;
   Opts.CollectIncludePath = tru

[PATCH] D94697: [clangd] Update CC Ranking model with better sampling.

2021-01-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 316969.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94697

Files:
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json

Index: clang-tools-extra/clangd/quality/model/features.json
===
--- clang-tools-extra/clangd/quality/model/features.json
+++ clang-tools-extra/clangd/quality/model/features.json
@@ -1,8 +1,4 @@
 [
-{
-"name": "FilterLength",
-"kind": "NUMBER"
-},
 {
 "name": "IsDeprecated",
 "kind": "NUMBER"
@@ -20,11 +16,15 @@
 "kind": "NUMBER"
 },
 {
-"name": "IsNameInContext",
+"name": "NumNameInContext",
 "kind": "NUMBER"
 },
 {
-"name": "IsForbidden",
+"name": "FractionNameInContext",
+"kind": "NUMBER"
+},
+{
+"name": "IsNameInContext",
 "kind": "NUMBER"
 },
 {
@@ -32,7 +32,7 @@
 "kind": "NUMBER"
 },
 {
-"name": "FileProximityDistance",
+"name": "FileProximityDistanceCost",
 "kind": "NUMBER"
 },
 {
@@ -40,7 +40,7 @@
 "kind": "NUMBER"
 },
 {
-"name": "SymbolScopeDistance",
+"name": "SymbolScopeDistanceCost",
 "kind": "NUMBER"
 },
 {
@@ -81,4 +81,4 @@
 "type": "clang::clangd::SymbolRelevanceSignals::AccessibleScope",
 "header": "Quality.h"
 }
-]
\ No newline at end of file
+]
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -501,12 +501,24 @@
 
   SymbolRelevanceSignals::DerivedSignals Derived =
   Relevance.calculateDerivedSignals();
-  E.setIsNameInContext(Derived.NameMatchesContext);
-  E.setIsForbidden(Relevance.Forbidden);
+  int NumMatch = 0;
+  if (Relevance.ContextWords) {
+for (const auto &Word : Relevance.ContextWords->keys()) {
+  if (Relevance.Name.contains_lower(Word)) {
+++NumMatch;
+  }
+}
+  }
+  E.setIsNameInContext(NumMatch > 0);
+  E.setNumNameInContext(NumMatch);
+  E.setFractionNameInContext(
+  Relevance.ContextWords && Relevance.ContextWords->size() > 0
+  ? NumMatch * 1.0 / Relevance.ContextWords->size()
+  : 0);
   E.setIsInBaseClass(Relevance.InBaseClass);
-  E.setFileProximityDistance(Derived.FileProximityDistance);
+  E.setFileProximityDistanceCost(Derived.FileProximityDistance);
   E.setSemaFileProximityScore(Relevance.SemaFileProximityScore);
-  E.setSymbolScopeDistance(Derived.ScopeProximityDistance);
+  E.setSymbolScopeDistanceCost(Derived.ScopeProximityDistance);
   E.setSemaSaysInScope(Relevance.SemaSaysInScope);
   E.setScope(Relevance.Scope);
   E.setContextKind(Relevance.Context);
@@ -514,7 +526,6 @@
   E.setHadContextType(Relevance.HadContextType);
   E.setHadSymbolType(Relevance.HadSymbolType);
   E.setTypeMatchesPreferred(Relevance.TypeMatchesPreferred);
-  E.setFilterLength(Relevance.FilterLength);
 
   DecisionForestScores Scores;
   // Exponentiating DecisionForest prediction makes the score of each tree a
@@ -525,6 +536,9 @@
   // data that needs fixits is not-feasible.
   if (Relevance.NeedsFixIts)
 Scores.ExcludingName *= 0.5;
+  if (Relevance.Forbidden)
+Scores.ExcludingName *= 0;
+
   // NameMatch should be a multiplier on total score to support rescoring.
   Scores.Total = Relevance.NameMatch * Scores.ExcludingName;
   return Scores;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94786: [clang][ASTImporter] Add support for importing CXXFoldExpr.

2021-01-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: martong, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94786

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -639,6 +639,22 @@
   hasUnqualifiedDesugaredType(constantArrayType(hasSize(7));
 }
 
+const internal::VariadicDynCastAllOfMatcher cxxFoldExpr;
+
+TEST_P(ImportExpr, ImportCXXFoldExpr) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "void declToImport(Ts... args) {"
+ "  const int i1 = (... + args);"
+ "  const int i2 = (1 + ... + args);"
+ "  const int i3 = (args + ...);"
+ "  const int i4 = (args + ... + 1);"
+ "};"
+ "void g() { declToImport(1, 2, 3, 4, 5); }",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ functionTemplateDecl(hasDescendant(cxxFoldExpr(;
+}
+
 /// \brief Matches __builtin_types_compatible_p:
 /// GNU extension to check equivalent types
 /// Given
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -644,6 +644,7 @@
 ExpectedStmt 
VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E);
 ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E);
 ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E);
+ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E);
 
 template
 Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) {
@@ -8011,6 +8012,25 @@
   *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
 }
 
+ExpectedStmt ASTNodeImporter::VisitCXXFoldExpr(CXXFoldExpr *E) {
+  Error Err = Error::success();
+
+  auto ToType = importChecked(Err, E->getType());
+  auto ToCallee = importChecked(Err, E->getCallee());
+  auto ToLParenLoc = importChecked(Err, E->getLParenLoc());
+  auto ToLHS = importChecked(Err, E->getLHS());
+  auto ToEllipsisLoc = importChecked(Err, E->getEllipsisLoc());
+  auto ToRHS = importChecked(Err, E->getRHS());
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+
+  if (Err)
+return std::move(Err);
+
+  return new (Importer.getToContext())
+  CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS, E->getOperator(),
+  ToEllipsisLoc, ToRHS, ToRParenLoc, E->getNumExpansions());
+}
+
 Error ASTNodeImporter::ImportOverriddenMethods(CXXMethodDecl *ToMethod,
CXXMethodDecl *FromMethod) {
   Error ImportErrors = Error::success();


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -639,6 +639,22 @@
   hasUnqualifiedDesugaredType(constantArrayType(hasSize(7));
 }
 
+const internal::VariadicDynCastAllOfMatcher cxxFoldExpr;
+
+TEST_P(ImportExpr, ImportCXXFoldExpr) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "void declToImport(Ts... args) {"
+ "  const int i1 = (... + args);"
+ "  const int i2 = (1 + ... + args);"
+ "  const int i3 = (args + ...);"
+ "  const int i4 = (args + ... + 1);"
+ "};"
+ "void g() { declToImport(1, 2, 3, 4, 5); }",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ functionTemplateDecl(hasDescendant(cxxFoldExpr(;
+}
+
 /// \brief Matches __builtin_types_compatible_p:
 /// GNU extension to check equivalent types
 /// Given
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -644,6 +644,7 @@
 ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E);
 ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E);
 ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E);
+ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E);
 
 template
 Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) {
@@ -8011,6 +8012,25 @@
   *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
 }
 
+ExpectedStmt ASTNodeImporter::VisitCXXFoldExpr(CXXFoldExpr *E) {
+  Error Err = Error::success();
+
+  auto ToType = importChecked(Err, E->getType());
+  auto ToCallee = importChecked(Err, E->getCallee());
+  auto ToLParenLoc = importChecked(Err, E->getLParenLoc());
+  auto ToLHS = importChecked(Err, E->getLHS());
+  auto ToEllipsisLoc = importChe

[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

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

Thank you for taking the time to fix this and the performance measurements to 
boot.
My only question is does this try and index lambdas, under the hood they are 
declared as a CXXRecordDecl, defined in function scope?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

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


[PATCH] D94787: [clang][AST] Add get functions for CXXFoldExpr paren locations.

2021-01-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94787

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


Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -4614,6 +4614,8 @@
   /// Get the operand that doesn't contain a pack, for a binary fold.
   Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
 
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+  SourceLocation getRParenLoc() const { return RParenLoc; }
   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
   BinaryOperatorKind getOperator() const { return Opcode; }
 


Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -4614,6 +4614,8 @@
   /// Get the operand that doesn't contain a pack, for a binary fold.
   Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
 
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+  SourceLocation getRParenLoc() const { return RParenLoc; }
   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
   BinaryOperatorKind getOperator() const { return Opcode; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94786: [clang][ASTImporter] Add support for importing CXXFoldExpr.

2021-01-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a reviewer: martong.
balazske added a comment.
Herald added a subscriber: rnkovacs.

There is a related bug report:
https://bugs.llvm.org/show_bug.cgi?id=48004


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94786

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


[clang-tools-extra] d5047d7 - [clangd] Update CC Ranking model with better sampling.

2021-01-15 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2021-01-15T18:13:24+01:00
New Revision: d5047d762f391c94939d67fc84cae25b24125694

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

LOG: [clangd] Update CC Ranking model with better sampling.

A better sampling strategy was used to generate the dataset for this
model.
New signals introduced in this model:
- NumNameInContext: Number of words in the context that matches the name
of the candidate.
- FractionNameInContext: Fraction of the words in context matching the
name of the candidate.

We remove the signal `IsForbidden` from the model and down rank
forbidden signals aggresively.

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

Added: 


Modified: 
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/quality/model/features.json
clang-tools-extra/clangd/quality/model/forest.json

Removed: 



error:
 too big or took too long to generate


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


[PATCH] D94697: [clangd] Update CC Ranking model with better sampling.

2021-01-15 Thread Utkarsh Saxena 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 rGd5047d762f39: [clangd] Update CC Ranking model with better 
sampling. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94697

Files:
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json

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


[clang] bc84f89 - [OpenCL][Docs] Fixed cross-section reference in OpenCLSupport

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

Author: Anastasia Stulova
Date: 2021-01-15T17:20:13Z
New Revision: bc84f89c71ab62d510973f64f022bee31e53af96

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

LOG: [OpenCL][Docs] Fixed cross-section reference in OpenCLSupport

Tags: #clang

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 7e5bb41f7dbc..5be7e91adcaf 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -37,7 +37,7 @@ Clang implements language version 1.0 published in `the 
official
 release of C++ for OpenCL Documentation
 
`_.
 
-Limited support of experimental C++ libraries is described in the 
`experimental features `.
+Limited support of experimental C++ libraries is described in the 
:ref:`experimental features `.
 
 Bugzilla bugs for this functionality are typically prefixed
 with '[C++4OpenCL]' - click `here



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


[PATCH] D94802: [clang][cli] Parse HeaderSearch options separately

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94802

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
@@ -1796,7 +1796,23 @@
 }
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags,
   const std::string &WorkingDir) {
+  HeaderSearchOptions *HeaderSearchOpts = &Opts;
+  bool Success = true;
+
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING( 
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,
\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
+MERGER, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
+
   if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
 Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
 
@@ -2993,7 +3009,7 @@
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
   llvm::Triple T(Res.getTargetOpts().Triple);
-  ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
+  ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
 Res.getFileSystemOpts().WorkingDir);
   if (DashX.getFormat() == InputKind::Precompiled ||
   DashX.getLanguage() == Language::LLVM_IR) {
@@ -3214,6 +3230,7 @@
EXTRACTOR, TABLE_INDEX)
 
 #define DIAG_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
 #define LANG_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
 #define CODEGEN_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
 
@@ -3221,6 +3238,7 @@
 
 #undef CODEGEN_OPTION_WITH_MARSHALLING
 #undef LANG_OPTION_WITH_MARSHALLING
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
 #undef DIAG_OPTION_WITH_MARSHALLING
 #undef OPTION_WITH_MARSHALLING
 #undef GENERATE_OPTION_WITH_MARSHALLING
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -256,7 +256,7 @@
 class CodeGenOpts
   : KeyPathAndMacro<"CodeGenOpts.", base, "CODEGEN_"> {}
 class HeaderSearchOpts
-  : KeyPathAndMacro<"HeaderSearchOpts->", base> {}
+  : KeyPathAndMacro<"HeaderSearchOpts->", base, "HEADER_SEARCH_"> {}
 class PreprocessorOpts
   : KeyPathAndMacro<"PreprocessorOpts->", base> {}
 class FileSystemOpts


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1796,7 +1796,23 @@
 }
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags,
   const std::string &WorkingDir) {
+  HeaderSearchOptions *HeaderSearchOpts = &Opts;
+  bool Success = true;
+
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING( \
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+MERGER, EXTRACTOR, TABLE_INDEX)\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  \
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  \
+MERGER, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
+
   if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
 Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
 
@@ -2993,7 +3009,7 @@
   LangOpts.IsHeaderFile);
   ParseTargetAr

[clang] 6227069 - [DebugInfo][CodeView] Change in line tables only mode to emit type information

2021-01-15 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2021-01-15T09:28:27-08:00
New Revision: 6227069bdce6b0c3c22f0a0c8f1aef705985125a

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

LOG: [DebugInfo][CodeView] Change in line tables only mode to emit type 
information
for function scopes, rather than using the qualified name.

In line-tables-only mode, we used to emit qualified names as the display name 
for functions when using CodeView.
This patch changes to emitting the parent scopes instead, with forward 
declarations for class types.
The total object file size ends up being slightly smaller than if we use the 
full qualified names.

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

Added: 
clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 881ee24546c2..00606d3ae507 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -254,24 +254,12 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl 
*FD) {
   FunctionTemplateSpecializationInfo *Info =
   FD->getTemplateSpecializationInfo();
 
-  // Emit the unqualified name in normal operation. LLVM and the debugger can
-  // compute the fully qualified name from the scope chain. If we're only
-  // emitting line table info, there won't be any scope chains, so emit the
-  // fully qualified name here so that stack traces are more accurate.
-  // FIXME: Do this when emitting DWARF as well as when emitting CodeView after
-  // evaluating the size impact.
-  bool UseQualifiedName = DebugKind == codegenoptions::DebugLineTablesOnly &&
-  CGM.getCodeGenOpts().EmitCodeView;
-
-  if (!Info && FII && !UseQualifiedName)
+  if (!Info && FII)
 return FII->getName();
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  if (!UseQualifiedName)
-FD->printName(OS);
-  else
-FD->printQualifiedName(OS, getPrintingPolicy());
+  FD->printName(OS);
 
   // Add any template specialization args.
   if (Info) {
@@ -1058,7 +1046,10 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType 
*Ty,
   Flags |= llvm::DINode::FlagNonTrivial;
 
   // Create the type.
-  SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
+  SmallString<256> Identifier;
+  // Don't include a linkage name in line tables only.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo())
+Identifier = getTypeIdentifier(Ty, CGM, TheCU);
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align, Flags,
   Identifier);
@@ -2326,6 +2317,9 @@ static bool 
shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
 if (ES->hasExternalDefinitions(RD) == ExternalASTSource::EK_Always)
   return true;
 
+  if (DebugKind == codegenoptions::DebugLineTablesOnly)
+return true;
+
   if (DebugKind > codegenoptions::LimitedDebugInfo)
 return false;
 
@@ -3473,7 +3467,11 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl 
GD, llvm::DIFile *Unit,
   DebugKind <= 
codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 
-  if (CGM.getCodeGenOpts().hasReducedDebugInfo()) {
+  // Emit the function scope in line tables only mode (if CodeView) to
+  // 
diff erentiate between function names.
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo() ||
+  (DebugKind == codegenoptions::DebugLineTablesOnly &&
+   CGM.getCodeGenOpts().EmitCodeView)) {
 if (const NamespaceDecl *NSDecl =
 dyn_cast_or_null(FD->getDeclContext()))
   FDContext = getOrCreateNamespace(NSDecl);
@@ -3482,6 +3480,8 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, 
llvm::DIFile *Unit,
   llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
   FDContext = getContextDescriptor(RDecl, Mod ? Mod : TheCU);
 }
+  }
+  if (CGM.getCodeGenOpts().hasReducedDebugInfo()) {
 // Check if it is a noreturn-marked function
 if (FD->isNoReturn())
   Flags |= llvm::DINode::FlagNoReturn;

diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
index 15f625d8832d..935fded5e67c 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -20,11 +20,9 @@ void freefunc() { }
 
 namespace N {
   int b() { return 0; }
-// UNQUAL-DAG: "b"
-// QUAL-DAG: "N::b"
+// CHECK-DAG: "b"
   namespace { void func() { } }
-// UNQUAL-DAG: "func"
-// QUAL-DAG: "N::`anonymous namespace'::func"
+// CHECK-DAG: "func"
 }
 
 v

[PATCH] D94639: [DebugInfo][CodeView] Change in line tables only mode to emit parent/context scopes for functions, using declarations for types

2021-01-15 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6227069bdce6: [DebugInfo][CodeView] Change in line tables 
only mode to emit type information (authored by akhuang).

Changed prior to commit:
  https://reviews.llvm.org/D94639?vs=316779&id=317001#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94639

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp

Index: clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debug-info-kind=line-tables-only -S -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix LINUX %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=line-tables-only -gcodeview -S -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix MSVC %s
+
+// Check that we emit type information for function scopes in line tables for
+// CodeView.
+
+namespace A {
+void f() {}
+
+struct S {
+  static void m() {}
+};
+}
+
+int main() {
+  A::f();
+  A::S::m();
+  return 0;
+  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "f"
+  // MSVC-SAME: scope: [[SCOPE1:![0-9]+]]
+  // MSVC-SAME: )
+  // MSVC:   [[SCOPE1]] = !DINamespace(name: "A", {{.*}})
+  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "m"
+  // MSVC-SAME: scope: [[SCOPE2:![0-9]+]]
+  // MSVC-SAME: )
+  // MSVC:   [[SCOPE2]] = !DICompositeType(tag: DW_TAG_structure_type,
+  // MSVC-SAME: name: "S",
+  // MSVC-SAME: scope: [[SCOPE1]]
+  // MSVC-SAME: )
+
+  // LINUX-NOT: !DINamespace
+  // LINUX-NOT: !DICompositeType
+  return 0;
+}
Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -20,11 +20,9 @@
 
 namespace N {
   int b() { return 0; }
-// UNQUAL-DAG: "b"
-// QUAL-DAG: "N::b"
+// CHECK-DAG: "b"
   namespace { void func() { } }
-// UNQUAL-DAG: "func"
-// QUAL-DAG: "N::`anonymous namespace'::func"
+// CHECK-DAG: "func"
 }
 
 void _c(void) {
@@ -35,24 +33,19 @@
 struct foo {
   int operator+(int);
   foo(){}
-// UNQUAL-DAG: "foo"
-// QUAL-DAG: "foo::foo"
+// CHECK-DAG: "foo"
 
   ~foo(){}
-// UNQUAL-DAG: "~foo"
-// QUAL-DAG: "foo::~foo"
+// CHECK-DAG: "~foo"
 
   foo(int i){}
-// UNQUAL-DAG: "foo"
-// QUAL-DAG: "foo::foo"
+// CHECK-DAG: "foo"
 
   foo(char *q){}
-// UNQUAL-DAG: "foo"
-// QUAL-DAG: "foo::foo"
+// CHECK-DAG: "foo"
 
   static foo* static_method() { return 0; }
-// UNQUAL-DAG: "static_method"
-// QUAL-DAG: "foo::static_method"
+// CHECK-DAG: "static_method"
 
 };
 
@@ -61,8 +54,7 @@
   foo::static_method();
 }
 
-// UNQUAL-DAG: "operator+"
-// QUAL-DAG: "foo::operator+"
+// CHECK-DAG: "operator+"
 int foo::operator+(int a) { return a; }
 
 // PR17371
@@ -82,17 +74,11 @@
 void OverloadedNewDelete::operator delete[](void *) { }
 int OverloadedNewDelete::operator+(int x) { return x; };
 
-// UNQUAL-DAG: "operator new"
-// UNQUAL-DAG: "operator new[]"
-// UNQUAL-DAG: "operator delete"
-// UNQUAL-DAG: "operator delete[]"
-// UNQUAL-DAG: "operator+"
-// QUAL-DAG: "OverloadedNewDelete::operator new"
-// QUAL-DAG: "OverloadedNewDelete::operator new[]"
-// QUAL-DAG: "OverloadedNewDelete::operator delete"
-// QUAL-DAG: "OverloadedNewDelete::operator delete[]"
-// QUAL-DAG: "OverloadedNewDelete::operator+"
-
+// CHECK-DAG: "operator new"
+// CHECK-DAG: "operator new[]"
+// CHECK-DAG: "operator delete"
+// CHECK-DAG: "operator delete[]"
+// CHECK-DAG: "operator+"
 
 template 
 void fn_tmpl() {}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -254,24 +254,12 @@
   FunctionTemplateSpecializationInfo *Info =
   FD->getTemplateSpecializationInfo();
 
-  // Emit the unqualified name in normal operation. LLVM and the debugger can
-  // compute the fully qualified name from the scope chain. If we're only
-  // emitting line table info, there won't be any scope chains, so emit the
-  // fully qualified name here so that stack traces are more accurate.
-  // FIXME: Do this when emitting DWARF as well as when emitting CodeView after
-  // evaluating the size impact.
-  bool UseQualifiedName = DebugKind == codegenoptions::DebugLineTablesOnly &&
-  CGM.getCodeGenOpts().EmitCodeView;
-
-  if (!Info && FII && !UseQualifiedName)
+  if (!Info && FII)
 return FII->getName();
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  if (!UseQualifiedName)
-FD->print

[PATCH] D94803: [clang][cli] Generate HeaderSearch options separately

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94803

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -400,6 +400,23 @@
 MERGER(KEYPATH, static_cast(*MaybeValue));  
\
   }
 
+// Capture the extracted value as a lambda argument to avoid potential issues
+// with lifetime extension of the reference.
+#define GENERATE_OPTION_WITH_MARSHALLING(  
\
+ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
+TABLE_INDEX)   
\
+  if ((FLAGS)&options::CC1Option) {
\
+[&](const auto &Extracted) {   
\
+  if (ALWAYS_EMIT ||   
\
+  (Extracted !=
\
+   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
+  : (DEFAULT_VALUE 
\
+DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
+ TABLE_INDEX, Extracted);  
\
+}(EXTRACTOR(KEYPATH)); 
\
+  }
+
 static void FixupInvocation(CompilerInvocation &Invocation,
 DiagnosticsEngine &Diags,
 const InputArgList &Args) {
@@ -1795,6 +1812,22 @@
   return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
+static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  const HeaderSearchOptions *HeaderSearchOpts = &Opts;
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING( 
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  GENERATE_OPTION_WITH_MARSHALLING(
\
+  Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
+}
+
 static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags,
   const std::string &WorkingDir) {
@@ -3202,23 +3235,6 @@
 
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
-  // Capture the extracted value as a lambda argument to avoid potential issues
-  // with lifetime extension of the reference.
-#define GENERATE_OPTION_WITH_MARSHALLING(  
\
-ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
-TABLE_INDEX)   
\
-  if ((FLAGS)&options::CC1Option) {
\
-[&](const auto &Extracted) {   
\
-  if (ALWAYS_EMIT ||   
\
-  (Extracted !=
\
-   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
-  : (DEFAULT_VALUE 
\
-DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
- TABLE_INDEX, Extracted);  
\
-}(EXTRACTOR(KEYPATH)); 
\
-  }
-
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
@@ -3230,7 +3246,6 @@
EXTRACTOR, TABLE_INDEX)
 
 #define DIAG_OPTION

[PATCH] D94472: [clang][cli] Manually generate header search arguments

2021-01-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 317003.
jansvoboda11 added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Add (improved) round-trip mechanism


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -90,11 +90,22 @@
 }
 
 std::vector ArgList::getAllArgValues(OptSpecifier Id) const {
+  recordQueriedOpts(Id);
   SmallVector Values;
   AddAllArgValues(Values, Id);
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+   const DenseSet &ExcludeIds) const {
+  for (const Arg *Arg : *this) {
+if (!ExcludeIds.contains(Arg->getOption().getID())) {
+  Arg->claim();
+  Arg->render(*this, Output);
+}
+  }
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -137,6 +137,16 @@
   /// The first and last index of each different OptSpecifier ID.
   DenseMap OptRanges;
 
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+
+  /// Record the queried OptSpecifiers.
+  template 
+  void recordQueriedOpts(OptSpecifiers... Ids) const {
+SmallVector OptsSpecifiers({toOptSpecifier(Ids).getID()...});
+QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
+  }
+
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
   OptRange getRange(std::initializer_list Ids) const;
@@ -203,6 +213,7 @@
   template
   iterator_range>
   filtered(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.begin() + Range.first;
 auto E = Args.begin() + Range.second;
@@ -214,6 +225,7 @@
   template
   iterator_range>
   filtered_reverse(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.rend() - Range.second;
 auto E = Args.rend() - Range.first;
@@ -308,6 +320,10 @@
   A->render(*this, Output);
   }
 
+  /// AddAllArgsExcept - Render all arguments not matching any of the excluded
+  /// ids.
+  void AddAllArgsExcept(ArgStringList &Output,
+const DenseSet &ExcludeIds) const;
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
   void AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids,
@@ -342,6 +358,9 @@
   ///
   void ClaimAllArgs() const;
 
+  /// Return the OptSpecifiers queried from this argument list.
+  const DenseSet &getQueriedOpts() const { return QueriedOpts; }
+
   /// @}
   /// @name Arg Synthesis
   /// @{
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -48,10 +48,12 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -1812,9 +1814,9 @@
   return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
-static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
- SmallVectorImpl &Args,
- CompilerInvocation::StringAllocator SA) {
+void CompilerInvocation::GenerateHeaderSearchArgs(
+const HeaderSearchOptions &Opts, SmallVectorImpl &Args,
+CompilerInvocation::StringAllocator SA) {
   const HeaderSearchOptions *HeaderSearchOpts = &Opts;
 #define HEADER_SEARCH_OPTION_WITH_MARSHALLING( \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
@@ -1826,6 +1828,118 @@
   IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX)
 #include "clang/Driver/Options.inc"
 #undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
+
+  const OptTable &OptTable = getDriverOptTable();
+
+  s

[PATCH] D94804: [clang] Allow LifetimeExtendedTemporary to have no access specifier

2021-01-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: hokein.
adamcz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The check only runs in debug mode during serialization, but
assert()-fail on:

  struct S { const int& x = 7; };

in C++ mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94804

Files:
  clang/lib/AST/DeclBase.cpp
  clang/test/PCH/cxx-reference.h


Index: clang/test/PCH/cxx-reference.h
===
--- clang/test/PCH/cxx-reference.h
+++ clang/test/PCH/cxx-reference.h
@@ -11,3 +11,7 @@
 LR &&rrlr = c;
 RR &lrrr = c;
 RR && = 'c';
+
+struct S {
+  const int &x = 1; // LifetimeExtendedTemporary inside struct
+};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -971,21 +971,19 @@
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
   // 7. it's a block literal declaration
-  if (isa(this) ||
-  isa(this) ||
-  isa(this) ||
-  !getDeclContext() ||
-  !isa(getDeclContext()) ||
-  isInvalidDecl() ||
-  isa(this) ||
-  isa(this) ||
+  // 8. it's a temporary with lifetime extended due to being default value.
+  if (isa(this) || isa(this) ||
+  isa(this) || !getDeclContext() ||
+  !isa(getDeclContext()) || isInvalidDecl() ||
+  isa(this) || isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||
   // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
   // AS_none as access specifier.
   isa(this) ||
-  isa(this))
+  isa(this) ||
+  isa(this))
 return true;
 
   assert(Access != AS_none &&


Index: clang/test/PCH/cxx-reference.h
===
--- clang/test/PCH/cxx-reference.h
+++ clang/test/PCH/cxx-reference.h
@@ -11,3 +11,7 @@
 LR &&rrlr = c;
 RR &lrrr = c;
 RR && = 'c';
+
+struct S {
+  const int &x = 1; // LifetimeExtendedTemporary inside struct
+};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -971,21 +971,19 @@
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
   // 7. it's a block literal declaration
-  if (isa(this) ||
-  isa(this) ||
-  isa(this) ||
-  !getDeclContext() ||
-  !isa(getDeclContext()) ||
-  isInvalidDecl() ||
-  isa(this) ||
-  isa(this) ||
+  // 8. it's a temporary with lifetime extended due to being default value.
+  if (isa(this) || isa(this) ||
+  isa(this) || !getDeclContext() ||
+  !isa(getDeclContext()) || isInvalidDecl() ||
+  isa(this) || isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||
   // FIXME: a ClassTemplateSpecialization or CXXRecordDecl can have
   // AS_none as access specifier.
   isa(this) ||
-  isa(this))
+  isa(this) ||
+  isa(this))
 return true;
 
   assert(Access != AS_none &&
___
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-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1839
+OptName = Dash + OptTable.getOptionName(OPT_stdlib_EQ);
+Args.emplace_back(SA(OptName + "libc++"));
+  }

I plan to move the prefixing of the option name and serialization of the value 
into a separate function, so we don't have to duplicate the logic here.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3110
+template 
+void RoundTrip(ParseFn &&Parse, GenerateFn &&Generate, ResetFn &&Reset,
+   CompilerInvocation &Res, InputArgList &OriginalArgs) {

I'd like to rename this function to something like `MaybeRoundTrip` and avoid 
the round-trip in release builds with `#ifndef NDEBUG`.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3216
+
+  RoundTrip(ParseHS, GenerateHS, ResetHS, Res, Args);
   if (DashX.getFormat() == InputKind::Precompiled ||

I plan to extract this into `ParseHeaderSearchArgsMaybeRoundtrip`.



Comment at: llvm/include/llvm/Option/ArgList.h:141
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+

These will be removed once we're able to generate all command line arguments. 
(We won't need to check which options to copy from the original command line 
and which to generate.)


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] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2021-01-15 Thread Wei Mi via Phabricator via cfe-commits
wmi accepted this revision.
wmi added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: llvm/lib/Transforms/IPO/SampleProfile.cpp:363
   const FunctionSamples *CalleeSamples;
   uint64_t CallsiteCount;
+  // Call site distribution factor to prorate the profile samples for a

hoy wrote:
> wmi wrote:
> > CallsiteCount will be the count before being prorated or after if 
> > CallsiteDistribution is not 1.0?
> It is the count after prorated. The prorated count will be used to guide 
> inlining. For example, if a callsite is duplicated in LTO prelink, then in 
> LTO postlink the two copies will get their own distribution factors and their 
> prorated counts are used to decide if they should be inlined independently.
Ok, better comment it. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

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


[PATCH] D94474: [WIP][clang][cli] Test manual header search argument generation with round-trip

2021-01-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 abandoned this revision.
jansvoboda11 added a comment.

Hmm, that would still require us to keep a list of options we've converted. 
It's better than hard-coding it like this patch does, but I'd like it to be 
more automatic.

I've updated D94472  with my initial 
implementation of more hands-off solution. The gist is that the original 
`ArgList` instance constructs set of options the `CompilerInvocation` queries 
during parsing. This will tell us which options we should be able to generate 
and which we shouldn't need to copy from the original argument list to the new 
one via `AddAllArgsXxx`.

Abandoning this patch as per your suggestion to merge round-tripping with the 
actual command line generation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94474

___
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-15 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP, LLVM.

The custom mapper API did not previously support the mapping names added 
previously. This means they were not present if a user requested debugging 
information while using the mapper functions. This adds basic support for 
passing the mapped names to the runtime library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94806

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  openmp/libomptarget/src/interface.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/test/mapping/declare_mapper_api.cpp

Index: openmp/libomptarget/test/mapping/declare_mapper_api.cpp
===
--- openmp/libomptarget/test/mapping/declare_mapper_api.cpp
+++ openmp/libomptarget/test/mapping/declare_mapper_api.cpp
@@ -15,9 +15,10 @@
   void *Begin;
   int64_t Size;
   int64_t Type;
+  void *Name;
   MapComponentInfoTy() = default;
-  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type)
-  : Base(Base), Begin(Begin), Size(Size), Type(Type) {}
+  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type, void *Name)
+  : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
 };
 
 struct MapperComponentsTy {
@@ -30,7 +31,8 @@
 #endif
 int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
 void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
- void *begin, int64_t size, int64_t type);
+ void *begin, int64_t size, int64_t type, 
+ void *name);
 #ifdef __cplusplus
 }
 #endif
@@ -40,8 +42,8 @@
   void *base, *begin;
   int64_t size, type;
   // Push 2 elements into MC.
-  __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
-  __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
+  __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
+  __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
   int64_t num = __tgt_mapper_num_components((void *)&MC);
   // CHECK: num=2
   printf("num=%" PRId64 "\n", num);
Index: openmp/libomptarget/src/private.h
===
--- openmp/libomptarget/src/private.h
+++ openmp/libomptarget/src/private.h
@@ -48,9 +48,11 @@
   void *Begin;
   int64_t Size;
   int64_t Type;
+  void *Name;
   MapComponentInfoTy() = default;
-  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type)
-  : Base(Base), Begin(Begin), Size(Size), Type(Type) {}
+  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type,
+ void *Name)
+  : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
 };
 
 // This structure stores all components of a user-defined mapper. The number of
@@ -64,8 +66,10 @@
 // The mapper function pointer type. It follows the signature below:
 // void .omp_mapper...(void *rt_mapper_handle,
 //   void *base, void *begin,
-//   size_t size, int64_t type);
-typedef void (*MapperFuncPtrTy)(void *, void *, void *, int64_t, int64_t);
+//   size_t size, int64_t type,
+//   void * name);
+typedef void (*MapperFuncPtrTy)(void *, void *, void *, int64_t, int64_t,
+void *);
 
 // Function pointer type for target_data_* functions (targetDataBegin,
 // targetDataEnd and targetDataUpdate).
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -209,15 +209,16 @@
 /// Call the user-defined mapper function followed by the appropriate
 // target_data_* function (target_data_{begin,end,update}).
 int targetDataMapper(DeviceTy &Device, void *arg_base, void *arg,
- int64_t arg_size, int64_t arg_type, void *arg_mapper,
+ int64_t arg_size, int64_t arg_type,
+ map_var_info_t arg_names, void *arg_mapper,
  TargetDataFuncPtrTy target_data_function) {
   DP("Calling the mapper function " DPxMOD "\n", DPxPTR(arg_mapper));
 
   // The mapper function fills up Components.
   MapperComponentsTy MapperComponents;
   MapperFuncPtrTy MapperFuncPtr = (MapperFuncPtrTy)(arg_mapper);
-  (*MapperFuncPtr)((

[PATCH] D94808: [NewPM][Inliner] Move mandatory inliner inside function simplification pipeline

2021-01-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: hiraditya, eraman.
aeubanks requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94808

Files:
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/IPO/Inliner.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-module-inliner-wrapper.ll
  llvm/test/Transforms/Inline/inline_stats.ll
  llvm/test/Transforms/Inline/pr46945.ll

Index: llvm/test/Transforms/Inline/pr46945.ll
===
--- llvm/test/Transforms/Inline/pr46945.ll
+++ llvm/test/Transforms/Inline/pr46945.ll
@@ -1,12 +1,6 @@
-; RUN: opt %s -o - -S -passes=always-inliner-wrapper | FileCheck %s
 ; RUN: opt %s -o - -S -passes='default' | FileCheck %s
-; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s -check-prefix=BASELINE
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
 
-; In the baseline case, a will be first inlined into b, which makes c recursive,
-; and, thus, un-inlinable. We need a baseline case to make sure intra-SCC order
-; is as expected: b first, then a.
-
-; BASELINE: call void @b()
 ; CHECK-NOT: call void @b()
 define void @b() alwaysinline {
 entry:
Index: llvm/test/Transforms/Inline/inline_stats.ll
===
--- llvm/test/Transforms/Inline/inline_stats.ll
+++ llvm/test/Transforms/Inline/inline_stats.ll
@@ -9,9 +9,6 @@
 ; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
 ; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK
 
-; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER
-; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes=WRAPPER-VERBOSE,WRAPPER
-
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
 ; CHECK-BASIC-NOT: -- Inlined not imported function
Index: llvm/test/Other/new-pm-module-inliner-wrapper.ll
===
--- llvm/test/Other/new-pm-module-inliner-wrapper.ll
+++ /dev/null
@@ -1,7 +0,0 @@
-; RUN: opt -disable-verify -debug-pass-manager -passes='always-inliner-wrapper' -S %s 2>&1 | FileCheck %s
-
-; CHECK: Running pass: InlinerPass
-
-define void @foo() {
-  ret void
-}
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -658,6 +658,10 @@
 InlineAdvisor &
 InlinerPass::getAdvisor(const ModuleAnalysisManagerCGSCCProxy::Result &MAM,
 FunctionAnalysisManager &FAM, Module &M) {
+  if (Mandatory) {
+OwnedAdvisor = std::make_unique(FAM);
+return *OwnedAdvisor;
+  }
   auto *IAA = MAM.getCachedResult(M);
   if (!IAA) {
 // It should still be possible to run the inliner as a stand-alone SCC pass,
@@ -668,8 +672,9 @@
 // duration of the inliner pass, and thus the lifetime of the owned advisor.
 // The one we would get from the MAM can be invalidated as a result of the
 // inliner's activity.
-OwnedDefaultAdvisor.emplace(FAM, getInlineParams());
-return *OwnedDefaultAdvisor;
+OwnedAdvisor =
+std::make_unique(FAM, getInlineParams());
+return *OwnedAdvisor;
   }
   assert(IAA->getAdvisor() &&
  "Expected a present InlineAdvisorAnalysis also have an "
@@ -1017,6 +1022,7 @@
 
 ModuleInlinerWrapperPass::ModuleInlinerWrapperPass(InlineParams Params,
bool Debugging,
+   bool MandatoryFirst,
InliningAdvisorMode Mode,
unsigned MaxDevirtIterations)
 : Params(Params), Mode(Mode), MaxDevirtIterations(MaxDevirtIterations),
@@ -1026,6 +1032,8 @@
   // into the callers so that our optimizations can reflect that.
   // For PreLinkThinLTO pass, we disable hot-caller heuristic for sample PGO
   // because it makes profile annotation in the backend inaccurate.
+  if (MandatoryFirst)
+PM.addPass(InlinerPass(/*Mandatory*/ true));
   PM.addPass(InlinerPass());
 }
 
Index: llvm/lib/Passes/PassRegistry.def
===

[PATCH] D94808: [NewPM][Inliner] Move mandatory inliner inside function simplification pipeline

2021-01-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Wondering if this makes sense to you (before I go and finish cleaning up all 
the tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94808

___
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-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert 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/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] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 317015.
usaxena95 added a comment.

Added tests for not indexing lambdas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.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
@@ -1637,14 +1637,28 @@
 template
 struct $5^TemplateBase {};
 struct $5[[Child3]] : public TemplateBase {};
+
+// Local classes.
+void LocationFunction() {
+  struct $0[[LocalClass1]] : Base {
+void $1[[Foo]]() override;
+  };
+  struct $6^LocalBase {
+virtual void $7^Bar();
+  };
+  struct $6[[LocalClass2]]: LocalBase {
+void $7[[Bar]]() override;
+  };
+}
   )cpp";
 
   Annotations Code(Test);
   auto TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  for (StringRef Label : {"0", "1", "2", "3", "4", "5"}) {
+  auto Index = TU.index();
+  for (StringRef Label : {"0", "1", "2", "3", "4", "5", "6", "7"}) {
 for (const auto &Point : Code.points(Label)) {
-  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  EXPECT_THAT(findImplementations(AST, Point, Index.get()),
   UnorderedPointwise(DeclRange(), Code.ranges(Label)))
   << Code.code() << " at " << Point << " for Label " << Label;
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -55,6 +55,7 @@
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(HasName, Name, "") { return arg.Name == Name; }
 MATCHER_P(TemplateArgs, TemplArgs, "") {
   return arg.TemplateSpecializationArgs == TemplArgs;
 }
@@ -157,6 +158,37 @@
   EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
 }
 
+TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {
+  build(R"(
+namespace nx {
+auto f() {
+  int Local;
+  auto LocalLambda = [&](){
+Local++;
+class ClassInLambda{};
+return Local;
+  };
+} // auto ensures function body is parsed.
+auto foo() {
+  class LocalBase {
+virtual void LocalVirtual();
+void LocalConcrete();
+int BaseMember;
+  };
+}
+} // namespace nx
+  )",
+"");
+  auto AST = File.build();
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("ClassInLambda", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalBase", /*Qualified=*/false));
+  EXPECT_TRUE(shouldCollect("LocalVirtual", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("LocalConcrete", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("BaseMember", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+}
+
 TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
   HeaderName = "f.proto.h";
   build(
@@ -228,7 +260,7 @@
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
-IndexOpts.IndexFunctionLocals = false;
+IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
 return std::make_unique(Collector, std::move(IndexOpts),
  PragmaHandler);
@@ -320,7 +352,11 @@
 void ff() {} // ignore
 }
 
-void f1() {}
+void f1() {
+  auto LocalLambda = [&](){
+class ClassInLambda{};
+  };
+}
 
 namespace foo {
 // Type alias
@@ -351,7 +387,7 @@
AllOf(QName("Foo::operator="), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested"), ForCodeCompletion(false)),
AllOf(QName("Foo::Nested::f"), ForCodeCompletion(false)),
-
+   AllOf(QName("ClassInLambda"), ForCodeCompletion(false)),
AllOf(QName("Friend"), ForCodeCompletion(true)),
AllOf(QName("f1"), ForCodeCompletion(true)),
AllOf(QName("f2"), ForCodeCompletion(true)),
@@ -774,8 +810,9 @@
   };
   EXPECT_EQ(Container("ref1a"),
 findSymbol(Symbols, "f2").ID); // function body (call)
-  EXPECT_EQ(Container("ref1b"),
-findSymbol(Symbols, "f2").ID); // function body (addres

[PATCH] D94785: [clangd] Index local classes, virtual and overriding methods.

2021-01-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added a comment.

In D94785#2501312 , @njames93 wrote:

> My only question is does this try and index lambdas, under the hood they are 
> declared as a CXXRecordDecl, defined in function scope?

I would not expect that to happen as it is an anonymous class and we filter 
those in the beginning of `shouldCollectSymbol`.
Added tests to test this.

Although now that I enabled this in all SymbolCollectorTests, this causes a 
regression in RefContainers.

  void f2() {
(void) $ref1a[[f1]](1);
auto fptr = &$ref1b[[f1]];
  }

`&f1` is contained in `fptr` instead of `f2`. No immediate ideas why would this 
happen. Will take a look into this next week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94785

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


[PATCH] D94808: [NewPM][Inliner] Move mandatory inliner inside function simplification pipeline

2021-01-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

I think InlineAdvisor::getAdvice needs to take a bool MandatoryOnly, which 
Inliner then passes. This allows us to then use the same advisor for both the 
always case and the policy-driven inliner instances, which allows that advisor 
to correctly book-keep any module wide state it may want to.




Comment at: llvm/include/llvm/Transforms/IPO/Inliner.h:111
+  std::unique_ptr OwnedAdvisor;
+  bool Mandatory;
 };

Nit: const bool



Comment at: llvm/lib/Transforms/IPO/Inliner.cpp:661
 FunctionAnalysisManager &FAM, Module &M) {
+  if (Mandatory) {
+OwnedAdvisor = std::make_unique(FAM);

This should move to line 675: if we have installed an advisor, we use it, and 
the inliner pass passes to getAdvice() whether it only needs mandatory advice. 
All advisors need to support the mandatory case anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94808

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


[PATCH] D94808: [NewPM][Inliner] Move mandatory inliner inside function simplification pipeline

2021-01-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Transforms/IPO/Inliner.cpp:661
 FunctionAnalysisManager &FAM, Module &M) {
+  if (Mandatory) {
+OwnedAdvisor = std::make_unique(FAM);

mtrofin wrote:
> This should move to line 675: if we have installed an advisor, we use it, and 
> the inliner pass passes to getAdvice() whether it only needs mandatory 
> advice. All advisors need to support the mandatory case anyway.
The whole point of https://bugs.llvm.org/show_bug.cgi?id=46945 was that we need 
to run the alwaysinliner first. Even if all advisors support the mandatory 
case, they may inline in the wrong order. That can either be fixed by running 
alwaysinliner first, or by having the inliner look at alwaysinline calls first.

If we have an advisor like the ML one, we will always use that one, then 
potentially end up inlining in the wrong order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94808

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


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

2021-01-15 Thread Tom Ritter via Phabricator via cfe-commits
tomrittervg updated this revision to Diff 317027.
tomrittervg added a comment.

Remove braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94624

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


Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -49,6 +49,14 @@
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 static cl::OptionCategory ClangQueryCategory("clang-query options");
 
+static cl::opt
+UseColor("use-color",
+ cl::desc(
+ R"(Use colors in detailed AST output. If not set, colors
+will be used if the terminal connected to
+standard output supports colors.)"),
+ cl::init(false), cl::cat(ClangQueryCategory));
+
 static cl::list Commands("c", cl::desc("Specify command to run"),
   cl::value_desc("command"),
   cl::cat(ClangQueryCategory));
@@ -109,6 +117,19 @@
 
   ClangTool Tool(OptionsParser->getCompilations(),
  OptionsParser->getSourcePathList());
+
+  if (UseColor.getNumOccurrences() > 0) {
+ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, 
StringRef /*unused*/) {
+  CommandLineArguments AdjustedArgs = Args;
+  if (UseColor)
+AdjustedArgs.push_back("-fdiagnostics-color");
+  else
+AdjustedArgs.push_back("-fno-diagnostics-color");
+  return AdjustedArgs;
+};
+Tool.appendArgumentsAdjuster(colorAdjustor);
+  }
+
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
Index: clang-tools-extra/clang-query/Query.cpp
===
--- clang-tools-extra/clang-query/Query.cpp
+++ clang-tools-extra/clang-query/Query.cpp
@@ -156,8 +156,7 @@
 if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   const ASTContext &Ctx = AST->getASTContext();
-  const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
+  ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);
   Dumper.Visit(BI->second);
   OS << "\n";


Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -49,6 +49,14 @@
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 static cl::OptionCategory ClangQueryCategory("clang-query options");
 
+static cl::opt
+UseColor("use-color",
+ cl::desc(
+ R"(Use colors in detailed AST output. If not set, colors
+will be used if the terminal connected to
+standard output supports colors.)"),
+ cl::init(false), cl::cat(ClangQueryCategory));
+
 static cl::list Commands("c", cl::desc("Specify command to run"),
   cl::value_desc("command"),
   cl::cat(ClangQueryCategory));
@@ -109,6 +117,19 @@
 
   ClangTool Tool(OptionsParser->getCompilations(),
  OptionsParser->getSourcePathList());
+
+  if (UseColor.getNumOccurrences() > 0) {
+ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, StringRef /*unused*/) {
+  CommandLineArguments AdjustedArgs = Args;
+  if (UseColor)
+AdjustedArgs.push_back("-fdiagnostics-color");
+  else
+AdjustedArgs.push_back("-fno-diagnostics-color");
+  return AdjustedArgs;
+};
+Tool.appendArgumentsAdjuster(colorAdjustor);
+  }
+
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
Index: clang-tools-extra/clang-query/Query.cpp
===
--- clang-tools-extra/clang-query/Query.cpp
+++ clang-tools-extra/clang-query/Query.cpp
@@ -156,8 +156,7 @@
 if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   const ASTContext &Ctx = AST->getASTContext();
-  const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
+  ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);
   Dumper.Visit(BI->second);
   OS << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-01-15 Thread Tom Ritter via Phabricator via cfe-commits
tomrittervg added a comment.

I started trying to work on a patch, but I'm still unpacking from a move and 
don't have all my machines set up - trying to enable and build tests filled up 
my hard drive (even after I removed the easy-to-remove stuff), so I don't think 
I'm going to be able to create a test for this in the short-term.




Comment at: clang-tools-extra/clang-query/Query.cpp:159
   const ASTContext &Ctx = AST->getASTContext();
-  const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
+  ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);

aaron.ballman wrote:
> Semi-idle curiosity, does the source manager have a different diagnostics 
> object than the AST? I guess I'm a bit surprised this change is needed (or is 
> the change just a minor simplification to the code?).
Just a minor simplification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94624

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


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

2021-01-15 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 317038.
jhuber6 added a comment.

Fixed test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94806

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  openmp/libomptarget/src/interface.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/test/mapping/declare_mapper_api.cpp

Index: openmp/libomptarget/test/mapping/declare_mapper_api.cpp
===
--- openmp/libomptarget/test/mapping/declare_mapper_api.cpp
+++ openmp/libomptarget/test/mapping/declare_mapper_api.cpp
@@ -15,9 +15,10 @@
   void *Begin;
   int64_t Size;
   int64_t Type;
+  void *Name;
   MapComponentInfoTy() = default;
-  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type)
-  : Base(Base), Begin(Begin), Size(Size), Type(Type) {}
+  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type, void *Name)
+  : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
 };
 
 struct MapperComponentsTy {
@@ -30,7 +31,8 @@
 #endif
 int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
 void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
- void *begin, int64_t size, int64_t type);
+ void *begin, int64_t size, int64_t type, 
+ void *name);
 #ifdef __cplusplus
 }
 #endif
@@ -40,8 +42,8 @@
   void *base, *begin;
   int64_t size, type;
   // Push 2 elements into MC.
-  __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
-  __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
+  __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
+  __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
   int64_t num = __tgt_mapper_num_components((void *)&MC);
   // CHECK: num=2
   printf("num=%" PRId64 "\n", num);
Index: openmp/libomptarget/src/private.h
===
--- openmp/libomptarget/src/private.h
+++ openmp/libomptarget/src/private.h
@@ -48,9 +48,11 @@
   void *Begin;
   int64_t Size;
   int64_t Type;
+  void *Name;
   MapComponentInfoTy() = default;
-  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type)
-  : Base(Base), Begin(Begin), Size(Size), Type(Type) {}
+  MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type,
+ void *Name)
+  : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
 };
 
 // This structure stores all components of a user-defined mapper. The number of
@@ -64,8 +66,10 @@
 // The mapper function pointer type. It follows the signature below:
 // void .omp_mapper...(void *rt_mapper_handle,
 //   void *base, void *begin,
-//   size_t size, int64_t type);
-typedef void (*MapperFuncPtrTy)(void *, void *, void *, int64_t, int64_t);
+//   size_t size, int64_t type,
+//   void * name);
+typedef void (*MapperFuncPtrTy)(void *, void *, void *, int64_t, int64_t,
+void *);
 
 // Function pointer type for target_data_* functions (targetDataBegin,
 // targetDataEnd and targetDataUpdate).
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -209,15 +209,16 @@
 /// Call the user-defined mapper function followed by the appropriate
 // target_data_* function (target_data_{begin,end,update}).
 int targetDataMapper(DeviceTy &Device, void *arg_base, void *arg,
- int64_t arg_size, int64_t arg_type, void *arg_mapper,
+ int64_t arg_size, int64_t arg_type,
+ map_var_info_t arg_names, void *arg_mapper,
  TargetDataFuncPtrTy target_data_function) {
   DP("Calling the mapper function " DPxMOD "\n", DPxPTR(arg_mapper));
 
   // The mapper function fills up Components.
   MapperComponentsTy MapperComponents;
   MapperFuncPtrTy MapperFuncPtr = (MapperFuncPtrTy)(arg_mapper);
-  (*MapperFuncPtr)((void *)&MapperComponents, arg_base, arg, arg_size,
-  arg_type);
+  (*MapperFuncPtr)((void *)&MapperComponents, arg_base, arg, arg_size, arg_type,
+   arg_names);
 
   // Construct new arrays for args_base, args, arg_sizes and arg_types
   // using the information in MapperComponents and call the corresponding
@@ -226,6 +227,7 @@
   std::vector MapperArgs(MapperComponents.Component

[PATCH] D94814: [HIP] Support `__managed__` attribute

2021-01-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: dexonsmith, jdoerfert, hiraditya, mgorny.
Herald added a reviewer: aaron.ballman.
yaxunl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch implements codegen for `__managed__` variable attribute for HIP.

Diagnostics will be added later.


https://reviews.llvm.org/D94814

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  llvm/include/llvm/IR/ReplaceConstant.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/ReplaceConstant.cpp
  llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp

Index: llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp
===
--- llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp
+++ llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp
@@ -21,6 +21,7 @@
 #include "llvm/IR/IntrinsicsXCore.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/NoFolder.h"
+#include "llvm/IR/ReplaceConstant.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
@@ -74,57 +75,6 @@
   return ConstantArray::get(NewType, Elements);
 }
 
-static Instruction *
-createReplacementInstr(ConstantExpr *CE, Instruction *Instr) {
-  IRBuilder Builder(Instr);
-  unsigned OpCode = CE->getOpcode();
-  switch (OpCode) {
-case Instruction::GetElementPtr: {
-  SmallVector CEOpVec(CE->operands());
-  ArrayRef CEOps(CEOpVec);
-  return dyn_cast(Builder.CreateInBoundsGEP(
-  cast(CE)->getSourceElementType(), CEOps[0],
-  CEOps.slice(1)));
-}
-case Instruction::Add:
-case Instruction::Sub:
-case Instruction::Mul:
-case Instruction::UDiv:
-case Instruction::SDiv:
-case Instruction::FDiv:
-case Instruction::URem:
-case Instruction::SRem:
-case Instruction::FRem:
-case Instruction::Shl:
-case Instruction::LShr:
-case Instruction::AShr:
-case Instruction::And:
-case Instruction::Or:
-case Instruction::Xor:
-  return dyn_cast(
-  Builder.CreateBinOp((Instruction::BinaryOps)OpCode,
-  CE->getOperand(0), CE->getOperand(1),
-  CE->getName()));
-case Instruction::Trunc:
-case Instruction::ZExt:
-case Instruction::SExt:
-case Instruction::FPToUI:
-case Instruction::FPToSI:
-case Instruction::UIToFP:
-case Instruction::SIToFP:
-case Instruction::FPTrunc:
-case Instruction::FPExt:
-case Instruction::PtrToInt:
-case Instruction::IntToPtr:
-case Instruction::BitCast:
-  return dyn_cast(
-  Builder.CreateCast((Instruction::CastOps)OpCode,
- CE->getOperand(0), CE->getType(),
- CE->getName()));
-default:
-  llvm_unreachable("Unhandled constant expression!\n");
-  }
-}
 
 static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) {
   do {
Index: llvm/lib/IR/ReplaceConstant.cpp
===
--- /dev/null
+++ llvm/lib/IR/ReplaceConstant.cpp
@@ -0,0 +1,68 @@
+//===- ReplaceConstant.cpp - Replace LLVM constant expression--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a utility function for replacing LLVM constant
+// expressions by instructions.
+//
+//===--===//
+
+#include "llvm/IR/ReplaceConstant.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/NoFolder.h"
+
+namespace llvm {
+Instruction *createReplacementInstr(ConstantExpr *CE, Instruction *Instr) {
+  IRBuilder Builder(Instr);
+  unsigned OpCode = CE->getOpcode();
+  switch (OpCode) {
+  case Instruction::GetElementPtr: {
+SmallVector CEOpVec(CE->operands());
+ArrayRef CEOps(CEOpVec);
+return dyn_cast(
+Builder.CreateInBoundsGEP(cast(CE)->getSourceElementType(),
+  CEOps[0], CEOps.slice(1)));
+  }
+  case Instruction::Add:
+  case Instruction::Sub:
+  case Instruction::Mul:
+  case Instruction::UDiv:
+  case Instruction::SDiv:
+  case Instruction::FD

[clang] a1be47b - [CodeView][DebugInfo] Add test case to show that linkage names are not

2021-01-15 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2021-01-15T12:05:33-08:00
New Revision: a1be47b4771467998d7549dcd1b9f9cebdaa9af9

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

LOG: [CodeView][DebugInfo] Add test case to show that linkage names are not
being added to class types in -gline-tables-only.
Also changed the name of the test file for clarity.
(follow up to D94639)

Added: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Modified: 


Removed: 
clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp



diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
deleted file mode 100644
index f096e334a158..
--- a/clang/test/CodeGenCXX/debug-info-codeview-scopes.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu 
-debug-info-kind=line-tables-only -S -emit-llvm -std=c++11 -o - %s | FileCheck 
--check-prefix LINUX %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc 
-debug-info-kind=line-tables-only -gcodeview -S -emit-llvm -std=c++11 -o - %s | 
FileCheck --check-prefix MSVC %s
-
-// Check that we emit type information for function scopes in line tables for
-// CodeView.
-
-namespace A {
-void f() {}
-
-struct S {
-  static void m() {}
-};
-}
-
-int main() {
-  A::f();
-  A::S::m();
-  return 0;
-  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "f"
-  // MSVC-SAME: scope: [[SCOPE1:![0-9]+]]
-  // MSVC-SAME: )
-  // MSVC:   [[SCOPE1]] = !DINamespace(name: "A", {{.*}})
-  // MSVC:   !{{[0-9]+}} = distinct !DISubprogram(name: "m"
-  // MSVC-SAME: scope: [[SCOPE2:![0-9]+]]
-  // MSVC-SAME: )
-  // MSVC:   [[SCOPE2]] = !DICompositeType(tag: DW_TAG_structure_type,
-  // MSVC-SAME: name: "S",
-  // MSVC-SAME: scope: [[SCOPE1]]
-  // MSVC-SAME: )
-
-  // LINUX-NOT: !DINamespace
-  // LINUX-NOT: !DICompositeType
-  return 0;
-}

diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
new file mode 100644
index ..25f801737f74
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -gcodeview -debug-info-kind=line-tables-only -S \
+// RUN:   -emit-llvm -o - | FileCheck %s
+// Checks that clang with "-gline-tables-only" with CodeView emits some debug
+// info for variables and types when they appear in function scopes.
+
+namespace NS {
+struct C {
+public:
+  void m() {}
+};
+void f() {}
+}
+
+NS::C c;
+
+void test() {
+  // CHECK: ![[EMPTY:[0-9]+]] = !{}
+  // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
+  // CHECK-SAME:  type: ![[F:[0-9]+]]
+  // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  NS::f();
+
+  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:  type: ![[F]]
+  // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
+  // CHECK-SAME:  flags: DIFlagFwdDecl
+  // CHECK-NOT: identifier
+  c.m();
+}



___
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-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: davidxl, vsk, gulfem.
Herald added subscribers: dexonsmith, wenlei, dang, jdoerfert, steven_wu, 
hiraditya, mgorny.
phosek requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This change implements support for applying profile instrumentation
only to selected files or functions. The implementation uses the
sanitizer special case list format to select which files and functions
to instrument, and relies on the new noprofile IR attribute to exclude
functions from instrumentation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94820

Files:
  clang/docs/SourceBasedCodeCoverage.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
@@ -974,6 +974,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
@@ -1639,6 +1639,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

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

2021-01-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

A concern I have is that the round-tripping might be too low level since it 
requires each group of options to opt-in somehow. Having something at the 
top-level that doesn't have to be touched again would be easier to validate / 
understand, and might better serve the purpose of verifying that the 
lower-level details were implemented correctly by not depending on them to turn 
it on.

A more minor concern is that I don't think this should always or only active 
when `!NDEBUG`. It would be ideal if it could be switched on and off in both 
release builds and asserts builds via a `-cc1` flag, maybe something like 
`-round-trip-args`. Then the Clang driver can set that flag by default in 
asserts builds, with a small `#ifndef NDEBUG` block that adds the `-cc1` 
argument. Search for `-discard-value-names` or `-disable-free` for other 
examples.

If we round-trip at the top level, then I think it's not too hard to implement 
a `-round-trip-args` flag with two different modes:

- A "strict" mode that treats the final parse as canonical. I think this is 
what we want long-term (in asserts mode).
- A "relaxed" mode that treats the first parse as canonical. I think we turn 
this on now-ish (in asserts mode), even though many args don't yet have 
generators.

Both modes check that the generated args match for original parse -> generate 
-> round-tripped parse -> generate. Only "strict" mode returns the result of 
the round-tripped parse, so in "relaxed" mode we haven't dropped anything from 
`Res`.

Here's a possible implementation that assumes most of `CreateFromArgs` has been 
moved to `CreateFromArgsImpl` or something:

  bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
  ArrayRef 
CommandLineArgs,
  DiagnosticsEngine &Diags,
  const char *Argv0) {
const OptTable &Opts = getDriverOptTable();
unsigned MissingArgIndex, MissingArgCount;
DiagnosticsEngine *ActiveDiags = &Diags;
CompilerInvocation *ActiveInvocation = &Res;
auto Parse = [&](InputArgList &Args) {
  return CreateFromArgsImpl(*ActiveInvocation, Opts, Args,
*ActiveDiags, Argv0,
MissingArgIndex, MissingArgCount);
};
  
// Just parse and return if we're not round-tripping.
const unsigned IncludedFlagsBitmask = options::CC1Option;
InputArgList OriginalArgs = Opts.ParseArgs(CommandLineArgs, MissingArgIndex,
   MissingArgCount, 
IncludedFlagsBitmask);
  
// The driver sets -round-trip-args by default in asserts builds.
StringRef RoundTrip = OriginalArgs;
bool ShouldRoundTrip = !(RoundTrip.empty() || RoundTrip == "off");
if (!ShouldRoundTrip)
  return Parse(OriginalArgs);
  
// Validate -round-trip-args.
bool IsRoundTripStrict = RoundTrip == "strict"
if (!IsRoundTripStrict && RoundTrip != "relaxed")) {
  Diags();
  return false;
}
  
// For -round-trip-args=strict, the first parse is just a temporary used to
// generate canonical -cc1 args, and the round-tripped parse is canonical. 
If
// any used arg is missing generation code, it'll get dropped on the floor.
//
// For -round-trip-args=relaxed, the first parse is canonical. The 
round-trip
// still checks that when generated args are parsed they'll generate the 
same
// args again. However, it doesn't provide coverage for args that aren't
// generated correctly.
Optional TempDiags;
Optional TempInvocation;
if (IsRoundTripStrict) {
  TempDiags.emplace(/*Store diags to replay them*/);
  TempInvocation.emplace();
  ActiveDiags = &*TempDiags;
  ActiveInvocation = &*TempInvocation;
}
  
// Parse the provided command-line. If this fails, it does not indicate a 
program
// bug, and we don't have a way to test round-tripping.
if (!Parse(OriginalArgs)) {
  if (IsRoundTripStrict)
replayDiagnostics(*TempDiags, Diags);
  return false;
}
  
StringPool<> Strings;
auto Generate = [&](SmallVectorImpl GeneratedArgs) {
  return GenerateCommandLine(*ActiveInvocation, GeneratedArgs, Strings);
};
  
// Generate a new -cc1 command-line from the first parse.
SmallVector GeneratedArgs1;
if (!Generate(GeneratedArgs1))
  llvm::report_fatal_error("Argument generation failed when 
round-tripping!");
  
// Swap out diagnostics.
if (IsRoundTripStrict) {
  ActiveDiags = &Diags;
  ActiveInvocation = &Res;
  TempDiags = None;
  TempInvocation = None;
} else {
  TempInvocation.emplace();
  TempDiags.emplace(/*ignore diags*/);
  ActiveDiags = &*TempDiags;
  ActiveInvocation = &*TempInvocation;
}
  
// Fill up Res and Diags with the second parse.
InputArgList RoundTrippedArgs =
Opts.ParseArgs(Genera

[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

2021-01-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D85223#2452363 , @JonChesterfield 
wrote:

> I concede that making the variables external, and trying to give them unique 
> names, does work around static variables not working. I believe static 
> variables are subjected to more aggressive optimisation than external ones 
> but the effect might not be significant.
>
> This "works" in cuda today because the loader ignores the local annotation 
> when accessing the variable. There is some probably unintended behaviour when 
> multiple static variables have the same name in that the first one wins.
>
> The corresponding change to the hsa loader is trivial. Why is making the 
> symbols external, with the associated complexity in picking non-conflicting 
> names, considered better than changing the loader?

Three reasons:

1. The loader would like to look up dynsym only, which conforms better to the 
standard dynamic linker behavior and is more efficient than looking up all 
symbols.

2. There could be symbols with the same name from different compilation units 
and they end up as local symbols with the same name in the binary. How does the 
loader know which is which.

3. If a device symbol is static but actually accessed by the host code in the 
same compilation unit, the device symbol has de facto external linkage since it 
is truly accessed by some one out side of the device object (this is due to the 
unfortunate fact that a single source file ends up with a host object and a 
device object even though they are supposed to be the same compilation unit).  
Keeping the device symbol with internal linkage will cause the compiler over 
optimize the device code.


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

https://reviews.llvm.org/D85223

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


[clang] 4a47da2 - [Sema] turns -Wfree-nonheap-object on by default

2021-01-15 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2021-01-15T21:38:47Z
New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263

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

LOG: [Sema] turns -Wfree-nonheap-object on by default

We'd discussed adding the warning to -Wall in D89988. This patch honours that.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Analysis/NewDelete-intersections.mm
clang/test/Analysis/free.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d500ab321058..04ba89aa457e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -110,6 +110,7 @@ def FloatConversion :
  FloatZeroConversion]>;
 
 def FrameAddress : DiagGroup<"frame-address">;
+def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7d36397a7993..e93657898f58 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
 def warn_no_dynamic_cast_with_rtti_disabled: Warning<
-  "dynamic_cast will not work since RTTI data is disabled by " 
+  "dynamic_cast will not work since RTTI data is disabled by "
   "%select{-fno-rtti-data|/GR-}0">, InGroup;
 def warn_no_typeid_with_rtti_disabled: Warning<
   "typeid will not work since RTTI data is disabled by "
@@ -7625,8 +7625,7 @@ def warn_condition_is_assignment : Warning<"using the 
result of an "
   InGroup;
 def warn_free_nonheap_object
   : Warning<"attempt to call %0 on non-heap object %1">,
-InGroup>,
-DefaultIgnore; // FIXME: add to -Wall after sufficient testing
+InGroup;
 
 // Completely identical except off by default.
 def warn_condition_is_idiomatic_assignment : Warning<"using the result "

diff  --git a/clang/test/Analysis/NewDelete-intersections.mm 
b/clang/test/Analysis/NewDelete-intersections.mm
index f01d62f8d365..6f81034ee349 100644
--- a/clang/test/Analysis/NewDelete-intersections.mm
+++ b/clang/test/Analysis/NewDelete-intersections.mm
@@ -24,9 +24,6 @@
 extern "C" void free(void *);
 
 void testMallocFreeNoWarn() {
-  int i;
-  free(&i); // no warn
-
   int *p1 = (int *)malloc(sizeof(int));
   free(++p1); // no warn
 
@@ -51,7 +48,7 @@ void testDeleteMalloced() {
 
   int *p2 = (int *)__builtin_alloca(sizeof(int));
   delete p2; // no warn
-} 
+}
 
 void testUseZeroAllocatedMalloced() {
   int *p1 = (int *)malloc(0);
@@ -79,13 +76,13 @@ void testObjcFreeNewed() {
 }
 
 void testFreeAfterDelete() {
-  int *p = new int;  
+  int *p = new int;
   delete p;
   free(p); // newdelete-warning{{Use of memory after it is freed}}
 }
 
 void testStandardPlacementNewAfterDelete() {
-  int *p = new int;  
+  int *p = new int;
   delete p;
   p = new (p) int; // newdelete-warning{{Use of memory after it is freed}}
 }

diff  --git a/clang/test/Analysis/free.c b/clang/test/Analysis/free.c
index 0d29bacf274c..b50145713924 100644
--- a/clang/test/Analysis/free.c
+++ b/clang/test/Analysis/free.c
@@ -12,17 +12,23 @@ void *alloca(size_t);
 
 void t1 () {
   int a[] = { 1 };
-  free(a); // expected-warning {{Argument to free() is the address of the 
local variable 'a', which is not memory allocated by malloc()}}
+  free(a);
+  // expected-warning@-1{{Argument to free() is the address of the local 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t2 () {
   int a = 1;
-  free(&a); // expected-warning {{Argument to free() is the address of the 
local variable 'a', which is not memory allocated by malloc()}}
+  free(&a);
+  // expected-warning@-1{{Argument to free() is the address of the local 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t3 () {
   static int a[] = { 1 };
-  free(a); // expected-warning {{Argument to free() is the address of the 
static variable 'a', which is not memory allocated by malloc()}}
+  free(a);
+  // expected-warning@-1{{Argument to free() is the address of the static 
variable 'a', which is not memory allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}
 }
 
 void t4

[PATCH] D94786: [clang][ASTImporter] Add support for importing CXXFoldExpr.

2021-01-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:655
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ functionTemplateDecl(hasDescendant(cxxFoldExpr(;
+}

Is it possible to check that we imported four fold expressions and maybe also 
check the operator of each one? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94786

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


[PATCH] D94825: [NewPM]i[Inliner] Move the 'always inliner' case in the same CGSCC pass as 'regular' inliner

2021-01-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin created this revision.
mtrofin added a reviewer: aeubanks.
Herald added subscribers: hiraditya, eraman.
mtrofin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Expanding from D94808  - we ensure the same 
InlineAdvisor is used by both
InlinerPass instances. The notion of mandatory inlining is moved into
the core InlineAdvisor: advisors anyway have to handle that case, so
this change also factors out that a bit better.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94825

Files:
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Analysis/MLInlineAdvisor.h
  llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/IPO/Inliner.h
  llvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Analysis/MLInlineAdvisor.cpp
  llvm/lib/Analysis/ReplayInlineAdvisor.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-module-inliner-wrapper.ll
  llvm/test/Transforms/Inline/inline_stats.ll
  llvm/test/Transforms/Inline/pr46945.ll

Index: llvm/test/Transforms/Inline/pr46945.ll
===
--- llvm/test/Transforms/Inline/pr46945.ll
+++ llvm/test/Transforms/Inline/pr46945.ll
@@ -1,12 +1,6 @@
-; RUN: opt %s -o - -S -passes=always-inliner-wrapper | FileCheck %s
 ; RUN: opt %s -o - -S -passes='default' | FileCheck %s
-; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s -check-prefix=BASELINE
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
 
-; In the baseline case, a will be first inlined into b, which makes c recursive,
-; and, thus, un-inlinable. We need a baseline case to make sure intra-SCC order
-; is as expected: b first, then a.
-
-; BASELINE: call void @b()
 ; CHECK-NOT: call void @b()
 define void @b() alwaysinline {
 entry:
Index: llvm/test/Transforms/Inline/inline_stats.ll
===
--- llvm/test/Transforms/Inline/inline_stats.ll
+++ llvm/test/Transforms/Inline/inline_stats.ll
@@ -6,11 +6,11 @@
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK
 
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK
+; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
+; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK
 
-; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER
-; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes=WRAPPER-VERBOSE,WRAPPER
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefix=MANDATORY-FIRST
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefix=MANDATORY-FIRST
 
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
@@ -30,15 +30,20 @@
 ; CHECK: non-imported functions inlined anywhere: 1 [33.33% of non-imported functions]
 ; CHECK: non-imported functions inlined into importing module: 1 [33.33% of non-imported functions]
 
-; WRAPPER-VERBOSE: -- List of inlined functions:
-; WRAPPER-VERBOSE: Inlined imported function [external5]: #inlines = 1, #inlines_to_importing_module = 1
-; WRAPPER: -- Summary:
-; WRAPPER: All functions: 10, imported functions: 7
-; WRAPPER: inlined functions: 1 [10% of all functions]
-; WRAPPER: imported functions inlined anywhere: 1 [14.29% of imported functions]
-; WRAPPER: imported functions inlined into importing module: 1 [14.29% of imported functions], remaining: 6 [85.71% of imported functions]
-; WRAPPER: non-imported functions inlined anywhere: 0 [0% of non-imported functions]
-; WRAPPER: non-imported functions inlined into importing module: 0 [0% of non-imported functions]
+; MANDATORY-FIRST: - Summary:
+; MA

[PATCH] D94827: [SimplifyCFG] Require and preserve dominator tree

2021-01-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: fhahn, jdoerfert, arsenm, mkazantsev, kuhar, 
brzycki, nikic.
lebedev.ri added projects: LLVM, AMDGPU.
Herald added subscribers: wenlei, kerbowa, steven_wu, hiraditya, nhaehnle, 
jvesely.
lebedev.ri requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

My motivation is the following two problems i've hit myself:

- `FoldBranchToCommonDest()` (and possibly 
`FoldValueComparisonIntoPredecessors()`) can't 'really' be extended to handle 
the case where bonus instruction has external uses, in the case where we have a 
successor that has multiple predecessors, but is dominated by the def block - 
there may not be a PHI node, we need to form it, but to know how to fill it we 
need to check for dominance, but well, we don't have the Dominator tree :) 
While it would be possible to write a function to check that some block 
dominates another, it seems like a hack. 
(59560e85897afc50090b6c3d920bacfd28b49d06 
, 
https://bugs.llvm.org/show_bug.cgi?id=48450)
- Even though SimplifyCFGPass drops unreachable blocks 
(`removeUnreachableBlocks()`), SimplifyCFG transformations may end up creating 
more unreachable blocks, and we may happily try to SimplifyCFG them, which is, 
at best, not very profitable, and at worst leads to crashes 
(ef93f7a11c347534ac768ec8bbbed64cd20c41d2 
, 
https://bugs.llvm.org/show_bug.cgi?id=48450#c8)

Indeed, simplifycfg pass didn't know how to preserve dominator tree,
it took me just under a month (starting with 
e1133179587dd895962a2fe4d6eb0cb1e63b5ee2 
)
do rectify that, now it fully knows how to, there's likely some problems with 
that still,
but i've dealt with everything i can spot so far.

I think we now can flip the switch.

Full disclosure: this isn't a compile-time win per-se, nor do i expect it to be 
one
should we actually start to make use of DominatorTree in SimplifyCFG.
Current best-case results suggest +0.5% geomean compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=a14c36fe27f5c36de44049237011d140a724&to=fd53c482aca9e20d76fb57def3ab0af851d1c697&stat=instructions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94827

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/CodeGen/DwarfEHPrepare.cpp
  llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
  llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/opt-LTO-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/pm-pgo-preinline.ll

Index: llvm/test/Other/pm-pgo-preinline.ll
===
--- llvm/test/Other/pm-pgo-preinline.ll
+++ llvm/test/Other/pm-pgo-preinline.ll
@@ -10,7 +10,6 @@
 ; CHECK-Osz-NEXT: SROA
 ; CHECK-Osz-NEXT: Early CSE
 ; CHECK-Osz-NEXT: Simplify the CFG
-; CHECK-Osz-NEXT: Dominator Tree Construction
 ; CHECK-Osz-NEXT: Basic Alias Analysis (stateless AA impl)
 ; CHECK-Osz-NEXT: Function Alias Analysis Results
 ; CHECK-Osz-NEXT: Natural Loop Information
Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -13,8 +13,8 @@
 ; CHECK-EXT:  Good Bye World Pass
 ; CHECK-NOEXT-NOT:  Good Bye World Pass
 ; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
-; CHECK-NEXT: Simplify the CFG
 ; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Simplify the CFG
 ; CHECK-NEXT: SROA
 ; CHECK-NEXT: Early CSE
 ; CHECK-NEXT: Lower 'expect' Intrinsics
@@ -75,7 +75,6 @@
 ; CHECK-NEXT: Jump Threading
 ; CHECK-NEXT: Value Propagation
 ; CHECK-NEXT: Simplify the CFG
-; CHECK-NEXT: Dominator Tree Construction
 ; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT: Function Alias Analysis Results
 ; CHECK-NEXT: Natural Loop Information
@@ -87,7 +86,6 @@
 ; CHECK-NEXT: Tail Call Elimination
 ; CHECK-NEXT: Simplify the CFG
 ; CHECK-NEXT: Reassociate expressions
-; CHE

[PATCH] D94829: [NFC] Add -std=c11 to attr-availability.c

2021-01-15 Thread Justice Adams via Phabricator via cfe-commits
justice_adams created this revision.
justice_adams added reviewers: nigelp-xmos, aaron.ballman.
justice_adams added a project: clang.
justice_adams requested review of this revision.

This test will fail with any toolchains that don't default to C11.

Adding this switch to the clang invocation in the test fixes the issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94829

Files:
  clang/test/Parser/attr-availability.c


Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
 
 #if !__has_feature(attribute_availability)
 #  error 'availability' attribute is not available


Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
 
 #if !__has_feature(attribute_availability)
 #  error 'availability' attribute is not available
___
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-15 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.

Couple of optional pieces.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3338-3340
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = Loc.isValid() ? getOrCreateFile(Loc) : nullptr;
+  const unsigned Line = getLineNumber(Loc);

Might be more readable, even though it provides the same behavior, with 
something like:
```
  llvm::DIFile *DefUnit = nullptr;
  unsigned Line = 0;
  if (SourceLocation Loc = RD->getLocation(); Loc.isValid()) {
DefUnit = getOrCreateFile(Loc);
Line = getLineNumber(Loc);
  }
```



Comment at: clang/test/CodeGen/X86/x86_64-arguments.c:550
+/// The synthesized __va_list_tag does not have file/line fields.
+// CHECK: = distinct !DICompositeType(tag: DW_TAG_structure_type, name: 
"__va_list_tag", size:

Perhaps CHECK-NOT would be a more explicit way to do that rather than relying 
on field ordering/the fact that 'size' comes after the file/line fields.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94735

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


[PATCH] D94829: [NFC] Add -std=c11 to attr-availability.c

2021-01-15 Thread Douglas Yung via Phabricator via cfe-commits
dyung accepted this revision.
dyung 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/D94829/new/

https://reviews.llvm.org/D94829

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


[PATCH] D93776: [clang-format] Add StatementAttributeLikeMacros option

2021-01-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

*ping*
And I don't have a better name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93776

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


  1   2   >