Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Nick Desaulniers via cfe-commits
Note that kernel developers are requesting output support with ASM goto.
Doesn't need to be in V1 of ASM go-to support, but we should expect it to
be implemented in the future. We should help users with diagnostics that
this is not supported, and add asserts that will help us implement such a
feature in the future.


On Tue, Feb 5, 2019, 3:32 AM Richard Smith - zygoloid via Phabricator <
revi...@reviews.llvm.org wrote:

> rsmith added inline comments.
>
>
> 
> Comment at: lib/AST/Stmt.cpp:457-460
>this->NumOutputs = NumOutputs;
>this->NumInputs = NumInputs;
>this->NumClobbers = NumClobbers;
> +  this->NumLabels = NumLabels;
> 
> jyu2 wrote:
> > rsmith wrote:
> > > Please assert that you don't have both outputs and labels here. (If
> you did, you would assign them the same slots within `Exprs`.)
> > >
> > > You also seem to be missing `Sema` enforcement of the rule that you
> cannot have both outputs and labels. (If you want to actually support that
> as an intentional extension to the GCC functionality, you should change the
> implementation of `GCCAsmStmt` to use different slots for outputs and
> labels, add some tests, and add a `-Wgcc-compat` warning for that case.
> Seems better to just add an error for it for now.)
> > This is enforcement during the parer.
> >
> > for example:
> > a.c:12:23: error: expected ':'
> > asm goto ("decl %0;" :"a": "m"(cond) : "memory" );
> >
> > Do you think this is enough for now?
> > Thanks.
> > Jennifer
> Thanks, I see it now. Please still add the assert here.
>
> I'd also like a custom diagnostic for that parse error; it'd seem easy and
> useful to add an "asm goto cannot have output constraints" error.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56571/new/
>
> https://reviews.llvm.org/D56571
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57464: Generalize method overloading on addr spaces to C++

2019-02-05 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:2313
+}
+  }
 

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > Anastasia wrote:
> > > > > Anastasia wrote:
> > > > > > ebevhan wrote:
> > > > > > > Is there a reason that the attributes are parsed here and not in 
> > > > > > > `ParseFunctionDeclarator` like the rest of the ref-qualifiers 
> > > > > > > (and the OpenCL++ ASes)?
> > > > > > > 
> > > > > > > That is possibly why the parser is getting confused with the 
> > > > > > > trailing return.
> > > > > > Good question! I have a feeling that this was done to unify parsing 
> > > > > > of all CXX members, not just methods. For collecting the method 
> > > > > > qualifiers it would certainly help making flow more coherent if 
> > > > > > this was moved to `ParseFunctionDeclarator`. I will try to 
> > > > > > experiment with this a bit more. What I found strange that the 
> > > > > > attributes here are attached to the function type itself instead of 
> > > > > > its  qualifiers. May be @rjmccall can shed some more light on the 
> > > > > > overall flow...
> > > > > I looked at this a bit more and it seems that all the GNU attributes 
> > > > > other than addr spaces belong to the function (not to be applied to 
> > > > > `this`) for example 
> > > > > https://blog.timac.org/2016/0716-constructor-and-destructor-attributes/.
> > > > >  It seems correct to parse them here and apply to the function type. 
> > > > > Although we could separate parsing of addr space attribute only and 
> > > > > move into `ParseFunctionDeclarator`.  However this will only be 
> > > > > needed for the function type not for the data members. So not sure 
> > > > > whether it will make the flow any cleaner.
> > > > > I looked at this a bit more and it seems that all the GNU attributes 
> > > > > other than addr spaces belong to the function (not to be applied to 
> > > > > this) 
> > > > 
> > > > Hm, I know what you mean. It's why Clang usually complains when you try 
> > > > placing an AS attribute after a function declarator, because it's 
> > > > trying to apply it to the function rather than the method qualifiers.
> > > > 
> > > > > However this will only be needed for the function type not for the 
> > > > > data members. 
> > > > 
> > > > But we aren't really interested in data members, are we? Like struct 
> > > > fields, non-static data members cannot be qualified with ASes (they 
> > > > should 'inherit' the AS from the object type), and static ones should 
> > > > probably just accept ASes as part of the member type itself.
> > > > 
> > > > These patches are to enable AS-qualifiers on methods, so it only stands 
> > > > to reason that those ASes would be parsed along with the other method 
> > > > qualifiers.
> > > > 
> > > > ParseFunctionDeclarator calls ParseTypeQualifierListOpt to get the 
> > > > cv-qualifier-seq for the method qualifiers. Currently it's set to 
> > > > `AR_NoAttributesParsed`. If we enable parsing attributes there, then 
> > > > the qualifier parsing might 'eat' attributes that were possibly meant 
> > > > for the function.
> > > > 
> > > > This is just a guess, but what I think you could do is include 
> > > > attributes in the cv-qualifier parsing with `AR_GNUAttributesParsed`, 
> > > > look for any AS attributes, take their AS and mark them invalid, then 
> > > > move the attributes (somehow) from the qualifier-DeclSpec to the 
> > > > `FnAttrs` function attribute list.
> > > > 
> > > > (The reason I'm concerned about where/how the qualifiers are parsed is 
> > > > because this approach only works for custom ASes applied with the GNU 
> > > > attribute directly. It won't work if custom address spaces are given 
> > > > with a custom keyword qualifier, like in OpenCL. If the ASes are parsed 
> > > > into the DeclSpec used for the other ref-qualifiers, then both of these 
> > > > cases should 'just work'.)
> > > > But we aren't really interested in data members, are we? Like struct 
> > > > fields, non-static data members cannot be qualified with ASes (they 
> > > > should 'inherit' the AS from the object type), and static ones should 
> > > > probably just accept ASes as part of the member type itself.
> > >  
> > > Pointer data members can be qualified by and address space, but this 
> > > should be parsed before.
> > > 
> > > 
> > > > This is just a guess, but what I think you could do is include 
> > > > attributes in the cv-qualifier parsing with AR_GNUAttributesParsed, 
> > > > look for any AS attributes, take their AS and mark them invalid, then 
> > > > move the attributes (somehow) from the qualifier-DeclSpec to the 
> > > > FnAttrs function attribute list.
> > > 
> > > Ok, I will try that. Thanks for sharing your ideas!
> > > 
> > > Pointer data members can be qualified by and address space, but this 
> > > should be parsed before.
> > 
> > Right, pointer-to-member is a thing. I always forget ab

[PATCH] D57581: Explicitly add language standard option to test cases that rely on the C++14 default

2019-02-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D57581



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


r353150 - Fix the sphinx buildbot after D54429

2019-02-05 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Tue Feb  5 02:19:39 2019
New Revision: 353150

URL: http://llvm.org/viewvc/llvm-project?rev=353150&view=rev
Log:
Fix the sphinx buildbot after D54429

Modified:
cfe/trunk/docs/analyzer/checkers.rst

Modified: cfe/trunk/docs/analyzer/checkers.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/checkers.rst?rev=353150&r1=353149&r2=353150&view=diff
==
--- cfe/trunk/docs/analyzer/checkers.rst (original)
+++ cfe/trunk/docs/analyzer/checkers.rst Tue Feb  5 02:19:39 2019
@@ -1943,7 +1943,7 @@ debug
 ^
 
 Checkers used for debugging the analyzer.
-:doc:`DebugChecks` page contains a detailed description.
+:doc:`developer-docs/DebugChecks` page contains a detailed description.
 
 debug.AnalysisOrder
 """


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


[PATCH] D54429: [analyzer] Creating standard Sphinx documentation

2019-02-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: docs/analyzer/checkers.rst:1946
+Checkers used for debugging the analyzer.
+:doc:`DebugChecks` page contains a detailed description.
+

NoQ wrote:
> The error is on this line. It might be that this link should mention the 
> directory (something like `developer-docs/DebugChecks`). Previously 
> `DebugChecks` was on the top level, so it wasn't necessary.
Yup, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D54429



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


[PATCH] D57732: Correct inf typo

2019-02-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57732



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


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57739

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Format.h
  unittests/clangd/TweakTests.cpp

Index: unittests/clangd/TweakTests.cpp
===
--- unittests/clangd/TweakTests.cpp
+++ unittests/clangd/TweakTests.cpp
@@ -9,6 +9,7 @@
 
 #include "Annotations.h"
 #include "SourceCode.h"
+#include "Format.h"
 #include "TestTU.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
@@ -77,7 +78,8 @@
 void checkNotAvailable(StringRef ID, llvm::StringRef Input) {
   return checkAvailable(ID, Input, /*Available=*/false);
 }
-llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
+llvm::Expected apply(StringRef ID, llvm::StringRef Input,
+  bool Format) {
   Annotations Code(Input);
   Range SelectionRng;
   if (Code.points().size() != 0) {
@@ -102,12 +104,19 @@
   auto Replacements = (*T)->apply(S);
   if (!Replacements)
 return Replacements.takeError();
+  if (Format) {
+Replacements = cleanupAndFormat(
+Code.code(), *Replacements,
+clang::format::getGoogleStyle(::clang::format::FormatStyle::LK_Cpp));
+if (!Replacements)
+  return Replacements.takeError();
+  }
   return applyAllReplacements(Code.code(), *Replacements);
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
-llvm::StringRef Output) {
-  EXPECT_THAT_EXPECTED(apply(ID, Input), HasValue(Output))
+llvm::StringRef Output, bool Format = false) {
+  EXPECT_THAT_EXPECTED(apply(ID, Input, Format), HasValue(Output))
   << "action id is" << ID;
 }
 
@@ -150,6 +159,22 @@
   )cpp";
   checkTransform(ID, Input, Output);
 
+  Input = R"cpp(
+void test() {
+  ^if () { return 100; } else { continue; }
+}
+  )cpp";
+  Output = R"cpp(
+void test() {
+  if () {
+continue;
+  } else {
+return 100;
+  }
+}
+  )cpp";
+  checkTransform(ID, Input, Output, /*Format=*/true);
+
   // Available in subexpressions of the condition.
   checkAvailable(ID, R"cpp(
 void test() {
Index: clangd/Format.h
===
--- /dev/null
+++ clangd/Format.h
@@ -0,0 +1,28 @@
+//===--- Format.h --*- 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
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+
+// Cleanup and format the given replacements.
+inline llvm::Expected
+cleanupAndFormat(StringRef Code, const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style) {
+  auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  if (!CleanReplaces)
+return CleanReplaces;
+  return formatReplacements(Code, std::move(*CleanReplaces), Style);
+}
+
+} // namespace clangd
+} // namespace clang
\ No newline at end of file
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -23,6 +23,7 @@
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "refactor/Tweak.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -223,7 +224,7 @@
Callback> CB);
 
   /// Apply the code tweak with a specified \p ID.
-  void applyTweak(PathRef File, Range Sel, StringRef ID,
+  void applyTweak(StringRef Code, PathRef File, Range Sel, StringRef ID,
   Callback CB);
 
   /// Only for testing purposes.
@@ -257,12 +258,15 @@
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
 private:
-  /// FIXME: This stats several files to find a .clang-format file. I/O can be
-  /// slow. Think of a way to cache this.
   llvm::Expected
   formatCode(llvm::StringRef Code, PathRef File,
  ArrayRef Ranges);
 
+  /// FIXME: This stats several files to find a .clang-format file. I/O can be
+  /// slow. Think of a way to cache this.
+  llvm::Expected getFormatStyle(llvm::StringRef Code,
+ PathRef File);
+
   tooling::CompileCommand getCompileCommand(PathRef File);
 
   const GlobalCompilationDatabase &CDB;
Index: clangd/ClangdServer.cpp
==

[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clangd/ClangdServer.cpp:366
+  auto Style = getFormatStyle(Code, File);
+  if (!Style)
+return;

not sure the err-handling strategy here -- maybe if this is failed, we still 
apply replacements (without formatting), rather than stopping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdServer.cpp:366
+  auto Style = getFormatStyle(Code, File);
+  if (!Style)
+return;

hokein wrote:
> not sure the err-handling strategy here -- maybe if this is failed, we still 
> apply replacements (without formatting), rather than stopping.
You should use `getFormatStyleForFile` from SourceCode.h


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


[PATCH] D57740: [ASTImporter] Import every Decl in lambda record

2019-02-05 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
gamesh411 added reviewers: a.sidorin, shafik.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously only the fields were imported. Now every Decl is imported.
This way the destructor decl is not missing after import.

Patch by balazske (Balázs Kéri)


Repository:
  rC Clang

https://reviews.llvm.org/D57740

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


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2417,6 +2417,27 @@
   EXPECT_EQ(ToDFOutOfClass->getPreviousDecl(), ToDFInClass);
 }
 
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void foo() {
+(void)[]() { ; };
+  }
+  )",
+  Lang_CXX11);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  CXXRecordDecl *LambdaRec =
+  cast(cast(
+   *cast(ToD->getBody())->body_begin())
+   ->getSubExpr())
+  ->getLambdaClass();
+  EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -7382,13 +7382,9 @@
   // NOTE: lambda classes are created with BeingDefined flag set up.
   // It means that ImportDefinition doesn't work for them and we should fill it
   // manually.
-  if (ToClass->isBeingDefined()) {
-for (auto FromField : FromClass->fields()) {
-  auto ToFieldOrErr = import(FromField);
-  if (!ToFieldOrErr)
-return ToFieldOrErr.takeError();
-}
-  }
+  if (ToClass->isBeingDefined())
+if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+  return std::move(Err);
 
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2417,6 +2417,27 @@
   EXPECT_EQ(ToDFOutOfClass->getPreviousDecl(), ToDFInClass);
 }
 
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void foo() {
+(void)[]() { ; };
+  }
+  )",
+  Lang_CXX11);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  CXXRecordDecl *LambdaRec =
+  cast(cast(
+   *cast(ToD->getBody())->body_begin())
+   ->getSubExpr())
+  ->getLambdaClass();
+  EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -7382,13 +7382,9 @@
   // NOTE: lambda classes are created with BeingDefined flag set up.
   // It means that ImportDefinition doesn't work for them and we should fill it
   // manually.
-  if (ToClass->isBeingDefined()) {
-for (auto FromField : FromClass->fields()) {
-  auto ToFieldOrErr = import(FromField);
-  if (!ToFieldOrErr)
-return ToFieldOrErr.takeError();
-}
-  }
+  if (ToClass->isBeingDefined())
+if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+  return std::move(Err);
 
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Could we move the code to the `Tweak` itself, so that all the callers would get 
the formatting? I.e.

  class Tweak {
 Replacements apply() {  // This is now non-virtual.
   auto Replacements = doApply();
   return cleanupAndFormat(Replacements);
 }
  
  protected:
 virtual Replacements doApply() = 0; // inheritors should implement this 
now. Note: the name is terrible, suggestions are welcome.
  };

This would ensure the callers don't need to deal with the formatting on their 
own.




Comment at: clangd/ClangdServer.cpp:362
 
-void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
+void ClangdServer::applyTweak(StringRef Code, PathRef File, Range Sel,
+  StringRef TweakID,

We can get the contents from `InpAST.Inputs.Contents`, no need to add an extra 
parameter.
Moving `getFormatStyle()` into the callback body should be ok.



Comment at: clangd/ClangdServer.cpp:500
+llvm::Expected
+ClangdServer::getFormatStyle(llvm::StringRef Code, PathRef File) {
+  return format::getStyle(format::DefaultFormatStyle, File,

Could this function get a `vfs::FileSystem` as a parameter?
Would server as a hint to the readers that it accesses the filesystem and allow 
to reuse vfs instances when they're already available (the apply tweaks case)



Comment at: clangd/ClangdServer.h:267
+  /// slow. Think of a way to cache this.
+  llvm::Expected getFormatStyle(llvm::StringRef Code,
+ PathRef File);

NIT: could we swap the parameters for consistency with the other functions in 
this class (i.e. `File` goes first)



Comment at: clangd/Format.h:29
+} // namespace clang
\ No newline at end of file


NIT: add newline at the end of file.



Comment at: unittests/clangd/TweakTests.cpp:82
+llvm::Expected apply(StringRef ID, llvm::StringRef Input,
+  bool Format) {
   Annotations Code(Input);

NIT: remove the parameter, this should be the default.
At least until we run into the checks that deliberately don't want the 
formatting



Comment at: unittests/clangd/TweakTests.cpp:110
+Code.code(), *Replacements,
+clang::format::getGoogleStyle(::clang::format::FormatStyle::LK_Cpp));
+if (!Replacements)

NIT: maybe prefer LLVM style? To avoid context-switching.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:366
+  auto Style = getFormatStyle(Code, File);
+  if (!Style)
+return;

ioeric wrote:
> hokein wrote:
> > not sure the err-handling strategy here -- maybe if this is failed, we 
> > still apply replacements (without formatting), rather than stopping.
> You should use `getFormatStyleForFile` from SourceCode.h
> not sure the err-handling strategy here -- maybe if this is failed, we still 
> apply replacements (without formatting), rather than stopping.
Returning an error seems fine, this probably shouldn't happen under normal 
conditions and failing early means we're more likely to find the root-cause of 
the problem.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


r353160 - Fix ICE on reference binding with mismatching addr spaces.

2019-02-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Tue Feb  5 03:32:58 2019
New Revision: 353160

URL: http://llvm.org/viewvc/llvm-project?rev=353160&view=rev
Log:
Fix ICE on reference binding with mismatching addr spaces.

When we attempt to add an addr space qual to a type already
qualified by an addr space ICE is triggered. Before creating
a type with new address space, remove the old addr space.

Fixing PR38614!

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


Added:
cfe/trunk/test/SemaOpenCLCXX/address-space-of-this.cl
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=353160&r1=353159&r2=353160&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Feb  5 03:32:58 2019
@@ -4670,19 +4670,23 @@ static void TryReferenceInitializationCo
 //   applied.
 // Postpone address space conversions to after the temporary 
materialization
 // conversion to allow creating temporaries in the alloca address space.
-auto AS1 = T1Quals.getAddressSpace();
-auto AS2 = T2Quals.getAddressSpace();
-T1Quals.removeAddressSpace();
-T2Quals.removeAddressSpace();
-QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-if (T1Quals != T2Quals)
+auto T1QualsIgnoreAS = T1Quals;
+auto T2QualsIgnoreAS = T2Quals;
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  T1QualsIgnoreAS.removeAddressSpace();
+  T2QualsIgnoreAS.removeAddressSpace();
+}
+QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1QualsIgnoreAS);
+if (T1QualsIgnoreAS != T2QualsIgnoreAS)
   Sequence.AddQualificationConversionStep(cv1T4, ValueKind);
 Sequence.AddReferenceBindingStep(cv1T4, ValueKind == VK_RValue);
 ValueKind = isLValueRef ? VK_LValue : VK_XValue;
-if (AS1 != AS2) {
-  T1Quals.addAddressSpace(AS1);
-  QualType cv1AST4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-  Sequence.AddQualificationConversionStep(cv1AST4, ValueKind);
+// Add addr space conversion if required.
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  auto T4Quals = cv1T4.getQualifiers();
+  T4Quals.addAddressSpace(T1Quals.getAddressSpace());
+  QualType cv1T4WithAS = S.Context.getQualifiedType(T2, T4Quals);
+  Sequence.AddQualificationConversionStep(cv1T4WithAS, ValueKind);
 }
 
 //   In any case, the reference is bound to the resulting glvalue (or to

Added: cfe/trunk/test/SemaOpenCLCXX/address-space-of-this.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address-space-of-this.cl?rev=353160&view=auto
==
--- cfe/trunk/test/SemaOpenCLCXX/address-space-of-this.cl (added)
+++ cfe/trunk/test/SemaOpenCLCXX/address-space-of-this.cl Tue Feb  5 03:32:58 
2019
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic 
-verify -fsyntax-only
+// expected-no-diagnostics
+
+// Extract from PR38614
+struct C {};
+
+C f1() {
+ return C{};
+}
+
+C f2(){
+C c;
+return c;
+}


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


[PATCH] D57524: Fix ICE on attempt to add an addr space qual to a type qualified by an addr space

2019-02-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353160: Fix ICE on reference binding with mismatching addr 
spaces. (authored by stulova, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D57524?vs=185024&id=185272#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57524

Files:
  lib/Sema/SemaInit.cpp
  test/SemaOpenCLCXX/address-space-of-this.cl


Index: test/SemaOpenCLCXX/address-space-of-this.cl
===
--- test/SemaOpenCLCXX/address-space-of-this.cl
+++ test/SemaOpenCLCXX/address-space-of-this.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic 
-verify -fsyntax-only
+// expected-no-diagnostics
+
+// Extract from PR38614
+struct C {};
+
+C f1() {
+ return C{};
+}
+
+C f2(){
+C c;
+return c;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -4670,19 +4670,23 @@
 //   applied.
 // Postpone address space conversions to after the temporary 
materialization
 // conversion to allow creating temporaries in the alloca address space.
-auto AS1 = T1Quals.getAddressSpace();
-auto AS2 = T2Quals.getAddressSpace();
-T1Quals.removeAddressSpace();
-T2Quals.removeAddressSpace();
-QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-if (T1Quals != T2Quals)
+auto T1QualsIgnoreAS = T1Quals;
+auto T2QualsIgnoreAS = T2Quals;
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  T1QualsIgnoreAS.removeAddressSpace();
+  T2QualsIgnoreAS.removeAddressSpace();
+}
+QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1QualsIgnoreAS);
+if (T1QualsIgnoreAS != T2QualsIgnoreAS)
   Sequence.AddQualificationConversionStep(cv1T4, ValueKind);
 Sequence.AddReferenceBindingStep(cv1T4, ValueKind == VK_RValue);
 ValueKind = isLValueRef ? VK_LValue : VK_XValue;
-if (AS1 != AS2) {
-  T1Quals.addAddressSpace(AS1);
-  QualType cv1AST4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-  Sequence.AddQualificationConversionStep(cv1AST4, ValueKind);
+// Add addr space conversion if required.
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  auto T4Quals = cv1T4.getQualifiers();
+  T4Quals.addAddressSpace(T1Quals.getAddressSpace());
+  QualType cv1T4WithAS = S.Context.getQualifiedType(T2, T4Quals);
+  Sequence.AddQualificationConversionStep(cv1T4WithAS, ValueKind);
 }
 
 //   In any case, the reference is bound to the resulting glvalue (or to


Index: test/SemaOpenCLCXX/address-space-of-this.cl
===
--- test/SemaOpenCLCXX/address-space-of-this.cl
+++ test/SemaOpenCLCXX/address-space-of-this.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// expected-no-diagnostics
+
+// Extract from PR38614
+struct C {};
+
+C f1() {
+ return C{};
+}
+
+C f2(){
+C c;
+return c;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -4670,19 +4670,23 @@
 //   applied.
 // Postpone address space conversions to after the temporary materialization
 // conversion to allow creating temporaries in the alloca address space.
-auto AS1 = T1Quals.getAddressSpace();
-auto AS2 = T2Quals.getAddressSpace();
-T1Quals.removeAddressSpace();
-T2Quals.removeAddressSpace();
-QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-if (T1Quals != T2Quals)
+auto T1QualsIgnoreAS = T1Quals;
+auto T2QualsIgnoreAS = T2Quals;
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  T1QualsIgnoreAS.removeAddressSpace();
+  T2QualsIgnoreAS.removeAddressSpace();
+}
+QualType cv1T4 = S.Context.getQualifiedType(cv2T2, T1QualsIgnoreAS);
+if (T1QualsIgnoreAS != T2QualsIgnoreAS)
   Sequence.AddQualificationConversionStep(cv1T4, ValueKind);
 Sequence.AddReferenceBindingStep(cv1T4, ValueKind == VK_RValue);
 ValueKind = isLValueRef ? VK_LValue : VK_XValue;
-if (AS1 != AS2) {
-  T1Quals.addAddressSpace(AS1);
-  QualType cv1AST4 = S.Context.getQualifiedType(cv2T2, T1Quals);
-  Sequence.AddQualificationConversionStep(cv1AST4, ValueKind);
+// Add addr space conversion if required.
+if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
+  auto T4Quals = cv1T4.getQualifiers();
+  T4Quals.addAddressSpace(T1Quals.getAddressSpace());
+  QualType cv1T4WithAS = S.Context.getQualifiedType(T2, T4Quals);
+  Sequence.AddQualificationConversionStep(cv1T4WithAS, ValueKind);
 }
 
 //   In any case, the referen

[PATCH] D56003: [RFC] [CFE] Allocatable Global Register Variables for ARM

2019-02-05 Thread Carey Williams via Phabricator via cfe-commits
carwil updated this revision to Diff 185277.
carwil added a comment.

Removed the complicated frame pointer/ffixed combination errors in favour of an 
always on warning (in a new group, so it can be silenced).


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

https://reviews.llvm.org/D56003

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/Options.td
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/ARM.h
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-reserved-reg-options.c
  test/Sema/arm-global-regs.c

Index: test/Sema/arm-global-regs.c
===
--- /dev/null
+++ test/Sema/arm-global-regs.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -triple arm %s
+
+// Check a small subset of valid and invalid global register variable declarations.
+
+register unsigned arm_r3 __asm("r3");   //expected-error {{register 'r3' unsuitable for global register variables on this target}}
+
+register unsigned arm_r12 __asm("r12"); //expected-error {{register 'r12' unsuitable for global register variables on this target}}
+
+register unsigned arm_r5 __asm("r5");
+
+register unsigned arm_r9 __asm("r9");
+
+register unsigned arm_sp __asm("sp");
\ No newline at end of file
Index: test/Driver/arm-reserved-reg-options.c
===
--- /dev/null
+++ test/Driver/arm-reserved-reg-options.c
@@ -0,0 +1,35 @@
+// ## FP ARM + Thumb
+// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R11 %s
+// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r11 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r7 -mthumb -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R7 %s
+// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r7 -mthumb -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// RUN: %clang -target thumbv6m-none-eabi -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R7 %s
+// RUN: %clang -target thumbv6m-none-eabi -### -ffixed-r7 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// ## FP Darwin (R7)
+// RUN: %clang -target armv6-apple-darwin9 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R7 %s
+// RUN: %clang -target armv6-apple-darwin9 -### -ffixed-r7 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// RUN: %clang -target armv6-apple-ios3 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R7 %s
+// RUN: %clang -target armv6-apple-ios3 -### -ffixed-r7 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// RUN: %clang -target armv7s-apple-darwin10 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R7 %s
+// RUN: %clang -target armv7s-apple-darwin10 -### -ffixed-r7 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// ## FP Windows (R11)
+// RUN: %clang -target armv7-windows -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING-R11 %s
+// RUN: %clang -target armv7-windows -### -ffixed-r11 -Wno-fixed-registers -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-WARNING %s
+
+// ## FRWPI (R9)
+// RUN: %clang -target arm-arm-none-eabi -### -frwpi -ffixed-r9 -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-CONFLICT %s
+// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r9 -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-VALID %s
+// RUN: %clang -target arm-arm-none-eabi -### -frwpi -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-VALID %s
+
+// CHECK-WARNING-R11: warning: '-ffixed-r11' has been specified but 'r11' may still be used as a frame pointer [-Wfixed-registers]
+// CHECK-WARNING-R7: warning: '-ffixed-r7' has been specified but 'r7' may still be used as a frame pointer [-Wfixed-registers]
+// CHECK-NO-WARNING-NOT: may still be used as a frame pointer [-Wfixed-registers]
+
+// CHECK-RESERVED-FRWPI-CONFLICT: option '-ffixed-r9' cannot be specified with '-frwpi'
+// CHECK-RESERVED-FRWPI-VALID-NOT: option '-ffixed-r9' cannot be specified with '-frwpi'
\ No newline at end of file
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -547,11 +547,37 @@
   Features.push_back("+strict-align");
   }
 
-  // llvm does not support reserving registers in general. There is support
-  // for reserving r9 on ARM though (defined as a platform-specific register
-  // in ARM EABI).
-  if (Args.hasArg(options::OPT_ffixed_r9))
-Features.push_back("+reserve-r9");
+  // Do not allow r9 reservation with -frwpi.
+  if (Args.hasArg(options::OPT_ffixed_

r353163 - [NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default

2019-02-05 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Tue Feb  5 04:05:53 2019
New Revision: 353163

URL: http://llvm.org/viewvc/llvm-project?rev=353163&view=rev
Log:
[NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default

When Clang/LLVM is built with the CLANG_DEFAULT_STD_CXX CMake macro that sets
the default standard to something other than C++14, there are a number of lit
tests that fail as they rely on the C++14 default.
This patch just adds the language standard option explicitly to such test cases.

Differential revision: https://reviews.llvm.org/D57581

Modified:
cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
cfe/trunk/test/CodeGenCXX/new-overflow.cpp
cfe/trunk/test/CodeGenCXX/new.cpp
cfe/trunk/test/Lexer/cxx-features.cpp
cfe/trunk/test/Lexer/half-literal.cpp
cfe/trunk/test/Modules/friend-definition-2.cpp
cfe/trunk/test/Modules/merge-lambdas.cpp
cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
cfe/trunk/test/SemaTemplate/argument-dependent-lookup.cpp
cfe/trunk/test/SemaTemplate/class-template-decl.cpp
cfe/trunk/test/SemaTemplate/typo-dependent-name.cpp

Modified: cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp?rev=353163&r1=353162&r2=353163&view=diff
==
--- cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp 
(original)
+++ cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp Tue 
Feb  5 04:05:53 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:24:5 %s -o 
- 2>&1 | FileCheck %s
 template 
 auto make_func() {
   struct impl {

Modified: cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp?rev=353163&r1=353162&r2=353163&view=diff
==
--- cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp (original)
+++ cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp Tue Feb  5 04:05:53 2019
@@ -1,7 +1,7 @@
 // We run clang in completion mode to force skipping of function bodies and
 // check if the function bodies were skipped by observing the warnings that
 // clang produces.
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:60:1 %s -o - 2>&1 
| FileCheck %s
+// RUN: not %clang_cc1 -std=c++14 -fsyntax-only -code-completion-at=%s:60:1 %s 
-o - 2>&1 | FileCheck %s
 template 
 auto not_skipped() {
   int x;

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=353163&r1=353162&r2=353163&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Tue Feb  5 04:05:53 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks %s -emit-llvm -o - 
| FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefix=PATTERN
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s 
-check-prefix=ZERO
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefix=PATTERN
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s 
-check-prefix=ZERO
 
 template void used(T &) noexcept;
 

Modified: cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp?rev=353163&r1=353162&r2=353163&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp Tue Feb  5 
04:05:53 2019
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
-// RUN: -disable-llvm-passes\
+// RUN: -disable-llvm-passes -std=c++14 \
 // RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
 // RUN: FileCheck --check-prefix=CHECK --check-pref

[PATCH] D57464: Generalize method overloading on addr spaces to C++

2019-02-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:2313
+}
+  }
 

ebevhan wrote:
> Anastasia wrote:
> > ebevhan wrote:
> > > Anastasia wrote:
> > > > ebevhan wrote:
> > > > > Anastasia wrote:
> > > > > > Anastasia wrote:
> > > > > > > ebevhan wrote:
> > > > > > > > Is there a reason that the attributes are parsed here and not 
> > > > > > > > in `ParseFunctionDeclarator` like the rest of the 
> > > > > > > > ref-qualifiers (and the OpenCL++ ASes)?
> > > > > > > > 
> > > > > > > > That is possibly why the parser is getting confused with the 
> > > > > > > > trailing return.
> > > > > > > Good question! I have a feeling that this was done to unify 
> > > > > > > parsing of all CXX members, not just methods. For collecting the 
> > > > > > > method qualifiers it would certainly help making flow more 
> > > > > > > coherent if this was moved to `ParseFunctionDeclarator`. I will 
> > > > > > > try to experiment with this a bit more. What I found strange that 
> > > > > > > the attributes here are attached to the function type itself 
> > > > > > > instead of its  qualifiers. May be @rjmccall can shed some more 
> > > > > > > light on the overall flow...
> > > > > > I looked at this a bit more and it seems that all the GNU 
> > > > > > attributes other than addr spaces belong to the function (not to be 
> > > > > > applied to `this`) for example 
> > > > > > https://blog.timac.org/2016/0716-constructor-and-destructor-attributes/.
> > > > > >  It seems correct to parse them here and apply to the function 
> > > > > > type. Although we could separate parsing of addr space attribute 
> > > > > > only and move into `ParseFunctionDeclarator`.  However this will 
> > > > > > only be needed for the function type not for the data members. So 
> > > > > > not sure whether it will make the flow any cleaner.
> > > > > > I looked at this a bit more and it seems that all the GNU 
> > > > > > attributes other than addr spaces belong to the function (not to be 
> > > > > > applied to this) 
> > > > > 
> > > > > Hm, I know what you mean. It's why Clang usually complains when you 
> > > > > try placing an AS attribute after a function declarator, because it's 
> > > > > trying to apply it to the function rather than the method qualifiers.
> > > > > 
> > > > > > However this will only be needed for the function type not for the 
> > > > > > data members. 
> > > > > 
> > > > > But we aren't really interested in data members, are we? Like struct 
> > > > > fields, non-static data members cannot be qualified with ASes (they 
> > > > > should 'inherit' the AS from the object type), and static ones should 
> > > > > probably just accept ASes as part of the member type itself.
> > > > > 
> > > > > These patches are to enable AS-qualifiers on methods, so it only 
> > > > > stands to reason that those ASes would be parsed along with the other 
> > > > > method qualifiers.
> > > > > 
> > > > > ParseFunctionDeclarator calls ParseTypeQualifierListOpt to get the 
> > > > > cv-qualifier-seq for the method qualifiers. Currently it's set to 
> > > > > `AR_NoAttributesParsed`. If we enable parsing attributes there, then 
> > > > > the qualifier parsing might 'eat' attributes that were possibly meant 
> > > > > for the function.
> > > > > 
> > > > > This is just a guess, but what I think you could do is include 
> > > > > attributes in the cv-qualifier parsing with `AR_GNUAttributesParsed`, 
> > > > > look for any AS attributes, take their AS and mark them invalid, then 
> > > > > move the attributes (somehow) from the qualifier-DeclSpec to the 
> > > > > `FnAttrs` function attribute list.
> > > > > 
> > > > > (The reason I'm concerned about where/how the qualifiers are parsed 
> > > > > is because this approach only works for custom ASes applied with the 
> > > > > GNU attribute directly. It won't work if custom address spaces are 
> > > > > given with a custom keyword qualifier, like in OpenCL. If the ASes 
> > > > > are parsed into the DeclSpec used for the other ref-qualifiers, then 
> > > > > both of these cases should 'just work'.)
> > > > > But we aren't really interested in data members, are we? Like struct 
> > > > > fields, non-static data members cannot be qualified with ASes (they 
> > > > > should 'inherit' the AS from the object type), and static ones should 
> > > > > probably just accept ASes as part of the member type itself.
> > > >  
> > > > Pointer data members can be qualified by and address space, but this 
> > > > should be parsed before.
> > > > 
> > > > 
> > > > > This is just a guess, but what I think you could do is include 
> > > > > attributes in the cv-qualifier parsing with AR_GNUAttributesParsed, 
> > > > > look for any AS attributes, take their AS and mark them invalid, then 
> > > > > move the attributes (somehow) from the qualifier-DeclSpec to the 
> > > > > FnAttrs function attribute list.
> > > > 
> > > > O

[PATCH] D57581: Explicitly add language standard option to test cases that rely on the C++14 default

2019-02-05 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353163: [NFC] Explicitly add -std=c++14 option to tests that 
rely on the C++14 default (authored by nemanjai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57581?vs=185093&id=185278#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57581

Files:
  cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
  cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
  cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
  cfe/trunk/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  cfe/trunk/test/CodeGenCXX/new-overflow.cpp
  cfe/trunk/test/CodeGenCXX/new.cpp
  cfe/trunk/test/Lexer/cxx-features.cpp
  cfe/trunk/test/Lexer/half-literal.cpp
  cfe/trunk/test/Modules/friend-definition-2.cpp
  cfe/trunk/test/Modules/merge-lambdas.cpp
  cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  cfe/trunk/test/SemaTemplate/argument-dependent-lookup.cpp
  cfe/trunk/test/SemaTemplate/class-template-decl.cpp
  cfe/trunk/test/SemaTemplate/typo-dependent-name.cpp

Index: cfe/trunk/test/SemaTemplate/typo-dependent-name.cpp
===
--- cfe/trunk/test/SemaTemplate/typo-dependent-name.cpp
+++ cfe/trunk/test/SemaTemplate/typo-dependent-name.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
 
 using nullptr_t = decltype(nullptr);
 
Index: cfe/trunk/test/SemaTemplate/class-template-decl.cpp
===
--- cfe/trunk/test/SemaTemplate/class-template-decl.cpp
+++ cfe/trunk/test/SemaTemplate/class-template-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
 
 template class A;
 
Index: cfe/trunk/test/SemaTemplate/argument-dependent-lookup.cpp
===
--- cfe/trunk/test/SemaTemplate/argument-dependent-lookup.cpp
+++ cfe/trunk/test/SemaTemplate/argument-dependent-lookup.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -verify %s -DHAVE_UNQUALIFIED_LOOKUP_RESULTS
+// RUN: %clang_cc1 -std=c++14 -verify %s
+// RUN: %clang_cc1 -std=c++14 -verify %s -DHAVE_UNQUALIFIED_LOOKUP_RESULTS
 // expected-no-diagnostics
 
 namespace address_of {
Index: cfe/trunk/test/Lexer/cxx-features.cpp
===
--- cfe/trunk/test/Lexer/cxx-features.cpp
+++ cfe/trunk/test/Lexer/cxx-features.cpp
@@ -6,9 +6,9 @@
 //
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
-// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
-// RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
-// RUN: %clang_cc1 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
+// RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
+// RUN: %clang_cc1 -std=c++14 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
 // RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify -fsized-deallocation %s
 
 // expected-no-diagnostics
Index: cfe/trunk/test/Lexer/half-literal.cpp
===
--- cfe/trunk/test/Lexer/half-literal.cpp
+++ cfe/trunk/test/Lexer/half-literal.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple aarch64-linux-gnu %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic -triple aarch64-linux-gnu %s
 float a = 1.0h; // expected-error{{no matching literal operator for call to 'operator""h' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
 float b = 1.0H; // expected-error{{invalid suffix 'H' on floating constant}}
 
Index: cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
===
--- cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
+++ cfe/trunk/test/SemaCXX/int-ptr-cast-SFINAE.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17
 
 void foo(int* a, int *b) {
Index: cfe/trunk/test/Modules/friend-definition-2.cpp
===

[PATCH] D57746: [clangd] Add CLI flag "-clang-tidy" to enable/disable running clang-tidy checks.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57746

Files:
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -203,10 +203,16 @@
 
 static llvm::cl::opt ClangTidyChecks(
 "clang-tidy-checks",
-llvm::cl::desc("List of clang-tidy checks to run (this will override "
-   ".clang-tidy files)"),
+llvm::cl::desc(
+"List of clang-tidy checks to run (this will override "
+".clang-tidy files). Only meaningful when -clang-tidy flag is on."),
 llvm::cl::init(""));
 
+static llvm::cl::opt EnableClangTidy(
+"clang-tidy",
+llvm::cl::desc("Enable clang-tidy diagnostics."),
+llvm::cl::init(true));
+
 static llvm::cl::opt SuggestMissingIncludes(
 "suggest-missing-includes",
 llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -441,13 +447,16 @@
   }
 
   // Create an empty clang-tidy option.
-  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-  OverrideClangTidyOptions.Checks = ClangTidyChecks;
-  tidy::FileOptionsProvider ClangTidyOptProvider(
-  tidy::ClangTidyGlobalOptions(),
-  /* Default */ tidy::ClangTidyOptions::getDefaults(),
-  /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
-  Opts.ClangTidyOptProvider = &ClangTidyOptProvider;
+  std::unique_ptr ClangTidyOptProvider;
+  if (EnableClangTidy) {
+auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+OverrideClangTidyOptions.Checks = ClangTidyChecks;
+ClangTidyOptProvider = llvm::make_unique(
+tidy::ClangTidyGlobalOptions(),
+/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
+  }
+  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   ClangdLSPServer LSPServer(
   *TransportLayer, FSProvider, CCOpts, CompileCommandsDirPath,


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -203,10 +203,16 @@
 
 static llvm::cl::opt ClangTidyChecks(
 "clang-tidy-checks",
-llvm::cl::desc("List of clang-tidy checks to run (this will override "
-   ".clang-tidy files)"),
+llvm::cl::desc(
+"List of clang-tidy checks to run (this will override "
+".clang-tidy files). Only meaningful when -clang-tidy flag is on."),
 llvm::cl::init(""));
 
+static llvm::cl::opt EnableClangTidy(
+"clang-tidy",
+llvm::cl::desc("Enable clang-tidy diagnostics."),
+llvm::cl::init(true));
+
 static llvm::cl::opt SuggestMissingIncludes(
 "suggest-missing-includes",
 llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -441,13 +447,16 @@
   }
 
   // Create an empty clang-tidy option.
-  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-  OverrideClangTidyOptions.Checks = ClangTidyChecks;
-  tidy::FileOptionsProvider ClangTidyOptProvider(
-  tidy::ClangTidyGlobalOptions(),
-  /* Default */ tidy::ClangTidyOptions::getDefaults(),
-  /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
-  Opts.ClangTidyOptProvider = &ClangTidyOptProvider;
+  std::unique_ptr ClangTidyOptProvider;
+  if (EnableClangTidy) {
+auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+OverrideClangTidyOptions.Checks = ClangTidyChecks;
+ClangTidyOptProvider = llvm::make_unique(
+tidy::ClangTidyGlobalOptions(),
+/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
+  }
+  Opts.ClangTidyOptProvider = ClangTidyOptProvider.get();
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   ClangdLSPServer LSPServer(
   *TransportLayer, FSProvider, CCOpts, CompileCommandsDirPath,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-02-05 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 185283.
lewis-revill added a comment.
Herald added a project: clang.

Added RISC-V to thread specifier test as a means of checking TLS is supported.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57055

Files:
  lib/Basic/Targets/RISCV.h
  test/CodeGen/thread-specifier.c


Index: test/CodeGen/thread-specifier.c
===
--- test/CodeGen/thread-specifier.c
+++ test/CodeGen/thread-specifier.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: @b = external thread_local global
 // CHECK: @d.e = internal thread_local global
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -35,7 +35,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();


Index: test/CodeGen/thread-specifier.c
===
--- test/CodeGen/thread-specifier.c
+++ test/CodeGen/thread-specifier.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: @b = external thread_local global
 // CHECK: @d.e = internal thread_local global
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -35,7 +35,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353116 - [OBJC] Add attribute to mark Objective C class as non-lazy

2019-02-05 Thread Joe Daniels via cfe-commits
Author: joseph_daniels
Date: Mon Feb  4 15:32:55 2019
New Revision: 353116

URL: http://llvm.org/viewvc/llvm-project?rev=353116&view=rev
Log:
[OBJC] Add attribute to mark Objective C class as non-lazy

A non-lazy class will be initialized eagerly when the Objective-C runtime is
loaded. This is required for certain system classes which have instances 
allocated in
non-standard ways, such as the classes for blocks and constant strings.
Adding this attribute is essentially equivalent to providing a trivial
+load method but avoids the (fairly small) load-time overheads associated
with defining and calling such a method.

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

Added:
cfe/trunk/test/SemaObjC/attr-objc-non-lazy.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=353116&r1=353115&r2=353116&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Feb  4 15:32:55 2019
@@ -1758,6 +1758,13 @@ def ObjCRootClass : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def ObjCNonLazyClass : Attr {
+  let Spellings = [Clang<"objc_nonlazy_class">];
+  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let LangOpts = [ObjC];
+  let Documentation = [ObjCNonLazyClassDocs];
+}
+
 def ObjCSubclassingRestricted : InheritableAttr {
   let Spellings = [Clang<"objc_subclassing_restricted">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=353116&r1=353115&r2=353116&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Feb  4 15:32:55 2019
@@ -3699,6 +3699,19 @@ ensure that this class cannot be subclas
   }];
 }
 
+def ObjCNonLazyClassDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+This attribute can be added to an Objective-C ``@interface`` declaration to
+add the class to the list of non-lazily initialized classes. A non-lazy class
+will be initialized eagerly when the Objective-C runtime is loaded.  This is
+required for certain system classes which have instances allocated in
+non-standard ways, such as the classes for blocks and constant strings.  Adding
+this attribute is essentially equivalent to providing a trivial `+load` method 
+but avoids the (fairly small) load-time overheads associated with defining and
+calling such a method.
+  }];
+}
 
 def SelectAnyDocs : Documentation {
   let Category = DocCatType;

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=353116&r1=353115&r2=353116&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Feb  4 15:32:55 2019
@@ -6261,9 +6261,10 @@ CGObjCNonFragileABIMac::BuildClassObject
   return GV;
 }
 
-bool
-CGObjCNonFragileABIMac::ImplementationIsNonLazy(const ObjCImplDecl *OD) const {
-  return OD->getClassMethod(GetNullarySelector("load")) != nullptr;
+bool CGObjCNonFragileABIMac::ImplementationIsNonLazy(
+const ObjCImplDecl *OD) const {
+  return OD->getClassMethod(GetNullarySelector("load")) != nullptr ||
+ OD->getClassInterface()->hasAttr();
 }
 
 void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl 
*OID,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=353116&r1=353115&r2=353116&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Feb  4 15:32:55 2019
@@ -6832,6 +6832,9 @@ static void ProcessDeclAttribute(Sema &S
   case ParsedAttr::AT_ObjCRootClass:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_ObjCNonLazyClass:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_ObjCSubclassingRestricted:
 handleSimpleAttribute(S, D, AL);
 break;

Modified: cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/non-lazy-classes.m?rev=353116&r1=353115&r2=353116&view=diff
==
--- cfe/trunk/test/CodeGenObjC/

[PATCH] D57747: [Sema] SequenceChecker: Fix handling of operator ||, && and ?:

2019-02-05 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: aaron.ballman, rsmith.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

The current handling of the operators `||`, `&&` and `?:` has a number of false 
positive and false negative. The issues for operator `||` and `&&` are:

1. We need to add sequencing regions for the LHS and RHS as is done for the 
comma operator. Not doing so causes false positives in expressions like `((a++, 
false) || (a++, false));` (from PR39779, see PR22197 for another example).

2. In the current implementation when the evaluation of the LHS fails, the RHS 
is added to a worklist to be processed later. This results in false negatives 
in expressions like `(a && a++) + a`.

Fix these issues by introducing sequencing regions for the LHS and RHS, and by 
not deferring the visitation of the RHS.

The issues with the ternary operator `?:` are similar, with the added twist 
that we should not warn on expressions like `(x ? y += 1 : y += 2)` since 
exactly one of the 2nd and 3rd expression is going to be evaluated, but we 
should still warn on expressions like `(x ? y += 1 : y += 2) = y`.


Repository:
  rC Clang

https://reviews.llvm.org/D57747

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/warn-unsequenced.c
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused -Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
+int g1();
+int g2(int);
 
 struct A {
   int x, y;
@@ -57,20 +59,20 @@
   a = A { ++a, a++ }.x; // expected-warning {{unsequenced modifications to 'a'}}
   A { ++a, a++ }.x + A { ++a, a++ }.y; // expected-warning {{unsequenced modifications to 'a'}}
 
-  (xs[2] && (a = 0)) + a; // ok
+  (xs[2] && (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (0 && (a = 0)) + a; // ok
   (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
-  (xs[3] || (a = 0)) + a; // ok
+  (xs[3] || (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 || (a = 0)) + a; // ok
 
-  (xs[4] ? a : ++a) + a; // ok
+  (xs[4] ? a : ++a) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 ? a : ++a) + a; // ok
   (0 ? a : a++) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 ? a : a++) + a; // ok
-  (xs[5] ? ++a : ++a) + a; // FIXME: warn here
+  (xs[5] ? ++a : ++a) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
   (++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
@@ -93,10 +95,10 @@
   // unconditional.
   a = a++ && f(a, a);
 
-  // This has undefined behavior if a != 0. FIXME: We should diagnose this.
-  (a && a++) + a;
+  // This has undefined behavior if a != 0.
+  (a && a++) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
-  (xs[7] && ++a) * (!xs[7] && ++a); // ok
+  (xs[7] && ++a) * (!xs[7] && ++a); // expected-warning {{multiple unsequenced modifications to 'a'}}
 
   xs[0] = (a = 1, a); // ok
   (a -= 128) &= 128; // ok
@@ -104,11 +106,49 @@
 
   xs[8] ? ++a + a++ : 0; // expected-warning {{multiple unsequenced modifications to 'a'}}
   xs[8] ? 0 : ++a + a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  xs[8] ? ++a : a++; // ok
+  xs[8] ? ++a : a++; // no-warning
+  xs[8] ? a+=1 : a+= 2; // no-warning
+  (xs[8] ? a+=1 : a+= 2) = a; // expected-warning {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a+=1 : a) = a; // expected-warning {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a : a+= 2) = a; // expected-warning {{unsequenced modification and access to 'a'}}
+  a = (xs[8] ? a+=1 : a+= 2); // no-warning
+  a += (xs[8] ? a+=1 : a+= 2); // expected-warning {{unsequenced modification and access to 'a'}}
+
+  (false ? a+=1 : a) = a; // no-warning
+  (true ? a+=1 : a) = a; // expected-warning {{unsequenced modification and access to 'a'}}
+  (false ? a : a+=2) = a; // expected-warning {{unsequenced modification and access to 'a'}}
+  (true ? a : a+=2) = a; // no-warning
 
   xs[8] && (++a + a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
   xs[8] || (++a + a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
 
+  ((a++, false) || (a++, false)); // no-warning PR39779
+  ((a++, true) && (a++, true)); // no-warning PR39779
+
+  int i,j;
+  (i = g1(), false) || (j = g2(i)); // no-warning PR22197
+  (i = g1(), true) && (j = g2(i)); // no-warning PR22197
+
+  (a++, false) || (a++, false) || (a++, false) || 

[PATCH] D57464: Generalize method overloading on addr spaces to C++

2019-02-05 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:2313
+}
+  }
 

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > Anastasia wrote:
> > > > > ebevhan wrote:
> > > > > > Anastasia wrote:
> > > > > > > Anastasia wrote:
> > > > > > > > ebevhan wrote:
> > > > > > > > > Is there a reason that the attributes are parsed here and not 
> > > > > > > > > in `ParseFunctionDeclarator` like the rest of the 
> > > > > > > > > ref-qualifiers (and the OpenCL++ ASes)?
> > > > > > > > > 
> > > > > > > > > That is possibly why the parser is getting confused with the 
> > > > > > > > > trailing return.
> > > > > > > > Good question! I have a feeling that this was done to unify 
> > > > > > > > parsing of all CXX members, not just methods. For collecting 
> > > > > > > > the method qualifiers it would certainly help making flow more 
> > > > > > > > coherent if this was moved to `ParseFunctionDeclarator`. I will 
> > > > > > > > try to experiment with this a bit more. What I found strange 
> > > > > > > > that the attributes here are attached to the function type 
> > > > > > > > itself instead of its  qualifiers. May be @rjmccall can shed 
> > > > > > > > some more light on the overall flow...
> > > > > > > I looked at this a bit more and it seems that all the GNU 
> > > > > > > attributes other than addr spaces belong to the function (not to 
> > > > > > > be applied to `this`) for example 
> > > > > > > https://blog.timac.org/2016/0716-constructor-and-destructor-attributes/.
> > > > > > >  It seems correct to parse them here and apply to the function 
> > > > > > > type. Although we could separate parsing of addr space attribute 
> > > > > > > only and move into `ParseFunctionDeclarator`.  However this will 
> > > > > > > only be needed for the function type not for the data members. So 
> > > > > > > not sure whether it will make the flow any cleaner.
> > > > > > > I looked at this a bit more and it seems that all the GNU 
> > > > > > > attributes other than addr spaces belong to the function (not to 
> > > > > > > be applied to this) 
> > > > > > 
> > > > > > Hm, I know what you mean. It's why Clang usually complains when you 
> > > > > > try placing an AS attribute after a function declarator, because 
> > > > > > it's trying to apply it to the function rather than the method 
> > > > > > qualifiers.
> > > > > > 
> > > > > > > However this will only be needed for the function type not for 
> > > > > > > the data members. 
> > > > > > 
> > > > > > But we aren't really interested in data members, are we? Like 
> > > > > > struct fields, non-static data members cannot be qualified with 
> > > > > > ASes (they should 'inherit' the AS from the object type), and 
> > > > > > static ones should probably just accept ASes as part of the member 
> > > > > > type itself.
> > > > > > 
> > > > > > These patches are to enable AS-qualifiers on methods, so it only 
> > > > > > stands to reason that those ASes would be parsed along with the 
> > > > > > other method qualifiers.
> > > > > > 
> > > > > > ParseFunctionDeclarator calls ParseTypeQualifierListOpt to get the 
> > > > > > cv-qualifier-seq for the method qualifiers. Currently it's set to 
> > > > > > `AR_NoAttributesParsed`. If we enable parsing attributes there, 
> > > > > > then the qualifier parsing might 'eat' attributes that were 
> > > > > > possibly meant for the function.
> > > > > > 
> > > > > > This is just a guess, but what I think you could do is include 
> > > > > > attributes in the cv-qualifier parsing with 
> > > > > > `AR_GNUAttributesParsed`, look for any AS attributes, take their AS 
> > > > > > and mark them invalid, then move the attributes (somehow) from the 
> > > > > > qualifier-DeclSpec to the `FnAttrs` function attribute list.
> > > > > > 
> > > > > > (The reason I'm concerned about where/how the qualifiers are parsed 
> > > > > > is because this approach only works for custom ASes applied with 
> > > > > > the GNU attribute directly. It won't work if custom address spaces 
> > > > > > are given with a custom keyword qualifier, like in OpenCL. If the 
> > > > > > ASes are parsed into the DeclSpec used for the other 
> > > > > > ref-qualifiers, then both of these cases should 'just work'.)
> > > > > > But we aren't really interested in data members, are we? Like 
> > > > > > struct fields, non-static data members cannot be qualified with 
> > > > > > ASes (they should 'inherit' the AS from the object type), and 
> > > > > > static ones should probably just accept ASes as part of the member 
> > > > > > type itself.
> > > > >  
> > > > > Pointer data members can be qualified by and address space, but this 
> > > > > should be parsed before.
> > > > > 
> > > > > 
> > > > > > This is just a guess, but what I think you could do is include 
> > > > > > attributes in the cv-qualifier parsing with AR_GNUAttributesParsed, 
> > > > > > look for any AS attributes, take the

[PATCH] D54604: Automatic variable initialization

2019-02-05 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.
Herald added a project: LLVM.

I think doing separate stores of 0xAA into struct members instead of copying 
part of .rodata over it will let us do a much better job in optimizing away 
redundant stores.
I've opened https://bugs.llvm.org/show_bug.cgi?id=40605 to track that.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54604



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


[PATCH] D57740: [ASTImporter] Import every Decl in lambda record

2019-02-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:2432
+  EXPECT_TRUE(ToD);
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  CXXRecordDecl *LambdaRec =

Actually the `ToTU` is not needed, this line can be removed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57740



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


[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Aaron, Alex, any additional comments on this change?


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

https://reviews.llvm.org/D56850



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


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 185306.
hokein marked 9 inline comments as done.
hokein added a comment.

Adress review comments.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Format.h
  unittests/clangd/TweakTests.cpp

Index: unittests/clangd/TweakTests.cpp
===
--- unittests/clangd/TweakTests.cpp
+++ unittests/clangd/TweakTests.cpp
@@ -9,6 +9,7 @@
 
 #include "Annotations.h"
 #include "SourceCode.h"
+#include "Format.h"
 #include "TestTU.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
@@ -77,7 +78,8 @@
 void checkNotAvailable(StringRef ID, llvm::StringRef Input) {
   return checkAvailable(ID, Input, /*Available=*/false);
 }
-llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
+llvm::Expected apply(StringRef ID, llvm::StringRef Input,
+  bool Format) {
   Annotations Code(Input);
   Range SelectionRng;
   if (Code.points().size() != 0) {
@@ -102,12 +104,19 @@
   auto Replacements = (*T)->apply(S);
   if (!Replacements)
 return Replacements.takeError();
+  if (Format) {
+Replacements = cleanupAndFormat(
+Code.code(), *Replacements,
+clang::format::getLLVMStyle());
+if (!Replacements)
+  return Replacements.takeError();
+  }
   return applyAllReplacements(Code.code(), *Replacements);
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
-llvm::StringRef Output) {
-  EXPECT_THAT_EXPECTED(apply(ID, Input), HasValue(Output))
+llvm::StringRef Output, bool Format = false) {
+  EXPECT_THAT_EXPECTED(apply(ID, Input, Format), HasValue(Output))
   << "action id is" << ID;
 }
 
@@ -150,6 +159,22 @@
   )cpp";
   checkTransform(ID, Input, Output);
 
+  Input = R"cpp(
+void test() {
+  ^if () { return 100; } else { continue; }
+}
+  )cpp";
+  Output = R"cpp(
+void test() {
+  if () {
+continue;
+  } else {
+return 100;
+  }
+}
+  )cpp";
+  checkTransform(ID, Input, Output, /*Format=*/true);
+
   // Available in subexpressions of the condition.
   checkAvailable(ID, R"cpp(
 void test() {
Index: clangd/Format.h
===
--- /dev/null
+++ clangd/Format.h
@@ -0,0 +1,28 @@
+//===--- Format.h *- 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
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+
+// Cleanup and format the given replacements.
+inline llvm::Expected
+cleanupAndFormat(StringRef Code, const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style) {
+  auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  if (!CleanReplaces)
+return CleanReplaces;
+  return formatReplacements(Code, std::move(*CleanReplaces), Style);
+}
+
+} // namespace clangd
+} // namespace clang
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -23,6 +23,7 @@
 #include "index/FileIndex.h"
 #include "index/Index.h"
 #include "refactor/Tweak.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/FunctionExtras.h"
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -10,6 +10,7 @@
 #include "ClangdUnit.h"
 #include "CodeComplete.h"
 #include "FindSymbols.h"
+#include "Format.h"
 #include "Headers.h"
 #include "SourceCode.h"
 #include "Trace.h"
@@ -362,8 +363,9 @@
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
   Callback CB) {
-  auto Action = [Sel](decltype(CB) CB, std::string File, std::string TweakID,
-  Expected InpAST) {
+  auto Action = [Sel, this](decltype(CB) CB, std::string File,
+std::string TweakID,
+Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Selection = tweakSelection(Sel, *InpAST);
@@ -372,8 +374,15 @@
 auto A = prepareTweak(TweakID, *Selection);
 if (!A)
   return CB(A.takeError());
-// FIXME: run formatter on top of resulting replacements.
-return CB((*A)->apply(*Selection));
+auto R

[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D57739#1384844 , @ilya-biryukov 
wrote:

> Could we move the code to the `Tweak` itself, so that all the callers would 
> get the formatting? I.e.
>
>   class Tweak {
>  Replacements apply() {  // This is now non-virtual.
>auto Replacements = doApply();
>return cleanupAndFormat(Replacements);
>  }
>  
>   protected:
>  virtual Replacements doApply() = 0; // inheritors should implement this 
> now. Note: the name is terrible, suggestions are welcome.
>   };
>
>
> This would ensure the callers don't need to deal with the formatting on their 
> own.


This seems introduce intrusive changes to the Tweak interface (Tweak will need 
to know the `FormatStyle` somehow), I think this might be done in another patch.




Comment at: clangd/ClangdServer.cpp:366
+  auto Style = getFormatStyle(Code, File);
+  if (!Style)
+return;

ilya-biryukov wrote:
> ioeric wrote:
> > hokein wrote:
> > > not sure the err-handling strategy here -- maybe if this is failed, we 
> > > still apply replacements (without formatting), rather than stopping.
> > You should use `getFormatStyleForFile` from SourceCode.h
> > not sure the err-handling strategy here -- maybe if this is failed, we 
> > still apply replacements (without formatting), rather than stopping.
> Returning an error seems fine, this probably shouldn't happen under normal 
> conditions and failing early means we're more likely to find the root-cause 
> of the problem.
> You should use getFormatStyleForFile from SourceCode.h

Thanks for pointing it out! Didn't notice this method. I think we need to cache 
it somehow rather than calling this method every time.

> Returning an error seems fine, this probably shouldn't happen under normal 
> conditions and failing early means we're more likely to find the root-cause 
> of the problem.

I switched to use getFormatStyleForFile, it seems a reasonable API. 



Comment at: clangd/ClangdServer.h:267
+  /// slow. Think of a way to cache this.
+  llvm::Expected getFormatStyle(llvm::StringRef Code,
+ PathRef File);

ilya-biryukov wrote:
> NIT: could we swap the parameters for consistency with the other functions in 
> this class (i.e. `File` goes first)
removed, not needed any more.



Comment at: unittests/clangd/TweakTests.cpp:82
+llvm::Expected apply(StringRef ID, llvm::StringRef Input,
+  bool Format) {
   Annotations Code(Input);

ilya-biryukov wrote:
> NIT: remove the parameter, this should be the default.
> At least until we run into the checks that deliberately don't want the 
> formatting
I'm ok to make this change. I tempt to keep it because it would make writing 
test code easier -- if we always format the code, we might spend time on 
figuring out the format diff between `Before` and `After`, which is not worth.



Comment at: unittests/clangd/TweakTests.cpp:110
+Code.code(), *Replacements,
+clang::format::getGoogleStyle(::clang::format::FormatStyle::LK_Cpp));
+if (!Replacements)

ilya-biryukov wrote:
> NIT: maybe prefer LLVM style? To avoid context-switching.
good catch.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


[PATCH] D56849: [ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.

2019-02-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 185309.
ymandel added a comment.
Herald added a project: clang.

Sync'd with master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56849

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h

Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2886,14 +2886,22 @@
  InnerMatcher.matches(*UnderlyingDecl, Finder, Builder);
 }
 
-/// Matches on the implicit object argument of a member call expression.
+/// Matches on the implicit object argument of a member call expression, after
+/// stripping off any parentheses or implicit casts.
 ///
-/// Example matches y.x()
-///   (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))
+/// Given
 /// \code
-///   class Y { public: void x(); };
-///   void z() { Y y; y.x(); }
+///   class Y { public: void m(); };
+///   Y g();
+///   class X : public Y {};
+///   void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
 /// \endcode
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")
+///   matches `y.m()` and `(g()).m()`.
+/// cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")
+///   matches `x.m()`.
+/// cxxMemberCallExpr(on(callExpr()))
+///   matches `(g()).m()`.
 ///
 /// FIXME: Overload to allow directly matching types?
 AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher,
@@ -3253,6 +3261,23 @@
   .matches(Node, Finder, Builder);
 }
 
+/// Matches on the implicit object argument of a member call expression. Unlike
+/// `on`, matches the argument directly without stripping away anything.
+///
+/// Given
+/// \code
+///   class Y { public: void m(); };
+///   Y g();
+///   class X : public Y { void g(); };
+///   void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
+/// \endcode
+/// cxxMemberCallExpr(onImplicitObjectArgument(hasType(
+/// cxxRecordDecl(hasName("Y")
+///   matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
+/// cxxMemberCallExpr(on(callExpr()))
+///   does not match `(g()).m()`, because the parens are not ignored.
+///
+/// FIXME: Overload to allow directly matching types?
 AST_MATCHER_P(CXXMemberCallExpr, onImplicitObjectArgument,
   internal::Matcher, InnerMatcher) {
   const Expr *ExprNode = Node.getImplicitObjectArgument();
@@ -3260,8 +3285,22 @@
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
-/// Matches if the expression's type either matches the specified
-/// matcher, or is a pointer to a type that matches the InnerMatcher.
+/// Matches if the type of the expression's implicit object argument either
+/// matches the InnerMatcher, or is a pointer to a type that matches the
+/// InnerMatcher.
+///
+/// Given
+/// \code
+///   class Y { public: void m(); };
+///   class X : public Y { void g(); };
+///   void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); }
+/// \endcode
+/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
+/// cxxRecordDecl(hasName("Y")
+///   matches `y.m()`, `p->m()` and `x.m()`.
+/// cxxMemberCallExpr(thisPointerType(hasDeclaration(
+/// cxxRecordDecl(hasName("X")
+///   matches `x.g()`.
 AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
internal::Matcher, InnerMatcher, 0) {
   return onImplicitObjectArgument(
@@ -4963,18 +5002,22 @@
   return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
 }
 
-/// Matches a member expression where the object expression is
-/// matched by a given matcher.
+/// Matches a member expression where the object expression is matched by a
+/// given matcher. Implicit object expressions are included; that is, it matches
+/// use of implicit `this`.
 ///
 /// Given
 /// \code
-///   struct X { int m; };
-///   void f(X x) { x.m; m; }
+///   struct X {
+/// int m;
+/// int f(X x) { x.m; return m; }
+///   };
 /// \endcode
-/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))
-///   matches "x.m" and "m"
-/// with hasObjectExpression(...)
-///   matching "x" and the implicit object expression of "m" which has type X*.
+/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")
+///   matches `x.m`, but not `m`; however,
+/// memberExpr(hasObjectExpression(hasType(pointsTo(
+//  cxxRecordDecl(hasName("X"))
+///   matches `m` (aka. `this->m`), but not `x.m`.
 AST_POLYMORPHIC_MATCHER_P(
 hasObjectExpression,
 AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -4810,16 +4810,20 @@
 
 
 Matcher

[PATCH] D56849: [ASTMatchers][NFC] Update comments on assorted `CXXMemberCallExpr` matchers.

2019-02-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Alex, can you please submit this?  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56849



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


[PATCH] D57755: [clangd] Some minor fixes.

2019-02-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57755

Files:
  clangd/Selection.cpp
  clangd/refactor/Tweak.h
  unittests/clangd/SelectionTests.cpp
  unittests/clangd/TweakTests.cpp


Index: unittests/clangd/TweakTests.cpp
===
--- unittests/clangd/TweakTests.cpp
+++ unittests/clangd/TweakTests.cpp
@@ -1,9 +1,8 @@
 //===-- TweakTests.cpp --*- C++ 
-*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 
//===--===//
 
Index: unittests/clangd/SelectionTests.cpp
===
--- unittests/clangd/SelectionTests.cpp
+++ unittests/clangd/SelectionTests.cpp
@@ -1,4 +1,4 @@
-//===-- RIFFTests.cpp - Binary container unit tests 
---===//
+//===-- SelectionTests.cpp - 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clangd/refactor/Tweak.h
===
--- clangd/refactor/Tweak.h
+++ clangd/refactor/Tweak.h
@@ -56,8 +56,8 @@
   /// defining the Tweak. Definition is provided automatically by
   /// REGISTER_TWEAK.
   virtual const char *id() const = 0;
-  /// Run the first stage of the action. The non-None result indicates that the
-  /// action is available and should be shown to the user. Returns None if the
+  /// Run the first stage of the action. Returns true indicating that the
+  /// action is available and should be shown to the user. Returns false if the
   /// action is not available.
   /// This function should be fast, if the action requires non-trivial work it
   /// should be moved into 'apply'.
Index: clangd/Selection.cpp
===
--- clangd/Selection.cpp
+++ clangd/Selection.cpp
@@ -1,4 +1,4 @@
-//===--- Selection.h 
--===//
+//===--- Selection.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: unittests/clangd/TweakTests.cpp
===
--- unittests/clangd/TweakTests.cpp
+++ unittests/clangd/TweakTests.cpp
@@ -1,9 +1,8 @@
 //===-- TweakTests.cpp --*- C++ -*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 //===--===//
 
Index: unittests/clangd/SelectionTests.cpp
===
--- unittests/clangd/SelectionTests.cpp
+++ unittests/clangd/SelectionTests.cpp
@@ -1,4 +1,4 @@
-//===-- RIFFTests.cpp - Binary container unit tests ---===//
+//===-- SelectionTests.cpp - --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
Index: clangd/refactor/Tweak.h
===
--- clangd/refactor/Tweak.h
+++ clangd/refactor/Tweak.h
@@ -56,8 +56,8 @@
   /// defining the Tweak. Definition is provided automatically by
   /// REGISTER_TWEAK.
   virtual const char *id() const = 0;
-  /// Run the first stage of the action. The non-None result indicates that the
-  /// action is available and should be shown to the user. Returns None if the
+  /// Run the first stage of the action. Returns true indicating that the
+  /// action is available and should be shown to the user. Returns false if the
   /// action is not available.
   /// This function should be fast, if the action requires non-trivial work it
   /// should be moved into 'apply'.
Index: clangd/Selection.cpp
=

[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

2019-02-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1259-1260
+  // This gets the index of the last Stmt before the trailing NullStmts. If
+  // this compound expression contains nothing but NullStmts, then we return
+  // the index of the last one. If the compound statement is empty, return
+  // None.

Given the name of the function, why return the index of the last null statement 
if it only contains null statements? 



Comment at: clang/include/clang/AST/Stmt.h:1270
+}
+return size() - 1;
+  }

The only way you can get here is if all statements are null statements, so this 
should return `None` as well, shouldn't it?



Comment at: clang/include/clang/AST/Stmt.h:1315-1316
+Optional ExprResult = getIndexOfLastNonNullStmt();
+return ExprResult.hasValue() ? body_begin()[ExprResult.getValue()]
+ : nullptr;
   }

`return ExprResult ? body_begin()[*ExprResult] : nullptr;`


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

https://reviews.llvm.org/D57086



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


r353181 - [opaque pointer types] Fix the CallInfo passed to EmitCall in some

2019-02-05 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Feb  5 08:05:50 2019
New Revision: 353181

URL: http://llvm.org/viewvc/llvm-project?rev=353181&view=rev
Log:
[opaque pointer types] Fix the CallInfo passed to EmitCall in some
edge cases.

Currently, EmitCall emits a call instruction with a function type
derived from the pointee-type of the callee. This *should* be the same
as the type created from the CallInfo parameter, but in some cases an
incorrect CallInfo was being passed.

All of these fixes were discovered by the addition of the assert in
EmitCall which verifies that the passed-in CallInfo matches the
Callee's function type.

As far as I know, these issues caused no bugs at the moment, as the
correct types were ultimately being emitted. But, some would become
problematic when pointee types are removed.

List of fixes:

* arrangeCXXConstructorCall was passing an incorrect value for the
  number of Required args, when calling an inheriting constructor
  where the inherited constructor is variadic. (The inheriting
  constructor doesn't actually get passed any of the user's args, but
  the code was calculating it as if it did).

* arrangeFreeFunctionLikeCall was not including the count of the
  pass_object_size arguments in the count of required args.

* OpenCL uses other address spaces for the "this" pointer. However,
  commonEmitCXXMemberOrOperatorCall was not annotating the address
  space on the "this" argument of the call.

* Destructor calls were being created with EmitCXXMemberOrOperatorCall
  instead of EmitCXXDestructorCall in a few places. This was a problem
  because the calling convention sometimes has destructors returning
  "this" rather than void, and the latter function knows about that,
  and sets up the types properly (through calling
  arrangeCXXStructorDeclaration), while the former does not.

* generateObjCGetterBody: the 'objc_getProperty' function returns type
  'id', but was being called as if it returned the particular
  property's type. (That is of course the *dynamic* return type, and
  there's a downcast immediately after.)

* OpenMP user-defined reduction functions (#pragma omp declare
  reduction) can be called with a subclass of the declared type. In
  such case, the call was being setup as if the function had been
  actually declared to take the subtype, rather than the base type.

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

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/CodeGenObjC/getter-property-mismatch.m

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=353181&r1=353180&r2=353181&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb  5 08:05:50 2019
@@ -67,10 +67,17 @@ unsigned CodeGenTypes::ClangCallConvToLL
 }
 
 /// Derives the 'this' type for codegen purposes, i.e. ignoring method CVR
-/// qualification.
-static CanQualType GetThisType(ASTContext &Context, const CXXRecordDecl *RD,
-   const CXXMethodDecl *MD) {
-  QualType RecTy = Context.getTagDeclType(RD)->getCanonicalTypeInternal();
+/// qualification. Either or both of RD and MD may be null. A null RD indicates
+/// that there is no meaningful 'this' type, and a null MD can occur when
+/// calling a method pointer.
+CanQualType CodeGenTypes::DeriveThisType(const CXXRecordDecl *RD,
+ const CXXMethodDecl *MD) {
+  QualType RecTy;
+  if (RD)
+RecTy = Context.getTagDeclType(RD)->getCanonicalTypeInternal();
+  else
+RecTy = Context.VoidTy;
+
   if (MD)
 RecTy = Context.getAddrSpaceQualType(RecTy, 
MD->getMethodQualifiers().getAddressSpace());
   return Context.getPointerType(CanQualType::CreateUnsafe(RecTy));
@@ -235,7 +242,7 @@ static CallingConv getCallingConventionF
 
 /// Arrange the argument and result information for a call to an
 /// unknown C++ non-static member function of the given abstract type.
-/// (Zero value of RD means we don't have any meaningful "this" argument type,
+/// (A null RD means we don't have any meaningful "this" argument type,
 ///  so fall back to a generic pointer type).
 /// The member function must be an ordinary function, i.e. not a
 /// constructor or destructor.
@@ -246,10 +253,7 @@ CodeGenTypes::arrangeCXXMethodType(const
   SmallVector argTypes;
 
   // Add the 'this' pointer.
-  if (RD)
-argTypes.push_back(GetThisType(Context, RD, MD));
-  else
-argTypes.push_back(Context.VoidPtrTy);
+  argTypes.push_back(DeriveThisType(RD, MD));
 
   return ::arrangeLLVMFunctionInfo(
   *this, true, argTypes,
@@ -303,7 +307,7 @@ CodeGenTypes::arrangeCXXStructorDeclarat
 
   SmallVector argTypes;
   

[PATCH] D57664: [opaque pointer types] Fix the CallInfo passed to EmitCall in some edge cases.

2019-02-05 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353181: [opaque pointer types] Fix the CallInfo passed to 
EmitCall in some (authored by jyknight, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57664?vs=184975&id=185313#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57664

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaOpenMP.cpp
  test/CodeGenObjC/getter-property-mismatch.m

Index: test/CodeGenObjC/getter-property-mismatch.m
===
--- test/CodeGenObjC/getter-property-mismatch.m
+++ test/CodeGenObjC/getter-property-mismatch.m
@@ -15,6 +15,4 @@
 
 // CHECK:  [[CALL:%.*]] = tail call i8* @objc_getProperty
 // CHECK:  [[ONE:%.*]] = bitcast i8* [[CALL:%.*]] to [[T1:%.*]]*
-// CHECK:  [[TWO:%.*]] = bitcast [[T1]]* [[ONE]] to [[T2:%.*]]*
-// CHECK:  ret [[T2]]* [[TWO]]
-
+// CHECK:  ret [[T1]]* [[ONE]]
Index: lib/CodeGen/CodeGenTypes.h
===
--- lib/CodeGen/CodeGenTypes.h
+++ lib/CodeGen/CodeGenTypes.h
@@ -182,6 +182,10 @@
   /// Convert clang calling convention to LLVM callilng convention.
   unsigned ClangCallConvToLLVMCallConv(CallingConv CC);
 
+  /// Derives the 'this' type for codegen purposes, i.e. ignoring method CVR
+  /// qualification.
+  CanQualType DeriveThisType(const CXXRecordDecl *RD, const CXXMethodDecl *MD);
+
   /// ConvertType - Convert type T into a llvm::Type.
   llvm::Type *ConvertType(QualType T);
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1566,9 +1566,8 @@
 Callee = CGCallee::forDirect(
 CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), GD);
 
-  CGF.EmitCXXMemberOrOperatorCall(DD, Callee, ReturnValueSlot(),
-  This.getPointer(), VTT, VTTTy,
-  nullptr, nullptr);
+  CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(), VTT, VTTTy, nullptr,
+getFromDtorType(Type));
 }
 
 void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT,
@@ -1766,9 +1765,8 @@
   CGCallee Callee =
   CGCallee::forVirtual(CE, GlobalDecl(Dtor, DtorType), This, Ty);
 
-  CGF.EmitCXXMemberOrOperatorCall(Dtor, Callee, ReturnValueSlot(),
-  This.getPointer(), /*ImplicitParam=*/nullptr,
-  QualType(), CE, nullptr);
+  CGF.EmitCXXDestructorCall(Dtor, Callee, This.getPointer(), nullptr,
+QualType(), nullptr, getFromDtorType(DtorType));
   return nullptr;
 }
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -67,10 +67,17 @@
 }
 
 /// Derives the 'this' type for codegen purposes, i.e. ignoring method CVR
-/// qualification.
-static CanQualType GetThisType(ASTContext &Context, const CXXRecordDecl *RD,
-   const CXXMethodDecl *MD) {
-  QualType RecTy = Context.getTagDeclType(RD)->getCanonicalTypeInternal();
+/// qualification. Either or both of RD and MD may be null. A null RD indicates
+/// that there is no meaningful 'this' type, and a null MD can occur when
+/// calling a method pointer.
+CanQualType CodeGenTypes::DeriveThisType(const CXXRecordDecl *RD,
+ const CXXMethodDecl *MD) {
+  QualType RecTy;
+  if (RD)
+RecTy = Context.getTagDeclType(RD)->getCanonicalTypeInternal();
+  else
+RecTy = Context.VoidTy;
+
   if (MD)
 RecTy = Context.getAddrSpaceQualType(RecTy, MD->getMethodQualifiers().getAddressSpace());
   return Context.getPointerType(CanQualType::CreateUnsafe(RecTy));
@@ -235,7 +242,7 @@
 
 /// Arrange the argument and result information for a call to an
 /// unknown C++ non-static member function of the given abstract type.
-/// (Zero value of RD means we don't have any meaningful "this" argument type,
+/// (A null RD means we don't have any meaningful "this" argument type,
 ///  so fall back to a generic pointer type).
 /// The member function must be an ordinary function, i.e. not a
 /// constructor or destructor.
@@ -246,10 +253,7 @@
   SmallVector argTypes;
 
   // Add the 'this' pointer.
-  if (RD)
-argTypes.push_back(GetThisType(Context, RD, MD));
-  else
-argTypes.push_back(Context.VoidPtrTy);
+  argTypes.push_back(DeriveThisType(RD, MD));
 
   return ::arrangeLLVMFunctionInfo(
   *this, true, argTypes,
@@ -303,7 +307,7 @@
 
   SmallVector argTypes;
   SmallVector paramInfos;
-  argTypes.push_back(GetThisType(Context, MD->getParent(), MD));
+  argTypes.push_back(DeriveThisType(MD->getParent(), MD));
 

[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

2019-02-05 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1260
+  // this compound expression contains nothing but NullStmts, then we return
+  // the index of the last one. If the compound statement is empty, return
+  // None.

Additionally I am not sure that the comment is optimal. This is inside 
`CompoundStmt` and it is therefore strange to use "if this compound 
expression", since the compound expression is represented with the `StmtExpr` 
node.



Comment at: clang/include/clang/AST/Stmt.h:1303
+  // Replace the Stmt that would be the result of this compound expression with
+  // another Stmt.
+  void setStmtExpr(Stmt *S) {

I think it needs at the very least to mention that this is about the GNU 
extension. Perhaps it would be useful to mention the relation between the 
`CompoundStmt` node and the `StmtExpr` node ? Also more generally is it not 
possible to avoid mutating the compound statement node after it has been 
created ?



Comment at: clang/include/clang/AST/Stmt.h:1312
+
+  // Get the Stmt representing the result of this compound expression.
+  Stmt *getStmtExprResult() const {

Same, I would find it clearer if you mentioned the extension.


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

https://reviews.llvm.org/D57086



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


r353186 - [OPENMP] issue error messages for multiple teams contructs in a target construct

2019-02-05 Thread Kelvin Li via cfe-commits
Author: kli
Date: Tue Feb  5 08:43:00 2019
New Revision: 353186

URL: http://llvm.org/viewvc/llvm-project?rev=353186&view=rev
Log:
[OPENMP] issue error messages for multiple teams contructs in a target construct

The fix is to issue error messages if there are more than one 
teams construct inside a target constructs.

#pragma omp target
{
  #pragma omp teams
  {  ...  }

  #pragma omp teams
  { ... }
}

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=353186&r1=353185&r2=353186&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Feb  5 08:43:00 2019
@@ -7067,7 +7067,9 @@ StmtResult Sema::ActOnOpenMPTargetDirect
   auto I = CS->body_begin();
   while (I != CS->body_end()) {
 const auto *OED = dyn_cast(*I);
-if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind())) {
+if (!OED || !isOpenMPTeamsDirective(OED->getDirectiveKind()) ||
+OMPTeamsFound) {
+
   OMPTeamsFound = false;
   break;
 }

Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=353186&r1=353185&r2=353186&view=diff
==
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Tue Feb  5 08:43:00 2019
@@ -4080,6 +4080,13 @@ void foo() {
   }
 #pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
   {
+#pragma omp teams // expected-note {{directive outside teams construct here}}
+++a;
+#pragma omp teams // expected-note {{nested teams construct here}}
+++a;
+  }
+#pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
+  {
 ++a;   // expected-note {{statement outside teams construct here}}
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
@@ -12692,6 +12699,13 @@ void foo() {
 ++a;
   }
 #pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
+  {
+#pragma omp teams // expected-note {{directive outside teams construct here}}
+++a;
+#pragma omp teams // expected-note {{nested teams construct here}}
+++a;
+  }
+#pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
   {
 ++a;  // expected-note {{statement outside teams construct here}}
 #pragma omp teams // expected-note {{nested teams construct here}}


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


[PATCH] D57690: [OPENMP] issue error messages for multiple teams contructs in a target constructs

2019-02-05 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 closed this revision.
kkwli0 added a comment.

Committed: r353186


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

https://reviews.llvm.org/D57690



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


[PATCH] D57747: [Sema] SequenceChecker: Fix handling of operator ||, && and ?:

2019-02-05 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Looking at git blame, this change means that we will warn on `(b && x++) + (!b 
&& x++)`. However we will also warn on an expression like `(x > some_constant 
&& y++) + (x < some_constant && y++)`. This seems to be the job of a static 
analyser which is able to do some control flow analysis. Moreover for this 
warning it seems to me that having some false negatives is worse than having 
some false positive. As a data point I ran this on the entire LLVM codebase and 
on all of Boost, and did not find any additional warning.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57747



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


[PATCH] D57755: [clangd] Some minor fixes.

2019-02-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. Many thanks!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57755



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


[PATCH] D57747: [Sema] SequenceChecker: Fix handling of operator ||, && and ?:

2019-02-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

The "false negatives" in the current behaviour are the result of an intentional 
decision to avoid false positives for unsequenced operations that cannot 
actually both happen as part of the same evaluation (because both are 
conditional on different and mutually-exclusive conditions), such as the false 
positive we now get in the tests. I think it's reasonable to revisit that 
decision, though; the new false positive cases do not realistically seem likely 
to occur in real code whereas the false negatives do.




Comment at: test/Sema/warn-unsequenced.c:79
 
-  (xs[7] && ++a) * (!xs[7] && ++a); // ok
+  (xs[7] && ++a) * (!xs[7] && ++a); // expected-warning {{multiple unsequenced 
modifications to 'a'}}
 

Please at least add a FIXME for this false positive.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57747



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


[PATCH] D57739: [clangd] Format tweak's replacements.

2019-02-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D57739#1385144 , @hokein wrote:

> This seems introduce intrusive changes to the Tweak interface (Tweak will 
> need to know the `FormatStyle` somehow), I think this might be done in 
> another patch.


It's totally fine, since we have just a single tweak now and changing the 
interface costs nothing.
The important part is making it **hard** to misuse the interface and forcing 
formatting on all the users of the interface is a significant burden. E.g. 
other users of `ClangdServer` (tests, users of clangd C++ API)  shouldn't worry 
about formatting on their own.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57739



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


[PATCH] D57764: [AArch64] Add Cortex-A76 and Cortex-A76AE Support

2019-02-05 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman created this revision.
LukeCheeseman added a reviewer: olista01.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

- Add clang frontend testing for cortex-a76 and cortex-a76ae


Repository:
  rC Clang

https://reviews.llvm.org/D57764

Files:
  test/Driver/aarch64-cpus.c
  test/Driver/aarch64-dotprod.c
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c

Index: test/Driver/arm-dotprod.c
===
--- test/Driver/arm-dotprod.c
+++ test/Driver/arm-dotprod.c
@@ -7,6 +7,8 @@
 // RUN: %clang -### -target arm-linux-eabi -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target arm-linux-eabi -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a76 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a76ae %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
 // CHECK: "+dotprod"
 
@@ -17,6 +19,10 @@
 // RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
 // RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a76 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a76ae %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
 // RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
 // We rely on the backend disabling dotprod as it depends on neon, so check that
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -667,8 +667,12 @@
 
 // RUN: %clang -target arm -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76ae -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a55 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76ae -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
 //
 // RUN: %clang -target arm -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=exynos-m4 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
@@ -697,8 +701,12 @@
 
 // RUN: %clang -target armeb -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target armeb -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target armeb -mcpu=cortex-a76 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target armeb -mcpu=cortex-a76ae -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a55 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a76ae -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
 //
 // RUN: %clang -target armeb -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target arm -mcpu=exynos-m4 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
@@ -730,8 +738,12 @@
 
 // RUN: %clang -target arm -mcpu=cortex-a55 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A-THUMB %s
+// RUN: %clang -target arm -mcpu=cortex-a76 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A-THUMB %s
+// RUN: %clang -target arm -mcpu=cortex-a76ae -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a55 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -che

[PATCH] D57765: [ARM] Add Cortex-M35P Support

2019-02-05 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman created this revision.
LukeCheeseman added a reviewer: olista01.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

- Add clang frontend testing for Cortex-M35P


Repository:
  rC Clang

https://reviews.llvm.org/D57765

Files:
  test/Driver/arm-cortex-cpus.c


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -823,6 +823,7 @@
 // CHECK-CPUV8MBASE:  "-cc1"{{.*}} "-triple" "thumbv8m.base-
 
 // RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8MMAIN %s
+// RUN: %clang -target arm -mcpu=cortex-m35p -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8MMAIN %s
 // CHECK-CPUV8MMAIN:  "-cc1"{{.*}} "-triple" "thumbv8m.main-
 
 // == Check whether -mcpu accepts mixed-case values.


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -823,6 +823,7 @@
 // CHECK-CPUV8MBASE:  "-cc1"{{.*}} "-triple" "thumbv8m.base-
 
 // RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8MMAIN %s
+// RUN: %clang -target arm -mcpu=cortex-m35p -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8MMAIN %s
 // CHECK-CPUV8MMAIN:  "-cc1"{{.*}} "-triple" "thumbv8m.main-
 
 // == Check whether -mcpu accepts mixed-case values.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57767: [opaque pointer types] Cleanup CGBuilder's Create*GEP.

2019-02-05 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added a reviewer: dblaikie.
Herald added subscribers: cfe-commits, jfb, jholewinski.
Herald added a project: clang.

The various EltSize, Offset, DataLayout, and StructLayout arguments
are all computable from the Address's element type and the DataLayout
which the CGBuilder already has access to.

After having previously asserted that the computed values are the same
as those passed in, now remove the redundant arguments from
CGBuilder's Create*GEP functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57767

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3642,8 +3642,8 @@
 
 static Address EmitX86_64VAArgFromMemory(CodeGenFunction &CGF,
  Address VAListAddr, QualType Ty) {
-  Address overflow_arg_area_p = CGF.Builder.CreateStructGEP(
-  VAListAddr, 2, CharUnits::fromQuantity(8), "overflow_arg_area_p");
+  Address overflow_arg_area_p =
+  CGF.Builder.CreateStructGEP(VAListAddr, 2, "overflow_arg_area_p");
   llvm::Value *overflow_arg_area =
 CGF.Builder.CreateLoad(overflow_arg_area_p, "overflow_arg_area");
 
@@ -3714,18 +3714,14 @@
   Address gp_offset_p = Address::invalid(), fp_offset_p = Address::invalid();
   llvm::Value *gp_offset = nullptr, *fp_offset = nullptr;
   if (neededInt) {
-gp_offset_p =
-CGF.Builder.CreateStructGEP(VAListAddr, 0, CharUnits::Zero(),
-"gp_offset_p");
+gp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "gp_offset_p");
 gp_offset = CGF.Builder.CreateLoad(gp_offset_p, "gp_offset");
 InRegs = llvm::ConstantInt::get(CGF.Int32Ty, 48 - neededInt * 8);
 InRegs = CGF.Builder.CreateICmpULE(gp_offset, InRegs, "fits_in_gp");
   }
 
   if (neededSSE) {
-fp_offset_p =
-CGF.Builder.CreateStructGEP(VAListAddr, 1, CharUnits::fromQuantity(4),
-"fp_offset_p");
+fp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 1, "fp_offset_p");
 fp_offset = CGF.Builder.CreateLoad(fp_offset_p, "fp_offset");
 llvm::Value *FitsInFP =
   llvm::ConstantInt::get(CGF.Int32Ty, 176 - neededSSE * 16);
@@ -3754,9 +3750,7 @@
   // loads than necessary. Can we clean this up?
   llvm::Type *LTy = CGF.ConvertTypeForMem(Ty);
   llvm::Value *RegSaveArea = CGF.Builder.CreateLoad(
-  CGF.Builder.CreateStructGEP(
-  VAListAddr, 3, CharUnits::fromQuantity(8) + CGF.getPointerSize()),
-  "reg_save_area");
+  CGF.Builder.CreateStructGEP(VAListAddr, 3), "reg_save_area");
 
   Address RegAddr = Address::invalid();
   if (neededInt && neededSSE) {
@@ -3782,16 +3776,13 @@
 llvm::Value *V = CGF.Builder.CreateAlignedLoad(
 TyLo, CGF.Builder.CreateBitCast(RegLoAddr, PTyLo),
 CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(TyLo)));
-CGF.Builder.CreateStore(V,
-CGF.Builder.CreateStructGEP(Tmp, 0, CharUnits::Zero()));
+CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 0));
 
 // Copy the second element.
 V = CGF.Builder.CreateAlignedLoad(
 TyHi, CGF.Builder.CreateBitCast(RegHiAddr, PTyHi),
 CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(TyHi)));
-CharUnits Offset = CharUnits::fromQuantity(
-   getDataLayout().getStructLayout(ST)->getElementOffset(1));
-CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1, Offset));
+CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
 
 RegAddr = CGF.Builder.CreateElementBitCast(Tmp, LTy);
   } else if (neededInt) {
@@ -3838,12 +3829,10 @@
 Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
 V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
 RegAddrLo, ST->getStructElementType(0)));
-CGF.Builder.CreateStore(V,
-   CGF.Builder.CreateStructGEP(Tmp, 0, CharUnits::Zero()));
+CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 0));
 V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
 RegAddrHi, ST->getStructElementType(1)));
-CGF.Builder.CreateStore(V,
-  CGF.Builder.CreateStructGEP(Tmp, 1, CharUnits::

[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2019-02-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Could you rebase please? Many things have changed since you last update. After 
that I'll happily commit on your behalf if you don't have a commit access just 
yet.


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

https://reviews.llvm.org/D35068



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-02-05 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I emailed llvm-dev and cfe-dev on January 16th. The only responses I got back 
were of the don't care variety. For now it seems the constrained intrinsics 
will only be used by clang.

@rsmith, does the direction of this patch seem reasonable for clang?

Once Richard comments is there anything else needing us to delay here?


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

https://reviews.llvm.org/D53157



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


[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-02-05 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 185341.
dgoldman added a comment.
Herald added a project: clang.

- Output class scope for ObjCPropertyDecl


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924

Files:
  lib/AST/Decl.cpp
  unittests/AST/NamedDeclPrinterTest.cpp


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ 
objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,17 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,19 @@
const PrintingPolicy &P) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as 
context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+if (auto *MD = PD->getSetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);
@@ -1604,6 +1613,15 @@
 OS << *ED;
   else
 continue;
+} else if (const auto *CD = dyn_cast(DC)) {
+  if (CD->IsClassExtension()) {
+if (P.SuppressUnwrittenScope)
+  continue;
+else
+  OS << "(class extension)";
+  } else {
+OS << *CD;
+  }
 } else {
   OS << *cast(DC);
 }


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,17 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,19 @@
const PrintingPolicy &P) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+if (auto *MD = PD->getSetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);
@@ -1604,6 +1613,15 @@
 OS << *ED;
   else
 continue;
+   

[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-02-05 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D56924#1379342 , @arphaman wrote:

> Do you know if this have an effect on the output of completion results or 
> other tooling-based output?
>
> A couple of requests:
>
> - This behavior should be controlled by a printing policy flag 
> `SupressUnwrittenScope` (specifically for the '::(class extension)').
> - I also agree with Sam's comment. The property should still be qualified by 
> the class name as well, e.g. `Obj::(class extension)::property`.


It's possible - clangd for instance was crashing because of the current 
behavior: ::property instead of Obj::property or (class extension)::property.

- Added although see below
- I've modified this to be more in line with the current handling of Objc 
methods, but this no longer outputs the "(class extension)", do you think it 
should output both?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D57768: [SYCL] Add SYCL device compilation flow.

2019-02-05 Thread Alexey Bader via Phabricator via cfe-commits
bader created this revision.
bader added reviewers: keryell, Naghasan.
Herald added subscribers: cfe-commits, ebevhan.
Herald added a project: clang.

-fsycl-is-device enables compilation of the device part of SYCL source
file.

Patch by Mariya Podchishchaeva 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57768

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp


Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -1056,6 +1056,12 @@
 Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
   }
 
+  // Define indicating that the source file is being compiled with a SYCL
+  // device compiler which doesn't produce host binary.
+  if (LangOpts.SYCLIsDevice) {
+Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
+  }
+
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
 #define OPENCLEXT(Ext) \
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2875,6 +2875,8 @@
   << Opts.OMPHostIRFile;
   }
 
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+
   // Set CUDA mode for OpenMP target NVPTX if specified in options
   Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3150,6 +3150,9 @@
 defm underscoring : BooleanFFlag<"underscoring">, Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
+// SYCL options
+def sycl_device_only : Flag<["--"], "sycl-device-only">,
+  HelpText<"Compile SYCL code for device only">;
 
 include "CC1Options.td"
 
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -836,8 +836,14 @@
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
   HelpText<"Path to the IR file produced by the frontend for the host.">;
 
-} // let Flags = [CC1Option]
+//===--===//
+// SYCL Options
+//===--===//
 
+def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
+  HelpText<"Generate code for SYCL device.">;
+
+} // let Flags = [CC1Option]
 
 
//===--===//
 // cc1as-only Options
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -215,6 +215,8 @@
 LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate 
transcendental functions")
 LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
 
+LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
+
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")


Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -1056,6 +1056,12 @@
 Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
   }
 
+  // Define indicating that the source file is being compiled with a SYCL
+  // device compiler which doesn't produce host binary.
+  if (LangOpts.SYCLIsDevice) {
+Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
+  }
+
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
 #define OPENCLEXT(Ext) \
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2875,6 +2875,8 @@
   << Opts.OMPHostIRFile;
   }
 
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+
   // Set CUDA mode for OpenMP target NVPTX if specified in options
   Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a subscriber: jyknight.
craig.topper added inline comments.



Comment at: lib/CodeGen/CGStmt.cpp:2236
+llvm::CallBrInst *Result =
+Builder.CreateCallBr(FTy, IA, Fallthrough, Transfer, Args);
+UpdateAsmCallInst(cast(*Result), HasSideEffect, ReadOnly,

I don't think we need to pass FTy here now. I made that change before @jyknight 
added FunctionCallee that should be able to find the type from the InlineAsm. 
The CallBr IRBuilder code should have a FunctionCallee Create function as of 
yesterday.


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

https://reviews.llvm.org/D56571



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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2019-02-05 Thread Nick Renieris via Phabricator via cfe-commits
VelocityRa added a comment.

Ping.


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

https://reviews.llvm.org/D28462



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


[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

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

LGTM!


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

https://reviews.llvm.org/D56850



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


[PATCH] D57771: [CUDA] Add basic support for CUDA-10.1

2019-02-05 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, sanjoy.

https://reviews.llvm.org/D57771

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 10010
 #error "Unsupported CUDA version!"
 #endif
 
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -60,6 +60,8 @@
 return CudaVersion::CUDA_92;
   if (Major == 10 && Minor == 0)
 return CudaVersion::CUDA_100;
+  if (Major == 10 && Minor == 1)
+return CudaVersion::CUDA_101;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -445,6 +445,10 @@
   llvm::FunctionCallee RegisterFatbinFunc = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(VoidPtrPtrTy, VoidPtrTy, false),
   addUnderscoredPrefixToName("RegisterFatBinary"));
+  // void __cudaRegisterFatBinaryEnd(void **);
+  llvm::FunctionCallee RegisterFatbinEndFunc = CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
+  "__cudaRegisterFatBinaryEnd");
   // struct { int magic, int version, void * gpu_binary, void * dont_care };
   llvm::StructType *FatbinWrapperTy =
   llvm::StructType::get(IntTy, IntTy, VoidPtrTy, VoidPtrTy);
@@ -616,6 +620,11 @@
 // Call __cuda_register_globals(GpuBinaryHandle);
 if (RegisterGlobalsFunc)
   CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+
+// CUDA version requires calling __cudaRegisterFatBinaryEnd(Handle);
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+   CudaFeature::CUDA_USES_FATBIN_REGISTER_END))
+  CtorBuilder.CreateCall(RegisterFatbinEndFunc, RegisterFatbinCall);
   } else {
 // Generate a unique module ID.
 SmallString<64> ModuleID;
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -25,6 +25,8 @@
 return "9.2";
   case CudaVersion::CUDA_100:
 return "10.0";
+  case CudaVersion::CUDA_101:
+return "10.1";
   }
   llvm_unreachable("invalid enum");
 }
@@ -37,7 +39,8 @@
   .Case("9.0", CudaVersion::CUDA_90)
   .Case("9.1", CudaVersion::CUDA_91)
   .Case("9.2", CudaVersion::CUDA_92)
-  .Case("10.0", CudaVersion::CUDA_100);
+  .Case("10.0", CudaVersion::CUDA_100)
+  .Case("10.1", CudaVersion::CUDA_101);
 }
 
 const char *CudaArchToString(CudaArch A) {
@@ -352,6 +355,8 @@
 return CudaVersion::CUDA_92;
   case 100:
 return CudaVersion::CUDA_100;
+  case 101:
+return CudaVersion::CUDA_101;
   default:
 return CudaVersion::UNKNOWN;
   }
@@ -365,6 +370,8 @@
   switch (Feature) {
   case CudaFeature::CUDA_USES_NEW_LAUNCH:
 return Version >= CudaVersion::CUDA_92;
+  case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
+return Version >= CudaVersion::CUDA_101;
   }
   llvm_unreachable("Unknown CUDA feature.");
 }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -25,7 +25,8 @@
   CUDA_91,
   CUDA_92,
   CUDA_100,
-  LATEST = CUDA_100,
+  CUDA_101,
+  LATEST = CUDA_101,
 };
 const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
@@ -107,6 +108,8 @@
 enum class CudaFeature {
   // CUDA-9.2+ uses a new API for launching kernels.
   CUDA_USES_NEW_LAUNCH,
+  // CUDA-10.1+ needs explicit end of GPU binary registration.
+  CUDA_USES_FATBIN_REGISTER_END,
 };
 
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353197 - Minor cleanup: remove CGBuild::CreateConst*ByteGEP overloads taking a Value*.

2019-02-05 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Feb  5 11:01:33 2019
New Revision: 353197

URL: http://llvm.org/viewvc/llvm-project?rev=353197&view=rev
Log:
Minor cleanup: remove CGBuild::CreateConst*ByteGEP overloads taking a Value*.

Modified:
cfe/trunk/lib/CodeGen/CGBuilder.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=353197&r1=353196&r2=353197&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Tue Feb  5 11:01:33 2019
@@ -258,17 +258,6 @@ public:
 CharUnits::fromQuantity(Offset.getSExtValue(;
   }
 
-  llvm::Value *CreateConstInBoundsByteGEP(llvm::Value *Ptr, CharUnits Offset,
-  const llvm::Twine &Name = "") {
-assert(Ptr->getType()->getPointerElementType() == TypeCache.Int8Ty);
-return CreateInBoundsGEP(Ptr, getSize(Offset), Name);
-  }
-  llvm::Value *CreateConstByteGEP(llvm::Value *Ptr, CharUnits Offset,
-  const llvm::Twine &Name = "") {
-assert(Ptr->getType()->getPointerElementType() == TypeCache.Int8Ty);
-return CreateGEP(Ptr, getSize(Offset), Name);
-  }
-
   using CGBuilderBaseTy::CreateMemCpy;
   llvm::CallInst *CreateMemCpy(Address Dest, Address Src, llvm::Value *Size,
bool IsVolatile = false) {

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=353197&r1=353196&r2=353197&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Feb  5 11:01:33 2019
@@ -309,10 +309,9 @@ static Address emitVoidPtrDirectVAArg(Co
 
   // Advance the pointer past the argument, then store that back.
   CharUnits FullDirectSize = DirectSize.alignTo(SlotSize);
-  llvm::Value *NextPtr =
-CGF.Builder.CreateConstInBoundsByteGEP(Addr.getPointer(), FullDirectSize,
-   "argp.next");
-  CGF.Builder.CreateStore(NextPtr, VAListAddr);
+  Address NextPtr =
+  CGF.Builder.CreateConstInBoundsByteGEP(Addr, FullDirectSize, 
"argp.next");
+  CGF.Builder.CreateStore(NextPtr.getPointer(), VAListAddr);
 
   // If the argument is smaller than a slot, and this is a big-endian
   // target, the argument will be right-adjusted in its slot.
@@ -8211,9 +8210,8 @@ Address SparcV9ABIInfo::EmitVAArg(CodeGe
   }
 
   // Update VAList.
-  llvm::Value *NextPtr =
-Builder.CreateConstInBoundsByteGEP(Addr.getPointer(), Stride, "ap.next");
-  Builder.CreateStore(NextPtr, VAListAddr);
+  Address NextPtr = Builder.CreateConstInBoundsByteGEP(Addr, Stride, 
"ap.next");
+  Builder.CreateStore(NextPtr.getPointer(), VAListAddr);
 
   return Builder.CreateBitCast(ArgAddr, ArgPtrTy, "arg.addr");
 }
@@ -8566,9 +8564,8 @@ Address XCoreABIInfo::EmitVAArg(CodeGenF
 
   // Increment the VAList.
   if (!ArgSize.isZero()) {
-llvm::Value *APN =
-  Builder.CreateConstInBoundsByteGEP(AP.getPointer(), ArgSize);
-Builder.CreateStore(APN, VAListAddr);
+Address APN = Builder.CreateConstInBoundsByteGEP(AP, ArgSize);
+Builder.CreateStore(APN.getPointer(), VAListAddr);
   }
 
   return Val;


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


[PATCH] D57771: [CUDA] Add basic support for CUDA-10.1

2019-02-05 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 185353.
tra added a comment.

Make the function object local.


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

https://reviews.llvm.org/D57771

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 10010
 #error "Unsupported CUDA version!"
 #endif
 
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -60,6 +60,8 @@
 return CudaVersion::CUDA_92;
   if (Major == 10 && Minor == 0)
 return CudaVersion::CUDA_100;
+  if (Major == 10 && Minor == 1)
+return CudaVersion::CUDA_101;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -616,6 +616,16 @@
 // Call __cuda_register_globals(GpuBinaryHandle);
 if (RegisterGlobalsFunc)
   CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+
+// CUDA version requires calling __cudaRegisterFatBinaryEnd(Handle);
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+   CudaFeature::CUDA_USES_FATBIN_REGISTER_END)) {
+  // void __cudaRegisterFatBinaryEnd(void **);
+  llvm::FunctionCallee RegisterFatbinEndFunc = CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
+  "__cudaRegisterFatBinaryEnd");
+  CtorBuilder.CreateCall(RegisterFatbinEndFunc, RegisterFatbinCall);
+}
   } else {
 // Generate a unique module ID.
 SmallString<64> ModuleID;
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -25,6 +25,8 @@
 return "9.2";
   case CudaVersion::CUDA_100:
 return "10.0";
+  case CudaVersion::CUDA_101:
+return "10.1";
   }
   llvm_unreachable("invalid enum");
 }
@@ -37,7 +39,8 @@
   .Case("9.0", CudaVersion::CUDA_90)
   .Case("9.1", CudaVersion::CUDA_91)
   .Case("9.2", CudaVersion::CUDA_92)
-  .Case("10.0", CudaVersion::CUDA_100);
+  .Case("10.0", CudaVersion::CUDA_100)
+  .Case("10.1", CudaVersion::CUDA_101);
 }
 
 const char *CudaArchToString(CudaArch A) {
@@ -352,6 +355,8 @@
 return CudaVersion::CUDA_92;
   case 100:
 return CudaVersion::CUDA_100;
+  case 101:
+return CudaVersion::CUDA_101;
   default:
 return CudaVersion::UNKNOWN;
   }
@@ -365,6 +370,8 @@
   switch (Feature) {
   case CudaFeature::CUDA_USES_NEW_LAUNCH:
 return Version >= CudaVersion::CUDA_92;
+  case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
+return Version >= CudaVersion::CUDA_101;
   }
   llvm_unreachable("Unknown CUDA feature.");
 }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -25,7 +25,8 @@
   CUDA_91,
   CUDA_92,
   CUDA_100,
-  LATEST = CUDA_100,
+  CUDA_101,
+  LATEST = CUDA_101,
 };
 const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
@@ -107,6 +108,8 @@
 enum class CudaFeature {
   // CUDA-9.2+ uses a new API for launching kernels.
   CUDA_USES_NEW_LAUNCH,
+  // CUDA-10.1+ needs explicit end of GPU binary registration.
+  CUDA_USES_FATBIN_REGISTER_END,
 };
 
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57768: [SYCL] Add SYCL device compilation flow.

2019-02-05 Thread Ronan Keryell via Phabricator via cfe-commits
keryell accepted this revision.
keryell added a comment.
This revision is now accepted and ready to land.

That looks good. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57768



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


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-02-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/Expr.cpp:2562
+return ICE->getSubExpr();
+
+  else if (auto *FE = dyn_cast_or_null(E))

riccibruno wrote:
> It is something that is actually possible to audit. I did look at where each 
> of the skipped node are created and it *seems* that a null child is not 
> possible. However it is very easy to miss a case and adding the null check 
> give the various `Expr::Ignore*` the following nice property:
> 
> Regardless of the state of the AST, for every expression `E` (null or not). 
> `Ignore*(E)` produces the correct result (which may be null).
> 
> But perhaps the correct invariant to maintain is that these nodes have always 
> a non-null child ?
> 
> I re-ran the benchmarks more carefully and here are the results I got (on my 
> usual benchmark: `-fyntax-only` on all of Boost, 20 iterations with `perf 
> stat`):
> 
> 8.2117 +- 0.0131 seconds (with the null check)
> 8.2028 +- 0.0058 seconds (without the null check)
> But perhaps the correct invariant to maintain is that these nodes have always 
> a non-null child ?

I believe we treat this as an invariant in a lot of other places, so it seems 
like a reasonable invariant here. Being more resilient is not a bad thing, but 
it may also mask broken invariants elsewhere.

I'll leave it to @rsmith to make the final call though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267



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


r353199 - [opaque pointer types] More trivial changes to pass FunctionType to CallInst.

2019-02-05 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Feb  5 11:17:50 2019
New Revision: 353199

URL: http://llvm.org/viewvc/llvm-project?rev=353199&view=rev
Log:
[opaque pointer types] More trivial changes to pass FunctionType to CallInst.

Change various functions to use FunctionCallee or Function*.

Pass function type through __builtin_dump_struct's dumpRecord helper.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=353199&r1=353198&r2=353199&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Feb  5 11:17:50 2019
@@ -1331,8 +1331,8 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
 }
 
 static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
-   Value *&RecordPtr, CharUnits Align, Value *Func,
-   int Lvl) {
+   Value *&RecordPtr, CharUnits Align,
+   llvm::FunctionCallee Func, int Lvl) {
   const auto *RT = RType->getAs();
   ASTContext &Context = CGF.getContext();
   RecordDecl *RD = RT->getDecl()->getDefinition();
@@ -1736,6 +1736,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   }
 
   case Builtin::BI__builtin_dump_struct: {
+llvm::Type *LLVMIntTy = getTypes().ConvertType(getContext().IntTy);
+llvm::FunctionType *LLVMFuncType = llvm::FunctionType::get(
+LLVMIntTy, {llvm::Type::getInt8PtrTy(getLLVMContext())}, true);
+
 Value *Func = EmitScalarExpr(E->getArg(1)->IgnoreImpCasts());
 CharUnits Arg0Align = 
EmitPointerWithAlignment(E->getArg(0)).getAlignment();
 
@@ -1743,7 +1747,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 QualType Arg0Type = Arg0->getType()->getPointeeType();
 
 Value *RecordPtr = EmitScalarExpr(Arg0);
-Value *Res = dumpRecord(*this, Arg0Type, RecordPtr, Arg0Align, Func, 0);
+Value *Res = dumpRecord(*this, Arg0Type, RecordPtr, Arg0Align,
+{LLVMFuncType, Func}, 0);
 return RValue::get(Res);
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=353199&r1=353198&r2=353199&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Feb  5 11:17:50 2019
@@ -2201,7 +2201,7 @@ void CodeGenFunction::pushRegularPartial
 }
 
 /// Lazily declare the @llvm.lifetime.start intrinsic.
-llvm::Constant *CodeGenModule::getLLVMLifetimeStartFn() {
+llvm::Function *CodeGenModule::getLLVMLifetimeStartFn() {
   if (LifetimeStartFn)
 return LifetimeStartFn;
   LifetimeStartFn = llvm::Intrinsic::getDeclaration(&getModule(),
@@ -2210,7 +2210,7 @@ llvm::Constant *CodeGenModule::getLLVMLi
 }
 
 /// Lazily declare the @llvm.lifetime.end intrinsic.
-llvm::Constant *CodeGenModule::getLLVMLifetimeEndFn() {
+llvm::Function *CodeGenModule::getLLVMLifetimeEndFn() {
   if (LifetimeEndFn)
 return LifetimeEndFn;
   LifetimeEndFn = llvm::Intrinsic::getDeclaration(&getModule(),

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=353199&r1=353198&r2=353199&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Tue Feb  5 11:17:50 2019
@@ -278,7 +278,7 @@ void CodeGenFunction::FinishThunk() {
   FinishFunction();
 }
 
-void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
+void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
 const ThunkInfo *Thunk,
 bool IsUnprototyped) {
   assert(isa(CurGD.getDecl()) &&
@@ -303,7 +303,7 @@ void CodeGenFunction::EmitCallAndReturnF
 CGM.ErrorUnsupported(
 MD, "non-trivial argument copy for return-adjusting thunk");
 }
-EmitMustTailThunk(CurGD, AdjustedThisPtr, CalleePtr);
+EmitMustTailThunk(CurGD, AdjustedThisPtr, Callee);
 return;
   }
 
@@ -354,8 +354,8 @@ void CodeGenFunction::EmitCallAndReturnF
 
   // Now emit our call.
   llvm::CallBase *CallOrInvoke;
-  CGCallee Callee = CGCallee::forDirect(CalleePtr, CurGD);
-  RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, &CallOrInvoke);
+  RValue RV = EmitCall(*CurFnInfo, CGCallee::forDirect(Callee, CurGD), Slot,
+   CallArgs, &CallOrInvoke);
 
   // Consider return adjustment if we have ThunkInfo.
   if (Thunk && !Thunk

[PATCH] D57674: [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals

2019-02-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/ArgumentCommentCheck.cpp:228-236
+static bool isStringLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast(Arg);
+  return Cast ? isa(Cast->getSubExpr()) : false;
+}
+
+static bool isNullPtrLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast(Arg);

What's going on with these? Why not `return isa(Arg->IgnoreImpCasts());` 
(at which point, no need for the separate functions).



Comment at: clang-tidy/bugprone/ArgumentCommentCheck.cpp:312-318
+(((CommentBoolLiterals && isa(Args[I])) ||
+  (CommentIntegerLiterals && isa(Args[I])) ||
+  (CommentFloatLiterals && isa(Args[I])) ||
+  (CommentUserDefinedLiterals && isa(Args[I])) ||
+  (CommentCharacterLiterals && isa(Args[I])) ||
+  (CommentStringLiterals && isStringLiteral(Args[I])) ||
+  (CommentNullPtrs && isNullPtrLiteral(Args[I]) {

This is a bit... much. I'm not certain what would be a better approach, but at 
the very least, factoring this out into a simple function call should make it a 
bit less... much. :-)



Comment at: clang-tidy/bugprone/ArgumentCommentCheck.h:43-50
   const bool StrictMode;
+  const bool CommentBoolLiterals;
+  const bool CommentIntegerLiterals;
+  const bool CommentFloatLiterals;
+  const bool CommentStringLiterals;
+  const bool CommentUserDefinedLiterals;
+  const bool CommentCharacterLiterals;

At this point, I think it would be better to turn these into: `const unsigned 
Blah : 1;`



Comment at: docs/clang-tidy/checks/bugprone-argument-comment.rst:40
+
+  void foo(bool turn_key,bool press_button);
+

aaron.ballman wrote:
> Format the code examples from our style guide as well (same below).
This still seems to be happening in the current revision?


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

https://reviews.llvm.org/D57674



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


Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Eli Friedman via cfe-commits
What sort of outputs, specifically?  Memory outputs are easy; I think the LLVM 
IR patch actually supports them already.  Register outputs are complicated... I 
guess they're also possible, but we would need to come up with some frontend 
rule that allows sane code generation.  Consider the case where two or more asm 
gotos jump to the same destination, and output a value to the same register, 
but a different variable.  In general, it's possible to lower by rewriting the 
PHI nodes to match, then inserting a switch at the beginning of the destination 
to fix the rewritten PHIs.  But that's both expensive at runtime and difficult 
to implement, so we probably want a rule that prohibits constructs which would 
require that sort of lowering.


If we do intend to implement register outputs at some point, we might want to 
draft a design at the LLVM IR level now, so we have some confidence the current 
IR is forward-compatible.


Obviously we should have diagnostics in the parser if the user tries to write 
an asm goto with an output.  I'm not worried about the difficulty of fixing the 
frontend otherwise; this patch isn't that big in the first place.


-Eli



From: Nick Desaulniers 
Sent: Tuesday, February 5, 2019 1:14 AM
To: reviews+d56571+public+1482c3abd76a8...@reviews.llvm.org
Cc: Yu, Jennifer; Keane, Erich; chandl...@gmail.com; syaghm...@apple.com; 
craig.top...@gmail.com; h...@chromium.org; e5ten.a...@gmail.com; 
d...@golovin.in; natechancel...@gmail.com; tstel...@redhat.com; Eli Friedman; 
srhi...@google.com; era...@google.com; cfe-commits@lists.llvm.org
Subject: [EXT] Re: [PATCH] D56571: [RFC prototype] Implementation of asm-goto 
support in clang

Note that kernel developers are requesting output support with ASM goto. 
Doesn't need to be in V1 of ASM go-to support, but we should expect it to be 
implemented in the future. We should help users with diagnostics that this is 
not supported, and add asserts that will help us implement such a feature in 
the future.


On Tue, Feb 5, 2019, 3:32 AM Richard Smith - zygoloid via Phabricator 
mailto:revi...@reviews.llvm.org> wrote:
rsmith added inline comments.



Comment at: lib/AST/Stmt.cpp:457-460
   this->NumOutputs = NumOutputs;
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
+  this->NumLabels = NumLabels;

jyu2 wrote:
> rsmith wrote:
> > Please assert that you don't have both outputs and labels here. (If you 
> > did, you would assign them the same slots within `Exprs`.)
> >
> > You also seem to be missing `Sema` enforcement of the rule that you cannot 
> > have both outputs and labels. (If you want to actually support that as an 
> > intentional extension to the GCC functionality, you should change the 
> > implementation of `GCCAsmStmt` to use different slots for outputs and 
> > labels, add some tests, and add a `-Wgcc-compat` warning for that case. 
> > Seems better to just add an error for it for now.)
> This is enforcement during the parer.
>
> for example:
> a.c:12:23: error: expected ':'
> asm goto ("decl %0;" :"a": "m"(cond) : "memory" );
>
> Do you think this is enough for now?
> Thanks.
> Jennifer
Thanks, I see it now. Please still add the assert here.

I'd also like a custom diagnostic for that parse error; it'd seem easy and 
useful to add an "asm goto cannot have output constraints" error.


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

https://reviews.llvm.org/D56571



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


Re: r352930 - [WebAssembly] Add an import_field function attribute

2019-02-05 Thread Aaron Ballman via cfe-commits
On Fri, Feb 1, 2019 at 8:27 PM Dan Gohman  wrote:
>
>
>
> On Fri, Feb 1, 2019 at 2:31 PM Aaron Ballman  wrote:
>>
>> On Fri, Feb 1, 2019 at 5:25 PM Dan Gohman via cfe-commits
>>  wrote:
>> >
>> > Author: djg
>> > Date: Fri Feb  1 14:25:23 2019
>> > New Revision: 352930
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=352930&view=rev
>> > Log:
>> > [WebAssembly] Add an import_field function attribute
>> >
>> > This is similar to import_module, but sets the import field name
>> > instead.
>> >
>> > By default, the import field name is the same as the C/asm/.o symbol
>> > name. However, there are situations where it's useful to have it be
>> > different. For example, suppose I have a wasm API with a module named
>> > "pwsix" and a field named "read". There's no risk of namespace
>> > collisions with user code at the wasm level because the generic name
>> > "read" is qualified by the module name "pwsix". However in the C/asm/.o
>> > namespaces, the module name is not used, so if I have a global function
>> > named "read", it is intruding on the user's namespace.
>> >
>> > With the import_field module, I can declare my function (in libc) to be
>> > "__read", and then set the wasm import module to be "pwsix" and the wasm
>> > import field to be "read". So at the C/asm/.o levels, my symbol is
>> > outside the user namespace.
>> >
>> > Differential Revision: https://reviews.llvm.org/D57602
>>
>> Btw, this review never went to cfe-commits, but it should have. :-)
>
>
> Yes, my mistake.

No worries, it seems there was a misbehaving phab script that did this
automatically for a few reviews, but it's been fixed.

>>
>>
>> > Added:
>> > cfe/trunk/test/CodeGen/wasm-import-name.c
>> >   - copied, changed from r352781, 
>> > cfe/trunk/test/CodeGen/wasm-import-module.c
>> > Modified:
>> > cfe/trunk/include/clang/Basic/Attr.td
>> > cfe/trunk/include/clang/Basic/AttrDocs.td
>> > cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> > cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> > cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
>> >
>> > Modified: cfe/trunk/include/clang/Basic/Attr.td
>> > URL: 
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=352930&r1=352929&r2=352930&view=diff
>> > ==
>> > --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> > +++ cfe/trunk/include/clang/Basic/Attr.td Fri Feb  1 14:25:23 2019
>> > @@ -1514,11 +1514,19 @@ def AMDGPUNumVGPR : InheritableAttr {
>> >  def WebAssemblyImportModule : InheritableAttr,
>> >TargetSpecificAttr {
>> >let Spellings = [Clang<"import_module">];
>> > -  let Args = [StringArgument<"ImportModuleName">];
>> > +  let Args = [StringArgument<"ImportModule">];
>> >let Documentation = [WebAssemblyImportModuleDocs];
>> >let Subjects = SubjectList<[Function], ErrorDiag>;
>> >  }
>> >
>> > +def WebAssemblyImportName : InheritableAttr,
>> > +TargetSpecificAttr {
>> > +  let Spellings = [Clang<"import_name">];
>> > +  let Args = [StringArgument<"ImportName">];
>> > +  let Documentation = [WebAssemblyImportNameDocs];
>> > +  let Subjects = SubjectList<[Function], ErrorDiag>;
>> > +}
>> > +
>> >  def NoSplitStack : InheritableAttr {
>> >let Spellings = [GCC<"no_split_stack">];
>> >let Subjects = SubjectList<[Function], ErrorDiag>;
>> >
>> > Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
>> > URL: 
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=352930&r1=352929&r2=352930&view=diff
>> > ==
>> > --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
>> > +++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Feb  1 14:25:23 2019
>> > @@ -3730,6 +3730,23 @@ reuqest a specific module name be used i
>> >}];
>> >  }
>> >
>> > +def WebAssemblyImportNameDocs : Documentation {
>> > +  let Category = DocCatFunction;
>> > +  let Content = [{
>> > +Clang supports the ``__attribute__((import_name()))``
>> > +attribute for the WebAssembly target. This attribute may be attached to a
>> > +function declaration, where it modifies how the symbol is to be imported
>> > +within the WebAssembly linking environment.
>> > +
>> > +WebAssembly imports use a two-level namespace scheme, consisting of a 
>> > module
>> > +name, which typically identifies a module from which to import, and a 
>> > field
>> > +name, which typically identifies a field from that module to import. By
>> > +default, field names for C/C++ symbols are the same as their C/C++ symbol
>> > +names. This attribute can be used to override the default behavior, and
>> > +reuqest a specific field name be used instead.
>> > +  }];
>> > +}
>> > +
>> >  def ArtificialDocs : Documentation {
>> >let Category = DocCatFunction;
>> >let Content = [{
>> >
>> > Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 185360.
jyu2 added a comment.

1>emit better error for use of output constraints.
2> Add assert for NumLabels and NumOutputs are both larger than 0.


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

https://reviews.llvm.org/D56571

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/asm-goto.cpp
  test/CodeGen/asm-goto.c
  test/CodeGen/asm.c
  test/CodeGen/inline-asm-mixed-style.c
  test/Coverage/c-language-features.inc
  test/PCH/asm.h
  test/Parser/asm.c
  test/Parser/asm.cpp
  test/Sema/asm.c
  test/Sema/inline-asm-validate-tmpl.cpp
  test/Sema/scope-check.c

Index: test/Sema/scope-check.c
===
--- test/Sema/scope-check.c
+++ test/Sema/scope-check.c
@@ -232,3 +232,18 @@
 
 // rdar://9024687
 int test16(int [sizeof &&z]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+
+//Asm goto:
+int test16(int n)
+{
+  // expected-error@+2 {{cannot jump from this goto statement to its label}}
+  // expected-error@+1 {{cannot jump from this goto statement to its label}}
+  asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  return ({int a[n];label_true: 2;});
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  int b[n];
+loop:
+  return 0;
+}
Index: test/Sema/inline-asm-validate-tmpl.cpp
===
--- test/Sema/inline-asm-validate-tmpl.cpp
+++ test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
 }
 int	foo() { testc<2>(10); }
+
+// these should compile without error
+template  bool testd()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+bool foox() { return testd<0> (); }
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -295,3 +295,28 @@
   return r0 + r1;
 }
 
+void test18()
+{
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("" : : : : lab, lab, lab2, lab);
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+  int x,x1;
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+  // expected-error@+1 {{operand with 'l' modifier must refer to a label}}
+  asm ("jne %l0"::"r"(&&lab));
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm ("jne %l0":::);
+  // expected-error@+1 {{operand with 'l' modifier must refer to a label}}
+  asm goto ("jne %l0"::"r"(x)::lab);
+  asm goto ("jne %l0"lab);
+}
Index: test/Parser/asm.cpp
===
--- test/Parser/asm.cpp
+++ test/Parser/asm.cpp
@@ -7,3 +7,54 @@
 int foo5 asm (U"bar5"); // expected-error {{cannot use unicode string literal in 'asm'}}
 int foo6 asm ("bar6"_x); // expected-error {{string literal with user-defined suffix cannot be used here}}
 int foo6 asm ("" L"bar7"); // expected-error {{cannot use wide string literal in 'asm'}}
+
+int zoo ()
+{
+  int x,cond,*e;
+  // expected-error@+1 {{expected ')'}}
+  asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)
+  // expected-error@+1  {{'asm goto' cannot have output constraints}}
+  asm goto ("decl %0; jnz %l[a]" :"=r"(x): "m"(x) : "memory" : a);
+  // expected-error@+1 {{expected identifie}}
+  asm goto ("decl %0;" :: "m"(x) : "memory" : );
+  // expected-error@+1  {{expected ':'}}
+  asm goto ("decl %0;" :: "m"(x) : "memory" );
+  // expected-error@+1 {{use of undeclared label 'x'}}
+  asm goto ("decl %0;" :: "m"(x) : "memory" :x);
+  // expected-error@+1 {{use of undeclared label 'b'}}
+  asm goto ("decl %0;" :: "m"(x) : "memory" :b);
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm goto ("testl %0, %0; jne %l3;" :: 

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-05 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 marked 2 inline comments as done.
jyu2 added inline comments.



Comment at: lib/AST/Stmt.cpp:457-460
   this->NumOutputs = NumOutputs;
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
+  this->NumLabels = NumLabels;

rsmith wrote:
> jyu2 wrote:
> > rsmith wrote:
> > > Please assert that you don't have both outputs and labels here. (If you 
> > > did, you would assign them the same slots within `Exprs`.)
> > > 
> > > You also seem to be missing `Sema` enforcement of the rule that you 
> > > cannot have both outputs and labels. (If you want to actually support 
> > > that as an intentional extension to the GCC functionality, you should 
> > > change the implementation of `GCCAsmStmt` to use different slots for 
> > > outputs and labels, add some tests, and add a `-Wgcc-compat` warning for 
> > > that case. Seems better to just add an error for it for now.)
> > This is enforcement during the parer.  
> > 
> > for example:
> > a.c:12:23: error: expected ':'
> > asm goto ("decl %0;" :"a": "m"(cond) : "memory" );
> > 
> > Do you think this is enough for now?
> > Thanks.
> > Jennifer
> Thanks, I see it now. Please still add the assert here.
> 
> I'd also like a custom diagnostic for that parse error; it'd seem easy and 
> useful to add an "asm goto cannot have output constraints" error.
Okay added.



Comment at: lib/CodeGen/CGStmt.cpp:2236
+llvm::CallBrInst *Result =
+Builder.CreateCallBr(FTy, IA, Fallthrough, Transfer, Args);
+UpdateAsmCallInst(cast(*Result), HasSideEffect, ReadOnly,

craig.topper wrote:
> I don't think we need to pass FTy here now. I made that change before 
> @jyknight added FunctionCallee that should be able to find the type from the 
> InlineAsm. The CallBr IRBuilder code should have a FunctionCallee Create 
> function as of yesterday.
Removed.


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

https://reviews.llvm.org/D56571



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


r353204 - [DEBUG_INFO][NVPTX] Generate correct data about variable address class.

2019-02-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Feb  5 11:45:57 2019
New Revision: 353204

URL: http://llvm.org/viewvc/llvm-project?rev=353204&view=rev
Log:
[DEBUG_INFO][NVPTX] Generate correct data about variable address class.

Summary:
Added ability to generate correct debug info data about the variable
address class. Currently, for all the locals and globals the default
values are used, ADDR_local_space(6) for locals and ADDR_global_space(5)
for globals. The values are taken from the table in
  
https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf.
  We need to emit correct data for address classes of, at least, shared
  and constant globals. Currently, all these variables are treated by
  the cuda-gdb debugger as the variables in the global address space
  and, thus, it require manual data type casting.

Reviewers: echristo, probinson

Subscribers: jholewinski, aprantl, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCUDA/debug-info-address-class.cu
Modified:
cfe/trunk/lib/Basic/Targets/NVPTX.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.h?rev=353204&r1=353203&r2=353204&view=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.h (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.h Tue Feb  5 11:45:57 2019
@@ -35,6 +35,16 @@ static const unsigned NVPTXAddrSpaceMap[
 3, // cuda_shared
 };
 
+/// The DWARF address class. Taken from
+/// 
https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
+static const int NVPTXDWARFAddrSpaceMap[] = {
+-1, // Default, opencl_private or opencl_generic - not defined
+5,  // opencl_global
+-1,
+8,  // opencl_local or cuda_shared
+4,  // opencl_constant or cuda_constant
+};
+
 class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
@@ -124,6 +134,20 @@ public:
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
 
+  /// \returns If a target requires an address within a target specific address
+  /// space \p AddressSpace to be converted in order to be used, then return 
the
+  /// corresponding target specific DWARF address space.
+  ///
+  /// \returns Otherwise return None and no conversion will be emitted in the
+  /// DWARF.
+  Optional
+  getDWARFAddressSpace(unsigned AddressSpace) const override {
+if (AddressSpace >= llvm::array_lengthof(NVPTXDWARFAddrSpaceMap) ||
+NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)
+  return llvm::None;
+return NVPTXDWARFAddrSpaceMap[AddressSpace];
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 // CUDA compilations support all of the host's calling conventions.
 //

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=353204&r1=353203&r2=353204&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  5 11:45:57 2019
@@ -4232,6 +4232,14 @@ void CGDebugInfo::EmitGlobalVariable(llv
 SmallVector Expr;
 unsigned AddressSpace =
 CGM.getContext().getTargetAddressSpace(D->getType());
+if (CGM.getLangOpts().CUDA && CGM.getLangOpts().CUDAIsDevice) {
+  if (D->hasAttr())
+AddressSpace =
+CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared);
+  else if (D->hasAttr())
+AddressSpace =
+CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant);
+}
 AppendAddressSpaceXDeref(AddressSpace, Expr);
 
 GVE = DBuilder.createGlobalVariableExpression(

Added: cfe/trunk/test/CodeGenCUDA/debug-info-address-class.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/debug-info-address-class.cu?rev=353204&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/debug-info-address-class.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/debug-info-address-class.cu Tue Feb  5 11:45:57 
2019
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device -triple 
nvptx-unknown-unknown -debug-info-kind=limited -dwarf-version=2 
-debugger-tuning=gdb | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DAG: ![[FILEVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: 
"FileVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}}, isLocal: false, isDefinition: true)
+// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: 
!DIExpression())
+__device__ int FileVar0;
+// CHECK-DAG: ![[FILEVAR1:[0-9]+]] = distinct !DIGlobalVariab

[PATCH] D57162: [DEBUG_INFO][NVPTX] Generate correct data about variable address class.

2019-02-05 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353204: [DEBUG_INFO][NVPTX] Generate correct data about 
variable address class. (authored by ABataev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57162?vs=183325&id=185364#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57162

Files:
  lib/Basic/Targets/NVPTX.h
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCUDA/debug-info-address-class.cu


Index: test/CodeGenCUDA/debug-info-address-class.cu
===
--- test/CodeGenCUDA/debug-info-address-class.cu
+++ test/CodeGenCUDA/debug-info-address-class.cu
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device -triple 
nvptx-unknown-unknown -debug-info-kind=limited -dwarf-version=2 
-debugger-tuning=gdb | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DAG: ![[FILEVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: 
"FileVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}}, isLocal: false, isDefinition: true)
+// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: 
!DIExpression())
+__device__ int FileVar0;
+// CHECK-DAG: ![[FILEVAR1:[0-9]+]] = distinct !DIGlobalVariable(name: 
"FileVar1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}}, isLocal: false, isDefinition: true)
+// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR1]], expr: 
!DIExpression(DW_OP_constu, 8, DW_OP_swap, DW_OP_xderef))
+__device__ __shared__ int FileVar1;
+// CHECK-DAG: ![[FILEVAR2:[0-9]+]] = distinct !DIGlobalVariable(name: 
"FileVar2", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}}, isLocal: false, isDefinition: true)
+// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR2]], expr: 
!DIExpression(DW_OP_constu, 4, DW_OP_swap, DW_OP_xderef))
+__device__ __constant__ int FileVar2;
+
+__device__ void kernel1(
+// CHECK-DAG: ![[ARG:[0-9]+]] = !DILocalVariable(name: "Arg", arg: 
{{[0-9]+}}, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}})
+// CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata 
![[ARG]], metadata !DIExpression()), !dbg !{{[0-9]+}}
+int Arg) {
+// CHECK-DAG: ![[FUNCVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: 
"FuncVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: 
!{{[0-9]+}}, isLocal: true, isDefinition: true)
+// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR0]], expr: 
!DIExpression(DW_OP_constu, 8, DW_OP_swap, DW_OP_xderef))
+  __shared__ int FuncVar0;
+  // CHECK-DAG: ![[FUNCVAR1:[0-9]+]] = !DILocalVariable(name: "FuncVar1", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
+  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata 
![[FUNCVAR1]], metadata !DIExpression()), !dbg !{{[0-9]+}}
+  int FuncVar1;
+}
Index: lib/Basic/Targets/NVPTX.h
===
--- lib/Basic/Targets/NVPTX.h
+++ lib/Basic/Targets/NVPTX.h
@@ -35,6 +35,16 @@
 3, // cuda_shared
 };
 
+/// The DWARF address class. Taken from
+/// 
https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
+static const int NVPTXDWARFAddrSpaceMap[] = {
+-1, // Default, opencl_private or opencl_generic - not defined
+5,  // opencl_global
+-1,
+8,  // opencl_local or cuda_shared
+4,  // opencl_constant or cuda_constant
+};
+
 class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
@@ -124,6 +134,20 @@
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
 
+  /// \returns If a target requires an address within a target specific address
+  /// space \p AddressSpace to be converted in order to be used, then return 
the
+  /// corresponding target specific DWARF address space.
+  ///
+  /// \returns Otherwise return None and no conversion will be emitted in the
+  /// DWARF.
+  Optional
+  getDWARFAddressSpace(unsigned AddressSpace) const override {
+if (AddressSpace >= llvm::array_lengthof(NVPTXDWARFAddrSpaceMap) ||
+NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)
+  return llvm::None;
+return NVPTXDWARFAddrSpaceMap[AddressSpace];
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 // CUDA compilations support all of the host's calling conventions.
 //
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4232,6 +4232,14 @@
 SmallVector Expr;
 unsigned AddressSpace =
 CGM.getContext().getTargetAddressSpace(D->getType());
+if (CGM.getLangOpts().CUDA && CGM.getLangOpts().CUDAIsDevice)

[PATCH] D57230: [analyzer] Toning down invalidation a bit

2019-02-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.
Herald added a project: LLVM.

Hmm. `writes_to_superobject`?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57230



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


[libunwind] r353208 - [CMake] Support compiler-rt builtins library in tests

2019-02-05 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Feb  5 11:50:47 2019
New Revision: 353208

URL: http://llvm.org/viewvc/llvm-project?rev=353208&view=rev
Log:
[CMake] Support compiler-rt builtins library in tests

We're building tests with -nostdlib which means that we need to
explicitly include the builtins library. When using libgcc (default)
we can simply include -lgcc_s on the link line, but when using
compiler-rt builtins we need a complete path to the builtins library.

This path is already available in CMake as _BUILTINS_LIBRARY,
so we just need to pass that path to lit and if config.compiler_rt is
true, link it to the test.

Prior to this patch, running tests when compiler-rt is being used as
the builtins library was broken as all tests would fail to link, but
with this change running tests when compiler-rt bultins library is
being used should be supported.

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

Modified:
libunwind/trunk/test/lit.site.cfg.in

Modified: libunwind/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/lit.site.cfg.in?rev=353208&r1=353207&r2=353208&view=diff
==
--- libunwind/trunk/test/lit.site.cfg.in (original)
+++ libunwind/trunk/test/lit.site.cfg.in Tue Feb  5 11:50:47 2019
@@ -8,7 +8,7 @@ config.libcxx_src_root  = "@LIBU
 config.libunwind_headers= "@LIBUNWIND_SOURCE_DIR@/include"
 config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@"
 config.llvm_unwinder= True
-config.compiler_rt  = @LIBUNWIND_USE_COMPILER_RT@
+config.builtins_library = "@LIBUNWIND_BUILTINS_LIBRARY@"
 config.enable_threads   = @LIBUNWIND_ENABLE_THREADS@
 config.use_sanitizer= "@LLVM_USE_SANITIZER@"
 config.enable_32bit = @LIBUNWIND_BUILD_32_BITS@


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


r353212 - Do not use frame pointer by default for MSP430

2019-02-05 Thread Anton Korobeynikov via cfe-commits
Author: asl
Date: Tue Feb  5 12:15:03 2019
New Revision: 353212

URL: http://llvm.org/viewvc/llvm-project?rev=353212&view=rev
Log:
Do not use frame pointer by default for MSP430

This is suggested by 3.3.9 of MSP430 EABI document.
We do allow user to manually enable frame pointer. GCC toolchain uses the same 
behavior.

Patch by Dmitry Mikushev!

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

Added:
cfe/trunk/test/CodeGen/msp430-fp-elim.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=353212&r1=353211&r2=353212&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Feb  5 12:15:03 2019
@@ -519,6 +519,7 @@ static bool useFramePointerForTargetByDe
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::msp430:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;

Added: cfe/trunk/test/CodeGen/msp430-fp-elim.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/msp430-fp-elim.c?rev=353212&view=auto
==
--- cfe/trunk/test/CodeGen/msp430-fp-elim.c (added)
+++ cfe/trunk/test/CodeGen/msp430-fp-elim.c Tue Feb  5 12:15:03 2019
@@ -0,0 +1,19 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_ENFORCED
+// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_DEFAULT
+
+// Check the frame pointer is not used on MSP430 by default, but can be 
forcibly turned on.
+
+// FP_ENFORCED: push r4
+// FP_ENFORCED: mov r4, r4
+// FP_ENFORCED: pop r4
+// FP_DEFAULT: .globl fp_elim_check
+// FP_DEFAULT-NOT: push r4
+// FP_DEFAULT: mov r4, r4
+// FP_DEFAULT-NOT: pop r4
+
+void fp_elim_check()
+{
+   asm volatile ("mov r4, r4");
+}
+


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


[PATCH] D56925: Do not use frame pointer by default for MSP430

2019-02-05 Thread Anton Korobeynikov via Phabricator via cfe-commits
asl accepted this revision.
asl added a comment.
This revision is now accepted and ready to land.
Herald added a project: clang.

Ok now


Repository:
  rC Clang

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

https://reviews.llvm.org/D56925



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


[PATCH] D56925: Do not use frame pointer by default for MSP430

2019-02-05 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353212: Do not use frame pointer by default for MSP430 
(authored by asl, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56925

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/CodeGen/msp430-fp-elim.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -519,6 +519,7 @@
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::msp430:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
Index: cfe/trunk/test/CodeGen/msp430-fp-elim.c
===
--- cfe/trunk/test/CodeGen/msp430-fp-elim.c
+++ cfe/trunk/test/CodeGen/msp430-fp-elim.c
@@ -0,0 +1,19 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_ENFORCED
+// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_DEFAULT
+
+// Check the frame pointer is not used on MSP430 by default, but can be 
forcibly turned on.
+
+// FP_ENFORCED: push r4
+// FP_ENFORCED: mov r4, r4
+// FP_ENFORCED: pop r4
+// FP_DEFAULT: .globl fp_elim_check
+// FP_DEFAULT-NOT: push r4
+// FP_DEFAULT: mov r4, r4
+// FP_DEFAULT-NOT: pop r4
+
+void fp_elim_check()
+{
+   asm volatile ("mov r4, r4");
+}
+


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -519,6 +519,7 @@
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::msp430:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
Index: cfe/trunk/test/CodeGen/msp430-fp-elim.c
===
--- cfe/trunk/test/CodeGen/msp430-fp-elim.c
+++ cfe/trunk/test/CodeGen/msp430-fp-elim.c
@@ -0,0 +1,19 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_ENFORCED
+// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_DEFAULT
+
+// Check the frame pointer is not used on MSP430 by default, but can be forcibly turned on.
+
+// FP_ENFORCED: push r4
+// FP_ENFORCED: mov r4, r4
+// FP_ENFORCED: pop r4
+// FP_DEFAULT: .globl fp_elim_check
+// FP_DEFAULT-NOT: push r4
+// FP_DEFAULT: mov r4, r4
+// FP_DEFAULT-NOT: pop r4
+
+void fp_elim_check()
+{
+	asm volatile ("mov r4, r4");
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 185375.
yaxunl retitled this revision from "Let AMDGPU compile MSVC headers containing 
vectorcall" to "[CUDA][HIP] Check calling convention based on function target".
yaxunl edited the summary of this revision.
yaxunl added a reviewer: tra.
yaxunl added a comment.

My last fix is not right. This patch fixes the issue by checking calling 
convention based on whether it is host or device function.


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

https://reviews.llvm.org/D57716

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/amdgpu-windows-vectorcall.cu


Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-windows-vectorcall.cu
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only 
-verify %s
+
+// expected-no-diagnostics
+template
+ struct A
+ {
+ };
+
+template struct A<_Ret (__cdecl 
_Arg0::*)(_Types) > { };
+template struct A<_Ret (__vectorcall 
_Arg0::*)(_Types) > {};
+
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4614,8 +4614,31 @@
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {
+auto CUDATarget = IdentifyCUDATarget(FD);
+if (CUDATarget == CFT_HostDevice) {
+  A = TI.checkCallingConvention(CC);
+  if (A == TargetInfo::CCCR_OK && Aux)
+A = Aux->checkCallingConvention(CC);
+} else if (LangOpts.CUDAIsDevice) {
+  if (CUDATarget == CFT_Device || CUDATarget == CFT_Global) {
+A = TI.checkCallingConvention(CC);
+  } else if (CUDATarget == CFT_Host && Aux) {
+A = Aux->checkCallingConvention(CC);
+  }
+} else {
+  if ((CUDATarget == CFT_Device || CUDATarget == CFT_Global) && Aux) {
+A = Aux->checkCallingConvention(CC);
+  } else if (CUDATarget == CFT_Host) {
+A = TI.checkCallingConvention(CC);
+  }
+}
+  } else {
+A = TI.checkCallingConvention(CC);
+  }
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
   Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;


Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-windows-vectorcall.cu
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+template
+ struct A
+ {
+ };
+
+template struct A<_Ret (__cdecl _Arg0::*)(_Types) > { };
+template struct A<_Ret (__vectorcall _Arg0::*)(_Types) > {};
+
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4614,8 +4614,31 @@
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {
+auto CUDATarget = IdentifyCUDATarget(FD);
+if (CUDATarget == CFT_HostDevice) {
+  A = TI.checkCallingConvention(CC);
+  if (A == TargetInfo::CCCR_OK && Aux)
+A = Aux->checkCallingConvention(CC);
+} else if (LangOpts.CUDAIsDevice) {
+  if (CUDATarget == CFT_Device || CUDATarget == CFT_Global) {
+A = TI.checkCallingConvention(CC);
+  } else if (CUDATarget == CFT_Host && Aux) {
+A = Aux->checkCallingConvention(CC);
+  }
+} else {
+  if ((CUDATarget == CFT_Device || CUDATarget == CFT_Global) && Aux) {
+A = Aux->checkCallingConvention(CC);
+  } else if (CUDATarget == CFT_Host) {
+A = TI.checkCallingConvention(CC);
+  }
+}
+  } else {
+A = TI.checkCallingConvention(CC);
+  }
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
   Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353214 - [DOCS]Support for emission of the debug info for the Cuda devices, NFC.

2019-02-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Feb  5 12:38:36 2019
New Revision: 353214

URL: http://llvm.org/viewvc/llvm-project?rev=353214&view=rev
Log:
[DOCS]Support for emission of the debug info for the Cuda devices, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=353214&r1=353213&r2=353214&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Tue Feb  5 12:38:36 2019
@@ -101,7 +101,7 @@ between the threads in the parallel regi
 Collapsed loop nest counter
 ---
 
-When using the collapse clause on a loop nest the default behaviour is to
+When using the collapse clause on a loop nest the default behavior is to
 automatically extend the representation of the loop counter to 64 bits for
 the cases where the sizes of the collapsed loops are not known at compile
 time. To prevent this conservative choice and use at most 32 bits,
@@ -124,5 +124,8 @@ Features not supported or with limited s
 - Automatic translation of math functions in target regions to device-specific
   math functions is not implemented yet.
 
-- Debug information for OpenMP target regions is not supported yet.
+- Debug information for OpenMP target regions is supported, but sometimes it 
may
+  be required to manually specify the address class of the inspected variables.
+  In some cases the local variables are actually allocated in the global 
memory,
+  but the debug info may be not aware of it.
 

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=353214&r1=353213&r2=353214&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Feb  5 12:38:36 2019
@@ -133,11 +133,12 @@ ABI Changes in Clang
 OpenMP Support in Clang
 --
 
-- ...
+- Added emission of the debug information for NVPTX target devices.
 
 CUDA Support in Clang
 -
 
+- Added emission of the debug information for the device code.
 
 Internal API Changes
 


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


[PATCH] D57674: [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals

2019-02-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang-tidy/bugprone/ArgumentCommentCheck.cpp:228-236
+static bool isStringLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast(Arg);
+  return Cast ? isa(Cast->getSubExpr()) : false;
+}
+
+static bool isNullPtrLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast(Arg);

aaron.ballman wrote:
> What's going on with these? Why not `return 
> isa(Arg->IgnoreImpCasts());` (at which point, no need for the separate 
> functions).
OK, my bad, I was just looking at the ast-dump on godbolt.org thinking... how 
do I get past that ImplicitCasrExpr, learning these tricks in the AST isn't 
always obvious despite me looking in doxygen, when you don't know what to look 
for its hard to know..but this is a neat trick and I'm happy to learn.



Comment at: docs/clang-tidy/checks/bugprone-argument-comment.rst:40
+
+  void foo(bool turn_key,bool press_button);
+

aaron.ballman wrote:
> aaron.ballman wrote:
> > Format the code examples from our style guide as well (same below).
> This still seems to be happening in the current revision?
Sorry didn't catch your meaning but I assume it was the space between the 
arguments...


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

https://reviews.llvm.org/D57674



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


[PATCH] D57674: [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals

2019-02-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 185385.
MyDeveloperDay marked 6 inline comments as done.
MyDeveloperDay added a comment.

Address review comments


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

https://reviews.llvm.org/D57674

Files:
  clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tidy/bugprone/ArgumentCommentCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-argument-comment.rst
  test/clang-tidy/bugprone-argument-comment-literals.cpp

Index: test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -0,0 +1,107 @@
+// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
+// RUN:   -config="{CheckOptions: [{key: CommentBoolLiterals, value: 1},{key: CommentIntegerLiterals, value: 1}, {key: CommentFloatLiterals, value: 1}, {key: CommentUserDefinedLiterals, value: 1}, {key: CommentStringLiterals, value: 1}, {key: CommentNullPtrs, value: 1}, {key: CommentCharacterLiterals, value: 1}]}" --
+
+struct A {
+  void foo(bool abc);
+  void foo(bool abc, bool cde);
+  void foo(const char *, bool abc);
+  void foo(int iabc);
+  void foo(float fabc);
+  void foo(double dabc);
+  void foo(const char *strabc);
+  void fooW(const wchar_t *wstrabc);
+  void fooPtr(A *ptrabc);
+  void foo(char chabc);
+};
+
+double operator"" _km(long double);
+
+void test() {
+  A a;
+
+  a.foo(true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/true);
+
+  a.foo(false);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false);
+
+  a.foo(true, false);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:15: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/true, /*cde=*/false);
+
+  a.foo(false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:16: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(/*abc=*/false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(false, /*cde=*/true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  bool val1 = true;
+  bool val2 = false;
+  a.foo(val1, val2);
+
+  a.foo("", true);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo("", /*abc=*/true);
+
+  a.foo(0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'iabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*iabc=*/0);
+
+  a.foo(1.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'fabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*fabc=*/1.0f);
+
+  a.foo(1.0);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/1.0);
+
+  int val3 = 10;
+  a.foo(val3);
+
+  float val4 = 10.0;
+  a.foo(val4);
+
+  double val5 = 10.0;
+  a.foo(val5);
+
+  a.foo("Hello World");
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'strabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*strabc=*/"Hello World");
+  //
+  a.fooW(L"Hello World");
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: argument comment missing for literal argument 'wstrabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.fooW(/*wstrabc=*/L"Hello World");
+
+  a.fooPtr(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: argument comment missing for literal argument 'ptrabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.fooPtr(/*ptrabc=*/nullptr);
+
+  a.foo(402.0_km);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'dabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*dabc=*/402.0_km);
+
+  a.foo('A');
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'chabc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*chabc=*/'A');
+}
+
+void f(bool _with_underscores_);
+void ignores_underscores() {
+  f(false);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warni

[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.

Sorry, this fell off my radar :). LGTM too.


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

https://reviews.llvm.org/D56850



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


[PATCH] D57674: [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals

2019-02-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang-tidy/bugprone/ArgumentCommentCheck.cpp:257
 Ctx->getLangOpts());
   };
 

@aaron.ballman, slight aside (and not in the code I introduced), when I run 
clang-tidy on the code I'm sending for review, I get the following...

```
C:\clang\llvm\tools\clang\tools\extra\clang-tidy\bugprone\ArgumentCommentCheck.cpp:253:8:
 warning: invalid case style for variable 'makeFileCharRange' 
[readability-identifier-naming]
  auto makeFileCharRange = [Ctx](SourceLocation Begin, SourceLocation End) {
   ^
   MakeFileCharRange

```

according to the .clang-tidy, a variable should be CamelCase, and a function 
camelBack, as its a Lambda what do we consider it should be? and does this 
really require an improvement in readability-identifier-naming? (might be 
something I'd be happy to look at next)

```
Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming'
CheckOptions:
  - key: readability-identifier-naming.ClassCase
value:   CamelCase
  - key: readability-identifier-naming.EnumCase
value:   CamelCase
  - key: readability-identifier-naming.FunctionCase
value:   camelBack
  - key: readability-identifier-naming.MemberCase
value:   CamelCase
  - key: readability-identifier-naming.ParameterCase
value:   CamelCase
  - key: readability-identifier-naming.UnionCase
value:   CamelCase
  - key: readability-identifier-naming.VariableCase
value:   CamelCase
```










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

https://reviews.llvm.org/D57674



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2019-02-05 Thread Lang Hames via Phabricator via cfe-commits
lhames accepted this revision.
lhames added a comment.
This revision is now accepted and ready to land.

Looks like this was LGTM'd but never applied. Stephen -- do you have commit 
access?


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

https://reviews.llvm.org/D36806



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


r353219 - Fix a missing word in comment

2019-02-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Feb  5 13:21:01 2019
New Revision: 353219

URL: http://llvm.org/viewvc/llvm-project?rev=353219&view=rev
Log:
Fix a missing word in comment

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=353219&r1=353218&r2=353219&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  5 13:21:01 2019
@@ -450,8 +450,8 @@ CGDebugInfo::createFile(StringRef FileNa
 for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
   llvm::sys::path::append(DirBuf, *CurDirIt);
 if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
-  // The common prefix only the root; stripping it would cause
-  // LLVM diagnostic locations to be more confusing.
+  // Don't strip the common prefix if it is only the root "/"
+  // since that would make LLVM diagnostic locations confusing.
   Dir = {};
   File = RemappedFile;
 } else {


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


[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:4621-4638
+auto CUDATarget = IdentifyCUDATarget(FD);
+if (CUDATarget == CFT_HostDevice) {
+  A = TI.checkCallingConvention(CC);
+  if (A == TargetInfo::CCCR_OK && Aux)
+A = Aux->checkCallingConvention(CC);
+} else if (LangOpts.CUDAIsDevice) {
+  if (CUDATarget == CFT_Device || CUDATarget == CFT_Global) {

This is rather convoluted.
Perhaps it would be easier to understand if the code is restructured. along 
these lines:

```
// Returns a tuple indicating whether we need to check TargetInfo on 
host/device side of the compilation
bool CheckHost = false, CheckDevice=false;

switch (CudaTarget) { 
case CFT_HostDevice: 
  CheckHost = true; CheckDevice=true; break;
case CFT_Host: 
  CheckHost = true; break;
case CFG_Device: 
case CFG_Global: 
  CheckDevice=true; break;
  }
} ();
TargetInfo *HostTI = CudaIsDevice ? Aux : &TI;
TargetInfo * DeviceTI = CudaIsDevice ? &TI : Aux;
if (CheckHost && HostTI)
  HostTI->checkCallingConvention(CC);
if (CheckDevice && DeviceTI)
DeviceTI->checkCallingConvention(CC);

```



Comment at: test/SemaCUDA/amdgpu-windows-vectorcall.cu:3
+
+// expected-no-diagnostics
+template

It may be good to add a check where we *would* expect to see the diagnostics.


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

https://reviews.llvm.org/D57716



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


[PATCH] D57771: [CUDA] Add basic support for CUDA-10.1

2019-02-05 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:620
+
+// CUDA version requires calling __cudaRegisterFatBinaryEnd(Handle);
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),

Was confused by this sentence for a while.  Maybe change to "Check whether cuda 
version requires "?


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

https://reviews.llvm.org/D57771



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


[PATCH] D57771: [CUDA] Add basic support for CUDA-10.1

2019-02-05 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 185398.
tra added a comment.

Made a comment more readable.


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

https://reviews.llvm.org/D57771

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 10010
 #error "Unsupported CUDA version!"
 #endif
 
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -60,6 +60,8 @@
 return CudaVersion::CUDA_92;
   if (Major == 10 && Minor == 0)
 return CudaVersion::CUDA_100;
+  if (Major == 10 && Minor == 1)
+return CudaVersion::CUDA_101;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -616,6 +616,16 @@
 // Call __cuda_register_globals(GpuBinaryHandle);
 if (RegisterGlobalsFunc)
   CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+
+// Call __cudaRegisterFatBinaryEnd(Handle) if this CUDA version needs it.
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+   CudaFeature::CUDA_USES_FATBIN_REGISTER_END)) {
+  // void __cudaRegisterFatBinaryEnd(void **);
+  llvm::FunctionCallee RegisterFatbinEndFunc = CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
+  "__cudaRegisterFatBinaryEnd");
+  CtorBuilder.CreateCall(RegisterFatbinEndFunc, RegisterFatbinCall);
+}
   } else {
 // Generate a unique module ID.
 SmallString<64> ModuleID;
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -25,6 +25,8 @@
 return "9.2";
   case CudaVersion::CUDA_100:
 return "10.0";
+  case CudaVersion::CUDA_101:
+return "10.1";
   }
   llvm_unreachable("invalid enum");
 }
@@ -37,7 +39,8 @@
   .Case("9.0", CudaVersion::CUDA_90)
   .Case("9.1", CudaVersion::CUDA_91)
   .Case("9.2", CudaVersion::CUDA_92)
-  .Case("10.0", CudaVersion::CUDA_100);
+  .Case("10.0", CudaVersion::CUDA_100)
+  .Case("10.1", CudaVersion::CUDA_101);
 }
 
 const char *CudaArchToString(CudaArch A) {
@@ -352,6 +355,8 @@
 return CudaVersion::CUDA_92;
   case 100:
 return CudaVersion::CUDA_100;
+  case 101:
+return CudaVersion::CUDA_101;
   default:
 return CudaVersion::UNKNOWN;
   }
@@ -365,6 +370,8 @@
   switch (Feature) {
   case CudaFeature::CUDA_USES_NEW_LAUNCH:
 return Version >= CudaVersion::CUDA_92;
+  case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
+return Version >= CudaVersion::CUDA_101;
   }
   llvm_unreachable("Unknown CUDA feature.");
 }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -25,7 +25,8 @@
   CUDA_91,
   CUDA_92,
   CUDA_100,
-  LATEST = CUDA_100,
+  CUDA_101,
+  LATEST = CUDA_101,
 };
 const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
@@ -107,6 +108,8 @@
 enum class CudaFeature {
   // CUDA-9.2+ uses a new API for launching kernels.
   CUDA_USES_NEW_LAUNCH,
+  // CUDA-10.1+ needs explicit end of GPU binary registration.
+  CUDA_USES_FATBIN_REGISTER_END,
 };
 
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57787: [clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)

2019-02-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: JonasToth, aaron.ballman.
lebedev.ri added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.

The check should ignore the main function, the program entry point.
It is not possible to use `std::array<>` for the `argv`.
The alternative is to use `char** argv`.

Fixes PR40604 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57787

Files:
  clang-tidy/modernize/AvoidCArraysCheck.cpp
  test/clang-tidy/modernize-avoid-c-arrays.cpp


Index: test/clang-tidy/modernize-avoid-c-arrays.cpp
===
--- test/clang-tidy/modernize-avoid-c-arrays.cpp
+++ test/clang-tidy/modernize-avoid-c-arrays.cpp
@@ -86,3 +86,20 @@
   int j[1];
 };
 }
+
+int not_main(int argc, char *argv[]) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, 
use std::array<> instead
+  int f4[] = {1, 2};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, 
use std::array<> instead
+}
+
+int main(int argc, char *argv[]) {
+  int f5[] = {1, 2};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, 
use std::array<> instead
+
+  auto not_main = [](int argc, char *argv[]) {
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style 
arrays, use std::array<> instead
+int f6[] = {1, 2};
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, 
use std::array<> instead
+  };
+}
Index: clang-tidy/modernize/AvoidCArraysCheck.cpp
===
--- clang-tidy/modernize/AvoidCArraysCheck.cpp
+++ clang-tidy/modernize/AvoidCArraysCheck.cpp
@@ -30,6 +30,14 @@
   return Node.isExternCContext();
 }
 
+AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) {
+  const clang::DeclContext *DC = Node.getDeclContext();
+  const clang::FunctionDecl *FD = llvm::dyn_cast(DC);
+  if (!FD)
+return false; // If not a function, then certainly not 'main'.
+  return FD->isMain();
+}
+
 } // namespace
 
 namespace clang {
@@ -43,7 +51,8 @@
 
   Finder->addMatcher(
   typeLoc(hasValidBeginLoc(), hasType(arrayType()),
-  unless(anyOf(hasParent(varDecl(isExternC())),
+  unless(anyOf(hasParent(parmVarDecl(isArgvOfMain())),
+   hasParent(varDecl(isExternC())),
hasParent(fieldDecl(
hasParent(recordDecl(isExternCContext(),
hasAncestor(functionDecl(isExternC())


Index: test/clang-tidy/modernize-avoid-c-arrays.cpp
===
--- test/clang-tidy/modernize-avoid-c-arrays.cpp
+++ test/clang-tidy/modernize-avoid-c-arrays.cpp
@@ -86,3 +86,20 @@
   int j[1];
 };
 }
+
+int not_main(int argc, char *argv[]) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
+  int f4[] = {1, 2};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+}
+
+int main(int argc, char *argv[]) {
+  int f5[] = {1, 2};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+
+  auto not_main = [](int argc, char *argv[]) {
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> instead
+int f6[] = {1, 2};
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+  };
+}
Index: clang-tidy/modernize/AvoidCArraysCheck.cpp
===
--- clang-tidy/modernize/AvoidCArraysCheck.cpp
+++ clang-tidy/modernize/AvoidCArraysCheck.cpp
@@ -30,6 +30,14 @@
   return Node.isExternCContext();
 }
 
+AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) {
+  const clang::DeclContext *DC = Node.getDeclContext();
+  const clang::FunctionDecl *FD = llvm::dyn_cast(DC);
+  if (!FD)
+return false; // If not a function, then certainly not 'main'.
+  return FD->isMain();
+}
+
 } // namespace
 
 namespace clang {
@@ -43,7 +51,8 @@
 
   Finder->addMatcher(
   typeLoc(hasValidBeginLoc(), hasType(arrayType()),
-  unless(anyOf(hasParent(varDecl(isExternC())),
+  unless(anyOf(hasParent(parmVarDecl(isArgvOfMain())),
+   hasParent(varDecl(isExternC())),
hasParent(fieldDecl(
hasParent(recordDecl(isExternCContext(),
hasAncestor(functionDecl(isExternC())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-02-05 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked an inline comment as done.
riccibruno added inline comments.



Comment at: lib/AST/Expr.cpp:2562
+return ICE->getSubExpr();
+
+  else if (auto *FE = dyn_cast_or_null(E))

aaron.ballman wrote:
> riccibruno wrote:
> > It is something that is actually possible to audit. I did look at where 
> > each of the skipped node are created and it *seems* that a null child is 
> > not possible. However it is very easy to miss a case and adding the null 
> > check give the various `Expr::Ignore*` the following nice property:
> > 
> > Regardless of the state of the AST, for every expression `E` (null or not). 
> > `Ignore*(E)` produces the correct result (which may be null).
> > 
> > But perhaps the correct invariant to maintain is that these nodes have 
> > always a non-null child ?
> > 
> > I re-ran the benchmarks more carefully and here are the results I got (on 
> > my usual benchmark: `-fyntax-only` on all of Boost, 20 iterations with 
> > `perf stat`):
> > 
> > 8.2117 +- 0.0131 seconds (with the null check)
> > 8.2028 +- 0.0058 seconds (without the null check)
> > But perhaps the correct invariant to maintain is that these nodes have 
> > always a non-null child ?
> 
> I believe we treat this as an invariant in a lot of other places, so it seems 
> like a reasonable invariant here. Being more resilient is not a bad thing, 
> but it may also mask broken invariants elsewhere.
> 
> I'll leave it to @rsmith to make the final call though.
All right. Lets go with `dyn_cast` to preserve the original behavior.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2019-02-05 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In D36806#1385936 , @lhames wrote:

> Looks like this was LGTM'd but never applied. Stephen -- do you have commit 
> access?


Yeah, I was waiting on someone with approval for this area of the code to 
comment and then lost track of it. I can recheck it tonight and then submit it. 
Thank you for going back through these patches. :)


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

https://reviews.llvm.org/D36806



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


r353227 - [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls

2019-02-05 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Feb  5 14:26:44 2019
New Revision: 353227

URL: http://llvm.org/viewvc/llvm-project?rev=353227&view=rev
Log:
[analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX 
method calls

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

Modified:
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/retain-release.mm

Modified: cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RetainSummaryManager.cpp?rev=353227&r1=353226&r2=353227&view=diff
==
--- cfe/trunk/lib/Analysis/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Tue Feb  5 14:26:44 2019
@@ -499,19 +499,19 @@ RetainSummaryManager::generateSummary(co
 if (const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
   return S;
 
-  if (TrackObjCAndCFObjects)
-if (const RetainSummary *S =
-getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, 
AllowAnnotations))
-  return S;
-
   if (const auto *MD = dyn_cast(FD))
-if (!(TrackOSObjects && isOSObjectRelated(MD)))
+if (!isOSObjectRelated(MD))
   return getPersistentSummary(RetEffect::MakeNoRet(),
   ArgEffects(AF.getEmptyMap()),
   ArgEffect(DoNothing),
   ArgEffect(StopTracking),
   ArgEffect(DoNothing));
 
+  if (TrackObjCAndCFObjects)
+if (const RetainSummary *S =
+getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, 
AllowAnnotations))
+  return S;
+
   return getDefaultSummary();
 }
 

Modified: cfe/trunk/test/Analysis/retain-release.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.mm?rev=353227&r1=353226&r2=353227&view=diff
==
--- cfe/trunk/test/Analysis/retain-release.mm (original)
+++ cfe/trunk/test/Analysis/retain-release.mm Tue Feb  5 14:26:44 2019
@@ -471,7 +471,6 @@ void rdar33832412() {
   void* x = IOBSDNameMatching(); // no-warning
 }
 
-
 namespace member_CFRetains {
 class Foo {
 public:
@@ -485,3 +484,22 @@ void bar() {
   foo.CFRetain(0); // no-warning
 }
 }
+
+namespace cxx_method_escaping {
+
+struct S {
+  static CFArrayRef testGetNoTracking();
+  CFArrayRef testGetNoTrackingMember();
+};
+
+void test_cxx_static_method_escaping() {
+  CFArrayRef arr = S::testGetNoTracking();
+  CFRelease(arr);
+}
+
+void test_cxx_method_escaping(S *s) {
+  CFArrayRef arr = s->testGetNoTrackingMember();
+  CFRelease(arr);
+}
+
+}


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


[PATCH] D57782: [analyzer] [RetainCountChecker] Bugfix: in non-OSObject-mode, do not track CXX method calls

2019-02-05 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
george.karpenkov marked an inline comment as done.
Closed by commit rC353227: [analyzer] [RetainCountChecker] Bugfix: in 
non-OSObject-mode, do not track CXX… (authored by george.karpenkov, committed 
by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57782?vs=185392&id=185407#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57782

Files:
  lib/Analysis/RetainSummaryManager.cpp
  test/Analysis/retain-release.mm


Index: lib/Analysis/RetainSummaryManager.cpp
===
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -499,19 +499,19 @@
 if (const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
   return S;
 
-  if (TrackObjCAndCFObjects)
-if (const RetainSummary *S =
-getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, 
AllowAnnotations))
-  return S;
-
   if (const auto *MD = dyn_cast(FD))
-if (!(TrackOSObjects && isOSObjectRelated(MD)))
+if (!isOSObjectRelated(MD))
   return getPersistentSummary(RetEffect::MakeNoRet(),
   ArgEffects(AF.getEmptyMap()),
   ArgEffect(DoNothing),
   ArgEffect(StopTracking),
   ArgEffect(DoNothing));
 
+  if (TrackObjCAndCFObjects)
+if (const RetainSummary *S =
+getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, 
AllowAnnotations))
+  return S;
+
   return getDefaultSummary();
 }
 
Index: test/Analysis/retain-release.mm
===
--- test/Analysis/retain-release.mm
+++ test/Analysis/retain-release.mm
@@ -471,7 +471,6 @@
   void* x = IOBSDNameMatching(); // no-warning
 }
 
-
 namespace member_CFRetains {
 class Foo {
 public:
@@ -485,3 +484,22 @@
   foo.CFRetain(0); // no-warning
 }
 }
+
+namespace cxx_method_escaping {
+
+struct S {
+  static CFArrayRef testGetNoTracking();
+  CFArrayRef testGetNoTrackingMember();
+};
+
+void test_cxx_static_method_escaping() {
+  CFArrayRef arr = S::testGetNoTracking();
+  CFRelease(arr);
+}
+
+void test_cxx_method_escaping(S *s) {
+  CFArrayRef arr = s->testGetNoTrackingMember();
+  CFRelease(arr);
+}
+
+}


Index: lib/Analysis/RetainSummaryManager.cpp
===
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -499,19 +499,19 @@
 if (const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
   return S;
 
-  if (TrackObjCAndCFObjects)
-if (const RetainSummary *S =
-getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
-  return S;
-
   if (const auto *MD = dyn_cast(FD))
-if (!(TrackOSObjects && isOSObjectRelated(MD)))
+if (!isOSObjectRelated(MD))
   return getPersistentSummary(RetEffect::MakeNoRet(),
   ArgEffects(AF.getEmptyMap()),
   ArgEffect(DoNothing),
   ArgEffect(StopTracking),
   ArgEffect(DoNothing));
 
+  if (TrackObjCAndCFObjects)
+if (const RetainSummary *S =
+getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
+  return S;
+
   return getDefaultSummary();
 }
 
Index: test/Analysis/retain-release.mm
===
--- test/Analysis/retain-release.mm
+++ test/Analysis/retain-release.mm
@@ -471,7 +471,6 @@
   void* x = IOBSDNameMatching(); // no-warning
 }
 
-
 namespace member_CFRetains {
 class Foo {
 public:
@@ -485,3 +484,22 @@
   foo.CFRetain(0); // no-warning
 }
 }
+
+namespace cxx_method_escaping {
+
+struct S {
+  static CFArrayRef testGetNoTracking();
+  CFArrayRef testGetNoTrackingMember();
+};
+
+void test_cxx_static_method_escaping() {
+  CFArrayRef arr = S::testGetNoTracking();
+  CFRelease(arr);
+}
+
+void test_cxx_method_escaping(S *s) {
+  CFArrayRef arr = s->testGetNoTrackingMember();
+  CFRelease(arr);
+}
+
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353228 - [analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path

2019-02-05 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Feb  5 14:26:57 2019
New Revision: 353228

URL: http://llvm.org/viewvc/llvm-project?rev=353228&view=rev
Log:
[analyzer] [testing] Inside CmpRuns.py output also print the filename of the 
first item in the path

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

Modified:
cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=353228&r1=353227&r2=353228&view=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Tue Feb  5 14:26:57 2019
@@ -73,6 +73,21 @@ class AnalysisDiagnostic(object):
 return fileName[len(root) + 1:]
 return fileName
 
+def getRootFileName(self):
+path = self._data['path']
+if not path:
+return self.getFileName()
+p = path[0]
+if 'location' in p:
+fIdx = p['location']['file']
+else: # control edge
+fIdx = path[0]['edges'][0]['start'][0]['file']
+out = self._report.files[fIdx]
+root = self._report.run.root
+if out.startswith(root):
+return out[len(root):]
+return out
+
 def getLine(self):
 return self._loc['line']
 
@@ -106,7 +121,13 @@ class AnalysisDiagnostic(object):
 funcnamePostfix = "#" + self._data['issue_context']
 else:
 funcnamePostfix = ""
-return '%s%s:%d:%d, %s: %s' % (self.getFileName(),
+rootFilename = self.getRootFileName()
+fileName = self.getFileName()
+if rootFilename != fileName:
+filePrefix = "[%s] %s" % (rootFilename, fileName)
+else:
+filePrefix = rootFilename
+return '%s%s:%d:%d, %s: %s' % (filePrefix,
funcnamePostfix,
self.getLine(),
self.getColumn(), self.getCategory(),


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


r353229 - [analyzer] Document RetainCountChecker behavior and annotations

2019-02-05 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Feb  5 14:27:10 2019
New Revision: 353229

URL: http://llvm.org/viewvc/llvm-project?rev=353229&view=rev
Log:
[analyzer] Document RetainCountChecker behavior and annotations

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

Modified:
cfe/trunk/www/analyzer/annotations.html

Modified: cfe/trunk/www/analyzer/annotations.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/annotations.html?rev=353229&r1=353228&r2=353229&view=diff
==
--- cfe/trunk/www/analyzer/annotations.html (original)
+++ cfe/trunk/www/analyzer/annotations.html Tue Feb  5 14:27:10 2019
@@ -60,6 +60,16 @@ recognized by GCC. Their use can be cond
   Attribute 
'ns_consumes_self'
 
 
+Libkern Memory Management Annotations
+  
+Attribute 
'os_returns_retained'
+Attribute 
'os_returns_not_retained'
+Attribute 'os_consumed'
+Attribute 
'os_consumes_this'
+Out Parameters
+  
+
+
   
 
 Custom Assertion Handlers
@@ -482,6 +492,183 @@ a +1 retain count.
 which is functionally equivalent to the combination of 
NS_CONSUMES_SELF
 and NS_RETURNS_RETAINED shown above.
 
+Libkern Memory Management Annotations
+
+https://developer.apple.com/documentation/kernel/osobject?language=objc";>Libkern
+requires developers to inherit all heap allocated objects from 
OSObject
+and to perform manual reference counting.
+The reference counting model is very similar to MRR (manual retain-release) 
mode in
+https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html";>Objective-C
+or to CoreFoundation reference counting.
+Freshly-allocated objects start with a reference count of 1,
+and calls to retain increment it,
+while calls to release decrement it.
+The object is deallocated whenever its reference count reaches zero.
+
+Manually incrementing and decrementing reference counts is error-prone:
+over-retains lead to leaks, and over-releases lead to uses-after-free.
+The analyzer can help the programmer to check for unbalanced
+retain/release calls.
+
+The reference count checking is based on the principle of
+locality: it should be possible to establish correctness
+(lack of leaks/uses after free) by looking at each function body,
+and the declarations (not the definitions) of all the functions it interacts
+with.
+
+In order to support such reasoning, it should be possible to 
summarize
+the behavior of each function, with respect to reference count
+of its returned values and attributes.
+
+By default, the following summaries are assumed:
+
+  All functions starting with get or Get,
+unless they are returning subclasses of OSIterator,
+  are assumed to be returning at +0.
+  That is, the caller has no reference
+  count obligations with respect to the reference count of the 
returned object
+  and should leave it untouched.
+  
+
+  
+All other functions are assumed to return at +1.
+That is, the caller has an obligation to release such objects.
+  
+
+  
+Functions are assumed not to change the reference count of their 
parameters,
+including the implicit this parameter.
+  
+
+
+These summaries can be overriden with the following
+https://clang.llvm.org/docs/AttributeReference.html#os-returns-not-retained";>attributes:
+
+Attribute 'os_returns_retained'
+
+The os_returns_retained attribute (accessed through the macro 
+LIBKERN_RETURNS_RETAINED) plays a role identical to ns_returns_retained for functions
+returning OSObject subclasses.
+The attribute indicates that it is a callers responsibility to release the
+returned object.
+
+
+
+Attribute 'os_returns_not_retained'
+
+The os_returns_not_retained attribute (accessed through the macro 

+LIBKERN_RETURNS_NOT_RETAINED) plays a role identical to ns_returns_not_retained for functions
+returning OSObject subclasses.
+The attribute indicates that the caller should not change the retain
+count of the returned object.
+
+
+Example
+
+
+class MyClass {
+  OSObject *f;
+  LIBKERN_RETURNS_NOT_RETAINED OSObject *myFieldGetter();
+}
+ 
+ 
+// Note that the annotation only has to be applied to the function declaration.
+OSObject * MyClass::myFieldGetter() {
+  return f;
+}
+
+
+Attribute 'os_consumed'
+
+Similarly to ns_consumed attribute,
+os_consumed (accessed through LIBKERN_CONSUMED) attribute,
+applied to a parameter,
+indicates that the call to the function consumes the parameter:
+the callee should either release it or store it and release it in the 
destructor,
+while the caller should assume one is subtracted from the reference count
+after the call.
+
+
+IOReturn addToList(LIBKERN_CONSUMED IOPMinformee *newInformee);
+
+
+Attribute 'os_consumes_this'
+
+Similarly to ns_consumes_self,
+the os_consumes_self attribute indicates that the method call
+consumes the implicit this argument: the caller
+should assume one was subtracted from the referenc

r353231 - [Preprocessor] Add a note with framework location for "file not found" error.

2019-02-05 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Feb  5 14:34:55 2019
New Revision: 353231

URL: http://llvm.org/viewvc/llvm-project?rev=353231&view=rev
Log:
[Preprocessor] Add a note with framework location for "file not found" error.

When a framework with the same name is available at multiple framework
search paths, we use the first matching location. If a framework at this
location doesn't have all the headers, it can be confusing for
developers because they see only an error `'Foo/Foo.h' file not found`,
can find the complete framework with required header, and don't know the
incomplete framework was used instead.

Add a note explaining a framework without required header was found.
Also mention framework directory path to make it easier to find the
incomplete framework.

rdar://problem/39246514

Reviewers: arphaman, erik.pilkington, jkorous

Reviewed By: jkorous

Subscribers: jkorous, dexonsmith, cfe-commits

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


Added:
cfe/trunk/test/Preprocessor/include-header-missing-in-framework.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=353231&r1=353230&r2=353231&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Feb  5 14:34:55 2019
@@ -418,6 +418,8 @@ def err_pp_file_not_found_angled_include
   "'%0' file not found with  include; use \"quotes\" instead">;
 def err_pp_file_not_found_typo_not_fatal
 : Error<"'%0' file not found, did you mean '%1'?">;
+def note_pp_framework_without_header : Note<
+  "did not find header '%0' in framework '%1' (loaded from '%2')">;
 def err_pp_error_opening_file : Error<
   "error opening file '%0': %1">, DefaultFatal;
 def err_pp_empty_filename : Error<"empty filename">;

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=353231&r1=353230&r2=353231&view=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Tue Feb  5 14:34:55 2019
@@ -170,6 +170,9 @@ public:
   /// set to true if the file is located in a framework that has been
   /// user-specified to be treated as a system framework.
   ///
+  /// \param [out] IsFrameworkFound For a framework directory set to true if
+  /// specified '.framework' directory is found.
+  ///
   /// \param [out] MappedName if this is a headermap which maps the filename to
   /// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this
   /// vector and point Filename to it.
@@ -180,6 +183,7 @@ public:
   Module *RequestingModule,
   ModuleMap::KnownHeader *SuggestedModule,
   bool &InUserSpecifiedSystemFramework,
+  bool &IsFrameworkFound,
   bool &HasBeenMapped,
   SmallVectorImpl &MappedName) const;
 
@@ -190,7 +194,8 @@ private:
   SmallVectorImpl *RelativePath,
   Module *RequestingModule,
   ModuleMap::KnownHeader *SuggestedModule,
-  bool &InUserSpecifiedSystemFramework) const;
+  bool &InUserSpecifiedSystemFramework,
+  bool &IsFrameworkFound) const;
 
 };
 

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=353231&r1=353230&r2=353231&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Feb  5 14:34:55 2019
@@ -142,22 +142,22 @@ public:
   virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0;
 };
 
+/// This structure is used to record entries in our framework cache.
+struct FrameworkCacheEntry {
+  /// The directory entry which should be used for the cached framework.
+  const DirectoryEntry *Directory;
+
+  /// Whether this framework has been "user-specified" to be treated as if it
+  /// were a system framework (even if it was found outside a system framework
+  /// directory).
+  bool I

[PATCH] D56561: [Preprocessor] For missing file in framework add note about framework location.

2019-02-05 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353231: [Preprocessor] Add a note with framework location 
for "file not found" error. (authored by vsapsai, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D56561?vs=184866&id=185412#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56561

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/DirectoryLookup.h
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/Preprocessor.h
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/Rewrite/InclusionRewriter.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Lex/Pragma.cpp
  lib/Lex/Preprocessor.cpp
  test/Preprocessor/include-header-missing-in-framework.c

Index: test/Preprocessor/include-header-missing-in-framework.c
===
--- test/Preprocessor/include-header-missing-in-framework.c
+++ test/Preprocessor/include-header-missing-in-framework.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fsyntax-only -F %S/Inputs -DTYPO_CORRECTION -verify %s
+
+// After finding a requested framework, we don't look for the same framework in
+// a different location even if requested header is not found in the framework.
+// It can be confusing when there is a framework with required header later in
+// header search paths. Mention in diagnostics where the header lookup stopped.
+
+#ifndef TYPO_CORRECTION
+#include 
+// expected-error@-1 {{'TestFramework/NotExistingHeader.h' file not found}}
+// expected-note@-2 {{did not find header 'NotExistingHeader.h' in framework 'TestFramework' (loaded from}}
+
+#else
+// Don't emit extra note for unsuccessfully typo-corrected include.
+#include <#TestFramework/NotExistingHeader.h>
+// expected-error@-1 {{'#TestFramework/NotExistingHeader.h' file not found}}
+#endif // TYPO_CORRECTION
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -286,7 +286,7 @@
 const DirectoryLookup *CurDir = nullptr;
 const FileEntry *FE = HS.LookupFile(
 Name, SourceLocation(), /*Angled*/ false, nullptr, CurDir,
-None, nullptr, nullptr, nullptr, nullptr, nullptr);
+None, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
 if (!FE) {
   CI.getDiagnostics().Report(diag::err_module_header_file_not_found)
 << Name;
Index: lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -414,7 +414,7 @@
   // FIXME: Why don't we call PP.LookupFile here?
   const FileEntry *File = PP.getHeaderSearchInfo().LookupFile(
   Filename, SourceLocation(), isAngled, Lookup, CurDir, Includers, nullptr,
-  nullptr, nullptr, nullptr, nullptr);
+  nullptr, nullptr, nullptr, nullptr, nullptr);
 
   FileExists = File != nullptr;
   return true;
Index: lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -480,7 +480,7 @@
 const DirectoryLookup *CurDir;
 const FileEntry *FE =
 PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
-   nullptr, nullptr, nullptr, nullptr);
+   nullptr, nullptr, nullptr, nullptr, nullptr);
 if (!FE) {
   Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
diag::err_verify_missing_file) << Filename << KindStr;
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -506,7 +506,7 @@
   const DirectoryLookup *CurDir;
   const FileEntry *File =
   LookupFile(FilenameTok.getLocation(), Filename, isAngled, nullptr,
- nullptr, CurDir, nullptr, nullptr, nullptr, nullptr);
+ nullptr, CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);
   if (!File) {
 if (!SuppressIncludeNotFoundError)
   Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -665,7 +665,8 @@
 const DirectoryLookup *FromDir, const FileEntry *FromFile,
 const DirectoryLookup *&CurDir, SmallVectorImpl *SearchPath,
 SmallVectorImpl *RelativePath,
-ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool SkipCache) {
+ModuleMap::KnownHeader *SuggestedModul

r353232 - Basic CUDA-10 support.

2019-02-05 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Feb  5 14:38:58 2019
New Revision: 353232

URL: http://llvm.org/viewvc/llvm-project?rev=353232&view=rev
Log:
Basic CUDA-10 support.

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

Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=353232&r1=353231&r2=353232&view=diff
==
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Tue Feb  5 14:38:58 2019
@@ -25,7 +25,8 @@ enum class CudaVersion {
   CUDA_91,
   CUDA_92,
   CUDA_100,
-  LATEST = CUDA_100,
+  CUDA_101,
+  LATEST = CUDA_101,
 };
 const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
@@ -107,6 +108,8 @@ CudaVersion MaxVersionForCudaArch(CudaAr
 enum class CudaFeature {
   // CUDA-9.2+ uses a new API for launching kernels.
   CUDA_USES_NEW_LAUNCH,
+  // CUDA-10.1+ needs explicit end of GPU binary registration.
+  CUDA_USES_FATBIN_REGISTER_END,
 };
 
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);

Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=353232&r1=353231&r2=353232&view=diff
==
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Tue Feb  5 14:38:58 2019
@@ -25,6 +25,8 @@ const char *CudaVersionToString(CudaVers
 return "9.2";
   case CudaVersion::CUDA_100:
 return "10.0";
+  case CudaVersion::CUDA_101:
+return "10.1";
   }
   llvm_unreachable("invalid enum");
 }
@@ -37,7 +39,8 @@ CudaVersion CudaStringToVersion(llvm::St
   .Case("9.0", CudaVersion::CUDA_90)
   .Case("9.1", CudaVersion::CUDA_91)
   .Case("9.2", CudaVersion::CUDA_92)
-  .Case("10.0", CudaVersion::CUDA_100);
+  .Case("10.0", CudaVersion::CUDA_100)
+  .Case("10.1", CudaVersion::CUDA_101);
 }
 
 const char *CudaArchToString(CudaArch A) {
@@ -352,6 +355,8 @@ static CudaVersion ToCudaVersion(llvm::V
 return CudaVersion::CUDA_92;
   case 100:
 return CudaVersion::CUDA_100;
+  case 101:
+return CudaVersion::CUDA_101;
   default:
 return CudaVersion::UNKNOWN;
   }
@@ -365,6 +370,8 @@ bool CudaFeatureEnabled(CudaVersion Vers
   switch (Feature) {
   case CudaFeature::CUDA_USES_NEW_LAUNCH:
 return Version >= CudaVersion::CUDA_92;
+  case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
+return Version >= CudaVersion::CUDA_101;
   }
   llvm_unreachable("Unknown CUDA feature.");
 }

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=353232&r1=353231&r2=353232&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue Feb  5 14:38:58 2019
@@ -616,6 +616,16 @@ llvm::Function *CGNVCUDARuntime::makeMod
 // Call __cuda_register_globals(GpuBinaryHandle);
 if (RegisterGlobalsFunc)
   CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+
+// Call __cudaRegisterFatBinaryEnd(Handle) if this CUDA version needs it.
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+   CudaFeature::CUDA_USES_FATBIN_REGISTER_END)) {
+  // void __cudaRegisterFatBinaryEnd(void **);
+  llvm::FunctionCallee RegisterFatbinEndFunc = CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
+  "__cudaRegisterFatBinaryEnd");
+  CtorBuilder.CreateCall(RegisterFatbinEndFunc, RegisterFatbinCall);
+}
   } else {
 // Generate a unique module ID.
 SmallString<64> ModuleID;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=353232&r1=353231&r2=353232&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Feb  5 14:38:58 2019
@@ -60,6 +60,8 @@ static CudaVersion ParseCudaVersionFile(
 return CudaVersion::CUDA_92;
   if (Major == 10 && Minor == 0)
 return CudaVersion::CUDA_100;
+  if (Major == 10 && Minor == 1)
+return CudaVersion::CUDA_101;
   return CudaVersion::UNKNOWN;
 }
 

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=353232&r1=353231&r2=353232&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_ru

[PATCH] D57771: [CUDA] Add basic support for CUDA-10.1

2019-02-05 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353232: Basic CUDA-10 support. (authored by tra, committed 
by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57771?vs=185398&id=185414#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57771

Files:
  cfe/trunk/include/clang/Basic/Cuda.h
  cfe/trunk/lib/Basic/Cuda.cpp
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/include/clang/Basic/Cuda.h
===
--- cfe/trunk/include/clang/Basic/Cuda.h
+++ cfe/trunk/include/clang/Basic/Cuda.h
@@ -25,7 +25,8 @@
   CUDA_91,
   CUDA_92,
   CUDA_100,
-  LATEST = CUDA_100,
+  CUDA_101,
+  LATEST = CUDA_101,
 };
 const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
@@ -107,6 +108,8 @@
 enum class CudaFeature {
   // CUDA-9.2+ uses a new API for launching kernels.
   CUDA_USES_NEW_LAUNCH,
+  // CUDA-10.1+ needs explicit end of GPU binary registration.
+  CUDA_USES_FATBIN_REGISTER_END,
 };
 
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -60,6 +60,8 @@
 return CudaVersion::CUDA_92;
   if (Major == 10 && Minor == 0)
 return CudaVersion::CUDA_100;
+  if (Major == 10 && Minor == 1)
+return CudaVersion::CUDA_101;
   return CudaVersion::UNKNOWN;
 }
 
Index: cfe/trunk/lib/Basic/Cuda.cpp
===
--- cfe/trunk/lib/Basic/Cuda.cpp
+++ cfe/trunk/lib/Basic/Cuda.cpp
@@ -25,6 +25,8 @@
 return "9.2";
   case CudaVersion::CUDA_100:
 return "10.0";
+  case CudaVersion::CUDA_101:
+return "10.1";
   }
   llvm_unreachable("invalid enum");
 }
@@ -37,7 +39,8 @@
   .Case("9.0", CudaVersion::CUDA_90)
   .Case("9.1", CudaVersion::CUDA_91)
   .Case("9.2", CudaVersion::CUDA_92)
-  .Case("10.0", CudaVersion::CUDA_100);
+  .Case("10.0", CudaVersion::CUDA_100)
+  .Case("10.1", CudaVersion::CUDA_101);
 }
 
 const char *CudaArchToString(CudaArch A) {
@@ -352,6 +355,8 @@
 return CudaVersion::CUDA_92;
   case 100:
 return CudaVersion::CUDA_100;
+  case 101:
+return CudaVersion::CUDA_101;
   default:
 return CudaVersion::UNKNOWN;
   }
@@ -365,6 +370,8 @@
   switch (Feature) {
   case CudaFeature::CUDA_USES_NEW_LAUNCH:
 return Version >= CudaVersion::CUDA_92;
+  case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
+return Version >= CudaVersion::CUDA_101;
   }
   llvm_unreachable("Unknown CUDA feature.");
 }
Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 10010
 #error "Unsupported CUDA version!"
 #endif
 
Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -616,6 +616,16 @@
 // Call __cuda_register_globals(GpuBinaryHandle);
 if (RegisterGlobalsFunc)
   CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+
+// Call __cudaRegisterFatBinaryEnd(Handle) if this CUDA version needs it.
+if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+   CudaFeature::CUDA_USES_FATBIN_REGISTER_END)) {
+  // void __cudaRegisterFatBinaryEnd(void **);
+  llvm::FunctionCallee RegisterFatbinEndFunc = CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
+  "__cudaRegisterFatBinaryEnd");
+  CtorBuilder.CreateCall(RegisterFatbinEndFunc, RegisterFatbinCall);
+}
   } else {
 // Generate a unique module ID.
 SmallString<64> ModuleID;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57794: Fix MSVC constructor call extension after b92d290e48e9 (r353181).

2019-02-05 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: thakis, rsmith.
Herald added subscribers: cfe-commits, mstorsjo.
Herald added a project: clang.

The assert added to EmitCall there was triggering in Windows Chromium
builds, due to a mismatch of the return type.

The MSVC constructor call extension (`this->Foo::Foo()`) was emitting
the constructor call from 'EmitCXXMemberOrOperatorMemberCallExpr' via
calling 'EmitCXXMemberOrOperatorCall', instead of
'EmitCXXConstructorCall'. On targets where HasThisReturn is true, that
was failing to set the proper return type in the call info.

Switching to calling EmitCXXConstructorCall also allowed removing some
code e.g. the trivial copy/move support, which is already handled in
EmitCXXConstructorCall.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57794

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/constructor-direct-call.cpp

Index: clang/test/CodeGenCXX/constructor-direct-call.cpp
===
--- clang/test/CodeGenCXX/constructor-direct-call.cpp
+++ clang/test/CodeGenCXX/constructor-direct-call.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK32 --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK64 --check-prefix=CHECK
 
 class Test1 {
 public:
@@ -9,7 +10,8 @@
   Test1 var;
   var.Test1::Test1();
 
-  // CHECK:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 4, i1 false)
+  // CHECK32:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 4, i1 false)
+  // CHECK64:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 4, i1 false)
   var.Test1::Test1(var);
 }
 
@@ -22,13 +24,16 @@
 
 void f2() {
   // CHECK:  %var = alloca %class.Test2, align 4
-  // CHECK-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK32-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK64-NEXT:  %call = call %class.Test2* @"??0Test2@@QEAA@XZ"(%class.Test2* %var)
   Test2 var;
 
-  // CHECK-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK32-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK64-NEXT:  %call1 = call %class.Test2* @"??0Test2@@QEAA@XZ"(%class.Test2* %var)
   var.Test2::Test2();
 
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 8, i1 false)
+  // CHECK32:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 8, i1 false)
+  // CHECK64:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 8, i1 false)
   var.Test2::Test2(var);
 }
 
@@ -45,15 +50,19 @@
 };
 
 void f3() {
-  // CHECK: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK32: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK64: %call = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var)
   Test3 var;
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var2)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var2)
+  // CHECK64-NEXT: %call1 = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var2)
   Test3 var2;
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK64-NEXT: %call2 = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var)
   var.Test3::Test3();
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
+  // CHECK64-NEXT: %call3 = call %class.Test3* @"??0Test3@@QEAA@AEBV0@@Z"(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
   var.Test3::Test3(var2);
 }
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -249,13 +249,25 @@
 This = EmitLValue(Base);
   }
 
+  if (const CXXConstructorDecl *Ctor = dyn_cast(MD)) {
+// This is the MSVC p->Ctor::Ctor(...) extension. We assume that's
+// constructing a new complete object of type Ctor.
+assert(!RtlArgs);
+assert(ReturnValue.isNull() && "Constructor shouldn't have return value");
+CallArgList Args;
+commonEmitCXXMemberOrOperatorCall(
+*this, Ctor, This.getPointer(), /*ImplicitParam=*/nullptr,
+/*ImplicitParamTy=*/QualType(), CE, A

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-05 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

So Eli is concerned we might end up with many globals in the small data section 
or not picking the best candidates if we pass -G to all files in LTO.
I don’t know if anyone has experimented with a heuristic to selectively pick 
which globals and of which size will be allowed to go into the  small data 
section.
Simon, do you have any insight?
Shiva, maybe for now we don’t pass the flag to LTO. But I think you got the 
correct mechanism. The only other suggestion I have is to add a RISC-V specific 
function to avoid too much RISC-V specific code in 
gnutools::Linker::constructJob. You just check the triple and call something 
like toolchains::RISCVToolChain::AddGoldPluginAdditionalFlags.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


r353240 - [modules] Fix handling of initializers for templated global variables.

2019-02-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Feb  5 15:37:13 2019
New Revision: 353240

URL: http://llvm.org/viewvc/llvm-project?rev=353240&view=rev
Log:
[modules] Fix handling of initializers for templated global variables.

For global variables with unordered initialization that are instantiated
within a module, we previously did not emit the global (or its
initializer) at all unless it was used in the importing translation unit
(and sometimes not even then!), leading to misbehavior and link errors.

We now emit the initializer for an instantiated global variable with
unordered initialization with side-effects in a module into every
translation unit that imports the module. This is unfortunate, but
mostly matches the behavior of a non-modular compilation and seems to be
the best that we can reasonably do.

Added:
cfe/trunk/test/Modules/initializers.cpp
Modified:
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/Serialization/ASTCommon.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=353240&r1=353239&r2=353240&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Feb  5 15:37:13 2019
@@ -1377,6 +1377,10 @@ void TextNodeDumper::VisitCapturedDecl(c
 
 void TextNodeDumper::VisitImportDecl(const ImportDecl *D) {
   OS << ' ' << D->getImportedModule()->getFullModuleName();
+
+  for (Decl *InitD :
+   D->getASTContext().getModuleInitializers(D->getImportedModule()))
+dumpDeclRef(InitD, "initializer");
 }
 
 void TextNodeDumper::VisitPragmaCommentDecl(const PragmaCommentDecl *D) {

Modified: cfe/trunk/lib/Serialization/ASTCommon.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.h?rev=353240&r1=353239&r2=353240&view=diff
==
--- cfe/trunk/lib/Serialization/ASTCommon.h (original)
+++ cfe/trunk/lib/Serialization/ASTCommon.h Tue Feb  5 15:37:13 2019
@@ -108,6 +108,21 @@ template void numberAnonymo
   }
 }
 
+/// Determine whether the given declaration will be included in the per-module
+/// initializer if it needs to be eagerly handed to the AST consumer. If so, we
+/// should not hand it to the consumer when deserializing it, nor include it in
+/// the list of eagerly deserialized declarations.
+inline bool isPartOfPerModuleInitializer(const Decl *D) {
+  if (isa(D))
+return true;
+  // Template instantiations are notionally in an "instantiation unit" rather
+  // than in any particular translation unit, so they need not be part of any
+  // particular (sub)module's per-module initializer.
+  if (auto *VD = dyn_cast(D))
+return !isTemplateInstantiation(VD->getTemplateSpecializationKind());
+  return false;
+}
+
 } // namespace serialization
 
 } // namespace clang

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=353240&r1=353239&r2=353240&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Feb  5 15:37:13 2019
@@ -2779,7 +2779,7 @@ static bool isConsumerInterestedIn(ASTCo
 
   // An ImportDecl or VarDecl imported from a module map module will get
   // emitted when we import the relevant module.
-  if (isa(D) || isa(D)) {
+  if (isPartOfPerModuleInitializer(D)) {
 auto *M = D->getImportedOwningModule();
 if (M && M->Kind == Module::ModuleMapModule &&
 Ctx.DeclMustBeEmitted(D))

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=353240&r1=353239&r2=353240&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Tue Feb  5 15:37:13 2019
@@ -2272,7 +2272,7 @@ static bool isRequiredDecl(const Decl *D
   if (isa(D) || isa(D))
 return true;
 
-  if (WritingModule && (isa(D) || isa(D))) {
+  if (WritingModule && isPartOfPerModuleInitializer(D)) {
 // These declarations are part of the module initializer, and are emitted
 // if and when the module is imported, rather than being emitted eagerly.
 return false;

Added: cfe/trunk/test/Modules/initializers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/initializers.cpp?rev=353240&view=auto
==
--- cfe/trunk/test/Modules/initializers.cpp (added)
+++ cfe/trunk/test/Modules/initializers.cpp Tue Feb  5 15:37:13 2019
@@ -0,0 +1,242 @@
+// RUN: %clan

[PATCH] D57626: Disallow trivial_abi on a class if all copy and move constructors are deleted

2019-02-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked 2 inline comments as done.
ahatanak added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2953
+  "have bases of non-trivial class types|have virtual bases|"
+  "have __weak fields under ARC|have fields of non-trivial class types}0">;
 

Quuxplusone wrote:
> nit: "of non-trivial class types" should be "of non-trivial class type" in 
> both places.
> 
> And I would write "are not move-constructible" rather than "don't have 
> non-deleted copy/move constructors". Double negations aren't non-bad.
> 
> Actually I would rephrase this as `'trivial_abi' is disallowed on this class 
> because it %select{is not move-constructible|is polymorphic|has a base of 
> non-trivial class type|has a virtual base|has a __weak field|has a field of 
> non-trivial class type}`, i.e., we're not just giving information about 
> "classes" in general, we're talking about "this class" specifically. We could 
> even name the class if we're feeling generous.
Does not being move-constructible imply that the class doesn't have a *public* 
copy or move constructor that isn't deleted? If it does, that is slightly 
different than saying the copy and move constructors of the class are all 
deleted. When the users see the message "is not move-constructible", they might 
think the copy or move constructor that isn't deleted has to be public in order 
to annotate the class with `trivial_abi`. For `trivial_abi`, a private one is 
good enough.

I think your other suggestions are all good ideas.



Comment at: lib/Sema/SemaDeclCXX.cpp:7886
+return false;
+  };
+

Quuxplusone wrote:
> How confident are we that this logic is correct?  I ask because I need 
> something similar for my own diagnostic in D50119. If this logic is 
> rock-solid (no lurking corner-case bugs), I should copy it — and/or it should 
> be moved into a helper member function on `CXXRecordDecl` so that other 
> people can call it too.
I think it's correct. The first part looks for implicit constructors that are 
not deleted, and the for loop looks for the explicitly declared ones that 
aren't deleted.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57626



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


[PATCH] D57794: Fix MSVC constructor call extension after b92d290e48e9 (r353181).

2019-02-05 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk 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/D57794/new/

https://reviews.llvm.org/D57794



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-05 Thread James Clarke via Phabricator via cfe-commits
jrtc27 requested changes to this revision.
jrtc27 added a comment.
This revision now requires changes to proceed.

Please update `docs/ClangCommandLineReference.rst`. Also, in my limited 
testing, GCC just seems to pass the `-msmall-data-limit=...` flag straight 
through to the linker through `COLLECT_GCC_OPTIONS`. Finally, please add tests 
for `-msmall-data-limit=...` instead of or as well as `-G`, since GCC only 
recognises the former on RISC-V.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


r353246 - Fix MSVC constructor call extension after b92d290e48e9 (r353181).

2019-02-05 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Feb  5 16:06:03 2019
New Revision: 353246

URL: http://llvm.org/viewvc/llvm-project?rev=353246&view=rev
Log:
Fix MSVC constructor call extension after b92d290e48e9 (r353181).

The assert added to EmitCall there was triggering in Windows Chromium
builds, due to a mismatch of the return type.

The MSVC constructor call extension (`this->Foo::Foo()`) was emitting
the constructor call from 'EmitCXXMemberOrOperatorMemberCallExpr' via
calling 'EmitCXXMemberOrOperatorCall', instead of
'EmitCXXConstructorCall'. On targets where HasThisReturn is true, that
was failing to set the proper return type in the call info.

Switching to calling EmitCXXConstructorCall also allowed removing some
code e.g. the trivial copy/move support, which is already handled in
EmitCXXConstructorCall.

Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=928861
Differential Revision: https://reviews.llvm.org/D57794

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/constructor-direct-call.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=353246&r1=353245&r2=353246&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Feb  5 16:06:03 2019
@@ -249,13 +249,25 @@ RValue CodeGenFunction::EmitCXXMemberOrO
 This = EmitLValue(Base);
   }
 
+  if (const CXXConstructorDecl *Ctor = dyn_cast(MD)) {
+// This is the MSVC p->Ctor::Ctor(...) extension. We assume that's
+// constructing a new complete object of type Ctor.
+assert(!RtlArgs);
+assert(ReturnValue.isNull() && "Constructor shouldn't have return value");
+CallArgList Args;
+commonEmitCXXMemberOrOperatorCall(
+*this, Ctor, This.getPointer(), /*ImplicitParam=*/nullptr,
+/*ImplicitParamTy=*/QualType(), CE, Args, nullptr);
+
+EmitCXXConstructorCall(Ctor, Ctor_Complete, /*ForVirtualBase=*/false,
+   /*Delegating=*/false, This.getAddress(), Args,
+   AggValueSlot::DoesNotOverlap, CE->getExprLoc(),
+   /*NewPointerIsChecked=*/false);
+return RValue::get(nullptr);
+  }
 
   if (MD->isTrivial() || (MD->isDefaulted() && MD->getParent()->isUnion())) {
 if (isa(MD)) return RValue::get(nullptr);
-if (isa(MD) &&
-cast(MD)->isDefaultConstructor())
-  return RValue::get(nullptr);
-
 if (!MD->getParent()->mayInsertExtraPadding()) {
   if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) {
 // We don't like to generate the trivial copy/move assignment operator
@@ -268,20 +280,6 @@ RValue CodeGenFunction::EmitCXXMemberOrO
 EmitAggregateAssign(This, RHS, CE->getType());
 return RValue::get(This.getPointer());
   }
-
-  if (isa(MD) &&
-  cast(MD)->isCopyOrMoveConstructor()) {
-// Trivial move and copy ctor are the same.
-assert(CE->getNumArgs() == 1 && "unexpected argcount for trivial 
ctor");
-const Expr *Arg = *CE->arg_begin();
-LValue RHS = EmitLValue(Arg);
-LValue Dest = MakeAddrLValue(This.getAddress(), Arg->getType());
-// This is the MSVC p->Ctor::Ctor(...) extension. We assume that's
-// constructing a new complete object of type Ctor.
-EmitAggregateCopy(Dest, RHS, Arg->getType(),
-  AggValueSlot::DoesNotOverlap);
-return RValue::get(This.getPointer());
-  }
   llvm_unreachable("unknown trivial member function");
 }
   }
@@ -293,9 +291,6 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (const auto *Dtor = dyn_cast(CalleeDecl))
 FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
 Dtor, StructorType::Complete);
-  else if (const auto *Ctor = dyn_cast(CalleeDecl))
-FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
-Ctor, StructorType::Complete);
   else
 FInfo = &CGM.getTypes().arrangeCXXMethodDeclaration(CalleeDecl);
 
@@ -318,11 +313,9 @@ RValue CodeGenFunction::EmitCXXMemberOrO
 if (IsImplicitObjectCXXThis || isa(IOA))
   SkippedChecks.set(SanitizerKind::Null, true);
   }
-  EmitTypeCheck(
-  isa(CalleeDecl) ? 
CodeGenFunction::TCK_ConstructorCall
-  : CodeGenFunction::TCK_MemberCall,
-  CallLoc, This.getPointer(), C.getRecordType(CalleeDecl->getParent()),
-  /*Alignment=*/CharUnits::Zero(), SkippedChecks);
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall, CallLoc, This.getPointer(),
+C.getRecordType(CalleeDecl->getParent()),
+/*Alignment=*/CharUnits::Zero(), SkippedChecks);
 
   // C++ [class.virtual]p12:
   //   Explicit qualification with the scope operator (5.1) suppresses the
@@ -366,11 +359,7 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   // 'CalleeDecl' instead.
 
   CGCallee Callee;
-  if (c

[PATCH] D57794: Fix MSVC constructor call extension after b92d290e48e9 (r353181).

2019-02-05 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353246: Fix MSVC constructor call extension after 
b92d290e48e9 (r353181). (authored by jyknight, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57794?vs=185426&id=185430#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57794

Files:
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/test/CodeGenCXX/constructor-direct-call.cpp

Index: cfe/trunk/test/CodeGenCXX/constructor-direct-call.cpp
===
--- cfe/trunk/test/CodeGenCXX/constructor-direct-call.cpp
+++ cfe/trunk/test/CodeGenCXX/constructor-direct-call.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK32 --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.11.0 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK64 --check-prefix=CHECK
 
 class Test1 {
 public:
@@ -9,7 +10,8 @@
   Test1 var;
   var.Test1::Test1();
 
-  // CHECK:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 4, i1 false)
+  // CHECK32:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 4, i1 false)
+  // CHECK64:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 4, i1 false)
   var.Test1::Test1(var);
 }
 
@@ -22,13 +24,16 @@
 
 void f2() {
   // CHECK:  %var = alloca %class.Test2, align 4
-  // CHECK-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK32-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK64-NEXT:  %call = call %class.Test2* @"??0Test2@@QEAA@XZ"(%class.Test2* %var)
   Test2 var;
 
-  // CHECK-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK32-NEXT:  call x86_thiscallcc void @_ZN5Test2C1Ev(%class.Test2* %var)
+  // CHECK64-NEXT:  %call1 = call %class.Test2* @"??0Test2@@QEAA@XZ"(%class.Test2* %var)
   var.Test2::Test2();
 
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 8, i1 false)
+  // CHECK32:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 8, i1 false)
+  // CHECK64:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 8, i1 false)
   var.Test2::Test2(var);
 }
 
@@ -45,15 +50,19 @@
 };
 
 void f3() {
-  // CHECK: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK32: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK64: %call = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var)
   Test3 var;
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var2)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var2)
+  // CHECK64-NEXT: %call1 = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var2)
   Test3 var2;
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
+  // CHECK64-NEXT: %call2 = call %class.Test3* @"??0Test3@@QEAA@XZ"(%class.Test3* %var)
   var.Test3::Test3();
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
+  // CHECK32-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
+  // CHECK64-NEXT: %call3 = call %class.Test3* @"??0Test3@@QEAA@AEBV0@@Z"(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
   var.Test3::Test3(var2);
 }
Index: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp
@@ -249,13 +249,25 @@
 This = EmitLValue(Base);
   }
 
+  if (const CXXConstructorDecl *Ctor = dyn_cast(MD)) {
+// This is the MSVC p->Ctor::Ctor(...) extension. We assume that's
+// constructing a new complete object of type Ctor.
+assert(!RtlArgs);
+assert(ReturnValue.isNull() && "Constructor shouldn't have return value");
+CallArgList Args;
+commonEmitCXXMemberOrOperatorCall(
+*this, Ctor, This.getPointer(), /*ImplicitParam=*/nullptr,
+/*ImplicitParamTy=*/QualType(), CE, Args, nullptr);
+
+EmitCXXConstructorCall(Ctor, Ctor_Complete, /*ForVirtualBase=*/false,
+   /*Delegating=*/false, This.getAddress(), Args,
+   AggValueSlot::DoesNotOverlap, CE->getExprLoc(),
+   /*NewPointerIsChecked=*/false);
+return 

  1   2   >