[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7759-7761
+  // The default setting for PointerAlignment is PAS_Right.
+  // But if we set PointerAlignment as PAS_Left, the formatter
+  // would mis-format the pointer alignment.

ChuanqiXu wrote:
> HazardyKnusperkeks wrote:
> > I don't think this should be in the tests, because it is not true (if your 
> > patch works).
> I'm confusing about your comment. What is not true? Do you mean if my patch 
> works then the `co_return *a;` should be formatted as `co_return* a`?
No, I refer to the comment. You say `would mis-format`, but it wouln't because 
of your change, or not? Otherwise the tests would not pass.


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

https://reviews.llvm.org/D91245

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


[PATCH] D92155: Load plugins when creating a CompilerInvocation.

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

In D92155#2453597 , @psionic12 wrote:

> In D92155#2450474 , @nridge wrote:
>
>> Something just occurred to me: can't clangd arguments also be controlled by 
>> the untrusted repository by having a `.vscode/settings.json` file with 
>> specificed `"clangd.arguments"` checked in?

Hmm, maybe... I thought `getConfiguration('clangd')` with no scope specified 
was supposed to be global (i.e. not a workspace-specific setting). There's a 
scope you can pass in, and we're not providing one.

Nevertheless testing it locally these flags do seem to be used. We should fix 
this, I think `workspace.getConfiguration('clangd').inspect('arguments')` and 
then applying the components manually makes it possible. This is a horrible 
breaking change, though :-(

Alternatives would be treating clangd args as untrusted too, conceding that 
opening a file in vscode can own the user, some list of safe flags...

> Yeah, there are too many ways to pass an argument without user's awareness, 
> all the safety protections we talked about aren't help much, and I think this 
> is not the clangd's problem, it exists in clang as well. So I think loading 
> plugin codes guarded with CLANG_PLUGIN_SUPPORT on is enough, no more 
> complicity protections should added.

I can't agree with this, even if other problems exist, it's not OK to introduce 
a big problem with a broad scope, when we have alternatives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92155

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


[PATCH] D93220: [clangd] Add error handling (elog) in code completion.

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



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:193
+} else {
+  elog("Code completion header path manipulation failed {0}",
+   HeaderFile.takeError());

I think this is too noisy.

We can hit this in "normal" cases of certain projects.
For better or worse, we don't currently filter out index results where we know 
the responsible header and can't include it (because it's not under any include 
path entry). In these cases toHeaderFile() returns an error.

Since this can happen in the normal case for *each* completion candidate 
(default 100), and completion requests are very frequent, this could dominate 
log output in affected projects.

It *might* be OK at vlog? I get the desire to not silence errors here. I think 
the question is what are the error cases we're *trying* to call out loudly. 
Maybe we can separate out the "shouldn't happen" vs the "fairly expected" cases.
(Even then there's the prospect that this is either going to not fire or fire 
dozens of times, which is a little sad)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93220

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


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

2020-12-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Very nice, thanks!
I'll land this for you now.


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

https://reviews.llvm.org/D92041

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


[PATCH] D92155: Load plugins when creating a CompilerInvocation.

2020-12-15 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D92155#2454175 , @sammccall wrote:

> I thought `getConfiguration('clangd')` with no scope specified was supposed 
> to be global (i.e. not a workspace-specific setting). There's a scope you can 
> pass in, and we're not providing one.
>
> Nevertheless testing it locally these flags do seem to be used. We should fix 
> this, I think `workspace.getConfiguration('clangd').inspect('arguments')` and 
> then applying the components manually makes it possible. This is a horrible 
> breaking change, though :-(

Apart from the breaking nature of the change, I think being able to specify 
`"clangd.arguments"` per-workspace is a very important use case (to take the 
most obvious example, `--compile-commands-dir` is workspace-specific).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92155

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

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



Comment at: clang/unittests/Format/FormatTest.cpp:7759-7761
+  // The default setting for PointerAlignment is PAS_Right.
+  // But if we set PointerAlignment as PAS_Left, the formatter
+  // would mis-format the pointer alignment.

HazardyKnusperkeks wrote:
> ChuanqiXu wrote:
> > HazardyKnusperkeks wrote:
> > > I don't think this should be in the tests, because it is not true (if 
> > > your patch works).
> > I'm confusing about your comment. What is not true? Do you mean if my patch 
> > works then the `co_return *a;` should be formatted as `co_return* a`?
> No, I refer to the comment. You say `would mis-format`, but it wouln't 
> because of your change, or not? Otherwise the tests would not pass.



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

https://reviews.llvm.org/D91245

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


[clang-tools-extra] 9c328e7 - [clangd] Add hover info for `this` expr

2020-12-15 Thread Sam McCall via cfe-commits

Author: xndcn
Date: 2020-12-15T09:47:29+01:00
New Revision: 9c328e7afafd15795fed54e3b0c1c5bd4fa97dfa

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

LOG: [clangd] Add hover info for `this` expr

How about add hover information for `this` expr?
It seems useful to show related information about the class for `this` expr 
sometimes.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index d599ccb557c2..e461c7c43364 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -552,7 +552,8 @@ HoverInfo getHoverContents(const NamedDecl *D, const 
SymbolIndex *Index) {
 
 /// Generate a \p Hover object given the type \p T.
 HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
-   const SymbolIndex *Index) {
+   const SymbolIndex *Index,
+   bool SuppressScope = false) {
   HoverInfo HI;
 
   if (const auto *D = T->getAsTagDecl()) {
@@ -566,6 +567,7 @@ HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
 // Builtin types
 auto Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
 Policy.SuppressTagKeyword = true;
+Policy.SuppressScope = SuppressScope;
 HI.Name = T.getAsString(Policy);
   }
   return HI;
@@ -628,15 +630,29 @@ llvm::StringLiteral getNameForExpr(const Expr *E) {
   return llvm::StringLiteral("expression");
 }
 
-// Generates hover info for evaluatable expressions.
+// Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
-llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
+llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST,
+   const SymbolIndex *Index) {
   // There's not much value in hovering over "42" and getting a hover card
   // saying "42 is an int", similar for other literals.
   if (isLiteral(E))
 return llvm::None;
 
   HoverInfo HI;
+  // For `this` expr we currently generate hover with pointee type.
+  if (const CXXThisExpr *CTE = dyn_cast(E)) {
+QualType OriginThisType = CTE->getType()->getPointeeType();
+QualType ClassType = declaredType(OriginThisType->getAsTagDecl());
+// For partial specialization class, origin `this` pointee type will be
+// parsed as `InjectedClassNameType`, which will ouput template arguments
+// like "type-parameter-0-0". So we retrieve user written class type in 
this
+// case.
+QualType PrettyThisType = AST.getASTContext().getPointerType(
+QualType(ClassType.getTypePtr(), OriginThisType.getCVRQualifiers()));
+return getHoverContents(PrettyThisType, AST.getASTContext(), Index,
+/*SuppressScope=*/true);
+  }
   // For expressions we currently print the type and the value, iff it is
   // evaluatable.
   if (auto Val = printExprValue(E, AST.getASTContext())) {
@@ -861,7 +877,7 @@ llvm::Optional getHover(ParsedAST &AST, Position 
Pos,
   HI->Value = printExprValue(N, AST.getASTContext());
 maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
   } else if (const Expr *E = N->ASTNode.get()) {
-HI = getHoverContents(E, AST);
+HI = getHoverContents(E, AST, Index);
   }
   // FIXME: support hovers for other nodes?
   //  - built-in types

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index fdebf0da6710..bac0e525664b 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,6 +2019,56 @@ TEST(Hover, All) {
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+  // comment
+  namespace ns {
+class Foo {
+  Foo* bar() {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "Foo *"; }},
+  {
+  R"cpp(// this expr for template class
+  namespace ns {
+template 
+class Foo {
+  Foo* bar() const {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "const Foo *"; }},
+  {
+  R"cpp(// this expr for specialization class
+  namespace ns {
+template  class Foo {};
+t

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

2020-12-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c328e7afafd: [clangd] Add hover info for `this` expr 
(authored by xndcn, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92041

Files:
  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
@@ -2019,6 +2019,56 @@
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+  // comment
+  namespace ns {
+class Foo {
+  Foo* bar() {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "Foo *"; }},
+  {
+  R"cpp(// this expr for template class
+  namespace ns {
+template 
+class Foo {
+  Foo* bar() const {
+return [[t^his]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "const Foo *"; }},
+  {
+  R"cpp(// this expr for specialization class
+  namespace ns {
+template  class Foo {};
+template <>
+struct Foo {
+  Foo* bar() {
+return [[thi^s]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "Foo *"; }},
+  {
+  R"cpp(// this expr for partial specialization struct
+  namespace ns {
+template  struct Foo {};
+template 
+struct Foo {
+  Foo* bar() const {
+return [[thi^s]];
+  }
+};
+  }
+  )cpp",
+  [](HoverInfo &HI) { HI.Name = "const Foo *"; }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -552,7 +552,8 @@
 
 /// Generate a \p Hover object given the type \p T.
 HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx,
-   const SymbolIndex *Index) {
+   const SymbolIndex *Index,
+   bool SuppressScope = false) {
   HoverInfo HI;
 
   if (const auto *D = T->getAsTagDecl()) {
@@ -566,6 +567,7 @@
 // Builtin types
 auto Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
 Policy.SuppressTagKeyword = true;
+Policy.SuppressScope = SuppressScope;
 HI.Name = T.getAsString(Policy);
   }
   return HI;
@@ -628,15 +630,29 @@
   return llvm::StringLiteral("expression");
 }
 
-// Generates hover info for evaluatable expressions.
+// Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
-llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
+llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST,
+   const SymbolIndex *Index) {
   // There's not much value in hovering over "42" and getting a hover card
   // saying "42 is an int", similar for other literals.
   if (isLiteral(E))
 return llvm::None;
 
   HoverInfo HI;
+  // For `this` expr we currently generate hover with pointee type.
+  if (const CXXThisExpr *CTE = dyn_cast(E)) {
+QualType OriginThisType = CTE->getType()->getPointeeType();
+QualType ClassType = declaredType(OriginThisType->getAsTagDecl());
+// For partial specialization class, origin `this` pointee type will be
+// parsed as `InjectedClassNameType`, which will ouput template arguments
+// like "type-parameter-0-0". So we retrieve user written class type in this
+// case.
+QualType PrettyThisType = AST.getASTContext().getPointerType(
+QualType(ClassType.getTypePtr(), OriginThisType.getCVRQualifiers()));
+return getHoverContents(PrettyThisType, AST.getASTContext(), Index,
+/*SuppressScope=*/true);
+  }
   // For expressions we currently print the type and the value, iff it is
   // evaluatable.
   if (auto Val = printExprValue(E, AST.getASTContext())) {
@@ -861,7 +877,7 @@
   HI->Value = printExprValue(N, AST.getASTContext());
 maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
   } else if (const Expr *E = N->ASTNode.get()) {
-HI = getHoverContents(E, AST);
+HI = getHoverContents

[PATCH] D93240: [clang-format] Add SpaceBeforeCaseColon option

2020-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I generally don't have the same aversion to new options than others have, but 
can you point out a style guide that might want this option. (that is kind of 
the process)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93240

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


[PATCH] D93240: [clang-format] Add SpaceBeforeCaseColon option

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



Comment at: clang/unittests/Format/FormatTest.cpp:12115
+   "  break;\n"
"}",
InheritanceStyle);

maybe add a `default` example with {}

try not to change existing tests just add your own new ones



Comment at: clang/unittests/Format/FormatTest.cpp:12158
"default:\n"
+   "  break;\n"
"}",

Add new test leave the old one alone


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93240

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


[clang] f24e58d - [clang][cli] Create accessors for exception models in LangOptions

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

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: f24e58df7ddf2dc9f13c8f8fc259f0374f04aca3

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

LOG: [clang][cli] Create accessors for exception models in LangOptions

This abstracts away the members that are being replaced in a follow-up patch.

Depends on D83979.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/Frontend/InitPreprocessor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 203c45fdd9a7..d4791650ec6b 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -380,6 +380,11 @@ class LangOptions : public LangOptionsBase {
   bool isSignReturnAddressScopeAll() const {
 return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
   }
+
+  bool hasSjLjExceptions() const { return SjLjExceptions; }
+  bool hasSEHExceptions() const { return SEHExceptions; }
+  bool hasDWARFExceptions() const { return DWARFExceptions; }
+  bool hasWasmExceptions() const { return WasmExceptions; }
 };
 
 /// Floating point control options

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 554688ac987b..2dbf30ef171f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -497,13 +497,13 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   // Set EABI version.
   Options.EABIVersion = TargetOpts.EABIVersion;
 
-  if (LangOpts.SjLjExceptions)
+  if (LangOpts.hasSjLjExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
-  if (LangOpts.SEHExceptions)
+  if (LangOpts.hasSEHExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
-  if (LangOpts.DWARFExceptions)
+  if (LangOpts.hasDWARFExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
-  if (LangOpts.WasmExceptions)
+  if (LangOpts.hasWasmExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
   Options.NoInfsFPMath = LangOpts.NoHonorInfs;

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 85604cf5e611..f8a486909e41 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -121,11 +121,11 @@ static const EHPersonality &getCPersonality(const 
TargetInfo &Target,
   const llvm::Triple &T = Target.getTriple();
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_C_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_C;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_C_SEH;
   return EHPersonality::GNU_C;
 }
@@ -149,9 +149,9 @@ static const EHPersonality &getObjCPersonality(const 
TargetInfo &Target,
 LLVM_FALLTHROUGH;
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
-if (L.SjLjExceptions)
+if (L.hasSjLjExceptions())
   return EHPersonality::GNU_ObjC_SJLJ;
-if (L.SEHExceptions)
+if (L.hasSEHExceptions())
   return EHPersonality::GNU_ObjC_SEH;
 return EHPersonality::GNU_ObjC;
   }
@@ -165,13 +165,13 @@ static const EHPersonality &getCXXPersonality(const 
TargetInfo &Target,
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (T.isOSAIX())
 return EHPersonality::XL_CPlusPlus;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_CPlusPlus_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_CPlusPlus;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (L.WasmExceptions)
+  if (L.hasWasmExceptions())
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
@@ -476,7 +476,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TODO Correctly handle exception specification in wasm
-if (CGM.getLangOpts().WasmExceptions) {
+if (CGM.getLangOpts().hasWasmExceptions()) {
   if (EST == EST_DynamicNone)
 EHStack.pushTerminate();
   else
@@ -564,7 +564,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TO

[clang] 573255b - [clang][cli] Squash exception model in LangOptions into one member

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

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: 573255b47eb9b210e74a1c620fee363dfaa52794

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

LOG: [clang][cli] Squash exception model in LangOptions into one member

This squashes multiple members in LangOptions into one. This is leveraged in a 
follow-up patch that implements marshalling of related command-line options.

Depends on D93214.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 19fb4ae82b89..251fd68f4df8 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -129,10 +129,8 @@ LANGOPT(ZVector   , 1, 0, "System z vector 
extensions")
 LANGOPT(Exceptions, 1, 0, "exception handling")
 LANGOPT(ObjCExceptions, 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
-LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
-LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
-LANGOPT(SEHExceptions , 1, 0, "SEH .xdata exception handling")
-LANGOPT(WasmExceptions, 1, 0, "WebAssembly exception handling")
+ENUM_LANGOPT(ExceptionHandling, ExceptionHandlingKind, 3,
+ ExceptionHandlingKind::None, "exception handling")
 LANGOPT(IgnoreExceptions  , 1, 0, "ignore exceptions")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d4791650ec6b..2780e4bf35fd 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -22,6 +22,7 @@
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCTargetOptions.h"
 #include 
 #include 
 
@@ -209,6 +210,9 @@ class LangOptions : public LangOptionsBase {
 FPE_Strict
   };
 
+  /// Possible exception handling behavior.
+  using ExceptionHandlingKind = llvm::ExceptionHandling;
+
   enum class LaxVectorConversionKind {
 /// Permit no implicit vector bitcasts.
 None,
@@ -381,10 +385,21 @@ class LangOptions : public LangOptionsBase {
 return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
   }
 
-  bool hasSjLjExceptions() const { return SjLjExceptions; }
-  bool hasSEHExceptions() const { return SEHExceptions; }
-  bool hasDWARFExceptions() const { return DWARFExceptions; }
-  bool hasWasmExceptions() const { return WasmExceptions; }
+  bool hasSjLjExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::SjLj;
+  }
+
+  bool hasSEHExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::WinEH;
+  }
+
+  bool hasDWARFExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::DwarfCFI;
+  }
+
+  bool hasWasmExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::Wasm;
+  }
 };
 
 /// Floating point control options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c1d5364d72ea..e4058cfc1915 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2981,10 +2981,14 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Diags.Report(diag::err_fe_invalid_exception_model)
   << Opt.getName() << T.str();
 
-Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
-Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
-Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
-Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
+if (Opt.matches(options::OPT_fsjlj_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::SjLj);
+else if (Opt.matches(options::OPT_fseh_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::WinEH);
+else if (Opt.matches(options::OPT_fdwarf_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::DwarfCFI);
+else if (Opt.matches(options::OPT_fwasm_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::Wasm);
   }
 
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);



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

[PATCH] D93214: [clang][cli] Create accessors for exception models in LangOptions

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf24e58df7ddf: [clang][cli] Create accessors for exception 
models in LangOptions (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93214?vs=311577&id=311830#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93214

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/Frontend/InitPreprocessor.cpp

Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -753,12 +753,12 @@
   if (LangOpts.GNUCVersion && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
 
-  if (LangOpts.SjLjExceptions)
+  if (LangOpts.hasSjLjExceptions())
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
-  else if (LangOpts.SEHExceptions)
+  else if (LangOpts.hasSEHExceptions())
 Builder.defineMacro("__SEH__");
-  else if (LangOpts.DWARFExceptions &&
-  (TI.getTriple().isThumb() || TI.getTriple().isARM()))
+  else if (LangOpts.hasDWARFExceptions() &&
+   (TI.getTriple().isThumb() || TI.getTriple().isARM()))
 Builder.defineMacro("__ARM_DWARF_EH__");
 
   if (LangOpts.Deprecated)
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -121,11 +121,11 @@
   const llvm::Triple &T = Target.getTriple();
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_C_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_C;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_C_SEH;
   return EHPersonality::GNU_C;
 }
@@ -149,9 +149,9 @@
 LLVM_FALLTHROUGH;
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
-if (L.SjLjExceptions)
+if (L.hasSjLjExceptions())
   return EHPersonality::GNU_ObjC_SJLJ;
-if (L.SEHExceptions)
+if (L.hasSEHExceptions())
   return EHPersonality::GNU_ObjC_SEH;
 return EHPersonality::GNU_ObjC;
   }
@@ -165,13 +165,13 @@
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (T.isOSAIX())
 return EHPersonality::XL_CPlusPlus;
-  if (L.SjLjExceptions)
+  if (L.hasSjLjExceptions())
 return EHPersonality::GNU_CPlusPlus_SJLJ;
-  if (L.DWARFExceptions)
+  if (L.hasDWARFExceptions())
 return EHPersonality::GNU_CPlusPlus;
-  if (L.SEHExceptions)
+  if (L.hasSEHExceptions())
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (L.WasmExceptions)
+  if (L.hasWasmExceptions())
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
@@ -476,7 +476,7 @@
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TODO Correctly handle exception specification in wasm
-if (CGM.getLangOpts().WasmExceptions) {
+if (CGM.getLangOpts().hasWasmExceptions()) {
   if (EST == EST_DynamicNone)
 EHStack.pushTerminate();
   else
@@ -564,7 +564,7 @@
 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
 // case of throw with types, we ignore it and print a warning for now.
 // TODO Correctly handle exception specification in wasm
-if (CGM.getLangOpts().WasmExceptions) {
+if (CGM.getLangOpts().hasWasmExceptions()) {
   if (EST == EST_DynamicNone)
 EHStack.popTerminate();
   return;
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -497,13 +497,13 @@
   // Set EABI version.
   Options.EABIVersion = TargetOpts.EABIVersion;
 
-  if (LangOpts.SjLjExceptions)
+  if (LangOpts.hasSjLjExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
-  if (LangOpts.SEHExceptions)
+  if (LangOpts.hasSEHExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
-  if (LangOpts.DWARFExceptions)
+  if (LangOpts.hasDWARFExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
-  if (LangOpts.WasmExceptions)
+  if (LangOpts.hasWasmExceptions())
 Options.ExceptionModel = llvm::ExceptionHandling::Wasm;
 
   Options.NoInfsFPMath = LangOpts.NoHonorInfs;
Index: clang/include/clang/Basic/LangOptions.h
===
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -380,6 +380,11 @@
   bool isSignReturnAddressSco

[clang] 56c5548 - [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option

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

Author: Jan Svoboda
Date: 2020-12-15T10:15:58+01:00
New Revision: 56c5548d7f07f5853a2e40562db08dc2e56ece03

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

LOG: [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single 
-exception-model=xxx option

This patch enables marshalling of the exception model options while enforcing 
their mutual exclusivity. The clang driver interface remains the same, this 
only affects the cc1 command line.

Depends on D93215.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/exceptions.c
clang/test/CodeGen/personality.c
clang/test/CodeGenCXX/mingw-w64-exceptions.c
clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
clang/test/CodeGenCXX/personality.cpp
clang/test/CodeGenCXX/wasm-eh.cpp
clang/test/CodeGenObjC/personality.m
clang/test/CodeGenObjCXX/objfw-exceptions.mm
clang/test/CodeGenObjCXX/personality.mm
clang/test/Driver/arch-armv7k.c
clang/test/Driver/freebsd.c
clang/test/Driver/fsjlj-exceptions.c
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp
clang/test/Driver/windows-exceptions.cpp
clang/test/Frontend/windows-exceptions.cpp
clang/test/Preprocessor/init-arm.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 0f1b68bd0e7d..def189f65994 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -111,7 +111,7 @@ def err_fe_invalid_alignment : Error<
 def err_fe_invalid_wchar_type
 : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 
'int'">;
 def err_fe_invalid_exception_model
-   : Error<"invalid exception model '%0' for target '%1'">;
+   : Error<"invalid exception model 
'%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">;
 def warn_fe_concepts_ts_flag : Warning<
   "-fconcepts-ts is deprecated - use '-std=c++20' for Concepts support">,
   InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 2780e4bf35fd..be2c7a004e0b 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -31,6 +31,8 @@ namespace clang {
 /// Bitfields of LangOptions, split out from LangOptions in order to ensure 
that
 /// this large collection of bitfields is a trivial class type.
 class LangOptionsBase {
+  friend class CompilerInvocation;
+
 public:
   // Define simple language options (with no accessors).
 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 67d41c3711f5..f3aa6750b794 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1265,13 +1265,22 @@ def fencoding_EQ : Joined<["-"], "fencoding=">, 
Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, 
Flags<[CoreOption]>;
 defm exceptions : OptInFFlag<"exceptions", "Enable", "Disable", " support for 
exception handling">;
 def fdwarf_exceptions : Flag<["-"], "fdwarf-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use DWARF style exceptions">;
+  HelpText<"Use DWARF style exceptions">;
 def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
+  HelpText<"Use SjLj style exceptions">;
 def fseh_exceptions : Flag<["-"], "fseh-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use SEH style exceptions">;
+  HelpText<"Use SEH style exceptions">;
 def fwasm_exceptions : Flag<["-"], "fwasm-exceptions">, Group,
-  Flags<[CC1Option]>, HelpText<"Use WebAssembly style exceptions">;
+  HelpText<"Use WebAssembly style exceptions">;
+def exception_model : Separate<["-"], "exception-model">,
+  Flags<[CC1Option, NoDriverOption]>, HelpText<"The exception model: 
dwarf|sjlj|seh|wasm">,
+  Values<"dwarf,sjlj,seh,wasm">,
+  NormalizedValuesScope<"llvm::ExceptionHandling">,
+  NormalizedValues<["DwarfCFI", "SjLj", "WinEH", "Wasm"]>,
+  MarshallingInfoString<"LangOpts->ExceptionHandling", "None">,
+  AutoNormalizeEnum;
+def exception_model_EQ : Joined<["-"], "exception-model=">,
+  Flags<[CC1Option, NoDriverOption]>, Alias;
 def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Group, 
Flags<[CC1Option]>,
   HelpText<"Enable support for ignoring exception handling constructs">;
 def fexcess_pr

[PATCH] D93215: [clang][cli] Squash exception model in LangOptions into one member

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG573255b47eb9: [clang][cli] Squash exception model in 
LangOptions into one member (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93215?vs=311580&id=311831#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93215

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2981,10 +2981,14 @@
   Diags.Report(diag::err_fe_invalid_exception_model)
   << Opt.getName() << T.str();
 
-Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
-Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
-Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
-Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
+if (Opt.matches(options::OPT_fsjlj_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::SjLj);
+else if (Opt.matches(options::OPT_fseh_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::WinEH);
+else if (Opt.matches(options::OPT_fdwarf_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::DwarfCFI);
+else if (Opt.matches(options::OPT_fwasm_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::Wasm);
   }
 
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
Index: clang/include/clang/Basic/LangOptions.h
===
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -22,6 +22,7 @@
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCTargetOptions.h"
 #include 
 #include 
 
@@ -209,6 +210,9 @@
 FPE_Strict
   };
 
+  /// Possible exception handling behavior.
+  using ExceptionHandlingKind = llvm::ExceptionHandling;
+
   enum class LaxVectorConversionKind {
 /// Permit no implicit vector bitcasts.
 None,
@@ -381,10 +385,21 @@
 return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
   }
 
-  bool hasSjLjExceptions() const { return SjLjExceptions; }
-  bool hasSEHExceptions() const { return SEHExceptions; }
-  bool hasDWARFExceptions() const { return DWARFExceptions; }
-  bool hasWasmExceptions() const { return WasmExceptions; }
+  bool hasSjLjExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::SjLj;
+  }
+
+  bool hasSEHExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::WinEH;
+  }
+
+  bool hasDWARFExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::DwarfCFI;
+  }
+
+  bool hasWasmExceptions() const {
+return getExceptionHandling() == llvm::ExceptionHandling::Wasm;
+  }
 };
 
 /// Floating point control options
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -129,10 +129,8 @@
 LANGOPT(Exceptions, 1, 0, "exception handling")
 LANGOPT(ObjCExceptions, 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
-LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
-LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
-LANGOPT(SEHExceptions , 1, 0, "SEH .xdata exception handling")
-LANGOPT(WasmExceptions, 1, 0, "WebAssembly exception handling")
+ENUM_LANGOPT(ExceptionHandling, ExceptionHandlingKind, 3,
+ ExceptionHandlingKind::None, "exception handling")
 LANGOPT(IgnoreExceptions  , 1, 0, "ignore exceptions")
 LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2981,10 +2981,14 @@
   Diags.Report(diag::err_fe_invalid_exception_model)
   << Opt.getName() << T.str();
 
-Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
-Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
-Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
-Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
+if (Opt.matches(options::OPT_fsjlj_exceptions))
+  Opts.setExceptionHandling(llvm::ExceptionHandling::S

[PATCH] D93216: [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56c5548d7f07: [clang][cli] Squash multiple cc1 
-fxxx-exceptions flags into single -exception… (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D93216?vs=311589&id=311832#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93216

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/exceptions.c
  clang/test/CodeGen/personality.c
  clang/test/CodeGenCXX/mingw-w64-exceptions.c
  clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  clang/test/CodeGenCXX/personality.cpp
  clang/test/CodeGenCXX/wasm-eh.cpp
  clang/test/CodeGenObjC/personality.m
  clang/test/CodeGenObjCXX/objfw-exceptions.mm
  clang/test/CodeGenObjCXX/personality.mm
  clang/test/Driver/arch-armv7k.c
  clang/test/Driver/freebsd.c
  clang/test/Driver/fsjlj-exceptions.c
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp
  clang/test/Driver/windows-exceptions.cpp
  clang/test/Frontend/windows-exceptions.cpp
  clang/test/Preprocessor/init-arm.c

Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1051,7 +1051,7 @@
 // Thumbebv7: #define __THUMB_INTERWORK__ 1
 // Thumbebv7: #define __thumb2__ 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv7-pc-windows-gnu -fdwarf-exceptions %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv7-pc-windows-gnu -exception-model=dwarf %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
Index: clang/test/Frontend/windows-exceptions.cpp
===
--- clang/test/Frontend/windows-exceptions.cpp
+++ clang/test/Frontend/windows-exceptions.cpp
@@ -1,27 +1,27 @@
 // RUN: %clang_cc1 -triple i686--windows-msvc -fsyntax-only %s
-// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-DWARF %s
-// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SEH %s
-// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SJLJ %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -exception-model=dwarf %s 2>&1 | FileCheck -check-prefix=MSVC-X86-DWARF %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -exception-model=seh %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SEH %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -exception-model=sjlj %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SJLJ %s
 
 // RUN: %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only %s
-// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-DWARF %s
-// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SEH %s
-// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SJLJ %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -exception-model=dwarf %s 2>&1 | FileCheck -check-prefix=MSVC-X64-DWARF %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -exception-model=seh %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SEH %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -exception-model=sjlj %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SJLJ %s
 
 // RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only %s
-// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fdwarf-exceptions %s
-// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fseh-exceptions %s
-// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -exception-model=dwarf %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -exception-model=seh %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -exception-model=sjlj %s
 
 // RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only %s
-// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fdwarf-exceptions %s
-// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fseh-exceptions %s
-// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsynta

[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-15 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:673-686
+def ProcA78C : SubtargetFeature<"cortex-a78c", "ARMProcFamily",
+"CortexA78C",
+"Cortex-A78C ARM processors", [
+HasV8_2aOps,
+FeatureCrypto,
+FeatureFPARMv8,
+FeatureFuseAES,

MarkMurrayARM wrote:
> ktkachov wrote:
> > According to the TRM at https://developer.arm.com/documentation/102226/0001 
> > Cortex-A78C also supports Pointer Authetication and the Flag Manipulation 
> > instructions as well (CFINV, RMIF etc). I think this feature set doesn't 
> > reflect that?
> ktkachov: FeaturePA?
> 
Ah indeed for pointer authentication. I think it also needs FeatureFMI for the 
flag manipulation instructions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


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

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:287
+static void
+denormalizeString(SmallVectorImpl &Args, const char *Spelling,
+  CompilerInvocation::StringAllocator SA, unsigned, T &&Value) 
{

dexonsmith wrote:
> jansvoboda11 wrote:
> > We should keep an eye on the number of instantiations of this function 
> > template (and `normalizeStringIntegral`).
> > 
> > If it grows, we can employ the SFINAE trick used for 
> > `makeFlagToValueNormalizer`.
> Does it work to take the parameter as a `Twine` to avoid the template?
> ```
> static void
> denormalizeString(SmallVectorImpl &Args, const char *Spelling,
>   CompilerInvocation::StringAllocator SA, unsigned, Twine 
> Value) {
>   Args.push_back(Spelling);
>   Args.push_back(SA(Value));
> }
> ```
In general no. The `Twine` constructor is `explicit` for some types (integers, 
chars, etc.).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84186

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


[PATCH] D93094: [clang][cli] Prevent double denormalization

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:267
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdebug-pass-manager")));
+  ASSERT_EQ(count(GeneratedArgs, "-fdebug-pass-manager"), 1);
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";

dexonsmith wrote:
> jansvoboda11 wrote:
> > Is it wise to rely on pointer comparison here? The call to `count` returns 
> > 2 before changing the denormalizer and 1 after, but I'm not sure if it will 
> > work on all platforms.
> Does this compile / avoid the pointer comparison?
> ```
> ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1);
> ```
Yes, this forces the `const char *` from GeneratedArgs to be converted into 
`StringRef`, which does comparison via `::memcmp`.

If we decide comparing `StringRef`s is a better solution, I'd be inclined to 
create a helper function or custom matcher that does the conversion to 
`StringRef`. That way, we don't have to worry about doing the right thing in 
test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93094

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


[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D92634#2451646 , @danielmarjamaki 
wrote:

> No reviews => I will not contribute.

Hi, thanks for the patch! I am terribly sorry that we could not pick this up 
earlier. You can always ping the community with a simple 'Ping' message. 
Unfortunately, it often happens that a non-trivial patch stalls in the review 
queue, a ping might push that a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92634

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


[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D92634#2453822 , @OikawaKirie wrote:

> I think it could be better to implement this check with a checker on 
> `PreStmt` and so on. And IMO, checkers have enough 
> functionalities to report these problems.
>
> Besides, the return value should be the exact value computed from the two 
> integers, even unknown, rather than undefined. As the developers may overflow 
> an integer on purpose.

+1
To provide warnings on overflows is a great idea. However, perhaps a separate 
new checker should emit a report with more information (i.e. that an overflow 
could happen vs "undefined").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92634

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 311849.
ChuanqiXu added a comment.

Edit the comment to avoid misleading.


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

https://reviews.llvm.org/D91245

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set 
PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1960,6 +1960,7 @@
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, 
tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1960,6 +1960,7 @@
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D92797#2452497 , @compnerd wrote:

> Ping

I am terribly sorry for keeping you waiting always. Thanks for your patience.




Comment at: clang/include/clang/APINotes/APINotesWriter.h:1
+//===-- APINotesWriter.h - API Notes Writer -*- C++ 
-*-===//
+//

How are we going to use this class? I mean what are the use cases to call the 
Writer from inside Clang?
I understand that the Reader might be used to read up the serialized APINotes 
file.

What will be the usual process of using an APINotes file? Is it like:
```
1) Edit `APINotesX.yaml` by hand (by a library author)
2) Serialize `APINotesX.yaml` -> `APINotesX.serialized` (Would this require a 
special Clang invocation?)
3) Run Clang for the usual tasks (analysis, etc) but with feeding it with 
`APINotesX.serialized`
```
Would it be possible to feed the raw `APINotesX.yaml` to Clang and skip the 
whole serialize/deserialize steps? If yes, then maybe we should put more focus 
on that first  (but maybe it's already too late since we added the 
serialization format and the reader).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7759-7761
+  // The default setting for PointerAlignment is PAS_Right.
+  // But if we set PointerAlignment as PAS_Left, the formatter
+  // would mis-format the pointer alignment.

MyDeveloperDay wrote:
> HazardyKnusperkeks wrote:
> > ChuanqiXu wrote:
> > > HazardyKnusperkeks wrote:
> > > > I don't think this should be in the tests, because it is not true (if 
> > > > your patch works).
> > > I'm confusing about your comment. What is not true? Do you mean if my 
> > > patch works then the `co_return *a;` should be formatted as `co_return* 
> > > a`?
> > No, I refer to the comment. You say `would mis-format`, but it wouln't 
> > because of your change, or not? Otherwise the tests would not pass.
> 
Oh, I got it. Thanks!


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

https://reviews.llvm.org/D91245

___
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-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D93258#2453828 , @yaxunl wrote:

> Can they use rocm release branches of llvm/clang with the corresponding rocm 
> release? As llvm/clang trunk is like the development branch, it is 
> understandable that they may contain new changes that may temporarily not 
> working with previous rocm releases.

Code object v4 does not work with any rocm release, or with code published that 
is not in a release. As far as open source goes, it exists only as some 
documentation and the change to clang that decided it was the right default to 
use.

That change turned out to be largely harmless as the back end uses v3 despite 
the docs and clang -### claiming it will use v4.

Depending on a library doesn't exist is absolutely not 'understandable'. I 
believe this patch undoes a mistaken step in that direction and that the hip 
tests are also in error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

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


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong requested changes to this revision.
martong added inline comments.
This revision now requires changes to proceed.



Comment at: clang/unittests/AST/StructuralEquivalenceTest.cpp:1656-1662
+  R"(
+  template 
+  void f() {
+T x;
+(void)_Generic(x, float: 1, int: 0);
+  }
+  )",

> Change the DeclMatcher.h test code to expose the ability to not assert on 
> null Nodes from a match.

The original idea was to assert in the DeclMatcher to indicate a failure in the 
test itself. In the past it happened to me often that I wrote a wrong matcher 
and that assertion indicated it and that was really helpful.

So, I'd suggest an alternative approach instead of this change in the 
DeclMatcher: Try to instantiate the template function itself, so even if the 
delayed template instantiation option is set, the compiler must instantiate. 

Related code in other ASTImporter tests:
https://github.com/llvm/llvm-project/blob/bd0709266911bce2f1e8a875f9ed49d56953f323/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp#L60


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Aside: Would you be prepared to take a look at D34225: [clang-format] Teach 
clang-format how to handle C++ coroutines  
which is pretty much been abandoned, and see if there is anything there that 
might help the co_routinues support?


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

https://reviews.llvm.org/D91245

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


[PATCH] D93206: [AArch64][NEON] Remove undocumented vceqz{,q}_p16, vml{a,s}q_n_f64 intrinsics

2020-12-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith accepted this revision.
bsmith added a comment.
This revision is now accepted and ready to land.

Changes look good to me, also can confirm these are in fact not part of the 
ACLE specification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93206

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 311856.
MarkMurrayARM added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

Files:
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -268,6 +268,13 @@
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
  ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_SEC | ARM::AEK_MP |
+ ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP |
+ ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+
   EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
  ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
  ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
@@ -334,7 +341,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 91;
+static constexpr unsigned NumARMCPUArchs = 92;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -893,6 +900,12 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS,
   "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_RAS | AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+  AArch64::AEK_FP | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_RDM,
+  "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
   "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
   AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
@@ -1062,7 +1075,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 45;
+static constexpr unsigned NumAArch64CPUArchs = 46;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/ARM/ARMSubtarget.h
===
--- llvm/lib/Target/ARM/ARMSubtarget.h
+++ llvm/lib/Target/ARM/ARMSubtarget.h
@@ -63,6 +63,7 @@
 CortexA76,
 CortexA77,
 CortexA78,
+CortexA78C,
 CortexA8,
 CortexA9,
 CortexM3,
Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -294,6 +294,7 @@
   case CortexA76:
   case CortexA77:
   case CortexA78:
+  case CortexA78C:
   case CortexR4:
   case CortexR4F:
   case CortexR5:
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -598,6 +598,8 @@
"Cortex-A77 ARM processors", []>;
 def ProcA78 : SubtargetFeature<"cortex-a78", "ARMProcFamily", "CortexA78",
"Cortex-A78 ARM processors", []>;
+def ProcA78C: SubtargetFeature<"a78c", "ARMProcFamily", "CortexA78C",
+   "Cortex-A78C ARM processors", []>;
 def ProcX1  : SubtargetFeature<"cortex-x1", "ARMProcFamily", "CortexX1",
"Cortex-X1 ARM processors", []>;
 
@@ -1275,6 +1277,13 @@
  FeatureFullFP16,
  FeatureDotProd]>;
 
+def : ProcNoItin<"cortex-a78c", [ARMv82a,
+ FeatureHWDivThumb,
+ FeatureHWDivARM,
+ FeatureCrypto,
+ FeatureCRC,
+ FeatureFullFP16]>;
+
 def : ProcNoItin<"cortex-x1",   [ARMv82a, ProcX1,
  FeatureHWDivThumb,
  FeatureHWDivARM,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h

[PATCH] D93222: [RFC][analyzer] Introduce MacroExpansionContext to libAnalysis

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Nice and precise work! And special thanks for the unit tests. I've found some 
minor nits.




Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:77
+  /// \param MacroExpansionLoc Must be the expansion location of a macro.
+  /// \return The textual representation of the token sequence which were
+  /// substituted in place of the macro.

?



Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:79-80
+  /// substituted in place of the macro.
+  /// If no macro was expanded at that location, returns an empty
+  /// string.
+  MacroExpansionText

I think we should have an Optional as a return type, so we'd be able to 
detect if no macro expansion happened. (?)



Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:81
+  /// string.
+  MacroExpansionText
+  getExpandedMacroForLocation(SourceLocation MacroExpansionLoc) const;

Could this be `StringRef` also?



Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:87-88
+  /// the macro expansion chain from the given location.
+  /// If no macro was expanded at that location, returns an empty
+  /// string.
+  StringRef

We should be able to distinguish between no macro expansion (1) and expansion 
to an empty string (2). So, I think we should have an Optional as a 
return type.



Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:39
+
+  SourceLocation ExpansionEnd = [Range, &SM = SM, &MacroName] {
+// If the range is empty, use the length of the macro.

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93222

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


[PATCH] D84187: Port DependencyOutput string based options to new option parsing system

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84187

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


[PATCH] D93022: [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM

2020-12-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM marked 4 inline comments as done.
MarkMurrayARM added a comment.

Marked addressed comments as "done". Some debug code has been abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93022

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


[PATCH] D93223: [RFC][analyzer] Create MacroExpansionContext member in AnalysisConsumer and pass down to the diagnostics consumers

2020-12-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Looks quite straight-forward other than that new prototype.




Comment at: clang/include/clang/Analysis/PathDiagnostic.h:911
 
+void createHTMLSingleFileDiagnosticConsumer(
+PathDiagnosticConsumerOptions DiagOpts,

Why do we need this prototype here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93223

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


[PATCH] D93222: [RFC][analyzer] Introduce MacroExpansionContext to libAnalysis

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



Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:82
+  MacroExpansionText
+  getExpandedMacroForLocation(SourceLocation MacroExpansionLoc) const;
+

`getExpandedText` ? Since what you get back is not a macro anymore.



Comment at: clang/include/clang/Analysis/MacroExpansionContext.h:90
+  StringRef
+  getSubstitutedTextForLocation(SourceLocation MacroExpansionLoc) const;
+

`Substituted` is a bit ambiguous to me. What about `getOriginalText` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93222

___
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-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



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

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.


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] D84187: [clang][cli] Port DependencyOutput string based options to new option parsing system

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

Rebase, undo unnecessary move of options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84187

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


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1646,10 +1646,7 @@
 
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.HeaderIncludeOutputFile =
-  std::string(Args.getLastArgValue(OPT_header_include_file));
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1661,9 +1658,6 @@
   } else {
 Opts.ShowIncludesDest = ShowIncludesDestination::None;
   }
-  Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
-  Opts.ModuleDependencyOutputDir =
-  std::string(Args.getLastArgValue(OPT_module_dependency_dir));
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -968,11 +968,14 @@
   HelpText<"Print macro definitions in -E mode instead of normal output">;
 def dead__strip : Flag<["-"], "dead_strip">;
 def dependency_file : Separate<["-"], "dependency-file">, Flags<[CC1Option]>,
-  HelpText<"Filename (or -) to write dependency output to">;
+  HelpText<"Filename (or -) to write dependency output to">,
+  MarshallingInfoString<"DependencyOutputOpts.OutputFile">;
 def dependency_dot : Separate<["-"], "dependency-dot">, Flags<[CC1Option]>,
-  HelpText<"Filename to write DOT-formatted header dependencies to">;
+  HelpText<"Filename to write DOT-formatted header dependencies to">,
+  MarshallingInfoString<"DependencyOutputOpts.DOTOutputFile">;
 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
-  Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
+  Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">,
+  MarshallingInfoString<"DependencyOutputOpts.ModuleDependencyOutputDir">;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
   Flags<[NoXarchOption, RenderAsInput]>,
   HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
@@ -4355,7 +4358,8 @@
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag<"DependencyOutputOpts.IncludeModuleFiles">;
 def header_include_file : Separate<["-"], "header-include-file">,
-  HelpText<"Filename (or -) to write header include output to">;
+  HelpText<"Filename (or -) to write header include output to">,
+  MarshallingInfoString<"DependencyOutputOpts.HeaderIncludeOutputFile">;
 def show_includes : Flag<["--"], "show-includes">,
   HelpText<"Print cl.exe style /showIncludes to stdout">;
 


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1646,10 +1646,7 @@
 
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.HeaderIncludeOutputFile =
-  std::string(Args.getLastArgValue(OPT_header_include_file));
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1661,9 +1658,6 @@
   } else {
 Opts.ShowIncludesDest = ShowIncludesDestination::None;
   }
-  Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
-  Opts.ModuleDependencyOutputDir =
-  std::string(Args.getLastArgValue(OPT_module_dependency_dir));
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -968,11 +968,14 @@
   HelpText<"Print macro definitions in -E mode instead of 

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

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



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

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.


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] D84190: Port FrontendOpts simple string based options to new option parsing system

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a reviewer: dexonsmith.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84190

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D91245#2454504 , @MyDeveloperDay 
wrote:

> Aside: Would you be prepared to take a look at D34225: [clang-format] Teach 
> clang-format how to handle C++ coroutines  
> which is pretty much been abandoned, and see if there is anything there that 
> might help the co_routinues support?

I think the test cases in D34225: [clang-format] Teach clang-format how to 
handle C++ coroutines  are rare in our codes. 
It is a little strange to write `co_return (43)` instead of `co_return 43`. And 
the grammar `for co_await (auto x : range)` is used rarely. I think both of 
them  are defects of clang-format while they are really rare in actual 
environments.


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

https://reviews.llvm.org/D91245

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

not that rare it seems

https://github.com/search?q=%22co_return+%28%22&type=code
https://github.com/search?q=%22for+co_await+%28%22&type=code


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

https://reviews.llvm.org/D91245

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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I don't like seeing users having to use ```// clang-format off```

  auto try_sequence = [](int& ref) -> return_ignore {
  /* clang-format off */
  for co_await(int v : return_random_int())
  ref = v;
  /* clang-format on*/
  };

it would be nice if we could land a co_routines improvement


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

https://reviews.llvm.org/D91245

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


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

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

Rebase, undo unnecessary move of options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84190

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2084,15 +2084,11 @@
 << A->getAsString(Args) << A->getValue();
   }
 
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_o));
   Opts.Plugins = Args.getAllArgValues(OPT_load);
-  Opts.TimeTraceGranularity = getLastArgIntValue(
-  Args, OPT_ftime_trace_granularity_EQ, Opts.TimeTraceGranularity, Diags);
   Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
   Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
   Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
   Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
-  Opts.ASTDumpFilter = std::string(Args.getLastArgValue(OPT_ast_dump_filter));
   Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
   // Only the -fmodule-file= form.
   for (const auto *A : Args.filtered(OPT_fmodule_file)) {
@@ -2107,22 +2103,10 @@
 Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
<< "-emit-module";
 
-  Opts.OverrideRecordLayoutsFile =
-  std::string(Args.getLastArgValue(OPT_foverride_record_layout_EQ));
-  Opts.AuxTriple = std::string(Args.getLastArgValue(OPT_aux_triple));
   if (Args.hasArg(OPT_aux_target_cpu))
 Opts.AuxTargetCPU = std::string(Args.getLastArgValue(OPT_aux_target_cpu));
   if (Args.hasArg(OPT_aux_target_feature))
 Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
-  Opts.StatsFile = std::string(Args.getLastArgValue(OPT_stats_file));
-
-  Opts.MTMigrateDir =
-  std::string(Args.getLastArgValue(OPT_mt_migrate_directory));
-  Opts.ARCMTMigrateReportOut =
-  std::string(Args.getLastArgValue(OPT_arcmt_migrate_report_output));
-
-  Opts.ObjCMTWhiteListPath =
-  std::string(Args.getLastArgValue(OPT_objcmt_whitelist_dir_path));
 
   if (Opts.ARCMTAction != FrontendOptions::ARCMT_None &&
   Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -557,7 +557,8 @@
 def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt,
   HelpText<"Apply modifications and produces temporary files that conform to ARC">;
 def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">,
-  HelpText<"Output path for the plist report">,  Flags<[CC1Option]>;
+  HelpText<"Output path for the plist report">,  Flags<[CC1Option]>,
+  MarshallingInfoString<"FrontendOpts.ARCMTMigrateReportOut">;
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">, Flags<[CC1Option]>,
   MarshallingInfoFlag<"FrontendOpts.ARCMTMigrateEmitARCErrors">;
@@ -620,7 +621,8 @@
   MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_DesignatedInitializer">;
 
 def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>,
-  HelpText<"Only modify files with a filename contained in the provided directory path">;
+  HelpText<"Only modify files with a filename contained in the provided directory path">,
+  MarshallingInfoString<"FrontendOpts.ObjCMTWhiteListPath">;
 // The misspelt "white-list" [sic] alias is due for removal.
 def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>,
 Alias;
@@ -2273,7 +2275,8 @@
   MarshallingInfoFlag<"FrontendOpts.TimeTrace">;
 def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group,
   HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
-  Flags<[CC1Option, CoreOption]>;
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoStringInt<"FrontendOpts.TimeTraceGranularity", "500u">;
 def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group,
   HelpText<"Print subprocess statistics">;
 def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group,
@@ -3176,7 +3179,8 @@
 def object : Flag<["-"], "object">;
 def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption, RenderAsInput,
   CC1Option, CC1AsOption, FC1Option, FlangOption]>,
-  HelpText<"Write output to ">, MetaVarName<"">;
+  HelpText<"Write output to ">, MetaVarName<"">,
+  MarshallingInfoString<"FrontendOpts.OutputFile">;
 def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">;
 def pass_exit_

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

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a reviewer: dexonsmith.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


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] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D91245#2454610 , @MyDeveloperDay 
wrote:

> I don't like seeing users having to use ```// clang-format off```
>
>   auto try_sequence = [](int& ref) -> return_ignore {
>   /* clang-format off */
>   for co_await(int v : return_random_int())
>   ref = v;
>   /* clang-format on*/
>   };
>
> it would be nice if we could land a co_routines improvement

From the links, I find most of them are test cases of LLVM projects. But I 
agree with you that `/* clang-format off */` looks ugly. And I find that the 
grammar `for co_await ()` is missing in newer standard documentation (N4849) 
while it was there in N4680. Maybe it is necessary to check whether this 
grammar is abandoned.


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

https://reviews.llvm.org/D91245

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


[clang] 8b48d24 - [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2020-12-15T20:50:46+08:00
New Revision: 8b48d24373204fc2fe6aac1f1f850fa3b6c18445

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

LOG: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid 
misleading pointer alignment

Summary: The clang-format may go wrong when handle c++ coroutine keywords and 
pointer.
The default value for PointerAlignment is PAS_Right. So the following format is 
good:
```
co_return *a;
```
But within some code style, the value for PointerAlignment is PAS_Left, the 
behavior goes wrong:
```
co_return* a;
```

test-plan: check-clang

reviewers: MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index b1c9c37a8ed9..821b46b75f6b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1964,6 +1964,7 @@ class AnnotatingParser {
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, 
tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1c78b6e2cb1e..a3dbec9a669f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set 
PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {



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


[PATCH] D91245: [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment

2020-12-15 Thread Chuanqi Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b48d2437320: [clang-format] Recognize c++ coroutine 
keywords as unary operator to avoid… (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91245

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set 
PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1964,6 +1964,7 @@
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, 
tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7755,6 +7755,15 @@
 
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
+
+  // Check that * is not treated as a binary operator when we set PointerAlignment
+  // as PAS_Left after a keyword and not a declaration.
+  FormatStyle PASLeftStyle = getLLVMStyle();
+  PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("co_return *a;", PASLeftStyle);
+  verifyFormat("co_await *a;", PASLeftStyle);
+  verifyFormat("co_yield *a", PASLeftStyle);
+  verifyFormat("return *a;", PASLeftStyle);
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1964,6 +1964,7 @@
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
+   tok::kw_co_return, tok::kw_co_await, tok::kw_co_yield,
tok::equal, tok::kw_delete, tok::kw_sizeof,
tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
___
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-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 311872.
jansvoboda11 added a comment.

Rebase, undo unnecessary move of options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84668

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -244,6 +244,15 @@
   return None;
 }
 
+template 
+static void denormalizeSimpleEnum(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator SA,
+  unsigned TableIndex, T Value) {
+  return denormalizeSimpleEnum(Args, Spelling, SA, TableIndex,
+   static_cast(Value));
+}
+
 static void denormalizeSimpleEnum(SmallVectorImpl &Args,
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
@@ -3724,28 +3733,7 @@
 
 static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
 DiagnosticsEngine &Diags) {
-  Opts.CodeModel = std::string(Args.getLastArgValue(OPT_mcmodel_EQ, "default"));
-  Opts.ABI = std::string(Args.getLastArgValue(OPT_target_abi));
-  if (Arg *A = Args.getLastArg(OPT_meabi)) {
-StringRef Value = A->getValue();
-llvm::EABI EABIVersion = llvm::StringSwitch(Value)
- .Case("default", llvm::EABI::Default)
- .Case("4", llvm::EABI::EABI4)
- .Case("5", llvm::EABI::EABI5)
- .Case("gnu", llvm::EABI::GNU)
- .Default(llvm::EABI::Unknown);
-if (EABIVersion == llvm::EABI::Unknown)
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
-<< Value;
-else
-  Opts.EABIVersion = EABIVersion;
-  }
-  Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
-  Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
-  Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
-  Opts.LinkerVersion =
-  std::string(Args.getLastArgValue(OPT_target_linker_version));
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
   Opts.AllowAMDGPUUnsafeFPAtomics =
   Args.hasFlag(options::OPT_munsafe_fp_atomics,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2603,7 +2603,8 @@
 def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias;
 def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[NoXarchOption]>;
-def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>;
+def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>,
+  MarshallingInfoString<"TargetOpts->CodeModel", [{std::string("default")}]>;
 def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group, Flags<[NoXarchOption, CC1Option]>,
   HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "
"12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">;
@@ -2669,7 +2670,10 @@
 def mthread_model : Separate<["-"], "mthread-model">, Group, Flags<[CC1Option]>,
   HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">;
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
-  HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
+  HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">,
+  MarshallingInfoString<"TargetOpts->EABIVersion", "Default">,
+  NormalizedValuesScope<"llvm::EABI">,
+  NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>, AutoNormalizeEnum;
 
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>,
@@ -3935,9 +3939,11 @@
 let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
 
 def target_cpu : Separate<["-"], "target-cpu">,
-  HelpText<"Target a specific cpu type">;
+  HelpText<"Target a specific cpu type">,
+  MarshallingInfoString<"TargetOpts->CPU">;
 def tune_cpu : Separate<["-"], "tune-cpu">,
-  HelpText<"Tune for a specific cpu type">;
+  HelpText<"Tune for a specific cpu type">,
+  MarshallingInfoString<"TargetOpts->TuneCPU">;
 def target_feature : Separate<["-"], "target-feature">,
   HelpText<"Targe

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

2020-12-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


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] D1810: [ARM] Fix AArch32 and pre-v8 poly types to be unsigned

2020-12-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith abandoned this revision.
bsmith added a comment.
Herald added subscribers: danielkiss, kristof.beyls.

This change is very old and almost certainly out of date, therefore abandoning.


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

https://reviews.llvm.org/D1810

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


[clang-tools-extra] 965d71c - [clangd] Avoid traversing C:\ -> C: when looking for CDBs

2020-12-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-12-15T13:59:00+01:00
New Revision: 965d71c69acce658e9e3de00b25a351b00937820

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

LOG: [clangd] Avoid traversing C:\ -> C: when looking for CDBs

Boost in its infinite wisdom considers C: a parent of C:\, and we've
inherited that. This breaks the assumption that after canonicalizing a
path, the path parents are the directory's parents.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 23e8c9fe716d..20139c12abed 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -29,13 +29,27 @@ namespace clang {
 namespace clangd {
 namespace {
 
+// Variant of parent_path that operates only on absolute paths.
+PathRef absoluteParent(PathRef Path) {
+  assert(llvm::sys::path::is_absolute(Path));
+#if defined(_WIN32)
+  // llvm::sys says "C:\" is absolute, and its parent is "C:" which is 
relative.
+  // This unhelpful behavior seems to have been inherited from boost.
+  if (llvm::sys::path::relative_path(Path)).empty(); {
+return PathRef();
+  }
+#endif
+  PathRef Result = llvm::sys::path::parent_path(Path);
+  assert(Result.empty() || llvm::sys::path::is_absolute(Result));
+  return Result;
+}
+
 // Runs the given action on all parent directories of filename, starting from
 // deepest directory and going up to root. Stops whenever action succeeds.
 void actOnAllParentDirectories(PathRef FileName,
llvm::function_ref Action) {
-  for (auto Path = llvm::sys::path::parent_path(FileName);
-   !Path.empty() && !Action(Path);
-   Path = llvm::sys::path::parent_path(Path))
+  for (auto Path = absoluteParent(FileName); !Path.empty() && !Action(Path);
+   Path = absoluteParent(Path))
 ;
 }
 



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


[clang-tools-extra] 92dd077 - Reland [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

2020-12-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-12-15T14:00:03+01:00
New Revision: 92dd077af1ff89929f5502c6c887358f51d5afc1

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

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

This reverts commit 4d956af594c5adc9d566d1846d86dd89c70c9c0b.

Assertion failures on windows fixed by
965d71c69acce658e9e3de00b25a351b00937820

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 20139c12abed..bad9c359798e 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -16,11 +16,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 #include 
@@ -72,10 +74,117 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef 
File) const {
   return Cmd;
 }
 
+// Loads and caches the CDB from a single directory.
+//
+// This class is threadsafe, which is to say we have independent locks for each
+// directory we're searching for a CDB.
+// Loading is deferred until first access.
+//
+// The DirectoryBasedCDB keeps a map from path => DirectoryCache.
+// Typical usage is to:
+//  - 1) determine all the paths that might be searched
+//  - 2) acquire the map lock and get-or-create all the DirectoryCache entries
+//  - 3) release the map lock and query the caches as desired
+//
+// FIXME: this should revalidate the cache sometimes
+// FIXME: IO should go through a VFS
+class DirectoryBasedGlobalCompilationDatabase::DirectoryCache {
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  const std::string Path;
+
+  // True if we've looked for a CDB here and found none.
+  // (This makes it possible for get() to return without taking a lock)
+  // FIXME: this should have an expiry time instead of lasting forever.
+  std::atomic FinalizedNoCDB = {false};
+
+  // Guards following cache state.
+  std::mutex Mu;
+  // Has cache been filled from disk? FIXME: this should be an expiry time.
+  bool CachePopulated = false;
+  // Whether a new CDB has been loaded but not broadcast yet.
+  bool NeedsBroadcast = false;
+  // Last loaded CDB, meaningful if CachePopulated is set.
+  // shared_ptr so we can overwrite this when callers are still using the CDB.
+  std::shared_ptr CDB;
+
+public:
+  DirectoryCache(llvm::StringRef Path) : Path(Path) {
+assert(llvm::sys::path::is_absolute(Path));
+  }
+
+  // Get the CDB associated with this directory.
+  // ShouldBroadcast:
+  //  - as input, signals whether the caller is willing to broadcast a
+  //newly-discovered CDB. (e.g. to trigger background indexing)
+  //  - as output, signals whether the caller should do so.
+  // (If a new CDB is discovered and ShouldBroadcast is false, we mark the
+  // CDB as needing broadcast, and broadcast it next time we can).
+  std::shared_ptr
+  get(bool &ShouldBroadcast) {
+// Fast path for common case without taking lock.
+if (FinalizedNoCDB.load()) {
+  ShouldBroadcast = false;
+  return nullptr;
+}
+std::lock_guard Lock(Mu);
+auto RequestBroadcast = llvm::make_scope_exit([&, OldCDB(CDB.get())] {
+  // If we loaded a new CDB, it should be broadcast at some point.
+  if (CDB != nullptr && CDB.get() != OldCDB)
+NeedsBroadcast = true;
+  else if (CDB == nullptr) // nothing to broadcast anymore!
+NeedsBroadcast = false;
+  // If we have something to broadcast, then do so iff allowed.
+  if (!ShouldBroadcast)
+return;
+  ShouldBroadcast = NeedsBroadcast;
+  NeedsBroadcast = false;
+});
+
+// For now, we never actually attempt to revalidate a populated cache.
+if (CachePopulated)
+  return CDB;
+assert(CDB == nullptr);
+
+load();
+CachePopulated = true;
+
+if (!CDB)
+  FinalizedNoCDB.store(true);
+return CDB;
+  }
+
+  llvm::StringRef path() const { return Path; }
+
+private:
+  // Updates `CDB` from disk state.
+  void load() {
+std::string Error; // ignored, because it's often "didn't find anything".
+CDB = tooling::CompilationDatabase::loadFromDirectory(Path, Error);
+if (!CDB) {
+  // Fallback: check for $src/build, the conventional CMake build root.
+  // Probe existence first to avoid each plugin doing IO if it doesn't
+  /

[PATCH] D93222: [RFC][analyzer] Introduce MacroExpansionContext to libAnalysis

2020-12-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Overall looks good to me, I have some minor nits and questions inline.




Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:22
+: PP(PP), SM(PP.getSourceManager()), LangOpts(LangOpts) {
+  class MacroExpansionRangeRecorder : public PPCallbacks {
+const Preprocessor &PP;

It may be more idiomatic to put classes in an anonymous namespace rather than 
expanding them in a method.



Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:33
+
+void MacroExpands(const Token &MacroName, const MacroDefinition &MD,
+  SourceRange Range, const MacroArgs *Args) override {

Will we end up recording ranges for intermediate macro expansions? If yes, we 
might end up recording excessive amount of ranges. Is there any way to only 
record final expansion ranges in that case?



Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:39
+
+  SourceLocation ExpansionEnd = [Range, &SM = SM, &MacroName] {
+// If the range is empty, use the length of the macro.

martong wrote:
> ?
Why do you need the assignment in `&SM = SM`?



Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:94
+  if (it == ExpandedTokens.end())
+return MacroExpansionText("");
+  return it->getSecond();

I am a bit uneasy about this. As far as I understand a macro could be expanded 
to an empty string. How could the user differentiate between a valid empty 
expansion and a lookup failure. Also, can this lookup ever fail in a well 
behaving code? Do we need to add `llvm_unreachable()` or something?



Comment at: clang/lib/Analysis/MacroExpansionContext.cpp:105
+  if (it == ExpansionRanges.end())
+return "";
+

Similar concerns to above. Do we want an assert? When can this happen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93222

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


[clang-tools-extra] 5186eda - [clangd] Oops, fix code in #ifdef WIN32

2020-12-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-12-15T14:17:54+01:00
New Revision: 5186eda3269333b2fb38800e9ded2a27ae87f99b

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

LOG: [clangd] Oops, fix code in #ifdef WIN32

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index bad9c359798e..add0eec4a2c8 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -37,7 +37,7 @@ PathRef absoluteParent(PathRef Path) {
 #if defined(_WIN32)
   // llvm::sys says "C:\" is absolute, and its parent is "C:" which is 
relative.
   // This unhelpful behavior seems to have been inherited from boost.
-  if (llvm::sys::path::relative_path(Path)).empty(); {
+  if (llvm::sys::path::relative_path(Path).empty()) {
 return PathRef();
   }
 #endif



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


[PATCH] D93223: [RFC][analyzer] Create MacroExpansionContext member in AnalysisConsumer and pass down to the diagnostics consumers

2020-12-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:129
+Plugins(plugins), Injector(injector), CTU(CI),
+MacroExpansions(PP, CI.getLangOpts()) {
 DigestAnalyzerOptions();

This will always record macro related information right? Some of the diagnostic 
consumers might not ever touch macro expansions. I think it would be great to 
only record expansions when we actually will end up using them.  Alternatively, 
a benchmark proving the runtime of recording negligible on macro heavy code 
(boost maybe?) might be sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93223

___
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-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Yay! Deleting code is always nice.




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

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.


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] D93224: [RFC][analyzer] Use the MacroExpansionContext for macro expansions in plists

2020-12-15 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Internally we analyzed 16 projects with this patch-stack. No reports were 
changed!
Now we don't crash on macro expansions in our test set, yey.

I've checked a few expansions and seemed to be readable enough.




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

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.


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] D91979: [Clang][Attr] Introduce the `assume` function attribute

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:742
   "the argument to %0 has side effects that will be discarded">,
-  InGroup>;
+  InGroup;
+def warn_assume_attribute_string_unknown : Warning<

aaron.ballman wrote:
> This changes behavior for users because `-Wno-assume` now needs to be spelled 
> `-Wno-assumption` -- I think we may want to keep the diagnostics for the 
> assumption attribute separate from the diagnostics for builtin assume.
> 
> For instance, I think the assumption attribute warnings will all wind up 
> leading to an ignored attribute, so perhaps the new grouping should be under 
> the existing ignored attributes group.
I think we can ignore this comment now, but I do wonder whether we should split 
the diagnostic group somewhat. To me, the "may be misspelled" warning is going 
to always be a serious warning -- it means the user fat-fingered something and 
the attribute is likely to not do anything useful. But the non-misspelling 
warning seems like a less severe warning because I may be relying on an 
undocumented string from a pass. So I could imagine wanting to turn off all of 
the warnings for using an undocumented string from a pass but wanting to retain 
all of the misspelling warnings. However, you may be envisioning a different 
usage pattern for this than I am. WDYT?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:744
+def warn_assume_attribute_string_unknown : Warning<
+  "the assumption string '%0' is not known and might be misspelled">,
+  InGroup;

aaron.ballman wrote:
> I'd say that this case should probably be worded `unknown assumption string 
> '%0'; attribute ignored`
In light of wanting to keep the attribute around, I think this should be 
`unknown assumption string '%0'; attribute is potentially ignored` or something 
along those lines.  Basically, I think the diagnostic should focus on the fact 
that the user cannot predict what happens with this attribute.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:747
+def warn_assume_attribute_string_unknown_suggested : Warning<
+  "the assumption string '%0' is not known and might be misspelled; "
+  "did you mean '%1'?">,

aaron.ballman wrote:
> Similarly: `unknown assumption string '%0' may be misspelled; attribute 
> ignored, did you mean '%1'?`
Similar here. `unknown assumption string '%0' may be misspelled; attribute is 
potentially ignored, did you mean '%1'?`



Comment at: clang/include/clang/Sema/Sema.h:10002
+  /// Check if \p AssumptionStr is a known assumption and warn if not.
+  void CheckAssumptionAttr(SourceLocation Loc, StringRef AssumptionStr);
+

Should this be a static function in SemaDeclAttr.cpp rather than a public part 
of the Sema interface? I can't think of any other callers for this aside from 
`handleAssumptionAttr()`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1681
+  StringRef Str;
+  if (AL.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(AL, 0, Str))
+return;

jdoerfert wrote:
> aaron.ballman wrote:
> > No need to check the count manually, the common attribute handler should do 
> > that for you already.
> Copied from the generic templated handler.
Ah, yeah, that one needs to do the test because it may be called for an 
attribute expecting a variadic number of arguments.



Comment at: llvm/include/llvm/IR/Assumptions.h:15
+
+#ifndef LLVM_ASSUMPTIONS_H
+#define LLVM_ASSUMPTIONS_H

Should probably fix the lint warning here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

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


[PATCH] D92198: [clangd] Log remote index connectivity status

2020-12-15 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.

LG with one fix around the atomic




Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:49
+auto NewStatus = Channel->GetState(/*try_to_connect=*/false);
+if (ConnectionStatus != NewStatus)
+  vlog("Remote index connection [{0}]: {1} => {2}", ServerAddress,

you access ConnectionStatus twice, and have a race between them.

```
auto OldStatus = ConnectionStatus.exchange(NewStatus);
if (OldStatus != NewStatus)
  log(...)
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92198

___
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-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

From the CFE's perspective, this is all that should be needed.  Is there a BPF 
code-owner who can test it and see if it is acceptable?


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-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In general, I think this is reasonable -- there's a bit more work to be done 
before it's ready to land, but this is heading in the right direction.




Comment at: clang/include/clang/Basic/Attr.td:559
+/// A attribute is either a declaration attribute or a statement attribute.
+class DeclOrStmtAttr : Attr;
+

I think this should be an `InheritableAttr`, like `DeclOrTypeAttr`. With 
type/decl attributes, those are almost always for things like calling 
conventions or other cases where inheritance of the attribute is really likely 
to be the correct default. It's less clear to me that the same is true for 
stmt/decl attributes aside from the observation that most decl attributes are 
inheritable. We may need to come up with a better approach for inheritance here 
at some point when we find a stmt/decl attribute that should not be inheritable.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2185
 
+static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!isFunctionOrMethod(D)) {

No need for this function, you can set `let SimpleHandler = 1;` in Attr.td -- 
the common attribute handler code should handle checking the subject list for 
you automatically.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7757
+  case ParsedAttr::AT_NoMerge:
+handleNoMergeAttr(S, D, AL);
+break;

Then this can become `handleSimpleAttribute(S, D, AL);`



Comment at: clang/test/CodeGen/attr-nomerge.cpp:73
+// CHECK-DAG: attributes #[[ATTR2]] = {{{.*}}nomerge{{.*}}}
+// CHECK-DAG: attributes #[[ATTR3]] = {{{.*}}nomerge{{.*}}}

Can you also add a test case to demonstrate that inheriting the attribute on a 
later redeclaration works? It can either be a codegen test or an AST dump test.



Comment at: clang/test/Sema/attr-nomerge.cpp:11
 
-  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute 
cannot be applied to a declaration}}
+  [[clang::nomerge]] label: bar(); // expected-warning {{'nomerge' attribute 
only applies to functions and methods}}
 

This diagnostic is no longer correct -- nomerge now applies to more things. You 
may need to teach the clang attribute emitter about stmt/decl attribute types 
so that it can generate a better diagnostic in `diagnoseAppertainsTo()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

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


[PATCH] D92990: [clangd] Provide suggestions with invalid config keys

2020-12-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: hokein.
sammccall added a comment.

Sorry about being slow here.
Just a couple of suggestions to avoid cluttering the config parsing bits too 
much, and IIUC fixits can be removed.




Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:211
+llvm::SmallVector
+unseenKeys(const llvm::SmallSet &SeenKeys) const {
+  llvm::SmallVector Result;

I think inlining unseenKeys into warnUnknownKeys would be more readable by 
isolating the mechanics of typo correction into fewer places.



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:219
+
+static llvm::Optional
+bestGuess(llvm::StringRef Search,

I think we can pull this function out of this class, since it doesn't have much 
to do with config parsing. (Probably just anonymous above - it's not so 
reusable since candidates aren't always just strings)



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:291
+  void error(const llvm::Twine &Msg, llvm::SMRange Range,
+ llvm::ArrayRef Fixes = {}) {
 HadError = true;

please remove the SMFixIt bits, since we don't have any way to use them



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:231
+unsigned EditDistance = Search.edit_distance(Item, true, MaxEdit);
+if (EditDistance == MaxEdit) {
+  if (!Result)

njames93 wrote:
> sammccall wrote:
> > This branch is confusing.
> > It seems to be saying if we have a tie for best, don't return either 
> > result. Why is that important/worth any complexity?
> If we have 2 (or more) possible solutions, we can't say for certainty what 
> the user wanted, in which case its best to not suggest anything, in case its 
> incorrect and instead force the user to take an informed look. It doesn't 
> really add much complexity to do this check, And most of this code is copied 
> from somewhere else in llvm as its a pretty common routine. Maybe they could 
> be coalesced into 1 class to reduce duplication,
Well, there isn't *any* case where we can say for certain that we know what the 
user wanted.

If this were a common library then that shifts the complexity/accuracy tradeoff 
and justifies a bit of extra work. As it is, the fact that it's copy/pasted 
doesn't help much with maintaining/reading it. We can keep this, though I don't 
feel great about it.

(FWIW, these same copy/pasted numbers thresholds are used for clang's typo 
correction, and we're pretty sure they're not very good - @hokein has tuning 
them on his backlog)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92990

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


[PATCH] D93296: [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly

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

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

Initializer lists with a try-block are incorrectly formatted.

e.g.

  Foo(int abc, int def) try : _abc(abc), _def{def}, _ghi{1} {
callA();
callB();
  } catch (std::exception&) {
  }

is formatted as:

  Foo(int abc, int def) try : _abc(abc), _def { def }
  , _ghi{1} {
callA();
callB();
  }
  catch (std::exception&) {
  }

This revision adds support in the parseTryCatch for braced initializers in the 
initializer list


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93296

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,20 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first identifier.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,20 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first identifier.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51650: Implement target_clones multiversioning

2020-12-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 311890.
erichkeane added a comment.

Since there seems to be at least a little renewed interest in this from a 
handful of people lately, I spend the time to rebase this and do some minor 
cleanup tasks.


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

https://reviews.llvm.org/D51650

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-clones.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-cpuspecific.c
  clang/test/Sema/attr-target-clones.c

Index: clang/test/Sema/attr-target-clones.c
===
--- /dev/null
+++ clang/test/Sema/attr-target-clones.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// Duplicates are allowed, however they alter name mangling.
+// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
+// expected-warning@+1 2 {{version list contains duplicate entries}}
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,")))
+empty_target_3(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default, ,avx2")))
+empty_target_4(void);
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,avx2", "")))
+empty_target_5(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("default", "default")))
+dupe_default(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("avx2,avx2,default")))
+dupe_normal(void);
+
+// expected-error@+2 {{'target_clones' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("avx2,default"), target_clones("arch

[PATCH] D92874: [clangd] Validate clang-tidy Checks in clangd config.

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

Thanks! Just some organization nits.




Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:26
 
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "CompileCommands.h"

This is a pretty weird place to depend on clang-tidy.
Can we move the "is this a clang-tidy check name" function to somewhere more 
clang-tidy related, like `TidyProvider.h` or even 
`clang-tidy/ClangTidyModuleRegistry.h`? ("isRegisteredCheck")



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:355
+  // tidy check, most likely due to a typo.
+  static bool isInvalidCheckGlob(StringRef CheckGlob) {
+// Any wildcards just assume they aren't invalid

naming nits:
 - prefer positive over negative names
 - "glob" is confusing here as we don't actually handle globs
 - outside of the clang-tidy namespace, "check" needs a "tidy" qualifier

What about `isTidyCheckName`, and move the `*` test into the caller? Then the 
semantics of the function are really clear without having to read the body or 
comment.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:386
+   llvm::formatv(
+   "Check glob '{0}' doesn't specify any known clang-tidy check",
+   Str)

message could be clearer - "clang-tidy check '{0}' was not found"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92874

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


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

2020-12-15 Thread Sunny via Phabricator via cfe-commits
achieveartificialintelligence created this revision.
achieveartificialintelligence added reviewers: HsiangKai, rkruppe, kito-cheng, 
craig.topper, jrtc27, luismarques.
Herald added subscribers: frasercrmck, NickHung, evandro, apazos, 
sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
achieveartificialintelligence requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93298

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32d-invalid.s
  llvm/test/MC/RISCV/rv32zfh-invalid.s
  llvm/test/MC/RISCV/rvzfinx-valid.s

Index: llvm/test/MC/RISCV/rvzfinx-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-valid.s
@@ -0,0 +1,333 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zfinx %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+fmadd.h a0, a1, a2, a3
+# CHECK-INST: fmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x43,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 43 f5 c5 6c 
+
+fmsub.h a0, a1, a2, a3
+# CHECK-INST: fmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x47,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 47 f5 c5 6c 
+
+fnmsub.h a0, a1, a2, a3
+# CHECK-INST: fnmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4b,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4b f5 c5 6c 
+
+fnmadd.h a0, a1, a2, a3
+# CHECK-INST: fnmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4f,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4f f5 c5 6c 
+
+fadd.h a0, a1, a2
+# CHECK-INST: fadd.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x04]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 04 
+
+fsub.h a0, a1, a2
+# CHECK-INST: fsub.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x0c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 0c 
+
+fmul.h a0, a1, a2
+# CHECK-INST: fmul.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x14]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 14 
+
+fdiv.h a0, a1, a2
+# CHECK-INST: fdiv.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x1c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 1c 
+
+fsqrt.h a0, a1
+# CHECK-INST: fsqrt.h a0, a1
+# CHECK-ENCODING: [0x53,0xf5,0x05,0x5c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 05 5c 
+
+fsgnj.h a0, a1, a2
+# CHECK-INST: fsgnj.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 24 
+
+fsgnjn.h a0, a1, a2
+# CHECK-INST: fsgnjn.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 24 
+
+fsgnjx.h a0, a1, a2
+# CHECK-INST: fsgnjx.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 24 
+
+fmin.h a0, a1, a2
+# CHECK-INST: fmin.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 2c 
+
+fmax.h a0, a1, a2
+# CHECK-INST: fmax.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 2c 
+
+feq.h a0, a1, a2
+# CHECK-INST: feq.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 a4 
+
+flt.h a0, a1, a2
+# CHECK-INST: flt.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 a4 
+
+fle.h a0, a1, a2
+# CHECK-INST: fle.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 a4 
+
+fclass.h a0, a1
+# CHECK-INST: fclass.h a0, a1
+# CHECK-ENCODING: [0x53,0x95,0x05,0xe4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 05 e4 
+
+fma

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

2020-12-15 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir accepted this revision.
saghir added a comment.

LGTM. A minor nit regarding an incomplete comment in 
`llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll` which can be addressed 
when committing the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91974

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


[PATCH] D91819: [PowerPC] Enable paired vector type and intrinsics when MMA is disabled

2020-12-15 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir accepted this revision.
saghir 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/D91819/new/

https://reviews.llvm.org/D91819

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


[PATCH] D93078: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

2020-12-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D93078#2453891 , @pengfei wrote:

> LGTM. Thanks.
> `update_test_prefix.py` assumes the conflicting output. You may need to 
> change the expection of it as well.

oh yes - made it check the new warning. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93078

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


[PATCH] D93078: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

2020-12-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 311896.
mtrofin added a comment.

update_test_prefix.py change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93078

Files:
  clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
  clang/test/utils/update_cc_test_checks/prefix-never-matches.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
  llvm/test/tools/UpdateTestChecks/update_test_checks/prefix-never-matches.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_test_prefix.py

Index: llvm/utils/update_test_prefix.py
===
--- llvm/utils/update_test_prefix.py
+++ llvm/utils/update_test_prefix.py
@@ -31,7 +31,7 @@
 t = re.search('Assertions have been autogenerated by (.*)', s)
 if t:
 s = os.popen('llvm/' + t.group(1) + ' ' + i + ' 2>&1').read()
-if 'Found conflicting' in s:
+if 'had conflicting output from different RUN lines for all functions' in s:
 return -1
 s = os.popen('git diff ' + i).read()
 if re.search('\n(?:-+)\n', s) or re.search('\n[+-].*(?&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.ll %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
@@ -0,0 +1,7 @@
+; RUN: opt -O0 -S < %s  | FileCheck %s -check-prefix=A
+; RUN: opt -O3 -S < %s  | FileCheck %s -check-prefix=A
+
+define i32 @foo(i32 %i) {
+%r = add i32 1, 1
+ret i32 %r
+}
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
@@ -0,0 +1,8 @@
+# REQUIRES: x86-registered-target
+
+# RUN: cp -f %S/Inputs/prefix-never-matches.ll %t.ll
+# RUN: %update_llc_test_checks %t.ll 2>&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.ll %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86-registered-target
+
+# RUN: cp -f %S/Inputs/common-label-different-bodies-1.ll %t-1.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-2.ll %t-2.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-3.ll %t-3.ll
+# RUN: %update_llc_test_checks %t-1.ll
+# RUN: %update_llc_test_checks %t-2.ll
+# RUN: %update_llc_test_checks %t-3.ll
+# RUN: FileCheck --input-file=%t-1.ll %s
+# RUN: FileCheck --input-file=%t-2.ll %s
+# RUN: FileCheck --input-file=%t-3.ll %s
+
+# CHECK: B-LABEL: fold_v2i64
+# CHECK-NOT: A-LABEL: fold_v2i64
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
@@ -0,0 +1,10 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=A
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> )
+  ret <2 x i64> %r
+}
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A,B
+;

[PATCH] D90159: [DDG] Data Dependence Graph - DOT printer

2020-12-15 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added a comment.

In D90159#2453805 , @Meinersbur wrote:

> Can I help fixing the Windows build problem?

I think I have a fix (please see the updated patch), but don't have access to a 
windows machine to verify. Would you be able to try building with MSVC and let 
me know if it passes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90159

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


[PATCH] D90159: [DDG] Data Dependence Graph - DOT printer

2020-12-15 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour updated this revision to Diff 311897.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90159

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  llvm/include/llvm/Analysis/CFGPrinter.h
  llvm/include/llvm/Analysis/DDG.h
  llvm/include/llvm/Analysis/DDGPrinter.h
  llvm/include/llvm/Support/DOTGraphTraits.h
  llvm/include/llvm/Support/GraphWriter.h
  llvm/lib/Analysis/CFGPrinter.cpp
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/CallPrinter.cpp
  llvm/lib/Analysis/DDGPrinter.cpp
  llvm/lib/CodeGen/MachineScheduler.cpp
  llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def

Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -384,6 +384,7 @@
 #define LOOP_PASS(NAME, CREATE_PASS)
 #endif
 LOOP_PASS("canon-freeze", CanonicalizeFreezeInLoopsPass())
+LOOP_PASS("dot-ddg", DDGDotPrinterPass())
 LOOP_PASS("invalidate", InvalidateAllAnalysesPass())
 LOOP_PASS("licm", LICMPass())
 LOOP_PASS("loop-idiom", LoopIdiomRecognizePass())
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Analysis/DDG.h"
+#include "llvm/Analysis/DDGPrinter.h"
 #include "llvm/Analysis/Delinearization.h"
 #include "llvm/Analysis/DemandedBits.h"
 #include "llvm/Analysis/DependenceAnalysis.h"
Index: llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
===
--- llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
+++ llvm/lib/CodeGen/ScheduleDAGPrinter.cpp
@@ -35,7 +35,7 @@
   return true;
 }
 
-static bool isNodeHidden(const SUnit *Node) {
+static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
   return (Node->NumPreds > 10 || Node->NumSuccs > 10);
 }
 
Index: llvm/lib/CodeGen/MachineScheduler.cpp
===
--- llvm/lib/CodeGen/MachineScheduler.cpp
+++ llvm/lib/CodeGen/MachineScheduler.cpp
@@ -3836,7 +3836,7 @@
 return true;
   }
 
-  static bool isNodeHidden(const SUnit *Node) {
+  static bool isNodeHidden(const SUnit *Node, const ScheduleDAG *G) {
 if (ViewMISchedCutoff == 0)
   return false;
 return (Node->Preds.size() > ViewMISchedCutoff
Index: llvm/lib/Analysis/DDGPrinter.cpp
===
--- /dev/null
+++ llvm/lib/Analysis/DDGPrinter.cpp
@@ -0,0 +1,150 @@
+//===- DDGPrinter.cpp - DOT printer for the data dependence graph --==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+//===--===//
+//
+// This file defines the `-dot-ddg` analysis pass, which emits DDG in DOT format
+// in a file named `ddg..dot` for each loop  in a function.
+//===--===//
+
+#include "llvm/Analysis/DDGPrinter.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/GraphWriter.h"
+
+using namespace llvm;
+
+static cl::opt DotOnly("dot-ddg-only", cl::init(false), cl::Hidden,
+ cl::ZeroOrMore, cl::desc("simple ddg dot graph"));
+static cl::opt DDGDotFilenamePrefix(
+"dot-ddg-filename-prefix", cl::init("ddg"), cl::Hidden,
+cl::desc("The prefix used for the DDG dot file names."));
+
+static void writeDDGToDotFile(DataDependenceGraph &G, bool DOnly = false);
+
+//======//
+// Implementation of DDG DOT Printer for a loop
+//======//
+PreservedAnalyses DDGDotPrinterPass::run(Loop &L, LoopAnalysisManager &AM,
+ LoopStandardAnalysisResults &AR,
+ LPMUpdater &U) {
+  writeDDGToDotFile(*AM.getResult(L, AR), DotOnly);
+  return PreservedAnalyses::all();
+}
+
+static void writeDDGToDotFile(DataDependenceGraph &G, bool DOnly) {
+  std::string Filename =
+  Twine(DDGDotFilenamePrefix + "." + G.getName() + ".dot").str();
+  errs() << "Writing '" << Filename << "'...";
+
+  std::error_code EC;
+  raw_fd_ostream File(Filename, EC, sys::fs::F_Text);
+
+  if (!EC)
+// We only provide the constant verson of the DOTGraphTrait specialization,
+// hence the conversion to const pointer
+WriteGraph(File, (co

[PATCH] D90275: [clang][IR] Add support for leaf attribute

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

In D90275#2453641 , @gulfem wrote:

>> This is missing a lang ref entry for `nocallback` and the `attributes.ll` 
>> test is arguably broken (see below).
>
> Could you please elaborate on missing lang ref entry? Where that should be 
> added?

Sure, my bad. Each enum attribute needs an entry in the language reference to 
define it's meaning, see also 
https://llvm.org/docs/LangRef.html#function-attributes
The content is in llvm/docs/LangRef.rst.

>> The "definition" in `llvm/include/llvm/IR/Attributes.td` (see below), does 
>> not match the the behavior of `clang/test/CodeGen/attr-leaf.c`.
>> As I mentioned before, this doesn't have a meaning on definitions and that 
>> needs to be captured in the semantics (and preferably the FE).
>
> In that test case, `leaf` attribute is on the declaration.
> What kind of a test case do you suggest to add?

We need to first define the meaning of `nocallback` in the IR, without that it 
is hard to do anything else.

---

The problem in `llvm/test/Bitcode/attributes.ll` is clear?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

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


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

2020-12-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Firstly, please generate your diffs with full context (-U with a 
sufficiently-large number). Secondly, can we avoid having to do a bunch of 
duplication with some clever use of multiclasses for F/D/Zfh and pseudos? 
Though maybe it's small enough that the duplication is easier to reason about 
than an obfuscated abstracted version.

Also, do you not need more predicates? You can't just assume all of F, D and 
Zfh exist.

As for Zfinx itself, well, the idea is fine, but I really detest the way it's 
being done as an extension to F/D/Zfh. Running F code on an FZfh core _does not 
work_ so it is not an _extension_. Instead it should really be a set of 
separate extensions to I/E that conflict with F/D/Zfh, i.e. Zfinx, Zdinx and 
Zfhinx, but apparently asking code that complies with a ratified standard to 
change itself in order to not break when a new extension is introduced is a-ok 
in the RISC-V world.




Comment at: llvm/test/MC/RISCV/rv32zfh-invalid.s:33
-# Integer registers where FP regs are expected
-fadd.h a2, a1, a0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction
-

These need to stay, but presumably instead as errors about Zfinx not being 
enabled?


Repository:
  rG LLVM Github Monorepo

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] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-12-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 311898.
vsavchenko added a comment.

Refine conventions for completion handlers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-called-once.m
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- /dev/null
+++ clang/test/SemaObjC/warn-called-once.m
@@ -0,0 +1,950 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions -Wcompletion-handler %s
+
+#define NULL (void *)0
+#define CALLED_ONCE __attribute__((called_once))
+#define NORETURN __attribute__((noreturn))
+
+@protocol NSObject
+@end
+@interface NSObject 
+- (id)copy;
+- (id)class;
+- autorelease;
+@end
+
+typedef unsigned int NSUInteger;
+typedef struct {
+} NSFastEnumerationState;
+
+@interface NSArray <__covariant NSFastEnumeration>
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@interface NSMutableArray : NSArray 
+- addObject:anObject;
+@end
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+
+void escape(void (^callback)(void));
+void escape_void(void *);
+void indirect_call(void (^callback)(void) CALLED_ONCE);
+void indirect_conv(void (^completionHandler)(void));
+void filler(void);
+void exit(int) NORETURN;
+
+void double_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_parens(void (^callback)(void) CALLED_ONCE) {
+  (callback)(); // expected-note{{previous call is here}}
+  (callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr(void (*callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr_deref(void (*callback)(void) CALLED_ONCE) {
+  (*callback)(); // expected-note{{previous call is here}}
+  (*callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void multiple_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  // We don't really need to repeat the same warning for the same parameter.
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback(); // expected-note{{previous call is here}}
+  } else {
+cond += 42;
+  }
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+
+  if (cond) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  } else {
+cond += 42;
+  }
+}
+
+void double_call_branching_3(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback();
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void double_call_branching_4(int cond1, int cond2, void (^callback)(void) CALLED_ONCE) {
+  if (cond1) {
+cond2 = !cond2;
+  } else {
+callback(); // expected-note{{previous call is here}}
+  }
+
+  if (cond2) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void double_call_loop(int counter, void (^callback)(void) CALLED_ONCE) {
+  while (counter > 0) {
+counter--;
+// Both note and warning are on the same line, which is a common situation
+// in loops.
+callback(); // expected-note{{previous call is here}}
+// expected-warning@-1{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void never_called_trivial(void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter marked 'called_once' is never called}}
+}
+
+int never_called_branching(int x, void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter 

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

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

Thanks! This seems more consistent with our other hovers, but is going to be 
better-formatted/more attractive in VSCode.
There are a couple of wrinkles I'd like to discuss :-)

Brevity
---

This is clear and mostly consistent (documentation excepted), but uses three 
lines where clearly two would do - the "auto" title provides very little 
information, and the documentation only a bit more (pun intended!)

Can we combine them? The title has SymbolKind which normally holds the 
category. We can't easily add new SymbolKinds (it's an enum we don't own, which 
we should fix, but that's a yak-shave). But `TypeAlias` almost fits these roles 
for auto. What do you think about setting Kind/Name/Definition? This would give:

  type-alias `auto`
  const Foo&

This leaves the question of what to do with undeduced auto, maybe:

  type-alias `auto`
  /* not deduced */

(There are other cases: function parameter types `void foo(auto X)` and NTTP 
types `template  class Y` but we can punt on those)

this


D92041  recently added support for showing the 
type when hovering over `this`. It followed the existing `auto` behavior (put 
everything in `Name`) because that's the only place we were showing types per 
se.

So you're going to have a merge conflict, and we need to decide how to render 
it.

I don't really have a better idea than setting `Name = "this"`, setting 
`Definition`, and leaving Kind=Unknown. Maybe we can do better once we can 
easily extend the SymbolKind enum.


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] D93078: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

2020-12-15 Thread Mircea Trofin 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 rGe2dc306b1ac7: [utils] Fix UpdateTestChecks case where 2 runs 
differ for last label (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93078

Files:
  clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
  clang/test/utils/update_cc_test_checks/prefix-never-matches.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
  llvm/test/tools/UpdateTestChecks/update_test_checks/prefix-never-matches.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_test_prefix.py

Index: llvm/utils/update_test_prefix.py
===
--- llvm/utils/update_test_prefix.py
+++ llvm/utils/update_test_prefix.py
@@ -31,7 +31,7 @@
 t = re.search('Assertions have been autogenerated by (.*)', s)
 if t:
 s = os.popen('llvm/' + t.group(1) + ' ' + i + ' 2>&1').read()
-if 'Found conflicting' in s:
+if 'had conflicting output from different RUN lines for all functions' in s:
 return -1
 s = os.popen('git diff ' + i).read()
 if re.search('\n(?:-+)\n', s) or re.search('\n[+-].*(?&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.ll %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll
@@ -0,0 +1,7 @@
+; RUN: opt -O0 -S < %s  | FileCheck %s -check-prefix=A
+; RUN: opt -O3 -S < %s  | FileCheck %s -check-prefix=A
+
+define i32 @foo(i32 %i) {
+%r = add i32 1, 1
+ret i32 %r
+}
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test
@@ -0,0 +1,8 @@
+# REQUIRES: x86-registered-target
+
+# RUN: cp -f %S/Inputs/prefix-never-matches.ll %t.ll
+# RUN: %update_llc_test_checks %t.ll 2>&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.ll %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test
@@ -0,0 +1,14 @@
+# REQUIRES: x86-registered-target
+
+# RUN: cp -f %S/Inputs/common-label-different-bodies-1.ll %t-1.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-2.ll %t-2.ll
+# RUN: cp -f %S/Inputs/common-label-different-bodies-3.ll %t-3.ll
+# RUN: %update_llc_test_checks %t-1.ll
+# RUN: %update_llc_test_checks %t-2.ll
+# RUN: %update_llc_test_checks %t-3.ll
+# RUN: FileCheck --input-file=%t-1.ll %s
+# RUN: FileCheck --input-file=%t-2.ll %s
+# RUN: FileCheck --input-file=%t-3.ll %s
+
+# CHECK: B-LABEL: fold_v2i64
+# CHECK-NOT: A-LABEL: fold_v2i64
\ No newline at end of file
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll
@@ -0,0 +1,10 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=A
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=A
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> )
+  ret <2 x i64> %r
+}
Index: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll
===
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Input

[clang] e2dc306 - [utils] Fix UpdateTestChecks case where 2 runs differ for last label

2020-12-15 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2020-12-15T07:16:54-08:00
New Revision: e2dc306b1ac71258e6ce40a66e778527f282c355

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

LOG: [utils] Fix UpdateTestChecks case where 2 runs differ for last label

Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
clang/test/utils/update_cc_test_checks/prefix-never-matches.test

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-2.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-3.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/prefix-never-matches.ll

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/common-label-different-bodies.test

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/prefix-never-matches.test

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/prefix-never-matches.ll

llvm/test/tools/UpdateTestChecks/update_test_checks/prefix-never-matches.test

Modified: 
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_test_prefix.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp 
b/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
new file mode 100644
index ..75bd5b1249a7
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/prefix-never-matches.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -O0 -o - %s | 
FileCheck %s -check-prefix=A
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -O3 -o - %s | 
FileCheck %s -check-prefix=A
+
+int foo(int i ) {
+return 1;
+}
\ No newline at end of file

diff  --git a/clang/test/utils/update_cc_test_checks/prefix-never-matches.test 
b/clang/test/utils/update_cc_test_checks/prefix-never-matches.test
new file mode 100644
index ..7100377337bc
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/prefix-never-matches.test
@@ -0,0 +1,6 @@
+# RUN: cp -f %S/Inputs/prefix-never-matches.cpp %t.cpp
+# RUN: %update_cc_test_checks %t.cpp 2>&1 | FileCheck %s
+# RUN: FileCheck --input-file=%t.cpp %s --check-prefix=OUTPUT
+
+# CHECK: WARNING: Prefix A had conflicting output
+# OUTPUT-NOT: A:
\ No newline at end of file

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll
new file mode 100644
index ..c5f2bc9ba5bc
--- /dev/null
+++ 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-1.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2 | FileCheck %s 
--check-prefixes=A,B
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s 
--allow-unused-prefixes=true --check-prefixes=C,A,UNUSED
+
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+; A: declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
+
+define <2 x i64> @fold_v2i64() {
+entry:
+  %r = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> )
+  ret <2 x i64> %r
+}

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll
new file mode 100644
index ..bc1990462d37
--- /dev/null
+++ 
b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-
diff erent-bodies-2.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=

[clang-tools-extra] bda7d0a - [clangd] Improve goToDefinition on auto and dectype

2020-12-15 Thread Sam McCall via cfe-commits

Author: Quentin Chateau
Date: 2020-12-15T16:32:22+01:00
New Revision: bda7d0af970718c243d93b22a8449c20156e574f

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

LOG: [clangd] Improve goToDefinition on auto and dectype

locateSymbolAt (used in goToDeclaration) follows the
deduced type instead of failing to locate the declaration.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index ac4543026a9f..c7ec401c6479 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -463,6 +463,42 @@ locateASTReferent(SourceLocation CurLoc, const 
syntax::Token *TouchedIdentifier,
   return Result;
 }
 
+std::vector locateSymbolForType(const ParsedAST &AST,
+   const QualType &Type) {
+  const auto &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed to get a path for the main file, so no symbol.");
+return {};
+  }
+
+  auto Decls = targetDecl(DynTypedNode::create(Type.getNonReferenceType()),
+  DeclRelation::TemplatePattern | DeclRelation::Alias);
+  if (Decls.empty())
+return {};
+
+  std::vector Results;
+  const auto &ASTContext = AST.getASTContext();
+
+  for (const NamedDecl *D : Decls) {
+D = getPreferredDecl(D);
+
+auto Loc = makeLocation(ASTContext, nameLocation(*D, SM), *MainFilePath);
+if (!Loc)
+  continue;
+
+Results.emplace_back();
+Results.back().Name = printName(ASTContext, *D);
+Results.back().PreferredDeclaration = *Loc;
+if (const NamedDecl *Def = getDefinition(D))
+  Results.back().Definition =
+  makeLocation(ASTContext, nameLocation(*Def, SM), *MainFilePath);
+  }
+
+  return Results;
+}
+
 bool tokenSpelledAt(SourceLocation SpellingLoc, const syntax::TokenBuffer &TB) 
{
   auto ExpandedTokens = TB.expandedTokens(
   TB.sourceManager().getMacroArgExpandedLocation(SpellingLoc));
@@ -707,15 +743,31 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
 return {};
   }
 
-  const syntax::Token *TouchedIdentifier =
-  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
-  if (TouchedIdentifier)
-if (auto Macro =
-locateMacroReferent(*TouchedIdentifier, AST, *MainFilePath))
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return {*std::move(Macro)};
+  const syntax::Token *TouchedIdentifier = nullptr;
+  auto TokensTouchingCursor =
+  syntax::spelledTokensTouching(*CurLoc, AST.getTokens());
+  for (const syntax::Token &Tok : TokensTouchingCursor) {
+if (Tok.kind() == tok::identifier) {
+  if (auto Macro = locateMacroReferent(Tok, AST, *MainFilePath))
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return {*std::move(Macro)};
+
+  TouchedIdentifier = &Tok;
+  break;
+}
+
+if (Tok.kind() == tok::kw_auto || Tok.kind() == tok::kw_decltype) {
+  // go-to-definition on auto should find the definition of the deduced
+  // type, if possible
+  if (auto Deduced = getDeducedType(AST.getASTContext(), Tok.location())) {
+auto LocSym = locateSymbolForType(AST, *Deduced);
+if (!LocSym.empty())
+  return LocSym;
+  }
+}
+  }
 
   ASTNodeKind NodeKind;
   auto ASTResults = locateASTReferent(*CurLoc, TouchedIdentifier, AST,

diff  --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp 
b/clang-tools-extra/clangd/unittests/ASTTests.cpp
index 21f70dcc3168..4c52c72d703c 100644
--- a/clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -26,23 +26,168 @@ namespace clang {
 namespace clangd {
 namespace {
 
-TEST(GetDeducedType, KwAutoExpansion) {
+TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
   struct Test {
 StringRef AnnotatedCode;
 const char *DeducedType;
   } Tests[] = {
   {"^auto i = 0;", "int"},
   {"^auto f(){ return 1;};", "int"},
+  {
+  R"cpp( // auto on struct in a namespace
+  namespace ns1 { struct S {}; }
+  ^auto v = ns1::S{};
+  )cpp",
+  "struct ns1::S",
+  },
+  {
+  R"cpp( // decltype on struct
+  namespace ns1 { struct S 

[PATCH] D92977: [clangd] Improve hover and goToDefinition on auto and dectype

2020-12-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbda7d0af9707: [clangd] Improve goToDefinition on auto and 
dectype (authored by qchateau, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92977

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -640,6 +640,134 @@
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// auto builtin type (not supported)
+^auto x = 42;
+  )cpp",
+
+  R"cpp(// auto on lambda
+auto x = [[[]]]{};
+^auto y = x;
+  )cpp",
+
+  R"cpp(// auto on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+^auto x = ns1::S1{};
+  )cpp",
+
+  R"cpp(// decltype on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+ns1::S1 i;
+^decltype(i) j;
+  )cpp",
+
+  R"cpp(// decltype(auto) on struct
+namespace ns1 {
+struct [[S1]] {};
+} // namespace ns1
+
+ns1::S1 i;
+ns1::S1& j = i;
+^decltype(auto) k = j;
+  )cpp",
+
+  R"cpp(// auto on template class
+template class [[Foo]] {};
+
+^auto x = Foo();
+  )cpp",
+
+  R"cpp(// auto on template class with forward declared class
+template class [[Foo]] {};
+class X;
+
+^auto x = Foo();
+  )cpp",
+
+  R"cpp(// auto on specialized template class
+template class Foo {};
+template<> class [[Foo]] {};
+
+^auto x = Foo();
+  )cpp",
+
+  R"cpp(// auto on initializer list.
+namespace std
+{
+  template
+  class [[initializer_list]] {};
+}
+
+^auto i = {1,2};
+  )cpp",
+
+  R"cpp(// auto function return with trailing type
+struct [[Bar]] {};
+^auto test() -> decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// decltype in trailing return type
+struct [[Bar]] {};
+auto test() -> ^decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// auto in function return
+struct [[Bar]] {};
+^auto test() {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// auto& in function return
+struct [[Bar]] {};
+^auto& test() {
+  static Bar x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// auto* in function return
+struct [[Bar]] {};
+^auto* test() {
+  Bar* x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// const auto& in function return
+struct [[Bar]] {};
+const ^auto& test() {
+  static Bar x;
+  return x;
+}
+  )cpp",
+
+  R"cpp(// decltype(auto) in function return
+struct [[Bar]] {};
+^decltype(auto) test() {
+  return Bar();
+}
+  )cpp",
+
+  R"cpp(// decltype of function with trailing return type.
+struct [[Bar]] {};
+auto test() -> decltype(Bar()) {
+  return Bar();
+}
+void foo() {
+  ^decltype(test()) i = test();
+}
+  )cpp",
+
   R"cpp(// Override specifier jumps to overridden method
 class Y { virtual void $decl[[a]]() = 0; };
 class X : Y { void a() ^override {} };
Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -26,23 +26,168 @@
 namespace clangd {
 namespace {
 
-TEST(GetDeducedType, KwAutoExpansion) {
+TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
   struct Test {
 StringRef AnnotatedCode;
 const char *DeducedType;
   } Tests[] = {
   {"^auto i = 0;", "int"},
   {"^auto f(){ return 1;};", "int"},
+  {
+  R"cpp( // auto on struct in a namespace
+  namespace ns1 { struct S {}; }
+  ^auto v = ns1::S{};
+  )cpp",
+  "struct ns1::S",
+  },
+  {
+  R"cpp( // decltype on struct
+  namespace ns1 { struct S {}; }
+  ns1::S i;
+  ^decltype(i) j;
+  )cpp",
+  "ns1::S",
+  },
+  {
+  R"cpp(// decltype(auto) on struct&
+namespace ns1 {
+struct S {};
+} // namespace ns1
+
+ns1::S i;
+ns1::S& j = i;
+^decltype(auto) k = j;
+  )

[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-12-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 311903.
vsavchenko added a comment.

Fix minor things


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-called-once.m
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- /dev/null
+++ clang/test/SemaObjC/warn-called-once.m
@@ -0,0 +1,950 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions -Wcompletion-handler %s
+
+#define NULL (void *)0
+#define CALLED_ONCE __attribute__((called_once))
+#define NORETURN __attribute__((noreturn))
+
+@protocol NSObject
+@end
+@interface NSObject 
+- (id)copy;
+- (id)class;
+- autorelease;
+@end
+
+typedef unsigned int NSUInteger;
+typedef struct {
+} NSFastEnumerationState;
+
+@interface NSArray <__covariant NSFastEnumeration>
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@interface NSMutableArray : NSArray 
+- addObject:anObject;
+@end
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+
+void escape(void (^callback)(void));
+void escape_void(void *);
+void indirect_call(void (^callback)(void) CALLED_ONCE);
+void indirect_conv(void (^completionHandler)(void));
+void filler(void);
+void exit(int) NORETURN;
+
+void double_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_parens(void (^callback)(void) CALLED_ONCE) {
+  (callback)(); // expected-note{{previous call is here}}
+  (callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr(void (*callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr_deref(void (*callback)(void) CALLED_ONCE) {
+  (*callback)(); // expected-note{{previous call is here}}
+  (*callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void multiple_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  // We don't really need to repeat the same warning for the same parameter.
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback(); // expected-note{{previous call is here}}
+  } else {
+cond += 42;
+  }
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+
+  if (cond) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  } else {
+cond += 42;
+  }
+}
+
+void double_call_branching_3(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback();
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void double_call_branching_4(int cond1, int cond2, void (^callback)(void) CALLED_ONCE) {
+  if (cond1) {
+cond2 = !cond2;
+  } else {
+callback(); // expected-note{{previous call is here}}
+  }
+
+  if (cond2) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void double_call_loop(int counter, void (^callback)(void) CALLED_ONCE) {
+  while (counter > 0) {
+counter--;
+// Both note and warning are on the same line, which is a common situation
+// in loops.
+callback(); // expected-note{{previous call is here}}
+// expected-warning@-1{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void never_called_trivial(void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter marked 'called_once' is never called}}
+}
+
+int never_called_branching(int x, void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter marked 'called_once' is ne

[PATCH] D92751: Precondition isHomogeneousAggregate on isCXX14Aggregate

2020-12-15 Thread David Truby via Phabricator via cfe-commits
DavidTruby updated this revision to Diff 311906.
DavidTruby added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Added extra tests for additional conditions and IR -> assembly tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92751

Files:
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  llvm/test/CodeGen/AArch64/arm64-windows-calls.ll

Index: llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
===
--- llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
+++ llvm/test/CodeGen/AArch64/arm64-windows-calls.ll
@@ -98,3 +98,41 @@
   %this1 = load %class.C*, %class.C** %this.addr, align 8
   ret void
 }
+
+; The following tests correspond to tests in
+; clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+
+; Pod is a trivial HFA
+%struct.Pod = type { [2 x double] }
+; Not an aggregate according to C++14 spec => not HFA according to MSVC
+%struct.NotCXX14Aggregate  = type { %struct.Pod }
+; NotPod is a C++14 aggregate. But not HFA, because it contains
+; NotCXX14Aggregate (which itself is not HFA because it's not a C++14
+; aggregate).
+%struct.NotPod = type { %struct.NotCXX14Aggregate }
+
+define dso_local %struct.Pod @copy_pod(%struct.Pod* %x) {
+  %x1 = load %struct.Pod, %struct.Pod* %x, align 8
+  ret %struct.Pod %x1
+; CHECK: ldp d0, d1, [x0]
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
+
+define dso_local void
+@copy_notcxx14aggregate(%struct.NotCXX14Aggregate* inreg noalias sret(%struct.NotCXX14Aggregate) align 8 %agg.result,
+%struct.NotCXX14Aggregate* %x) {
+  %1 = bitcast %struct.NotCXX14Aggregate* %agg.result to i8*
+  %2 = bitcast %struct.NotCXX14Aggregate* %x to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %1, i8* align 8 %2, i64 16, i1 false)
+  ret void
+; CHECK: str q0, [x0]
+}
+
+define dso_local [2 x i64] @copy_notpod(%struct.NotPod* %x) {
+  %x1 = bitcast %struct.NotPod* %x to [2 x i64]*
+  %x2 = load [2 x i64], [2 x i64]* %x1
+  ret [2 x i64] %x2
+; CHECK: ldp x8, x1, [x0]
+; CHECK: mov x0, x8
+}
Index: clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -468,3 +468,41 @@
 // WIN64-LABEL: define dso_local void @"?g@C@pr30293@@QEAAXXZ"(%"struct.pr30293::C"* {{[^,]*}} %this)
 // WIN64: declare dso_local void @"?h@C@pr30293@@UEAAXUSmallWithDtor@@@Z"(i8*, i32)
 }
+
+namespace pr47611 {
+// MSVC on Arm includes "isCXX14Aggregate" as part of its definition of
+// Homogeneous Floating-point Aggregate (HFA). Additionally, it has a different
+// handling of C++14 aggregates, which can lead to confusion.
+
+// Pod is a trivial HFA.
+struct Pod {
+  double b[2];
+};
+// Not an aggregate according to C++14 spec => not HFA according to MSVC.
+struct NotCXX14Aggregate {
+  NotCXX14Aggregate();
+  Pod p;
+};
+// NotPod is a C++14 aggregate. But not HFA, because it contains
+// NotCXX14Aggregate (which itself is not HFA because it's not a C++14
+// aggregate).
+struct NotPod {
+  NotCXX14Aggregate x;
+};
+struct Empty {};
+// A class with a base is returned in standard registers by MSVC
+struct HasEmptyBase : public Empty {
+  double b[2];
+};
+struct HasPodBase : public Pod {};
+// WOA64-LABEL: define dso_local %"struct.pr47611::Pod" @"?copy@pr47611@@YA?AUPod@1@PEAU21@@Z"(%"struct.pr47611::Pod"* %x)
+Pod copy(Pod *x) { return *x; }  // MSVC: ldp d0,d1,[x0], Clang: ldp d0,d1,[x0]
+// WOA64-LABEL: define dso_local void @"?copy@pr47611@@YA?AUNotCXX14Aggregate@1@PEAU21@@Z"(%"struct.pr47611::NotCXX14Aggregate"* inreg noalias sret(%"struct.pr47611::NotCXX14Aggregate") align 8 %agg.result, %"struct.pr47611::NotCXX14Aggregate"* %x)
+NotCXX14Aggregate copy(NotCXX14Aggregate *x) { return *x; } // MSVC: stp x8,x9,[x0], Clang: str q0,[x0]
+// WOA64-LABEL: define dso_local [2 x i64] @"?copy@pr47611@@YA?AUNotPod@1@PEAU21@@Z"(%"struct.pr47611::NotPod"* %x)
+NotPod copy(NotPod *x) { return *x; }
+// WOA64-LABEL: define dso_local void @"?copy@pr47611@@YA?AUHasEmptyBase@1@PEAU21@@Z"(%"struct.pr47611::HasEmptyBase"* inreg noalias sret(%"struct.pr47611::HasEmptyBase") align 8 %agg.result, %"struct.pr47611::HasEmptyBase"* %x)
+HasEmptyBase copy(HasEmptyBase *x) { return *x; }
+// WOA64-LABEL: define dso_local void @"?copy@pr47611@@YA?AUHasPodBase@1@PEAU21@@Z"(%"struct.pr47611::HasPodBase"* inreg noalias sret(%"struct.pr47611::HasPodBase") align 8 %agg.result, %"struct.pr47611::HasPodBase"* %x)
+HasPodBase copy(HasPodBase *x) { return *x; }
+};
Index: clang/lib/CodeGen/TargetInfo.cpp
=

[PATCH] D93164: [AST] Add generator for source location introspection

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

Do I understand correctly that the workflow is to use the new dumping tool to 
generate the needed JSON file that then gets used as input to 
generate_cxx_src_locs.py which creates NodeLocationIntrospection.cpp/.h that 
then gets used by clang-query (eventually)? So there are two levels of 
translation involved to get the final source code? If so, do you know what the 
performance/overhead for this looks like compared to a typical build? I'm 
trying to get an idea for whether this will have negative impacts on the build 
bots such that we may want to add an LLVM cmake configure option to control 
whether this work happens or not.




Comment at: clang/lib/Tooling/DumpTool/APIData.h:1
+//===- srclocdumper.cpp ===//
+//

Looks like a copy pasta error.



Comment at: clang/lib/Tooling/DumpTool/APIData.h:10
+
+#ifndef LLVM_CLANG_TOOLING_APIDATA_H
+#define LLVM_CLANG_TOOLING_APIDATA_H

Might as well fix this lint warning.



Comment at: clang/lib/Tooling/DumpTool/APIData.h:21
+
+  bool IsEmpty() const { return Locs.empty() && Rngs.empty(); }
+

per the usual naming rules.



Comment at: clang/lib/Tooling/DumpTool/APIData.h:25
+  std::vector Rngs;
+  // TODO: Extend this with locations available via typelocs etc.
+};

Are these extensions going to add new members for those? If so, perhaps `Locs` 
and `Rngs` should have more descriptive names initially?



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:40
+  // TODO: Extend this with other clades
+  namedDecl(hasName("clang::Stmt")).bind("nodeClade")),
+  optionally(isDerivedFrom(cxxRecordDecl().bind("derivedFrom"

TIL what "clade" means, thank you for that new word. :-D



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:71-74
+  if (!Obj.Locs.empty())
+JsonObj["locs"] = Obj.Locs;
+  if (!Obj.Rngs.empty())
+JsonObj["rngs"] = Obj.Rngs;

Similar question here about whether we should use less generic names or not.



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:125
+  for (const auto &BN : BoundNodesVec) {
+if (const auto Node = BN.getNodeAs("classMethod")) {
+  // Only record the getBeginLoc etc on Stmt etc, because it will call





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:127
+  // Only record the getBeginLoc etc on Stmt etc, because it will call
+  // more-derived implementations pseudo-virtually
+  if ((ASTClass->getName() != "Stmt" && ASTClass->getName() != "Decl") &&





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:134
+  // Only record the getExprLoc on Expr, because it will call
+  // more-derived implementations pseudo-virtually
+  if ((ASTClass->getName() != "Expr") &&





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:135-136
+  // more-derived implementations pseudo-virtually
+  if ((ASTClass->getName() != "Expr") &&
+  (Node->getName() == "getExprLoc")) {
+continue;





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:154-155
+
+auto NodeClade = Result.Nodes.getNodeAs("nodeClade");
+auto CladeName = NodeClade->getName();
+





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:157
+
+if (auto DerivedFrom =
+Result.Nodes.getNodeAs("derivedFrom"))





Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h:10
+
+#ifndef LLVM_CLANG_TOOLING_ASTSRCLOCPROCESSOR_H
+#define LLVM_CLANG_TOOLING_ASTSRCLOCPROCESSOR_H

This one as well.



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h:17
+
+#include 
+#include 

I don't think this is being used, but you should include what you use 
(`StringRef`, `unique_ptr`)



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h:29
+public:
+  ASTSrcLocProcessor(StringRef JsonPath);
+

Should this ctor be marked `explicit`?



Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h:31-34
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File);
+
+  void Generate();





Comment at: clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp:43
+
+static cl::opt JsonOutputPath("json-output-path",
+   cl::desc("json output path"),

Hmmm, do we want such a long name for this option? I was guessing that `-o` 
isn't appropriate because there may be mu

[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

2020-12-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds a frontend action for emitting object files. While Flang
does not support code-generation, this action remains a placeholder.
This patch simply provides glue-code to connect the compiler driver
with the appropriate frontend action.

The new action is triggered with the `-c` compiler driver flag, i.e.
`flang-new -c`. This is then translated to `flang-new -fc1 -emit-obj`,
so `-emit-obj` has to be marked as supported as well.

As code-generation is not available yet, `flang-new -c` results in a
driver error:

  error: code-generation is not available yet

Hopefully this will help communicating the level of available
functionality within Flang.

I also commented out `-triple` in Flang::ConstructJob and updated some
comments there. This is similar to https://reviews.llvm.org/D93027. I
wanted to make sure that it's clear that we can't support `-triple`
until we have code-generation. However, once code-generation is
available we _will need_ `-triple`.

As this patch adds `-emit-obj`, the emit-obj.f90 becomes irrelevant and
is deleted. Instead, phases.f90 is added to demonstrate that users can
control compilation phases (indeed, `-c` is a phase control flag).

Depends on: D92854 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93301

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/code-gen.f90
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Flang-Driver/phases.f90

Index: flang/test/Flang-Driver/phases.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/phases.f90
@@ -0,0 +1,20 @@
+! RUN: %flang-new -E -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=PP
+! RUN: %flang-new -fsyntax-only -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=COMPILE
+! RUN: %flang-new -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=EMIT_OBJ
+
+! REQUIRES: new-flang-driver
+
+! This test verifies the phase control in Flang compiler driver.
+
+! PP: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! PP-NEXT: 1: preprocessor, {0}, f95
+
+! COMPILE: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! COMPILE-NEXT: 1: preprocessor, {0}, f95
+! COMPILE-NEXT: 2: compiler, {1}, none
+
+! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95
+! EMIT_OBJ-NEXT: 2: compiler, {1}, ir
+! EMIT_OBJ-NEXT: +- 3: backend, {2}, assembler
+! EMIT_OBJ-NEXT: 4: assembler, {3}, object
Index: flang/test/Flang-Driver/emit-obj.f90
===
--- flang/test/Flang-Driver/emit-obj.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-! RUN: not %flang-new  %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
-
-! REQUIRES: new-flang-driver
-
-! By default (e.g. when no options like `-E` are passed) flang-new
-! creates a job that corresponds to `-emit-obj`. This option/action is
-! not yet supported. Verify that this is correctly reported as error.
-
-! ERROR: error: unknown argument: '-triple'
-! ERROR: error: unknown argument: '-emit-obj'
-
-! ERROR-FC1: error: unknown argument: '-emit-obj'
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -19,6 +19,7 @@
 ! HELP-EMPTY:
 ! HELP-NEXT:OPTIONS:
 ! HELP-NEXT: -###   Print (but do not run) the commands to run for this compilation
+! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -32,6 +33,7 @@
 ! HELP-FC1:USAGE: flang-new
 ! HELP-FC1-EMPTY:
 ! HELP-FC1-NEXT:OPTIONS:
+! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -EOnly run the preprocessor
 ! HELP-FC1-NEXT: -help Display available options
 ! HELP-FC1-NEXT: -o  Write output to 
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f

[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

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

@dang , I would appreciate if you could take a look at the diff in Options.td - 
you introduced the most recent changes there: https://reviews.llvm.org/D82574. 
I got a bit confused with the nested `let` statements there. I couldn't find a 
better way of marking `-emit-obj` as a both `CC1Option` and `FC1Option`, so I 
just extracted it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93301

___
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-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 311915.
jansvoboda11 added a comment.

Fix: avoid template instantiations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84668

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -244,10 +244,12 @@
   return None;
 }
 
+template ::value, bool> = true>
 static void denormalizeSimpleEnum(SmallVectorImpl &Args,
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
-  unsigned TableIndex, unsigned Value) {
+  unsigned TableIndex, T Value) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
   if (auto MaybeEnumVal = findValueTableByValue(Table, Value)) {
@@ -259,6 +261,16 @@
   }
 }
 
+template ::value, bool> = true>
+static void denormalizeSimpleEnum(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator SA,
+  unsigned TableIndex, T Value) {
+  return denormalizeSimpleEnum(Args, Spelling, SA, TableIndex,
+   static_cast(Value));
+}
+
 static void denormalizeSimpleEnumJoined(SmallVectorImpl &Args,
 const char *Spelling,
 CompilerInvocation::StringAllocator SA,
@@ -3724,28 +3736,7 @@
 
 static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
 DiagnosticsEngine &Diags) {
-  Opts.CodeModel = std::string(Args.getLastArgValue(OPT_mcmodel_EQ, "default"));
-  Opts.ABI = std::string(Args.getLastArgValue(OPT_target_abi));
-  if (Arg *A = Args.getLastArg(OPT_meabi)) {
-StringRef Value = A->getValue();
-llvm::EABI EABIVersion = llvm::StringSwitch(Value)
- .Case("default", llvm::EABI::Default)
- .Case("4", llvm::EABI::EABI4)
- .Case("5", llvm::EABI::EABI5)
- .Case("gnu", llvm::EABI::GNU)
- .Default(llvm::EABI::Unknown);
-if (EABIVersion == llvm::EABI::Unknown)
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
-<< Value;
-else
-  Opts.EABIVersion = EABIVersion;
-  }
-  Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
-  Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
-  Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
-  Opts.LinkerVersion =
-  std::string(Args.getLastArgValue(OPT_target_linker_version));
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
   Opts.AllowAMDGPUUnsafeFPAtomics =
   Args.hasFlag(options::OPT_munsafe_fp_atomics,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2603,7 +2603,8 @@
 def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias;
 def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[NoXarchOption]>;
-def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>;
+def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>,
+  MarshallingInfoString<"TargetOpts->CodeModel", [{std::string("default")}]>;
 def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group, Flags<[NoXarchOption, CC1Option]>,
   HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "
"12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">;
@@ -2669,7 +2670,10 @@
 def mthread_model : Separate<["-"], "mthread-model">, Group, Flags<[CC1Option]>,
   HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">;
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
-  HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
+  HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">,
+  MarshallingInfoString<"TargetOpts->EABIVersion", "Default">,
+  NormalizedValuesScope<"llvm::EABI">,
+  NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>, AutoNormalizeEnum;
 
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstri

[clang] 8acb5f2 - [clang][driver][NFC] Use StringRef instead of std::string

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

Author: Nathan James
Date: 2020-12-15T16:19:12Z
New Revision: 8acb5f2723ecaf0f1904a085ad79d0623cec38f6

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

LOG: [clang][driver][NFC] Use StringRef instead of std::string

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5e4eb8c4e6c52..dc9ec1b9c3623 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -779,10 +779,9 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation 
&C,
 /// by Dirs.
 ///
 static bool searchForFile(SmallVectorImpl &FilePath,
-  ArrayRef Dirs,
-  StringRef FileName) {
+  ArrayRef Dirs, StringRef FileName) {
   SmallString<128> WPath;
-  for (const std::string &Dir : Dirs) {
+  for (const StringRef &Dir : Dirs) {
 if (Dir.empty())
   continue;
 WPath.clear();
@@ -807,7 +806,7 @@ bool Driver::readConfigFile(StringRef FileName) {
   // Read options from config file.
   llvm::SmallString<128> CfgFileName(FileName);
   llvm::sys::path::native(CfgFileName);
-  ConfigFile = std::string(CfgFileName.str());
+  ConfigFile = std::string(CfgFileName);
   bool ContainErrors;
   CfgOptions = std::make_unique(
   ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
@@ -864,9 +863,10 @@ bool Driver::loadConfigFile() {
 std::vector ConfigFiles =
 CLOptions->getAllArgValues(options::OPT_config);
 if (ConfigFiles.size() > 1) {
-  if (!std::all_of(
-  ConfigFiles.begin(), ConfigFiles.end(),
-  [ConfigFiles](std::string s) { return s == ConfigFiles[0]; })) {
+  if (!std::all_of(ConfigFiles.begin(), ConfigFiles.end(),
+   [ConfigFiles](const std::string &s) {
+ return s == ConfigFiles[0];
+   })) {
 Diag(diag::err_drv_duplicate_config);
 return true;
   }
@@ -939,10 +939,7 @@ bool Driver::loadConfigFile() {
   }
 
   // Prepare list of directories where config file is searched for.
-  SmallVector CfgFileSearchDirs;
-  CfgFileSearchDirs.push_back(UserConfigDir);
-  CfgFileSearchDirs.push_back(SystemConfigDir);
-  CfgFileSearchDirs.push_back(Dir);
+  StringRef CfgFileSearchDirs[] = {UserConfigDir, SystemConfigDir, Dir};
 
   // Try to find config file. First try file with corrected architecture.
   llvm::SmallString<128> CfgFilePath;
@@ -973,7 +970,7 @@ bool Driver::loadConfigFile() {
   // --config. If it was deduced from executable name, it is not an error.
   if (FileSpecifiedExplicitly) {
 Diag(diag::err_drv_config_file_not_found) << CfgFileName;
-for (const std::string &SearchDir : CfgFileSearchDirs)
+for (const StringRef &SearchDir : CfgFileSearchDirs)
   if (!SearchDir.empty())
 Diag(diag::note_drv_config_file_searched_in) << SearchDir;
 return true;



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


[PATCH] D93031: Enable fexec-charset option

2020-12-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 311911.
abhina.sreeskantharajan added a comment.

Thanks for your quick reviews! I haven't addressed all the comments yet but I 
plan to address all of them. I put up this patch early because it has a few 
major changes:

- moves LiteralTranslator class to Preprocessor instead of being a static 
global class
- add isUTFLiteral() function to detect strings like u8"..." and stop 
translation
- translate wide string literals to the system charset for now (we don't have 
an implementation plan for -fwide-charset right now)
- remove tests that check fexec-charset will not accept non-UTF charsets




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/LiteralTranslator.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/LiteralTranslator.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1023,6 +1023,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static unsigned EatNumber(StringRef &Str) {
   assert(!Str.empty() && Str[0] >= '0' && Str[0] <= '9' && "Not a number");
   unsigned Result = 0;
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -390,6 +390,9 @@
   /// if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -209,9 +209,6 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
-
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
 // RUN: -falign-functions -falign-functions=2 -fno-align-functions\
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -209,10 +209,6 @@
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
 
-// /execution-charset: should warn on everything except UTF-8.
-// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
-// execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
-//
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
Index: clang/test/CodeGen/systemz-charset.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-charset.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fexec-charset IBM-1047 -o - | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -target s390x-ibm-zos -o - | FileCheck %s
+
+char *UpperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+// CHECK: c"\C1\C2\C3\C4\C5\C6\C7\C8\C9\D1\D2\D3\D4\D5\D6\D7\D8\D9\E2\E3\E4\E5\E6\E7\E8\E9\00"
+
+char *LowerCaseLetters = "abcdefghijklmnopqrstuvwxyz";
+//CHECK: c"\81\82\83\84\85\86\87\88\89\91\92\93\94\95\96\97\98\99\A2\A3\A4\A5\A6\A7\A8\A9\00"
+
+char *Digits = "0123456789";
+// CHECK: c"\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\00"
+
+char *SpecialCharac

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

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

Rebase, move options back to their original lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84669

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/c-generate.c

Index: clang/test/Profile/c-generate.c
===
--- clang/test/Profile/c-generate.c
+++ clang/test/Profile/c-generate.c
@@ -7,7 +7,7 @@
 //
 // PROF-INSTR-NONE-NOT: __llvm_prf
 //
-// PROF-INSTR-GARBAGE: invalid PGO instrumentor in argument '-fprofile-instrument=garbage'
+// PROF-INSTR-GARBAGE: invalid value 'garbage' in '-fprofile-instrument=garbage'
 
 int main(void) {
   return 0;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -347,7 +347,8 @@
 }
 
 static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags) {
+DiagnosticsEngine &Diags,
+const InputArgList &Args) {
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
@@ -366,6 +367,11 @@
   T.isWindowsMSVCEnvironment())
 Diags.Report(diag::err_fe_invalid_exception_model)
 << static_cast(LangOpts.getExceptionHandling()) << T.str();
+
+  if (!CodeGenOpts.ProfileRemappingFile.empty() && CodeGenOpts.LegacyPassManager)
+Diags.Report(diag::err_drv_argument_only_allowed_with)
+<< Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
+<< "-fno-legacy-pass-manager";
 }
 
 //===--===//
@@ -808,28 +814,6 @@
   }
 }
 
-// Set the profile kind for fprofile-instrument.
-static void setPGOInstrumentor(CodeGenOptions &Opts, ArgList &Args,
-   DiagnosticsEngine &Diags) {
-  Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ);
-  if (A == nullptr)
-return;
-  StringRef S = A->getValue();
-  unsigned I = llvm::StringSwitch(S)
-   .Case("none", CodeGenOptions::ProfileNone)
-   .Case("clang", CodeGenOptions::ProfileClangInstr)
-   .Case("llvm", CodeGenOptions::ProfileIRInstr)
-   .Case("csllvm", CodeGenOptions::ProfileCSIRInstr)
-   .Default(~0U);
-  if (I == ~0U) {
-Diags.Report(diag::err_drv_invalid_pgo_instrumentor) << A->getAsString(Args)
- << S;
-return;
-  }
-  auto Instrumentor = static_cast(I);
-  Opts.setProfileInstr(Instrumentor);
-}
-
 // Set the profile kind using fprofile-instrument-use-path.
 static void setPGOUseInstrumentor(CodeGenOptions &Opts,
   const Twine &ProfileName) {
@@ -895,57 +879,12 @@
   Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
/* Default */ false);
 
-  if (Arg *A = Args.getLastArg(OPT_fveclib)) {
-StringRef Name = A->getValue();
-if (Name == "Accelerate")
-  Opts.setVecLib(CodeGenOptions::Accelerate);
-else if (Name == "libmvec")
-  Opts.setVecLib(CodeGenOptions::LIBMVEC);
-else if (Name == "MASSV")
-  Opts.setVecLib(CodeGenOptions::MASSV);
-else if (Name == "SVML")
-  Opts.setVecLib(CodeGenOptions::SVML);
-else if (Name == "none")
-  Opts.setVecLib(CodeGenOptions::NoLibrary);
-else
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
-  }
-
-  if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
-unsigned Val =
-llvm::StringSwitch(A->getValue())
-.Case("line-tables-only", codegenoptions::DebugLineTablesOnly)
-.Case("line-directives-only", codegenoptions::DebugDirectivesOnly)
-.Case("constructor", codegenoptions::DebugInfoConstructor)
-.Case("limited", codegenoptions::LimitedDebugInfo)
-.Case("standalone", codegenoptions::FullDebugInfo)
-.Case("unused-types", codegenoptions::UnusedTypeInfo)
-.Default(~0U);
-if (Val == ~0U)
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
-<< A->getValue();
-else
-  Opts.setDebugInfo(static_cast(Val));
-  }
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
   // constructor homing.
   if (Args.getLastArg(OPT_fuse_ctor_homing))
 if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
   Opts.setDebugInfo(c

[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-12-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 311922.
jdoerfert marked 5 inline comments as done.
jdoerfert added a comment.

Addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/assume_attr.c
  clang/test/CodeGenCXX/assume_attr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-assume.c
  llvm/include/llvm/IR/Assumptions.h
  llvm/lib/IR/Assumptions.cpp
  llvm/lib/IR/CMakeLists.txt

Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_llvm_component_library(LLVMCore
   AbstractCallSite.cpp
   AsmWriter.cpp
+  Assumptions.cpp
   Attributes.cpp
   AutoUpgrade.cpp
   BasicBlock.cpp
Index: llvm/lib/IR/Assumptions.cpp
===
--- /dev/null
+++ llvm/lib/IR/Assumptions.cpp
@@ -0,0 +1,36 @@
+//===- Assumptions.cpp -- Collection of helpers for assumptions ---===//
+//
+// 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 "llvm/IR/Assumptions.h"
+#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Function.h"
+
+using namespace llvm;
+
+bool llvm::hasAssumption(Function &F,
+ const KnownAssumptionString &AssumptionStr) {
+  const Attribute &A = F.getFnAttribute(AssumptionAttrKey);
+  if (!A.isValid())
+return false;
+  assert(A.isStringAttribute() && "Expected a string attribute!");
+
+  SmallVector Strings;
+  A.getValueAsString().split(Strings, ",");
+
+  return llvm::any_of(Strings, [=](StringRef Assumption) {
+return Assumption == AssumptionStr;
+  });
+}
+
+StringSet<> llvm::KnownAssumptionStrings({
+"omp_no_openmp",  // OpenMP 5.1
+"omp_no_openmp_routines", // OpenMP 5.1
+"omp_no_parallelism", // OpenMP 5.1
+});
Index: llvm/include/llvm/IR/Assumptions.h
===
--- /dev/null
+++ llvm/include/llvm/IR/Assumptions.h
@@ -0,0 +1,50 @@
+//===--- Assumptions.h - Assumption handling and organization ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// String assumptions that are known to optimization passes should be placed in
+// the KnownAssumptionStrings set. This can be done in various ways, i.a.,
+// via a static KnownAssumptionString object.
+//
+//===--===//
+
+#ifndef LLVM_IR_ASSUMPTIONS_H
+#define LLVM_IR_ASSUMPTIONS_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace llvm {
+
+class Function;
+
+/// The key we use for assumption attributes.
+constexpr StringRef AssumptionAttrKey = "llvm.assume";
+
+/// A set of known assumption strings that are accepted without warning and
+/// which can be recommended as typo correction.
+extern StringSet<> KnownAssumptionStrings;
+
+/// Helper that allows to insert a new assumption string in the known assumption
+/// set by creating a (static) object.
+struct KnownAssumptionString {
+  KnownAssumptionString(StringRef AssumptionStr)
+  : AssumptionStr(AssumptionStr) {
+KnownAssumptionStrings.insert(AssumptionStr);
+  }
+  operator StringRef() const { return AssumptionStr; }
+
+private:
+  StringRef AssumptionStr;
+};
+
+/// Return true if \p F has the assumption \p AssumptionStr attached.
+bool hasAssumption(Function &F, const KnownAssumptionString &AssumptionStr);
+
+} // namespace llvm
+
+#endif
Index: clang/test/Sema/attr-assume.c
===
--- /dev/null
+++ clang/test/Sema/attr-assume.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+void f1() __attribute__((assume(3))); // expected-error {{'assume' attribute requires a string}}
+void f2() __attribute__((assume(int))); // expected-error {{expected expression}}
+void f3() __attribute__((assume(for))); // expected-e

[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-12-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1689
+
+llvm::StringSet<> Sema::KnownAssumptionStrings({
+"omp_no_openmp",  // OpenMP 5.1

aaron.ballman wrote:
> The current approach is reasonable, but I wonder if there's a way we can 
> force this list to be filled out by the backend pass authors such that the 
> frontend can query the backend for the supported list?
We do, kinda. A backend that wants to query an assumption from the 
`llvm.assume` function attribute needs to provide a `KnownAssumptionStr` which 
has a comment people might read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

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


[PATCH] D93031: Enable fexec-charset option

2020-12-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 9 inline comments as done.
abhina.sreeskantharajan added a comment.

In D93031#2447230 , @rsmith wrote:

> I'm overall pretty happy about how clean and non-invasive the changes 
> required here are. But please make sure you don't change the encodings of 
> `u8"..."` / `u"..."` / `U"..."` literals; those need to stay as UTF-8 / 
> UTF-16 / UTF-32. Also, we should have a story for how the wide execution 
> character set is controlled -- is it derived from the narrow execution 
> character set, or can the two be changed independently, or ...?
>
> We should use the original source form of the string literal when 
> pretty-printing a `StringLiteral` or `CharacterLiteral`; there are a bunch of 
> UTF-8 assumptions baked into `StmtPrinter` that will need revisiting. And 
> we'll need to modify the handful of places that put the contents of 
> `StringLiteral`s into diagnostics (`#warning`, `#error`, `static_assert`) and 
> make them use a different `ConversionState`, since our assumption is that 
> diagnostic output should be in UTF-8.

Yes, these are some of the complications we will need to visit in later 
patches. We may need to somehow save the original string or reverse the 
translation.




Comment at: clang/include/clang/Driver/Options.td:3583-3584
 
+def fexec_charset : Separate<["-"], "fexec-charset">, 
MetaVarName<"">,
+  HelpText<"Set the execution  for string and character literals">;
 def target_cpu : Separate<["-"], "target-cpu">,

tahonermann wrote:
> How about substituting "character set", "character encoding", or "charset" 
> for "codepage"?
> 
> This doesn't state what names are recognized.  The ones provided by the 
> system iconv() implementation (as is the case for gcc)?  Or all names and 
> aliases specified by the [[ 
> https://www.iana.org/assignments/character-sets/character-sets.xhtml | IANA 
> character set registry ]]?
> 
> The set of recognized names can be a superset of the names that are actually 
> supported.
I've updated the description from codepage to charset.

It's hard to specify what charsets are supported because iconv library differs 
between targets, so the list will not be the same on every platform.



Comment at: clang/include/clang/Lex/LiteralTranslator.h:32
+  static llvm::StringRef ExecCharset;
+  static llvm::StringMap ExecCharsetTables;
+

rsmith wrote:
> Similarly, use of a global cache here will require you guard it with a mutex.
> 
> As an alternative, how about we move all this state to be per-instance state, 
> and store an instance of `LiteralTranslator` on the `Preprocessor`?
Thanks, I've added an instance of LiteralTranslator to Preprocessor instead and 
use that when the Preprocessor is available. There is one constructor of 
StringLiteralParser that does not pass Preprocessor as an argument, so I had to 
create a LiteralTranslator instance there as well.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5969-5977
+  // Pass all -fexec-charset options to cc1.
+  std::vector vList =
+  Args.getAllArgValues(options::OPT_fexec_charset_EQ);
+  // Set the default fexec-charset as the system charset.
+  CmdArgs.push_back("-fexec-charset");
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
+  for (auto it = vList.begin(), ie = vList.end(); it != ie; ++it) {

tahonermann wrote:
> I think it would be preferable to diagnose an unrecognized character encoding 
> name here if possible.  The current changes will result in an unrecognized 
> name (as opposed to one that is unsupported for the target) being diagnosed 
> for each compiler instance.
Since we do not know what charsets are supported by the iconv library on the 
target platform, we don't know what charsets are actually invalid until we try 
creating a CharSetConverter.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3573
+StringRef Value = ExecCharset->getValue();
+Opts.ExecCharset = (std::string)Value;
+  }

tahonermann wrote:
> I wouldn't expect the cast to `std::string` to be needed here.
Without that cast, I get the following build error:
```
 error: no viable overloaded '='
```



Comment at: clang/test/Driver/cl-options.c:214
+// RUN: %clang_cl /execution-charset:iso8859-1 -### -- %s 2>&1 | FileCheck 
-check-prefix=execution-charset-iso8859-1 %s
+// execution-charset-iso8859-1-NOT: invalid value 'iso8859-1' in 
'/execution-charset:iso8859-1'
+

rsmith wrote:
> Checking for "don't produce exactly this one spelling of this one diagnostic" 
> is not a useful test; if we started warning on this again, there's a good 
> chance the warning would be spelled differently, so your test does not do a 
> good job of determining whether the code under test is bad (it passes in most 
> bad states as well as in the good state). `...-NOT: error` and 

[PATCH] D93008: [clang][cli] Do not marshall only CC1Option flags in BoolOption

2020-12-15 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/D93008/new/

https://reviews.llvm.org/D93008

___
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-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/lib/Frontend/FrontendActions.cpp:87
+  defaultKinds, features, ci.allCookedSources()};
+  semanticsContext.set_moduleDirectory("."s);
+  Fortran::semantics::Semantics semantics{

CarolineConcatto wrote:
> Just a quick question:
> Why you cannot use this function:
> CompilerInvocation::SetDefaultFortranOpts
> instead of using  semanticsContext.set_moduleDirectory("."s);
> ?
Hard-coded values are bad, thanks for pointing that out!

We can't use `CompilerInvocation::SetDefaultFortranOpts` here, as that's for 
`Fortran::parser::Options`, and here we are dealing with the internal state of 
`Fortran::semantics::SemanticsContext`. 

However, `moduleDirectory_` is in fact initialised to `"."s` by default: 
https://github.com/llvm/llvm-project/blob/8acb5f2723ecaf0f1904a085ad79d0623cec38f6/flang/include/flang/Semantics/semantics.h#L185.
 

So, it's safe to delete this line for now. A proper solution/approach will be 
implemented once we add support for `-module-dir`: 
https://docs.google.com/spreadsheets/d/1JRe39lP_KhtkYxFEIvwrCFlE5v1Ofa_krOHI-XXXWPY/edit#gid=0.


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] D93247: [Sema] Fix a miscompile by retaining array qualifiers when folding VLAs to constant arrays

2020-12-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks!


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

https://reviews.llvm.org/D93247

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


[PATCH] D93094: [clang][cli] Prevent double denormalization

2020-12-15 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 test fix.




Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:267
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdebug-pass-manager")));
+  ASSERT_EQ(count(GeneratedArgs, "-fdebug-pass-manager"), 1);
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";

jansvoboda11 wrote:
> dexonsmith wrote:
> > jansvoboda11 wrote:
> > > Is it wise to rely on pointer comparison here? The call to `count` 
> > > returns 2 before changing the denormalizer and 1 after, but I'm not sure 
> > > if it will work on all platforms.
> > Does this compile / avoid the pointer comparison?
> > ```
> > ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1);
> > ```
> Yes, this forces the `const char *` from GeneratedArgs to be converted into 
> `StringRef`, which does comparison via `::memcmp`.
> 
> If we decide comparing `StringRef`s is a better solution, I'd be inclined to 
> create a helper function or custom matcher that does the conversion to 
> `StringRef`. That way, we don't have to worry about doing the right thing in 
> test cases.
I believe that if you have shared libraries enabled this is guaranteed to be 
different. We should do a string comparison here, and I think a helper makes 
sense if we expect to do this more often.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93094

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


[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

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

LGTM (found one very minor late nit in a cmake file though). Thank you for the 
discussion on this!




Comment at: clang/lib/Sema/CMakeLists.txt:3
   FrontendOpenMP
+  Core
   Support

Might as well keep this list alphabetized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

___
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-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 311925.
awarzynski added a comment.

Address comment from @CarolineConcatto + rebase


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(&compInst);
+
+  // 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
@@ -11,6 +11,7 @@
 #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 +69,33 @@
 return;
   }
 }
+
+void ParseSyntaxOnlyAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  // TODO: These should be specifiable by users. For now just use the defaults.
+  common::LanguageFeatureControl features;
+  Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
+
+  // Parse
+  ci.parsing().Parse(llvm::outs());
+  auto &parseTree{*ci.parsing().parseTree()};
+
+  // Prepare semantics
+  Fortran::semant

[PATCH] D92874: [clangd] Validate clang-tidy Checks in clangd config.

2020-12-15 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:26
 
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "CompileCommands.h"

sammccall wrote:
> This is a pretty weird place to depend on clang-tidy.
> Can we move the "is this a clang-tidy check name" function to somewhere more 
> clang-tidy related, like `TidyProvider.h` or even 
> `clang-tidy/ClangTidyModuleRegistry.h`? ("isRegisteredCheck")
Moving to `ClangTidyModuleRegistry.h` will still require this include.
Moving the function to `TidyProvider.h` may have a case, but as TidyProvider 
doesn't use the function I'm not sure it belongs in there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92874

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


[PATCH] D92874: [clangd] Validate clang-tidy Checks in clangd config.

2020-12-15 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 311926.
njames93 added a comment.

Address some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92874

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -200,6 +200,24 @@
   EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("StrictMode"), "true");
   EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("example-check.ExampleOption"),
 "0");
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+}
+
+TEST_F(ConfigCompileTests, TidyBadChecks) {
+  Frag.ClangTidy.Add.emplace_back("unknown-check");
+  Frag.ClangTidy.Remove.emplace_back("*");
+  Frag.ClangTidy.Remove.emplace_back("llvm-includeorder");
+  EXPECT_TRUE(compileAndApply());
+  // Ensure bad checks are stripped from the glob.
+  EXPECT_EQ(Conf.ClangTidy.Checks, "-*");
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(
+  AllOf(DiagMessage("clang-tidy check 'unknown-check' was not found"),
+DiagKind(llvm::SourceMgr::DK_Warning)),
+  AllOf(
+  DiagMessage("clang-tidy check 'llvm-includeorder' was not found"),
+  DiagKind(llvm::SourceMgr::DK_Warning;
 }
 
 TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -23,6 +23,7 @@
 //
 //===--===//
 
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "CompileCommands.h"
 #include "Config.h"
 #include "ConfigFragment.h"
@@ -35,7 +36,9 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
@@ -47,7 +50,31 @@
 #include 
 
 namespace clang {
+namespace tidy {
+/// Returns if a clang tidy \p Check has been registered.
+static bool isRegisteredCheck(StringRef Check) {
+  assert(!Check.empty());
+  assert(!Check.contains('*') && "isRegisteredCheck doesn't support globs");
+  assert(Check.trim().size() == Check.size() &&
+ "Check has trailing or leading whitespace");
+  assert(Check.front() != '-');
+
+  static const llvm::StringSet AllChecks = [] {
+llvm::StringSet Result;
+ClangTidyCheckFactories Factories;
+for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries())
+  E.instantiate()->addCheckFactories(Factories);
+for (const auto &Factory : Factories)
+  Result.insert(Factory.getKey());
+return Result;
+  }();
+
+  return AllChecks.contains(Check);
+}
+
+} // namespace tidy
 namespace clangd {
+
 namespace config {
 namespace {
 
@@ -349,13 +376,19 @@
 
   void appendTidyCheckSpec(std::string &CurSpec,
const Located &Arg, bool IsPositive) {
-StringRef Str = *Arg;
+StringRef Str = StringRef(*Arg).trim();
 // Don't support negating here, its handled if the item is in the Add or
 // Remove list.
 if (Str.startswith("-") || Str.contains(',')) {
   diag(Error, "Invalid clang-tidy check name", Arg.Range);
   return;
 }
+if (!Str.contains('*') && !tidy::isRegisteredCheck(Str)) {
+  diag(Warning,
+   llvm::formatv("clang-tidy check '{0}' was not found", Str).str(),
+   Arg.Range);
+  return;
+}
 CurSpec += ',';
 if (!IsPositive)
   CurSpec += '-';
___
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-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D93079#2451782 , @JonChesterfield 
wrote:

> Is this for cases where we are compiling a subset of the target code, i.e. 
> without link time optimisation?

Upstream cannot to LTO on any target code as of now :(

> It's interesting that we might want a static function on the gpu and an 
> external one on the cpu. The user could presumably make it static and provide 
> a different, host-only function which calls it as a workaround.

If they have control. Code in a header for example might not be changeable. 
Though I will add it to the remark description for sure.

> I'm nervous about this one because it looks like a property the compiler 
> should already be able to derive (given LTO, anyway), and I don't see how we 
> can diagnose when the user annotation is inaccurate, e.g. because of changes 
> elsewhere in the codebase after it was added.

This is always an issue with assumes/assertions/annotations/... Unsure what to 
say. I'd be fine with retiring this one as soon as we can do LTO upstream, and 
I am all in favor of making that the only/default mode then too.


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


  1   2   3   >