[clang-tools-extra] 72439b6 - [clangd] Add a flag to turn on recovery-expr.

2020-04-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-04-01T09:03:56+02:00
New Revision: 72439b6b9557d5c58ec7f95a14722ef581906a17

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

LOG: [clangd] Add a flag to turn on recovery-expr.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 36af6c98d18b..0882784f7031 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -134,7 +134,8 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
  : nullptr),
   GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
-  TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot),
+  BuildRecoveryAST(Opts.BuildRecoveryAST), TweakFilter(Opts.TweakFilter),
+  WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
@@ -191,6 +192,7 @@ void ClangdServer::addDocument(PathRef File, 
llvm::StringRef Contents,
   Inputs.ForceRebuild = ForceRebuild;
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
+  Inputs.Opts.BuildRecoveryAST = BuildRecoveryAST;
   bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);
   // If we loaded Foo.h, we want to make sure Foo.cpp is indexed.
   if (NewFile && BackgroundIdx)

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index a0659c7c3d22..f1e981e6c14f 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -118,6 +118,9 @@ class ClangdServer {
 /// enabled.
 ClangTidyOptionsBuilder GetClangTidyOptions;
 
+/// If true, turn on the `-frecovery-ast` clang flag.
+bool BuildRecoveryAST = false;
+
 /// Clangd's workspace root. Relevant for "workspace" operations not bound
 /// to a particular file.
 /// FIXME: If not set, should use the current working directory.
@@ -345,6 +348,9 @@ class ClangdServer {
   // can be caused by missing includes (e.g. member access in incomplete type).
   bool SuggestMissingIncludes = false;
 
+  // If true, preserve expressions in AST for broken code.
+  bool BuildRecoveryAST = false;
+
   std::function TweakFilter;
 
   // GUARDED_BY(CachedCompletionFuzzyFindRequestMutex)

diff  --git a/clang-tools-extra/clangd/Compiler.h 
b/clang-tools-extra/clangd/Compiler.h
index ef5386bb0d17..b7cc174455f3 100644
--- a/clang-tools-extra/clangd/Compiler.h
+++ b/clang-tools-extra/clangd/Compiler.h
@@ -38,6 +38,7 @@ class IgnoreDiagnostics : public DiagnosticConsumer {
 struct ParseOptions {
   tidy::ClangTidyOptions ClangTidyOpts;
   bool SuggestMissingIncludes = false;
+  bool BuildRecoveryAST = false;
 };
 
 /// Information required to run clang, e.g. to parse AST or do code completion.

diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index 1d6997f0b4d4..2c7cb5d2b85d 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -253,6 +253,10 @@ ParsedAST::build(llvm::StringRef Version,
   const PrecompiledPreamble *PreamblePCH =
   Preamble ? &Preamble->Preamble : nullptr;
 
+  // Recovery expression currently only works for C++.
+  if (CI->getLangOpts()->CPlusPlus)
+CI->getLangOpts()->RecoveryAST = Opts.BuildRecoveryAST;
+
   StoreDiags ASTDiags;
   std::string Content = std::string(Buffer->getBuffer());
   std::string Filename =

diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index fdee71fd2244..48f15420032f 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -132,6 +132,10 @@ buildPreamble(PathRef FileName, CompilerInvocation &CI,
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  // Recovery expression currently only works for C++.
+  if (CI.getLangOpts()->CPlusPlus)
+CI.getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
+

[PATCH] D77066: [analyzer] ApiModeling: Add buffer size arg constraint

2020-04-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D77066#1953280 , @Charusso wrote:

>   getDynamicSizeWithOffset(State, MR, SVB) {
> Offset = State->getStoreManager().getStaticOffset(MR, SVB);
> ...
>   }
>


Hm, the MemRegion's offset should be great. I was thinking about if we would 
store SVal offsets in the Store.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77066



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


[PATCH] D77142: [clangd] Add a flag to turn on recovery-expr.

2020-04-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 254097.
hokein added a comment.

mention C++ only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77142

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -56,6 +56,7 @@
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS(Files);
   Inputs.Opts = ParseOptions();
+  Inputs.Opts.BuildRecoveryAST = true;
   Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
   Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
   Inputs.Index = ExternalIndex;
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -132,6 +132,16 @@
   EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
+TEST_F(TargetDeclTest, Recovery) {
+  Code = R"cpp(
+// error-ok: testing behavior on broken code
+int f();
+int f(int, int);
+int x = [[f]](42);
+  )cpp";
+  EXPECT_DECLS("UnresolvedLookupExpr", "int f()", "int f(int, int)");
+}
+
 TEST_F(TargetDeclTest, UsingDecl) {
   Code = R"cpp(
 namespace foo {
@@ -685,6 +695,15 @@
 )cpp",
 "0: targets = {x}\n"
 "1: targets = {X::a}\n"},
+   {R"cpp(
+// error-ok: testing with broken code
+int bar();
+int foo() {
+  return $0^bar() + $1^bar(42);
+}
+)cpp",
+"0: targets = {bar}\n"
+"1: targets = {bar}\n"},
// Namespaces and aliases.
{R"cpp(
   namespace ns {}
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,6 +281,15 @@
 Hidden,
 };
 
+opt RecoveryAST{
+"recovery-ast",
+cat(Features),
+desc("Preserve expressions in AST for broken code (C++ only). Note that "
+ "this feature is experimental and may lead to crashes"),
+init(false),
+Hidden,
+};
+
 opt WorkerThreadsCount{
 "j",
 cat(Misc),
@@ -629,6 +638,7 @@
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
+  Opts.BuildRecoveryAST = RecoveryAST;
 
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -132,6 +132,10 @@
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  // Recovery expression currently only works for C++.
+  if (CI.getLangOpts()->CPlusPlus)
+CI.getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
+
   CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
   if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
 log("Couldn't set working directory when building the preamble.");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -253,6 +253,10 @@
   const PrecompiledPreamble *PreamblePCH =
   Preamble ? &Preamble->Preamble : nullptr;
 
+  // Recovery expression currently only works for C++.
+  if (CI->getLangOpts()->CPlusPlus)
+CI->getLangOpts()->RecoveryAST = Opts.BuildRecoveryAST;
+
   StoreDiags ASTDiags;
   std::string Content = std::string(Buffer->getBuffer());
   std::string Filename =
Index: clang-tools-extra/clangd/Compiler.h
===
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -38,6 +38,7 @@
 struct ParseOptions {
   tidy::ClangTidyOptions ClangTidyOpts;
   bool SuggestMissingIncludes = false;
+  bool BuildRecoveryAST = false;
 };
 
 /// Information required to run clang, e.g. to parse AST or do code completion.
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -118,6 +118,9

[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-04-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1828
+  if (CodeGenOpts.BranchTargetEnforcement) {
+FuncAttrs.addAttribute("branch-target-enforcement", "true");
+  }

danielkiss wrote:
> chill wrote:
> > I would really prefer to not set values "true" or "false" for the 
> > attribute: we don't really have tri-state logic there 
> > (absent/present-true/present-false), and those values just add some 
> > not-very useful string processing.
> > 
> the attribute will be  "absent" for the runtime emitted function.
How about setting the attribute for LLVM created functions at the time of 
creation, just like Clang created functions
get their attribute at the time of creation?




Comment at: clang/lib/CodeGen/CGCall.cpp:1831
+
+  auto RASignKind = CodeGenOpts.getSignReturnAddress();
+  if (RASignKind != CodeGenOptions::SignReturnAddressScope::None) {

danielkiss wrote:
> chill wrote:
> > What do we get from setting the PACBTI state in the  default function 
> > attributes? We still have 
> > to do a per function processing, we can just as well avoid repeating the 
> > logic, and spare us some
> > adding and potentially removing attributes churn.
> > 
> in the new patch the per function processing will change the attribute only 
> if really need.
Sure, but that's duplication of code/logic, it's a source of countless issues 
"oh, here's the place I should fix that thing ... oh noes,  turns out I have to 
fix ten more ... hope I've found all ..." ;)




Comment at: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp:200
+if (!F.hasFnAttribute("branch-target-enforcement"))
+  return false;
+Attribute A = F.getFnAttribute("branch-target-enforcement");

chill wrote:
> chill wrote:
> > This should be "true", although the comment might turn out moot.
> > 
> > If we somehow end up with a function, that does not have that attribute, we 
> > should clear the
> > ELF flag.
> > 
> Oh, I see, those are the cases of sanitizer functions, created at LLVM level, 
> that don't have the attribute.
> Please, leave a comment in that sense.
Or, as mentioned in the other comment, check if it's possible to set the 
attribute at the time of creation (from module attributes?).  Tri-state logic 
is added complexity, if it's necessary, it's necessary, but if it's not, better 
make it simpler.


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

https://reviews.llvm.org/D75181



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


[PATCH] D77142: [clangd] Add a flag to turn on recovery-expr.

2020-04-01 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72439b6b9557: [clangd] Add a flag to turn on recovery-expr. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77142

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -56,6 +56,7 @@
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS(Files);
   Inputs.Opts = ParseOptions();
+  Inputs.Opts.BuildRecoveryAST = true;
   Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
   Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
   Inputs.Index = ExternalIndex;
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -132,6 +132,16 @@
   EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
+TEST_F(TargetDeclTest, Recovery) {
+  Code = R"cpp(
+// error-ok: testing behavior on broken code
+int f();
+int f(int, int);
+int x = [[f]](42);
+  )cpp";
+  EXPECT_DECLS("UnresolvedLookupExpr", "int f()", "int f(int, int)");
+}
+
 TEST_F(TargetDeclTest, UsingDecl) {
   Code = R"cpp(
 namespace foo {
@@ -685,6 +695,15 @@
 )cpp",
 "0: targets = {x}\n"
 "1: targets = {X::a}\n"},
+   {R"cpp(
+// error-ok: testing with broken code
+int bar();
+int foo() {
+  return $0^bar() + $1^bar(42);
+}
+)cpp",
+"0: targets = {bar}\n"
+"1: targets = {bar}\n"},
// Namespaces and aliases.
{R"cpp(
   namespace ns {}
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,6 +281,15 @@
 Hidden,
 };
 
+opt RecoveryAST{
+"recovery-ast",
+cat(Features),
+desc("Preserve expressions in AST for broken code (C++ only). Note that "
+ "this feature is experimental and may lead to crashes"),
+init(false),
+Hidden,
+};
+
 opt WorkerThreadsCount{
 "j",
 cat(Misc),
@@ -629,6 +638,7 @@
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
+  Opts.BuildRecoveryAST = RecoveryAST;
 
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -132,6 +132,10 @@
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  // Recovery expression currently only works for C++.
+  if (CI.getLangOpts()->CPlusPlus)
+CI.getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
+
   CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
   if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
 log("Couldn't set working directory when building the preamble.");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -253,6 +253,10 @@
   const PrecompiledPreamble *PreamblePCH =
   Preamble ? &Preamble->Preamble : nullptr;
 
+  // Recovery expression currently only works for C++.
+  if (CI->getLangOpts()->CPlusPlus)
+CI->getLangOpts()->RecoveryAST = Opts.BuildRecoveryAST;
+
   StoreDiags ASTDiags;
   std::string Content = std::string(Buffer->getBuffer());
   std::string Filename =
Index: clang-tools-extra/clangd/Compiler.h
===
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -38,6 +38,7 @@
 struct ParseOptions {
   tidy::ClangTidyOptions ClangTidyOpts;
   bool SuggestMissingIncludes = false;
+  bool BuildRecoveryAST = false;
 };
 
 /// Information required to run clang, e.g. to parse AST or do code completion.
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-e

[clang] 57fd86d - [AVR] Fix function pointer address space

2020-04-01 Thread Dylan McKay via cfe-commits

Author: Vlastimil Labsky
Date: 2020-04-01T21:08:37+13:00
New Revision: 57fd86de879cf2b4c7001b6d0a09df60877ce24d

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

LOG: [AVR] Fix function pointer address space

Summary:
Function pointers should be created with program address space.
This fixes function pointers on AVR.

Reviewers: dylanmckay

Reviewed By: dylanmckay

Subscribers: Jim, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTypes.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index befd80de96f0..29adc2c7adb3 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -595,7 +595,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
 if (PointeeType->isVoidTy())
   PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
-unsigned AS = Context.getTargetAddressSpace(ETy);
+
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);
+
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }



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


[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the serialized AST

2020-04-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oh wow! thanks for looking into this.

Looking at the history,  it seems like an oversight. The patch that introduced 
packexpansion bit: 
https://github.com/llvm/llvm-project/commit/44c247f0f009eec70a193335c8a353d6f8602bfd.

it didn't add that field to pchattr serialization code unfortunately. (another 
example on isimplicit, which adds attr to record 
https://github.com/llvm/llvm-project/commit/36a5350e51a6dcfae424332aaa266a1e5bfb8c4f)

Could you add tests though ? Something similar to clang/test/PCH/attrs-PR8406.c 
should be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77194



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


[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the serialized AST

2020-04-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

also please update the commit message to mention "PCH" rather than "serialized 
ast".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77194



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


[PATCH] D70411: [analyzer] CERT: STR31-C

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



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp:55
+  // they can cause a not null-terminated string. In this case we store the
+  // string is being not null-terminated in the 'NullTerminationMap'.
+  //

The functions `gets`, `strcpy` return a null-terminated string according to 
standard, probably `sprintf` too, and the `fscanf` `%s` output is 
null-terminated too even if no length is specified (maybe it writes outside of 
the specified buffer but null terminated).



Comment at: clang/test/Analysis/cert/str31-c.cpp:117
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);

Do we get a warning if the `+1` above is missing?


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

https://reviews.llvm.org/D70411



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


[PATCH] D77119: [AVR] Fix function pointer address space

2020-04-01 Thread Dylan McKay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57fd86de879c: [AVR] Fix function pointer address space 
(authored by vlastik, committed by dylanmckay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77119

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp


Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -595,7 +595,11 @@
 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
 if (PointeeType->isVoidTy())
   PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
-unsigned AS = Context.getTargetAddressSpace(ETy);
+
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);
+
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }


Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -595,7 +595,11 @@
 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
 if (PointeeType->isVoidTy())
   PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
-unsigned AS = Context.getTargetAddressSpace(ETy);
+
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);
+
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77131: [clang] Move branch-protection from CodeGenOptions to LangOptions

2020-04-01 Thread Tamas Petz via Phabricator via cfe-commits
tamas.petz added a comment.

Tests pass, however, I am not sure ParseLangArgs is called in all the necessary 
cases (see the occurrences in the code).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77131



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


[PATCH] D77199: [clang-tidy] Address false positive in modernize-use-default-member-init

2020-04-01 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Fixes incorrect warning emitted by "modernize-use-default-member-init" (new to 
10.0.0) .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77199

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,9 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer 
for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl(;
+declRefExpr(to(enumConstantDecl(;
+
+  auto Init =
+  anyOf(initListExpr(anyOf(
+allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
+initCountIs(0))),
+InitBase);
 
   Finder->addMatcher(
   cxxConstructorDecl(


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,9 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl(;
+declRefExpr(to(enumConstantDecl(;
+
+  auto Init =
+  anyOf(initListExpr(anyOf(
+allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
+initCountIs(0))),
+InitBase);
 
   Finder->addMatcher(
   cxxConstructorDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-04-01 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@baloghadamsoftware @Szelethus it would be great to have the name of the 
checkers in the error message
The error is "error: checker cannot be enabled with analyzer option 
'aggressive-binary-operation-simplification' == false"
and I had to look at this patch to understand that it is about iterator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


[PATCH] D77193: [X86] Add SERIALIZE instruction.

2020-04-01 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 254114.

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

https://reviews.llvm.org/D77193

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/serializeintrin.h
  clang/test/CodeGen/x86-serialize-intrin.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/serialize-intrinsic.ll
  llvm/test/MC/Disassembler/X86/x86-16.txt
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-16.s
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -1877,3 +1877,7 @@
 // CHECK: enqcmds 485498096, %rax
 // CHECK: encoding: [0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c]
 enqcmds 485498096, %rax
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10876,3 +10876,7 @@
 // CHECK: enqcmds 8128(%bx,%di), %ax
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
 enqcmds 8128(%bx,%di), %ax
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/X86/x86-16.s
===
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -1029,3 +1029,7 @@
 // CHECK: enqcmds (%edi), %edi
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x3f]
 enqcmds (%edi), %edi
+
+// CHECK: serialize
+// CHECK: encoding: [0x0f,0x01,0xe8]
+serialize
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -691,3 +691,6 @@
 
 # CHECK: enqcmds 485498096, %rax
 0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -943,3 +943,6 @@
 
 # CHECK: enqcmds 8128(%bx,%di), %ax
 0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/MC/Disassembler/X86/x86-16.txt
===
--- llvm/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/test/MC/Disassembler/X86/x86-16.txt
@@ -836,3 +836,6 @@
 
 # CHECK: enqcmds (%edi), %edi
 0x67,0xf3,0x0f,0x38,0xf8,0x3f
+
+# CHECK: serialize
+0x0f 0x01 0xe8
Index: llvm/test/CodeGen/X86/serialize-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/serialize-intrinsic.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86_64
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+serialize | FileCheck %s --check-prefix=X32
+
+define void @test_serialize() {
+; X86_64-LABEL: test_serialize:
+; X86_64:   # %bb.0: # %entry
+; X86_64-NEXT:serialize
+; X86_64-NEXT:retq
+;
+; X86-LABEL: test_serialize:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:serialize
+; X86-NEXT:retl
+;
+; X32-LABEL: test_serialize:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:serialize
+; X32-NEXT:retq
+entry:
+  call void @llvm.x86.serialize()
+  ret void
+}
+
+declare void @llvm.x86.serialize()
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -397,6 +397,9 @@
   /// Processor supports PCONFIG instruction
   bool HasPCONFIG = false;
 
+  /// Processor supports SERIALIZE instruction
+  bool HasSERIALIZE = false;
+
   /// Processor has a single uop BEXTR implementation.
   bool HasFastBEXTR = false;
 
@@ -706,6 +709,7 @@
   bool threewayBranchProfitable() const { return ThreewayBranchProfitable; }
   bool hasINVPCID() const { return HasINVPCID; }
   bool hasENQCMD() const { return HasENQCMD; }
+  bool hasSERIALIZE() const { return HasSERIALIZE; }

[clang] 08a53db - [clang] Minor cleanup in CloneDetectionTest

2020-04-01 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-04-01T10:48:50+02:00
New Revision: 08a53dba93389a9859c12e948d8281a839cffbdb

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

LOG: [clang] Minor cleanup in CloneDetectionTest

Follow up to e8f13f4f62f.

Added: 


Modified: 
clang/unittests/Analysis/CloneDetectionTest.cpp

Removed: 




diff  --git a/clang/unittests/Analysis/CloneDetectionTest.cpp 
b/clang/unittests/Analysis/CloneDetectionTest.cpp
index e09d0733f044..f8f3602f5a2a 100644
--- a/clang/unittests/Analysis/CloneDetectionTest.cpp
+++ b/clang/unittests/Analysis/CloneDetectionTest.cpp
@@ -42,7 +42,7 @@ class NoBarFunctionConstraint {
   for (const StmtSequence &Arg : {A, B}) {
 if (const auto *D =
 dyn_cast(Arg.getContainingDecl())) {
-  if (StringRef(D->getNameAsString()).startswith("bar"))
+  if (D->getName().startswith("bar"))
 return false;
 }
   }



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


[clang-tools-extra] 038f03c - [clangd] Force delayed-template-parsing off in code completion.

2020-04-01 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-01T11:09:15+02:00
New Revision: 038f03cb5ef5d44676cbde06560ed2668f4a7acc

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

LOG: [clangd] Force delayed-template-parsing off in code completion.

Summary:
It prevents code completion entirely in affected method bodies.
The main reason it's turned on is for compatibility with headers, so we turn it
off for the main file only. This is allowed because it's a compatible langopt.

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

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 344b90ecaa32..86ea5f26d397 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1072,6 +1072,10 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   FrontendOpts.SkipFunctionBodies = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
+  // Code completion won't trigger in delayed template bodies.
+  // This is on-by-default in windows to allow parsing SDK headers; we're only
+  // disabling it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
   // Setup code completion.
   FrontendOpts.CodeCompleteOpts = Options;
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 06dccfa93956..3cb18f6893e9 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -127,7 +127,6 @@ CodeCompleteResult completions(llvm::StringRef Text,
   Annotations Test(Text);
   auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
   TU.Filename = FilePath.str();
   return completions(TU, Test.point(), std::move(IndexSymbols),
  std::move(Opts));
@@ -2660,6 +2659,20 @@ TEST(CompletionTest, NoCrashWithIncompleteLambda) {
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, DelayedTemplateParsing) {
+  Annotations Test(R"cpp(
+int xxx;
+template  int foo() { return xx^; }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  // Even though delayed-template-parsing is on, we will disable it to provide
+  // completion in templates.
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+
+  EXPECT_THAT(completions(TU, Test.point()).Completions,
+  Contains(Named("xxx")));
+}
+
 TEST(CompletionTest, CompletionRange) {
   const char *WithRange = "auto x = [[abc]]^";
   auto Completions = completions(WithRange);



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


[PATCH] D77131: [clang] Move branch-protection from CodeGenOptions to LangOptions

2020-04-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a reviewer: efriedma.
chill added a subscriber: efriedma.
chill added a comment.

Following @efriedma  comment here 
http://lists.llvm.org/pipermail/cfe-dev/2020-March/065017.html LGTM.




Comment at: clang/include/clang/Basic/TargetInfo.h:18
 #include "clang/Basic/AddressSpaces.h"
-#include "clang/Basic/LLVM.h"
 #include "clang/Basic/CodeGenOptions.h"
+#include "clang/Basic/LLVM.h"

This include is probably not needed anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77131



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


[PATCH] D77176: [clangd] Force delayed-template-parsing off in code completion.

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

thanks, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77176



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


[PATCH] D77176: [clangd] Force delayed-template-parsing off in code completion.

2020-04-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG038f03cb5ef5: [clangd] Force delayed-template-parsing off in 
code completion. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77176

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


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -127,7 +127,6 @@
   Annotations Test(Text);
   auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
   TU.Filename = FilePath.str();
   return completions(TU, Test.point(), std::move(IndexSymbols),
  std::move(Opts));
@@ -2660,6 +2659,20 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, DelayedTemplateParsing) {
+  Annotations Test(R"cpp(
+int xxx;
+template  int foo() { return xx^; }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  // Even though delayed-template-parsing is on, we will disable it to provide
+  // completion in templates.
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+
+  EXPECT_THAT(completions(TU, Test.point()).Completions,
+  Contains(Named("xxx")));
+}
+
 TEST(CompletionTest, CompletionRange) {
   const char *WithRange = "auto x = [[abc]]^";
   auto Completions = completions(WithRange);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1072,6 +1072,10 @@
   FrontendOpts.SkipFunctionBodies = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
+  // Code completion won't trigger in delayed template bodies.
+  // This is on-by-default in windows to allow parsing SDK headers; we're only
+  // disabling it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
   // Setup code completion.
   FrontendOpts.CodeCompleteOpts = Options;
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -127,7 +127,6 @@
   Annotations Test(Text);
   auto TU = TestTU::withCode(Test.code());
   // To make sure our tests for completiopns inside templates work on Windows.
-  TU.ExtraArgs = {"-fno-delayed-template-parsing"};
   TU.Filename = FilePath.str();
   return completions(TU, Test.point(), std::move(IndexSymbols),
  std::move(Opts));
@@ -2660,6 +2659,20 @@
   EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
 }
 
+TEST(CompletionTest, DelayedTemplateParsing) {
+  Annotations Test(R"cpp(
+int xxx;
+template  int foo() { return xx^; }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  // Even though delayed-template-parsing is on, we will disable it to provide
+  // completion in templates.
+  TU.ExtraArgs.push_back("-fdelayed-template-parsing");
+
+  EXPECT_THAT(completions(TU, Test.point()).Completions,
+  Contains(Named("xxx")));
+}
+
 TEST(CompletionTest, CompletionRange) {
   const char *WithRange = "auto x = [[abc]]^";
   auto Completions = completions(WithRange);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1072,6 +1072,10 @@
   FrontendOpts.SkipFunctionBodies = true;
   // Disable typo correction in Sema.
   CI->getLangOpts()->SpellChecking = false;
+  // Code completion won't trigger in delayed template bodies.
+  // This is on-by-default in windows to allow parsing SDK headers; we're only
+  // disabling it for the main-file (not preamble).
+  CI->getLangOpts()->DelayedTemplateParsing = false;
   // Setup code completion.
   FrontendOpts.CodeCompleteOpts = Options;
   FrontendOpts.CodeCompletionAt.FileName = std::string(Input.FileName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-04-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1688
 CheckConstexprKind Kind) {
+  assert(!NewFD->isInvalidDecl());
   const CXXMethodDecl *MD = dyn_cast(NewFD);

rsmith wrote:
> Instead of asserting this, please just return false on an invalid 
> declaration. There's nothing fundamentally wrong with calling this function 
> on an invalid declaration, but as usual, if we encounter something invalid, 
> we should suppress follow-on diagnostics.
oh, thanks. This function is only called in two places, and both of them check 
the NewFD->isValid before calling it, so my understanding is that this function 
is required a valid NewFD.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5005
+if (Member->getInit() && Member->getInit()->containsErrors())
+  Constructor->setInvalidDecl();
 if (Member->isBaseInitializer())

rsmith wrote:
> rsmith wrote:
> > This is inappropriate. The "invalid" bit on a declaration indicates whether 
> > the declaration is invalid, not whether the definition is invalid.
> > 
> > What we should do is add a "contains errors" bit to `Stmt`, and mark the 
> > function body as containing errors if it has an initializer that contains 
> > an error.
> As an example of why this distinction matters: the "contains errors" bit 
> indicates whether external users of the declaration should ignore it / 
> suppress errors on it, or whether they can still treat it as a regular 
> declaration. It's not ideal for an error in the body of a function to affect 
> the diagnostic behavior of a caller to that function, since the body is 
> (typically) irrelevant to the validity of that caller.
Thanks for the suggestions and clarifications!  The "invalid" bit of decl is 
subtle, I didn't infer it from the code before, thanks for the explanation.

Setting the decl invalid seemed much safer to us, and would avoid running a lot 
of unexpected code paths in clang which might violate the assumptions. 

> What we should do is add a "contains errors" bit to Stmt, and mark the 
> function body as containing errors if it has an initializer that contains an 
> error.

This sounds promising, but there are no free bit in Stmt at the moment :( (to 
add the ErrorBit to expr, we have sacrificed the `IsOMPStructuredBlock` bit, it 
would be easier after the ongoing FPOptions stuff finished, which will free 
certain bits).

since this crash is blocking recovery-expr stuff, it is prioritized for us to 
fix it. Maybe a compromising plan for now is to fix it in 
`CheckConstexprFunctionDefinition` (just moving the inspecting `InitExpr` code 
there) -- the crash is from `isPotentialConstantExpr` which is only called in 
`CheckConstexprFunctionDefinition`, should cover all cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-04-01 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D75171#1954279 , @sylvestre.ledru 
wrote:

> @baloghadamsoftware @Szelethus it would be great to have the name of the 
> checkers in the error message
>  The error is "error: checker cannot be enabled with analyzer option 
> 'aggressive-binary-operation-simplification' == false"
>  and I had to look at this patch to understand that it is about iterator


Huh, that is a fair point -- Adam, can you patch it in please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


[PATCH] D75561: Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

2020-04-01 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

I seems quite a lot of APIs in Clang are already requiring non-const Modules so 
I think this is fine to make D75488  possible. 
Let's ship it


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

https://reviews.llvm.org/D75561



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


[PATCH] D77204: [clangd] Run semaCodeComplete only with a preamble

2020-04-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

It is used by code completion and signature help. Code completion
already uses a special no-compile mode for missing preambles, so this change is
a no-op for that.

As for signature help, it already blocks for a preamble and missing it implies
clang has failed to parse the preamble and retrying it in signature help likely
will fail again. And even if it doesn't, request latency will be too high to be
useful as parsing preambles is expensive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77204

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -552,15 +552,13 @@
   EXPECT_ERROR(runFindDocumentHighlights(Server, FooCpp, Position()));
   EXPECT_ERROR(runRename(Server, FooCpp, Position(), "new_name",
  clangd::RenameOptions()));
+  EXPECT_ERROR(runSignatureHelp(Server, FooCpp, Position()));
   // Identifier-based fallback completion.
   EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Position(),
clangd::CodeCompleteOptions()))
   .Completions,
   ElementsAre(Field(&CodeCompletion::Name, "int"),
   Field(&CodeCompletion::Name, "main")));
-  auto SigHelp = runSignatureHelp(Server, FooCpp, Position());
-  ASSERT_TRUE(bool(SigHelp)) << "signatureHelp returned an error";
-  EXPECT_THAT(SigHelp->signatures, IsEmpty());
 }
 
 class ClangdThreadingTest : public ClangdVFSTest {};
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -276,7 +276,7 @@
 /// Get signature help at a specified \p Pos in \p FileName.
 SignatureHelp signatureHelp(PathRef FileName,
 const tooling::CompileCommand &Command,
-const PreambleData *Preamble, StringRef Contents,
+const PreambleData &Preamble, StringRef Contents,
 Position Pos,
 IntrusiveRefCntPtr VFS,
 const SymbolIndex *Index);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1022,7 +1022,7 @@
 struct SemaCompleteInput {
   PathRef FileName;
   const tooling::CompileCommand &Command;
-  const PreambleData *Preamble;
+  const PreambleData &Preamble;
   llvm::StringRef Contents;
   size_t Offset;
   llvm::IntrusiveRefCntPtr VFS;
@@ -1054,8 +1054,8 @@
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
-  if (Input.Preamble && Input.Preamble->StatCache)
-VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
+  if (Input.Preamble.StatCache)
+VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
   ParseInputs ParseInput;
   ParseInput.CompileCommand = Input.Command;
   ParseInput.FS = VFS;
@@ -1095,9 +1095,7 @@
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
   // the remapped buffers do not get freed.
   auto Clang = prepareCompilerInstance(
-  std::move(CI),
-  (Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble
-: nullptr,
+  std::move(CI), !CompletingInPreamble ? &Input.Preamble.Preamble : nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
   Clang->getPreprocessorOpts().SingleFileParseMode = CompletingInPreamble;
   Clang->setCodeCompletionConsumer(Consumer.release());
@@ -1114,8 +1112,7 @@
   //  - but Sema code complete won't see them: as part of the preamble, they're
   //deserialized only when mentioned.
   // Force them to be deserialized so SemaCodeComplete sees them.
-  if (Input.Preamble)
-loadMainFilePreambleMacros(Clang->getPreprocessor(), *Input.Preamble);
+  loadMainFilePreambleMacros(Clang->getPreprocessor(), Input.Preamble);
   if (Includes)
 Clang->getPreprocessor().addPPCallbacks(
 collectIncludeStructureCallback(Clang->getSourceManager(), Includes));
@@ -1754,12 +1751,12 @@
   return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
  ? std::move(Flow).runWithoutSema(Contents, *Offset,

[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-04-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5005
+if (Member->getInit() && Member->getInit()->containsErrors())
+  Constructor->setInvalidDecl();
 if (Member->isBaseInitializer())

hokein wrote:
> rsmith wrote:
> > rsmith wrote:
> > > This is inappropriate. The "invalid" bit on a declaration indicates 
> > > whether the declaration is invalid, not whether the definition is invalid.
> > > 
> > > What we should do is add a "contains errors" bit to `Stmt`, and mark the 
> > > function body as containing errors if it has an initializer that contains 
> > > an error.
> > As an example of why this distinction matters: the "contains errors" bit 
> > indicates whether external users of the declaration should ignore it / 
> > suppress errors on it, or whether they can still treat it as a regular 
> > declaration. It's not ideal for an error in the body of a function to 
> > affect the diagnostic behavior of a caller to that function, since the body 
> > is (typically) irrelevant to the validity of that caller.
> Thanks for the suggestions and clarifications!  The "invalid" bit of decl is 
> subtle, I didn't infer it from the code before, thanks for the explanation.
> 
> Setting the decl invalid seemed much safer to us, and would avoid running a 
> lot of unexpected code paths in clang which might violate the assumptions. 
> 
> > What we should do is add a "contains errors" bit to Stmt, and mark the 
> > function body as containing errors if it has an initializer that contains 
> > an error.
> 
> This sounds promising, but there are no free bit in Stmt at the moment :( (to 
> add the ErrorBit to expr, we have sacrificed the `IsOMPStructuredBlock` bit, 
> it would be easier after the ongoing FPOptions stuff finished, which will 
> free certain bits).
> 
> since this crash is blocking recovery-expr stuff, it is prioritized for us to 
> fix it. Maybe a compromising plan for now is to fix it in 
> `CheckConstexprFunctionDefinition` (just moving the inspecting `InitExpr` 
> code there) -- the crash is from `isPotentialConstantExpr` which is only 
> called in `CheckConstexprFunctionDefinition`, should cover all cases.
I don't think the availability or otherwise of a bit in stmt is the critical 
factor here. Adding a bit to stmt will be a huge amount of work because (unlike 
expr/type) stmts don't have dependence, so there's no existing dependence 
propagation/handling to reuse.

When a ctor has an init expr with an error, I think we ultimately need to 
choose between:
1. ctor is constant-evaluable. (This seems obviously wrong)
2. ctor is not-constant-evaluable. (This creates spurious "must be a constant 
expression" diags)
3. ctor is invalid and therefore we never ask. (This creates other spurious 
diags due to not finding the ctor)
4. ctor-with-errors is handled specially (we find it but don't check it for 
constant-evaluability).

Adding a stmt bit is 4, and is certainly the best long-term direction. 2 seems 
like a reasonable short-term solution though. Can we modify the is-constexpr 
check to return false if errors are present, before asserting there's no 
dependent code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041



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


[PATCH] D77205: [X86] Add TSXLDTRK instructions.

2020-04-01 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing created this revision.
tianqing added reviewers: craig.topper, RKSimon, LuoYuanke.
Herald added subscribers: cfe-commits, hiraditya, mgorny.
Herald added a project: clang.

For more details about these instructions, please refer to the latest ISE 
document: 
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77205

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/tsxldtrkintrin.h
  clang/test/CodeGen/x86-tsxldtrk-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
  llvm/test/MC/Disassembler/X86/x86-16.txt
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-16.s
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -1877,3 +1877,9 @@
 // CHECK: enqcmds 485498096, %rax
 // CHECK: encoding: [0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c]
 enqcmds 485498096, %rax
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10876,3 +10876,9 @@
 // CHECK: enqcmds 8128(%bx,%di), %ax
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
 enqcmds 8128(%bx,%di), %ax
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-16.s
===
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -1029,3 +1029,9 @@
 // CHECK: enqcmds (%edi), %edi
 // CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x3f]
 enqcmds (%edi), %edi
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -691,3 +691,9 @@
 
 # CHECK: enqcmds 485498096, %rax
 0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -943,3 +943,9 @@
 
 # CHECK: enqcmds 8128(%bx,%di), %ax
 0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-16.txt
===
--- llvm/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/test/MC/Disassembler/X86/x86-16.txt
@@ -836,3 +836,9 @@
 
 # CHECK: enqcmds (%edi), %edi
 0x67,0xf3,0x0f,0x38,0xf8,0x3f
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+tsxldtrk | FileCheck %s --check-prefix=X32
+
+define void @test_tsxldtrk() {
+; X64-LABEL: test_tsxldtrk:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:xsusldtrk
+; X64-NEXT:xresldtrk
+; X64-NEXT:retq
+;
+; X86-LABEL: test_tsxldtrk:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:xsusldtrk
+; X86-NEXT:xresldtrk
+; X86-NEXT:retl
+;
+; X32-LABEL: test_tsxldtrk:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:xsusldtrk
+; X32-NEXT:xresldtrk
+; X32-NEXT:retq
+entry:
+   call void @llvm.x86.xsusldtrk()
+   call void @llvm.x86.xresldtrk()
+   ret void
+}
+
+declare void @llvm.x86.xsusldtrk()
+declare void @llvm.x86.xresldtrk()
\ No 

[PATCH] D77134: [clang][AARCH64] Add __ARM_FEATURE_{PAC, BTI}_DEFAULT defines

2020-04-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill accepted this revision.
chill added a comment.
This revision is now accepted and ready to land.

LGTM, conditional on the dependent patch. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77134



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


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-04-01 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1828
+  if (CodeGenOpts.BranchTargetEnforcement) {
+FuncAttrs.addAttribute("branch-target-enforcement", "true");
+  }

chill wrote:
> danielkiss wrote:
> > chill wrote:
> > > I would really prefer to not set values "true" or "false" for the 
> > > attribute: we don't really have tri-state logic there 
> > > (absent/present-true/present-false), and those values just add some 
> > > not-very useful string processing.
> > > 
> > the attribute will be  "absent" for the runtime emitted function.
> How about setting the attribute for LLVM created functions at the time of 
> creation, just like Clang created functions
> get their attribute at the time of creation?
> 
Attributes are not always set in clang as I see:
CodeGenModule::CreateRuntimeFunction() -> 
CodeGenModule::GetOrCreateLLVMFunction  
CreateRuntimeFunction could be fixed but, the common location for LLVM created 
function is the llvm::Function::Create() where the CodeGenOpts and LangOpts are 
no available.
Adding target specific code there seems not right for me.


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

https://reviews.llvm.org/D75181



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


[PATCH] D77206: [clangd] Don't send semanticHighlights to clients that support semanticTokens.

2020-04-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

This allows the standard mechanism to gracefully displace the old one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77206

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/semantic-tokens.test


Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -1,5 +1,10 @@
-# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s 
-implicit-check-not=semanticHighlight
+# Send capabilities for both Theia semanticHighlight & standard semanticTokens.
+# clangd should not use/acknowledge the Theia protocol in this case.
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"capabilities":{"textDocument":{
+  "semanticHighlightingCapabilities":{"semanticHighlighting":true},
+  "semanticTokens":{"dynamicRegistration":true}
+
 ---
 
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","text":"int
 x = 2;"}}}
 ---
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -433,8 +433,13 @@
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
 
+  /// Client advertises support for the semanticTokens feature.
+  /// We support the textDocument/semanticTokens request in any case.
+  /// textDocument.semanticTokens
+  bool SemanticTokens = false;
   /// Client supports Theia semantic highlighting extension.
   /// https://github.com/microsoft/vscode-languageserver-node/pull/367
+  /// This will be ignored if the client also supports semanticTokens.
   /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
   /// FIXME: drop this support once clients support LSP 3.16 Semantic Tokens.
   bool TheiaSemanticHighlighting = false;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -297,6 +297,8 @@
   SemanticHighlighting->getBoolean("semanticHighlighting"))
 R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
 }
+if (auto *SemanticHighlighting = TextDocument->getObject("semanticTokens"))
+  R.SemanticTokens = true;
 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
   if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
 R.DiagnosticCategory = *CategorySupport;
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -145,7 +145,7 @@
 /// fetch system include path.
 std::vector QueryDriverGlobs;
 
-/// Enable semantic highlighting features.
+/// Enable notification-based semantic highlighting.
 bool TheiaSemanticHighlighting = false;
 
 /// Returns true if the tweak should be enabled.
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -480,6 +480,13 @@
 
   ClangdServerOpts.TheiaSemanticHighlighting =
   Params.capabilities.TheiaSemanticHighlighting;
+  if (Params.capabilities.TheiaSemanticHighlighting &&
+  Params.capabilities.SemanticTokens) {
+log("Client supports legacy semanticHighlights notification and standard "
+"semanticTokens request, choosing the latter (no notifications).");
+ClangdServerOpts.TheiaSemanticHighlighting = false;
+  }
+
   if (Params.rootUri && *Params.rootUri)
 ClangdServerOpts.WorkspaceRoot = std::string(Params.rootUri->file());
   else if (Params.rootPath && !Params.rootPath->empty())
@@ -612,7 +619,7 @@
 ;
   if (NegotiatedOffsetEncoding)
 Result["offsetEncoding"] = *NegotiatedOffsetEncoding;
-  if (Params.capabilities.TheiaSemanticHighlighting)
+  if (ClangdServerOpts.TheiaSemanticHighlighting)
 Result.getObject("capabilities")
 ->insert(
 {"semanticHighlighting",


Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/cla

[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

@SjoerdMeijer are you happy with the changes I've made to the tests?


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

https://reviews.llvm.org/D76238



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


[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 254148.
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

- Made Flags `uint64_t` instead of `unsigned`.
- Simplified encoding of flags in SveEmitter and moved encoding of properties 
into the `Flags` variable to the constructor of Intrinsic.
- Added (encoding of) MergeType as well.


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

https://reviews.llvm.org/D76617

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -65,9 +65,6 @@
 applyModifier(CharMod);
   }
 
-  /// Return the value in SVETypeFlags for this type.
-  unsigned getTypeFlags() const;
-
   bool isPointer() const { return Pointer; }
   bool isVoidPointer() const { return Pointer && Void; }
   bool isSigned() const { return Signed; }
@@ -138,36 +135,22 @@
   /// The architectural #ifdef guard.
   std::string Guard;
 
+  // The merge suffix such as _m, _x or _z.
+  std::string MergeSuffix;
+
   /// The types of return value [0] and parameters [1..].
   std::vector Types;
 
   /// The "base type", which is VarType('d', BaseTypeSpec).
   SVEType BaseType;
 
-  unsigned Flags;
+  uint64_t Flags;
 
 public:
-  /// The type of predication.
-  enum MergeType {
-MergeNone,
-MergeAny,
-MergeOp1,
-MergeZero,
-MergeAnyExp,
-MergeZeroExp,
-MergeInvalid
-  } Merge;
-
-  Intrinsic(StringRef Name, StringRef Proto, int64_t MT, StringRef LLVMName,
-unsigned Flags, TypeSpec BT, ClassKind Class, SVEEmitter &Emitter,
-StringRef Guard)
-  : Name(Name.str()), LLVMName(LLVMName), Proto(Proto.str()),
-BaseTypeSpec(BT), Class(Class), Guard(Guard.str()), BaseType(BT, 'd'),
-Flags(Flags), Merge(MergeType(MT)) {
-// Types[0] is the return value.
-for (unsigned I = 0; I < Proto.size(); ++I)
-  Types.emplace_back(BaseTypeSpec, Proto[I]);
-  }
+  Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy,
+StringRef MergeSuffix, uint64_t MemoryElementTy, StringRef LLVMName,
+uint64_t Flags, TypeSpec BT, ClassKind Class, SVEEmitter &Emitter,
+StringRef Guard);
 
   ~Intrinsic()=default;
 
@@ -179,14 +162,13 @@
 
   StringRef getGuard() const { return Guard; }
   ClassKind getClassKind() const { return Class; }
-  MergeType getMergeType() const { return Merge; }
 
   SVEType getReturnType() const { return Types[0]; }
   ArrayRef getTypes() const { return Types; }
   SVEType getParamType(unsigned I) const { return Types[I + 1]; }
   unsigned getNumParams() const { return Proto.size() - 1; }
 
-  unsigned getFlags() const { return Flags; }
+  uint64_t getFlags() const { return Flags; }
   bool isFlagSet(uint64_t Flag) const { return Flags & Flag;}
 
   /// Return the type string for a BUILTIN() macro in Builtins.def.
@@ -209,7 +191,7 @@
   void emitIntrinsic(raw_ostream &OS) const;
 
 private:
-  std::string getMergeSuffix() const;
+  std::string getMergeSuffix() const { return MergeSuffix; }
   std::string mangleName(ClassKind LocalCK) const;
   std::string replaceTemplatedArgs(std::string Name, TypeSpec TS,
std::string Proto) const;
@@ -221,8 +203,8 @@
   llvm::StringMap EltTypes;
   llvm::StringMap MemEltTypes;
   llvm::StringMap FlagTypes;
+  llvm::StringMap MergeTypes;
 
-  unsigned getTypeFlags(const SVEType &T);
 public:
   SVEEmitter(RecordKeeper &R) : Records(R) {
 for (auto *RV : Records.getAllDerivedDefinitions("EltType"))
@@ -231,8 +213,56 @@
   MemEltTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
 for (auto *RV : Records.getAllDerivedDefinitions("FlagType"))
   FlagTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
+for (auto *RV : Records.getAllDerivedDefinitions("MergeType"))
+  MergeTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
+  }
+
+  /// Returns the enum value for the flag type
+  unsigned getEnumValueForFlag(StringRef C) const {
+auto Res = FlagTypes.find(C);
+if (Res != FlagTypes.end())
+  return Res->getValue();
+llvm_unreachable("Unsupported flag");
+  }
+
+  // Returns the SVETypeFlags for a given value and mask.
+  unsigned encodeFlag(unsigned V, StringRef MaskName) const {
+auto It = FlagTypes.find(MaskName);
+if (It != FlagTypes.end()) {
+  uint64_t Mask = It->getValue();
+  unsigned Shift = llvm::countTrailingZeros(Mask);
+  return (V << Shift) & Mask;
+}
+llvm_unreachable("Unsupported flag");
+  }
+
+  // Returns the SVETypeFlags for the given element type.
+  unsigned encodeEltType(StringRef EltName) {
+auto It = EltTypes.find(EltName);
+if (It != EltTypes.end())
+  return encodeFlag(It->getValue(), "EltTypeMask");
+ll

[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-04-01 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks for the ping, hadn't noticed the updates.

I may have also missed why you need the SVE_ACLE_FUNC macro. Can you quickly 
comment why you need that? Just asking because in my opinion it doesn't really 
make it more pleasant to read (so it's there for another reason).

On one of the other tickets (may have missed a notification there too)  I asked 
why you need option `-fallow-half-arguments-and-returns`. Do you really need 
that, and why?

And last question is if you really need to pass these defines 
`-D__ARM_FEATURE_SVE`?


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

https://reviews.llvm.org/D76238



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


[clang-tools-extra] 43aa04e - [clangd] Run semaCodeComplete only with a preamble

2020-04-01 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-01T13:02:47+02:00
New Revision: 43aa04eb7a617ee75dfcbbe2d395b8208e66c0e0

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

LOG: [clangd] Run semaCodeComplete only with a preamble

Summary:
It is used by code completion and signature help. Code completion
already uses a special no-compile mode for missing preambles, so this change is
a no-op for that.

As for signature help, it already blocks for a preamble and missing it implies
clang has failed to parse the preamble and retrying it in signature help likely
will fail again. And even if it doesn't, request latency will be too high to be
useful as parsing preambles is expensive.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 0882784f7031..c1773258554c 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -271,9 +271,13 @@ void ClangdServer::signatureHelp(PathRef File, Position 
Pos,
 if (!IP)
   return CB(IP.takeError());
 
-auto PreambleData = IP->Preamble;
-CB(clangd::signatureHelp(File, IP->Command, PreambleData, IP->Contents, 
Pos,
- FS, Index));
+const auto *PreambleData = IP->Preamble;
+if (!PreambleData)
+  return CB(llvm::createStringError(llvm::inconvertibleErrorCode(),
+"Failed to parse includes"));
+
+CB(clangd::signatureHelp(File, IP->Command, *PreambleData, IP->Contents,
+ Pos, FS, Index));
   };
 
   // Unlike code completion, we wait for an up-to-date preamble here.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 86ea5f26d397..b544510ecea1 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1022,7 +1022,7 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 struct SemaCompleteInput {
   PathRef FileName;
   const tooling::CompileCommand &Command;
-  const PreambleData *Preamble;
+  const PreambleData &Preamble;
   llvm::StringRef Contents;
   size_t Offset;
   llvm::IntrusiveRefCntPtr VFS;
@@ -1054,8 +1054,8 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
-  if (Input.Preamble && Input.Preamble->StatCache)
-VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
+  if (Input.Preamble.StatCache)
+VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
   ParseInputs ParseInput;
   ParseInput.CompileCommand = Input.Command;
   ParseInput.FS = VFS;
@@ -1099,9 +1099,7 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. 
Otherwise
   // the remapped buffers do not get freed.
   auto Clang = prepareCompilerInstance(
-  std::move(CI),
-  (Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble
-: nullptr,
+  std::move(CI), !CompletingInPreamble ? &Input.Preamble.Preamble : 
nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
   Clang->getPreprocessorOpts().SingleFileParseMode = CompletingInPreamble;
   Clang->setCodeCompletionConsumer(Consumer.release());
@@ -1118,8 +1116,7 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   //  - but Sema code complete won't see them: as part of the preamble, they're
   //deserialized only when mentioned.
   // Force them to be deserialized so SemaCodeComplete sees them.
-  if (Input.Preamble)
-loadMainFilePreambleMacros(Clang->getPreprocessor(), *Input.Preamble);
+  loadMainFilePreambleMacros(Clang->getPreprocessor(), Input.Preamble);
   if (Includes)
 Clang->getPreprocessor().addPPCallbacks(
 collectIncludeStructureCallback(Clang->getSourceManager(), Includes));
@@ -1758,12 +1755,12 @@ codeComplete(PathRef FileName, const 
tooling::CompileCommand &Command,
   return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
  ? std::move(Flow).runWithoutSema(Contents, *Offset, VFS)
  : std::move(Flow).run(
-   {FileName, Comman

[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

(sorry, I wrote the comments earlier but forgot to click 'submit' :) )




Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

SjoerdMeijer wrote:
> Just curious about the `-fallow-half-arguments-and-returns`, do you need that 
> here?
> 
> And if not here, why do you need it elsewhere (looks enabled on all tests)?
It's not needed for this test, but we've generated most of our tests from the 
ACLE spec and the tests that use a scalar float16_t (== __fp16) will need this, 
such as the ACLE intrinsic:

  svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);

If you feel strongly about it, I could remove it from the other RUN lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D77048: [Clang][CodeGen] Fixing mismatch between memory layout and const expressions for oversized bitfields

2020-04-01 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked 2 inline comments as done.
pratlucas added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:613
+  
+  // Add padding bits in case of over-sized bit-field.
+  //   "The first sizeof(T)*8 bits are used to hold the value of the bit-field,

efriedma wrote:
> The existing code in ConstantAggregateBuilder::add should skip over padding.  
> I'm not sure what you're trying to accomplish by adding more code dealing 
> with padding here.
You're right, I missed the fact that `FieldOffset`s take care of this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77048



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


[PATCH] D76678: [SveEmitter] Add range checks for immediates and predicate patterns.

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked 3 inline comments as done.
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:153
+}
+def ImmCheckPredicatePattern: ImmCheckType<0>;  // 0..31
+def ImmCheck1_16: ImmCheckType<1>;  // 1..16

SjoerdMeijer wrote:
> would it make sense to call this `ImmCheck0_31`?
Sure, I can change that.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7571
+  else if (Builtin->LLVMIntrinsic != 0) {
+llvm::Type* OverloadedTy = getSVEType(TypeFlags);
+

efriedma wrote:
> I'm not sure why you need a second way to convert SVE types separate from 
> ConvertType
For the intrinsics added here, that's indeed correct, but for others, the 
OverloadedTy is not necessarily the return type. This is determined by the type 
string in the arm_sve.td file. For example:

```def SVQDECH_S : SInst<"svqdech_pat[_{d}]",   "ddIi", "s", MergeNone, 
"aarch64_sve_sqdech", 
  ^
```
The `default` type `d` (in this case both return value, and first parameter) is 
the overloaded type.

For other intrinsics, such as
```def SVSHRNB  : SInst<"svshrnb[_n_{d}]","hdi",  "silUsUiUl", 
MergeNone, "aarch64_sve_shrnb",
 ^
```
The overloaded type is the first parameter, not the result type.



Comment at: 
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdech.c:10
+{
+  return svqdech_pat_s16(op, SV_VL8, 0); // expected-error-re {{argument value 
{{[0-9]+}} is outside the valid range [1, 16]}}
+}

SjoerdMeijer wrote:
> nit: why use a regexp for the argument value and not just its value?
Mostly because for most tests, there is no ambiguity and it would be a hassle 
to update all the generated tests. The regular expression is also used for many 
similar tests in Clang for e.g. Neon or other builtins. I guess for these tests 
it makes sense to be more explicit which operand is out of range (given that 
there are two immediates). Are you happy for me to change it for these tests, 
but not others where there is only a single immediate (i.e. where the message 
cannot be ambiguous)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76678



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


[PATCH] D77209: [Syntax] Add mapping from spelled to expanded tokens for TokenBuffer

2020-04-01 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Same restrictions apply as in the other direction: macro arguments are
not supported yet, only full macro expansions can be mapped.

Taking over from https://reviews.llvm.org/D72581.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77209

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -57,6 +57,7 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::Not;
 using ::testing::Pointee;
@@ -185,10 +186,14 @@
   template 
   llvm::ArrayRef findSubrange(llvm::ArrayRef Subrange,
  llvm::ArrayRef Range, Eq F) {
-for (auto Begin = Range.begin(); Begin < Range.end(); ++Begin) {
+assert(Subrange.size() >= 1);
+if (Range.size() < Subrange.size())
+  return llvm::makeArrayRef(Range.end(), Range.end());
+for (auto Begin = Range.begin(), Last = Range.end() - Subrange.size();
+ Begin <= Last; ++Begin) {
   auto It = Begin;
-  for (auto ItSub = Subrange.begin();
-   ItSub != Subrange.end() && It != Range.end(); ++ItSub, ++It) {
+  for (auto ItSub = Subrange.begin(); ItSub != Subrange.end();
+   ++ItSub, ++It) {
 if (!F(*ItSub, *It))
   goto continue_outer;
   }
@@ -889,4 +894,100 @@
   ASSERT_EQ(Code.points().size(), 8u);
 }
 
+TEST_F(TokenBufferTest, ExpandedBySpelled) {
+  recordTokens(R"cpp(
+a1 a2 a3 b1 b2
+  )cpp");
+  // Sanity check: expanded and spelled tokens are stored separately.
+  EXPECT_THAT(findExpanded("a1 a2"), Not(SameRange(findSpelled("a1 a2";
+  // Searching for subranges of expanded tokens should give the corresponding
+  // spelled ones.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1 a2 a3 b1 b2")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1 a2 a3")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("b1 b2")),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+
+  // Test search on simple macro expansions.
+  recordTokens(R"cpp(
+#define A a1 a2 a3
+#define B b1 b2
+
+A split B
+  )cpp");
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("A split B")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 split b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("A split").drop_back()),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("split B").drop_front()),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+
+  // Recursive macro invocations.
+  recordTokens(R"cpp(
+#define ID(x) x
+#define B b1 b2
+
+ID(ID(ID(a1) a2 a3)) split ID(B)
+  )cpp");
+
+  EXPECT_THAT(
+  Buffer.expandedForSpelled(findSpelled("ID ( ID ( ID ( a1 ) a2 a3 ) )")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( B )")),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(
+  findSpelled("ID ( ID ( ID ( a1 ) a2 a3 ) ) split ID ( B )")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 split b1 b2";
+  // FIXME: these should succeed, but we do not support macro arguments yet.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1")), IsEmpty());
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( a1 ) a2")),
+  IsEmpty());
+
+  // Empty macro expansions.
+  recordTokens(R"cpp(
+#define EMPTY
+#define ID(X) X
+
+EMPTY EMPTY ID(1 2 3) EMPTY EMPTY split1
+EMPTY EMPTY ID(4 5 6) split2
+ID(7 8 9) EMPTY EMPTY
+  )cpp");
+  // Covered by empty expansions on one of both of the sides.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 1 2 3 )")),
+  ElementsAre(SameRange(findExpanded("1 2 3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 4 5 6 )")),
+  ElementsAre(SameRange(findExpanded("4 5 6";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 7 8 9 )")),
+  ElementsAre(SameRange(findExpanded("7 8 9";
+  // Including the empty macro expansions on the side.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("EMPTY ID ( 1 2 3 )")),
+  ElementsAre(SameRange(findExpanded("1 2 3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 1 2 3 ) EMPTY")),
+  ElementsAre(SameRange(findExpanded("1 

[PATCH] D77048: [Clang][CodeGen] Fixing mismatch between memory layout and const expressions for oversized bitfields

2020-04-01 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 254156.
pratlucas added a comment.

Removing unecessary handling of padding bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77048

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp

Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -1,11 +1,14 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP64 %s
-// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP32 %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix=CHECK-LP64 -check-prefix=CHECK %s
+// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP32 -check-prefix=CHECK %s
+// RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-A64BE -check-prefix=CHECK %s
+// RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-A32BE -check-prefix=CHECK %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
   int a;
   int b: 39;
-} t1;
+};
+Test1 t1;
 
 // CHECK-LP64: %union.Test2 = type { i8 }
 union Test2 {
@@ -17,10 +20,16 @@
   int : 9;
 } t3;
 
+// CHECK: %union.Test4 = type { i8, i8 }
+union Test4 {
+  char val : 16;
+};
+Test4 t4;
 
 #define CHECK(x) if (!(x)) return __LINE__
 
-int f() {
+// CHECK: define i32 @_Z11test_assignv()
+int test_assign() {
   struct {
 int a;
 
@@ -37,7 +46,41 @@
   CHECK(c.b == (unsigned long long)-1);
   CHECK(c.c == 0);
 
-// CHECK-LP64: ret i32 0
-// CHECK-LP32: ret i32 0
+  Test1 u1;
+  Test4 u2;
+
+  u1.b = 1;
+  u2.val = 42;
+
+  CHECK(u1.b == 1);
+  CHECK(u2.val == 42);
+
+  // CHECK: ret i32 0
+  return 0;
+}
+
+// CHECK: define i32 @_Z9test_initv()
+int test_init() {
+  struct S {
+int a;
+
+unsigned long long b : 65;
+
+int c;
+  };
+  S s1 = {1, 42, 0};
+
+  CHECK(s1.a == 1);
+  CHECK(s1.b == (unsigned long long)42);
+  CHECK(s1.c == 0);
+
+  Test1 u1 = {1};
+  Test4 u2 = {42};
+
+  CHECK(u1.a == 1);
+  CHECK(u1.b == 1);
+  CHECK(u2.val == 42);
+
+  // CHECK: ret i32 0
   return 0;
 }
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -589,19 +589,21 @@
 bool ConstStructBuilder::AppendBitField(
 const FieldDecl *Field, uint64_t FieldOffset, llvm::ConstantInt *CI,
 bool AllowOverwrite) {
-  uint64_t FieldSize = Field->getBitWidthValue(CGM.getContext());
+  const CGRecordLayout &RL =
+  CGM.getTypes().getCGRecordLayout(Field->getParent());
+  const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
   llvm::APInt FieldValue = CI->getValue();
 
   // Promote the size of FieldValue if necessary
   // FIXME: This should never occur, but currently it can because initializer
   // constants are cast to bool, and because clang is not enforcing bitfield
   // width limits.
-  if (FieldSize > FieldValue.getBitWidth())
-FieldValue = FieldValue.zext(FieldSize);
+  if (Info.Size > FieldValue.getBitWidth())
+FieldValue = FieldValue.zext(Info.Size);
 
   // Truncate the size of FieldValue to the bit field size.
-  if (FieldSize < FieldValue.getBitWidth())
-FieldValue = FieldValue.trunc(FieldSize);
+  if (Info.Size < FieldValue.getBitWidth())
+FieldValue = FieldValue.trunc(Info.Size);
 
   return Builder.addBits(FieldValue,
  CGM.getContext().toBits(StartOffset) + FieldOffset,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76238: [SveEmitter] Implement builtins for contiguous loads/stores

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D76238#1954585 , @SjoerdMeijer 
wrote:

> Thanks for the ping, hadn't noticed the updates.
>
> I may have also missed why you need the SVE_ACLE_FUNC macro. Can you quickly 
> comment why you need that? Just asking because in my opinion it doesn't 
> really make it more pleasant to read (so it's there for another reason).


Thanks, these are all good questions!

In the previous revision of the patch there were separate test files for the 
short-forms (overloaded forms) of the tests. For example:

  svint8_t svadd[_s8]_z(svbool_t pg, svint8_t op1, svint8_t op2)

has the fully specific intrinsic `svadd_s8_z`, but also the overloaded form 
`svadd_z`. With the SVE_ACLE_FUNC(..) macro we can test both variants with a 
different RUN line, one where the [_s] suffix is ignored, the other where all 
suffixes are concatenated, depending on whether SVE_OVERLOADED_FORMS is defined.

> On one of the other tickets (may have missed a notification there too)  I 
> asked why you need option `-fallow-half-arguments-and-returns`. Do you really 
> need that, and why?

I answered that on the other patch now. Sorry about that, forgot to click 
'submit' earlier.

> And last question is if you really need to pass these defines 
> `-D__ARM_FEATURE_SVE`?

`__ARM_FEATURE_SVE` is automatically enabled by the compiler when the compiler 
implements the ACLE spec and +sve is specified. Given that the compiler doesn't 
yet implement the spec, these tests add the feature macro explicitly. Once all 
builtins are upstreamed, we'll update these tests by removing the explicit 
`-D__ARM_FEATURE_SVE` flag.


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

https://reviews.llvm.org/D76238



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


[PATCH] D77204: [clangd] Run semaCodeComplete only with a preamble

2020-04-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43aa04eb7a61: [clangd] Run semaCodeComplete only with a 
preamble (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D77204?vs=254133&id=254165#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77204

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

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1049,8 +1049,12 @@
   auto Preamble =
   buildPreamble(testPath(TU.Filename), *CI, /*OldPreamble=*/nullptr, Inputs,
 /*InMemory=*/true, /*Callback=*/nullptr);
-  return signatureHelp(testPath(TU.Filename), Inputs.CompileCommand,
-   Preamble.get(), Text, Point, Inputs.FS, Index.get());
+  if (!Preamble) {
+ADD_FAILURE() << "Couldn't build Preamble";
+return {};
+  }
+  return signatureHelp(testPath(TU.Filename), Inputs.CompileCommand, *Preamble,
+   Text, Point, Inputs.FS, Index.get());
 }
 
 SignatureHelp signatures(llvm::StringRef Text,
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -552,15 +552,13 @@
   EXPECT_ERROR(runFindDocumentHighlights(Server, FooCpp, Position()));
   EXPECT_ERROR(runRename(Server, FooCpp, Position(), "new_name",
  clangd::RenameOptions()));
+  EXPECT_ERROR(runSignatureHelp(Server, FooCpp, Position()));
   // Identifier-based fallback completion.
   EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Position(),
clangd::CodeCompleteOptions()))
   .Completions,
   ElementsAre(Field(&CodeCompletion::Name, "int"),
   Field(&CodeCompletion::Name, "main")));
-  auto SigHelp = runSignatureHelp(Server, FooCpp, Position());
-  ASSERT_TRUE(bool(SigHelp)) << "signatureHelp returned an error";
-  EXPECT_THAT(SigHelp->signatures, IsEmpty());
 }
 
 class ClangdThreadingTest : public ClangdVFSTest {};
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -276,7 +276,7 @@
 /// Get signature help at a specified \p Pos in \p FileName.
 SignatureHelp signatureHelp(PathRef FileName,
 const tooling::CompileCommand &Command,
-const PreambleData *Preamble, StringRef Contents,
+const PreambleData &Preamble, StringRef Contents,
 Position Pos,
 IntrusiveRefCntPtr VFS,
 const SymbolIndex *Index);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1022,7 +1022,7 @@
 struct SemaCompleteInput {
   PathRef FileName;
   const tooling::CompileCommand &Command;
-  const PreambleData *Preamble;
+  const PreambleData &Preamble;
   llvm::StringRef Contents;
   size_t Offset;
   llvm::IntrusiveRefCntPtr VFS;
@@ -1054,8 +1054,8 @@
   IncludeStructure *Includes = nullptr) {
   trace::Span Tracer("Sema completion");
   llvm::IntrusiveRefCntPtr VFS = Input.VFS;
-  if (Input.Preamble && Input.Preamble->StatCache)
-VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS));
+  if (Input.Preamble.StatCache)
+VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
   ParseInputs ParseInput;
   ParseInput.CompileCommand = Input.Command;
   ParseInput.FS = VFS;
@@ -1099,9 +1099,7 @@
   // NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
   // the remapped buffers do not get freed.
   auto Clang = prepareCompilerInstance(
-  std::move(CI),
-  (Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble
-: nullptr,
+  std::move(CI), !CompletingInPreamble ? &Input.Preamble.Preamble : nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
   Clang->getPreprocessorOpts().SingleFileParseMode = CompletingInPreamble;
   Clang->setCodeCompletionConsumer(Consumer.release());
@@ -1118,8 +1116,7 @@
   //  - but Sema code complete won't see them

[PATCH] D76432: [clangd] Add a tweak for adding "using" statement.

2020-04-01 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

In D76432#1952798 , @sammccall wrote:

> Still LG, should I land this?


Yes please :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76432



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


[clang-tools-extra] db3d64e - [clangd-vscode] NFC; Improve wording in documentation and update VSCode tasks

2020-04-01 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-04-01T14:16:55+02:00
New Revision: db3d64eebbe0aad87631c6fada01b06753377a44

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

LOG: [clangd-vscode] NFC; Improve wording in documentation and update VSCode 
tasks

Summary:
VSCode tasks are updated to the latest supported versions: deprecated
values are removed and replaced by their new counterparts.

Reviewers: hokein

Reviewed By: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json

Removed: 




diff  --git 
a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
index cd6b87bd05c0..7d414bc00f32 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
@@ -1,4 +1,4 @@
-// A launch configuration that compiles the extension and then opens it inside 
a new window
+// A launch configuration that compiles extension and opens it inside a new 
window.
 {
 "version": "0.1.0",
 "configurations": [

diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
index fb7f662e14d1..65b1c9598c0e 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
@@ -6,25 +6,27 @@
 // ${fileExtname}: the current opened file's extension
 // ${cwd}: the current working directory of the spawned process
 
-// A task runner that calls a custom npm script that compiles the extension.
+// Task runner calls custom npm script to compile the extension.
 {
-"version": "0.1.0",
+"version": "2.0.0",
 
-// we want to run npm
+// Run NPM.
 "command": "npm",
 
-// the command is a shell script
-"isShellCommand": true,
+// This command is a shell script.
+"type": "shell",
 
 // show the output window only if unrecognized errors occur.
-"showOutput": "silent",
+"presentation": {
+"reveal": "silent",
+},
 
-// we run the custom script "compile" as defined in package.json
+// Run custom "compile" script as defined in package.json
 "args": ["run", "compile", "--loglevel", "silent"],
 
-// The tsc compiler is started in watching mode
-"isWatching": true,
+// tsc compiler is kept alive and runs in the background.
+"isBackground": true,
 
-// use the standard tsc in watch mode problem matcher to find compile 
problems in the output.
+// Find compilation problems in the output through tsc in watch mode.
 "problemMatcher": "$tsc-watch"
-}
\ No newline at end of file
+}

diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md 
b/clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
index e888aba3ea20..15f2b930329e 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
@@ -10,20 +10,20 @@ A guide of developing `vscode-clangd` extension.
 ## Steps
 
 1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
+2. Make sure you have clangd in `/usr/bin/clangd` or edit `src/extension.ts` to
 point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+3. To start a development instance of VS code extended with this, run:
 
 ```bash
$ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
$ npm install
$ code .
-   # When VS Code starts, press .
+   # When VSCode starts, press .
 ```
 
 # Contributing
 
-Please follow the exsiting code style when contributing to the extension, we
+Please follow the existing code style when contributing to the extension, we
 recommend to run `npm run format` before sending a patch.
 
 # Publish to VS Code Marketplace
@@ -38,15 +38,15 @@ to the marketplace.
 * Bump the version in `package.json`, and commit the change to upstream
 
 The extension is published under `llvm-vs-code-extensions` account, which is
-currently maintained by clangd developers. If you want to make a new release,
-please contact clangd-...@lists.llvm.org.
+maintained

[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.






Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

sdesmalen wrote:
> SjoerdMeijer wrote:
> > Just curious about the `-fallow-half-arguments-and-returns`, do you need 
> > that here?
> > 
> > And if not here, why do you need it elsewhere (looks enabled on all tests)?
> It's not needed for this test, but we've generated most of our tests from the 
> ACLE spec and the tests that use a scalar float16_t (== __fp16) will need 
> this, such as the ACLE intrinsic:
> 
>   svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);
> 
> If you feel strongly about it, I could remove it from the other RUN lines.
Well, I think this is my surprise then. Thinking out loud: we're talking SVE 
here, which always implies FP16. That's why I am surprised that we bother with 
a storage-type only type. Looking at the SVE ACLE I indeed see:

  float16_t equivalent to __fp16

where I was probably expecting:

  float16_t equivalent to _Float16

and with that everything would be sorted I guess, then we also don't need the 
hack^W workaround that is `-fallow-half-arguments-and-returns`. But maybe there 
is a good reason to use/choose `__fp16` that I don't see here. Probably worth a 
quick question for the ARM SVE ACLE, would you mind quickly checking?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-04-01 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer updated this revision to Diff 254171.
aschwaighofer added a comment.

- Implement for the GNU runtimes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077

Files:
  clang/include/clang/CodeGen/CodeGenABITypes.h
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/CGObjCRuntime.h

Index: clang/lib/CodeGen/CGObjCRuntime.h
===
--- clang/lib/CodeGen/CGObjCRuntime.h
+++ clang/lib/CodeGen/CGObjCRuntime.h
@@ -211,6 +211,11 @@
   /// implementations.
   virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0;
 
+  /// GetOrEmitProtocol - Get the protocol object for the given
+  /// declaration, emitting it if necessary. The return value has type
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+
   /// Generate a function preamble for a method with the specified
   /// types.
 
Index: clang/lib/CodeGen/CGObjCRuntime.cpp
===
--- clang/lib/CodeGen/CGObjCRuntime.cpp
+++ clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -13,14 +13,15 @@
 //===--===//
 
 #include "CGObjCRuntime.h"
-#include "CGCleanup.h"
 #include "CGCXXABI.h"
+#include "CGCleanup.h"
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
@@ -383,3 +384,9 @@
 CGM.getTypes().GetFunctionType(argsInfo)->getPointerTo();
   return MessageSendInfo(argsInfo, signatureType);
 }
+
+llvm::Constant *
+clang::CodeGen::emitObjCProtocolObject(CodeGenModule &CGM,
+   const ObjCProtocolDecl *protocol) {
+  return CGM.getObjCRuntime().GetOrEmitProtocol(protocol);
+}
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1107,11 +1107,6 @@
 
   void GenerateProtocol(const ObjCProtocolDecl *PD) override;
 
-  /// GetOrEmitProtocol - Get the protocol object for the given
-  /// declaration, emitting it if necessary. The return value has type
-  /// ProtocolPtrTy.
-  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD)=0;
-
   /// GetOrEmitProtocolRef - Get a forward reference to the protocol
   /// object for the given declaration, emitting it if needed. These
   /// forward references will be filled in with empty bodies if no
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -617,6 +617,13 @@
   llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
const ObjCProtocolDecl *PD) override;
   void GenerateProtocol(const ObjCProtocolDecl *PD) override;
+
+  virtual llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD);
+
+  llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) override {
+return GenerateProtocolRef(PD);
+  }
+
   llvm::Function *ModuleInitFunction() override;
   llvm::FunctionCallee GetPropertyGetFunction() override;
   llvm::FunctionCallee GetPropertySetFunction() override;
@@ -1348,7 +1355,7 @@
   void GenerateProtocol(const ObjCProtocolDecl *PD) override {
 // Do nothing - we only emit referenced protocols.
   }
-  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) {
+  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) override {
 std::string ProtocolName = PD->getNameAsString();
 auto *&Protocol = ExistingProtocols[ProtocolName];
 if (Protocol)
@@ -3039,13 +3046,18 @@
 
 llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
 const ObjCProtocolDecl *PD) {
+  auto protocol = GenerateProtocolRef(PD);
+  llvm::Type *T =
+  CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
+  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+}
+
+llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) {
   llvm::Constant *&protocol = ExistingProtocols[PD->getNameAsString()];
   if (!protocol)
 GenerateProtocol(PD);
   assert(protocol && "Unknown protocol");
-  llvm::Type *T =
-CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
-  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+  return protocol;
 }
 
 llvm::Constant *
Index: clang/include/clang/CodeGen/CodeGenABITypes.h
==

[PATCH] D76595: [clangd-vscode] NFC; Improve wording in documentation and update VSCode tasks

2020-04-01 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb3d64eebbe0: [clangd-vscode] NFC; Improve wording in 
documentation and update VSCode tasks (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76595

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
  clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
  clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json

Index: clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json
@@ -26,4 +26,4 @@
 "node_modules",
 ".vscode-test"
 ]
-}
\ No newline at end of file
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -3,7 +3,7 @@
 import * as semanticHighlighting from './semantic-highlighting';
 
 /**
- * Method to get workspace configuration option
+ * Get an option from workspace configuration.
  * @param option name of the option (e.g. for clangd.path should be path)
  * @param defaultValue default value to return if option is not set
  */
@@ -75,8 +75,8 @@
 }
 
 /**
- *  this method is called when your extension is activate
- *  your extension is activated the very first time the command is executed
+ *  This method is called when the extension is activated. The extension is
+ *  activated the very first time a command is executed.
  */
 export function activate(context: vscode.ExtensionContext) {
   const syncFileEvents = getConfig('syncFileEvents', true);
@@ -97,7 +97,7 @@
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
-// cuda is not supported by vscode, but our extension does.
+// CUDA is not supported by vscode, but our extension does supports it.
 { scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
 { scheme: 'file', language: 'objective-cpp'}
@@ -106,7 +106,7 @@
 // FIXME: send sync file events when clangd provides implementations.
 },
 initializationOptions: { clangdFileStatus: true },
-// Do not switch to output window when clangd returns output
+// Do not switch to output window when clangd returns output.
 revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never,
 
 // We hack up the completion items a bit to prevent VSCode from re-ranking them
@@ -126,7 +126,7 @@
   provideCompletionItem: async (document, position, context, token, next) => {
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
-  // Gets the prefix used by vscode when doing fuzzymatch.
+  // Gets the prefix used by VSCode when doing fuzzymatch.
   let prefix = document.getText(new vscode.Range(item.range.start, position))
   if (prefix)
 item.filterText = prefix + "_" + item.filterText;
Index: clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
@@ -10,20 +10,20 @@
 ## Steps
 
 1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
+2. Make sure you have clangd in `/usr/bin/clangd` or edit `src/extension.ts` to
 point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+3. To start a development instance of VS code extended with this, run:
 
 ```bash
$ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
$ npm install
$ code .
-   # When VS Code starts, press .
+   # When VSCode starts, press .
 ```
 
 # Contributing
 
-Please follow the exsiting code style when contributing to the extension, we
+Please follow the existing code style when contributing to the extension, we
 recommend to run `npm run format` before sending a patch.
 
 # Publish to VS Code Marketplace
@@ -38,15 +38,15 @@
 * Bump the version in `package.json`, and commit the change to upstream
 
 The extension is published under `llvm-vs-code-extensions` account, which is
-currently maintained by clangd dev

[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-04-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 254170.
hokein added a comment.

refine the fix based on the comment:

now constexpr ctor with error initializers is still a valid decl but not
constant-evaluate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+struct X {
+  int Y;
+  constexpr X() // expected-error {{constexpr constructor never produces}}
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+};
+// no crash on evaluating the constexpr ctor.
+constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
+
+struct X2 {
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
+ // expected-note {{subexpression not valid in a constant 
expression}}
+  constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
+};
+
+struct CycleDelegate {
+  int Y;
+  CycleDelegate(int)
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+  // no bogus "delegation cycle" diagnostic
+  CycleDelegate(float) : CycleDelegate(1) {}
+};
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -45,6 +45,7 @@
 #include "clang/Sema/Template.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/Casting.h"
 #include 
 #include 
 #include 
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4975,6 +4975,13 @@
 return false;
   }
 
+  if (const auto *CtorDecl = dyn_cast_or_null(Definition)) 
{
+for (const auto *InitExpr : CtorDecl->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
+
   // Can we evaluate this function call?
   if (Definition && Definition->isConstexpr() && Body)
 return true;
@@ -14736,6 +14743,15 @@
   if (FD->isDependentContext())
 return true;
 
+  // Bail out if a constexpr constructor has an initializer that contains an
+  // error. We deliberately don't produce a diagnostic, as we have produced a
+  // relevant diagnostic when parsing the error initializer.
+  if (const auto *Ctor = dyn_cast(FD)) {
+for (const auto *InitExpr : Ctor->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
   Expr::EvalStatus Status;
   Status.Diag = &Diags;
 


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+struct X {
+  int Y;
+  constexpr X() // expected-error {{constexpr constructor never produces}}
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+};
+// no crash on evaluating the constexpr ctor.
+constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}}
+
+struct X2 {
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
+ // expected-note {{subexpression not valid in a constant expression}}
+  constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
+};
+
+struct CycleDelegate {
+  int Y;
+  CycleDelegate(int)
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+  // no bogus "delegation cycle" diagnostic
+  CycleDelegate(float) : CycleDelegate(1) {}
+};
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -45,6 +45,7 @@
 #include "clang/Sema/Template.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/Casting.h"
 #include 
 #include 
 #include 
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4975,6 +4975,13 @@
 return false;
   }
 
+  if (const auto *CtorDecl = dyn_cast_or_null(Definition)) {
+for (const auto *InitExpr : CtorDecl->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
+
   // Can we evaluate t

[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-04-01 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer marked an inline comment as done.
aschwaighofer added inline comments.



Comment at: clang/lib/CodeGen/CGObjCRuntime.h:217
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+

rjmccall wrote:
> aschwaighofer wrote:
> > aschwaighofer wrote:
> > > rjmccall wrote:
> > > > Can this name more closely parallel the "external" name, like 
> > > > `getOrEmitProtocolObject`?
> > > > 
> > > > Also, I think we're incrementally lowercasing new method names.
> > > This is an already existing method. I just moved it higher in the class 
> > > hierarchy to CGObjCRuntime from CGObjCMac so that it is callable from 
> > > getOrEmitProtocolObject.
> > s/getOrEmitProtocolObject/emitObjCProtocolObject
> I see.  Well, in that case, I won't ask you to rename it, but please do 
> implement it for the GNU runtime as I mentioned.
Done. I introduced 
`CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD)` because it only 
existed in the `CGObjCGNUstep2` subclass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[PATCH] D77131: [clang] Move branch-protection from CodeGenOptions to LangOptions

2020-04-01 Thread Tamas Petz via Phabricator via cfe-commits
tamas.petz updated this revision to Diff 254174.
tamas.petz added a comment.

Address review comments.


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

https://reviews.llvm.org/D77131

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1386,38 +1386,6 @@
 
   Opts.Addrsig = Args.hasArg(OPT_faddrsig);
 
-  if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) {
-StringRef SignScope = A->getValue();
-
-if (SignScope.equals_lower("none"))
-  Opts.setSignReturnAddress(CodeGenOptions::SignReturnAddressScope::None);
-else if (SignScope.equals_lower("all"))
-  Opts.setSignReturnAddress(CodeGenOptions::SignReturnAddressScope::All);
-else if (SignScope.equals_lower("non-leaf"))
-  Opts.setSignReturnAddress(
-  CodeGenOptions::SignReturnAddressScope::NonLeaf);
-else
-  Diags.Report(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << SignScope;
-
-if (Arg *A = Args.getLastArg(OPT_msign_return_address_key_EQ)) {
-  StringRef SignKey = A->getValue();
-  if (!SignScope.empty() && !SignKey.empty()) {
-if (SignKey.equals_lower("a_key"))
-  Opts.setSignReturnAddressKey(
-  CodeGenOptions::SignReturnAddressKeyValue::AKey);
-else if (SignKey.equals_lower("b_key"))
-  Opts.setSignReturnAddressKey(
-  CodeGenOptions::SignReturnAddressKeyValue::BKey);
-else
-  Diags.Report(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << SignKey;
-  }
-}
-  }
-
-  Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
-
   Opts.KeepStaticConsts = Args.hasArg(OPT_fkeep_static_consts);
 
   Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
@@ -3347,6 +3315,40 @@
   Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
 
   Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags);
+
+  if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) {
+StringRef SignScope = A->getValue();
+
+if (SignScope.equals_lower("none"))
+  Opts.setSignReturnAddressScope(
+  LangOptions::SignReturnAddressScopeKind::None);
+else if (SignScope.equals_lower("all"))
+  Opts.setSignReturnAddressScope(
+  LangOptions::SignReturnAddressScopeKind::All);
+else if (SignScope.equals_lower("non-leaf"))
+  Opts.setSignReturnAddressScope(
+  LangOptions::SignReturnAddressScopeKind::NonLeaf);
+else
+  Diags.Report(diag::err_drv_invalid_value)
+  << A->getAsString(Args) << SignScope;
+
+if (Arg *A = Args.getLastArg(OPT_msign_return_address_key_EQ)) {
+  StringRef SignKey = A->getValue();
+  if (!SignScope.empty() && !SignKey.empty()) {
+if (SignKey.equals_lower("a_key"))
+  Opts.setSignReturnAddressKey(
+  LangOptions::SignReturnAddressKeyKind::AKey);
+else if (SignKey.equals_lower("b_key"))
+  Opts.setSignReturnAddressKey(
+  LangOptions::SignReturnAddressKeyKind::BKey);
+else
+  Diags.Report(diag::err_drv_invalid_value)
+  << A->getAsString(Args) << SignKey;
+  }
+}
+  }
+
+  Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5107,9 +5107,11 @@
 if (!FD)
   return;
 
-CodeGenOptions::SignReturnAddressScope Scope = CGM.getCodeGenOpts().getSignReturnAddress();
-CodeGenOptions::SignReturnAddressKeyValue Key = CGM.getCodeGenOpts().getSignReturnAddressKey();
-bool BranchTargetEnforcement = CGM.getCodeGenOpts().BranchTargetEnforcement;
+LangOptions::SignReturnAddressScopeKind Scope =
+CGM.getLangOpts().getSignReturnAddressScope();
+LangOptions::SignReturnAddressKeyKind Key =
+CGM.getLangOpts().getSignReturnAddressKey();
+bool BranchTargetEnforcement = CGM.getLangOpts().BranchTargetEnforcement;
 if (const auto *TA = FD->getAttr()) {
   ParsedTargetAttr Attr = TA->parse();
   if (!Attr.BranchProtection.empty()) {
@@ -5125,14 +5127,14 @@
 }
 
 auto *Fn = cast(GV);
-if (Scope != CodeGenOptions::SignReturnAddressScope::None) {
+   

[PATCH] D77148: [analyzer] ApiModeling: Add buffer size arg constraint with multiplier involved

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



Comment at: clang/test/Analysis/std-c-library-functions-arg-constraints.c:155
+  __buf_size_arg_constraint_mul(buf, s, sizeof(short));
+  clang_analyzer_eval(s * sizeof(short) <= 6); // \
+  // report-warning{{TRUE}} \

`s <= 3` is better here? We know that the buffer has space for 3 short's. But 
it is better to assume nothing about `sizeof(short)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77148



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


[clang-tools-extra] 43eca88 - Fix "control reaches end of non-void function" warning. NFCI.

2020-04-01 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-04-01T14:08:48+01:00
New Revision: 43eca880c6eda10fd191c4e9e04bf04830c9c6f2

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

LOG: Fix "control reaches end of non-void function" warning. NFCI.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 77b2cbce40d9..59af922d4005 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -520,6 +520,7 @@ llvm::StringRef toSemanticTokenType(HighlightingKind Kind) {
   case HighlightingKind::InactiveCode:
 return "comment";
   }
+  llvm_unreachable("unhandled HighlightingKind");
 }
 
 std::vector



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added a subscriber: rsandifo-arm.
sdesmalen added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

SjoerdMeijer wrote:
> sdesmalen wrote:
> > SjoerdMeijer wrote:
> > > Just curious about the `-fallow-half-arguments-and-returns`, do you need 
> > > that here?
> > > 
> > > And if not here, why do you need it elsewhere (looks enabled on all 
> > > tests)?
> > It's not needed for this test, but we've generated most of our tests from 
> > the ACLE spec and the tests that use a scalar float16_t (== __fp16) will 
> > need this, such as the ACLE intrinsic:
> > 
> >   svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);
> > 
> > If you feel strongly about it, I could remove it from the other RUN lines.
> Well, I think this is my surprise then. Thinking out loud: we're talking SVE 
> here, which always implies FP16. That's why I am surprised that we bother 
> with a storage-type only type. Looking at the SVE ACLE I indeed see:
> 
>   float16_t equivalent to __fp16
> 
> where I was probably expecting:
> 
>   float16_t equivalent to _Float16
> 
> and with that everything would be sorted I guess, then we also don't need the 
> hack^W workaround that is `-fallow-half-arguments-and-returns`. But maybe 
> there is a good reason to use/choose `__fp16` that I don't see here. Probably 
> worth a quick question for the ARM SVE ACLE, would you mind quickly checking?
> 
> 
As just checked with @rsandifo-arm, the reason is that the definition of 
`float16_t` has to be compatible with `arm_neon.h`, which uses `__fp16` for 
both Clang and GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D72581: [Syntax] Add mapping from spelled to expanded tokens for TokenBuffer

2020-04-01 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko marked 5 inline comments as done.
hlopko added a comment.

I'm submitting this patch at https://reviews.llvm.org/D77209 (with Ilya's 
permission). Let's continue the review there.




Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:228
+  /// multiple times and this function will return multiple results in those
+  /// cases. This happens when \p Spelled is inside a macro argument.
+  ///

sammccall wrote:
> Nit: move the FIXME up here? Documenting this justifies the signature, but 
> currently it *never* happens.
Done.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:248
+  llvm::SmallVector, 1>
+  expandedForSpelled(llvm::ArrayRef Spelled) const;
+

sammccall wrote:
> out of curiosity, do you have a motivating use for this function?
> 
> I think it's clear enough that it will be useful, completeness dictates it 
> should be here, and use cases aren't always the best way to think about 
> designing these libraries. But it'd help me understand some of the details 
> better.
Will ask Ilya offline.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:198
+TokenBuffer::expandedForSpelled(llvm::ArrayRef Spelled) const {
+  assert(!Spelled.empty());
+  assert(Spelled.front().location().isFileID());

sammccall wrote:
> This is a little surprising (vs returning `{}`). 
> 
> It seems plausible that you'll map file offsets -> spelled tokens -> expanded 
> tokens, and that the middle step might "accidentally" be empty. Caller can 
> always check, but why require them to here?
Done.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:205
+
+  auto &File = It->second;
+  assert(File.SpelledTokens.data() <= Spelled.data());

sammccall wrote:
> nit: mind spelling this type out? it's important, not particularly verbose, 
> and long-lived
Done.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:209
+
+  auto *FrontMapping = mappingStartingBeforeSpelled(File, &Spelled.front());
+  unsigned SpelledFrontI = &Spelled.front() - File.SpelledTokens.data();

sammccall wrote:
> This section could use some comments about how the index calculations relate 
> to high-level concepts.
> 
> AIUI the branches are: spelled token precedes all PP usage, spelled token is 
> transformed by PP (subcases: macro args and other PP usage), spelled token 
> follows PP usage.
> 
> The next section probably only needs to comment about the purpose of the 
> divergence (+1/End to refer to one-past the region of interest).
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72581



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


[PATCH] D77209: [Syntax] Add mapping from spelled to expanded tokens for TokenBuffer

2020-04-01 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko updated this revision to Diff 254188.
hlopko added a comment.

Adding comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77209

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -57,6 +57,7 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::Not;
 using ::testing::Pointee;
@@ -185,10 +186,14 @@
   template 
   llvm::ArrayRef findSubrange(llvm::ArrayRef Subrange,
  llvm::ArrayRef Range, Eq F) {
-for (auto Begin = Range.begin(); Begin < Range.end(); ++Begin) {
+assert(Subrange.size() >= 1);
+if (Range.size() < Subrange.size())
+  return llvm::makeArrayRef(Range.end(), Range.end());
+for (auto Begin = Range.begin(), Last = Range.end() - Subrange.size();
+ Begin <= Last; ++Begin) {
   auto It = Begin;
-  for (auto ItSub = Subrange.begin();
-   ItSub != Subrange.end() && It != Range.end(); ++ItSub, ++It) {
+  for (auto ItSub = Subrange.begin(); ItSub != Subrange.end();
+   ++ItSub, ++It) {
 if (!F(*ItSub, *It))
   goto continue_outer;
   }
@@ -889,4 +894,111 @@
   ASSERT_EQ(Code.points().size(), 8u);
 }
 
+TEST_F(TokenBufferTest, ExpandedBySpelled) {
+  recordTokens(R"cpp(
+a1 a2 a3 b1 b2
+  )cpp");
+  // Sanity check: expanded and spelled tokens are stored separately.
+  EXPECT_THAT(findExpanded("a1 a2"), Not(SameRange(findSpelled("a1 a2";
+  // Searching for subranges of expanded tokens should give the corresponding
+  // spelled ones.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1 a2 a3 b1 b2")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1 a2 a3")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("b1 b2")),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+
+  // Test search on simple macro expansions.
+  recordTokens(R"cpp(
+#define A a1 a2 a3
+#define B b1 b2
+
+A split B
+  )cpp");
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("A split B")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 split b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("A split").drop_back()),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("split B").drop_front()),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+
+  // Ranges not fully covering macro expansions should fail.
+  recordTokens(R"cpp(
+#define ID(x) x
+
+ID(a)
+  )cpp");
+  // Spelled don't cover entire mapping (missing ID token) -> empty result
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("( a )")), IsEmpty());
+  // Spelled don't cover entire mapping (missing ) token) -> empty result
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( a")), IsEmpty());
+
+  // Recursive macro invocations.
+  recordTokens(R"cpp(
+#define ID(x) x
+#define B b1 b2
+
+ID(ID(ID(a1) a2 a3)) split ID(B)
+  )cpp");
+
+  EXPECT_THAT(
+  Buffer.expandedForSpelled(findSpelled("ID ( ID ( ID ( a1 ) a2 a3 ) )")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( B )")),
+  ElementsAre(SameRange(findExpanded("b1 b2";
+  EXPECT_THAT(Buffer.expandedForSpelled(
+  findSpelled("ID ( ID ( ID ( a1 ) a2 a3 ) ) split ID ( B )")),
+  ElementsAre(SameRange(findExpanded("a1 a2 a3 split b1 b2";
+  // FIXME: these should succeed, but we do not support macro arguments yet.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("a1")), IsEmpty());
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( a1 ) a2")),
+  IsEmpty());
+
+  // Empty macro expansions.
+  recordTokens(R"cpp(
+#define EMPTY
+#define ID(X) X
+
+EMPTY EMPTY ID(1 2 3) EMPTY EMPTY split1
+EMPTY EMPTY ID(4 5 6) split2
+ID(7 8 9) EMPTY EMPTY
+  )cpp");
+  // Covered by empty expansions on one of both of the sides.
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 1 2 3 )")),
+  ElementsAre(SameRange(findExpanded("1 2 3";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 4 5 6 )")),
+  ElementsAre(SameRange(findExpanded("4 5 6";
+  EXPECT_THAT(Buffer.expandedForSpelled(findSpelled("ID ( 7 8 9 )")),
+  ElementsAre(SameRange(findExpanded("7 8 9";
+  // Including the em

[PATCH] D77148: [analyzer] ApiModeling: Add buffer size arg constraint with multiplier involved

2020-04-01 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/test/Analysis/std-c-library-functions-arg-constraints.c:155
+  __buf_size_arg_constraint_mul(buf, s, sizeof(short));
+  clang_analyzer_eval(s * sizeof(short) <= 6); // \
+  // report-warning{{TRUE}} \

balazske wrote:
> `s <= 3` is better here? We know that the buffer has space for 3 short's. But 
> it is better to assume nothing about `sizeof(short)`.
That would have been better if the range based constraint solver was able to 
solve the in-equation to `s`. So, even though the analyzer knows that `s * 2 <= 
6` it cannot reason about `s` itself. This is the limitation of the solver. I 
believe @baloghadamsoftware has a few patches that directs this deficiency: 
D49074 and D50256


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77148



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX

2020-04-01 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 254193.
ZarkoCA added a comment.

Fixed test cases that were breaking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76130

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix32-cc-abi-vaarg.ll
  llvm/test/CodeGen/PowerPC/aix64-cc-abi-vaarg.ll

Index: llvm/test/CodeGen/PowerPC/aix64-cc-abi-vaarg.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix64-cc-abi-vaarg.ll
@@ -0,0 +1,360 @@
+; RUN: llc -O2 -mtriple powerpc64-ibm-aix-xcoff -stop-after=machine-cp -verify-machineinstrs < %s | \
+; RUN: FileCheck --check-prefixes=CHECK,64BIT %s
+
+; RUN: llc -O2 -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \
+; RUN: -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefixes=CHECKASM,ASM64 %s
+
+  target datalayout = "E-m:e-i64:64-n32:64"
+  target triple = "powerpc64-ibm-aix-xcoff"
+  
+  define i32 @int_va_arg(i32 %a, ...) local_unnamed_addr  {
+  entry:
+%arg1 = alloca i8*, align 8
+%arg2 = alloca i8*, align 8
+%0 = bitcast i8** %arg1 to i8*
+call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0) 
+%1 = bitcast i8** %arg2 to i8*
+call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %1)
+call void @llvm.va_start(i8* nonnull %0)
+call void @llvm.va_copy(i8* nonnull %1, i8* nonnull %0)
+%2 = va_arg i8** %arg1, i32
+%add = add nsw i32 %2, %a
+%3 = va_arg i8** %arg2, i32
+%mul = shl i32 %3, 1
+%add3 = add nsw i32 %add, %mul
+call void @llvm.va_end(i8* nonnull %0)
+call void @llvm.va_end(i8* nonnull %1)
+call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %1) 
+call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0) 
+ret i32 %add3
+  }
+
+  declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) 
+  declare void @llvm.va_start(i8*) 
+  declare void @llvm.va_copy(i8*, i8*) 
+  declare void @llvm.va_end(i8*) 
+  declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) 
+  
+; 64BIT-LABEL:   name:int_va_arg
+; 64BIT-LABEL:   liveins:
+; 64BIT-DAG: - { reg: '$x3', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x4', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x5', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x6', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x7', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x8', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x9', virtual-reg: '' }
+; 64BIT-DAG: - { reg: '$x10', virtual-reg: '' }
+
+; 64BIT-LABEL:   fixedStack:
+; 64BIT-DAG: - { id: 0, type: default, offset: 56, size: 8
+
+; 64BIT-LABEL:   stack:
+; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8
+; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8 
+
+; 64BIT-LABEL:   body: |
+; 64BIT-DAG: bb.0.entry:
+; 64BIT-DAG: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10
+; 64BIT-DAG: STD killed renamable $x4, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0)
+; 64BIT-DAG: STD killed renamable $x5, 8, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 8)
+; 64BIT-DAG: STD killed renamable $x6, 16, %fixed-stack.0 :: (store 8)
+; 64BIT-DAG: STD killed renamable $x7, 24, %fixed-stack.0 :: (store 8)
+; 64BIT-DAG: STD killed renamable $x8, 32, %fixed-stack.0 :: (store 8)
+; 64BIT-DAG: STD killed renamable $x9, 40, %fixed-stack.0 :: (store 8)
+; 64BIT-DAG: STD killed renamable $x10, 48, %fixed-stack.0 :: (store 8)
+; 64BIT-DAG: renamable $x11 = ADDI8 %fixed-stack.0, 0
+; 64BIT-DAG: STD renamable $x11, 0, %stack.1.arg2 :: (store 8 into %ir.1)
+; 64BIT-DAG: renamable $x4 = LD 0, %stack.1.arg2 :: (load 8 from %ir.arg2)
+; 64BIT-DAG: renamable $x7 = ADDI8 renamable $x4, 4
+; 64BIT-DAG: renamable $x5 = ADDI8 %fixed-stack.0, 4
+; 64BIT-DAG: renamable $r6 = LWZ 0, %fixed-stack.0 :: (load 4 from %fixed-stack.0, align 8)
+; 64BIT-DAG: STD killed renamable $x11, 0, %stack.0.arg1 :: (store 8 into %ir.0)
+; 64BIT-DAG: STD killed renamable $x5, 0, %stack.0.arg1 :: (store 8 into %ir.arg1)
+; 64BIT-DAG: STD killed renamable $x7, 0, %stack.1.arg2 :: (store 8 into %ir.arg2)
+; 64BIT-DAG: renamable $r4 = LWZ 0, killed renamable $x4 :: (load 4)
+; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r6, renamable $r3, implicit killed $x3
+; 64BIT-DAG: renamable $r4 = RLWINM killed renamable $r4, 1, 0, 30
+; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, killed renamable $r4, implicit-def $x3
+; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $x3
+
+; ASM64-LABEL:   .int_va_arg:
+; ASM64-DAG: std 4, 56(1)
+; ASM64-DAG: addi 4, 1, 56
+; ASM64-DAG: std 4, -16(1)
+; ASM64-DAG: std 4, -8(1)
+; ASM64-DAG: ld 4, -16(1)
+; ASM64-DAG: std 5, 64(1)
+; ASM64-DAG: addi 5, 1, 60
+; ASM64-DAG: std 5, -8(1)
+;

[clang] e3033c0 - [llvm][clang][IFS] Enhancing the llvm-ifs yaml format for symbol lists.

2020-04-01 Thread Puyan Lotfi via cfe-commits

Author: Puyan Lotfi
Date: 2020-04-01T10:49:06-04:00
New Revision: e3033c0ce5517efddbf92a079ad1e0ca4868591f

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

LOG: [llvm][clang][IFS] Enhancing the llvm-ifs yaml format for symbol lists.

Prior to this change the clang interface stubs format resembled
something ending with a symbol list like this:

 Symbols:
   a: { Type: Func }

This was problematic because we didn't actually want a map format and
also because we didn't like that an empty symbol list required
"Symbols: {}". That is to say without the empty {} llvm-ifs would crash
on an empty list.

With this new format it is much more clear which field is the symbol
name, and instead the [] that is used to express an empty symbol vector
is optional, ie:

Symbols:
 - { Name: a, Type: Func }

or

Symbols: []

or

Symbols:

This further diverges the format from existing llvm-elftapi. This is a
good thing because although the format originally came from the same
place, they are not the same in any way.

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

Added: 
clang/test/InterfaceStubs/empty.c
llvm/test/tools/llvm-ifs/empty1.ifs
llvm/test/tools/llvm-ifs/empty2.ifs

Modified: 
clang/include/clang/Frontend/FrontendActions.h
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/test/InterfaceStubs/bad-format.cpp
clang/test/InterfaceStubs/blocks.c
clang/test/InterfaceStubs/class-template-partial-specialization.cpp
clang/test/InterfaceStubs/conflict-type.ifs
clang/test/InterfaceStubs/constructor-using-shadow.cpp
clang/test/InterfaceStubs/cxx-conversion.cpp
clang/test/InterfaceStubs/cxxdeduction-guide.cpp
clang/test/InterfaceStubs/driver-test3.c
clang/test/InterfaceStubs/func.ifs
clang/test/InterfaceStubs/hidden-class-inheritance.cpp
clang/test/InterfaceStubs/indirect-field-decl.cpp
clang/test/InterfaceStubs/inline.c
clang/test/InterfaceStubs/lambda.cpp
clang/test/InterfaceStubs/namespace-alias.cpp
clang/test/InterfaceStubs/namespace.cpp
clang/test/InterfaceStubs/non-type-template-parm-decl.cpp
clang/test/InterfaceStubs/object.c
clang/test/InterfaceStubs/object.ifs
clang/test/InterfaceStubs/ppc.cpp
clang/test/InterfaceStubs/template-constexpr.cpp
clang/test/InterfaceStubs/template-namespace-function.cpp
clang/test/InterfaceStubs/template-template-parm-decl.cpp
clang/test/InterfaceStubs/trycatch.cpp
clang/test/InterfaceStubs/unresolved-using-typename.cpp
clang/test/InterfaceStubs/usings.cpp
clang/test/InterfaceStubs/var-template-specialization-decl.cpp
clang/test/InterfaceStubs/weak.cpp
clang/test/InterfaceStubs/windows.cpp
llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
llvm/test/tools/llvm-ifs/conflict-header-format.ifs
llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
llvm/test/tools/llvm-ifs/conflict-header-version.ifs
llvm/test/tools/llvm-ifs/conflict-size.ifs
llvm/test/tools/llvm-ifs/conflict-type.ifs
llvm/test/tools/llvm-ifs/conflict-weak.ifs
llvm/test/tools/llvm-ifs/default-empty.ifs
llvm/test/tools/llvm-ifs/func.ifs
llvm/test/tools/llvm-ifs/ios-tbd.ifs
llvm/test/tools/llvm-ifs/macos-tbd.ifs
llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
llvm/test/tools/llvm-ifs/object.ifs
llvm/test/tools/llvm-ifs/strong.ifs
llvm/test/tools/llvm-ifs/tvos-tbd.ifs
llvm/test/tools/llvm-ifs/version-ok.ifs
llvm/test/tools/llvm-ifs/watchos-tbd.ifs
llvm/test/tools/llvm-ifs/weak-mismatch.ifs
llvm/test/tools/llvm-ifs/weak.ifs
llvm/tools/llvm-ifs/llvm-ifs.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendActions.h 
b/clang/include/clang/Frontend/FrontendActions.h
index 89ac20075fa4..9ca2bfda2138 100644
--- a/clang/include/clang/Frontend/FrontendActions.h
+++ b/clang/include/clang/Frontend/FrontendActions.h
@@ -119,17 +119,13 @@ class GenerateModuleAction : public ASTFrontendAction {
   bool hasASTFileSupport() const override { return false; }
 };
 
-class GenerateInterfaceStubAction : public ASTFrontendAction {
-protected:
-  TranslationUnitKind getTranslationUnitKind() override { return TU_Module; }
-
-  bool hasASTFileSupport() const override { return false; }
-};
-
-class GenerateInterfaceIfsExpV1Action : public GenerateInterfaceStubAction {
+class GenerateInterfaceStubsAction : public ASTFrontendAction {
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,

[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-04-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10019
+  return SetCGInfo(
+  new PPCAIX32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == 
"soft"));
 return SetCGInfo(

ZarkoCA wrote:
> jasonliu wrote:
> > Does AIX have soft Float? If not, do we want to always pass in 'false'? 
> Thanks, missed changing this.  I set it to hard.
I don't think `CodeGenOpts.FloatABI == "hard"` is what we want though. 
Currently it means if CodeGenOpts.FloatABI is really "hard", then it will pass 
in `true` for `SoftFloatABI` to indicate we are soft float ABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76360



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


[PATCH] D76979: [clang][llvm] Interface Stubs new yaml file format changes.

2020-04-01 Thread Puyan Lotfi 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 rGe3033c0ce551: [llvm][clang][IFS] Enhancing the llvm-ifs yaml 
format for symbol lists. (authored by plotfi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76979

Files:
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/blocks.c
  clang/test/InterfaceStubs/class-template-partial-specialization.cpp
  clang/test/InterfaceStubs/conflict-type.ifs
  clang/test/InterfaceStubs/constructor-using-shadow.cpp
  clang/test/InterfaceStubs/cxx-conversion.cpp
  clang/test/InterfaceStubs/cxxdeduction-guide.cpp
  clang/test/InterfaceStubs/driver-test3.c
  clang/test/InterfaceStubs/empty.c
  clang/test/InterfaceStubs/func.ifs
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/indirect-field-decl.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/lambda.cpp
  clang/test/InterfaceStubs/namespace-alias.cpp
  clang/test/InterfaceStubs/namespace.cpp
  clang/test/InterfaceStubs/non-type-template-parm-decl.cpp
  clang/test/InterfaceStubs/object.c
  clang/test/InterfaceStubs/object.ifs
  clang/test/InterfaceStubs/ppc.cpp
  clang/test/InterfaceStubs/template-constexpr.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/template-template-parm-decl.cpp
  clang/test/InterfaceStubs/trycatch.cpp
  clang/test/InterfaceStubs/unresolved-using-typename.cpp
  clang/test/InterfaceStubs/usings.cpp
  clang/test/InterfaceStubs/var-template-specialization-decl.cpp
  clang/test/InterfaceStubs/weak.cpp
  clang/test/InterfaceStubs/windows.cpp
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
  llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
  llvm/test/tools/llvm-ifs/conflict-header-format.ifs
  llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
  llvm/test/tools/llvm-ifs/conflict-header-version.ifs
  llvm/test/tools/llvm-ifs/conflict-size.ifs
  llvm/test/tools/llvm-ifs/conflict-type.ifs
  llvm/test/tools/llvm-ifs/conflict-weak.ifs
  llvm/test/tools/llvm-ifs/default-empty.ifs
  llvm/test/tools/llvm-ifs/empty1.ifs
  llvm/test/tools/llvm-ifs/empty2.ifs
  llvm/test/tools/llvm-ifs/func.ifs
  llvm/test/tools/llvm-ifs/ios-tbd.ifs
  llvm/test/tools/llvm-ifs/macos-tbd.ifs
  llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
  llvm/test/tools/llvm-ifs/object.ifs
  llvm/test/tools/llvm-ifs/strong.ifs
  llvm/test/tools/llvm-ifs/tvos-tbd.ifs
  llvm/test/tools/llvm-ifs/version-ok.ifs
  llvm/test/tools/llvm-ifs/watchos-tbd.ifs
  llvm/test/tools/llvm-ifs/weak-mismatch.ifs
  llvm/test/tools/llvm-ifs/weak.ifs
  llvm/tools/llvm-ifs/llvm-ifs.cpp

Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -26,6 +26,7 @@
 #include "llvm/TextAPI/MachO/TextAPIWriter.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace llvm::yaml;
@@ -34,8 +35,8 @@
 #define DEBUG_TYPE "llvm-ifs"
 
 namespace {
-const VersionTuple IFSVersionCurrent(1, 2);
-}
+const VersionTuple IFSVersionCurrent(2, 0);
+} // end anonymous namespace
 
 static cl::opt Action("action", cl::desc(""),
cl::value_desc("write-ifs | write-bin"),
@@ -76,6 +77,7 @@
 }
 
 struct IFSSymbol {
+  IFSSymbol() = default;
   IFSSymbol(std::string SymbolName) : Name(SymbolName) {}
   std::string Name;
   uint64_t Size;
@@ -85,6 +87,8 @@
   bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; }
 };
 
+LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
+
 namespace llvm {
 namespace yaml {
 /// YAML traits for IFSSymbolType.
@@ -124,6 +128,7 @@
 /// YAML traits for IFSSymbol.
 template <> struct MappingTraits {
   static void mapping(IO &IO, IFSSymbol &Symbol) {
+IO.mapRequired("Name", Symbol.Name);
 IO.mapRequired("Type", Symbol.Type);
 // The need for symbol size depends on the symbol type.
 if (Symbol.Type == IFSSymbolType::NoType)
@@ -140,20 +145,6 @@
   static const bool flow = true;
 };
 
-/// YAML traits for set of IFSSymbols.
-template <> struct CustomMappingTraits> {
-  static void inputOne(IO &IO, StringRef Key, std::set &Set) {
-std::string Name = Key.str();
-IFSSymbol Sym(Name);
-IO.mapRequired(Name.c_str(), Sym);
-Set.insert(Sym);
-  }
-
-  static void output(IO &IO, std::set &Set) {
-for (auto &Sym : Set)
-  IO.mapRequired(Sym.Name.c_str(), const_cast(Sym));
-  }
-};
 } // namespace yaml
 } // namespace l

[PATCH] D76790: [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

2020-04-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76790



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


[PATCH] D77219: UBSan ␇ runtime

2020-04-01 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
Herald added subscribers: Sanitizers, cfe-commits, ributzka, dexonsmith, 
jkorous, cryptoad, mgorny.
Herald added projects: clang, Sanitizers.
jfb edited the summary of this revision.

Yes, this is April 1st and the patch isn't particularly serious.

There is a ␇ UBSan runtime available. It is named in honor of Bell Labs (who
gave us the C programming language and Undefined Behavior), the ASCII "bell"
character (value `07`), and famed violinist Joshua Bell. It is not related to
the city of Bell in California. This runtime will emit sound, most traditionally
the terminal's bell sound, when undefined behavior occurs.

To use the minimal runtime, add `-fsanitize-bel-runtime` to the clang command
line options. For example, if you're used to compiling with
`-fsanitize=undefined`, you could enable the minimal runtime with
`-fsanitize=undefined -fsanitize-bel-runtime`.

When combined with `-fsanitize-recover=undefined`, the ␇ runtime will simply
chime on Undefined Behavior without killing the program for each chime. To avoid
Pavlovian effects, the ␇ runtime uses Advanced Compiler Techniques called
"heuristics" to avoid chiming too often at the same location.

On macOS, the ␇ runtime will helpfully announce what specific undefined behavior
you've encountered, and then taunt you.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77219

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/unsigned-overflow-bel.c
  clang/test/Driver/fsanitize.c
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/ubsan_bel/CMakeLists.txt
  compiler-rt/lib/ubsan_bel/ubsan.syms.extra
  compiler-rt/lib/ubsan_bel/ubsan_bel_handlers.cpp
  compiler-rt/test/ubsan_bel/CMakeLists.txt
  compiler-rt/test/ubsan_bel/TestCases/alignment-assumption.c
  compiler-rt/test/ubsan_bel/TestCases/implicit-integer-sign-change.c
  
compiler-rt/test/ubsan_bel/TestCases/implicit-signed-integer-truncation-or-sign-change.c
  compiler-rt/test/ubsan_bel/TestCases/implicit-signed-integer-truncation.c
  compiler-rt/test/ubsan_bel/TestCases/implicit-unsigned-integer-truncation.c
  compiler-rt/test/ubsan_bel/TestCases/nullptr-and-nonzero-offset.c
  compiler-rt/test/ubsan_bel/TestCases/recover-dedup-limit.cpp
  compiler-rt/test/ubsan_bel/TestCases/recover-dedup.cpp
  compiler-rt/test/ubsan_bel/TestCases/test-darwin-interface.c
  compiler-rt/test/ubsan_bel/TestCases/uadd-overflow.cpp
  compiler-rt/test/ubsan_bel/lit.common.cfg.py
  compiler-rt/test/ubsan_bel/lit.site.cfg.py.in

Index: compiler-rt/test/ubsan_bel/lit.site.cfg.py.in
===
--- /dev/null
+++ compiler-rt/test/ubsan_bel/lit.site.cfg.py.in
@@ -0,0 +1,11 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+# Tool-specific config options.
+config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@"
+config.target_arch = "@UBSAN_TEST_TARGET_ARCH@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg.py")
Index: compiler-rt/test/ubsan_bel/lit.common.cfg.py
===
--- /dev/null
+++ compiler-rt/test/ubsan_bel/lit.common.cfg.py
@@ -0,0 +1,40 @@
+# -*- Python -*-
+
+import os
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value == None:
+lit_config.fatal(
+  "No attribute %r in test configuration! You may need to run "
+  "tests from your build directory or add this attribute "
+  "to lit.site.cfg.py " % attr_name)
+  return attr_value
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+config.name = 'UBSan-Bel-' + config.target_arch
+
+def build_invocation(compile_flags):
+  return " " + " ".join([config.clang] + compile_flags) + " "
+
+target_cflags = [get_required_attr(config, "target_cflags")]
+clang_ubsan_cflags = ["-fsanitize-bel-runtime"] + target_cflags
+clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags
+
+# Define %clang and %clangxx substitutions to use in test RUN lines.
+config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
+config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cpp']
+
+# Check that the host supports UndefinedBehaviorSanitizerBel tests
+if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows
+  config.unsupported = True
+
+# Don't target x8

[clang-tools-extra] c6a65bb - clagn-tidy/doc: Add a link to readability-static-accessed-through-instance from readability-convert-member-functions-to-static

2020-04-01 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2020-04-01T17:01:48+02:00
New Revision: c6a65bb93f218dbdec98f51952a309afda5608ea

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

LOG: clagn-tidy/doc: Add a link to readability-static-accessed-through-instance 
from readability-convert-member-functions-to-static

Added: 


Modified: 

clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
index 891f6be63714..c2f05cf589ea 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
@@ -10,5 +10,5 @@ After applying modifications as suggested by the check, 
runnnig the check again
 might find more opportunities to mark member functions ``static``.
 
 After making a member function ``static``, you might want to run the check
-`readability-static-accessed-through-instance` to replace calls like
+`readability-static-accessed-through-instance 
`_ to replace calls like
 ``Instance.method()`` by ``Class::method()``.



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

sdesmalen wrote:
> SjoerdMeijer wrote:
> > sdesmalen wrote:
> > > SjoerdMeijer wrote:
> > > > Just curious about the `-fallow-half-arguments-and-returns`, do you 
> > > > need that here?
> > > > 
> > > > And if not here, why do you need it elsewhere (looks enabled on all 
> > > > tests)?
> > > It's not needed for this test, but we've generated most of our tests from 
> > > the ACLE spec and the tests that use a scalar float16_t (== __fp16) will 
> > > need this, such as the ACLE intrinsic:
> > > 
> > >   svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);
> > > 
> > > If you feel strongly about it, I could remove it from the other RUN lines.
> > Well, I think this is my surprise then. Thinking out loud: we're talking 
> > SVE here, which always implies FP16. That's why I am surprised that we 
> > bother with a storage-type only type. Looking at the SVE ACLE I indeed see:
> > 
> >   float16_t equivalent to __fp16
> > 
> > where I was probably expecting:
> > 
> >   float16_t equivalent to _Float16
> > 
> > and with that everything would be sorted I guess, then we also don't need 
> > the hack^W workaround that is `-fallow-half-arguments-and-returns`. But 
> > maybe there is a good reason to use/choose `__fp16` that I don't see here. 
> > Probably worth a quick question for the ARM SVE ACLE, would you mind 
> > quickly checking?
> > 
> > 
> As just checked with @rsandifo-arm, the reason is that the definition of 
> `float16_t` has to be compatible with `arm_neon.h`, which uses `__fp16` for 
> both Clang and GCC.
I was suspecting it was compatability reasons, but perhaps not with 
`arm_neon.h`. So what exactly does it mean to be compatible with arm_neon.h? I 
mean, put simply and naively, if you target SVE, you include arm_sve.h, and go 
from there. How does that interact with arm_neon.h and why can float16_t not be 
a proper half type? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D76130: [PPC][AIX] Implement variadic function handling in LowerFormalArguments_AIX

2020-04-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/aix32-cc-abi-vaarg.ll:8
+
+  target datalayout = "E-m:e-p:32:32-i64:64-n32"
+  target triple = "powerpc-ibm-aix-xcoff"

minor nit: I don't think these target datalayout and triple are necessary. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76130



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-04-01 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

After looking more closely at the code I think the issue is within 
hasLocalStorage() which is called in hasGlobalStorage(). My expectation would 
be that anything inside of function scope would be considered local but I'm not 
very certain.
Any thoughts on whether hasLocalStorage() should be modified or if I should 
change the check and use some more ad-hoc implementation, instead of 
hasGlobalStorage(), to determine if the variable is local or global?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D77221: [AVR] Rework MCU family detection to support more AVR MCUs

2020-04-01 Thread Vlastimil Labsky via Phabricator via cfe-commits
vlastik created this revision.
vlastik added a reviewer: dylanmckay.
Herald added subscribers: cfe-commits, Jim, hiraditya, mgorny.
Herald added a project: clang.

AVR port now supports only ATmega328.
This patch makes more MCUs work with clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77221

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Basic/Targets/AVR.h
  clang/lib/Driver/ToolChains/AVR.cpp
  llvm/include/llvm/Support/AVRTargetParser.h
  llvm/lib/Support/AVRTargetParser.cpp
  llvm/lib/Support/CMakeLists.txt

Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -54,6 +54,7 @@
 add_llvm_component_library(LLVMSupport
   AArch64TargetParser.cpp
   ABIBreak.cpp
+  AVRTargetParser.cpp
   ARMTargetParser.cpp
   AMDGPUMetadata.cpp
   APFloat.cpp
Index: llvm/lib/Support/AVRTargetParser.cpp
===
--- /dev/null
+++ llvm/lib/Support/AVRTargetParser.cpp
@@ -0,0 +1,317 @@
+//===-- AVRTargetParser - Parser for AVR target features *- 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
+//
+//===--===//
+//
+// This file implements a target parser to recognise AVR CPUs
+//
+//===--===//
+
+#include "llvm/Support/AVRTargetParser.h"
+
+#include "llvm/ADT/SmallVector.h"
+
+using namespace llvm;
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static constexpr AVR::MCUInfo AVRMcus[] = {
+{"avr1", "at90s1200", "__AVR_AT90S1200__"},
+{"avr1", "attiny11", "__AVR_ATtiny11__"},
+{"avr1", "attiny12", "__AVR_ATtiny12__"},
+{"avr1", "attiny15", "__AVR_ATtiny15__"},
+{"avr1", "attiny28", "__AVR_ATtiny28__"},
+{"avr2", "at90s2313", "__AVR_AT90S2313__"},
+{"avr2", "at90s2323", "__AVR_AT90S2323__"},
+{"avr2", "at90s2333", "__AVR_AT90S2333__"},
+{"avr2", "at90s2343", "__AVR_AT90S2343__"},
+{"avr2", "attiny22", "__AVR_ATtiny22__"},
+{"avr2", "attiny26", "__AVR_ATtiny26__"},
+{"avr25", "at86rf401", "__AVR_AT86RF401__"},
+{"avr2", "at90s4414", "__AVR_AT90S4414__"},
+{"avr2", "at90s4433", "__AVR_AT90S4433__"},
+{"avr2", "at90s4434", "__AVR_AT90S4434__"},
+{"avr2", "at90s8515", "__AVR_AT90S8515__"},
+{"avr2", "at90c8534", "__AVR_AT90c8534__"},
+{"avr2", "at90s8535", "__AVR_AT90S8535__"},
+{"avr25", "ata5272", "__AVR_ATA5272__"},
+{"avr25", "attiny13", "__AVR_ATtiny13__"},
+{"avr25", "attiny13a", "__AVR_ATtiny13A__"},
+{"avr25", "attiny2313", "__AVR_ATtiny2313__"},
+{"avr25", "attiny2313a", "__AVR_ATtiny2313A__"},
+{"avr25", "attiny24", "__AVR_ATtiny24__"},
+{"avr25", "attiny24a", "__AVR_ATtiny24A__"},
+{"avr25", "attiny4313", "__AVR_ATtiny4313__"},
+{"avr25", "attiny44", "__AVR_ATtiny44__"},
+{"avr25", "attiny44a", "__AVR_ATtiny44A__"},
+{"avr25", "attiny84", "__AVR_ATtiny84__"},
+{"avr25", "attiny84a", "__AVR_ATtiny84A__"},
+{"avr25", "attiny25", "__AVR_ATtiny25__"},
+{"avr25", "attiny45", "__AVR_ATtiny45__"},
+{"avr25", "attiny85", "__AVR_ATtiny85__"},
+{"avr25", "attiny261", "__AVR_ATtiny261__"},
+{"avr25", "attiny261a", "__AVR_ATtiny261A__"},
+{"avr25", "attiny461", "__AVR_ATtiny461__"},
+{"avr25", "attiny461a", "__AVR_ATtiny461A__"},
+{"avr25", "attiny861", "__AVR_ATtiny861__"},
+{"avr25", "attiny861a", "__AVR_ATtiny861A__"},
+{"avr25", "attiny87", "__AVR_ATtiny87__"},
+{"avr25", "attiny43u", "__AVR_ATtiny43U__"},
+{"avr25", "attiny48", "__AVR_ATtiny48__"},
+{"avr25", "attiny88", "__AVR_ATtiny88__"},
+{"avr25", "attiny828", "__AVR_ATtiny828__"},
+{"avr3", "at43usb355", "__AVR_AT43USB355__"},
+{"avr3", "at76c711", "__AVR_AT76C711__"},
+{"avr31", "atmega103", "__AVR_ATmega103__"},
+{"avr31", "at43usb320", "__AVR_AT43USB320__"},
+{"avr35", "attiny167", "__AVR_ATtiny167__"},
+{"avr35", "at90usb82", "__AVR_AT90USB82__"},
+{"avr35", "at90usb162", "__AVR_AT90USB162__"},
+{"avr35", "ata5505", "__AVR_ATA5505__"},
+{"avr35", "atmega8u2", "__AVR_ATmega8U2__"},
+{"avr35", "atmega16u2", "__AVR_ATmega16U2__"},
+{"avr35", "atmega32u2", "__AVR_ATmega32U2__"},
+{"avr35", "attiny1634", "__AVR_ATtiny1634__"},
+{"avr4", "atmega8", "__AVR_ATmega8__"},
+{"avr4", "ata6289", "__AVR_ATA6289__"},
+{"avr4", "atmega8a", "__AVR_ATmega8A__"},
+{"avr4", "ata6285", "__AVR_ATA6285__"},
+{"avr4", "ata6286", "__AVR_ATA6286__"},
+{"avr4", "atmega48", "__AVR_ATmega48__"},
+{"avr4", "atmega48a", "__AVR_ATmega48A__"},
+{"avr4", "atmega48pa", "__AVR_ATmega48PA__"},
+{"avr4

[clang] 3500cc8 - [analyzer] RetainCountChecker: Add a suppression for OSSymbols.

2020-04-01 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-04-01T18:16:44+03:00
New Revision: 3500cc8d891bb3825bb3275affe6db8b12f2f695

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

LOG: [analyzer] RetainCountChecker: Add a suppression for OSSymbols.

OSSymbol objects are particular XNU OSObjects that aren't really
reference-counted. Therefore you cannot do any harm by over- or
under-releasing them.

Added: 


Modified: 
clang/lib/Analysis/RetainSummaryManager.cpp
clang/test/Analysis/osobject-retain-release.cpp

Removed: 




diff  --git a/clang/lib/Analysis/RetainSummaryManager.cpp 
b/clang/lib/Analysis/RetainSummaryManager.cpp
index 00bc854a8804..9f45a8efe546 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -146,7 +146,9 @@ static bool isSubclass(const Decl *D,
 }
 
 static bool isOSObjectSubclass(const Decl *D) {
-  return D && isSubclass(D, "OSMetaClassBase");
+  // OSSymbols are particular OSObjects that are allocated globally
+  // and therefore aren't really refcounted, so we ignore them.
+  return D && isSubclass(D, "OSMetaClassBase") && !isSubclass(D, "OSSymbol");
 }
 
 static bool isOSObjectDynamicCast(StringRef S) {

diff  --git a/clang/test/Analysis/osobject-retain-release.cpp 
b/clang/test/Analysis/osobject-retain-release.cpp
index 41606a30c39f..d88349dcd807 100644
--- a/clang/test/Analysis/osobject-retain-release.cpp
+++ b/clang/test/Analysis/osobject-retain-release.cpp
@@ -53,6 +53,9 @@ struct MyArray : public OSArray {
   OSObject *generateObject(OSObject *input) override;
 };
 
+// These are never refcounted.
+struct OSSymbol : OSObject {};
+
 struct OtherStruct {
   static void doNothingToArray(OSArray *array);
   OtherStruct(OSArray *arr);
@@ -754,3 +757,10 @@ void test() {
   b(0);
 }
 } // namespace inherited_constructor_crash
+
+namespace ossymbol_suppression {
+OSSymbol *createSymbol();
+void test() {
+  OSSymbol *sym = createSymbol(); // no-warning
+}
+} // namespace ossymbol_suppression



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


[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-04-01 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 4 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10019
+  return SetCGInfo(
+  new PPCAIX32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == 
"soft"));
 return SetCGInfo(

jasonliu wrote:
> ZarkoCA wrote:
> > jasonliu wrote:
> > > Does AIX have soft Float? If not, do we want to always pass in 'false'? 
> > Thanks, missed changing this.  I set it to hard.
> I don't think `CodeGenOpts.FloatABI == "hard"` is what we want though. 
> Currently it means if CodeGenOpts.FloatABI is really "hard", then it will 
> pass in `true` for `SoftFloatABI` to indicate we are soft float ABI.
You're right. I wanted to keep the symmetry but that's not the correct thing to 
do. 


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

https://reviews.llvm.org/D76360



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-01 Thread Anna Thomas via Phabricator via cfe-commits
anna requested review of this revision.
anna added a comment.

fixed buildbot failure. see above comments and added testcase `test8`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-01 Thread Anna Thomas via Phabricator via cfe-commits
anna updated this revision to Diff 254213.
anna added a comment.
This revision is now accepted and ready to land.

whitelist valid return attributes and only add those. Added testcase for 
signext.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140

Files:
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/ret_attr_update.ll

Index: llvm/test/Transforms/Inline/ret_attr_update.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/ret_attr_update.ll
@@ -0,0 +1,223 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+; RUN: opt < %s -passes=always-inline -S | FileCheck %s
+
+declare i8* @foo(i8*) argmemonly nounwind
+
+define i8* @callee(i8 *%p) alwaysinline {
+; CHECK-LABEL: @callee(
+; CHECK-NEXT:[[R:%.*]] = call i8* @foo(i8* noalias [[P:%.*]])
+; CHECK-NEXT:ret i8* [[R]]
+;
+  %r = call i8* @foo(i8* noalias %p)
+  ret i8* %r
+}
+
+define i8* @caller(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call nonnull i8* @foo(i8* noalias [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee(i8* %gep)
+  ret i8* %p
+}
+
+declare void @llvm.experimental.guard(i1,...)
+; Cannot add nonnull attribute to foo
+; because the guard is a throwing call
+define internal i8* @callee_with_throwable(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %cond = icmp ne i8* %r, null
+  call void (i1, ...) @llvm.experimental.guard(i1 %cond) [ "deopt"() ]
+  ret i8* %r
+}
+
+declare i8* @bar(i8*) readonly nounwind
+; Here also we cannot add nonnull attribute to the call bar.
+define internal i8* @callee_with_explicit_control_flow(i8* %p) alwaysinline {
+  %r = call i8* @bar(i8* %p)
+  %cond = icmp ne i8* %r, null
+  br i1 %cond, label %ret, label %orig
+
+ret:
+  ret i8* %r
+
+orig:
+  ret i8* %p
+}
+
+define i8* @caller2(i8* %ptr, i64 %x, i1 %cond) {
+; CHECK-LABEL: @caller2(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I:%.*]] = icmp ne i8* [[R_I]], null
+; CHECK-NEXT:call void (i1, ...) @llvm.experimental.guard(i1 [[COND_I]]) [ "deopt"() ]
+; CHECK-NEXT:[[R_I1:%.*]] = call i8* @bar(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I2:%.*]] = icmp ne i8* [[R_I1]], null
+; CHECK-NEXT:br i1 [[COND_I2]], label [[RET_I:%.*]], label [[ORIG_I:%.*]]
+; CHECK:   ret.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT:%.*]]
+; CHECK:   orig.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT]]
+; CHECK:   callee_with_explicit_control_flow.exit:
+; CHECK-NEXT:[[Q3:%.*]] = phi i8* [ [[R_I1]], [[RET_I]] ], [ [[GEP]], [[ORIG_I]] ]
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[PRET:%.*]], label [[QRET:%.*]]
+; CHECK:   pret:
+; CHECK-NEXT:ret i8* [[R_I]]
+; CHECK:   qret:
+; CHECK-NEXT:ret i8* [[Q3]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee_with_throwable(i8* %gep)
+  %q = call nonnull i8* @callee_with_explicit_control_flow(i8* %gep)
+  br i1 %cond, label %pret, label %qret
+
+pret:
+  ret i8* %p
+
+qret:
+  ret i8* %q
+}
+
+define internal i8* @callee3(i8 *%p) alwaysinline {
+  %r = call noalias i8* @foo(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to the existing attributes on foo.
+define i8* @caller3(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller3(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call noalias dereferenceable_or_null(12) i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee3(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @inf_loop_call(i8*) nounwind
+; We cannot propagate attributes to foo because we do not know whether inf_loop_call
+; will return execution.
+define internal i8* @callee_with_sideeffect_callsite(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %v = call i8* @inf_loop_call(i8* %p)
+  ret i8* %r
+}
+
+; do not add deref attribute to foo
+define i8* @test4(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[V_I:%.*]] = call i8* @inf_loop_call(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee_with_sideeffect_callsite(i8* %gep)
+  ret i8* %p
+}

[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-04-01 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 254214.
ZarkoCA marked an inline comment as done.
ZarkoCA added a comment.

Set isSoftFloat to return false for AIX.


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

https://reviews.llvm.org/D76360

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-vararg.c
  clang/test/CodeGen/aix32-dwarf-error.c

Index: clang/test/CodeGen/aix32-dwarf-error.c
===
--- /dev/null
+++ clang/test/CodeGen/aix32-dwarf-error.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify -emit-llvm %s
+
+static unsigned char dwarf_reg_size_table[1024];
+
+int test() {
+  __builtin_init_dwarf_reg_size_table(dwarf_reg_size_table); //expected-error {{cannot compile this __builtin_init_dwarf_reg_size_table yet}}
+  return __builtin_dwarf_sp_column();
+}
Index: clang/test/CodeGen/aix-vararg.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vararg.c
@@ -0,0 +1,39 @@
+// REQUIRES: powerpc-registered-target
+// REQUIRES: asserts
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s --check-prefix=32BIT
+
+void aix_varg(int a, ...) {
+  __builtin_va_list arg;
+  __builtin_va_start(arg, a);
+  __builtin_va_list arg2;
+  __builtin_va_arg(arg, int);
+  __builtin_va_copy(arg2, arg);
+  __builtin_va_end(arg);
+  __builtin_va_end(arg2);
+}
+
+  // 32BIT:   define void @aix_varg(i32 %a, ...) #0 {
+  // 32BIT-NEXT:  entry:
+  // 32BIT-NEXT:%a.addr = alloca i32, align 4
+  // 32BIT-NEXT:%arg = alloca i8*, align 4
+  // 32BIT-NEXT:%arg2 = alloca i8*, align 4
+  // 32BIT-NEXT:store i32 %a, i32* %a.addr, align 4
+  // 32BIT-NEXT:%arg1 = bitcast i8** %arg to i8*
+  // 32BIT-NEXT:call void @llvm.va_start(i8* %arg1)
+  // 32BIT-NEXT:%argp.cur = load i8*, i8** %arg, align 4
+  // 32BIT-NEXT:%argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
+  // 32BIT-NEXT:store i8* %argp.next, i8** %arg, align 4
+  // 32BIT-NEXT:%0 = bitcast i8* %argp.cur to i32*
+  // 32BIT-NEXT:%1 = load i32, i32* %0, align 4
+  // 32BIT-NEXT:%2 = bitcast i8** %arg2 to i8*
+  // 32BIT-NEXT:%3 = bitcast i8** %arg to i8*
+  // 32BIT-NEXT:call void @llvm.va_copy(i8* %2, i8* %3)
+  // 32BIT-NEXT:%arg3 = bitcast i8** %arg to i8*
+  // 32BIT-NEXT:call void @llvm.va_end(i8* %arg3)
+  // 32BIT-NEXT:%arg24 = bitcast i8** %arg2 to i8*
+  // 32BIT-NEXT:call void @llvm.va_end(i8* %arg24)
+  // 32BIT-NEXT:ret void
+  // 32BIT-NEXT:  }
+  // 32BIT: declare void @llvm.va_start(i8*) #1
+  // 32BIT: declare void @llvm.va_copy(i8*, i8*) #1
+  // 32BIT: declare void @llvm.va_end(i8*) #1
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4173,14 +4173,15 @@
 
 // PowerPC-32
 namespace {
-/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
-class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
+/// PowerPC32ABIInfo - The 32-bit PowerPC ABI information, used by PowerPC ELF
+/// (SVR4), Darwin and AIX.
+class PowerPC32ABIInfo : public DefaultABIInfo {
   bool IsSoftFloatABI;
 
   CharUnits getParamTypeAlignment(QualType Ty) const;
 
 public:
-  PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, bool SoftFloatABI)
+  PowerPC32ABIInfo(CodeGen::CodeGenTypes &CGT, bool SoftFloatABI)
   : DefaultABIInfo(CGT), IsSoftFloatABI(SoftFloatABI) {}
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
@@ -4190,7 +4191,7 @@
 class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   PPC32TargetCodeGenInfo(CodeGenTypes &CGT, bool SoftFloatABI)
-  : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT, SoftFloatABI)) {}
+  : TargetCodeGenInfo(new PowerPC32ABIInfo(CGT, SoftFloatABI)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 // This is recovered from gcc output.
@@ -4200,9 +4201,22 @@
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
 };
+
+class PPCAIX32TargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  PPCAIX32TargetCodeGenInfo(CodeGenTypes &CGT, bool SoftFloatABI)
+  : TargetCodeGenInfo(new PowerPC32ABIInfo(CGT, SoftFloatABI)) {}
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+return 1; // r1 is the dedicated stack pointer
+  }
+
+  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override;
+};
 }
 
-CharUnits PPC32_SVR4_ABIInfo::getParamTypeAlignment(QualType Ty) const {
+CharUnits PowerPC32ABIInfo::getParamTypeAlignment(QualType Ty) const {
   // Complex types are passed just like their elements
   if (const ComplexType *CTy = Ty->

[PATCH] D77219: UBSan ␇ runtime

2020-04-01 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

Sorry but I don't think this can land until it has options for sending 
sanitizer output to Slack channels and SMS numbers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77219



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


[PATCH] D77222: [clangd] Fix an assertion crash in ReferenceFinder.

2020-04-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

The assertion is almost correct, but it fails on refs from non-preamble


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77222

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1121,6 +1121,30 @@
   }
 }
 
+TEST(FindReferences, MainFileReferencesOnly) {
+  llvm::StringRef Test =
+  R"cpp(
+void test() {
+  int [[fo^o]] = 1;
+  // refs not from main file should not be included.
+  #include "foo.inc"
+})cpp";
+
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  TU.AdditionalFiles["foo.inc"] = R"cpp(
+  foo = 3;
+)cpp";
+  auto AST = TU.build();
+
+  std::vector> ExpectedLocations;
+  for (const auto &R : Code.ranges())
+ExpectedLocations.push_back(RangeIs(R));
+  EXPECT_THAT(findReferences(AST, Code.point(), 0).References,
+  ElementsAreArray(ExpectedLocations))
+  << Test;
+}
+
 TEST(FindReferences, ExplicitSymbols) {
   const char *Tests[] = {
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -583,13 +583,11 @@
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override 
{
 assert(D->isCanonicalDecl() && "expect D to be a canonical declaration");
-if (!CanonicalTargets.count(D))
+const SourceManager &SM = AST.getSourceManager();
+if (!CanonicalTargets.count(D) || !isInsideMainFile(Loc, SM))
   return true;
 const auto &TB = AST.getTokens();
-const SourceManager &SM = AST.getSourceManager();
 Loc = SM.getFileLoc(Loc);
-// We are only traversing decls *inside* the main file, so this should 
hold.
-assert(isInsideMainFile(Loc, SM));
 if (const auto *Tok = TB.spelledTokenAt(Loc))
   References.push_back({*Tok, Roles});
 return true;


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1121,6 +1121,30 @@
   }
 }
 
+TEST(FindReferences, MainFileReferencesOnly) {
+  llvm::StringRef Test =
+  R"cpp(
+void test() {
+  int [[fo^o]] = 1;
+  // refs not from main file should not be included.
+  #include "foo.inc"
+})cpp";
+
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  TU.AdditionalFiles["foo.inc"] = R"cpp(
+  foo = 3;
+)cpp";
+  auto AST = TU.build();
+
+  std::vector> ExpectedLocations;
+  for (const auto &R : Code.ranges())
+ExpectedLocations.push_back(RangeIs(R));
+  EXPECT_THAT(findReferences(AST, Code.point(), 0).References,
+  ElementsAreArray(ExpectedLocations))
+  << Test;
+}
+
 TEST(FindReferences, ExplicitSymbols) {
   const char *Tests[] = {
   R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -583,13 +583,11 @@
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
 assert(D->isCanonicalDecl() && "expect D to be a canonical declaration");
-if (!CanonicalTargets.count(D))
+const SourceManager &SM = AST.getSourceManager();
+if (!CanonicalTargets.count(D) || !isInsideMainFile(Loc, SM))
   return true;
 const auto &TB = AST.getTokens();
-const SourceManager &SM = AST.getSourceManager();
 Loc = SM.getFileLoc(Loc);
-// We are only traversing decls *inside* the main file, so this should hold.
-assert(isInsideMainFile(Loc, SM));
 if (const auto *Tok = TB.spelledTokenAt(Loc))
   References.push_back({*Tok, Roles});
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

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

Thanks, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077



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


[PATCH] D70366: Add new 'flatten' LLVM attribute to fix clang's 'flatten' function attribute

2020-04-01 Thread LevitatingLion via Phabricator via cfe-commits
LevitatingLion updated this revision to Diff 254217.
LevitatingLion added a comment.
Herald added a reviewer: sstefan1.

I rebased my changes onto 49d00824bbb 
, renamed 
the attribute to 'alwaysinline_recursively', and added some more tests. The 
testcase 'highLevelStructure.3.2.ll' does not fail anymore, all regression 
tests pass.

Are there any more places where changes are required? I looked at the changes 
when other attributes were introduced and grep'd for 'Attribute::AlwaysInline' 
to find places which need handling of the new attribute.


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

https://reviews.llvm.org/D70366

Files:
  clang/lib/CodeGen/CGCall.cpp
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
  llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
  llvm/lib/Transforms/IPO/AlwaysInliner.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/IPO/PartialInlining.cpp
  llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/Inline/always-inline-recursively.ll

Index: llvm/test/Transforms/Inline/always-inline-recursively.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/always-inline-recursively.ll
@@ -0,0 +1,267 @@
+; RUN: opt < %s -inline-threshold=0 -inline -S | FileCheck %s
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+;
+; Ensure the threshold has no impact on these decisions.
+; RUN: opt < %s -inline-threshold=2000 -inline -S | FileCheck %s
+; RUN: opt < %s -inline-threshold=2000 -always-inline -S | FileCheck %s
+; RUN: opt < %s -inline-threshold=-2000 -inline -S | FileCheck %s
+; RUN: opt < %s -inline-threshold=-2000 -always-inline -S | FileCheck %s
+
+; In the tests involving recursive functions we call the external function and
+; continue recursion depending on the external variable, so that any recursion
+; conditions are opaque to the optimizer
+
+; Following tests are conducted, for annotating call-sites and function declarations:
+;   Test that a simple tree call-graph is inlined
+;   Test that functions marked noinline are not inlined
+;   Test that a recursive call is not inlined
+;   Test that an indirectly recursive call is inlined until a directly recursive call remains
+
+; External funcion not visible to the optimizer
+declare void @ext_func()
+; External variable not visible to the optimizer
+@ext_var = external global i32
+
+; Test that a simple tree call-graph is inlined
+; when annotating call-sites
+
+define void @test_calls_tree() {
+; CHECK-LABEL: @test_calls_tree() {
+  call void @test_calls_tree_1() alwaysinline_recursively
+; CHECK-NEXT: call void @ext_func() #1
+  call void @test_calls_tree_2() alwaysinline_recursively
+; CHECK-NEXT: call void @ext_func() #1
+; CHECK-NEXT: call void @ext_func() #1
+; CHECK-NEXT: call void @ext_func() #1
+  ret void
+; CHECK-NEXT: ret void
+}
+
+define void @test_calls_tree_1() {
+  call void @ext_func()
+  ret void
+}
+
+define void @test_calls_tree_2() {
+  call void @test_calls_tree_2_1()
+  call void @test_calls_tree_2_2()
+  call void @test_calls_tree_2_3()
+  ret void
+}
+
+define void @test_calls_tree_2_1() {
+call void @ext_func()
+ret void
+}
+
+define void @test_calls_tree_2_2() {
+call void @ext_func()
+ret void
+}
+
+define void @test_calls_tree_2_3() {
+call void @ext_func()
+ret void
+}
+
+; Test that functions marked noinline are not inlined
+; when annotating call-sites
+
+define void @test_calls_noinline() {
+; CHECK-LABEL: @test_calls_noinline() {
+  call void @test_calls_noinline_inlined() alwaysinline_recursively
+; CHECK-NEXT: call void @ext_func() #1
+  call void @test_calls_noinline_inlined2() alwaysinline_recursively
+; CHECK-NEXT: call void @test_calls_noinline_notinlined()
+  ret void
+; CHECK-NEXT: ret void
+}
+
+define void @test_calls_noinline_inlined() {
+  call void @ext_func()
+  ret void
+}
+
+define void @test_calls_noinline_inlined2() {
+  call void @test_calls_noinline_notinlined()
+  ret void
+}
+
+define void @test_calls_noinline_notinlined() noinline {
+call void @ext_func()
+ret void
+}
+
+; Test that a recursive call is not inlined
+; when annotating call-sites
+
+de

[clang] 153dadf - [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-04-01 Thread Arnold Schwaighofer via cfe-commits

Author: Arnold Schwaighofer
Date: 2020-04-01T08:55:56-07:00
New Revision: 153dadf3a3ca3c47f8c0fb718ec96616a05e42fd

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

LOG: [clang] CodeGen: Make getOrEmitProtocol public for Swift

Summary:
Swift would like to use clang's apis to emit protocol declarations.

This commits adds the public API:

```
 emitObjCProtocolObject(CodeGenModule &CGM, const ObjCProtocolDecl *p);
```

rdar://60888524

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/CodeGen/CodeGenABITypes.h
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp
clang/lib/CodeGen/CGObjCRuntime.h

Removed: 




diff  --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 31f0cea57232..5f4af7fd2a36 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -28,11 +28,12 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 
 namespace llvm {
-  class DataLayout;
-  class Module;
-  class Function;
-  class FunctionType;
-  class Type;
+class Constant;
+class DataLayout;
+class Module;
+class Function;
+class FunctionType;
+class Type;
 }
 
 namespace clang {
@@ -44,6 +45,7 @@ class CoverageSourceInfo;
 class DiagnosticsEngine;
 class HeaderSearchOptions;
 class ObjCMethodDecl;
+class ObjCProtocolDecl;
 class PreprocessorOptions;
 
 namespace CodeGen {
@@ -137,6 +139,13 @@ llvm::Function 
*getNonTrivialCStructDestructor(CodeGenModule &CGM,
CharUnits DstAlignment,
bool IsVolatile, QualType QT);
 
+/// Get a pointer to a protocol object for the given declaration, emitting it 
if
+/// it hasn't already been emitted in this translation unit. Note that the ABI
+/// for emitting a protocol reference in code (e.g. for a protocol expression)
+/// in most runtimes is not as simple as just materializing a pointer to this
+/// object.
+llvm::Constant *emitObjCProtocolObject(CodeGenModule &CGM,
+   const ObjCProtocolDecl *p);
 }  // end namespace CodeGen
 }  // end namespace clang
 

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index db78309e9fd9..35b926808492 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -617,6 +617,13 @@ class CGObjCGNU : public CGObjCRuntime {
   llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
const ObjCProtocolDecl *PD) override;
   void GenerateProtocol(const ObjCProtocolDecl *PD) override;
+
+  virtual llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD);
+
+  llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) override {
+return GenerateProtocolRef(PD);
+  }
+
   llvm::Function *ModuleInitFunction() override;
   llvm::FunctionCallee GetPropertyGetFunction() override;
   llvm::FunctionCallee GetPropertySetFunction() override;
@@ -1348,7 +1355,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   void GenerateProtocol(const ObjCProtocolDecl *PD) override {
 // Do nothing - we only emit referenced protocols.
   }
-  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) {
+  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) override {
 std::string ProtocolName = PD->getNameAsString();
 auto *&Protocol = ExistingProtocols[ProtocolName];
 if (Protocol)
@@ -3039,13 +3046,18 @@ CGObjCGNU::GenerateProtocolList(ArrayRef 
Protocols) {
 
 llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
 const ObjCProtocolDecl *PD) {
+  auto protocol = GenerateProtocolRef(PD);
+  llvm::Type *T =
+  CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
+  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+}
+
+llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) {
   llvm::Constant *&protocol = ExistingProtocols[PD->getNameAsString()];
   if (!protocol)
 GenerateProtocol(PD);
   assert(protocol && "Unknown protocol");
-  llvm::Type *T =
-CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
-  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+  return protocol;
 }
 
 llvm::Constant *

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 87fd51b5d8b1..3986310eaa70 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1107,11 +1107,6 @@ class CGObjCCommonMac : public CodeGen::CGObjCRuntime {
 
   void GeneratePr

[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

SjoerdMeijer wrote:
> sdesmalen wrote:
> > SjoerdMeijer wrote:
> > > sdesmalen wrote:
> > > > SjoerdMeijer wrote:
> > > > > Just curious about the `-fallow-half-arguments-and-returns`, do you 
> > > > > need that here?
> > > > > 
> > > > > And if not here, why do you need it elsewhere (looks enabled on all 
> > > > > tests)?
> > > > It's not needed for this test, but we've generated most of our tests 
> > > > from the ACLE spec and the tests that use a scalar float16_t (== 
> > > > __fp16) will need this, such as the ACLE intrinsic:
> > > > 
> > > >   svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);
> > > > 
> > > > If you feel strongly about it, I could remove it from the other RUN 
> > > > lines.
> > > Well, I think this is my surprise then. Thinking out loud: we're talking 
> > > SVE here, which always implies FP16. That's why I am surprised that we 
> > > bother with a storage-type only type. Looking at the SVE ACLE I indeed 
> > > see:
> > > 
> > >   float16_t equivalent to __fp16
> > > 
> > > where I was probably expecting:
> > > 
> > >   float16_t equivalent to _Float16
> > > 
> > > and with that everything would be sorted I guess, then we also don't need 
> > > the hack^W workaround that is `-fallow-half-arguments-and-returns`. But 
> > > maybe there is a good reason to use/choose `__fp16` that I don't see 
> > > here. Probably worth a quick question for the ARM SVE ACLE, would you 
> > > mind quickly checking?
> > > 
> > > 
> > As just checked with @rsandifo-arm, the reason is that the definition of 
> > `float16_t` has to be compatible with `arm_neon.h`, which uses `__fp16` for 
> > both Clang and GCC.
> I was suspecting it was compatability reasons, but perhaps not with 
> `arm_neon.h`. So what exactly does it mean to be compatible with arm_neon.h? 
> I mean, put simply and naively, if you target SVE, you include arm_sve.h, and 
> go from there. How does that interact with arm_neon.h and why can float16_t 
> not be a proper half type? 
If you target SVE, you can still use Neon instructions, so it's still possible 
to include arm_neon.h as well. If those have differing definitions of 
float16_t, that may give trouble when using builtins from both the Neon and SVE 
header files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D77219: UBSan ␇ runtime

2020-04-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: compiler-rt/lib/ubsan_bel/ubsan_bel_handlers.cpp:40-42
+static std::random_device r;
+static std::default_random_engine e(r());
+static std::uniform_int_distribution d(0, sizeof(quips) / 
sizeof(quips[0]) - 1);

I'm not sure we should be introducing randomness into UB handler.
I think what this instead should do, is attach gdb to the process and fix the 
UB-invoking instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77219



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


[PATCH] D77077: [clang] CodeGen: Make getOrEmitProtocol public for Swift

2020-04-01 Thread Arnold Schwaighofer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG153dadf3a3ca: [clang] CodeGen: Make getOrEmitProtocol public 
for Swift (authored by aschwaighofer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77077

Files:
  clang/include/clang/CodeGen/CodeGenABITypes.h
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/CGObjCRuntime.h

Index: clang/lib/CodeGen/CGObjCRuntime.h
===
--- clang/lib/CodeGen/CGObjCRuntime.h
+++ clang/lib/CodeGen/CGObjCRuntime.h
@@ -211,6 +211,11 @@
   /// implementations.
   virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0;
 
+  /// GetOrEmitProtocol - Get the protocol object for the given
+  /// declaration, emitting it if necessary. The return value has type
+  /// ProtocolPtrTy.
+  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
+
   /// Generate a function preamble for a method with the specified
   /// types.
 
Index: clang/lib/CodeGen/CGObjCRuntime.cpp
===
--- clang/lib/CodeGen/CGObjCRuntime.cpp
+++ clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -13,14 +13,15 @@
 //===--===//
 
 #include "CGObjCRuntime.h"
-#include "CGCleanup.h"
 #include "CGCXXABI.h"
+#include "CGCleanup.h"
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
@@ -383,3 +384,9 @@
 CGM.getTypes().GetFunctionType(argsInfo)->getPointerTo();
   return MessageSendInfo(argsInfo, signatureType);
 }
+
+llvm::Constant *
+clang::CodeGen::emitObjCProtocolObject(CodeGenModule &CGM,
+   const ObjCProtocolDecl *protocol) {
+  return CGM.getObjCRuntime().GetOrEmitProtocol(protocol);
+}
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1107,11 +1107,6 @@
 
   void GenerateProtocol(const ObjCProtocolDecl *PD) override;
 
-  /// GetOrEmitProtocol - Get the protocol object for the given
-  /// declaration, emitting it if necessary. The return value has type
-  /// ProtocolPtrTy.
-  virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD)=0;
-
   /// GetOrEmitProtocolRef - Get a forward reference to the protocol
   /// object for the given declaration, emitting it if needed. These
   /// forward references will be filled in with empty bodies if no
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -617,6 +617,13 @@
   llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
const ObjCProtocolDecl *PD) override;
   void GenerateProtocol(const ObjCProtocolDecl *PD) override;
+
+  virtual llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD);
+
+  llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) override {
+return GenerateProtocolRef(PD);
+  }
+
   llvm::Function *ModuleInitFunction() override;
   llvm::FunctionCallee GetPropertyGetFunction() override;
   llvm::FunctionCallee GetPropertySetFunction() override;
@@ -1348,7 +1355,7 @@
   void GenerateProtocol(const ObjCProtocolDecl *PD) override {
 // Do nothing - we only emit referenced protocols.
   }
-  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) {
+  llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) override {
 std::string ProtocolName = PD->getNameAsString();
 auto *&Protocol = ExistingProtocols[ProtocolName];
 if (Protocol)
@@ -3039,13 +3046,18 @@
 
 llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
 const ObjCProtocolDecl *PD) {
+  auto protocol = GenerateProtocolRef(PD);
+  llvm::Type *T =
+  CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
+  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+}
+
+llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) {
   llvm::Constant *&protocol = ExistingProtocols[PD->getNameAsString()];
   if (!protocol)
 GenerateProtocol(PD);
   assert(protocol && "Unknown protocol");
-  llvm::Type *T =
-CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
-  return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
+  return protocol;
 }
 
 llvm::Constant *
Index: clang/include/clang/CodeGen/CodeGenA

[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-01 Thread Anna Thomas via Phabricator via cfe-commits
anna updated this revision to Diff 254222.
anna added a comment.

fixed missing code left out during rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140

Files:
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/ret_attr_update.ll

Index: llvm/test/Transforms/Inline/ret_attr_update.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/ret_attr_update.ll
@@ -0,0 +1,223 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+; RUN: opt < %s -passes=always-inline -S | FileCheck %s
+
+declare i8* @foo(i8*) argmemonly nounwind
+
+define i8* @callee(i8 *%p) alwaysinline {
+; CHECK-LABEL: @callee(
+; CHECK-NEXT:[[R:%.*]] = call i8* @foo(i8* noalias [[P:%.*]])
+; CHECK-NEXT:ret i8* [[R]]
+;
+  %r = call i8* @foo(i8* noalias %p)
+  ret i8* %r
+}
+
+define i8* @caller(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call nonnull i8* @foo(i8* noalias [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee(i8* %gep)
+  ret i8* %p
+}
+
+declare void @llvm.experimental.guard(i1,...)
+; Cannot add nonnull attribute to foo
+; because the guard is a throwing call
+define internal i8* @callee_with_throwable(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %cond = icmp ne i8* %r, null
+  call void (i1, ...) @llvm.experimental.guard(i1 %cond) [ "deopt"() ]
+  ret i8* %r
+}
+
+declare i8* @bar(i8*) readonly nounwind
+; Here also we cannot add nonnull attribute to the call bar.
+define internal i8* @callee_with_explicit_control_flow(i8* %p) alwaysinline {
+  %r = call i8* @bar(i8* %p)
+  %cond = icmp ne i8* %r, null
+  br i1 %cond, label %ret, label %orig
+
+ret:
+  ret i8* %r
+
+orig:
+  ret i8* %p
+}
+
+define i8* @caller2(i8* %ptr, i64 %x, i1 %cond) {
+; CHECK-LABEL: @caller2(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I:%.*]] = icmp ne i8* [[R_I]], null
+; CHECK-NEXT:call void (i1, ...) @llvm.experimental.guard(i1 [[COND_I]]) [ "deopt"() ]
+; CHECK-NEXT:[[R_I1:%.*]] = call i8* @bar(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I2:%.*]] = icmp ne i8* [[R_I1]], null
+; CHECK-NEXT:br i1 [[COND_I2]], label [[RET_I:%.*]], label [[ORIG_I:%.*]]
+; CHECK:   ret.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT:%.*]]
+; CHECK:   orig.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT]]
+; CHECK:   callee_with_explicit_control_flow.exit:
+; CHECK-NEXT:[[Q3:%.*]] = phi i8* [ [[R_I1]], [[RET_I]] ], [ [[GEP]], [[ORIG_I]] ]
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[PRET:%.*]], label [[QRET:%.*]]
+; CHECK:   pret:
+; CHECK-NEXT:ret i8* [[R_I]]
+; CHECK:   qret:
+; CHECK-NEXT:ret i8* [[Q3]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee_with_throwable(i8* %gep)
+  %q = call nonnull i8* @callee_with_explicit_control_flow(i8* %gep)
+  br i1 %cond, label %pret, label %qret
+
+pret:
+  ret i8* %p
+
+qret:
+  ret i8* %q
+}
+
+define internal i8* @callee3(i8 *%p) alwaysinline {
+  %r = call noalias i8* @foo(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to the existing attributes on foo.
+define i8* @caller3(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller3(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call noalias dereferenceable_or_null(12) i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee3(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @inf_loop_call(i8*) nounwind
+; We cannot propagate attributes to foo because we do not know whether inf_loop_call
+; will return execution.
+define internal i8* @callee_with_sideeffect_callsite(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %v = call i8* @inf_loop_call(i8* %p)
+  ret i8* %r
+}
+
+; do not add deref attribute to foo
+define i8* @test4(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[V_I:%.*]] = call i8* @inf_loop_call(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee_with_sideeffect_callsite(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @baz(i8*) nounwind readonly
+define internal i8* @callee5(i8* %p) alwaysin

[PATCH] D77225: [clangd] Support textDocument/semanticTokens/edits

2020-04-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, mgrang, 
jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

This returns incremental highlights as a set of edits against the
previous highlights.

Server-side, we compute the full set of highlights, this just saves
wire-format size.

For now, the diff used is trivial: everything from the first change to
the last change is sent as a single edit.

The wire format is grungy - the replacement offset/length refer to
positions in the encoded array instead of the logical list of tokens.
We use token-oriented structs and translating to LSP forms when serializing.
This departs from LSP (but is consistent with semanticTokens today).

Tested in VSCode insiders (with a patched client to enable experimental
features).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77225

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -14,8 +14,10 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include 
 
@@ -23,6 +25,9 @@
 namespace clangd {
 namespace {
 
+using testing::IsEmpty;
+using testing::SizeIs;
+
 MATCHER_P(LineNumber, L, "") { return arg.Line == L; }
 MATCHER(EmptyHighlightings, "") { return arg.Tokens.empty(); }
 
@@ -720,25 +725,29 @@
   ASSERT_EQ(Counter.Count, 1);
 }
 
+// Ranges are highlighted as variables, unless highlighted as $Function etc.
+std::vector tokens(llvm::StringRef MarkedText) {
+  Annotations A(MarkedText);
+  std::vector Results;
+  for (const Range& R : A.ranges())
+Results.push_back({HighlightingKind::Variable, R});
+  for (unsigned I = 0; I < static_cast(HighlightingKind::LastKind); ++I) {
+HighlightingKind Kind = static_cast(I);
+for (const Range& R : A.ranges(llvm::to_string(Kind)))
+  Results.push_back({Kind, R});
+  }
+  llvm::sort(Results);
+  return Results;
+}
+
 TEST(SemanticHighlighting, toSemanticTokens) {
-  auto CreatePosition = [](int Line, int Character) -> Position {
-Position Pos;
-Pos.line = Line;
-Pos.character = Character;
-return Pos;
-  };
+  auto Results = toSemanticTokens(tokens(R"(
+ [[blah]]
 
-  std::vector Tokens = {
-  {HighlightingKind::Variable,
-   Range{CreatePosition(1, 1), CreatePosition(1, 5)}},
-  {HighlightingKind::Function,
-   Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
-  {HighlightingKind::Variable,
-   Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
-  };
+$Function[[big]] [[bang]]
+  )"));
 
-  std::vector Results = toSemanticTokens(Tokens);
-  EXPECT_EQ(Tokens.size(), Results.size());
+  ASSERT_THAT(Results, SizeIs(3));
   EXPECT_EQ(Results[0].tokenType, unsigned(HighlightingKind::Variable));
   EXPECT_EQ(Results[0].deltaLine, 1u);
   EXPECT_EQ(Results[0].deltaStart, 1u);
@@ -755,6 +764,38 @@
   EXPECT_EQ(Results[2].length, 4u);
 }
 
+TEST(SemanticHighlighting, diffSemanticTokens) {
+  auto Before = toSemanticTokens(tokens(R"(
+[[foo]] [[bar]] [[baz]]
+[[one]] [[two]] [[three]]
+  )"));
+  EXPECT_THAT(diffTokens(Before, Before), IsEmpty());
+
+  auto After = toSemanticTokens(tokens(R"(
+[[foo]] [[hello]] [[world]] [[baz]]
+[[one]] [[two]] [[three]]
+  )"));
+
+  // Replace [bar, baz] with [hello, world, baz]
+  auto Diff = diffTokens(Before, After);
+  ASSERT_THAT(Diff, SizeIs(1));
+  EXPECT_EQ(1u, Diff.front().startToken);
+  EXPECT_EQ(2u, Diff.front().deleteTokens);
+  ASSERT_THAT(Diff.front().tokens, SizeIs(3));
+  // hello
+  EXPECT_EQ(0u, Diff.front().tokens[0].deltaLine);
+  EXPECT_EQ(4u, Diff.front().tokens[0].deltaStart);
+  EXPECT_EQ(5u, Diff.front().tokens[0].length);
+  // world
+  EXPECT_EQ(0u, Diff.front().tokens[1].deltaLine);
+  EXPECT_EQ(6u, Diff.front().tokens[1].deltaStart);
+  EXPECT_EQ(5u, Diff.front().tokens[1].length);
+  // baz
+  EXPECT_EQ(0u, Diff.front().tokens[2].deltaLine);
+  EXPECT_EQ(6u, Diff.front().tokens[2].deltaStart);
+  EXPECT_EQ(3u, Diff.front().tokens[2].length);
+}
+
 TEST(SemanticHighlighting, toTheiaSemanticHighlightingInformation) {
   auto CreatePosition = [](int Line, int Character) -> 

[PATCH] D77062: [analyzer] Added check for unaccaptable equality operation between Loc and NonLoc types

2020-04-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 254225.
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Reworked solution. Simplified CStringChecker::assumeZero. 
Added test (taken from the bug).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77062

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/string.c


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void* func_strcpy_no_assertion();
+char*** ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned 
char*)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -266,13 +266,16 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
+  // LazyCompoundVal cannot be handled by assume
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val && !V.getAs()) {
+// return pair shall be {null, non-null} so reorder states
+std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void* func_strcpy_no_assertion();
+char*** ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char*)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -266,13 +266,16 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
+  // LazyCompoundVal cannot be handled by assume
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val && !V.getAs()) {
+// return pair shall be {null, non-null} so reorder states
+std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77219: UBSan ␇ runtime

2020-04-01 Thread JF Bastien via Phabricator via cfe-commits
jfb marked an inline comment as done.
jfb added inline comments.



Comment at: compiler-rt/lib/ubsan_bel/ubsan_bel_handlers.cpp:40-42
+static std::random_device r;
+static std::default_random_engine e(r());
+static std::uniform_int_distribution d(0, sizeof(quips) / 
sizeof(quips[0]) - 1);

lebedev.ri wrote:
> I'm not sure we should be introducing randomness into UB handler.
> I think what this instead should do, is attach gdb to the process and fix the 
> UB-invoking instructions.
Hmm, should it be sudo-random to ensure that `rm -rf /` works?

What is gdb? Is it like lldb but not as low-level?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77219



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Trying to help Melanie respond to the comments, so I ran through the patch and 
came up with the following comments/responses.  Sorry for the 'surprise hit' :)




Comment at: clang/include/clang/AST/Expr.h:3474
+  static unsigned sizeOfTrailingObjects(bool hasFP, bool isCompound) {
+return (hasFP ? 1 : 0) * sizeof(unsigned) +
+   (isCompound ? 2 : 0) * sizeof(QualType);

rjmccall wrote:
> Sorry, I wasn't trying to say you need this here!  Since you can use 
> TrailingObjects for BinaryOperator, you absolutely should take advantage of 
> what it does.   I was just pointing you at the CallExpr stuff so that you can 
> see the places you'll need to update when you add this storage to CallExpr.
Yep, this shouldn't be necessary.  Uses of this should be able to use 
totalSizeToAlloc and additionalSizeToAlloc.



Comment at: clang/include/clang/AST/Expr.h:3674
+
+  void setHasFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
+  bool hasFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }

Since changing this value can result in a change of allocation size, I don't 
think this should be settable after creation.



Comment at: clang/include/clang/AST/Expr.h:3680
+  }
+  FPOptions getFPFeatures(const ASTContext &C) const {
+if (hasFPFeatures())

Whats the purpose of having both of these?  It seems that you can either: 1- 
Have only the first and require consumers to check if they aren't sure, or 2- 
Only do the second, and those who have checked just get the default anyway.



Comment at: clang/include/clang/AST/Expr.h:3739
 
-  BinaryOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
-BinaryOperatorBits.Opc = BO_MulAssign;
-  }
-};
-
-/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
-/// track of the type the operation is performed in.  Due to the semantics of
-/// these operators, the operands are promoted, the arithmetic performed, an
-/// implicit conversion back to the result type done, then the assignment takes
-/// place.  This captures the intermediate type which the computation is done
-/// in.
-class CompoundAssignOperator : public BinaryOperator {
-  QualType ComputationLHSType;
-  QualType ComputationResultType;
-public:
-  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResType,
- ExprValueKind VK, ExprObjectKind OK,
- QualType CompLHSType, QualType CompResultType,
- SourceLocation OpLoc, FPOptions FPFeatures)
-: BinaryOperator(lhs, rhs, opc, ResType, VK, OK, OpLoc, FPFeatures,
- true),
-  ComputationLHSType(CompLHSType),
-  ComputationResultType(CompResultType) {
-assert(isCompoundAssignmentOp() &&
-   "Only should be used for compound assignments");
-  }
-
-  /// Build an empty compound assignment operator expression.
-  explicit CompoundAssignOperator(EmptyShell Empty)
-: BinaryOperator(CompoundAssignOperatorClass, Empty) { }
-
-  // The two computation types are the type the LHS is converted
-  // to for the computation and the type of the result; the two are
-  // distinct in a few cases (specifically, int+=ptr and ptr-=ptr).
-  QualType getComputationLHSType() const { return ComputationLHSType; }
-  void setComputationLHSType(QualType T) { ComputationLHSType = T; }
-
-  QualType getComputationResultType() const { return ComputationResultType; }
-  void setComputationResultType(QualType T) { ComputationResultType = T; }
-
-  static bool classof(const Stmt *S) {
-return S->getStmtClass() == CompoundAssignOperatorClass;
+  BinaryOperator(EmptyShell Empty, unsigned hasFPFeatures, unsigned isCompound)
+  : Expr(BinaryOperatorClass, Empty) {

Nit, I'd prefer this be named 'isCompoundAssignment'.  Also, the patch seems a 
little inconsistent with FPFeatures vs FPOptions.



Comment at: clang/include/clang/AST/StmtVisitor.h:146
+  RetTy VisitBin##NAME(PTR(BinaryOperator) S, ParamTys... P) { 
\
+DISPATCH(BinAssign, BinaryOperator);   
\
   }

rjmccall wrote:
> Comment needs updating, but more importantly, you're making all of these fall 
> back on `VisitBinAssign`, which is definitely not correct.
@rjmccall : What would you think fits better?  If we don't have something like 
this, VisitBinaryOperator is going to have to redirect to VisitBinAssign 
anyway.  We could presumably keep VisitCompoundAssignOperator, but that seems 
like a naming difference.



Comment at: clang/include/clang/Basic/LangOptions.h:385
+  static FPOptions defaultWithoutTrailingStorage() {
+FPOptions result;
+return result;

Nit: return {}; ?  

Also, why are there two versions of this?  It seems that the ASTContext one 
should be the 

[clang] 6593360 - AMDGPU: Fix consistently backwards logic for default denormal mode

2020-04-01 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-04-01T12:36:22-04:00
New Revision: 6593360ee760c0c98cf7fb05be70aa4ea455a42a

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

LOG: AMDGPU: Fix consistently backwards logic for default denormal mode

I forgot to squash this into c9d65a48af1d7bbfed7e785613cc9d9acf71821b

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e6a5af99b203..2cec0dc9de22 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -109,11 +109,10 @@ bool AMDGPUToolChain::getDefaultDenormsAreZeroForTarget(
 
   // Default to enabling f32 denormals by default on subtargets where fma is
   // fast with denormals
-  const bool DefaultDenormsAreZeroForTarget =
+  const bool BothDenormAndFMAFast =
   (ArchAttr & llvm::AMDGPU::FEATURE_FAST_FMA_F32) &&
   (ArchAttr & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
-
-  return DefaultDenormsAreZeroForTarget;
+  return !BothDenormAndFMAFast;
 }
 
 llvm::DenormalMode AMDGPUToolChain::getDefaultDenormalModeForType(
@@ -137,7 +136,7 @@ llvm::DenormalMode 
AMDGPUToolChain::getDefaultDenormalModeForType(
   // TODO: There are way too many flags that change this. Do we need to check
   // them all?
   bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
- !getDefaultDenormsAreZeroForTarget(Kind);
+ getDefaultDenormsAreZeroForTarget(Kind);
   // Outputs are flushed to zero, preserving sign
   return DAZ ? llvm::DenormalMode::getPreserveSign() :
llvm::DenormalMode::getIEEE();



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


[clang] 4ea3650 - HIP: Link correct denormal mode library

2020-04-01 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-04-01T12:36:22-04:00
New Revision: 4ea3650c212ae471657d3a253cd424ce9d1316ac

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

LOG: HIP: Link correct denormal mode library

This wasn't respecting the flush mode based on the default, and also
wasn't correctly handling the explicit
-fno-cuda-flush-denormals-to-zero overriding the mode.

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-device-libs.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index d21b3f5f0b19..e4ace81dbac7 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -285,6 +285,7 @@ void HIPToolChain::addClangTargetOptions(
   (void) GpuArch;
   assert(DeviceOffloadingKind == Action::OFK_HIP &&
  "Only HIP offloading kinds are supported for GPUs.");
+  auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
 
   CC1Args.push_back("-target-cpu");
   CC1Args.push_back(DriverArgs.MakeArgStringRef(GpuArch));
@@ -345,11 +346,14 @@ void HIPToolChain::addClangTargetOptions(
 std::string GFXVersion = GpuArch.drop_front(3).str();
 std::string ISAVerBC = "oclc_isa_version_" + GFXVersion + ".amdgcn.bc";
 
-llvm::StringRef FlushDenormalControlBC;
-if (DriverArgs.hasArg(options::OPT_fcuda_flush_denormals_to_zero))
-  FlushDenormalControlBC = "oclc_daz_opt_on.amdgcn.bc";
-else
-  FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";
+bool FTZDAZ = DriverArgs.hasFlag(
+  options::OPT_fcuda_flush_denormals_to_zero,
+  options::OPT_fno_cuda_flush_denormals_to_zero,
+  getDefaultDenormsAreZeroForTarget(Kind));
+
+std::string FlushDenormalControlBC = FTZDAZ ?
+  "oclc_daz_opt_on.amdgcn.bc" :
+  "oclc_daz_opt_off.amdgcn.bc";
 
 llvm::StringRef WaveFrontSizeBC;
 if (stoi(GFXVersion) < 1000)
@@ -359,7 +363,7 @@ void HIPToolChain::addClangTargetOptions(
 
 BCLibs.append({"hip.amdgcn.bc", "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
-   std::string(FlushDenormalControlBC),
+   FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC,
std::string(WaveFrontSizeBC)});

diff  --git a/clang/test/Driver/hip-device-libs.hip 
b/clang/test/Driver/hip-device-libs.hip
index b79cb70cbe68..cb1747c2d798 100644
--- a/clang/test/Driver/hip-device-libs.hip
+++ b/clang/test/Driver/hip-device-libs.hip
@@ -2,23 +2,94 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// Test flush-denormals-to-zero enabled uses oclc_daz_opt_on
+// Test if oclc_daz_opt_on or if oclc_daz_opt_off is linked depending on
+// expected denormal mode.
 
+// Test subtarget with flushing on by default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib   \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM,FLUSHD
+
+
+// Test subtarget with flushing off by ddefault.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
+
+
+// Test explicit flag, opposite of target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -fcuda-flush-denormals-to-zero \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,FLUSHD
 
-// Test flush-denormals-to-zero disabled uses oclc_daz_opt_off
 
+// Test explicit flag, opposite of target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   -fno-cuda-flush-denormals-to-zero \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
+
+
+// Test explicit flag, same as target default.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -fno-cuda-flush-denormals-to-zero \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
+
+// Test explicit flag, same as target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   -fcuda-flush-denormals-to-zero \
+// RUN:   --hip-device-l

[clang] 95fac2e - [WebAssembly] Rename SIMD min/max/avgr intrinsics for consistency

2020-04-01 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-04-01T09:38:41-07:00
New Revision: 95fac2e46b73c67495dbdb43ef178d33281c05ec

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

LOG: [WebAssembly] Rename SIMD min/max/avgr intrinsics for consistency

Summary:
The convention for the wasm_simd128.h intrinsics is to have the
integer sign in the lane interpretation rather than as a suffix. This
PR changes the names of the integer min, max, and avgr intrinsics to
match this convention.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 3b30ddbd527b..c2c57cadfdf2 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -650,28 +650,28 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_mul(v128_t __a,
   return (v128_t)((__u8x16)__a * (__u8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
+v128_t __b) {
   return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
@@ -745,28 +745,28 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i16x8_mul(v128_t __a,
   return (v128_t)((__u16x8)__a * (__u16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_AT

[PATCH] D76791: [Matrix] Implement matrix index expressions ([][]).

2020-04-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 254228.
fhahn added a comment.

Use placeholder type for incomplete matrix index expressions, as suggested by 
@rjmccall


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76791

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp

Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -std=c++11 -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = &f;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes outside allowed dimensions.
+  a[-1][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[3][-1] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[3][-1u] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[-1u][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[5][2] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[4][10] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[5][10.0] = f;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
+
+void extract(sx5x10_t a, float f) {
+  // Non integer indexes.
+  float v1 = a[3][f];
+  // expected-error@-1 {{matrix column index is not an integer}}
+  float v2 = a[f][9];
+  // expected-error@-1 {{matrix row index is not an integer}}
+  float v3 = a[f][f];
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  char *v4 = a[3][4];
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an lvalue of type 'float'}}
+
+  // Indexes outside allowed dimensions.
+  float v5 = a[-1][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v6 = a[3][-1];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v8 = a[-1u][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v9 = a[5][2];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v10 = a[4][10];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v11 = a[5][10.0];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
+
+void incomplete_matrix_index_expr(sx5x10_t a, float f) {
+  float x = a[3];
+  // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
+  a[2] = f;
+  // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
+}
Index: clang/test/Sema/matrix-type-operators.c
===
--- /dev/null
+++ clang/test/Sema/matrix-type-operators.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = &f;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes outside allowed dimensions.
+  a[-1][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[3

[PATCH] D76950: HIP: Link correct denormal mode library

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm marked an inline comment as done.
arsenm added a comment.

4ea3650c212ae471657d3a253cd424ce9d1316ac 



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

https://reviews.llvm.org/D76950



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:264
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

yaxunl wrote:
> could you please rebase your patch?
> 
> The patch seems to contain irrelevant diffs.
You're probably looking at the wrong history diff


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

https://reviews.llvm.org/D59321



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 254229.
arsenm marked an inline comment as done.
arsenm added a comment.

Rebase again


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/hip.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -99,9 +99,9 @@
   {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
+  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
 };
 
 const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef Table) {
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -151,7 +151,10 @@
 
   // Common features.
   FEATURE_FAST_FMA_F32 = 1 << 4,
-  FEATURE_FAST_DENORMAL_F32 = 1 << 5
+  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
+
+  // Wavefront 32 is available.
+  FEATURE_WAVE32 = 1 << 6
 };
 
 StringRef getArchNameAMDGCN(GPUKind AK);
Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,163 @@
+// REQUIRES: clang-driver
+// REQUIRES: amdgpu-r

[PATCH] D77185: [WebAssembly] Rename SIMD min/max/avgr intrinsics for consistency

2020-04-01 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95fac2e46b73: [WebAssembly] Rename SIMD min/max/avgr 
intrinsics for consistency (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77185

Files:
  clang/lib/Headers/wasm_simd128.h

Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -650,28 +650,28 @@
   return (v128_t)((__u8x16)__a * (__u8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
+v128_t __b) {
   return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
 }
 
@@ -745,28 +745,28 @@
   return (v128_t)((__u16x8)__a * (__u16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_s_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_u(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_max_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_avgr_u(v128_t __a,
-  v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_avgr(v128_t __a,
+v128_t __b) {
   return (v128_t)__builtin_wasm_avgr_u_i16x8((__i16x8)__a, (__i16x8)__b);
 }
 
@@ -816,23 +816,23 @@
   return (v128_t)((__u32x4)__a * (__u32x4)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min_s(v128_t __a,
- v128_t __b) {
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min(v128_t __a,
+   v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i32x4((__i32x4)__a, (__i32x4)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min_u(v128_t __a,
-

[PATCH] D77048: [Clang][CodeGen] Fixing mismatch between memory layout and const expressions for oversized bitfields

2020-04-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D77048/new/

https://reviews.llvm.org/D77048



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-01 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+

sdesmalen wrote:
> SjoerdMeijer wrote:
> > sdesmalen wrote:
> > > SjoerdMeijer wrote:
> > > > sdesmalen wrote:
> > > > > SjoerdMeijer wrote:
> > > > > > Just curious about the `-fallow-half-arguments-and-returns`, do you 
> > > > > > need that here?
> > > > > > 
> > > > > > And if not here, why do you need it elsewhere (looks enabled on all 
> > > > > > tests)?
> > > > > It's not needed for this test, but we've generated most of our tests 
> > > > > from the ACLE spec and the tests that use a scalar float16_t (== 
> > > > > __fp16) will need this, such as the ACLE intrinsic:
> > > > > 
> > > > >   svfloat16_t svadd_m(svbool_t, svfloat16_t, float16_t);
> > > > > 
> > > > > If you feel strongly about it, I could remove it from the other RUN 
> > > > > lines.
> > > > Well, I think this is my surprise then. Thinking out loud: we're 
> > > > talking SVE here, which always implies FP16. That's why I am surprised 
> > > > that we bother with a storage-type only type. Looking at the SVE ACLE I 
> > > > indeed see:
> > > > 
> > > >   float16_t equivalent to __fp16
> > > > 
> > > > where I was probably expecting:
> > > > 
> > > >   float16_t equivalent to _Float16
> > > > 
> > > > and with that everything would be sorted I guess, then we also don't 
> > > > need the hack^W workaround that is 
> > > > `-fallow-half-arguments-and-returns`. But maybe there is a good reason 
> > > > to use/choose `__fp16` that I don't see here. Probably worth a quick 
> > > > question for the ARM SVE ACLE, would you mind quickly checking?
> > > > 
> > > > 
> > > As just checked with @rsandifo-arm, the reason is that the definition of 
> > > `float16_t` has to be compatible with `arm_neon.h`, which uses `__fp16` 
> > > for both Clang and GCC.
> > I was suspecting it was compatability reasons, but perhaps not with 
> > `arm_neon.h`. So what exactly does it mean to be compatible with 
> > arm_neon.h? I mean, put simply and naively, if you target SVE, you include 
> > arm_sve.h, and go from there. How does that interact with arm_neon.h and 
> > why can float16_t not be a proper half type? 
> If you target SVE, you can still use Neon instructions, so it's still 
> possible to include arm_neon.h as well. If those have differing definitions 
> of float16_t, that may give trouble when using builtins from both the Neon 
> and SVE header files.
ok, thank, got it. So we are supporting this case:

   #include 
   #include 
   void foo () {
  neon_intrinsic();
  sve_intrinsic();
   }

Well, I find this very unfortunate, because it could have been so beautiful, 
and now we're still have this storage-only type while even the ACLE discourages 
its use. The use of `-fallow-half-arguments-and-returns` is just a minor 
annoyance, but point is it shouldn't have been necessary.

Now I am wondering why the ARM SVE ACLE  is using float16_t, and not just 
_Float16. Do you  have any insights in that too perhaps? 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[clang] f08df46 - [OPENMP50]Add initial support for OpenMP 5.0 iterator.

2020-04-01 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-04-01T12:53:55-04:00
New Revision: f08df464ae89972a777c0a7e299a2c153a9829d8

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

LOG: [OPENMP50]Add initial support for OpenMP 5.0 iterator.

Added basic parsing/semantic analysis/(de)serialization support for
iterator expression introduced in OpenMP 5.0.

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/BuiltinTypes.def
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/ExprOpenMP.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/OpenMP/depobj_messages.cpp
clang/test/OpenMP/task_ast_print.cpp
clang/test/OpenMP/task_depend_messages.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 641f058dafaa..0acd50021ed8 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2180,7 +2180,12 @@ enum CXCursorKind {
*/
   CXCursor_OMPArrayShapingExpr = 150,
 
-  CXCursor_LastExpr = CXCursor_OMPArrayShapingExpr,
+  /**
+   * OpenMP 5.0 [2.1.6 Iterators]
+   */
+  CXCursor_OMPIteratorExpr = 151,
+
+  CXCursor_LastExpr = CXCursor_OMPIteratorExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ebb5ca593843..6813ab58874e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -970,7 +970,7 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/OpenCLImageTypes.def"
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
   CanQualType OCLQueueTy, OCLReserveIDTy;
-  CanQualType OMPArraySectionTy, OMPArrayShapingTy;
+  CanQualType OMPArraySectionTy, OMPArrayShapingTy, OMPIteratorTy;
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   CanQualType Id##Ty;
 #include "clang/Basic/OpenCLExtensionTypes.def"

diff  --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index f42503773945..f8eb4ec19c8f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -316,8 +316,11 @@ PLACEHOLDER_TYPE(OMPArraySection, OMPArraySectionTy)
 // A placeholder type for OpenMP array shaping operation.
 PLACEHOLDER_TYPE(OMPArrayShaping, OMPArrayShapingTy)
 
+// A placeholder type for OpenMP iterators.
+PLACEHOLDER_TYPE(OMPIterator, OMPIteratorTy)
+
 #ifdef LAST_BUILTIN_TYPE
-LAST_BUILTIN_TYPE(OMPArrayShaping)
+LAST_BUILTIN_TYPE(OMPIterator)
 #undef LAST_BUILTIN_TYPE
 #endif
 

diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index 63947eaff73b..ab742c9b70dd 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -88,6 +88,7 @@ class PseudoObjectExpr;
 class AtomicExpr;
 class OMPArraySectionExpr;
 class OMPArrayShapingExpr;
+class OMPIteratorExpr;
 class ObjCArrayLiteral;
 class ObjCDictionaryLiteral;
 class ObjCBoxedExpr;
@@ -174,6 +175,7 @@ ExprDependence computeDependence(AtomicExpr *E);
 
 ExprDependence computeDependence(OMPArraySectionExpr *E);
 ExprDependence computeDependence(OMPArrayShapingExpr *E);
+ExprDependence computeDependence(OMPIteratorExpr *E);
 
 ExprDependence computeDependence(ObjCArrayLiteral *E);
 ExprDependence computeDependence

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-04-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

It's unsurprising that the Linux kernel's own Fortify implementation is 
incompatible with Clang. The whole feature should never have been implemented 
in the library to begin with, but here we are. I think the Linux kernel folks 
would prefer it if we can fix forward and find a way to make their Fortify 
implementation work, though.

For fixing forward, the question is, why did LLVM emit a standalone call to 
mempcy? Did LLVM inline the thing marked always_inline? Or did 
`__builtin_memcpy` compile down to `call i8* @memcpy(...)` instead of `call 
void @llvm.memcpy.*`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/StmtVisitor.h:146
+  RetTy VisitBin##NAME(PTR(BinaryOperator) S, ParamTys... P) { 
\
+DISPATCH(BinAssign, BinaryOperator);   
\
   }

erichkeane wrote:
> rjmccall wrote:
> > Comment needs updating, but more importantly, you're making all of these 
> > fall back on `VisitBinAssign`, which is definitely not correct.
> @rjmccall : What would you think fits better?  If we don't have something 
> like this, VisitBinaryOperator is going to have to redirect to VisitBinAssign 
> anyway.  We could presumably keep VisitCompoundAssignOperator, but that seems 
> like a naming difference.
`VisitBinAssign` is an existing method that is used specifically for the simple 
assignment operator.  The old delegation was that `VisitBinMulAssign` delegated 
to `VisitCompoundAssignOperator`, which delegated to `VisitBinaryOperator` 
(because CAO was a subclass of that), which delegated to `VisitExpr`.  The 
natural new delegation here would be for `VisitBinMulAssign` to just delegate 
directly to `VisitBinaryOperator`.  If it's still useful to have an 
intermediate visitor method in the delegation chain for all the compound 
assignment operators, that's fine, but it shouldn't be `VisitBinAssign`.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

erichkeane wrote:
> rjmccall wrote:
> > The problem with having both functions that take `ASTContext`s and 
> > functions that don't is that it's easy to mix them, so they either need to 
> > have the same behavior (in which case it's pointless to have an overload 
> > that takes the `ASTContext`) or you're making something really error-prone.
> > 
> > I would feel a lot more confident that you were designing and using these 
> > APIs correctly if you actually took advantage of the ability to not store 
> > trailing FPOptions in some case, like when they match the global settings 
> > in the ASTContext.  That way you'll actually be verifying that everything 
> > behaves correctly if nodes don't store FPOptions.  If you do that, I think 
> > you'll see my point about not having all these easily-confusable functions 
> > that do or do not take `ASTContext`s..
> I think I disagree with @rjmccall that these requiresTrailingStorage should 
> be here at all.  I think we should store in the AST ANY programmer opinion, 
> even if they match the global setting.  It seems to me that this would be 
> more tolerant of any global-setting rewrites that modules/et-al introduce, as 
> well as make the AST Print consistent.  Always storing FPOptions when the 
> user has explicitly overriding it also better captures the programmer's 
> intent.
I covered this elsewhere in the review.  If you want to have that tolerance — 
and I think you should — then expressions should store (and Sema should track) 
the active pragma state, which can be most easily expressed as a pair of an 
FPOptions and a mask to apply to the global FPOptions.  When you enter a 
pragma, you clear the relevant bits from the global FPOptions mask.

But the whole point of putting this stuff in trailing storage is so that you 
can make FPOptions as big as you need without actually inflating the AST size 
for a million nodes that don't care in the slightest about FPOptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

rjmccall wrote:
> erichkeane wrote:
> > rjmccall wrote:
> > > The problem with having both functions that take `ASTContext`s and 
> > > functions that don't is that it's easy to mix them, so they either need 
> > > to have the same behavior (in which case it's pointless to have an 
> > > overload that takes the `ASTContext`) or you're making something really 
> > > error-prone.
> > > 
> > > I would feel a lot more confident that you were designing and using these 
> > > APIs correctly if you actually took advantage of the ability to not store 
> > > trailing FPOptions in some case, like when they match the global settings 
> > > in the ASTContext.  That way you'll actually be verifying that everything 
> > > behaves correctly if nodes don't store FPOptions.  If you do that, I 
> > > think you'll see my point about not having all these easily-confusable 
> > > functions that do or do not take `ASTContext`s..
> > I think I disagree with @rjmccall that these requiresTrailingStorage should 
> > be here at all.  I think we should store in the AST ANY programmer opinion, 
> > even if they match the global setting.  It seems to me that this would be 
> > more tolerant of any global-setting rewrites that modules/et-al introduce, 
> > as well as make the AST Print consistent.  Always storing FPOptions when 
> > the user has explicitly overriding it also better captures the programmer's 
> > intent.
> I covered this elsewhere in the review.  If you want to have that tolerance — 
> and I think you should — then expressions should store (and Sema should 
> track) the active pragma state, which can be most easily expressed as a pair 
> of an FPOptions and a mask to apply to the global FPOptions.  When you enter 
> a pragma, you clear the relevant bits from the global FPOptions mask.
> 
> But the whole point of putting this stuff in trailing storage is so that you 
> can make FPOptions as big as you need without actually inflating the AST size 
> for a million nodes that don't care in the slightest about FPOptions.
> But the whole point of putting this stuff in trailing storage is so that you 
> can make FPOptions as big as you need without actually inflating the AST size 
> for a million nodes that don't care in the slightest about FPOptions.

I meant to say: for a million nodes that don't care in the slightest about 
FPOptions, as well as for a million more nodes that aren't using pragma 
overrides.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-04-01 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 254238.
DmitryPolukhin added a comment.

Use options priority instead of overriding local options by global


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -85,7 +85,7 @@
   ExtraArgsBefore: ['arg-before3', 'arg-before4']
   )");
   ASSERT_TRUE(!!Options2);
-  ClangTidyOptions Options = Options1->mergeWith(*Options2);
+  ClangTidyOptions Options = Options1->mergeWith(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,26 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
+
+// For this test we have to use names of the real checks because otherwise values are ignored.
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
+// CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
+// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
+// CHECK-CHILD4-NEXT: value: '1
+// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
+// CHECK-CHILD4-NEXT: value: '20'
+// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
+// CHECK-CHILD4-NEXT: value: reasonable
+// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
+// CHECK-CHILD4-NEXT: value: '0'
+
+// RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
+// CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}/Inputs/config-files/4/44/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-loop-convert' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-use-using' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
@@ -0,0 +1,9 @@
+InheritParentConfig: true
+Checks: 'llvm-qualified-auto'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '20'
+  - key: llvm-qualified-auto.AddConstToQualified
+value:   '1'
+  - key: IgnoreMacros
+value:   '0'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
@@ -0,0 +1,8 @@
+Checks: '-*,modernize-loop-convert,modernize-use-using'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '10'
+  - key: modernize-loop-convert.MinConfidence
+value:   reasonable
+  - key: modernize-use-using.IgnoreMacros
+   

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 254242.
jcai19 added a comment.

Remove an unnecessary line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,8 +571,8 @@
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s
 // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
Index: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-3
+
+#define ARRLEN 10
+
+typedef struct {
+  int i;
+  char c;
+} S;
+
+int foo () {
+  long a = 888;
+  S arr1[ARRLEN], arr2[ARRLEN];
+// PATTERN-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+// PATTERN-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+
+// ZERO-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+// ZERO-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+
+  return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3273,6 +3273,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3088,6 +3088,13 @@
 CmdArgs.push_back(
 Args.MakeArgString("-ftrivial-auto-var-init=" + TrivialAutoVarInit));
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+A->claim();
+StringRef Val = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString("-ftrivial-auto-var-init-stop-after=" + Val));
+  }
 }
 
 static void RenderOpenCLOptions(const ArgList &Args, ArgStringList &CmdArgs) {
Index: clan

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 254240.
jcai19 added a comment.

Address some of the concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,8 +571,8 @@
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s
 // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
Index: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-3
+
+#define ARRLEN 10
+
+typedef struct {
+  int i;
+  char c;
+} S;
+
+int foo () {
+  long a = 888;
+  S arr1[ARRLEN], arr2[ARRLEN];
+// PATTERN-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+// PATTERN-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// PATTERN-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 -86, i64 80, i1 false)
+
+// ZERO-STOP-AFTER-2-NOT: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-2-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+// ZERO-STOP-AFTER-3: %1 = bitcast [10 x %struct.S]* %arr2 to i8*
+// ZERO-STOP-AFTER-3: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 80, i1 false)
+
+  return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3273,6 +3273,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3088,6 +3088,13 @@
 CmdArgs.push_back(
 Args.MakeArgString("-ftrivial-auto-var-init=" + TrivialAutoVarInit));
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+A->claim();
+StringRef Val = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString("-ftrivial-auto-var-init-stop-after=" + Val));
+  }
 }
 
 static void RenderOpenCLOptions(const ArgList &Args, ArgStringList &CmdArgs) {
Index: cl

[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

rjmccall wrote:
> rjmccall wrote:
> > erichkeane wrote:
> > > rjmccall wrote:
> > > > The problem with having both functions that take `ASTContext`s and 
> > > > functions that don't is that it's easy to mix them, so they either need 
> > > > to have the same behavior (in which case it's pointless to have an 
> > > > overload that takes the `ASTContext`) or you're making something really 
> > > > error-prone.
> > > > 
> > > > I would feel a lot more confident that you were designing and using 
> > > > these APIs correctly if you actually took advantage of the ability to 
> > > > not store trailing FPOptions in some case, like when they match the 
> > > > global settings in the ASTContext.  That way you'll actually be 
> > > > verifying that everything behaves correctly if nodes don't store 
> > > > FPOptions.  If you do that, I think you'll see my point about not 
> > > > having all these easily-confusable functions that do or do not take 
> > > > `ASTContext`s..
> > > I think I disagree with @rjmccall that these requiresTrailingStorage 
> > > should be here at all.  I think we should store in the AST ANY programmer 
> > > opinion, even if they match the global setting.  It seems to me that this 
> > > would be more tolerant of any global-setting rewrites that modules/et-al 
> > > introduce, as well as make the AST Print consistent.  Always storing 
> > > FPOptions when the user has explicitly overriding it also better captures 
> > > the programmer's intent.
> > I covered this elsewhere in the review.  If you want to have that tolerance 
> > — and I think you should — then expressions should store (and Sema should 
> > track) the active pragma state, which can be most easily expressed as a 
> > pair of an FPOptions and a mask to apply to the global FPOptions.  When you 
> > enter a pragma, you clear the relevant bits from the global FPOptions mask.
> > 
> > But the whole point of putting this stuff in trailing storage is so that 
> > you can make FPOptions as big as you need without actually inflating the 
> > AST size for a million nodes that don't care in the slightest about 
> > FPOptions.
> > But the whole point of putting this stuff in trailing storage is so that 
> > you can make FPOptions as big as you need without actually inflating the 
> > AST size for a million nodes that don't care in the slightest about 
> > FPOptions.
> 
> I meant to say: for a million nodes that don't care in the slightest about 
> FPOptions, as well as for a million more nodes that aren't using pragma 
> overrides.
Right, I get the intent, and I completely agree with that.  My point was EVERY 
Expr that is affected by a #pragma should store it.  Though, after looking at 
your Macro concern above, I'm less compelled.

I guess was suggesting that the logic for "requiresTrailingStorage" should just 
be "modified by a pragma" instead of "FPOptions != The global setting".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


  1   2   3   >