[PATCH] D84186: [clang][cli] Convert Analyzer option string based options to new option parsing system

2020-12-17 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 rGcaeb56503ec8: [clang][cli] Convert Analyzer option string 
based options to new option parsing… (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84186

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

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -161,6 +161,12 @@
   code Denormalizer = "denormalizeString";
 }
 
+class MarshallingInfoStringInt
+  : MarshallingInfo {
+  code Normalizer = "normalizeStringIntegral<"#type#">";
+  code Denormalizer = "denormalizeString";
+}
+
 class MarshallingInfoFlag
   : MarshallingInfo {
   code Normalizer = "normalizeSimpleFlag";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -93,6 +93,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -282,12 +283,38 @@
 
 static void denormalizeString(SmallVectorImpl ,
   const char *Spelling,
-  CompilerInvocation::StringAllocator SA,
-  unsigned TableIndex, const std::string ) {
+  CompilerInvocation::StringAllocator SA, unsigned,
+  Twine Value) {
   Args.push_back(Spelling);
   Args.push_back(SA(Value));
 }
 
+template ::value &&
+   std::is_constructible::value,
+   bool> = false>
+static void denormalizeString(SmallVectorImpl ,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator SA,
+  unsigned TableIndex, T Value) {
+  denormalizeString(Args, Spelling, SA, TableIndex, Twine(Value));
+}
+
+template 
+static Optional normalizeStringIntegral(OptSpecifier Opt, int,
+   const ArgList ,
+   DiagnosticsEngine ) {
+  auto *Arg = Args.getLastArg(Opt);
+  if (!Arg)
+return None;
+  IntTy Res;
+  if (StringRef(Arg->getValue()).getAsInteger(0, Res)) {
+Diags.Report(diag::err_drv_invalid_int_value)
+<< Arg->getAsString(Args) << Arg->getValue();
+  }
+  return Res;
+}
+
 static Optional normalizeTriple(OptSpecifier Opt, int TableIndex,
  const ArgList ,
  DiagnosticsEngine ) {
@@ -522,14 +549,6 @@
 .Case("false", false)
 .Default(false);
 
-  Opts.AnalyzeSpecificFunction =
-  std::string(Args.getLastArgValue(OPT_analyze_function));
-  Opts.maxBlockVisitOnPath =
-  getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
-  Opts.InlineMaxStackDepth =
-  getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
- Opts.InlineMaxStackDepth, Diags);
-
   Opts.CheckersAndPackages.clear();
   for (const Arg *A :
Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -259,8 +259,7 @@
   bool AnalyzerWerror : 1;
 
   /// The inlining stack depth limit.
-  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
-  unsigned InlineMaxStackDepth = 5;
+  unsigned InlineMaxStackDepth;
 
   /// The mode of function selection used during inlining.
   AnalysisInliningMode InliningMode = NoRedundancy;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4110,7 +4110,8 @@
   HelpText<"Emit verbose output about the analyzer's progress">,
   MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
 def analyze_function : Separate<["-"], "analyze-function">,
-  HelpText<"Run analysis on specific function (for C++ include parameters in name)">;
+  HelpText<"Run analysis on specific function (for C++ include parameters in name)">,
+  MarshallingInfoString<"AnalyzerOpts->AnalyzeSpecificFunction">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
   HelpText<"Only show error-related paths in the analysis 

[clang] caeb565 - [clang][cli] Convert Analyzer option string based options to new option parsing system

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

Author: Jan Svoboda
Date: 2020-12-18T08:56:06+01:00
New Revision: caeb56503ec897c7244cff0657c11e87d2644f82

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

LOG: [clang][cli] Convert Analyzer option string based options to new option 
parsing system

Depends on D84185

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ca9615e2e769..9987143009d3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4110,7 +4110,8 @@ def analyzer_display_progress : Flag<["-"], 
"analyzer-display-progress">,
   HelpText<"Emit verbose output about the analyzer's progress">,
   MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
 def analyze_function : Separate<["-"], "analyze-function">,
-  HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">;
+  HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">,
+  MarshallingInfoString<"AnalyzerOpts->AnalyzeSpecificFunction">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, 
Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
   HelpText<"Only show error-related paths in the analysis graph">,
@@ -4124,7 +4125,9 @@ def analyzer_dump_egraph : Separate<["-"], 
"analyzer-dump-egraph">,
 def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, 
Alias;
 
 def analyzer_inline_max_stack_depth : Separate<["-"], 
"analyzer-inline-max-stack-depth">,
-  HelpText<"Bound on stack depth while inlining (4 by default)">;
+  HelpText<"Bound on stack depth while inlining (4 by default)">,
+  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
+  MarshallingInfoStringInt<"AnalyzerOpts->InlineMaxStackDepth", "5">;
 def analyzer_inline_max_stack_depth_EQ : Joined<["-"], 
"analyzer-inline-max-stack-depth=">,
   Alias;
 
@@ -4137,7 +4140,8 @@ def analyzer_disable_retry_exhausted : Flag<["-"], 
"analyzer-disable-retry-exhau
   MarshallingInfoFlag<"AnalyzerOpts->NoRetryExhausted">;
 
 def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">,
-  HelpText<"The maximum number of times the analyzer will go through a loop">;
+  HelpText<"The maximum number of times the analyzer will go through a loop">,
+  MarshallingInfoStringInt<"AnalyzerOpts->maxBlockVisitOnPath", "4">;
 def analyzer_stats : Flag<["-"], "analyzer-stats">,
   HelpText<"Print internal analyzer statistics.">,
   MarshallingInfoFlag<"AnalyzerOpts->PrintStats">;

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h 
b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index e1093772e02c..ccf35e0a81ec 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -259,8 +259,7 @@ class AnalyzerOptions : public 
RefCountedBase {
   bool AnalyzerWerror : 1;
 
   /// The inlining stack depth limit.
-  // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
-  unsigned InlineMaxStackDepth = 5;
+  unsigned InlineMaxStackDepth;
 
   /// The mode of function selection used during inlining.
   AnalysisInliningMode InliningMode = NoRedundancy;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 5fbafa3b2583..d2b590f08507 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -93,6 +93,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -282,12 +283,38 @@ static Optional normalizeString(OptSpecifier 
Opt, int TableIndex,
 
 static void denormalizeString(SmallVectorImpl ,
   const char *Spelling,
-  CompilerInvocation::StringAllocator SA,
-  unsigned TableIndex, const std::string ) {
+  CompilerInvocation::StringAllocator SA, unsigned,
+  Twine Value) {
   Args.push_back(Spelling);
   Args.push_back(SA(Value));
 }
 
+template ::value &&
+   std::is_constructible::value,
+   bool> = false>
+static void denormalizeString(SmallVectorImpl ,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator SA,
+  unsigned TableIndex, T Value) {
+  denormalizeString(Args, Spelling, SA, 

[clang] 8c1f2d1 - Following up on PR48517, fix handling of template arguments that refer

2020-12-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-17T23:54:37-08:00
New Revision: 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e

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

LOG: Following up on PR48517, fix handling of template arguments that refer
to dependent declarations.

Treat an id-expression that names a local variable in a templated
function as being instantiation-dependent.

This addresses a language defect whereby a reference to a dependent
declaration can be formed without any construct being value-dependent.
Fixing that through value-dependence turns out to be problematic, so
instead this patch takes the approach (proposed on the core reflector)
of allowing the use of pointers or references to (but not values of)
dependent declarations inside value-dependent expressions, and instead
treating template arguments as dependent if they evaluate to a constant
involving such dependent declarations.

This ends up affecting a bunch of OpenMP tests, due to OpenMP
imprecisely handling instantiation-dependent constructs, bailing out
early instead of processing dependent constructs to the extent possible
when handling the template.

Added: 
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp

Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/OpenMP/distribute_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_collapse_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp
clang/test/OpenMP/target_simd_collapse_messages.cpp
clang/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_update_from_messages.cpp
clang/test/OpenMP/target_update_to_messages.cpp
clang/test/OpenMP/task_messages.cpp
clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_simd_dist_schedule_messages.cpp
clang/test/SemaCXX/warn-unused-lambda-capture.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp



diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index c8d87ec48a3f..e1c3b6944142 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -578,12 +578,12 @@ class Expr : public ValueStmt {
   struct EvalStatus {
 /// Whether the evaluated expression has side effects.
 /// For example, (f() && 0) can be folded, but it still has side effects.
-bool HasSideEffects;
+bool HasSideEffects = false;
 
 /// Whether the evaluation hit undefined behavior.
 /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined 
behavior.
 /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
-bool HasUndefinedBehavior;
+bool HasUndefinedBehavior = false;
 
 /// Diag - If this is non-null, it will be filled in with a stack of notes
 /// indicating why evaluation failed (or why it failed to produce a 
constant
@@ -592,10 +592,7 @@ class Expr : public ValueStmt {
 /// foldable. If the expression is foldable, but not a constant expression,
 /// the notes will describes why it isn't a constant expression. If the
 /// expression *is* a constant expression, no notes will be produced.
-SmallVectorImpl *Diag;
-
-EvalStatus()
-: HasSideEffects(false), HasUndefinedBehavior(false), Diag(nullptr) {}
+SmallVectorImpl *Diag = nullptr;
 
 // hasSideEffects - Return true if the evaluated expression has
 // side effects.
@@ -606,8 +603,11 @@ class Expr : public ValueStmt {
 
   /// EvalResult is a struct with detailed info about an evaluated expression.
   struct EvalResult : EvalStatus {
-/// Val - This is the value the expression can be folded to.
+/// This is the value the expression can 

[clang] 4b38885 - Ensure that we transform types into the current instantiation even if

2020-12-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 4b388859f527f822a27bcee409242c421f199f1d

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

LOG: Ensure that we transform types into the current instantiation even if
they're only instantiation-dependent.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaTemplate/class-template-decl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2b6eb397b82b..949df53b40e0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5491,7 +5491,7 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema 
, Declarator ,
 // Grab the type from the parser.
 TypeSourceInfo *TSI = nullptr;
 QualType T = S.GetTypeFromParser(DS.getRepAsType(), );
-if (T.isNull() || !T->isDependentType()) break;
+if (T.isNull() || !T->isInstantiationDependentType()) break;
 
 // Make sure there's a type source info.  This isn't really much
 // of a waste; most dependent types should have type source info

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index dd361ec91abe..64259767d98a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -10730,7 +10730,7 @@ namespace {
 /// For the purposes of type reconstruction, a type has already been
 /// transformed if it is NULL or if it is not dependent.
 bool AlreadyTransformed(QualType T) {
-  return T.isNull() || !T->isDependentType();
+  return T.isNull() || !T->isInstantiationDependentType();
 }
 
 /// Returns the location of the entity whose type is being
@@ -10783,7 +10783,7 @@ namespace {
 TypeSourceInfo *Sema::RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
 SourceLocation Loc,
 DeclarationName Name) {
-  if (!T || !T->getType()->isDependentType())
+  if (!T || !T->getType()->isInstantiationDependentType())
 return T;
 
   CurrentInstantiationRebuilder Rebuilder(*this, Loc, Name);

diff  --git a/clang/test/SemaTemplate/class-template-decl.cpp 
b/clang/test/SemaTemplate/class-template-decl.cpp
index 453218ac3b40..c054a6a8d82f 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -167,3 +167,17 @@ namespace abstract_dependent_class {
   };
   template A *A::clone() { return new A; } // 
expected-error {{abstract class type 'A'}}
 }
+
+namespace qualified_out_of_line {
+  struct rbnode {};
+  template struct pair {};
+  template struct rbtree {
+using base = rbnode;
+pair f();
+  };
+  template
+  pair::base, typename rbtree::base>
+  rbtree::f() {
+return {};
+  }
+}



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


[clang] 71886c5 - Where possible, don't try to ask whether a template argument is

2020-12-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 71886c56f336667969be4cac0b6a17a3f75b7555

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

LOG: Where possible, don't try to ask whether a template argument is
dependent until it's been converted to match its parameter.

The type of a non-type template parameter can in general affect whether
the template argument is dependent.

Note that this is not always possible. For template arguments that name
static local variables in templates, the type of the template parameter
affects whether the argument is dependent, so the query is imprecise
until we know the parameter type. For example, in:

template void f() {
  static const int n = 5;
  typename T::template X x;
}

... we don't know whether 'n' is dependent until we know whether the
corresponding template parameter is of type 'int' or 'const int&'.

Added: 
clang/test/SemaTemplate/instantiate-static-local.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a3059b83c1be..21c8bf79152e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5112,11 +5112,24 @@ class alignas(8) TemplateSpecializationType
 
 public:
   /// Determine whether any of the given template arguments are dependent.
-  static bool anyDependentTemplateArguments(ArrayRef Args,
-bool );
-
-  static bool anyDependentTemplateArguments(const TemplateArgumentListInfo &,
-bool );
+  ///
+  /// The converted arguments should be supplied when known; whether an
+  /// argument is dependent can depend on the conversions performed on it
+  /// (for example, a 'const int' passed as a template argument might be
+  /// dependent if the parameter is a reference but non-dependent if the
+  /// parameter is an int).
+  ///
+  /// Note that the \p Args parameter is unused: this is intentional, to remind
+  /// the caller that they need to pass in the converted arguments, not the
+  /// specified arguments.
+  static bool
+  anyDependentTemplateArguments(ArrayRef Args,
+ArrayRef Converted);
+  static bool
+  anyDependentTemplateArguments(const TemplateArgumentListInfo &,
+ArrayRef Converted);
+  static bool anyInstantiationDependentTemplateArguments(
+  ArrayRef Args);
 
   /// True if this template specialization type matches a current
   /// instantiation in the context in which it is found.

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e5811dbc44c5..5dec80be9ccb 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3590,24 +3590,24 @@ void 
SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID ,
 ID.AddPointer(P.getAsType().getAsOpaquePtr());
 }
 
-bool TemplateSpecializationType::
-anyDependentTemplateArguments(const TemplateArgumentListInfo ,
-  bool ) {
-  return anyDependentTemplateArguments(Args.arguments(),
-   InstantiationDependent);
+bool TemplateSpecializationType::anyDependentTemplateArguments(
+const TemplateArgumentListInfo , ArrayRef 
Converted) {
+  return anyDependentTemplateArguments(Args.arguments(), Converted);
 }
 
-bool TemplateSpecializationType::
-anyDependentTemplateArguments(ArrayRef Args,
-  bool ) {
-  for (const TemplateArgumentLoc  : Args) {
-if (ArgLoc.getArgument().isDependent()) {
-  InstantiationDependent = true;
+bool TemplateSpecializationType::anyDependentTemplateArguments(
+ArrayRef Args, ArrayRef Converted) {
+  for (const TemplateArgument  : Converted)
+if (Arg.isDependent())
   return true;
-}
+  return false;
+}
 
+bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
+  ArrayRef Args) {
+  for (const TemplateArgumentLoc  : Args) {
 if (ArgLoc.getArgument().isInstantiationDependent())
-  InstantiationDependent = true;
+  return true;
   }
   return false;
 }

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index ddd95faebe99..1ff7b1cdd515 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1053,25 +1053,20 @@ ReturnTypeRequirement(TemplateParameterList *TPL) :
   auto *Constraint =
   cast_or_null(
   TC->getImmediatelyDeclaredConstraint());
-  bool Dependent = false;
-  if (Constraint->getTemplateArgsAsWritten()) {
-for (auto  :
- 

[clang] 638867a - DR2064: decltype(E) is only a dependent type if E is type-dependent, not

2020-12-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 638867afd4bce4a2c56dea041299428af3727d61

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

LOG: DR2064: decltype(E) is only a dependent type if E is type-dependent, not
if E is merely instantiation-dependent.

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Type.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/Sema/invalid-bitwidth-expr.mm
clang/test/SemaCXX/invalid-template-base-specifier.cpp
clang/test/SemaTemplate/dependent-expr.cpp
clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index ca96b65574bd..8c47047a7526 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -255,6 +255,12 @@ inline TypeDependence 
toTypeDependence(TemplateNameDependence D) {
 inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
   return Dependence(D).type();
 }
+/// Compute the dependence of a type that depends on the type of an expression,
+/// given the dependence of that expression and of its type.
+inline TypeDependence typeToTypeDependence(ExprDependence ED, TypeDependence 
TD) {
+  return Dependence(ED & ~ExprDependence::Value).type() |
+ (TD & TypeDependence::VariablyModified);
+}
 
 inline NestedNameSpecifierDependence
 toNestedNameSpecifierDependendence(TypeDependence D) {

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 44545f00b146..0190573fe36e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5383,10 +5383,10 @@ QualType ASTContext::getDecltypeType(Expr *e, QualType 
UnderlyingType) const {
   DecltypeType *dt;
 
   // C++11 [temp.type]p2:
-  //   If an expression e involves a template parameter, decltype(e) denotes a
-  //   unique dependent type. Two such decltype-specifiers refer to the same
-  //   type only if their expressions are equivalent (14.5.6.1).
-  if (e->isInstantiationDependent()) {
+  //   If an expression e is type-dependent, decltype(e) denotes a unique
+  //   dependent type. Two such decltype-specifiers refer to the same type only
+  //   if their expressions are equivalent (14.5.6.1).
+  if (e->isTypeDependent()) {
 llvm::FoldingSetNodeID ID;
 DependentDecltypeType::Profile(ID, *this, e);
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 6c8d5687c64a..01deb598a078 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2582,6 +2582,11 @@ void CXXNameMangler::mangleType(QualType T) {
   // instantation-dependent qualifiers. See
   // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
 
+  // Don't desugar instantiation-dependent decltype / typeof types. We need
+  // to mangle the expression as written.
+  if (isa(T))
+break;
+
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index af39b80ef9e4..e5811dbc44c5 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -125,8 +125,7 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType 
can,
 //   template int arr[] = {N...};
 : Type(tc, can,
et->getDependence() |
-   (sz ? toTypeDependence(
- turnValueToTypeDependence(sz->getDependence()))
+   (sz ? toTypeDependence(sz->getDependence())
: TypeDependence::None) |
(tc == VariableArray ? TypeDependence::VariablyModified
 : TypeDependence::None) |
@@ -3396,9 +3395,8 @@ QualType MacroQualifiedType::getModifiedType() const {
 
 TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
 : Type(TypeOfExpr, can,
-   toTypeDependence(E->getDependence()) |
-   (E->getType()->getDependence() &
-TypeDependence::VariablyModified)),
+   typeToTypeDependence(E->getDependence(),
+E->getType()->getDependence())),
   TOExpr(E) {}
 
 bool TypeOfExprType::isSugared() const {
@@ -3418,18 +3416,12 @@ void 
DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID ,
 }
 
 DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
-// C++11 [temp.type]p2: "If an expression e involves a template parameter,
-// decltype(e) denotes a unique dependent type." Hence a decltype type is
-// type-dependent even if its expression is 

[PATCH] D93490: [clang-format] PR48539 ReflowComments breaks Qt translation comments

2020-12-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93490

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


[clang] d3bf0bb - PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of

2020-12-17 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-12-17T21:31:23-08:00
New Revision: d3bf0bb18952d830fe6df6f791a64552b271000b

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

LOG: PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of
the nested-name-specifier when determining whether a qualified type is
instantiation-dependent.

Added: 
clang/test/SemaTemplate/instantiation-dependence.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/partial-spec-instantiate.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 945ea7a600c0..a3059b83c1be 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5398,7 +5398,9 @@ class ElaboratedType final
   ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
  QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
   : TypeWithKeyword(Keyword, Elaborated, CanonType,
-NamedType->getDependence()),
+NamedType->getDependence() |
+(NNS ? toTypeDependence(NNS->getDependence())
+ : TypeDependence::None)),
 NNS(NNS), NamedType(NamedType) {
 ElaboratedTypeBits.HasOwnedTagDecl = false;
 if (OwnedTagDecl) {

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 73c8f17a5d36..6c8d5687c64a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2578,6 +2578,10 @@ void CXXNameMangler::mangleType(QualType T) {
 if (!TST->isTypeAlias())
   break;
 
+  // FIXME: We presumably shouldn't strip off ElaboratedTypes with
+  // instantation-dependent qualifiers. See
+  // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
+
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)

diff  --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index 478a0d7d00dd..8bfa29a8b667 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -239,6 +239,20 @@ namespace dr1550 { // dr1550: yes
   }
 }
 
+namespace dr1558 { // dr1558: 12
+#if __cplusplus >= 201103L
+  template using first_of = T;
+  template first_of f(int); // expected-note 
{{'int' cannot be used prior to '::'}}
+  template void f(...) = delete; // expected-note {{deleted}}
+
+  struct X { typedef void type; };
+  void test() {
+f(0);
+f(0); // expected-error {{deleted}}
+  }
+#endif
+}
+
 namespace dr1560 { // dr1560: 3.5
   void f(bool b, int n) {
 (b ? throw 0 : n) = (b ? n : throw 0) = 0;

diff  --git a/clang/test/CodeGenCXX/mangle-template.cpp 
b/clang/test/CodeGenCXX/mangle-template.cpp
index 9b5220572c2e..40688de7e12e 100644
--- a/clang/test/CodeGenCXX/mangle-template.cpp
+++ b/clang/test/CodeGenCXX/mangle-template.cpp
@@ -342,3 +342,23 @@ namespace fixed_size_parameter_pack {
   template void f(A::B<0, Ns...>);
   void g() { f<1, 2>({}); }
 }
+
+namespace type_qualifier {
+  template using int_t = int;
+  template void f(decltype(int_t() + 1)) {}
+  // FIXME: This mangling doesn't work: we need to mangle the
+  // instantiation-dependent 'int_t' operand.
+  // CHECK: @_ZN14type_qualifier1fIPiEEvDTplcvi_ELi1EE
+  template void f(int);
+
+  // Note that this template has 
diff erent constraints but would mangle the
+  // same:
+  //template void f(decltype(int_t() + 1)) {}
+
+  struct impl { using type = void; };
+  template using alias = impl;
+  template void g(decltype(alias::type(), 1)) {}
+  // FIXME: Similarly we need to mangle the `T*` in here.
+  // CHECK: @_ZN14type_qualifier1gIPiEEvDTcmcvv_ELi1EE
+  template void g(int);
+}

diff  --git a/clang/test/SemaTemplate/instantiation-dependence.cpp 
b/clang/test/SemaTemplate/instantiation-dependence.cpp
new file mode 100644
index ..75eb510cb68d
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-dependence.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+// Ensure we substitute into instantiation-dependent but non-dependent
+// constructs. The poster-child for this is...
+template using void_t = void;
+
+namespace PR24076 {
+  template T declval();
+  struct s {};
+
+  template() + 1)>>
+void foo(T) {} // expected-note {{invalid operands to binary expression}}
+
+  void f() {
+foo(s{}); // expected-error {{no matching function}}
+  }
+
+  template() + 1)>> // expected-error 
{{invalid operands to binary expression}}
+  struct bar {};
+
+  bar bar; // expected-note {{in instantiation of}}

[PATCH] D72235: [clang-tidy] new altera unroll loops check

2020-12-17 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 312676.
ffrankies added a comment.

- removed unnecessary comment


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,359 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c
+
+// Inner loops should be unrolled
+__kernel void nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+for (int j = 0; j < 2000; ++j) { 
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[0] += i + j;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[1] += i + j;
+j++;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0; 
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[2] += i + j;
+j++;
+} while (j < 2000);
+}
+
+int i = 0;
+while (i < 1000) {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[3] += i + j;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[4] += i + j;
+j++;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[5] += i + j;
+j++;
+} while (j < 2000);
+i++;
+}
+
+i = 0;
+do {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[6] += i + j;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[7] += i + j;
+j++;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[8] += i + j;
+j++;
+} while (j < 2000);
+i++;
+} while (i < 1000);
+
+for (int i = 0; i < 100; ++i) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+printf("Hello");
+}
+
+i = 0;
+while (i < 100) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+i++;
+}
+
+i = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+i++;
+} while (i < 100);
+}
+
+// These loops are all correctly unrolled
+__kernel void unrolled_nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+#pragma unroll
+for (int j = 0; j < 50; ++j) {
+A[0] += i + j;
+}
+}
+
+for (int i = 0; i < 

[PATCH] D72235: [clang-tidy] new altera unroll loops check

2020-12-17 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 312675.
ffrankies marked 9 inline comments as done.
ffrankies added a comment.

- Rebased with master branch
- Diagnostics are re-worded so they're not complete sentences

Check ready for further review


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,359 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c
+
+// Inner loops should be unrolled
+__kernel void nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+for (int j = 0; j < 2000; ++j) { 
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[0] += i + j;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[1] += i + j;
+j++;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0; 
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[2] += i + j;
+j++;
+} while (j < 2000);
+}
+
+int i = 0;
+while (i < 1000) {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[3] += i + j;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[4] += i + j;
+j++;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[5] += i + j;
+j++;
+} while (j < 2000);
+i++;
+}
+
+i = 0;
+do {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[6] += i + j;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[7] += i + j;
+j++;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[8] += i + j;
+j++;
+} while (j < 2000);
+i++;
+} while (i < 1000);
+
+for (int i = 0; i < 100; ++i) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+printf("Hello");
+}
+
+i = 0;
+while (i < 100) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+i++;
+}
+
+i = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+i++;
+} while (i < 100);
+}
+
+// These loops are all correctly unrolled
+__kernel void unrolled_nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+

[PATCH] D73418: [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

2020-12-17 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D73418#2461943 , @ayermolo wrote:

> @tejohnson I was wondering where does this @anon.{{.*}} gets set, or in 
> general where can I find more information about it.
>
> When I step through the code in emitVTableTypeMetadata, it's still.
>
> @0 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast 
> (%rtti.CompleteObjectLocator* @"??_R4A@?A0x3E47408C@@6B@" to i8*), i8* 
> bitcast (i32 (%"struct.(anonymous namespace)::A"*)* 
> @"?f@A@?A0x3E47408C@@UEAAHXZ" to i8*)] }, comdat($"??_7A@?A0x3E47408C@@6B@")
>
> Thanks

It would be later, in LLVM, see nameUnamedGlobals in 
llvm/lib/Transforms/Utils/NameAnonGlobals.cpp. It is called towards the end the 
compile when generating bitcode for LTO, as we need everything named in order 
to generate summary information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73418

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


[PATCH] D93224: [RFC][analyzer] Use the MacroExpansionContext for macro expansions in plists

2020-12-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:20-21
 #include "clang/Basic/Version.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Lex/Preprocessor.h"

Will these two includes be ultimately removed? Like, even in the CTU case?



Comment at: 
clang/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:148
  nameSET_PTR_VAR_TO_NULL
- expansionptr = 0
+ expansionptr =0
 

steakhal wrote:
> xazax.hun wrote:
> > martong wrote:
> > > martong wrote:
> > > > I wonder how much added value do we have with these huge and clumsy 
> > > > plist files... We already have the concise unittests, which are quite 
> > > > self explanatory. I'd just simply delete these plist files.
> > > Perhaps in the test cpp file we should just execute a FileCheck for the 
> > > expansions. We are totally not interested to check the whole contents of 
> > > the plist, we are interested only to see if there were expansions.
> > We do need some plist tests to ensure that the correct plist format is 
> > emitted. How much of those do we need might be up for debate.
> It's certainly a pain to keep all the locations in sync with the code.
I'm absolutely in favor of not testing the //entire// plist files whenever 
possible. Just keep some minimal context available so that to not accidentally 
match the wrong test. Yes we obviously need some tests for the entire plist 
files but we already have a lot of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93224

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


[PATCH] D92493: [IR] Add hot to function attributes and use hot/cold attribute in function section prefix/suffix

2020-12-17 Thread Rong Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3733463dbb58: [IR][PGO] Add hot func attribute and use 
hot/cold attribute in func section (authored by xur).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D92493?vs=312273=312664#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92493

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attributes.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
  llvm/test/MC/AsmParser/function_hot_attr.ll

Index: llvm/test/MC/AsmParser/function_hot_attr.ll
===
--- /dev/null
+++ llvm/test/MC/AsmParser/function_hot_attr.ll
@@ -0,0 +1,13 @@
+; Test hot function attribute
+; RUN: llc < %s | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: hot noinline norecurse nounwind readnone uwtable
+define dso_local i32 @hot4() #0 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.hot.,"ax",@progbits
+; CHECK: .globl  hot4
+
+attributes #0 = { hot noinline norecurse nounwind readnone uwtable }
Index: llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
@@ -0,0 +1,101 @@
+; Test hot or unlikely section postfix based on profile and user annotation.
+; RUN: llc < %s | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: inlinehint norecurse nounwind readnone uwtable
+define dso_local i32 @hot1() #0 !prof !31 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.hot.,"ax",@progbits
+; CHECK: .globl  hot1
+
+; Function Attrs: cold norecurse nounwind readnone uwtable
+define dso_local i32 @cold1() #1 !prof !32 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.unlikely.,"ax",@progbits
+; CHECK: .globl  cold1
+
+; Function Attrs: cold inlinehint noinline norecurse nounwind optsize readnone uwtable
+define dso_local i32 @hot2() #2 !prof !31 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.hot.,"ax",@progbits
+; CHECK: .globl  hot2
+
+define dso_local i32 @normal() {
+entry:
+  ret i32 1
+}
+; CHECK: text
+; CHECK: .globl  normal
+
+; Function Attrs: hot noinline norecurse nounwind readnone uwtable
+define dso_local i32 @hot3() #3 !prof !32 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.hot.,"ax",@progbits
+; CHECK: .globl  hot3
+
+; Function Attrs: cold noinline norecurse nounwind optsize readnone uwtable
+define dso_local i32 @cold2() #4 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.unlikely.,"ax",@progbits
+; CHECK: .globl  cold2
+
+; Function Attrs: hot noinline norecurse nounwind readnone uwtable
+define dso_local i32 @hot4() #3 {
+entry:
+  ret i32 1
+}
+; CHECK: .section.text.hot.,"ax",@progbits
+; CHECK: .globl  hot4
+
+attributes #0 = { inlinehint norecurse nounwind readnone uwtable }
+attributes #1 = { cold norecurse nounwind readnone uwtable }
+attributes #2 = { cold inlinehint noinline norecurse nounwind optsize readnone uwtable }
+attributes #3 = { hot noinline norecurse nounwind readnone uwtable }
+attributes #4 = { cold noinline norecurse nounwind optsize readnone uwtable }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!30}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"ProfileSummary", !2}
+!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}
+!3 = !{!"ProfileFormat", !"InstrProf"}
+!4 = !{!"TotalCount", i64 402020}
+!5 = !{!"MaxCount", i64 20}
+!6 = !{!"MaxInternalCount", i64 2000}
+!7 = !{!"MaxFunctionCount", i64 20}
+!8 = !{!"NumCounts", i64 7}
+!9 = !{!"NumFunctions", i64 5}
+!10 = !{!"IsPartialProfile", i64 0}
+!11 = !{!"PartialProfileRatio", double 0.00e+00}
+!12 = !{!"DetailedSummary", !13}
+!13 = !{!14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29}
+!14 = !{i32 1, i64 20, i32 1}
+!15 = !{i32 10, i64 20, i32 1}
+!16 = !{i32 20, i64 20, i32 1}
+!17 = !{i32 30, i64 20, i32 1}
+!18 = !{i32 40, i64 20, i32 1}
+!19 = !{i32 50, i64 10, i32 3}
+!20 = !{i32 60, i64 10, i32 3}
+!21 = !{i32 70, i64 10, i32 3}
+!22 = !{i32 80, i64 10, i32 3}
+!23 = !{i32 90, i64 10, i32 3}
+!24 = !{i32 95, i64 10, i32 3}
+!25 = !{i32 99, i64 10, i32 3}
+!26 = !{i32 999000, i64 2000, 

[clang] 3733463 - [IR][PGO] Add hot func attribute and use hot/cold attribute in func section

2020-12-17 Thread Rong Xu via cfe-commits

Author: Rong Xu
Date: 2020-12-17T18:41:12-08:00
New Revision: 3733463dbb58a29892be3872bd32f93cb9af492c

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

LOG: [IR][PGO] Add hot func attribute and use hot/cold attribute in func section

Clang FE currently has hot/cold function attribute. But we only have
cold function attribute in LLVM IR.

This patch adds support of hot function attribute to LLVM IR.  This
attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and
isFunctionColdInCallGraph).

This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
is true, this function will be marked as hot. Otherwise,
(2) If the user annotates a function as cold or
isFunctionColdInCallGraph is true, this function will be marked as
cold.

The changes are:
(1) user annotated function attribute will used in setting function
section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.

The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover
all the hot functions.

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

Added: 
llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
llvm/test/MC/AsmParser/function_hot_attr.ll

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attributes.c
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Bitcode/attributes.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index bfc7b8e74d8f..e28736bd3d2f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1944,6 +1944,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Cold);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::Hot);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7dd343dbcc16..93916e85a461 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1744,7 +1744,8 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
 B.addAttribute(llvm::Attribute::OptimizeForSize);
   B.addAttribute(llvm::Attribute::Cold);
 }
-
+if (D->hasAttr())
+  B.addAttribute(llvm::Attribute::Hot);
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);
   }

diff  --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index 0c1455d3c612..5ef176c138af 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -63,6 +63,13 @@ void t72() { t71(); }
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
 
+// CHECK: define void @t82() [[HOTDEF:#[0-9]+]] {
+void t81(void) __attribute__((hot));
+void t82() __attribute__((hot));
+void t82() { t81(); }
+// CHECK: call void @t81() [[HOTSITE:#[0-9]+]]
+// CHECK: declare void @t81() [[HOTDECL:#[0-9]+]]
+
 // CHECK: define void @t10() [[NUW]] section "xSECT" {
 void t10(void) __attribute__((section("xSECT")));
 void t10(void) {}
@@ -72,6 +79,9 @@ void __attribute__((section("xSECT"))) t11(void) {}
 // CHECK: define i32 @t19() [[NUW]] {
 extern int t19(void) __attribute__((weak_import));
 int t19(void) {
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
   return 10;
 }
 
@@ -111,6 +121,9 @@ void t24(f_t f1) {
 // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
 // CHECK: attributes [[COLDDEF]] = { cold {{.*}}}
 // CHECK: attributes [[COLDDECL]] = { cold {{.*}}}
+// CHECK: attributes [[HOTDEF]] = { hot {{.*}}}
+// CHECK: attributes [[HOTDECL]] = { hot {{.*}}}
 // CHECK: attributes 

[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-12-17 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added a comment.

Hi, Is there any more concerns, feedbacks or suggestions?
thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D73418: [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

2020-12-17 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo added a comment.

@tejohnson I was wondering where does this @anon.{{.*}} gets set, or in general 
where can I find more information about it.

When I step through the code in emitVTableTypeMetadata, it's still.

@0 = private unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast 
(%rtti.CompleteObjectLocator* @"??_R4A@?A0x3E47408C@@6B@" to i8*), i8* bitcast 
(i32 (%"struct.(anonymous namespace)::A"*)* @"?f@A@?A0x3E47408C@@UEAAHXZ" to 
i8*)] }, comdat($"??_7A@?A0x3E47408C@@6B@")

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73418

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


[PATCH] D72241: [clang-tidy] new altera single work item barrier check

2020-12-17 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 312658.
ffrankies marked an inline comment as done.
ffrankies added a comment.

@aaron.ballman hmm, that is strange. I've rebased the patch and updated the 
diff, let me know if this one doesn't work either or there's something else 
you'd like me to try. Thanks! For what it's worth it's building just fine and 
passing the clang-tools tests on my end.


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

https://reviews.llvm.org/D72241

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
  clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-single-work-item-barrier.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
@@ -0,0 +1,300 @@
+// RUN: %check_clang_tidy -check-suffix=OLDCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLOLDAOC
+// RUN: %check_clang_tidy -check-suffix=NEWCLOLDAOC %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLOLDAOC
+// RUN: %check_clang_tidy -check-suffix=OLDCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLDCLNEWAOC
+// RUN: %check_clang_tidy -check-suffix=NEWCLNEWAOC %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEWCLNEWAOC
+
+#ifdef OLDCLOLDAOC  // OpenCL 1.2 Altera Offline Compiler < 17.1
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  // CHECK-MESSAGES-OLDCLOLDAOC: :[[@LINE-1]]:15: warning: kernel function 'error_barrier_no_id' does not call 'get_global_id' or 'get_local_id' and will be treated as a single work-item [altera-single-work-item-barrier]
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-OLDCLOLDAOC: :[[@LINE-1]]:3: note: barrier call is in a single work-item and may error out
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void __kernel success_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+
+void success_nokernel_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void success_nokernel_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void success_nokernel_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void success_nokernel_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+#endif
+
+#ifdef NEWCLOLDAOC  // OpenCL 2.0 Altera Offline Compiler < 17.1
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  // CHECK-MESSAGES-NEWCLOLDAOC: :[[@LINE-1]]:15: warning: kernel function 'error_barrier_no_id' does not call 'get_global_id' or 'get_local_id' and will be treated as a single work-item [altera-single-work-item-barrier]
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-NEWCLOLDAOC: :[[@LINE-1]]:3: note: barrier call is in a single work-item and may error out
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = 

[PATCH] D93436: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

2020-12-17 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2808f597f872: [clangd] Print .clang-tidy configuration 
parsing errors using [ev]?log. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93436

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


Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else


Index: clang-tools-extra/clangd/TidyProvider.cpp
===
--- clang-tools-extra/clangd/TidyProvider.cpp
+++ clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 2808f59 - [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

2020-12-17 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-18T02:07:27Z
New Revision: 2808f597f872e68a8bd69d5b53f5d583665b4c4f

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

LOG: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

Currently warnings when parsing .clang-tidy are printed directly to errs.
This is less than ideal as there is no synchronisation printing to errs, 
leading to potential races.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/TidyProvider.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index c6ee09ae16d2..c12dab7e2e5e 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@ class DotClangTidyCache : private FileCache {
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else



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


[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! I think this is in pretty good shape, remaining stuff is up to you.

Let me know if/when you want me to land this!




Comment at: clang-tools-extra/clangd/Hover.cpp:618
+  } else {
+CXXRecordDecl *D = QT->getAsCXXRecordDecl();
+if (D && D->isLambda())

qchateau wrote:
> sammccall wrote:
> > You've rewritten this logic compared to the old 
> > `getHoverContents(QualType)`, and I think there are regressions:
> >  - We've dropped class documentation (see e.g. 
> > ac3f9e48421712168884d59cbfe8b294dd76a19b, this is visible in the tests)
> >  - we're no longer using printName() to print tag-decls, which I expect 
> > changes e.g. the printing of anyonymous structs which is special-cased in 
> > that function (we have tests for this but probably not in combination with 
> > auto)
> >  - we're no longer using the printing-policy to print non-tag types, which 
> > will lead to some random changes
> > 
> > I don't see a reason for these changes, can we revert them?
> - I can re-add class documentation, but should it work when `auto` is a 
> pointer or a ref ? In that case, I'll need something like your `unwrapType` 
> of https://reviews.llvm.org/D93314
> - `printName` will print `C` instead of `class C` even if I hack around and 
> give it the right `PrintingPolicy`. The problem is that IDE (at least VSCode) 
> does not know what `C` is and cannot color it, which looks a nice less nice. 
> Up to you !
> - I can re-add the printing policy for non-tag types, and add it for 
> tag-types if we chose not to use `printName`.
> should it work when auto is a pointer or a ref?

I think no need for now, I just want to avoid the regression.
(Nice to have, but at least in the codebases I work in, `auto` is much more 
common than `decltype(auto)` so it's rarely a reference, and pointers are 
idiomatically written `auto*`)

> printName will print C instead of class C even if I hack around and give it 
> the right PrintingPolicy.

Yeah... it's not supposed to, though the extra clarity is valuable here. You 
could just hack around this and prepend the TagTypeKind yourself :-)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1717
 struct Bar {};
+// auto function return with trailing type
 ^[[auto]] test() -> decltype(Bar()) {

can you restore the comments to the original position above the struct, so we 
test that the documentation comment is included?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:999
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};

qchateau wrote:
> sammccall wrote:
> > (not convinced this is fundamentally not useful - the fact that it's a 
> > template parameter means it's probably worth having a hover card for it at 
> > some point. But I agree with suppressing it for now)
> As a user I'd prefer the hover to work over the whole `decltype(auto)` 
> expression. But that does not seem quite compatible with the way tokens are 
> parsed.
> 
> Are you suggesting I remove the test case or should I add a `FIXME` comment ?
Sorry, I think we're talking about different examples.

(I agree decltype(auto) should ideally be a single thing and we should support 
hover on all of it, no need to address in this patch, FIXME would be nice).

But I was talking about the lambda auto parameter, where your comment says "not 
useful". Anyway, nothing to do here either except maybe soften the comment to 
"not supported at the moment".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

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


[PATCH] D78058: option to write files to memory instead of disk

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

It's great that you're looking at this! Clang tooling in general and clangd in 
particular a lot of use of VFS (particularly when deployed inside google), so 
I've got a fair bit of interest/experience in these interfaces. And we'd also 
looked at virtualizing module caches in particular for clangd (but haven't 
tackled it yet).

A couple of high-level design questions:

- if the goal is really to make module caching work without a physical disk, is 
virtualizing the FS underlying the cache really the right abstraction? Compared 
to an alternative like plugging in a ModuleCache interface, it seems like quite 
a complicated contract to have to maintain, and less flexible too (we've 
dreamed about ideas like a network-distributed cache, expiry, selectively 
sharing cached modules based on security context etc... easier if the objects 
are modules+metadata rather than filenames+bytes). Of course it's pretty 
generic and maybe can be used for other stuff too, but...
- if we *are* going to introduce a writable VFS concept to LLVM, I feel we must 
allow this to be reused for virtualizing file writes in general. (clang has 
several ad-hoc mechanisms for virtual file inputs that AIUI predate llvm::vfs, 
and they're a pain). I think at minimum we should ensure that the writable FS 
is an interface rather than just one implementation, and that we can implement 
it well for the real FS also. Does this seem reasonable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78058

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


[PATCH] D93079: [OpenMP] Introduce an assumption to ignore possible external callers

2020-12-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Ah, this may be one of the things aomp changed for nvptx. We did something 
around linking but I've never looked into exactly what. In that case fine by me 
- it's a sharp edge, but I'd expect it to make a difference in benchmarks until 
whole program optimisation is online.

I think the strategy we want to converge on is equivalent to:

  N openmp source files -> bitcode -> llvm-link -> 
mlink-builtin-bitcode=nvptx.devicertl -> opt -> ptxas 

which interacts poorly with the compile/link separation. So presumably we 
should blend in the devicertl in an lld plugin, as that's when users expect the 
whole program to be available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93079

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


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

2020-12-17 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@ahatanak this patch should now be a nfc for types that don't have anything to 
do with the trivial-abi attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


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

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

- Fix base-derived case.
- Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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

Index: clang/test/SemaObjCXX/attr-trivial-abi.mm
===
--- clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -101,34 +101,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-  struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyMoveDeleted a;
-  };
-
-  struct __attribute__((trivial_abi)) CopyDeleted {
-CopyDeleted(const CopyDeleted &) = delete;
-CopyDeleted(CopyDeleted &&) = default;
-  };
-
-  struct __attribute__((trivial_abi)) MoveDeleted {
-MoveDeleted(const MoveDeleted &) = default;
-MoveDeleted(MoveDeleted &&) = delete;
-  };
-
-  struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-CopyDeleted a;
-MoveDeleted b;
-  };
-
-  // This is fine since the move constructor isn't deleted.
-  struct __attribute__((trivial_abi)) S20 {
-int & // a member of rvalue reference type deletes the copy constructor.
-  };
-}
Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -34,6 +34,21 @@
   S3_2 s32;
 };
 
+struct NonTrivial {
+  NonTrivial(const NonTrivial &) {}
+  ~NonTrivial() {}
+};
+
+struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{has a field of a non-trivial class type}}
+  NonTrivial n;
+  ~S18() {}
+};
+
+struct __attribute__((trivial_abi)) S19 : NonTrivial { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{'trivial_abi' is disallowed on 'S19' because it has a base of a non-trivial class type}}
+  int n;
+  ~S19() {}
+};
+
 struct S4 {
   int a;
 };
@@ -79,34 +94,3 @@
 };
 
 S17 s17;
-
-namespace deletedCopyMoveConstructor {
-struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyMoveDeleted a;
-};
-
-struct __attribute__((trivial_abi)) CopyDeleted {
-  CopyDeleted(const CopyDeleted &) = delete;
-  CopyDeleted(CopyDeleted &&) = default;
-};
-
-struct __attribute__((trivial_abi)) MoveDeleted {
-  MoveDeleted(const MoveDeleted &) = default;
-  MoveDeleted(MoveDeleted &&) = delete;
-};
-
-struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
-  CopyDeleted a;
-  MoveDeleted b;
-};
-
-// This is fine since the move constructor isn't deleted.
-struct __attribute__((trivial_abi)) S20 {
-  int & // a member of rvalue reference type deletes the copy constructor.
-};
-} // namespace deletedCopyMoveConstructor
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -1,10 +1,19 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-NEW-ABI
 // RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++20 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-20 

[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D92577

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


[clang] 3203143 - CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-12-17 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2020-12-17T14:30:31-08:00
New Revision: 3203143f1356a4e4e3ada231156fc6da6e1a9f9d

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

LOG: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

Add a special case for handling __builtin_mul_overflow with unsigned
inputs and a signed output to avoid emitting the __muloti4 library
call on x86_64.  __muloti4 is not implemented in libgcc, so avoiding
this call fixes compilation of some programs that call
__builtin_mul_overflow with these arguments.

For example, this fixes the build of cpio with clang, which includes code from
gnulib that calls __builtin_mul_overflow with these argument types.

Reviewed By: vsk

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

Added: 


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

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 40bb5f5f0689..60bfa90e22fc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1832,6 +1832,47 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr ) {
   return RValue::get(BufAddr.getPointer());
 }
 
+static bool isSpecialUnsignedMultiplySignedResult(
+unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info,
+WidthAndSignedness ResultInfo) {
+  return BuiltinID == Builtin::BI__builtin_mul_overflow &&
+ Op1Info.Width == Op2Info.Width && Op2Info.Width == ResultInfo.Width &&
+ !Op1Info.Signed && !Op2Info.Signed && ResultInfo.Signed;
+}
+
+static RValue EmitCheckedUnsignedMultiplySignedResult(
+CodeGenFunction , const clang::Expr *Op1, WidthAndSignedness Op1Info,
+const clang::Expr *Op2, WidthAndSignedness Op2Info,
+const clang::Expr *ResultArg, QualType ResultQTy,
+WidthAndSignedness ResultInfo) {
+  assert(isSpecialUnsignedMultiplySignedResult(
+ Builtin::BI__builtin_mul_overflow, Op1Info, Op2Info, ResultInfo) 
&&
+ "Cannot specialize this multiply");
+
+  llvm::Value *V1 = CGF.EmitScalarExpr(Op1);
+  llvm::Value *V2 = CGF.EmitScalarExpr(Op2);
+
+  llvm::Value *HasOverflow;
+  llvm::Value *Result = EmitOverflowIntrinsic(
+  CGF, llvm::Intrinsic::umul_with_overflow, V1, V2, HasOverflow);
+
+  // The intrinsic call will detect overflow when the value is > UINT_MAX,
+  // however, since the original builtin had a signed result, we need to report
+  // an overflow when the result is greater than INT_MAX.
+  auto IntMax = llvm::APInt::getSignedMaxValue(ResultInfo.Width);
+  llvm::Value *IntMaxValue = llvm::ConstantInt::get(Result->getType(), IntMax);
+
+  llvm::Value *IntMaxOverflow = CGF.Builder.CreateICmpUGT(Result, IntMaxValue);
+  HasOverflow = CGF.Builder.CreateOr(HasOverflow, IntMaxOverflow);
+
+  bool isVolatile =
+  ResultArg->getType()->getPointeeType().isVolatileQualified();
+  Address ResultPtr = CGF.EmitPointerWithAlignment(ResultArg);
+  CGF.Builder.CreateStore(CGF.EmitToMemory(Result, ResultQTy), ResultPtr,
+  isVolatile);
+  return RValue::get(HasOverflow);
+}
+
 /// Determine if a binop is a checked mixed-sign multiply we can specialize.
 static bool isSpecialMixedSignMultiply(unsigned BuiltinID,
WidthAndSignedness Op1Info,
@@ -3952,6 +3993,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   RightInfo, ResultArg, ResultQTy,
   ResultInfo);
 
+if (isSpecialUnsignedMultiplySignedResult(BuiltinID, LeftInfo, RightInfo,
+  ResultInfo))
+  return EmitCheckedUnsignedMultiplySignedResult(
+  *this, LeftArg, LeftInfo, RightArg, RightInfo, ResultArg, ResultQTy,
+  ResultInfo);
+
 WidthAndSignedness EncompassingInfo =
 EncompassingIntegerType({LeftInfo, RightInfo, ResultInfo});
 

diff  --git a/clang/test/CodeGen/builtins-overflow.c 
b/clang/test/CodeGen/builtins-overflow.c
index b7f8d7437e21..636a571d1364 100644
--- a/clang/test/CodeGen/builtins-overflow.c
+++ b/clang/test/CodeGen/builtins-overflow.c
@@ -1,9 +1,9 @@
 // Test CodeGen for Security Check Overflow Builtins.
 // rdar://13421498
 
-// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | 
FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
+// RUN: %clang_cc1 -triple 

[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-12-17 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
tstellar marked an inline comment as done.
Closed by commit rG3203143f1356: CodeGen: Improve generated IR for 
__builtin_mul_overflow(uint, uint, int) (authored by tstellar).
Herald added a subscriber: pengfei.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405

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

Index: clang/test/CodeGen/builtins-overflow.c
===
--- clang/test/CodeGen/builtins-overflow.c
+++ clang/test/CodeGen/builtins-overflow.c
@@ -1,9 +1,9 @@
 // Test CodeGen for Security Check Overflow Builtins.
 // rdar://13421498
 
-// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
+// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i64 -DLONG_MAX=9223372036854775807 %s
+// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
 
 extern unsigned UnsignedErrorCode;
 extern unsigned long UnsignedLongErrorCode;
@@ -111,6 +111,51 @@
   return r;
 }
 
+int test_mul_overflow_uint_uint_int(unsigned x, unsigned y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_int
+  // CHECK: [[S:%.+]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %{{.+}}, i32 %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i32, i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i32, i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt i32 [[Q]], 2147483647
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // CHECK: store i32 [[Q]], i32*
+  // CHECK: br i1 [[C2]]
+  int r;
+  if (__builtin_mul_overflow(x, y, ))
+overflowed();
+  return r;
+}
+
+int test_mul_overflow_uint_uint_int_volatile(unsigned x, unsigned y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_int_volatile
+  // CHECK: [[S:%.+]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %{{.+}}, i32 %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i32, i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i32, i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt i32 [[Q]], 2147483647
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // CHECK: store volatile i32 [[Q]], i32*
+  // CHECK: br i1 [[C2]]
+  volatile int r;
+  if (__builtin_mul_overflow(x, y, ))
+overflowed();
+  return r;
+}
+
+long test_mul_overflow_ulong_ulong_long(unsigned long x, unsigned long y) {
+  // CHECK-LABEL: @test_mul_overflow_ulong_ulong_long
+  // CHECK: [[S:%.+]] =  call { [[LONG_TYPE]], i1 } @llvm.umul.with.overflow.[[LONG_TYPE]]([[LONG_TYPE]] %{{.+}}, [[LONG_TYPE]] %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt [[LONG_TYPE]] [[Q]], [[LONG_MAX]]
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // LONG64: store [[LONG_TYPE]] [[Q]], [[LONG_TYPE]]*
+  // LONG64: br i1 [[C2]]
+  long r;
+  if (__builtin_mul_overflow(x, y, ))
+overflowed();
+  return r;
+}
+
 int test_mul_overflow_int_int_int(int x, int y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_int_int_int
   // CHECK-NOT: ext
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1832,6 +1832,47 @@
   return RValue::get(BufAddr.getPointer());
 }
 
+static bool isSpecialUnsignedMultiplySignedResult(
+unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info,
+WidthAndSignedness ResultInfo) {
+  return BuiltinID == Builtin::BI__builtin_mul_overflow &&
+ Op1Info.Width == Op2Info.Width && Op2Info.Width == ResultInfo.Width &&
+ !Op1Info.Signed && !Op2Info.Signed && ResultInfo.Signed;
+}
+
+static RValue EmitCheckedUnsignedMultiplySignedResult(
+CodeGenFunction , const clang::Expr *Op1, WidthAndSignedness Op1Info,
+const clang::Expr *Op2, WidthAndSignedness Op2Info,
+const clang::Expr *ResultArg, QualType ResultQTy,
+WidthAndSignedness ResultInfo) {
+  assert(isSpecialUnsignedMultiplySignedResult(
+ Builtin::BI__builtin_mul_overflow, Op1Info, Op2Info, ResultInfo) &&
+ "Cannot specialize this multiply");
+
+  llvm::Value *V1 = CGF.EmitScalarExpr(Op1);
+  llvm::Value *V2 = CGF.EmitScalarExpr(Op2);
+
+  llvm::Value *HasOverflow;
+  llvm::Value *Result = EmitOverflowIntrinsic(
+  CGF, 

[PATCH] D93333: tidy: supress warning for default member funcs

2020-12-17 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons accepted this revision as: malcolm.parsons.
malcolm.parsons 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/D9/new/

https://reviews.llvm.org/D9

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:1846
+(*Iter)->setInvalidDecl();
+  }
 }

rjmccall wrote:
> You can have multiple tag declarations because of complex declarators or 
> type-specifiers, e.g. `struct A (*var)(struct B)` or `_Atomic(struct 
> A(*)(struct B))`.  It should already be an error to write the latter without 
> a declarator, but you do need to not diagnose if there *is* a declarator.  
> Probably the right way to write this is to ignore tags in the first walk but 
> remember whether you saw a non-tag; if you don't, diagnose the first tag.
Good point on the more complex declarators -- I've added some extra tests for 
that case as well.


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

https://reviews.llvm.org/D92577

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 312613.
aaron.ballman added a comment.

Updating based on review feedback.


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

https://reviews.llvm.org/D92577

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/for.c


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -2,6 +2,12 @@
 
 // Check C99 6.8.5p3
 void b1 (void) { for (void (*f) (void);;); }
-void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of 
non-local variable}}
+void b2 (void) { for (void f (void);;); }   // expected-error {{non-variable 
declaration in 'for' loop}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of 
non-local variable}}
-void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of 
non-local variable}}
+void b4 (void) { for (typedef int f;;); }   // expected-error {{non-variable 
declaration in 'for' loop}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error 
{{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error 
{{declaration of non-local variable}}
+void b9 (void) { for (struct { int i; } (*s)(struct { int j; } o) = 0;;); }
+void b10(void) { for (typedef struct { int i; } (*s)(struct { int j; });;); } 
// expected-error {{non-variable declaration in 'for' loop}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,15 +1822,27 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
+  const Decl *NonVarSeen = nullptr;
+  bool VarDeclSeen = false;
   for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
-if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
-  VD = nullptr;
-if (!VD) {
-  Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-  DI->setInvalidDecl();
+if (VarDecl *VD = dyn_cast(DI)) {
+  VarDeclSeen = true;
+  if (VD->isLocalVarDecl() && !VD->hasLocalStorage()) {
+Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
+DI->setInvalidDecl();
+  }
+} else if (!NonVarSeen) {
+  // Keep track of the first non-variable declaration we saw so that
+  // we can diagnose if we don't see any variable declarations. This
+  // covers a case like declaring a typedef, function, or structure
+  // type rather than a variable.
+  NonVarSeen = DI;
 }
   }
+  // Diagnose if we saw a non-variable declaration but no variable
+  // declarations.
+  if (NonVarSeen && !VarDeclSeen)
+Diag(NonVarSeen->getLocation(), diag::err_non_variable_decl_in_for);
 }
   }
 


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -2,6 +2,12 @@
 
 // Check C99 6.8.5p3
 void b1 (void) { for (void (*f) (void);;); }
-void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of non-local variable}}
+void b2 (void) { for (void f (void);;); }   // expected-error {{non-variable declaration in 'for' loop}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of non-local variable}}
-void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of non-local variable}}
+void b4 (void) { for (typedef int f;;); }   // expected-error {{non-variable declaration in 'for' loop}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error {{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error {{declaration of non-local variable}}
+void b9 (void) { for (struct { int i; } (*s)(struct { int j; } o) = 0;;); }
+void b10(void) { for (typedef struct { int i; } (*s)(struct { int j; });;); } // expected-error {{non-variable declaration in 'for' loop}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,15 +1822,27 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
+  const Decl *NonVarSeen = nullptr;
+  bool VarDeclSeen = false;
   for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
-if (VD && 

[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-12-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D87188#2461497 , @lebedev.ri wrote:

> @mstorsjo i've bothered @dmajor to give this a try on some of mozilla's CI, 
> and unfortunately it came back green..
> I don't recall if i can reproduce it locally (on vanilla test suite, i'll 
> recheck),
> but right now it would seem that you are the only one who can reproduce this 
> :/
>
> Were you able to make any progress on a somewhat more actionable reproducer?
>
> What would be really helpful is a standalone source that can be compiled and 
> run (here by be locally, on linux x86_64)
> that produces different result with/without this change.

IIRC I'm only able to reproduce this for aarch64 (and possibly arm) targets 
unfortunately. I can make a kind of standalone testcase with one single file 
built from source, linked and executed along with a bigger piece of code 
(either from source or prebuilt object files), but it'd be for aarch64-linux 
(or aarch64-darwin if that helps - I haven't tried reproducing it there but I'd 
presume it behaves the same as I noticed the bug first on aarch64 windows).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87188

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


[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-12-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: dmajor.
lebedev.ri added a comment.

@mstorsjo i've bothered @dmajor to give this a try on some of mozilla's CI, and 
unfortunately it came back green..
I don't recall if i can reproduce it locally (on vanilla test suite, i'll 
recheck),
but right now it would seem that you are the only one who can reproduce this :/

Were you able to make any progress on a somewhat more actionable reproducer?

What would be really helpful is a standalone source that can be compiled and 
run (here by be locally, on linux x86_64)
that produces different result with/without this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87188

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

In D93428#2461343 , @apazos wrote:

> Thanks Daniel for the explanation.

No problem at all.

In D93428#2461343 , @apazos wrote:

> Was the support added for GNU assembler as well? Is it the same flag name?

Not yet, I requested the same flag from our GNU team when the flag is added to 
Clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer 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 rGc755e41c336c: Fix -Wno-error= parsing in clang-format. 
(authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/docs/ClangFormat.rst
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- differing format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   differing format depending on an option 
being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading 

[clang] c755e41 - Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via cfe-commits

Author: Joachim Meyer
Date: 2020-12-17T22:23:42+01:00
New Revision: c755e41c336c898873db6c3c58a2819a982f60de

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

LOG: Fix -Wno-error= parsing in clang-format.

As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit 
set.
This way the parsing is fixed and also we can possibly add new options easily.

Reviewed By: MyDeveloperDay

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

Added: 
clang/test/Format/error-config.cpp

Modified: 
clang/docs/ClangFormat.rst
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index b746ed3453df..d5333c0032b4 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@ to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# 
code.
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- 
diff ering format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   
diff ering format depending on an option being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading from stdin, clang-format assumes 
this
  filename to determine the language.

diff  --git a/clang/test/Format/error-config.cpp 
b/clang/test/Format/error-config.cpp
new file mode 100644
index ..7fbc869f3a3c
--- /dev/null
+++ b/clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index a1b42a6d0940..64f0e2badf33 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@ static cl::opt SortIncludes(
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "
diff ering format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@ static cl::opt
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable 

[PATCH] D93490: [clang-format] PR48539 ReflowComments breaks Qt translation comments

2020-12-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, curdeius, JakeMerdichAMD, JVApen.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

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

Add support for Qt Translator Comments to reflow

When reflown and a part of the comments are added on a new line, it should 
repeat these extra characters as part of the comment token.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93490

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -702,6 +702,22 @@
"  // long 1 2 3 4 5 6\n"
"}",
getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("//: A comment that\n"
+"//: doesn't fit on\n"
+"//: one line",
+format("//: A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//= A comment that\n"
+"//= doesn't fit on\n"
+"//= one line",
+format("//= A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//~ A comment that\n"
+"//~ doesn't fit on\n"
+"//~ one line",
+format("//~ A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -41,8 +41,8 @@
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
 const FormatStyle ) {
-  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", 
"//",
-"//!"};
+  static const char *const KnownCStylePrefixes[] = {
+  "///<", "//!<", "///", "//", "//!", "//:", "//=", "//~"};
   static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
""};
   ArrayRef KnownPrefixes(KnownCStylePrefixes);


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -702,6 +702,22 @@
"  // long 1 2 3 4 5 6\n"
"}",
getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("//: A comment that\n"
+"//: doesn't fit on\n"
+"//: one line",
+format("//: A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//= A comment that\n"
+"//= doesn't fit on\n"
+"//= one line",
+format("//= A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//~ A comment that\n"
+"//~ doesn't fit on\n"
+"//~ one line",
+format("//~ A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -41,8 +41,8 @@
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
 const FormatStyle ) {
-  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//",
-"//!"};
+  static const char *const KnownCStylePrefixes[] = {
+  "///<", "//!<", "///", "//", "//!", "//:", "//=", "//~"};
   static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
""};
   ArrayRef KnownPrefixes(KnownCStylePrefixes);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 312596.
fodinabor added a comment.

Update ClangFormat.rst.
This is manually well formatted.. will try to make a new patch in the coming 
days to actually fix it in the support library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/docs/ClangFormat.rst
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- differing format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   differing format depending on an option 
being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading from 

[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Thanks Daniel for the explanation. Was the support added for GNU assembler as 
well? Is it the same flag name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93458: clang-cl: Remove /Zd flag

2020-12-17 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49c248bd62a3: clang-cl: Remove /Zd flag (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93458

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6801,10 +6801,9 @@
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
 
-  // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present.
-  if (Arg *DebugInfoArg =
-  Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd,
-  options::OPT_gline_tables_only)) {
+  // Emit CodeView if -Z7 or -gline-tables-only are present.
+  if (Arg *DebugInfoArg = Args.getLastArg(options::OPT__SLASH_Z7,
+  options::OPT_gline_tables_only)) {
 *EmitCodeView = true;
 if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
   *DebugInfoKind = codegenoptions::LimitedDebugInfo;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5351,8 +5351,6 @@
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;
-def _SLASH_Zd : CLFlag<"Zd">,
-  HelpText<"Emit debug line number tables only">;
 def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
   HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -119,6 +119,14 @@
   `nonnull` attribute on `this` for configurations that need it to be nullable.
 - ``-gsplit-dwarf`` no longer implies ``-g2``.
 
+Removed Compiler Flags
+-
+
+The following options no longer exist.
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.
+
 New Pragmas in Clang
 
 


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6801,10 +6801,9 @@
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
 
-  // Emit 

[clang] 49c248b - clang-cl: Remove /Zd flag

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

Author: Nico Weber
Date: 2020-12-17T15:39:40-05:00
New Revision: 49c248bd62a3cb2f0e7e3991ee0190943bd2bbec

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

LOG: clang-cl: Remove /Zd flag

cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ef7903e16f7fa..a3038aa03cded 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -119,6 +119,14 @@ Modified Compiler Flags
   `nonnull` attribute on `this` for configurations that need it to be nullable.
 - ``-gsplit-dwarf`` no longer implies ``-g2``.
 
+Removed Compiler Flags
+-
+
+The following options no longer exist.
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.
+
 New Pragmas in Clang
 
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 07f15add28ec6..ca9615e2e7692 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5351,8 +5351,6 @@ def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">,
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;
-def _SLASH_Zd : CLFlag<"Zd">,
-  HelpText<"Emit debug line number tables only">;
 def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
   HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6ec6a551fafee..300ab6e815e23 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6801,10 +6801,9 @@ void Clang::AddClangCLArgs(const ArgList , 
types::ID InputType,
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
 
-  // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present.
-  if (Arg *DebugInfoArg =
-  Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd,
-  options::OPT_gline_tables_only)) {
+  // Emit CodeView if -Z7 or -gline-tables-only are present.
+  if (Arg *DebugInfoArg = Args.getLastArg(options::OPT__SLASH_Z7,
+  options::OPT_gline_tables_only)) {
 *EmitCodeView = true;
 if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
   *DebugInfoKind = codegenoptions::LimitedDebugInfo;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 1e04cc9f62713..f4b7a57e0bb70 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 43713d955b9bc..db70fca5222c6 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"



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


[PATCH] D93439: [OpenMP][NFC] Provide a new remark and documentation

2020-12-17 Thread Johannes Doerfert 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 rG994bb6eb7d01: [OpenMP][NFC] Provide a new remark and 
documentation (authored by jdoerfert).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D93439?vs=312357=312587#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93439

Files:
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/docs/remarks/OptimizationRemarks.rst


Index: openmp/docs/remarks/OptimizationRemarks.rst
===
--- openmp/docs/remarks/OptimizationRemarks.rst
+++ openmp/docs/remarks/OptimizationRemarks.rst
@@ -1,2 +1,30 @@
 OpenMP Optimization Remarks
 ===
+
+
+.. _omp100:
+.. _omp_no_external_caller_in_target_region:
+
+`[OMP100]` Potentially unknown OpenMP target region caller
+--
+
+A function remark that indicates the function, when compiled for a GPU, is
+potentially called from outside the translation unit. Note that a remark is
+only issued if we tried to perform an optimization which would require us to
+know all callers on the GPU.
+
+To facilitate OpenMP semantics on GPUs we provide a runtime mechanism through
+which the code that makes up the body of a parallel region is shared with the
+threads in the team. Generally we use the address of the outlined parallel
+region to identify the code that needs to be executed. If we know all target
+regions that reach the parallel region we can avoid this function pointer
+passing scheme and often improve the register usage on the GPU. However, If a
+parallel region on the GPU is in a function with external linkage we may not
+know all callers statically. If there are outside callers within target
+regions, this remark is to be ignored. If there are no such callers, users can
+modify the linkage and thereby help optimization with a `static` or
+`__attribute__((internal))` function annotation. If changing the linkage is
+impossible, e.g., because there are outside callers on the host, one can split
+the function into an external visible interface which is not compiled for
+the target and an internal implementation which is compiled for the target
+and should be called from within the target region.
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1469,8 +1469,16 @@
 }
 
 CachedKernel = nullptr;
-if (!F.hasLocalLinkage())
+if (!F.hasLocalLinkage()) {
+
+  // See https://openmp.llvm.org/remarks/OptimizationRemarks.html
+  auto Remark = [&](OptimizationRemark OR) {
+return OR << "[OMP100] Potentially unknown OpenMP target region 
caller";
+  };
+  emitRemarkOnFunction(, "OMP100", Remark);
+
   return nullptr;
+}
   }
 
   auto GetUniqueKernelForUse = [&](const Use ) -> Kernel {
Index: clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
===
--- clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -4,7 +4,7 @@
 
 // host-no-diagnostics
 
-void bar(void) {
+void bar(void) { // expected-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #1 



  \
  // expected-remark@#1 {{Found a parallel region that is 
called in a target region but not part of a combined target construct nor nesed 
inside a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}} \
  // expected-remark@#1 {{Parallel region is not known to 
be called from a unique single target region, maybe the surrounding function 
has external linkage?; will not attempt to rewrite the state machine use.}}
Index: clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
===
--- clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ 

[clang] 994bb6e - [OpenMP][NFC] Provide a new remark and documentation

2020-12-17 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-12-17T14:38:26-06:00
New Revision: 994bb6eb7d01db1d9461e54d17a63af2ba1af2c9

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

LOG: [OpenMP][NFC] Provide a new remark and documentation

If a GPU function is externally reachable we give up trying to find the
(unique) kernel it is called from. This can hinder optimizations. Emit a
remark and explain mitigation strategies.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
openmp/docs/remarks/OptimizationRemarks.rst

Removed: 




diff  --git 
a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c 
b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
index 163f0b92468a..d5b5530fc361 100644
--- a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -4,7 +4,7 @@
 
 // host-no-diagnostics
 
-void bar1(void) {
+void bar1(void) {// all-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #0
  // all-remark@#0 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nesed inside 
a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
  // safe-remark@#0 {{Parallel region is not known to be 
called from a unique single target region, maybe the surrounding function has 
external linkage?; will not attempt to rewrite the state machine use.}}
@@ -13,7 +13,7 @@ void bar1(void) {
   {
   }
 }
-void bar2(void) {
+void bar2(void) {// all-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #1
  // all-remark@#1 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nesed inside 
a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
  // safe-remark@#1 {{Parallel region is not known to be 
called from a unique single target region, maybe the surrounding function has 
external linkage?; will not attempt to rewrite the state machine use.}}

diff  --git a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c 
b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
index 97507041e195..5747a05a13d3 100644
--- a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -4,7 +4,7 @@
 
 // host-no-diagnostics
 
-void bar(void) {
+void bar(void) { // expected-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #1 



  \
  // expected-remark@#1 {{Found a parallel region that is 
called in a target region but not part of a combined target construct nor nesed 
inside a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}} \
  // expected-remark@#1 {{Parallel region is not known to 
be called from a unique single target region, maybe the surrounding function 
has external linkage?; will not attempt to rewrite the state machine use.}}

diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp 
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 6053412bae84..5b4772028daf 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1469,8 +1469,16 @@ Kernel OpenMPOpt::getUniqueKernelFor(Function ) {
 }
 
 CachedKernel = nullptr;
-if (!F.hasLocalLinkage())
+if (!F.hasLocalLinkage()) {
+
+  // See https://openmp.llvm.org/remarks/OptimizationRemarks.html
+  auto Remark = [&](OptimizationRemark OR) {
+return OR << "[OMP100] Potentially unknown OpenMP target region 
caller";
+  };
+  emitRemarkOnFunction(, "OMP100", 

[PATCH] D68410: [AttrDocs] document always_inline

2020-12-17 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe75fec2b238f: [AttrDocs] document always_inline (authored by 
nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -5653,3 +5653,22 @@
 `_ for more information.
   }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inlining heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the Microsoft Docs on Inline Functions`_, `the GCC Common Function
+Attribute docs`_, and `the GCC Inline docs`_.
+
+.. _the Microsoft Docs on Inline Functions: 
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -684,7 +684,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -5653,3 +5653,22 @@
 `_ for more information.
   }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inlining heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the Microsoft Docs on Inline Functions`_, `the GCC Common Function
+Attribute docs`_, and `the GCC Inline docs`_.
+
+.. _the Microsoft Docs on Inline Functions: https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -684,7 +684,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e75fec2 - [AttrDocs] document always_inline

2020-12-17 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-12-17T12:34:23-08:00
New Revision: e75fec2b238f0e26cfb7645f2208baebe3440d41

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

LOG: [AttrDocs] document always_inline

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ce2ee40dc036..ba6c459f4a43 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -684,7 +684,7 @@ def AlignMac68k : InheritableAttr {
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index c3a412158aba..6f47ca505b5e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5653,3 +5653,22 @@ Requirements on Development Tools - Engineering 
Specification Documentation
 `_ for more information.
   }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inlining heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the Microsoft Docs on Inline Functions`_, `the GCC Common Function
+Attribute docs`_, and `the GCC Inline docs`_.
+
+.. _the Microsoft Docs on Inline Functions: 
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}



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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

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


[PATCH] D93483: Add element-type to the Vector TypeLoc types.

2020-12-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: fhahn, rjmccall.
erichkeane requested review of this revision.

As shown by bug 48540, GCC vector types would cause a crash when the
declaration hada ParenType. This was because the walking of the
declaration would try to expand the 'inner' type, but there was no
ability to get it from the vector type.  This patch adds that element
type access to the vector type loc objects.


https://reviews.llvm.org/D93483

Files:
  clang/include/clang/AST/TypeLoc.h
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -513,3 +513,22 @@
 }
 
 } // namespace PR45780
+
+namespace PR48540 {
+// The below used to cause an OOM error, or an assert, make sure it is still
+//  valid.
+int(__attribute__((vector_size(16 a;
+
+template 
+struct S {
+  T(__attribute__((vector_size(16
+  a;
+  int(__attribute__((vector_size(I b;
+  T(__attribute__((vector_size(I
+  c;
+};
+
+void use() {
+  S s;
+}
+} // namespace PR48540
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -5176,7 +5176,7 @@
 QualType TreeTransform::TransformDependentVectorType(
 TypeLocBuilder , DependentVectorTypeLoc TL) {
   const DependentVectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5217,7 +5217,7 @@
   const DependentSizedExtVectorType *T = TL.getTypePtr();
 
   // FIXME: ext vector locs should be nested
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5384,7 +5384,7 @@
 QualType TreeTransform::TransformVectorType(TypeLocBuilder ,
  VectorTypeLoc TL) {
   const VectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
@@ -5407,7 +5407,7 @@
 QualType TreeTransform::TransformExtVectorType(TypeLocBuilder ,
 ExtVectorTypeLoc TL) {
   const VectorType *T = TL.getTypePtr();
-  QualType ElementType = getDerived().TransformType(T->getElementType());
+  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
   if (ElementType.isNull())
 return QualType();
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6133,6 +6133,17 @@
 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
   TL.setExpansionLoc(Chunk.Loc);
 }
+void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.setNameLoc(Chunk.Loc); }
+void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void
+VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -1749,30 +1749,79 @@
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
-class VectorTypeLoc : public InheritingConcreteTypeLoc {
+struct VectorTypeLocInfo {
+  SourceLocation NameLoc;
+};
+
+class VectorTypeLoc : public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext , SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
 };
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
 class DependentVectorTypeLoc
-: public InheritingConcreteTypeLoc {};
+: public ConcreteTypeLoc {
+public:
+  SourceLocation 

[PATCH] D92955: [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-17 Thread Valentin Clement 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 rGf4c8b8031800: [openmp] Remove clause from OMPKinds.def and 
use OMP.td info (authored by clementval).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92955

Files:
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  flang/include/flang/Parser/dump-parse-tree.h
  flang/include/flang/Parser/parse-tree.h
  flang/lib/Parser/unparse.cpp
  flang/lib/Semantics/check-omp-structure.h
  llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/TableGen/DirectiveEmitter.h
  llvm/test/TableGen/directive2.td
  llvm/utils/TableGen/DirectiveEmitter.cpp

Index: llvm/utils/TableGen/DirectiveEmitter.cpp
===
--- llvm/utils/TableGen/DirectiveEmitter.cpp
+++ llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -645,6 +645,72 @@
   GenerateFlangClauseUnparse(DirLang, OS);
 }
 
+void GenerateClauseClassMacro(const DirectiveLanguage ,
+  raw_ostream ) {
+  // Generate macros style information for legacy code in clang
+  IfDefScope Scope("GEN_CLANG_CLAUSE_CLASS", OS);
+
+  OS << "\n";
+
+  OS << "#ifndef CLAUSE\n";
+  OS << "#define CLAUSE(Enum, Str, Implicit)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_CLASS\n";
+  OS << "#define CLAUSE_CLASS(Enum, Str, Class)\n";
+  OS << "#endif\n";
+  OS << "#ifndef CLAUSE_NO_CLASS\n";
+  OS << "#define CLAUSE_NO_CLASS(Enum, Str)\n";
+  OS << "#endif\n";
+  OS << "\n";
+  OS << "#define __CLAUSE(Name, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, #Name, Class)\n";
+  OS << "#define __CLAUSE_NO_CLASS(Name)\\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, #Name, /* Implicit */ false) \\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, #Name)\n";
+  OS << "#define __IMPLICIT_CLAUSE_CLASS(Name, Str, Class)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_CLASS(" << DirLang.getClausePrefix()
+ << "##Name, Str, Class)\n";
+  OS << "#define __IMPLICIT_CLAUSE_NO_CLASS(Name, Str)  \\\n";
+  OS << "  CLAUSE(" << DirLang.getClausePrefix()
+ << "##Name, Str, /* Implicit */ true)\\\n";
+  OS << "  CLAUSE_NO_CLASS(" << DirLang.getClausePrefix() << "##Name, Str)\n";
+  OS << "\n";
+
+  for (const auto  : DirLang.getClauses()) {
+Clause C{R};
+if (C.getClangClass().empty()) { // NO_CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_NO_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\")\n";
+  } else {
+OS << "__CLAUSE_NO_CLASS(" << C.getFormattedName() << ")\n";
+  }
+} else { // CLASS
+  if (C.isImplicit()) {
+OS << "__IMPLICIT_CLAUSE_CLASS(" << C.getFormattedName() << ", \""
+   << C.getFormattedName() << "\", " << C.getClangClass() << ")\n";
+  } else {
+OS << "__CLAUSE(" << C.getFormattedName() << ", " << C.getClangClass()
+   << ")\n";
+  }
+}
+  }
+
+  OS << "\n";
+  OS << "#undef __IMPLICIT_CLAUSE_NO_CLASS\n";
+  OS << "#undef __IMPLICIT_CLAUSE_CLASS\n";
+  OS << "#undef __CLAUSE\n";
+  OS << "#undef CLAUSE_NO_CLASS\n";
+  OS << "#undef CLAUSE_CLASS\n";
+  OS << "#undef CLAUSE\n";
+}
+
 // Generate the implemenation section for the enumeration in the directive
 // language.
 void EmitDirectivesGen(RecordKeeper , raw_ostream ) {
@@ -653,6 +719,8 @@
 return;
 
   EmitDirectivesFlangImpl(DirLang, OS);
+
+  GenerateClauseClassMacro(DirLang, OS);
 }
 
 // Generate the implemenation for the enumeration in the directive
Index: llvm/test/TableGen/directive2.td
===
--- llvm/test/TableGen/directive2.td
+++ llvm/test/TableGen/directive2.td
@@ -23,10 +23,15 @@
   let isValueList = 1;
 }
 def TDLC_ClauseC : Clause<"clausec"> {
+  let clangClass = "ClauseC";
   let flangClassValue = "Name";
   let defaultValue = "*";
   let isValueOptional = 1;
 }
+def TDLC_ClauseD : Clause<"claused"> {
+  let clangClass = "ClauseD";
+  let isImplicit = 1;
+}
 
 def TDL_DirA : 

[clang] f4c8b80 - [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-17 Thread via cfe-commits

Author: Valentin Clement
Date: 2020-12-17T14:08:12-05:00
New Revision: f4c8b80318005ca61bfed9b40ee9e6039194159b

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

LOG: [openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for 
the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros 
previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 65319a19728b..649b57113424 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMP.inc"
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 2141f85911be..a91f6b0c1a69 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,8 +147,9 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMP.inc"
 NKI_NumberOfKinds
   };
 
@@ -205,8 +206,9 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMP.inc"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index cc6d3a93ba09..877c1d87d8ac 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,22 +7758,22 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
-  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
+  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMP.inc"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
+#define CLAUSE_NO_CLASS(Enum, Str) 
\
   case 

[PATCH] D93458: clang-cl: Remove /Zd flag

2020-12-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm


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

https://reviews.llvm.org/D93458

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


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

2020-12-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

`byval` actually means it'll be passed on the stack, not as a pointer, so yes, 
that's a real change in conventions from an indirect argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

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



Comment at: clang/lib/Sema/SemaStmt.cpp:1846
+(*Iter)->setInvalidDecl();
+  }
 }

You can have multiple tag declarations because of complex declarators or 
type-specifiers, e.g. `struct A (*var)(struct B)` or `_Atomic(struct 
A(*)(struct B))`.  It should already be an error to write the latter without a 
declarator, but you do need to not diagnose if there *is* a declarator.  
Probably the right way to write this is to ignore tags in the first walk but 
remember whether you saw a non-tag; if you don't, diagnose the first tag.


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

https://reviews.llvm.org/D92577

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


[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-17 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto accepted this revision.
CarolineConcatto added a comment.

Thank you @awarzynski for implementing fsyntax-only. 
It is another feature that the new driver provides, it is nice to see thing 
falling into place.
The patch looks good to me!




Comment at: flang/include/flang/Frontend/FrontendActions.h:13
 #include "flang/Frontend/FrontendAction.h"
+#include "llvm/Support/raw_ostream.h"
 

Do you need this library here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

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


[PATCH] D91974: [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

2020-12-17 Thread Albion Fung 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 rGc2892978e919: [PowerPC] Rename the vector pair intrinsics 
and builtins to replace the _mma_… (authored by bsaleil, committed by Conanap).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91974

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-mma.c
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-mma-types.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-mma-types.cpp
  clang/test/SemaCXX/ppc-pair-mma-types.cpp
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
  llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
  llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
  llvm/test/CodeGen/PowerPC/mma-outer-product.ll
  llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
  llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
@@ -0,0 +1,357 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-NOMMA
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE-NOMMA
+
+; This test also checks that the paired vector intrinsics are available even
+; when MMA is disabled.
+
+; assemble_pair
+declare <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8>, <16 x i8>)
+define void @ass_pair(<256 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: ass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:stxv v2, 16(r3)
+; CHECK-NEXT:stxv v3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: ass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:vmr v3, v2
+; CHECK-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-NOMMA-NEXT:stxv v3, 0(r3)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: ass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: ass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:vmr v3, v2
+; CHECK-BE-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NOMMA-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = tail call <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8> %vc, <16 x i8> %vc)
+  store <256 x i1> %0, <256 x i1>* %ptr, align 32
+  ret void
+}
+
+; disassemble_pair
+declare { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1>)
+define void @disass_pair(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
+; CHECK-LABEL: disass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxv vs1, 0(r3)
+; CHECK-NEXT:lxv vs0, 16(r3)
+; CHECK-NEXT:stxv vs1, 0(r4)
+; CHECK-NEXT:stxv vs0, 0(r5)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: disass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:lxv vs1, 0(r3)
+; CHECK-NOMMA-NEXT:lxv vs0, 16(r3)
+; CHECK-NOMMA-NEXT:stxv vs1, 0(r4)
+; CHECK-NOMMA-NEXT:stxv vs0, 0(r5)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: disass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: disass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NOMMA-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NOMMA-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NOMMA-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NOMMA-NEXT:blr

[clang] c289297 - [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

2020-12-17 Thread Albion Fung via cfe-commits

Author: Baptiste Saleil
Date: 2020-12-17T13:19:27-05:00
New Revision: c2892978e919bf66535729c70fba73c4c3224548

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

LOG: [PowerPC] Rename the vector pair intrinsics and builtins to replace the 
_mma_ prefix by _vsx_

On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to 
replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

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

Added: 
clang/test/CodeGen/builtins-ppc-pair-mma.c
clang/test/Sema/ppc-pair-mma-types.c
clang/test/SemaCXX/ppc-pair-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
llvm/test/CodeGen/PowerPC/mma-outer-product.ll
llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll

Removed: 
clang/test/CodeGen/builtins-ppc-mma.c
clang/test/Sema/ppc-mma-types.c
clang/test/SemaCXX/ppc-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll



diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 8975d126b897..39c66f5daeb1 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -7,8 +7,9 @@
 
//===--===//
 //
 // This file defines the PowerPC-specific builtin function database.  Users of
-// this file must define the BUILTIN macro or the MMA_BUILTIN macro to make use
-// of this information.
+// this file must define the BUILTIN macro or the CUSTOM_BUILTIN macro to
+// make use of this information. The latter is used for builtins requiring
+// custom code generation and checking.
 //
 
//===--===//
 
@@ -18,9 +19,9 @@
 // The format of this database matches clang/Basic/Builtins.def except for the
 // MMA builtins that are using their own format documented below.
 
-#if defined(BUILTIN) && !defined(MMA_BUILTIN)
-#   define MMA_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_mma_##ID, 
"i.", "t")
-#elif defined(MMA_BUILTIN) && !defined(BUILTIN)
+#if defined(BUILTIN) && !defined(CUSTOM_BUILTIN)
+#   define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", 
"t")
+#elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN)
 #   define BUILTIN(ID, TYPES, ATTRS)
 #endif
 
@@ -659,94 +660,94 @@ BUILTIN(__builtin_setflm, "dd", "")
 // Cache built-ins
 BUILTIN(__builtin_dcbf, "vvC*", "")
 
-// MMA built-ins
-// All MMA built-ins are declared here using the MMA_BUILTIN macro. Because
-// these built-ins rely on target-dependent types and to avoid pervasive 
change,
-// they are type checked manually in Sema using custom type descriptors.
-// The first argument of the MMA_BUILTIN macro is the name of the built-in, the
-// second argument specifies the type of the function (result value, then each
-// argument) as follows:
+// Built-ins requiring custom code generation.
+// Because these built-ins rely on target-dependent types and to avoid 
pervasive
+// change, they are type checked manually in Sema using custom type 
descriptors.
+// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
+// with its prefix, the second argument specifies the type of the function
+// (result value, then each argument) as follows:
 //  i -> Unsigned integer followed by the greatest possible value for that
 //   argument or 0 if no constraint on the value.
 //   (e.g. i15 for a 4-bits value)
-//  v -> void
 //  V -> Vector type used with MMA builtins (vector unsigned char)
-//  W -> MMA vector type followed by the size of the vector type.
+//  W -> PPC Vector type followed by the size of the vector type.
 //   (e.g. W512 for __vector_quad)
+//  any other descriptor -> Fall back to generic type descriptor decoding.
 // The 'C' suffix can be used as a suffix to specify the const type.
 // The '*' suffix can be used as a suffix to specify a pointer to a type.
 // The third argument is set to true if the builtin accumulates its result into
 // 

[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 312547.
awarzynski added a comment.

Tidy-up include paths

This was pointed out by @CarolineConcatto offline, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/syntax-only.f90
  flang/unittests/Frontend/PrintPreprocessedTest.cpp

Index: flang/unittests/Frontend/PrintPreprocessedTest.cpp
===
--- flang/unittests/Frontend/PrintPreprocessedTest.cpp
+++ flang/unittests/Frontend/PrintPreprocessedTest.cpp
@@ -76,4 +76,60 @@
   llvm::sys::fs::remove(inputFile);
   compInst.ClearOutputFiles(/*EraseFiles=*/true);
 }
+
+TEST(FrontendAction, ParseSyntaxOnly) {
+  std::string inputFile = "test-file.f";
+  std::error_code ec;
+
+  // 1. Create the input file for the file manager
+  // AllSources (which is used to manage files inside every compiler instance),
+  // works with paths. This means that it requires a physical file. Create one.
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+FAIL() << "Fail to create the file need by the test";
+
+  // Populate the input file with the pre-defined input and flush it.
+  *(os) << "! if_stmt.f90:\n"
+<< "IF (A > 0.0) IF (B < 0.0) A = LOG (A)\n"
+<< "END";
+  os.reset();
+
+  // Get the path of the input file
+  llvm::SmallString<64> cwd;
+  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+FAIL() << "Failed to obtain the current working directory";
+  std::string testFilePath(cwd.c_str());
+  testFilePath += "/" + inputFile;
+
+  // 2. Prepare the compiler (CompilerInvocation + CompilerInstance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->frontendOpts().programAction_ = ParseSyntaxOnly;
+
+  compInst.set_invocation(std::move(invocation));
+  compInst.frontendOpts().inputs_.push_back(
+  FrontendInputFile(testFilePath, Language::Fortran));
+
+  // 3. Set-up the output stream for the semantic diagnostics.
+  llvm::SmallVector outputDiagBuffer;
+  std::unique_ptr outputStream(
+  new llvm::raw_svector_ostream(outputDiagBuffer));
+  compInst.set_semaOutputStream(std::move(outputStream));
+
+  // 4. Execute the ParseSyntaxOnly action
+  bool success = ExecuteCompilerInvocation();
+
+  // 5. Validate the expected output
+  EXPECT_FALSE(success);
+  EXPECT_TRUE(!outputDiagBuffer.empty());
+  EXPECT_TRUE(
+  llvm::StringRef(outputDiagBuffer.data())
+  .startswith(
+  ":2:14: error: IF statement is not allowed in IF statement\n"));
+
+  // 6. Clear the input files.
+  llvm::sys::fs::remove(inputFile);
+}
 } // namespace
Index: flang/test/Flang-Driver/syntax-only.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/syntax-only.f90
@@ -0,0 +1,9 @@
+! RUN: not %flang-new -fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: not %f18 -fparse-only %s 2>&1 | FileCheck %s
+
+! REQUIRES: new-flang-driver
+
+! CHECK: IF statement is not allowed in IF statement
+! CHECK: semantic errors in {{.*}}syntax-only.f90
+IF (A > 0.0) IF (B < 0.0) A = LOG (A)
+END
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -32,6 +32,9 @@
   case PrintPreprocessedInput:
 return std::make_unique();
 break;
+  case ParseSyntaxOnly:
+return std::make_unique();
+break;
   default:
 break;
 // TODO:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -7,10 +7,12 @@
 //===--===//
 
 #include "flang/Frontend/FrontendActions.h"
+#include "flang/Common/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/source.h"
+#include "flang/Semantics/semantics.h"
 
 using namespace Fortran::frontend;
 
@@ -68,3 +70,33 @@
 return;
   }
 }
+
+void ParseSyntaxOnlyAction::ExecuteAction() {
+  CompilerInstance  = this->instance();
+
+  // TODO: These should be specifiable by users. For now just use the defaults.
+  

[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

> Is there a reason why assembly files have a different flag (i.e. 
> -mmark-bti-property) to create the .note.gnu.property with the BTI entry?

In assembly the compiler can't guarantee the landing pads are in place, 
therefore it doesn't add it automatically.
The original concept was this the developers should add the landing pads 
wherever needed and by adding the note they mark the file is compatible with 
BTI.
After adding BTI to many assembly code it was clear the note is error prone and 
cumbersome to handle and I thing it provides zero protection against regression 
issues , so the `-mmark-bti-property` is introduced. 
The developers still should add the landing pads but optionally they could mark 
the files in the build system instead of the assembly files. 
The worry is if the assembly file would be marked automatically the produces 
binary probably won't run correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:618
+  } else {
+CXXRecordDecl *D = QT->getAsCXXRecordDecl();
+if (D && D->isLambda())

sammccall wrote:
> You've rewritten this logic compared to the old `getHoverContents(QualType)`, 
> and I think there are regressions:
>  - We've dropped class documentation (see e.g. 
> ac3f9e48421712168884d59cbfe8b294dd76a19b, this is visible in the tests)
>  - we're no longer using printName() to print tag-decls, which I expect 
> changes e.g. the printing of anyonymous structs which is special-cased in 
> that function (we have tests for this but probably not in combination with 
> auto)
>  - we're no longer using the printing-policy to print non-tag types, which 
> will lead to some random changes
> 
> I don't see a reason for these changes, can we revert them?
- I can re-add class documentation, but should it work when `auto` is a pointer 
or a ref ? In that case, I'll need something like your `unwrapType` of 
https://reviews.llvm.org/D93314
- `printName` will print `C` instead of `class C` even if I hack around and 
give it the right `PrintingPolicy`. The problem is that IDE (at least VSCode) 
does not know what `C` is and cannot color it, which looks a nice less nice. Up 
to you !
- I can re-add the printing policy for non-tag types, and add it for tag-types 
if we chose not to use `printName`.



Comment at: clang-tools-extra/clangd/Hover.cpp:631
+// getDeducedType are handled.
+class ExtraAutoTypeHoverVisitor
+: public RecursiveASTVisitor {

sammccall wrote:
> This functionality (reporting the `auto` type in structured bindings, and not 
> reporting non-deduced uses of auto) belongs in the getDeducedType() helper 
> rather than as a layer on top.
> (Especially because it has to be done via an AST traversal rather than 
> SelectionTree)
> 
> I'd suggest leaving it out of this patch to get this the original change 
> landed quickly - this seems like a mostly-unrelated enhancement. But up to 
> you.
I'll remove this. I'll leave out the case of structured bindings for arrays 
(which is really weird and specific), but I guess I'll fix`getDeducedType` to 
return the undeduced `QualType` instead of `None` (which it already does but 
only for return types).



Comment at: clang-tools-extra/clangd/Hover.cpp:907
+
+  HI->Name = tok::getTokenName(Tok.kind());
+  HighlightRange = Tok.range(SM).toCharRange(SM);

sammccall wrote:
> decltype(auto) and decltype(expr) are fairly different things and ultimately 
> we should be displaying them differently I think ("decltype(auto)" vs 
> "decltype(...)").
> 
> Unfortunately it's awkward because our getDeducedType helper handles both at 
> the moment (and so is misnamed, because decltype(expr) isn't deduced at all).
> 
> Can you add `// FIXME: distinguish decltype(auto) vs decltype(expr)` and I'll 
> do some refactoring later?
Sure, I'll add the comment. I'll leave that refactoring to you, I'm not quite 
sure how you intent to achieve it.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:999
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};

sammccall wrote:
> (not convinced this is fundamentally not useful - the fact that it's a 
> template parameter means it's probably worth having a hover card for it at 
> some point. But I agree with suppressing it for now)
As a user I'd prefer the hover to work over the whole `decltype(auto)` 
expression. But that does not seem quite compatible with the way tokens are 
parsed.

Are you suggesting I remove the test case or should I add a `FIXME` comment ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

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


[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 312545.
qchateau marked 3 inline comments as done.
qchateau added a comment.

I updated this diff according to your review. There are a few things that may 
still need change but I need your input, see my other comments :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -379,6 +379,30 @@
  HI.Definition = "class X {}";
}},
 
+  // auto on structured bindings
+  {R"cpp(
+void foo() {
+  struct S { int x; float y; };
+  [[au^to]] [x, y] = S();
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "struct S";
+   }},
+  // undeduced auto
+  {R"cpp(
+template
+void foo() {
+  [[au^to]] x = T{};
+}
+)cpp",
+   [](HoverInfo ) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "/* not deduced */";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -386,8 +410,9 @@
 }
 )cpp",
[](HoverInfo ) {
- HI.Name = "(lambda)";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class(lambda)";
}},
   // auto on template instantiation
   {R"cpp(
@@ -397,8 +422,9 @@
 }
 )cpp",
[](HoverInfo ) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
   // auto on specialized template
   {R"cpp(
@@ -409,8 +435,9 @@
 }
 )cpp",
[](HoverInfo ) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
 
   // macro
@@ -582,8 +609,9 @@
   }
   )cpp",
   [](HoverInfo ) {
-HI.Name = "Foo";
-HI.Kind = index::SymbolKind::Class;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "class Foo";
   }},
   {// Falls back to primary template, when the type is not instantiated.
R"cpp(
@@ -955,20 +983,9 @@
   llvm::StringRef Tests[] = {
   "^int main() {}",
   "void foo() {^}",
-  R"cpp(// structured binding. Not supported yet
-struct Bar {};
-void foo() {
-  Bar a[2];
-  ^auto [x,y] = a;
-}
-  )cpp",
-  R"cpp(// Template auto parameter. Nothing (Not useful).
-template
-void func() {
-}
-void foo() {
-   func<1>();
-}
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};
   )cpp",
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
@@ -1545,9 +1562,9 @@
 }
   )cpp",
   [](HoverInfo ) {
-HI.Name = "int";
-// FIXME: Should be Builtin/Integral.
-HI.Kind = index::SymbolKind::Unknown;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
   }},
   {
   R"cpp(// Simple initialization with const auto
@@ -1555,14 +1572,22 @@
   const ^[[auto]] i = 1;
 }
   )cpp",
-  [](HoverInfo ) { HI.Name = "int"; }},
+  [](HoverInfo ) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with const auto&
 void foo() {
   const ^[[auto]]& i = 1;
 }
   )cpp",
-  [](HoverInfo ) { HI.Name = "int"; }},
+  [](HoverInfo ) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with auto&
 void foo() {
@@ -1570,7 +1595,11 @@
   ^[[auto]]& i = x;
 }
   )cpp",
-  [](HoverInfo ) { HI.Name = "int"; }},
+  [](HoverInfo ) {
+

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

2020-12-17 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D92361#2459655 , @rjmccall wrote:

> In D92361#2459513 , @zoecarver wrote:
>
>>> I think that as long as the class leaves a copy/move constructor defaulted, 
>>> there's no need for a new trivial_abi attribute.
>>
>> Sorry, I'm not sure I follow. Could you elaborate a bit or provide an 
>> example? What do you mean by "new" trivial_abi attribute?
>
> Sorry, I mean that I think Akira's example should be passed directly.  It 
> shouldn't require its own trivial_abi attribute in order to get the treatment.

No worries. I understand now. The problem we're discussing actually has nothing 
to do with the trivial-abi attribute. We just need to make sure that 
non-trival-abi types are not affected by this change (and it appears they were).




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

Quuxplusone wrote:
> zoecarver wrote:
> > ahatanak wrote:
> > > zoecarver wrote:
> > > > ahatanak wrote:
> > > > > It looks like this patch changes the way `D` is passed in the 
> > > > > following code:
> > > > > 
> > > > > ```
> > > > > struct B {
> > > > >   int i[4];
> > > > >   B();
> > > > >   B(const B &) = default;
> > > > >   B(B &&);
> > > > > };
> > > > > 
> > > > > struct D : B {
> > > > >   D();
> > > > >   D(const D &) = default;
> > > > >   D(D &&) = delete;
> > > > > };
> > > > > 
> > > > > void testB(B a);
> > > > > void testD(D a);
> > > > > 
> > > > > void testCallB() {
> > > > >   B b;
> > > > >   testB(b);
> > > > > }
> > > > > 
> > > > > void testCallD() {
> > > > >   D d;
> > > > >   testD(d);
> > > > > }
> > > > > ```
> > > > > 
> > > > > `B` cannot be passed in registers because it has a non-trivial move 
> > > > > constructor, whereas `D` can be passed in registers because the move 
> > > > > constructor is deleted and the copy constructor is trivial.
> > > > > 
> > > > > I'm not sure what the best way to handle this is, but I just wanted 
> > > > > to point this out.
> > > > Hmm. Good catch. One way to fix this would be to simply create a 
> > > > `HasPassableSubobject` variable and add that to the conditions below 
> > > > (instead of returning false here). But, it seems that `D` isn't passed 
> > > > by registers (even though, maybe it should be) on ToT: 
> > > > https://godbolt.org/z/4xevW5 
> > > > 
> > > > Given that, do you think it's OK to return false here, or should I 
> > > > update this patch to use the logic I just described (even though that 
> > > > would be a nfc)? 
> > > The argument is byval, so `D` is passed directly. If you remove `-O3` and 
> > > add `-target aarch64`, you'll see that `[2 x i64]` is being passed
> > Ah, I see now. Great. Thanks. I'll update the patch. 
> Akira's example is legal C++ with no Clang-specific attributes, so its 
> behavior is governed by the appropriate platform's ABI doc — there exists one 
> correct answer.
> At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree 
> on the answer: `B` and `D` have exactly the same passing convention. If your 
> patch breaks that, that's a problem.
> Contrariwise, it appears that `B` and `D` have different passing conventions 
> on "armv8" according to Clang, and the same passing convention on "ARM64" 
> according to GCC: https://godbolt.org/z/j9jzYG
> Of course if the programmer adds `[[clang::trivial_abi]]` to one of them, 
> then all bets are off, standards-wise, and you're free to figure out a way to 
> pass it in registers if you want to. But otherwise I think you have to follow 
> what the ABI says.
> Bear in mind that I don't really know ABIs other than Itanium/x86-64. Maybe 
> the problem here is that other platforms don't have well-defined ABIs and so 
> we get to make one up? Maybe everyone except me is already aware that that's 
> what we're doing? :)
> At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree 
> on the answer: B and D have exactly the same passing convention. If your 
> patch breaks that, that's a problem.

IIUC (and that's a big "if") being trivial for the purposes of a call, does not 
mean it will _always_ be passed through registers. (For example, we'd never 
pass a 512-byte type through registers.) And, I don't think they do have the 
same calling convention, though they are both passed indirectly. As Akira 
rightly pointed out, on ToT `D` has the `byval` attribute indicating that it 
_could_ be passed directly (according to the ABI/standard at least). While it 
might not be an observable change in the assembly, my patch (or at least the 
current version on phab) removes the byval argument. I have a local version 
that fixes this, though, and I'll upload that shortly. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE 

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

2020-12-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh yes, somehow I overlooked that, sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312538.
ArcsinX added a comment.

`StringRef` => `llvm::StringRef` in one more place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,12 @@
 void relations(const RelationsRequest ,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1291,12 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const Ref ) { Results2.insert(Foo.ID, O); }));
-  

[PATCH] D93395: [clang][cli] Remove -f[no-]trapping-math from -cc1 command line

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

This looks fine to be as that code is definitely dead. I would wait for 
@SjoerdMeijer in case there's a bug in the existing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93395

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


[PATCH] D93436: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice! From here it seems like mostly a question of plumbing/refactoring on the 
clangd side to be able to surface these diagnostics, similar to how you did it 
with config files.

At some point, particularly if we also support .clang-format files, it might 
even be worth reconsidering if there's a lightweight way to become a 
language-server for such files. Less in order to provide quickfixes and code 
completion (which would be huge effort), and more to be able to surface 
diagnostics for files that are opened in the editor (rather than waiting until 
clangd tries to parse them for some other reason)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93436

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


[PATCH] D84672: [clang][cli] Port PreprocessorOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D84672/new/

https://reviews.llvm.org/D84672

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


[PATCH] D93079: [OpenMP] Introduce an assumption to ignore possible external callers

2020-12-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 312535.
jdoerfert added a comment.

Rebase on top of D93439 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93079

Files:
  clang/include/clang/Basic/AttrDocs.td
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  openmp/docs/remarks/OptimizationRemarks.rst

Index: openmp/docs/remarks/OptimizationRemarks.rst
===
--- openmp/docs/remarks/OptimizationRemarks.rst
+++ openmp/docs/remarks/OptimizationRemarks.rst
@@ -25,6 +25,13 @@
 modify the linkage and thereby help optimization with a `static` or
 `__attribute__((internal))` function annotation. If changing the linkage is
 impossible, e.g., because there are outside callers on the host, one can split
-the function into an external visible interface which is not compiled for
-the target and an internal implementation which is compiled for the target
-and should be called from within the target region.
+the function into an external visible interface which is not compiled for the
+target and an internal implementation which is compiled for the target and
+should be called from within the target region. Finally,  we provide an
+assumption for the target side which can be spelled either as
+`__attribute__((assume("omp_no_external_caller_in_target_region")))` or as
+OpenMP assumption, i.a., `#pragma omp begin assume
+ext_no_external_caller_in_target_region`. The assumption effectively allows the
+compiler to assume no caller outside the current translation unit will call the
+function from a target region, hence the function is not called from outside
+translation units on the device.
Index: llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
===
--- llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
+++ llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
@@ -7,12 +7,18 @@
 ; #pragma omp parallel
 ; { }
 ; }
+; __attribute__((assume("no_external_callers")))
+; void baz(void) {
+; #pragma omp parallel
+; { }
+; }
 ; void foo(void) {
 ;   #pragma omp target teams
 ;   {
 ; #pragma omp parallel
 ; {}
 ; bar();
+; baz();
 ; #pragma omp parallel
 ; {}
 ;   }
@@ -23,13 +29,16 @@
 ; another kernel.
 
 ; CHECK-DAG: @__omp_outlined__1_wrapper.ID = private constant i8 undef
+; CHECK-DAG: @__omp_outlined__2b_wrapper.ID = private constant i8 undef
 ; CHECK-DAG: @__omp_outlined__3_wrapper.ID = private constant i8 undef
 
 ; CHECK-DAG:   icmp eq i8* %5, @__omp_outlined__1_wrapper.ID
+; CHECK-DAG:   icmp eq i8* %b6, @__omp_outlined__2b_wrapper.ID
 ; CHECK-DAG:   icmp eq i8* %7, @__omp_outlined__3_wrapper.ID
 
 ; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__1_wrapper.ID)
-; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__2_wrapper to i8*))
+; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__2a_wrapper to i8*))
+; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__2b_wrapper.ID)
 ; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__3_wrapper.ID)
 
 
@@ -69,11 +78,20 @@
 
 .check.next:  ; preds = %.execute.parallel
   %6 = load i8*, i8** %work_fn, align 8
-  %work_match1 = icmp eq i8* %6, bitcast (void ()* @__omp_outlined__2_wrapper to i8*)
-  br i1 %work_match1, label %.execute.fn2, label %.check.next3
+  %work_match1 = icmp eq i8* %6, bitcast (void ()* @__omp_outlined__2a_wrapper to i8*)
+  br i1 %work_match1, label %.execute.fn2a, label %.check.next2
+
+.execute.fn2a: ; preds = %.check.next
+  call void @__omp_outlined__2a_wrapper()
+  br label %.terminate.parallel
+
+.check.next2:  ; preds = %.execute.parallel
+  %b6 = load i8*, i8** %work_fn, align 8
+  %work_match1b = icmp eq i8* %b6, bitcast (void ()* @__omp_outlined__2b_wrapper to i8*)
+  br i1 %work_match1b, label %.execute.fn2b, label %.check.next3
 
-.execute.fn2: ; preds = %.check.next
-  call void @__omp_outlined__2_wrapper()
+.execute.fn2b: ; preds = %.check.next
+  call void @__omp_outlined__2b_wrapper()
   br label %.terminate.parallel
 
 .check.next3: ; preds = %.check.next
@@ -111,6 +129,7 @@
 define internal void @__omp_outlined__() {
   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__1_wrapper to i8*))
   call void @bar()
+  call void @baz()
   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__3_wrapper to i8*))
   

[PATCH] D84671: [clang][cli] Port LangOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D84671/new/

https://reviews.llvm.org/D84671

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


[PATCH] D93458: clang-cl: Remove /Zd flag

2020-12-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

lgtm, but perhaps Reid should take a look




Comment at: clang/docs/ReleaseNotes.rst:127
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.




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

https://reviews.llvm.org/D93458

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


[PATCH] D84670: [clang][cli] Port HeaderSearch simple string options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with nit.




Comment at: clang/include/clang/Driver/Options.td:1815
+  HelpText<"Specify the interval (in seconds) after which a module file will 
be considered unused">,
+  MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 
*60 * 60">;
 def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group,

Missing a space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84670

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked an inline comment as done.
ArcsinX added a comment.

Thank you for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D84668: [clang][cli] Port TargetOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with the fix above.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:264-265
 
+template ::value, bool> = true>
+static void denormalizeSimpleEnum(SmallVectorImpl ,

jansvoboda11 wrote:
> dexonsmith wrote:
> > Once the template is gone from the `unsigned` overload above, I wonder if 
> > we can use `!std::is_convertible` here, and let the `unsigned` 
> > overload directly catch any enums that aren't strongly typed.
> Unfortunately, `std::is_convertible::value == false` when `T` is 
> an `enum class` (and it's the same for `std::is_constructible T>::value`): .
> 
> I didn't find any type trait in the standard library that would have the same 
> semantics as `static_cast`, but we could use something like 
> this: .
I would suggest instead to just rename the `unsigned` version to 
`denormalizeSimpleEnumImpl` and removing the constraints on this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84668

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312530.
ArcsinX added a comment.

`unique_function indexedFiles() const` => 
`unique_function indexedFiles() const`
`StringRef` => `llvm::StringRef` for consistency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,12 @@
 void relations(const RelationsRequest ,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1291,12 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const 

[PATCH] D92290: [clangd] Use clangd's Context mechanism to make the ASTContext of the AST being operated on available everywhere

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry for taking a while to get to this...

I'm not sure this is really a helpful use of Context. (Though some would argue 
that there are no good uses, my manager was appalled when we added it...)
Does this enable some future work, or is it reasonable to evaluate this patch 
in isolation?

There's of course no hard-and-fast rules but my checklist is:

- is this some kind of optional input, like overriding some behavior? (i.e. 
forgetting it isn't terrible, and we needn't burden all callers)
- does the parameter otherwise need to be plumbed through many layers, most of 
which don't use it?
- will parameter otherwise need to be added to public interfaces where they 
don't make sense?

Here it's a mandatory input, and the alternative is cluttering a couple of 
layers of purely-private interfaces, so this seems like a lot of magic to avoid 
a fairly small amount of awkwardness.

(The original use cases for context were around VFS state for embedders, where 
*all* these things were true - the lspEncoding() is another place where this is 
IMO a pretty good tradeoff)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[PATCH] D93464: [analyzer] Refine suppression mechanism to better support AST checks

2020-12-17 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun, mgorny.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit slightly changes the way suppressions were checked before.
Instead of going up from statements and expressions, where bugs were
found, and looking for statements and declarations with attributes,
we traverse function bodies once and map locations with suppressions.

This approach can help with the majority of AST checks that report
directly on source locations.  It is not trivial to map locations
back to nodes, so its much easier to map both nodes and suppressions
to locations and reason only on that level.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93464

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/test/Analysis/suppression-attr.m

Index: clang/test/Analysis/suppression-attr.m
===
--- clang/test/Analysis/suppression-attr.m
+++ clang/test/Analysis/suppression-attr.m
@@ -2,6 +2,9 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=osx.cocoa.MissingSuperCall \
 // RUN:   -analyzer-checker=osx.cocoa.NSError \
+// RUN:   -analyzer-checker=osx.ObjCProperty \
+// RUN:   -analyzer-checker=osx.cocoa.RetainCount \
+// RUN:   -analyzer-checker=alpha.core.CastToStruct \
 // RUN:   -Wno-unused-value -Wno-objc-root-class -verify %s
 
 #define SUPPRESS __attribute__((suppress))
@@ -31,6 +34,9 @@
 + (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
 @end
 
+@interface NSMutableString : NSObject
+@end
+
 void dereference_1() {
   int *x = 0;
   *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
@@ -77,6 +83,28 @@
   SUPPRESS int y = *x; // no-warning
 }
 
+void retain_release_leak_1() {
+  [[NSMutableString alloc] init]; // expected-warning{{Potential leak of an object of type 'NSMutableString *'}}
+}
+
+void retain_release_leak_suppression_1() {
+  SUPPRESS { [[NSMutableString alloc] init]; }
+}
+
+void retain_release_leak_2(int cond) {
+  id obj = [[NSMutableString alloc] init]; // expected-warning{{Potential leak of an object stored into 'obj'}}
+  if (cond) {
+[obj release];
+  }
+}
+
+void retain_release_leak__suppression_2(int cond) {
+  SUPPRESS id obj = [[NSMutableString alloc] init];
+  if (cond) {
+[obj release];
+  }
+}
+
 @interface UIResponder : NSObject {
 }
 - (char)resignFirstResponder;
@@ -84,6 +112,7 @@
 
 @interface Test : UIResponder {
 }
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
 @end
 @implementation Test
 
@@ -98,6 +127,7 @@
 
 @interface TestSuppress : UIResponder {
 }
+@property(copy) SUPPRESS NSMutableString *mutableStr;
 @end
 @implementation TestSuppress
 
@@ -108,3 +138,23 @@
 - (void)methodWhichMayFail:(NSError **)error SUPPRESS { // no-warning
 }
 @end
+
+struct AB {
+  int A, B;
+};
+
+struct ABC {
+  int A, B, C;
+};
+
+void ast_checker_1() {
+  struct AB Ab;
+  struct ABC *Abc;
+  Abc = (struct ABC *) // expected-warning {{Casting data to a larger structure type and accessing a field can lead to memory access errors or data corruption}}
+}
+
+void ast_checker_suppress_1() {
+  struct AB Ab;
+  struct ABC *Abc;
+  SUPPRESS { Abc = (struct ABC *) }
+}
Index: clang/lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Core/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -11,6 +11,7 @@
   BlockCounter.cpp
   BugReporter.cpp
   BugReporterVisitors.cpp
+  BugSuppression.cpp
   CallEvent.cpp
   Checker.cpp
   CheckerContext.cpp
Index: clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
@@ -0,0 +1,184 @@
+//===- BugSuppression.cpp - Suppression interface -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+
+using namespace 

[PATCH] D84669: [clang][cli] Port CodeGenOpts simple string flags to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with the comment.




Comment at: clang/include/clang/Driver/Options.td:2123-2125
 def fpatchable_function_entry_EQ : Joined<["-"], 
"fpatchable-function-entry=">, Group, Flags<[CC1Option]>,
-  MetaVarName<"">, HelpText<"Generate M NOPs before function entry and 
N-M NOPs after function entry">;
+  MetaVarName<"">, HelpText<"Generate M NOPs before function entry and 
N-M NOPs after function entry">,
+  MarshallingInfoStringInt<"CodeGenOpts.PatchableFunctionEntryCount">;

This should have a comment saying that the cc1 semantics are different from the 
driver semantics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84669

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Thanks for clarifying - so the property is being set for C/C++ files but not 
for assembly files. I think it should be set automatically for both when one 
uses clang driver to compile/assemble.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D93102#2460034 , @tmatheson wrote:

> In D93102#2458433 , @aaron.ballman 
> wrote:
>
>> LGTM aside from a minor nit. Thank you for the patch! Do you need me to 
>> commit on your behalf? If so, are you okay with `Tomas Matheson 
>> ` for patch attribution?
>
> Thanks for the review. I will ask for commit access for future but if you 
> could commit this one in the meantime that would be appreciated. That's fine 
> for attribution.

I've commit on your behalf in f50066292477fb26806336e5604615d0eddde399 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

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


[clang] f500662 - Detect section type conflicts between functions and variables

2020-12-17 Thread Aaron Ballman via cfe-commits

Author: Tomas Matheson
Date: 2020-12-17T11:43:47-05:00
New Revision: f50066292477fb26806336e5604615d0eddde399

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

LOG: Detect section type conflicts between functions and variables

If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attributes.c
clang/test/Sema/attr-section.c
clang/test/SemaCXX/attr-section.cpp
clang/test/SemaObjC/method-attributes.m

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ff84eb52e96e..0c5d82b3e9aa 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3086,13 +3086,12 @@ OPT_LIST(V)
   };
 
   struct SectionInfo {
-DeclaratorDecl *Decl;
+NamedDecl *Decl;
 SourceLocation PragmaSectionLocation;
 int SectionFlags;
 
 SectionInfo() = default;
-SectionInfo(DeclaratorDecl *Decl,
-SourceLocation PragmaSectionLocation,
+SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation,
 int SectionFlags)
 : Decl(Decl), PragmaSectionLocation(PragmaSectionLocation),
   SectionFlags(SectionFlags) {}

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ff0257634d9d..6b81494e8eff 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9757,9 +9757,8 @@ class Sema final {
 PSK_CodeSeg,
   };
 
-  bool UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *TheDecl);
+  bool UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *TheDecl);
   bool UnifySection(StringRef SectionName,
 int SectionFlags,
 SourceLocation PragmaSectionLocation);

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index ae6c3ea7313e..5901bd66b7a6 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -481,9 +481,8 @@ void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
   VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
 }
 
-bool Sema::UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *Decl) {
+bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *Decl) {
   SourceLocation PragmaLocation;
   if (auto A = Decl->getAttr())
 if (A->isImplicit())

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 954388dda82e..7750d713f927 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3081,8 +3081,14 @@ static void handleSectionAttr(Sema , Decl *D, const 
ParsedAttr ) {
   }
 
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
-  if (NewAttr)
+  if (NewAttr) {
 D->addAttr(NewAttr);
+if (isa(D))
+  S.UnifySection(NewAttr->getName(),
+ ASTContext::PSF_Execute | ASTContext::PSF_Read,
+ cast(D));
+  }
 }
 
 // This is used for `__declspec(code_seg("segname"))` on a decl.

diff  --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index f6323e9be548..0c1455d3c612 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -63,11 +63,11 @@ void t72() { t71(); }
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
 
-// CHECK: define void @t10() [[NUW]] section "SECT" {
-void t10(void) __attribute__((section("SECT")));
+// CHECK: define void @t10() [[NUW]] section "xSECT" {
+void t10(void) __attribute__((section("xSECT")));
 void t10(void) {}
-// CHECK: define void @t11() [[NUW]] section "SECT" {
-void __attribute__((section("SECT"))) t11(void) {}
+// CHECK: define void @t11() [[NUW]] section "xSECT" {
+void __attribute__((section("xSECT"))) t11(void) {}
 
 // CHECK: define i32 @t19() [[NUW]] {
 extern int t19(void) __attribute__((weak_import));

diff  --git a/clang/test/Sema/attr-section.c b/clang/test/Sema/attr-section.c
index bc4247411130..509c9752d8c3 100644
--- a/clang/test/Sema/attr-section.c
+++ b/clang/test/Sema/attr-section.c
@@ -26,9 +26,27 @@ extern int a __attribute__((section("foo,zed"))); // 
expected-warning {{section
 
 // Not 

[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau planned changes to this revision.
qchateau added a comment.

> Periodic malloc_trim seems like it solves a real problem, one I don't 
> personally fully understand but we may never do - I feel convinced we should 
> use it anyway. It probably has some overhead, who knows how much.

It does indeed look like facing the problem from the wrong side (fight the end 
result instead of finding the root cause) but at that point it does solve an 
annoying problem. As I investigated this, I found that replacing `DenseMap` and 
`StringMap` wtih `std::map` mitigates the issue. I think allocating huge chunks 
of contiguous memory temporarily make this issue worse. Not very useful, but 
hey, I'm just sharing what I observed. As I previously said, resolving this 
problem by changing containers or allocators is a lot of work and is not 
guaranteed to actually solve the issue.

> It's process-wide (not per-thread, and certainly not per-program-module) so 
> the fact that slapping it in FileSymbols::buildIndex solves the problem only 
> proves that function is called periodically :-)
> This is a system-level function, I think we should probably be calling it 
> periodically from something top-level like ClangdMain or ClangdLSPServer.
> (We could almost slip it in with ClangdLSPServer::maybeExportMemoryProfile(), 
> except we don't want to link it to incoming notifications as memory can 
> probably grow while silently background indexing)

It can indeed be called somewhere else, I tried a few different placed before 
submitting this diff. That can be change easily, it's not a problem. I'd also 
like to see it at higher level: my first implementation called it periodically, 
inspired from `maybeExportMemoryProfile`, but I got worried by the background 
index filling the RAM while the user is not in front of his computer, 
`onBackgroundIndexProgress` should address this issue.

> I think we should pass a nonzero `pad` to malloc_trim of several MB. It only 
> affects the main thread, but the main thread is constantly allocating small 
> short-lived objects (e.g. JSON encoding/decoding) and cutting it to the bone 
> only to have it sbrk again seems pointless.

Good point


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

___
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`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Hi @FarisRehman ! Thank you for working on this! Could you add tests?




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:75
 
+  Args.AddAllArgs(CmdArgs, options::OPT_I);
+

This would ideally go to a dedicated method for parsing preprocessor options.



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:13
   std::vector> Macros;
+  std::vector SearchDirectoriesFromI;
 

[nit] I'd be tempted to be more explicit here, e.g. 
`SearchDirectoriesFromDashI;`.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:170
+  // Add the ordered list of -I's.
+  for (const auto *A : args.filtered(clang::driver::options::OPT_I))
+opts.SearchDirectoriesFromI.emplace_back(A->getValue());

Lower case, sadly.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:240-243
-  // These defaults are based on the defaults in f18/f18.cpp.
-  std::vector searchDirectories{"."s};
-  fortranOptions.searchDirectories = searchDirectories;
   fortranOptions.isFixedForm = false;

_Moving_ this code seems like _unrelated_ change.


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] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 312518.
fodinabor added a comment.

Add lit test to ensure behaviour of the -Wno-error=unkown flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if 

[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D93428#2460032 , @danielkiss wrote:

> The `.note.gnu.property` is already generated when C/C++ files are compiled 
> with `-mbranch-protection=bti`.  
> `-mmark-bti-property` is only for assembly file where the 
> `.note.gnu.property` should be added manually otherwise.
>
> Do you have any reproducer where C/C++ behaves unexpectedly?

I think Ana misunderstood the reason for this patch. We haven't seen any 
compilation of C/C++ behaving unexpectedly. -mbranch-protection=bti generates 
the .nute.gnu.property for C/C++ files from our experiments, but doesn't work 
for assembly files. Is there a reason why assembly files have a different flag 
(i.e. -mmark-bti-property) to create the .note.gnu.property with the BTI entry?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

___
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`

2020-12-17 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:228
+  // Note: GCC drops anything following an end-of-line character.
+  llvm::StringRef::size_type End = MacroBody.find_first_of("\n\r");
+  MacroBody = MacroBody.substr(0, End);

This is a change in behavior from f18, right? If so, the commit message should 
mention it and why it's changing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93401

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312508.
ArcsinX added a comment.

Fix comment inside IndexClient::indexedFiles()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,11 @@
 void relations(const RelationsRequest ,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1290,11 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const Ref ) { Results2.insert(Foo.ID, O); }));
-  EXPECT_THAT(std::move(Results2).build(),
- 

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Fantastic, thanks so much!




Comment at: clang-tools-extra/clangd/index/Merge.cpp:129
+StaticContainsFile{Static->indexedFiles()}
+  ](llvm::StringRef FileURI) mutable {
+return DynamicContainsFile(FileURI) || StaticContainsFile(FileURI);

Currently the signature says that the returned function is not const/threadsafe.
If you prefer, you can have it be `unique_function`, 
then the contract is that it's const/threadsafe and you don't need `mutable` 
here.

Up to you though, I can't think of a case where we *need* it to be threadsafe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D93258: [amdgpu] Default to code object v3

2020-12-17 Thread Jon Chesterfield 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 rGdaf39e3f2dba: [amdgpu] Default to code object v3 (authored 
by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-code-object-version.hip
  llvm/docs/AMDGPUUsage.rst


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.
Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@
  HelpText<"Execution model (WebAssembly only)">;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 

[clang] daf39e3 - [amdgpu] Default to code object v3

2020-12-17 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2020-12-17T16:09:33Z
New Revision: daf39e3f2dba18bd39cd89a1c91bae126a31d4fe

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

LOG: [amdgpu] Default to code object v3

[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-code-object-version.hip
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f384e0d993c2..07f15add28ec 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 72bedc16846d..04d0e0771f70 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {

diff  --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 51d9004b0cbf..6e4e96688593 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index 6d3fa7021a7a..c8dda47352ab 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@ The AMDGPU backend uses the following ELF header:
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@ non-AMD key names should be prefixed by "*vendor-name*.".
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@ same *vendor-name*.
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.



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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Wow, all abstractions truly are lies. Thanks for the investigation!

After doing some reading[1], my understanding is roughly:

- our pattern of allocations causes glibc malloc to retain a *much* larger heap 
than our outstanding allocations, growing without (or with large) bound
- malloc maintains several arenas and grows each as needed, and only implicitly 
shrinks them "from the top". A lives-forever object at the end of an arena will 
prevent it implicitly shrinking past that point.
- clangd has lives-almost-forever allocations, e.g. when background indexing 
that could be causing this. If we get unlucky and allocate it at a point when 
the arena happens to be really full, it doesn't matter if the arena spends most 
of its time mostly-empty.
- use of multiple threads means more arenas, and thus more fragmentation/waste.
- malloc_trim() is able to free more aggressively, looking "inside" the arenas 
[2]
- this affects glibc malloc only, which explains why we've only had this 
problem reported on linux and we haven't gotten reports from google-internal 
users (our production binaries use tcmalloc)

Some back-of-the-envelope numbers: I guess we grow until we have enough space 
to satisfy every allocation in every arena, so the wasted space/gaps is 
NumArenas times what you expect, which is 8 * NumCores, which can easily be 500 
on a big workstation - if we expect (wild guess) 80% efficiency = 25% overhead 
for a single-threaded app, then this could yield 12500% overhead = 0.8% 
efficiency at the steady state, which is a 100x increase in memory usage. This 
sounds like a plausible explanation for the bug reports (but I'm not an expert 
and am guessing a lot).

[1] particularly: 
https://stackoverflow.com/questions/38644578/understanding-glibc-malloc-trimming
[2] https://man7.org/linux/man-pages/man3/malloc_trim.3.html - see notes 
regarding glibc 2.8

---

So where does this leave us, other than fairly unimpressed with glibc malloc?

Periodic malloc_trim seems like it solves a real problem, one I don't 
personally fully understand but we may never do - I feel convinced we should 
use it anyway. It probably has some overhead, who knows how much.

We need to work out how to guard it not just for glibc, but also for using 
glibc malloc rather than alternative like jemalloc, tcmalloc et al.
(We could *require* the use of an alternative malloc and not fix this, but that 
doesn't seem terribly practical to me)

It's process-wide (not per-thread, and certainly not per-program-module) so the 
fact that slapping it in FileSymbols::buildIndex solves the problem only proves 
that function is called periodically :-)
This is a system-level function, I think we should probably be calling it 
periodically from something top-level like ClangdMain or ClangdLSPServer.
(We could almost slip it in with ClangdLSPServer::maybeExportMemoryProfile(), 
except we don't want to link it to incoming notifications as memory can 
probably grow while silently background indexing)

I think we should pass a nonzero `pad` to malloc_trim of several MB. It only 
affects the main thread, but the main thread is constantly allocating small 
short-lived objects (e.g. JSON encoding/decoding) and cutting it to the bone 
only to have it sbrk again seems pointless.




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:50
 
+void trimMemory() {
+  if (malloc_trim(0))

this function belongs in `llvm/Support/Process.h`, next to 
Process::GetMallocUsage().

This is full of OS-specific bits (`#ifdef HAVE_MALLINFO`) etc that probably 
guide how we should set this up.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:275
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+

I think this should like in ClangdLSPServer, triggered by all of:
 - various events: outgoing notification, incoming notification, 
onBackgroundIndexProgress()
 - an option specified by ClangdMain (I think it might even be cleanest to 
inject a "PeriodicMemoryCleanup" function via ClangdLSPServer::Options)
 - a timer having expired since the last time we called this - maybe a minute?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


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

2020-12-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

zoecarver wrote:
> ahatanak wrote:
> > zoecarver wrote:
> > > ahatanak wrote:
> > > > It looks like this patch changes the way `D` is passed in the following 
> > > > code:
> > > > 
> > > > ```
> > > > struct B {
> > > >   int i[4];
> > > >   B();
> > > >   B(const B &) = default;
> > > >   B(B &&);
> > > > };
> > > > 
> > > > struct D : B {
> > > >   D();
> > > >   D(const D &) = default;
> > > >   D(D &&) = delete;
> > > > };
> > > > 
> > > > void testB(B a);
> > > > void testD(D a);
> > > > 
> > > > void testCallB() {
> > > >   B b;
> > > >   testB(b);
> > > > }
> > > > 
> > > > void testCallD() {
> > > >   D d;
> > > >   testD(d);
> > > > }
> > > > ```
> > > > 
> > > > `B` cannot be passed in registers because it has a non-trivial move 
> > > > constructor, whereas `D` can be passed in registers because the move 
> > > > constructor is deleted and the copy constructor is trivial.
> > > > 
> > > > I'm not sure what the best way to handle this is, but I just wanted to 
> > > > point this out.
> > > Hmm. Good catch. One way to fix this would be to simply create a 
> > > `HasPassableSubobject` variable and add that to the conditions below 
> > > (instead of returning false here). But, it seems that `D` isn't passed by 
> > > registers (even though, maybe it should be) on ToT: 
> > > https://godbolt.org/z/4xevW5 
> > > 
> > > Given that, do you think it's OK to return false here, or should I update 
> > > this patch to use the logic I just described (even though that would be a 
> > > nfc)? 
> > The argument is byval, so `D` is passed directly. If you remove `-O3` and 
> > add `-target aarch64`, you'll see that `[2 x i64]` is being passed
> Ah, I see now. Great. Thanks. I'll update the patch. 
Akira's example is legal C++ with no Clang-specific attributes, so its behavior 
is governed by the appropriate platform's ABI doc — there exists one correct 
answer.
At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree on 
the answer: `B` and `D` have exactly the same passing convention. If your patch 
breaks that, that's a problem.
Contrariwise, it appears that `B` and `D` have different passing conventions on 
"armv8" according to Clang, and the same passing convention on "ARM64" 
according to GCC: https://godbolt.org/z/j9jzYG
Of course if the programmer adds `[[clang::trivial_abi]]` to one of them, then 
all bets are off, standards-wise, and you're free to figure out a way to pass 
it in registers if you want to. But otherwise I think you have to follow what 
the ABI says.
Bear in mind that I don't really know ABIs other than Itanium/x86-64. Maybe the 
problem here is that other platforms don't have well-defined ABIs and so we get 
to make one up? Maybe everyone except me is already aware that that's what 
we're doing? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


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

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@FarisRehman, thank you for working on this! This looks really good and I think 
that it's almost ready. I did leave a few comments, but most are a matter of 
style and should be easy to address.




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:70-71
+  types::ID InputType = Input.getType();
+  if (types::getPreprocessedType(InputType) != types::TY_INVALID) {
+Args.AddAllArgs(CmdArgs, {options::OPT_D, options::OPT_U});
+  }

Clang deals with the preprocessor options in a dedicated method, 
`AddPreprocessingOptions`. See here: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/clang/lib/Driver/ToolChains/Clang.cpp#L1077

I feel that it might be a good idea to follow that. The preprocessor options 
(and the corresponding logic) are bound to grow, so we may as well add a 
dedicated method sooner rather than later.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:73
+  }
+  Args.ClaimAllArgs(options::OPT_D);
+

AFAIK, when you call `AddAllArgs` the corresponding options are eventually 
_claimed_: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/llvm/lib/Option/ArgList.cpp#L112
So, IIUC, this line is not needed.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:77
 
-  const auto& D = C.getDriver();
   // TODO: Replace flang-new with flang once the new driver replaces the

This change is not needed, is it?



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:32
 
+  Fortran::frontend::PreprocessorOptions preprocessorOpts_;
+

1. Could you add a comment explaining what this is for?

2. Could you follow the current semantics used in the file and make it a 
`std::shared_ptr`? Long term we can expect `PreprocessorOptions` to grow big 
and at that point we wouldn't want to copy it too often (especially when 
compiling a lot of files).



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:84
   // compiler driver options in libclangDriver.
-  void SetDefaultFortranOpts();
+  void SetFortranOpts();
 };

IIUC, you are renaming this method because it is finally translating the user 
provided options (i.e. preprocessorOpts()) into Frontend options (i.e. 
`fortranOptions`). However, with your changes this method:
* sets some _sane_ predefined defaults
* adds some stuff from the user (the preprocessor defines)

So it's somewhere in between `SetDefaultFortranOpts` and `SetFortranOpts` (i.e. 
both names are _almost_ accurate). Perhaps splitting this into two methods 
would be better? E.g.:
* `SetDefaultFortranOpts` (leave as is)
* `SetFortranOpts` (implements new functionality, to replace 
`SetDefaultFortranOpts`  eventually)



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:1
+#ifndef LLVM_FLANG_PREPROCESSOROPTIONS_H
+#define LLVM_FLANG_PREPROCESSOROPTIONS_H

Missing file header: https://llvm.org/docs/CodingStandards.html#file-headers



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:8
+
+/// PreprocessorOptions - This class is used for passing the various options
+/// used in preprocessor initialization to the parser options.

[nit] No need to repeat the name of the class.



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:12
+public:
+  std::vector> Macros;
+

[nit] IMO this would be preferred : `/*isUndef=*/bool` 
(https://llvm.org/docs/CodingStandards.html#comment-formatting) (currently you 
have `bool /*isUndef*/`)



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:157
 
+static void ParsePreprocessorArgs(
+Fortran::frontend::PreprocessorOptions , llvm::opt::ArgList ) {

I couldn't find any notes on naming static functions here: 
https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md. This 
means that we fallow this: 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly.
 So, `parsePreprocessorArgs` instead of `ParsePreprocessorArgs`.

Also, could you add a comment briefly explaining what the method is for? E.g. 
`Parses all preprocessor input arguments and populates the preprocessor options 
accordingly`? Ideally doxygen :) See example here: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/flang/include/flang/Frontend/CompilerInstance.h#L158-L163



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:160
+  // Add macros from the command line.
+  for (const auto *A : args.filtered(
+   clang::driver::options::OPT_D, clang::driver::options::OPT_U)) {

Variable names should start with lower case.

[nit] Perhaps `currentArg` instead of `A` for the sake of being explicit?  Or 
`curArg`?




[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 312500.
qchateau added a comment.
Herald added a subscriber: mgorny.

Add macro to use malloc_trim only if available


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -41,10 +42,21 @@
 #include 
 #include 
 
+#ifdef HAVE_MALLOC_TRIM
+#include 
+#endif // HAVE_MALLOC_TRIM
+
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+#ifdef HAVE_MALLOC_TRIM
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+#endif // HAVE_MALLOC_TRIM
+}
+
 SlabTuple indexSymbols(ASTContext , std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +275,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -154,6 +154,13 @@
   clangdSupport
   )
 
+check_symbol_exists(malloc_trim malloc.h HAVE_MALLOC_TRIM)
+if (HAVE_MALLOC_TRIM)
+  target_compile_definitions(obj.clangDaemon
+PRIVATE HAVE_MALLOC_TRIM
+)
+endif ()
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -41,10 +42,21 @@
 #include 
 #include 
 
+#ifdef HAVE_MALLOC_TRIM
+#include 
+#endif // HAVE_MALLOC_TRIM
+
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+#ifdef HAVE_MALLOC_TRIM
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+#endif // HAVE_MALLOC_TRIM
+}
+
 SlabTuple indexSymbols(ASTContext , std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +275,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -154,6 +154,13 @@
   clangdSupport
   )
 
+check_symbol_exists(malloc_trim malloc.h HAVE_MALLOC_TRIM)
+if (HAVE_MALLOC_TRIM)
+  target_compile_definitions(obj.clangDaemon
+PRIVATE HAVE_MALLOC_TRIM
+)
+endif ()
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

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

In D93459#2460445 , @fodinabor wrote:

> Btw. is there a way to add tests for command-line options, so this won't 
> happen unnoticed again?

I'd guess some lit tests could be used to verify the command line syntax is 
correct

  // RUN: clang-format --Wno-error=unknown --style=`{UnknownKey: true}` 
--dump-config

If it can't parse that command line, or it maybe parses it incorrectly, 
clang-format will return non-zero and fail the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

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


[PATCH] D93103: Enable the _ExtInt extension on the BPF Target

2020-12-17 Thread Sean Young via Phabricator via cfe-commits
seanyoung added a comment.

Patch submitted 
https://lore.kernel.org/bpf/20201217150102.ga13...@gofer.mess.org/T/#u


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93103

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


[PATCH] D92800: [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 Thread Zequan Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb0f7288051e: [Clang] Make nomerge attribute a function 
attribute as well as a statement… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-nomerge.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  llvm/include/llvm/IR/Attributes.td

Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -124,7 +124,7 @@
 /// Function is called early and/or often, so lazy binding isn't worthwhile.
 def NonLazyBind : EnumAttr<"nonlazybind">;
 
-/// Disable merging for call sites
+/// Disable merging for specified functions or call sites.
 def NoMerge : EnumAttr<"nomerge">;
 
 /// Pointer is known to be not null.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2693,6 +2693,7 @@
   { "ATTR", "Attr" },
   { "TYPE_ATTR", "TypeAttr" },
   { "STMT_ATTR", "StmtAttr" },
+  { "DECL_OR_STMT_ATTR", "DeclOrStmtAttr" },
   { "INHERITABLE_ATTR", "InheritableAttr" },
   { "DECL_OR_TYPE_ATTR", "DeclOrTypeAttr" },
   { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" },
@@ -3779,7 +3780,8 @@
 OS << (Attr.isSubClassOf("TypeAttr") ||
Attr.isSubClassOf("DeclOrTypeAttr")) << ";\n";
 OS << "IsStmt = ";
-OS << Attr.isSubClassOf("StmtAttr") << ";\n";
+OS << (Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr"))
+   << ";\n";
 OS << "IsKnownToGCC = ";
 OS << IsKnownToGCC(Attr) << ";\n";
 OS << "IsSupportedByPragmaAttribute = ";
Index: clang/test/Sema/attr-nomerge.cpp
===
--- clang/test/Sema/attr-nomerge.cpp
+++ clang/test/Sema/attr-nomerge.cpp
@@ -8,10 +8,10 @@
   int x;
   [[clang::nomerge]] x = 10; // expected-warning {{nomerge attribute is ignored because there exists no call expression inside the statement}}
 
-  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
 
 }
 
-int f();
+[[clang::nomerge]] int f();
 
-[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -92,6 +92,7 @@
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
 // CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
Index: clang/test/CodeGen/attr-nomerge.cpp
===
--- clang/test/CodeGen/attr-nomerge.cpp
+++ clang/test/CodeGen/attr-nomerge.cpp
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
 
-bool bar();
-void f(bool, bool);
+class A {
+public:
+  [[clang::nomerge]] A();
+  [[clang::nomerge]] ~A();
+  [[clang::nomerge]] void f();
+  [[clang::nomerge]] virtual void g();
+  [[clang::nomerge]] static void f1();
+};
 
-void foo(int i) {
+class B : public A {
+public:
+  void g() override;
+};
+
+[[clang::nomerge]] bool bar();
+[[clang::nomerge]] void f(bool, bool);
+
+void foo(int i, A *ap, B *bp) {
   [[clang::nomerge]] bar();
   [[clang::nomerge]] (i = 4, bar());
   [[clang::nomerge]] (void)(bar());
@@ -12,18 +26,68 @@
   [[clang::nomerge]] for (bar(); bar(); bar()) {}
   [[clang::nomerge]] { asm("nop"); }
   bar();
+
+  ap->g();
+  bp->g();
+
+  A a;
+  a.f();
+  a.g();
+  A::f1();
+
+  B b;
+  b.g();
+}
+
+int g(int i);
+
+void something() {
+  g(1);

[clang] fb0f728 - [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-12-17T07:45:38-08:00
New Revision: fb0f7288051eb2745bb9211306f53ff9aa6f73e2

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

LOG: [Clang] Make nomerge attribute a function attribute as well as a statement 
attribute.

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

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attr-nomerge.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-nomerge.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
llvm/include/llvm/IR/Attributes.td

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 8d9fb8f2bf27..e453733ab92c 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -162,6 +162,21 @@ class InheritableAttr : public Attr {
   }
 };
 
+class DeclOrStmtAttr : public InheritableAttr {
+protected:
+  DeclOrStmtAttr(ASTContext , const AttributeCommonInfo ,
+ attr::Kind AK, bool IsLateParsed,
+ bool InheritEvenIfAlreadyPresent)
+  : InheritableAttr(Context, CommonInfo, AK, IsLateParsed,
+InheritEvenIfAlreadyPresent) {}
+
+public:
+  static bool classof(const Attr *A) {
+return A->getKind() >= attr::FirstDeclOrStmtAttr &&
+   A->getKind() <= attr::LastDeclOrStmtAttr;
+  }
+};
+
 class InheritableParamAttr : public InheritableAttr {
 protected:
   InheritableParamAttr(ASTContext ,

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7d566e64c99b..ce2ee40dc036 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -570,6 +570,9 @@ class InheritableAttr : Attr {
 /// attributes, but have historically been written on declarations.
 class DeclOrTypeAttr : InheritableAttr;
 
+/// A attribute is either a declaration attribute or a statement attribute.
+class DeclOrStmtAttr : InheritableAttr;
+
 /// A target-specific attribute.  This class is meant to be used as a mixin
 /// with InheritableAttr or Attr depending on the attribute's needs.
 class TargetSpecificAttr {
@@ -1317,9 +1320,12 @@ def Unlikely : StmtAttr {
   let Documentation = [LikelihoodDocs];
 }
 
-def NoMerge : StmtAttr {
+def NoMerge : DeclOrStmtAttr {
   let Spellings = [Clang<"nomerge">];
   let Documentation = [NoMergeDocs];
+  let InheritEvenIfAlreadyPresent = 1;
+  let Subjects = SubjectList<[Function], ErrorDiag, "functions and 
statements">;
+  let SimpleHandler = 1;
 }
 
 def FastCall : DeclOrTypeAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 4f8cd8ecd86f..c3a412158aba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -386,7 +386,11 @@ location of certain calls. For example, it will prevent 
tail merging otherwise
 identical code sequences that raise an exception or terminate the program. Tail
 merging normally reduces the precision of source location information, making
 stack traces less useful for debugging. This attribute gives the user control
-over the tradeoff between code size and debug information precision.
+over the tradeoff between code size and debug information precision. 
+
+``nomerge`` attribute can also be used as function attribute to prevent all 
+calls to the specified function from merging. It has no effect on indirect 
+calls.
   }];
 }
 

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 28a7d128505a..bfc7b8e74d8f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1968,6 +1968,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 NBA = Fn->getAttr();
   }
+  if (!AttrOnCallSite && TargetDecl->hasAttr())
+FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.
@@ -4978,11 +4980,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);
 
-  // Add call-site nomerge attribute if exists.
-  if (InNoMergeAttributedStmt)
-Attrs =
-  Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
- llvm::Attribute::NoMerge);
+  // Add nomerge attribute to the call-site if the callee function doesn't have
+  // the attribute.
+  if (const FunctionDecl 

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312497.
ArcsinX added a comment.

Make `indexedFiles()` to return `[](StringRef){return false;}` instead of 
`nullptr`.
Add comments.
Do not call `indexedFiles()` at every file check for `MergeIndex`.
Consume error if `URI::resolve()` fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,11 @@
 void relations(const RelationsRequest ,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1290,11 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   

[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau added a comment.

> Side note is this memory failing to free behaviour observed on windows?

No idea, I only develop on linux. Looking at the the github issues, it seems 
people that had the issue were also using the linux version...so we can't 
conclude anything about windows




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:51
+void trimMemory() {
+  if (malloc_trim(0))
+vlog("Trimmed memory");

njames93 wrote:
> It may be helpful to log how many times this call fails to free any memory.
From what I observed, it (almost?) never fails to free memory, although 
sometimes it's only a few kB.
Anyway, are you suggesting to keep track of how many time we call `malloc_trim` 
and how many times it fails ? Or simply logging when it fails ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92577#2458903 , @rjmccall wrote:

> Please test that there's actually an object declared and that it's not *just* 
> a tag declaration.

Good catch, I've corrected this and added some more test coverage.


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

https://reviews.llvm.org/D92577

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 312494.
aaron.ballman added a comment.

Updating based on review feedback.


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

https://reviews.llvm.org/D92577

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/for.c


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,7 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of 
non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of 
non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of 
non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error 
{{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error 
{{declaration of non-local variable}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,13 +1822,28 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
-  for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
+  for (auto Iter = DS->decl_begin(), End = DS->decl_end(); Iter != End;
+   ++Iter) {
+VarDecl *VD = dyn_cast(*Iter);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
+
 if (!VD) {
-  Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-  DI->setInvalidDecl();
+  // It is possible to declare non-variable declarations as part of the
+  // declaration part of a 'for' statement, such as defining a 
structure
+  // or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+  if (isa(*Iter)) {
+// The declaration immediately after the tag decl needs to be a
+// variable declaration. We don't care if it's a valid variable
+// declaration because the validity will be checked on the next
+// iteration through the declarations in the group.
+if (Iter + 1 == End || !isa(*(Iter + 1)))
+  Diag((*Iter)->getLocation(), diag::err_non_variable_decl_in_for);
+  } else {
+Diag((*Iter)->getLocation(),
+ diag::err_non_local_variable_decl_in_for);
+(*Iter)->setInvalidDecl();
+  }
 }
   }
 }


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,7 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error {{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error {{declaration of non-local variable}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,13 +1822,28 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
-  for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
+  for (auto Iter = DS->decl_begin(), End = DS->decl_end(); Iter != End;
+   ++Iter) {
+VarDecl *VD = dyn_cast(*Iter);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
+
 if (!VD) {
-  Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-  DI->setInvalidDecl();
+  // It is possible to declare non-variable declarations as part of the
+  // declaration part of a 'for' statement, such as defining a structure
+  // or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+  if (isa(*Iter)) {
+// The declaration immediately after the tag decl needs to be a
+// variable declaration. We don't care if it's a valid variable
+// declaration because the validity will be checked on the next
+// iteration through the declarations in the group.
+if (Iter + 1 == End || !isa(*(Iter 

[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2020-12-17 Thread luxufan via Phabricator via cfe-commits
StephenFan added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td:102
+: InstAlias;
+

use GPR as instruction operand may cause the codegen part of zfinx report 
errors. Because the GPR has data type i32 or i64, However, the zfinx will deal 
with the data type f64 or f32.


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

https://reviews.llvm.org/D93298

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


[PATCH] D91444: [InstCombine] Preserve !annotation on newly created instructions.

2020-12-17 Thread Florian Hahn 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 rG01089c876bff: [InstCombine] Preserve !annotation on newly 
created instructions. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D91444?vs=312216=312490#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91444

Files:
  clang/test/CodeGenCXX/auto-var-init.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/annotations.ll

Index: llvm/test/Transforms/InstCombine/annotations.ll
===
--- llvm/test/Transforms/InstCombine/annotations.ll
+++ llvm/test/Transforms/InstCombine/annotations.ll
@@ -49,8 +49,8 @@
 
 define void @copy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @copy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -61,8 +61,8 @@
 
 define void @libcallcopy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memcpy(i8* %d, i8* %s, i64 1), !annotation !0
@@ -73,8 +73,8 @@
 
 define void @libcallcopy_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memcpy_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -85,8 +85,8 @@
 
 define void @move_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @move_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memmove.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -97,8 +97,8 @@
 
 define void @libcallmove_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memmove(i8* %d, i8* %s, i64 1), !annotation !0
@@ -109,8 +109,8 @@
 
 define void @libcallmove_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memmove_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -121,7 +121,7 @@
 
 define void @set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memset.p0i8.i32(i8* %d, i8 1, i32 1, i1 false), !annotation !0
@@ -132,7 +132,7 @@
 
 define void @libcall_set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memset(i8* %d, i32 1, i64 1), !annotation !0
@@ -143,7 +143,7 @@
 
 define void @libcall_set_1_byte_chk(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte_chk({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memset_chk(i8* %d, i32 

  1   2   >