Re: [PATCH] D52533: [test] Use --sysroot instead of -B in print-multi-directory.c

2018-10-03 Thread Christian BRUEL via cfe-commits
Hi Martin,

Actually I reread the developer policy, 
(https://llvm.org/docs/DeveloperPolicy.html#id13). As I contributed this 
code and take responsibility for it. It seems that I can approve this patch.

So it looks OK for me, sorry for the delay,

Cheers

Christian

On 10/02/2018 07:55 PM, Martin Storsjö via Phabricator wrote:
> mstorsjo added a comment.
>
> Ping @jroelofs or someone else willing to have a look
>
>
> Repository:
>rC Clang
>
> https://reviews.llvm.org/D52533
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Hello, @erichkeane

I am working on int to float checker but I haven't found yet a way how to check 
if integer fits to float's significant bits. Maybe you can recommend me 
something? I already tried some LLVM APIs but no success. (cc @spatel as you 
will probably know the right function to do it)


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D52819: Support checking out cte to 'extra' only as backward compatibility

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, mgorny.

This requirement to check it out in a directory called 'extra' was never
documented for git users, so git users doing the obvious thing (just
clone, don't specify a name) will silently not get clang-tools-extra
built.

Even reading the code is confusing because the
`add_llvm_external_project` macro appears to be used in place of the
`add_subdirectory` command, though the latter treats the second
placement argument as just a build directory name.  So, anyone assuming
the same semantic with `add_llvm_external_project` would be confused.


Repository:
  rC Clang

https://reviews.llvm.org/D52819

Files:
  tools/CMakeLists.txt
  www/get_started.html


Index: www/get_started.html
===
--- www/get_started.html
+++ www/get_started.html
@@ -66,7 +66,7 @@
   
 cd llvm/tools/clang/tools
 svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk
-extra
+clang-tools-extra
 cd ../../../..
   
   
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -26,12 +26,17 @@
   add_clang_subdirectory(scan-view)
 endif()
 
-# We support checking out the clang-tools-extra repository into the 'extra'
-# subdirectory. It contains tools developed as part of the Clang/LLVM project
-# on top of the Clang tooling platform. We keep them in a separate repository
-# to keep the primary Clang repository small and focused.
-# It also may be included by LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR.
-add_llvm_external_project(clang-tools-extra extra)
+if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/extra)
+
+# Documentation for working with SVN used to recommend using
+# the name 'extra'.  Support that for now as backwards
+# compatibility
+message(DEPRECATION "Checking out clang-tools-extra into a directory 
called 'extra' is deprecated.
+Rename the directory to 'clang-tools-extra' instead.")
+add_llvm_external_project(clang-tools-extra extra)
+else()
+add_llvm_external_project(clang-tools-extra)
+endif()
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)


Index: www/get_started.html
===
--- www/get_started.html
+++ www/get_started.html
@@ -66,7 +66,7 @@
   
 cd llvm/tools/clang/tools
 svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk
-extra
+clang-tools-extra
 cd ../../../..
   
   
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -26,12 +26,17 @@
   add_clang_subdirectory(scan-view)
 endif()
 
-# We support checking out the clang-tools-extra repository into the 'extra'
-# subdirectory. It contains tools developed as part of the Clang/LLVM project
-# on top of the Clang tooling platform. We keep them in a separate repository
-# to keep the primary Clang repository small and focused.
-# It also may be included by LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR.
-add_llvm_external_project(clang-tools-extra extra)
+if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/extra)
+
+# Documentation for working with SVN used to recommend using
+# the name 'extra'.  Support that for now as backwards
+# compatibility
+message(DEPRECATION "Checking out clang-tools-extra into a directory called 'extra' is deprecated.
+Rename the directory to 'clang-tools-extra' instead.")
+add_llvm_external_project(clang-tools-extra extra)
+else()
+add_llvm_external_project(clang-tools-extra)
+endif()
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r343664 - [clang-query] Add single-letter 'q' alias for 'quit'

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 00:52:44 2018
New Revision: 343664

URL: http://llvm.org/viewvc/llvm-project?rev=343664&view=rev
Log:
[clang-query] Add single-letter 'q' alias for 'quit'

Reviewers: aaron.ballman, pcc

Reviewed By: aaron.ballman

Subscribers: Szelethus, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/Query.cpp
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=343664&r1=343663&r2=343664&view=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct  3 00:52:44 2018
@@ -45,7 +45,7 @@ bool HelpQuery::run(llvm::raw_ostream &O
 "Set whether to print bindings as diagnostics,\n"
 ""
 "AST pretty prints or AST dumps.\n"
-"  quit  "
+"  quit, q   "
 "Terminates the query session.\n\n";
   return true;
 }

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=343664&r1=343663&r2=343664&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct  3 00:52:44 2018
@@ -166,6 +166,7 @@ QueryRef QueryParser::doParse() {
   .Case("let", PQK_Let)
   .Case("m", PQK_Match, /*IsCompletion=*/false)
   .Case("match", PQK_Match)
+  .Case("q", PQK_Quit,  /*IsCompletion=*/false)
   .Case("quit", PQK_Quit)
   .Case("set", PQK_Set)
   .Case("unlet", PQK_Unlet)

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp?rev=343664&r1=343663&r2=343664&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Wed Oct  
3 00:52:44 2018
@@ -51,6 +51,9 @@ TEST_F(QueryParserTest, Quit) {
   QueryRef Q = parse("quit");
   ASSERT_TRUE(isa(Q));
 
+  Q = parse("q");
+  ASSERT_TRUE(isa(Q));
+
   Q = parse("quit me");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);


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


[PATCH] D52746: [clang-query] Add single-letter 'q' alias for 'quit'

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343664: [clang-query] Add single-letter 'q' 
alias for 'quit' (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52746?vs=167984&id=168077#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52746

Files:
  clang-query/Query.cpp
  clang-query/QueryParser.cpp
  unittests/clang-query/QueryParserTest.cpp


Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -51,6 +51,9 @@
   QueryRef Q = parse("quit");
   ASSERT_TRUE(isa(Q));
 
+  Q = parse("q");
+  ASSERT_TRUE(isa(Q));
+
   Q = parse("quit me");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -45,7 +45,7 @@
 "Set whether to print bindings as diagnostics,\n"
 ""
 "AST pretty prints or AST dumps.\n"
-"  quit  "
+"  quit, q   "
 "Terminates the query session.\n\n";
   return true;
 }
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -166,6 +166,7 @@
   .Case("let", PQK_Let)
   .Case("m", PQK_Match, /*IsCompletion=*/false)
   .Case("match", PQK_Match)
+  .Case("q", PQK_Quit,  /*IsCompletion=*/false)
   .Case("quit", PQK_Quit)
   .Case("set", PQK_Set)
   .Case("unlet", PQK_Unlet)


Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -51,6 +51,9 @@
   QueryRef Q = parse("quit");
   ASSERT_TRUE(isa(Q));
 
+  Q = parse("q");
+  ASSERT_TRUE(isa(Q));
+
   Q = parse("quit me");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' me'", cast(Q)->ErrStr);
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -45,7 +45,7 @@
 "Set whether to print bindings as diagnostics,\n"
 ""
 "AST pretty prints or AST dumps.\n"
-"  quit  "
+"  quit, q   "
 "Terminates the query session.\n\n";
   return true;
 }
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -166,6 +166,7 @@
   .Case("let", PQK_Let)
   .Case("m", PQK_Match, /*IsCompletion=*/false)
   .Case("match", PQK_Match)
+  .Case("q", PQK_Quit,  /*IsCompletion=*/false)
   .Case("quit", PQK_Quit)
   .Case("set", PQK_Set)
   .Case("unlet", PQK_Unlet)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343665 - Allow comments with '#' in dynamic AST Matchers

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 00:56:43 2018
New Revision: 343665

URL: http://llvm.org/viewvc/llvm-project?rev=343665&view=rev
Log:
Allow comments with '#' in dynamic AST Matchers

Summary: This is necessary for clang-query to be able to handle comments.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=343665&r1=343664&r2=343665&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Wed Oct  3 00:56:43 2018
@@ -110,6 +110,10 @@ private:
 }
 
 switch (Code[0]) {
+case '#':
+  Result.Kind = TokenInfo::TK_Eof;
+  Result.Text = "";
+  return Result;
 case ',':
   Result.Kind = TokenInfo::TK_Comma;
   Result.Text = Code.substr(0, 1);

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=343665&r1=343664&r2=343665&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Wed Oct  3 00:56:43 
2018
@@ -148,8 +148,8 @@ TEST(ParserTest, ParseMatcher) {
   const uint64_t ExpectedBar = Sema.expectMatcher("Bar");
   const uint64_t ExpectedBaz = Sema.expectMatcher("Baz");
   Sema.parse(" Foo ( Bar ( 17), Baz( \n \"B A,Z\") ) .bind( \"Yo!\") ");
-  for (size_t i = 0, e = Sema.Errors.size(); i != e; ++i) {
-EXPECT_EQ("", Sema.Errors[i]);
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
   }
 
   EXPECT_NE(ExpectedFoo, ExpectedBar);
@@ -181,6 +181,21 @@ TEST(ParserTest, ParseMatcher) {
   EXPECT_EQ("Yo!", Foo.BoundID);
 }
 
+TEST(ParserTest, ParseComment) {
+  MockSema Sema;
+  const uint64_t ExpectedFoo = Sema.expectMatcher("Foo");
+  Sema.parse(" Foo() # Bar() ");
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
+  }
+
+  EXPECT_EQ(1ULL, Sema.Matchers.size());
+
+  Sema.parse("Foo(#) ");
+
+  EXPECT_EQ("1:4: Error parsing matcher. Found end-of-code while looking for 
')'.", Sema.Errors[1]);
+}
+
 using ast_matchers::internal::Matcher;
 
 Parser::NamedValueMap getTestNamedValues() {


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


[PATCH] D52751: Allow comments with '#' in dynamic AST Matchers

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343665: Allow comments with '#' in dynamic AST 
Matchers (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52751?vs=167987&id=168078#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52751

Files:
  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -110,6 +110,10 @@
 }
 
 switch (Code[0]) {
+case '#':
+  Result.Kind = TokenInfo::TK_Eof;
+  Result.Text = "";
+  return Result;
 case ',':
   Result.Kind = TokenInfo::TK_Comma;
   Result.Text = Code.substr(0, 1);
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -148,8 +148,8 @@
   const uint64_t ExpectedBar = Sema.expectMatcher("Bar");
   const uint64_t ExpectedBaz = Sema.expectMatcher("Baz");
   Sema.parse(" Foo ( Bar ( 17), Baz( \n \"B A,Z\") ) .bind( \"Yo!\") ");
-  for (size_t i = 0, e = Sema.Errors.size(); i != e; ++i) {
-EXPECT_EQ("", Sema.Errors[i]);
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
   }
 
   EXPECT_NE(ExpectedFoo, ExpectedBar);
@@ -181,6 +181,21 @@
   EXPECT_EQ("Yo!", Foo.BoundID);
 }
 
+TEST(ParserTest, ParseComment) {
+  MockSema Sema;
+  const uint64_t ExpectedFoo = Sema.expectMatcher("Foo");
+  Sema.parse(" Foo() # Bar() ");
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
+  }
+
+  EXPECT_EQ(1ULL, Sema.Matchers.size());
+
+  Sema.parse("Foo(#) ");
+
+  EXPECT_EQ("1:4: Error parsing matcher. Found end-of-code while looking for 
')'.", Sema.Errors[1]);
+}
+
 using ast_matchers::internal::Matcher;
 
 Parser::NamedValueMap getTestNamedValues() {


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -110,6 +110,10 @@
 }
 
 switch (Code[0]) {
+case '#':
+  Result.Kind = TokenInfo::TK_Eof;
+  Result.Text = "";
+  return Result;
 case ',':
   Result.Kind = TokenInfo::TK_Comma;
   Result.Text = Code.substr(0, 1);
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -148,8 +148,8 @@
   const uint64_t ExpectedBar = Sema.expectMatcher("Bar");
   const uint64_t ExpectedBaz = Sema.expectMatcher("Baz");
   Sema.parse(" Foo ( Bar ( 17), Baz( \n \"B A,Z\") ) .bind( \"Yo!\") ");
-  for (size_t i = 0, e = Sema.Errors.size(); i != e; ++i) {
-EXPECT_EQ("", Sema.Errors[i]);
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
   }
 
   EXPECT_NE(ExpectedFoo, ExpectedBar);
@@ -181,6 +181,21 @@
   EXPECT_EQ("Yo!", Foo.BoundID);
 }
 
+TEST(ParserTest, ParseComment) {
+  MockSema Sema;
+  const uint64_t ExpectedFoo = Sema.expectMatcher("Foo");
+  Sema.parse(" Foo() # Bar() ");
+  for (const auto &E : Sema.Errors) {
+EXPECT_EQ("", E);
+  }
+
+  EXPECT_EQ(1ULL, Sema.Matchers.size());
+
+  Sema.parse("Foo(#) ");
+
+  EXPECT_EQ("1:4: Error parsing matcher. Found end-of-code while looking for ')'.", Sema.Errors[1]);
+}
+
 using ast_matchers::internal::Matcher;
 
 Parser::NamedValueMap getTestNamedValues() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r343666 - [clang-query] Add comment token handling

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 01:21:54 2018
New Revision: 343666

URL: http://llvm.org/viewvc/llvm-project?rev=343666&view=rev
Log:
[clang-query] Add comment token handling

Summary:
It is possible to pass a file of commands to clang-query using the
command line option -f or --preload.  Make it possible to write comments
in such files.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: mgorny, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=343666&r1=343665&r2=343666&view=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct  3 01:21:54 2018
@@ -37,6 +37,11 @@ StringRef QueryParser::lexWord() {
 ++Begin;
   }
 
+  if (*Begin == '#') {
+End = Begin;
+return StringRef();
+  }
+
   const char *WordBegin = Begin;
 
   while (true) {
@@ -127,6 +132,7 @@ namespace {
 
 enum ParsedQueryKind {
   PQK_Invalid,
+  PQK_Comment,
   PQK_NoOp,
   PQK_Help,
   PQK_Let,
@@ -161,6 +167,7 @@ QueryRef QueryParser::doParse() {
   StringRef CommandStr;
   ParsedQueryKind QKind = LexOrCompleteWord(this, CommandStr)
   .Case("", PQK_NoOp)
+  .Case("#", PQK_Comment, /*IsCompletion=*/false)
   .Case("help", PQK_Help)
   .Case("l", PQK_Let, /*IsCompletion=*/false)
   .Case("let", PQK_Let)
@@ -173,6 +180,7 @@ QueryRef QueryParser::doParse() {
   .Default(PQK_Invalid);
 
   switch (QKind) {
+  case PQK_Comment:
   case PQK_NoOp:
 return new NoOpQuery;
 

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp?rev=343666&r1=343665&r2=343666&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Wed Oct  
3 01:21:54 2018
@@ -146,6 +146,17 @@ TEST_F(QueryParserTest, LetUnlet) {
 cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Comment) {
+  QueryRef Q = parse("# let foo decl()");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("let foo decl() # creates a decl() matcher called foo");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("set bind-root false # reduce noise");
+  ASSERT_TRUE(isa>(Q));
+}
+
 TEST_F(QueryParserTest, Complete) {
   std::vector Comps =
   QueryParser::complete("", 0, QS);


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


[PATCH] D52806: [python] Support overriding library path via environment

2018-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 168079.
mgorny added a comment.

To avoid consumers of the bindings, I've changed the patch to set the path only 
through tests. As a result, the binding API is unchanged.


https://reviews.llvm.org/D52806

Files:
  bindings/python/README.txt
  bindings/python/tests/cindex/test_access_specifiers.py
  bindings/python/tests/cindex/test_cdb.py
  bindings/python/tests/cindex/test_code_completion.py
  bindings/python/tests/cindex/test_comment.py
  bindings/python/tests/cindex/test_cursor.py
  bindings/python/tests/cindex/test_cursor_kind.py
  bindings/python/tests/cindex/test_diagnostics.py
  bindings/python/tests/cindex/test_exception_specification_kind.py
  bindings/python/tests/cindex/test_file.py
  bindings/python/tests/cindex/test_index.py
  bindings/python/tests/cindex/test_linkage.py
  bindings/python/tests/cindex/test_location.py
  bindings/python/tests/cindex/test_tls_kind.py
  bindings/python/tests/cindex/test_token_kind.py
  bindings/python/tests/cindex/test_tokens.py
  bindings/python/tests/cindex/test_translation_unit.py
  bindings/python/tests/cindex/test_type.py

Index: bindings/python/tests/cindex/test_type.py
===
--- bindings/python/tests/cindex/test_type.py
+++ bindings/python/tests/cindex/test_type.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 import gc
 import unittest
 
Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from contextlib import contextmanager
 import gc
 import os
Index: bindings/python/tests/cindex/test_tokens.py
===
--- bindings/python/tests/cindex/test_tokens.py
+++ bindings/python/tests/cindex/test_tokens.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import CursorKind
 from clang.cindex import Index
 from clang.cindex import SourceLocation
Index: bindings/python/tests/cindex/test_token_kind.py
===
--- bindings/python/tests/cindex/test_token_kind.py
+++ bindings/python/tests/cindex/test_token_kind.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import TokenKind
 
 import unittest
Index: bindings/python/tests/cindex/test_tls_kind.py
===
--- bindings/python/tests/cindex/test_tls_kind.py
+++ bindings/python/tests/cindex/test_tls_kind.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import TLSKind
 from clang.cindex import Cursor
 from clang.cindex import TranslationUnit
Index: bindings/python/tests/cindex/test_location.py
===
--- bindings/python/tests/cindex/test_location.py
+++ bindings/python/tests/cindex/test_location.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import Cursor
 from clang.cindex import File
 from clang.cindex import SourceLocation
Index: bindings/python/tests/cindex/test_linkage.py
===
--- bindings/python/tests/cindex/test_linkage.py
+++ bindings/python/tests/cindex/test_linkage.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import LinkageKind
 from clang.cindex import Cursor
 from clang.cindex import TranslationUnit
Index: bindings/python/tests/cindex/test_index.py
===
--- bindings/python/tests/cindex/test_index.py
+++ bindings/python/tests/cindex/test_index.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import *
 import os
 import unittest
Index: bindings/python/tests/cindex/test_file.py
===
--- bindings/python/tests/ci

[PATCH] D52752: [clang-query] Add comment token handling

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343666: [clang-query] Add comment token handling (authored 
by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52752?vs=167848&id=168080#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52752

Files:
  clang-query/QueryParser.cpp
  unittests/clang-query/QueryParserTest.cpp


Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -146,6 +146,17 @@
 cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Comment) {
+  QueryRef Q = parse("# let foo decl()");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("let foo decl() # creates a decl() matcher called foo");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("set bind-root false # reduce noise");
+  ASSERT_TRUE(isa>(Q));
+}
+
 TEST_F(QueryParserTest, Complete) {
   std::vector Comps =
   QueryParser::complete("", 0, QS);
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -37,6 +37,11 @@
 ++Begin;
   }
 
+  if (*Begin == '#') {
+End = Begin;
+return StringRef();
+  }
+
   const char *WordBegin = Begin;
 
   while (true) {
@@ -127,6 +132,7 @@
 
 enum ParsedQueryKind {
   PQK_Invalid,
+  PQK_Comment,
   PQK_NoOp,
   PQK_Help,
   PQK_Let,
@@ -161,6 +167,7 @@
   StringRef CommandStr;
   ParsedQueryKind QKind = LexOrCompleteWord(this, CommandStr)
   .Case("", PQK_NoOp)
+  .Case("#", PQK_Comment, /*IsCompletion=*/false)
   .Case("help", PQK_Help)
   .Case("l", PQK_Let, /*IsCompletion=*/false)
   .Case("let", PQK_Let)
@@ -173,6 +180,7 @@
   .Default(PQK_Invalid);
 
   switch (QKind) {
+  case PQK_Comment:
   case PQK_NoOp:
 return new NoOpQuery;
 


Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -146,6 +146,17 @@
 cast(Q)->ErrStr);
 }
 
+TEST_F(QueryParserTest, Comment) {
+  QueryRef Q = parse("# let foo decl()");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("let foo decl() # creates a decl() matcher called foo");
+  ASSERT_TRUE(isa(Q));
+
+  Q = parse("set bind-root false # reduce noise");
+  ASSERT_TRUE(isa>(Q));
+}
+
 TEST_F(QueryParserTest, Complete) {
   std::vector Comps =
   QueryParser::complete("", 0, QS);
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -37,6 +37,11 @@
 ++Begin;
   }
 
+  if (*Begin == '#') {
+End = Begin;
+return StringRef();
+  }
+
   const char *WordBegin = Begin;
 
   while (true) {
@@ -127,6 +132,7 @@
 
 enum ParsedQueryKind {
   PQK_Invalid,
+  PQK_Comment,
   PQK_NoOp,
   PQK_Help,
   PQK_Let,
@@ -161,6 +167,7 @@
   StringRef CommandStr;
   ParsedQueryKind QKind = LexOrCompleteWord(this, CommandStr)
   .Case("", PQK_NoOp)
+  .Case("#", PQK_Comment, /*IsCompletion=*/false)
   .Case("help", PQK_Help)
   .Case("l", PQK_Let, /*IsCompletion=*/false)
   .Case("let", PQK_Let)
@@ -173,6 +180,7 @@
   .Default(PQK_Invalid);
 
   switch (QKind) {
+  case PQK_Comment:
   case PQK_NoOp:
 return new NoOpQuery;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag

2018-10-03 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6
+ clang_version
+clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 
85a6dda64587a5a18482f091cbcf020fbd3ec1dd) (https://github.com/llvm-mirror/llvm 
1ffbf26a1a0a190d69327af875a3337b74a2ce82)
+ diagnostics

You are diffing against a hardcoded output file which contains //a git hash//! 
Won't this break at the next commit?!


Repository:
  rC Clang

https://reviews.llvm.org/D52742



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


[PATCH] D52752: [clang-query] Add comment token handling

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: clang-query/QueryParser.cpp:42
+End = Begin;
+return StringRef(Begin, 0);
+  }

aaron.ballman wrote:
> This is just returning an empty `StringRef`, isn't it? Might as well return 
> `StringRef()` through the default constructor for clarity.
I copied the pattern from a few lines above, but there is it actually necessary 
as it is used in the code completion infrastructure. Comments don't participate 
in code completion so I changed it as described.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52752



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


[PATCH] D52798: [cl-compat] Change /JMC from unsupported to ignored.

2018-10-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks for fixing! Please also update the test in test/Driver/cl-options.c and 
include me on clang-cl code reviews.


Repository:
  rL LLVM

https://reviews.llvm.org/D52798



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


[PATCH] D52771: [private][clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 168088.
lebedev.ri added a subscriber: cfe-commits.
lebedev.ri added a comment.

Finds classes that not only contain the data (non-static member variables),
but also have logic (non-static member functions), and diagnoses all member
variables that have any other scope other than `private`. They should be
made `private`, and manipulated exclusively via the member functions.

Optionally, classes with all member variables being `public` could be
ignored, and optionally all `public` member variables could be ignored.

Options
---

- IgnoreClassesWithAllMemberVariablesBeingPublic

  Allows to completely ignore classes if **all** the member variables in that 
class have `public` visibility.

- IgnorePublicMemberVariables

  Allows to ignore (not diagnose) **all** the member variables with `public` 
visibility scope.

References:

- MISRA 11-0-1 Member data in non-POD class types shall be private.
- http://www.codingstandard.com/rule/11-1-1-declare-all-data-members-private/
- 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently
- 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-private
- 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-protected


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
  docs/ReleaseNotes.rst
  
docs/clang-tidy/checks/cppcoreguidelines-non-private-member-variables-in-classes.rst
  docs/clang-tidy/checks/hicpp-non-private-member-variables-in-classes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
  test/clang-tidy/misc-non-private-member-variables-in-classes.cpp

Index: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
@@ -0,0 +1,350 @@
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffix=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffix=IGNOREPUBLICONLY %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+// RUN: %check_clang_tidy -check-suffix=IGNOREPUBLIC %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+
+////
+
+// Only data, do not warn
+
+struct S0 {
+  int S0_v0;
+
+public:
+  int S0_v1;
+
+protected:
+  int S0_v2;
+
+private:
+  int S0_v3;
+};
+
+class S1 {
+  int S1_v0;
+
+public:
+  int S1_v1;
+
+protected:
+  int S1_v2;
+
+private:
+  int S1_v3;
+};
+
+////
+
+// All functions are static, do not warn.
+
+struct S2 {
+  static void S2_m0();
+  int S2_v0;
+
+public:
+  static void S2_m1();
+  int S2_v1;
+
+protected:
+  static void S2_m3();
+  int S2_v2;
+
+private:
+  static void S2_m4();
+  int S2_v3;
+};
+
+class S3 {
+  static void S3_m0();
+  int S3_v0;
+
+public:
+  static void S3_m1();
+  int S3_v1;
+
+protected:
+  static void S3_m3();
+  int S3_v2;
+
+private:
+  static void S3_m4();
+  int S3_v3;
+};
+
+////
+
+// Has non-static method with default visibility.
+
+struct S4 {
+  void S4_m0();
+
+  int S4_v0;
+  // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S4_v0' of struct 'S4' has public vi

[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp:26
+
+AST_MATCHER(clang::CXXRecordDecl, hasNonStaticMethod) {
+  return hasMethod(unless(isStaticStorageClass()))

I think this and the next matcher can be a normal variable.

```
auto HasNonStaticMethod = hasMethod(unless(isStaticStorageClass()));

...
... allOf(anyOf(isStruct(), isClass()), HasMethods, HasNonStaticMethod)
...
```



Comment at: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp:55
+  // We may optionally ignore classes where all the member variables are 
public.
+  auto recordIsInteresting =
+  allOf(anyOf(isStruct(), isClass()), hasMethods(), hasNonStaticMethod(),

Please make this variable uppercase, same for next matcher



Comment at: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp:76
+  const auto *Field = Result.Nodes.getNodeAs("field");
+  const auto *Record = Result.Nodes.getNodeAs("record");
+  diag(Field->getLocation(),

Please add assertions that these pointers are not-null. Some random bug could 
match only one of these too and result in null-deref



Comment at: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h:31
+class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck {
+  const bool IgnoreClassesWithAllMemberVariablesBeingPublic;
+  const bool IgnorePublicMemberVariables;

i believe usually the private state is written at the bottom of a class. I dont 
have a strong opinion, but i believe alex does prefer it.



Comment at: docs/ReleaseNotes.rst:99
+
+  Finds classes that not only contain the data (non-static member variables),
+  but also have logic (non-static member functions), and diagnoses all member

Please shorten the text in the release notes a bit. Usually one sentence should 
be enough, you can explain more in the docs



Comment at: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp:1
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s 
misc-non-private-member-variables-in-classes %t
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s 
misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: 
[{key: 
misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, 
value: 0}, {key: 
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic,
 value: 0}]}' --

I would prefer multiple test-files instead of mixing them all together.



Comment at: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp:9
+
+// Only data, do not warn
+

The test miss 
- templated classes (should be diagnosed normally) 
- inheritance (public, private, protected) (should not add a new warning in the 
subclass)
- and macros creating members. (dont know what to do there, but just warn?)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771



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


[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 168091.
JonasToth marked 2 inline comments as done.
JonasToth added a comment.

- remove spurious local variable


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tidy/readability/IsolateDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-declaration.rst
  test/clang-tidy/readability-isolate-declaration-cxx17.cpp
  test/clang-tidy/readability-isolate-declaration-fixing.cpp
  test/clang-tidy/readability-isolate-declaration.c
  test/clang-tidy/readability-isolate-declaration.cpp

Index: test/clang-tidy/readability-isolate-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-declaration.cpp
@@ -0,0 +1,412 @@
+// RUN: %check_clang_tidy %s readability-isolate-declaration %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+
+  auto int1 = 42, int2 = 0, int3 = 43;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: auto int1 = 42;
+  // CHECK-FIXES: {{^  }}auto int2 = 0;
+  // CHECK-FIXES: {{^  }}auto int3 = 43;
+
+  decltype(auto) ptr1 = &int1, ptr2 = &int1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(auto) ptr1 = &int1;
+  // CHECK-FIXES: {{^  }}decltype(auto) ptr2 = &int1;
+
+  decltype(k) ptr3 = &int1, ptr4 = &int1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(k) ptr3 = &int1;
+  // CHECK-FIXES: {{^  }}decltype(k) ptr4 = &int1;
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = &i;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = &i;
+
+  int *(i_ptr) = nullptr, *((i_ptr2));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *(i_ptr) = nullptr;
+  // CHECK-FIXES: {{^  }}int *((i_ptr2));
+
+  float(*f_ptr)[42], (((f_value))) = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*f_ptr)[42];
+  // CHECK-FIXES: {{^  }}float (((f_value))) = 42;
+
+  float(((*f_ptr2)))[42], ((*f_ptr3)), f_value2 = 42.f;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr2)))[42];
+  // CHECK-FIXES: {{^  }}float ((*f_ptr3));
+  // CHECK-FIXES: {{^  }}float f_value2 = 42.f;
+
+  float(((*f_ptr4)))[42], *f_ptr5, ((f_value3));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr4)))[42];
+  // CHECK-FIXES: {{^  }}float *f_ptr5;
+  // CHECK-FIXES: {{^  }}float ((f_value3));
+
+  void(((*f2))(int)), (*g2)(int, float);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: void (((*f2))(int));
+  // CHECK-FIXES: {{^  }}void (*g2)(int, float);
+
+  float(*(*(*f_ptr6)))[42], (*f_ptr7);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*(*(*f_ptr6)))[42];
+  // CHECK-FIXES: {{^  }}float (*f_ptr7);
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* *

[PATCH] D52688: [clang-tidy] NFC use CHECK-NOTES in tests for fuchsia-default-arguments

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 168092.
JonasToth added a comment.

- remove FIX-IT as these will be filtered with the other patch


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52688

Files:
  test/clang-tidy/fuchsia-default-arguments.cpp


Index: test/clang-tidy/fuchsia-default-arguments.cpp
===
--- test/clang-tidy/fuchsia-default-arguments.cpp
+++ test/clang-tidy/fuchsia-default-arguments.cpp
@@ -1,14 +1,13 @@
 // RUN: %check_clang_tidy %s fuchsia-default-arguments %t
 
 int foo(int value = 5) { return value; }
-// CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
 // CHECK-FIXES: int foo(int value) { return value; }
 
 int f() {
   foo();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
-  // CHECK-NEXT: note: default parameter was declared here:
-  // CHECK-NEXT: int foo(int value = 5) { return value; }
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-8]]:9: note: default parameter was declared here
 }
 
 int bar(int value) { return value; }
@@ -21,16 +20,16 @@
 class Baz {
 public:
   int a(int value = 5) { return value; }
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
   // CHECK-FIXES: int a(int value) { return value; }
 
   int b(int value) { return value; }
 };
 
 class Foo {
   // Fix should be suggested in declaration
   int a(int value = 53);
-  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
   // CHECK-FIXES: int a(int value);
 };
 
@@ -41,21 +40,21 @@
 
 // Elided functions
 void f(int = 5) {};
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
 // CHECK-FIXES: void f(int) {};
 
 void g(int) {};
 
 // Should not suggest fix for macro-defined parameters
 #define D(val) = val
 
 void h(int i D(5));
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
 // CHECK-FIXES-NOT: void h(int i);
 
 void x(int i);
 void x(int i = 12);
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
 // CHECK-FIXES: void x(int i);
 
 void x(int i) {}
@@ -65,17 +64,17 @@
 };
 
 void S::x(int i = 12) {}
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: declaring a parameter with a 
default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default 
argument is disallowed [fuchsia-default-arguments]
 // CHECK-FIXES: void S::x(int i) {}
 
 int main() {
   S s;
   s.x();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
-  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-9]]:11: note: default parameter was declared here
   // CHECK-NEXT: void S::x(int i = 12) {}
   x();
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
-  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a 
default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-19]]:8: note: default parameter was declared here
   // CHECK-NEXT: void x(int i = 12);
 }


Index: test/clang-tidy/fuchsia-default-arguments.cpp
===
--- test/clang-tidy/fuchsia-default-arguments.cpp
+++ test/clang-tidy/fuchsia-default-arguments.cpp
@@ -1,14 +1,13 @@
 // RUN: %check_cla

[PATCH] D41648: [clang-tidy] implement cppcoreguidelines macro rules

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 168094.
JonasToth added a comment.

- Merge branch 'master' into check_macros_usage


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41648

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
  clang-tidy/cppcoreguidelines/MacroUsageCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
  test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
  test/clang-tidy/cppcoreguidelines-macro-usage.cpp

Index: test/clang-tidy/cppcoreguidelines-macro-usage.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define PROBLEMATIC_CONSTANT 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro used to declare a constant; consider using a 'constexpr' constant
+
+#define PROBLEMATIC_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: function-like macro used; consider a 'constexpr' template function
+
+#define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro used; consider using a 'constexpr' variadic template function
+
+#endif
Index: test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cppcoreguidelines-macro-usage.AllowedRegexp, value: "DEBUG_*|TEST_*"}]}' --
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define PROBLEMATIC_CONSTANT 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro used to declare a constant; consider using a 'constexpr' constant
+
+#define PROBLEMATIC_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: function-like macro used; consider a 'constexpr' template function
+
+#define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro used; consider using a 'constexpr' variadic template function
+
+#define DEBUG_CONSTANT 0
+#define DEBUG_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+#define DEBUG_VARIADIC(...) (__VA_ARGS__)
+#define TEST_CONSTANT 0
+#define TEST_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+#define TEST_VARIADIC(...) (__VA_ARGS__)
+
+#endif
Index: test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cppcoreguidelines-macro-usage.CheckCapsOnly, value: 1}]}' --
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define problematic_constant 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#define problematic_function(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#define problematic_variadic(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#endif
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -88,6 +88,7 @@
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-macro-usage
cppcoreguidelines-narrowing-conversions
cppcoreguidelines-no-malloc
cppcoreguidelines-owning-memory
Index: docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - cppcoreguidelines-macro-usage
+
+cppcoreguidelines-macro-usage
+=
+
+Find macro usage that is considered problematic because better language
+constructs exist for the task.
+
+The relevant sections in the C++ Core Guidelines are 
+`Enum.1 `_,
+`ES.30 

[clang-tools-extra] r343673 - [clang-tidy] NFC reorder registering in CppCoreGuidelines module

2018-10-03 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Oct  3 03:37:19 2018
New Revision: 343673

URL: http://llvm.org/viewvc/llvm-project?rev=343673&view=rev
Log:
[clang-tidy] NFC reorder registering in CppCoreGuidelines module

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=343673&r1=343672&r2=343673&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Wed Oct  3 03:37:19 2018
@@ -40,10 +40,10 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "cppcoreguidelines-avoid-goto");
-CheckFactories.registerCheck(
-"cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck(
 "cppcoreguidelines-avoid-magic-numbers");
+CheckFactories.registerCheck(
+"cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck(
 "cppcoreguidelines-narrowing-conversions");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");


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


[PATCH] D41648: [clang-tidy] implement cppcoreguidelines macro rules

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@aaron.ballman What do you think of the current version of this check?
As migration strategy the option for `CAPS_ONLY` is provided, otherwise the 
filtering is provided to silence necessary macros (which kind of enforces a 
common prefix for macros). This does implement both the cppcoreguidelines and 
allows migration.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41648



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


[PATCH] D41648: [clang-tidy] implement cppcoreguidelines macro rules

2018-10-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 168095.
JonasToth added a comment.

- add more positive tests
- Merge branch 'master' into check_macros_usage


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41648

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
  clang-tidy/cppcoreguidelines/MacroUsageCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
  test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
  test/clang-tidy/cppcoreguidelines-macro-usage.cpp

Index: test/clang-tidy/cppcoreguidelines-macro-usage.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define PROBLEMATIC_CONSTANT 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro used to declare a constant; consider using a 'constexpr' constant
+
+#define PROBLEMATIC_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: function-like macro used; consider a 'constexpr' template function
+
+#define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro used; consider using a 'constexpr' variadic template function
+
+#endif
Index: test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cppcoreguidelines-macro-usage.AllowedRegexp, value: "DEBUG_*|TEST_*"}]}' --
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define PROBLEMATIC_CONSTANT 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro used to declare a constant; consider using a 'constexpr' constant
+
+#define PROBLEMATIC_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: function-like macro used; consider a 'constexpr' template function
+
+#define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro used; consider using a 'constexpr' variadic template function
+
+#define DEBUG_CONSTANT 0
+#define DEBUG_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+#define DEBUG_VARIADIC(...) (__VA_ARGS__)
+#define TEST_CONSTANT 0
+#define TEST_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+#define TEST_VARIADIC(...) (__VA_ARGS__)
+
+#endif
Index: test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cppcoreguidelines-macro-usage.CheckCapsOnly, value: 1}]}' --
+
+#ifndef INCLUDE_GUARD
+#define INCLUDE_GUARD
+
+#define problematic_constant 0
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#define problematic_function(x, y) ((a) > (b) ? (a) : (b))
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#define problematic_variadic(...) (__VA_ARGS__)
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro definition does not define the macro name using all uppercase characters
+
+#define OKISH_CONSTANT 42
+#define OKISH_FUNCTION(x, y) ((a) > (b) ? (a) : (b))
+#define OKISH_VARIADIC(...) (__VA_ARGS__)
+
+#endif
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -88,6 +88,7 @@
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-macro-usage
cppcoreguidelines-narrowing-conversions
cppcoreguidelines-no-malloc
cppcoreguidelines-owning-memory
Index: docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - cppcoreguidelines-macro-usage
+
+cppcoreguidelines-macro-usage
+=
+
+Find macro usage that is considered problematic because better language
+constructs exist for the task.
+
+The relevant sections in the C++ Core Guidelines are 
+`Enum.1 

[PATCH] D52117: Generate llvm.loop.parallel_accesses instead of llvm.mem.parallel_loop_access metadata.

2018-10-03 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 168096.
Meinersbur added a comment.

- Upload diff for clang portion (instead of https://reviews.llvm.org/D52116)


Repository:
  rC Clang

https://reviews.llvm.org/D52117

Files:
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  test/CodeGenCXX/pragma-loop-safety-nested.cpp
  test/CodeGenCXX/pragma-loop-safety-outer.cpp
  test/CodeGenCXX/pragma-loop-safety.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/loops_explicit_clauses_codegen.cpp
  test/OpenMP/ordered_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/schedule_codegen.cpp
  test/OpenMP/simd_codegen.cpp
  test/OpenMP/simd_metadata.c
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/taskloop_simd_codegen.cpp

Index: test/OpenMP/taskloop_simd_codegen.cpp
===
--- test/OpenMP/taskloop_simd_codegen.cpp
+++ test/OpenMP/taskloop_simd_codegen.cpp
@@ -83,17 +83,17 @@
 // CHECK: [[LB_I32:%.+]] = trunc i64 [[LB_VAL]] to i32
 // CHECK: store i32 [[LB_I32]], i32* [[CNT:%.+]],
 // CHECK: br label
-// CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],{{.*}}!llvm.mem.parallel_loop_access [[LOOP1:!.+]]
+// CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],{{.*}}!llvm.access.group
 // CHECK: [[VAL_I64:%.+]] = sext i32 [[VAL]] to i64
-// CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],{{.*}}!llvm.mem.parallel_loop_access [[LOOP1]]
+// CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],{{.*}}!llvm.access.group
 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
-// CHECK: load i32, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP1]]
-// CHECK: store i32 %{{.*}}!llvm.mem.parallel_loop_access [[LOOP1]]
-// CHECK: load i32, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP1]]
+// CHECK: load i32, i32* %{{.*}}!llvm.access.group
+// CHECK: store i32 %{{.*}}!llvm.access.group
+// CHECK: load i32, i32* %{{.*}}!llvm.access.group
 // CHECK: add nsw i32 %{{.+}}, 1
-// CHECK: store i32 %{{.+}}, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP1]]
-// CHECK: br label %{{.*}}!llvm.loop [[LOOP1]]
+// CHECK: store i32 %{{.+}}, i32* %{{.*}}!llvm.access.group
+// CHECK: br label %{{.*}}!llvm.loop
 // CHECK: ret i32 0
 
 // CHECK: define internal i32 [[TASK2]](
@@ -113,17 +113,17 @@
 // CHECK: [[LB_I32:%.+]] = trunc i64 [[LB_VAL]] to i32
 // CHECK: store i32 [[LB_I32]], i32* [[CNT:%.+]],
 // CHECK: br label
-// CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],{{.*}}!llvm.mem.parallel_loop_access [[LOOP2:!.+]]
+// CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],{{.*}}!llvm.access.group
 // CHECK: [[VAL_I64:%.+]] = sext i32 [[VAL]] to i64
-// CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],{{.*}}!llvm.mem.parallel_loop_access [[LOOP2]]
+// CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],{{.*}}!llvm.access.group
 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
-// CHECK: load i32, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP2]]
-// CHECK: store i32 %{{.*}}!llvm.mem.parallel_loop_access [[LOOP2]]
-// CHECK: load i32, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP2]]
+// CHECK: load i32, i32* %{{.*}}!llvm.access.group
+// CHECK: store i32 %{{.*}}!llvm.access.group
+// CHECK: load i32, i32* %{{.*}}!llvm.access.group
 // CHECK: add nsw i32 %{{.+}}, 1
-// CHECK: store i32 %{{.+}}, i32* %{{.*}}!llvm.mem.parallel_loop_access [[LOOP2]]
-// CHECK: br label %{{.*}}!llvm.loop [[LOOP2]]
+// CHECK: store i32 %{{.+}}, i32* %{{.*}}!llvm.access.group
+// CHECK: br label %{{.*}}!llvm.loop
 // CHECK: ret i32 0
 
 // CHECK: define internal i32 [[TASK3]](
@@ -142,7 +142,7 @@
 // CHECK: [[LB_VAL:%.+]] = load i64, i64* [[LB]],
 // CHECK: store i64 [[LB_VAL]], i64* [[CNT:%.+]],
 // CHECK: br label
-// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-NOT: !llvm.access.group
 // CHECK: br label %{{.*}}!llvm.loop
 // CHECK: ret i32 0
 
@@ -192,14 +192,14 @@
 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
 // CHECK: load i32, i32* %
-// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-NOT: !llvm.access.group
 // CHECK: store i32 %
-// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-NOT: !llvm.access.group
 // CHECK: load i32, i32* %
-// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-NOT: !llvm.access.group
 // CHECK: add nsw i32 %{{.+}}, 1
 // CHECK: store i32 %{{.+}}, i32* %
-// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-NOT: !llvm.access.group
 // CHECK: br label %{{.*}}!llvm.loop
 // CHECK: ret i32 0
 
Index: test/OpenMP/target_simd_codegen.cpp
===
--- test/OpenMP/target_simd_codegen.cpp
+++ test/OpenMP/target_simd_codegen.cpp
@@ -342,7 +342,7 @@
 // CHECK-64:[[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i32*
 // CHECK-64:   

[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag

2018-10-03 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus marked 3 inline comments as done.
Szelethus added inline comments.



Comment at: 
test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6
+ clang_version
+clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 
85a6dda64587a5a18482f091cbcf020fbd3ec1dd) (https://github.com/llvm-mirror/llvm 
1ffbf26a1a0a190d69327af875a3337b74a2ce82)
+ diagnostics

whisperity wrote:
> You are diffing against a hardcoded output file which contains //a git 
> hash//! Won't this break at the next commit?!
I'm actually using `%diff_plist`!
```
// Check the actual plist output.
//   RUN: cat %t.plist | %diff_plist \
//   RUN:   %S/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
```
Here's the patch that implemented it (should jump to the config file): 
D52036#change-mOw5EmE2OiVA


Repository:
  rC Clang

https://reviews.llvm.org/D52742



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


[PATCH] D52819: Support checking out cte to 'extra' only as backward compatibility

2018-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Given the scope of what this changes (such as 3rd party configurations), I 
think that this requires a broader community discussion than what you'll get 
from this patch. I would suggest starting an [RFC] thread on cfe-commits and 
cfe-dev to see what people think of the idea.

Personally, I'm opposed to the idea. There is limited benefit compared to the 
number of scripts I will have to go update for out-of-tree builds where I'll 
suddenly be getting cmake warnings about a directory name that I've used 
without issue for years. If anything, I think the logic should be reversed so 
that we warn users who try to use "clang-tools-extra" as the directory name 
rather than "extra".


Repository:
  rC Clang

https://reviews.llvm.org/D52819



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


[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2018-10-03 Thread Jano Simas via Phabricator via cfe-commits
janosimas added a comment.

I like a lot of this syntax you proposed, makes a lot more sense to me.

The script will be shorter and the doc will be "auto updated" with the 
clang-tidy doc.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49864



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


r343681 - Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

2018-10-03 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Wed Oct  3 04:58:19 2018
New Revision: 343681

URL: http://llvm.org/viewvc/llvm-project?rev=343681&view=rev
Log:
Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

Summary:
When people are really sure they'll get the lock they sometimes use
__builtin_expect. It's also used by some assertion implementations.
Asserting that try-lock succeeded is basically the same as asserting
that the lock is not held by anyone else (and acquiring it).

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: kristina, cfe-commits

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

Modified:
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=343681&r1=343680&r2=343681&view=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Wed Oct  3 04:58:19 2018
@@ -33,6 +33,7 @@
 #include "clang/Analysis/Analyses/ThreadSafetyUtil.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
@@ -1388,8 +1389,11 @@ const CallExpr* ThreadSafetyAnalyzer::ge
   if (!Cond)
 return nullptr;
 
-  if (const auto *CallExp = dyn_cast(Cond))
+  if (const auto *CallExp = dyn_cast(Cond)) {
+if (CallExp->getBuiltinCallee() == Builtin::BI__builtin_expect)
+  return getTrylockCallExpr(CallExp->getArg(0), C, Negate);
 return CallExp;
+  }
   else if (const auto *PE = dyn_cast(Cond))
 return getTrylockCallExpr(PE->getSubExpr(), C, Negate);
   else if (const auto *CE = dyn_cast(Cond))

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=343681&r1=343680&r2=343681&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Wed Oct  3 04:58:19 
2018
@@ -1754,12 +1754,27 @@ struct TestTryLock {
 mu.Unlock();
   }
 
+  void foo2_builtin_expect() {
+if (__builtin_expect(!mu.TryLock(), false))
+  return;
+a = 2;
+mu.Unlock();
+  }
+
   void foo3() {
 bool b = mu.TryLock();
 if (b) {
   a = 3;
   mu.Unlock();
 }
+  }
+
+  void foo3_builtin_expect() {
+bool b = mu.TryLock();
+if (__builtin_expect(b, true)) {
+  a = 3;
+  mu.Unlock();
+}
   }
 
   void foo4() {


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


[PATCH] D52398: Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

2018-10-03 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343681: Thread safety analysis: Unwrap __builtin_expect in 
getTrylockCallExpr (authored by aaronpuchert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52398

Files:
  cfe/trunk/lib/Analysis/ThreadSafety.cpp
  cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp


Index: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1754,14 +1754,29 @@
 mu.Unlock();
   }
 
+  void foo2_builtin_expect() {
+if (__builtin_expect(!mu.TryLock(), false))
+  return;
+a = 2;
+mu.Unlock();
+  }
+
   void foo3() {
 bool b = mu.TryLock();
 if (b) {
   a = 3;
   mu.Unlock();
 }
   }
 
+  void foo3_builtin_expect() {
+bool b = mu.TryLock();
+if (__builtin_expect(b, true)) {
+  a = 3;
+  mu.Unlock();
+}
+  }
+
   void foo4() {
 bool b = mu.TryLock();
 if (!b) return;
Index: cfe/trunk/lib/Analysis/ThreadSafety.cpp
===
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp
@@ -33,6 +33,7 @@
 #include "clang/Analysis/Analyses/ThreadSafetyUtil.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
@@ -1388,8 +1389,11 @@
   if (!Cond)
 return nullptr;
 
-  if (const auto *CallExp = dyn_cast(Cond))
+  if (const auto *CallExp = dyn_cast(Cond)) {
+if (CallExp->getBuiltinCallee() == Builtin::BI__builtin_expect)
+  return getTrylockCallExpr(CallExp->getArg(0), C, Negate);
 return CallExp;
+  }
   else if (const auto *PE = dyn_cast(Cond))
 return getTrylockCallExpr(PE->getSubExpr(), C, Negate);
   else if (const auto *CE = dyn_cast(Cond))


Index: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1754,14 +1754,29 @@
 mu.Unlock();
   }
 
+  void foo2_builtin_expect() {
+if (__builtin_expect(!mu.TryLock(), false))
+  return;
+a = 2;
+mu.Unlock();
+  }
+
   void foo3() {
 bool b = mu.TryLock();
 if (b) {
   a = 3;
   mu.Unlock();
 }
   }
 
+  void foo3_builtin_expect() {
+bool b = mu.TryLock();
+if (__builtin_expect(b, true)) {
+  a = 3;
+  mu.Unlock();
+}
+  }
+
   void foo4() {
 bool b = mu.TryLock();
 if (!b) return;
Index: cfe/trunk/lib/Analysis/ThreadSafety.cpp
===
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp
@@ -33,6 +33,7 @@
 #include "clang/Analysis/Analyses/ThreadSafetyUtil.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
@@ -1388,8 +1389,11 @@
   if (!Cond)
 return nullptr;
 
-  if (const auto *CallExp = dyn_cast(Cond))
+  if (const auto *CallExp = dyn_cast(Cond)) {
+if (CallExp->getBuiltinCallee() == Builtin::BI__builtin_expect)
+  return getTrylockCallExpr(CallExp->getArg(0), C, Negate);
 return CallExp;
+  }
   else if (const auto *PE = dyn_cast(Cond))
 return getTrylockCallExpr(PE->getSubExpr(), C, Negate);
   else if (const auto *CE = dyn_cast(Cond))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D46535#1253473, @xbolva00 wrote:

> Hello, @erichkeane
>
> I am working on int to float checker but I haven't found yet a way how to 
> check if integer fits to float's significant bits. Maybe you can recommend me 
> something? I already tried some LLVM APIs but no success. (cc @spatel as you 
> will probably know the right function to do it)


I'm not sure what you mean by that... Every Integer is representable (lossy of 
course) as a float as far as I know.  You'll obviously lose the LSDs, but it'll 
be representable.  Are you trying to check whether it is round-trip-able?  If 
thats the case, I think you'll need to make sure it entirely fits in the 
mantissa.  You can get the amount of mantissa bits by checking the APFloat's 
fltSemantics.  There are a couple of builtin ones that I think end up being 
useful, but the 'precision' field seems like what you want.


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Yeah, I want to check if it fits into mantissa.


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D52058: Add Parameters to DW_AT_name Attribute of Template Variables

2018-10-03 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D52058



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


[PATCH] D52800: Java import sorting in clang-format

2018-10-03 Thread Sam Maier via Phabricator via cfe-commits
SamMaier updated this revision to Diff 168111.
SamMaier set the repository for this revision to rC Clang.
SamMaier added a comment.

Changed std::sort to llvm::sort


Repository:
  rC Clang

https://reviews.llvm.org/D52800

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJava.cpp

Index: unittests/Format/SortImportsTestJava.cpp
===
--- unittests/Format/SortImportsTestJava.cpp
+++ unittests/Format/SortImportsTestJava.cpp
@@ -0,0 +1,141 @@
+//===- unittest/Format/SortImportsTestJava.cpp - Import sort unit tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJava : public ::testing::Test {
+protected:
+  std::vector GetCodeRange(StringRef Code) {
+return std::vector(1, tooling::Range(0, Code.size()));
+  }
+
+  std::string sort(StringRef Code, std::vector Ranges) {
+auto Replaces = sortIncludes(FmtStyle, Code, Ranges, "input.java");
+Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+auto Sorted = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Sorted));
+auto Result = applyAllReplacements(
+*Sorted, reformat(FmtStyle, *Sorted, Ranges, "input.java"));
+EXPECT_TRUE(static_cast(Result));
+return *Result;
+  }
+
+  std::string sort(StringRef Code) { return sort(Code, GetCodeRange(Code)); }
+
+  FormatStyle FmtStyle;
+
+public:
+  SortImportsTestJava() {
+FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
+FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
+FmtStyle.SortIncludes = true;
+  }
+};
+
+TEST_F(SortImportsTestJava, StaticSplitFromNormal) {
+  EXPECT_EQ("import static org.b;\n"
+"\n"
+"import org.a;\n",
+sort("import org.a;\n"
+ "import static org.b;\n"));
+}
+
+TEST_F(SortImportsTestJava, CapitalBeforeLowercase) {
+  EXPECT_EQ("import org.Test;\n"
+"import org.a.Test;\n"
+"import org.b;\n",
+sort("import org.a.Test;\n"
+ "import org.Test;\n"
+ "import org.b;\n"));
+}
+
+TEST_F(SortImportsTestJava, SplitGroupsWithNewline) {
+  EXPECT_EQ("import static com.test.a;\n"
+"\n"
+"import static org.a;\n"
+"\n"
+"import static com.a;\n"
+"\n"
+"import com.test.b;\n"
+"\n"
+"import org.b;\n"
+"\n"
+"import com.b;\n",
+sort("import static com.test.a;\n"
+ "import static org.a;\n"
+ "import static com.a;\n"
+ "import com.test.b;\n"
+ "import org.b;\n"
+ "import com.b;\n"));
+}
+
+TEST_F(SortImportsTestJava, UnspecifiedGroupAfterAllGroups) {
+  EXPECT_EQ("import com.test.a;\n"
+"\n"
+"import org.a;\n"
+"\n"
+"import com.a;\n"
+"\n"
+"import abc.a;\n"
+"import xyz.b;\n",
+sort("import com.test.a;\n"
+ "import com.a;\n"
+ "import xyz.b;\n"
+ "import abc.a;\n"
+ "import org.a;\n"));
+}
+
+TEST_F(SortImportsTestJava, NoSortOutsideRange) {
+  std::vector Ranges = {tooling::Range(27, 15)};
+  EXPECT_EQ("import org.b;\n"
+"import org.a;\n"
+"// comments\n"
+"// that do\n"
+"// nothing\n",
+sort("import org.b;\n"
+ "import org.a;\n"
+ "// comments\n"
+ "// that do\n"
+ "// nothing\n",
+ Ranges));
+}
+
+TEST_F(SortImportsTestJava, SortWhenRangeContainsOneLine) {
+  std::vector Ranges = {tooling::Range(27, 20)};
+  EXPECT_EQ("import org.a;\n"
+"import org.b;\n"
+"\n"
+"import com.a;\n"
+"// comments\n"
+"// that do\n"
+"// nothing\n",
+sort("import org.b;\n"
+ "import org.a;\n"
+ "import com.a;\n"
+ "// comments\n"
+ "// that do\n"
+ "// nothing\n",
+ Ranges));
+}
+
+TEST_F(SortImportsTestJava, DeduplicateImports) {
+  EXPECT_EQ("import org.a;\n", sort("import org.a;\n"
+"import org.a;\n"));
+}
+
+} // end namespace
+} // end namespace format
+} // end namespace clang
Index: unittests/Format/CMakeLists.txt
==

[PATCH] D52819: Support checking out cte to 'extra' only as backward compatibility

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Will do!


Repository:
  rC Clang

https://reviews.llvm.org/D52819



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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-10-03 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov updated this revision to Diff 168115.
AlexeySachkov added a comment.
Herald added a subscriber: arphaman.

Applied comments from Anastasia. Updated headers to conform with the latest spec


https://reviews.llvm.org/D51484

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  include/clang/Basic/OpenCLExtensionTypes.def
  include/clang/Basic/OpenCLExtensions.def
  include/clang/Sema/Initialization.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/module.modulemap
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Headers/opencl-c.h
  lib/Index/USRGeneration.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl
  test/Headers/opencl-c-header.cl
  test/SemaOpenCL/extension-version.cl
  test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
  tools/libclang/CIndex.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -70,6 +70,8 @@
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) BTCASE(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) BTCASE(Id);
+#include "clang/Basic/OpenCLExtensionTypes.def"
 BTCASE(OCLSampler);
 BTCASE(OCLEvent);
 BTCASE(OCLQueue);
@@ -605,6 +607,8 @@
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
+#define EXT_OPAQUE_TYPE(ExtTYpe, Id, Ext) TKIND(Id);
+#include "clang/Basic/OpenCLExtensionTypes.def"
 TKIND(OCLSampler);
 TKIND(OCLEvent);
 TKIND(OCLQueue);
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1519,6 +1519,9 @@
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
+#define EXT_OPAQUE_TYPE(ExtTYpe, Id, Ext) \
+  case BuiltinType::Id:
+#include "clang/Basic/OpenCLExtensionTypes.def"
   case BuiltinType::OCLSampler:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
Index: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
===
--- /dev/null
+++ test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s
+
+#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
+
+// Having the initializers defined in the test allows us not to include default
+// opencl header, and thus reducing test execution time.
+// The initializers' values must match with ones defined in the default opencl
+// header (clang/lib/Headers/opencl-c.h)
+
+#define CLK_AVC_ME_INITIALIZE_INTEL 0x0
+
+#define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL 0x0
+#define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL 0x0
+#define CLK_AVC_SIC_PAYLOAD_INITIALIZE_INTEL 0x0
+
+#define CLK_AVC_IME_RESULT_INITIALIZE_INTEL 0x0
+#define CLK_AVC_REF_RESULT_INITIALIZE_INTEL 0x0
+#define CLK_AVC_SIC_RESULT_INITIALIZE_INTEL 0x0
+
+#define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0
+#define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0
+#define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0
+#define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0
+
+// negative test cases
+struct st{};
+typedef char char4 __attribute__((ext_vector_type(4)));
+void foo(bool b, char c, short s, long l, float f, double d, void* v,
+ char4 c4, event_t e, struct st ss) {
+  intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}}
+  intel_sub_group_avc_mce_payload_t payload_mce2 = 1; // No literal initializer for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}}
+  intel_sub_group_avc

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-03 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 168116.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,30 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
 // PS3: target datalayout = "E-m:e-p:32:32-i64:64-n32:64"
Index: test/CodeGen/mips-zero-sized-struct.c
===
--- test/CodeGen/mips-zero-sized-struct.c
+++ test/CodeGen/mips-zero-sized-struct.c
@@ -2,8 +2,12 @@
 // RUN: 

[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-10-03 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov marked 7 inline comments as done.
AlexeySachkov added inline comments.



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:13
+
+#define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL   { 0 }
+#define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL   { 0 }

Anastasia wrote:
> Just 0 would work too?
Yes, it would



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:26
+ char4 c4, event_t e, struct st ss) {
+  intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer 
for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}

Anastasia wrote:
> Would it make sense to add a check for non-zero constant?
> 
> Also can you assign variables of intel_sub_group_avc_mce_payload_t type from 
> the same type? Any other restrictions on assignment (i.e. w integer literals) 
> and operations over these types?
> Also can you assign variables of intel_sub_group_avc_mce_payload_t type from 
> the same type?

Yes, such assignment is allowed.

> Any other restrictions on assignment (i.e. w integer literals)

All of these types can only be initialized using call to a special built-ins or 
using predefined macros like `CLK_AVC_REF_RESULT_INITIALIZE_INTEL`. Any other 
assignment should lead to an error. 

I found that I'm able to assign variable of type 
`intel_sub_group_avc_imc_payload_t` to variable of type 
`intel_sub_group_avc_mce_payload_t`, so I will update the patch when I 
implement such diagnostic message.

> and operations over these types?
Variables of these types can only be used as return values or arguments for 
built-in functions described in the specification. All other operations are 
restricted


https://reviews.llvm.org/D51484



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


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-03 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ohhh. make check-all is needed, instead of make check

> test/CodeGen/target-data.c

  is due to duplicate line `MIPS-64EL: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"'

> test/Driver/mips-cs.cpp

  is due to this test use the hardcode path `/mips-linux-gnu/', so mipsel and 
mips64el also need
  BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
  although MIPSTriples should in the last order.




Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:109
 
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";

atanasyan wrote:
> If target triple is mips-mti-linux-gnuabin32 the code above set (incorrectly) 
> the `ABIName` to `n64` and this statement will be `false`.
as I know mips-mti-linux-gnuabin32 is never used, at least for gcc.
Should we allow it?



Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:85
 
   if (ABIName.empty() &&
   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||

atanasyan wrote:
> Is possible to rewrite this piece of code (lines 85-114) as follows?
> ```
>   if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
> ABIName = "n32";
> 
>   if (ABIName.empty() &&
>   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
>Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
> ABIName = llvm::StringSwitch(CPUName)
>   .Case("mips1", "o32")
>   .Case("mips2", "o32")
>   .Case("mips3", "n64")
>   .Case("mips4", "n64")
>   .Case("mips5", "n64")
>   .Case("mips32", "o32")
>   .Case("mips32r2", "o32")
>   .Case("mips32r3", "o32")
>   .Case("mips32r5", "o32")
>   .Case("mips32r6", "o32")
>   .Case("mips64", "n64")
>   .Case("mips64r2", "n64")
>   .Case("mips64r3", "n64")
>   .Case("mips64r5", "n64")
>   .Case("mips64r6", "n64")
>   .Case("octeon", "n64")
>   .Case("p5600", "o32")
>   .Default("");
>   }
> ```
OK. I didn't do like this because I am not very full confident about whether 
there are some case that it is set to N32 even -gnuabin32 is used.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2082
 BiarchTripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
-BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
+BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
+BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples));

atanasyan wrote:
> Why do you remove `BiarchTripleAliases.append(begin(MIPSTriples), 
> end(MIPSTriples));` in that case only? Is it intended?
ohhh, my fault. I should remove from mipsel also.



Comment at: lib/Driver/ToolChains/Linux.cpp:47
   bool IsAndroid = TargetTriple.isAndroid();
+  std::string MipsCpu = "", Mips64Abi = "gnuabi64";
+  if (TargetEnvironment == llvm::Triple::GNUABIN32)

atanasyan wrote:
> - Do you need `MipsCpu` variable?
> - Is it possible to use any lightweight type like `StringRef` for the 
> `Mips64Abi`?
oh, MipsCpu is not used here, while used in D50850.
In that patch. we need different CPU names:

mipsel vs mipsisa32r6el

etc. It is my fault to split the patches.


StringRef  is not OK as, the return value of getMultiarchTriple is std::string.



Comment at: lib/Driver/ToolChains/Linux.cpp:118
   case llvm::Triple::mips64:
 if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
   return "mips64-linux-gnu";

atanasyan wrote:
> If a user has two toolchains installed into "/lib/mips64-linux-gnu" and 
> "/lib/mips64-linux-gnuabin32", this code always selects mips64-linux-gnu even 
> if N32 ABI is requested. Is it intended?
Yes. It is intended.

I don't want my patch change the behavior of llvm/clang:
the previous of llvm/clang behavior is perfering /lib/mips64-linux-gnu.

And on Debian, /lib/mips64-linux-gnu should never exists, we use
/lib/mips64-linux-gnuabi64
and 
   /lib/mips64-linux-gnuabin32




Comment at: lib/Driver/ToolChains/Linux.cpp:118
   case llvm::Triple::mips64:
 if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
   return "mips64-linux-gnu";

wzssyqa wrote:
> atanasyan wrote:
> > If a user has two toolchains installed into "/lib/mips64-linux-gnu" and 
> > "/lib/mips64-linux-gnuabin32", this code always selects mips64-linux-gnu 
> > even if N32 ABI is requested. Is it intended?
> Yes. It is intended.
> 
> I don't want my patch change the behavior of llvm/clang:
> the previous of llvm/clang behavior is perfering /lib/mips64-linux-gnu.
> 
> And on Debian, /lib/mips64-linux-gnu

[PATCH] D37813: clang-format: better handle namespace macros

2018-10-03 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D37813#1184051, @klimek wrote:

> The problem here is that we have different opinions on how the formatting on 
> namespace macros should behave in the first place- I think they should behave 
> like namespaces, you want them to be formatted differently.
>  Given that you want full control over the formatting of those macros, and 
> them not actually be formatted exactly like namespaces or classes, I think we 
> need a more generic mechanism for you to express that.


Not sure what you mean here. I want them to behave like namespaces as well, 
this is actually the use case I have... As implemented, they indeed behave 
exactly like namespaces :

  TESTSUITE(a) {   namespace a {
  } // TESTSUITE(a)} // namespace a
  VS
  TESTSUITE(a) { TESTSUITE(b) {namespace a { namespace b {
  } // TESTSUITE(a::b) }} // namespace a::b

(as long as there is a single argument. When multiple arguments are used, I add 
to choose a heuristic...)

As far as I understand, the divergence is that you would want something to 
"match" the implementation of the macro, while I propose a simpler heuristic, 
which should work fine for namespaces...


Repository:
  rC Clang

https://reviews.llvm.org/D37813



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


[PATCH] D52800: Java import sorting in clang-format

2018-10-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/Format.cpp:848
 ChromiumStyle.IndentWidth = 4;
+ChromiumStyle.JavaImportGroups = {
+"android",

It would be helpful to link to a style guide reference for this.



Comment at: lib/Format/Format.cpp:1837-1838
+// import declarations with the same text will be deduplicated. Between each
+// import group, a newline is inserted, and within each import group, a
+// case-sensitive sort is performed.
+static void sortJavaImports(const FormatStyle &Style,

It would be helpful to spell out the sort order and add tests with respect to 
`.` and `*`. ASCII ordering has `* < . < A < a` which seems reasonable.



Comment at: lib/Format/Format.cpp:1922
+StringRef Trimmed = Line.trim();
+if (Trimmed == "// clang-format off")
+  FormattingOff = true;

Please add a test for this.



Comment at: lib/Format/Format.cpp:1932
+bool IsStatic = false;
+if (Static.contains("static")) {
+  IsStatic = true;

Hm, this would also pick up the `static` in `import a.*; // static`, right? IMO 
not a big problem, just add a note about it.



Comment at: unittests/Format/SortImportsTestJava.cpp:130
+ "// that do\n"
+ "// nothing\n",
+ Ranges));

I wonder what happens if there are comments between import statements and 
comment lines after import statements. Consider adding some tests for that.


Repository:
  rC Clang

https://reviews.llvm.org/D52800



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


[PATCH] D52058: Add Parameters to DW_AT_name Attribute of Template Variables

2018-10-03 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Thanks! I'll go ahead and commit this.


Repository:
  rC Clang

https://reviews.llvm.org/D52058



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


r343699 - [COFF, ARM64] Add _ReadWriteBarrier intrinsic

2018-10-03 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Wed Oct  3 10:24:21 2018
New Revision: 343699

URL: http://llvm.org/viewvc/llvm-project?rev=343699&view=rev
Log:
[COFF, ARM64] Add _ReadWriteBarrier intrinsic

Reviewers: rnk, mstorsjo, compnerd, TomTan, haripul, javed.absar

Reviewed By: rnk

Subscribers: kristof.beyls, chrib, jfb, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=343699&r1=343698&r2=343699&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Wed Oct  3 10:24:21 2018
@@ -103,6 +103,8 @@ TARGET_HEADER_BUILTIN(_InterlockedIncrem
 TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=343699&r1=343698&r2=343699&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Oct  3 10:24:21 2018
@@ -6581,6 +6581,10 @@ Value *CodeGenFunction::EmitAArch64Built
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI_ReadWriteBarrier)
+return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent,
+   llvm::SyncScope::SingleThread);
+
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {

Modified: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c?rev=343699&r1=343698&r2=343699&view=diff
==
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c Wed Oct  3 10:24:21 2018
@@ -59,3 +59,10 @@ void check__sevl(void) {
 
 // CHECK-MSVC: @llvm.aarch64.hint(i32 5)
 // CHECK-LINUX: error: implicit declaration of function '__sevl'
+
+void check_ReadWriteBarrier() {
+  _ReadWriteBarrier();
+}
+
+// CHECK-MSVC: fence syncscope("singlethread")
+// CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'


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


[PATCH] D52809: [COFF, ARM64] Add _ReadWriteBarrier intrinsic

2018-10-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343699: [COFF, ARM64] Add _ReadWriteBarrier intrinsic 
(authored by mgrang, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52809?vs=168048&id=168131#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52809

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c


Index: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -59,3 +59,10 @@
 
 // CHECK-MSVC: @llvm.aarch64.hint(i32 5)
 // CHECK-LINUX: error: implicit declaration of function '__sevl'
+
+void check_ReadWriteBarrier() {
+  _ReadWriteBarrier();
+}
+
+// CHECK-MSVC: fence syncscope("singlethread")
+// CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -6581,6 +6581,10 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI_ReadWriteBarrier)
+return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent,
+   llvm::SyncScope::SingleThread);
+
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {
Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -103,6 +103,8 @@
 TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN


Index: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -59,3 +59,10 @@
 
 // CHECK-MSVC: @llvm.aarch64.hint(i32 5)
 // CHECK-LINUX: error: implicit declaration of function '__sevl'
+
+void check_ReadWriteBarrier() {
+  _ReadWriteBarrier();
+}
+
+// CHECK-MSVC: fence syncscope("singlethread")
+// CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -6581,6 +6581,10 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI_ReadWriteBarrier)
+return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent,
+   llvm::SyncScope::SingleThread);
+
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {
Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -103,6 +103,8 @@
 TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-10-03 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In https://reviews.llvm.org/D45776#1251256, @lebedev.ri wrote:

> Did this intentionally omit the possibility to pass a group of prefixes, like 
> `FileCheck` supports?
>  Usefulness of this feature is somewhat penalized by this.


I did not fully realize what do you mean. Can you please provide a sample? I 
see only single `-check-prefix=` in `FileCheck`.


Repository:
  rL LLVM

https://reviews.llvm.org/D45776



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


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D45776#1253934, @zinovy.nis wrote:

> In https://reviews.llvm.org/D45776#1251256, @lebedev.ri wrote:
>
> > Did this intentionally omit the possibility to pass a group of prefixes, 
> > like `FileCheck` supports?
> >  Usefulness of this feature is somewhat penalized by this.
>
>
> I did not fully realize what do you mean. Can you please provide a sample? I 
> see only single `-check-prefix=` in `FileCheck`.


https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-check-prefixes


Repository:
  rL LLVM

https://reviews.llvm.org/D45776



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


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D45776#1253934, @zinovy.nis wrote:

> In https://reviews.llvm.org/D45776#1251256, @lebedev.ri wrote:
>
> > Did this intentionally omit the possibility to pass a group of prefixes, 
> > like `FileCheck` supports?
> >  Usefulness of this feature is somewhat penalized by this.
>
>
> I did not fully realize what do you mean. Can you please provide a sample? I 
> see only single `-check-prefix=` in `FileCheck`.


https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-check-prefixes


Repository:
  rL LLVM

https://reviews.llvm.org/D45776



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


[PATCH] D52658: [OpenCL] Remove PIPE_RESERVE_ID_VALID_BIT from opencl-c.h

2018-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I am OK with the change.


Repository:
  rC Clang

https://reviews.llvm.org/D52658



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.
xbolva00 updated this revision to Diff 168137.

https://reviews.llvm.org/D52835

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c


Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, 
Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_float_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);


Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_float_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 168137.

https://reviews.llvm.org/D52835

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c


Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, 
Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_float_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);


Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_float_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52807: [COFF, ARM64] Add _InterlockedCompareExchangePointer_nf intrinsic

2018-10-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3003
+  case Builtin::BI_InterlockedCompareExchangePointer:
+  case Builtin::BI_InterlockedCompareExchangePointer_nf: {
 llvm::Type *RTy;

rnk wrote:
> Is the no fence version really equivalent to this seq_cst version here?
I don't see InterlockedCompareExchangePointer creating a fence but it should. 
(since it is the fence version). So maybe that needs to be fixed (and possibly 
other fence functions).

InterlockedCompareExchangePointer_nf should not create a fence so the current 
implementation seems correct.


Repository:
  rC Clang

https://reviews.llvm.org/D52807



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 168140.
xbolva00 added a comment.

- Added tests


https://reviews.llvm.org/D52835

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c
  test/Sema/impcast-integer-float.c


Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'float'}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'float'}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'float'}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'double'}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'double'}}
+double b4 = (1ULL << 63) + 1; // expected-warning {{implicit conversion 
loses floating-point precision: 'unsigned long long' to 'double'}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, 
Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_float_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);


Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'float'}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'float'}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'float'}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'double'}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'double'}}
+double b4 = (1ULL << 63) + 1; // expected-warning {{implicit conversion loses floating-point precision: 'unsigned long long' to 'double'}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion 

[PATCH] D52791: [Diagnostics] Check for misleading pointer declarations

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Any futher comments?


https://reviews.llvm.org/D52791



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/Sema/ext_vector_casts.c:121
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}

How is floating-point precision is being lost if the cast is from an integer?
I'm guessing you want to add a new diag with a more appropriate description.


https://reviews.llvm.org/D52835



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: test/Sema/ext_vector_casts.c:121
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}

lebedev.ri wrote:
> How is floating-point precision is being lost if the cast is from an integer?
> I'm guessing you want to add a new diag with a more appropriate description.
yeah :/ so maybe integer precision?


https://reviews.llvm.org/D52835



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 168141.

https://reviews.llvm.org/D52835

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c
  test/Sema/impcast-integer-float.c


Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'float'}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'float'}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'float'}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'double'}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'double'}}
+double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion 
loses integer precision: 'unsigned long long' to 'double'}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
integer precision: 'unsigned int' to 'float2' (vector of 2 'float' values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10852,6 +10852,31 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, 
Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  return DiagnoseImpCast(S, E, T, CC,
+ diag::warn_impcast_integer_precision);
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);


Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'float'}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'float'}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'float'}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'double'}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'double'}}
+double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion loses integer precision: 'unsigned long long' to 'double'}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses integer precision: 'unsigned int' to 'float2' (vector of 2 'float' values)}}
   vf = vf + 2.1; // expected-warning {{implicit 

[PATCH] D52838: [COFF, ARM64] Add __getReg intrinsic

2018-10-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
mgrang added reviewers: rnk, mstorsjo, compnerd, TomTan, haripul.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

Repository:
  rC Clang

https://reviews.llvm.org/D52838

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/arm64-microsoft-intrinsics.c

Index: test/CodeGen/arm64-microsoft-intrinsics.c
===
--- test/CodeGen/arm64-microsoft-intrinsics.c
+++ test/CodeGen/arm64-microsoft-intrinsics.c
@@ -66,3 +66,42 @@
 
 // CHECK-MSVC: fence syncscope("singlethread")
 // CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
+
+unsigned __int64 check_getReg() {
+  unsigned volatile __int64 reg;
+  reg = __getReg(0);
+  reg = __getReg(1);
+  reg = __getReg(2);
+  reg = __getReg(3);
+  reg = __getReg(4);
+  reg = __getReg(5);
+  reg = __getReg(6);
+  reg = __getReg(7);
+  reg = __getReg(8);
+  reg = __getReg(9);
+  reg = __getReg(10);
+  reg = __getReg(11);
+  reg = __getReg(12);
+  reg = __getReg(13);
+  reg = __getReg(14);
+  reg = __getReg(15);
+  reg = __getReg(16);
+  reg = __getReg(17);
+  reg = __getReg(18);
+  reg = __getReg(19);
+  reg = __getReg(20);
+  reg = __getReg(21);
+  reg = __getReg(22);
+  reg = __getReg(23);
+  reg = __getReg(24);
+  reg = __getReg(25);
+  reg = __getReg(26);
+  reg = __getReg(27);
+  reg = __getReg(28);
+  reg = __getReg(29);
+  reg = __getReg(30);
+  reg = __getReg(31);
+  return reg;
+}
+
+// CHECK-MSVC: llvm.read_register.i64
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -865,6 +865,13 @@
 #endif
 
 /**\
+|* MS AArch64 specific
+\**/
+#if defined(__aarch64__)
+unsigned __int64 __getReg(int);
+#endif
+
+/**\
 |* Privileged intrinsics
 \**/
 #if defined(__i386__) || defined(__x86_64__)
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -6582,6 +6582,30 @@
 return Builder.CreateCall(F, {StoreVal, StoreAddr}, "stxr");
   }
 
+  if (BuiltinID == AArch64::BI__getReg) {
+APSInt Value;
+if (!E->getArg(0)->EvaluateAsInt(Value, CGM.getContext()))
+  CGM.Error(E->getArg(0)->getBeginLoc(),
+"__getReg expects a constant input parameter");
+
+if (Value < 0 || Value > 31)
+  CGM.Error(E->getArg(0)->getBeginLoc(),
+"__getReg expects an input parameter between 0 and 31");
+
+LLVMContext &Context = CGM.getLLVMContext();
+SmallString<8> StrVal;
+Value.toString(StrVal);
+std::string Reg = "x" + std::string(StrVal.c_str());
+
+llvm::Metadata *Ops[] = {llvm::MDString::get(Context, Reg)};
+llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops);
+llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName);
+
+llvm::Value *F =
+CGM.getIntrinsic(llvm::Intrinsic::read_register, {Int64Ty});
+return Builder.CreateCall(F, Metadata);
+  }
+
   if (BuiltinID == AArch64::BI__builtin_arm_clrex) {
 Function *F = CGM.getIntrinsic(Intrinsic::aarch64_clrex);
 return Builder.CreateCall(F);
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -104,6 +104,7 @@
 TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
 TARGET_HEADER_BUILTIN(_ReadWriteBarrier, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(__getReg, "ULLii", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
 #undef BUILTIN
 #undef LANGBUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/Sema/ext_vector_casts.c:121
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point 
precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion loses 
floating-point precision: 'unsigned int' to 'float2' (vector of 2 'float' 
values)}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses 
floating-point precision}}

xbolva00 wrote:
> lebedev.ri wrote:
> > How is floating-point precision is being lost if the cast is from an 
> > integer?
> > I'm guessing you want to add a new diag with a more appropriate description.
> yeah :/ so maybe integer precision?
It's still rather a bit too vague i'd say.
It should describe what you actually checked.


https://reviews.llvm.org/D52835



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


[PATCH] D52838: [COFF, ARM64] Add __getReg intrinsic

2018-10-03 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

I have some questions about the behavior of getReg:

__getReg ultimately invokes AArch64TargetLowering::getRegisterByName in 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp. You can __getReg only those 
registers which appear in the switch-case inside that function. Even then the 
logic there checks if the requested register is reserved. If not, then it makes 
the reg = 0 which results in "Invalid register name" error.

I am not sure how this should be dealt with. Is it fine to add all regs (0-31) 
to the switch-case in getRegisterByName? And should the checks for 
isRegReserved be bypassed for COFF?


Repository:
  rC Clang

https://reviews.llvm.org/D52838



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


r343702 - [test] Use --sysroot instead of -B in print-multi-directory.c

2018-10-03 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Oct  3 11:24:05 2018
New Revision: 343702

URL: http://llvm.org/viewvc/llvm-project?rev=343702&view=rev
Log:
[test] Use --sysroot instead of -B in print-multi-directory.c

This avoids finding a similar matching GCC installation outside
of the test directory tree in the surrounding environment, which
would make the test fail. (This happened on Ubuntu 16.04.)

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

Modified:
cfe/trunk/test/Driver/print-multi-directory.c

Modified: cfe/trunk/test/Driver/print-multi-directory.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-multi-directory.c?rev=343702&r1=343701&r2=343702&view=diff
==
--- cfe/trunk/test/Driver/print-multi-directory.c (original)
+++ cfe/trunk/test/Driver/print-multi-directory.c Wed Oct  3 11:24:05 2018
@@ -1,6 +1,6 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86-MULTILIBS %s
 
@@ -9,7 +9,7 @@
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux -m64 \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86_64-MULTILIBS 
%s
 


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


[PATCH] D52533: [test] Use --sysroot instead of -B in print-multi-directory.c

2018-10-03 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343702: [test] Use --sysroot instead of -B in 
print-multi-directory.c (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52533?vs=167066&id=168143#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52533

Files:
  test/Driver/print-multi-directory.c


Index: test/Driver/print-multi-directory.c
===
--- test/Driver/print-multi-directory.c
+++ test/Driver/print-multi-directory.c
@@ -1,15 +1,15 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86-MULTILIBS %s
 
 // CHECK-X86-MULTILIBS:  32
 // CHECK-X86-MULTILIBS-NOT:  {{^.+$}}
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux -m64 \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86_64-MULTILIBS 
%s
 


Index: test/Driver/print-multi-directory.c
===
--- test/Driver/print-multi-directory.c
+++ test/Driver/print-multi-directory.c
@@ -1,15 +1,15 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86-MULTILIBS %s
 
 // CHECK-X86-MULTILIBS:  32
 // CHECK-X86-MULTILIBS-NOT:  {{^.+$}}
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>/dev/null \
 // RUN: -target i386-none-linux -m64 \
-// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN: -print-multi-directory \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86_64-MULTILIBS %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r343703 - [clang-doc] Avoid parsing undefined base classes

2018-10-03 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Oct  3 11:25:27 2018
New Revision: 343703

URL: http://llvm.org/viewvc/llvm-project?rev=343703&view=rev
Log:
[clang-doc] Avoid parsing undefined base classes

Don't try to parse base classes for declarations that are not
definitions (segfaults, as there is no DefinitionData to access).

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

Modified:
clang-tools-extra/trunk/clang-doc/Serialize.cpp
clang-tools-extra/trunk/test/clang-doc/bc-record.cpp
clang-tools-extra/trunk/test/clang-doc/mapper-record.cpp
clang-tools-extra/trunk/test/clang-doc/md-record.cpp
clang-tools-extra/trunk/test/clang-doc/public-record.cpp
clang-tools-extra/trunk/test/clang-doc/test_cases/record.cpp
clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp

Modified: clang-tools-extra/trunk/clang-doc/Serialize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Serialize.cpp?rev=343703&r1=343702&r2=343703&view=diff
==
--- clang-tools-extra/trunk/clang-doc/Serialize.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Serialize.cpp Wed Oct  3 11:25:27 2018
@@ -244,6 +244,9 @@ static void parseParameters(FunctionInfo
 }
 
 static void parseBases(RecordInfo &I, const CXXRecordDecl *D) {
+  // Don't parse bases if this isn't a definition.
+  if (!D->isThisDeclarationADefinition())
+return;
   for (const CXXBaseSpecifier &B : D->bases()) {
 if (B.isVirtual())
   continue;

Modified: clang-tools-extra/trunk/test/clang-doc/bc-record.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/bc-record.cpp?rev=343703&r1=343702&r2=343703&view=diff
==
--- clang-tools-extra/trunk/test/clang-doc/bc-record.cpp (original)
+++ clang-tools-extra/trunk/test/clang-doc/bc-record.cpp Wed Oct  3 11:25:27 
2018
@@ -39,6 +39,8 @@ class X {
   class Y {};
 };
 
+class G;
+
 // RUN: clang-doc --dump-intermediate --doxygen --extra-arg=-fmodules-ts -p %t 
%t/test.cpp -output=%t/docs
 
 
@@ -158,118 +160,130 @@ class X {
 // CHECK-2-NEXT:   
 // CHECK-2-NEXT: 
 
-// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/641AB4A3D36399954ACDE29C7A8833032BF40472.bc | FileCheck %s 
--check-prefix CHECK-3
+// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/4202E8BF0ECB12AE354C8499C52725B0EE30AED5.bc | FileCheck %s 
--check-prefix CHECK-3
 // CHECK-3: 
 // CHECK-3-NEXT: 
 // CHECK-3-NEXT:   
 // CHECK-3-NEXT: 
-// CHECK-3-NEXT: 
+// CHECK-3-NEXT: 
 // CHECK-3-NEXT:   
-// CHECK-3-NEXT:blob data = 'Y'
-// CHECK-3-NEXT:   
-// CHECK-3-NEXT: 
-// CHECK-3-NEXT:  blob data = 'X'
-// CHECK-3-NEXT: 
-// CHECK-3-NEXT: 
-// CHECK-3-NEXT:   
-// CHECK-3-NEXT:blob data = '{{.*}}'
+// CHECK-3-NEXT:blob data = 'G'
+// CHECK-3-NEXT:blob data = '{{.*}}'
 // CHECK-3-NEXT:   
 // CHECK-3-NEXT: 
 
-// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/.bc | FileCheck %s 
--check-prefix CHECK-4
+// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/641AB4A3D36399954ACDE29C7A8833032BF40472.bc | FileCheck %s 
--check-prefix CHECK-4
 // CHECK-4: 
 // CHECK-4-NEXT: 
 // CHECK-4-NEXT:   
 // CHECK-4-NEXT: 
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:  blob data = 'H'
-// CHECK-4-NEXT:  blob data = 
'{{.*}}'
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT:  blob data = 'void'
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT:   
+// CHECK-4-NEXT: 
+// CHECK-4-NEXT:   
+// CHECK-4-NEXT:blob data = 'Y'
+// CHECK-4-NEXT:   
 // CHECK-4-NEXT: 
-// CHECK-4-NEXT:  blob data = 'B'
-// CHECK-4-NEXT:  blob data = 
'{{.*}}'
-// CHECK-4-NEXT:  blob data = 'X'
-// CHECK-4-NEXT:  blob data = 'Y'
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:  blob data = 'Bc'
-// CHECK-4-NEXT:  blob data = 
'{{.*}}'
-// CHECK-4-NEXT: 
-// CHECK-4-NEXT:  blob data = 'A'
-// CHECK-4-NEXT:  blob data = 'B'
-// CHECK-4-NEXT:   
-// CHECK-4-NEXT: 
+// CHECK-4-NEXT:  blob data = 'X'
+// CHECK-4-NEXT: 
+// CHECK-4-NEXT: 
+// CHECK-4-NEXT:   
+// CHECK-4-NEXT:blob data = '{{.*}}'
+// CHECK-4-NEXT:   
+// CHECK-4-NEXT: 
 
-// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/0921737541208B8FA9BB42B60F78AC1D779AA054.bc | FileCheck %s 
--check-prefix CHECK-5
+// RUN: llvm-bcanalyzer --dump 
%t/docs/bc/.bc | FileCheck %s 
--check-prefix CHECK-5
 // CHECK-5: 
 // CHECK-5-NEXT: 
 // CHECK-5-NEXT:   
 // CHECK-5-NEXT: 
-// CHECK-5-NEXT: 
-// CHECK-5-NEXT:   
-// CHECK-5-NEXT:blob data = 'D'
-// CHECK-5-NEXT:blob data = '{{.*}}'
-// CHECK-5-NEXT:   
-// CHECK-5-NEXT: 
+// CHECK-5-NEXT: 
+// CHECK-5-NEXT:   
+// CHECK-5-NEXT: 
+// CHECK-5-NEXT:  blob data = 'H'
+// CHECK-

[PATCH] D52313: [clang-doc] Avoid parsing undefined base classes

2018-10-03 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343703: [clang-doc] Avoid parsing undefined base classes 
(authored by juliehockett, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52313?vs=166526&id=168144#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52313

Files:
  clang-tools-extra/trunk/clang-doc/Serialize.cpp
  clang-tools-extra/trunk/test/clang-doc/bc-record.cpp
  clang-tools-extra/trunk/test/clang-doc/mapper-record.cpp
  clang-tools-extra/trunk/test/clang-doc/md-record.cpp
  clang-tools-extra/trunk/test/clang-doc/public-record.cpp
  clang-tools-extra/trunk/test/clang-doc/test_cases/record.cpp
  clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp

Index: clang-tools-extra/trunk/clang-doc/Serialize.cpp
===
--- clang-tools-extra/trunk/clang-doc/Serialize.cpp
+++ clang-tools-extra/trunk/clang-doc/Serialize.cpp
@@ -244,6 +244,9 @@
 }
 
 static void parseBases(RecordInfo &I, const CXXRecordDecl *D) {
+  // Don't parse bases if this isn't a definition.
+  if (!D->isThisDeclarationADefinition())
+return;
   for (const CXXBaseSpecifier &B : D->bases()) {
 if (B.isVirtual())
   continue;
Index: clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp
===
--- clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp
+++ clang-tools-extra/trunk/test/clang-doc/yaml-record.cpp
@@ -39,6 +39,8 @@
   class Y {};
 };
 
+class G;
+
 // RUN: clang-doc --format=yaml --doxygen --extra-arg=-fmodules-ts -p %t %t/test.cpp -output=%t/docs
 
 
@@ -90,133 +92,143 @@
 // CHECK-2-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-2-NEXT: ...
 
-// RUN: cat %t/docs/./E.yaml | FileCheck %s --check-prefix CHECK-3
+// RUN: cat %t/docs/./G.yaml | FileCheck %s --check-prefix CHECK-3
 // CHECK-3: ---
 // CHECK-3-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-3-NEXT: Name:'E'
-// CHECK-3-NEXT: DefLocation: 
-// CHECK-3-NEXT:   LineNumber:  25
-// CHECK-3-NEXT:   Filename:'test'
+// CHECK-3-NEXT: Name:'G'
+// CHECK-3-NEXT: Location:
+// CHECK-3-NEXT:   - LineNumber:  42
+// CHECK-3-NEXT: Filename:'test'
 // CHECK-3-NEXT: TagType: Class
-// CHECK-3-NEXT: ChildFunctions:  
-// CHECK-3-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-3-NEXT: Name:'E'
-// CHECK-3-NEXT: Namespace:   
-// CHECK-3-NEXT:   - Type:Record
-// CHECK-3-NEXT: Name:'E'
-// CHECK-3-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-3-NEXT: DefLocation: 
-// CHECK-3-NEXT:   LineNumber:  27
-// CHECK-3-NEXT:   Filename:'test'
-// CHECK-3-NEXT: IsMethod:true
-// CHECK-3-NEXT: Parent:  
-// CHECK-3-NEXT:   Type:Record
-// CHECK-3-NEXT:   Name:'E'
-// CHECK-3-NEXT:   USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-3-NEXT: ReturnType:  
-// CHECK-3-NEXT:   Type:
-// CHECK-3-NEXT: Name:'void'
-// CHECK-3-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-

[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Two main points: I don't think this check is covering all of the suffixes (I 
don't see `q` or `i32` support, for instance), and at least for the CERT rule 
this is covering, it diagnoses more than it should. The CERT rule is specific 
to `l` vs `L` but imposes no requirements on `u` vs `U`.




Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:88-89
 "readability-string-compare");
+CheckFactories.registerCheck(
+"readability-uppercase-literal-suffix");
 CheckFactories.registerCheck(

Please keep this sorted alphabetically.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:25
+
+struct IntegerLiteral {
+  using type = clang::IntegerLiteral;

It's unfortunate that clang::IntegerLiteral and 
clang::tidy::readability::IntegerLiteral are distinct types that are strongly 
related to one another. I'm not keen on this name, as it means reading the 
code, an unqualified IntegerLiteral is hard to reason about.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:30-31
+  static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral("");
+  // Integer suffix can only consist of 'u' and 'l' chars.
+  static constexpr llvm::StringLiteral Suffixes = llvm::StringLiteral("uUlL");
+};

There are other suffixes for integer literals. See `NumericLiteralParser`.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:37
+
+struct FloatingLiteral {
+  using type = clang::FloatingLiteral;

Same naming concerns here.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:47-48
+  static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral("pP");
+  // Floating suffix can only consist of 'u' and 'l' chars.
+  static constexpr llvm::StringLiteral Suffixes = llvm::StringLiteral("fFlL");
+};

There are more suffixes here (see `NumericLiteralParser` again), and this 
comment seems to be copy pasta.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:99-100
+ const SourceManager &SM) {
+  auto Begin = GetMacroAwareLocation(Loc.getBegin(), SM);
+  auto End = GetMacroAwareLocation(Loc.getEnd(), SM);
+  if (!Begin || !End)

Don't use `auto` here.



Comment at: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp:122
+  // The literal may have macro expansion, we need the final expanded src 
range.
+  auto Range = GetMacroAwareSourceRange(ReplacementDsc.LiteralLocation, SM);
+  if (!Range)

Don't use `auto` here.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670



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


[PATCH] D52839: Inform AST's UnaryOperator of FENV_ACCESS

2018-10-03 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added a reviewer: rsmith.
Herald added a reviewer: javed.absar.
Herald added a subscriber: cfe-commits.

The UnaryOperator needs to know about #pragma FENV_ACCESS to eventually 
properly emit the constrained math intrinsics. This diff just gets the 
information about the pragma into that part of the AST.

The visible behavior of clang is unaffected and so this cannot yet be tested.


Repository:
  rC Clang

https://reviews.llvm.org/D52839

Files:
  include/clang/AST/Expr.h
  lib/AST/ASTImporter.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp

Index: lib/Sema/SemaPseudoObject.cpp
===
--- lib/Sema/SemaPseudoObject.cpp
+++ lib/Sema/SemaPseudoObject.cpp
@@ -133,7 +133,8 @@
  uop->getValueKind(),
  uop->getObjectKind(),
  uop->getOperatorLoc(),
- uop->canOverflow());
+ uop->canOverflow(),
+ FPOptions());
   }
 
   if (GenericSelectionExpr *gse = dyn_cast(e)) {
@@ -543,7 +544,7 @@
   !resultType->isDependentType()
   ? S.Context.getTypeSize(resultType) >=
 S.Context.getTypeSize(S.Context.IntTy)
-  : false);
+  : false, FPOptions());
   return complete(syntactic);
 }
 
@@ -1564,7 +1565,8 @@
   // Do nothing if the operand is dependent.
   if (op->isTypeDependent())
 return new (Context) UnaryOperator(op, opcode, Context.DependentTy,
-   VK_RValue, OK_Ordinary, opcLoc, false);
+   VK_RValue, OK_Ordinary, opcLoc, false,
+   FPOptions());
 
   assert(UnaryOperator::isIncrementDecrementOp(opcode));
   Expr *opaqueRef = op->IgnoreParens();
@@ -1650,7 +1652,8 @@
 Expr *op = stripOpaqueValuesFromPseudoObjectRef(*this, uop->getSubExpr());
 return new (Context) UnaryOperator(
 op, uop->getOpcode(), uop->getType(), uop->getValueKind(),
-uop->getObjectKind(), uop->getOperatorLoc(), uop->canOverflow());
+uop->getObjectKind(), uop->getOperatorLoc(), uop->canOverflow(),
+FPOptions());
   } else if (CompoundAssignOperator *cop
= dyn_cast(syntax)) {
 Expr *lhs = stripOpaqueValuesFromPseudoObjectRef(*this, cop->getLHS());
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -12146,7 +12146,8 @@
   if (Input->isTypeDependent()) {
 if (Fns.empty())
   return new (Context) UnaryOperator(Input, Opc, Context.DependentTy,
- VK_RValue, OK_Ordinary, OpLoc, false);
+ VK_RValue, OK_Ordinary, OpLoc, false,
+ FPFeatures);
 
 CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators
 UnresolvedLookupExpr *Fn
@@ -13671,7 +13672,8 @@
 
 return new (Context) UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
VK_RValue, OK_Ordinary,
-   UnOp->getOperatorLoc(), false);
+   UnOp->getOperatorLoc(), false,
+   FPFeatures);
   }
 }
 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
@@ -13682,7 +13684,8 @@
 return new (Context) UnaryOperator(SubExpr, UO_AddrOf,
  Context.getPointerType(SubExpr->getType()),
VK_RValue, OK_Ordinary,
-   UnOp->getOperatorLoc(), false);
+   UnOp->getOperatorLoc(), false,
+   FPFeatures);
   }
 
   // C++ [except.spec]p17:
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -4307,7 +4307,8 @@
 Expr *sub = stripARCUnbridgedCast(uo->getSubExpr());
 return new (Context)
 UnaryOperator(sub, UO_Extension, sub->getType(), sub->getValueKind(),
-  sub->getObjectKind(), uo->getOperatorLoc(), false);
+  sub->getObjectKind(), uo->getOperatorLoc(), false,
+  FPFeatures);
   } else if (GenericSelectionExpr *gse = dyn_cast(e)) {
 assert(!gse->isResultDependent());
 
Index: lib/Sema/SemaE

[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: jbcoe, arphaman, frutiger.

Add a new CMake rule check-clang-python to run the Python bindings'
test suite, and include it in check-all.


Repository:
  rC Clang

https://reviews.llvm.org/D52840

Files:
  CMakeLists.txt
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Test target to run Python test suite from main build.
+
+add_custom_target(check-clang-python
+   COMMAND CLANG_LIBRARY_PATH=$ 
${PYTHON_EXECUTABLE} -m unittest discover
+   DEPENDS libclang
+   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
+add_dependencies(check-all check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -502,6 +502,7 @@
   )
   endif()
   add_subdirectory(utils/perf-training)
+  add_subdirectory(bindings/python/tests)
 endif()
 
 option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Test target to run Python test suite from main build.
+
+add_custom_target(check-clang-python
+	COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover
+	DEPENDS libclang
+	WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
+add_dependencies(check-all check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -502,6 +502,7 @@
   )
   endif()
   add_subdirectory(utils/perf-training)
+  add_subdirectory(bindings/python/tests)
 endif()
 
 option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343707 - Add template type and value parameter metadata nodes to template variable specializations

2018-10-03 Thread Matthew Voss via cfe-commits
Author: ormris
Date: Wed Oct  3 11:45:04 2018
New Revision: 343707

URL: http://llvm.org/viewvc/llvm-project?rev=343707&view=rev
Log:
Add template type and value parameter metadata nodes to template variable 
specializations

Summary: Add an optional attribute referring to a tuple of type and value 
template parameter nodes to the DIGlobalVariable node. This allows us to record 
the parameters of template variable specializations.

Reviewers: dblaikie, aprantl, probinson, JDevlieghere, clayborg, jingham

Reviewed By: JDevlieghere

Subscribers: cfe-commits

Tags: #debug-info

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=343707&r1=343706&r2=343707&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Oct  3 11:45:04 2018
@@ -41,6 +41,7 @@
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
@@ -1776,6 +1777,29 @@ CGDebugInfo::CollectFunctionTemplatePara
   return llvm::DINodeArray();
 }
 
+llvm::DINodeArray CGDebugInfo::CollectVarTemplateParams(const VarDecl *VL,
+llvm::DIFile *Unit) {
+  if (auto *TS = dyn_cast(VL)) {
+auto T = TS->getSpecializedTemplateOrPartial();
+auto TA = TS->getTemplateArgs().asArray();
+// Collect parameters for a partial specialization
+if (T.is()) {
+  const TemplateParameterList *TList =
+T.get()
+->getTemplateParameters();
+  return CollectTemplateParams(TList, TA, Unit);
+}
+
+// Collect parameters for an explicit specialization
+if (T.is()) {
+  const TemplateParameterList *TList = T.get()
+->getTemplateParameters();
+  return CollectTemplateParams(TList, TA, Unit);
+}
+  }
+  return llvm::DINodeArray();
+}
+
 llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(
 const ClassTemplateSpecializationDecl *TSpecial, llvm::DIFile *Unit) {
   // Always get the full list of parameters, not just the ones from
@@ -3070,6 +3094,7 @@ void CGDebugInfo::collectFunctionDeclPro
 void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
   unsigned &LineNo, QualType &T,
   StringRef &Name, StringRef &LinkageName,
+  llvm::MDTuple *&TemplateParameters,
   llvm::DIScope *&VDContext) {
   Unit = getOrCreateFile(VD->getLocation());
   LineNo = getLineNumber(VD->getLocation());
@@ -3093,6 +3118,13 @@ void CGDebugInfo::collectVarDeclProps(co
   if (LinkageName == Name)
 LinkageName = StringRef();
 
+  if (isa(VD)) {
+llvm::DINodeArray parameterNodes = CollectVarTemplateParams(VD, &*Unit);
+TemplateParameters = parameterNodes.get();
+  } else {
+TemplateParameters = nullptr;
+  }
+
   // Since we emit declarations (DW_AT_members) for static members, place the
   // definition of those static members in the namespace they were declared in
   // in the source code (the lexical decl context).
@@ -3173,12 +3205,14 @@ CGDebugInfo::getGlobalVariableForwardDec
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   llvm::DIScope *DContext = Unit;
   unsigned Line = getLineNumber(Loc);
+  llvm::MDTuple *TemplateParameters = nullptr;
 
-  collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, DContext);
+  collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, TemplateParameters,
+  DContext);
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, TemplateParameters, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -4089,7 +4123,9 @@ void CGDebugInfo::EmitGlobalVariable(llv
   unsigned LineNo;
   StringRef DeclName, LinkageName;
   QualType T;
-  collectVarDeclProps(D, Unit, LineNo, T, DeclName, LinkageName, DContext);
+  llvm::MDTuple *TemplateParameters = nullptr;
+  collectVarDeclProps(D, Unit, LineNo, T, DeclName, LinkageName,
+  TemplateParameters, DContext);
 
   // Attempt to store one global variable for the declaration - even if we
   // emit a lot of fields.
@@ -4115,7 +4151,8 @@ void CGDebugInfo::EmitGlobalVariable(llv
 DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, 

[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 168150.
xbolva00 added a comment.

- better warning


https://reviews.llvm.org/D52835

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/ext_vector_casts.c
  test/Sema/impcast-integer-float.c

Index: test/Sema/impcast-integer-float.c
===
--- test/Sema/impcast-integer-float.c
+++ test/Sema/impcast-integer-float.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only
+
+#define shift_plus_one(x) ((1ULL << x) + 1)
+
+void test(void) {
+float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.147484E+9}}
+float a2 = 1ULL << 31;
+float a3 = shift_plus_one(31); // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.147484E+9}}
+float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483647 to 2.147483E+9}}
+
+double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}}
+double b2 = 1ULL << 63;
+double b3 = shift_plus_one(63); // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}}
+double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775807 to 9.223372036854775E+18}}
+}
Index: test/Sema/ext_vector_casts.c
===
--- test/Sema/ext_vector_casts.c
+++ test/Sema/ext_vector_casts.c
@@ -118,7 +118,7 @@
   vf = l + vf;
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4.294967E+9}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
   vd = l + vd;
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -105,6 +105,12 @@
Context.getTargetInfo());
 }
 
+/// Force the precision of the source value down so we don't print digits which
+/// are usually useless
+static unsigned AdjustPrecision(unsigned precision) {
+  return (precision * 59 + 195) / 196;
+}
+
 /// Checks that a call expression's argument count is the desired number.
 /// This is useful when doing custom type-checking.  Returns true on error.
 static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount) {
@@ -10418,7 +10424,7 @@
   // tricky to implement.
   SmallString<16> PrettySourceValue;
   unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
-  precision = (precision * 59 + 195) / 196;
+  precision = AdjustPrecision(precision);
   Value.toString(PrettySourceValue, precision);
 
   SmallString<16> PrettyTargetValue;
@@ -10852,6 +10858,42 @@
 return;
   }
 
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {
+  FloatSem = &llvm::APFloat::IEEEsingle();
+} else if (Target->isSpecificBuiltinType(BuiltinType::Double)) {
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+
+if (FloatSem) {
+  llvm::APFloat FloatValue(*FloatSem);
+  llvm::APSInt IntValue;
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;
+
+if (FloatValue.convertFromAPInt(IntValue, Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {
+  SmallString<16> PrettyTargetValue;
+  SmallString<16> PrettySourceValue;
+  unsigned precision = llvm::APFloat::semanticsPrecision(*FloatSem);
+  precision = AdjustPrecision(precision);
+  FloatValue.toString(PrettyTargetValue, precision);
+  IntValue.toString(PrettySourceValue);
+
+  S.DiagRuntimeBehavior(
+  E->getExprLoc(), E,
+  S.PDiag(diag::warn_impcast_literal_float_to_integer)
+  << E->getType() << T << PrettySourceValue << PrettyTargetValue
+  << E->getSourceRange() << clang::SourceRange(CC));
+  return;
+}
+  }
+}
+  }
+
   DiagnoseNullConversion(S, E, T, CC);
 
   S.DiscardMisalignedMemberAddress(Target, E);
___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D52058: Add template type and value parameter metadata nodes to template variable specializations

2018-10-03 Thread Matthew Voss via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343707: Add template type and value parameter metadata nodes 
to template variable… (authored by ormris, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52058?vs=167849&id=168152#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52058

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-template-member.cpp

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -248,6 +248,11 @@
   llvm::DINodeArray CollectFunctionTemplateParams(const FunctionDecl *FD,
   llvm::DIFile *Unit);
 
+  /// A helper function to collect debug info for function template
+  /// parameters.
+  llvm::DINodeArray CollectVarTemplateParams(const VarDecl *VD,
+ llvm::DIFile *Unit);
+
   /// A helper function to collect debug info for template
   /// parameters.
   llvm::DINodeArray
@@ -645,7 +650,9 @@
   /// Collect various properties of a VarDecl.
   void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
unsigned &LineNo, QualType &T, StringRef &Name,
-   StringRef &LinkageName, llvm::DIScope *&VDContext);
+   StringRef &LinkageName,
+   llvm::MDTuple *&TemplateParameters,
+   llvm::DIScope *&VDContext);
 
   /// Allocate a copy of \p A using the DebugInfoNames allocator
   /// and return a reference to it. If multiple arguments are given the strings
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -41,6 +41,7 @@
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
@@ -1776,6 +1777,29 @@
   return llvm::DINodeArray();
 }
 
+llvm::DINodeArray CGDebugInfo::CollectVarTemplateParams(const VarDecl *VL,
+llvm::DIFile *Unit) {
+  if (auto *TS = dyn_cast(VL)) {
+auto T = TS->getSpecializedTemplateOrPartial();
+auto TA = TS->getTemplateArgs().asArray();
+// Collect parameters for a partial specialization
+if (T.is()) {
+  const TemplateParameterList *TList =
+T.get()
+->getTemplateParameters();
+  return CollectTemplateParams(TList, TA, Unit);
+}
+
+// Collect parameters for an explicit specialization
+if (T.is()) {
+  const TemplateParameterList *TList = T.get()
+->getTemplateParameters();
+  return CollectTemplateParams(TList, TA, Unit);
+}
+  }
+  return llvm::DINodeArray();
+}
+
 llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(
 const ClassTemplateSpecializationDecl *TSpecial, llvm::DIFile *Unit) {
   // Always get the full list of parameters, not just the ones from
@@ -3070,6 +3094,7 @@
 void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
   unsigned &LineNo, QualType &T,
   StringRef &Name, StringRef &LinkageName,
+  llvm::MDTuple *&TemplateParameters,
   llvm::DIScope *&VDContext) {
   Unit = getOrCreateFile(VD->getLocation());
   LineNo = getLineNumber(VD->getLocation());
@@ -3093,6 +3118,13 @@
   if (LinkageName == Name)
 LinkageName = StringRef();
 
+  if (isa(VD)) {
+llvm::DINodeArray parameterNodes = CollectVarTemplateParams(VD, &*Unit);
+TemplateParameters = parameterNodes.get();
+  } else {
+TemplateParameters = nullptr;
+  }
+
   // Since we emit declarations (DW_AT_members) for static members, place the
   // definition of those static members in the namespace they were declared in
   // in the source code (the lexical decl context).
@@ -3173,12 +3205,14 @@
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   llvm::DIScope *DContext = Unit;
   unsigned Line = getLineNumber(Loc);
+  llvm::MDTuple *TemplateParameters = nullptr;
 
-  collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, DContext);
+  collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, TemplateParameters,
+  DContext);
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, TemplateParameters, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -4089,7 +4123,9 @@
   unsigned LineNo;
 

[PATCH] D52281: [clang-tidy] Add modernize check to use std::invoke in generic code

2018-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:32
+  //   ::std::invoke(func, 1)
+  Finder->addMatcher(callExpr(has(declRefExpr())).bind("functor"), this);
+

I don't think this will work for calls wrapped in parens or with spurious 
dereferences.
```
void f(int) {}

int main() {
  void (*fp)(int) = f;

  fp(12);
  (fp)(12);
  (*fp)(12);
}
```
It seems like all of those can be replaced by `std::invoke()` directly.



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:97
+ Functor->getSourceRange(),
+ (Twine("::std::invoke(") + Param +
+  (Functor->getNumArgs() == 0 ? "" : ", ") + OriginalParams)

You might be able to get rid of the explicit `Twine` construction here now that 
`Param` is a `Twine`. I could be remembering wrong though.


https://reviews.llvm.org/D52281



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


[PATCH] D52807: [COFF, ARM64] Add _InterlockedCompareExchangePointer_nf intrinsic

2018-10-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3003
+  case Builtin::BI_InterlockedCompareExchangePointer:
+  case Builtin::BI_InterlockedCompareExchangePointer_nf: {
 llvm::Type *RTy;

mgrang wrote:
> rnk wrote:
> > Is the no fence version really equivalent to this seq_cst version here?
> I don't see InterlockedCompareExchangePointer creating a fence but it should. 
> (since it is the fence version). So maybe that needs to be fixed (and 
> possibly other fence functions).
> 
> InterlockedCompareExchangePointer_nf should not create a fence so the current 
> implementation seems correct.
"create a fence" is a little confusing because the AArch64 ldaxr/stlxr have 
builtin fences... but presumably the "nf" version should use ldxr/stxr instead. 
 At the IR level, that corresponds to "monotonic".


Repository:
  rC Clang

https://reviews.llvm.org/D52807



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


[PATCH] D52839: Inform AST's UnaryOperator of FENV_ACCESS

2018-10-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Maybe take this very slightly further so it becomes testable: change the 
expression evaluator (lib/AST/ExprConstant.cpp) so it treats floating-point 
operations as non-constant if they're potentially-overflowing.

You also need to update lib/Serialization/AST{Reader,Writer}Stmt.cpp to 
round-trip this information through AST files.

How do you intend for this to work in template instantiation? Do we record the 
pragmas in the AST (and likewise for the state on entry to each function) so 
that we can rebuild the `FPOptions` during instantiation, or should we be 
inheriting the `FPOptions` from the expression in the template onto the 
expression in the instantiation? In the latter case, it would make more sense 
to me to track `FPOptions` on the `Scope` rather than as a `Sema` member, so 
that the state is more-obviously unavailable during template instantiation.




Comment at: include/clang/AST/Expr.h:1794-1796
+  // This is only meaningful for operations on floating point types and 0
+  // otherwise.
+  unsigned FPFeatures : 3;

Move this adjacent to the other bitfields so we don't spend 32 / 64 bits on it.


Repository:
  rC Clang

https://reviews.llvm.org/D52839



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:110
+/// are usually useless
+static unsigned AdjustPrecision(unsigned precision) {
+  return (precision * 59 + 195) / 196;

Hmm I don't terribly understand how this function works.  Also, comment 
above needs to end in a period.  

Can you elaborate further as to how this works?  Those are 3 pretty suspect 
looking magic numbers...



Comment at: lib/Sema/SemaChecking.cpp:10862
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {

Since there is only 1, and fltSemantics is really small (2 shorts + 2 uints), 
making this a 'by copy' is likely a better solution than a pointer.



Comment at: lib/Sema/SemaChecking.cpp:10867
+  FloatSem = &llvm::APFloat::IEEEdouble();
+}
+

This else case ends up needing to be handled above, but why not also handle the 
other floating types?  



Comment at: lib/Sema/SemaChecking.cpp:10873
+  if (E->EvaluateAsInt(IntValue, S.Context, Expr::SE_AllowSideEffects)) {
+if (S.SourceMgr.isInSystemMacro(CC))
+  return;

It seems like this should be checked way before we convert it to an integer or 
do the other float-semantics disambiguation.



Comment at: lib/Sema/SemaChecking.cpp:10877
+if (FloatValue.convertFromAPInt(IntValue, 
Source->isSignedIntegerType(),
+llvm::APFloat::rmTowardZero) !=
+llvm::APFloat::opOK) {

Is this the rounding mode that we use?  Also, you might need to check this 
against some sort of current state for rounding mode.  I know that there is an 
effort to do FENV_ACCESS, which this might change, right?



Comment at: lib/Sema/SemaChecking.cpp:10883
+  precision = AdjustPrecision(precision);
+  FloatValue.toString(PrettyTargetValue, precision);
+  IntValue.toString(PrettySourceValue);

I wonder if this call (finding the precision, 'adjusting' it, then writing to a 
smallstring might be a better thing to pull into its own function rather than 
AdjustPrecision.


https://reviews.llvm.org/D52835



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


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-10-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Every Integer is representable (lossy of course) as a float as far as I know.

Casting a __uint128_t to float can overflow.  And overflowing a _Float16 is 
easy.  (Of course, both __uint128_t and _Float16 are rare in normal C/C++ code.)


Repository:
  rC Clang

https://reviews.llvm.org/D46535



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


[PATCH] D52695: [clang][Parse] Diagnose useless null statements (PR39111)

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 168157.
lebedev.ri marked 4 inline comments as done.
lebedev.ri added a comment.

After looking at stage-2 of LLVM, remove `-Wextra-semi-stmt` from `-Wextra`, 
and add `-Wempty-init-stmt` back into `-Wextra`.
Anything else?


Repository:
  rC Clang

https://reviews.llvm.org/D52695

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseStmt.cpp
  test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp
  test/Parser/extra-semi-resulting-in-nullstmt.cpp

Index: test/Parser/extra-semi-resulting-in-nullstmt.cpp
===
--- /dev/null
+++ test/Parser/extra-semi-resulting-in-nullstmt.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -verify %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -fixit %t
+// RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -Werror %t
+
+#define GOODMACRO(varname) int varname
+#define BETTERMACRO(varname) GOODMACRO(varname);
+#define NULLMACRO(varname)
+
+enum MyEnum {
+  E1,
+  E2
+};
+
+void test() {
+  ; // expected-warning {{';' with no preceding expression is a null statement}}
+  ; // expected-warning {{';' with no preceding expression is a null statement}}
+
+  // clang-format: off
+  ;; // expected-warning 2 {{';' with no preceding expression is a null statement}}
+  // clang-format: on
+
+  {}; // expected-warning {{';' with no preceding expression is a null statement}}
+
+  {
+; // expected-warning {{';' with no preceding expression is a null statement}}
+  }
+
+  if (true) {
+; // expected-warning {{';' with no preceding expression is a null statement}}
+  }
+
+  GOODMACRO(v0); // OK
+
+  GOODMACRO(v1;) // OK
+
+  BETTERMACRO(v2) // OK
+
+  BETTERMACRO(v3;) // Extra ';', but within macro expansion, so ignored.
+
+  BETTERMACRO(v4); // expected-warning {{';' with no preceding expression is a null statement}}
+
+  BETTERMACRO(v5;); // expected-warning {{';' with no preceding expression is a null statement}}
+
+  NULLMACRO(v6) // OK
+
+  NULLMACRO(v7); // OK. This could be either GOODMACRO() or BETTERMACRO() situation, so we can't know we can drop it.
+
+  if (true)
+; // OK
+
+  while (true)
+; // OK
+
+  do
+; // OK
+  while (true);
+
+  for (;;) // OK
+;  // OK
+
+  MyEnum my_enum;
+  switch (my_enum) {
+  case E1:
+// stuff
+break;
+  case E2:; // OK
+  }
+
+  for (;;) {
+for (;;) {
+  goto contin_outer;
+}
+  contin_outer:; // OK
+  }
+}
Index: test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp
===
--- /dev/null
+++ test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -Wextra -std=c++2a -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -std=c++2a -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wempty-init-stmt -std=c++2a -verify %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -fixit %t
+// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -Werror %t
+
+struct S {
+  int *begin();
+  int *end();
+};
+
+void naive(int x) {
+  if (; true) // expected-warning {{init-statement of 'if' is a null statement}}
+;
+
+  switch (; x) { // expected-warning {{init-statement of 'switch' is a null statement}}
+  }
+
+  for (; int y : S()) // expected-warning {{init-statement of 'range-based for' is a null statement}}
+;
+
+  for (;;) // OK
+;
+}
+
+#define NULLMACRO
+
+void with_null_macro(int x) {
+  if (NULLMACRO; true)
+;
+
+  switch (NULLMACRO; x) {
+  }
+
+  for (NULLMACRO; int y : S())
+;
+}
+
+#define SEMIMACRO ;
+
+void with_semi_macro(int x) {
+  if (SEMIMACRO true)
+;
+
+  switch (SEMIMACRO x) {
+  }
+
+  for (SEMIMACRO int y : S())
+;
+}
+
+#define PASSTHROUGHMACRO(x) x
+
+void with_passthrough_macro(int x) {
+  if (PASSTHROUGHMACRO(;) true)
+;
+
+  switch (PASSTHROUGHMACRO(;) x) {
+  }
+
+  for (PASSTHROUGHMACRO(;) int y : S())
+;
+}
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -992,6 +992,15 @@
   continue;
 }
 
+if (Tok.is(tok::semi)) {
+  bool HasLeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
+  SourceLocation SemiLocation = Tok.getLocation();
+  if (!HasLeadingEmptyMacro && !SemiLocation.isMacroID()) {
+Diag(SemiLocation, diag::warn_null_statement)
+<< FixItHint::CreateRemoval(SemiLocation);
+  }
+}
+
 StmtResult R;
 if (Tok.isNot(tok::kw___extension__)) {
   R = ParseStatementOrDeclaration(Stmts, ACK_Any);
@@ -1588,10 +1597,15 @@
   ParsedAttributesWithRange attrs(AttrFactory);
   MaybeParseCXX11Attributes(attrs);
 
+  SourceLocation EmptyInitStmtSemiLoc;
+
   // Parse the first part

[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Steve Canon via Phabricator via cfe-commits
scanon added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:110
+/// are usually useless
+static unsigned AdjustPrecision(unsigned precision) {
+  return (precision * 59 + 195) / 196;

erichkeane wrote:
> Hmm I don't terribly understand how this function works.  Also, comment 
> above needs to end in a period.  
> 
> Can you elaborate further as to how this works?  Those are 3 pretty suspect 
> looking magic numbers...
It's attempting to compute the number of good base-10 digits (59/196 ~= 
log2(10)). We should really just make APFloat print the shortest 
round-trippable digit sequence instead. Yes, this is tricky to implement, but 
we don't need to implement it. There are two recent high-quality 
implementations available, which are both significantly faster than previous 
algorithms: Ryu and Swift's 
(https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftDtoa.cpp).
 Swift's has the virtue of already being used in LLVM-family languages and 
having a tidy single-file implementation, but either would be perfectly usable, 
I think.

Neither supports float128 yet, but we could simply drop them in for float, 
double, and float80.


https://reviews.llvm.org/D52835



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


[PATCH] D52842: clang-format: Don't insert spaces in front of :: for Java 8 Method References.

2018-10-03 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: djasper.

The existing code kept the space if it was there for identifiers, and it didn't 
handle `this`. After this patch, for java `this` is handled in addition to 
identifiers, and existing space is always stripped between identifier and `::`.


https://reviews.llvm.org/D52842

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJava.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2774,6 +2774,9 @@
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
+  if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
+  (Left.is(tok::identifier) || Left.is(tok::kw_this)))
+return false;
   if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
 // Generally don't remove existing spaces between an identifier and "::".
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -443,6 +443,19 @@
getStyleWithColumns(40));
 }
 
+TEST_F(FormatTestJava, MethodReference) {
+  EXPECT_EQ("private void foo() {\n"
+"  f(this::methodReference);\n"
+"  f(C.super::methodReference);\n"
+"  Consumer c = System.out::println;\n"
+"}",
+format("private void foo() {\n"
+   "  f(this ::methodReference);\n"
+   "  f(C.super ::methodReference);\n"
+   "  Consumer c = System.out ::println;\n"
+   "}"));
+}
+
 TEST_F(FormatTestJava, CppKeywords) {
   verifyFormat("public void union(Type a, Type b);");
   verifyFormat("public void struct(Object o);");


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2774,6 +2774,9 @@
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
+  if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
+  (Left.is(tok::identifier) || Left.is(tok::kw_this)))
+return false;
   if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
 // Generally don't remove existing spaces between an identifier and "::".
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -443,6 +443,19 @@
getStyleWithColumns(40));
 }
 
+TEST_F(FormatTestJava, MethodReference) {
+  EXPECT_EQ("private void foo() {\n"
+"  f(this::methodReference);\n"
+"  f(C.super::methodReference);\n"
+"  Consumer c = System.out::println;\n"
+"}",
+format("private void foo() {\n"
+   "  f(this ::methodReference);\n"
+   "  f(C.super ::methodReference);\n"
+   "  Consumer c = System.out ::println;\n"
+   "}"));
+}
+
 TEST_F(FormatTestJava, CppKeywords) {
   verifyFormat("public void union(Type a, Type b);");
   verifyFormat("public void struct(Object o);");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52782: [clang-tidy] Sequence statements with multiple parents correctly (PR39149)

2018-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/utils/ExprSequence.cpp:103
   for (const Stmt *Parent : getParentStmts(S, Context)) {
+// For statements that have multiple parents, make sure we're using the
+// parent that lies within the sub-tree under Root.

JonasToth wrote:
> I find the first part of the comment unclear. Does this loop handle `for` 
> only?
I think this means English "for" and not C `for`. Could rewrite to `If a 
statement has multiple parents, ` instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52782



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


[PATCH] D52782: [clang-tidy] Sequence statements with multiple parents correctly (PR39149)

2018-10-03 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.

This seems reasonable to me.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52782



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


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/performance/ForRangeCopyCheck.h:43
   const bool WarnOnAllAutoCopies;
+  const std::vector WhiteListTypes;
 };

Nit: can you name it `AllowedTypes` rather than `WhiteListTypes`? Use similar 
nomenclature ("allow" instead of "white") elsewhere as well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52727



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


[PATCH] D52843: Update Clang Windows getting started docs

2018-10-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: zturner, STL_MSFT.
Herald added a subscriber: jfb.
rnk added a subscriber: aaron.ballman.

- Update the example VS project generation to use VS2017.
- Add docs for generating ninja build files, since they are popular.
- Remove reference to "make update" which no longer exists. Mention the 
monorepo instead.
- Try to explain gnuwin32/coreutils requirements better.


https://reviews.llvm.org/D52843

Files:
  clang/www/get_started.html

Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -127,23 +127,21 @@
   
 
 
-If you encounter problems while building Clang, make sure that your LLVM
-checkout is at the same revision as your Clang checkout. LLVM's interfaces
-change over time, and mismatched revisions are not expected to work
-together.
-
 Simultaneously Building Clang and LLVM:
 
 Once you have checked out Clang into the llvm source tree it will build along
 with the rest of llvm. To build all of LLVM and Clang together all at
 once simply run make from the root LLVM directory.
 
-Note: Observe that Clang is technically part of a separate
-Subversion repository. As mentioned above, the latest Clang sources are tied to
-the latest sources in the LLVM tree. You can update your toplevel LLVM project
-and all (possibly unrelated) projects inside it with make
-update. This will run svn update on all subdirectories related
-to subversion. 
+If you encounter problems while building Clang, make sure that your LLVM
+checkout is at the same revision as your Clang checkout. LLVM's interfaces
+change over time, and mismatched revisions are not expected to work
+together. We recommend writing a script to automatically run svn up in
+each repository to keep them synchronized. Alternatively, you may consider using
+the unofficial
+https://llvm.org/docs/GettingStarted.html#for-developers-to-work-with-a-git-monorepo";>git monorepo
+which automatically keeps everything in sync at the same revision and lets you
+commit changes atomically across multiple LLVM subprojects.
 
 Using Visual Studio
 
@@ -160,18 +158,18 @@
 project files.  Get it from:
 http://www.cmake.org/cmake/resources/software.html";>
 http://www.cmake.org/cmake/resources/software.html
-Visual Studio 2013 or later
-Python.  This is needed only if you will be running the tests
-(which is essential, if you will be developing for clang).
-Get it from:
+Visual Studio 2015 or later
+Python.  It is used to run the clang test suite. Get it from:
 http://www.python.org/download/";>
 http://www.python.org/download/
 GnuWin32 tools
-These are also necessary for running the tests.
-(Note that the grep from MSYS or Cygwin doesn't work with the tests
-because of embedded double-quotes in the search strings.  The GNU
-grep does work in this case.)
-Get them from http://getgnuwin32.sourceforge.net/";>
+The Clang and LLVM test suite use various GNU core utilities, such as
+grep, sed, and find. The gnuwin32 packages
+are the oldest and most well-tested way to get these tools. However, the
+MSys utilities provided by git for Windows have been known to work.
+Cygwin has worked in the past, but is not well tested.
+If you don't already have the core utilies from some other source, get
+gnuwin32 from http://getgnuwin32.sourceforge.net/";>
 http://getgnuwin32.sourceforge.net/.
   
   
@@ -195,11 +193,13 @@
 cd ..\..  (back to where you started)
 mkdir build (for building without polluting the source dir)
 cd build
-If you are using Visual Studio 2013:  cmake -G "Visual Studio 12" ..\llvm
-By default, the Visual Studio project files generated by CMake use the
- 32-bit toolset. If you are developing on a 64-bit version of Windows and
- want to use the 64-bit toolset, pass the ``-Thost=x64`` flag when
- generating the Visual Studio solution. This requires CMake 3.8.0 or later.
+If you are using Visual Studio 2017:
+  cmake -G "Visual Studio 15 2017 Win64" ..\llvm
+This will generate x64 binaries by default, which should perform better.
+  If you want 32-bit x86 binaries, you will need to use the x64-to-x86
+  compiler and linker, or the linker may run out of memory. Pass the
+  -Thost=x64 flag when generating the Visual Studio solution. This
+  requires CMake 3.8.0 or later.
 See the https://www.llvm.org/docs/CMake.html";>LLVM CMake guide for
 more information on other configuration options for CMake.
 The above, if successful, will have created an LLVM.sln file in the
@@ -224,6 +224,40 @@
 to the latest code base, use the svn update command in both the
 llvm and llvm\tools\clang directories, as they are separate repositories.
 
+Using Ninja alongside Visual Studio
+
+We 

[PATCH] D52842: clang-format: Don't insert spaces in front of :: for Java 8 Method References.

2018-10-03 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 168161.
thakis edited the summary of this revision.

https://reviews.llvm.org/D52842

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJava.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2553,8 +2553,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
   Left.MatchingParen->Previous &&
-  Left.MatchingParen->Previous->is(tok::period))
+  (Left.MatchingParen->Previous->is(tok::period) ||
+   Left.MatchingParen->Previous->is(tok::coloncolon)))
 // A.>>DoSomething();
+// A::>>DoSomething();
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
@@ -2774,6 +2776,9 @@
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
+  if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
+  (Left.is(tok::identifier) || Left.is(tok::kw_this)))
+return false;
   if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
 // Generally don't remove existing spaces between an identifier and "::".
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -443,6 +443,22 @@
getStyleWithColumns(40));
 }
 
+TEST_F(FormatTestJava, MethodReference) {
+  EXPECT_EQ(
+  "private void foo() {\n"
+  "  f(this::methodReference);\n"
+  "  f(C.super::methodReference);\n"
+  "  Consumer c = System.out::println;\n"
+  "  Iface mRef = Ty::meth;\n"
+  "}",
+  format("private void foo() {\n"
+ "  f(this ::methodReference);\n"
+ "  f(C.super ::methodReference);\n"
+ "  Consumer c = System.out ::println;\n"
+ "  Iface mRef = Ty ::  meth;\n"
+ "}"));
+}
+
 TEST_F(FormatTestJava, CppKeywords) {
   verifyFormat("public void union(Type a, Type b);");
   verifyFormat("public void struct(Object o);");


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2553,8 +2553,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
   Left.MatchingParen->Previous &&
-  Left.MatchingParen->Previous->is(tok::period))
+  (Left.MatchingParen->Previous->is(tok::period) ||
+   Left.MatchingParen->Previous->is(tok::coloncolon)))
 // A.>>DoSomething();
+// A::>>DoSomething();
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
@@ -2774,6 +2776,9 @@
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
+  if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
+  (Left.is(tok::identifier) || Left.is(tok::kw_this)))
+return false;
   if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
 // Generally don't remove existing spaces between an identifier and "::".
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -443,6 +443,22 @@
getStyleWithColumns(40));
 }
 
+TEST_F(FormatTestJava, MethodReference) {
+  EXPECT_EQ(
+  "private void foo() {\n"
+  "  f(this::methodReference);\n"
+  "  f(C.super::methodReference);\n"
+  "  Consumer c = System.out::println;\n"
+  "  Iface mRef = Ty::meth;\n"
+  "}",
+  format("private void foo() {\n"
+ "  f(this ::methodReference);\n"
+ "  f(C.super ::methodReference);\n"
+ "  Consumer c = System.out ::println;\n"
+ "  Iface mRef = Ty ::  meth;\n"
+ "}"));
+}
+
 TEST_F(FormatTestJava, CppKeywords) {
   verifyFormat("public void union(Type a, Type b);");
   verifyFormat("public void struct(Object o);");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343711 - [OPENMP] Add reverse_offload clause to requires directive

2018-10-03 Thread Patrick Lyster via cfe-commits
Author: plyster
Date: Wed Oct  3 13:07:58 2018
New Revision: 343711

URL: http://llvm.org/viewvc/llvm-project?rev=343711&view=rev
Log:
[OPENMP] Add reverse_offload clause to requires directive

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/requires_unified_address_ast_print.cpp
cfe/trunk/test/OpenMP/requires_unified_address_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=343711&r1=343710&r2=343711&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Oct  3 13:07:58 2018
@@ -796,6 +796,37 @@ public:
   }
 };
 
+/// This represents 'reverse_offload' clause in the '#pragma omp requires'
+/// directive.
+///
+/// \code
+/// #pragma omp requires reverse_offload
+/// \endcode
+/// In this example directive '#pragma omp requires' has 'reverse_offload'
+/// clause.
+class OMPReverseOffloadClause final : public OMPClause {
+public:
+  friend class OMPClauseReader;
+  /// Build 'reverse_offload' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_reverse_offload, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPReverseOffloadClause()
+  : OMPClause(OMPC_reverse_offload, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_reverse_offload;
+  }
+};
+
 /// This represents 'schedule' clause in the '#pragma omp ...' directive.
 ///
 /// \code

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=343711&r1=343710&r2=343711&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Oct  3 13:07:58 2018
@@ -2874,6 +2874,12 @@ bool RecursiveASTVisitor::Visit
 }
 
 template 
+bool RecursiveASTVisitor::VisitOMPReverseOffloadClause(
+OMPReverseOffloadClause *) {
+  return true;
+}
+
+template 
 bool
 RecursiveASTVisitor::VisitOMPScheduleClause(OMPScheduleClause *C) {
   TRY_TO(VisitOMPClauseWithPreInit(C));

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=343711&r1=343710&r2=343711&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Oct  3 13:07:58 2018
@@ -281,6 +281,7 @@ OPENMP_CLAUSE(task_reduction,  OMPTaskRe
 OPENMP_CLAUSE(in_reduction,  OMPInReductionClause)
 OPENMP_CLAUSE(unified_address, OMPUnifiedAddressClause)
 OPENMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause)
+OPENMP_CLAUSE(reverse_offload, OMPReverseOffloadClause)
 
 // Clauses allowed for OpenMP directive 'parallel'.
 OPENMP_PARALLEL_CLAUSE(if)
@@ -465,6 +466,7 @@ OPENMP_TARGET_CLAUSE(reduction)
 // Clauses allowed for OpenMP directive 'requires'.
 OPENMP_REQUIRES_CLAUSE(unified_address)
 OPENMP_REQUIRES_CLAUSE(unified_shared_memory)
+OPENMP_REQUIRES_CLAUSE(reverse_offload)
 
 // Clauses allowed for OpenMP directive 'target data'.
 OPENMP_TARGET_DATA_CLAUSE(if)

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=343711&r1=343710&r2=343711&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct  3 13:07:58 2018
@@ -9171,6 +9171,10 @@ public:
   /// Called on well-formed 'unified_address' clause.
   OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc,
   SourceLocation EndLoc);
+  
+  /// Called on well-formed 'reverse_offload' clause.
+  OMPClause *ActOnOpenMPRe

[PATCH] D52811: [COFF, ARM64] Add _InterlockedAdd intrinsic

2018-10-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

None of this seems to be ARM64 specific - if I read it correctly, this adds the 
_InterlockedAdd intrinsic for ARM and X64 as well. How come this hasn't been an 
issue for those targets up until now? Do those targets have any other code 
somewhere handling it, that might conflict after this patch?


Repository:
  rC Clang

https://reviews.llvm.org/D52811



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


[PATCH] D52811: [COFF, ARM64] Add _InterlockedAdd intrinsic

2018-10-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> How come this hasn't been an issue for those targets up until now?

MSVC doesn't define _InterlockedAdd for x64.


Repository:
  rC Clang

https://reviews.llvm.org/D52811



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


[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 168162.
lebedev.ri marked 5 inline comments as done.
lebedev.ri added a comment.

Address review notes - more tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
  clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
  docs/ReleaseNotes.rst
  
docs/clang-tidy/checks/cppcoreguidelines-non-private-member-variables-in-classes.rst
  docs/clang-tidy/checks/hicpp-non-private-member-variables-in-classes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
  test/clang-tidy/misc-non-private-member-variables-in-classes.cpp

Index: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
@@ -0,0 +1,387 @@
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffix=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
+// RUN: %check_clang_tidy -check-suffix=IGNOREPUBLICONLY %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+// RUN: %check_clang_tidy -check-suffix=IGNOREPUBLIC %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
+
+////
+
+// Only data, do not warn
+
+struct S0 {
+  int S0_v0;
+
+public:
+  int S0_v1;
+
+protected:
+  int S0_v2;
+
+private:
+  int S0_v3;
+};
+
+class S1 {
+  int S1_v0;
+
+public:
+  int S1_v1;
+
+protected:
+  int S1_v2;
+
+private:
+  int S1_v3;
+};
+
+////
+
+// All functions are static, do not warn.
+
+struct S2 {
+  static void S2_m0();
+  int S2_v0;
+
+public:
+  static void S2_m1();
+  int S2_v1;
+
+protected:
+  static void S2_m3();
+  int S2_v2;
+
+private:
+  static void S2_m4();
+  int S2_v3;
+};
+
+class S3 {
+  static void S3_m0();
+  int S3_v0;
+
+public:
+  static void S3_m1();
+  int S3_v1;
+
+protected:
+  static void S3_m3();
+  int S3_v2;
+
+private:
+  static void S3_m4();
+  int S3_v3;
+};
+
+////
+
+// Has non-static method with default visibility.
+
+struct S4 {
+  void S4_m0();
+
+  int S4_v0;
+  // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S4_v0' of struct 'S4' has public visibility
+  // CHECK-MESSAGES-IGNOREPUBLICONLY: :[[@LINE-2]]:7: warning: member variable 'S4_v0' of struct 'S4' has public visibility
+public:
+  int S4_v1;
+  // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S4_v1' of struct 'S4' has public visibility
+  // CHECK-MESSAGES-IGNOREPUBLICONLY: :[[@LINE-2]]:7: warning: member variable 'S4_v1' of struct 'S4' has public visibility
+protected:
+  int S4_v2;
+  // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S4_v2' of struct 'S4' has protected visibility
+  // CHECK-MESSAGES-PROTECTED: :[[@LINE-2]]:7: warning: member variable 'S4_v2' of struct 'S4' has protected visibility
+  // CHECK-MESSAGES-IGNOREPUBLICONLY: :[[@LINE-3]]:7: warning: member variable 'S4_v2' of struct 'S4' has protected visibility
+  // CHECK-MESSAGES-IGNOREPUBLIC: :[[@LINE-4]]:7: warning: member variable 'S4_v2' of struct 'S4' has protected visibility
+private:
+  int S4_v3;
+};
+
+class S5 {
+  void S5_m0();
+
+  int S5_v0;
+
+public:
+  int S5_v1;
+  // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S5_v1' of class 'S5' has public visibility
+  // CHECK-MESSAGES-IGNOREPUBLICONLY: :[[@LINE-2]]:7: warning: member variable 'S5_v1' of

[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp:26
+
+AST_MATCHER(clang::CXXRecordDecl, hasNonStaticMethod) {
+  return hasMethod(unless(isStaticStorageClass()))

JonasToth wrote:
> I think this and the next matcher can be a normal variable.
> 
> ```
> auto HasNonStaticMethod = hasMethod(unless(isStaticStorageClass()));
> 
> ...
> ... allOf(anyOf(isStruct(), isClass()), HasMethods, HasNonStaticMethod)
> ...
> ```
They could, but these have a very meaningful meaning, so i'd argue it would not 
be worse to keep them 
out here refactored as proper matchers, in case someone else needs them 
elsewhere (so he could just
move them from here into more general place, as opposed to writing a 
duplicating matcher.)



Comment at: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp:1
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s 
misc-non-private-member-variables-in-classes %t
+// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s 
misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: 
[{key: 
misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, 
value: 0}, {key: 
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic,
 value: 0}]}' --

JonasToth wrote:
> I would prefer multiple test-files instead of mixing them all together.
Hmm, no. Then the tests will have to be duplicated in N files,
because i really do want to see what each of these 4 configurations do on the 
*same* input.

It only looks ugly because the script only supports `-check-suffix=`,
and not `-check-suffixes=`, which would significantly cut down on check-lines.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771



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


[PATCH] D52838: [COFF, ARM64] Add __getReg intrinsic

2018-10-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added subscribers: efriedma, peter.smith.
mstorsjo added a comment.

In https://reviews.llvm.org/D52838#1253998, @mgrang wrote:

> I have some questions about the behavior of getReg:
>
> __getReg ultimately invokes getRegisterByName in 
> http://llvm.org/doxygen/AArch64ISelLowering_8cpp_source.html.
>
> You can __getReg only those registers which appear in the switch-case inside 
> that function. Even then the logic there checks if the requested register is 
> reserved. If not, then it makes the reg = 0 which results in "Invalid 
> register name" error.
>
> I am not sure how this should be dealt with. Is it fine to add all regs 
> (0-31) to the switch-case in getRegisterByName? And should the checks for 
> isRegReserved be bypassed for COFF?


I don't really know about this one, I'll add a few more people who might be 
able to comment on it. @efriedma @peter.smith


Repository:
  rC Clang

https://reviews.llvm.org/D52838



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


[PATCH] D52811: [COFF, ARM64] Add _InterlockedAdd intrinsic

2018-10-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D52811#1254162, @efriedma wrote:

> > How come this hasn't been an issue for those targets up until now?
>
> MSVC doesn't define _InterlockedAdd for x64.


Ok - but judging from the context here, this would make clang define it there - 
which probably isn't desired?


Repository:
  rC Clang

https://reviews.llvm.org/D52811



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


[PATCH] D52791: [Diagnostics] Check for misleading pointer declarations

2018-10-03 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

There's a false positive.

  int **A, *B; // false positive: declaring a variable of type 'int *'; did you 
mean to declare a pointer?

And IMO this should also warn:

  int **A, B; // no warning currently


https://reviews.llvm.org/D52791



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


[PATCH] D52800: Java import sorting in clang-format

2018-10-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Another example: we have to be careful with something like this as we don't 
want to break correct code:

  import x;
  import a.loong.
c;
  import y;




Comment at: unittests/Format/SortImportsTestJava.cpp:130
+ "// that do\n"
+ "// nothing\n",
+ Ranges));

krasimir wrote:
> I wonder what happens if there are comments between import statements and 
> comment lines after import statements. Consider adding some tests for that.
Specifically, as discussed, we wanna keep comments about imports together with 
them when we reorder stuff around.


Repository:
  rC Clang

https://reviews.llvm.org/D52800



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10862
+  if (Source->isIntegerType() && Target->isFloatingType()) {
+const llvm::fltSemantics *FloatSem = nullptr;
+if (Target->isSpecificBuiltinType(BuiltinType::Float)) {

erichkeane wrote:
> Since there is only 1, and fltSemantics is really small (2 shorts + 2 uints), 
> making this a 'by copy' is likely a better solution than a pointer.
llvm::fltSemantics has incomplete type and cannot be defined :/ Quite strange 
error


https://reviews.llvm.org/D52835



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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10883
+  precision = AdjustPrecision(precision);
+  FloatValue.toString(PrettyTargetValue, precision);
+  IntValue.toString(PrettySourceValue);

erichkeane wrote:
> I wonder if this call (finding the precision, 'adjusting' it, then writing to 
> a smallstring might be a better thing to pull into its own function rather 
> than AdjustPrecision.
I go thru LLVM code and I see we use rmNearestTiesToEven. So I am gonna change 
it.


https://reviews.llvm.org/D52835



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


r343715 - [analyzer] [tests] [quickfix] Make the test more resilient for a non-defaut std configuration

2018-10-03 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct  3 13:46:50 2018
New Revision: 343715

URL: http://llvm.org/viewvc/llvm-project?rev=343715&view=rev
Log:
[analyzer] [tests] [quickfix] Make the test more resilient for a non-defaut std 
configuration

Modified:
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/synthesized_body.cpp

Modified: 
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/synthesized_body.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/synthesized_body.cpp?rev=343715&r1=343714&r2=343715&view=diff
==
--- 
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/synthesized_body.cpp 
(original)
+++ 
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/synthesized_body.cpp 
Wed Oct  3 13:46:50 2018
@@ -20,6 +20,6 @@ void call_deref_once() {
 
 
 // RUN: rm -rf %t.output
-// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output 
html -o %t.output %s
+// RUN: %clang_analyze_cc1 -std=c++11 -analyze -analyzer-checker=core 
-analyzer-output html -o %t.output %s
 // RUN: cat %t.output/* | FileCheck %s --match-full-lines
 // CHECK: var relevant_lines = {"1": {"3": 1,  "8": 1, "11": 1, "12": 1, "15": 
1, "16": 1, "17": 1, "18": 1}};


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


r343716 - Sort list of matchers

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 13:52:45 2018
New Revision: 343716

URL: http://llvm.org/viewvc/llvm-project?rev=343716&view=rev
Log:
Sort list of matchers

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=343716&r1=343715&r2=343716&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Oct  3 13:52:45 2018
@@ -133,10 +133,10 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(asString);
   REGISTER_MATCHER(atomicExpr);
   REGISTER_MATCHER(atomicType);
-  REGISTER_MATCHER(autoType);
   REGISTER_MATCHER(autoreleasePoolStmt)
-  REGISTER_MATCHER(binaryOperator);
+  REGISTER_MATCHER(autoType);
   REGISTER_MATCHER(binaryConditionalOperator);
+  REGISTER_MATCHER(binaryOperator);
   REGISTER_MATCHER(blockDecl);
   REGISTER_MATCHER(blockPointerType);
   REGISTER_MATCHER(booleanType);
@@ -189,10 +189,10 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
-  REGISTER_MATCHER(decltypeType);
   REGISTER_MATCHER(declCountIs);
   REGISTER_MATCHER(declRefExpr);
   REGISTER_MATCHER(declStmt);
+  REGISTER_MATCHER(decltypeType);
   REGISTER_MATCHER(defaultStmt);
   REGISTER_MATCHER(dependentSizedArrayType);
   REGISTER_MATCHER(designatedInitExpr);
@@ -233,6 +233,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
   REGISTER_MATCHER(hasAnyParameter);
+  REGISTER_MATCHER(hasAnySelector);
   REGISTER_MATCHER(hasAnySubstatement);
   REGISTER_MATCHER(hasAnyTemplateArgument);
   REGISTER_MATCHER(hasAnyUsingShadowDecl);
@@ -291,7 +292,6 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
-  REGISTER_MATCHER(hasAnySelector);
   REGISTER_MATCHER(hasSingleDecl);
   REGISTER_MATCHER(hasSize);
   REGISTER_MATCHER(hasSizeExpr);
@@ -311,8 +311,8 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasUnqualifiedDesugaredType);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
-  REGISTER_MATCHER(ignoringImplicit);
   REGISTER_MATCHER(ignoringImpCasts);
+  REGISTER_MATCHER(ignoringImplicit);
   REGISTER_MATCHER(ignoringParenCasts);
   REGISTER_MATCHER(ignoringParenImpCasts);
   REGISTER_MATCHER(ignoringParens);
@@ -343,21 +343,21 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isDefinition);
   REGISTER_MATCHER(isDeleted);
   REGISTER_MATCHER(isExceptionVariable);
+  REGISTER_MATCHER(isExpansionInFileMatching);
+  REGISTER_MATCHER(isExpansionInMainFile);
+  REGISTER_MATCHER(isExpansionInSystemHeader);
   REGISTER_MATCHER(isExplicit);
   REGISTER_MATCHER(isExplicitTemplateSpecialization);
   REGISTER_MATCHER(isExpr);
   REGISTER_MATCHER(isExternC);
   REGISTER_MATCHER(isFinal);
-  REGISTER_MATCHER(isInline);
   REGISTER_MATCHER(isImplicit);
-  REGISTER_MATCHER(isExpansionInFileMatching);
-  REGISTER_MATCHER(isExpansionInMainFile);
+  REGISTER_MATCHER(isInline);
   REGISTER_MATCHER(isInstanceMessage);
   REGISTER_MATCHER(isInstantiated);
-  REGISTER_MATCHER(isExpansionInSystemHeader);
+  REGISTER_MATCHER(isInstantiationDependent);
   REGISTER_MATCHER(isInteger);
   REGISTER_MATCHER(isIntegral);
-  REGISTER_MATCHER(isInstantiationDependent);
   REGISTER_MATCHER(isInTemplateInstantiation);
   REGISTER_MATCHER(isLambda);
   REGISTER_MATCHER(isListInitialization);
@@ -406,7 +406,6 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(nullPointerConstant);
   REGISTER_MATCHER(nullStmt);
   REGISTER_MATCHER(numSelectorArgs);
-  REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCatchStmt);
   REGISTER_MATCHER(objcCategoryDecl);
   REGISTER_MATCHER(objcCategoryImplDecl);
@@ -422,6 +421,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(objcProtocolDecl);
   REGISTER_MATCHER(objcThrowStmt);
   REGISTER_MATCHER(objcTryStmt);
+  REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(on);
   REGISTER_MATCHER(onImplicitObjectArgument);
   REGISTER_MATCHER(opaqueValueExpr);
@@ -459,8 +459,8 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(switchCase);
   REGISTER_MATCHER(switchStmt);
   REGISTER_MATCHER(templateArgument);
-  REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
+  REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateSpecializationType);
   REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
@@ -468,11 +468,11 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(to);
   REGISTER_MATCHER(translationUnitDecl);
   REGISTER_MATCHER(type);
+  REGISTER_MATCHER(typeAliasDecl);
+  REGISTER_MATCHER(typeAliasTemplateDecl);
   REGISTER_MATCHER(typedefDecl);
   REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
-  REGIS

r343717 - Add matchers missing from dynamic AST registry

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 13:52:51 2018
New Revision: 343717

URL: http://llvm.org/viewvc/llvm-project?rev=343717&view=rev
Log:
Add matchers missing from dynamic AST registry

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=343717&r1=343716&r2=343717&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Oct  3 13:52:51 2018
@@ -296,6 +296,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasSize);
   REGISTER_MATCHER(hasSizeExpr);
   REGISTER_MATCHER(hasSourceExpression);
+  REGISTER_MATCHER(hasSpecializedTemplate);
   REGISTER_MATCHER(hasStaticStorageDuration);
   REGISTER_MATCHER(hasSyntacticForm);
   REGISTER_MATCHER(hasTargetDecl);
@@ -308,6 +309,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasUnaryOperand);
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasUnderlyingDecl);
+  REGISTER_MATCHER(hasUnderlyingType);
   REGISTER_MATCHER(hasUnqualifiedDesugaredType);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
@@ -342,6 +344,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isDefaulted);
   REGISTER_MATCHER(isDefinition);
   REGISTER_MATCHER(isDeleted);
+  REGISTER_MATCHER(isDelegatingConstructor);
   REGISTER_MATCHER(isExceptionVariable);
   REGISTER_MATCHER(isExpansionInFileMatching);
   REGISTER_MATCHER(isExpansionInMainFile);
@@ -380,6 +383,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isTypeDependent);
   REGISTER_MATCHER(isUnion);
   REGISTER_MATCHER(isUnsignedInteger);
+  REGISTER_MATCHER(isUserProvided);
   REGISTER_MATCHER(isValueDependent);
   REGISTER_MATCHER(isVariadic);
   REGISTER_MATCHER(isVirtual);
@@ -403,6 +407,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(namesType);
   REGISTER_MATCHER(nestedNameSpecifier);
   REGISTER_MATCHER(nestedNameSpecifierLoc);
+  REGISTER_MATCHER(nonTypeTemplateParmDecl);
   REGISTER_MATCHER(nullPointerConstant);
   REGISTER_MATCHER(nullStmt);
   REGISTER_MATCHER(numSelectorArgs);
@@ -441,6 +446,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(refersToDeclaration);
   REGISTER_MATCHER(refersToIntegralType);
   REGISTER_MATCHER(refersToType);
+  REGISTER_MATCHER(refersToTemplate);
   REGISTER_MATCHER(requiresZeroInitialization);
   REGISTER_MATCHER(returns);
   REGISTER_MATCHER(returnStmt);
@@ -458,6 +464,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(substTemplateTypeParmType);
   REGISTER_MATCHER(switchCase);
   REGISTER_MATCHER(switchStmt);
+  REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(templateArgument);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateName);


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


r343720 - Remove stray character from docs

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 13:53:02 2018
New Revision: 343720

URL: http://llvm.org/viewvc/llvm-project?rev=343720&view=rev
Log:
Remove stray character from docs

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=343720&r1=343719&r2=343720&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Oct  3 13:53:02 2018
@@ -929,7 +929,7 @@ AST_MATCHER_P(TemplateArgument, refersTo
 /// Given
 /// \code
 ///   template class S> class X {};
-///   template class Y {};"
+///   template class Y {};
 ///   X xi;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(


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


r343719 - Update documentation for correctness

2018-10-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct  3 13:52:57 2018
New Revision: 343719

URL: http://llvm.org/viewvc/llvm-project?rev=343719&view=rev
Log:
Update documentation for correctness

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=343719&r1=343718&r2=343719&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Oct  3 13:52:57 2018
@@ -645,12 +645,12 @@ AST_MATCHER(FunctionDecl, isMain) {
 ///
 /// Given
 /// \code
-///   tempalate class A {};
-///   typedef A B;
+/// template class A {}; #1
+/// template<> class A {}; #2
 /// \endcode
 /// 
classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
-///   matches 'B' with classTemplateDecl() matching the class template
-///   declaration of 'A'.
+///   matches '#2' with classTemplateDecl() matching the class template
+///   declaration of 'A' at #1.
 AST_MATCHER_P(ClassTemplateSpecializationDecl, hasSpecializedTemplate,
   internal::Matcher, InnerMatcher) {
   const ClassTemplateDecl* Decl = Node.getSpecializedTemplate();
@@ -5283,7 +5283,7 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType
 ///   decltype(2.0) b = 2.0;
 /// \endcode
 /// decltypeType(hasUnderlyingType(isInteger()))
-///   matches "auto a"
+///   matches the type of "a"
 ///
 /// Usable as: Matcher
 AST_TYPE_TRAVERSE_MATCHER(hasUnderlyingType, getUnderlyingType,


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


r343721 - [test] Fix -Wunused-variable in rC343665

2018-10-03 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed Oct  3 13:53:53 2018
New Revision: 343721

URL: http://llvm.org/viewvc/llvm-project?rev=343721&view=rev
Log:
[test] Fix -Wunused-variable in rC343665

Modified:
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=343721&r1=343720&r2=343721&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Wed Oct  3 13:53:53 
2018
@@ -183,7 +183,7 @@ TEST(ParserTest, ParseMatcher) {
 
 TEST(ParserTest, ParseComment) {
   MockSema Sema;
-  const uint64_t ExpectedFoo = Sema.expectMatcher("Foo");
+  Sema.expectMatcher("Foo");
   Sema.parse(" Foo() # Bar() ");
   for (const auto &E : Sema.Errors) {
 EXPECT_EQ("", E);


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


[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions

2018-10-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:110
+/// are usually useless
+static unsigned AdjustPrecision(unsigned precision) {
+  return (precision * 59 + 195) / 196;

scanon wrote:
> erichkeane wrote:
> > Hmm I don't terribly understand how this function works.  Also, comment 
> > above needs to end in a period.  
> > 
> > Can you elaborate further as to how this works?  Those are 3 pretty suspect 
> > looking magic numbers...
> It's attempting to compute the number of good base-10 digits (59/196 ~= 
> log2(10)). We should really just make APFloat print the shortest 
> round-trippable digit sequence instead. Yes, this is tricky to implement, but 
> we don't need to implement it. There are two recent high-quality 
> implementations available, which are both significantly faster than previous 
> algorithms: Ryu and Swift's 
> (https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftDtoa.cpp).
>  Swift's has the virtue of already being used in LLVM-family languages and 
> having a tidy single-file implementation, but either would be perfectly 
> usable, I think.
> 
> Neither supports float128 yet, but we could simply drop them in for float, 
> double, and float80.
Function names should start with lower case I think?



Comment at: lib/Sema/SemaChecking.cpp:111
+static unsigned AdjustPrecision(unsigned precision) {
+  return (precision * 59 + 195) / 196;
+}

Can we use divideCeil from llvm/Support/MathExtras.h?



Comment at: lib/Sema/SemaChecking.cpp:10881
+  SmallString<16> PrettySourceValue;
+  unsigned precision = llvm::APFloat::semanticsPrecision(*FloatSem);
+  precision = AdjustPrecision(precision);

Variable name should start with uppercase


https://reviews.llvm.org/D52835



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


[PATCH] D47344: LWG 2843 "Unclear behavior of std::pmr::memory_resource::do_allocate()"

2018-10-03 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 168169.
Quuxplusone edited the summary of this revision.
Quuxplusone added a reviewer: ldionne.
Quuxplusone added a comment.
Herald added a subscriber: libcxx-commits.

Rebased on master. Added @ldionne as reviewer.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47344

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp

Index: src/experimental/memory_resource.cpp
===
--- src/experimental/memory_resource.cpp
+++ src/experimental/memory_resource.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "experimental/memory_resource"
+#include "memory"
 
 #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
 #include "atomic"
@@ -23,38 +24,51 @@
 
 // new_delete_resource()
 
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+static bool is_aligned_to(void *ptr, size_t align)
+{
+void *p2 = ptr;
+size_t space = 1;
+void *result = _VSTD::align(align, 1, p2, space);
+return (result == ptr);
+}
+#endif
+
 class _LIBCPP_TYPE_VIS __new_delete_memory_resource_imp
 : public memory_resource
 {
-public:
-~__new_delete_memory_resource_imp() = default;
-
-protected:
-virtual void* do_allocate(size_t __size, size_t __align)
-{ return _VSTD::__libcpp_allocate(__size, __align); /* FIXME */}
+void *do_allocate(size_t bytes, size_t align) override
+{
+#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+return _VSTD::__libcpp_allocate(bytes, align);
+#else
+if (bytes == 0)
+bytes = 1;
+void *result = _VSTD::__libcpp_allocate(bytes, align);
+if (!is_aligned_to(result, align)) {
+_VSTD::__libcpp_deallocate(result, align);
+__throw_bad_alloc();
+}
+return result;
+#endif
+}
 
-virtual void do_deallocate(void * __p, size_t, size_t __align)
-{ _VSTD::__libcpp_deallocate(__p, __align); /* FIXME */ }
+void do_deallocate(void *p, size_t, size_t align) override
+{ _VSTD::__libcpp_deallocate(p, align); }
 
-virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
-{ return &__other == this; }
+bool do_is_equal(const memory_resource& other) const _NOEXCEPT override
+{ return &other == this; }
 };
 
 // null_memory_resource()
 
 class _LIBCPP_TYPE_VIS __null_memory_resource_imp
 : public memory_resource
 {
-public:
-~__null_memory_resource_imp() = default;
-
-protected:
-virtual void* do_allocate(size_t, size_t) {
-__throw_bad_alloc();
-}
-virtual void do_deallocate(void *, size_t, size_t) {}
-virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
-{ return &__other == this; }
+void *do_allocate(size_t, size_t) override { __throw_bad_alloc(); }
+void do_deallocate(void *, size_t, size_t) override {}
+bool do_is_equal(const memory_resource& other) const _NOEXCEPT override
+{ return &other == this; }
 };
 
 namespace {
Index: include/experimental/memory_resource
===
--- include/experimental/memory_resource
+++ include/experimental/memory_resource
@@ -195,7 +195,7 @@
 }
 
 _LIBCPP_INLINE_VISIBILITY
-void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {
+void deallocate(_ValueType * __p, size_t __n) {
 _LIBCPP_ASSERT(__n <= __max_size(),
"deallocate called for size which exceeds max_size()");
 __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
@@ -265,7 +265,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-void destroy(_Tp * __p) _NOEXCEPT
+void destroy(_Tp * __p)
 { __p->~_Tp(); }
 
 _LIBCPP_INLINE_VISIBILITY
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343722 - [ASTMatchers] Fix DynamicASTMatchersTests again

2018-10-03 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed Oct  3 14:00:44 2018
New Revision: 343722

URL: http://llvm.org/viewvc/llvm-project?rev=343722&view=rev
Log:
[ASTMatchers] Fix DynamicASTMatchersTests again

Modified:
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=343722&r1=343721&r2=343722&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Wed Oct  3 14:00:44 
2018
@@ -183,7 +183,6 @@ TEST(ParserTest, ParseMatcher) {
 
 TEST(ParserTest, ParseComment) {
   MockSema Sema;
-  Sema.expectMatcher("Foo");
   Sema.parse(" Foo() # Bar() ");
   for (const auto &E : Sema.Errors) {
 EXPECT_EQ("", E);


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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

I didn't run it, but CMake-wise this looks fine. (I trust you did)

I notice some tests use

  from tests.cindex.util import foo

while others use

  from .util import foo

You might want to make that consistent in a follow-up.


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


  1   2   >